本文整理汇总了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);
}
示例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);
}
}
示例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
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
*/
}
}
示例8: readById
import org.alfresco.repo.node.integrity.IntegrityException; //导入依赖的package包/类
@Override
public Sheep readById(String id, Parameters parameters)
{
throw new IntegrityException("bad integrity", null);
}
示例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());
}