Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

When adding a ACL to a resource getting UMException: string length wrong

Avatar

Level 2

When I try to add an a ACL to a resource I get the following exception:

com.adobe.repository.bindings.dsc.client.ResourceRepositoryClientException: ALC-REP-101-000: Caught UMException: string length wrong
        at com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient.writeAccessControlList(ResourceRepositoryClient.java:879)

The code that I am using is the following:

// Set up a new access control list to grant access to the
// given user.
AccessControlList acl = new AccessControlList();

// Create permissions for the user
List permissions = new ArrayList();
permissions.add(AccessControlEntry.READ_METADATA_USER_PERM);
permissions.add(AccessControlEntry.READ_CONTENT_USER_PERM);
permissions.add(AccessControlEntry.WRITE_ACL_USER_PERM);
permissions.add(AccessControlEntry.WRITE_USER_PERM);
acl.setPermissionsForUser(user,permissions);

// Set the access control list for the document
repositoryClient.writeAccessControlList(docUri, acl, true);

Can anyone help me find what I am doing wrong?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 4

Instead of passing the username you have to pass the User oid.

You can find the user's oid by using the DirectoryManager API

View solution in original post

5 Replies

Avatar

Former Community Member

Could you post the source in its entirety or send it to stwalker.adobe@gmail.com?

Steve

Avatar

Level 2

Hi Steve,

Here is the source as you requested:

import javax.activation.MimetypesFileTypeMap;
import java.io.*;
import java.util.*;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
import com.adobe.repository.infomodel.*;
import com.adobe.repository.infomodel.bean.*;
import com.adobe.repository.RepositoryException;
import com.adobe.idp.Document;

public class LCRepository
{
    private ServiceClientFactory                     scFactory;
    private ResourceRepositoryClient              repositoryClient;
    private RepositoryInfomodelFactoryBean    infomodelFactory;
    private String                                           currUser;

    static public final String separator = "/";

    public LCfiles(String username,String password)
    {
        currUser = username;

//Set connection properties required to invoke LiveCycle ES2
Properties connectionProps = new Properties();
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://ift-6:1099");

connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL, ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, username);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, password);

        // Create the service client factory
        scFactory = ServiceClientFactory.createInstance(connectionProps);

        // Create a ResourceRepositoryClient object using the service client factory
        repositoryClient = new ResourceRepositoryClient(scFactory);

        // Create a RepositoryInfomodelFactoryBean needed for creating resources
        infomodelFactory = new RepositoryInfomodelFactoryBean(null);
    }
   
   // ..
    // Methods for creating folders, adding documents (resources) to folders,
    // listing folder content, reading a document, etc.
    // ..

   
    /*------------------------------------------------------------------------*/
    public final void grantACL(String docUri,String user) throws RepositoryException
    {
        // Set up a new access control list to grant access to the given user.
        AccessControlList acl = new AccessControlList();

        // Create permissions for the user
        List permissions = new ArrayList();
        permissions.add(AccessControlEntry.READ_METADATA_USER_PERM);
        permissions.add(AccessControlEntry.READ_CONTENT_USER_PERM);
        permissions.add(AccessControlEntry.WRITE_ACL_USER_PERM);
        permissions.add(AccessControlEntry.WRITE_USER_PERM);
        acl.setPermissionsForUser(user,permissions);

        // Set the access control list for the document
        repositoryClient.writeAccessControlList(docUri, acl, true);
    }
}

The grantACL method call would be similar to the following:

lcRepHandle = new LCRepository(userName,password); 

try
{

     lcRepHandle.grantACL(document.getPath(), user);

}
catch (RepositoryException ex)
{
     Logger.getLogger(DocumentProperties.class.getName()).log(Level.SEVERE, null, ex);
}

Where "document" is a Resource and "user" is a string containing a userID.

Thanks

Avatar

Level 2

Anyone knows a solution to this problem. In addition to the code posted above, I try with running the "Quick Start (EJB mode): Managing access control lists using the Java API" and I get the same Exception.

Avatar

Correct answer by
Level 4

Instead of passing the username you have to pass the User oid.

You can find the user's oid by using the DirectoryManager API

Avatar

Level 2

Thanks Chetan.

That solved the problem. The documentation did not make this clear.