Revert to original code structure pre-mavenization

* merges from previous branches are now possible without tree conflicts
  * added back missing commits when structure was changed (r59445, r59446) .. see RM-765
  * updated Maven POM's to use existing code structure
  * NOTE: r59454 and r59473 may have been missed in this update .. will go back and re-add



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@59491 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2014-01-08 06:38:59 +00:00
parent 098833f8d5
commit ebe454f13e
885 changed files with 535 additions and 361 deletions

View File

@@ -0,0 +1,132 @@
/*
* 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.repo.action;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Extended action service implementation.
*
* @author Roy Wetherall
* @since 2.1
*/
public class ExtendedActionServiceImpl extends ActionServiceImpl implements ApplicationContextAware
{
/** File plan service */
private FilePlanService filePlanService;
/** Application context */
private ApplicationContext extendedApplicationContext;
/**
* @see org.alfresco.repo.action.ActionServiceImpl#setApplicationContext(org.springframework.context.ApplicationContext)
*/
public void setApplicationContext(ApplicationContext applicationContext)
{
super.setApplicationContext(applicationContext);
extendedApplicationContext = applicationContext;
}
/**
* @param filePlanService file plan service
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* @see org.alfresco.repo.action.ActionServiceImpl#getActionConditionDefinition(java.lang.String)
*/
public ActionConditionDefinition getActionConditionDefinition(String name)
{
// get direct access to action condition definition (i.e. ignoring public flag of executer)
ActionConditionDefinition definition = null;
Object bean = extendedApplicationContext.getBean(name);
if (bean != null && bean instanceof ActionConditionEvaluator)
{
ActionConditionEvaluator evaluator = (ActionConditionEvaluator) bean;
definition = evaluator.getActionConditionDefintion();
}
return definition;
}
/**
* @see org.alfresco.repo.action.ActionServiceImpl#getActionDefinitions(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public List<ActionDefinition> getActionDefinitions(NodeRef nodeRef)
{
List<ActionDefinition> result = null;
// first use the base implementation to get the list of action definitions
List<ActionDefinition> actionDefinitions = super.getActionDefinitions(nodeRef);
if (nodeRef == null)
{
// nothing to filter
result = actionDefinitions;
}
else
{
// get the file component kind of the node reference
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
result = new ArrayList<ActionDefinition>(actionDefinitions.size());
// check each action definition
for (ActionDefinition actionDefinition : actionDefinitions)
{
if (actionDefinition instanceof RecordsManagementActionDefinition)
{
if (kind != null)
{
Set<FilePlanComponentKind> applicableKinds = ((RecordsManagementActionDefinition)actionDefinition).getApplicableKinds();
if (applicableKinds == null || applicableKinds.size() == 0 || applicableKinds.contains(kind))
{
// an RM action can only act on a RM artifact
result.add(actionDefinition);
}
}
}
else
{
if (kind == null)
{
// a non-RM action can only act on a non-RM artifact
result.add(actionDefinition);
}
}
}
}
return result;
}
}

View File

@@ -0,0 +1,175 @@
/*
* 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.repo.action.parameter;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Date parameter processor.
*
* @author Roy Wetherall
* @since 2.1
*/
public class DateParameterProcessor extends ParameterProcessor
{
private static final String DAY = "day";
private static final String WEEK = "week";
private static final String MONTH = "month";
private static final String YEAR = "year";
private static final String SHORT = "short";
private static final String LONG = "long";
private static final String NUMBER = "number";
/**
* @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public String process(String value, NodeRef actionedUponNodeRef)
{
// the default position is to return the value un-changed
String result = value;
// strip the processor name from the value
value = stripName(value);
if (value.isEmpty() == false)
{
String[] values = value.split("\\.", 2);
String field = values[0].trim();
if (DAY.equalsIgnoreCase(field))
{
result = handleDay(values);
}
else if (MONTH.equalsIgnoreCase(field))
{
result = handleMonth(values);
}
else if (YEAR.equalsIgnoreCase(field))
{
result = handleYear(values);
}
else
{
throw new AlfrescoRuntimeException("Cannot process the field '" + field + "'.");
}
}
return result;
}
private String handleDay(String[] values)
{
String style = getStyle(values);
String pattern;
if (SHORT.equalsIgnoreCase(style))
{
pattern = "EE";
}
else if (LONG.equalsIgnoreCase(style))
{
pattern = "EEEE";
}
else if (NUMBER.equalsIgnoreCase(style))
{
pattern = "u";
}
else if (YEAR.equalsIgnoreCase(style))
{
pattern = "D";
}
else
{
throw new AlfrescoRuntimeException("The pattern 'date.day." + style + "' is not supported!");
}
return new SimpleDateFormat(pattern).format(new Date());
}
private String handleMonth(String[] values)
{
String style = getStyle(values);
String pattern;
if (SHORT.equalsIgnoreCase(style))
{
pattern = "MMM";
}
else if (LONG.equalsIgnoreCase(style))
{
pattern = "MMMM";
}
else if (NUMBER.equalsIgnoreCase(style))
{
pattern = "MM";
}
else
{
throw new AlfrescoRuntimeException("The pattern 'date.month." + style + "' is not supported!");
}
return new SimpleDateFormat(pattern).format(new Date());
}
private String handleYear(String[] values)
{
String style = getStyle(values);
String pattern;
if (SHORT.equalsIgnoreCase(style))
{
pattern = "yy";
}
else if (LONG.equalsIgnoreCase(style))
{
pattern = "yyyy";
}
else if (WEEK.equalsIgnoreCase(style))
{
pattern = "w";
}
else
{
throw new AlfrescoRuntimeException("The pattern 'date.year." + style + "' is not supported!");
}
return new SimpleDateFormat(pattern).format(new Date());
}
private String getStyle(String[] values)
{
String style;
if (values.length == 1)
{
style = SHORT;
}
else
{
style = values[1].trim();
}
return style;
}
}

View File

@@ -0,0 +1,55 @@
/*
* 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.repo.action.parameter;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.surf.util.I18NUtil;
/**
* Message parameter processor.
*
* @author Roy Wetherall
* @since 2.1
*/
public class MessageParameterProcessor extends ParameterProcessor
{
/**
* @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public String process(String value, NodeRef actionedUponNodeRef)
{
// the default position is to return the value un-changed
String result = value;
// strip the processor name from the value
value = stripName(value);
if (value.isEmpty() == false)
{
result = I18NUtil.getMessage(value);
if (result == null)
{
throw new AlfrescoRuntimeException("The message parameter processor could not resolve the message for the id " + value);
}
}
return result;
}
}

View File

@@ -0,0 +1,130 @@
/*
* 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.repo.action.parameter;
import java.io.Serializable;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
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.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.apache.commons.lang.ArrayUtils;
/**
* Node parameter processor.
*
* @author Roy Wetherall
* @since 2.1
*/
public class NodeParameterProcessor extends ParameterProcessor
{
/** Supported data types */
private QName[] supportedDataTypes =
{
DataTypeDefinition.TEXT,
DataTypeDefinition.BOOLEAN,
DataTypeDefinition.DATE,
DataTypeDefinition.DATETIME,
DataTypeDefinition.DOUBLE,
DataTypeDefinition.FLOAT,
DataTypeDefinition.INT,
DataTypeDefinition.MLTEXT
};
/** Node service */
private NodeService nodeService;
/** Namespace service */
private NamespaceService namespaceService;
/** Dictionary service */
private DictionaryService dictionaryService;
/**
* @param nodeService node service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param namespaceService namespace service
*/
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
/**
* @param dictionaryService dictionary service
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/**
* @see org.alfresco.repo.action.parameter.ParameterProcessor#process(java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public String process(String value, NodeRef actionedUponNodeRef)
{
// the default position is to return the value un-changed
String result = value;
// strip the processor name from the value
value = stripName(value);
if (value.isEmpty() == false)
{
QName qname = QName.createQName(value, namespaceService);
PropertyDefinition propertyDefinition = dictionaryService.getProperty(qname);
if (propertyDefinition == null)
{
throw new AlfrescoRuntimeException("The property " + value + " does not have a property definition.");
}
QName type = propertyDefinition.getDataType().getName();
if (ArrayUtils.contains(supportedDataTypes, type) == true)
{
Serializable propertyValue = nodeService.getProperty(actionedUponNodeRef, qname);
if (propertyValue != null)
{
result = propertyValue.toString();
}
else
{
// set the result to the empty string
result = "";
}
}
else
{
throw new AlfrescoRuntimeException("The property " + value + " is of type " + type.toString() + " which is not supported by parameter substitution.");
}
}
return result;
}
}

View File

@@ -0,0 +1,94 @@
/*
* 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.repo.action.parameter;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Abstract parameter processor implementation.
*
* @author Roy Wetherall
* @since 2.1
*/
public abstract class ParameterProcessor
{
/** Processor name */
private String name;
/** Parameter processor component */
private ParameterProcessorComponent parameterProcessorComponent;
/**
* @return parameter processor name
*/
public String getName()
{
return name;
}
/**
* @param name parameter processor name
*/
public void setName(String name)
{
this.name = name;
}
/**
* @param parameterProcessorComponent parameter processor component
*/
public void setParameterProcessorComponent(ParameterProcessorComponent parameterProcessorComponent)
{
this.parameterProcessorComponent = parameterProcessorComponent;
}
/**
* Init method
*/
public void init()
{
parameterProcessorComponent.register(this);
}
/**
* Process the parameter value.
*
* @param value substitution value
* @param actionedUponNodeRef actioned upon node reference
* @return String processed string, original string if subs string invalid
*/
public abstract String process(String value, NodeRef actionedUponNodeRef);
/**
* Strips the name of the processor from the subs value.
*
* @param value subs value
* @return String subs value with the name and '.' delimiter removed
*/
protected String stripName(String value)
{
String result = "";
String[] values = value.split("\\.", 2);
if (values.length == 2)
{
result = values[1];
}
return result;
}
}

View File

@@ -0,0 +1,137 @@
/*
* 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.repo.action.parameter;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.action.ParameterizedItem;
import org.alfresco.service.cmr.action.ParameterizedItemDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Parameter processor component
*
* @author Roy Wetherall
* @since 2.1
*/
public class ParameterProcessorComponent
{
/** regex used to parse parameters */
private static final String REG_EX = "\\$\\{([^\\$\\{]+)\\}";
/** registry of parameter processors */
private Map<String, ParameterProcessor> processors = new HashMap<String, ParameterProcessor>(5);
/**
* Register parameter processor
*
* @param processor
*/
public void register(ParameterProcessor processor)
{
this.processors.put(processor.getName(), processor);
}
/**
*
* @param ruleItem
* @param ruleItemDefinition
* @param actionedUponNodeRef
*/
public void process(ParameterizedItem ruleItem, ParameterizedItemDefinition ruleItemDefinition, NodeRef actionedUponNodeRef)
{
for (Map.Entry<String, Serializable> entry : ruleItem.getParameterValues().entrySet())
{
String parameterName = entry.getKey();
Object parameterValue = entry.getValue();
// only sub string property values
if (parameterValue != null && parameterValue instanceof String)
{
// set the updated parameter value
ruleItem.setParameterValue(parameterName, process((String)parameterValue, actionedUponNodeRef));
}
}
}
/**
* Process the value for substitution within the context of the provided node.
*
* @param value value
* @param nodeRef node reference
* @return String resulting value
*/
public String process(String value, NodeRef nodeRef)
{
// match the substitution pattern
Pattern patt = Pattern.compile(REG_EX);
Matcher m = patt.matcher(value);
StringBuffer sb = new StringBuffer(value.length());
while (m.find())
{
String text = m.group(1);
// lookup parameter processor to use
ParameterProcessor processor = lookupProcessor(text);
if (processor == null)
{
throw new AlfrescoRuntimeException("A parameter processor has not been found for the substitution string " + text);
}
else
{
// process each substitution value
text = processor.process(text, nodeRef);
}
// append new value
m.appendReplacement(sb, Matcher.quoteReplacement(text));
}
m.appendTail(sb);
return sb.toString();
}
/**
* Look up parameter processor
*
* @param value
* @return
*/
private ParameterProcessor lookupProcessor(String value)
{
ParameterProcessor result = null;
if (value != null && value.isEmpty() == false)
{
String[] values = value.split("\\.", 2);
if (values.length != 0)
{
// get the processor from the registered map
result = processors.get(values[0]);
}
}
return result;
}
}