Search in sources :

Example 1 with EntityAcl

use of org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.EntityAcl in project pentaho-platform by pentaho.

the class ExportManifestEntity method getRepositoryFileAcl.

/**
 * Helper method for importing. Returns a FileRepositoryAcl object for the the ExportManifestEntity. Will return null
 * if there is no EntityAcl present.
 *
 * @return RepositoryFile
 */
public RepositoryFileAcl getRepositoryFileAcl() throws ExportManifestFormatException {
    RepositoryFileAcl repositoryFileAcl;
    EntityAcl entityAcl = getEntityAcl();
    if (entityAcl == null) {
        return null;
    }
    ArrayList<RepositoryFileAce> repositoryFileAces = new ArrayList<RepositoryFileAce>();
    RepositoryFileSid rfs;
    for (EntityAcl.Aces ace : entityAcl.getAces()) {
        rfs = getSid(ace.getRecipient(), ace.getRecipientType());
        HashSet<RepositoryFilePermission> permissionSet = new HashSet<RepositoryFilePermission>();
        for (String permission : ace.getPermissions()) {
            permissionSet.add(getPermission(permission));
        }
        RepositoryFileAce repositoryFileAce = new RepositoryFileAce(rfs, EnumSet.copyOf(permissionSet));
        repositoryFileAces.add(repositoryFileAce);
    }
    repositoryFileAcl = new RepositoryFileAcl("", getSid(entityAcl.getOwner(), entityAcl.getOwnerType()), entityAcl.isEntriesInheriting(), repositoryFileAces);
    return repositoryFileAcl;
}
Also used : RepositoryFileSid(org.pentaho.platform.api.repository2.unified.RepositoryFileSid) RepositoryFileAce(org.pentaho.platform.api.repository2.unified.RepositoryFileAce) ArrayList(java.util.ArrayList) RepositoryFilePermission(org.pentaho.platform.api.repository2.unified.RepositoryFilePermission) EntityAcl(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.EntityAcl) RepositoryFileAcl(org.pentaho.platform.api.repository2.unified.RepositoryFileAcl) HashSet(java.util.HashSet)

Example 2 with EntityAcl

use of org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.EntityAcl in project pentaho-platform by pentaho.

the class ExportManifestEntity method createEntityAcl.

private void createEntityAcl(String userId) {
    entityAcl = new EntityAcl();
    entityAcl.setEntriesInheriting(true);
}
Also used : EntityAcl(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.EntityAcl)

Example 3 with EntityAcl

use of org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.EntityAcl in project pentaho-platform by pentaho.

the class ExportManifestEntity method createEntityAcl.

private void createEntityAcl(RepositoryFileAcl repositoryFileAcl) {
    DefaultTenantedPrincipleNameResolver nameResolver = new DefaultTenantedPrincipleNameResolver();
    if (repositoryFileAcl == null) {
        return;
    }
    entityAcl = new EntityAcl();
    entityAcl.setEntriesInheriting(repositoryFileAcl.isEntriesInheriting());
    entityAcl.setOwner(nameResolver.getPrincipleName(repositoryFileAcl.getOwner().getName()));
    entityAcl.setOwnerType(repositoryFileAcl.getOwner().getType().name());
    List<EntityAcl.Aces> aces = entityAcl.getAces();
    aces.clear();
    for (RepositoryFileAce repositoryFileAce : repositoryFileAcl.getAces()) {
        EntityAcl.Aces ace = new EntityAcl.Aces();
        ace.setRecipient(nameResolver.getPrincipleName(repositoryFileAce.getSid().getName()));
        ace.setRecipientType(repositoryFileAce.getSid().getType().name());
        List<String> permissions = ace.getPermissions();
        for (RepositoryFilePermission permission : repositoryFileAce.getPermissions()) {
            permissions.add(permission.toString());
        }
        aces.add(ace);
    }
}
Also used : RepositoryFileAce(org.pentaho.platform.api.repository2.unified.RepositoryFileAce) RepositoryFilePermission(org.pentaho.platform.api.repository2.unified.RepositoryFilePermission) DefaultTenantedPrincipleNameResolver(org.pentaho.platform.security.userroledao.DefaultTenantedPrincipleNameResolver) EntityAcl(org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.EntityAcl)

Aggregations

EntityAcl (org.pentaho.platform.plugin.services.importexport.exportManifest.bindings.EntityAcl)3 RepositoryFileAce (org.pentaho.platform.api.repository2.unified.RepositoryFileAce)2 RepositoryFilePermission (org.pentaho.platform.api.repository2.unified.RepositoryFilePermission)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)1 RepositoryFileSid (org.pentaho.platform.api.repository2.unified.RepositoryFileSid)1 DefaultTenantedPrincipleNameResolver (org.pentaho.platform.security.userroledao.DefaultTenantedPrincipleNameResolver)1