RM-4327: changed InvalidParameterException with IntegrityException

This commit is contained in:
Silviu Dinuta
2016-11-10 16:58:05 +02:00
parent 579ebdd2df
commit 7753ccad06
13 changed files with 53 additions and 62 deletions

View File

@@ -27,13 +27,13 @@
package org.alfresco.module.org_alfresco_module_rm.model;
import java.security.InvalidParameterException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.policy.annotation.BehaviourRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -99,9 +99,9 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
* @param childType the child node
* @param acceptedUniqueChildType a list of node types that are accepted as children of the provided parent only once
* @param acceptedMultipleChildType a list of node types that are accepted as children of the provided parent multiple times
* @throws InvalidParameterException if the child association doesn't comply with the RM rules
* @throws IntegrityException if the child association doesn't comply with the RM rules
*/
protected void validateNewChildAssociation(NodeRef parent, NodeRef child, List<QName> acceptedUniqueChildType, List<QName> acceptedMultipleChildType) throws InvalidParameterException
protected void validateNewChildAssociation(NodeRef parent, NodeRef child, List<QName> acceptedUniqueChildType, List<QName> acceptedMultipleChildType) throws IntegrityException
{
QName childType = getInternalNodeService().getType(child);
if(acceptedUniqueChildType.contains(childType))
@@ -109,12 +109,12 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
// check the user is not trying to create multiple children of a type that is only accepted once
if(nodeService.getChildAssocs(parent, Sets.newHashSet(childType)).size() > 1)
{
throw new InvalidParameterException("Operation failed. Multiple children of this type are not allowed.");
throw new IntegrityException("Operation failed. Multiple children of this type are not allowed.", null);
}
}
else if(!acceptedMultipleChildType.contains(childType))
{
throw new InvalidParameterException("Operation failed. Children of type " + childType + " are not allowed");
throw new IntegrityException("Operation failed. Children of type " + childType + " are not allowed", null);
}
}
@@ -122,9 +122,9 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
* Helper method that checks if the newly created child association is between the sub-types of accepted types.
* @param childType the child node
* @param acceptedMultipleChildType a list of node types that are accepted as children of the provided parent multiple times
* @throws InvalidParameterException if the child association isn't between the sub-types of accepted types
* @throws IntegrityException if the child association isn't between the sub-types of accepted types
*/
protected void validateNewChildAssociationSubTypesIncluded(NodeRef child, List<QName> acceptedMultipleChildType) throws InvalidParameterException
protected void validateNewChildAssociationSubTypesIncluded(NodeRef child, List<QName> acceptedMultipleChildType) throws IntegrityException
{
QName childType = getInternalNodeService().getType(child);
for(QName type : acceptedMultipleChildType)
@@ -135,6 +135,6 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
}
}
//no match was found in sub-types of permitted types list
throw new InvalidParameterException("Operation failed. Children of type " + childType + " are not allowed");
throw new IntegrityException("Operation failed. Children of type " + childType + " are not allowed", null);
}
}

View File

@@ -28,7 +28,6 @@
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import java.io.Serializable;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -41,6 +40,7 @@ import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
@@ -343,14 +343,14 @@ public class RmSiteType extends BaseBehaviourBean
*/
@Override
protected void validateNewChildAssociation(NodeRef parent, NodeRef child, List<QName> acceptedUniqueChildType,
List<QName> acceptedMultipleChildType) throws InvalidParameterException
List<QName> acceptedMultipleChildType) throws IntegrityException
{
super.validateNewChildAssociation(parent, child, acceptedUniqueChildType, acceptedMultipleChildType);
// check the user is not trying to create more than 2 folders that are created by default.
if(nodeService.getChildAssocs(parent, Sets.newHashSet(ContentModel.TYPE_FOLDER)).size() > 2)
{
throw new InvalidParameterException("Operation failed. Children of type " + ContentModel.TYPE_FOLDER + " are not allowed");
throw new IntegrityException("Operation failed. Children of type " + ContentModel.TYPE_FOLDER + " are not allowed", null);
}
}
}

View File

@@ -26,12 +26,11 @@
*/
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import java.security.InvalidParameterException;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
import org.alfresco.repo.policy.annotation.BehaviourKind;
@@ -84,7 +83,7 @@ public class TransferContainerType extends BaseBehaviourBean
)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
{
throw new InvalidParameterException("Operation failed. Creation is not allowed in Transfer Container");
throw new IntegrityException("Operation failed. Creation is not allowed in Transfer Container", null);
}
@Override

View File

@@ -27,10 +27,9 @@
package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import java.security.InvalidParameterException;
import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
import org.alfresco.repo.policy.annotation.BehaviourKind;
@@ -76,6 +75,6 @@ public class TransferType extends BaseBehaviourBean implements NodeServicePolici
)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
{
throw new InvalidParameterException("Operation failed. Creation is not allowed in Transfer Folders");
throw new IntegrityException("Operation failed. Creation is not allowed in Transfer Folders", null);
}
}

View File

@@ -27,11 +27,10 @@
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import java.security.InvalidParameterException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
@@ -78,7 +77,7 @@ public class RM3341Test extends BaseRMTestCase
fileFolderService.create(holdContainer, "test file", ContentModel.TYPE_CONTENT);
fail("This should have thrown an exception");
}
catch (InvalidParameterException e)
catch (IntegrityException e)
{
// ("Content can't be added to a hold container. Use record folders to file content.")
}
@@ -104,7 +103,7 @@ public class RM3341Test extends BaseRMTestCase
fail("This should have thrown an exception");
}
catch (InvalidParameterException e)
catch (IntegrityException e)
{
// ("Content can't be added to a transfer container. Use record folders to file content.")
}

View File

@@ -26,10 +26,9 @@
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import java.security.InvalidParameterException;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.module.org_alfresco_module_rm.test.util.TestModel;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.util.GUID;
import org.springframework.extensions.surf.util.I18NUtil;
@@ -50,7 +49,7 @@ public class RM3450Test extends BaseRMTestCase
doTestInTransaction(new FailureTest
(
I18NUtil.getMessage(MSG_CANNOT_CAST_TO_RM_TYPE),
InvalidParameterException.class
IntegrityException.class
)
{
@Override

View File

@@ -29,11 +29,11 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.when;
import java.security.InvalidParameterException;
import java.util.Arrays;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -69,7 +69,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
* When adding a child of type TYPE_FILE_PLAN
* Then an error should be thrown
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testAddFileplanToFileplan()
{
ChildAssociationRef childAssoc = createFileplanContainerChild(TYPE_FILE_PLAN);
@@ -112,7 +112,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
* When adding another child of type TYPE_HOLD_CONTAINER
* Then an error should be thrown
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testCreateMultipleHoldContainers()
{
ChildAssociationRef existingHoldAssoc = createFileplanContainerChild(TYPE_HOLD_CONTAINER);
@@ -141,7 +141,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
* When adding another child of type TYPE_TRANSFER_CONTAINER
* Then an error should be thrown
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testCreateMultipleTransferContainers()
{
ChildAssociationRef existingHoldAssoc = createFileplanContainerChild(TYPE_TRANSFER_CONTAINER);
@@ -170,7 +170,7 @@ public class FilePlanTypeUnitTest extends BaseUnitTest
* When adding another child of type TYPE_UNFILED_RECORD_CONTAINER
* Then an error should be thrown
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testCreateMultipleUnfiledRecordsContainers()
{
ChildAssociationRef existingHoldAssoc = createFileplanContainerChild(TYPE_UNFILED_RECORD_CONTAINER);

View File

@@ -29,10 +29,9 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.InvalidParameterException;
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -52,9 +51,9 @@ public class HoldContainerTypeUnitTest extends BaseUnitTest
/**
* Given that we try to add a non "rma:hold" type to hold container,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test (expected = InvalidParameterException.class)
@Test (expected = IntegrityException.class)
public void testAddNonHoldTypeToHoldContainer()
{
QName type = AlfMock.generateQName();

View File

@@ -30,7 +30,6 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
@@ -38,6 +37,7 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.module.org_alfresco_module_rm.test.util.MockAuthenticationUtilHelper;
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteInfo;
@@ -77,9 +77,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add non allowed type to rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddNonAcceptedTypeToRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
@@ -149,9 +149,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add more than two cm:folder to rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddMoreThanTwhoFolderTypeToRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
@@ -208,9 +208,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add one dod:filePlan to standard rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddDODFilePlanTypeToStandardRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
@@ -225,9 +225,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add more than one rma:filePlan to rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddMoreThanOneFilePlanTypeToRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_RM_SITE, true);
@@ -281,9 +281,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add more than one dod:filePlan to rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddMoreThanOneDODFilePlanTypeToRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_DOD_5015_SITE, true);
@@ -315,9 +315,9 @@ public class RmSiteTypeUnitTest extends BaseUnitTest implements DOD5015Model
/**
* Given that we try to add one rma:filePlan to DOD rm site,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddStandardFilePlanTypeToDODRmSite()
{
NodeRef rmSiteNodeRef = generateNodeRef(TYPE_DOD_5015_SITE, true);

View File

@@ -29,10 +29,9 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.InvalidParameterException;
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -52,9 +51,9 @@ public class TransferContainerTypeUnitTest extends BaseUnitTest
/**
* Given that we try to add to transfer container,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddToTransferContainerTest()
{
NodeRef transferContainer = generateNodeRef(TYPE_TRANSFER_CONTAINER, true);

View File

@@ -30,10 +30,9 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.InvalidParameterException;
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -53,9 +52,9 @@ public class TransferTypeUnitTest extends BaseUnitTest
/**
* Given that we try to add to transfer type folder,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddToTransferFolderTest()
{
NodeRef transferFolder = generateNodeRef(TYPE_TRANSFER, true);

View File

@@ -30,11 +30,10 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.InvalidParameterException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -54,9 +53,9 @@ public class UnfiledRecordContainerTypeUnitTest extends BaseUnitTest
/**
* Given that we try to add a type that is not one of "rma:unfiledRecordFolder", "cm:content" or "rma:nonElectronicDocument" types to unfiled record container,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddNonAcceptedTypeToUnfiledRecordContainer()
{
QName type = AlfMock.generateQName();

View File

@@ -30,11 +30,10 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.type;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.security.InvalidParameterException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -54,9 +53,9 @@ public class UnfiledRecordFolderTypeUnitTest extends BaseUnitTest
/**
* Given that we try to add a type that is not one of "rma:unfiledRecordFolder", "cm:content" or "rma:nonElectronicDocument" types to unfiled record folder,
* Then InvalidParameterException is thrown.
* Then IntegrityException is thrown.
*/
@Test(expected = InvalidParameterException.class)
@Test(expected = IntegrityException.class)
public void testAddNonAcceptedTypeToUnfiledRecordFolder()
{
QName type = AlfMock.generateQName();