当前位置: 首页>>代码示例>>Java>>正文


Java IntegrityException类代码示例

本文整理汇总了Java中org.alfresco.repo.node.integrity.IntegrityException的典型用法代码示例。如果您正苦于以下问题:Java IntegrityException类的具体用法?Java IntegrityException怎么用?Java IntegrityException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IntegrityException类属于org.alfresco.repo.node.integrity包,在下文中一共展示了IntegrityException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unlock

import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
@Override
public Node unlock(String nodeId, Parameters parameters)
{
    NodeRef nodeRef = validateOrLookupNode(nodeId, null);

    if (isSpecialNode(nodeRef, getNodeType(nodeRef)))
    {
        throw new PermissionDeniedException("Current user doesn't have permission to unlock node " + nodeId);
    }
    if (!lockService.isLocked(nodeRef))
    {
        throw new IntegrityException("Can't unlock node " + nodeId + " because it isn't locked", null);
    }
    
    lockService.unlock(nodeRef);
    return getFolderOrDocument(nodeId, parameters);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:18,代码来源:NodesImpl.java

示例2: restoreArchivedNode

import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
@Override
public Node restoreArchivedNode(String archivedId)
{
    //First check the node is valid and has been archived.
    NodeRef validatedNodeRef = nodes.validateNode(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, archivedId);
    RestoreNodeReport restored = nodeArchiveService.restoreArchivedNode(validatedNodeRef);
    switch (restored.getStatus())
    {
        case SUCCESS:
            return nodes.getFolderOrDocumentFullInfo(restored.getRestoredNodeRef(), null, null, null, null);
        case FAILURE_PERMISSION:
            throw new PermissionDeniedException();
        case FAILURE_INTEGRITY:
            throw new IntegrityException("Restore failed due to an integrity error", null);
        case FAILURE_DUPLICATE_CHILD_NODE_NAME:
            throw new ConstraintViolatedException("Name already exists in target");
        case FAILURE_INVALID_ARCHIVE_NODE:
            throw new EntityNotFoundException(archivedId);
        case FAILURE_INVALID_PARENT:
            throw new NotFoundException("Invalid parent id "+restored.getTargetParentNodeRef());
        default:
            throw new ApiException("Unable to restore node "+archivedId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:DeletedNodesImpl.java

示例3: testDeleteWorkingCopyLinkAssociation

import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
/**
 * MNT-2641 The cm:workingcopylink association cannot be removed
 */
public void testDeleteWorkingCopyLinkAssociation()
{
 // Create a FolderA
    final NodeRef folderA = createFolder("DeleteOriginalAssociationFromCopy_" + GUID.generate());

    // Create content in FolderA
    final NodeRef orig = createContent("original_" + GUID.generate(), folderA);

    // Check out the document
    NodeRef workingCopy = this.cociService.checkout(orig);
    assertNotNull(workingCopy);
    
    // Check that the cm:original association is present
    assertEquals("Did not find cm:workingcopylink",
            1, nodeService.getSourceAssocs(workingCopy, ContentModel.ASSOC_WORKING_COPY_LINK).size());
    
    setComplete();
    endTransaction();
    
    // try to delete cm:workingcopylink association - must be denied
    try
    {
        nodeService.removeAssociation(orig, workingCopy, ContentModel.ASSOC_WORKING_COPY_LINK);
        fail("Should not have been allowed to remove the association from working copy to original");
    }
    catch (IntegrityException e)
    {
        // Expected
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:34,代码来源:CheckOutCheckInServiceImplTest.java

示例4: testIntegrityException

import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
@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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:AlfrescoCmisExceptionInterceptorTest.java

示例5: invoke

import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:57,代码来源:AlfrescoCmisExceptionInterceptor.java

示例6: testMailNotSentIfRollback

import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
public void testMailNotSentIfRollback()
{
    this.nodeService.addAspect(this.nodeRef, ContentModel.ASPECT_LOCKABLE, null);
    
    Map<String, Serializable> params = new HashMap<String, Serializable>(1);
    params.put(MailActionExecuter.PARAM_TO, "[email protected]");
    params.put(MailActionExecuter.PARAM_SUBJECT, "testMailNotSentIfRollback()");
    params.put(MailActionExecuter.PARAM_TEXT, "This email should NOT have been sent.");
    
    Rule rule = createRule(
            RuleType.INBOUND, 
            MailActionExecuter.NAME, 
            params, 
            NoConditionEvaluator.NAME, 
            null);
    
    this.ruleService.saveRule(this.nodeRef, rule);

    String illegalName = "MyName.txt "; // space at end
    
    MailActionExecuter mailService = (MailActionExecuter) ((ApplicationContextFactory) applicationContext
                .getBean("OutboundSMTP")).getApplicationContext().getBean("mail");
    mailService.setTestMode(true);
    mailService.clearLastTestMessage();
    
    try
    {
        this.nodeService.createNode(
                this.nodeRef,
                ContentModel.ASSOC_CHILDREN,                
                QName.createQName(TEST_NAMESPACE, "children"),
                ContentModel.TYPE_CONTENT,
                makeNameProperty(illegalName)).getChildRef();
        fail("createNode() should have failed.");
    }
    catch(IntegrityException e)
    {
        // Expected exception.
        // An email should NOT appear in the recipients email
    }
    
    MimeMessage lastMessage = mailService.retrieveLastTestMessage();
    assertNull("Message should NOT have been sent", lastMessage);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:45,代码来源:RuleServiceCoverageTest.java

示例7: delete

import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
@Override
@WebApiDescription(title = "Delete version")
public void delete(String nodeId, String versionId, Parameters parameters)
{
    Version v = findVersion(nodeId, versionId);

    // live (aka versioned) nodeRef
    NodeRef nodeRef = v.getVersionedNodeRef();

    if (sr.getPermissionService().hasPermission(nodeRef, PermissionService.DELETE) != AccessStatus.ALLOWED)
    {
        throw new PermissionDeniedException("Cannot delete version");
    }

    versionService.deleteVersion(nodeRef, v);

    Map<QName, Serializable> props = sr.getNodeService().getProperties(nodeRef);
    if (props.get(ContentModel.PROP_VERSION_LABEL) == null)
    {
        // attempt to delete last version - we do not yet support this (see REPO-835 & REPO-834)
        // note: alternatively, the client can remove the "cm:versionable" aspect (if permissions allow) to clear the version history and disable versioning
        throw new IntegrityException("Cannot delete last version (did you mean to disable versioning instead ?) ["+nodeId+","+versionId+"]", null);
        
        /*
        if (props.get(ContentModel.PROP_VERSION_TYPE) != null)
        {
            // minor fix up to versionable aspect - ie. remove versionType
            behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
            behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
            try
            {
                sr.getNodeService().removeProperty(nodeRef, ContentModel.PROP_VERSION_TYPE);
            }
            finally
            {
                behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
                behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
            }
        }
        */
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:43,代码来源:NodeVersionsRelation.java

示例8: readById

import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
@Override
public Sheep readById(String id, Parameters parameters)
{
    throw new IntegrityException("bad integrity", null);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:6,代码来源:BadEntityResource.java

示例9: testMatchException

import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
@Test
public void testMatchException()
{
    ErrorResponse response = assistant.resolveException(new ApiException(null));
    assertNotNull(response);
    assertEquals(500, response.getStatusCode());  //default to INTERNAL_SERVER_ERROR
   
    response = assistant.resolveException(new InvalidArgumentException(null));
    assertEquals(400, response.getStatusCode());  //default to STATUS_BAD_REQUEST

    response = assistant.resolveException(new InvalidQueryException(null));
    assertEquals(400, response.getStatusCode());  //default to STATUS_BAD_REQUEST
    
    response = assistant.resolveException(new NotFoundException(null));
    assertEquals(404, response.getStatusCode());  //default to STATUS_NOT_FOUND
    
    response = assistant.resolveException(new EntityNotFoundException(null));
    assertEquals(404, response.getStatusCode());  //default to STATUS_NOT_FOUND

    response = assistant.resolveException(new RelationshipResourceNotFoundException(null, null));
    assertEquals(404, response.getStatusCode());  //default to STATUS_NOT_FOUND

    response = assistant.resolveException(new PermissionDeniedException(null));
    assertEquals(403, response.getStatusCode());  //default to STATUS_FORBIDDEN

    response = assistant.resolveException(new UnsupportedResourceOperationException(null));
    assertEquals(405, response.getStatusCode());  //default to STATUS_METHOD_NOT_ALLOWED

    response = assistant.resolveException(new DeletedResourceException(null));
    assertEquals(405, response.getStatusCode());  //default to STATUS_METHOD_NOT_ALLOWED
    
    response = assistant.resolveException(new ConstraintViolatedException(null));
    assertEquals(409, response.getStatusCode());  //default to STATUS_CONFLICT    
    
    response = assistant.resolveException(new StaleEntityException(null));
    assertEquals(409, response.getStatusCode());  //default to STATUS_CONFLICT    

    //Try a random exception
    response = assistant.resolveException(new FormNotFoundException(null));
    assertEquals(500, response.getStatusCode());  //default to INTERNAL_SERVER_ERROR

    response = assistant.resolveException(new InsufficientStorageException(null));
    assertEquals(507, response.getStatusCode());

    response = assistant.resolveException(new IntegrityException(null));
    assertEquals(422, response.getStatusCode());
    
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:49,代码来源:ExceptionResolverTests.java


注:本文中的org.alfresco.repo.node.integrity.IntegrityException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。