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@55074 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-09-07 20:09:45 +00:00
parent 5df0df19e7
commit 1098fda2bb
2 changed files with 10 additions and 16 deletions

View File

@@ -214,11 +214,11 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
*/ */
public void addCustomMapping(String from, String to) public void addCustomMapping(String from, String to)
{ {
if (StringUtils.isBlank(from) || StringUtils.isBlank(to) || !getEmailMappingKeys().contains(from)) if (StringUtils.isBlank(from) || StringUtils.isBlank(to))
{ {
throw new AlfrescoRuntimeException("Invalid values for from/to."); throw new AlfrescoRuntimeException("Invalid values for from/to.");
} }
// create custom mapping // create custom mapping
CustomMapping customMapping = new CustomMapping(from, to); CustomMapping customMapping = new CustomMapping(from, to);
@@ -245,6 +245,11 @@ public class CustomEmailMappingServiceImpl extends AbstractLifecycleBean impleme
*/ */
public void deleteCustomMapping(String from, String to) public void deleteCustomMapping(String from, String to)
{ {
if (StringUtils.isBlank(from) || StringUtils.isBlank(to))
{
throw new AlfrescoRuntimeException("Invalid values for from/to.");
}
// create custom mapping // create custom mapping
CustomMapping customMapping = new CustomMapping(from, to); CustomMapping customMapping = new CustomMapping(from, to);

View File

@@ -65,7 +65,7 @@ public class CustomEMailMappingServiceImplTest extends BaseRMTestCase
assertTrue(checkCustomMappingsSize(20)); assertTrue(checkCustomMappingsSize(20));
String firstKey = eMailMappingService.getEmailMappingKeys().get(0); String firstKey = eMailMappingService.getEmailMappingKeys().get(0);
// Add a custom mapping // Add a custom mapping
eMailMappingService.addCustomMapping(firstKey, "cm:monkeyFace"); eMailMappingService.addCustomMapping(firstKey, "cm:monkeyFace");
@@ -90,7 +90,7 @@ public class CustomEMailMappingServiceImplTest extends BaseRMTestCase
// Check the email mapping keys size // Check the email mapping keys size
// There are 6 "standard" EmailMappingKeys + 2 CustomEmailMappingKeys are added on setUp // There are 6 "standard" EmailMappingKeys + 2 CustomEmailMappingKeys are added on setUp
assertTrue(checkEmailMappingKeysSize(8)); assertTrue(checkEmailMappingKeysSize(8));
try try
{ {
eMailMappingService.addCustomMapping(" ", "cm:monkeyFace"); eMailMappingService.addCustomMapping(" ", "cm:monkeyFace");
@@ -114,18 +114,7 @@ public class CustomEMailMappingServiceImplTest extends BaseRMTestCase
} }
eMailMappingService.addCustomMapping(firstKey, "cm:monkeyFace"); //valid key eMailMappingService.addCustomMapping(firstKey, "cm:monkeyFace"); //valid key
try
{
eMailMappingService.addCustomMapping(firstKey+"invalid", "cm:monkeyFace");//invalid key
fail("Should not get here. Invalid data.");
}
catch (AlfrescoRuntimeException are)
{
assertNotNull(are); //Must throw this exception
assertTrue(are.getMessage().contains("Invalid values for"));
}
return null; return null;
} }
}, rmAdminName); }, rmAdminName);