Search in sources :

Example 1 with CmisRuntimeException

use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project iaf by ibissource.

the class CmisEventDispatcher method contains.

public boolean contains(CmisEvent event) {
    if (StringUtils.isNotEmpty(dispatcherName)) {
        JavaListener listener = JavaListener.getListener(dispatcherName);
        if (listener == null) {
            // Adapter registered but not started
            throw new CmisRuntimeException("unable to bridge cmis request, dispatcher offline");
        }
        HashMap<String, Object> messageContext = new HashMap<>();
        messageContext.put(CMIS_EVENT_KEY, event.getLabel());
        try {
            String result = listener.processRequest(null, event.getLabel(), messageContext);
            // Result should determine if we should proceed, an exception may be thrown.
            return Boolean.parseBoolean(result);
        } catch (ListenerException e) {
            // Append the message so it becomes visible in the soap-fault (when using WS)
            throw new CmisRuntimeException("unable to bridge cmis request: " + e.getMessage(), e);
        }
    } else {
        return eventListeners.containsKey(event);
    }
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) JavaListener(nl.nn.adapterframework.receivers.JavaListener)

Example 2 with CmisRuntimeException

use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project iaf by ibissource.

the class RepositoryConnectorFactory method createService.

protected FilterCmisService createService(CallContext context) {
    BridgedCmisService service = null;
    try {
        service = new BridgedCmisService(context);
        LOG.info("created repository service [" + service + "]");
    } catch (Exception e) {
        throw new CmisRuntimeException("could not create service instance: " + e, e);
    }
    return service;
}
Also used : CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)

Example 3 with CmisRuntimeException

use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project iaf by ibissource.

the class RepositoryConnectorFactory method getService.

@Override
public CmisService getService(CallContext context) {
    if (!CMIS_BRIDGE_ENABLED) {
        throw new CmisRuntimeException("CMIS bridge not enabled");
    }
    if (!CmisEventDispatcher.getInstance().hasEventListeners()) {
        throw new CmisRuntimeException("no CMIS bridge events registered");
    }
    LOG.debug("retrieve repository service");
    // Make sure that each thread in the HTTP CONN POOL has it's own BridgedCmisService
    CallContextAwareCmisService service = threadLocalService.get();
    if (service == null) {
        service = new ConformanceCmisServiceWrapper(createService(context));
        threadLocalService.set(service);
        LOG.debug("stored repository service in local http-conn-thread");
    }
    // Update the CallContext
    service.setCallContext(context);
    return service;
}
Also used : CallContextAwareCmisService(org.apache.chemistry.opencmis.server.support.wrapper.CallContextAwareCmisService) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) ConformanceCmisServiceWrapper(org.apache.chemistry.opencmis.server.support.wrapper.ConformanceCmisServiceWrapper)

Example 4 with CmisRuntimeException

use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project copper-cms by PogeyanOSS.

the class ObjectActor method createDocument.

private JSONObject createDocument(PostRequest request) throws CmisInvalidArgumentException, CmisConstraintException, IllegalArgumentException, CmisRuntimeException {
    String permission = request.getUserObject().getPermission();
    String principalId = request.getUserObject().getUserDN();
    IUserGroupObject[] groupsId = request.getUserObject().getGroups();
    if (!Helpers.getGroupPermission(permission, groupsId)) {
        throw new CmisRuntimeException(request.getUserName() + " is not authorized to applyAcl.");
    }
    String folderId = request.getObjectId() != null ? request.getObjectId() : null;
    VersioningState versioningState = request.getEnumParameter(QueryGetRequest.PARAM_VERSIONIG_STATE, VersioningState.class);
    // String token = request.getParameter(request.PARAM_TOKEN);
    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 = null;
    if (request.getContentStream() == null) {
        newObjectId = CmisObjectService.Impl.createDocument(request.getRepositoryId(), prop, folderId, null, versioningState, request.getPolicies(), aclImp, request.getRemoveAcl(), request.getUserObject().getUserDN());
    } else {
        newObjectId = CmisObjectService.Impl.createDocument(request.getRepositoryId(), prop, folderId, request.getContentStream(), versioningState, request.getPolicies(), aclImp, request.getRemoveAcl(), request.getUserObject().getUserDN());
    }
    ObjectData object = CmisObjectService.Impl.getSimpleObject(request.getRepositoryId(), newObjectId, request.getUserObject().getUserDN(), BaseTypeId.CMIS_DOCUMENT);
    if (object == null) {
        MetricsInputs.markUploadErrorMeter();
        throw new CmisRuntimeException("New document is null!");
    }
    // return object
    JSONObject jsonObject = JSONConverter.convert(object, CmisTypeCacheService.get(request.getRepositoryId()), JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
    return jsonObject;
}
Also used : IUserGroupObject(com.pogeyan.cmis.api.auth.IUserGroupObject) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) VersioningState(org.apache.chemistry.opencmis.commons.enums.VersioningState) Acl(org.apache.chemistry.opencmis.commons.data.Acl) Properties(org.apache.chemistry.opencmis.commons.data.Properties) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Example 5 with CmisRuntimeException

use of org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException in project copper-cms by PogeyanOSS.

the class ObjectActor method getProperties.

private JSONObject getProperties(QueryGetRequest t) throws CmisInvalidArgumentException, IllegalArgumentException, CmisRuntimeException {
    String permission = t.getUserObject().getPermission();
    if (!Helpers.checkingUserPremission(permission, "get")) {
        throw new CmisRuntimeException(t.getUserName() + " is not authorized to applyAcl.");
    }
    String objectId = t.getObjectId();
    ReturnVersion returnVersion = t.getEnumParameter(QueryGetRequest.PARAM_RETURN_VERSION, ReturnVersion.class);
    String filter = t.getParameter(QueryGetRequest.PARAM_FILTER);
    boolean succinct = t.getBooleanParameter(QueryGetRequest.PARAM_SUCCINCT, false);
    DateTimeFormat dateTimeFormat = t.getDateTimeFormatParameter();
    LOG.info("getObject->ObjectID{}", objectId);
    if (returnVersion == ReturnVersion.LATEST || returnVersion == ReturnVersion.LASTESTMAJOR) {
        // TODO: implement version
        return null;
    } else {
        ObjectData object = CmisObjectService.Impl.getObject(t.getRepositoryId(), objectId, filter, true, IncludeRelationships.NONE, "cmis:none", false, false, null, t.getUserObject().getUserDN(), t.getBaseTypeId());
        Properties properties = object.getProperties();
        if (properties == null) {
            throw new CmisRuntimeException("Properties are null!");
        }
        JSONObject result = JSONConverter.convert(properties, objectId.toString(), CmisTypeCacheService.get(t.getRepositoryId()), JSONConverter.PropertyMode.CHANGE, succinct, dateTimeFormat);
        return result;
    }
}
Also used : ReturnVersion(org.apache.chemistry.opencmis.commons.impl.ReturnVersion) CmisRuntimeException(org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException) JSONObject(org.apache.chemistry.opencmis.commons.impl.json.JSONObject) ObjectData(org.apache.chemistry.opencmis.commons.data.ObjectData) Properties(org.apache.chemistry.opencmis.commons.data.Properties) DateTimeFormat(org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)

Aggregations

CmisRuntimeException (org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException)53 DateTimeFormat (org.apache.chemistry.opencmis.commons.enums.DateTimeFormat)35 JSONObject (org.apache.chemistry.opencmis.commons.impl.json.JSONObject)35 ObjectData (org.apache.chemistry.opencmis.commons.data.ObjectData)22 BigInteger (java.math.BigInteger)10 Properties (org.apache.chemistry.opencmis.commons.data.Properties)10 Acl (org.apache.chemistry.opencmis.commons.data.Acl)8 JSONArray (org.apache.chemistry.opencmis.commons.impl.json.JSONArray)8 Holder (org.apache.chemistry.opencmis.commons.spi.Holder)8 IUserGroupObject (com.pogeyan.cmis.api.auth.IUserGroupObject)6 IncludeRelationships (org.apache.chemistry.opencmis.commons.enums.IncludeRelationships)6 CmisInvalidArgumentException (org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException)6 IOException (java.io.IOException)4 Map (java.util.Map)4 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)4 HashMap (java.util.HashMap)3 ObjectList (org.apache.chemistry.opencmis.commons.data.ObjectList)3 TypeDefinition (org.apache.chemistry.opencmis.commons.definitions.TypeDefinition)3 IBaseObject (com.pogeyan.cmis.api.data.IBaseObject)2 InputStream (java.io.InputStream)2