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);
}
}
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;
}
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;
}
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;
}
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;
}
}
Aggregations