diff options
22 files changed, 879 insertions, 247 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/config/NotificationCleanupConfig.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/config/NotificationCleanupConfig.java index f18dea93..c32650e2 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/config/NotificationCleanupConfig.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/config/NotificationCleanupConfig.java @@ -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 diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java index af34176c..69f25683 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/SchedulerController.java @@ -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); } } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/ExternalRoleDetails.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/ExternalRoleDetails.java index e561c8d3..bb902786 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/ExternalRoleDetails.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/domain/ExternalRoleDetails.java @@ -38,78 +38,27 @@ 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; } - + } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java index 1886b8b5..14dfebee 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java @@ -37,20 +37,20 @@ */ 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(); - } - } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterfaceIfc.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterfaceIfc.java index c49dd1d1..8d37a125 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterfaceIfc.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterfaceIfc.java @@ -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); +} diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceImpl.java index 4a3cf63c..c0881640 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleFunctionServiceImpl.java @@ -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(); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/util/EPUserUtils.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/util/EPUserUtils.java index 99a29116..80db8c86 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/util/EPUserUtils.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/util/EPUserUtils.java @@ -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; } } } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/SchedulerControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/SchedulerControllerTest.java index b1816ec6..5d323012 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/SchedulerControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/SchedulerControllerTest.java @@ -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() { diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java index 7383330d..80ca1424 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java @@ -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); diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/OpenIdConnectLoginStrategy.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/OpenIdConnectLoginStrategy.java index 456f0011..f4b8445d 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/OpenIdConnectLoginStrategy.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/OpenIdConnectLoginStrategy.java @@ -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); diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/SimpleLoginStrategy.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/SimpleLoginStrategy.java index a5f87908..79ae20fa 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/SimpleLoginStrategy.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/authentication/SimpleLoginStrategy.java @@ -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."); } diff --git a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/LoginController.java b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/LoginController.java index 56064b99..3b0281fb 100644 --- a/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/LoginController.java +++ b/ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/LoginController.java @@ -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); diff --git a/portal-BE/.gitignore b/portal-BE/.gitignore new file mode 100644 index 00000000..a2a3040a --- /dev/null +++ b/portal-BE/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/portal-BE/.mvn/wrapper/MavenWrapperDownloader.java b/portal-BE/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 00000000..72308aa4 --- /dev/null +++ b/portal-BE/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/portal-BE/.mvn/wrapper/maven-wrapper.jar b/portal-BE/.mvn/wrapper/maven-wrapper.jar Binary files differnew file mode 100644 index 00000000..01e67997 --- /dev/null +++ b/portal-BE/.mvn/wrapper/maven-wrapper.jar diff --git a/portal-BE/.mvn/wrapper/maven-wrapper.properties b/portal-BE/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..cd0d451c --- /dev/null +++ b/portal-BE/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip diff --git a/portal-BE/mvnw b/portal-BE/mvnw new file mode 100755 index 00000000..8b9da3b8 --- /dev/null +++ b/portal-BE/mvnw @@ -0,0 +1,286 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/portal-BE/mvnw.cmd b/portal-BE/mvnw.cmd new file mode 100644 index 00000000..fef5a8f7 --- /dev/null +++ b/portal-BE/mvnw.cmd @@ -0,0 +1,161 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/portal-BE/pom.xml b/portal-BE/pom.xml new file mode 100644 index 00000000..43d0cae5 --- /dev/null +++ b/portal-BE/pom.xml @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.2.0.M4</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + <groupId>org.onap</groupId> + <artifactId>portal</artifactId> + <version>0.0.1-SNAPSHOT</version> + <name>portal</name> + <description></description> + + <properties> + <java.version>1.8</java.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-security</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-thymeleaf</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.session</groupId> + <artifactId>spring-session-core</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-aop</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-devtools</artifactId> + <scope>runtime</scope> + <optional>true</optional> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + </exclusion> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework.security</groupId> + <artifactId>spring-security-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> + + <repositories> + <repository> + <id>spring-milestones</id> + <name>Spring Milestones</name> + <url>https://repo.spring.io/milestone</url> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>spring-milestones</id> + <name>Spring Milestones</name> + <url>https://repo.spring.io/milestone</url> + </pluginRepository> + </pluginRepositories> + +</project> diff --git a/portal-BE/src/main/java/org/onap/portal/PortalApplication.java b/portal-BE/src/main/java/org/onap/portal/PortalApplication.java new file mode 100644 index 00000000..4a7f4f85 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/PortalApplication.java @@ -0,0 +1,13 @@ +package org.onap.portal; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class PortalApplication { + + public static void main(String[] args) { + SpringApplication.run(PortalApplication.class, args); + } + +} diff --git a/portal-BE/src/main/resources/application.properties b/portal-BE/src/main/resources/application.properties new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/portal-BE/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/portal-BE/src/test/java/org/onap/portal/PortalApplicationTests.java b/portal-BE/src/test/java/org/onap/portal/PortalApplicationTests.java new file mode 100644 index 00000000..24871dc4 --- /dev/null +++ b/portal-BE/src/test/java/org/onap/portal/PortalApplicationTests.java @@ -0,0 +1,13 @@ +package org.onap.portal; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class PortalApplicationTests { + + @Test + void contextLoads() { + } + +} |