cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with the class UnrestrictedSessionRunner

klebervz_
Confirmed Champ
Confirmed Champ

Hi,

I'm using the UnrestrictedSessionRunner class to try to WRITE_SECURITY permission before saving a Document(Task) to a user who is not in the Admin group , the runUnrestricted () method returns a new session without the information we need to grant permission. Here's an example

protected class WritePermission extends UnrestrictedSessionRunner {

    protected WritePermission(CoreSession session) {
        super(session);
        // this.session = documentManager;
    }

    @Override
    public void run() throws ClientException {

        DocumentModel doc = getCurrentDocument();
        ACP acp = null;
        DocumentModel doc2 = session.getDocument(new PathRef(
                doc.getPath().toString()));
        try {
            acp = doc2.getACP();
        } catch (Exception e) {

        }

        if (acp == null) {
            acp = new ACPImpl();
        }
        ACL acl = acp.getOrCreateACL();
        int WorkspaceAdminACEIndex = acl.indexOf(new ACE(
                session.getPrincipal().toString(),
                SecurityConstants.WRITE_SECURITY, true));
        if (WorkspaceAdminACEIndex == -1) {
            ACE ace = new ACE(session.getPrincipal().toString(),
                    SecurityConstants.WRITE_SECURITY, true);
            acl.add(0, ace);
            acp.addACL(acl);
            doc2.setACP(acp, true);
        }
        session.saveDocument(doc2);
        session.save();
    }
}

new WritePermission(documentManager).runUnrestricted(); // calling the runUnrestricted method.

How could grant permission to the user in this new session returned by runUnrestricted () method?

6 REPLIES 6

Florent_Guillau
World-Class Innovator
World-Class Innovator

I don't understand the problem you have.

klebervz_
Confirmed Champ
Confirmed Champ

Hi,

Vladimir_Pasqui
Star Collaborator
Star Collaborator

Hello,

SergioFerreira_
Confirmed Champ
Confirmed Champ

Hi Vladimir and Florent

Florent_Guillau
World-Class Innovator
World-Class Innovator

This was just fixed and will be available in the next 5.8 hotfix (NXP-14939).

Hi, Thank You

Getting started

Attention: Blogs & Forums are in READ-ONLY mode from Oct 9-19 as we transition to our new platform. Learn more.

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.