Merge remote-tracking branch 'origin/feature/RM-4362_UpdateAPI_ImplAndDoc'

This commit is contained in:
Tuna Aksoy
2016-12-20 16:30:00 +00:00
3 changed files with 28 additions and 29 deletions

View File

@@ -20,4 +20,5 @@ rm.service.node-has-aspect=The record type {1} is already showing for record {0}
rm.service.final-version=Final
rm.service.final-version-description=The final archived record version
rm.service.enable-autoversion-on-record-creation=Auto Version on Record Creation
rm.service.add-children-to-closed-record-folder=You can't add new items to a closed record folder
rm.service.add-children-to-closed-record-folder=You can't add new items to a closed record folder
rm.service.update-record-content=Could not update content property as it's immutable for records.

View File

@@ -37,20 +37,24 @@ 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;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* rma:record behaviour bean
@@ -67,7 +71,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
@@ -81,7 +86,10 @@ public class RecordAspect extends AbstractDisposableItem
/** record service */
protected RecordService recordService;
/** I18N */
private static final String MSG_CANNOT_UPDATE_RECORD_CONTENT = "rm.service.update-record-content";
/**
* @param extendedSecurityService extended security service
*/
@@ -336,4 +344,19 @@ 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)
{
// Allow creation of content but not update
if (beforeValue != null)
{
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_UPDATE_RECORD_CONTENT), 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);
}
}