RM-4327: extracted error messages for type restrictions in

action.service.properties
This commit is contained in:
Silviu Dinuta
2016-11-14 11:21:32 +02:00
parent 6891845cb3
commit 7c4b03e9f4
6 changed files with 24 additions and 10 deletions

View File

@@ -40,6 +40,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.I18NUtil;
import com.google.common.collect.Sets;
@@ -56,6 +57,10 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
/** Logger */
protected static final Log LOGGER = LogFactory.getLog(BaseBehaviourBean.class);
/** I18N */
protected static final String UNIQUE_CHILD_TYPE_ERROR = "rm.action.unique.child.type-error-message";
protected static final String MULTIPLE_CHILDREN_TYPE_ERROR = "rm.action.multiple.children.type-error-message";
/** behaviour filter */
protected BehaviourFilter behaviourFilter;
@@ -109,12 +114,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 IntegrityException("Operation failed. Multiple children of this type are not allowed.", null);
throw new IntegrityException(I18NUtil.getMessage(UNIQUE_CHILD_TYPE_ERROR), null);
}
}
else if(!acceptedMultipleChildType.contains(childType))
{
throw new IntegrityException("Operation failed. Children of type " + childType + " are not allowed", null);
throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, childType), null);
}
}
@@ -135,6 +140,6 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
}
}
//no match was found in sub-types of permitted types list
throw new IntegrityException("Operation failed. Children of type " + childType + " are not allowed", null);
throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, childType), null);
}
}

View File

@@ -78,7 +78,7 @@ public class RecordFolderType extends AbstractDisposableItem
protected VitalRecordService vitalRecordService;
/** I18N */
private static final String MSG_CANNOT_CREATE_RECORD_FOLDER = "rm.action.record-folder-create";
private static final String MSG_CANNOT_CREATE_RECORD_FOLDER_CHILD = "rm.action.create.record.folder.child-error-message";
/**
* @param recordService record service
@@ -228,7 +228,7 @@ public class RecordFolderType extends AbstractDisposableItem
if (!instanceOf(nodeRef, ContentModel.TYPE_CONTENT) && notFolderOrRmFolderSubType)
{
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_CREATE_RECORD_FOLDER), null);
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_CREATE_RECORD_FOLDER_CHILD, nodeService.getType(nodeRef)), null);
}
// ensure nothing is being added to a closed record folder
NodeRef recordFolder = childAssocRef.getParentRef();
@@ -258,7 +258,7 @@ public class RecordFolderType extends AbstractDisposableItem
// only records can be added in a record folder or hidden folders(is the case of e-mail attachments)
if (instanceOf(recordFolder, ContentModel.TYPE_FOLDER) && !nodeService.hasAspect(recordFolder, ContentModel.ASPECT_HIDDEN))
{
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_CREATE_RECORD_FOLDER), null);
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_CREATE_RECORD_FOLDER_CHILD, nodeService.getType(recordFolder)), null);
}
behaviourFilter.disableBehaviour();

View File

@@ -59,6 +59,7 @@ import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ParameterCheck;
import org.alfresco.util.PropertyMap;
import org.springframework.extensions.surf.util.I18NUtil;
import com.google.common.collect.Sets;
@@ -350,7 +351,7 @@ public class RmSiteType extends BaseBehaviourBean
// 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 IntegrityException("Operation failed. Children of type " + ContentModel.TYPE_FOLDER + " are not allowed", null);
throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, ContentModel.TYPE_FOLDER), null);
}
}
}

View File

@@ -49,6 +49,7 @@ public class TransferContainerType extends BaseBehaviourBean
implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy
{
private final static String MSG_ERROR_ADD_CONTENT_CONTAINER = "rm.service.error-add-content-container";
private final static String MSG_ERROR_ADD_CHILD_TO_TRANSFER_CONTAINER = "rm.action.create.transfer.container.child-error-message";
private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForTransferContainer";
/**
@@ -83,7 +84,7 @@ public class TransferContainerType extends BaseBehaviourBean
)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
{
throw new IntegrityException("Operation failed. Creation is not allowed in Transfer Container", null);
throw new IntegrityException(I18NUtil.getMessage(MSG_ERROR_ADD_CHILD_TO_TRANSFER_CONTAINER), null);
}
@Override

View File

@@ -34,6 +34,7 @@ import org.alfresco.repo.policy.annotation.Behaviour;
import org.alfresco.repo.policy.annotation.BehaviourBean;
import org.alfresco.repo.policy.annotation.BehaviourKind;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* rma:transfer behaviour bean
@@ -44,6 +45,7 @@ import org.alfresco.service.cmr.repository.ChildAssociationRef;
@BehaviourBean(defaultType = "rma:transfer")
public class TransferType extends BaseBehaviourBean implements NodeServicePolicies.OnCreateChildAssociationPolicy
{
private final static String MSG_ERROR_ADD_CHILD_TO_TRANSFER = "rm.action.create.transfer.child-error-message";
private static final String BEHAVIOUR_NAME = "onCreateChildAssocsForTransferType";
/**
@@ -75,6 +77,6 @@ public class TransferType extends BaseBehaviourBean implements NodeServicePolici
)
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
{
throw new IntegrityException("Operation failed. Creation is not allowed in Transfer Folders", null);
throw new IntegrityException(I18NUtil.getMessage(MSG_ERROR_ADD_CHILD_TO_TRANSFER), null);
}
}