mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge remote-tracking branch 'origin/feature/RM-4362_UpdateAPI_ImplAndDoc'
This commit is contained in:
@@ -21,3 +21,4 @@ rm.service.final-version=Final
|
|||||||
rm.service.final-version-description=The final archived record version
|
rm.service.final-version-description=The final archived record version
|
||||||
rm.service.enable-autoversion-on-record-creation=Auto Version on Record Creation
|
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.
|
@@ -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.model.behaviour.AbstractDisposableItem;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
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.CopyBehaviourCallback;
|
||||||
import org.alfresco.repo.copy.CopyDetails;
|
import org.alfresco.repo.copy.CopyDetails;
|
||||||
import org.alfresco.repo.copy.CopyServicePolicies;
|
import org.alfresco.repo.copy.CopyServicePolicies;
|
||||||
import org.alfresco.repo.copy.DefaultCopyBehaviourCallback;
|
import org.alfresco.repo.copy.DefaultCopyBehaviourCallback;
|
||||||
import org.alfresco.repo.node.NodeServicePolicies;
|
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.Behaviour.NotificationFrequency;
|
||||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
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.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.ScriptService;
|
import org.alfresco.service.cmr.repository.ScriptService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rma:record behaviour bean
|
* rma:record behaviour bean
|
||||||
@@ -67,7 +71,8 @@ public class RecordAspect extends AbstractDisposableItem
|
|||||||
RecordsManagementPolicies.OnCreateReference,
|
RecordsManagementPolicies.OnCreateReference,
|
||||||
RecordsManagementPolicies.OnRemoveReference,
|
RecordsManagementPolicies.OnRemoveReference,
|
||||||
NodeServicePolicies.OnMoveNodePolicy,
|
NodeServicePolicies.OnMoveNodePolicy,
|
||||||
CopyServicePolicies.OnCopyCompletePolicy
|
CopyServicePolicies.OnCopyCompletePolicy,
|
||||||
|
ContentServicePolicies.OnContentPropertyUpdatePolicy
|
||||||
{
|
{
|
||||||
/** Well-known location of the scripts folder. */
|
/** Well-known location of the scripts folder. */
|
||||||
// TODO make configurable
|
// TODO make configurable
|
||||||
@@ -82,6 +87,9 @@ public class RecordAspect extends AbstractDisposableItem
|
|||||||
/** record service */
|
/** record service */
|
||||||
protected RecordService recordService;
|
protected RecordService recordService;
|
||||||
|
|
||||||
|
/** I18N */
|
||||||
|
private static final String MSG_CANNOT_UPDATE_RECORD_CONTENT = "rm.service.update-record-content";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param extendedSecurityService extended security service
|
* @param extendedSecurityService extended security service
|
||||||
*/
|
*/
|
||||||
@@ -336,4 +344,19 @@ public class RecordAspect extends AbstractDisposableItem
|
|||||||
extendedSecurityService.remove(targetNodeRef);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -27,15 +27,11 @@
|
|||||||
|
|
||||||
package org.alfresco.rm.rest.api.nodes;
|
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.BinaryProperties;
|
||||||
import org.alfresco.rest.framework.WebApiDescription;
|
import org.alfresco.rest.framework.WebApiDescription;
|
||||||
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
import org.alfresco.rest.framework.core.exceptions.EntityNotFoundException;
|
||||||
import org.alfresco.rest.framework.resource.EntityResource;
|
import org.alfresco.rest.framework.resource.EntityResource;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.BinaryResourceAction;
|
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.content.BinaryResource;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
import org.alfresco.rest.framework.resource.parameters.Parameters;
|
||||||
import org.alfresco.rm.rest.api.RMNodes;
|
import org.alfresco.rm.rest.api.RMNodes;
|
||||||
@@ -49,8 +45,7 @@ import org.springframework.beans.factory.InitializingBean;
|
|||||||
* @since 2.6
|
* @since 2.6
|
||||||
*/
|
*/
|
||||||
@EntityResource(name="records", title = "Records")
|
@EntityResource(name="records", title = "Records")
|
||||||
public class RecordsEntityResource implements BinaryResourceAction.Update<Node>,
|
public class RecordsEntityResource implements BinaryResourceAction.Read,
|
||||||
BinaryResourceAction.Read,
|
|
||||||
InitializingBean
|
InitializingBean
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -83,24 +78,4 @@ public class RecordsEntityResource implements BinaryResourceAction.Update<Node>,
|
|||||||
return nodes.getContent(recordId, parameters, true);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user