You are viewing limited content. For full access, please sign in.

Question

Question

Java Document Creation

SDK
asked on March 7, 2014 Show version history

Hello. I'm having a problem with document creation in Java. I am sorting documents then uploading them to the location they need to be in. When I get to the part where the document is being created, my program just hangs. I'm not seeing any errors on my end or on the server's end. Maybe you guys can help.

 

Here is my code:

public void uploadFile(File incomingFile, String incomingPath) throws FileNotFoundException
	{
		path = incomingPath;
		
		//Connection setup
		Session session = new Session();
		RepositoryRegistration repo = new RepositoryRegistration(serverName, repoName, port);
		session.connect(repo);
		session.logIn(repo, username, password);
		System.out.println("Logging in");
		
		
		System.out.println("Creating Document");
//This is the last log statement that show up. It hangs after this
//but before the "Doc created" one.
		Document doc = null;
		doc = Document.create(path, EnumSet.of(EntryNameOption.NONE), session);
		System.out.println("Doc created");
		doc.lock(LockType.EXCLUSIVE);
		doc.writeEDoc(incomingFile);
		System.out.println("Doc written");
		doc.unlock();
		doc.refresh();
		doc.save();
		
		session.logOut();
		System.out.println("Done. Logging out");
		
		
	}

 

0 0

Replies

replied on March 10, 2014 Show version history

I am not a java programmer and do not have access to a java environment to test with.  That said, it looks like you are using RepositoryAccess to try to create your files inside of Laserfiche.  You then need to use DocumentServices to import the files into the repository.

 

If it is true that you are using RA, I do not know why you do not get an error, but the Document.Create() method does not return a Document object as you are trying to do in your code.  Document.Create() returns an integer that equals the EntryID for the newly created entry.

 

Also the .WriteEdoc() method is a DocumentInfo method and not a valid Document object method like you try to do in your code.  As well, the DocumentInfo.WriteEdoc() method does not do what you seem to think it does.  You need to use the DocumentServices DLL to import your files into the repository.

0 0
replied on March 28, 2014

Could you debug into the program and check if incomingPath is a valid Laserfiche document path? It should be like "\folder1\documentname". And what is your server version the java program tries to connect?

0 0
replied on March 31, 2014 Show version history

Yes,  I verified that the incomingPath is a valid path. The server version is 8.2
 

0 0
replied on July 6, 2014

Hi Taylor, after creation of the document, it is locked and then written with its content which will throw an exception. Please check your log - it would certainly throw a "LockedObjectException" exception.

Correct way is to unlock it and then set with its content.

0 0
replied on July 7, 2014

Taylor, suggest to add a try/catch for Exception Handling. That is the only way to see what is going on (apart from debug logging)

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.