Merge changes Ia1e5c405,Ie890b499,Ie8b58f17,I76c96d30,I7814f090, ...
authorManoop Talasila <talasila@research.att.com>
Mon, 16 Sep 2019 15:50:47 +0000 (15:50 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 16 Sep 2019 15:50:47 +0000 (15:50 +0000)
* changes:
  WidgetsControllerTest up
  WidgetsCatalogController up
  WidgetsCatalogMarkupController up
  WidgetsController Up
  WidgetsController Up
  WidgetsController Up
  portal-BE documentation up
  Docker-compose up
  Coverity Scan issues fix

deliveries/Dockerfile.sdk
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/ECOMPLogoutController.java
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/controller/PeerBroadcastSocket.java
ecomp-portal-BE-os/src/main/java/org/onap/portalapp/portal/controller/AppsOSController.java

index 6afbb6c..5f96aaa 100644 (file)
@@ -1,54 +1,40 @@
-# Dockerfile for image with ONAP Portal SDK demo app
+# Dockerfile for SDK image with ONAP Portal
 
-# Multistage to be able to have SDK war content and not war itself
-FROM busybox:latest AS war-decompress
+FROM tomcat:8.5.35-jre8-alpine
 
 # Arguments are supplied by build.sh script
 # the defaults below only support testing
 ARG SDK_WAR=build/epsdk-app-os.war
-
-# Just variables, never passed in
-ARG SDKCONTEXT=ONAPPORTALSDK
-
-RUN mkdir ${SDKCONTEXT}
-
-# SDK app has only a war
-COPY $SDK_WAR ${SDKCONTEXT}
-RUN cd ${SDKCONTEXT} && unzip -q *.war && rm *.war
-
-
-# Yields an image 823 MB
-FROM openjdk:8-alpine
-# Yields an image 1.4 GB
-# FROM openjdk:8-jdk
-ARG SDK_WAR=build/epsdk-app-os.war
 ARG HTTP_PROXY
 ARG HTTPS_PROXY
 
+
 # Just variables, never passed in
-ARG TOMCAT_VERSION=8.0.37
-ARG TOMCAT=apache-tomcat-${TOMCAT_VERSION}
-ARG TOMCATTAR=${TOMCAT}.tar.gz
-ARG TOMCATHOME=/opt/${TOMCAT}
 ARG SDKCONTEXT=ONAPPORTALSDK
 
+ARG TOMCAT=/usr/local/tomcat
+ARG TOMCATHOME=${TOMCAT}
+ARG SERVERXML=${SERVERXML}
 
 ENV http_proxy $HTTP_PROXY
 ENV https_proxy $HTTPS_PROXY
-RUN if [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::http::proxy  \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf; fi && \
-    if [ ! -z ${HTTPS_PROXY} ]; then echo "Acquire::https::proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf; fi
+RUN if [ -d /etc/apt ] && [ ! -z ${HTTP_PROXY} ]; then echo "Acquire::http::proxy  \"${HTTP_PROXY}\";" >> /etc/apt/apt.conf; fi && \
+    if [ -d /etc/apt ] && [ ! -z ${HTTPS_PROXY} ]; then echo "Acquire::https::proxy \"${HTTPS_PROXY}\";" >> /etc/apt/apt.conf; fi
+
 
-# Install Tomcat.  This image already has curl.
 # Remove manager and sample apps
-WORKDIR /tmp
-RUN wget -q http://archive.apache.org/dist/tomcat/tomcat-8/v${TOMCAT_VERSION}/bin/${TOMCATTAR} && \
-    tar -xzf ${TOMCATTAR} && \
-    rm ${TOMCATTAR} &&\
-    rm -fr ${TOMCAT}/webapps/[a-z]* &&\
-    mkdir -p /opt &&\
-    mv ${TOMCAT} /opt
+RUN rm -rf ${TOMCAT}/webapps/[a-z]*
+RUN mkdir -p /opt
+COPY ${SERVERXML} ${TOMCAT}/conf
+# TODO: ????
+#RUN mv ${TOMCAT} /opt
 
-COPY --from=war-decompress /${SDKCONTEXT} ${TOMCATHOME}/webapps/${SDKCONTEXT}/
+WORKDIR ${TOMCATHOME}/webapps
+RUN mkdir ${SDKCONTEXT}
+
+# Portal has many parts
+COPY $SDK_WAR ${SDKCONTEXT}
+RUN cd ${SDKCONTEXT} && unzip -q *.war && rm *.war
 
 VOLUME ${TOMCATHOME}/logs
 
@@ -61,4 +47,5 @@ ENV PATH $PATH:$JAVA_HOME/bin:${TOMCATHOME}/bin
 COPY start-apache-tomcat.sh /
 
 # Define default command
-CMD /start-apache-tomcat.sh
+ENV TOMCATHOME=$TOMCATHOME
+CMD /start-apache-tomcat.sh -b $TOMCATHOME
\ No newline at end of file
index 062a2e2..54fcf3a 100644 (file)
@@ -33,7 +33,7 @@
  *
  * ============LICENSE_END============================================
  *
- * 
+ *
  */
 package org.onap.portalapp.controller;
 
@@ -62,72 +62,77 @@ import org.springframework.web.servlet.ModelAndView;
 @org.springframework.context.annotation.Configuration
 @EnableAspectJAutoProxy
 @Profile("src")
-public class ECOMPLogoutController extends EPUnRestrictedBaseController{
-       
-       private EPUser user;
-       private static final String EP_SERVICE = "EPService";
-       EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ECOMPLogoutController.class);
-
-       @EPAuditLog
-       @RequestMapping(value = {"/logout.htm" }, method = RequestMethod.GET)
-       public ModelAndView logOut(HttpServletRequest request,
-                                                               HttpServletResponse response) throws Exception {
-       
-               ModelAndView modelView = null;
-                               
-               chatRoomLogout(request);
-               logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Logout request received.");
-               
-               modelView = new ModelAndView("redirect:login.htm");
-               
-               /**
-               if (UserUtils.isClientMobileDevice(request)){
-               modelView.setViewName(modelView.getViewName().concat("?viewType=mobile"));
-               }
-               */
-               String cookieDoamin = EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN);
-               Cookie epCookie = new Cookie(EP_SERVICE, "");
-               epCookie.setMaxAge(0);
-               epCookie.setDomain(cookieDoamin);
-               epCookie.setPath("/");
-               
-               Cookie appHeaderCookie = new Cookie("show_app_header", "");
-               appHeaderCookie.setMaxAge(0);
-               appHeaderCookie.setDomain(cookieDoamin);
-               appHeaderCookie.setPath("/");
-               
-               Cookie appTabCookie = new Cookie("cookieTabs", "");
-               appTabCookie.setMaxAge(0);
-               appTabCookie.setDomain(cookieDoamin);
-               appTabCookie.setPath("/");
-               
-               Cookie appVisInvisTabCookie = new Cookie("visInVisCookieTabs", "");
-               appVisInvisTabCookie.setMaxAge(0);
-               appVisInvisTabCookie.setDomain(cookieDoamin);
-               appVisInvisTabCookie.setPath("/");
-               
-           response.addCookie(epCookie);       
-           response.addCookie(appHeaderCookie);
-           response.addCookie(appTabCookie);
-           response.addCookie(appVisInvisTabCookie);
-               request.getSession().invalidate();
-               
-               logger.debug(EELFLoggerDelegate.debugLogger, "ECOMPLogoutController.handleRequestInternal - Successfully processed the logout request.");
-               
-               return modelView;
-       }
-       
-       @EPMetricsLog
-       public void chatRoomLogout(HttpServletRequest request){
-               request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest(); 
-               setUser(EPUserUtils.getUserSession(request));
-       }
-       
-       public EPUser getUser() {
-               return user;
-       }
-       
-       public void setUser(EPUser user) {
-               this.user = user;
-       }
+public class ECOMPLogoutController extends EPUnRestrictedBaseController {
+
+    private EPUser user;
+    private static final String EP_SERVICE = "EPService";
+    EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ECOMPLogoutController.class);
+
+    @EPAuditLog
+    @RequestMapping(value = { "/logout.htm" }, method = RequestMethod.GET)
+    public ModelAndView logOut(HttpServletRequest request,
+            HttpServletResponse response) throws Exception {
+
+        ModelAndView modelView = null;
+
+        chatRoomLogout(request);
+        logger.debug(EELFLoggerDelegate.debugLogger,
+                "ECOMPLogoutController.handleRequestInternal - Logout request received.");
+
+        modelView = new ModelAndView("redirect:login.htm");
+
+        /**
+         * if (UserUtils.isClientMobileDevice(request)){
+         * modelView.setViewName(modelView.getViewName().concat("?viewType=mobile")); }
+         */
+        String cookieDoamin = EPSystemProperties.getProperty(EPSystemProperties.COOKIE_DOMAIN);
+        Cookie epCookie = new Cookie(EP_SERVICE, "");
+        epCookie.setSecure(true);
+        epCookie.setMaxAge(0);
+        epCookie.setDomain(cookieDoamin);
+        epCookie.setPath("/");
+
+        Cookie appHeaderCookie = new Cookie("show_app_header", "");
+        appHeaderCookie.setSecure(true);
+        appHeaderCookie.setMaxAge(0);
+        appHeaderCookie.setDomain(cookieDoamin);
+        appHeaderCookie.setPath("/");
+
+        Cookie appTabCookie = new Cookie("cookieTabs", "");
+        appTabCookie.setSecure(true);
+        appTabCookie.setMaxAge(0);
+        appTabCookie.setDomain(cookieDoamin);
+        appTabCookie.setPath("/");
+
+        Cookie appVisInvisTabCookie = new Cookie("visInVisCookieTabs", "");
+        appVisInvisTabCookie.setSecure(true);
+        appVisInvisTabCookie.setMaxAge(0);
+        appVisInvisTabCookie.setDomain(cookieDoamin);
+        appVisInvisTabCookie.setPath("/");
+
+        response.addCookie(epCookie);
+        response.addCookie(appHeaderCookie);
+        response.addCookie(appTabCookie);
+        response.addCookie(appVisInvisTabCookie);
+        request.getSession().invalidate();
+
+        logger.debug(EELFLoggerDelegate.debugLogger,
+                "ECOMPLogoutController.handleRequestInternal - Successfully processed the logout request.");
+
+        return modelView;
+    }
+
+    @EPMetricsLog
+    public void chatRoomLogout(HttpServletRequest request) {
+        request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
+        setUser(EPUserUtils.getUserSession(request));
+    }
+
+    public EPUser getUser() {
+        return user;
+    }
+
+    public void setUser(EPUser user) {
+        this.user = user;
+    }
 }
index c80419f..de8524e 100644 (file)
@@ -35,7 +35,7 @@
  *
  * ============LICENSE_END============================================
  *
- * 
+ *
  */
 package org.onap.portalapp.controller;
 
@@ -53,51 +53,50 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
 
 @ServerEndpoint("/opencontact")
 public class PeerBroadcastSocket {
-       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerBroadcastSocket.class);
-       private static final ObjectMapper mapper = new ObjectMapper();
+    private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PeerBroadcastSocket.class);
+    private static final ObjectMapper mapper = new ObjectMapper();
 
-       protected static final Map<String, Object> channelMap = new HashMap<>();
-       private Map<String, String> sessionMap = new HashMap<>();
+    private static final Map<String, Object> channelMap = new HashMap<>();
+    private Map<String, String> sessionMap = new HashMap<>();
 
-       @OnMessage
-       public void message(String message, Session session) {
-               try {
-                       Map<String, Object> jsonObject = mapper.readValue(message, Map.class);
-                       save(jsonObject, session);
-               } catch (Exception ex) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "Failed" + ex.getMessage());
-               }
-       }
+    @OnMessage
+    public void message(String message, Session session) {
+        try {
+            Map<String, Object> jsonObject = mapper.readValue(message, Map.class);
+            save(jsonObject, session);
+        } catch (Exception ex) {
+            logger.error(EELFLoggerDelegate.errorLogger, "Failed", ex);
+        }
+    }
 
-       @OnOpen
-       public void open(Session session) {
-               logger.info(EELFLoggerDelegate.debugLogger, "Channel opened");
-       }
+    @OnOpen
+    public void open(Session session) {
+        logger.info(EELFLoggerDelegate.debugLogger, "Channel opened");
+    }
 
-       @OnClose
-       public void close(Session session) {
-               String channel = sessionMap.get(session.getId());
-               if (channel != null) {
-                       Object sessObj = channelMap.get(channel);
-                       if (sessObj != null) {
-                               try {
-                                       ((Session) sessObj).close();
-                               } catch (IOException e) {
-                                       logger.error(EELFLoggerDelegate.errorLogger, "Failed to close" + e.getMessage());
-                               }
-                       }
-                       channelMap.remove(channel);
-               }
-               logger.info(EELFLoggerDelegate.debugLogger, "Channel closed");
-       }
+    @OnClose
+    public void close(Session session) {
+        String channel = sessionMap.get(session.getId());
+        if (channel != null) {
+            Object sessObj = channelMap.get(channel);
+            if (sessObj != null) {
+                try {
+                    ((Session) sessObj).close();
+                } catch (IOException e) {
+                    logger.error(EELFLoggerDelegate.errorLogger, "Failed to close", e);
+                }
+            }
+            channelMap.remove(channel);
+        }
+        logger.info(EELFLoggerDelegate.debugLogger, "Channel closed");
+    }
 
-       private void save(Map<String, Object> jsonObject, Session session) {
-               final Optional<String> from = Optional.of(jsonObject.get("from").toString());
-               if (from.isPresent() && channelMap.get(from.get()) == null) {
-                       this.channelMap.put(from.toString(), session);
-                       this.sessionMap.put(session.getId(), from.toString());
-               }
-       }
+    private void save(Map<String, Object> jsonObject, Session session) {
+        final Optional<String> from = Optional.of(jsonObject.get("from").toString());
+        if (from.isPresent() && channelMap.get(from.get()) == null) {
+            channelMap.put(from.toString(), session);
+            this.sessionMap.put(session.getId(), from.toString());
+        }
+    }
 
 }
-
index e109ef5..b1154aa 100644 (file)
@@ -39,23 +39,17 @@ package org.onap.portalapp.portal.controller;
 
 import java.util.HashMap;
 import java.util.Map;
-
 import java.util.Set;
 import javax.servlet.http.HttpServletRequest;
-
 import javax.validation.ConstraintViolation;
 import javax.validation.Validation;
 import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
-import lombok.NoArgsConstructor;
 import org.json.JSONObject;
 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.logging.aop.EPAuditLog;
-import org.onap.portalapp.portal.service.AdminRolesService;
-import org.onap.portalapp.portal.service.EPAppService;
-import org.onap.portalapp.portal.service.PersUserAppService;
 import org.onap.portalapp.portal.service.UserService;
 import org.onap.portalapp.util.EPUserUtils;
 import org.onap.portalapp.validation.SecureString;
@@ -68,6 +62,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
+import lombok.NoArgsConstructor;
 
 @RestController
 @Configuration
@@ -75,73 +70,74 @@ import org.springframework.web.bind.annotation.RestController;
 @EPAuditLog
 @NoArgsConstructor
 public class AppsOSController extends AppsController {
-       private static final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
-       
-       private static final String FAILURE = "failure";
-       private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsOSController.class);
+    private static final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
 
-       @Autowired
-       UserService userService;
+    private static final String FAILURE = "failure";
+    private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsOSController.class);
+
+    @Autowired
+    UserService userService;
+
+    /**
+     * Create new application's contact us details.
+     *
+     * @param contactUs
+     * @return
+     */
+    @RequestMapping(value = "/portalApi/saveNewUser", method = RequestMethod.POST, produces = "application/json")
+    public PortalRestResponse<String> saveNewUser(HttpServletRequest request, @RequestBody EPUser newUser) {
+        EPUser user = EPUserUtils.getUserSession(request);
+        if (newUser == null)
+            return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, FAILURE,
+                    "New User cannot be null or empty");
+
+        if (!(super.getAdminRolesService().isSuperAdmin(user) || super.getAdminRolesService().isAccountAdmin(user))
+                && !user.getLoginId().equalsIgnoreCase(newUser.getLoginId())) {
+            return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, FAILURE,
+                    "UnAuthorized");
+        }
 
-       /**
-        * Create new application's contact us details.
-        * 
-        * @param contactUs
-        * @return
-        */
-       @RequestMapping(value = "/portalApi/saveNewUser", method = RequestMethod.POST, produces = "application/json")
-       public PortalRestResponse<String> saveNewUser(HttpServletRequest request,@RequestBody EPUser newUser) {
-               EPUser user = EPUserUtils.getUserSession(request);
-               if (newUser == null)
-                       return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, FAILURE,
-                                       "New User cannot be null or empty");
-               
-               if (!(super.getAdminRolesService().isSuperAdmin(user) || super.getAdminRolesService().isAccountAdmin(user))){
-                       if(!user.getLoginId().equalsIgnoreCase(newUser.getLoginId()))
-                               return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, FAILURE,
-                                               "UnAuthorized");
-               }
-                       
         String checkDuplicate = request.getParameter("isCheck");
-               String saveNewUser = FAILURE;
-               try {
-                       saveNewUser = userService.saveNewUser(newUser,checkDuplicate);
-               } catch (Exception e) {
-                       return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, saveNewUser, e.getMessage());
-               }
-               return new PortalRestResponse<>(PortalRestStatusEnum.OK, saveNewUser, "");
-       }
-       
-       @RequestMapping(value = { "/portalApi/currentUserProfile/{loginId}" }, method = RequestMethod.GET, produces = "application/json")
-       public String getCurrentUserProfile(HttpServletRequest request, @PathVariable("loginId") String loginId) {
+        String saveNewUser = FAILURE;
+        try {
+            saveNewUser = userService.saveNewUser(newUser, checkDuplicate);
+        } catch (Exception e) {
+            logger.error(EELFLoggerDelegate.errorLogger, "Exception in saveNewUser", e);
+            return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, saveNewUser, e.getMessage());
+        }
+        return new PortalRestResponse<>(PortalRestStatusEnum.OK, saveNewUser, "");
+    }
+
+    @RequestMapping(value = { "/portalApi/currentUserProfile/{loginId}" }, method = RequestMethod.GET,
+            produces = "application/json")
+    public String getCurrentUserProfile(HttpServletRequest request, @PathVariable("loginId") String loginId) {
 
-               if(loginId != null){
-                       Validator validator = validatorFactory.getValidator();
-                       SecureString secureString = new SecureString(loginId);
-                       Set<ConstraintViolation<SecureString>> constraintViolations = validator.validate(secureString);
+        if (loginId != null) {
+            Validator validator = validatorFactory.getValidator();
+            SecureString secureString = new SecureString(loginId);
+            Set<ConstraintViolation<SecureString>> constraintViolations = validator.validate(secureString);
 
-                       if (!constraintViolations.isEmpty()){
-                               return "loginId is not valid";
-                       }
-               }
+            if (!constraintViolations.isEmpty()) {
+                return "loginId is not valid";
+            }
+        }
 
-               
-               Map<String,String> map = new HashMap<>();
-               EPUser user;
-               try {
-                        user = (EPUser) userService.getUserByUserId(loginId).get(0);
-                        map.put("firstName", user.getFirstName());
-                    map.put("lastName", user.getLastName());
-                    map.put("email", user.getEmail());
-                        map.put("loginId", user.getLoginId());
-                        map.put("loginPwd",user.getLoginPwd());
-                        map.put("middleInitial",user.getMiddleInitial());
-               } catch (Exception e) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "Failed to get user info", e);
-               }
+        Map<String, String> map = new HashMap<>();
+        EPUser user;
+        try {
+            user = (EPUser) userService.getUserByUserId(loginId).get(0);
+            map.put("firstName", user.getFirstName());
+            map.put("lastName", user.getLastName());
+            map.put("email", user.getEmail());
+            map.put("loginId", user.getLoginId());
+            map.put("loginPwd", user.getLoginPwd());
+            map.put("middleInitial", user.getMiddleInitial());
+        } catch (Exception e) {
+            logger.error(EELFLoggerDelegate.errorLogger, "Failed to get user info", e);
+        }
 
-               JSONObject j = new JSONObject(map);
-               return j.toString();
-       }
+        JSONObject j = new JSONObject(map);
+        return j.toString();
+    }
 
-}
\ No newline at end of file
+}