Hi,
Thru LAPI, I am adding a document to livelink.Now, next time when the user tries to add the same file it should be created as a version of the first file.
I have written code for that, I was trying to create a version the second time the file is uploaded in the catch statement.
I use java to program.I am attaching the rpogram here.
/****************My Java program****************
import java.io.*;
import java.util.*;
import java.text.DateFormat.*;
import com.opentext.api.*;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Category;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.Logger.*;
public class versionDocument
{
static Category cat = Category.getInstance(AddDocumentWCategory.class.getName());
private static String Server = ""; //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 = ""; //username
private static String Pass = ""; //passwd
public static void main (String args[])
{
//variables
LLSession session;
LAPI_DOCUMENTS doc;
//create a new session
//Get into livelink
session = new LLSession (Server, Port, DFT, User, Pass);
doc = new LAPI_DOCUMENTS (session);
LAPI_ATTRIBUTES attr = new LAPI_ATTRIBUTES(session);
LAPI_ATTRIBUTES attributes= 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();
//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;
//Get the volumeID and objectID for the EnterpriseWS
try
{
PropertyConfigurator.configure("c://PTDI//log4j.properties");
cat.info("Starting this batch");
if(doc.AccessEnterpriseWS(entInfo) != 0)
{
System.out.println("AccessEnterpriseWS Failed.");
cat.error("Accessing Enterprise workspace 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", 255917);
catID.add("Version", 0);
//Use the catID to fetch the category Version
if (doc.FetchCategoryVersion(catID, catVersion) != 0)
{
System.out.println("FetchCategoryVersion Failed.");
cat.error("FetchCategoryVersion Failed.");
return;
}
attrValues.add("3-Pending");
if (attr.AttrSetValues(catVersion, "Status", attr.ATTR_DATAVALUES, attrValPath, attrValues) != 0)
{
System.out.println("AttrSetValues Failed here.");
cat.error("Status attrsetvalue failed");
return;
}
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)
{
cat.error("Create object failed");
// objectID = entInfo.toInteger("ID");
System.out.println("CreateObjectEx Failed.");
System.out.println("Error Message: " + session.getErrMsg());
cat.error("Error Message: " + session.getErrMsg());
// return;
}
else
{
System.out.println("Document Object created successfully:Next we have to add a version to complete it");
}
docObjectID = objectInfo.toInteger("ID");
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);
}
catch(Exception ex)
{
cat.error("in catch");
System.out.println("in catch ");
int m =doc.CreateVersion(volumeID, docObjectID, "c:\\temp\\tlist.txt", versionInfo);
System.out.println("value of m is"+ m);
}
} //Main ends
}//Class ends
*/
I greatly appreciate your help.
Thanks,
Sunu
Thru LAPI, I am adding a document to livelink.Now, next time when the user tries to add the same file it should be created as a version of the first file.
I have written code for that, I was trying to create a version the second time the file is uploaded in the catch statement.
I use java to program.I am attaching the rpogram here.
/****************My Java program****************
import java.io.*;
import java.util.*;
import java.text.DateFormat.*;
import com.opentext.api.*;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Category;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.Logger.*;
public class versionDocument
{
static Category cat = Category.getInstance(AddDocumentWCategory.class.getName());
private static String Server = ""; //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 = ""; //username
private static String Pass = ""; //passwd
public static void main (String args[])
{
//variables
LLSession session;
LAPI_DOCUMENTS doc;
//create a new session
//Get into livelink
session = new LLSession (Server, Port, DFT, User, Pass);
doc = new LAPI_DOCUMENTS (session);
LAPI_ATTRIBUTES attr = new LAPI_ATTRIBUTES(session);
LAPI_ATTRIBUTES attributes= 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();
//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;
//Get the volumeID and objectID for the EnterpriseWS
try
{
PropertyConfigurator.configure("c://PTDI//log4j.properties");
cat.info("Starting this batch");
if(doc.AccessEnterpriseWS(entInfo) != 0)
{
System.out.println("AccessEnterpriseWS Failed.");
cat.error("Accessing Enterprise workspace 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", 255917);
catID.add("Version", 0);
//Use the catID to fetch the category Version
if (doc.FetchCategoryVersion(catID, catVersion) != 0)
{
System.out.println("FetchCategoryVersion Failed.");
cat.error("FetchCategoryVersion Failed.");
return;
}
attrValues.add("3-Pending");
if (attr.AttrSetValues(catVersion, "Status", attr.ATTR_DATAVALUES, attrValPath, attrValues) != 0)
{
System.out.println("AttrSetValues Failed here.");
cat.error("Status attrsetvalue failed");
return;
}
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)
{
cat.error("Create object failed");
// objectID = entInfo.toInteger("ID");
System.out.println("CreateObjectEx Failed.");
System.out.println("Error Message: " + session.getErrMsg());
cat.error("Error Message: " + session.getErrMsg());
// return;
}
else
{
System.out.println("Document Object created successfully:Next we have to add a version to complete it");
}
docObjectID = objectInfo.toInteger("ID");
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);
}
catch(Exception ex)
{
cat.error("in catch");
System.out.println("in catch ");
int m =doc.CreateVersion(volumeID, docObjectID, "c:\\temp\\tlist.txt", versionInfo);
System.out.println("value of m is"+ m);
}
} //Main ends
}//Class ends
*/
I greatly appreciate your help.
Thanks,
Sunu