mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-5012 - fix write records created in current transaction
This commit is contained in:
@@ -27,20 +27,46 @@
|
||||
|
||||
package org.alfresco.module.org_alfresco_module_rm.capability.policy;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImpl;
|
||||
import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
import net.sf.acegisecurity.vote.AccessDecisionVoter;
|
||||
|
||||
public class WriteContentPolicy extends AbstractBasePolicy
|
||||
{
|
||||
protected TransactionalResourceHelper transactionalResourceHelper;
|
||||
|
||||
public void setTransactionalResourceHelper(TransactionalResourceHelper transactionalResourceHelper)
|
||||
{
|
||||
this.transactionalResourceHelper = transactionalResourceHelper;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public int evaluate(
|
||||
public int evaluate(
|
||||
MethodInvocation invocation,
|
||||
Class[] params,
|
||||
ConfigAttributeDefinition cad)
|
||||
{
|
||||
NodeRef updatee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent());
|
||||
return getCapabilityService().getCapability("WriteContent").evaluate(updatee);
|
||||
try{
|
||||
NodeRef updatee = getTestNode(invocation, params, cad.getParameters().get(0), cad.isParent());
|
||||
Set<NodeRef> newRecords = transactionalResourceHelper.getSet(RecordServiceImpl.KEY_NEW_RECORDS);
|
||||
if(newRecords.contains(updatee))
|
||||
{
|
||||
return AccessDecisionVoter.ACCESS_GRANTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return getCapabilityService().getCapability("WriteContent").evaluate(updatee);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1205,11 +1205,11 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
disablePropertyEditableCheck();
|
||||
try
|
||||
{
|
||||
authenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
authenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Void doWork() throws Exception {
|
||||
@Override
|
||||
public Void doWork() throws Exception {
|
||||
Map<QName, Serializable> props = new HashMap<>();
|
||||
|
||||
if(!nodeService.hasAspect(document, ASPECT_RECORD_COMPONENT_ID))
|
||||
@@ -1226,19 +1226,19 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
props.put(PROP_IDENTIFIER, recordId);
|
||||
props.put(PROP_ORIGIONAL_NAME, name);
|
||||
}
|
||||
nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, props);
|
||||
nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, props);
|
||||
|
||||
// remove versionable aspect(s)
|
||||
nodeService.removeAspect(document, RecordableVersionModel.ASPECT_VERSIONABLE);
|
||||
// remove versionable aspect(s)
|
||||
nodeService.removeAspect(document, RecordableVersionModel.ASPECT_VERSIONABLE);
|
||||
|
||||
// remove the owner
|
||||
|
||||
ownableService.setOwner(document, OwnableService.NO_OWNER);
|
||||
|
||||
appendIdentifierToName(nodeService, document);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
// remove the owner
|
||||
|
||||
ownableService.setOwner(document, OwnableService.NO_OWNER);
|
||||
|
||||
appendIdentifierToName(nodeService, document);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
Reference in New Issue
Block a user