use of org.apache.chemistry.opencmis.commons.data.Acl 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);
}
use of org.apache.chemistry.opencmis.commons.data.Acl in project alfresco-remote-api by Alfresco.
the class TestRemovePermissions method testRemoveAllPermissions_WEBSERVICE_10.
/**
* cmisws?wsdl is not available using jetty in automated test suite should
* be runned using an external alfresco server
*/
// @Test
public void testRemoveAllPermissions_WEBSERVICE_10() {
Folder testFolder = null;
try {
Session session = getWEBSERVICE_10_Session();
if (session == null) {
fail("WEBSERVICE 1.0 session cannot be null");
}
testFolder = createFolder(session, "testRemoveAllPermissions_WEBSERVICE_10");
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.Acl in project alfresco-remote-api by Alfresco.
the class TestRemovePermissions method testRemoveAllPermissions_ATOMPUB_10.
@Test
public void testRemoveAllPermissions_ATOMPUB_10() {
Folder testFolder = null;
try {
Session session = getATOMPUB_10_Session();
if (session == null) {
fail("ATOMPUB 1.0 session cannot be null");
}
testFolder = createFolder(session, "testRemoveAllPermissions_ATOMPUB_10");
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.Acl in project alfresco-remote-api by Alfresco.
the class TestRemovePermissions method testRemoveAllPermissions_BROWSER_11.
@Test
public void testRemoveAllPermissions_BROWSER_11() {
Folder testFolder = null;
try {
Session session = getBROWSER_11_Session();
if (session == null) {
fail("ATOMPUB 1.1 session cannot be null");
}
testFolder = createFolder(session, "testRemoveAllPermissions_BROWSER_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.Acl in project copper-cms by PogeyanOSS.
the class ObjectActor method createItem.
private JSONObject createItem(PostRequest request) throws CmisInvalidArgumentException, CmisObjectNotFoundException, IllegalArgumentException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
String principalId = request.getUserObject().getUserDN();
IUserGroupObject[] groups = request.getUserObject().getGroups();
if (!Helpers.getGroupPermission(permission, groups)) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String folderId = request.getObjectId() != null ? request.getObjectId() : null;
boolean succinct = request.getBooleanParameter(QueryGetRequest.CONTROL_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
Properties prop = CmisPropertyConverter.Impl.createNewProperties(request.getPropertyData(), request.getRepositoryId());
Acl aclImp = CmisUtils.Object.getAcl(request.getAddAcl(), principalId, permission);
String newObjectId = CmisObjectService.Impl.createItem(request.getRepositoryId(), prop, folderId, request.getPolicies(), aclImp, request.getRemoveAcl(), request.getUserObject().getUserDN());
ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_ITEM);
if (object == null) {
throw new CmisRuntimeException("New folder is null!");
}
// return object
JSONObject jsonObject = JSONConverter.convert(object, null, JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
return jsonObject;
}
Aggregations