use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderList in project copper-cms by PogeyanOSS.
the class NavigationActor method getChildren.
private JSONObject getChildren(QueryGetRequest request) throws CmisObjectNotFoundException, CmisRuntimeException {
String permission = request.getUserObject().getPermission();
if (!Helpers.checkingUserPremission(permission, "get")) {
throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
}
String folderId = request.getObjectId();
String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
String orderBy = request.getParameter(QueryGetRequest.PARAM_ORDER_BY);
Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
includeAllowableActions = includeAllowableActions == null ? false : includeAllowableActions;
IncludeRelationships includeRelationships = request.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
Boolean includePathSegment = request.getBooleanParameter(QueryGetRequest.PARAM_PATH_SEGMENT);
BigInteger maxItems = request.getBigIntegerParameter(QueryGetRequest.PARAM_MAX_ITEMS);
BigInteger skipCount = request.getBigIntegerParameter(QueryGetRequest.PARAM_SKIP_COUNT);
boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
ObjectInFolderList children = CmisNavigationService.Impl.getChildren(request.getRepositoryId(), folderId, filter, orderBy, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, maxItems, skipCount, null, request.getUserObject());
if (children == null) {
throw new CmisRuntimeException("Children are null!");
}
JSONObject jsonChildren = JSONConverter.convert(children, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat);
return jsonChildren;
}
use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderList in project copper-cms by PogeyanOSS.
the class AbstractSessionTest method checkChildren.
protected CmisTestResult checkChildren(Session session, Folder folder, String message) {
List<CmisTestResult> results = new ArrayList<CmisTestResult>();
CmisTestResult f;
if (folder == null) {
return createResult(FAILURE, "Folder is null!");
}
// getChildren
boolean supportsOrderByName = isOrderByNameSupported(session);
OperationContext orderContext = (supportsOrderByName ? SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME : SELECT_ALL_NO_CACHE_OC);
long childrenCount = 0;
long childrenFolderCount = 0;
ItemIterable<CmisObject> children = folder.getChildren(orderContext);
int orderByNameIssues = 0;
String lastName = null;
for (CmisObject child : children) {
childrenCount++;
if (child instanceof Folder) {
childrenFolderCount++;
}
checkChild(session, results, folder, child);
if (lastName != null && child.getName() != null) {
if (child.getName().compareToIgnoreCase(lastName) < 0) {
orderByNameIssues++;
}
}
lastName = child.getName();
}
if (children.getTotalNumItems() >= 0) {
f = createResult(WARNING, "Number of children doesn't match the reported total number of items!");
addResult(results, assertEquals(childrenCount, children.getTotalNumItems(), null, f));
} else {
addResult(results, createResult(WARNING, "getChildren did not report the total number of items!"));
}
if (supportsOrderByName) {
f = createResult(WARNING, "Children should be ordered by cmis:name, but they are not! (It might be a collation mismtach.)");
addResult(results, assertEquals(0, orderByNameIssues, null, f));
} else {
addResult(results, createResult(INFO, "Repository doesn't support Order By for getChildren()."));
}
// test path segments
ObjectInFolderList pathSegementChildren = session.getBinding().getNavigationService().getChildren(session.getRepositoryInfo().getId(), folder.getId(), "cmis:objectId,cmis:name", null, null, null, null, Boolean.TRUE, BigInteger.valueOf(10), BigInteger.ZERO, null);
if (pathSegementChildren != null && pathSegementChildren.getObjects() != null) {
for (ObjectInFolderData objectInFolder : pathSegementChildren.getObjects()) {
String pathSegement = objectInFolder.getPathSegment();
String objectId = (String) objectInFolder.getObject().getProperties().getProperties().get(PropertyIds.OBJECT_ID).getFirstValue();
if (pathSegement == null) {
addResult(results, createResult(FAILURE, "getChildren omitted path segement! ID: " + objectId));
} else {
CmisObject pathSegementChild = session.getObjectByPath(folder.getPath(), pathSegement);
f = createResult(FAILURE, "Combining the path of the parent folder and the path segement of a child returns a different object! ID: " + objectId);
addResult(results, assertEquals(objectId, pathSegementChild.getId(), null, f));
}
}
}
if (isGetDescendantsSupported(session)) {
long descendantsCount = 0;
List<Tree<FileableCmisObject>> descendants = folder.getDescendants(1, SELECT_ALL_NO_CACHE_OC);
for (Tree<FileableCmisObject> child : descendants) {
descendantsCount++;
if (child == null) {
addResult(results, createResult(FAILURE, "Folder descendants contain a null tree!"));
} else {
checkChild(session, results, folder, child.getItem());
}
}
f = createResult(FAILURE, "Number of descendants doesn't match the number of children returned by getChildren!");
addResult(results, assertEquals(childrenCount, descendantsCount, null, f));
} else {
addResult(results, createResult(SKIPPED, "getDescendants is not supported."));
}
if (isGetFolderTreeSupported(session)) {
long folderTreeCount = 0;
List<Tree<FileableCmisObject>> folderTree = folder.getFolderTree(1, SELECT_ALL_NO_CACHE_OC);
for (Tree<FileableCmisObject> child : folderTree) {
folderTreeCount++;
if (child == null) {
addResult(results, createResult(FAILURE, "Folder tree contains a null tree!"));
} else {
checkChild(session, results, folder, child.getItem());
}
}
f = createResult(FAILURE, "Number of folders doesn't match the number of folders returned by getChildren!");
addResult(results, assertEquals(childrenFolderCount, folderTreeCount, null, f));
} else {
addResult(results, createResult(SKIPPED, "getFolderTree is not supported."));
}
// --- wrap up ---
CmisTestResultImpl result = createResult(getWorst(results), message);
result.getChildren().addAll(results);
return result.getStatus().getLevel() <= OK.getLevel() ? null : result;
}
use of org.apache.chemistry.opencmis.commons.data.ObjectInFolderList in project copper-cms by PogeyanOSS.
the class OperationContextTest method runLowLevelApiTests.
/**
* Checks for change events and path segments.
*/
public void runLowLevelApiTests(Session session, Folder testFolder, Document testDocument) {
CmisTestResult f;
String repositoryId = session.getRepositoryInfo().getId();
String filter = "cmis:objectId,cmis:baseTypeId,cmis:objectTypeId";
// get the object
ObjectData doc1 = session.getBinding().getObjectService().getObject(repositoryId, testDocument.getId(), filter, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, Boolean.FALSE, null);
// check for change events
f = createResult(CmisTestResultStatus.WARNING, "getObject() delivered a change event, which doesn't make sense.");
addResult(assertNull(doc1.getChangeEventInfo(), null, f));
// get the test folder children
ObjectInFolderList children = session.getBinding().getNavigationService().getChildren(repositoryId, testFolder.getId(), filter, null, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null, BigInteger.ZERO, null);
// check for path segments
for (ObjectInFolderData child : children.getObjects()) {
f = createResult(CmisTestResultStatus.WARNING, "getChildren() delivered a path segment, although it hasn't been requested.");
addResult(assertNull(child.getPathSegment(), null, f));
}
// get the document parent
List<ObjectParentData> parents = session.getBinding().getNavigationService().getObjectParents(repositoryId, testDocument.getId(), filter, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null);
// check for relative path segments
for (ObjectParentData parent : parents) {
f = createResult(CmisTestResultStatus.WARNING, "getObjectParents() delivered a relative path segment, although it hasn't been requested.");
addResult(assertNull(parent.getRelativePathSegment(), null, f));
}
}
Aggregations