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!

Handle invalid values in the valid values popup text type

Status
Not open for further replies.

hanreb

Technical User
Jan 23, 2008
90
US
Hi,

I am writing a program in LAPI(java).
My problem may be trivial to you. But I am looking for a solution and I appreciate your help.
I have a category that will be attached to a document and this document has to be uploaded in livelink.
I have a problem to solve here. I have a popup text type as an attribute which is a mandatory field, which has a set of valid values. But if the user enters a value that is not in the list of valid values, then also this category has to be attached to the document and uploaded into livelink.
I am pasting my code here
Could you please search for "See the piece of code below"



import java.io.*;
import java.util.*;
import java.text.DateFormat.*;
import com.opentext.api.*; //import LAPI objects
//lapi.jar should be available in classpath


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 AddDocumentWCategory
{
static Category cat = Category.getInstance(AddDocumentWCategory.class.getName());

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 = "livelink"; //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);
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;

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", 3);
//Use the catID to fetch the category Version
if (doc.FetchCategoryVersion(catID, catVersion) != 0)
{
System.out.println("FetchCategoryVersion Failed.");
cat.error("FetchCategoryVersion Failed.");
return;
}
//See the piece of code below

attrValues.add("test"); //test is not a valid value

// attrValues.add("3-Pending"); This is in the Valid values list
//But if user enters a value test, for such invalid values I had put a value “XXX” in the list of valid values. So here I should be able to attach “XXX” as the attribute value, attach the category successfully and upload the document successfully

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");
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());
cat.error("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) {
cat.error("in catch");
System.out.println("in catch "+ex);

}

} //Main ends
}//Class ends


I appreciate your help.
Thanks,
Sunu
 
Livelink does not check whether or not it is a valuid value thru code.Thru the GUI it is enforced because it builds up that from the catversion datastructure.Parse the catversion datastructure inside that is a list for your valid vals.Then run your own tests to see if the suppled value is one in the list.

So initiate this in your code to an llvalue

LLValue myCat=doc.FetchCategoryVersion(catID, catVersion)

now this myCat has the valid vals.Look for a suitable LLvalue iterator like PrintTypeTree.java and pass myCat to it.It will spit out the datastructure for you.

Then run your tests.

Hope that helps


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