1

Using the SDK for a Web Service, I have been able to add a user to a WorkSpace and grant them access, however the WorkSpace isn't refiled and so they effectively have access to only the root folder and nothing else.

I know there is the Refile() method, I am just not sure how to perform a refile of folders and documents within the WorkSpace.

Currently I have a function which grants a user access to the WorkSpace, I have tested and this function works, the following is part of the function, before this code I have initiated WorkSpace search methods and the code below is iterating through the search results.

Dim retString As String = ""
For Each w As IManWorkspace In oDB.SearchWorkspaces(oparams, oWparams)
' Get the WorkSpace security container
Dim oSec As IManSecurity = w.Security
Dim oUACLs As IManUserACLs = oSec.UserACLs
' Grant the user the defined access
oUACLs.Add(sUserID, imAccessRight.imRightReadWrite)
' Apply the changes
w.Update()
' Refresh the Collection on the client
oUACLs.Refresh()

' TO DO: REFILE THE SUB-FOLDERS AND DOCUMENTS

retString = oUACLs.Contains(sUserID).ToString()


Next

Return retString(at the moment I have hard-coded the defined access for the user to the WorkSpace, this will be changed to a dynamic value before going live).

As I already have the WorkSpace object, the

COM Developers Reference Guide (pg 244)

says I need to get an IManProfiledFolder object and then get the profile belonging to the profiled folder object:

Code:

Dim objProfFldr as IManProfiledFolder = w w being an IManWorkSpace in my above code Dim objProf as IManProfile = objProfFldr.Profile I can then get the WorkSpace security object via:

Dim oSecurity AS IManSecurity = w.SecurityAnd putting this together, I guess this makes the complete Refile() method be called as Refile(objProf, oSecurity).

I am just not clear on how I apply this all to the WorkSpace, do I need to iterate through all sub-folders and apply the Refile() method to each document, or can I issue a method at the WorkSpace level that will do the iteration for me?

Lima
  • 1,203
  • 3
  • 22
  • 51

2 Answers2

1

Unfortunately there isn't a folder or workspace level refiling method. The Refile method is only available on the IManDocument object so you have to recursively enumerate each folder and it's .Contents in the workspace and call the Refile method on each document.

You should check the return value (IManProfileUpdateResult) of the Refile method as you may not have rights to amend the document profile if a user has locked their document down.

G Davison
  • 1,079
  • 1
  • 14
  • 21
  • Great, thanks for the response. I kind of thought it was too hopeful that there would be a magical method that could do it for me :) Thanks also for the pointers. – Lima Oct 15 '15 at 00:09
0

You may achieve this behavior with the help of one of the following methods form the IManWorkspace object:

 IManProfileUpdateResult UpdateAllWithResults(string file);
 void UpdateAll(string file, ref object errors);

For more details please take a look into the "iManage WorkSite COM Developer’s Reference Guide (p.334)"

The following helper method could be helpful:

public void UpdateWorkspace(IManWorkspace workspace)
{
    var filePath = Path.GetTempFileName();
    try
    {
        if (workspace.HasObjectID)
            workspace.GetCopy(filePath);

        var results = workspace.UpdateAllWithResults(filePath);

        if (!results.Succeeded)
        {
            // Error handling
        }
    }
    finally
    {
        if (File.Exists(filePath))
            File.Delete(filePath);
    }
}

Hope that helps you or somebody else.

Ruslan Shupoval
  • 611
  • 7
  • 7
  • Looks interesting, I'm not familiar with the Path.GetTempFileName() method, what does it do? – Lima Oct 22 '15 at 23:21
  • This method creates temporary file within user's temporary folder. For more details please refer to the following [MSDN article](https://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename%28v=vs.110%29.aspx). It is then used with IManWorkspace.GetCopy() in order to obtain copy of workspace's document and after that this document is used with UpdateAll() or UpdateAllWithResults() methods in order to not lost data (in case of any) related with that workspace. – Ruslan Shupoval Oct 23 '15 at 07:25
  • So this is getting the WorkSpaces XML file? How does it refile all documents within the WorkSpace? – Lima Oct 23 '15 at 11:31
  • Correct. The IManWorkspace.GetCopy() method returns copy of workspce xml document. I'm not sure about the internal implementation but according with SDK the IManWorkSpace object has three update methods: Update, UpdateAll, and UpdateAllWithResults, which refreshes the metadata on the workspace and all the items it contains. We have been using this in our project. – Ruslan Shupoval Oct 23 '15 at 13:46
  • We do all our refiling directly in DB via SQL DML. Ping me for a sample. – Yevgeniy Jul 16 '17 at 10:48