Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...just the few hours I've spent on this site I have learned a lot. I can now implement features that will be very useful to my company, and some of those I never knew existed..."

Geography

Where in the world do Tek-Tips members come from?

Creating different versions of a document in LAPI

hanreb (TechnicalUser)
16 Feb 08 4:26
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

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close