summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-common/src/main')
-rw-r--r--ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java
index ba90f46f..600deeb3 100644
--- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java
+++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/BroadcastController.java
@@ -37,7 +37,9 @@
*/
package org.onap.portalapp.controller.sample;
+import java.io.IOException;
import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
@@ -67,6 +69,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class BroadcastController extends RestrictedBaseController {
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(BroadcastController.class);
+
+ private static final String BROADCAST_MESSAGE = "broadcastMessage";
+ private static final String BROADCAST_SITIES = "broadcastSites";
+ private static final String UTF8 = "UTF-8";
@Autowired
private BroadcastService broadcastService;
@@ -77,8 +83,8 @@ public class BroadcastController extends RestrictedBaseController {
ObjectMapper mapper = new ObjectMapper();
try {
- model.put("broadcastMessage", mapper.writeValueAsString(broadcastService.getBroadcastMessage(request)));
- model.put("broadcastSites", mapper.writeValueAsString(referenceData(request).get("broadcastSites")));
+ model.put(BROADCAST_MESSAGE, mapper.writeValueAsString(broadcastService.getBroadcastMessage(request)));
+ model.put(BROADCAST_SITIES, mapper.writeValueAsString(referenceData(request).get(BROADCAST_SITIES)));
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "broadcast() failed", e);
}
@@ -92,8 +98,8 @@ public class BroadcastController extends RestrictedBaseController {
try {
- model.put("broadcastMessage", mapper.writeValueAsString(broadcastService.getBroadcastMessage(request)));
- model.put("broadcastSites", mapper.writeValueAsString(referenceData(request).get("broadcastSites")));
+ model.put(BROADCAST_MESSAGE, mapper.writeValueAsString(broadcastService.getBroadcastMessage(request)));
+ model.put(BROADCAST_SITIES, mapper.writeValueAsString(referenceData(request).get(BROADCAST_SITIES)));
JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
JSONObject j = new JSONObject(msg);
response.getWriter().write(j.toString());
@@ -109,7 +115,7 @@ public class BroadcastController extends RestrictedBaseController {
Map lookupData = new HashMap();
if ("true".equals(SystemProperties.getProperty(SystemProperties.CLUSTERED))) {
- lookupData.put("broadcastSites", AppUtils.getLookupList("fn_lu_broadcast_site", "broadcast_site_cd",
+ lookupData.put(BROADCAST_SITIES, AppUtils.getLookupList("fn_lu_broadcast_site", "broadcast_site_cd",
"broadcast_site_descr", "", "broadcast_site_descr"));
}
@@ -117,21 +123,21 @@ public class BroadcastController extends RestrictedBaseController {
}
@RequestMapping(value = { "/broadcast/save" }, method = RequestMethod.POST)
- public ModelAndView save(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ModelAndView save(HttpServletRequest request, HttpServletResponse response) throws IOException {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
- BroadcastMessage broadcastMessage = mapper.readValue(root.get("broadcastMessage").toString(),
+ BroadcastMessage broadcastMessage = mapper.readValue(root.get(BROADCAST_MESSAGE).toString(),
BroadcastMessage.class);
broadcastService.saveBroadcastMessage(broadcastMessage);
- response.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
String responseString = mapper.writeValueAsString(broadcastMessage);
@@ -141,8 +147,8 @@ public class BroadcastController extends RestrictedBaseController {
return null;
} catch (Exception e) {
- response.setCharacterEncoding("UTF-8");
- request.setCharacterEncoding("UTF-8");
+ response.setCharacterEncoding(UTF8);
+ request.setCharacterEncoding(UTF8);
PrintWriter out = response.getWriter();
out.write("An error occurred while saving the BroadcastMessage in the save () mapping-/broadcast/save ");
logger.error(EELFLoggerDelegate.errorLogger, "save() failed", e);