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!

accessDirectoryById

Status
Not open for further replies.

clayton23

Programmer
Mar 3, 2004
2
US
I am no dummy I promise, and actually I am a bit embarrassed that I have to ask for help on something that should be so simple so I apologize in advance, but since I have spent two days trying to find a solution on my own without success I must ask for help.

So I am having problems doing something that would seem to be very simple. Basically I am trying to allow my user to navigate their folder tree, and publish documents to it via LAPI, but I can't figure out how to let them do it. Here is a method from the LLSessionManager that lets them got to their PWS.

1. I can access their personal workspace just fine:

public void accessPersonalWorkspace() throws Exception
{
// Access the user's Personal Workspace
this.status = documents.AccessPersonalWS( this.pwsInfo );

if ( this.status == 0 )
{

this.parentVol = this.pwsInfo.toInteger( "VolumeID" );
this.parentID = this.pwsInfo.toInteger( "ID" );
int createdby = this.pwsInfo.toInteger("CreatedBy");
String name = this.pwsInfo.toString("Name");
debug ( "Accessed Personal Workspace:"+name );

}
else
handelError();
}

So you can imagine what is next, a user wants to navigate down to one of the child folders and add a document: We have given them the id of the folder that they now want to access, and allow them to pass it to the function that *should* change the directory. But it doesn't.

//set directory by id *DOES NOT WORK*

public void accessDirectoryById(int id) throws Exception
{

debug("accessDirectoryById:"+id);
// Access directory
LLValue dirInfo = new LLValue().setAssocNotSet();
dirInfo.add("ID", id);
dirInfo.add("VolumeID", this.parentID);

//I would think this would do it, GetObject doesn't work for me either.
//and the API is opaque at best.
this.status = this.documents.AccessPersonalWS(dirInfo);

if ( this.status == 0 )
{
this.pwsInfo = dirInfo;
debug("it worked.");
String name = this.pwsInfo.toString( "Name" );
this.parentVol = this.pwsInfo.toInteger( "VolumeID" );
this.parentID = pwsInfo.toInteger( "ID" );
debug ( "Accessed Directory:"+name );
}
else
handelError();
}


I know this comes from not understanding the API but honestly in all the code samples and posts I have seen no one is trying to do this.

If you have a lead I would appreciate it.


Clay
 
Hello,
For the life of me I couldnot find the prototypes that you are using.I am on livelink 9.1.0 SP3(public void accessDirectoryById(int id) throws Exception).Is this a new prototype.However here is a quick one I rigged up using
plain old java.Not the best code you will see out there
and belive me it works.If the code is too much broken and will not compile publish your email and I will be able to send the ADD.java file
Code:
import java.util.*;//for our date manip
import java.io.*;
import com.opentext.api.*;	//import LAPI objects

public class ADD
{

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 persInfo = (new LLValue()).setAssocNotSet();

	int volumeID;
	int objectID;
		if(doc.AccessEnterpriseWS(entInfo) != 0)
		{
			System.out.println("AccessEnterpriseWS Failed.");
						return;
		}
           else
            {
            volumeID = entInfo.toInteger("VolumeID");
			objectID = entInfo.toInteger("ID");
			System.out.println("Enterprise Volume"+volumeID+" Enterprise ObjID"+objectID);
            }


//prototype for AccessPersonalWS public  int   AccessPersonalWS( LLValue     personalInfo )

            if(doc.AccessPersonalWS(persInfo) != 0)
		{
			System.out.println("AccessPersonalWS Failed.");
						return;
		}
           else
            {
            volumeID = persInfo.toInteger("VolumeID");
			objectID = persInfo.toInteger("ID");
			System.out.println("Personal Volume"+volumeID+"Personal ObjID"+objectID);
            }

 //Let's add sume stuff into the personalworkspace of the logged in user
 //I have a directory called BarBar with an objID of 9997 edit yours
 //to the correct ID


 /*Java/.NET Method Declaration (File Input)

 public   int   AddDocument(
                    int          parentVolID,
                    int          parentID,
                    String       name,
                    String       filePath,
                    LLValue      objectInfo,  //for output
                    LLValue      versionInfo //for output )*/



   //we got the parentvolid and parentID before
   LLValue objectInfo = (new LLValue()).setAssocNotSet();
   LLValue versionInfo = (new LLValue()).setAssocNotSet();

if(doc.AddDocument(volumeID,9997,"New Document","C:\\temp\\barbar.txt",objectInfo,versionInfo)!= 0)
{
System.out.println("Could not add document may be missing from path specified ");
return;
}
else
{
//show info from livelink for simplicity only simple things published

System.out.println("Name of document"+objectInfo.toString("Name"));
System.out.println("ID"+objectInfo.toInteger("ID"));
//show some version info things too

System.out.println("Name of document"+versionInfo.toString("Name"));
System.out.println("Name of File"+versionInfo.toString("FileName"));
System.out.println("ID"+versionInfo.toInteger("NodeID"));
System.out.println("Create Date"+versionInfo.toDate("CreateDate"));

}

//Program will error if second time it is run because
//we are tring to add a document already existing
//i just put the prototype here in case you want to exapnd on it
//Java/.NET Method Declaration (File Input)

/*public	int	CreateVersion(
                  int	            volumeID,
                  int	            objectID,
                  String	    filePath,
                  LLValue	    versionInfo )*/




}

}


Freedom is not worth having if it does not include the freedom to make mistakes.
Mahatma Gandhi

appnair

 
no, I think you misunderstand. accessDirectoryById is an implementation I am attempting to provide as a wrapper function because the LAPI is well....opaque.

I have solved the problem by using documents.GetObjectInfo(this.parentVol,id,dirInfo); what you need to know is that parent volume is the first argument of the call, this is a negaitive number which reperests of the atual id of the folder you are getting the child from, again not clear.

here is the implementation that works:

public void accessDirectoryById(int id) throws Exception
{

debug("accessDirectoryById:"+id+" parent:"+this.parentID+" volume:"+this.parentVol);
// Access directory
LLValue dirInfo = new LLValue().setAssocNotSet();

this.status = this.documents.GetObjectInfo(this.parentVol,id,dirInfo);

if ( this.status == 0 )
{
this.pwsInfo = dirInfo;
debug("it worked.");
String name = pwsInfo.toString( "Name" );
this.parentVol = this.pwsInfo.toInteger( "VolumeID" );
this.parentID = this.pwsInfo.toInteger( "ID" );
debug ( "Accessed Directory:"+name );
}
else
handleError();
}

This implementation is assuming that you are getting a child of where you *are*, once you access the child directory that becomes where you *are* by setting this.pwsInfo = dirInfo;.

Clay
 
thanks after posting this I took a closer look and was able to figure out that it was your implementation.I kind of do not mind the idiosyncracies of the API so was just trying to help

Freedom is not worth having if it does not include the freedom to make mistakes.
Mahatma Gandhi

appnair

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top