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!

Rename an Object in LAPI

Status
Not open for further replies.

kalabog

Programmer
Sep 17, 2003
4
AU
I can't seem to find resources on renaming an object using LAPI. Im assuming this *MUST* be possible. All I could see is adding, deleting and copying...

Is there a way of renaming a dtree node (folder/project) using LAPI without the use of LAPI copy & LAPI delete?

Any help appreciated.

cheers
Kalabog
 
I have included a working java source file with lots of comments showing my thought process.What I am doing here is getting the nodeID of a project and then changing the CreateDate parameter and the 'Name' parameter.Once you compile it and run after changing the parameters for your livelink test server you should see the name changed to reverse everytime it runs,for which i have used the stringbuffer's reverse function.I have tested it on a project object but folders should work fine too.

/*
The code albeit hard coded uses the livelink java api combined
for getting project related info
In this example I retreive Project related items and update them
Written in answer for an kalbhog query in tektip's
@author K N Nair (appoos@hotmail.com) alias appnair/samalayali
kn_nair@ssa-sa.sel.sony.com in tektips
tested java version "1.3.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
OJVM Client VM (build 9.0.2.572 cdov, Copyright (c) 1998-2002 Oracle Corp., nojit)
*/



//to get project related items
import java.util.*;//for our date manip
import com.opentext.api.*;
public class GetProjectAndUpdateName
{
private static String Server = "127.0.0.1"; //livelink host
private static int Port = 5556; //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 = "123admin"; //passwd

public static void main (String [] args)
{
try
{
//variables
LLSession session;
LAPI_DOCUMENTS doc;
session = new LLSession (Server, Port, DFT, User, Pass);
doc = new LAPI_DOCUMENTS (session);
LLValue LLvalueABS=new LLValue().setAssocNotSet();
int volID, objID,versionID;
volID = -2000;
// Parent VolumeID usually enterprise workspace
// use accessenterprise if you do not like hardcoding
objID = 57937;//unique number of my project
//Query the nodeID or for that matter anything
if (doc.GetObjectInfo(-2000,57937,LLvalueABS) == 0)
//-2000 is my enterprise workspace
//57937 is the project ObJID I'm looking for
//LLvalueABS is the LLvalue object I created
{
System.out.println("Document Fetched Successfully");
int CreatedBy = - LLvalueABS.toInteger("CreatedBy");
int CacheExpiration=- LLvalueABS.toInteger("CacheExpiration");
Date CreateDate= LLvalueABS.toDate("CreateDate");
Date myDate=new Date();//get system date to update this para
String Name = LLvalueABS.toString("Name");
//to show user we can manipulate a string we will
//use a string buffer object and reverse it
StringBuffer revName1=new StringBuffer(Name);
revName1.reverse();//we reversed the StringBuffer Object
String revName2=revName1.toString();//back to string for livelink
System.out.print("this was created by"+CreatedBy);
System.out.print("CacheExpiration"+CacheExpiration);
System.out.print("Name"+Name);
System.out.print("Created Date"+CreateDate);
System.out.println("Staring to update Created Date");
LLvalueABS.add("CreateDate",myDate);
LLvalueABS.add("Name",revName2);
//We will update the Created date & name with the date now on system
//all other updatable objects are in builder documentation
doc.UpdateObjectInfo( volID, objID, LLvalueABS ) ;
CreateDate= LLvalueABS.toDate("CreateDate");
System.out.print("Created Date should have changed"+CreateDate);
System.out.print("Updated Name "+revName2);


//K N Nair see LAPI docs for all the other parameters you can query on
}
else
{
System.out.println("Failed to fetch Document");

//Error Checking
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());
}


}
catch (Throwable e)
{
System.err.println(e.getMessage() );
e.printStackTrace (System.err);
}
}

}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top