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,243 @@
/*
* 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.web.scripts.dictionary;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.QName;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Webscript to get the Classdefinitions using classfilter , namespaceprefix and name
*
* This class makes it possible to get only RM related class definitions
* @see ClassesGet for the original implementation
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RmClassesGet extends DictionaryWebServiceBase implements RecordsManagementModel
{
private static final String MODEL_PROP_KEY_CLASS_DEFS = "classdefs";
private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs";
private static final String MODEL_PROP_KEY_ASSOCIATION_DETAILS = "assocdefs";
private static final String CLASS_FILTER_OPTION_TYPE1 = "all";
private static final String CLASS_FILTER_OPTION_TYPE2 = "aspect";
private static final String CLASS_FILTER_OPTION_TYPE3 = "type";
private static final String REQ_URL_TEMPL_VAR_CLASS_FILTER = "cf";
private static final String REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX = "nsp";
private static final String REQ_URL_TEMPL_VAR_NAME = "n";
/** Site service*/
private SiteService siteService;
/**
* @param siteService the site service to set
*/
public void setSiteService(SiteService siteService)
{
this.siteService = siteService;
}
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
return executeImpl(req, status, cache, RmDictionaryWebServiceUtils.isRmSite(req, siteService));
}
/**
* Execute custom Java logic
*
* @param req Web Script request
* @param status Web Script status
* @param cache Web Script cache
* @param isRM indicates whether the request comes from an RM site or not
* @return custom service model
*/
private Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache, boolean isRM)
{
String classFilter = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_CLASS_FILTER));
String namespacePrefix = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX));
String name = getValidInput(req.getParameter(REQ_URL_TEMPL_VAR_NAME));
String className = null;
Map<QName, ClassDefinition> classdef = new HashMap<QName, ClassDefinition>();
Map<QName, Collection<PropertyDefinition>> propdef = new HashMap<QName, Collection<PropertyDefinition>>();
Map<QName, Collection<AssociationDefinition>> assocdef = new HashMap<QName, Collection<AssociationDefinition>>();
Map<String, Object> model = new HashMap<String, Object>();
List<QName> qnames = new ArrayList<QName>();
QName classQname = null;
QName myModel = null;
//if classfilter is not given, then it defaults to all
if (classFilter == null)
{
classFilter = "all";
}
//validate classfilter
if (isValidClassFilter(classFilter) == false)
{
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the classfilter - " + classFilter + " provided in the URL");
}
//name alone has no meaning without namespaceprefix
if (namespacePrefix == null && name != null)
{
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Missing namespaceprefix parameter in the URL - both combination of name and namespaceprefix is needed");
}
//validate the namespaceprefix and name parameters => if namespaceprefix is given, then name has to be validated along with it
if (namespacePrefix != null)
{
//validate name parameter if present along with the namespaceprefix
if (name != null)
{
className = namespacePrefix + "_" + name;
if (isValidClassname(className) == false)
{
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the name - " + name + "parameter in the URL");
}
classQname = QName.createQName(getFullNamespaceURI(className));
classdef.put(classQname, this.dictionaryservice.getClass(classQname));
propdef.put(classQname, this.dictionaryservice.getClass(classQname).getProperties().values());
assocdef.put(classQname, this.dictionaryservice.getClass(classQname).getAssociations().values());
}
else
{
//if name is not given then the model is extracted from the namespaceprefix, there can be more than one model associated with one namespaceprefix
String namespaceUri = namespaceService.getNamespaceURI(namespacePrefix);
for (QName qnameObj : this.dictionaryservice.getAllModels())
{
if (qnameObj.getNamespaceURI().equals(namespaceUri))
{
name = qnameObj.getLocalName();
myModel = QName.createQName(getFullNamespaceURI(namespacePrefix + "_" + name));
// check the classfilter to pull out either all or type or aspects
if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1))
{
qnames.addAll(this.dictionaryservice.getAspects(myModel));
qnames.addAll(this.dictionaryservice.getTypes(myModel));
}
else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3))
{
qnames.addAll(this.dictionaryservice.getTypes(myModel));
}
else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2))
{
qnames.addAll(this.dictionaryservice.getAspects(myModel));
}
}
}
}
}
// if namespacePrefix is null, then check the class filter to pull out either all, type or aspects
if (myModel == null)
{
if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE1))
{
qnames.addAll(getAspects(isRM));
qnames.addAll(getTypes(isRM));
}
else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE3))
{
qnames.addAll(getTypes(isRM));
}
else if (classFilter.equalsIgnoreCase(CLASS_FILTER_OPTION_TYPE2))
{
qnames.addAll(getAspects(isRM));
}
}
if (classdef.isEmpty() == true)
{
for (QName qnameObj : qnames)
{
classdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj));
propdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj).getProperties().values());
assocdef.put(qnameObj, this.dictionaryservice.getClass(qnameObj).getAssociations().values());
}
}
List<ClassDefinition> classDefinitions = new ArrayList<ClassDefinition>(classdef.values());
Collections.sort(classDefinitions, new DictionaryComparators.ClassDefinitionComparator(dictionaryservice));
model.put(MODEL_PROP_KEY_CLASS_DEFS, classDefinitions);
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, propdef.values());
model.put(MODEL_PROP_KEY_ASSOCIATION_DETAILS, assocdef.values());
model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, dictionaryservice);
return model;
}
/**
* Returns the names of the types depending on {@link isRM} parameter
*
* @param isRM if true only RM related types will be retrieved
* @return The names of the types defined within the specified model or all of them depending on {@link isRM} parameter
*/
private Collection<QName> getTypes(boolean isRM)
{
if (isRM == true)
{
return this.dictionaryservice.getTypes(RM_MODEL);
}
else
{
return this.dictionaryservice.getAllTypes();
}
}
/**
* Returns the names of the aspects depending on {@link isRM} parameter
*
* @param isRM if true only RM related aspects will be retrieved
* @return The names of the aspects defined within the specified model or all of them depending on {@link isRM} parameter
*/
private Collection<QName> getAspects(boolean isRM)
{
if (isRM == true)
{
return this.dictionaryservice.getAspects(RM_MODEL);
}
else
{
return this.dictionaryservice.getAllAspects();
}
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.web.scripts.dictionary;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.apache.commons.lang.StringUtils;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Util class for dictionary web services
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RmDictionaryWebServiceUtils
{
private static final String SITE_ID = "siteId";
private static final String SITE_PRESET = "rm-site-dashboard";
public static boolean isRmSite(WebScriptRequest req, SiteService siteService)
{
boolean isRmSite = false;
String siteId = req.getParameter(SITE_ID);
if (StringUtils.isNotBlank(siteId) == true)
{
SiteInfo site = siteService.getSite(siteId);
if (site != null)
{
if (site.getSitePreset().equals(SITE_PRESET) == true)
{
isRmSite = true;
}
}
}
return isRmSite;
}
}

View File

@@ -0,0 +1,177 @@
/*
* 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.web.scripts.dictionary;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.QName;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Webscript to get the Propertydefinitions for a given classname eg. =>cm_person
*
* This class makes it possible to get only RM related property definitions
* @see PropertiesGet for the original implementation
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RmPropertiesGet extends DictionaryWebServiceBase implements RecordsManagementModel
{
private static final String MODEL_PROP_KEY_PROPERTY_DETAILS = "propertydefs";
private static final String DICTIONARY_CLASS_NAME = "classname";
private static final String PARAM_NAME = "name";
private static final String REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX = "nsp";
/** Site service*/
private SiteService siteService;
/**
* @param siteService the site service to set
*/
public void setSiteService(SiteService siteService)
{
this.siteService = siteService;
}
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
return executeImpl(req, status, cache, RmDictionaryWebServiceUtils.isRmSite(req, siteService));
}
/**
* Execute custom Java logic
*
* @param req Web Script request
* @param status Web Script status
* @param cache Web Script cache
* @param isRM indicates whether the request comes from an RM site or not
* @return custom service model
*/
private Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache, boolean isRM)
{
QName classQName = null;
String className = req.getServiceMatch().getTemplateVars().get(DICTIONARY_CLASS_NAME);
if (className != null && className.length() != 0)
{
classQName = createClassQName(className);
if (classQName == null)
{
// Error
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Check the className - " + className + " - parameter in the URL");
}
}
String[] names = req.getParameterValues(PARAM_NAME);
String namespacePrefix = req.getParameter(REQ_URL_TEMPL_VAR_NAMESPACE_PREFIX);
String namespaceURI = null;
if (namespacePrefix != null)
{
namespaceURI = this.namespaceService.getNamespaceURI(namespacePrefix);
}
Map<QName, PropertyDefinition> propMap = null;
if (classQName == null)
{
if (names != null)
{
propMap = new HashMap<QName, PropertyDefinition>(names.length);
for (String name : names)
{
QName propQName = QName.createQName(name, namespaceService);
PropertyDefinition propDef = dictionaryservice.getProperty(propQName);
if (propDef != null)
{
propMap.put(propQName, propDef);
}
}
}
else
{
Collection<QName> propQNames = getProperties(isRM);
propMap = new HashMap<QName, PropertyDefinition>(propQNames.size());
for (QName propQName : propQNames)
{
propMap.put(propQName, dictionaryservice.getProperty(propQName));
}
}
}
else
{
// Get all the property definitions for the class
propMap = dictionaryservice.getClass(classQName).getProperties();
}
// Filter the properties by URI
List<PropertyDefinition> props = new ArrayList<PropertyDefinition>(propMap.size());
for (Map.Entry<QName, PropertyDefinition> entry : propMap.entrySet())
{
if ((namespaceURI != null &&
namespaceURI.equals(entry.getKey().getNamespaceURI()) == true) ||
namespaceURI == null)
{
props.add(entry.getValue());
}
}
// Order property definitions by title
Collections.sort(props, new DictionaryComparators.PropertyDefinitionComparator(dictionaryservice));
// Pass list of property definitions to template
Map<String, Object> model = new HashMap<String, Object>();
model.put(MODEL_PROP_KEY_PROPERTY_DETAILS, props);
model.put(MODEL_PROP_KEY_MESSAGE_LOOKUP, dictionaryservice);
return model;
}
/**
* Returns the names of the properties depending on {@link isRM} parameter
*
* @param isRM if true only RM related properties will be retrieved
* @return The names of the properties defined within the specified model or all of them depending on {@link isRM} parameter
*/
private Collection<QName> getProperties(boolean isRM)
{
if (isRM == true)
{
return dictionaryservice.getProperties(RM_MODEL);
}
else
{
return dictionaryservice.getAllProperties(null);
}
}
}

View File

@@ -0,0 +1,99 @@
/*
* 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.web.scripts.roles;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.script.admin.RoleDeclarativeWebScript;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.lang.StringUtils;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Abstract class for adding/removing a user/group to/from a role
* This class contains the common methods needed in the sub classes.
*
* @author Tuna Aksoy
* @since 2.1
*/
public class AbstractRmAuthorities extends RoleDeclarativeWebScript
{
/** Constants for the url parameters */
private static final String ROLE_ID = "roleId";
private static final String AUTHORITY_NAME = "authorityName";
/**
* Util method for getting the nodeRef from the request
*
* @param req The webscript request
* @return The nodeRef passed in the request
*/
protected NodeRef getFilePlan(WebScriptRequest req)
{
NodeRef filePlan = super.getFilePlan(req);
if (filePlan == null)
{
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No filePlan was provided on the URL.");
}
return filePlan;
}
/**
* Util method for getting the roleId from the request
*
* @param req The webscript request
* @return The role id passed in the request
*/
protected String getRoleId(WebScriptRequest req)
{
return getParamValue(req, ROLE_ID);
}
/**
* Util method for getting the authorityName from the request
*
* @param req The webscript request
* @return The authorityName passed in the request
*/
protected String getAuthorityName(WebScriptRequest req)
{
return getParamValue(req, AUTHORITY_NAME);
}
/**
* Helper method to get the value of parameter from the request
*
* @param req The webscript request
* @param param The name of the parameter for which the value is requested
* @return The value for the requested parameter
*/
private String getParamValue(WebScriptRequest req, String param)
{
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
String authorityName = templateVars.get(param);
if (StringUtils.isBlank(authorityName))
{
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No '" + param + "' was provided on the URL.");
}
return authorityName;
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.web.scripts.roles;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Webscript for removing a user or a group from a role
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RmAuthoritiesDelete extends AbstractRmAuthorities
{
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
* org.springframework.extensions.webscripts.Status,
* org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
NodeRef filePlan = getFilePlan(req);
String roleId = getRoleId(req);
String authorityName = getAuthorityName(req);
filePlanRoleService.unassignRoleFromAuthority(filePlan, roleId, authorityName);
return new HashMap<String, Object>();
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.web.scripts.roles;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Webscript for adding a user or a group to a role
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RmAuthoritiesPost extends AbstractRmAuthorities
{
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
* org.springframework.extensions.webscripts.Status,
* org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
NodeRef filePlan = getFilePlan(req);
String roleId = getRoleId(req);
String authorityName = getAuthorityName(req);
filePlanRoleService.assignRoleToAuthority(filePlan, roleId, authorityName);
return new HashMap<String, Object>();
}
}

View File

@@ -0,0 +1,81 @@
/*
* 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.web.scripts.rule;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.action.ActionService;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Implementation for Java backed webscript to get the RM related action condition definition list.
*
* @author Roy Wetherall
* @since 2.1
*/
public class RmActionConditionDefinitionsGet extends DeclarativeWebScript
{
private ActionService actionService;
private RecordsManagementActionService recordsManagementActionService;
public void setActionService(ActionService actionService)
{
this.actionService = actionService;
}
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
{
this.recordsManagementActionService = recordsManagementActionService;
}
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
List<ActionConditionDefinition> dmDefs = actionService.getActionConditionDefinitions();
List<RecordsManagementActionCondition> conditions = recordsManagementActionService.getRecordsManagementActionConditions();
List<ActionConditionDefinition> defs = new ArrayList<ActionConditionDefinition>(dmDefs.size()+conditions.size());
defs.addAll(dmDefs);
for (RecordsManagementActionCondition condition: conditions)
{
if (condition.isPublicCondition() == true)
{
defs.add(condition.getRecordsManagementActionConditionDefinition());
}
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("actionconditiondefinitions", defs);
return model;
}
}

View File

@@ -0,0 +1,71 @@
/*
* 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.web.scripts.rule;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.service.cmr.action.ActionDefinition;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Implementation for Java backed webscript to get the RM related action definition list.
*
* @author Tuna Aksoy
* @since 2.1
*/
public class RmActionDefinitionsGet extends DeclarativeWebScript
{
private RecordsManagementActionService recordsManagementActionService;
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
{
this.recordsManagementActionService = recordsManagementActionService;
}
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
List<RecordsManagementAction> actions = recordsManagementActionService.getRecordsManagementActions();
Set<ActionDefinition> defs = new HashSet<ActionDefinition>(actions.size());
for (RecordsManagementAction action : actions)
{
if (action.isPublicAction() == true)
{
defs.add(action.getRecordsManagementActionDefinition());
}
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("actiondefinitions", defs);
return model;
}
}