Merged BRANCHES/V2.0 to HEAD:

52115: RM-732: CLONE - "caveat" functionality of the (dod5015) Records Management Module is not cluster-aware
   52262: RM-757: Permission confusion after upgrade from 1.0
   52264: RM:  Unable to set list of values after migration from 1.0->2.0.3
   52294: RM-769 (Impossible to add access for several values)
   52340: RM: Saved searches where not being upgraded correctly
       * searches resaved on upgrade (to account for updated model)
       * searches are public by defalut
       * relates to RM-758



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@52341 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-07-10 06:34:29 +00:00
11 changed files with 632 additions and 236 deletions

View File

@@ -684,7 +684,6 @@
<property name="rma:reviewPeriod"> <property name="rma:reviewPeriod">
<title>Review Period</title> <title>Review Period</title>
<type>d:period</type> <type>d:period</type>
<mandatory>true</mandatory>
<default>none|0</default> <default>none|0</default>
</property> </property>
<property name="rma:vitalRecordIndicator"> <property name="rma:vitalRecordIndicator">

View File

@@ -64,6 +64,19 @@
<property name="nodeService" ref="NodeService"/> <property name="nodeService" ref="NodeService"/>
<property name="recordsManagementService" ref="RecordsManagementService" /> <property name="recordsManagementService" ref="RecordsManagementService" />
<property name="behaviourFilter" ref="policyBehaviourFilter"/> <property name="behaviourFilter" ref="policyBehaviourFilter"/>
<property name="permissionService" ref="PermissionService"/>
<property name="recordsManagementSecurityService" ref="RecordsManagementSecurityService" />
</bean>
<bean id="org_alfresco_module_rm_RMv2SavedSearchPatch"
parent="module.baseComponent"
class="org.alfresco.module.org_alfresco_module_rm.patch.RMv2SavedSearchPatch">
<property name="moduleId" value="org_alfresco_module_rm"/>
<property name="name" value="org_alfresco_module_rm_RMv2SavedSearchPatch"/>
<property name="description" value="Patches the existing saved seaches."/>
<property name="sinceVersion" value="2.0"/>
<property name="appliesFromVersion" value="2.0"/>
<property name="recordsManagementSearchService" ref="RecordsManagementSearchService" />
</bean> </bean>
<bean id="org_alfresco_module_rm_RMv21InPlacePatch" <bean id="org_alfresco_module_rm_RMv21InPlacePatch"

View File

@@ -1309,6 +1309,41 @@
<property name="caveatAspects" ref="caveatAspects"/> <property name="caveatAspects" ref="caveatAspects"/>
<property name="caveatModels" ref="caveatModels"/> <property name="caveatModels" ref="caveatModels"/>
<property name="caveatConfig" ref="caveatConfigCache"/>
</bean>
<!-- ===================================== -->
<!-- Record Management Caveat Config Cache -->
<!-- ===================================== -->
<!-- The cross-transaction shared cache for in-memory CaveatConfig -->
<bean name="caveatConfigSharedCache" class="org.alfresco.repo.cache.EhCacheAdapter">
<property name="cache">
<bean class="org.springframework.cache.ehcache.EhCacheFactoryBean" >
<property name="cacheManager">
<ref bean="internalEHCacheManager" />
</property>
<property name="cacheName">
<value>org.alfresco.cache.caveatConfigCache</value>
</property>
</bean>
</property>
</bean>
<!-- The transactional cache for in-memory CaveatConfig -->
<bean name="caveatConfigCache" class="org.alfresco.repo.cache.TransactionalCache">
<property name="sharedCache">
<ref bean="caveatConfigSharedCache" />
</property>
<property name="name">
<value>org.alfresco.caveatConfigTransactionalCache</value>
</property>
<property name="maxCacheSize" value="500" />
<property name="mutable" value="true" />
<property name="disableSharedCache" value="${system.cache.disableMutableSharedCaches}" />
</bean> </bean>
<bean id="caveatAspects" class="java.util.ArrayList" > <bean id="caveatAspects" class="java.util.ArrayList" >

View File

@@ -123,6 +123,7 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
/** Constants */ /** Constants */
public static final String RMC_CUSTOM_ASSOCS = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customAssocs"; public static final String RMC_CUSTOM_ASSOCS = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customAssocs";
private static final String CUSTOM_CONSTRAINT_TYPE = org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.class.getName(); private static final String CUSTOM_CONSTRAINT_TYPE = org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.class.getName();
private static final String CAPATIBILITY_CUSTOM_CONTRAINT_TYPE = org.alfresco.module.org_alfresco_module_dod5015.caveat.RMListOfValuesConstraint.class.getName();
private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "records_management_custom_model"); private static final NodeRef RM_CUSTOM_MODEL_NODE_REF = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "records_management_custom_model");
private static final String PARAM_ALLOWED_VALUES = "allowedValues"; private static final String PARAM_ALLOWED_VALUES = "allowedValues";
private static final String PARAM_CASE_SENSITIVE = "caseSensitive"; private static final String PARAM_CASE_SENSITIVE = "caseSensitive";
@@ -1413,7 +1414,9 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
} }
String type = customConstraint.getType(); String type = customConstraint.getType();
if ((type == null) || (! type.equals(CUSTOM_CONSTRAINT_TYPE))) if (type == null ||
(type.equals(CUSTOM_CONSTRAINT_TYPE) == false &&
type.equals(CAPATIBILITY_CUSTOM_CONTRAINT_TYPE) == false))
{ {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE)); throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_UNEXPECTED_TYPE_CONSTRAINT, type, constraintNameAsPrefixString, CUSTOM_CONSTRAINT_TYPE));
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2011 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -22,17 +22,22 @@ import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic; import org.alfresco.module.org_alfresco_module_rm.caveat.RMListOfValuesConstraint.MatchLogic;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.content.ContentServicePolicies; import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.node.NodeServicePolicies;
@@ -96,16 +101,25 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
private static final QName DATATYPE_TEXT = DataTypeDefinition.TEXT; private static final QName DATATYPE_TEXT = DataTypeDefinition.TEXT;
/**
* Lock objects
*/
private ReadWriteLock lock = new ReentrantReadWriteLock();
private Lock readLock = lock.readLock();
private Lock writeLock = lock.writeLock();
/* /*
* Caveat Config * Caveat Config (Shared) config
* first string is property name * first string is property name
* second string is authority name (user or group full name) * second string is authority name (user or group full name)
* third string is list of values of property * third string is list of values of property
*/ */
private SimpleCache<String, Map<String, List<String>>> caveatConfig;
// TODO - convert to SimpleCache to be cluster-aware (for dynamic changes to caveat config across a cluster) public void setCaveatConfig(SimpleCache<String, Map<String, List<String>>> caveatConfig)
private Map<String, Map<String, List<String>>> caveatConfig = new ConcurrentHashMap<String, Map<String, List<String>>>(2); {
this.caveatConfig = caveatConfig;
}
public void setPolicyComponent(PolicyComponent policyComponent) public void setPolicyComponent(PolicyComponent policyComponent)
{ {
@@ -251,6 +265,12 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
validateAndReset(childAssocRef.getChildRef()); validateAndReset(childAssocRef.getChildRef());
} }
/**
* Validate the caveat config and optionally update the cache.
*
* @param nodeRef The nodeRef of the config
* @param updateCache Set to <code>true</code> to update the cache
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void validateAndReset(NodeRef nodeRef) protected void validateAndReset(NodeRef nodeRef)
{ {
@@ -408,15 +428,29 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
} }
} }
// Valid, so update try
caveatConfig.clear();
for (Map.Entry<String, Object> conEntry : caveatConfigMap.entrySet())
{ {
String conStr = conEntry.getKey(); writeLock.lock();
Map<String, List<String>> caveatMap = (Map<String, List<String>>)conEntry.getValue(); // we can't just clear the cache, as all puts to the cache afterwards in this transaction will be ignored
// first delete all keys that are now not in the config
caveatConfig.getKeys().retainAll(caveatConfigMap.keySet());
caveatConfig.put(conStr, caveatMap); for (Map.Entry<String, Object> conEntry : caveatConfigMap.entrySet())
{
String conStr = conEntry.getKey();
Map<String, List<String>> caveatMap = (Map<String, List<String>>)conEntry.getValue();
Map<String, List<String>> cacheValue = caveatConfig.get(conStr);
if (cacheValue == null || !cacheValue.equals(caveatMap))
{
// update the cache
caveatConfig.put(conStr, caveatMap);
}
}
}
finally
{
writeLock.unlock();
} }
} }
catch (JSONException e) catch (JSONException e)
@@ -494,9 +528,19 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
} }
// Get list of all caveat qualified names // Get list of all caveat qualified names
public Set<String> getRMConstraintNames() public Collection<String> getRMConstraintNames()
{ {
return caveatConfig.keySet(); Collection<String> rmConstraintNames = Collections.emptySet();
try
{
readLock.lock();
rmConstraintNames = caveatConfig.getKeys();
}
finally
{
readLock.unlock();
}
return Collections.unmodifiableCollection(rmConstraintNames);
} }
// Get allowed values for given caveat (for current user) // Get allowed values for given caveat (for current user)
@@ -511,6 +555,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
{ {
// note: userName and userGroupNames must not be null // note: userName and userGroupNames must not be null
caveatConfig.get(constraintName); caveatConfig.get(constraintName);
Set<String> userGroupFullNames = authorityService.getAuthoritiesForUser(userName); Set<String> userGroupFullNames = authorityService.getAuthoritiesForUser(userName);
allowedValues = getRMAllowedValues(userName, userGroupFullNames, constraintName); allowedValues = getRMAllowedValues(userName, userGroupFullNames, constraintName);
} }
@@ -524,7 +569,16 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
Set<String>allowedValues = new HashSet<String>(); Set<String>allowedValues = new HashSet<String>();
// note: userName and userGroupNames must not be null // note: userName and userGroupNames must not be null
Map<String, List<String>> caveatConstraintDef = caveatConfig.get(constraintName); Map<String, List<String>> caveatConstraintDef = null;
try
{
readLock.lock();
caveatConstraintDef = caveatConfig.get(constraintName);
}
finally
{
readLock.unlock();
}
if (caveatConstraintDef != null) if (caveatConstraintDef != null)
{ {
@@ -546,7 +600,7 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
List<String>ret = new ArrayList<String>(); List<String>ret = new ArrayList<String>();
ret.addAll(allowedValues); ret.addAll(allowedValues);
return ret; return Collections.unmodifiableList(ret);
} }
/** /**
@@ -691,23 +745,53 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
* *
* @param listName the name of the RMConstraintList * @param listName the name of the RMConstraintList
* @param authorityName * @param authorityName
* @param values * @param value
* @throws AlfrescoRuntimeException if either the list or the authority do not already exist. * @throws AlfrescoRuntimeException if either the list or the authority do not already exist.
*/ */
public void addRMConstraintListValue(String listName, String authorityName, String value) public void addRMConstraintListValue(String listName, String authorityName, String value)
{ {
Map<String, List<String>> members = caveatConfig.get(listName); Map<String, List<String>> members = null;
if(members == null) try
{ {
throw new AlfrescoRuntimeException("unable to add to list, list not defined:"+ listName); readLock.lock();
members = caveatConfig.get(listName);
if(members == null)
{
throw new AlfrescoRuntimeException("unable to add to list, list not defined:"+ listName);
}
try
{
readLock.unlock();
writeLock.lock();
// check again
members = caveatConfig.get(listName);
if(members == null)
{
throw new AlfrescoRuntimeException("unable to add to list, list not defined:"+ listName);
}
List<String> values = members.get(authorityName);
if(values == null)
{
throw new AlfrescoRuntimeException("Unable to add to authority in list. Authority not member listName: "+ listName + " authorityName:" +authorityName);
}
values.add(value);
caveatConfig.put(listName, members);
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
}
finally
{
readLock.lock();
writeLock.unlock();
}
} }
List<String> values = members.get(authorityName); finally
if(values == null)
{ {
throw new AlfrescoRuntimeException("Unable to add to authority in list. Authority not member listName: "+ listName + " authorityName:" +authorityName); readLock.unlock();
} }
values.add(value);
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
} }
/** /**
@@ -717,7 +801,24 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
*/ */
public Map<String, List<String>> getListDetails(String listName) public Map<String, List<String>> getListDetails(String listName)
{ {
return caveatConfig.get(listName); Map<String, List<String>> listDetails = null;
try
{
readLock.lock();
listDetails = caveatConfig.get(listName);
}
finally
{
readLock.unlock();
}
if (listDetails == null)
{
return Collections.emptyMap();
}
else
{
return Collections.unmodifiableMap(listDetails);
}
} }
public List<QName> getRMCaveatModels() public List<QName> getRMCaveatModels()
@@ -737,20 +838,30 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
*/ */
public void updateRMConstraintListAuthority(String listName, String authorityName, List<String>values) public void updateRMConstraintListAuthority(String listName, String authorityName, List<String>values)
{ {
Map<String, List<String>> members = caveatConfig.get(listName); Map<String, List<String>> members = null;
if(members == null) try
{ {
// Create the new list, with the authority name writeLock.lock();
Map<String, List<String>> constraint = new HashMap<String, List<String>>(0); members = caveatConfig.get(listName);
constraint.put(authorityName, values); if(members == null)
caveatConfig.put(listName, constraint); {
} // Create the new list, with the authority name
else Map<String, List<String>> constraint = new HashMap<String, List<String>>(0);
{ constraint.put(authorityName, new ArrayList<String>(values));
members.put(authorityName, values); members = constraint;
} }
else
{
members.put(authorityName, new ArrayList<String>(values));
}
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig)); caveatConfig.put(listName, members);
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
}
finally
{
writeLock.unlock();
}
} }
/** /**
@@ -763,57 +874,19 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
public void updateRMConstraintListValue(String listName, String valueName, List<String>authorities) public void updateRMConstraintListValue(String listName, String valueName, List<String>authorities)
{ {
// members contains member, values[]
Map<String, List<String>> members = caveatConfig.get(listName); Map<String, List<String>> members = caveatConfig.get(listName);
try
if(members == null)
{ {
// Members List does not exist writeLock.lock();
Map<String, List<String>> emptyConstraint = new HashMap<String, List<String>>(0);
caveatConfig.put(listName, emptyConstraint);
members = emptyConstraint;
} if(members == null)
// authorities contains authority, values[]
// pivot contains value, members[]
Map<String, List<String>> pivot = PivotUtil.getPivot(members);
// remove all authorities which have this value
List<String> existingAuthorities = pivot.get(valueName);
if(existingAuthorities != null)
{
for(String authority : existingAuthorities)
{ {
List<String> vals = members.get(authority); // Members List does not exist
vals.remove(valueName); Map<String, List<String>> emptyConstraint = new HashMap<String, List<String>>(0);
caveatConfig.put(listName, emptyConstraint);
members = emptyConstraint;
} }
}
// add the new authorities for this value
for(String authority : authorities)
{
List<String> vals = members.get(authority);
if(vals == null)
{
vals= new ArrayList<String>();
members.put(authority, vals);
}
vals.add(valueName);
}
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
}
public void removeRMConstraintListValue(String listName, String valueName)
{
// members contains member, values[]
Map<String, List<String>> members = caveatConfig.get(listName);
if(members == null)
{
// list does not exist
}
else
{
// authorities contains authority, values[] // authorities contains authority, values[]
// pivot contains value, members[] // pivot contains value, members[]
Map<String, List<String>> pivot = PivotUtil.getPivot(members); Map<String, List<String>> pivot = PivotUtil.getPivot(members);
@@ -828,9 +901,83 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
vals.remove(valueName); vals.remove(valueName);
} }
} }
// add the new authorities for this value
for(String authority : authorities)
{
List<String> vals = members.get(authority);
if(vals == null)
{
vals= new ArrayList<String>();
members.put(authority, vals);
}
vals.add(valueName);
}
caveatConfig.put(listName, members);
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig)); updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
} }
finally
{
writeLock.unlock();
}
}
public void removeRMConstraintListValue(String listName, String valueName)
{
Map<String, List<String>> members = null;
try
{
readLock.lock();
members = caveatConfig.get(listName);
if(members == null)
{
// list does not exist
}
else
{
try
{
readLock.unlock();
writeLock.lock();
// check again
members = caveatConfig.get(listName);
if(members == null)
{
// list does not exist
}
else
{
// authorities contains authority, values[]
// pivot contains value, members[]
Map<String, List<String>> pivot = PivotUtil.getPivot(members);
// remove all authorities which have this value
List<String> existingAuthorities = pivot.get(valueName);
if(existingAuthorities != null)
{
for(String authority : existingAuthorities)
{
List<String> vals = members.get(authority);
vals.remove(valueName);
}
caveatConfig.put(listName, members);
}
}
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
}
finally
{
readLock.lock();
writeLock.unlock();
}
}
}
finally
{
readLock.unlock();
}
} }
/** /**
@@ -842,26 +989,37 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
*/ */
public void removeRMConstraintListAuthority(String listName, String authorityName) public void removeRMConstraintListAuthority(String listName, String authorityName)
{ {
Map<String, List<String>> members = caveatConfig.get(listName); Map<String, List<String>> members = null;
if(members != null) try
{ {
members.remove(listName); writeLock.lock();
} members = caveatConfig.get(listName);
if(members != null)
{
members.remove(listName);
}
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig)); caveatConfig.put(listName, members);
} updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
}
finally
{
writeLock.unlock();
}
}
/** /**
* @param config the configuration to convert * @param config the configuration to convert
* @return a String containing the JSON representation of the configuration. * @return a String containing the JSON representation of the configuration.
*/ */
private String convertToJSONString(Map<String, Map<String, List<String>>> config) private String convertToJSONString(SimpleCache<String, Map<String, List<String>>> config)
{ {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
try try
{ {
Set<String> listNames = config.keySet(); Collection<String> listNames = config.getKeys();
for(String listName : listNames) for(String listName : listNames)
{ {
Map<String, List<String>> members = config.get(listName); Map<String, List<String>> members = config.get(listName);
@@ -931,14 +1089,30 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon
public void deleteRMConstraint(String listName) public void deleteRMConstraint(String listName)
{ {
caveatConfig.remove(listName); try
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig)); {
writeLock.lock();
caveatConfig.remove(listName);
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
}
finally
{
writeLock.unlock();
}
} }
public void addRMConstraint(String listName) public void addRMConstraint(String listName)
{ {
Map<String, List<String>> emptyConstraint = new HashMap<String, List<String>>(0); try
caveatConfig.put(listName, emptyConstraint); {
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig)); writeLock.lock();
Map<String, List<String>> emptyConstraint = new HashMap<String, List<String>>(0);
caveatConfig.put(listName, emptyConstraint);
updateOrCreateCaveatConfig(convertToJSONString(caveatConfig));
}
finally
{
writeLock.unlock();
}
} }
} }

View File

@@ -113,11 +113,20 @@ public class RecordsManagementTypeFormFilter extends RecordsManagementFormFilter
for (FieldDefinition fieldDef : fieldDefs) for (FieldDefinition fieldDef : fieldDefs)
{ {
String prefixName = fieldDef.getName(); String prefixName = fieldDef.getName();
if (prefixName.equals("rma:identifier")) if (prefixName.equals("rma:identifier") == true)
{ {
String defaultId = identifierService.generateIdentifier(typeName, null); String defaultId = identifierService.generateIdentifier(typeName, null);
fieldDef.setDefaultValue(defaultId); fieldDef.setDefaultValue(defaultId);
} }
// NOTE: we set these defaults in the form for backwards compatibility reasons (RM-753)
else if (prefixName.equals("rma:vitalRecordIndicator") == true)
{
fieldDef.setDefaultValue(Boolean.FALSE.toString());
}
else if (prefixName.equals("rma:reviewPeriod") == true)
{
fieldDef.setDefaultValue("none|0");
}
} }
} }

View File

@@ -18,11 +18,16 @@
*/ */
package org.alfresco.module.org_alfresco_module_rm.patch; package org.alfresco.module.org_alfresco_module_rm.patch;
import java.io.Serializable;
import java.util.List; import java.util.List;
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.RecordsManagementService;
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.dod5015.DOD5015Model;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.security.RecordsManagementSecurityService;
import org.alfresco.module.org_alfresco_module_rm.security.Role;
import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.patch.PatchDAO; import org.alfresco.repo.domain.patch.PatchDAO;
import org.alfresco.repo.domain.qname.QNameDAO; import org.alfresco.repo.domain.qname.QNameDAO;
@@ -30,6 +35,8 @@ import org.alfresco.repo.module.AbstractModuleComponent;
import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.Period;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair; import org.alfresco.util.Pair;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -53,6 +60,8 @@ public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent
private PatchDAO patchDAO; private PatchDAO patchDAO;
private NodeDAO nodeDAO; private NodeDAO nodeDAO;
private QNameDAO qnameDAO; private QNameDAO qnameDAO;
private PermissionService permissionService;
private RecordsManagementSecurityService recordsManagementSecurityService;
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
@@ -84,6 +93,22 @@ public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent
this.qnameDAO = qnameDAO; this.qnameDAO = qnameDAO;
} }
/**
* @param recordsManagementSecurityService records management security service
*/
public void setRecordsManagementSecurityService(RecordsManagementSecurityService recordsManagementSecurityService)
{
this.recordsManagementSecurityService = recordsManagementSecurityService;
}
/**
* @param permissionService permission service
*/
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
/** /**
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal() * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
*/ */
@@ -98,24 +123,53 @@ public class RMv2FilePlanNodeRefPatch extends AbstractModuleComponent
Pair<Long, QName> aspectPair = qnameDAO.getQName(ASPECT_FILE_PLAN_COMPONENT); Pair<Long, QName> aspectPair = qnameDAO.getQName(ASPECT_FILE_PLAN_COMPONENT);
if (aspectPair != null) if (aspectPair != null)
{ {
List<Long> records = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID()); List<Long> filePlanComponents = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID());
if (logger.isDebugEnabled() == true) if (logger.isDebugEnabled() == true)
{ {
logger.debug(" ... updating " + records.size() + " items" ); logger.debug(" ... updating " + filePlanComponents.size() + " items" );
} }
behaviourFilter.disableBehaviour(); behaviourFilter.disableBehaviour();
try try
{ {
for (Long record : records) for (Long filePlanComponent : filePlanComponents)
{ {
Pair<Long, NodeRef> recordPair = nodeDAO.getNodePair(record); Pair<Long, NodeRef> recordPair = nodeDAO.getNodePair(filePlanComponent);
NodeRef recordNodeRef = recordPair.getSecond(); NodeRef filePlanComponentNodeRef = recordPair.getSecond();
if (nodeService.getProperty(recordNodeRef, PROP_ROOT_NODEREF) == null) NodeRef filePlan = recordsManagementService.getFilePlan(filePlanComponentNodeRef);
// set the file plan node reference
if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null)
{ {
nodeService.setProperty(recordNodeRef, PROP_ROOT_NODEREF, recordsManagementService.getFilePlan(recordNodeRef)); nodeService.setProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF, filePlan);
}
// only set the rmadmin permissions on record categories, record folders and records
FilePlanComponentKind kind = recordsManagementService.getFilePlanComponentKind(filePlanComponentNodeRef);
if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) == true ||
FilePlanComponentKind.RECORD_FOLDER.equals(kind) == true ||
FilePlanComponentKind.RECORD.equals(kind) == true )
{
// ensure the that the records management role has read and file on the node
Role adminRole = recordsManagementSecurityService.getRole(filePlan, "Administrator");
if (adminRole != null)
{
permissionService.setPermission(filePlanComponentNodeRef, adminRole.getRoleGroupName(), RMPermissionModel.FILING, true);
}
// ensure that the default vital record default values have been set (RM-753)
Serializable vitalRecordIndicator = nodeService.getProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR);
if (vitalRecordIndicator == null)
{
nodeService.setProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR, false);
}
Serializable reviewPeriod = nodeService.getProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD);
if (reviewPeriod == null)
{
nodeService.setProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD, new Period("none|0"));
}
} }
} }
} }

View File

@@ -0,0 +1,95 @@
/*
* 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.patch;
import java.util.List;
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.search.RecordsManagementSearchService;
import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails;
import org.alfresco.repo.module.AbstractModuleComponent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanNameAware;
/**
* RM v2.0 Saved Search Patch
*
*
* @author Roy Wetherall
*/
public class RMv2SavedSearchPatch extends AbstractModuleComponent
implements BeanNameAware, RecordsManagementModel, DOD5015Model
{
/** Logger */
private static Log logger = LogFactory.getLog(RMv2SavedSearchPatch.class);
/** RM site id */
private static final String RM_SITE_ID = "rm";
/** Records management search service */
private RecordsManagementSearchService recordsManagementSearchService;
/**
* @param recordsManagementSearchService records management search service
*/
public void setRecordsManagementSearchService(RecordsManagementSearchService recordsManagementSearchService)
{
this.recordsManagementSearchService = recordsManagementSearchService;
}
/**
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
*/
@Override
protected void executeInternal() throws Throwable
{
if (logger.isDebugEnabled() == true)
{
logger.debug("RM Module RMv2SavedSearchPatch ...");
}
// get the saved searches
List<SavedSearchDetails> savedSearches = recordsManagementSearchService.getSavedSearches(RM_SITE_ID);
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... updating " + savedSearches.size() + " saved searches");
}
for (SavedSearchDetails savedSearchDetails : savedSearches)
{
// re-save each search so that the query is regenerated correctly
recordsManagementSearchService.deleteSavedSearch(RM_SITE_ID, savedSearchDetails.getName());
recordsManagementSearchService.saveSearch(RM_SITE_ID,
savedSearchDetails.getName(),
savedSearchDetails.getDescription(),
savedSearchDetails.getSearch(),
savedSearchDetails.getSearchParameters(),
savedSearchDetails.isPublic());
}
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... complete");
}
}
}

View File

@@ -95,7 +95,7 @@ public class SavedSearchDetails extends ReportDetails
private String siteId; private String siteId;
/** Indicates whether the saved search is public or not */ /** Indicates whether the saved search is public or not */
private boolean isPublic; private boolean isPublic = true;
/** Indicates whether the saved search is a report */ /** Indicates whether the saved search is a report */
private boolean isReport = false; private boolean isReport = false;
@@ -103,8 +103,10 @@ public class SavedSearchDetails extends ReportDetails
/** Namespace service */ /** Namespace service */
NamespaceService namespaceService; NamespaceService namespaceService;
/** Records management search service */
RecordsManagementSearchServiceImpl searchService; RecordsManagementSearchServiceImpl searchService;
/** Saves search details compatibility */
private SavedSearchDetailsCompatibility compatibility; private SavedSearchDetailsCompatibility compatibility;
/** /**
@@ -178,7 +180,7 @@ public class SavedSearchDetails extends ReportDetails
} }
// Determine whether the saved query is public or not // Determine whether the saved query is public or not
boolean isPublic = false; boolean isPublic = true;
if (search.has(PUBLIC) == true) if (search.has(PUBLIC) == true)
{ {
isPublic = search.getBoolean(PUBLIC); isPublic = search.getBoolean(PUBLIC);

View File

@@ -78,7 +78,15 @@ public class BroadcastVitalRecordDefinitionAction extends RMActionExecuterAbstra
private void propagateChangeToChildrenOf(NodeRef actionedUponNodeRef) private void propagateChangeToChildrenOf(NodeRef actionedUponNodeRef)
{ {
Map<QName, Serializable> parentProps = nodeService.getProperties(actionedUponNodeRef); Map<QName, Serializable> parentProps = nodeService.getProperties(actionedUponNodeRef);
boolean parentVri = (Boolean) parentProps.get(PROP_VITAL_RECORD_INDICATOR);
// parent vital record indicator, default to null if not set
boolean parentVri = false;
Boolean parentVriValue = (Boolean) parentProps.get(PROP_VITAL_RECORD_INDICATOR);
if (parentVriValue != null)
{
parentVri = parentVriValue.booleanValue();
}
Period parentReviewPeriod = (Period) parentProps.get(PROP_REVIEW_PERIOD); Period parentReviewPeriod = (Period) parentProps.get(PROP_REVIEW_PERIOD);
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(actionedUponNodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(actionedUponNodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);

View File

@@ -63,6 +63,10 @@ public class VitalRecordDefinitionImpl implements VitalRecordDefinition, Records
/* package */ static VitalRecordDefinition create(NodeService nodeService, NodeRef nodeRef) /* package */ static VitalRecordDefinition create(NodeService nodeService, NodeRef nodeRef)
{ {
Boolean enabled = (Boolean)nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR); Boolean enabled = (Boolean)nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR);
if (enabled == null)
{
enabled = Boolean.FALSE;
}
Period reviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD); Period reviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD);
return new VitalRecordDefinitionImpl(enabled, reviewPeriod); return new VitalRecordDefinitionImpl(enabled, reviewPeriod);
} }