Merge "Create module for Portal Spring Boot version"
authorManoop Talasila <talasila@research.att.com>
Tue, 13 Aug 2019 18:21:12 +0000 (18:21 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 13 Aug 2019 18:21:12 +0000 (18:21 +0000)
12 files changed:
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/config/NotificationCleanupConfig.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/ExternalRoleDetails.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterfaceIfc.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceImpl.java
ecomp-portal-BE-common/src/main/java/org/onap/portalapp/util/EPUserUtils.java
ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/SchedulerControllerTest.java
ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/OpenIdConnectLoginStrategy.java
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/SimpleLoginStrategy.java
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/LoginController.java

index f18dea9..c32650e 100644 (file)
@@ -40,6 +40,7 @@
  */
 package org.onap.portalapp.config;
 
+import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.annotation.Bean;
@@ -51,23 +52,25 @@ import java.util.TimerTask;
 
 @Configuration
 public class NotificationCleanupConfig implements ApplicationContextAware {
-       
+
        // Once every 10 minutes should be adequate
-       public static final int CLEANUP_PERIOD_MINUTES = 10;
-       
+       private static final int CLEANUP_PERIOD_MINUTES = 10;
+
        private static ApplicationContext applicationContext;
 
-       public void setApplicationContext(ApplicationContext context) {
-               applicationContext = context;
+
+       @Override
+       public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+               NotificationCleanupConfig.applicationContext = applicationContext;
        }
 
-       public static ApplicationContext getApplicationContext() {
+       static ApplicationContext getApplicationContext() {
                return applicationContext;
 
        }
 
        @PostConstruct
-       public void StartSchedular() {
+       public void startSchedular() {
                TimerTask task = new NotificationCleanup();
                Timer timer = new Timer();
                timer.schedule(task, 1000, (long) CLEANUP_PERIOD_MINUTES * 60 * 1000);
@@ -77,5 +80,4 @@ public class NotificationCleanupConfig implements ApplicationContextAware {
        public NotificationCleanupConfig getConfig() {
                return new NotificationCleanupConfig();
        }
-
 }
\ No newline at end of file
index af34176..69f2568 100644 (file)
@@ -41,7 +41,6 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
@@ -49,12 +48,12 @@ import java.util.UUID;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import lombok.NoArgsConstructor;
 import org.json.simple.JSONObject;
 import org.onap.portalapp.controller.EPRestrictedBaseController;
 import org.onap.portalapp.portal.domain.EPUser;
 import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
 import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
-import org.onap.portalapp.portal.exceptions.RoleFunctionException;
 import org.onap.portalapp.portal.logging.aop.EPAuditLog;
 import org.onap.portalapp.portal.logging.logic.EPLogUtil;
 import org.onap.portalapp.portal.scheduler.SchedulerProperties;
@@ -70,7 +69,6 @@ import org.onap.portalapp.portal.service.AdminRolesService;
 import org.onap.portalapp.portal.utils.PortalConstants;
 import org.onap.portalapp.util.EPUserUtils;
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.onap.portalsdk.core.service.DataAccessService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
@@ -87,62 +85,66 @@ import org.springframework.web.bind.annotation.RestController;
 @Configuration
 @EnableAspectJAutoProxy
 @EPAuditLog
+@NoArgsConstructor
 public class SchedulerController extends EPRestrictedBaseController {
+       private static final String USER_IS_UNAUTHORIZED_TO_MAKE_THIS_CALL = "User is unauthorized to make this call";
+
+       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerController.class);
+       private static final DateFormat requestDateFormat = new SimpleDateFormat("EEE, dd MMM YYYY HH:mm:ss z");
 
-       @Autowired
        private SchedulerRestInterface schedulerRestController;
-       
-       @Autowired
        private AdminRolesService adminRolesService;
 
-       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerController.class);
-
-       /** The request date format. */
-       public DateFormat requestDateFormat = new SimpleDateFormat("EEE, dd MMM YYYY HH:mm:ss z");
+       @Autowired
+       public SchedulerController(SchedulerRestInterface schedulerRestController,
+               AdminRolesService adminRolesService) {
+               this.schedulerRestController = schedulerRestController;
+               this.adminRolesService = adminRolesService;
+       }
 
        @RequestMapping(value = "/get_time_slots/{scheduler_request}", method = RequestMethod.GET, produces = "application/json")
        public ResponseEntity<String> getTimeSlots(HttpServletRequest request,
-                       @PathVariable("scheduler_request") String scheduler_request) throws Exception {
+                       @PathVariable("scheduler_request") String schedulerRequest) throws Exception {
                if (checkIfUserISValidToMakeSchedule(request)) {
                        try {
                                Date startingTime = new Date();
                                String startTimeRequest = requestDateFormat.format(startingTime);
                                logger.debug(EELFLoggerDelegate.debugLogger,
                                                "Controller Scheduler GET Timeslots for startTimeRequest: ", startTimeRequest);
-                               logger.debug(EELFLoggerDelegate.debugLogger, "Original Request = {} ", scheduler_request);
+                               logger.debug(EELFLoggerDelegate.debugLogger, "Original Request = {} ", schedulerRequest);
 
                                String path = SchedulerProperties.getProperty(SchedulerProperties.SCHEDULER_GET_TIME_SLOTS)
-                                               + scheduler_request;
+                                               + schedulerRequest;
 
-                               GetTimeSlotsWrapper schedulerResWrapper = getTimeSlots(scheduler_request, path, scheduler_request);
+                               GetTimeSlotsWrapper schedulerResWrapper = getTimeSlots(path, schedulerRequest);
 
                                Date endTime = new Date();
                                String endTimeRequest = requestDateFormat.format(endTime);
                                logger.debug(EELFLoggerDelegate.debugLogger, "Controller Scheduler - GET for EndTimeRequest = {}",
                                                endTimeRequest);
-                               return (new ResponseEntity<String>(schedulerResWrapper.getResponse(),
-                                               HttpStatus.valueOf(schedulerResWrapper.getStatus())));
+                               return (new ResponseEntity<>(schedulerResWrapper.getResponse(),
+                                       HttpStatus.valueOf(schedulerResWrapper.getStatus())));
                        } catch (Exception e) {
                                GetTimeSlotsWrapper schedulerResWrapper = new GetTimeSlotsWrapper();
                                schedulerResWrapper.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
                                schedulerResWrapper.setEntity(e.getMessage());
                                logger.error(EELFLoggerDelegate.errorLogger, "Exception with getTimeslots", e);
-                               return (new ResponseEntity<String>(schedulerResWrapper.getResponse(),
-                                               HttpStatus.INTERNAL_SERVER_ERROR));
+                               return (new ResponseEntity<>(schedulerResWrapper.getResponse(),
+                                       HttpStatus.INTERNAL_SERVER_ERROR));
                        }
                }else{
-                       return (new ResponseEntity<String>("User is unauthorized to make this call", HttpStatus.UNAUTHORIZED));
+                       return (new ResponseEntity<>(USER_IS_UNAUTHORIZED_TO_MAKE_THIS_CALL, HttpStatus.UNAUTHORIZED));
                }
        }
 
-       protected GetTimeSlotsWrapper getTimeSlots(String request, String path, String uuid) throws Exception {
+       protected GetTimeSlotsWrapper getTimeSlots(String path, String uuid) throws Exception {
 
                try {
                        // STARTING REST API CALL AS AN FACTORY INSTACE
                        logger.debug(EELFLoggerDelegate.debugLogger, "Get Time Slots Request START");
 
-                       GetTimeSlotsRestObject<String> restObjStr = new GetTimeSlotsRestObject<String>();
-                       String str = new String();
+                       GetTimeSlotsRestObject<String> restObjStr = new GetTimeSlotsRestObject<>();
+                       String str = "";
 
                        restObjStr.set(str);
 
@@ -169,7 +171,7 @@ public class SchedulerController extends EPRestrictedBaseController {
        @SuppressWarnings("unchecked")
        @RequestMapping(value = "/post_create_new_vnf_change", method = RequestMethod.POST, produces = "application/json")
        public ResponseEntity<String> postCreateNewVNFChange(HttpServletRequest request,
-                       @RequestBody JSONObject scheduler_request) throws Exception {
+                       @RequestBody JSONObject schedulerRequest) throws Exception {
                if (checkIfUserISValidToMakeSchedule(request)) {
                        try {
                                Date startingTime = new Date();
@@ -181,34 +183,34 @@ public class SchedulerController extends EPRestrictedBaseController {
                                // Generating uuid
                                String uuid = UUID.randomUUID().toString();
 
-                               scheduler_request.put("scheduleId", uuid);
+                               schedulerRequest.put("scheduleId", uuid);
                                logger.debug(EELFLoggerDelegate.debugLogger, "UUID = {} ", uuid);
 
                                // adding uuid to the request payload
-                               scheduler_request.put("scheduleId", uuid);
-                               logger.debug(EELFLoggerDelegate.debugLogger, "Original Request = {}", scheduler_request.toString());
+                               schedulerRequest.put("scheduleId", uuid);
+                               logger.debug(EELFLoggerDelegate.debugLogger, "Original Request = {}", schedulerRequest.toString());
 
                                String path = SchedulerProperties
                                                .getProperty(SchedulerProperties.SCHEDULER_CREATE_NEW_VNF_CHANGE_INSTANCE_VAL) + uuid;
 
-                               PostCreateNewVnfWrapper responseWrapper = postSchedulingRequest(scheduler_request, path, uuid);
+                               PostCreateNewVnfWrapper responseWrapper = postSchedulingRequest(schedulerRequest, path, uuid);
 
                                Date endTime = new Date();
                                String endTimeRequest = requestDateFormat.format(endTime);
                                logger.debug(EELFLoggerDelegate.debugLogger, "Controller Scheduler - POST= {}", endTimeRequest);
 
-                               return new ResponseEntity<String>(responseWrapper.getResponse(),
-                                               HttpStatus.valueOf(responseWrapper.getStatus()));
+                               return new ResponseEntity<>(responseWrapper.getResponse(),
+                                       HttpStatus.valueOf(responseWrapper.getStatus()));
                        } catch (Exception e) {
                                PostCreateNewVnfWrapper responseWrapper = new PostCreateNewVnfWrapper();
                                responseWrapper.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
                                responseWrapper.setEntity(e.getMessage());
                                logger.error(EELFLoggerDelegate.errorLogger, "Exception with postCreateNewVNFChange ", e);
-                               return (new ResponseEntity<String>(responseWrapper.getResponse(), HttpStatus.INTERNAL_SERVER_ERROR));
+                               return (new ResponseEntity<>(responseWrapper.getResponse(), HttpStatus.INTERNAL_SERVER_ERROR));
 
                        }
                }else{
-                       return (new ResponseEntity<String>("User is unauthorized to make this call",HttpStatus.UNAUTHORIZED));
+                       return (new ResponseEntity<>(USER_IS_UNAUTHORIZED_TO_MAKE_THIS_CALL, HttpStatus.UNAUTHORIZED));
                }
 
        }
@@ -219,11 +221,11 @@ public class SchedulerController extends EPRestrictedBaseController {
                try {
                        // STARTING REST API CALL AS AN FACTORY INSTACE
 
-                       PostCreateNewVnfRestObject<String> restObjStr = new PostCreateNewVnfRestObject<String>();
-                       String str = new String();
+                       PostCreateNewVnfRestObject<String> restObjStr = new PostCreateNewVnfRestObject<>();
+                       String str = "";
 
                        restObjStr.set(str);
-                       schedulerRestController.<String>Post(str, request, path, restObjStr);
+                       schedulerRestController.Post(str, request, path, restObjStr);
 
                        int status = restObjStr.getStatusCode();
                        if (status >= 200 && status <= 299) {
@@ -249,7 +251,7 @@ public class SchedulerController extends EPRestrictedBaseController {
 
        @RequestMapping(value = "/submit_vnf_change_timeslots", method = RequestMethod.POST, produces = "application/json")
        public ResponseEntity<String> postSubmitVnfChangeTimeslots(HttpServletRequest request,
-                       @RequestBody JSONObject scheduler_request) throws Exception {
+                       @RequestBody JSONObject schedulerRequest) throws Exception {
                if (checkIfUserISValidToMakeSchedule(request)) {
                try {
                        Date startingTime = new Date();
@@ -258,17 +260,17 @@ public class SchedulerController extends EPRestrictedBaseController {
                                        startTimeRequest);
 
                        // Generating uuid
-                       String uuid = (String) scheduler_request.get("scheduleId");
+                       String uuid = (String) schedulerRequest.get("scheduleId");
                        logger.debug(EELFLoggerDelegate.debugLogger, "UUID = {} ", uuid);
 
-                       scheduler_request.remove("scheduleId");
+                       schedulerRequest.remove("scheduleId");
                        logger.debug(EELFLoggerDelegate.debugLogger, "Original Request for the schedulerId= {} ",
-                                       scheduler_request.toString());
+                                       schedulerRequest.toString());
 
                        String path = SchedulerProperties.getProperty(SchedulerProperties.SCHEDULER_SUBMIT_NEW_VNF_CHANGE)
                                        .replace("{scheduleId}", uuid);
 
-                       PostSubmitVnfChangeTimeSlotsWrapper responseWrapper = postSubmitSchedulingRequest(scheduler_request, path,
+                       PostSubmitVnfChangeTimeSlotsWrapper responseWrapper = postSubmitSchedulingRequest(schedulerRequest, path,
                                        uuid);
 
                        Date endTime = new Date();
@@ -276,17 +278,17 @@ public class SchedulerController extends EPRestrictedBaseController {
                        logger.debug(EELFLoggerDelegate.debugLogger, " Controller Scheduler - POST Submit for end time request= {}",
                                        endTimeRequest);
 
-                       return (new ResponseEntity<String>(responseWrapper.getResponse(),HttpStatus.valueOf(responseWrapper.getStatus())));
+                       return (new ResponseEntity<>(responseWrapper.getResponse(), HttpStatus.valueOf(responseWrapper.getStatus())));
                        } catch (Exception e) {
                                PostSubmitVnfChangeTimeSlotsWrapper responseWrapper = new PostSubmitVnfChangeTimeSlotsWrapper();
                                responseWrapper.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
                                responseWrapper.setEntity(e.getMessage());
                                logger.error(EELFLoggerDelegate.errorLogger, "Exception with Post submit Vnf change Timeslots", e);
-                               return (new ResponseEntity<String>(responseWrapper.getResponse(), HttpStatus.INTERNAL_SERVER_ERROR));
+                               return (new ResponseEntity<>(responseWrapper.getResponse(), HttpStatus.INTERNAL_SERVER_ERROR));
 
                        }
                }else{
-                       return (new ResponseEntity<String>("User is unauthorized to make this call",HttpStatus.UNAUTHORIZED));
+                       return (new ResponseEntity<>(USER_IS_UNAUTHORIZED_TO_MAKE_THIS_CALL, HttpStatus.UNAUTHORIZED));
                }
        }
 
@@ -296,11 +298,11 @@ public class SchedulerController extends EPRestrictedBaseController {
                try {
                        // STARTING REST API CALL AS AN FACTORY INSTACE
 
-                       PostSubmitVnfChangeRestObject<String> restObjStr = new PostSubmitVnfChangeRestObject<String>();
-                       String str = new String();
+                       PostSubmitVnfChangeRestObject<String> restObjStr = new PostSubmitVnfChangeRestObject<>();
+                       String str = "";
 
                        restObjStr.set(str);
-                       schedulerRestController.<String>Post(str, request, path, restObjStr);
+                       schedulerRestController.Post(str, request, path, restObjStr);
 
                        int status = restObjStr.getStatusCode();
                        if (status >= 200 && status <= 299) {
@@ -362,19 +364,19 @@ public class SchedulerController extends EPRestrictedBaseController {
                                                throw new Exception(entry.getKey() + errorMsg);
                                }
                                logger.debug(EELFLoggerDelegate.debugLogger, " portalRestResponse - getSchedulerConstant= {}", map);
-                               portalRestResponse = new PortalRestResponse<Map<String, String>>(PortalRestStatusEnum.OK, "success",
-                                               map);
+                               portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.OK, "success",
+                                       map);
 
                        } catch (Exception e) {
                                logger.error(EELFLoggerDelegate.errorLogger, "getSchedulerConstant failed", e);
-                               portalRestResponse = new PortalRestResponse<Map<String, String>>(PortalRestStatusEnum.ERROR,
-                                               e.getMessage(), null);
+                               portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.ERROR,
+                                       e.getMessage(), null);
                        }
 
                }
         else{
                        logger.error(EELFLoggerDelegate.errorLogger, "getSchedulerConstant failed: User unauthorized to make this call");
-               portalRestResponse = new PortalRestResponse<Map<String, String>>(PortalRestStatusEnum.ERROR, "failed : Unauthorized", null);
+                       portalRestResponse = new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "failed : Unauthorized", null);
         }
                                return portalRestResponse;
        }
@@ -397,8 +399,6 @@ public class SchedulerController extends EPRestrictedBaseController {
                EPUser user = EPUserUtils.getUserSession(request);
                String portalApiPath = getPath(request);
                Set<String> functionCodeList = adminRolesService.getAllAppsFunctionsOfUser(user.getId().toString());
-               boolean isValidUser =   EPUserUtils.matchRoleFunctions(portalApiPath, functionCodeList);
-//             boolean isValidUser = functionCodeList.stream().anyMatch(x -> functionCodeList.contains(portalApiPath));
-               return isValidUser;
+               return EPUserUtils.matchRoleFunctions(portalApiPath, functionCodeList);
        }
 }
index e561c8d..bb90278 100644 (file)
 package org.onap.portalapp.portal.domain;
 
 import java.util.List;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
 
+@Getter
+@Setter
+@EqualsAndHashCode
 public class ExternalRoleDetails implements Comparable {
 
-       
        private String  name;
     private boolean active;
     private Integer priority;
-    
     private Long appId;     // used by ONAP only 
     private Long appRoleId; // used by ONAP only
-
        private List<EPAppRoleFunction> perms;
 
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public boolean isActive() {
-               return active;
-       }
-
-       public void setActive(boolean active) {
-               this.active = active;
-       }
-
-       public Integer getPriority() {
-               return priority;
-       }
-
-       public void setPriority(Integer priority) {
-               this.priority = priority;
-       }
-
-       public Long getAppId() {
-               return appId;
-       }
-
-       public void setAppId(Long appId) {
-               this.appId = appId;
-       }
-
-       public Long getAppRoleId() {
-               return appRoleId;
-       }
-
-       public void setAppRoleId(Long appRoleId) {
-               this.appRoleId = appRoleId;
-       }
-
-
-
-       public List<EPAppRoleFunction> getPerms() {
-               return perms;
-       }
-
-       public void setPerms(List<EPAppRoleFunction> perms) {
-               this.perms = perms;
-       }
-
        @Override
        public int compareTo(Object obj) {
                EPRole other = (EPRole)obj;
-
-       String c1 = getName();
-       String c2 = other.getName();
-
-       return (c1 == null || c2 == null) ? 1 : c1.compareTo(c2);
+               return (this.getName() == null || other.getName() == null) ? 1 : getName().equals(other.getName()) ? 0 : 1;
        }
 
-       
+
 }
index 1886b8b..14dfebe 100644 (file)
  */
 package org.onap.portalapp.portal.scheduler;
 
-import java.lang.reflect.Type;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializer;
 import java.util.Collections;
 import java.util.Date;
-
 import javax.security.auth.login.CredentialException;
 import javax.ws.rs.client.Client;
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedHashMap;
 import javax.ws.rs.core.Response;
-
+import lombok.NoArgsConstructor;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang.StringUtils;
-import org.apache.cxf.jaxrs.impl.ResponseImpl;
 import org.eclipse.jetty.util.security.Password;
 import org.json.simple.JSONObject;
 import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum;
@@ -63,45 +63,28 @@ import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.HttpClientErrorException;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-
+@SuppressWarnings("MalformedFormatString")
 @Service
+@NoArgsConstructor
 public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
-
+       private static final String APPLICATION_JSON = "application/json";
        private static final String PASSWORD_IS_EMPTY = "Password is Empty";
+       private static final String HTTP_CLIENT_ERROR = " HttpClientErrorException: Exception For the POST  ." 
+                                                                                                       + " MethodName: %APPLICATION_JSON, Url: %APPLICATION_JSON";
 
+       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerRestInterface.class);
        private static Client client = null;
+       private static Gson gson = null;
 
        private MultivaluedHashMap<String, Object> commonHeaders;
 
-       /** The logger. */
-       static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SchedulerRestInterface.class);
-
-       public SchedulerRestInterface() {
-               super();
-       }
-
-       Gson gson = null;
-
-       private final ObjectMapper mapper = new ObjectMapper();
-
-       private void init() {
+       private static void init() {
                logger.debug(EELFLoggerDelegate.debugLogger, "initializing");
                GsonBuilder builder = new GsonBuilder();
 
                // Register an adapter to manage the date types as long values
-               builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
-                       public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
-                                       throws JsonParseException {
-                               return new Date(json.getAsJsonPrimitive().getAsLong());
-                       }
-               });
+               builder.registerTypeAdapter(Date.class,
+                       (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
 
                gson = builder.create();
        }
@@ -114,7 +97,6 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
                final String username;
                final String password;
 
-               String methodName = "initRestClient";
                /* Setting user name based on properties */
                String retrievedUsername = SchedulerProperties.getProperty(SchedulerProperties.SCHEDULER_USER_NAME_VAL);
                if (retrievedUsername.isEmpty()) {
@@ -145,8 +127,8 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
                byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
                String authStringEnc = new String(authEncBytes);
 
-               commonHeaders = new MultivaluedHashMap<String, Object>();
-               commonHeaders.put("Authorization", Collections.singletonList((Object) ("Basic " + authStringEnc)));
+               commonHeaders = new MultivaluedHashMap<>();
+               commonHeaders.put("Authorization", Collections.singletonList(("Basic " + authStringEnc)));
 
                try {
                        if (!username.isEmpty()) {
@@ -166,7 +148,7 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
 
        @SuppressWarnings("unchecked")
        public <T> void Get(T t, String sourceId, String path,
-                       org.onap.portalapp.portal.scheduler.restobjects.RestObject<T> restObject) throws Exception {
+                       org.onap.portalapp.portal.scheduler.restobjects.RestObject<T> restObject) {
 
                String methodName = "Get";
                String url = SchedulerProperties.getProperty(SchedulerProperties.SCHEDULER_SERVER_URL_VAL) + path;
@@ -175,14 +157,14 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
                try {
                        initRestClient();
 
-                       final Response cres = client.target(url).request().accept("application/json").headers(commonHeaders).get();
+                       final Response cres = client.target(url).request().accept(APPLICATION_JSON).headers(commonHeaders).get();
 
                        int status = cres.getStatus();
                        restObject.setStatusCode(status);
 
-                       if (cres != null && cres.getEntity() != null) {
+                       if (cres.getEntity() != null) {
                                try {
-                                       String str = ((ResponseImpl) cres).readEntity(String.class);
+                                       String str = (cres).readEntity(String.class);
                                        if (t.getClass().getName().equals(String.class.getName())) {
                                                t = (T) str;
 
@@ -195,23 +177,21 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
                                }
                        } else {
                                t = null;
-                               restObject.set(t);
+                               restObject.set(null);
                        }
 
-                       // t = (T) cres.readEntity(t.getClass());
-
-                       if (t.equals("")) {
+                       if ("".equals(t)) {
                                restObject.set(null);
                        } else {
                                restObject.set(t);
                        }
                } catch (HttpClientErrorException e) {
                        String message = String.format(
-                                       " HttpClientErrorException: Exception For the POST  . MethodName: %s, Url: %s", methodName, url);
+                                       HTTP_CLIENT_ERROR, methodName, url);
                        logger.error(EELFLoggerDelegate.errorLogger, message, e);
                        EPLogUtil.schedulerAccessAlarm(logger, e.getStatusCode().value());
                } catch (Exception e) {
-                       String message = String.format("Exception For the POST . MethodName: %s, Url: %s", methodName, url);
+                       String message = String.format("Exception For the POST . MethodName: %APPLICATION_JSON, Url: %APPLICATION_JSON", methodName, url);
 
                        logger.error(EELFLoggerDelegate.errorLogger, message, e);
                        EPLogUtil.schedulerAccessAlarm(logger, HttpStatus.INTERNAL_SERVER_ERROR.value());
@@ -223,7 +203,7 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
        }
 
        @SuppressWarnings("unchecked")
-       public <T> void Post(T t, JSONObject requestDetails, String path, RestObject<T> restObject) throws Exception {
+       public <T> void Post(T t, JSONObject requestDetails, String path, RestObject<T> restObject) {
 
                String methodName = "Post";
                String url = SchedulerProperties.getProperty(SchedulerProperties.SCHEDULER_SERVER_URL_VAL) + path;
@@ -234,13 +214,13 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
                        initRestClient();
 
                        // Change the content length
-                       final Response cres = client.target(url).request().accept("application/json").headers(commonHeaders)
+                       final Response cres = client.target(url).request().accept(APPLICATION_JSON).headers(commonHeaders)
                                        .post(Entity.entity(requestDetails, MediaType.APPLICATION_JSON));
 
                        if (cres != null && cres.getEntity() != null) {
 
                                try {
-                                       String str = ((ResponseImpl) cres).readEntity(String.class);
+                                       String str = (cres).readEntity(String.class);
                                        if (t.getClass().getName().equals(String.class.getName())) {
                                                t = (T) str;
 
@@ -251,14 +231,12 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
                                } catch (Exception e) {
                                        EPLogUtil.logEcompError(logger, EPAppMessagesEnum.BeInvalidJsonInput, e);
                                }
-                               // t = (T) cres.readEntity(t.getClass());
                                restObject.set(t);
                        } else {
-                               t = null;
-                               restObject.set(t);
+                               restObject.set(null);
                        }
 
-                       int status = cres.getStatus();
+                       int status = cres != null ? cres.getStatus() : 0;
                        restObject.setStatusCode(status);
 
                        if (status >= 200 && status <= 299) {
@@ -266,19 +244,19 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
                                logger.debug(EELFLoggerDelegate.debugLogger, message);
 
                        } else {
-                               String message = String.format(" FAILED with http status  . MethodName: %s, Status: %s, Url: %s",
+                               String message = String.format(" FAILED with http status  . MethodName: %APPLICATION_JSON, Status: %APPLICATION_JSON, Url: %APPLICATION_JSON",
                                                methodName, status, url);
                                logger.debug(EELFLoggerDelegate.debugLogger, message);
                        }
 
                } catch (HttpClientErrorException e) {
                        String message = String.format(
-                                       " HttpClientErrorException: Exception For the POST  . MethodName: %s, Url: %s", methodName, url);
+                                       HTTP_CLIENT_ERROR, methodName, url);
                        logger.error(EELFLoggerDelegate.errorLogger, message, e);
                        EPLogUtil.schedulerAccessAlarm(logger, e.getStatusCode().value());
                } catch (Exception e) {
                        String message = String.format(
-                                       " HttpClientErrorException: Exception For the POST  . MethodName: %s, Url: %s", methodName, url);
+                                       HTTP_CLIENT_ERROR, methodName, url);
                        logger.error(EELFLoggerDelegate.errorLogger, message, e);
                        EPLogUtil.schedulerAccessAlarm(logger, HttpStatus.INTERNAL_SERVER_ERROR.value());
                        throw e;
@@ -287,6 +265,7 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
 
        @Override
        public void logRequest(JSONObject requestDetails) {
+               throw new UnsupportedOperationException();
        }
 
        @SuppressWarnings("unchecked")
@@ -294,18 +273,16 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
 
                String methodName = "Delete";
                String url = "";
-               Response cres = null;
+               Response cres;
 
                try {
                        initRestClient();
 
                        url = SchedulerProperties.getProperty(SchedulerProperties.SCHEDULER_SERVER_URL_VAL) + path;
 
-                       cres = client.target(url).request().accept("application/json").headers(commonHeaders)
+                       cres = client.target(url).request().accept(APPLICATION_JSON).headers(commonHeaders)
                                        // .entity(r)
                                        .build("DELETE", Entity.entity(requestDetails, MediaType.APPLICATION_JSON)).invoke();
-                       // .method("DELETE", Entity.entity(r, MediaType.APPLICATION_JSON));
-                       // .delete(Entity.entity(r, MediaType.APPLICATION_JSON));
 
                        int status = cres.getStatus();
                        restObject.setStatusCode(status);
@@ -325,8 +302,4 @@ public class SchedulerRestInterface implements SchedulerRestInterfaceIfc {
                }
        }
 
-       public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException {
-               return clazz.newInstance();
-       }
-
 }
index c49dd1d..8d37a12 100644 (file)
@@ -45,14 +45,14 @@ import org.springframework.stereotype.Service;
 @Service
 public interface SchedulerRestInterfaceIfc {
 
-       public void initRestClient();
+       void initRestClient();
 
-       public <T> void Get(T t, String sourceId, String path, org.onap.portalapp.portal.scheduler.restobjects.RestObject<T> restObject ) throws Exception;
+       <T> void Get(T t, String sourceId, String path, org.onap.portalapp.portal.scheduler.restobjects.RestObject<T> restObject ) throws Exception;
 
-       public <T> void Delete(T t, JSONObject requestDetails, String sourceID, String path, RestObject<T> restObject)
+       <T> void Delete(T t, JSONObject requestDetails, String sourceID, String path, RestObject<T> restObject)
                        throws Exception;
 
-       public <T> void Post(T t, JSONObject r, String path, RestObject<T> restObject) throws Exception;
+       <T> void Post(T t, JSONObject r, String path, RestObject<T> restObject) throws Exception;
 
-       public void logRequest(JSONObject requestDetails);
-}
\ No newline at end of file
+       void logRequest(JSONObject requestDetails);
+}
index 4a3cf63..c088164 100644 (file)
@@ -86,7 +86,7 @@ public class EPRoleFunctionServiceImpl implements EPRoleFunctionService {
                                .getAttribute(SystemProperties.getProperty(SystemProperties.ROLE_FUNCTIONS_ATTRIBUTE_NAME));
 
                if (roleFunctions == null) {
-                       HashMap roles = EPUserUtils.getRoles(request);
+                       HashMap roles = (HashMap) EPUserUtils.getRoles(request);
                        roleFunctions = new HashSet();
 
                        Iterator i = roles.keySet().iterator();
index 99a2911..80db8c8 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START==========================================
  * ONAP Portal
  * ===================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ===================================================================
  *
  * Unless otherwise specified, all software contained herein is licensed
@@ -41,18 +41,16 @@ import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
-
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
-
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.binary.Hex;
 import org.onap.portalapp.portal.domain.EPRole;
@@ -70,18 +68,14 @@ import org.onap.portalsdk.core.web.support.AppUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 
 public class EPUserUtils {
-
-       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUserUtils.class);
-
-       private final static Long ACCOUNT_ADMIN_ROLE_ID = 999L;
-
        public static final String ALL_ROLE_FUNCTIONS = "allRoleFunctions";
-       
-       // These decode values are based on HexDecoder
+
        private static final String decodeValueOfForwardSlash = "2f";
        private static final String decodeValueOfHyphen = "2d";
        private static final String decodeValueOfAsterisk = "2a";
+       private static final Long ACCOUNT_ADMIN_ROLE_ID = 999L;
 
+       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPUserUtils.class);
        private static DataAccessService dataAccessService;
 
        /**
@@ -111,15 +105,13 @@ public class EPUserUtils {
         *            Menu data
         * @param businessDirectMenuData
         *            Menu data
-        * @param loginMethod_ignored
-        *            How the user authenticated; ignored
         * @param ePRoleFunctionService
         *            role function service
         * @throws DecoderException 
         */
        @SuppressWarnings("rawtypes")
        public static void setUserSession(HttpServletRequest request, EPUser user, Set applicationMenuData,
-                       Set businessDirectMenuData, String loginMethod_ignored, EPRoleFunctionService ePRoleFunctionService) throws RoleFunctionException {
+                       Set businessDirectMenuData, EPRoleFunctionService ePRoleFunctionService) throws RoleFunctionException {
                HttpSession session = request.getSession(true);
 
                // clear the current user session to avoid any conflicts
@@ -136,9 +128,8 @@ public class EPUserUtils {
                session.setAttribute(SystemProperties.getProperty(SystemProperties.USER_NAME), user.getFullName());
 
                ServletContext context = session.getServletContext();
-               int licenseVerificationFlag = 3;
                try {
-                       licenseVerificationFlag = (Integer) context.getAttribute("licenseVerification");
+                       context.getAttribute("licenseVerification");
                } catch (Exception e) {
                        logger.error(EELFLoggerDelegate.errorLogger, "setUserSession failed to get licenseVerification attribute",
                                        e);
@@ -163,7 +154,7 @@ public class EPUserUtils {
        private static void setAllRoleFunctions(List<RoleFunction> allRoleFunctions, HttpSession session) throws RoleFunctionException {
                if (allRoleFunctions == null)
                        return;
-               Set<String> roleFnSet = new HashSet<String>();
+               Set<String> roleFnSet = new HashSet<>();
                for (RoleFunction roleFn : allRoleFunctions){
                        roleFnSet.add(decodeFunctionCode(roleFn.getCode()));
                }
@@ -221,8 +212,8 @@ public class EPUserUtils {
         * @return Map of role ID to role object
         */
        @SuppressWarnings("rawtypes")
-       public static HashMap getRoles(HttpServletRequest request) {
-               HashMap roles = null;
+       public static Map getRoles(HttpServletRequest request) {
+               HashMap roles;
 
                HttpSession session = AppUtils.getSession(request);
                roles = (HashMap) session.getAttribute(SystemProperties.getProperty(SystemProperties.ROLES_ATTRIBUTE_NAME));
@@ -251,11 +242,8 @@ public class EPUserUtils {
        @SuppressWarnings({ "rawtypes", "unchecked" })
        private static HashMap getAllUserRoles(EPUser user) {
                HashMap roles = new HashMap();
-               Iterator i = user.getEPRoles().iterator();
-
-               while (i.hasNext()) {
-                       EPRole role = (EPRole) i.next();
 
+               for (EPRole role : user.getEPRoles()) {
                        if (role.getActive()) {
                                roles.put(role.getId(), role);
 
@@ -267,9 +255,8 @@ public class EPUserUtils {
 
                // Additionally; the account admin role is overloaded between onap
                // portal and partners; lets also include that
-               Iterator<EPUserApp> appRolesIterator = user.getEPUserApps().iterator();
-               while (appRolesIterator.hasNext()) {
-                       EPRole role = (EPRole) appRolesIterator.next().getRole();
+               for (EPUserApp epUserApp : user.getEPUserApps()) {
+                       EPRole role = epUserApp.getRole();
 
                        if (role.getActive() && role.getId().equals(ACCOUNT_ADMIN_ROLE_ID)) {
                                roles.put(role.getId(), role);
@@ -295,10 +282,9 @@ public class EPUserUtils {
        private static void addChildRoles(EPRole role, HashMap roles) {
                Set childRoles = role.getChildRoles();
 
-               if (childRoles != null && childRoles.size() > 0) {
-                       Iterator j = childRoles.iterator();
-                       while (j.hasNext()) {
-                               EPRole childRole = (EPRole) j.next();
+               if (childRoles != null && !childRoles.isEmpty()) {
+                       for (Object o : childRoles) {
+                               EPRole childRole = (EPRole) o;
 
                                if (childRole.getActive()) {
                                        roles.put(childRole.getId(), childRole);
@@ -319,7 +305,7 @@ public class EPUserUtils {
        }
 
        @Autowired
-       public void setDataAccessService(DataAccessService dataAccessService) {
+       public static void setDataAccessService(DataAccessService dataAccessService) {
                EPUserUtils.dataAccessService = dataAccessService;
        }
 
@@ -341,12 +327,10 @@ public class EPUserUtils {
         *            HttpServletREquest
         * @return Long ID of current user
         */
-       public static Long getUserIdAsLong(HttpServletRequest request) {
+       static Long getUserIdAsLong(HttpServletRequest request) {
                Long userId = new Long(SystemProperties.getProperty(SystemProperties.APPLICATION_USER_ID));
-               if (request != null) {
-                       if (getUserSession(request) != null) {
+               if (request != null && getUserSession(request) != null) {
                                userId = getUserSession(request).getId();
-                       }
                }
                return userId;
        }
@@ -364,7 +348,7 @@ public class EPUserUtils {
                String requestId = "";
                try {
                        while (headerNames.hasMoreElements()) {
-                               String headerName = (String) headerNames.nextElement();
+                               String headerName = headerNames.nextElement();
                                logger.debug(EELFLoggerDelegate.debugLogger,
                                                "One header is " + headerName + " : " + request.getHeader(headerName));
                                if (headerName.equalsIgnoreCase(SystemProperties.ECOMP_REQUEST_ID)) {
@@ -386,7 +370,7 @@ public class EPUserUtils {
         *            HttpServletRequest
         * @return Full URL
         */
-       public static String getFullURL(HttpServletRequest request) {
+       static String getFullURL(HttpServletRequest request) {
                if (request != null) {
                        StringBuffer requestURL = request.getRequestURL();
                        String queryString = request.getQueryString();
@@ -402,7 +386,7 @@ public class EPUserUtils {
 
        public static Boolean matchRoleFunctions(String portalApiPath, Set<? extends String> roleFunctions) {
                String[] path = portalApiPath.split("/");
-               List<String> roleFunList = new ArrayList<>();
+               List<String> roleFunList;
                if (path.length > 1) {
                        roleFunList = roleFunctions.stream().filter(item -> item.startsWith(path[0])).collect(Collectors.toList());
                        if (roleFunList.size() >= 1) {
@@ -411,17 +395,13 @@ public class EPUserUtils {
                                        boolean b = true;
                                        if (roleFunctionArray.length == path.length) {
                                                for (int i = 0; i < roleFunctionArray.length; i++) {
-                                                       if (b) {
                                                                if (!roleFunctionArray[i].equals("*")) {
                                                                        Pattern p = Pattern.compile(Pattern.quote(path[i]), Pattern.CASE_INSENSITIVE);
                                                                        Matcher m = p.matcher(roleFunctionArray[i]);
                                                                        b = m.matches();
-
                                                                }
                                                        }
-                                               }
-                                                       if (b)
-                                                               return b;
+                                               if (b) return true;
                                        }
                                }
                        }
index b1816ec..5d32301 100644 (file)
@@ -48,7 +48,6 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.poi.ss.formula.functions.T;
 import org.json.simple.JSONObject;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
@@ -56,7 +55,6 @@ import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
-import org.onap.portalapp.portal.controller.SchedulerController;
 import org.onap.portalapp.portal.core.MockEPUser;
 import org.onap.portalapp.portal.domain.EPUser;
 import org.onap.portalapp.portal.framework.MockitoTestSuite;
@@ -84,7 +82,7 @@ public class SchedulerControllerTest {
        AdminRolesService adminRolesService;
 
        @InjectMocks
-       SchedulerController schedulerController = new SchedulerController();
+       SchedulerController schedulerController;
 
        @Before
        public void setup() {
index 7383330..80ca142 100644 (file)
@@ -256,7 +256,7 @@ public class EPUserUtilsTest {
                PowerMockito.when(AppUtils.getSession(mockedRequest)).thenReturn(session);
                PowerMockito.when(SystemProperties.getProperty(Matchers.anyString())).thenReturn("12");
                Mockito.when(session.getAttribute(Matchers.anyString())).thenReturn(roles);
-               roles=EPUserUtils.getRoles(mockedRequest);
+               roles= (HashMap) EPUserUtils.getRoles(mockedRequest);
                assertEquals(roles,expected);
 
 
@@ -279,7 +279,7 @@ public class EPUserUtilsTest {
                Mockito.when(session.getAttribute("attr_name")).thenReturn(user);
                Mockito.when(user.getEPRoles()).thenReturn(role);
                Mockito.when(session.getAttribute("12")).thenReturn(null);
-               roles=EPUserUtils.getRoles(mockedRequest);
+               roles= (HashMap) EPUserUtils.getRoles(mockedRequest);
                assertEquals(roles,expected);
 
        }
@@ -320,7 +320,7 @@ public class EPUserUtilsTest {
                Mockito.when(epRole.getChildRoles()).thenReturn(childRoles);
                Mockito.when(user.getEPUserApps()).thenReturn(epUserApps);
                Mockito.when(session.getAttribute("12")).thenReturn(null);
-               roles=  EPUserUtils.getRoles(mockedRequest);
+               roles= (HashMap) EPUserUtils.getRoles(mockedRequest);
                assertNotNull(roles);
        }
        
@@ -358,7 +358,7 @@ public class EPUserUtilsTest {
                Mockito.when(epRoleFunctionService.getRoleFunctions()).thenReturn(roleFunctions);
                Mockito.when(MenuBuilder.filterMenu(applicationMenuData, mockedRequest)).thenReturn(applicationMenuData);
                PowerMockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("12");
-        EPUserUtils.setUserSession(mockedRequest, user, applicationMenuData, businessDirectMenuData, "login_method", epRoleFunctionService);
+        EPUserUtils.setUserSession(mockedRequest, user, applicationMenuData, businessDirectMenuData,  epRoleFunctionService);
         assertNotNull(session);
 
 
@@ -383,7 +383,7 @@ public class EPUserUtilsTest {
                Mockito.when(epRoleFunctionService.getRoleFunctions()).thenReturn(null);
                Mockito.when(MenuBuilder.filterMenu(applicationMenuData, mockedRequest)).thenReturn(applicationMenuData);
                PowerMockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("12");
-        EPUserUtils.setUserSession(mockedRequest, user, applicationMenuData, businessDirectMenuData, "login_method", epRoleFunctionService);
+        EPUserUtils.setUserSession(mockedRequest, user, applicationMenuData, businessDirectMenuData,  epRoleFunctionService);
         assertNotNull(session);
        }
        
@@ -408,7 +408,7 @@ public class EPUserUtilsTest {
                Mockito.when(epRoleFunctionService.getRoleFunctions()).thenReturn(null);
                Mockito.when(MenuBuilder.filterMenu(applicationMenuData, mockedRequest)).thenReturn(applicationMenuData);
                PowerMockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("12");
-        EPUserUtils.setUserSession(mockedRequest, user, applicationMenuData, businessDirectMenuData, "login_method", epRoleFunctionService);
+        EPUserUtils.setUserSession(mockedRequest, user, applicationMenuData, businessDirectMenuData, epRoleFunctionService);
         assertNotNull(session);
 
 
index 456f001..f4b8445 100644 (file)
@@ -78,7 +78,7 @@ public class OpenIdConnectLoginStrategy extends org.onap.portalsdk.core.auth.Log
                        user.setLastName(userInfo.getFamilyName());
                        
                        //store the currently logged in user's information in the session
-                       EPUserUtils.setUserSession(request, user,  new HashSet(), new HashSet(), SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM),null);
+                       EPUserUtils.setUserSession(request, user,  new HashSet(), new HashSet(),null);
 
                        logger.info(EELFLoggerDelegate.errorLogger, request.getContextPath());
                        SessionCookieUtil.preSetUp(request, response);  
index a5f8790..79ae20f 100644 (file)
@@ -85,7 +85,7 @@ public class SimpleLoginStrategy extends org.onap.portalsdk.core.auth.LoginStrat
                         // in case authentication has passed but user is not in the ONAP data base, return a Guest User to the home page.
                        if (commandBean.getUser() != null) {
                                // store the currently logged in user's information in the session
-                               EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), commandBean.getBusinessDirectMenu(), "", ePRoleFunctionService);
+                               EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(), commandBean.getBusinessDirectMenu(), ePRoleFunctionService);
                                logger.info(EELFLoggerDelegate.debugLogger, commandBean.getUser().getOrgUserId() + " exists in the the system.");
                        }
                        
index 56064b9..3b0281f 100644 (file)
@@ -149,8 +149,7 @@ public class LoginController extends EPUnRestrictedBaseController implements Log
                } else {
                        // store the currently logged in user's information in the session
                        EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(),
-                                       commandBean.getBusinessDirectMenu(),
-                                       SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM), ePRoleFunctionService);
+                                       commandBean.getBusinessDirectMenu(), ePRoleFunctionService);
 
                        try {
                                logger.info(EELFLoggerDelegate.debugLogger, "loginValidate: store user info into share context begins");
@@ -265,8 +264,7 @@ public class LoginController extends EPUnRestrictedBaseController implements Log
                                                orgUserId);
 
                                EPUserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(),
-                                               commandBean.getBusinessDirectMenu(),
-                                               SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM), ePRoleFunctionService);
+                                               commandBean.getBusinessDirectMenu(), ePRoleFunctionService);
                                logger.info(EELFLoggerDelegate.debugLogger,
                                                "processSingleSignOn: now set up user session for {} finished", orgUserId);