RM-603 (REST API: users without Map Email Metadata capability can GET, POST, DELETE e-mail mappings)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@55076 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2013-09-07 21:17:41 +00:00
parent 1098fda2bb
commit 018bd7f557
2 changed files with 6 additions and 12 deletions

View File

@@ -2,11 +2,6 @@
<#escape x as jsonUtils.encodeJSONString(x)> <#escape x as jsonUtils.encodeJSONString(x)>
{ {
"success": ${success?string}, "data": <@emailmapLib.emailmapJSON emailmap=emailmap />
<#if success>
"data": <@emailmapLib.emailmapJSON emailmap=emailmap />
<#else>
"message": "${message}"
</#if>
} }
</#escape> </#escape>

View File

@@ -34,7 +34,7 @@ import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest; import org.springframework.extensions.webscripts.WebScriptRequest;
/** /**
* Implementation for Java backed webscript to return * Implementation for Java backed webscript to return
* custom email field mappings * custom email field mappings
*/ */
public class EmailMapPost extends DeclarativeWebScript public class EmailMapPost extends DeclarativeWebScript
@@ -44,7 +44,7 @@ public class EmailMapPost extends DeclarativeWebScript
/** /**
* Custom email mapping service * Custom email mapping service
* *
* @param customEmailMappingService the custom email mapping service * @param customEmailMappingService the custom email mapping service
*/ */
public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService) public void setCustomEmailMappingService(CustomEmailMappingService customEmailMappingService)
@@ -64,12 +64,11 @@ public class EmailMapPost extends DeclarativeWebScript
// Get the data from the content // Get the data from the content
JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent())); JSONObject json = new JSONObject(new JSONTokener(req.getContent().getContent()));
// Add custom mapping // Add custom mapping
customEmailMappingService.addCustomMapping(json.getString("from"), json.getString("to")); customEmailMappingService.addCustomMapping(json.getString("from"), json.getString("to"));
// Add the lists of custom mappings to the model // Add the lists of custom mappings to the model
model.put("emailmap", customEmailMappingService.getCustomMappings()); model.put("emailmap", customEmailMappingService.getCustomMappings());
model.put("success", true);
} }
catch (IOException iox) catch (IOException iox)
{ {
@@ -83,8 +82,8 @@ public class EmailMapPost extends DeclarativeWebScript
} }
catch (AlfrescoRuntimeException are) catch (AlfrescoRuntimeException are)
{ {
model.put("message", are.getMessage()); throw new WebScriptException(Status.STATUS_INTERNAL_SERVER_ERROR,
model.put("success", false); are.getMessage());
} }
return model; return model;