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!

works fine in IE, but get(name) error in Firefox when adding document

Status
Not open for further replies.

trbldntyrd

Programmer
Jun 7, 2011
7
US
I am able to successfully upload a document in IE. However, it crashes in Firefox, giving me the "get(name) not implemented for this datatype" error when trying to add a document. The document uploads to the livelink directory, but if I try to open it, I get a "version not found" error. Also, when I enumerate through the files in my web app, "?" displays for type and file name. My code is very simple...

[blue]
LLValue objInfo = (new LLValue()).setAssoc();
LLValue versionInfo = (new LLValue()).setAssocNotSet();
utility.Status = utility.Documents.AddDocument(livelinkVolumeID, parentID, docName, filePath, objInfo, versionInfo);
[/blue]

It errors out on the last line. The first four parameters have valid values, but I'm not sure about objInfo and versionInfo as I don't know what kind of values to expect. I am new to LAPI programming and there isn't much documentation online to help me. What could possibly be wrong? Any help is much appreciated.

Thanks.
 
I have done a lot of livelink programming but when I have to use lapi I have always used a programming lanaguage but not a browser.I am not sure I understand what is being said here

From the code lines it looks some like core lapi as some like customized code classes.

Try the attempt using regular java or C# and see what you get
it should not be this hard to just add a file to livelink and retreive it with lapi

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,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Sorry, that was C# code (ASP.NET w/ C#). I'm using what I assumed was the core LAPI class as well as a wrapper. I believe the first two lines uses the core LAPI, so it should pull up the object and version info, correct? If so, then it's a problem with the wrapper, but why would it work in IE and not Firefox?
 
my guess is since you are getting an error it is really not working in IE as well.AddDocument is just a convenience function in lapi which actually combines 2 calls shown in psuedocode.

First CreateObject(subtype 144).This will allocate a node like 123445 and enter in dtree as subtype=144
CreateVersion(filepath)-uploads the file and updates dversdata with actual files etc.

So when you say it works in IE I think only the first call is working.That is why it is probably saying cannot find version file.Livelink is not rolloing back even if the second call cannot do it so you have a node that is a document subtype with no version.

All lapi calls should be checked for session errors and the programmer needs to do the correct thing on failure.

as a matter of fact the adddocument call does not even work if the parentobject insists on a category and you have no means to provide that in the call.

If I were you I would use the livelink GUI go to the place where your program was supposed to add and add a document and see if you succeed as your lapi user.

I would also rewrite that using createobject and createversion lapi calls and trap session errors in any convenience function.

To explain to other posters I have posted so many fully functioning lapi code files in this forum and in all that you can see how to trap session errors.

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,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
BTW in lapi this just means

LLValue objInfo = (new LLValue()).setAssoc();
LLValue versionInfo = (new LLValue()).setAssocNotSet();

Initialize variaables to hold input /output values
that too you should not use

LLValue versionInfo = (new LLValue()).setAssocNotSet();
it is problematic pls use
LLValue versionInfo = (new LLValue()).setAssoc();

if what I posted earlier was making sense in createobject would populate objinfo(technical info about the node as in webnodes) and createVersion would populate version specific data as coming from dversdata the main things being mimetype,filesize etc that is needed for a browser to open/download the file

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,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
I tried the CreateObjecteEx method (using your trap session error code in another post), but now it doesn't work in IE. Same problem as in FireFox - the doc uploads to Livelink but doesn't get/retain the doc info like name, file type, and description. I also get the "version not found" error if I attempt to open it. I also tried to follow your suggestion in your previous post, but still had the same error. I tried the CreateVersion as well, but that didn't upload anything. Any ideas?
 
Oh, and there was no error on CreateObjectEx either. The method executed successfully. The file uploaded but with no file information other than the file name I passed to it and modified date.
 
try this code editing what you need to edit and trouble shoot.
if it works then change all the setassocNotSet() like I said before as Ot has deprecated its use.

Code:
//Specify import directives
import com.opentext.api.*;
import java.util.*;
public class CreateDocumentAndVersion
{

	//class member functions
	public static void main (String args[])
	{
		try
		{
			//Create a new Livelink Session
			LLSession session;
			session = new LLSession ("localhost", 4099, "", "Admin", "livelink", null);

			//Initialize any LAPI Objects
			LAPI_DOCUMENTS	doc = new LAPI_DOCUMENTS(session);
            LLValue myEntValues=new LLValue();
            int volumeID=0, objectID=0,versionID=0;
         //we are accessing the enterprise workspace
         if (doc.AccessEnterpriseWS(myEntValues) == 0)
          {
               volumeID = myEntValues.toInteger("VolumeID");
               objectID = myEntValues.toInteger("ID");
               System.out.println("This and other better Lapi samples at [URL unfurl="true"]http://www.greggriffiths.org");[/URL]
               System.out.println("My objID -->"+objectID+" My VolumeID is -->"+volumeID);
               System.out.println("I love LAPI.Dr Lapi");

          }//if ends

     // we need a folder to create our document
     //in this example we are trying to create in
     //enterprise workspace,change this call to
     //any valid folder id for this lapi users
     //has 'Add item' perms
         int myFolderObjID=objectID;


         String myDocToBeUploaded="c:\\temp\\test.txt";

			//////////////////////////////////////////////////////////////////////
			//Code to Create a Document
			//First we create the document node subtype
			//Then we add a  version
			//Demonstrates why this lapi call is superior
			//than AddDocument
			//////////////////////////////////////////////////////////////////////
			//Finally, we can create the document
			//create the output variable objectInfo, which will contain the object's information
			LLValue objectInfo = (new LLValue()).setAssocNotSet();

			//Setup any information for creation
			LLValue createInfo = (new LLValue()).setAssocNotSet();
			createInfo.add("Comments","These are the document's comments.");
			//Create the document object in Livelink
			//By changing the subtype you get to create
			//the differnet objecrs

			if(doc.CreateObjectEx(volumeID, myFolderObjID, doc.OBJECTTYPE, doc.DOCUMENTSUBTYPE, "New Document Name", createInfo, objectInfo) != 0)
			{
				GetErrors(session);
				//if it has errored out we should really be checking what the
				//error was .But since this is a createVersion on a pre-existing
				//node excercise we will assume that the error is due to a
				//pre-existing node we grab its information.For this we need
				//to list objects and we are interested in finding only the
				//documents

				/********************************************************/
				CreateVersion(session,doc,volumeID,objectID,objectInfo,myDocToBeUploaded);
				return;
			}
			else
				System.out.println("Document Object Created.");

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

//This function creates any number of versions if the node already exists
	public static void CreateVersion(LLSession session,LAPI_DOCUMENTS doc,int volumeID,int objectID,LLValue objectInfo,String path)
	{

        LLValue children=(new LLValue()).setTable();
        //create the output variable versionInfo, which will contain the version's information
		LLValue versionInfo = (new LLValue()).setAssocNotSet();
		doc.ListObjects(volumeID,objectID,"DTREE","subtype=144",doc.PERM_FULL,children);

/*since children is a RecArray we have to use content enumeration methods to figure
out the type of the object.The subtype=144 limits returning documents where the
PERM_FULL is applied to the lapi user making this call*/
/* see the full out put of this recarray.For simplicity we take the "Name" out
of it and compare to the name we are trying to give */

		    	}


























//This function outputs any errors from the session
	public static void GetErrors(LLSession session)
	{
		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());
	}





















	}//Class Ends

if this code errosr post the error message and i will try to debug it.change the paths and connection info logically

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,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
I tested this on my livelink with java.If this creates just the first part and not the second part put those errosr here and I will try if I understand it
Code:
//Specify import directives
import com.opentext.api.*;
import java.util.*;
public class CreateDocumentAndVersion
{

	//class member functions
	public static void main (String args[])
	{
		try
		{
			//Create a new Livelink Session
			LLSession session;
			session = new LLSession ("localhost", 2099, "", "Admin", "Admin", null);

			//Initialize any LAPI Objects
			LAPI_DOCUMENTS	doc = new LAPI_DOCUMENTS(session);
            LLValue myEntValues=new LLValue();
            int volumeID=0, objectID=0,versionID=0;
         //we are accessing the enterprise workspace
         if (doc.AccessEnterpriseWS(myEntValues) == 0)
          {
               volumeID = myEntValues.toInteger("VolumeID");
               objectID = myEntValues.toInteger("ID");
               System.out.println("This and other better Lapi samples at [URL unfurl="true"]http://www.greggriffiths.org");[/URL]
               System.out.println("My objID -->"+objectID+" My VolumeID is -->"+volumeID);
               System.out.println("I love LAPI.Dr Lapi");

          }//if ends

     // we need a folder to create our document
     //in this example we are trying to create in
     //enterprise workspace,change this call to
     //any valid folder id for this lapi users
     //has 'Add item' perms
         int myFolderObjID=objectID;


         String myDocToBeUploaded="c:\\temp\\test.txt";

			//////////////////////////////////////////////////////////////////////
			//Code to Create a Document
			//First we create the document node subtype
			//Then we add a  version
			//Demonstrates why this lapi call is superior
			//than AddDocument
			//////////////////////////////////////////////////////////////////////
			//Finally, we can create the document
			//create the output variable objectInfo, which will contain the object's information
			LLValue objectInfo = (new LLValue()).setAssoc();

			//Setup any information for creation
			LLValue createInfo = (new LLValue()).setAssoc();
			createInfo.add("Comments","These are the document's comments.");
			//Create the document object in Livelink
			//By changing the subtype you get to create
			//the differnet objecrs

			if(doc.CreateObjectEx(volumeID, myFolderObjID, doc.OBJECTTYPE, doc.DOCUMENTSUBTYPE, "New Document Name", createInfo, objectInfo) != 0)
			{
				GetErrors(session);
				/********************************************************/
				return;
				
			}
			else
			{
				System.out.println("Document Node Created Now trying to add a file to complete it");
				//we have to pass the objectid that was allocated here
				objectID = objectInfo.toInteger("ID");
				
				CreateVersion(session,doc,volumeID,objectID,myDocToBeUploaded);
				}
				

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

//This function creates exactly one version to an allocated node
	public static void CreateVersion(LLSession session,LAPI_DOCUMENTS doc,int volumeID,int objectID,String path)
	{
	LLValue versionInfo = (new LLValue()).setAssoc();
	if(doc.CreateVersion(volumeID,objectID,path,versionInfo)!= 0)
	{
		GetErrors(session);
		return;
	}
	else
	{
	System.out.println("Version also  Node Created Do not re-run program unless you remove the document you added or the node allocated");
	}
	
	
	
	
/*public	int	CreateVersion(
                  int	            volumeID,
                  int	            objectID,
                  String	    filePath,
                  LLValue	    versionInfo )*/

        

		    	}








//This function outputs any errors from the session
	public static void GetErrors(LLSession session)
	{
		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());
	}





















	}//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,Livelink ECM Champion 2008,Livelink ECM Champion 2010
 
Thanks so much for that. I figured the problem is that in FireFox, the fileupload control does not give the full path of the file (just the file name) for security reasons. I can upload successfully if I hard code a path. Also IE gives the full path of the file, but that may no longer be the case with IE 8 Is there any way I can upload a file without having to pass the filepath?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top