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

Question

Question

File contents not saved after writeEDoc using Java JRA SDK

SDK
asked on June 15, 2016 Show version history

Just wondering if I'm missing a step here.

I'm able to connect, log in, retrieve documents and search for documents using the Java SDK (9.2).

We are now trying to write to the entry. However, after calling Document.writeEDoc() the contents of the entry appear to be empty.

Pseudocode

filePath = "c:\temp\test.pdf";
documentFolder = Folder.getByPath("\WSTesting", Session);
documentVolume = Volume.getByName("DEFAULT", Session) />

myDoc = Document.create(
	documentFolder,
	documentName,
	documentVolume,
	EntryNameOption,
	Session
);

javaFile = CreateObject("java","java.io.File");
locktype = CreateObject("java","com.laserfiche.repositoryaccess.LockType");
mydoc.lock(locktype.EXCLUSIVE);
javaFile.init(filePath);
mydoc.writeEDoc(javaFile, "application.pdf");
mydoc.unlock();

retrievedoc = Document.getById(mydoc.getId(), Session)';

Retrieving the document works great (I get an entryID, etc), and the document object seems to be as expected (path, name, size all as expected). However, after all this, the entry in LF is empty. Page count is zero and opening the entry in LF client shows an empty file.

0 0

Answer

SELECTED ANSWER
replied on June 17, 2016

Try calling save() after setExtension.

0 0

Replies

replied on June 16, 2016

Are you sure you're not opening just the image viewer? Is the document showing the PDF icon in the Client? If you right-click it in the folder browser and choose Open\View Electronic Document, can you see it?

0 0
replied on June 16, 2016

Great question.

It just shows a generic file icon. Properties show "Number of pages: 0".

I'll dig a bit deeper. Maybe it is there and I'm just not seeing it right.

 

0 0
replied on June 16, 2016

I think you were exactly right Miruna.

Likely a misunderstanding of "pages" and how some of those pieces work.

Thanks!

0 0
replied on June 16, 2016

The number or pages is for image or text pages. An e-doc wouldn't have them unless you set them or generate them after the import through the Client.

As for the generic icon, I'm guessing if you look at the document's properties on the Document tab, its type is something like "application/octet-stream" rather than "application/pdf" since your script is not setting a MIME type.

0 0
replied on June 16, 2016

Actually, the type is "application/pdf" (Properties - Document - Electronic Document Properties - Type).

Running myDoc.setExtension("pdf") does't throw any errors, but doesn't change anything. The extension is always undefined.

0 0
SELECTED ANSWER
replied on June 17, 2016

Try calling save() after setExtension.

0 0
replied on June 17, 2016

Good suggestion Robert. No change though.

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

Sign in to reply to this post.