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:
@@ -464,8 +464,8 @@ public class RecordFolderTests extends BaseRMRestTest
|
||||
assertEquals(record.getParentId(), containerId);
|
||||
|
||||
//check the record name
|
||||
assertFalse(record.getName().equals(createdComponent.getName()),
|
||||
"Record Name"+ record.getName()+" doesn't contain the record identifier");
|
||||
assertTrue(record.getName().equals(createdComponent.getName()),
|
||||
"Record Name"+ record.getName()+" doesn't match the one returned on create");
|
||||
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()),
|
||||
"Record Name"+ createdComponent.getName()+" doesn't contain the record identifier in response when creating");
|
||||
assertEquals(createdComponent.getNodeType(), record.getNodeType());
|
||||
|
@@ -488,7 +488,7 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
||||
"The record name "+ record.getName()+" is not equal with the record name returned when creating the record " + createdComponent
|
||||
.getName());
|
||||
|
||||
assertTrue(record.getName().equals(record.getProperties().getIdentifier()));
|
||||
assertTrue(record.getName().contains(record.getProperties().getIdentifier()));
|
||||
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()));
|
||||
assertEquals(createdComponent.getNodeType(), record.getNodeType());
|
||||
|
||||
|
@@ -27,11 +27,23 @@
|
||||
|
||||
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(
|
||||
@@ -39,8 +51,22 @@ public class WriteContentPolicy extends AbstractBasePolicy
|
||||
Class[] params,
|
||||
ConfigAttributeDefinition cad)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ import java.util.List;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
@@ -408,8 +409,10 @@ public class RM978Test extends BaseRMTestCase
|
||||
List<ChildAssociationRef> rmFolderChildAssocs = nodeService.getChildAssocs(rmFolder);
|
||||
assertEquals(1, rmFolderChildAssocs.size());
|
||||
NodeRef movedDocument = rmFolderChildAssocs.iterator().next().getChildRef();
|
||||
String recordIdentifier = (String) nodeService.getProperty(movedDocument, RecordsManagementModel.PROP_IDENTIFIER);
|
||||
assertNotNull(recordIdentifier);
|
||||
String movedDocumentName = (String) nodeService.getProperty(movedDocument, ContentModel.PROP_NAME);
|
||||
assertEquals(document1Name, movedDocumentName);
|
||||
assertEquals(document1Name + " (" + recordIdentifier + ")", movedDocumentName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user