I am looking to get some help in using LAPI with servlets. I want to upload some documents into livelink thru LAPI and HTTP tunnel.
Please advice how to get info on doing this.
I am pasting the code that I developed to do the same.But gives the error, could not access server : com.opentext.api.LLCouldNotConnectHTTPException
I downloaded tomcat , which is on port 8080.
Please Advice.
Below is my code
****************
import java.io.*;
import java.util.*;
import java.text.DateFormat.*;
import com.opentext.api.*;
public class tryServlet
{
private static String Server = "hqp-as-llapdv01"; //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 here"; //passwd
public static void main (String args[])
{
//LLSession session1;
LAPI_DOCUMENTS doc;
//session1 = new LLSession (Server, Port, DFT, User, Pass);
// Grab some value objects
LLValue entInfo = (new LLValue()).setAssocNotSet();
LLValue createInfo = (new LLValue()).setAssocNotSet();
LLValue objectInfo = (new LLValue()).setAssocNotSet();
LLValue versionInfo = (new LLValue()).setAssocNotSet();
// Category stuff
LLValue catID = (new LLValue()).setAssocNotSet();
LLValue catVersion = new LLValue();
LLValue attrValues = new LLValue().setList();
LLValue defaultValues = new LLValue().setList();
int status;
LLValue objID = new LLValue().setAssoc();
LLValue attrValPath = new LLValue();
LLValue categories = new LLValue().setList();
LLValue cRequest = new LLValue().setAssoc();
LLValue extData = new LLValue().setAssoc();
LLValue attrInfo = new LLValue();
int volumeID=0;
int objectID=0;
int docObjectID=0;
// Instantiate config Assoc
LLValue config = new LLValue();
config.setAssoc();
// Set config Assoc value
config.add( "HTTPS", LLValue.LL_FALSE );
config.add( "LivelinkCGI", " );
config.add( "HTTPUserName", "tomcat" );
config.add( "HTTPPassword", "s3cret" );
// Instantiate session
LLSession session = new LLSession( " 8080, "","Admin", "passwod here", config );
doc = new LAPI_DOCUMENTS (session);
LAPI_ATTRIBUTES attr = new LAPI_ATTRIBUTES(session);
LAPI_ATTRIBUTES attributes= new LAPI_ATTRIBUTES (session);
try{
if(doc.AccessEnterpriseWS(entInfo) != 0)
{
System.out.println("AccessEnterpriseWS Failed.");
return;
}
//Grab the info from entInfo
volumeID = entInfo.toInteger("VolumeID");
objectID = entInfo.toInteger("ID");
System.out.println("Volume"+volumeID+"ObjID"+objectID);
catID.add("ID", 874264);
catID.add("Version", 1);
//Use the catID to fetch the category Version
if (doc.FetchCategoryVersion(catID, catVersion) != 0)
{
System.out.println("FetchCategoryVersion Failed.");
return;
}
System.out.println("where r u ?");
attrValues.add("Started");
if (attr.AttrSetValues(catVersion, "Status", attr.ATTR_DATAVALUES, attrValPath, attrValues) != 0)
{
System.out.println("AttrSetValues Failed here.");
}
categories.add( catVersion );
//Fill createInfo to spec (see documentation for the structure)
cRequest.add("Comment", "");
createInfo.add("request", cRequest);
createInfo.add("extendedData", extData);
createInfo.add("Categories", categories);
if(doc.CreateObjectEx(volumeID, objectID, doc.OBJECTTYPE,
doc.DOCUMENTSUBTYPE, "logfile.txt", createInfo, objectInfo) != 0)
{
System.out.println("CreateObjectEx Failed.");
System.out.println("Status Code: " + session.getStatus());
System.out.println("Api Error: " + session.getApiError());
System.out.println("Error Message: " + session.getErrMsg());
System.out.println("Status Message: " + session.getStatusMessage());
// return;
}
else
{
System.out.println("Document Object created successfully:Next we have to add a version to complete it");
}
docObjectID = objectInfo.toInteger("ID");
//Now upload version to complete document creation
if(doc.CreateVersion(volumeID, docObjectID, "c:\\temp\\tlist.txt", versionInfo) != 0)
{
System.out.println("CreateVersion Failed.be sure to remove the 0 byte stub in livelink if this happens");
return;
}
else
{
System.out.println("Version created successfully");
}
objID.add("ID",docObjectID);
System.out.println("out of if");
}catch(Exception ex) {
System.out.println("in catch "+ex);
}
} //Main ends
}//Class ends
************
Thanks,
Sunu
Please advice how to get info on doing this.
I am pasting the code that I developed to do the same.But gives the error, could not access server : com.opentext.api.LLCouldNotConnectHTTPException
I downloaded tomcat , which is on port 8080.
Please Advice.
Below is my code
****************
import java.io.*;
import java.util.*;
import java.text.DateFormat.*;
import com.opentext.api.*;
public class tryServlet
{
private static String Server = "hqp-as-llapdv01"; //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 here"; //passwd
public static void main (String args[])
{
//LLSession session1;
LAPI_DOCUMENTS doc;
//session1 = new LLSession (Server, Port, DFT, User, Pass);
// Grab some value objects
LLValue entInfo = (new LLValue()).setAssocNotSet();
LLValue createInfo = (new LLValue()).setAssocNotSet();
LLValue objectInfo = (new LLValue()).setAssocNotSet();
LLValue versionInfo = (new LLValue()).setAssocNotSet();
// Category stuff
LLValue catID = (new LLValue()).setAssocNotSet();
LLValue catVersion = new LLValue();
LLValue attrValues = new LLValue().setList();
LLValue defaultValues = new LLValue().setList();
int status;
LLValue objID = new LLValue().setAssoc();
LLValue attrValPath = new LLValue();
LLValue categories = new LLValue().setList();
LLValue cRequest = new LLValue().setAssoc();
LLValue extData = new LLValue().setAssoc();
LLValue attrInfo = new LLValue();
int volumeID=0;
int objectID=0;
int docObjectID=0;
// Instantiate config Assoc
LLValue config = new LLValue();
config.setAssoc();
// Set config Assoc value
config.add( "HTTPS", LLValue.LL_FALSE );
config.add( "LivelinkCGI", " );
config.add( "HTTPUserName", "tomcat" );
config.add( "HTTPPassword", "s3cret" );
// Instantiate session
LLSession session = new LLSession( " 8080, "","Admin", "passwod here", config );
doc = new LAPI_DOCUMENTS (session);
LAPI_ATTRIBUTES attr = new LAPI_ATTRIBUTES(session);
LAPI_ATTRIBUTES attributes= new LAPI_ATTRIBUTES (session);
try{
if(doc.AccessEnterpriseWS(entInfo) != 0)
{
System.out.println("AccessEnterpriseWS Failed.");
return;
}
//Grab the info from entInfo
volumeID = entInfo.toInteger("VolumeID");
objectID = entInfo.toInteger("ID");
System.out.println("Volume"+volumeID+"ObjID"+objectID);
catID.add("ID", 874264);
catID.add("Version", 1);
//Use the catID to fetch the category Version
if (doc.FetchCategoryVersion(catID, catVersion) != 0)
{
System.out.println("FetchCategoryVersion Failed.");
return;
}
System.out.println("where r u ?");
attrValues.add("Started");
if (attr.AttrSetValues(catVersion, "Status", attr.ATTR_DATAVALUES, attrValPath, attrValues) != 0)
{
System.out.println("AttrSetValues Failed here.");
}
categories.add( catVersion );
//Fill createInfo to spec (see documentation for the structure)
cRequest.add("Comment", "");
createInfo.add("request", cRequest);
createInfo.add("extendedData", extData);
createInfo.add("Categories", categories);
if(doc.CreateObjectEx(volumeID, objectID, doc.OBJECTTYPE,
doc.DOCUMENTSUBTYPE, "logfile.txt", createInfo, objectInfo) != 0)
{
System.out.println("CreateObjectEx Failed.");
System.out.println("Status Code: " + session.getStatus());
System.out.println("Api Error: " + session.getApiError());
System.out.println("Error Message: " + session.getErrMsg());
System.out.println("Status Message: " + session.getStatusMessage());
// return;
}
else
{
System.out.println("Document Object created successfully:Next we have to add a version to complete it");
}
docObjectID = objectInfo.toInteger("ID");
//Now upload version to complete document creation
if(doc.CreateVersion(volumeID, docObjectID, "c:\\temp\\tlist.txt", versionInfo) != 0)
{
System.out.println("CreateVersion Failed.be sure to remove the 0 byte stub in livelink if this happens");
return;
}
else
{
System.out.println("Version created successfully");
}
objID.add("ID",docObjectID);
System.out.println("out of if");
}catch(Exception ex) {
System.out.println("in catch "+ex);
}
} //Main ends
}//Class ends
************
Thanks,
Sunu