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!

LAPI Question - mime types and comments

Status
Not open for further replies.

oscript

Programmer
Mar 25, 2003
63
GB
I would like to be able to add both a comment and to set a spcific mime.type to to a specific version of a document created using CreateVersion.

I am using the following in Java with no compilation errors but critically no comment or mime type setting !:

....

// log the fac that the holder was created successfully
logger.info("Document Object Created...");

// create the output variable verInfo, which
// will contain the version's information
// such as a comment and a specific mime type
LLValue verInfo = (new LLValue()).setAssocNotSet();

LLValue docversion = (new LLValue()).setAssocNotSet();

// add a comment
docversion.add("Comment","LAPI added comment");

// and set a specific mime type
docversion.add("MimeType", "application/msword");

// now add the version info
verInfo.add("request", docversion);

// log what's being uploaded
logger.info("File to upload is " + filesource);

// create the version using the additional info
if (doc.CreateVersion(volumeID, dataID, filesource, verInfo) != 0) {.......

Clearly I am doing something wrong but cannot see what so hoping someone can help.

Steven
 
i think you are very close but I belive you are going wrong with the creatinfo assoc.I will put a example filehere.There is more stuff that I am doing here but you will get the idea.You do not need to explicity set mime type because when the request reaches the ll server it will get it by default.
Typically this is how you fulfill the request parmeters
//Fill createInfo to spec (see documentation for the structure)
cRequest.add("Comment", "My comment");

createInfo.add("request", cRequest);
Code:
import java.io.*;
import com.opentext.api.*;	//import LAPI objects

//lapi.jar should be available in classpath

public class AddDocument
{

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[])
{
	//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);
  //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;

		//Get the volumeID and objectID for the EnterpriseWS


		if(doc.AccessEnterpriseWS(entInfo) != 0)
		{
			System.out.println("AccessEnterpriseWS Failed.");
						return;
		}
		  //Grab the info from entInfo
			volumeID = entInfo.toInteger("VolumeID");
			objectID = entInfo.toInteger("ID");
			System.out.println("Volume"+volumeID+"ObjID"+objectID);

			/*
			Setup catID, hardcode the categories objectID we have the session now let's mess on categories
			Note that we are NOT creating a category but rather APPLYING a category to a library object
			such as a folder or document.If the Category has a mandatory value LL will forgive you for
			folder creation but not for version object such as a document.There is athird type of metadata
			in livelink called AdditionalNodeAttributes that can be understaood by looking at the GUI for object
			creation
			*/


			catID.add("ID", 152278);
	        catID.add("Version", 0);

	       //Use the catID to fetch the category Version
		   	if (doc.FetchCategoryVersion(catID, catVersion) != 0)
		   	{
		   		System.out.println("FetchCategoryVersion Failed.");
		   			   		return;
		   	}

		   	//Add the values to attrValues to be in the attribute
		   	//This is a validval which is a list object or appears as
		   	//a TEXT POPUP in livelink
		   	attrValues.add("7 - Pending Transmittal");

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

		   		return;
		   	}

		   	LLValue attrValues1 = (new LLValue()).setList();
			attrValues1.add("1.000");
			//See I have added the mandatory stuff for documents only
			 if (attr.AttrSetValues(catVersion, "Documentation Code", LAPI_ATTRIBUTES.ATTR_DATAVALUES, attrValPath, attrValues1) != 0)
			 {
			       System.out.println("AttrSetValues Failed.");

		   		   return;

			  }

/*In prod worthy code you will write a routine to find the catversion datastructure and see if the key/value
pair aka ASSOC that you are setting is matched up on datatypes*/


		   	//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);
		   	//If there is more than one category applied hence the reason for categories being a list
		   	//see how efficient data structures are in input/output
            //IN LL you create an OBJECT and then follow up additional stuff for eg
            //Folder is just a marker in a database,whereas a document needs a non zero
            //byte document to serve somebody with.But true to OOP an Object is the base class
            //then you have Folder,Document  et al.Never use the AddDocument LAPI command
            //it is severely limited in metadata capabilities.

		   	//Create document in enterpriseWS
		   	if(doc.CreateObjectEx(volumeID, objectID, doc.OBJECTTYPE,
		   			doc.DOCUMENTSUBTYPE, "BrandNewDocWithCategory1", createInfo, objectInfo) != 0)
		   	{
		   		System.out.println("CreateObjectEx Failed.");

		   		return;
		   	}
		   	else
		   	{
		   		System.out.println("Document Object created successfully:Next we have to add a version to complete it");
			}

		   	//Set objectID to objectID of the new document
		   	objectID = objectInfo.toInteger("ID");

		   	//Now upload version to complete document creation
		   	if(doc.CreateVersion(volumeID, objectID, "c:\\test.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");

		   	}


} //Main ends
}//Class ends

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer and probably certfiable,Livelink ECM Champion 2008

 
sorry all I think you have to use UpdateVersionInfo with those code using UpdateVersionInfo I am not sure it is smart to do that on creation

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer and probably certfiable,Livelink ECM Champion 2008

 
As usual thank you for the helpful response.

The issue here for me is that in LL9.1 the .docx extension is not picked up automatically when the document is created and so I am trying to circumnavigate this by explicitly setting the mime.type it at the time of creation.

Hence the line:

// and set a specific mime type
docversion.add("MimeType", "application/msword");

Seems daft but perhaps I should update subsequently ?

Steven
 
Greg - again thank you for the reply and yes you are strictly speaking correct (confirmed by OT).

However I have found that manually setting the mime.type of a document with the .docx extension to msword using the interface gets me the desired behaviour. So really I simply want at least to be able to set this mime type at the point of adding the version. Renaming the document with a docx ext to one with a doc extension works but is less desirable.
 
Greg - as is often the case the server and hence the <opentext>\config\mime.types file is controlled centrally. The stock response of course is that the version does not support Office 7.0 (.docx in my case) files are not supported.

The criticil thing is that if I could explicitly set the mime.type then I believe that the issue would be solved. Of course what was suggested by appnair was useful but still I find that the code does not allow the setting of this particular attribute (mime.type in my case). Does anyone have an example that they can share where they can either set the 'comment' for the individual version (surely must have been done?) or better still the mime.type ?

I would have expected this type of thing to work:

LLValue cRequest = new LLValue().setAssoc();
cRequest.add("Comment","added as a test for this version");
verInfo.add("request", cRequest);

if (doc.CreateVersion(volumeID, dataID, filesource, verInfo) != 0) {.....

Unfortunately it doesn't in my case - so I guess that I have overlooked something but cannot see for looking :(

Steven
 
my guess is that the mime.type you are setting is not in the mime.types file in your opentext config directory.Again I am guessing here OT may be checking whether or not the supplied one matches the definition.In nay case the mime that is called "octet stream" should be acceptable

Well, if I called the wrong number, why did you answer the phone?
James Thurber, New Yorker cartoon caption, June 5, 1937
Certified OT Developer and probably certfiable,Livelink ECM Champion 2008

 
The mime.type that I am setting is present but I must be doing something wrong:

// and set a specific mime type
docversion.add("MimeType", "application/msword");

If I set this using the interface then things work fine.

Do you or anyone have an extract to set the comment in a version of a document - this too I cannot get to work. I am only able to successfully set the comment at the object and not the document level ?

I am only trying to set this as a precursor to setting the mime.type.

Steven
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top