mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1194: As a records manager I want to create a 'standard' RM site that only displays records meta-data types relevant to standard RM practices, so that I don't get confused by unwanted DoD records meta-data types.
* record metadata aspects are now configured via spring and includes which file plan type they are relevant for * added 'unit test' structure .. for 'real' unit tests, ie anything that doesn't load the application context * included Mockito, new source location and unit test suite into POM * added unit and functional tests for feature (server) * refactored accordingly (webscripts, UI, etc) * visual test of UI .. automation tests to follow git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63013 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,11 +23,13 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
|
||||
import org.alfresco.repo.i18n.StaticMessageLookup;
|
||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
@@ -41,31 +43,54 @@ public class RecordTypeParameterConstraint extends BaseParameterConstraint
|
||||
/** Name constant */
|
||||
public static final String NAME = "rm-ac-record-types";
|
||||
|
||||
/** record service */
|
||||
private RecordService recordService;
|
||||
|
||||
/** dictionary service */
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
/** file plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
*/
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService dictionary service
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
|
||||
*/
|
||||
protected Map<String, String> getAllowableValuesImpl()
|
||||
{
|
||||
Set<QName> recordTypes = recordService.getRecordMetaDataAspects();
|
||||
// get the file plan
|
||||
// TODO we will likely have to re-implement as a custom control so that context of the file
|
||||
// plan can be correctly determined when setting the rule up
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
|
||||
Set<QName> recordTypes = recordService.getRecordMetadataAspects(filePlan);
|
||||
|
||||
Map<String, String> result = new HashMap<String, String>(recordTypes.size());
|
||||
for (QName recordType : recordTypes)
|
||||
{
|
||||
|
||||
AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType);
|
||||
if (aspectDefinition != null)
|
||||
{
|
||||
|
@@ -329,36 +329,6 @@ public class FilePlanServiceImpl extends ServiceBaseImpl
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlan(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public NodeRef getFilePlan(NodeRef nodeRef)
|
||||
{
|
||||
NodeRef result = null;
|
||||
if (nodeRef != null)
|
||||
{
|
||||
result = (NodeRef)getInternalNodeService().getProperty(nodeRef, PROP_ROOT_NODEREF);
|
||||
if (result == null)
|
||||
{
|
||||
if (instanceOf(nodeRef, TYPE_FILE_PLAN) == true)
|
||||
{
|
||||
result = nodeRef;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChildAssociationRef parentAssocRef = getInternalNodeService().getPrimaryParent(nodeRef);
|
||||
if (parentAssocRef != null)
|
||||
{
|
||||
result = getFilePlan(parentAssocRef.getParentRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlanBySiteId(java.lang.String)
|
||||
*/
|
||||
|
@@ -182,7 +182,7 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
|
||||
*/
|
||||
protected void addRecordMetadataPropertyFieldsToGroup(Form form, NodeRef nodeRef)
|
||||
{
|
||||
Set<QName> aspects = recordService.getRecordMetaDataAspects();
|
||||
Set<QName> aspects = recordService.getRecordMetadataAspects(nodeRef);
|
||||
|
||||
for (QName aspect : aspects)
|
||||
{
|
||||
|
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 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.Map;
|
||||
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Record metadata bootstrap bean.
|
||||
* <p>
|
||||
* This method of bootstrapping record metadata aspects into the RecordService deprecates the
|
||||
* previous practice of extending rma:recordMetaData.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class RecordMetadataBootstrap
|
||||
{
|
||||
/** record service */
|
||||
private RecordService recordService;
|
||||
|
||||
/** namespace service */
|
||||
private NamespaceService namespaceService;
|
||||
|
||||
/** map of record metadata aspects against file plan type */
|
||||
private Map<String, String> recordMetadataAspects;
|
||||
|
||||
/**
|
||||
* @param recordMetadataAspects map of record metadata aspects against file plan types
|
||||
*/
|
||||
public void setRecordMetadataAspects(Map<String, String> recordMetadataAspects)
|
||||
{
|
||||
this.recordMetadataAspects = recordMetadataAspects;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService namespace service
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
*/
|
||||
public void setRecordService(RecordService recordService)
|
||||
{
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init method
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
ParameterCheck.mandatory("recordService", recordService);
|
||||
ParameterCheck.mandatory("namespaceService", namespaceService);
|
||||
|
||||
if (recordMetadataAspects != null)
|
||||
{
|
||||
for (Map.Entry<String, String> entry : recordMetadataAspects.entrySet())
|
||||
{
|
||||
// convert to qname's
|
||||
QName recordMetadataAspect = QName.createQName(entry.getKey(), namespaceService);
|
||||
QName filePlanType = QName.createQName(entry.getValue(), namespaceService);
|
||||
|
||||
// register with record service
|
||||
recordService.registerRecordMetadataAspect(recordMetadataAspect, filePlanType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -36,6 +36,22 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public interface RecordService
|
||||
{
|
||||
/**
|
||||
* Register a record metadata aspect.
|
||||
* <p>
|
||||
* The file plan type indicates which file plan type the aspect applied to. Null indicates that
|
||||
* the aspect applies to rma:filePlan.
|
||||
* <p>
|
||||
* A record metadata aspect can be registered more than once if it applies to more than one
|
||||
* file plan type.
|
||||
*
|
||||
* @param recordMetadataAspect record metadata aspect qualified name
|
||||
* @param filePlanType file plan type
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
void registerRecordMetadataAspect(QName recordMetadataAspect, QName filePlanType);
|
||||
|
||||
/**
|
||||
* Disables the property editable check.
|
||||
*/
|
||||
@@ -50,8 +66,38 @@ public interface RecordService
|
||||
* Gets a list of all the record meta-data aspects
|
||||
*
|
||||
* @return {@link Set}<{@link QName}> list of record meta-data aspects
|
||||
*
|
||||
* @deprecated since 2.2, file plan component required to provide context
|
||||
*/
|
||||
@Deprecated
|
||||
Set<QName> getRecordMetaDataAspects();
|
||||
|
||||
/**
|
||||
* Gets a list of all the record metadata aspects relevant to the file plan type of the
|
||||
* file plan component provided.
|
||||
* <p>
|
||||
* If a null context is provided all record meta-data aspects are returned, but this is not
|
||||
* recommended.
|
||||
*
|
||||
* @param nodeRef node reference to file plan component providing context
|
||||
* @return {@link Set}<{@link QName}> list of record meta-data aspects
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
Set<QName> getRecordMetadataAspects(NodeRef nodeRef);
|
||||
|
||||
/**
|
||||
* Gets a list of all the record metadata aspect that relate to the provided file plan type.
|
||||
* <p>
|
||||
* If null is provided for the file plan type then record metadata aspects for the default
|
||||
* file plan type (rma:filePlan) are returned.
|
||||
*
|
||||
* @param filePlanType file plan type
|
||||
* @return{@link Set}<{@link QName}> list of record meta-data aspects
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
Set<QName> getRecordMetadataAspects(QName filePlanType);
|
||||
|
||||
/**
|
||||
* Checks whether if the given node reference is a record or not
|
||||
|
@@ -22,11 +22,13 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
@@ -117,6 +119,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA
|
||||
};
|
||||
|
||||
/** always edit model URI's */
|
||||
private static final String[] ALWAYS_EDIT_URIS = new String[]
|
||||
{
|
||||
NamespaceService.SECURITY_MODEL_1_0_URI,
|
||||
@@ -129,6 +132,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
NamespaceService.RENDITION_MODEL_1_0_URI
|
||||
};
|
||||
|
||||
/** record model URI's */
|
||||
private static final String[] RECORD_MODEL_URIS = new String[]
|
||||
{
|
||||
RM_URI,
|
||||
@@ -136,6 +140,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
DOD5015Model.DOD_URI
|
||||
};
|
||||
|
||||
/** non-record model URI's */
|
||||
private static final String[] NON_RECORD_MODEL_URIS = new String[]
|
||||
{
|
||||
NamespaceService.AUDIO_MODEL_1_0_URI,
|
||||
@@ -187,8 +192,8 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
/** Permission service */
|
||||
private PermissionService permissionService;
|
||||
|
||||
/** List of available record meta-data aspects */
|
||||
private Set<QName> recordMetaDataAspects;
|
||||
/** list of available record meta-data aspects and the file plan types the are applicable to */
|
||||
private Map<QName, Set<QName>> recordMetaDataAspects;
|
||||
|
||||
/** policies */
|
||||
private ClassPolicyDelegate<BeforeFileRecord> beforeFileRecord;
|
||||
@@ -313,11 +318,11 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
/** bind policies */
|
||||
// bind policies
|
||||
beforeFileRecord = policyComponent.registerClassPolicy(BeforeFileRecord.class);
|
||||
onFileRecord = policyComponent.registerClassPolicy(OnFileRecord.class);
|
||||
|
||||
/** bind behaviours */
|
||||
// bind behaviours
|
||||
policyComponent.bindAssociationBehaviour(
|
||||
NodeServicePolicies.OnCreateChildAssociationPolicy.QNAME,
|
||||
TYPE_RECORD_FOLDER,
|
||||
@@ -327,9 +332,11 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
NodeServicePolicies.BeforeDeleteChildAssociationPolicy.QNAME,
|
||||
ContentModel.TYPE_FOLDER,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
onDeleteDeclaredRecordLink);
|
||||
onDeleteDeclaredRecordLink);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
@@ -573,31 +580,125 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects()
|
||||
* Get map containing record metadata aspects.
|
||||
*
|
||||
* @return {@link Map}<{@link QName}, {@link Set}<{@link QName}>> map containing record metadata aspects
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
@Override
|
||||
public Set<QName> getRecordMetaDataAspects()
|
||||
protected Map<QName, Set<QName>> getRecordMetadataAspectsMap()
|
||||
{
|
||||
if (recordMetaDataAspects == null)
|
||||
{
|
||||
Collection<QName> aspects = dictionaryService.getAllAspects();
|
||||
recordMetaDataAspects = new HashSet<QName>(aspects.size());
|
||||
for (QName aspect : aspects)
|
||||
// create map
|
||||
recordMetaDataAspects = new HashMap<QName, Set<QName>>();
|
||||
|
||||
// init with legacy aspects
|
||||
initRecordMetaDataMap();
|
||||
}
|
||||
|
||||
return recordMetaDataAspects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the record meta-data map.
|
||||
* <p>
|
||||
* This is here to support backwards compatibility in case an existing
|
||||
* customization (pre 2.2) is still using the record meta-data aspect.
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
private void initRecordMetaDataMap()
|
||||
{
|
||||
// populate the inital set of record meta-data aspects .. this is here for legacy reasons
|
||||
Collection<QName> aspects = dictionaryService.getAllAspects();
|
||||
for (QName aspect : aspects)
|
||||
{
|
||||
AspectDefinition def = dictionaryService.getAspect(aspect);
|
||||
if (def != null)
|
||||
{
|
||||
AspectDefinition def = dictionaryService.getAspect(aspect);
|
||||
if (def != null)
|
||||
QName parent = def.getParentName();
|
||||
if (parent != null && ASPECT_RECORD_META_DATA.equals(parent) )
|
||||
{
|
||||
QName parent = def.getParentName();
|
||||
if (parent != null && ASPECT_RECORD_META_DATA.equals(parent) )
|
||||
{
|
||||
recordMetaDataAspects.add(aspect);
|
||||
}
|
||||
recordMetaDataAspects.put(aspect, Collections.singleton(TYPE_FILE_PLAN));
|
||||
}
|
||||
}
|
||||
}
|
||||
return recordMetaDataAspects;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#registerRecordMetadataAspect(org.alfresco.service.namespace.QName, org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
@Override
|
||||
public void registerRecordMetadataAspect(QName recordMetadataAspect, QName filePlanType)
|
||||
{
|
||||
ParameterCheck.mandatory("recordMetadataAspect", recordMetadataAspect);
|
||||
ParameterCheck.mandatory("filePlanType", filePlanType);
|
||||
|
||||
Set<QName> filePlanTypes = null;
|
||||
|
||||
if (getRecordMetadataAspectsMap().containsKey(recordMetadataAspect))
|
||||
{
|
||||
// get the current set of file plan types for this aspect
|
||||
filePlanTypes = (Set<QName>)getRecordMetadataAspectsMap().get(recordMetadataAspect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// create a new set for the file plan type
|
||||
filePlanTypes = new HashSet<QName>(1);
|
||||
getRecordMetadataAspectsMap().put(recordMetadataAspect, filePlanTypes);
|
||||
}
|
||||
|
||||
// add the file plan type
|
||||
filePlanTypes.add(filePlanType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 2.2, file plan is required to provide context
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Set<QName> getRecordMetaDataAspects()
|
||||
{
|
||||
return getRecordMetadataAspects(TYPE_FILE_PLAN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetaDataAspects(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public Set<QName> getRecordMetadataAspects(NodeRef nodeRef)
|
||||
{
|
||||
QName filePlanType = TYPE_FILE_PLAN;
|
||||
|
||||
if (nodeRef != null)
|
||||
{
|
||||
NodeRef filePlan = getFilePlan(nodeRef);
|
||||
filePlanType = nodeService.getType(filePlan);
|
||||
}
|
||||
|
||||
return getRecordMetadataAspects(filePlanType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#getRecordMetadataAspects(org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
@Override
|
||||
public Set<QName> getRecordMetadataAspects(QName filePlanType)
|
||||
{
|
||||
Set<QName> result = new HashSet<QName>(getRecordMetadataAspectsMap().size());
|
||||
|
||||
for (Entry<QName, Set<QName>> entry : getRecordMetadataAspectsMap().entrySet())
|
||||
{
|
||||
if (entry.getValue().contains(filePlanType))
|
||||
{
|
||||
result.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -24,9 +24,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
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.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
@@ -35,13 +37,19 @@ import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* Record metadata aspects GET
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RecordMetaDataAspectsGet extends DeclarativeWebScript
|
||||
{
|
||||
/** parameters */
|
||||
private static final String PARAM_NODEREF = "noderef";
|
||||
|
||||
protected DictionaryService dictionaryService;
|
||||
protected NamespaceService namespaceService;
|
||||
protected RecordService recordService;
|
||||
protected FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* Set the dictionary service instance
|
||||
@@ -71,14 +79,37 @@ public class RecordMetaDataAspectsGet extends DeclarativeWebScript
|
||||
this.recordService = recordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
// Get the nodeRef and confirm it is valid
|
||||
NodeRef nodeRef = null;
|
||||
String nodeRefValue = req.getParameter(PARAM_NODEREF);
|
||||
if (nodeRefValue == null || nodeRefValue.trim().length() == 0)
|
||||
{
|
||||
// get the file plan if a node ref hasn't been specified
|
||||
// TODO will need to remove when multi file plans supported
|
||||
nodeRef = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
nodeRef = new NodeRef(nodeRefValue);
|
||||
}
|
||||
|
||||
// Get the details of all the aspects
|
||||
Set<QName> aspectQNames = recordService.getRecordMetaDataAspects();
|
||||
Set<QName> aspectQNames = recordService.getRecordMetadataAspects(nodeRef);
|
||||
List<Map<String, Object>> aspects = new ArrayList<Map<String,Object>>(aspectQNames.size()+1);
|
||||
for (QName aspectQName : aspectQNames)
|
||||
{
|
||||
|
@@ -25,10 +25,12 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
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;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
@@ -37,7 +39,7 @@ import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
/**
|
||||
* RM serach properties GET web script
|
||||
* RM search properties GET web script
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
@@ -48,6 +50,7 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript
|
||||
private RecordService recordService;
|
||||
private DictionaryService dictionaryService;
|
||||
private NamespaceService namespaceService;
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/**
|
||||
* @param adminService records management admin service
|
||||
@@ -80,6 +83,14 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
public void setFilePlanService(FilePlanService filePlanService)
|
||||
{
|
||||
this.filePlanService = filePlanService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||
@@ -90,8 +101,13 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript
|
||||
Map<String, Object> model = new HashMap<String, Object>(13);
|
||||
|
||||
List<Group> groups = new ArrayList<Group>(5);
|
||||
|
||||
// get the file plan
|
||||
// TODO the file plan should be passed to this web script
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
|
||||
Set<QName> aspects = recordService.getRecordMetaDataAspects();
|
||||
// get the record metadata aspects
|
||||
Set<QName> aspects = recordService.getRecordMetadataAspects(filePlan);
|
||||
for (QName aspect : aspects)
|
||||
{
|
||||
Map<QName, PropertyDefinition> properties = dictionaryService.getPropertyDefs(aspect);
|
||||
|
@@ -21,7 +21,10 @@ package org.alfresco.module.org_alfresco_module_rm.util;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
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.QName;
|
||||
@@ -71,6 +74,50 @@ public class ServiceBaseImpl implements RecordsManagementModel
|
||||
return nodeService.hasAspect(nodeRef, ASPECT_RECORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file plan that a given file plan component resides within.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return {@link NodeRef} file plan, null if none
|
||||
*/
|
||||
public NodeRef getFilePlan(final NodeRef nodeRef)
|
||||
{
|
||||
NodeRef result = null;
|
||||
if (nodeRef != null)
|
||||
{
|
||||
RunAsWork<NodeRef> runAsWork = new RunAsWork<NodeRef>()
|
||||
{
|
||||
@Override
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
NodeRef result = (NodeRef)nodeService.getProperty(nodeRef, PROP_ROOT_NODEREF);
|
||||
if (result == null)
|
||||
{
|
||||
if (instanceOf(nodeRef, TYPE_FILE_PLAN) == true)
|
||||
{
|
||||
result = nodeRef;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChildAssociationRef parentAssocRef = nodeService.getPrimaryParent(nodeRef);
|
||||
if (parentAssocRef != null)
|
||||
{
|
||||
result = getFilePlan(parentAssocRef.getParentRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
result = AuthenticationUtil.runAsSystem(runAsWork);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to safely and quickly determine if a node is a type (or sub-type) of the one specified.
|
||||
*
|
||||
|
Reference in New Issue
Block a user