RM-765: Remove DOD meta-data from core RM model

* remove DOD meta-data from record aspect 
* create dod record aspect in dod model to contain dod specific meta-data (modelled as record mate data aspect so can be added manaually and UI reacts accodingly without modification) 
* automatically add dod record aspect to record when created (maintains status quo for the time being) 
* allow groups to be automatically added to form UI template when record meta-data found on record (DOD meta-data automatically displayed and editable if present) 
* add simple module patch frameowrk so RM patches going forward are module schema based (so order and application is predictable) 
* fix up existing patchs (pre 2.2) so basic order is guarenteed 
* add patch for DOD data reshuffle 
* general restructuring of patch configuration and implementations for clarity 



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@59972 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2014-01-15 17:16:42 +00:00
parent 42944b1aa6
commit e96d85d453
28 changed files with 1217 additions and 98 deletions

View File

@@ -0,0 +1,260 @@
/*
* 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.patch;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.transaction.TransactionService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanNameAware;
/**
* Abstract module patch implementation.
*
* @author Roy Wetherall
* @since 2.2
*/
public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
{
/** logger */
protected static Log logger = LogFactory.getLog(ModulePatch.class);
/** module patch service */
private ModulePatchExecuter modulePatchExecuter;
/** transaction service */
protected TransactionService transactionService;
/** module patch id */
private String id;
/** module patch description */
private String description;
/** module id */
private String moduleId;
/** module patch fixes from module schema number */
private int fixesFromSchema;
/** module patch fixes to module schema number */
private int fixesToSchema;
/** module patch target module schema number */
private int targetSchema;
/**
* Initiialisation method
*/
public void init()
{
modulePatchExecuter.register(this);
}
/**
* @param modulePatchExecuter module patch executer
*/
public void setModulePatchExecuter(ModulePatchExecuter modulePatchExecuter)
{
this.modulePatchExecuter = modulePatchExecuter;
}
/**
* @param transactionService transaction service
*/
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
}
/**
* @param id module patch id
*/
public void setId(String id)
{
this.id = id;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getId()
*/
@Override
public String getId()
{
return id;
}
/**
* Convenience method to set the module patch id to the bean name (if not already specified)
*/
@Override
public void setBeanName(String beanName)
{
if (id == null)
{
id = beanName;
}
}
/**
* @param description module patch description
*/
public void setDescription(String description)
{
this.description = description;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getDescription()
*/
@Override
public String getDescription()
{
return description;
}
/**
* @param moduleId module id
*/
public void setModuleId(String moduleId)
{
this.moduleId = moduleId;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getModuleId()
*/
@Override
public String getModuleId()
{
return moduleId;
}
public void setFixesFromSchema(int fixesFromSchema)
{
this.fixesFromSchema = fixesFromSchema;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getFixesFromSchema()
*/
@Override
public int getFixesFromSchema()
{
return fixesFromSchema;
}
public void setFixesToSchema(int fixesToSchema)
{
this.fixesToSchema = fixesToSchema;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getFixesToSchema()
*/
@Override
public int getFixesToSchema()
{
return fixesToSchema;
}
public void setTargetSchema(int targetSchema)
{
this.targetSchema = targetSchema;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#getTargetSchema()
*/
@Override
public int getTargetSchema()
{
return targetSchema;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch#apply()
*/
@Override
public void apply()
{
if (logger.isInfoEnabled() == true)
{
logger.info("Executing module patch \"" + description + "\"");
}
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... id=" + id +
",moduleId=" + moduleId +
",from=" + fixesFromSchema +
",to=" + fixesToSchema +
",target=" + targetSchema);
}
transactionService.getRetryingTransactionHelper().doInTransaction(
new ApplyCallback(),
true,
false);
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... module patch applied");
}
}
/**
* Apply patch internal method. Implementations can assume a transaction has
* been started.
*/
public abstract void applyInternal();
/**
* Apply callback worker class implementation
*/
private class ApplyCallback implements RetryingTransactionCallback<Void>
{
/**
* @see org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback#execute()
*/
@Override
public Void execute() throws Throwable
{
applyInternal();
return null;
}
}
/**
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(ModulePatch o)
{
int result = 0;
if (getTargetSchema() < o.getTargetSchema())
{
result = -1;
}
else if (getTargetSchema() > o.getTargetSchema())
{
result = 1;
}
return result;
}
}

View File

@@ -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.patch;
/**
* Module Patch Interface
*
* @author Roy Wetherall
* @since 2.2
*/
public interface ModulePatch extends Comparable<ModulePatch>
{
/**
* @return module patch id
*/
String getId();
/**
* @return module patch description
*/
String getDescription();
/**
* @return module id this patch applies to
*/
String getModuleId();
/**
* @return smallest module schema number that this patch may be applied to
*/
int getFixesFromSchema();
/**
* @return largest module schema number that this patch may be applied to
*/
int getFixesToSchema();
/**
* @return module schema number that this patch attempts to bring the repo up to
*/
int getTargetSchema();
/**
* Apply the module patch
*/
void apply();
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2005-2015 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;
/**
* Module patch service interface
*
* @author Roy Wetherall
* @since 2.2
*/
public interface ModulePatchExecuter
{
/**
* Register module patch with the module patch executer
*
* @param modulePatch module patch
*/
void register(ModulePatch modulePatch);
/**
* Init the schema version number
*/
void initSchemaVersion();
}

View File

@@ -0,0 +1,168 @@
/*
* 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.patch;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.module.AbstractModuleComponent;
import org.alfresco.service.cmr.attributes.AttributeService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Module patch executer base implementation
*
* @author Roy Wetherall
* @since 2.2
*/
public class ModulePatchExecuterImpl extends AbstractModuleComponent
implements ModulePatchExecuter
{
/** logger */
protected static Log logger = LogFactory.getLog(ModulePatchExecuterImpl.class);
/** default start schema */
private static final int START_SCHEMA = 0;
/** attribute key */
private static final String KEY_MODULE_SCHEMA = "module-schema";
/** configured module schema version */
protected int moduleSchema = START_SCHEMA;
/** attribute service */
protected AttributeService attributeService;
/** module patches */
protected Map<String, ModulePatch> modulePatches = new HashMap<String, ModulePatch>(21);
/**
* @param attributeService attribute service
*/
public void setAttributeService(AttributeService attributeService)
{
this.attributeService = attributeService;
}
/**
* @param moduleSchema configured module schema version
*/
public void setModuleSchema(int moduleSchema)
{
this.moduleSchema = moduleSchema;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter#register(org.alfresco.module.org_alfresco_module_rm.patch.ModulePatch)
*/
@Override
public void register(ModulePatch modulePatch)
{
// ensure that the module patch being registered relates to the module id
if (getModuleId().equals(modulePatch.getModuleId()) == false)
{
throw new AlfrescoRuntimeException("Unable to register module patch, becuase module id is invalid.");
}
if (logger.isDebugEnabled() == true)
{
logger.debug("Registering module patch " + modulePatch.getId() + " for module " + getModuleId());
}
modulePatches.put(modulePatch.getId(), modulePatch);
}
/**
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
*/
@Override
protected void executeInternal() throws Throwable
{
// get current schema version
int currentSchema = getCurrentSchema();
if (logger.isDebugEnabled() == true)
{
logger.debug("Running module patch executer (currentSchema=" + currentSchema + ", configuredSchema=" + moduleSchema + ")");
}
if (moduleSchema > currentSchema)
{
// determine what patches should be applied
List<ModulePatch> patchesToApply = new ArrayList<ModulePatch>(13);
for (ModulePatch modulePatch : modulePatches.values())
{
if (modulePatch.getFixesFromSchema() <= currentSchema &&
modulePatch.getFixesToSchema() >= currentSchema)
{
patchesToApply.add(modulePatch);
}
}
// apply the patches in the correct order
Collections.sort(patchesToApply);
for (ModulePatch patchToApply : patchesToApply)
{
patchToApply.apply();
}
// update the schema
updateSchema(moduleSchema);
}
}
/**
* Get the currently recorded schema version for the module
*
* @return int currently recorded schema version
*/
protected int getCurrentSchema()
{
Integer result = START_SCHEMA;
if (attributeService.exists(KEY_MODULE_SCHEMA, getModuleId()) == true)
{
result = (Integer)attributeService.getAttribute(KEY_MODULE_SCHEMA, getModuleId());
}
return result;
}
/**
* Update the recorded schema version for the module.
*
* @param newSchema new schema version
*/
protected void updateSchema(int newSchema)
{
attributeService.setAttribute(new Integer(newSchema), KEY_MODULE_SCHEMA, getModuleId());
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuter#initSchemaVersion()
*/
@Override
public void initSchemaVersion()
{
updateSchema(moduleSchema);
}
}

View File

@@ -1,61 +0,0 @@
/*
* 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.patch;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* RM v2.2 patch to updated modified capabilities.
*
* @author Tuna Aksoy
* @since 2.2
*/
public class RMv22CapabilityPatch extends BaseRMCapabilityPatch
{
/**
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
*/
@Override
protected void executePatch() throws Throwable
{
Set<NodeRef> filePlans = getFilePlans();
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... updating " + filePlans.size() + " file plans");
}
for (NodeRef filePlan : filePlans)
{
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... updating file plan " + filePlan.toString());
}
// add new capability
addCapability(filePlan,
"FileDestructionReport",
FilePlanRoleService.ROLE_ADMIN,
FilePlanRoleService.ROLE_RECORDS_MANAGER);
}
}
}

View File

@@ -16,8 +16,9 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.compatibility;
import org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchExecuterImpl;
import org.alfresco.repo.module.AbstractModuleComponent;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
@@ -31,6 +32,7 @@ import org.apache.commons.logging.LogFactory;
* @author Roy Wetherall
* @since 2.1
*/
@Deprecated
public abstract class ModulePatchComponent extends AbstractModuleComponent
{
/** logger */
@@ -42,6 +44,9 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent
/** Behaviour filter */
protected BehaviourFilter behaviourFilter;
/** module patch executer */
protected ModulePatchExecuterImpl modulePatchExecuter;
/**
* @param retryingTransactionHelper retrying transaction helper
*/
@@ -58,6 +63,24 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent
this.behaviourFilter = behaviourFilter;
}
/**
* @param modulePatchExecuter module patch executer
*/
public void setModulePatchExecuter(ModulePatchExecuterImpl modulePatchExecuter)
{
this.modulePatchExecuter = modulePatchExecuter;
}
/**
* Init method
*/
@Override
public void init()
{
super.init();
modulePatchExecuter.getDependsOn().add(this);
}
/**
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v20;
import java.io.InputStream;
import java.io.Serializable;
@@ -25,6 +25,7 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.notification.RecordsManagementNotificationHelper;
import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent;
import org.alfresco.repo.version.VersionModel;
import org.alfresco.service.cmr.audit.AuditService;
import org.alfresco.service.cmr.repository.ContentService;
@@ -39,8 +40,12 @@ import org.alfresco.service.namespace.QName;
import org.springframework.beans.factory.BeanNameAware;
/**
* Notification template patch implementation
*
* @author Roy Wetherall
* @since 2.0
*/
@SuppressWarnings("deprecation")
public class NotificationTemplatePatch extends ModulePatchComponent
implements BeanNameAware
{

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v20;
import java.io.Serializable;
import java.util.List;
@@ -26,6 +26,7 @@ import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.role.Role;
import org.alfresco.repo.domain.node.NodeDAO;
@@ -43,7 +44,9 @@ import org.springframework.beans.factory.BeanNameAware;
* RM v2.0 File Plan Node Ref Patch
*
* @author Roy Wetherall
* @since 2.0
*/
@SuppressWarnings("deprecation")
public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent
implements BeanNameAware, RecordsManagementModel, DOD5015Model
{

View File

@@ -16,12 +16,13 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v20;
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.patch.compatibility.ModulePatchComponent;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.patch.PatchDAO;
import org.alfresco.repo.domain.qname.QNameDAO;
@@ -33,9 +34,10 @@ import org.springframework.beans.factory.BeanNameAware;
/**
* RM v2.0 Model Updates Patch
*
*
* @author Roy Wetherall
* @since 2.0
*/
@SuppressWarnings("deprecation")
public class RMv2ModelPatch extends ModulePatchComponent
implements BeanNameAware, RecordsManagementModel, DOD5015Model
{

View File

@@ -16,13 +16,14 @@
* 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;
package org.alfresco.module.org_alfresco_module_rm.patch.v20;
import java.util.List;
import org.alfresco.model.ContentModel;
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.patch.compatibility.ModulePatchComponent;
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
import org.alfresco.module.org_alfresco_module_rm.search.SavedSearchDetails;
import org.alfresco.service.cmr.repository.ContentService;
@@ -34,9 +35,10 @@ import org.springframework.beans.factory.BeanNameAware;
/**
* RM v2.0 Saved Search Patch
*
*
* @author Roy Wetherall
* @since 2.0
*/
@SuppressWarnings("deprecation")
public class RMv2SavedSearchPatch extends ModulePatchComponent
implements BeanNameAware, RecordsManagementModel, DOD5015Model
{

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v21;
import java.io.InputStream;
import java.io.Serializable;
@@ -40,7 +40,7 @@ import org.alfresco.service.namespace.QName;
* @author Tuna Aksoy
* @since 2.1
*/
public class NotificationTemplatePatch_v21 extends ModulePatchComponent
public class NotificationTemplatePatch_v21 extends RMv21PatchComponent
{
/** Email template path */
private static final String PATH_REJECTED = "alfresco/module/org_alfresco_module_rm/bootstrap/content/record-rejected-email.ftl";

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v21;
import java.io.Serializable;
import java.util.HashMap;
@@ -44,7 +44,8 @@ import org.springframework.beans.factory.BeanNameAware;
* @author Craig Tan
* @since 2.1
*/
public class RMv21BehaviorScriptsPatch extends ModulePatchComponent implements BeanNameAware
@SuppressWarnings("deprecation")
public class RMv21BehaviorScriptsPatch extends RMv21PatchComponent implements BeanNameAware
{
/** rm config folder root lookup */
protected static final NodeRef RM_CONFIG = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_config_folder");
@@ -81,7 +82,7 @@ public class RMv21BehaviorScriptsPatch extends ModulePatchComponent implements B
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchComponent#executePatch()
* @see org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent#executePatch()
*/
@Override
protected void executePatch() throws Throwable

View File

@@ -16,11 +16,16 @@
* 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;
package org.alfresco.module.org_alfresco_module_rm.patch.v21;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.role.Role;
import org.alfresco.service.cmr.repository.NodeRef;
/**
@@ -29,8 +34,91 @@ import org.alfresco.service.cmr.repository.NodeRef;
* @author Roy Wetherall
* @since 2.1
*/
public class RMv21CapabilityPatch extends BaseRMCapabilityPatch
@SuppressWarnings("deprecation")
public class RMv21CapabilityPatch extends RMv21PatchComponent
{
/** File plan service */
private FilePlanService filePlanService;
/** File plan role service */
private FilePlanRoleService filePlanRoleService;
/** Capability service */
private CapabilityService capabilityService;
/**
* @param filePlanRoleService file plan role service
*/
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
{
this.filePlanRoleService = filePlanRoleService;
}
/**
* @param capabilityService capability service
*/
public void setCapabilityService(CapabilityService capabilityService)
{
this.capabilityService = capabilityService;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* Helper method to get the file plans
*
* @return Set of file plan node references
*/
protected Set<NodeRef> getFilePlans()
{
return filePlanService.getFilePlans();
}
/**
* Adds a new capability to the specified roles.
*
* @param filePlan file plan
* @param capabilityName capability name
* @param roles roles
*/
protected void addCapability(NodeRef filePlan, String capabilityName, String ... roles)
{
Capability capability = capabilityService.getCapability(capabilityName);
if (capability == null)
{
throw new AlfrescoRuntimeException("Unable to bootstrap RMv21 capabilities, because capability " + capabilityName + " does not exist.");
}
for (String roleName : roles)
{
Role role = filePlanRoleService.getRole(filePlan, roleName);
if (role != null)
{
// get the roles current capabilities
Set<Capability> capabilities = role.getCapabilities();
// only update if the capability is missing
if (capabilities.contains(capability) == false)
{
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... adding capability " + capabilityName + " to role " + role.getName());
}
capabilities.add(capability);
filePlanRoleService.updateRole(filePlan, role.getName(), role.getDisplayLabel(), capabilities);
}
}
}
}
/**
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
*/

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v21;
import java.util.HashSet;
import java.util.List;
@@ -47,7 +47,8 @@ import org.springframework.beans.factory.BeanNameAware;
* @author Roy Wetherall
* @since 2.1
*/
public class RMv21InPlacePatch extends ModulePatchComponent
@SuppressWarnings("deprecation")
public class RMv21InPlacePatch extends RMv21PatchComponent
implements BeanNameAware, RecordsManagementModel, DOD5015Model
{
/** Extended reader and writer role details */
@@ -202,7 +203,6 @@ public class RMv21InPlacePatch extends ModulePatchComponent
NodeRef container = filePlanService.getHoldContainer(filePlan);
@SuppressWarnings("deprecation")
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(filePlan, ASSOC_HOLDS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs)
{
@@ -221,7 +221,6 @@ public class RMv21InPlacePatch extends ModulePatchComponent
NodeRef container = filePlanService.getTransferContainer(filePlan);
@SuppressWarnings("deprecation")
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(filePlan, ASSOC_TRANSFERS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs)
{

View File

@@ -0,0 +1,76 @@
/*
* 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.v21;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent;
import org.alfresco.repo.module.ModuleComponent;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Convenience class to ensure all V2.0 patches are executed before v2.1
*
* @author Roy Wetherall
* @since 2.2
*/
@SuppressWarnings("deprecation")
public abstract class RMv21PatchComponent extends ModulePatchComponent
implements ApplicationContextAware
{
/** application context */
private ApplicationContext applicationContext;
/**
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
this.applicationContext = applicationContext;
}
/**
* init method
*/
@Override
public void init()
{
super.init();
// manual addition of V20 patch dependencies
List<ModuleComponent> depends = getDependsOn();
addDependency(depends, "org_alfresco_module_rm_notificationTemplatePatch");
addDependency(depends, "org_alfresco_module_rm_RMv2ModelPatch");
addDependency(depends, "org_alfresco_module_rm_RMv2FilePlanNodeRefPatch");
addDependency(depends, "org_alfresco_module_rm_RMv2SavedSearchPatch");
}
/**
* @param depends list of module dependencies
* @param beanName bean name
*/
private void addDependency(List<ModuleComponent> depends, String beanName)
{
ModuleComponent moduleComponent = (ModuleComponent)applicationContext.getBean(beanName);
depends.add(moduleComponent);
}
}

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v21;
import java.io.Serializable;
import java.util.HashMap;
@@ -40,7 +40,8 @@ import org.springframework.extensions.surf.util.I18NUtil;
*
* @author Roy Wetherall
*/
public class RMv2RMAdminUserPatch extends ModulePatchComponent implements BeanNameAware
@SuppressWarnings("deprecation")
public class RMv21RMAdminUserPatch extends RMv21PatchComponent implements BeanNameAware
{
/** I18N */
private static final String MSG_FIRST_NAME = "bootstrap.rmadmin.firstName";

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v21;
import java.util.List;
@@ -39,7 +39,8 @@ import org.springframework.beans.factory.BeanNameAware;
* @author Roy Wetherall
* @since 2.1
*/
public class RMv21RecordInheritancePatch extends ModulePatchComponent
@SuppressWarnings("deprecation")
public class RMv21RecordInheritancePatch extends RMv21PatchComponent
implements BeanNameAware, RecordsManagementModel, DOD5015Model
{
/** file plan permission service */

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v21;
import java.io.InputStream;
import java.io.Serializable;
@@ -40,7 +40,8 @@ import org.springframework.beans.factory.BeanNameAware;
* @author Roy Wetherall
* @since 2.1
*/
public class RMv21ReportServicePatch extends ModulePatchComponent
@SuppressWarnings("deprecation")
public class RMv21ReportServicePatch extends RMv21PatchComponent
implements BeanNameAware
{
private static final NodeRef TEMPLATE_ROOT = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, "rm_report_templates");

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v21;
import java.util.Arrays;
import java.util.HashSet;
@@ -36,7 +36,8 @@ import org.springframework.beans.factory.BeanNameAware;
* @author Tuna Aksoy
* @since 2.1
*/
public class RMv21RolesPatch extends ModulePatchComponent implements BeanNameAware
@SuppressWarnings("deprecation")
public class RMv21RolesPatch extends RMv21PatchComponent implements BeanNameAware
{
/** file plan service */
private FilePlanService filePlanService;
@@ -63,7 +64,7 @@ public class RMv21RolesPatch extends ModulePatchComponent implements BeanNameAwa
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.ModulePatchComponent#executePatch()
* @see org.alfresco.module.org_alfresco_module_rm.patch.compatibility.ModulePatchComponent#executePatch()
*/
@Override
protected void executePatch() throws Throwable

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v22;
import java.util.Set;
@@ -24,18 +24,20 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.role.Role;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Base class for the capability patch classes
* RM v2.2 patch to updated modified capabilities.
*
* @author Tuna Aksoy
* @since 2.2
*/
public abstract class BaseRMCapabilityPatch extends ModulePatchComponent
public class RMv22CapabilityPatch extends AbstractModulePatch
{
/** File plan service */
private FilePlanService filePlanService;
@@ -117,4 +119,32 @@ public abstract class BaseRMCapabilityPatch extends ModulePatchComponent
}
}
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal()
*/
@Override
public void applyInternal()
{
Set<NodeRef> filePlans = getFilePlans();
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... updating " + filePlans.size() + " file plans");
}
for (NodeRef filePlan : filePlans)
{
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... updating file plan " + filePlan.toString());
}
// add new capability
addCapability(filePlan,
"FileDestructionReport",
FilePlanRoleService.ROLE_ADMIN,
FilePlanRoleService.ROLE_RECORDS_MANAGER);
}
}
}

View File

@@ -0,0 +1,134 @@
/*
* 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.patch.v22;
import java.util.Collections;
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.patch.AbstractModulePatch;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.patch.PatchDAO;
import org.alfresco.repo.domain.qname.QNameDAO;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
/**
* DOD model separation module patch implementation
*
* @author Roy Wetherall
* @since 2.2
*/
public class RMv22DODModelSeparationModulePatch extends AbstractModulePatch
implements RecordsManagementModel
{
/** query batch size */
private static long BATCH_SIZE = 100000L;
/** QName DAO */
private QNameDAO qnameDAO;
/** Patch DAO */
private PatchDAO patchDAO;
/** Node DAO */
private NodeDAO nodeDAO;
/** qnames to update (switch to dod namespace) */
private QName[] qnames =
{
DOD5015Model.PROP_ORIGINATOR,
DOD5015Model.PROP_ORIGINATING_ORGANIZATION,
DOD5015Model.PROP_PUBLICATION_DATE,
DOD5015Model.PROP_MEDIA_TYPE,
DOD5015Model.PROP_FORMAT,
DOD5015Model.PROP_DATE_RECEIVED
};
/**
* @param qnameDAO QName DAO
*/
public void setQnameDAO(QNameDAO qnameDAO)
{
this.qnameDAO = qnameDAO;
}
/**
* @param patchDAO patch DAO
*/
public void setPatchDAO(PatchDAO patchDAO)
{
this.patchDAO = patchDAO;
}
/**
* @param nodeDAO node DAO
*/
public void setNodeDAO(NodeDAO nodeDAO)
{
this.nodeDAO = nodeDAO;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal()
*/
@Override
public void applyInternal()
{
Long maxNodeId = patchDAO.getMaxAdmNodeID();
// switch each qname from the rma namespace to the dod namespace
for (QName qname : qnames)
{
QName origional = QName.createQName(RecordsManagementModel.RM_URI, qname.getLocalName());
if (qnameDAO.getQName(origional) != null)
{
qnameDAO.updateQName(origional, qname);
}
}
long recordCount = patchDAO.getCountNodesWithAspects(Collections.singleton(ASPECT_RECORD));
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... updating " + recordCount + " records");
}
// apply the DOD record aspect to all exiting records
int completed = 0;
Pair<Long, QName> recordAspect = qnameDAO.getQName(ASPECT_RECORD);
if (recordAspect != null)
{
for (Long i = 0L; i < maxNodeId; i+=BATCH_SIZE)
{
List<Long> nodeIds = patchDAO.getNodesByAspectQNameId(recordAspect.getFirst(), i, i + BATCH_SIZE);
for (Long nodeId : nodeIds)
{
nodeDAO.addNodeAspects(nodeId, Collections.singleton(DOD5015Model.ASPECT_DOD_5015_RECORD));
}
completed += completed + nodeIds.size();
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... completed " + completed + " of " + recordCount);
}
}
}
}
}

View File

@@ -16,7 +16,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.patch;
package org.alfresco.module.org_alfresco_module_rm.patch.v22;
import java.io.InputStream;
import java.io.Serializable;
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
@@ -39,7 +40,7 @@ import org.alfresco.service.namespace.QName;
* @author Tuna Aksoy
* @since 2.2
*/
public class RMv22ReportTemplatePatch extends ModulePatchComponent
public class RMv22ReportTemplatePatch extends AbstractModulePatch
{
/** Report template path */
private static final String REPORT_TEMPLATE_PATH = "alfresco/module/org_alfresco_module_rm/bootstrap/report/report_rmr_transferReport.html.ftl";
@@ -70,8 +71,11 @@ public class RMv22ReportTemplatePatch extends ModulePatchComponent
this.contentService = contentService;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal()
*/
@Override
protected void executePatch() throws Throwable
public void applyInternal()
{
NodeRef transferReport = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, TRANSFER_REPORT);
NodeRef destructionReport = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, DESTRUCTION_REPORT);