public void apply(Registry repository,Resource resource) { try { for (PropertyData<?> prop: removeProperties) { CommonUtil.removeProperty(repository, resource, prop); } for (PropertyData<?> prop: updateProperties) { CommonUtil.setProperty(repository, resource, prop); } } catch (RegistryException e) { String msg = "Failed to apply properties to the resource"; log.error(msg, e); throw new CmisStorageException(msg, e); } } }
@Override public ErrorInfo extractError(Exception ex) { int statusCode = SC_INTERNAL_SERVER_ERROR; // 500 String exceptionName = "runtime"; if (ex instanceof CmisRuntimeException) { Throwable cause = ex.getCause(); if (cause instanceof RecoverableClientException) { // don't log something harsh in that case statusCode = getHttpStatus((RecoverableClientException) cause); } else { LOG.error(ex.getMessage(), ex); } } else if (ex instanceof CmisStorageException) { LOG.error(ex.getMessage(), ex); statusCode = getErrorCode((CmisStorageException) ex); exceptionName = ((CmisStorageException) ex).getExceptionName(); } else if (ex instanceof CmisBaseException) { statusCode = getErrorCode((CmisBaseException) ex); exceptionName = ((CmisBaseException) ex).getExceptionName(); } else if (ex instanceof IOException) { LOG.warn(ex.getMessage(), ex); } else { LOG.error(ex.getMessage(), ex); } String message = ex.getMessage(); if (!(ex instanceof CmisBaseException)) { message = "An error occurred!"; } return new ErrorInfo(statusCode, exceptionName, message); }
throw new CmisStorageException("Unable to read content: " + e.getMessage(), e);
LOG.error(createLogMessage(ex, request), ex); statusCode = getErrorCode((CmisStorageException) ex); exceptionName = ((CmisStorageException) ex).getExceptionName(); } else if (ex instanceof CmisBaseException) { statusCode = getErrorCode((CmisBaseException) ex);
throw new CmisStorageException("Unable to read content: " + e.getMessage(), e);
LOG.error(createLogMessage(ex, request), ex); statusCode = getErrorCode((CmisStorageException) ex); exceptionName = ((CmisStorageException) ex).getExceptionName(); } else if (ex instanceof CmisBaseException) { statusCode = getErrorCode((CmisBaseException) ex);
return new CmisPermissionDeniedException(message, errorContent, additionalData, t); } else if (CmisStorageException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) { return new CmisStorageException(message, errorContent, additionalData, t); } else if (CmisStreamNotSupportedException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) { return new CmisStreamNotSupportedException(message, errorContent, additionalData, t);
return new CmisRuntimeException(msg, code, errorContent, additionalData); case STORAGE: return new CmisStorageException(msg, code, errorContent, additionalData); case STREAM_NOT_SUPPORTED: return new CmisStreamNotSupportedException(msg, code, errorContent, additionalData);
/** * See CMIS 1.0 section 2.2.4.13 moveObject * * @throws CmisStorageException */ public RegistryObject move(RegistryFolder parent) { try { // move it if target location is not same as source location //TODO String destPath = CommonUtil.getDestPathOfNode(parent.getNode().getPath(), getNodeName()); String srcPath = resource.getPath(); Resource newNode; if (srcPath.equals(destPath)) { newNode = resource; } else { repository.move(srcPath, destPath); newNode = repository.get(destPath); } return create(newNode); } catch (RegistryException e) { String msg = "Failed ot move the object "; log.error(msg, e); throw new CmisStorageException(msg, e); } }
return new CmisPermissionDeniedException(message, errorContent, additionalData, t); } else if (CmisStorageException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) { return new CmisStorageException(message, errorContent, additionalData, t); } else if (CmisStreamNotSupportedException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) { return new CmisStreamNotSupportedException(message, errorContent, additionalData, t);
public RegistryFolder createFolder(RegistryFolder parentFolder, String name, Properties properties) { try { Collection node = repository.newCollection(); String destinationPath = CommonUtil.getTargetPathOfNode(parentFolder, name); repository.put(destinationPath, node); Resource resource = repository.get(destinationPath); // compile the properties RegistryFolder.setProperties(repository, resource, getTypeDefinition(), properties); return getGregNode(resource); } catch (RegistryException e) { log.debug(e.getMessage(), e); throw new CmisStorageException(e.getMessage(), e); } }
cancelCheckout(getRepository(), node); } else { throw new CmisStorageException("Cannot delete checked out document: " + node.getId());
String msg = "Failed to set the properties "; log.error(msg, e); throw new CmisStorageException(msg, e);
default: if (CmisStorageException.EXCEPTION_NAME.equals(exception)) { return new CmisStorageException(message, errorContent, t);
default: if (CmisStorageException.EXCEPTION_NAME.equals(exception)) { return new CmisStorageException(message, errorContent, additionalData, t);
/** * See CMIS 1.0 section 2.2.7.3 checkedIn * * @throws CmisRuntimeException */ public RegistryVersion checkin(Properties properties, ContentStream contentStream, String checkinComment) { Resource node = getNode(); try { if (!isCheckedOut(node)) { throw new CmisStorageException("Not checked out: " + node.getId()); } if (properties != null && !properties.getPropertyList().isEmpty()) { updateProperties(properties); } if (contentStream != null) { setContentStream(contentStream, true); } // todo handle checkinComment Resource resource = checkin(); String pathOfLatestVersion = getRepository().getVersions(resource.getPath())[0]; return new RegistryVersion(getRepository(), resource, pathOfLatestVersion, typeManager, pathManager); } catch (RegistryException e) { String msg = "Failed checkin"; log.error(msg, e); throw new CmisRuntimeException(msg, e); } }
throw new CmisStorageException("Expected " + csa.getLength() + " bytes but retrieved " + (a == null ? -1 : a.length()) + " bytes!");
/** * See CMIS 1.0 section 2.2.4.2 createDocumentFromSource * * @throws CmisStorageException */ public RegistryObject addNodeFromSource(RegistryDocument source, Properties properties) { try { String filename = source.getNodeName(); String destPath = getRepository().copy(source.getNode().getPath(), getNode().getPath() + "/" + filename); RegistryObject gregObject = create(getRepository().get(destPath)); // overlay new properties if (properties != null && properties.getProperties() != null) { updateProperties(gregObject.getNode(), gregObject.getTypeId(), properties); } //session.save(); return gregObject; } catch (RegistryException e) { String msg = "Failed to add the node " + source.getId(); log.error(msg, e); throw new CmisStorageException(msg, e); } }
String msg = "Failed to update properties "; log.error(msg, e); throw new CmisStorageException(msg, e);
throw new CmisStorageException(e.getMessage());