use of org.alfresco.module.org_alfresco_module_rm.capability.Capability in project records-management by Alfresco.
the class RM1008Test method testTransfer.
public void testTransfer() {
final NodeRef transferFolder = doTestInTransaction(new Test<NodeRef>() {
@Override
public NodeRef run() {
NodeRef transferCat = filePlanService.createRecordCategory(filePlan, "transferCat");
Map<QName, Serializable> dsProps = new HashMap<QName, Serializable>(3);
dsProps.put(PROP_DISPOSITION_AUTHORITY, "test");
dsProps.put(PROP_DISPOSITION_INSTRUCTIONS, "test");
dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, false);
DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(transferCat, dsProps);
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff");
adParams.put(PROP_DISPOSITION_DESCRIPTION, "test");
adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0");
dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, "transfer");
adParams.put(PROP_DISPOSITION_DESCRIPTION, "test");
adParams.put(PROP_DISPOSITION_PERIOD, "immediately|0");
dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
return recordFolderService.createRecordFolder(transferCat, "transferFolder");
}
});
final NodeRef transfer = doTestInTransaction(new Test<NodeRef>() {
@Override
public NodeRef run() {
rmActionService.executeRecordsManagementAction(transferFolder, "cutoff");
rmActionService.executeRecordsManagementAction(transferFolder, "transfer");
NodeRef transferContainer = filePlanService.getTransferContainer(filePlan);
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(transferContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
return childAssocs.get(0).getChildRef();
}
@Override
public void test(NodeRef result) throws Exception {
assertNotNull(result);
assertEquals(TYPE_TRANSFER, nodeService.getType(result));
}
});
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.ALLOWED, viewRecords.hasPermission(transfer));
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
return null;
}
}, ADMIN_USER);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
return null;
}
}, myUser);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
filePlanPermissionService.setPermission(filePlan, myUser, FILING);
return null;
}
}, ADMIN_USER);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.READ_RECORDS));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
return null;
}
}, myUser);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
filePlanPermissionService.deletePermission(filePlan, myUser, FILING);
return null;
}
}, ADMIN_USER);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
Capability viewRecords = capabilityService.getCapability("ViewRecords");
assertNotNull(viewRecords);
assertEquals(AccessStatus.DENIED, viewRecords.hasPermission(transfer));
assertEquals(AccessStatus.DENIED, permissionService.hasPermission(transfer, RMPermissionModel.FILING));
return null;
}
}, myUser);
}
use of org.alfresco.module.org_alfresco_module_rm.capability.Capability in project records-management by Alfresco.
the class DeclarativeCapabilityTest method testMoveRecordFolderCapability.
public void testMoveRecordFolderCapability() {
// grab the move record capability
final Capability capability = capabilityService.getCapability("MoveRecordFolder");
assertNotNull(capability);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
// first take a look at just the record
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(record));
assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(rmFolder, moveToCategory));
return null;
}
}, recordsManagerName);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
for (String user : testUsers) {
filePlanPermissionService.setPermission(moveToCategory, user, RMPermissionModel.FILING);
}
return null;
}
}, ADMIN_USER);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(record));
assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord));
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(rmFolder, moveToCategory));
return null;
}
}, recordsManagerName);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(record));
assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(rmFolder, moveToCategory));
return null;
}
}, rmUserName);
}
use of org.alfresco.module.org_alfresco_module_rm.capability.Capability in project records-management by Alfresco.
the class DeclarativeCapabilityTest method testCreateRecordCapability.
/**
* Specific declarative capability tests
*/
public void testCreateRecordCapability() {
final Capability capability = capabilityService.getCapability("CreateRecords");
assertNotNull(capability);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.ALLOWED, capability.hasPermission(record));
assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder));
return null;
}
}, recordsManagerName);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(record));
assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder));
return null;
}
}, rmUserName);
}
use of org.alfresco.module.org_alfresco_module_rm.capability.Capability in project records-management by Alfresco.
the class DeclarativeCapabilityTest method testMoveRecordCapability.
public void testMoveRecordCapability() {
// grab the move record capability
final Capability capability = capabilityService.getCapability("MoveRecords");
assertNotNull(capability);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
// first take a look at just the record
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(record));
assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(declaredRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder));
assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(undeclaredRecord));
// now lets take a look when we know what the destination is
// NOTE: should be denied since we do not have file permission on the destination folder
// despite having the capability!
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(record, moveToFolder));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(declaredRecord, moveToFolder));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(undeclaredRecord, moveToFolder));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(frozenRecord, moveToFolder));
return null;
}
}, recordsManagerName);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
for (String user : testUsers) {
filePlanPermissionService.setPermission(moveToFolder, user, RMPermissionModel.FILING);
}
return null;
}
}, ADMIN_USER);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
// first take a look at just the record
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(record));
assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(declaredRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder));
assertEquals(AccessStatus.UNDETERMINED, capability.hasPermission(undeclaredRecord));
// now lets take a look when we know what the destination is
// NOTE: should be allowed now since we have filling permission on the destination folder
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(record, moveToFolder));
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(declaredRecord, moveToFolder));
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, capability.evaluate(undeclaredRecord, moveToFolder));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(frozenRecord, moveToFolder));
return null;
}
}, recordsManagerName);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
// first take a look at just the record
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(record));
assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecordFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(recordFolderContainsFrozen));
assertEquals(AccessStatus.DENIED, capability.hasPermission(frozenRecord));
assertEquals(AccessStatus.DENIED, capability.hasPermission(closedFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(undeclaredRecord));
// now lets take a look when we know what the destination is
// NOTE: should be allowed now since we have filling permission on the destination folder
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(record, moveToFolder));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(declaredRecord, moveToFolder));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(undeclaredRecord, moveToFolder));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, capability.evaluate(frozenRecord, moveToFolder));
return null;
}
}, rmUserName);
}
use of org.alfresco.module.org_alfresco_module_rm.capability.Capability in project records-management by Alfresco.
the class CompositeCapabilityTest method testUpdate.
public void testUpdate() {
final Capability capability = capabilityService.getCapability("Update");
assertNotNull(capability);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.ALLOWED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.ALLOWED, capability.hasPermission(record));
assertEquals(AccessStatus.ALLOWED, capability.hasPermission(declaredRecord));
return null;
}
}, recordsManagerName);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmContainer));
assertEquals(AccessStatus.DENIED, capability.hasPermission(rmFolder));
assertEquals(AccessStatus.DENIED, capability.hasPermission(record));
assertEquals(AccessStatus.DENIED, capability.hasPermission(declaredRecord));
return null;
}
}, userName);
}
Aggregations