RM: Transparent records management prototype WIP

* Create Record service and refactor
  * Add 'createRecord' method that preserves origional location(s) of the content
  * Add content readers information to record on extended security aspect
  * Experimental dynamic authority
  * DM action to 'create' record
  * Behaviour and methods to create and get new record container



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/INPLACE@41707 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2012-09-18 02:15:16 +00:00
parent f288e47d8a
commit 7b9912626c
55 changed files with 1632 additions and 6292 deletions

View File

@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -446,15 +447,6 @@ public interface RecordsManagementService
// TODO move? copy? link?
/********** Record methods **********/
/**
* Get a list of all the record meta-data aspects
*
* @return {@link Set}<{@link QName}> list of record meta-data aspects
*/
Set<QName> getRecordMetaDataAspects();
/**
* Get all the record folders that a record is filed into.
*
@@ -463,12 +455,27 @@ public interface RecordsManagementService
*/
// TODO rename to List<NodeRef> getParentRecordFolders(NodeRef record);
List<NodeRef> getRecordFolders(NodeRef record);
/********** Deprecated **********/
/**
* Get a list of all the record meta-data aspects
*
* @return {@link Set}<{@link QName}> list of record meta-data aspects
*
* @deprecated As of 2.1, replaced by {@link RecordService#getRecordMetaDataAspects()}
*/
@Deprecated
Set<QName> getRecordMetaDataAspects();
/**
* Indicates whether the record is declared
*
*
* @param nodeRef node reference (record)
* @return boolean true if record is declared, false otherwise
*
* @deprecated As of 2.1, replaced by {@link RecordsService#isDeclared()}
*/
boolean isRecordDeclared(NodeRef nodeRef);
@Deprecated
boolean isRecordDeclared(NodeRef nodeRef);
}

View File

@@ -20,7 +20,6 @@ package org.alfresco.module.org_alfresco_module_rm;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -38,7 +37,6 @@ import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -77,7 +75,6 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
private final static String MSG_PARENT_RECORD_FOLDER_ROOT = "rm.service.parent-record-folder-root";
private final static String MSG_PARENT_RECORD_FOLDER_TYPE = "rm.service.parent-record-folder-type";
private final static String MSG_RECORD_FOLDER_TYPE = "rm.service.record-folder-type";
private final static String MSG_NOT_RECORD = "rm.service.not-record";
/** Store that the RM roots are contained within */
@SuppressWarnings("unused")
@@ -105,9 +102,6 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
/** Well-known location of the scripts folder. */
private NodeRef scriptsFolderNodeRef = new NodeRef("workspace", "SpacesStore", "rm_scripts");
/** List of available record meta-data aspects */
private Set<QName> recordMetaDataAspects;
/** Java behaviour */
private JavaBehaviour onChangeToDispositionActionDefinition;
@@ -253,7 +247,7 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
throw new AlfrescoRuntimeException("Unable to complete operation, because only content can be filed within a record folder.");
}
}
}
}
/**
* On add content to container
@@ -1001,7 +995,7 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
List<NodeRef> records = getRecords(recordFolder);
for (NodeRef record : records)
{
if (isRecordDeclared(record) == false)
if (serviceRegistry.getRecordService().isDeclared(record) == false)
{
result = false;
break;
@@ -1120,31 +1114,6 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
return createRecordFolder(parent, name, type, null);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getRecordMetaDataAspects()
*/
public Set<QName> getRecordMetaDataAspects()
{
if (recordMetaDataAspects == null)
{
recordMetaDataAspects = new HashSet<QName>(7);
Collection<QName> aspects = dictionaryService.getAllAspects();
for (QName aspect : aspects)
{
AspectDefinition def = dictionaryService.getAspect(aspect);
if (def != null)
{
QName parent = def.getParentName();
if (parent != null && ASPECT_RECORD_META_DATA.equals(parent) == true)
{
recordMetaDataAspects.add(aspect);
}
}
}
}
return recordMetaDataAspects;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getRecords(org.alfresco.service.cmr.repository.NodeRef)
*/
@@ -1164,21 +1133,7 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
}
}
return result;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isRecord(org.alfresco.service.cmr.repository.NodeRef, boolean)
*/
public boolean isRecordDeclared(NodeRef record)
{
if (isRecord(record) == false)
{
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NOT_RECORD, record.toString()));
}
return (this.nodeService.hasAspect(record, ASPECT_DECLARED_RECORD));
}
}
/**
* This method examines the old and new property sets and for those properties which
@@ -1271,4 +1226,24 @@ public class RecordsManagementServiceImpl implements RecordsManagementService,
return result;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#getRecordMetaDataAspects()
*/
@Override
@Deprecated
public Set<QName> getRecordMetaDataAspects()
{
return serviceRegistry.getRecordService().getRecordMetaDataAspects();
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementService#isRecordDeclared(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
@Deprecated
public boolean isRecordDeclared(NodeRef nodeRef)
{
return serviceRegistry.getRecordService().isDeclared(nodeRef);
}
}

View File

@@ -23,6 +23,7 @@ import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditSe
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
import org.alfresco.service.NotAuditable;
import org.alfresco.service.ServiceRegistry;
@@ -45,6 +46,7 @@ public interface RecordsManagementServiceRegistry extends ServiceRegistry
static final QName RECORDS_MANAGEMENT_SECURITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementSecurityService");
static final QName RECORDS_MANAGEMENT_AUDIT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordsManagementAuditService");
static final QName CAPABILITY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CapabilityService");
static final QName RECORD_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "RecordService");
/**
* @return records management service
@@ -52,6 +54,12 @@ public interface RecordsManagementServiceRegistry extends ServiceRegistry
@NotAuditable
RecordsManagementService getRecordsManagementService();
/**
* @return record service
*/
@NotAuditable
RecordService getRecordService();
/**
* @return disposition service
*/

View File

@@ -23,6 +23,7 @@ import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditSe
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
import org.alfresco.repo.service.ServiceDescriptorRegistry;
@@ -65,6 +66,14 @@ public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegis
{
return (RecordsManagementService)getService(RECORDS_MANAGEMENT_SERVICE);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordService()
*/
public RecordService getRecordService()
{
return (RecordService)getService(RECORD_SERVICE);
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementSecurityService()
@@ -74,7 +83,7 @@ public class RecordsManagementServiceRegistryImpl extends ServiceDescriptorRegis
return (RecordsManagementSecurityService)getService(RECORDS_MANAGEMENT_SECURITY_SERVICE);
}
/*
/**
* @see org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry#getRecordsManagementAuditService()
*/
public RecordsManagementAuditService getRecordsManagementAuditService()

View File

@@ -41,6 +41,7 @@ import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
@@ -99,6 +100,9 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra
/** Records management service */
protected RecordsManagementService recordsManagementService;
/** Record service */
protected RecordService recordService;
/** Disposition service */
protected DispositionService dispositionService;
@@ -193,6 +197,11 @@ public abstract class RMActionExecuterAbstractBase extends ActionExecuterAbstra
this.recordsManagementService = recordsManagementService;
}
public void setRecordService(RecordService recordService)
{
this.recordService = recordService;
}
/**
* Set the disposition service
*/

View File

@@ -100,7 +100,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx
if (this.recordsManagementService.isRecord(actionedUponNodeRef) == true)
{
// Can only execute disposition action on record if declared
if (this.recordsManagementService.isRecordDeclared(actionedUponNodeRef) == true)
if (recordService.isDeclared(actionedUponNodeRef) == true)
{
// Indicate that the disposition action is underway
this.nodeService.setProperty(nextDispositionActionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT, new Date());
@@ -315,7 +315,7 @@ public abstract class RMDispositionActionExecuterAbstractBase extends RMActionEx
if (this.recordsManagementService.isRecord(filePlanComponent) == true)
{
// Can only execute disposition action on record if declared
if (this.recordsManagementService.isRecordDeclared(filePlanComponent) == true)
if (recordService.isDeclared(filePlanComponent) == true)
{
return true;
}

View File

@@ -0,0 +1,148 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.action.dm;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
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.permission.RecordReadersDynamicAuthority;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
/**
* Creates a new record from an existing content object.
*
* Note: This is a 'normal' dm action, rather than a records management action.
*
* @author Roy Wetherall
*/
public class CreateRecordAction extends ActionExecuterAbstractBase
implements RecordsManagementModel
{
private RecordsManagementService recordsManagementService;
private RecordService recordService;
private PermissionService permissionService;
private NodeService nodeService;
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
{
this.recordsManagementService = recordsManagementService;
}
public void setRecordService(RecordService recordService)
{
this.recordService = recordService;
}
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
@Override
protected void executeImpl(Action action, final NodeRef actionedUponNodeRef)
{
// TODO we should use the file plan passed as a parameter
// grab the file plan
List<NodeRef> filePlans = recordsManagementService.getFilePlans();
if (filePlans.size() == 1)
{
final NodeRef filePlan = filePlans.get(0);
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
// get the documents readers
Long aclId = nodeService.getNodeAclId(actionedUponNodeRef);
Set<String> readers = permissionService.getReaders(aclId);
// get the documents primary parent assoc
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(actionedUponNodeRef);
/// get the new record container for the file plan
NodeRef newRecordContainer = recordService.getNewRecordContainer(filePlan);
if (newRecordContainer == null)
{
throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found.");
}
// move the document into the file plan
nodeService.moveNode(actionedUponNodeRef, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
// maintain the original primary location
nodeService.addChild(parentAssoc.getParentRef(), actionedUponNodeRef, parentAssoc.getTypeQName(), parentAssoc.getQName());
// add extended security information to the record
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
props.put(PROP_READERS, (Serializable)readers);
nodeService.addAspect(actionedUponNodeRef, ASPECT_EXTENDED_RECORD_SECURITY, props);
// add permission so readers can still 'see' the new record
// Note: using the regular permission service as we don't want to reflect this permission up (and down) the
// hierarchy
permissionService.setPermission(actionedUponNodeRef,
RecordReadersDynamicAuthority.RECORD_READERS,
RMPermissionModel.READ_RECORDS,
true);
return null;
}
});
}
else
{
throw new AlfrescoRuntimeException("Unable to file file plan.");
}
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> params)
{
// TODO eventually we will need to pass in the file plan as a parameter
// TODO .. or the RM site
}
}

View File

@@ -64,7 +64,7 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
{
if (recordsManagementService.isRecord(actionedUponNodeRef) == true)
{
if (recordsManagementService.isRecordDeclared(actionedUponNodeRef) == false)
if (recordService.isDeclared(actionedUponNodeRef) == false)
{
List<String> missingProperties = new ArrayList<String>(5);
// Aspect not already defined - check mandatory properties then add
@@ -195,7 +195,7 @@ public class DeclareRecordAction extends RMActionExecuterAbstractBase
{
if (recordsManagementService.isRecord(filePlanComponent) == true)
{
if (recordsManagementService.isRecordDeclared(filePlanComponent) == false)
if (recordService.isDeclared(filePlanComponent) == false)
{
// Aspect not already defined - check mandatory properties then add
List<String> missingProperties = new ArrayList<String>(10);

View File

@@ -114,7 +114,7 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase
if (recordsManagementService.isRecord(actionedUponNodeRef) == true)
{
if (recordsManagementService.isRecordDeclared(actionedUponNodeRef) == false)
if (recordService.isDeclared(actionedUponNodeRef) == false)
{
ChildAssociationRef parent = nodeService.getPrimaryParent(actionedUponNodeRef);
@@ -175,7 +175,7 @@ public class SplitEmailAction extends RMActionExecuterAbstractBase
{
if (recordsManagementService.isRecord(filePlanComponent) == true)
{
if (recordsManagementService.isRecordDeclared(filePlanComponent))
if (recordService.isDeclared(filePlanComponent))
{
if (throwException)
{

View File

@@ -48,7 +48,7 @@ public class UndeclareRecordAction extends RMActionExecuterAbstractBase
{
if (recordsManagementService.isRecord(actionedUponNodeRef) == true)
{
if (recordsManagementService.isRecordDeclared(actionedUponNodeRef) == true)
if (recordService.isDeclared(actionedUponNodeRef) == true)
{
// Remove the declared aspect
this.nodeService.removeAspect(actionedUponNodeRef, ASPECT_DECLARED_RECORD);
@@ -73,7 +73,7 @@ public class UndeclareRecordAction extends RMActionExecuterAbstractBase
{
if (recordsManagementService.isRecord(filePlanComponent) == true)
{
if (recordsManagementService.isRecordDeclared(filePlanComponent) == true)
if (recordService.isDeclared(filePlanComponent) == true)
{
return true;
}

View File

@@ -22,7 +22,7 @@ import net.sf.acegisecurity.vote.AccessDecisionVoter;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.caveat.RMCaveatConfigComponent;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -45,6 +45,7 @@ public class RMSecurityCommon
protected NodeService nodeService;
protected PermissionService permissionService;
protected RecordsManagementService rmService;
protected RecordService recordService;
protected RMCaveatConfigComponent caveatConfigComponent;
public void setNodeService(NodeService nodeService)
@@ -62,6 +63,11 @@ public class RMSecurityCommon
this.rmService = rmService;
}
public void setRecordService(RecordService recordService)
{
this.recordService = recordService;
}
public void setCaveatConfigComponent(RMCaveatConfigComponent caveatConfigComponent)
{
this.caveatConfigComponent = caveatConfigComponent;

View File

@@ -20,6 +20,7 @@ package org.alfresco.module.org_alfresco_module_rm.capability.declarative;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.springframework.beans.factory.BeanNameAware;
@@ -38,6 +39,7 @@ public abstract class AbstractCapabilityCondition implements CapabilityCondition
/** Services */
protected RecordsManagementService rmService;
protected RecordService recordService;
protected PermissionService permissionService;
protected NodeService nodeService;
@@ -49,6 +51,14 @@ public abstract class AbstractCapabilityCondition implements CapabilityCondition
this.rmService = rmService;
}
/**
* @param recordService record service
*/
public void setRecordService(RecordService recordService)
{
this.recordService = recordService;
}
/**
* @param permissionService permission service
*/

View File

@@ -128,6 +128,9 @@ public class DeclarativeCapability extends AbstractCapability
this.isUndetermined = isUndetermined;
}
/**
* @return
*/
public boolean isUndetermined()
{
return isUndetermined;

View File

@@ -33,7 +33,7 @@ public class DeclaredCapabilityCondition extends AbstractCapabilityCondition
boolean result = false;
if (FilePlanComponentKind.RECORD.equals(rmService.getFilePlanComponentKind(nodeRef)) == true)
{
result = rmService.isRecordDeclared(nodeRef);
result = recordService.isDeclared(nodeRef);
}
return result;
}

View File

@@ -70,7 +70,7 @@ public class CreateCapability extends DeclarativeCapability
{
if(linkee == null)
{
if(rmService.isRecord(destination) && rmService.isRecordDeclared(destination) == false)
if(rmService.isRecord(destination) && recordService.isDeclared(destination) == false)
{
if (permissionService.hasPermission(destination, RMPermissionModel.FILE_RECORDS) == AccessStatus.ALLOWED)
{
@@ -80,7 +80,7 @@ public class CreateCapability extends DeclarativeCapability
}
else
{
if(rmService.isRecord(linkee) && rmService.isRecord(destination) && rmService.isRecordDeclared(destination) == false)
if(rmService.isRecord(linkee) && rmService.isRecord(destination) && recordService.isDeclared(destination) == false)
{
if (permissionService.hasPermission(destination, RMPermissionModel.FILE_RECORDS) == AccessStatus.ALLOWED)
{

View File

@@ -25,6 +25,7 @@ import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.repo.forms.Field;
import org.alfresco.repo.forms.FieldGroup;
import org.alfresco.repo.forms.Form;
@@ -58,6 +59,7 @@ public abstract class RecordsManagementFormFilter<ItemType> extends AbstractFilt
protected RecordsManagementServiceRegistry rmServiceRegistry;
protected RecordsManagementService rmService;
protected RecordsManagementAdminService rmAdminService;
protected RecordService recordService;
/**
* Sets the NamespaceService instance
@@ -109,6 +111,14 @@ public abstract class RecordsManagementFormFilter<ItemType> extends AbstractFilt
this.rmAdminService = rmAdminService;
}
/**
* @param recordService record service
*/
public void setRecordService(RecordService recordService)
{
this.recordService = recordService;
}
/**
* Add property fields to group
*

View File

@@ -166,7 +166,7 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
protected void addRecordMetadataPropertyFieldsToGroup(Form form, NodeRef nodeRef)
{
Set<QName> aspects = rmService.getRecordMetaDataAspects();
Set<QName> aspects = recordService.getRecordMetaDataAspects();
for (QName aspect : aspects)
{
@@ -214,7 +214,7 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
{
if (rmService.isRecord(nodeRef) == true)
{
addTransientPropertyField(form, TRANSIENT_DECLARED, DataTypeDefinition.BOOLEAN, rmService.isRecordDeclared(nodeRef));
addTransientPropertyField(form, TRANSIENT_DECLARED, DataTypeDefinition.BOOLEAN, recordService.isDeclared(nodeRef));
}
DispositionSchedule ds = dispositionService.getDispositionSchedule(nodeRef);

View File

@@ -120,7 +120,7 @@ public class IdentifierServiceImpl implements IdentifierService
}
/**
* Generate an identifier for a given type of object with the acompanying context.
* Generate an identifier for a given type of object with the accompanying context.
*
* @param type content type
* @param context context

View File

@@ -28,6 +28,7 @@ import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AccessStatus;
@@ -49,6 +50,9 @@ public abstract class BaseEvaluator implements RecordsManagementModel
/** Records management service */
protected RecordsManagementService recordsManagementService;
/** Record service */
protected RecordService recordService;
/** Node service */
protected NodeService nodeService;
@@ -80,6 +84,14 @@ public abstract class BaseEvaluator implements RecordsManagementModel
this.recordsManagementService = recordsManagementService;
}
/**
* @param recordService record service
*/
public void setRecordService(RecordService recordService)
{
this.recordService = recordService;
}
/**
* @param nodeService node service
*/

View File

@@ -25,6 +25,7 @@ import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
@@ -41,6 +42,9 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
/** Records management service */
private RecordsManagementService recordsManagementService;
/** Record service */
private RecordService recordService;
/** Capability service */
private CapabilityService capabilityService;
@@ -56,7 +60,15 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
{
this.recordsManagementService = recordsManagementService;
}
}
/**
* @param recordService record service
*/
public void setRecordService(RecordService recordService)
{
this.recordService = recordService;
}
/**
* @param capabilityService capability service
@@ -219,7 +231,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
}
else
{
if (recordsManagementService.isRecordDeclared(nodeRef) == true)
if (recordService.isDeclared(nodeRef) == true)
{
result = "record";
}

View File

@@ -35,7 +35,7 @@ public class SplitEmailActionEvaluator extends BaseEvaluator
protected boolean evaluateImpl(NodeRef nodeRef)
{
boolean result = false;
if (recordsManagementService.isRecordDeclared(nodeRef) == false)
if (recordService.isDeclared(nodeRef) == false)
{
ContentData contentData = (ContentData)nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
if (contentData != null)

View File

@@ -57,6 +57,9 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
// Records management root container
public static final QName TYPE_FILE_PLAN = QName.createQName(RM_URI, "filePlan");
// New records container
public static final QName TYPE_NEW_RECORDS_CONTAINER = QName.createQName(RM_URI, "newRecordsContainer");
// Disposition instructions aspect
public static final QName ASPECT_SCHEDULED = QName.createQName(RM_URI, "scheduled");
public static final QName ASSOC_DISPOSITION_SCHEDULE = QName.createQName(RM_URI, "dispositionSchedule");
@@ -167,6 +170,7 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
public static final QName ASPECT_RECORDS_MANAGEMENT_ROOT = QName.createQName(RM_URI, "recordsManagementRoot");
public static final QName ASSOC_HOLDS = QName.createQName(RM_URI, "holds");
public static final QName ASSOC_TRANSFERS = QName.createQName(RM_URI, "transfers");
public static final QName ASSOC_NEW_RECORDS = QName.createQName(RM_URI, "newRecords");
// Hold type
public static final QName TYPE_HOLD = QName.createQName(RM_URI, "hold");
@@ -219,4 +223,8 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
public static final QName PROP_RS_DISPOITION_INSTRUCTIONS = QName.createQName(RM_URI, "recordSearchDispositionInstructions");
public static final QName PROP_RS_DISPOITION_AUTHORITY = QName.createQName(RM_URI, "recordSearchDispositionAuthority");
public static final QName PROP_RS_HOLD_REASON = QName.createQName(RM_URI, "recordSearchHoldReason");
// Extended record security aspect
public static final QName ASPECT_EXTENDED_RECORD_SECURITY = QName.createQName(RM_URI, "extendedRecordSecurity");
public static final QName PROP_READERS = QName.createQName(RM_URI, "readers");
}

View File

@@ -16,12 +16,13 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model;
package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.copy.AbstractCopyBehaviourCallback;
import org.alfresco.repo.copy.CopyBehaviourCallback;
import org.alfresco.repo.copy.CopyDetails;

View File

@@ -0,0 +1,115 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
/**
* Behaviour associated with the file plan type
*
* @author Roy Wetherall
*/
public class FilePlanType implements RecordsManagementModel,
NodeServicePolicies.OnCreateNodePolicy
{
/** Policy component */
private PolicyComponent policyComponent;
/** Node service */
private NodeService nodeService;
/** Permission service */
private PermissionService permissionService;
/** New record container name */
private static final String NAME_NR_CONTAINER = "New Records";
/**
* Set the policy component
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
/**
* Set node service
* @param nodeService node service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
/**
* Bean initialisation method
*/
public void init()
{
policyComponent.bindClassBehaviour(
NodeServicePolicies.OnCreateNodePolicy.QNAME,
TYPE_FILE_PLAN,
new JavaBehaviour(this, "onCreateNode", NotificationFrequency.TRANSACTION_COMMIT));
}
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy#onCreateNode(org.alfresco.service.cmr.repository.ChildAssociationRef)
*/
@Override
public void onCreateNode(ChildAssociationRef assoc)
{
// grab the newly created file plan
NodeRef filePlan = assoc.getChildRef();
// create the properties map
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1);
properties.put(ContentModel.PROP_NAME, NAME_NR_CONTAINER);
// create the 'new records' folder
NodeRef container = nodeService.createNode(
filePlan,
ASSOC_NEW_RECORDS,
QName.createQName(RM_URI, NAME_NR_CONTAINER),
TYPE_NEW_RECORDS_CONTAINER,
properties).getChildRef();
// set inheritance to false
permissionService.setInheritParentPermissions(container, false);
}
}

View File

@@ -16,11 +16,12 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model;
package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import java.io.Serializable;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;

View File

@@ -16,11 +16,12 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model;
package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model;
package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import java.io.Serializable;
import java.util.ArrayList;
@@ -26,6 +26,7 @@ import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.copy.AbstractCopyBehaviourCallback;
import org.alfresco.repo.copy.CopyBehaviourCallback;
import org.alfresco.repo.copy.CopyDetails;

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model;
package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import java.io.Serializable;
import java.util.ArrayList;
@@ -36,6 +36,7 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedul
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionScheduleImpl;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition;
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService;
import org.alfresco.repo.policy.JavaBehaviour;
@@ -315,13 +316,22 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
}
}
public void onAddRecordAspect(NodeRef nodeRef, QName aspectTypeQName)
public void onAddRecordAspect(final NodeRef nodeRef, final QName aspectTypeQName)
{
if (nodeService.exists(nodeRef) == true)
AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<Void>()
{
applySearchAspect(nodeRef);
setupDispositionScheduleProperties(nodeRef);
}
@Override
public Void doWork() throws Exception
{
if (nodeService.exists(nodeRef) == true)
{
applySearchAspect(nodeRef);
setupDispositionScheduleProperties(nodeRef);
}
return null;
}
});
}
public void recordFolderCreate(ChildAssociationRef childAssocRef)
@@ -494,13 +504,22 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
}
}
public void rmSearchAspectAdd(NodeRef nodeRef, QName aspectTypeQName)
{
if (nodeService.exists(nodeRef) == true)
public void rmSearchAspectAdd(final NodeRef nodeRef, final QName aspectTypeQName)
{
AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<Void>()
{
// Initialise the search parameteres as required
setVitalRecordDefintionDetails(nodeRef);
}
@Override
public Void doWork() throws Exception
{
if (nodeService.exists(nodeRef) == true)
{
// Initialise the search parameteres as required
setVitalRecordDefintionDetails(nodeRef);
}
return null;
}
});
}
public void vitalRecordDefintionAddAspect(NodeRef nodeRef, QName aspectTypeQName)

View File

@@ -16,8 +16,9 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model;
package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour;

View File

@@ -16,9 +16,10 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.model;
package org.alfresco.module.org_alfresco_module_rm.model.behaviour;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;

View File

@@ -1,370 +0,0 @@
package org.alfresco.module.org_alfresco_module_rm.permission;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.domain.permissions.AclDAO;
import org.alfresco.repo.security.permissions.AccessControlEntry;
import org.alfresco.repo.security.permissions.AccessControlList;
import org.alfresco.repo.security.permissions.PermissionEntry;
import org.alfresco.repo.security.permissions.PermissionReference;
import org.alfresco.repo.security.permissions.impl.ModelDAO;
import org.alfresco.repo.security.permissions.impl.PermissionServiceImpl;
import org.alfresco.repo.security.permissions.impl.RequiredPermission;
import org.alfresco.repo.security.permissions.impl.SimplePermissionReference;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
public class OtherImpl extends PermissionServiceImpl
{
static SimplePermissionReference RM_OLD_ALL_PERMISSIONS_REFERENCE = SimplePermissionReference.getPermissionReference(
QName.createQName("", PermissionService.ALL_PERMISSIONS),
PermissionService.ALL_PERMISSIONS);
private SimpleCache<Serializable, Set<String>> rmReadersCache;
private AclDAO rmAclDaoComponent;
private ModelDAO rmModelDao;
public void setRmReadersCache(SimpleCache<Serializable, Set<String>> rmReadersCache)
{
this.rmReadersCache = rmReadersCache;
}
public void setRmAclDAO(AclDAO rmAclDaoComponent)
{
this.rmAclDaoComponent = rmAclDaoComponent;
}
public void setRmModelDAO(ModelDAO rmModelDao)
{
this.rmModelDao = rmModelDao;
}
@Override
public void setAnyDenyDenies(boolean anyDenyDenies)
{
super.setAnyDenyDenies(anyDenyDenies);
rmReadersCache.clear();
}
@Override
public Set<String> getReaders(Long aclId)
{
Set<String> dmReaders = super.getReaders(aclId);
Set<String> rmReaders = rmReadersCache.get(aclId);
if (rmReaders == null)
{
rmReaders = buildRMReaders(aclId);
rmReadersCache.put(aclId, rmReaders);
}
Set<String> result = new HashSet<String>();
result.addAll(dmReaders);
result.addAll(rmReaders);
return result;
}
private Set<String> buildRMReaders(Long aclId)
{
AccessControlList acl = rmAclDaoComponent.getAccessControlList(aclId);
if (acl == null)
{
return Collections.emptySet();
}
HashSet<String> assigned = new HashSet<String>();
HashSet<String> readers = new HashSet<String>();
for (AccessControlEntry ace : acl.getEntries())
{
assigned.add(ace.getAuthority());
}
PermissionReference permissionRef = getPermissionReference(RMPermissionModel.READ_RECORDS);
for (String authority : assigned)
{
RMUnconditionalAclTest rmTest = new RMUnconditionalAclTest(permissionRef);
if (rmTest.evaluate(authority, aclId))
{
readers.add(authority);
}
}
return Collections.unmodifiableSet(readers);
}
/**
* Ignores type and aspect requirements on the node
*
*/
private class RMUnconditionalAclTest
{
/*
* The required permission.
*/
PermissionReference required;
/*
* Granters of the permission
*/
Set<PermissionReference> granters;
/*
* The additional permissions required at the node level.
*/
Set<PermissionReference> nodeRequirements = new HashSet<PermissionReference>();
/*
* Constructor just gets the additional requirements
*/
RMUnconditionalAclTest(PermissionReference required)
{
this.required = required;
// Set the required node permissions
if (required.equals(getPermissionReference(ALL_PERMISSIONS)))
{
nodeRequirements = rmModelDao.getUnconditionalRequiredPermissions(getPermissionReference(PermissionService.FULL_CONTROL), RequiredPermission.On.NODE);
}
else
{
nodeRequirements = rmModelDao.getUnconditionalRequiredPermissions(required, RequiredPermission.On.NODE);
}
if (rmModelDao.getUnconditionalRequiredPermissions(required, RequiredPermission.On.PARENT).size() > 0)
{
throw new IllegalStateException("Parent permissions can not be checked for an acl");
}
if (rmModelDao.getUnconditionalRequiredPermissions(required, RequiredPermission.On.CHILDREN).size() > 0)
{
throw new IllegalStateException("Child permissions can not be checked for an acl");
}
// Find all the permissions that grant the allowed permission
// All permissions are treated specially.
granters = new LinkedHashSet<PermissionReference>(128, 1.0f);
granters.addAll(rmModelDao.getGrantingPermissions(required));
granters.add(getAllPermissionReference());
granters.add(RM_OLD_ALL_PERMISSIONS_REFERENCE);
}
/**
* Internal hook point for recursion
*
* @param authorisations
* @param nodeRef
* @param denied
* @param recursiveIn
* @return true if granted
*/
boolean evaluate(String authority, Long aclId)
{
// Start out true and "and" all other results
boolean success = true;
// Check the required permissions but not for sets they rely on
// their underlying permissions
//if (modelDAO.checkPermission(required))
//{
// We have to do the test as no parent will help us out
success &= hasSinglePermission(authority, aclId);
if (!success)
{
return false;
}
//}
// Check the other permissions required on the node
for (PermissionReference pr : nodeRequirements)
{
// Build a new test
RMUnconditionalAclTest nt = new RMUnconditionalAclTest(pr);
success &= nt.evaluate(authority, aclId);
if (!success)
{
return false;
}
}
return success;
}
boolean hasSinglePermission(String authority, Long aclId)
{
// Check global permission
if (checkGlobalPermissions(authority))
{
return true;
}
if(aclId == null)
{
return false;
}
else
{
return checkRequired(authority, aclId);
}
}
/**
* Check if we have a global permission
*
* @param authorisations
* @return true if granted
*/
private boolean checkGlobalPermissions(String authority)
{
for (PermissionEntry pe : rmModelDao.getGlobalPermissionEntries())
{
if (isGranted(pe, authority))
{
return true;
}
}
return false;
}
/**
* Check that a given authentication is available on a node
*
* @param authorisations
* @param nodeRef
* @param denied
* @return true if a check is required
*/
boolean checkRequired(String authority, Long aclId)
{
AccessControlList acl = rmAclDaoComponent.getAccessControlList(aclId);
if (acl == null)
{
return false;
}
Set<Pair<String, PermissionReference>> denied = new HashSet<Pair<String, PermissionReference>>();
// Check if each permission allows - the first wins.
// We could have other voting style mechanisms here
for (AccessControlEntry ace : acl.getEntries())
{
if (isGranted(ace, authority, denied))
{
return true;
}
}
return false;
}
/**
* Is a permission granted
*
* @param pe -
* the permissions entry to consider
* @param granters -
* the set of granters
* @param authorisations -
* the set of authorities
* @param denied -
* the set of denied permissions/authority pais
* @return true if granted
*/
private boolean isGranted(AccessControlEntry ace, String authority, Set<Pair<String, PermissionReference>> denied)
{
// If the permission entry denies then we just deny
if (ace.getAccessStatus() == AccessStatus.DENIED)
{
denied.add(new Pair<String, PermissionReference>(ace.getAuthority(), ace.getPermission()));
Set<PermissionReference> granters = rmModelDao.getGrantingPermissions(ace.getPermission());
for (PermissionReference granter : granters)
{
denied.add(new Pair<String, PermissionReference>(ace.getAuthority(), granter));
}
// All the things granted by this permission must be
// denied
Set<PermissionReference> grantees = rmModelDao.getGranteePermissions(ace.getPermission());
for (PermissionReference grantee : grantees)
{
denied.add(new Pair<String, PermissionReference>(ace.getAuthority(), grantee));
}
// All permission excludes all permissions available for
// the node.
if (ace.getPermission().equals(getAllPermissionReference()) || ace.getPermission().equals(RM_OLD_ALL_PERMISSIONS_REFERENCE))
{
for (PermissionReference deny : rmModelDao.getAllPermissions())
{
denied.add(new Pair<String, PermissionReference>(ace.getAuthority(), deny));
}
}
return false;
}
// The permission is allowed but we deny it as it is in the denied
// set
if (denied != null)
{
Pair<String, PermissionReference> specific = new Pair<String, PermissionReference>(ace.getAuthority(), required);
if (denied.contains(specific))
{
return false;
}
}
// If the permission has a match in both the authorities and
// granters list it is allowed
// It applies to the current user and it is granted
if (authority.equals(ace.getAuthority()) && granters.contains(ace.getPermission()))
{
{
return true;
}
}
// Default deny
return false;
}
private boolean isGranted(PermissionEntry pe, String authority)
{
// If the permission entry denies then we just deny
if (pe.isDenied())
{
return false;
}
// If the permission has a match in both the authorities and
// granters list it is allowed
// It applies to the current user and it is granted
if (granters.contains(pe.getPermissionReference()) && authority.equals(pe.getAuthority()))
{
{
return true;
}
}
// Default deny
return false;
}
}
}

View File

@@ -0,0 +1,130 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.permission;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.security.permissions.DynamicAuthority;
import org.alfresco.repo.security.permissions.PermissionReference;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* @author Roy Wetherall
* @since 2.1
*/
public class RecordReadersDynamicAuthority implements DynamicAuthority, RecordsManagementModel, ApplicationContextAware
{
public static final String RECORD_READERS = "ROLE_RECORD_READERS";
private RecordsManagementService recordsManagementService;
private NodeService nodeService;
private AuthorityService authorityService;
private ApplicationContext applicationContext;
private RecordsManagementService getRecordsManagementService()
{
if (recordsManagementService == null)
{
recordsManagementService = (RecordsManagementService)applicationContext.getBean("recordsManagementService");
}
return recordsManagementService;
}
private NodeService getNodeService()
{
if (nodeService == null)
{
nodeService = (NodeService)applicationContext.getBean("nodeService");
}
return nodeService;
}
private AuthorityService getAuthorityService()
{
if (authorityService == null)
{
authorityService = (AuthorityService)applicationContext.getBean("authorityService");
}
return authorityService;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
this.applicationContext = applicationContext;
}
/**
* @see org.alfresco.repo.security.permissions.DynamicAuthority#getAuthority()
*/
@Override
public String getAuthority()
{
return RECORD_READERS;
}
/**
* @see org.alfresco.repo.security.permissions.DynamicAuthority#hasAuthority(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
*/
@SuppressWarnings("unchecked")
@Override
public boolean hasAuthority(NodeRef nodeRef, String userName)
{
boolean result = false;
FilePlanComponentKind kind = getRecordsManagementService().getFilePlanComponentKind(nodeRef);
if (FilePlanComponentKind.RECORD.equals(kind) == true)
{
if (getNodeService().hasAspect(nodeRef, ASPECT_EXTENDED_RECORD_SECURITY) == true)
{
result = true;
System.out.println("Setting hasAuthority to true! - " + userName + " - " + nodeRef.toString());
// Set<String> readers = (Set<String>)nodeService.getProperty(nodeRef, PROP_READERS);
// for (String reader : readers)
// {
// // check to see if the user is one of the readers or is contained there within
// }
}
}
return result;
}
/**
* @see org.alfresco.repo.security.permissions.DynamicAuthority#requiredFor()
*/
@Override
public Set<PermissionReference> requiredFor()
{
return null;
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.record;
import java.util.Set;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
*
* @author Roy Wetherall
* @since 2.1
*/
public interface RecordService
{
/**
* Get a list of all the record meta-data aspects
*
* @return {@link Set}<{@link QName}> list of record meta-data aspects
*/
Set<QName> getRecordMetaDataAspects();
/**
* Indicates whether the record is declared
*
* @param nodeRef node reference (record)
* @return boolean true if record is declared, false otherwise
*/
boolean isDeclared(NodeRef nodeRef);
// TODO boolean isRecordFiled(NodeRef record);
// TODO boolean isRecordClassified(NodeRef record);
NodeRef getNewRecordContainer(NodeRef filePlan);
NodeRef createRecord(NodeRef filePlan, NodeRef document);
// TODO NodeRef createAndFileRecord(NodeRef recordFolder, NodeRef document);
// TODO void fileRecord(NodeRef recordFolder, NodeRef record);
}

View File

@@ -0,0 +1,201 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.record;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.identifier.IdentifierService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
/**
* @author Roy Wetherall
* @since 2.1
*/
public class RecordServiceImpl implements RecordService, RecordsManagementModel
{
private NodeService nodeService;
private IdentifierService identifierService;
private RecordsManagementService recordsManagementService;
private DictionaryService dictionaryService;
private PolicyComponent policyComponent;
/** List of available record meta-data aspects */
private Set<QName> recordMetaDataAspects;
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setIdentifierService(IdentifierService identifierService)
{
this.identifierService = identifierService;
}
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
{
this.recordsManagementService = recordsManagementService;
}
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
public void init()
{
policyComponent.bindAssociationBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateChildAssociation"),
TYPE_NEW_RECORDS_CONTAINER,
ContentModel.ASSOC_CONTAINS,
new JavaBehaviour(this, "onCreateNewRecord", NotificationFrequency.TRANSACTION_COMMIT));
}
public void onCreateNewRecord(ChildAssociationRef childAssocRef, boolean bNew)
{
NodeRef nodeRef = childAssocRef.getChildRef();
if (nodeService.exists(nodeRef) == true)
{
QName type = nodeService.getType(nodeRef);
if (ContentModel.TYPE_CONTENT.equals(type) == true ||
dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT) == true)
{
makeRecord(nodeRef);
}
else
{
throw new AlfrescoRuntimeException("Only content can be created as a record.");
}
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects()
*/
public Set<QName> getRecordMetaDataAspects()
{
if (recordMetaDataAspects == null)
{
recordMetaDataAspects = new HashSet<QName>(7);
Collection<QName> aspects = dictionaryService.getAllAspects();
for (QName aspect : aspects)
{
AspectDefinition def = dictionaryService.getAspect(aspect);
if (def != null)
{
QName parent = def.getParentName();
if (parent != null && ASPECT_RECORD_META_DATA.equals(parent) == true)
{
recordMetaDataAspects.add(aspect);
}
}
}
}
return recordMetaDataAspects;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#isDeclared(org.alfresco.service.cmr.repository.NodeRef)
*/
public boolean isDeclared(NodeRef record)
{
return (nodeService.hasAspect(record, ASPECT_DECLARED_RECORD));
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getNewRecordContainer(org.alfresco.service.cmr.repository.NodeRef)
*/
public NodeRef getNewRecordContainer(NodeRef filePlan)
{
NodeRef result = null;
if (recordsManagementService.isFilePlan(filePlan) == true)
{
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(filePlan, ASSOC_NEW_RECORDS, RegexQNamePattern.MATCH_ALL);
if (assocs.size() != 1)
{
throw new AlfrescoRuntimeException("Error getting the new record container, because the container cannot be indentified.");
}
result = assocs.get(0).getChildRef();
}
return result;
}
@Override
public NodeRef createRecord(NodeRef filePlan, NodeRef document)
{
// get the documents primary parent assoc
ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(document);
/// get the new record container for the file plan
NodeRef newRecordContainer = getNewRecordContainer(filePlan);
if (newRecordContainer == null)
{
throw new AlfrescoRuntimeException("Unable to create record, because new record container could not be found.");
}
// move the document into the file plan
nodeService.moveNode(document, newRecordContainer, ContentModel.ASSOC_CONTAINS, parentAssoc.getQName());
// maintain the original primary location
nodeService.addChild(parentAssoc.getParentRef(), document, parentAssoc.getTypeQName(), parentAssoc.getQName());
return document;
}
/**
*
* @param document
*/
private void makeRecord(NodeRef document)
{
nodeService.addAspect(document, RecordsManagementModel.ASPECT_RECORD, null);
String recordId = identifierService.generateIdentifier(ASPECT_RECORD, nodeService.getPrimaryParent(document).getParentRef());
nodeService.setProperty(document, PROP_IDENTIFIER, recordId);
}
}

View File

@@ -33,8 +33,8 @@ import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementSearchBehaviour;
import org.alfresco.module.org_alfresco_module_rm.model.RmSiteType;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RmSiteType;
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
import org.alfresco.module.org_alfresco_module_rm.security.Role;
import org.alfresco.repo.security.authentication.AuthenticationUtil;

View File

@@ -20,28 +20,28 @@ package org.alfresco.module.org_alfresco_module_rm.script;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.alfresco.model.ContentModel;
import org.alfresco.model.RenditionModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementSearchBehaviour;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour;
import org.alfresco.repo.exporter.ACPExportPackageHandler;
import org.alfresco.repo.web.scripts.content.StreamACP;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.view.ExporterCrawlerParameters;
import org.alfresco.service.cmr.view.Location;
import org.alfresco.service.namespace.QName;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
/**
* Creates an RM specific ACP file of nodes to export then streams it back

View File

@@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.namespace.NamespaceService;
@@ -41,7 +41,7 @@ public class RecordMetaDataAspectsGet extends DeclarativeWebScript
{
protected DictionaryService dictionaryService;
protected NamespaceService namespaceService;
protected RecordsManagementService recordsManagementService;
protected RecordService recordService;
/**
* Set the dictionary service instance
@@ -62,10 +62,13 @@ public class RecordMetaDataAspectsGet extends DeclarativeWebScript
{
this.namespaceService = namespaceService;
}
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
/**
* @param recordService record service
*/
public void setRecordService(RecordService recordService)
{
this.recordsManagementService = recordsManagementService;
this.recordService = recordService;
}
/*
@@ -75,7 +78,7 @@ public class RecordMetaDataAspectsGet extends DeclarativeWebScript
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
// Get the details of all the aspects
Set<QName> aspectQNames = recordsManagementService.getRecordMetaDataAspects();
Set<QName> aspectQNames = recordService.getRecordMetaDataAspects();
List<Map<String, Object>> aspects = new ArrayList<Map<String,Object>>(aspectQNames.size()+1);
for (QName aspectQName : aspectQNames)
{

View File

@@ -24,17 +24,17 @@ import java.io.IOException;
import org.alfresco.model.ContentModel;
import org.alfresco.model.RenditionModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementSearchBehaviour;
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.RecordsManagementSearchBehaviour;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.view.ExporterCrawlerParameters;
import org.alfresco.service.cmr.view.Location;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Streams the nodes of a transfer object to the client in the form of an

View File

@@ -25,7 +25,7 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementAdminService;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
@@ -43,35 +43,45 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
*/
public class RMSearchPropertiesGet extends DeclarativeWebScript
{
private RecordsManagementAdminService adminService;
private RecordsManagementService recordsManagementService;
private DictionaryService dictionaryService;
/** Services */
private RecordsManagementAdminService adminService;
private RecordService recordService;
private DictionaryService dictionaryService;
private NamespaceService namespaceService;
/**
* @param adminService records management admin service
*/
public void setAdminService(RecordsManagementAdminService adminService)
{
this.adminService = adminService;
}
public void setRecordsManagementService(RecordsManagementService recordsManagementService)
/**
* @param recordService record service
*/
public void setRecordService(RecordService recordService)
{
this.recordsManagementService = recordsManagementService;
this.recordService = recordService;
}
/**
* @param dictionaryService dictionary service
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/**
* @param namespaceService namespace service
*/
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
/*
/**
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
*/
@Override
@@ -81,7 +91,7 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript
List<Group> groups = new ArrayList<Group>(5);
Set<QName> aspects = recordsManagementService.getRecordMetaDataAspects();
Set<QName> aspects = recordService.getRecordMetaDataAspects();
for (QName aspect : aspects)
{
Map<QName, PropertyDefinition> properties = dictionaryService.getPropertyDefs(aspect);