RM-4418 - removed posibility to update content

This commit is contained in:
Ana Bozianu
2016-12-16 11:39:11 +02:00
parent 2319ec8e8a
commit fb6a1c9946
2 changed files with 20 additions and 27 deletions

View File

@@ -37,17 +37,20 @@ import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.copy.CopyBehaviourCallback;
import org.alfresco.repo.copy.CopyDetails;
import org.alfresco.repo.copy.CopyServicePolicies;
import org.alfresco.repo.copy.DefaultCopyBehaviourCallback;
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;
import org.alfresco.repo.policy.annotation.BehaviourKind;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.ScriptService;
import org.alfresco.service.namespace.QName;
@@ -67,7 +70,8 @@ public class RecordAspect extends AbstractDisposableItem
RecordsManagementPolicies.OnCreateReference,
RecordsManagementPolicies.OnRemoveReference,
NodeServicePolicies.OnMoveNodePolicy,
CopyServicePolicies.OnCopyCompletePolicy
CopyServicePolicies.OnCopyCompletePolicy,
ContentServicePolicies.OnContentPropertyUpdatePolicy
{
/** Well-known location of the scripts folder. */
// TODO make configurable
@@ -336,4 +340,18 @@ public class RecordAspect extends AbstractDisposableItem
extendedSecurityService.remove(targetNodeRef);
}
}
@Override
@Behaviour
(
kind = BehaviourKind.CLASS,
notificationFrequency = NotificationFrequency.FIRST_EVENT
)
public void onContentPropertyUpdate(NodeRef nodeRef, QName propertyQName, ContentData beforeValue, ContentData afterValue)
{
if (beforeValue != null)
{
throw new IntegrityException("Content property cannot be updated for records", null);
}
}
}

View File

@@ -27,15 +27,11 @@
package org.alfresco.rm.rest.api.nodes;
import java.io.InputStream;
import org.alfresco.rest.api.model.Node;
import org.alfresco.rest.framework.BinaryProperties;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
import org.alfresco.rest.framework.resource.EntityResource;
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
import org.alfresco.rest.framework.resource.content.BasicContentInfo;
import org.alfresco.rest.framework.resource.content.BinaryResource;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rm.rest.api.RMNodes;
@@ -49,8 +45,7 @@ import org.springframework.beans.factory.InitializingBean;
* @since 2.6
*/
@EntityResource(name="records", title = "Records")
public class RecordsEntityResource implements BinaryResourceAction.Update<Node>,
BinaryResourceAction.Read,
public class RecordsEntityResource implements BinaryResourceAction.Read,
InitializingBean
{
@@ -83,24 +78,4 @@ public class RecordsEntityResource implements BinaryResourceAction.Update<Node>,
return nodes.getContent(recordId, parameters, true);
}
/**
* Upload new version of content
*
* This allow binary content update of an existing record.
*
* Note: alternatively, can upload via POST (multipart/form-data) with existing file name and form "overwrite=true".
*
* @param recordId the id of the record to set the content for
* @param contentInfo Basic information about the content stream
* @param stream an inputstream representing the new content of the node
* @param parameters {@link Parameters}
* @return information about the record that has been updated
*/
@Override
@WebApiDescription(title = "Upload content", description = "Upload content")
@BinaryProperties({"content"})
public Node updateProperty(String recordId, BasicContentInfo contentInfo, InputStream stream, Parameters parameters)
{
return nodes.updateContent(recordId, contentInfo, stream, parameters);
}
}