cancel
Showing results for 
Search instead for 
Did you mean: 

Node deep copy with permissions intact

ejholmgren
Champ in-the-making
Champ in-the-making
I am attempting to use the copy() method on a node that contains several child folders each with different permissions. The folder structure comes through intact, but the nested permissions get trashed. Is there correct way to do this?


var message = "createTitleContentFolderByNameAndTitleId failed";
var exception = "";
var success = false;

var folderName = args.folderName;
var titleId = args.titleId;

try
{
   
    if((folderName == null) || (folderName == "") || (titleId == null) || (titleId == ""))
    {
        message = "Expected folderName and titleId as arguments";
    }
    else
    {
        // Locate content folder for use as a template
        var templateQuery = "//.[@cm:name='Title Content Folders']/*[@cm:name='" + folderName + "']";
        message = "Searching against XPath query: " + templateQuery;
        var templateResults = companyhome.childrenByXPath(templateQuery);
       
        // Locate title folder (target parent)
        var titleQuery = "//.[@bm:title_id=" + titleId + "]";
        message = "Searching against XPath query: " + titleQuery;
        var titleResults = companyhome.childrenByXPath(titleQuery);
   
        if((templateResults.length > 0) && (titleResults.length > 0))
        {       
       var templateFolder = templateResults[0];
            var titleFolder = titleResults[0];
            var newContentFolder = templateFolder.copy(titleFolder, true);
            newContentFolder.name = templateFolder.name;
            if(newContentFolder != null)
            {
                 message = "Content folder created";
                 success = true;
            }
        }
        else
        {
            message = "Could not locate content folder or title folder";
        }
    }   
}
catch (e)
{
    exception = e.description;
}

model.message = message;
model.exception = exception;
model.success = success;
7 REPLIES 7

ejholmgren
Champ in-the-making
Champ in-the-making
I noticed that if I do the copy from the web interface, nested permissions remain intact. Obviously something different is going on behind the scenes.

ejholmgren
Champ in-the-making
Champ in-the-making
Still no responses? I have the following space structure that I'm trying to use as a template:

    - Space A [EveryoneSmiley Frustratedubscriber]
       
      - Space B [SomeGroup:Coordinator]
              - Space C [SomeGroup:Coordinator]
Even though I'm doing target.copy(SpaceA, true), the nested permissions get trashed and end up like this:

    - Space A [EveryoneSmiley Frustratedubscriber]
       
      - Space B [EveryoneSmiley Frustratedubscriber]
              - Space C [EveryoneSmiley Frustratedubscriber]
It works fine if I copy manually in the web UI. Is there another method I should be using other than .copy()?

mikeh
Star Contributor
Star Contributor
I suspect the "Inherit permissions" flag isn't being copied correctly, but please raise a JIRA in order for the issue to get attention.

Thanks,
Mike

damiar
Champ in-the-making
Champ in-the-making
Try to use a Java backed webscript to fix this in the meantime.

ejholmgren
Champ in-the-making
Champ in-the-making
I suspect the "Inherit permissions" flag isn't being copied correctly, but please raise a JIRA in order for the issue to get attention.

Thanks,
Mike

Inherit permissions flag was set on the last level of nodes, and it was trashing the permissions assigned to them. Turned if off and the copy works as it should with all permissions remaining intact. Thanks Mike.

Eric

tgmweb
Champ in-the-making
Champ in-the-making
ejholmgren, if you're still around, how did you get it to work exactly!?

I have a space template with permissions, and it completely ignores them when I do a deep copy - with inherit permissions unticked.

I'm using 3.2r2…

mabayona
Champ on-the-rise
Champ on-the-rise
I´m having exactly this problem with v3.2r2 Community.

When a space estructure with several levels and with different permissions is deep copied, the space structure is copied Ok but none of the permissions are copied.

My (ugly) workaround is recreate the permissions once the copy is complete.

I´ve just created an entry for this in JIRA: http://issues.alfresco.com/jira/browse/ALF-2638