RM-614: Can't complete record without "Complete Record" capability

* added enable/disable property check methods to record service .. useful when setting 'system' properties



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@54807 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-09-03 00:59:04 +00:00
parent 3e8270eaf7
commit 74eaebf9f5
3 changed files with 58 additions and 16 deletions

View File

@@ -69,22 +69,30 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
// Aspect not already defined - check mandatory properties then add
if (mandatoryPropertiesSet(actionedUponNodeRef, missingProperties) == true)
{
// Add the declared aspect
Map<QName, Serializable> declaredProps = new HashMap<QName, Serializable>(2);
declaredProps.put(PROP_DECLARED_AT, new Date());
declaredProps.put(PROP_DECLARED_BY, AuthenticationUtil.getRunAsUser());
this.nodeService.addAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD, declaredProps);
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
// remove all owner related rights
ownableService.setOwner(actionedUponNodeRef, OwnableService.NO_OWNER);
return null;
}
});
recordService.disablePropertyEditableCheck();
try
{
// Add the declared aspect
Map<QName, Serializable> declaredProps = new HashMap<QName, Serializable>(2);
declaredProps.put(PROP_DECLARED_AT, new Date());
declaredProps.put(PROP_DECLARED_BY, AuthenticationUtil.getRunAsUser());
this.nodeService.addAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD, declaredProps);
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
// remove all owner related rights
ownableService.setOwner(actionedUponNodeRef, OwnableService.NO_OWNER);
return null;
}
});
}
finally
{
recordService.enablePropertyEditableCheck();
}
}
else
{

View File

@@ -35,6 +35,16 @@ import org.alfresco.service.namespace.QName;
*/
public interface RecordService
{
/**
* Disables the property editable check.
*/
void disablePropertyEditableCheck();
/**
* Enables the property editable check. By default this is always enabled.
*/
void enablePropertyEditableCheck();
/**
* Gets a list of all the record meta-data aspects
*

View File

@@ -416,6 +416,24 @@ public class RecordServiceImpl implements RecordService,
onUpdateProperties.enable();
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#disablePropertyEditableCheck()
*/
@Override
public void disablePropertyEditableCheck()
{
onUpdateProperties.disable();
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#enablePropertyEditableCheck()
*/
@Override
public void enablePropertyEditableCheck()
{
onUpdateProperties.enable();
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects()
@@ -1031,6 +1049,12 @@ public class RecordServiceImpl implements RecordService,
return result;
}
/**
* Helper method that indicates whether a property is considered record metadata or not.
*
* @param property property
* @return boolea true if record metadata, false otherwise
*/
private boolean isRecordMetadata(QName property)
{
boolean result = ArrayUtils.contains(RECORD_MODEL_URIS, property.getNamespaceURI());