Search in sources :

Example 1 with ObjectParentData

use of org.apache.chemistry.opencmis.commons.data.ObjectParentData in project structr by structr.

the class CMISNavigationService method getObjectParents.

@Override
public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String propertyFilter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includeRelativePathSegment, ExtensionsData extension) {
    final App app = StructrApp.getInstance();
    try (final Tx tx = app.tx()) {
        final List<ObjectParentData> data = new LinkedList<>();
        final AbstractFile graphObject = app.get(AbstractFile.class, objectId);
        final Folder parent = graphObject.getParent();
        final ObjectData element = parent != null ? CMISObjectWrapper.wrap(parent, propertyFilter, includeAllowableActions) : new CMISRootFolder(propertyFilter, includeAllowableActions);
        final ObjectParentDataImpl impl = new ObjectParentDataImpl(element);
        impl.setRelativePathSegment(graphObject.getProperty(AbstractNode.name));
        data.add(impl);
        tx.success();
        return data;
    } catch (Throwable t) {
        logger.warn("", t);
    }
    return null;
}
Also used : StructrApp(org.structr.core.app.StructrApp) App(org.structr.core.app.App) ObjectParentData(org.apache.chemistry.opencmis.commons.data.ObjectParentData) AbstractFile(org.structr.web.entity.AbstractFile) Tx(org.structr.core.graph.Tx) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) CMISRootFolder(org.structr.files.cmis.repository.CMISRootFolder) CMISRootFolder(org.structr.files.cmis.repository.CMISRootFolder) Folder(org.structr.web.entity.Folder) ObjectParentDataImpl(org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectParentDataImpl) LinkedList(java.util.LinkedList)

Example 2 with ObjectParentData

use of org.apache.chemistry.opencmis.commons.data.ObjectParentData in project copper-cms by PogeyanOSS.

the class NavigationActor method getParents.

private JSONArray getParents(QueryGetRequest request) throws CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "get")) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    String objectId = request.getObjectId();
    String filter = request.getParameter(QueryGetRequest.PARAM_FILTER);
    Boolean includeAllowableActions = request.getBooleanParameter(QueryGetRequest.PARAM_ALLOWABLE_ACTIONS);
    IncludeRelationships includeRelationships = request.getEnumParameter(QueryGetRequest.PARAM_RELATIONSHIPS, IncludeRelationships.class);
    String renditionFilter = request.getParameter(QueryGetRequest.PARAM_RENDITION_FILTER);
    Boolean includeRelativePathSegment = request.getBooleanParameter(QueryGetRequest.PARAM_RELATIVE_PATH_SEGMENT);
    boolean succinct = request.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = request.getDateTimeFormatParameter();
    List<ObjectParentData> parents = CmisNavigationService.Impl.getObjectParents(request.getRepositoryId(), objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includeRelativePathSegment, null, request.getUserObject().getUserDN());
    if (parents == null) {
        throw new CmisRuntimeException("Parents are null!");
    }
    JSONArray jsonParents = new JSONArray();
    for (ObjectParentData parent : parents) {
        jsonParents.add(JSONConverter.convert(parent, CmisTypeCacheService.get(request.getRepositoryId()), succinct, dateTimeFormat));
    }
    return jsonParents;
}
Also used : ObjectParentData(org.apache.chemistry.opencmis.commons.data.ObjectParentData) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONArray(org.apache.chemistry.opencmis.commons.impl.json.JSONArray) IncludeRelationships(org.apache.chemistry.opencmis.commons.enums.IncludeRelationships) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 3 with ObjectParentData

use of org.apache.chemistry.opencmis.commons.data.ObjectParentData 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));
    }
}
Also used : ObjectParentData(org.apache.chemistry.opencmis.commons.data.ObjectParentData) ObjectInFolderList(org.apache.chemistry.opencmis.commons.data.ObjectInFolderList) CmisTestResult(org.apache.chemistry.opencmis.tck.CmisTestResult) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) ObjectInFolderData(org.apache.chemistry.opencmis.commons.data.ObjectInFolderData)

Aggregations

ObjectParentData (org.apache.chemistry.opencmis.commons.data.ObjectParentData)3 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)2 LinkedList (java.util.LinkedList)1 ObjectInFolderData (org.apache.chemistry.opencmis.commons.data.ObjectInFolderData)1 ObjectInFolderList (org.apache.chemistry.opencmis.commons.data.ObjectInFolderList)1 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)1 IncludeRelationships (org.apache.chemistry.opencmis.commons.enums.IncludeRelationships)1 CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)1 ObjectParentDataImpl (org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectParentDataImpl)1 JSONArray (org.apache.chemistry.opencmis.commons.impl.json.JSONArray)1 CmisTestResult (org.apache.chemistry.opencmis.tck.CmisTestResult)1 App (org.structr.core.app.App)1 StructrApp (org.structr.core.app.StructrApp)1 Tx (org.structr.core.graph.Tx)1 CMISRootFolder (org.structr.files.cmis.repository.CMISRootFolder)1 AbstractFile (org.structr.web.entity.AbstractFile)1 Folder (org.structr.web.entity.Folder)1