Callback File System: eldos.cbfs.ECBFSError: Access is denied - java

I've requested trial license for Callback File System and tried to write simple application using java! So, I've written next few lines and run it and received exception eldos.cbfs.ECBFSError: Access is denied
Code
import eldos.cbfs.CallbackFileSystem;
import eldos.cbfs.ECBFSError;
import eldos.cbfs.boolRef;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* #author Sergii.Zagriichuk
*/
public class Test1 {
private static Logger logger = Logger.getLogger(Test1.class.getName());
public static void main(String[] args) {
CallbackFileSystem callbackFileSystem = new CallbackFileSystem();
callbackFileSystem.setRegistrationKey("My registration key ");
try {
callbackFileSystem.install("<path to cab>\\cbfs.cab", "Test", true, 131072, new boolRef(false));
} catch (ECBFSError ecbfsError) {
logger.log(Level.SEVERE, ecbfsError.getMessage(), ecbfsError);
}
}
}
What do I should to do for fix this problem?
Thanks

Related

Cannot read email body with Spring: javax.mail.FolderClosedException

I'm trying to listen my Gmail inbox for incoming mails. Every time new mail arrives, I want to see it's subject and content.
So far, I have this:
import java.io.IOException;
import javax.mail.BodyPart;
import javax.mail.Folder;
import javax.mail.internet.ContentType;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.mail.util.MimeMessageParser;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.mail.transformer.MailToStringTransformer;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
public class GmailInboundImapIdleAdapterTestApp {
private static Log logger = LogFactory.getLog(GmailInboundImapIdleAdapterTestApp.class);
public static void main (String[] args) throws Exception {
#SuppressWarnings("resource")
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("/META-INF/spring/integration/gmail-imap-idle-config.xml");
DirectChannel inputChannel = ac.getBean("receiveChannel", DirectChannel.class);
inputChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message){
MimeMessage mm = (MimeMessage) message.getPayload();
try {
System.out.println("Subject: "+mm.getSubject());
System.out.println("Body: "+readPlainContent(mm));
}
catch (javax.mail.MessagingException e) {
System.out.println("MessagingException: "+e.getMessage());
e.printStackTrace();
}
catch (Exception e) {
System.out.println("Exception: "+e.getMessage());
e.printStackTrace();
}
}
});
}
private static String readHtmlContent(MimeMessage message) throws Exception {
return new MimeMessageParser(message).parse().getHtmlContent();
}
private static String readPlainContent(MimeMessage message) throws Exception {
return new MimeMessageParser(message).parse().getPlainContent();
}
}
It can read the mail subject correctly. But no luck with mail body.javax.mail.FolderClosedException hit me. How to fix this?
As Gary said: simple-content="true" or since recently autoCloseFolder = false: https://docs.spring.io/spring-integration/docs/5.2.0.RELEASE/reference/html/mail.html#mail-inbound
Starting with version 5.2, the autoCloseFolder option is provided on the mail receiver. Setting it to false doesn’t close the folder automatically after a fetch, but instead an IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE header (see MessageHeaderAccessor API for more information) is populated into every message to producer from the channel adapter. It is the target application’s responsibility to call the close() on this header whenever it is necessary in the downstream flow:

folder and file creation not working

I am currently having trouble creating a folder and a file if not present. I keep getting and error about it not being specified and I don't really know how to fix it.
this is my main
import java.io.IOException;
public class main {
/**
* #param args the command line arguments
*/
public static void main(String[] args) throws IOException{
timeKeepHome ja = new timeKeepHome();
//ja.setVisible(true);
fileTimeLog log = new fileTimeLog();
log.checkFile();
}
}
and this is my class to create the file/ folder.
import java.io.IOException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Formatter;
public class fileTimeLog
{
File log = new File("log/sixWeek.dat");
File folder = new File("log");
PrintWriter logW = new PrintWriter("log/sixWeek.dat");
public fileTimeLog() throws IOException
{
System.out.println("successful");
checkFile();
}
public void checkFile() throws IOException
{
if(!(log.exists()))
{
createFile();
}
}
public void saveTime() throws IOException
{
}
public void saveDate()
{
}
public void createFile() throws IOException
{
folder.mkdir();
logW = new PrintWriter(log);
logW.println("DONT MODIFY THIS FILE IF UNLESS YOU KNOW WHAT YOUR ARE DOING ");
logW.close();
}
}
and the error i'm getting
Exception in thread "main" java.io.FileNotFoundException: log\sixWeek.dat (The system cannot find the path specified)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(FileOutputStream.java:270)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at java.io.FileOutputStream.<init>(FileOutputStream.java:101)
at java.io.PrintWriter.<init>(PrintWriter.java:184)
at fileTimeLog.<init>(fileTimeLog.java:17)
at main.main(main.java:18)
I would make everything look nicer and neater but I'm just really frustrated and I've done research but don't really understand.
The Printwriter will try and create a file, so when you do this
PrintWriter logW = new PrintWriter("log/sixWeek.dat");
in your class defintion, then it will try to create it, but the folder does not exist until you do createFile
As you re-initialize logW in createFile anyway, you do not need to initialize it in your class defintion

How to load Apache Ignite Cache when reading from a text file

I created a file helloworld.txt. Now I'm reading from the file and then I want to load the contents of the file into the cache, and whenever the cache is updated, it should write to the file as well.
This is my code so far:
Please tell me what to do to load the cache and then write from the cache to the file, as the instructions are not clear from Apache Ignite documentation.
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
import org.apache.ignite.examples.ExampleNodeStartup;
import org.apache.ignite.examples.ExamplesUtils;
public class FileRead {
/** Cache name. */
private static final String CACHE_NAME = "FileCache";
/** Heap size required to run this example. */
public static final int MIN_MEMORY = 512 * 1024 * 1024;
/**
* Executes example.
*
* #param args Command line arguments, none required.
* #throws IgniteException If example execution failed.
*/
public static void main(String[] args) throws IgniteException {
ExamplesUtils.checkMinMemory(MIN_MEMORY);
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
System.out.println();
try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME)) {
long start = System.currentTimeMillis();
try (IgniteDataStreamer<Integer, String> stmr = ignite.dataStreamer(CACHE_NAME)) {
// Configure loader.
stmr.perNodeBufferSize(1024);
stmr.perNodeParallelOperations(8);
///FileReads();
try {
BufferedReader in = new BufferedReader
(new FileReader("/Users/akritibahal/Desktop/helloworld.txt"));
String str;
int i=0;
while ((str = in.readLine()) != null) {
System.out.println(str);
stmr.addData(i,str);
i++;
}
System.out.println("Loaded " + i + " keys.");
}
catch (IOException e) {
}
}
}
}
}
}
For information on how to load the cache from a persistence store please refer to this page: https://apacheignite.readme.io/docs/data-loading
You have two options:
Start a client node, create IgniteDataStreamer and use it to load the data. Simply call addData() for each line in the file.
Implement CacheStore.loadCache() method, provide the implementation in the cache configuration and call IgniteCache.loadCache().
Second approach will require to have the file on all server nodes, by there will be no communication between nodes, so most likely it will be faster.

AWS describeLogGroups() does not return the log groups

AWS describeLogGroups() does not return the log groups. Has anyone faced this? If yes, how did you overcome? Here's the code ...
import java.util.List;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.logs.AWSLogsClient;
import com.amazonaws.services.logs.model.DescribeLogGroupsResult;
import com.amazonaws.services.logs.model.LogGroup;
public class MyAWSLogGroups {
public static void main(String[] args) {
AWSCredentials credentials = new ProfileCredentialsProvider().getCredentials();
AWSLogsClient client = new AWSLogsClient(credentials);
DescribeLogGroupsResult logGroupsResult = client.describeLogGroups();
List<LogGroup> logGroups = logGroupsResult.getLogGroups();
// why does logGroups.size() return 0 ?
System.out.println("=> Number of Log Groups: " + logGroups.size());
for (LogGroup lg : logGroups) {
String logGroupName = lg.getLogGroupName();
System.out.println(logGroupName);
}
}
}
This AWS CLI reveals the log groups ...
$ aws logs describe-log-groups
I know it's a bit late, but just had this problem myself. Are your Cloudfront Logs in the a region other than US East?
We're in US West. The Java SKD defaults to us-east-1 but you probably set your client default region a while ago.
Use the configureRegion inherited method on your Client to set to your location region. Get your Region Enum from the Regions class documentation.
For me the solution was something like this (using the example code from above):
import java.util.List;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.services.logs.AWSLogsClient;
import com.amazonaws.services.logs.model.DescribeLogGroupsResult;
import com.amazonaws.services.logs.model.LogGroup;
import com.amazonaws.regions.Regions;
public class MyAWSLogGroups {
public static void main(String[] args) {
AWSCredentials credentials = new ProfileCredentialsProvider().getCredentials();
AWSLogsClient client = new AWSLogsClient(credentials);
client.configureRegion(Regions.US_WEST_2);
DescribeLogGroupsResult logGroupsResult = client.describeLogGroups();
List<LogGroup> logGroups = logGroupsResult.getLogGroups();
// why does logGroups.size() return 0 ?
System.out.println("=> Number of Log Groups: " + logGroups.size());
for (LogGroup lg : logGroups) {
String logGroupName = lg.getLogGroupName();
System.out.println(logGroupName);
}
}
}

wrote code in java for nutch

hello:
I'm writing code in java for nutch(open source search engine) to remove the movments from arabic words in the indexer.
I don't know what is the error in it.
Tthis is the code:
package com.mycompany.nutch.indexing;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.log4j.Logger;
import org.apache.nutch.crawl.CrawlDatum;
import org.apache.nutch.crawl.Inlinks;
import org.apache.nutch.indexer.IndexingException;
import org.apache.nutch.indexer.IndexingFilter;
import org.apache.nutch.indexer.NutchDocument;
import org.apache.nutch.parse.getData().parse.getData();
public class InvalidUrlIndexFilter implements IndexingFilter {
private static final Logger LOGGER =
Logger.getLogger(InvalidUrlIndexFilter.class);
private Configuration conf;
public void addIndexBackendOptions(Configuration conf) {
// NOOP
return;
}
public NutchDocument filter(NutchDocument doc, Parse parse, Text url,
CrawlDatum datum, Inlinks inlinks) throws IndexingException {
if (url == null) {
return null;
}
char[] parse.getData() = input.trim().toCharArray();
for(int p=0;p<parse.getData().length;p++)
if(!(parse.getData()[p]=='َ'||parse.getData()[p]=='ً'||parse.getData()[p]=='ُ'||parse.getData()[p]=='ِ'||parse.getData()[p]=='ٍ'||parse.getData()[p]=='ٌ' ||parse.getData()[p]=='ّ'||parse.getData()[p]=='ْ' ||parse.getData()[p]=='"' ))
new String.append(parse.getData()[p]);
return doc;
}
public Configuration getConf() {
return conf;
}
public void setConf(Configuration conf) {
this.conf = conf;
}
}
I think that the error is in using parse.getdata() but I don't know what I should use instead of it?
The line
char[] parse.getData() = input.trim().toCharArray();
will give you a compile error because the left hand side is not a variable. Please replace parse.getData() by a unique variable name (e.g. parsedData) in this line and the following lines.
Second the import of
import org.apache.nutch.parse.getData().parse.getData();
will also fail. Looks a lot like a text replace issue.

Categories