use of org.apache.chemistry.opencmis.commons.data.Ace in project alfresco-remote-api by Alfresco.
the class TestRemovePermissions method testRemoveAllPermissions_ATOMPUB_11.
@Test
public void testRemoveAllPermissions_ATOMPUB_11() {
Folder testFolder = null;
try {
Session session = getATOMPUB_11_Session();
if (session == null) {
fail("ATOMPUB 1.1 session cannot be null");
}
testFolder = createFolder(session, "testRemoveAllPermissions_ATOMPUB_11");
List<Ace> acl = create2TestACLs(session);
// adding new ACE
testFolder.addAcl(acl, AclPropagation.PROPAGATE);
Acl allacl = session.getAcl(session.createObjectId(testFolder.getId()), false);
int oldSize = allacl.getAces().size();
// Removing ALL ACEs
Acl newAcl = testFolder.removeAcl(allacl.getAces(), AclPropagation.PROPAGATE);
int newsize = newAcl.getAces().size();
System.out.println("Old ace size -->" + oldSize);
System.out.println("New ace size --> " + newsize);
assertTrue(newsize == oldSize - acl.size());
} catch (Exception ex) {
fail(ex.getMessage());
} finally {
if (testFolder != null) {
testFolder.delete();
}
}
}
use of org.apache.chemistry.opencmis.commons.data.Ace in project SearchServices by Alfresco.
the class CMISDataCreatorTest method testCreateLots.
public void testCreateLots() throws Exception {
Session session = getSession("admin", "admin");
Folder root = session.getRootFolder();
String folderNameBase = getRootFolderName();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
properties.put(PropertyIds.NAME, folderNameBase);
Folder base = root.createFolder(properties);
for (int i = 0; i < 10; i++) {
AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl("" + i + i + i);
List<String> permissions = new ArrayList<String>(1);
permissions.add(BasicPermissions.ALL);
List<Ace> addAces = new ArrayList<Ace>(1);
addAces.add(new AccessControlEntryImpl(principal, permissions));
base.addAcl(addAces, AclPropagation.PROPAGATE);
}
Thread last = null;
for (int i = 0; i < 10; i++) {
Creator creator = new Creator(base.getPath(), i);
Thread thread = new Thread(creator);
thread.start();
last = thread;
}
if (last != null) {
last.join();
}
ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false);
assertTrue(result.getTotalNumItems() > 0);
// result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false);
// assertTrue(result.getTotalNumItems() > 0);
}
use of org.apache.chemistry.opencmis.commons.data.Ace in project copper-cms by PogeyanOSS.
the class CmisRequestParameter method createAddAcl.
public Acl createAddAcl(ControlParser controlParser, PostRequest request) {
List<String> principals = controlParser.getValues(QueryGetRequest.CONTROL_ADD_ACE_PRINCIPAL);
if (principals == null) {
return null;
}
List<Ace> aces = new ArrayList<Ace>();
int i = 0;
for (String principalId : principals) {
aces.add(new AccessControlEntryImpl(new AccessControlPrincipalDataImpl(principalId), controlParser.getValues(QueryGetRequest.CONTROL_ADD_ACE_PERMISSION, i)));
i++;
}
return new AccessControlListImpl(aces);
}
use of org.apache.chemistry.opencmis.commons.data.Ace in project copper-cms by PogeyanOSS.
the class CmisRequestParameter method createRemoveAcl.
public Acl createRemoveAcl(ControlParser controlParser, PostRequest request) {
List<String> principals = controlParser.getValues(QueryGetRequest.CONTROL_REMOVE_ACE_PRINCIPAL);
if (principals == null) {
return null;
}
List<Ace> aces = new ArrayList<Ace>();
int i = 0;
for (String principalId : principals) {
aces.add(new AccessControlEntryImpl(new AccessControlPrincipalDataImpl(principalId), controlParser.getValues(QueryGetRequest.CONTROL_REMOVE_ACE_PERMISSION, i)));
i++;
}
return new AccessControlListImpl(aces);
}
use of org.apache.chemistry.opencmis.commons.data.Ace in project iaf by ibissource.
the class FilterCmisService method applyAcl.
@Override
public Acl applyAcl(String repositoryId, String objectId, Acl aces, AclPropagation aclPropagation) {
Acl orgAcl = getAclService().getAcl(repositoryId, objectId, Boolean.FALSE, null);
Acl removeAces = null;
if (orgAcl != null && orgAcl.getAces() != null && !orgAcl.getAces().isEmpty()) {
List<Ace> directAces = new ArrayList<Ace>();
for (Ace ace : orgAcl.getAces()) {
if (ace.isDirect()) {
directAces.add(ace);
}
}
if (!directAces.isEmpty()) {
removeAces = new AccessControlListImpl(directAces);
}
}
return getAclService().applyAcl(repositoryId, objectId, aces, removeAces, aclPropagation, null);
}
Aggregations