mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4312: review updates
This commit is contained in:
@@ -120,15 +120,14 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method that checks if the newly created child association is between the sub-types of accepted types.
|
* Helper method that checks if the newly created child association is between the sub-types of accepted types.
|
||||||
* @param parent the parent node
|
|
||||||
* @param childType the child node
|
* @param childType the child node
|
||||||
* @param acceptedMultipleChildType a list of node types that are accepted as children of the provided parent multiple times
|
* @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 InvalidParameterException if the child association isn't between the sub-types of accepted types
|
||||||
*/
|
*/
|
||||||
protected void validateNewChildAssociationSubTypesIncluded(NodeRef parent, NodeRef child, List<QName> acceptedMultipleChildType) throws InvalidParameterException
|
protected void validateNewChildAssociationSubTypesIncluded(NodeRef child, List<QName> acceptedMultipleChildType) throws InvalidParameterException
|
||||||
{
|
{
|
||||||
QName childType = getInternalNodeService().getType(child);
|
QName childType = getInternalNodeService().getType(child);
|
||||||
if(!validateNodeRef(acceptedMultipleChildType, child))
|
if(!validateNodeRef(acceptedMultipleChildType, childType))
|
||||||
{
|
{
|
||||||
throw new InvalidParameterException("Operation failed. Children of type " + childType + " are not allowed");
|
throw new InvalidParameterException("Operation failed. Children of type " + childType + " are not allowed");
|
||||||
}
|
}
|
||||||
@@ -138,20 +137,18 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
|
|||||||
* Checks if the type of the provided nodeRef it is between the sub-types of accepted types
|
* Checks if the type of the provided nodeRef it is between the sub-types of accepted types
|
||||||
*
|
*
|
||||||
* @param acceptedMultipleChildType
|
* @param acceptedMultipleChildType
|
||||||
* @param nodeRef
|
* @param nodeType
|
||||||
* @return true if the type of the nodeRef is between the sub-types of accepted types, or false otherwise
|
* @return true if the type of the nodeRef is between the sub-types of accepted types, or false otherwise
|
||||||
*/
|
*/
|
||||||
protected boolean validateNodeRef(List<QName> acceptedMultipleChildType, NodeRef nodeRef)
|
protected boolean validateNodeRef(List<QName> acceptedMultipleChildType, QName nodeType)
|
||||||
{
|
{
|
||||||
boolean result = false;
|
|
||||||
for(QName type : acceptedMultipleChildType)
|
for(QName type : acceptedMultipleChildType)
|
||||||
{
|
{
|
||||||
if(instanceOf(nodeRef, type))
|
if(instanceOf(nodeType, type))
|
||||||
{
|
{
|
||||||
result = true;
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -52,7 +52,7 @@ public class HoldContainerType extends BaseBehaviourBean
|
|||||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy
|
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_CONTENT_CONTAINER = "rm.service.error-add-content-container";
|
||||||
private static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_HOLD);
|
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_HOLD);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On every event
|
* On every event
|
||||||
@@ -65,7 +65,7 @@ public class HoldContainerType extends BaseBehaviourBean
|
|||||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||||
{
|
{
|
||||||
// check the created child is of an accepted type
|
// check the created child is of an accepted type
|
||||||
validateNewChildAssociationSubTypesIncluded(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
validateNewChildAssociationSubTypesIncluded(childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -52,7 +52,7 @@ public class TransferContainerType extends BaseBehaviourBean
|
|||||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnCreateNodePolicy
|
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_CONTENT_CONTAINER = "rm.service.error-add-content-container";
|
||||||
private static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_TRANSFER);
|
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_TRANSFER);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On every event
|
* On every event
|
||||||
@@ -65,7 +65,7 @@ public class TransferContainerType extends BaseBehaviourBean
|
|||||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean bNew)
|
||||||
{
|
{
|
||||||
// check the created child is of an accepted type
|
// check the created child is of an accepted type
|
||||||
validateNewChildAssociationSubTypesIncluded(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
validateNewChildAssociationSubTypesIncluded(childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -49,12 +49,12 @@ import org.alfresco.service.namespace.QName;
|
|||||||
public class UnfiledRecordContainerType extends BaseBehaviourBean
|
public class UnfiledRecordContainerType extends BaseBehaviourBean
|
||||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy
|
implements NodeServicePolicies.OnCreateChildAssociationPolicy
|
||||||
{
|
{
|
||||||
private static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_UNFILED_RECORD_FOLDER, ContentModel.TYPE_CONTENT, TYPE_NON_ELECTRONIC_DOCUMENT);
|
private final static List<QName> ACCEPTED_NON_UNIQUE_CHILD_TYPES = Arrays.asList(TYPE_UNFILED_RECORD_FOLDER, ContentModel.TYPE_CONTENT, TYPE_NON_ELECTRONIC_DOCUMENT);
|
||||||
@Override
|
@Override
|
||||||
@Behaviour(kind = BehaviourKind.ASSOCIATION)
|
@Behaviour(kind = BehaviourKind.ASSOCIATION)
|
||||||
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
|
||||||
{
|
{
|
||||||
// check the created child is of an accepted type
|
// check the created child is of an accepted type
|
||||||
validateNewChildAssociationSubTypesIncluded(childAssocRef.getParentRef(), childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
validateNewChildAssociationSubTypesIncluded(childAssocRef.getChildRef(), ACCEPTED_NON_UNIQUE_CHILD_TYPES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user