Merged BRANCHES/V2.2 to BRANCHES/V2.3:

97444: RM-1586 Restricted the custom metadata property names to alphanumeric and a few special characters
   97026: RM-1660 Fixed NPE exception on schema upgrade Also fixed transaction type for the capabilities schema update.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.3@97447 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alexandru Balan
2015-02-19 08:59:00 +00:00
3 changed files with 62 additions and 28 deletions

View File

@@ -58,6 +58,12 @@ public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
/** module patch target module schema number */ /** module patch target module schema number */
private int targetSchema; private int targetSchema;
/** if it should use a read only transaction */
private boolean txnReadOnly = true;
/** if it should use a new transaction */
private boolean txnRequiresNew = false;
/** /**
* Initiialisation method * Initiialisation method
@@ -66,6 +72,16 @@ public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
{ {
modulePatchExecuter.register(this); modulePatchExecuter.register(this);
} }
protected void setTxnReadOnly(boolean txnReadOnly)
{
this.txnReadOnly = txnReadOnly;
}
protected void setTxnRequiresNew(boolean txnRequiresNew)
{
this.txnRequiresNew = txnRequiresNew;
}
/** /**
* @param modulePatchExecuter module patch executer * @param modulePatchExecuter module patch executer
@@ -216,8 +232,8 @@ public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
// do patch in transaction // do patch in transaction
transactionService.getRetryingTransactionHelper().doInTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
new ApplyCallback(), new ApplyCallback(),
true, txnReadOnly,
false); txnRequiresNew);
if (LOGGER.isInfoEnabled()) if (LOGGER.isInfoEnabled())
{ {

View File

@@ -128,5 +128,13 @@ public abstract class CapabilityPatch extends AbstractModulePatch
} }
} }
@Override
public void apply()
{
setTxnReadOnly(false);
setTxnRequiresNew(true);
super.apply();
}
protected abstract void applyCapabilityPatch(NodeRef filePlan); protected abstract void applyCapabilityPatch(NodeRef filePlan);
} }

View File

@@ -126,35 +126,45 @@ public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent
NodeRef filePlan = filePlanService.getFilePlan(filePlanComponentNodeRef); NodeRef filePlan = filePlanService.getFilePlan(filePlanComponentNodeRef);
// set the file plan node reference if(filePlan != null)
if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null) {
{ // set the file plan node reference
nodeService.setProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF, filePlan); if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null)
{
nodeService.setProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF, filePlan);
}
// only set the admin permissions on record categories, record folders and records
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(filePlanComponentNodeRef);
if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) ||
FilePlanComponentKind.RECORD_FOLDER.equals(kind) ||
FilePlanComponentKind.RECORD.equals(kind))
{
// ensure the that the records management role has read and file on the node
Role adminRole = filePlanRoleService.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"));
}
}
} }
else
// only set the admin permissions on record categories, record folders and records
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(filePlanComponentNodeRef);
if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) ||
FilePlanComponentKind.RECORD_FOLDER.equals(kind) ||
FilePlanComponentKind.RECORD.equals(kind))
{ {
// ensure the that the records management role has read and file on the node if (LOGGER.isWarnEnabled())
Role adminRole = filePlanRoleService.getRole(filePlan, "Administrator");
if (adminRole != null)
{ {
permissionService.setPermission(filePlanComponentNodeRef, adminRole.getRoleGroupName(), RMPermissionModel.FILING, true); LOGGER.warn(" ... node " + filePlanComponent.toString() + " was skiped, beacuse there was no associated file plan.");
}
// 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"));
} }
} }
} }