summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-portal-BE-common/src')
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppContactUsController.java9
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BEPropertyReaderController.java9
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java53
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java37
4 files changed, 63 insertions, 45 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppContactUsController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppContactUsController.java
index b5876af8..8f456fde 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppContactUsController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/AppContactUsController.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
package org.onap.portalapp.portal.controller;
@@ -110,6 +110,7 @@ public class AppContactUsController extends EPRestrictedBaseController {
portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.OK, SUCCESS,
contactUsPortalResponse);
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getPortalDetails failed", e);
return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, FAILURE, e.getMessage());
}
return portalRestResponse;
@@ -162,7 +163,7 @@ public class AppContactUsController extends EPRestrictedBaseController {
/**
* Answers a list of objects with category-application-function details. Not
* all applications participate in the functional menu.
- *
+ *
* @param request HttpServletRequest
* @return PortalRestResponse<List<AppCategoryFunctionsItem>>
*/
@@ -185,7 +186,7 @@ public class AppContactUsController extends EPRestrictedBaseController {
/**
* Accepts a new application's contact us details.
- *
+ *
* @param contactUs AppContactUsItem
* @return PortalRestResponse<String>
*/
@@ -232,7 +233,7 @@ public class AppContactUsController extends EPRestrictedBaseController {
/**
* Deletes the specified application's contact-us details entry from the
* table.
- *
+ *
* @param id app ID
* @return PortalRestResponse<String>
*/
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BEPropertyReaderController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BEPropertyReaderController.java
index ad12bab0..51b1d484 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BEPropertyReaderController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BEPropertyReaderController.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
package org.onap.portalapp.portal.controller;
@@ -47,17 +47,22 @@ import org.onap.portalapp.portal.domain.BEProperty;
import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
import org.onap.portalsdk.core.controller.FusionBaseController;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
@RestController
@RequestMapping("/portalApi/properties")
public class BEPropertyReaderController extends FusionBaseController{
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(BEPropertyReaderController.class);
+
@RequestMapping(value = "/readProperty", method = RequestMethod.GET, produces = "application/json")
public PortalRestResponse<BEProperty> readProperty(HttpServletRequest request, @RequestParam String key) {
try {
return new PortalRestResponse<>(PortalRestStatusEnum.OK, "success", new BEProperty(key, SystemProperties.getProperty(key)));
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "readProperty failed", e);
return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, e.toString(), null);
- }
+ }
}
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java
index 0be5e7dc..9024570c 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/BasicAuthAccountController.java
@@ -33,7 +33,7 @@
*
* ============LICENSE_END============================================
*
- *
+ *
*/
package org.onap.portalapp.portal.controller;
@@ -53,6 +53,7 @@ import org.onap.portalapp.portal.logging.aop.EPAuditLog;
import org.onap.portalapp.portal.service.AdminRolesService;
import org.onap.portalapp.portal.service.BasicAuthAccountService;
import org.onap.portalapp.util.EPUserUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.bind.annotation.PathVariable;
@@ -67,6 +68,13 @@ import org.springframework.web.bind.annotation.RestController;
@EPAuditLog
public class BasicAuthAccountController extends EPRestrictedBaseController {
+ private static final String FAILURE = "FAILURE";
+ private static final String SUCCESS = "SUCCESS";
+ private static final String AUTHORIZATION_REQUIRED = "Authorization Required";
+ private static final String ADMIN_ONLY_OPERATIONS = "Admin Only Operation! ";
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(BasicAuthAccountController.class);
+
@Autowired
private BasicAuthAccountService basicAuthAccountService;
@@ -75,7 +83,7 @@ public class BasicAuthAccountController extends EPRestrictedBaseController {
/**
* Saves Basic Authentication account for external systems
- *
+ *
* @param request
* HttpServletRequest
* @param response
@@ -92,12 +100,12 @@ public class BasicAuthAccountController extends EPRestrictedBaseController {
EPUser user = EPUserUtils.getUserSession(request);
if (!adminRolesService.isSuperAdmin(user)) {
- return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Authorization Required",
- "Admin Only Operation! ");
+ return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, AUTHORIZATION_REQUIRED,
+ ADMIN_ONLY_OPERATIONS);
}
if (newBasicAuthAccount == null) {
- return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "FAILURE",
+ return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, FAILURE,
"newBasicAuthAccount cannot be null or empty");
}
long accountId = basicAuthAccountService.saveBasicAuthAccount(newBasicAuthAccount);
@@ -111,15 +119,16 @@ public class BasicAuthAccountController extends EPRestrictedBaseController {
basicAuthAccountService.saveEndpointAccount(accountId, endpointId);
}
} catch (Exception e) {
- return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, "createBasicAuthAccount failed", e);
+ return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, FAILURE, e.getMessage());
}
- return new PortalRestResponse<String>(PortalRestStatusEnum.OK, "SUCCESS", "");
+ return new PortalRestResponse<>(PortalRestStatusEnum.OK, SUCCESS, "");
}
/**
* Returns list of all BasicAuthCredentials in the system
- *
+ *
* @param request
* HttpServletRequest
* @param response
@@ -135,17 +144,17 @@ public class BasicAuthAccountController extends EPRestrictedBaseController {
EPUser user = EPUserUtils.getUserSession(request);
if (!adminRolesService.isSuperAdmin(user)) {
- return new PortalRestResponse<List<BasicAuthCredentials>>(PortalRestStatusEnum.ERROR,
+ return new PortalRestResponse<>(PortalRestStatusEnum.ERROR,
"UnAuthorized! Admin Only Operation", new ArrayList<>());
}
- return new PortalRestResponse<List<BasicAuthCredentials>>(PortalRestStatusEnum.OK, "Success",
+ return new PortalRestResponse<>(PortalRestStatusEnum.OK, "Success",
basicAuthAccountService.getAccountData());
}
/**
* Updates an existing BasicAuthCredentials account
- *
+ *
* @param request
* HttpServletRequest
* @param response
@@ -165,25 +174,26 @@ public class BasicAuthAccountController extends EPRestrictedBaseController {
EPUser user = EPUserUtils.getUserSession(request);
if (!adminRolesService.isSuperAdmin(user)) {
- return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Authorization Required",
- "Admin Only Operation! ");
+ return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, AUTHORIZATION_REQUIRED,
+ ADMIN_ONLY_OPERATIONS);
}
if (newBasicAuthAccount == null) {
- return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "FAILURE",
+ return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, FAILURE,
"BasicAuthCredentials cannot be null or empty");
}
try {
basicAuthAccountService.updateBasicAuthAccount(accountId, newBasicAuthAccount);
} catch (Exception e) {
- return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, "updateAccount failed", e);
+ return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, FAILURE, e.getMessage());
}
- return new PortalRestResponse<String>(PortalRestStatusEnum.OK, "SUCCESS", "");
+ return new PortalRestResponse<>(PortalRestStatusEnum.OK, SUCCESS, "");
}
/**
* deletes an existing BasicAuthCredentials account
- *
+ *
* @param request
* HttpServletRequest
* @param response
@@ -200,16 +210,17 @@ public class BasicAuthAccountController extends EPRestrictedBaseController {
EPUser user = EPUserUtils.getUserSession(request);
if (!adminRolesService.isSuperAdmin(user)) {
- return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Authorization Required",
- "Admin Only Operation! ");
+ return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, AUTHORIZATION_REQUIRED,
+ ADMIN_ONLY_OPERATIONS);
}
try {
basicAuthAccountService.deleteEndpointAccout(accountId);
} catch (Exception e) {
- return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "FAILURE", e.getMessage());
+ logger.error(EELFLoggerDelegate.errorLogger, "deleteAccount failed", e);
+ return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, FAILURE, e.getMessage());
}
- return new PortalRestResponse<String>(PortalRestStatusEnum.OK, "SUCCESS", "");
+ return new PortalRestResponse<>(PortalRestStatusEnum.OK, SUCCESS, "");
}
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java
index 17b5a127..56a4df3d 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/TicketEventController.java
@@ -85,6 +85,11 @@ import io.swagger.annotations.ApiOperation;
@EnableAspectJAutoProxy
@EPAuditLog
public class TicketEventController implements BasicAuthenticationController {
+
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(TicketEventController.class);
+
+ private static final String EVENT_DATE = "eventDate";
+ private final ObjectMapper objectMapper = new ObjectMapper();
private static final ValidatorFactory VALIDATOR_FACTORY = Validation.buildDefaultValidatorFactory();
@Autowired
@@ -93,15 +98,10 @@ public class TicketEventController implements BasicAuthenticationController {
@Autowired
private TicketEventService ticketEventService;
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(TicketEventController.class);
-
public boolean isAuxRESTfulCall() {
return true;
}
- private final ObjectMapper mapper = new ObjectMapper();
- private static final String EVENT_DATE = "eventDate";
-
@ApiOperation(
value = "Accepts messages from external ticketing systems and creates notifications for Portal users.",
response = PortalRestResponse.class)
@@ -125,7 +125,7 @@ public class TicketEventController implements BasicAuthenticationController {
}
try {
- JsonNode ticketEventNotif = mapper.readTree(ticketEventJson);
+ JsonNode ticketEventNotif = objectMapper.readTree(ticketEventJson);
// Reject request if required fields are missing.
String error = validateTicketEventMessage(ticketEventNotif);
@@ -173,9 +173,9 @@ public class TicketEventController implements BasicAuthenticationController {
epItem.setPriority(severity);
epItem.setCreatorId(null);
Set<EpRoleNotificationItem> roles = new HashSet<>();
- JsonNode SubscriberInfo = ticketEventNotif.get("SubscriberInfo");
- JsonNode userList = SubscriberInfo.get("UserList");
- String UserIds[] = userList.toString().replace("[", "").replace("]", "").trim().replace("\"", "")
+ JsonNode subscriberInfo = ticketEventNotif.get("SubscriberInfo");
+ JsonNode userList = subscriberInfo.get("UserList");
+ String userIds[] = userList.toString().replace("[", "").replace("]", "").trim().replace("\"", "")
.split(",");
String assetID = eventSource + ' '
+ userList.toString().replace("[", "").replace("]", "").trim().replace("\"", "") + ' '
@@ -184,8 +184,8 @@ public class TicketEventController implements BasicAuthenticationController {
assetID = body.get("assetID").asText();
}
epItem.setMsgHeader(assetID);
- List<EPUser> users = userNotificationService.getUsersByOrgIds(Arrays.asList(UserIds));
- for (String userId : UserIds) {
+ List<EPUser> users = userNotificationService.getUsersByOrgIds(Arrays.asList(userIds));
+ for (String userId : userIds) {
EpRoleNotificationItem roleNotifItem = new EpRoleNotificationItem();
for (EPUser user : users) {
if (user.getOrgUserId().equals(userId)) {
@@ -203,6 +203,7 @@ public class TicketEventController implements BasicAuthenticationController {
portalResponse.setMessage("processEventNotification: notification created");
portalResponse.setResponse("NotificationId is :" + epItem.notificationId);
} catch (Exception ex) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Expection in handleRequest", ex);
portalResponse.setStatus(PortalRestStatusEnum.ERROR);
response.setStatus(400);
portalResponse.setMessage(ex.toString());
@@ -222,15 +223,15 @@ public class TicketEventController implements BasicAuthenticationController {
JsonNode header = event.get("header");
JsonNode eventSource = header.get("eventSource");
JsonNode body = event.get("body");
- JsonNode SubscriberInfo = ticketEventNotif.get("SubscriberInfo");
- JsonNode userList = SubscriberInfo.get("UserList");
+ JsonNode subscriberInfo = ticketEventNotif.get("SubscriberInfo");
+ JsonNode userList = subscriberInfo.get("UserList");
- if (application == null || application.asText().length() == 0 || application.asText().equalsIgnoreCase("null"))
+ if (application == null || application.asText().length() == 0 || "null".equalsIgnoreCase(application.asText()))
return "Application is mandatory";
if (body == null)
return "body is mandatory";
if (eventSource == null || eventSource.asText().trim().length() == 0
- || eventSource.asText().equalsIgnoreCase("null"))
+ || "null".equalsIgnoreCase(eventSource.asText()))
return "Message Source is mandatory";
if (userList == null)
return "At least one user Id is mandatory";
@@ -238,10 +239,10 @@ public class TicketEventController implements BasicAuthenticationController {
if (eventDate != null && eventDate.asText().length() == 8)
return "EventDate is invalid";
- String UserIds[] = userList.toString().replace("[", "").replace("]", "").trim().replace("\"", "")
+ String[] userIds = userList.toString().replace("[", "").replace("]", "").trim().replace("\"", "")
.split(",");
- List<EPUser> users = userNotificationService.getUsersByOrgIds(Arrays.asList(UserIds));
- if (users == null || users.size() == 0)
+ List<EPUser> users = userNotificationService.getUsersByOrgIds(Arrays.asList(userIds));
+ if (users == null || users.isEmpty())
return "Invalid Org User ID";
return null;
}