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!

Update Category Information on a document

Status
Not open for further replies.

bhaner

Programmer
Oct 13, 2004
1
US
Does any one have a java example of updating category information on a document.
 
Attached is a very bad way(evrything hard coded) of doing it.Please use it at your risk ,understand it fully and do it.Why I say this is because using this method you need to fully understand the
assocs(type included)before you can do the category updating.My humble suggestion would be to download the EasyLAPI jar files form OT's knowledge base and try using that.It should be fairly simple to use.Also the CreateObjectEx expects all things to be assocs and you will have nasty surprises if your implementation of livelink
has manadatory system attributes.I have recently put a better Cats and Atts sample at if you care to look.
Code:
import java.util.*;//for our date manip
import java.io.*;
import com.opentext.api.*;	//import LAPI objects

public class ADWC
{

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 = "Admin"; //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();
	//Category stuff
	LLValue catID = (new LLValue()).setAssocNotSet();
	LLValue catVersion = new LLValue();
	LLValue attrValues = new LLValue().setList();
	LLValue	attrValPath = new LLValue();
	LLValue categories = new LLValue().setList();
	LLValue cRequest = new LLValue().setAssoc();
	LLValue extData = new LLValue().setAssoc();
	int volumeID;
	int objectID;
		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);

			//Setup catID, hardcode the categories objectID
			//19280 is the objID of my category called
			//test and it is at version 1
			//Populate the LLValue Object catID with that
			catID.add("ID", 19280);
	        catID.add("Version", 0);
	       //Use the catID to fetch the category Version
		   	if (doc.FetchCategoryVersion(catID, catVersion) != 0)
		   	{
		   		System.out.println("None of that category mate");
		   			   		return;
		   	}

		   	//Add the values to attrValues to be in the attribute
		   	//I have a text attribute called Test that will take
		   	//clear text trash
		   	//I guess if I had a date i would have to set it with a date
		   	//I cannot get both the attributes updated for some reason

		   Date myDate=new Date();//get system date to update this para

           attrValues.add(myDate);

		  	if (attr.AttrSetValues(catVersion, "Test Date", attr.ATTR_DATAVALUES, attrValPath, attrValues) != 0)
					   	{
					   		System.out.println("AttrSetValues Failed.");

					   		return;
		   	}

	        // attrValues.add("This is a test");
		 //  	if (attr.AttrSetValues(catVersion, "Test", attr.ATTR_DATAVALUES, attrValPath, attrValues) != 0)
		   //	{
		   	//	System.out.println("AttrSetValues Failed.");

		   	//	return;
		   //	}



		   	//Add category Version Assoc to categories List
		   	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);


		   	//Create document in enterpriseWS
		   	if(doc.CreateObjectEx(volumeID, objectID, doc.OBJECTTYPE,
		   			doc.DOCUMENTSUBTYPE, "PSMELLO's Docs", 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");

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

		   	}


}
}

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