use of org.apache.chemistry.opencmis.commons.data.ObjectData in project copper-cms by PogeyanOSS.
the class CreateAndDeletePolicyTest method run.
@Override
public void run(Session session) {
if (hasPolicies(session)) {
CmisTestResult f;
// create a test folder
Folder testFolder = createTestFolder(session);
try {
// create policy object
Policy policy = createPolicy(session, testFolder, "testPolicy", "TCK Test Policy");
// create document and apply policy
Document doc = createDocument(session, testFolder, "testDocument", "Policy Test");
if (Boolean.TRUE.equals(doc.getType().isControllablePolicy())) {
doc.applyPolicy(policy);
// check if policy has been applied
List<Policy> policies1 = doc.getPolicies();
boolean found1 = false;
for (Policy p : policies1) {
if (p.getId().equals(policy.getId())) {
found1 = true;
break;
}
}
f = createResult(FAILURE, "Policy has not been applied to document! Policy Id: " + policy.getId() + ", Doc Id: " + doc.getId());
addResult(assertIsTrue(found1, null, f));
// get the policies
List<ObjectData> policiesData2 = session.getBinding().getPolicyService().getAppliedPolicies(session.getRepositoryInfo().getId(), doc.getId(), "*", null);
boolean found2 = false;
if (policiesData2 != null && !policiesData2.isEmpty()) {
for (ObjectData p : policiesData2) {
if (p.getId().equals(policy.getId())) {
found2 = true;
break;
}
}
}
f = createResult(FAILURE, "Applied policy is not returned by the repository! Policy Id: " + policy.getId() + ", Doc Id: " + doc.getId());
addResult(assertIsTrue(found2, null, f));
// remove policy
doc.removePolicy(policy);
// check if policy has been applied
List<Policy> policies3 = doc.getPolicies();
if (policies3 != null) {
boolean found3 = false;
for (Policy p : policies3) {
if (p.getId().equals(policy.getId())) {
found3 = true;
break;
}
}
f = createResult(FAILURE, "Policy has not been removed from document! Policy Id: " + policy.getId() + ", Doc Id: " + doc.getId());
addResult(assertIsFalse(found3, null, f));
}
} else {
addResult(createResult(INFO, "Document type " + doc.getType().getId() + " does not allow applying and removing policies. Choose a different document type for this test."));
}
// delete document
deleteObject(doc);
// delete policy object
deleteObject(policy);
} finally {
// delete the test folder
deleteTestFolder();
}
} else {
addResult(createResult(SKIPPED, "Policies not supported. Test skipped!"));
}
}
use of org.apache.chemistry.opencmis.commons.data.ObjectData in project structr by structr.
the class CMISNavigationService method getFolderParent.
@Override
public ObjectData getFolderParent(final String repositoryId, final String folderId, final String propertyFilter, final ExtensionsData extension) {
final App app = StructrApp.getInstance();
ObjectData result = null;
try (final Tx tx = app.tx()) {
final AbstractFile graphObject = app.get(AbstractFile.class, folderId);
if (graphObject != null) {
final Folder parent = graphObject.getParent();
if (parent != null) {
result = CMISObjectWrapper.wrap(parent, propertyFilter, false);
}
}
tx.success();
} catch (Throwable t) {
logger.warn("", t);
}
if (result != null) {
return result;
}
return null;
}
Aggregations