mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +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:
@@ -17,6 +17,19 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Bootstrap DoD record metadata aspects -->
|
||||
<bean id="dod.recordMetadataAspectBootstrap" parent="recordMetadataAspectBootstrap">
|
||||
<property name="recordMetadataAspects">
|
||||
<map>
|
||||
<entry key="dod:dod5015record" value="dod:filePlan" />
|
||||
<entry key="dod:scannedRecord" value="dod:filePlan" />
|
||||
<entry key="dod:pdfRecord" value="dod:filePlan" />
|
||||
<entry key="dod:digitalPhotographRecord" value="dod:filePlan" />
|
||||
<entry key="dod:webRecord" value="dod:filePlan" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Bootstap the message property files -->
|
||||
<bean id="org_alfresco_module_rm_resourceBundles.dod5015" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
|
||||
<property name="resourceBundles">
|
||||
|
@@ -75,10 +75,7 @@
|
||||
<!-- DOD5015 Record Properties -->
|
||||
<!-- @since 2.2 -->
|
||||
<aspect name="dod:dod5015record">
|
||||
|
||||
<title>DOD5015 Record</title>
|
||||
<parent>rma:recordMetaData</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
<property name="dod:publicationDate">
|
||||
@@ -168,7 +165,6 @@
|
||||
|
||||
<aspect name="dod:scannedRecord">
|
||||
<title>Scanned Record</title>
|
||||
<parent>rma:recordMetaData</parent>
|
||||
<properties>
|
||||
<property name="dod:scannedFormat">
|
||||
<title>Image Format</title>
|
||||
@@ -208,14 +204,10 @@
|
||||
<mandatory>false</mandatory>
|
||||
</property>
|
||||
</properties>
|
||||
<mandatory-aspects>
|
||||
<aspect>rma:filePlanComponent</aspect>
|
||||
</mandatory-aspects>
|
||||
</aspect>
|
||||
|
||||
<aspect name="dod:pdfRecord">
|
||||
<title>PDF Record</title>
|
||||
<parent>rma:recordMetaData</parent>
|
||||
<properties>
|
||||
<property name="dod:producingApplication">
|
||||
<title>Producing Application</title>
|
||||
@@ -263,14 +255,10 @@
|
||||
</index>
|
||||
</property>
|
||||
</properties>
|
||||
<mandatory-aspects>
|
||||
<aspect>rma:filePlanComponent</aspect>
|
||||
</mandatory-aspects>
|
||||
</aspect>
|
||||
|
||||
<aspect name="dod:digitalPhotographRecord">
|
||||
<title>Digital Photograph Record</title>
|
||||
<parent>rma:recordMetaData</parent>
|
||||
<properties>
|
||||
<property name="dod:caption">
|
||||
<title>Caption</title>
|
||||
@@ -358,14 +346,10 @@
|
||||
</index>
|
||||
</property>
|
||||
</properties>
|
||||
<mandatory-aspects>
|
||||
<aspect>rma:filePlanComponent</aspect>
|
||||
</mandatory-aspects>
|
||||
</aspect>
|
||||
|
||||
<aspect name="dod:webRecord">
|
||||
<title>Web Record</title>
|
||||
<parent>rma:recordMetaData</parent>
|
||||
<properties>
|
||||
<property name="dod:webFileName">
|
||||
<title>Web File Name</title>
|
||||
@@ -443,9 +427,6 @@
|
||||
</index>
|
||||
</property>
|
||||
</properties>
|
||||
<mandatory-aspects>
|
||||
<aspect>rma:filePlanComponent</aspect>
|
||||
</mandatory-aspects>
|
||||
</aspect>
|
||||
|
||||
</aspects>
|
||||
|
@@ -751,7 +751,9 @@
|
||||
|
||||
</aspect>
|
||||
|
||||
<!-- Marker aspect used to indicate an aspect is used for record meta-data -->
|
||||
<!-- Marker aspect used to indicate an aspect is used for record meta-data -->
|
||||
<!-- @deprecated since 2.2, record metadata aspects are configured via spring -->
|
||||
<!-- using a bootstrap bean -->
|
||||
<aspect name="rma:recordMetaData">
|
||||
</aspect>
|
||||
|
||||
|
@@ -34,6 +34,7 @@
|
||||
<bean id="rm-ac-record-types" class="org.alfresco.module.org_alfresco_module_rm.action.constraint.RecordTypeParameterConstraint" parent="action-constraint">
|
||||
<property name="recordService" ref="RecordService"/>
|
||||
<property name="dictionaryService" ref="DictionaryService"/>
|
||||
<property name="filePlanService" ref="FilePlanService" />
|
||||
</bean>
|
||||
|
||||
<bean id="rm-ac-manual-events" class="org.alfresco.module.org_alfresco_module_rm.action.constraint.ManualEventParameterConstraint" parent="action-constraint">
|
||||
|
@@ -1178,6 +1178,11 @@
|
||||
<property name="permissionService" ref="permissionService" />
|
||||
</bean>
|
||||
|
||||
<bean id="recordMetadataAspectBootstrap" class="org.alfresco.module.org_alfresco_module_rm.record.RecordMetadataBootstrap" init-method="init" abstract="true">
|
||||
<property name="recordService" ref="recordService"/>
|
||||
<property name="namespaceService" ref="namespaceService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="RecordService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.module.org_alfresco_module_rm.record.RecordService</value>
|
||||
@@ -1222,7 +1227,9 @@
|
||||
<property name="objectDefinitionSource">
|
||||
<value>
|
||||
<![CDATA[
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.registerRecordMetadataAspect=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.getRecordMetaDataAspects=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.getRecordMetadataAspects=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.isRecord=RM_ALLOW
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.isDeclared=RM.Read.0
|
||||
org.alfresco.module.org_alfresco_module_rm.record.RecordService.isFiled=RM.Read.0
|
||||
|
@@ -168,6 +168,7 @@
|
||||
<property name="recordService" ref="RecordService" />
|
||||
<property name="dictionaryService" ref="DictionaryService" />
|
||||
<property name="namespaceService" ref="NamespaceService" />
|
||||
<property name="filePlanService" ref="FilePlanService" />
|
||||
</bean>
|
||||
|
||||
<bean id="webscript.org.alfresco.rma.rmauditlogstatus.get"
|
||||
@@ -474,6 +475,7 @@
|
||||
<property name="dictionaryService" ref="DictionaryService" />
|
||||
<property name="adminService" ref="RecordsManagementAdminService" />
|
||||
<property name="recordService" ref="RecordService" />
|
||||
<property name="filePlanService" ref="FilePlanService" />
|
||||
</bean>
|
||||
|
||||
<bean id="webscript.org.alfresco.slingshot.forms.metadata.get"
|
||||
|
@@ -4,7 +4,7 @@
|
||||
Gets all the record meta data aspects available.
|
||||
]]>
|
||||
</description>
|
||||
<url>/api/rma/recordmetadataaspects</url>
|
||||
<url>/api/rma/recordmetadataaspects?noderef={?nodeRef}</url>
|
||||
<format default="json"/>
|
||||
<authentication>user</authentication>
|
||||
<transaction allow="readonly">required</transaction>
|
||||
|
@@ -54,6 +54,17 @@
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>add-test-source</id>
|
||||
<goals>
|
||||
<goal>add-test-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>unit-test/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -197,6 +208,12 @@
|
||||
<classifier>tests</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
|
@@ -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,9 +66,39 @@ 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,
|
||||
@@ -330,6 +335,8 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
onDeleteDeclaredRecordLink);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy#onRemoveAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
|
||||
*/
|
||||
@@ -575,29 +582,123 @@ 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
|
||||
@@ -81,6 +84,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)
|
||||
*/
|
||||
@@ -91,7 +102,12 @@ public class RMSearchPropertiesGet extends DeclarativeWebScript
|
||||
|
||||
List<Group> groups = new ArrayList<Group>(5);
|
||||
|
||||
Set<QName> aspects = recordService.getRecordMetaDataAspects();
|
||||
// get the file plan
|
||||
// TODO the file plan should be passed to this web script
|
||||
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
|
||||
// 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.
|
||||
*
|
||||
|
@@ -38,7 +38,8 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
ServicesTestSuite.class,
|
||||
WebScriptTestSuite.class,
|
||||
IssueTestSuite.class,
|
||||
ParameterProcessorTestSuite.class
|
||||
ParameterProcessorTestSuite.class,
|
||||
DoD5015TestSuite.class
|
||||
})
|
||||
public class AllTestSuite
|
||||
{
|
||||
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.dod.RM1147DODRMSiteTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.dod.RM1194ExcludeDoDRecordTypesTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
|
||||
/**
|
||||
* DoD 5015 integration test suite
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses(
|
||||
{
|
||||
RM1147DODRMSiteTest.class,
|
||||
RM1194ExcludeDoDRecordTypesTest.class
|
||||
})
|
||||
public class DoD5015TestSuite
|
||||
{
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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.test.dod;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
|
||||
|
||||
/**
|
||||
* Integration test for RM1147 - A user can create a 'vanilla' or DOD compliant records management site.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class RM1194ExcludeDoDRecordTypesTest extends BaseRMTestCase implements DOD5015Model
|
||||
{
|
||||
/**
|
||||
* Don't create a RM test site in setup
|
||||
*/
|
||||
@Override
|
||||
protected boolean isRMSiteTest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the correct record metadata aspects are available for a DoD record.
|
||||
*/
|
||||
public void testDODRecord()
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
String siteId = GUID.generate();
|
||||
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
siteService.createSite("dodrmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_DOD_5015_SITE);
|
||||
NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary");
|
||||
assertNotNull(filePlan);
|
||||
|
||||
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne");
|
||||
NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne");
|
||||
NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One");
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertNotNull(record);
|
||||
Set<QName> aspects = recordService.getRecordMetadataAspects(record);
|
||||
assertNotNull(aspects);
|
||||
assertEquals(5, aspects.size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the correct record metadata aspects are available for a vanilla record.
|
||||
*/
|
||||
public void testVanillaRecord()
|
||||
{
|
||||
doTestInTransaction(new Test<NodeRef>()
|
||||
{
|
||||
String siteId = GUID.generate();
|
||||
|
||||
@Override
|
||||
public NodeRef run() throws Exception
|
||||
{
|
||||
siteService.createSite("rmsite", siteId, "title", "description", SiteVisibility.PUBLIC, TYPE_RM_SITE);
|
||||
NodeRef filePlan = siteService.getContainer(siteId, "documentlibrary");
|
||||
assertNotNull(filePlan);
|
||||
|
||||
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, "testOne");
|
||||
NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, "testOne");
|
||||
NodeRef record = utils.createRecord(recordFolder, "testOne.txt", "Test One");
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void test(NodeRef record) throws Exception
|
||||
{
|
||||
assertNotNull(record);
|
||||
Set<QName> aspects = recordService.getRecordMetadataAspects(record);
|
||||
assertNotNull(aspects);
|
||||
assertEquals(1, aspects.size());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -32,6 +32,7 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
|
||||
|
||||
/**
|
||||
@@ -69,6 +70,7 @@ public class RM1039Test extends BaseRMTestCase
|
||||
assertNotNull(result);
|
||||
assertNull(dispositionService.getDispositionSchedule(result));
|
||||
assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
|
||||
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -87,6 +89,7 @@ public class RM1039Test extends BaseRMTestCase
|
||||
assertNotNull(result);
|
||||
assertNull(dispositionService.getDispositionSchedule(result));
|
||||
assertFalse(nodeService.hasAspect(result, ASPECT_DISPOSITION_LIFECYCLE));
|
||||
assertEquals(AccessStatus.ALLOWED, permissionService.hasPermission(result, FILING));
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -26,7 +26,6 @@ import java.util.Set;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||
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.role.FilePlanRoleService;
|
||||
@@ -94,9 +93,9 @@ public class RecordServiceImplTest extends BaseRMTestCase
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
Set<QName> aspects = recordService.getRecordMetaDataAspects();
|
||||
Set<QName> aspects = recordService.getRecordMetadataAspects(filePlan);
|
||||
assertNotNull(aspects);
|
||||
assertEquals(6, aspects.size());
|
||||
assertEquals(1, aspects.size());
|
||||
assertTrue(aspects.containsAll(getAspectList()));
|
||||
|
||||
return null;
|
||||
@@ -110,14 +109,9 @@ public class RecordServiceImplTest extends BaseRMTestCase
|
||||
private List<QName> getAspectList()
|
||||
{
|
||||
QName[] aspects = new QName[]
|
||||
{
|
||||
DOD5015Model.ASPECT_DIGITAL_PHOTOGRAPH_RECORD,
|
||||
DOD5015Model.ASPECT_PDF_RECORD,
|
||||
DOD5015Model.ASPECT_WEB_RECORD,
|
||||
DOD5015Model.ASPECT_SCANNED_RECORD,
|
||||
ASPECT_RECORD_META_DATA,
|
||||
DOD5015Model.ASPECT_DOD_5015_RECORD
|
||||
};
|
||||
{
|
||||
ASPECT_RECORD_META_DATA
|
||||
};
|
||||
|
||||
return Arrays.asList(aspects);
|
||||
}
|
||||
|
@@ -224,4 +224,13 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Test record metadata aspect -->
|
||||
<bean id="testRecordMetadataAspectBootstrap" parent="recordMetadataAspectBootstrap">
|
||||
<property name="recordMetadataAspects">
|
||||
<map>
|
||||
<entry key="rmt:recordMetaData" value="rma:filePlan" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -48,7 +48,6 @@
|
||||
</aspect>
|
||||
|
||||
<aspect name="rmt:recordMetaData">
|
||||
<parent>rma:recordMetaData</parent>
|
||||
</aspect>
|
||||
|
||||
</aspects>
|
||||
|
@@ -3,6 +3,7 @@
|
||||
<suite name="JUnit AllTestSuite" verbose="1" >
|
||||
<test name="AllTests" junit="true">
|
||||
<classes>
|
||||
<class name="org.alfresco.module.org_alfresco_module_rm.AllUnitTestSuite" />
|
||||
<class name="org.alfresco.module.org_alfresco_module_rm.test.AllTestSuite" />
|
||||
</classes>
|
||||
</test>
|
||||
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordMetadataBootstrapUnitTest;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordServiceImplUnitTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
|
||||
/**
|
||||
* All unit test suite.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses(
|
||||
{
|
||||
RecordMetadataBootstrapUnitTest.class,
|
||||
RecordServiceImplUnitTest.class
|
||||
})
|
||||
public class AllUnitTestSuite
|
||||
{
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.junit.Before;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
/**
|
||||
* Unit test for RecordServiceImpl
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class BaseUnitTest implements RecordsManagementModel
|
||||
{
|
||||
protected static NodeRef FILE_PLAN_COMPONENT = generateNodeRef();
|
||||
protected static NodeRef FILE_PLAN = generateNodeRef();
|
||||
|
||||
@Mock(name="nodeService") protected NodeService mockedNodeService;
|
||||
@Mock(name="dictionaryService") protected DictionaryService mockedDictionaryService;
|
||||
@Mock(name="namespaceService") protected NamespaceService mockedNamespaceService;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
// set-up node service
|
||||
when(mockedNodeService.getProperty(FILE_PLAN_COMPONENT, PROP_ROOT_NODEREF)).thenReturn(FILE_PLAN);
|
||||
when(mockedNodeService.getType(FILE_PLAN)).thenReturn(TYPE_FILE_PLAN);
|
||||
|
||||
// set-up namespace service
|
||||
when(mockedNamespaceService.getNamespaceURI(RM_PREFIX)).thenReturn(RM_URI);
|
||||
|
||||
}
|
||||
|
||||
protected static QName generateQName()
|
||||
{
|
||||
return QName.createQName(RM_URI, GUID.generate());
|
||||
}
|
||||
|
||||
protected static NodeRef generateNodeRef()
|
||||
{
|
||||
return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate());
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 static org.mockito.Mockito.verify;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.BaseUnitTest;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
/**
|
||||
* Unit test for RecordMetadataBootstrap
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RecordMetadataBootstrapUnitTest extends BaseUnitTest
|
||||
{
|
||||
@Mock(name="recordService") private RecordService mockedRecordService;
|
||||
|
||||
@InjectMocks private RecordMetadataBootstrap bootstrap;
|
||||
|
||||
/**
|
||||
* Test init method to ensure set map will register correctly with record service.
|
||||
*/
|
||||
@Test
|
||||
public void testInit()
|
||||
{
|
||||
// create and set map
|
||||
Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put("rma:test1", "rma:filePlan");
|
||||
map.put("rma:test2", "rma:filePlan");
|
||||
bootstrap.setRecordMetadataAspects(map);
|
||||
|
||||
// call init
|
||||
bootstrap.init();
|
||||
|
||||
// verify that the metedata aspects where registered
|
||||
QName test1 = QName.createQName(RM_URI, "test1");
|
||||
QName test2 = QName.createQName(RM_URI, "test2");
|
||||
verify(mockedRecordService).registerRecordMetadataAspect(test1, TYPE_FILE_PLAN);
|
||||
verify(mockedRecordService).registerRecordMetadataAspect(test2, TYPE_FILE_PLAN);
|
||||
}
|
||||
}
|
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.BaseUnitTest;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
|
||||
/**
|
||||
* Unit test for RecordServiceImpl
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class RecordServiceImplUnitTest extends BaseUnitTest
|
||||
{
|
||||
private static NodeRef NON_STANDARD_FILE_PLAN_COMPONENT = generateNodeRef();
|
||||
private static NodeRef NON_STANDARD_FILE_PLAN = generateNodeRef();
|
||||
|
||||
private static QName TYPE_MY_FILE_PLAN = generateQName();
|
||||
private static QName ASPECT_FOR_FILE_PLAN = generateQName();
|
||||
private static QName ASPECT_FOR_MY_FILE_PLAN = generateQName();
|
||||
private static QName ASPECT_FOR_BOTH = generateQName();
|
||||
|
||||
@InjectMocks private RecordServiceImpl recordService;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Before
|
||||
@Override
|
||||
public void before()
|
||||
{
|
||||
super.before();
|
||||
|
||||
// set-up node service
|
||||
when(mockedNodeService.getProperty(NON_STANDARD_FILE_PLAN_COMPONENT, PROP_ROOT_NODEREF)).thenReturn(NON_STANDARD_FILE_PLAN);
|
||||
when(mockedNodeService.getType(NON_STANDARD_FILE_PLAN)).thenReturn(TYPE_MY_FILE_PLAN);
|
||||
|
||||
// set-up dictionary service
|
||||
when(mockedDictionaryService.getAllAspects()).thenReturn(CollectionUtils.EMPTY_COLLECTION);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegisterRecordMetadataAspect()
|
||||
{
|
||||
Map<QName, Set<QName>> map = recordService.getRecordMetadataAspectsMap();
|
||||
assertTrue(map.isEmpty());
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_FILE_PLAN, TYPE_FILE_PLAN);
|
||||
map = recordService.getRecordMetadataAspectsMap();
|
||||
assertEquals(1, map.size());
|
||||
assertTrue(map.containsKey(ASPECT_FOR_FILE_PLAN));
|
||||
Set<QName> types = map.get(ASPECT_FOR_FILE_PLAN);
|
||||
assertNotNull(types);
|
||||
assertEquals(1, types.size());
|
||||
assertTrue(types.contains(TYPE_FILE_PLAN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecordMetadataAspects()
|
||||
{
|
||||
// register a couple of record meta-data aspects
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_FILE_PLAN, TYPE_FILE_PLAN);
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_MY_FILE_PLAN, TYPE_MY_FILE_PLAN);
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_BOTH, TYPE_FILE_PLAN);
|
||||
recordService.registerRecordMetadataAspect(ASPECT_FOR_BOTH, TYPE_MY_FILE_PLAN);
|
||||
|
||||
Set<QName> set = recordService.getRecordMetadataAspects(FILE_PLAN_COMPONENT);
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
assertTrue(set.contains(ASPECT_FOR_FILE_PLAN));
|
||||
assertTrue(set.contains(ASPECT_FOR_BOTH));
|
||||
|
||||
set = recordService.getRecordMetadataAspects(NON_STANDARD_FILE_PLAN_COMPONENT);
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
assertTrue(set.contains(ASPECT_FOR_MY_FILE_PLAN));
|
||||
assertTrue(set.contains(ASPECT_FOR_BOTH));
|
||||
|
||||
set = recordService.getRecordMetadataAspects(TYPE_FILE_PLAN);
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
assertTrue(set.contains(ASPECT_FOR_FILE_PLAN));
|
||||
assertTrue(set.contains(ASPECT_FOR_BOTH));
|
||||
|
||||
set = recordService.getRecordMetadataAspects(TYPE_MY_FILE_PLAN);
|
||||
assertNotNull(set);
|
||||
assertEquals(2, set.size());
|
||||
assertTrue(set.contains(ASPECT_FOR_MY_FILE_PLAN));
|
||||
assertTrue(set.contains(ASPECT_FOR_BOTH));
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user