Home
Extended ECM
API, SDK, REST and Web Services
Looking for code to copy a folder structure and it's permissions
Joe_Ehrenfeld
I have an ASP.NET form outside of Livelink that captures data inputed by the user. When the user clicks the submit I would like to COPY and folder structure in Livelink and put it into a new folder with the top folder taking the name of of one the fields from the form. I will need persmissons as well. How can this be done?
Find more posts tagged with
Comments
Appu_Nair
One or two general qns1)what version of livelink ?2)Do you have the lapi sdk ?Alternative to lapi3)Do you have Object Importer module available?If you had OI all it will require from your asp.net form is to right a simple xml structure see an example below and it would create the folder structure.Note that the OI is not a synchronous process it will be done on a scheduler.<?xml version="1.0" encoding="UTF-8"?> Enterprise Temp Enterprise:Temp New Document
\LL OBJ IMPORTER\readme.txt If you want to do this via lapi or webservices then you have to programmatically know the node id of your template the permissions et al.This is not unsurmountable thru lapi.I would start with some simple examples of lapi or web services which is avilable here
https://knowledge.opentext.com/knowledge/llisapi.dll/fetch/2001/744073/2120338/3755714/customview.html?func=ll&objId=3755714&objAction=browse&sort=name
Joe_Ehrenfeld
Appu, thank you for the reply. I was able to get it to work using CopyObject (I know the template folder structure ID that I am going to copy ahead of time). But what I would like get back from the CopyObject method is the DataID of the new object that was created. Other than re-querying the database to get this value how can I obtain it immediately after it has been created.
Appu_Nair
Any object that is created thru lapi or anyother means like oscript gives you back a LLvalue object.In that ID is the field you are looking forobjectInfo.toInteger("ID"***************Code Excerpt***************See this code excerpt in which the documentNode was create if (doc.CreateObjectEx(volumeID, 92166, LAPI_DOCUMENTS.OBJECTTYPE, LAPI_DOCUMENTS.DOCUMENTSUBTYPE, "New Document Name", createInfo, objectInfo) != 0) { GetErrors(session); return; } else Console.WriteLine("Document Object Created."); //create the output variable versionInfo, which will contain the version's information LLValue versionInfo = (new LLValue()).setAssocNotSet(); //Add a version to the document object if (doc.CreateVersion(volumeID, objectInfo.toInteger("ID"), "c:\\test.txt", versionInfo) != 0) { GetErrors(session); return; } else Console.WriteLine("Version Created.");*************************************
Joe_Ehrenfeld
Appu, I am almost there with all the help you have given me thus far. I am able to copy a folder and its subfolders and get the dataid back of the folder created. What is not happening though is the persmissions from the folder template that is being copied is not carrying over. Is there an attibute or some parameter that I can pass for "Kepp Original Permissions"?
Appu_Nair
it is all in the documentation you have to use SetObjectRight can you try a simple example and see how you fare.if you need more than this letme know I will see if I can rig up oneJava/.NET Method Declarationpublic int SetObjectRight( int volumeID, int objectID, int operation, int rightID, int permissions, int subObjects )
Joe_Ehrenfeld
Appu, I see the method in my documentation, but I don't see the parameters where I can copy permissions from one object to the next. The folder template I am copying has several subfolders and those subfolders have different permissions. Seems to complicated to re-assign all those permissions to the new folders. So what I tried was initiating a workflow and the workflow step uses the copy and keep original permissions. But now the issue I have is I need the dataid of the folder that was created NOT the dataid of the new workflow. Now I have the name of the folder (same name as the workflow) and I know the parentID. I tried using ListObject, but my QueryStr param is not right. How would I set its value to something like WHERE name = 2131 K Street (Washington, DC)int i_volumeID = -2000;int i_parentID = 129862;LLValue children = new LLValue().setAssoc();string queryStringLQL =
@(OTDataID : 1234) OR
"2131 K Street (Washington, DC)"""; doc.ListObjects(i_volumeID, i_parentID, null, queryStringLQL, 0, children);Response.Write(children.toValue("ID") + "
");
Appu_Nair
ListObjects is to mimic thisselect * from dtree where subtype=0.It will just give you the first leval and will not follow the tree you will have to walk the tree.doc.ListObjects(i_volumeID, i_parentID, null, "dtree","name like 2131", 0, children);lvelink will reconstruct it as select * from dtree where name like this and and valid stuff.If you want to use lapi search object then your query is right.That means you have to create a LAPI_SEARCH objectI just ran this query thru listobjects and it worked the escape sequences maight be trickydoc.ListObjects(0, 82604, "dtree", " subtype=0 and name like '"+"Administrative%\'", 0, children);So to understand this correctly.You have a template with lot of different permissions sets and the lapi copy just ruins everythingso you have to re-do this from scratch.I have not personally tried it now you got me interested
Joe_Ehrenfeld
Appu, that is correct, I have a template of folders, with some subfolders having different permissions. For instance, the top level folder has only See and See Contents. The template controls what folders are added. Then there are some folders that have modify. AND some groups can have modify, while others only See and See contents. Looks like you want a challenge, well there you go!!By the way I was able to use ListObject() to get the dataID of my folder that was created from the workflow by using:string queryStr = "name ='2131 K Street (Washington, DC)'";This will work for me as the name value comes from a form field whose value is entered in by user. Then I used string dataID = children.toString("ID");Only problem with that is I get a the value back as: {201952763}I could use string.replace() to remove the brackets but can I get the dataID back with out the {}?Thanks Appu.
Appu_Nair
My advice rather than make a hack at it try to learn lapi or the newer modern savvy web services.Lapi returns datastructures and in this case you get a Recarray.I inlclude a simple parsing thing in case this helps:)***********************doc.ListObjects(0, 82604, "dtree", " subtype=0 and name like '"+"Administrative%\'", 0, children); int numItems = children.size(); LLValue child = new LLValue().setRecord(); // since it is a recarray it has rows of information for (int i = 0; i < numItems ; i++) { child = children.toValue(i); Console.Write(child.toValue("id")+"|"); Console.Write(child.toValue("name")+"|" ); Console.WriteLine(child.toValue("SubType")); }
Appu_Nair
I was actually able to look at the DAPI.CopyNode which is actually the call that doc.copyobject calls all said and done.And I hacked it by using this//trying a node copy doc.CopyObject(0, 87007, 0, 85606, 2, "will it work", objInfo); In case you are wondering what 2 it is a constant calledDAPI.COPY_SRC_PERMS I did not see that exposed in lapi so they might have a good reason not doing this.Try this completely at your own risk.One thing I noticed is the Owner gets changed to the user who executed the lapi that is probably what the item handler gives you as well.the assigned access list (below the line is correct)I think that is correct owner is always the person who created the object,you could change it later as well.