org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Checks if a child of a given type can be added to a given folder.
 */
@SuppressWarnings("unchecked")
public void checkChildObjectType(CMISNodeInfo folderInfo, String childType)
{
    TypeDefinitionWrapper targetType = folderInfo.getType();
    PropertyDefinitionWrapper allowableChildObjectTypeProperty = targetType
            .getPropertyById(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
    List<String> childTypes = (List<String>) allowableChildObjectTypeProperty.getPropertyAccessor().getValue(
            folderInfo);

    if ((childTypes == null) || childTypes.isEmpty())
    {
        return;
    }

    if (!childTypes.contains(childType))
    {
        throw new CmisConstraintException("Objects of type '" + childType + "' cannot be added to this folder!");
    }
}
 
Example #2
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Acl applyAcl(String repositoryId, String objectId, final Acl aces, AclPropagation aclPropagation)
{
    checkRepositoryId(repositoryId);

    // We are spec compliant if we just let it through and the tck will not fail

    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    // relationships don't have ACLs
    if (info.isVariant(CMISObjectVariant.ASSOC))
    {
        throw new CmisConstraintException("Relationships are not ACL controllable!");
    }

    final NodeRef nodeRef = info.getCurrentNodeNodeRef();
    final TypeDefinitionWrapper type = info.getType();

    connector.applyACL(nodeRef, type, aces);

    return connector.getACL(nodeRef, false);
}
 
Example #3
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Acl applyAcl(
        String repositoryId, String objectId, final Acl addAces, final Acl removeAces,
        AclPropagation aclPropagation, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // We are spec compliant if we just let it through and the tck will not fail

    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    // relationships don't have ACLs
    if (info.isVariant(CMISObjectVariant.ASSOC))
    {
        throw new CmisConstraintException("Relationships are not ACL controllable!");
    }

    final NodeRef nodeRef = info.getCurrentNodeNodeRef();
    final TypeDefinitionWrapper type = info.getType();

    connector.applyACL(nodeRef, type, addAces, removeAces);

    return connector.getACL(nodeRef, false);
}
 
Example #4
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void removePolicy(String repositoryId, String policyId, String objectId, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // what kind of object is it?
    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    TypeDefinitionWrapper type = info.getType();
    if (type == null)
    {
        throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
    }

    throw new CmisConstraintException("Object is not policy controllable!");
}
 
Example #5
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void setProperiesToObject(CmisService cmisService, String repositoryId, String objectIdStr, String propertyStr, BigInteger bigIntValue) throws CmisConstraintException{
    Properties properties = cmisService.getProperties(repositoryId, objectIdStr, null, null);
    PropertyIntegerImpl pd = (PropertyIntegerImpl)properties.getProperties().get(propertyStr);
    pd.setValue(bigIntValue);
    
    Collection<PropertyData<?>> propsList = new ArrayList<PropertyData<?>>();
    propsList.add(pd);
    
    Properties newProps = new PropertiesImpl(propsList);
    
    cmisService.updateProperties(repositoryId, new Holder<String>(objectIdStr), null, newProps, null);
}
 
Example #6
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Returns the definition after it has checked if the type can be used for
 * object creation.
 */
public TypeDefinitionWrapper getTypeForCreate(String cmisTypeId, BaseTypeId baseTypeId)
{
    TypeDefinitionWrapper type = getType(cmisTypeId);
    if ((type == null) || (type.getBaseTypeId() != baseTypeId))
    {
        switch (baseTypeId)
        {
        case CMIS_DOCUMENT:
            throw new CmisConstraintException("Type is not a document type!");
        case CMIS_FOLDER:
            throw new CmisConstraintException("Type is not a folder type!");
        case CMIS_RELATIONSHIP:
            throw new CmisConstraintException("Type is not a relationship type!");
        case CMIS_POLICY:
            throw new CmisConstraintException("Type is not a policy type!");
        case CMIS_ITEM:
            throw new CmisConstraintException("Type is not an item type!");
        }
    }

    if (!type.getTypeDefinition(false).isCreatable())
    {
        throw new CmisConstraintException("Type is not creatable!");
    }

    return type;
}
 
Example #7
Source File: AlfrescoCmisExceptionInterceptorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testIntegrityException() throws Throwable
{
    Exception e = new IntegrityException(null);
    Class<?> toCatch = CmisConstraintException.class;
    
    doMockCall(e, toCatch);
    doMockCall(new RuntimeException(new RuntimeException(e)), toCatch);
}
 
Example #8
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void checkDocumentTypeForContent(TypeDefinitionWrapper type)
{
    if (type == null)
    {
        throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
    }
    if (!(type instanceof DocumentTypeDefinitionWrapper))
    {
        throw new CmisStreamNotSupportedException("Object is not a document!");
    }
    if (((DocumentTypeDefinition) type.getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED)
    {
        throw new CmisConstraintException("Document cannot have content!");
    }
}
 
Example #9
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Sets the given ACL.
 */
public void applyACL(NodeRef nodeRef, TypeDefinitionWrapper type, Acl aces)
{
    boolean hasAces = (aces != null) && (aces.getAces() != null) && !aces.getAces().isEmpty();

    if (!hasAces && !permissionService.getInheritParentPermissions(nodeRef))
    {
        return;
    }

    if (!type.getTypeDefinition(false).isControllableAcl())
    {
        throw new CmisConstraintException("Object is not ACL controllable!");
    }

    // remove all permissions
    permissionService.deletePermissions(nodeRef);

    // set new permissions
    for (Ace ace : aces.getAces())
    {
        String principalId = ace.getPrincipalId();
        if (CMIS_USER.equals(principalId))
        {
            principalId = AuthenticationUtil.getFullyAuthenticatedUser();
        }

        List<String> permissions = translatePermissionsFromCMIS(ace.getPermissions());
        for (String permission : permissions)
        {
            permissionService.setPermission(nodeRef, principalId, permission, true);
        }
    }
}
 
Example #10
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void applyPolicies(NodeRef nodeRef, TypeDefinitionWrapper type, List<String> policies)
{
    if ((policies == null) || (policies.isEmpty()))
    {
        return;
    }

    if (!type.getTypeDefinition(false).isControllablePolicy())
    {
        throw new CmisConstraintException("Object is not policy controllable!");
    }

    // nothing else to do...
}
 
Example #11
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * CMIS deleteObject
 * 
 * @param context call context
 * @param objectId identifier of the file/folder
 */
public void deleteObject(CallContext context, String objectId) {
	debug("deleteObject " + objectId);
	validatePermission(objectId, context, Permission.DELETE);

	try {
		// get the file or folder
		PersistentObject object = getObject(objectId);
		if (object == null)
			throw new CmisObjectNotFoundException(String.format("Object %s not found!", objectId));

		if (object instanceof Folder) {
			Folder folder = (Folder) object;
			List<Document> docs = documentDao.findByFolder(folder.getId(), 2);
			List<Folder> folders = folderDao.findByParentId(folder.getId());

			// check if it is a folder and if it is empty
			if (!docs.isEmpty() || !folders.isEmpty())
				throw new CmisConstraintException(String.format("Folder %s is not empty!", objectId));
		}

		if (!delete(object))
			throw new CmisStorageException("Deletion failed!");
	} catch (Throwable t) {
		catchError(t);
	}
}
 
Example #12
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void checkOut(
        String repositoryId, final Holder<String> objectId, ExtensionsData extension,
        final Holder<Boolean> contentCopied)
{
    checkRepositoryId(repositoryId);

    CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");

    // Check for current version
    if (info.isVariant(CMISObjectVariant.CURRENT_VERSION))
    {
        // Good
    }
    else if (info.isVariant(CMISObjectVariant.VERSION))
    {
        throw new CmisInvalidArgumentException("Can't check out an old version of a document");
    }
    else {   
        throw new CmisInvalidArgumentException("Only documents can be checked out! Object was a " + info.getObjectVariant().toString());
    }

    // get object
    final NodeRef nodeRef = info.getNodeRef();

    if (!((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).isVersionable())
    {
        throw new CmisConstraintException("Document is not versionable!");
    }
    
    // check out
    NodeRef pwcNodeRef = connector.getCheckOutCheckInService().checkout(nodeRef);
    CMISNodeInfo pwcNodeInfo = createNodeInfo(pwcNodeRef);
    objectId.setValue(pwcNodeInfo.getObjectId());

    if (contentCopied != null)
    {
        contentCopied.setValue(connector.getFileFolderService().getReader(pwcNodeRef) != null);
    }
}
 
Example #13
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // get node ref
    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    if (!info.isDocument())
    {
        throw new CmisInvalidArgumentException("Object is not a document!");
    }

    final NodeRef nodeRef = info.getNodeRef();

    // get the folder node ref
    final NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef();

    // check primary parent
    if (connector.getNodeService().getPrimaryParent(nodeRef).getParentRef().equals(folderNodeRef))
    {
        throw new CmisConstraintException(
                "Unfiling from primary parent folder is not supported! Use deleteObject() instead.");
    }

    connector.getNodeService().removeChild(folderNodeRef, nodeRef);
}
 
Example #14
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public String createDocument(
        String repositoryId, final Properties properties, String folderId,
        final ContentStream contentStream, VersioningState versioningState, final List<String> policies,
        final Acl addAces, final Acl removeAces, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);
    
    // get the parent folder node ref
    final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Parent folder");

    // get name and type
    final String name = connector.getNameProperty(properties, null);
    final String objectTypeId = connector.getObjectTypeIdProperty(properties);
    final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_DOCUMENT);
    
    connector.checkChildObjectType(parentInfo, type.getTypeId());

    DocumentTypeDefinition docType = (DocumentTypeDefinition) type.getTypeDefinition(false);

    if ((docType.getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED) && (contentStream != null))
    {
        throw new CmisConstraintException("This document type does not support content!");
    }

    if ((docType.getContentStreamAllowed() == ContentStreamAllowed.REQUIRED) && (contentStream == null))
    {
        throw new CmisConstraintException("This document type does requires content!");
    }

    if (!docType.isVersionable() && (versioningState != VersioningState.NONE))
    {
        throw new CmisConstraintException("This document type is not versionable!");
    }
    
    versioningState = getDocumentDefaultVersioningState(versioningState, type);

    FileInfo fileInfo = connector.getFileFolderService().create(
            parentInfo.getNodeRef(), name, type.getAlfrescoClass());
    NodeRef nodeRef = fileInfo.getNodeRef();
    connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
    connector.applyPolicies(nodeRef, type, policies);
    connector.applyACL(nodeRef, type, addAces, removeAces);

    // handle content
    if (contentStream != null)
    {
        // write content
        String mimeType = parseMimeType(contentStream);
        String encoding = getEncoding(contentStream.getStream(), mimeType);
        ContentWriter writer = connector.getFileFolderService().getWriter(nodeRef);
        writer.setMimetype(mimeType);
        writer.setEncoding(encoding);
        writer.putContent(contentStream.getStream());
    }

    connector.extractMetadata(nodeRef);

    // generate "doclib" thumbnail asynchronously
    connector.createThumbnails(nodeRef, Collections.singleton("doclib"));

    connector.applyVersioningState(nodeRef, versioningState);

    String objectId = connector.createObjectId(nodeRef);

    connector.getActivityPoster().postFileFolderAdded(nodeRef);

    return objectId;
}
 
Example #15
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public String createRelationship(
        String repositoryId, Properties properties, List<String> policies, Acl addAces,
        Acl removeAces, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // get type
    String objectTypeId = connector.getObjectTypeIdProperty(properties);
    final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_RELATIONSHIP);

    // get source object
    String sourceId = connector.getSourceIdProperty(properties);
    CMISNodeInfo sourceInfo = getOrCreateNodeInfo(sourceId, "Source");

    if (!sourceInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !sourceInfo.isVariant(CMISObjectVariant.FOLDER) && !sourceInfo.isVariant(CMISObjectVariant.ITEM))
    {
        throw new CmisInvalidArgumentException("Source is not the latest version of a document, a folder or an item object!");
    }

    final NodeRef sourceNodeRef = sourceInfo.getNodeRef();

    // get target object
    String targetId = connector.getTargetIdProperty(properties);
    CMISNodeInfo targetInfo = getOrCreateNodeInfo(targetId, "Target");

    if (!targetInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !targetInfo.isVariant(CMISObjectVariant.FOLDER) && !targetInfo.isVariant(CMISObjectVariant.ITEM))
    {
        throw new CmisInvalidArgumentException(
                "Target is not the latest version of a document, a folder or an item object!!");
    }

    final NodeRef targetNodeRef = targetInfo.getNodeRef();

    // check policies and ACLs
    if ((policies != null) && (!policies.isEmpty()))
    {
        throw new CmisConstraintException("Relationships are not policy controllable!");
    }

    if ((addAces != null) && (addAces.getAces() != null) && (!addAces.getAces().isEmpty()))
    {
        throw new CmisConstraintException("Relationships are not ACL controllable!");
    }

    if ((removeAces != null) && (removeAces.getAces() != null) && (!removeAces.getAces().isEmpty()))
    {
        throw new CmisConstraintException("Relationships are not ACL controllable!");
    }

    // create relationship
    // ALF-10085 : disable auditing behaviour for this use case
    boolean wasEnabled = connector.disableBehaviour(ContentModel.ASPECT_AUDITABLE, sourceNodeRef);        // Lasts for txn
    try
    {
        AssociationRef assocRef = connector.getNodeService().createAssociation(
                sourceNodeRef, targetNodeRef, type.getAlfrescoClass());

        return CMISConnector.ASSOC_ID_PREFIX + assocRef.getId();
    }
    finally
    {
        if(wasEnabled)
        {
            connector.enableBehaviour(ContentModel.ASPECT_AUDITABLE, sourceNodeRef);
        }
    }
}
 
Example #16
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public String createDocumentFromSource(
        String repositoryId, String sourceId, final Properties properties,
        String folderId, VersioningState versioningState, final List<String> policies, final Acl addAces,
        final Acl removeAces, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // get the parent folder node ref
    final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Parent folder");

    // get source
    CMISNodeInfo info = getOrCreateNodeInfo(sourceId, "Source");

    // check source
    if (info.isVariant(CMISObjectVariant.ASSOC))
    {
        throw new CmisConstraintException("Source object is not a document!");
    }

    final NodeRef sourceNodeRef = info.getNodeRef();
    if (!info.isDocument())
    {
        throw new CmisConstraintException("Source object is not a document!");
    }
    
    // get name and type
    final String name = connector.getNameProperty(properties, info.getName());

    final TypeDefinitionWrapper type = info.getType();
    connector.checkChildObjectType(parentInfo, type.getTypeId());
    
    versioningState = getDocumentDefaultVersioningState(versioningState, type);

    try
    {
        FileInfo fileInfo = connector.getFileFolderService().copy(
                sourceNodeRef, parentInfo.getNodeRef(), name);
        NodeRef nodeRef = fileInfo.getNodeRef();
        connector.setProperties(nodeRef, type, properties, new String[] {
                PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
        connector.applyPolicies(nodeRef, type, policies);
        connector.applyACL(nodeRef, type, addAces, removeAces);
        
        connector.extractMetadata(nodeRef);
        connector.createThumbnails(nodeRef, Collections.singleton("doclib"));

        connector.applyVersioningState(nodeRef, versioningState);
        
        connector.getActivityPoster().postFileFolderAdded(nodeRef);
        
        return connector.createObjectId(nodeRef);
    }
    catch (FileNotFoundException e)
    {
        throw new CmisContentAlreadyExistsException("An object with this name already exists!", e);
    }
}
 
Example #17
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private List<String> translatePermissionsFromCMIS(List<String> permissions)
{
    List<String> result = new ArrayList<String>();

    if (permissions == null)
    {
        return result;
    }

    for (String permission : permissions)
    {
        if (permission == null)
        {
            throw new CmisConstraintException("Invalid null permission!");
        }

        if (BasicPermissions.READ.equals(permission))
        {
            result.add(PermissionService.READ);
        }
        else if (BasicPermissions.WRITE.equals(permission))
        {
            result.add(PermissionService.WRITE);
        }
        else if (BasicPermissions.ALL.equals(permission))
        {
            result.add(PermissionService.ALL_PERMISSIONS);
        }
        else if (!permission.startsWith("{"))
        {
            result.add(permission);
        }
        else
        {
            int sepIndex = permission.lastIndexOf('.');
            if (sepIndex == -1)
            {
                result.add(permission);
            }
            else
            {
                result.add(permission.substring(sepIndex + 1));
            }
        }
    }

    return result;
}
 
Example #18
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Gets the content from the repository.
 */
public ContentStream getContentStream(CMISNodeInfo info, String streamId, BigInteger offset, BigInteger length)
{
    // get the type and check if the object can have content
    TypeDefinitionWrapper type = info.getType();
    checkDocumentTypeForContent(type);

    // looks like a document, now get the content
    ContentStreamImpl result = new ContentStreamImpl();
    result.setFileName(info.getName());

    // if streamId is set, fetch other content
    NodeRef streamNodeRef = info.getNodeRef();
    if ((streamId != null) && (streamId.length() > 0))
    {
        CMISNodeInfo streamInfo = createNodeInfo(streamId);
        if (!streamInfo.isVariant(CMISObjectVariant.CURRENT_VERSION))
        {
            throw new CmisInvalidArgumentException("Stream id is invalid: " + streamId + ", expected variant " + CMISObjectVariant.CURRENT_VERSION + ", got variant " + streamInfo.getObjectVariant());
        }

        streamNodeRef = streamInfo.getNodeRef();
        type = streamInfo.getType();
        checkDocumentTypeForContent(type);
    }

    // get the stream now
    try
    {
        ContentReader contentReader = contentService.getReader(streamNodeRef, ContentModel.PROP_CONTENT);
        if (contentReader == null)
        {
            throw new CmisConstraintException("Document has no content!");
        }

        result.setMimeType(contentReader.getMimetype());
        long contentSize = contentReader.getSize();

        if ((offset == null) && (length == null))
        {
            result.setStream(contentReader.getContentInputStream());
            result.setLength(BigInteger.valueOf(contentSize));
            publishReadEvent(streamNodeRef, info.getName(), result.getMimeType(), contentSize, contentReader.getEncoding(), null);
        }
        else
        {
            long off = (offset == null ? 0 : offset.longValue());
            long len = (length == null ? contentSize : length.longValue());
            if (off + len > contentSize)
            {
                len = contentReader.getSize() - off;
            }

            result.setStream(new RangeInputStream(contentReader.getContentInputStream(), off, len));
            result.setLength(BigInteger.valueOf(len));
            publishReadEvent(streamNodeRef, info.getName(), result.getMimeType(), contentSize, contentReader.getEncoding(), off+" - "+len);
        }
    }
    catch (Exception e)
    {
        if (e instanceof CmisBaseException)
        {
            throw (CmisBaseException) e;
        }
        else
        {
            StringBuilder msg = new StringBuilder("Failed to retrieve content: " + e.getMessage());
            Throwable cause = e.getCause();
            if(cause != null)
            {
                // add the cause to the CMIS exception
                msg.append(", ");
                msg.append(cause.getMessage());
            }
            throw new CmisRuntimeException(msg.toString(), e);
        }
    }

    return result;
}
 
Example #19
Source File: AlfrescoCmisExceptionInterceptor.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Object invoke(MethodInvocation mi) throws Throwable
{
    try
    {
        return mi.proceed();
    }
    catch (Exception e)
    {
        // We dig into the exception to see if there is anything of interest to CMIS
        Throwable cmisAffecting = ExceptionStackUtil.getCause(e, EXCEPTIONS_OF_INTEREST);
        
        if (cmisAffecting == null)
        {
            // The exception is not something that CMIS needs to handle in any special way
            if (e instanceof CmisBaseException)
            {
                throw (CmisBaseException) e;
            }
            else
            {
                throw new CmisRuntimeException(e.getMessage(), e);
            }
        }
        // All other exceptions are carried through with full stacks but treated as the exception of interest
        else if (cmisAffecting instanceof AuthenticationException)
        {
            throw new CmisPermissionDeniedException(cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof CheckOutCheckInServiceException)
        {
            throw new CmisVersioningException("Check out failed: " + cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof FileExistsException)
        {
            throw new CmisContentAlreadyExistsException("An object with this name already exists: " + cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof IntegrityException)
        {
            throw new CmisConstraintException("Constraint violation: " + cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof AccessDeniedException)
        {
            throw new CmisPermissionDeniedException("Permission denied: " + cmisAffecting.getMessage(), e);
        }
        else if (cmisAffecting instanceof NodeLockedException)
        {
            throw new CmisUpdateConflictException("Update conflict: " + cmisAffecting.getMessage(), e);
        }
        else
        {
            // We should not get here, so log an error but rethrow to have CMIS handle the original cause
            logger.error("Exception type not handled correctly: " + e.getClass().getName());
            throw new CmisRuntimeException(e.getMessage(), e);
        }
    }
}