Added more validation and tests as a fix for RM-915: The creation of a new Email Mapping: It's possible to type into "map" field any text or spaces.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@55067 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gethin James
2013-09-06 17:41:02 +00:00
parent 626e42ffd6
commit 5df0df19e7
2 changed files with 49 additions and 5 deletions

View File

@@ -45,6 +45,7 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ParameterCheck;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
@@ -213,6 +214,11 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
*/
public void addCustomMapping(String from, String to)
{
if (StringUtils.isBlank(from) || StringUtils.isBlank(to) || !getEmailMappingKeys().contains(from))
{
throw new AlfrescoRuntimeException("Invalid values for from/to.");
}
// create custom mapping
CustomMapping customMapping = new CustomMapping(from, to);