use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class CmObjectType method beforeCopy.
/**
* @see org.alfresco.repo.copy.CopyServicePolicies.BeforeCopyPolicy#beforeCopy(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, name = COPY_BEHAVIOUR_NAME)
public void beforeCopy(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef) {
mandatory("sourceNodeRef", sourceNodeRef);
mandatory("targetNodeRef", targetNodeRef);
NodeRef sourceParentNodeRef = nodeService.getPrimaryParent(sourceNodeRef).getParentRef();
boolean isSourceParentFilePlanComponent = isFilePlanComponent(sourceParentNodeRef);
NodeRef targetParentNodeRef = nodeService.getPrimaryParent(targetNodeRef).getParentRef();
boolean isTargetNodeParentFilePlanComponent = isFilePlanComponent(targetParentNodeRef);
// The method should just check copy operations from outside of RM into the RM site
if (isSourceParentFilePlanComponent && isTargetNodeParentFilePlanComponent) {
return;
}
// Do not allow to copy anything outside of RM site into the RM site
if (!isSourceParentFilePlanComponent && isTargetNodeParentFilePlanComponent) {
throw new AlfrescoRuntimeException("Nothing can be copied from a collaboration site into a RM site.");
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class CmObjectType method onMoveNode.
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnMoveNodePolicy#onMoveNode(org.alfresco.service.cmr.repository.ChildAssociationRef, org.alfresco.service.cmr.repository.ChildAssociationRef)
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, name = MOVE_BEHAVIOUR_NAME)
public void onMoveNode(ChildAssociationRef oldChildAssocRef, ChildAssociationRef newChildAssocRef) {
mandatory("oldChildAssocRef", oldChildAssocRef);
mandatory("newChildAssocRef", newChildAssocRef);
NodeRef sourceParent = oldChildAssocRef.getParentRef();
boolean isSourceParentFilePlanComponent = isFilePlanComponent(sourceParent);
NodeRef targetParent = newChildAssocRef.getParentRef();
boolean isTargetParentFilePlanComponent = isFilePlanComponent(targetParent);
// The method should just check move operations from outside of RM into the RM site
if (isSourceParentFilePlanComponent && isTargetParentFilePlanComponent) {
return;
}
NodeRef object = oldChildAssocRef.getChildRef();
QName objectType = nodeService.getType(object);
// Only documents can be moved into the RM site
if (!objectType.equals(ContentModel.TYPE_CONTENT) && isTargetParentFilePlanComponent) {
throw new AlfrescoRuntimeException("Only documents can be moved from a collaboration site into a RM site.");
}
// Documents can be moved only into a RM folder
if (isTargetParentFilePlanComponent && !isRecordFolder(targetParent)) {
throw new AlfrescoRuntimeException("A document can only be moved into a folder in RM site.");
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class PublishUpdatesJobExecuter method publishUpdates.
/**
* Publish the updates made to the node.
* @param nodeRef node reference
*/
private void publishUpdates(final NodeRef nodeRef) {
RetryingTransactionHelper.RetryingTransactionCallback<Void> execution = new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {
@Override
public Void execute() {
behaviourFilter.disableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION);
try {
// Get the update to value for the node
String updateTo = (String) nodeService.getProperty(nodeRef, PROP_UPDATE_TO);
if (updateTo != null) {
if (logger.isDebugEnabled()) {
logger.debug("Node update to " + updateTo + " (noderef=" + nodeRef.toString() + ")");
}
// Get the publish executor
PublishExecutor executor = publishExecutorRegistry.get(updateTo);
if (executor == null) {
if (logger.isDebugEnabled()) {
logger.debug("Unable to find a corresponding publish executor. (noderef=" + nodeRef.toString() + ", updateTo=" + updateTo + ")");
}
throw new AlfrescoRuntimeException("Unable to find a corresponding publish executor. (noderef=" + nodeRef.toString() + ", updateTo=" + updateTo + ")");
}
if (logger.isDebugEnabled()) {
logger.debug("Attempting to publish updates. (nodeRef=" + nodeRef.toString() + ")");
}
// Publish
executor.publish(nodeRef);
} else {
if (logger.isDebugEnabled()) {
logger.debug("Unable to publish, because publish executor is not set.");
}
}
// Remove the unpublished update aspect
nodeService.removeAspect(nodeRef, ASPECT_UNPUBLISHED_UPDATE);
if (logger.isDebugEnabled()) {
logger.debug("Publish updates complete. (nodeRef=" + nodeRef.toString() + ")");
}
} finally {
behaviourFilter.enableBehaviour(nodeRef, TYPE_DISPOSITION_ACTION_DEFINITION);
}
return null;
}
};
retryingTransactionHelper.doInTransaction(execution);
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class CommonRMTestUtils method createRole.
public Role createRole(NodeRef filePlan, String roleName, String... capabilityNames) {
Set<Capability> capabilities = new HashSet<Capability>(capabilityNames.length);
for (String name : capabilityNames) {
Capability capability = capabilityService.getCapability(name);
if (capability == null) {
throw new AlfrescoRuntimeException("capability " + name + " not found.");
}
capabilities.add(capability);
}
return filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities);
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class DispositionServiceImpl method createDispositionSchedule.
/**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#createDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef, java.util.Map)
*/
@Override
public DispositionSchedule createDispositionSchedule(NodeRef nodeRef, Map<QName, Serializable> props) {
NodeRef dsNodeRef = null;
// Check mandatory parameters
ParameterCheck.mandatory("nodeRef", nodeRef);
// Check exists
if (!nodeService.exists(nodeRef)) {
throw new AlfrescoRuntimeException("Unable to create retention schedule, because node does not exist. (nodeRef=" + nodeRef.toString() + ")");
}
// Check is sub-type of rm:recordCategory
QName nodeRefType = nodeService.getType(nodeRef);
if (!TYPE_RECORD_CATEGORY.equals(nodeRefType) && !dictionaryService.isSubClass(nodeRefType, TYPE_RECORD_CATEGORY)) {
throw new AlfrescoRuntimeException("Unable to create retention schedule on a node that is not a records management container.");
}
behaviourFilter.disableBehaviour(nodeRef, ASPECT_SCHEDULED);
try {
// Add the schedules aspect if required
if (!nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) {
nodeService.addAspect(nodeRef, ASPECT_SCHEDULED, null);
}
// Check whether there is already a disposition schedule object present
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
if (assocs.isEmpty()) {
DispositionSchedule currentDispositionSchdule = getDispositionSchedule(nodeRef);
if (currentDispositionSchdule != null) {
List<NodeRef> items = getDisposableItemsImpl(currentDispositionSchdule.isRecordLevelDisposition(), nodeRef);
if (!items.isEmpty()) {
throw new AlfrescoRuntimeException("Can not create a retention schedule if there are disposable items already under the control of an other retention schedule");
}
}
// Create the disposition schedule object
dsNodeRef = nodeService.createNode(nodeRef, ASSOC_DISPOSITION_SCHEDULE, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("dispositionSchedule")), TYPE_DISPOSITION_SCHEDULE, props).getChildRef();
} else {
// Error since the node already has a disposition schedule set
throw new AlfrescoRuntimeException("Unable to create retention schedule on node that already has a retention schedule.");
}
} finally {
behaviourFilter.enableBehaviour(nodeRef, ASPECT_SCHEDULED);
}
// Create the return object
return new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef);
}
Aggregations