Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a document to a particular folder 1

Status
Not open for further replies.

smallredville

Programmer
Aug 18, 2008
115
SG
Hello...=)

After successful testing with the createObjectEx() and createVersion(), I tried to move one step ahead.

What I tried to do is to add a document to a specific folder; for e.g. Inside a root folder with (ID 2000 and volume ID -2000) has a folder with ID 684333.

I tried to add a document to that particular folder (ID = 684333), but I got an error message as follows:

Exception in thread "main" com.opentext.api.LLIllegalOperationException: get(name) not implemented for this datatype
at com.opentext.api.LLInstance.get(Unknown Source)
at com.opentext.api.LLValue.toValue(Unknown Source)
at com.opentext.api.LLConnect.unMarshall(Unknown Source)
at com.opentext.api.LAPI_DOCUMENTS.CreateObjectEx(Unknown Source)
at fetchVersionClass.main(fetchVersionClass.java:57)

-----------------------------------------------------------
The following is my JAVA code:


import java.util.*;//for our date manip

import java.io.*;
import com.opentext.api.*; //import LAPI objects


public class addDocument {

private static String Server = "localhost"; //livelink host

private static int Port = 2099; //livelink server port see opentext.ini

private static String DFT = ""; //default database file or schema

private static String User = "Admin"; //username

private static String Pass = "password"; //passwd


public static void main(String args[]) {

LLSession session;
LAPI_DOCUMENTS doc;
session = new LLSession(Server, Port, DFT, User, Pass);

doc = new LAPI_DOCUMENTS(session);

LAPI_ATTRIBUTES attr = new LAPI_ATTRIBUTES(session);

//Grab some value objects
LLValue entInfo = (new LLValue()).setAssocNotSet();
LLValue createInfo = (new LLValue()).setAssocNotSet();
LLValue objectInfo = (new LLValue()).setAssocNotSet();
LLValue versionInfo = (new LLValue()).setAssocNotSet();


int volumeID;
int objectID;
String fileType = "test_pdf_doc.pdf";
if (doc.AccessEnterpriseWS(entInfo) != 0) {
System.out.println("AccessEnterpriseWS Failed.");
return;
}

//Show that we got the volumeID and objectID for the EnterpriseWS

volumeID = entInfo.toInteger("VolumeID");
objectID = entInfo.toInteger("ID");
System.out.println("Volume" + volumeID + "ObjID" + objectID);

//hard-code the objectID as below 684436
objectID = 684436;

//Create document in enterpriseWS
//684436 is the node ID for folder named "Yo Yo" whihc is inside the node ID 2000
if (doc.CreateObjectEx(volumeID, objectID, doc.OBJECTTYPE,doc.DOCUMENTSUBTYPE, fileType, createInfo, objectInfo) != 0) {
System.out.println("CreateObjectEx Failed.");

return;
} else {
System.out.println("Document created successfully");

//Set objectID to objectID of the new document
}

// objectID = objectInfo.toInteger("ID");
//hard-code the objectID as below 684436
objectID = 684436;

//Now upload version to complete document creation
//if this file is not there io errors will happen
if (doc.CreateVersion(volumeID, objectID, "c:\\yoyo\\test_pdf_doc.pdf", versionInfo) != 0) {
System.out.println("CreateVersion Failed.");
return;
} else {
System.out.println("Version created successfully");

}


}
}


I deeply appreciate any helps/comments =)

many Thanks in advance,


 
is it as simple as
tried to add a document to that particular folder (ID = 684333),

but in code you are setting it to this

// objectID = objectInfo.toInteger("ID");
//hard-code the objectID as below 684436
objectID = 684436;

When session errors happen in lapi yu want to call and find the errors the seeion object holds.Get(name) errors are usually because you have a line of code that you expect will succeed but an error ahppened but your program is going thru the lines.things like this you mean to use 684333 but you rae puttig one that ends in 6.

I will test this code and see if it indeed is the typo when I get some time


Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Thanks Appnair for your prompt reply.

Let me share with you the objective behind this:

Currently I am trying to convert all Open Office Format documents(e.g. .odt files to PDF files) in the livelink workspace.

There will a program in JAVA, to read the info from the the database on the location path of the Open Office Format documents.

I will then use the LAPI - fetchVersion() - to get the documents to my local disks and another JAVA program will do the convertion to PDF files.

After convertion to the PDF files, I plan to use the LAPI - addDocument() (or maybe createObjectEx() and createVersion()) to put it back to the livelink workspace.

-----------------------------------------------------------

That is the reason why, I am getting myself familiar with all the related functions in LAPI.

If you think that my idea to the above mentioned problem is not right and you have better idea, kindly share it with me.

Lastly, I thank you in advance...



Regards,


smallredville

 
I really don't see any problem in your approach.Just understand that every objet in livelink has a dataid in dtree.If it is a versionable object then that is maintained in dversdata.

If I understand what you said is this

You have DocA with Objid 1234 and sitting at vers 4
You download it to desktop and manipulate it to PDF
since the object is already existing you cannot obviously createObject again .LL will allow only one object having the same name in a container.So when you want to add the modified PDF as version 5 you will need to locate the objid and add it as a version.

See this example of mine and see if this makes sense.

# ADD VERSION IF ALREADY EXISTS DoesObjectExist.cs

in this example I have an object called aa.las I am trying to add another one called aa.las





Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top