Fix dashboard repo issue 57/34557/1
authorHong Guan <hg4105@att.com>
Wed, 7 Mar 2018 17:21:17 +0000 (12:21 -0500)
committerHong Guan <hg4105@att.com>
Wed, 7 Mar 2018 17:21:17 +0000 (12:21 -0500)
Change-Id: I264bc0ec06bc308816bd96982efdfef28264978c
Issue-ID: CCSDK-196
Signed-off-by: Hong Guan <hg4105@att.com>
27 files changed:
.gitreview
ccsdk-app-common/pom.xml
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/CloudifyController.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ConsulController.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardHomeController.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardRestrictedBaseController.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ECDSingleSignOnController.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/HealthCheckController.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/domain/ControllerEndpoint.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/ControllerEndpointCredentials.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientImpl.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientMockImpl.java
ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/service/ControllerEndpointServiceImpl.java
ccsdk-app-common/src/main/java/org/onap/fusionapp/service/AdminAuthExtension.java
ccsdk-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java
ccsdk-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java
ccsdk-app-os/pom.xml
ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java
ccsdk-app-os/src/main/java/org/onap/portalapp/conf/HibernateMappingLocations.java
ccsdk-app-os/src/main/java/org/onap/portalapp/lm/FusionLicenseManagerImpl.java
ccsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java
ccsdk-app-os/src/main/java/org/onap/portalapp/service/AdminAuthExtension.java
ccsdk-app-os/src/main/resources/portal.properties
ccsdk-app-os/src/main/webapp/WEB-INF/jsp/login_external.jsp
ccsdk-app-overlay/src/main/webapp/WEB-INF/fusion-110-copy.hbm.xml
pom.xml

index 04cdce7..327b31d 100644 (file)
@@ -1,4 +1,4 @@
 [gerrit]
-host=gerrit.openecomp.org
+host=gerrit.onap.org
 port=29418
 project=ccsdk/dashboard.git
index b28b292..be05119 100644 (file)
-<?xml version="1.0"?>
-<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>
-
-       <groupId>org.onap.ccsdk.dashboard</groupId>
-       <artifactId>ccsdk-app-common</artifactId>
-       <version>1.1.0-SNAPSHOT</version>
-       <packaging>jar</packaging>
-       <name>ONAP Operations Manager Dashboard common</name>
-       <description>CCSDK Dashboard common Java code</description>
-
-       <properties>
-               <encoding>UTF-8</encoding>
-               <springframework.version>4.2.0.RELEASE</springframework.version>
-               <hibernate.version>4.3.11.Final</hibernate.version>
-               <eelf.version>1.0.0</eelf.version>
-               <epsdk.version>1.1.0</epsdk.version>
-               <nexusproxy>https://nexus.onap.org</nexusproxy>
-               <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
-               <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
-               <skipTests>true</skipTests>
-       </properties>
-
-       <repositories>
-               <repository>
-                       <!-- Releases repository has ECOMP release artifacts -->
-                       <id>ecomp-releases</id>
-                       <name>OpenECOMP - Release Repository</name>
-                       <url>${nexusproxy}/${releaseNexusPath}</url>
-               </repository>
-               <repository>
-                       <!-- Snapshots repository has ECOMP snapshot artifacts -->
-                       <id>ecomp-snapshots</id>
-                       <name>OpenECOMP - Snapshot Repository</name>
-                       <url>${nexusproxy}/${snapshotNexusPath}</url>
-               </repository>
-       </repositories>
-
-       <!-- disable doclint, a new feature in Java 8, when generating javadoc -->
-       <profiles>
-               <profile>
-                       <id>doclint-java8-disable</id>
-                       <activation>
-                               <jdk>[1.8,)</jdk>
-                       </activation>
-                       <build>
-                               <plugins>
-                                       <plugin>
-                                               <groupId>org.apache.maven.plugins</groupId>
-                                               <artifactId>maven-javadoc-plugin</artifactId>
-                                               <configuration>
-                                                       <additionalparam>-Xdoclint:none</additionalparam>
-                                               </configuration>
-                                       </plugin>
-                               </plugins>
-                       </build>
-               </profile>
-       </profiles>
-
-       <build>
-               <plugins>
-
-                       <!-- Compile to Java 1.8 class output format -->
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-compiler-plugin</artifactId>
-                               <version>3.1</version>
-                               <configuration>
-                                       <source>1.8</source>
-                                       <target>1.8</target>
-                               </configuration>
-                       </plugin>
-
-                       <!-- Put version into jar also -->
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-jar-plugin</artifactId>
-                               <version>2.6</version>
-                               <configuration>
-                                       <archive>
-                                               <manifestEntries>
-                                                       <archive-version>${project.version}</archive-version>
-                                               </manifestEntries>
-                                       </archive>
-                               </configuration>
-                       </plugin>
-
-                       <!-- Generate javadoc jar; see profile for Java 8 -->
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-javadoc-plugin</artifactId>
-                               <version>2.10.3</version>
-                               <executions>
-                                       <execution>
-                                               <id>attach-javadocs</id>
-                                               <goals>
-                                                       <goal>jar</goal>
-                                               </goals>
-                                       </execution>
-                               </executions>
-                       </plugin>
-
-                       <!-- Generate source jar -->
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-source-plugin</artifactId>
-                               <version>3.0.0</version>
-                               <executions>
-                                       <execution>
-                                               <id>attach-sources</id>
-                                               <goals>
-                                                       <goal>jar</goal>
-                                               </goals>
-                                       </execution>
-                               </executions>
-                       </plugin>
-
-                       <!-- no deployment needed -->
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-deploy-plugin</artifactId>
-                               <version>2.8</version>
-                               <configuration>
-                                       <skip>true</skip>
-                               </configuration>
-                       </plugin>
-
-               </plugins>
-
-       </build>
-
-       <dependencies>
-               <!-- For using HTTP Basic Auth in uService REST client -->
-               <dependency>
-                       <groupId>org.apache.httpcomponents</groupId>
-                       <artifactId>httpclient</artifactId>
-                       <version>4.3.5</version>
-               </dependency>
-               <!-- Postgresql driver -->
-               <dependency>
-                       <groupId>org.postgresql</groupId>
-                       <artifactId>postgresql</artifactId>
-                       <version>9.3-1100-jdbc41</version>
-               </dependency>
-               <!-- SDK components -->
-               <dependency>
-                       <groupId>org.openecomp.ecompsdkos</groupId>
-                       <artifactId>epsdk-core</artifactId>
-                       <version>${epsdk.version}</version>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>mysql</groupId>
-                                       <artifactId>mysql-connector-java</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>org.elasticsearch</groupId>
-                                       <artifactId>elasticsearch</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-               <dependency>
-                       <groupId>com.att.eelf</groupId>
-                       <artifactId>eelf-core</artifactId>
-                       <version>${eelf.version}</version>
-               </dependency>
-               <!-- Mapper -->
-               <dependency>
-                       <groupId>com.fasterxml.jackson.core</groupId>
-                       <artifactId>jackson-annotations</artifactId>
-                       <version>2.6.3</version>
-               </dependency>
-               <dependency>
-                       <groupId>com.fasterxml.jackson.core</groupId>
-                       <artifactId>jackson-core</artifactId>
-                       <version>2.6.3</version>
-               </dependency>
-               <dependency>
-                       <groupId>com.fasterxml.jackson.core</groupId>
-                       <artifactId>jackson-databind</artifactId>
-                       <version>2.6.3</version>
-               </dependency>
-               <dependency>
-                       <groupId>com.mchange</groupId>
-                       <artifactId>c3p0</artifactId>
-                       <version>0.9.5.2</version>
-               </dependency>
-               <dependency>
-                       <groupId>javax.servlet</groupId>
-                       <artifactId>javax.servlet-api</artifactId>
-                       <version>3.1.0</version>
-               </dependency>
-               <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       <version>4.12</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.json</groupId>
-                       <artifactId>json</artifactId>
-                       <version>20160212</version>
-               </dependency>
-               <!-- bridge to implement commons-logging using slf4j -->
-               <dependency>
-                       <groupId>org.slf4j</groupId>
-                       <artifactId>jcl-over-slf4j</artifactId>
-                       <version>1.7.12</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework</groupId>
-                       <artifactId>spring-context-support</artifactId>
-                       <version>${springframework.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework</groupId>
-                       <artifactId>spring-core</artifactId>
-                       <version>${springframework.version}</version>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>commons-logging</groupId>
-                                       <artifactId>commons-logging</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework</groupId>
-                       <artifactId>spring-tx</artifactId>
-                       <version>${springframework.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework</groupId>
-                       <artifactId>spring-web</artifactId>
-                       <version>${springframework.version}</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework</groupId>
-                       <artifactId>spring-webmvc</artifactId>
-                       <version>${springframework.version}</version>
-               </dependency>
-       </dependencies>
-
-       <!-- no distributionManagement section; no jars pushed to Maven central -->
-
-</project>
+<?xml version="1.0"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+       <modelVersion>4.0.0</modelVersion>\r
+\r
+       <groupId>org.onap.ccsdk.dashboard</groupId>\r
+       <artifactId>ccsdk-app-common</artifactId>\r
+       <version>1.1.0-SNAPSHOT</version>\r
+       <packaging>jar</packaging>\r
+       <name>ONAP Operations Manager Dashboard common</name>\r
+       <description>CCSDK Dashboard common Java code</description>\r
+\r
+       <properties>\r
+               <encoding>UTF-8</encoding>\r
+               <springframework.version>4.2.0.RELEASE</springframework.version>\r
+               <hibernate.version>4.3.11.Final</hibernate.version>\r
+               <eelf.version>1.0.0</eelf.version>\r
+               <epsdk.version>2.1.0</epsdk.version>\r
+               <nexusproxy>https://nexus.onap.org</nexusproxy>\r
+               <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>\r
+               <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>\r
+               <skipTests>true</skipTests>\r
+       </properties>\r
+\r
+       <repositories>\r
+               <repository>\r
+                       <!-- Releases repository has ECOMP release artifacts -->\r
+                       <id>ecomp-releases</id>\r
+                       <name>OpenECOMP - Release Repository</name>\r
+                       <url>${nexusproxy}/${releaseNexusPath}</url>\r
+               </repository>\r
+               <repository>\r
+                       <!-- Snapshots repository has ECOMP snapshot artifacts -->\r
+                       <id>ecomp-snapshots</id>\r
+                       <name>OpenECOMP - Snapshot Repository</name>\r
+                       <url>${nexusproxy}/${snapshotNexusPath}</url>\r
+               </repository>\r
+       </repositories>\r
+\r
+       <!-- disable doclint, a new feature in Java 8, when generating javadoc -->\r
+       <profiles>\r
+               <profile>\r
+                       <id>doclint-java8-disable</id>\r
+                       <activation>\r
+                               <jdk>[1.8,)</jdk>\r
+                       </activation>\r
+                       <build>\r
+                               <plugins>\r
+                                       <plugin>\r
+                                               <groupId>org.apache.maven.plugins</groupId>\r
+                                               <artifactId>maven-javadoc-plugin</artifactId>\r
+                                               <configuration>\r
+                                                       <additionalparam>-Xdoclint:none</additionalparam>\r
+                                               </configuration>\r
+                                       </plugin>\r
+                               </plugins>\r
+                       </build>\r
+               </profile>\r
+       </profiles>\r
+\r
+       <build>\r
+               <plugins>\r
+\r
+                       <!-- Compile to Java 1.8 class output format -->\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-compiler-plugin</artifactId>\r
+                               <version>3.1</version>\r
+                               <configuration>\r
+                                       <source>1.8</source>\r
+                                       <target>1.8</target>\r
+                               </configuration>\r
+                       </plugin>\r
+\r
+                       <!-- Put version into jar also -->\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-jar-plugin</artifactId>\r
+                               <version>2.6</version>\r
+                               <configuration>\r
+                                       <archive>\r
+                                               <manifestEntries>\r
+                                                       <archive-version>${project.version}</archive-version>\r
+                                               </manifestEntries>\r
+                                       </archive>\r
+                               </configuration>\r
+                       </plugin>\r
+\r
+                       <!-- Generate javadoc jar; see profile for Java 8 -->\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-javadoc-plugin</artifactId>\r
+                               <version>2.10.3</version>\r
+                               <executions>\r
+                                       <execution>\r
+                                               <id>attach-javadocs</id>\r
+                                               <goals>\r
+                                                       <goal>jar</goal>\r
+                                               </goals>\r
+                                       </execution>\r
+                               </executions>\r
+                       </plugin>\r
+\r
+                       <!-- Generate source jar -->\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-source-plugin</artifactId>\r
+                               <version>3.0.0</version>\r
+                               <executions>\r
+                                       <execution>\r
+                                               <id>attach-sources</id>\r
+                                               <goals>\r
+                                                       <goal>jar</goal>\r
+                                               </goals>\r
+                                       </execution>\r
+                               </executions>\r
+                       </plugin>\r
+\r
+                       <!-- no deployment needed -->\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-deploy-plugin</artifactId>\r
+                               <version>2.8</version>\r
+                               <configuration>\r
+                                       <skip>true</skip>\r
+                               </configuration>\r
+                       </plugin>\r
+\r
+               </plugins>\r
+\r
+       </build>\r
+\r
+       <dependencies>\r
+               <!-- For using HTTP Basic Auth in uService REST client -->\r
+               <dependency>\r
+                       <groupId>org.apache.httpcomponents</groupId>\r
+                       <artifactId>httpclient</artifactId>\r
+                       <version>4.3.5</version>\r
+               </dependency>\r
+               <!-- Postgresql driver -->\r
+               <dependency>\r
+                       <groupId>org.postgresql</groupId>\r
+                       <artifactId>postgresql</artifactId>\r
+                       <version>9.3-1100-jdbc41</version>\r
+               </dependency>\r
+               <!-- SDK components -->\r
+               <dependency>\r
+                       <groupId>org.onap.portal.sdk</groupId>\r
+                       <artifactId>epsdk-core</artifactId>\r
+                       <version>${epsdk.version}</version>\r
+                       <exclusions>\r
+                               <exclusion>\r
+                                       <groupId>mysql</groupId>\r
+                                       <artifactId>mysql-connector-java</artifactId>\r
+                               </exclusion>\r
+                               <exclusion>\r
+                                       <groupId>org.elasticsearch</groupId>\r
+                                       <artifactId>elasticsearch</artifactId>\r
+                               </exclusion>\r
+                       </exclusions>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>com.att.eelf</groupId>\r
+                       <artifactId>eelf-core</artifactId>\r
+                       <version>${eelf.version}</version>\r
+               </dependency>\r
+               <!-- Mapper -->\r
+               <dependency>\r
+                       <groupId>com.fasterxml.jackson.core</groupId>\r
+                       <artifactId>jackson-annotations</artifactId>\r
+                       <version>2.6.3</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>com.fasterxml.jackson.core</groupId>\r
+                       <artifactId>jackson-core</artifactId>\r
+                       <version>2.6.3</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>com.fasterxml.jackson.core</groupId>\r
+                       <artifactId>jackson-databind</artifactId>\r
+                       <version>2.6.3</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>com.mchange</groupId>\r
+                       <artifactId>c3p0</artifactId>\r
+                       <version>0.9.5.2</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>javax.servlet</groupId>\r
+                       <artifactId>javax.servlet-api</artifactId>\r
+                       <version>3.1.0</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>junit</groupId>\r
+                       <artifactId>junit</artifactId>\r
+                       <version>4.12</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.json</groupId>\r
+                       <artifactId>json</artifactId>\r
+                       <version>20160212</version>\r
+               </dependency>\r
+               <!-- bridge to implement commons-logging using slf4j -->\r
+               <dependency>\r
+                       <groupId>org.slf4j</groupId>\r
+                       <artifactId>jcl-over-slf4j</artifactId>\r
+                       <version>1.7.12</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.springframework</groupId>\r
+                       <artifactId>spring-context-support</artifactId>\r
+                       <version>${springframework.version}</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.springframework</groupId>\r
+                       <artifactId>spring-core</artifactId>\r
+                       <version>${springframework.version}</version>\r
+                       <exclusions>\r
+                               <exclusion>\r
+                                       <groupId>commons-logging</groupId>\r
+                                       <artifactId>commons-logging</artifactId>\r
+                               </exclusion>\r
+                       </exclusions>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.springframework</groupId>\r
+                       <artifactId>spring-tx</artifactId>\r
+                       <version>${springframework.version}</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.springframework</groupId>\r
+                       <artifactId>spring-web</artifactId>\r
+                       <version>${springframework.version}</version>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.springframework</groupId>\r
+                       <artifactId>spring-webmvc</artifactId>\r
+                       <version>${springframework.version}</version>\r
+               </dependency>\r
+       </dependencies>\r
+\r
+       <!-- no distributionManagement section; no jars pushed to Maven central -->\r
+\r
+</project>\r
index 1962c4f..7b05841 100644 (file)
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.controller;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.onap.ccsdk.dashboard.model.CloudifyDeploymentList;
-import org.onap.ccsdk.dashboard.model.CloudifyExecutionRequest;
-import org.onap.ccsdk.dashboard.exception.DashboardControllerException;
-import org.onap.ccsdk.dashboard.model.CloudifyBlueprint;
-import org.onap.ccsdk.dashboard.model.CloudifyBlueprintUpload;
-import org.onap.ccsdk.dashboard.model.CloudifyDeployment;
-import org.onap.ccsdk.dashboard.model.CloudifyDeploymentRequest;
-import org.onap.ccsdk.dashboard.model.CloudifyExecution;
-import org.onap.ccsdk.dashboard.model.CloudifyExecutionList;
-import org.onap.ccsdk.dashboard.model.ECTransportModel;
-import org.onap.ccsdk.dashboard.model.RestResponseError;
-import org.onap.ccsdk.dashboard.model.RestResponsePage;
-import org.onap.ccsdk.dashboard.rest.IControllerRestClient;
-import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
-import org.slf4j.MDC;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-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.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.client.HttpStatusCodeException;
-
-/**
- * Controller for Cloudify features: blueprints, deployments, executions.
- * Methods serve Ajax requests made by Angular scripts on pages that show
- * content.
- */
-@Controller
-@RequestMapping("/")
-public class CloudifyController extends DashboardRestrictedBaseController {
-
-    private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CloudifyController.class);
-
-    /**
-     * Enum for selecting an item type.
-     */
-    public enum CloudifyDataItem {
-        BLUEPRINT, DEPLOYMENT, EXECUTION;
-    }
-
-    private static final String BLUEPRINTS_PATH = "blueprints";
-    private static final String VIEW_BLUEPRINTS_PATH = "viewblueprints";
-    private static final String DEPLOYMENTS_PATH = "deployments";
-    private static final String EXECUTIONS_PATH = "executions";
-
-    /**
-     * Supports sorting blueprints by ID
-     */
-    private static Comparator<CloudifyBlueprint> blueprintComparator = Comparator.comparing(o -> o.id);
-
-    /**
-     * Supports sorting deployments by ID
-     */
-    private static Comparator<CloudifyDeployment> deploymentComparator = Comparator.comparing(o -> o.id);
-
-    /**
-     * Supports sorting executions by ID
-     */
-    private static Comparator<CloudifyExecution> executionComparator = Comparator.comparing(o -> o.id);
-
-    /**
-     * Gets one page of objects and supporting information via the REST client.
-     * On success, returns a PaginatedRestResponse object as String.
-     *
-     * @param option
-     *            Specifies which item list type to get
-     * @param pageNum
-     *            Page number of results
-     * @param pageSize
-     *            Number of items per browser page
-     * @return JSON block as String, see above.
-     * @throws DashboardControllerException
-     *             On any error; e.g., Network failure.
-     */
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    private String getItemListForPage(long userId, CloudifyDataItem option, int pageNum, int pageSize)
-        throws DashboardControllerException, JsonProcessingException {
-        IControllerRestClient restClient = getControllerRestClient(userId);
-        List itemList;
-        switch (option) {
-            case BLUEPRINT:
-                itemList = restClient.getBlueprints().items;
-                itemList.sort(blueprintComparator);
-                break;
-            case DEPLOYMENT:
-                itemList = restClient.getDeployments().items;
-                itemList.sort(deploymentComparator);
-                break;
-            default:
-                throw new DashboardControllerException(
-                    "getItemListForPage failed: unimplemented case: " + option.name());
-        }
-
-        // Shrink if needed
-        final int totalItems = itemList.size();
-        final int pageCount = (int) Math.ceil((double) totalItems / pageSize);
-        if (totalItems > pageSize) {
-            itemList = getPageOfList(pageNum, pageSize, itemList);
-        }
-        RestResponsePage<List> model = new RestResponsePage<>(totalItems, pageCount, itemList);
-        return objectMapper.writeValueAsString(model);
-    }
-
-    /**
-     * Gets one page of the specified items. This method traps exceptions and
-     * constructs an appropriate JSON block to report errors.
-     *
-     * @param request
-     *            Inbound request
-     * @param option
-     *            Item type to get
-     * @return JSON with one page of objects; or an error.
-     */
-    protected String getItemListForPageWrapper(HttpServletRequest request, CloudifyDataItem option) {
-        String outboundJson = null;
-        try {
-            User appUser = UserUtils.getUserSession(request);
-            if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0) {
-                throw new DashboardControllerException("getItemListForPageWrapper: Failed to get application user");
-            }
-            int pageNum = getRequestPageNumber(request);
-            int pageSize = getRequestPageSize(request);
-            outboundJson = getItemListForPage(appUser.getId(), option, pageNum, pageSize);
-        } catch (Exception ex) {
-            logger.error(EELFLoggerDelegate.errorLogger, "getItemListForPageWrapper caught exception", ex);
-            RestResponseError result;
-            if (ex instanceof HttpStatusCodeException) {
-                result = new RestResponseError(((HttpStatusCodeException) ex).getResponseBodyAsString());
-            } else {
-                result = new RestResponseError("Failed to get " + option.name(), ex);
-            }
-            try {
-                outboundJson = objectMapper.writeValueAsString(result);
-            } catch (JsonProcessingException jpe) {
-                // Should never, ever happen
-                outboundJson = "{ \"error\" : \"" + jpe.toString() + "\"}";
-            }
-        }
-        return outboundJson;
-    }
-
-    /**
-     * Serves one page of blueprints
-     *
-     * @param request
-     *            HttpServletRequest
-     * @return List of CloudifyBlueprint objects
-     */
-    @RequestMapping(value = {BLUEPRINTS_PATH}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getBlueprintsByPage(HttpServletRequest request) {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        String json = getItemListForPageWrapper(request, CloudifyDataItem.BLUEPRINT);
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return json;
-    }
-
-    /**
-     * Serves one page of deployments
-     *
-     * @param request
-     *            HttpServletRequest
-     * @return List of CloudifyDeployment objects
-     */
-    @RequestMapping(value = {DEPLOYMENTS_PATH}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getDeploymentsByPage(HttpServletRequest request) {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        String json = getItemListForPageWrapper(request, CloudifyDataItem.DEPLOYMENT);
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return json;
-    }
-
-    /**
-     * Gets the specified blueprint metadata.
-     *
-     * @param id
-     *            Blueprint ID
-     * @param request
-     *            HttpServletRequest
-     * @return Blueprint as JSON; or error.
-     * @throws JsonProcessingException
-     *             on serialization error
-     *
-     */
-    @RequestMapping(value = {BLUEPRINTS_PATH + "/{id}"}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getBlueprintById(@PathVariable("id") String id, HttpServletRequest request)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.getBlueprint(id);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("getBlueprintById failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Gets the specified blueprint content for viewing.
-     *
-     * @param id
-     *            Blueprint ID
-     * @param request
-     *            HttpServletRequest
-     * @return Blueprint as YAML; or error.
-     * @throws JsonProcessingException
-     *             on serialization error
-     *
-     */
-    @RequestMapping(value = {
-        VIEW_BLUEPRINTS_PATH + "/{id}"}, method = RequestMethod.GET, produces = "application/yaml")
-    @ResponseBody
-    public String viewBlueprintContentById(@PathVariable("id") String id, HttpServletRequest request)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.viewBlueprint(id);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("getBlueprintContentById failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Processes request to upload a blueprint from a remote server.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @param blueprint
-     *            Cloudify blueprint
-     * @return Blueprint as uploaded; or error.
-     * @throws JsonProcessingException
-     *             on serialization error
-     */
-    @RequestMapping(value = {BLUEPRINTS_PATH}, method = RequestMethod.POST, produces = "application/json")
-    @ResponseBody
-    public String uploadBlueprint(HttpServletRequest request, @RequestBody CloudifyBlueprintUpload blueprint)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.uploadBlueprint(blueprint);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("uploadBlueprint failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Deletes the specified blueprint.
-     *
-     * @param id
-     *            Blueprint ID
-     * @param request
-     *            HttpServletRequest
-     * @param response
-     *            HttpServletResponse
-     * @return No content on success; error on failure.
-     * @throws JsonProcessingException
-     *             On serialization failure
-     */
-    @RequestMapping(value = {BLUEPRINTS_PATH + "/{id}"}, method = RequestMethod.DELETE, produces = "application/json")
-    @ResponseBody
-    public String deleteBlueprint(@PathVariable("id") String id, HttpServletRequest request,
-        HttpServletResponse response) throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            int code = restClient.deleteBlueprint(id);
-            response.setStatus(code);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("deleteBlueprint failed on ID " + id, t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        if (result == null) {
-            return null;
-        } else {
-            return objectMapper.writeValueAsString(result);
-        }
-    }
-
-    /**
-     * Gets the specified deployment.
-     *
-     * @param id
-     *            Deployment ID
-     * @param request
-     *            HttpServletRequest
-     * @return Deployment for the specified ID; error on failure.
-     * @throws JsonProcessingException
-     *             On serialization failure
-     *
-     */
-    @RequestMapping(value = {DEPLOYMENTS_PATH + "/{id}"}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getDeploymentById(@PathVariable("id") String id, HttpServletRequest request)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.getDeployment(id);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("getDeploymentById failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Processes request to create a deployment based on a blueprint.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @param deployment
-     *            Deployment to upload
-     * @return Body of deployment; error on failure
-     * @throws JsonProcessingException
-     *             On serialization failure
-     */
-    @RequestMapping(value = {DEPLOYMENTS_PATH}, method = RequestMethod.POST, produces = "application/json")
-    @ResponseBody
-    public String createDeployment(HttpServletRequest request, @RequestBody CloudifyDeploymentRequest deployment)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.createDeployment(deployment);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("createDeployment failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Deletes the specified deployment.
-     *
-     * @param id
-     *            Deployment ID
-     * @param ignoreLiveNodes
-     *            Boolean indicator whether to force a delete in case of live
-     *            nodes
-     * @param request
-     *            HttpServletRequest
-     * @param response
-     *            HttpServletResponse
-     * @return Passes through HTTP status code from remote endpoint; no body on
-     *         success
-     * @throws JsonProcessingException
-     *             on serialization failure
-     */
-    @RequestMapping(value = {
-        DEPLOYMENTS_PATH + "/{id}"}, method = RequestMethod.DELETE, produces = "application/json")
-    @ResponseBody
-    public String deleteDeployment(@PathVariable("id") String id,
-        @RequestParam(value = "ignore_live_nodes", required = false) Boolean ignoreLiveNodes,
-        HttpServletRequest request, HttpServletResponse response) throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            int code = restClient.deleteDeployment(id, ignoreLiveNodes == null ? false : ignoreLiveNodes);
-            response.setStatus(code);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("deleteDeployment failed on ID " + id, t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        if (result == null) {
-            return null;
-        } else {
-            return objectMapper.writeValueAsString(result);
-        }
-    }
-
-    /**
-     * Gets and serves one page of executions:
-     * <OL>
-     * <LI>Gets all deployments; OR uses the specified deployment ID if the
-     * query parameter is present
-     * <LI>Gets executions for each deployment ID
-     * <LI>Sorts by execution ID
-     * <LI>Reduces the list to the page size (if needed)
-     * <LI>If the optional request parameter "status" is present, reduces the
-     * list to the executions with that status.
-     * </OL>
-     *
-     * @param request
-     *            HttpServletRequest
-     * @param deployment_id
-     *            Optional request parameter; if found, only executions for that
-     *            deployment ID are returned.
-     * @param status
-     *            Optional request parameter; if found, only executions with
-     *            that status are returned.
-     * @return List of CloudifyExecution objects
-     * @throws JsonProcessingException
-     *             on serialization failure
-     */
-    @SuppressWarnings("unchecked")
-    @RequestMapping(value = {EXECUTIONS_PATH}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getExecutionsByPage(HttpServletRequest request,
-        @RequestParam(value = "deployment_id", required = false) String deployment_id,
-        @RequestParam(value = "status", required = false) String status) throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            List<CloudifyExecution> itemList = new ArrayList<>();
-            IControllerRestClient restClient = getControllerRestClient(request);
-            List<String> depIds = new ArrayList<>();
-            if (deployment_id == null) {
-                CloudifyDeploymentList depList = restClient.getDeployments();
-                for (CloudifyDeployment cd : depList.items) {
-                    depIds.add(cd.id);
-                }
-            } else {
-                depIds.add(deployment_id);
-            }
-            for (String depId : depIds) {
-                CloudifyExecutionList exeList = restClient.getExecutions(depId);
-                itemList.addAll(exeList.items);
-            }
-            // Filter down to specified status as needed
-            if (status != null) {
-                itemList.removeIf(ce -> !status.equals(ce.status));
-            }
-            itemList.sort(executionComparator);
-
-            // Paginate
-            final int pageNum = getRequestPageNumber(request);
-            final int pageSize = getRequestPageSize(request);
-            final int totalItems = itemList.size();
-            final int pageCount = (int) Math.ceil((double) totalItems / pageSize);
-            // Shrink if needed
-            if (totalItems > pageSize) {
-                itemList = getPageOfList(pageNum, pageSize, itemList);
-            }
-            result = new RestResponsePage<>(totalItems, pageCount, itemList);
-        } catch (Exception t) {
-            result = new RestResponseError("getExecutionsByPage failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Gets the specified execution for one deployment.
-     *
-     * It's not clear why the deployment ID is needed.
-     *
-     * @param execution_id
-     *            Execution ID (path variable)
-     * @param deployment_id
-     *            Deployment ID (query parameter)
-     * @param request
-     *            HttpServletRequest
-     * @return CloudifyExecutionList
-     * @throws JsonProcessingException
-     *             on serialization failure
-     */
-    @RequestMapping(value = {EXECUTIONS_PATH + "/{id}"}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getExecutionByIdAndDeploymentId(@PathVariable("id") String execution_id,
-        @RequestParam("deployment_id") String deployment_id, HttpServletRequest request)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.getExecutions(deployment_id);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("getExecutionByIdAndDeploymentId failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Processes request to create an execution based on a deployment.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @param execution
-     *            Execution model
-     * @return Information about the execution
-     * @throws JsonProcessingException
-     *             on serialization failure
-     */
-    @RequestMapping(value = {EXECUTIONS_PATH}, method = RequestMethod.POST, produces = "application/json")
-    @ResponseBody
-    public String startExecution(HttpServletRequest request, @RequestBody CloudifyExecutionRequest execution)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.startExecution(execution);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("startExecution failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Cancels an execution.
-     *
-     * @param id
-     *            Execution ID
-     * @param deploymentId
-     *            Deployment ID (not clear why this is needed)
-     * @param action
-     *            Action to perform (not clear why this is needed)
-     * @param request
-     *            HttpServletRequest
-     * @param response
-     *            HttpServletRequest
-     * @return Passes through HTTP status code from remote endpoint; no body on success
-     * @throws JsonProcessingException
-     *             on serialization failure
-     */
-    @RequestMapping(value = {EXECUTIONS_PATH + "/{id}"}, method = RequestMethod.DELETE, produces = "application/json")
-    @ResponseBody
-    public String cancelExecution(@PathVariable("id") String id,
-        @RequestParam(value = "deployment_id") String deploymentId, @RequestParam(value = "action") String action,
-        HttpServletRequest request, HttpServletResponse response) throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            int code = restClient.cancelExecution(id, deploymentId, action);
-            response.setStatus(code);
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("cancelExecution failed on ID " + id, t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        if (result == null) {
-            return null;
-        } else {
-            return objectMapper.writeValueAsString(result);
-        }
-    }
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.controller;\r
+\r
+import com.fasterxml.jackson.core.JsonProcessingException;\r
+import java.util.ArrayList;\r
+import java.util.Comparator;\r
+import java.util.Date;\r
+import java.util.List;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.onap.ccsdk.dashboard.model.CloudifyDeploymentList;\r
+import org.onap.ccsdk.dashboard.model.CloudifyExecutionRequest;\r
+import org.onap.ccsdk.dashboard.exception.DashboardControllerException;\r
+import org.onap.ccsdk.dashboard.model.CloudifyBlueprint;\r
+import org.onap.ccsdk.dashboard.model.CloudifyBlueprintUpload;\r
+import org.onap.ccsdk.dashboard.model.CloudifyDeployment;\r
+import org.onap.ccsdk.dashboard.model.CloudifyDeploymentRequest;\r
+import org.onap.ccsdk.dashboard.model.CloudifyExecution;\r
+import org.onap.ccsdk.dashboard.model.CloudifyExecutionList;\r
+import org.onap.ccsdk.dashboard.model.ECTransportModel;\r
+import org.onap.ccsdk.dashboard.model.RestResponseError;\r
+import org.onap.ccsdk.dashboard.model.RestResponsePage;\r
+import org.onap.ccsdk.dashboard.rest.IControllerRestClient;\r
+import org.onap.portalsdk.core.domain.User;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.onap.portalsdk.core.util.SystemProperties;\r
+import org.onap.portalsdk.core.web.support.UserUtils;\r
+import org.slf4j.MDC;\r
+import org.springframework.stereotype.Controller;\r
+import org.springframework.web.bind.annotation.PathVariable;\r
+import org.springframework.web.bind.annotation.RequestBody;\r
+import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.bind.annotation.RequestMethod;\r
+import org.springframework.web.bind.annotation.RequestParam;\r
+import org.springframework.web.bind.annotation.ResponseBody;\r
+import org.springframework.web.client.HttpStatusCodeException;\r
+\r
+/**\r
+ * Controller for Cloudify features: blueprints, deployments, executions.\r
+ * Methods serve Ajax requests made by Angular scripts on pages that show\r
+ * content.\r
+ */\r
+@Controller\r
+@RequestMapping("/")\r
+public class CloudifyController extends DashboardRestrictedBaseController {\r
+\r
+    private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(CloudifyController.class);\r
+\r
+    /**\r
+     * Enum for selecting an item type.\r
+     */\r
+    public enum CloudifyDataItem {\r
+        BLUEPRINT, DEPLOYMENT, EXECUTION;\r
+    }\r
+\r
+    private static final String BLUEPRINTS_PATH = "blueprints";\r
+    private static final String VIEW_BLUEPRINTS_PATH = "viewblueprints";\r
+    private static final String DEPLOYMENTS_PATH = "deployments";\r
+    private static final String EXECUTIONS_PATH = "executions";\r
+\r
+    /**\r
+     * Supports sorting blueprints by ID\r
+     */\r
+    private static Comparator<CloudifyBlueprint> blueprintComparator = Comparator.comparing(o -> o.id);\r
+\r
+    /**\r
+     * Supports sorting deployments by ID\r
+     */\r
+    private static Comparator<CloudifyDeployment> deploymentComparator = Comparator.comparing(o -> o.id);\r
+\r
+    /**\r
+     * Supports sorting executions by ID\r
+     */\r
+    private static Comparator<CloudifyExecution> executionComparator = Comparator.comparing(o -> o.id);\r
+\r
+    /**\r
+     * Gets one page of objects and supporting information via the REST client.\r
+     * On success, returns a PaginatedRestResponse object as String.\r
+     *\r
+     * @param option\r
+     *            Specifies which item list type to get\r
+     * @param pageNum\r
+     *            Page number of results\r
+     * @param pageSize\r
+     *            Number of items per browser page\r
+     * @return JSON block as String, see above.\r
+     * @throws DashboardControllerException\r
+     *             On any error; e.g., Network failure.\r
+     */\r
+    @SuppressWarnings({"rawtypes", "unchecked"})\r
+    private String getItemListForPage(long userId, CloudifyDataItem option, int pageNum, int pageSize)\r
+        throws DashboardControllerException, JsonProcessingException {\r
+        IControllerRestClient restClient = getControllerRestClient(userId);\r
+        List itemList;\r
+        switch (option) {\r
+            case BLUEPRINT:\r
+                itemList = restClient.getBlueprints().items;\r
+                itemList.sort(blueprintComparator);\r
+                break;\r
+            case DEPLOYMENT:\r
+                itemList = restClient.getDeployments().items;\r
+                itemList.sort(deploymentComparator);\r
+                break;\r
+            default:\r
+                throw new DashboardControllerException(\r
+                    "getItemListForPage failed: unimplemented case: " + option.name());\r
+        }\r
+\r
+        // Shrink if needed\r
+        final int totalItems = itemList.size();\r
+        final int pageCount = (int) Math.ceil((double) totalItems / pageSize);\r
+        if (totalItems > pageSize) {\r
+            itemList = getPageOfList(pageNum, pageSize, itemList);\r
+        }\r
+        RestResponsePage<List> model = new RestResponsePage<>(totalItems, pageCount, itemList);\r
+        return objectMapper.writeValueAsString(model);\r
+    }\r
+\r
+    /**\r
+     * Gets one page of the specified items. This method traps exceptions and\r
+     * constructs an appropriate JSON block to report errors.\r
+     *\r
+     * @param request\r
+     *            Inbound request\r
+     * @param option\r
+     *            Item type to get\r
+     * @return JSON with one page of objects; or an error.\r
+     */\r
+    protected String getItemListForPageWrapper(HttpServletRequest request, CloudifyDataItem option) {\r
+        String outboundJson = null;\r
+        try {\r
+            User appUser = UserUtils.getUserSession(request);\r
+            if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0) {\r
+                throw new DashboardControllerException("getItemListForPageWrapper: Failed to get application user");\r
+            }\r
+            int pageNum = getRequestPageNumber(request);\r
+            int pageSize = getRequestPageSize(request);\r
+            outboundJson = getItemListForPage(appUser.getId(), option, pageNum, pageSize);\r
+        } catch (Exception ex) {\r
+            logger.error(EELFLoggerDelegate.errorLogger, "getItemListForPageWrapper caught exception", ex);\r
+            RestResponseError result;\r
+            if (ex instanceof HttpStatusCodeException) {\r
+                result = new RestResponseError(((HttpStatusCodeException) ex).getResponseBodyAsString());\r
+            } else {\r
+                result = new RestResponseError("Failed to get " + option.name(), ex);\r
+            }\r
+            try {\r
+                outboundJson = objectMapper.writeValueAsString(result);\r
+            } catch (JsonProcessingException jpe) {\r
+                // Should never, ever happen\r
+                outboundJson = "{ \"error\" : \"" + jpe.toString() + "\"}";\r
+            }\r
+        }\r
+        return outboundJson;\r
+    }\r
+\r
+    /**\r
+     * Serves one page of blueprints\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return List of CloudifyBlueprint objects\r
+     */\r
+    @RequestMapping(value = {BLUEPRINTS_PATH}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getBlueprintsByPage(HttpServletRequest request) {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        String json = getItemListForPageWrapper(request, CloudifyDataItem.BLUEPRINT);\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return json;\r
+    }\r
+\r
+    /**\r
+     * Serves one page of deployments\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return List of CloudifyDeployment objects\r
+     */\r
+    @RequestMapping(value = {DEPLOYMENTS_PATH}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getDeploymentsByPage(HttpServletRequest request) {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        String json = getItemListForPageWrapper(request, CloudifyDataItem.DEPLOYMENT);\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return json;\r
+    }\r
+\r
+    /**\r
+     * Gets the specified blueprint metadata.\r
+     *\r
+     * @param id\r
+     *            Blueprint ID\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return Blueprint as JSON; or error.\r
+     * @throws JsonProcessingException\r
+     *             on serialization error\r
+     *\r
+     */\r
+    @RequestMapping(value = {BLUEPRINTS_PATH + "/{id}"}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getBlueprintById(@PathVariable("id") String id, HttpServletRequest request)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.getBlueprint(id);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("getBlueprintById failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Gets the specified blueprint content for viewing.\r
+     *\r
+     * @param id\r
+     *            Blueprint ID\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return Blueprint as YAML; or error.\r
+     * @throws JsonProcessingException\r
+     *             on serialization error\r
+     *\r
+     */\r
+    @RequestMapping(value = {\r
+        VIEW_BLUEPRINTS_PATH + "/{id}"}, method = RequestMethod.GET, produces = "application/yaml")\r
+    @ResponseBody\r
+    public String viewBlueprintContentById(@PathVariable("id") String id, HttpServletRequest request)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.viewBlueprint(id);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("getBlueprintContentById failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Processes request to upload a blueprint from a remote server.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param blueprint\r
+     *            Cloudify blueprint\r
+     * @return Blueprint as uploaded; or error.\r
+     * @throws JsonProcessingException\r
+     *             on serialization error\r
+     */\r
+    @RequestMapping(value = {BLUEPRINTS_PATH}, method = RequestMethod.POST, produces = "application/json")\r
+    @ResponseBody\r
+    public String uploadBlueprint(HttpServletRequest request, @RequestBody CloudifyBlueprintUpload blueprint)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.uploadBlueprint(blueprint);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("uploadBlueprint failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Deletes the specified blueprint.\r
+     *\r
+     * @param id\r
+     *            Blueprint ID\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param response\r
+     *            HttpServletResponse\r
+     * @return No content on success; error on failure.\r
+     * @throws JsonProcessingException\r
+     *             On serialization failure\r
+     */\r
+    @RequestMapping(value = {BLUEPRINTS_PATH + "/{id}"}, method = RequestMethod.DELETE, produces = "application/json")\r
+    @ResponseBody\r
+    public String deleteBlueprint(@PathVariable("id") String id, HttpServletRequest request,\r
+        HttpServletResponse response) throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            int code = restClient.deleteBlueprint(id);\r
+            response.setStatus(code);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("deleteBlueprint failed on ID " + id, t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        if (result == null) {\r
+            return null;\r
+        } else {\r
+            return objectMapper.writeValueAsString(result);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Gets the specified deployment.\r
+     *\r
+     * @param id\r
+     *            Deployment ID\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return Deployment for the specified ID; error on failure.\r
+     * @throws JsonProcessingException\r
+     *             On serialization failure\r
+     *\r
+     */\r
+    @RequestMapping(value = {DEPLOYMENTS_PATH + "/{id}"}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getDeploymentById(@PathVariable("id") String id, HttpServletRequest request)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.getDeployment(id);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("getDeploymentById failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Processes request to create a deployment based on a blueprint.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param deployment\r
+     *            Deployment to upload\r
+     * @return Body of deployment; error on failure\r
+     * @throws JsonProcessingException\r
+     *             On serialization failure\r
+     */\r
+    @RequestMapping(value = {DEPLOYMENTS_PATH}, method = RequestMethod.POST, produces = "application/json")\r
+    @ResponseBody\r
+    public String createDeployment(HttpServletRequest request, @RequestBody CloudifyDeploymentRequest deployment)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.createDeployment(deployment);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("createDeployment failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Deletes the specified deployment.\r
+     *\r
+     * @param id\r
+     *            Deployment ID\r
+     * @param ignoreLiveNodes\r
+     *            Boolean indicator whether to force a delete in case of live\r
+     *            nodes\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param response\r
+     *            HttpServletResponse\r
+     * @return Passes through HTTP status code from remote endpoint; no body on\r
+     *         success\r
+     * @throws JsonProcessingException\r
+     *             on serialization failure\r
+     */\r
+    @RequestMapping(value = {\r
+        DEPLOYMENTS_PATH + "/{id}"}, method = RequestMethod.DELETE, produces = "application/json")\r
+    @ResponseBody\r
+    public String deleteDeployment(@PathVariable("id") String id,\r
+        @RequestParam(value = "ignore_live_nodes", required = false) Boolean ignoreLiveNodes,\r
+        HttpServletRequest request, HttpServletResponse response) throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            int code = restClient.deleteDeployment(id, ignoreLiveNodes == null ? false : ignoreLiveNodes);\r
+            response.setStatus(code);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("deleteDeployment failed on ID " + id, t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        if (result == null) {\r
+            return null;\r
+        } else {\r
+            return objectMapper.writeValueAsString(result);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Gets and serves one page of executions:\r
+     * <OL>\r
+     * <LI>Gets all deployments; OR uses the specified deployment ID if the\r
+     * query parameter is present\r
+     * <LI>Gets executions for each deployment ID\r
+     * <LI>Sorts by execution ID\r
+     * <LI>Reduces the list to the page size (if needed)\r
+     * <LI>If the optional request parameter "status" is present, reduces the\r
+     * list to the executions with that status.\r
+     * </OL>\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param deployment_id\r
+     *            Optional request parameter; if found, only executions for that\r
+     *            deployment ID are returned.\r
+     * @param status\r
+     *            Optional request parameter; if found, only executions with\r
+     *            that status are returned.\r
+     * @return List of CloudifyExecution objects\r
+     * @throws JsonProcessingException\r
+     *             on serialization failure\r
+     */\r
+    @SuppressWarnings("unchecked")\r
+    @RequestMapping(value = {EXECUTIONS_PATH}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getExecutionsByPage(HttpServletRequest request,\r
+        @RequestParam(value = "deployment_id", required = false) String deployment_id,\r
+        @RequestParam(value = "status", required = false) String status) throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            List<CloudifyExecution> itemList = new ArrayList<>();\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            List<String> depIds = new ArrayList<>();\r
+            if (deployment_id == null) {\r
+                CloudifyDeploymentList depList = restClient.getDeployments();\r
+                for (CloudifyDeployment cd : depList.items) {\r
+                    depIds.add(cd.id);\r
+                }\r
+            } else {\r
+                depIds.add(deployment_id);\r
+            }\r
+            for (String depId : depIds) {\r
+                CloudifyExecutionList exeList = restClient.getExecutions(depId);\r
+                itemList.addAll(exeList.items);\r
+            }\r
+            // Filter down to specified status as needed\r
+            if (status != null) {\r
+                itemList.removeIf(ce -> !status.equals(ce.status));\r
+            }\r
+            itemList.sort(executionComparator);\r
+\r
+            // Paginate\r
+            final int pageNum = getRequestPageNumber(request);\r
+            final int pageSize = getRequestPageSize(request);\r
+            final int totalItems = itemList.size();\r
+            final int pageCount = (int) Math.ceil((double) totalItems / pageSize);\r
+            // Shrink if needed\r
+            if (totalItems > pageSize) {\r
+                itemList = getPageOfList(pageNum, pageSize, itemList);\r
+            }\r
+            result = new RestResponsePage<>(totalItems, pageCount, itemList);\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("getExecutionsByPage failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Gets the specified execution for one deployment.\r
+     *\r
+     * It's not clear why the deployment ID is needed.\r
+     *\r
+     * @param execution_id\r
+     *            Execution ID (path variable)\r
+     * @param deployment_id\r
+     *            Deployment ID (query parameter)\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return CloudifyExecutionList\r
+     * @throws JsonProcessingException\r
+     *             on serialization failure\r
+     */\r
+    @RequestMapping(value = {EXECUTIONS_PATH + "/{id}"}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getExecutionByIdAndDeploymentId(@PathVariable("id") String execution_id,\r
+        @RequestParam("deployment_id") String deployment_id, HttpServletRequest request)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.getExecutions(deployment_id);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("getExecutionByIdAndDeploymentId failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Processes request to create an execution based on a deployment.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param execution\r
+     *            Execution model\r
+     * @return Information about the execution\r
+     * @throws JsonProcessingException\r
+     *             on serialization failure\r
+     */\r
+    @RequestMapping(value = {EXECUTIONS_PATH}, method = RequestMethod.POST, produces = "application/json")\r
+    @ResponseBody\r
+    public String startExecution(HttpServletRequest request, @RequestBody CloudifyExecutionRequest execution)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.startExecution(execution);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("startExecution failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Cancels an execution.\r
+     *\r
+     * @param id\r
+     *            Execution ID\r
+     * @param deploymentId\r
+     *            Deployment ID (not clear why this is needed)\r
+     * @param action\r
+     *            Action to perform (not clear why this is needed)\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param response\r
+     *            HttpServletRequest\r
+     * @return Passes through HTTP status code from remote endpoint; no body on success\r
+     * @throws JsonProcessingException\r
+     *             on serialization failure\r
+     */\r
+    @RequestMapping(value = {EXECUTIONS_PATH + "/{id}"}, method = RequestMethod.DELETE, produces = "application/json")\r
+    @ResponseBody\r
+    public String cancelExecution(@PathVariable("id") String id,\r
+        @RequestParam(value = "deployment_id") String deploymentId, @RequestParam(value = "action") String action,\r
+        HttpServletRequest request, HttpServletResponse response) throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            int code = restClient.cancelExecution(id, deploymentId, action);\r
+            response.setStatus(code);\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("cancelExecution failed on ID " + id, t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        if (result == null) {\r
+            return null;\r
+        } else {\r
+            return objectMapper.writeValueAsString(result);\r
+        }\r
+    }\r
+}\r
index 9f22456..8350737 100644 (file)
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.controller;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import java.net.URI;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import javax.servlet.http.HttpServletRequest;
-
-import org.onap.ccsdk.dashboard.model.ConsulHealthServiceRegistration;
-import org.onap.ccsdk.dashboard.model.ConsulNodeInfo;
-import org.onap.ccsdk.dashboard.model.ConsulServiceHealth;
-import org.onap.ccsdk.dashboard.model.RestResponsePage;
-import org.onap.ccsdk.dashboard.rest.IControllerRestClient;
-import org.onap.ccsdk.dashboard.exception.DashboardControllerException;
-import org.onap.ccsdk.dashboard.model.ConsulServiceInfo;
-import org.onap.ccsdk.dashboard.model.ECTransportModel;
-import org.onap.ccsdk.dashboard.model.RestResponseError;
-import org.onap.ccsdk.dashboard.model.RestResponseSuccess;
-import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
-import org.slf4j.MDC;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-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.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.client.HttpStatusCodeException;
-
-/**
- * Controller for Consul features: health checks of services, nodes, data
- * centers. Methods serve Ajax requests made by Angular scripts on pages that
- * show content.
- */
-@Controller
-@RequestMapping("/healthservices")
-public class ConsulController extends DashboardRestrictedBaseController {
-
-    private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ConsulController.class);
-
-    /**
-     * Enum for selecting an item type.
-     */
-    public enum ConsulDataItem {
-        SERVICE_INFO, SERVICE_HEALTH, NODES, DATACENTERS;
-    }
-
-    private static final String NODES_PATH = "/nodes";
-    private static final String SERVICES_PATH = "/services";
-
-    /**
-     * Supports sorting results by node name
-     */
-    private static Comparator<ConsulNodeInfo> nodeHealthComparator = Comparator.comparing(o -> o.node);
-
-    /**
-     * Supports sorting results by service name
-     */
-    private static Comparator<ConsulServiceHealth> serviceHealthComparator = Comparator.comparing(o -> o.serviceName);
-
-    /**
-     * Supports sorting results by service name
-     */
-    private static Comparator<ConsulServiceInfo> serviceInfoComparator = Comparator.comparing(o -> o.name);
-
-    /**
-     * Gets one page of objects and supporting information via the REST client. On
-     * success, returns a page of objects as String.
-     *
-     * @param option
-     *            Specifies which item type to get
-     * @param pageNum
-     *            Page number of results
-     * @param pageSize
-     *            Number of items per browser page
-     * @return JSON block as String, see above.
-     * @throws DashboardControllerException,
-     *             JsonProcessingException On any error; e.g., Network failure.
-     */
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    private String getItemListForPage(long userId, ConsulDataItem option, int pageNum, int pageSize)
-        throws DashboardControllerException, JsonProcessingException {
-        IControllerRestClient restClient = getControllerRestClient(userId);
-        List itemList;
-        switch (option) {
-            case NODES:
-                itemList = restClient.getNodes();
-                itemList.sort(nodeHealthComparator);
-                break;
-            case DATACENTERS:
-                itemList = restClient.getDatacenters();
-                break;
-            default:
-                throw new DashboardControllerException(
-                    "getItemListForPage failed: unimplemented case: " + option.name());
-        }
-
-        // Shrink if needed
-        if (itemList.size() > pageSize) {
-            itemList = getPageOfList(pageNum, pageSize, itemList);
-        }
-        int pageCount = (int) Math.ceil((double) itemList.size() / pageSize);
-        RestResponsePage<List> model = new RestResponsePage<>(itemList.size(), pageCount, itemList);
-        return objectMapper.writeValueAsString(model);
-    }
-
-    /**
-     * Gets one page of the specified items. This method traps exceptions and
-     * constructs an appropriate JSON block to report errors.
-     *
-     * @param request
-     *            Inbound request
-     * @param option
-     *            Item type to get
-     * @return JSON with one page of objects; or an error.
-     */
-    protected String getItemListForPageWrapper(HttpServletRequest request, ConsulDataItem option) {
-        String outboundJson;
-        try {
-            User appUser = UserUtils.getUserSession(request);
-            if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0) {
-                throw new DashboardControllerException("getItemListForPageWrapper: Failed to get application user");
-            }
-            int pageNum = getRequestPageNumber(request);
-            int pageSize = getRequestPageSize(request);
-            outboundJson = getItemListForPage(appUser.getId(), option, pageNum, pageSize);
-        } catch (Exception ex) {
-            // Remote service failed; build descriptive error message
-            logger.error(EELFLoggerDelegate.errorLogger, "getItemListForPageWrapper caught exception", ex);
-            RestResponseError result = new RestResponseError("Failed to get " + option.name(), ex);
-            try {
-                outboundJson = objectMapper.writeValueAsString(result);
-            } catch (JsonProcessingException jpe) {
-                // Should never, ever happen
-                outboundJson = "{ \"error\" : \"" + jpe.toString() + "\"}";
-            }
-        }
-        return outboundJson;
-    }
-
-    /**
-     * Serves all service details.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @return List of ConsulServiceInfo objects, as JSON
-     * @throws JsonProcessingException
-     *             if serialization fails
-     */
-    @RequestMapping(value = {SERVICES_PATH}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getServices(HttpServletRequest request) throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        Object result;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            List<ConsulServiceInfo> itemList = restClient.getServices();
-            itemList.sort(serviceInfoComparator);
-            result = itemList;
-        } catch (Exception t) {
-            result = new RestResponseError("getServices failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Serves service health details - not paginated.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @param serviceId
-     *            Service ID
-     * @return List of ConsulServiceHealth objects as JSON
-     * @throws JsonProcessingException
-     *             if serialization fails
-     */
-    @RequestMapping(value = {
-        SERVICES_PATH + "/{serviceId}"}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getServiceHealthDetails(HttpServletRequest request, @PathVariable String serviceId)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        Object result;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.getServiceHealth(serviceId);
-        } catch (Exception t) {
-            result = new RestResponseError("getServiceHealthDetails failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Serves service health historical data - not paginated.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @param serviceName
-     *            Service name as path parameter
-     * @param start
-     *            Earliest date-time as an ISO 8061 value, such as
-     *            2007-12-03T10:15:30+01:00
-     * @param end
-     *            Latest date-time as an ISO 8061 value, such as
-     *            2007-12-03T10:15:30+01:00
-     * @return List of ConsulServiceHealth objects as JSON
-     * @throws JsonProcessingException
-     *             if serialization fails
-     */
-    @RequestMapping(value = {"/svchist/{serviceName}"}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getServiceHealthHistory(HttpServletRequest request, //
-        @PathVariable String serviceName, //
-        @RequestParam String start, //
-        @RequestParam String end) throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        Object result = null;
-        try {
-            Instant startDateTime = Instant.parse(start);
-            Instant endDateTime = Instant.parse(end);
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.getServiceHealthHistory(serviceName, startDateTime, endDateTime);
-        } catch (HttpStatusCodeException e) {
-            // Rare, but can happen
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            // Work around the hack to report no-match.
-            result = new RestResponseError("getServiceHealthHistory failed: " + t.getMessage());
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Serves one page of service health information by getting all service names,
-     * then iterating over them to get the health of each service.
-     *
-     * ECOMP-C does NOT provide an API to get the health of all services in one
-     * request.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @return List of ConsulServiceHealth objects, as JSON
-     * @throws JsonProcessingException
-     *             on serialization exception
-     */
-    @SuppressWarnings("unchecked")
-    @RequestMapping(value = {"/serviceshealth"}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getServicesHealth(HttpServletRequest request) throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            List<ConsulServiceHealth> itemList = new ArrayList<>();
-            IControllerRestClient restClient = getControllerRestClient(request);
-            List<ConsulServiceInfo> svcInfoList = restClient.getServices();
-            for (ConsulServiceInfo csi : svcInfoList) {
-                List<ConsulServiceHealth> csh = restClient.getServiceHealth(csi.name);
-                itemList.addAll(csh);
-            }
-            itemList.sort(serviceHealthComparator);
-            // Paginate
-            final int pageNum = getRequestPageNumber(request);
-            final int pageSize = getRequestPageSize(request);
-            final int totalItems = itemList.size();
-            final int pageCount = (int) Math.ceil((double) totalItems / pageSize);
-            // Shrink if needed
-            if (totalItems > pageSize) {
-                itemList = getPageOfList(pageNum, pageSize, itemList);
-            }
-            result = new RestResponsePage<>(totalItems, pageCount, itemList);
-        } catch (Exception t) {
-            result = new RestResponseError("getServicesHealth failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Serves one page of node information.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @return List of ConsulNodeInfo objects, as JSON
-     */
-    @RequestMapping(value = {NODES_PATH}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getNodesInfo(HttpServletRequest request) {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        String json = getItemListForPageWrapper(request, ConsulDataItem.NODES);
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return json;
-    }
-
-    /**
-     * Serves node services health details - not paginated.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @param nodeName
-     *            Node name
-     * @return List of ConsulServiceHealth objects as JSON
-     * @throws JsonProcessingException
-     *             if serialization fails
-     */
-    @RequestMapping(value = {NODES_PATH + "/{nodeName}"}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getNodeServicesHealth(HttpServletRequest request, @PathVariable String nodeName)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        Object result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            result = restClient.getNodeServicesHealth(nodeName);
-        } catch (Exception t) {
-            result = new RestResponseError("getNodeServicesHealth failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Serves one page of data centers health.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @return List of ConsulHealthStatus objects
-     */
-    @RequestMapping(value = {"/datacenters"}, method = RequestMethod.GET, produces = "application/json")
-    @ResponseBody
-    public String getDatacentersHealth(HttpServletRequest request) {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        String json = getItemListForPageWrapper(request, ConsulDataItem.DATACENTERS);
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return json;
-    }
-
-    /**
-     * Processes request to register a service for health checks.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @param registration
-     *            Consul service registration
-     * @return URI of the newly registered resource
-     * @throws JsonProcessingException
-     *             on serialization error
-     */
-    @RequestMapping(value = {"/register"}, method = RequestMethod.POST, produces = "application/json")
-    @ResponseBody
-    public String registerService(HttpServletRequest request, @RequestBody ConsulHealthServiceRegistration registration)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            URI uri = restClient.registerService(registration);
-            result = new RestResponseSuccess(uri.toString());
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("registerService failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-
-    /**
-     * Processes request to deregister a service for health checks.
-     *
-     * @param request
-     *            HttpServletRequest
-     * @param serviceName
-     *            Consul service name to deregister
-     * @return Success or error indicator
-     * @throws JsonProcessingException
-     *             on serialization error
-     */
-    @RequestMapping(value = {
-        "/deregister" + "/{serviceName}"}, method = RequestMethod.POST, produces = "application/json")
-    @ResponseBody
-    public String deregisterService(HttpServletRequest request, @PathVariable String serviceName)
-        throws JsonProcessingException {
-        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-        ECTransportModel result = null;
-        try {
-            IControllerRestClient restClient = getControllerRestClient(request);
-            int code = restClient.deregisterService(serviceName);
-            result = new RestResponseSuccess("Deregistration yielded code " + Integer.toString(code));
-        } catch (HttpStatusCodeException e) {
-            result = new RestResponseError(e.getResponseBodyAsString());
-        } catch (Exception t) {
-            result = new RestResponseError("deregisterService failed", t);
-        }
-        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));
-        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-        return objectMapper.writeValueAsString(result);
-    }
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.controller;\r
+\r
+import com.fasterxml.jackson.core.JsonProcessingException;\r
+import java.net.URI;\r
+import java.time.Instant;\r
+import java.util.ArrayList;\r
+import java.util.Comparator;\r
+import java.util.Date;\r
+import java.util.List;\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+import org.onap.ccsdk.dashboard.model.ConsulHealthServiceRegistration;\r
+import org.onap.ccsdk.dashboard.model.ConsulNodeInfo;\r
+import org.onap.ccsdk.dashboard.model.ConsulServiceHealth;\r
+import org.onap.ccsdk.dashboard.model.RestResponsePage;\r
+import org.onap.ccsdk.dashboard.rest.IControllerRestClient;\r
+import org.onap.ccsdk.dashboard.exception.DashboardControllerException;\r
+import org.onap.ccsdk.dashboard.model.ConsulServiceInfo;\r
+import org.onap.ccsdk.dashboard.model.ECTransportModel;\r
+import org.onap.ccsdk.dashboard.model.RestResponseError;\r
+import org.onap.ccsdk.dashboard.model.RestResponseSuccess;\r
+import org.onap.portalsdk.core.domain.User;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.onap.portalsdk.core.util.SystemProperties;\r
+import org.onap.portalsdk.core.web.support.UserUtils;\r
+import org.slf4j.MDC;\r
+import org.springframework.stereotype.Controller;\r
+import org.springframework.web.bind.annotation.PathVariable;\r
+import org.springframework.web.bind.annotation.RequestBody;\r
+import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.bind.annotation.RequestMethod;\r
+import org.springframework.web.bind.annotation.RequestParam;\r
+import org.springframework.web.bind.annotation.ResponseBody;\r
+import org.springframework.web.client.HttpStatusCodeException;\r
+\r
+/**\r
+ * Controller for Consul features: health checks of services, nodes, data\r
+ * centers. Methods serve Ajax requests made by Angular scripts on pages that\r
+ * show content.\r
+ */\r
+@Controller\r
+@RequestMapping("/healthservices")\r
+public class ConsulController extends DashboardRestrictedBaseController {\r
+\r
+    private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ConsulController.class);\r
+\r
+    /**\r
+     * Enum for selecting an item type.\r
+     */\r
+    public enum ConsulDataItem {\r
+        SERVICE_INFO, SERVICE_HEALTH, NODES, DATACENTERS;\r
+    }\r
+\r
+    private static final String NODES_PATH = "/nodes";\r
+    private static final String SERVICES_PATH = "/services";\r
+\r
+    /**\r
+     * Supports sorting results by node name\r
+     */\r
+    private static Comparator<ConsulNodeInfo> nodeHealthComparator = Comparator.comparing(o -> o.node);\r
+\r
+    /**\r
+     * Supports sorting results by service name\r
+     */\r
+    private static Comparator<ConsulServiceHealth> serviceHealthComparator = Comparator.comparing(o -> o.serviceName);\r
+\r
+    /**\r
+     * Supports sorting results by service name\r
+     */\r
+    private static Comparator<ConsulServiceInfo> serviceInfoComparator = Comparator.comparing(o -> o.name);\r
+\r
+    /**\r
+     * Gets one page of objects and supporting information via the REST client. On\r
+     * success, returns a page of objects as String.\r
+     *\r
+     * @param option\r
+     *            Specifies which item type to get\r
+     * @param pageNum\r
+     *            Page number of results\r
+     * @param pageSize\r
+     *            Number of items per browser page\r
+     * @return JSON block as String, see above.\r
+     * @throws DashboardControllerException,\r
+     *             JsonProcessingException On any error; e.g., Network failure.\r
+     */\r
+    @SuppressWarnings({"unchecked", "rawtypes"})\r
+    private String getItemListForPage(long userId, ConsulDataItem option, int pageNum, int pageSize)\r
+        throws DashboardControllerException, JsonProcessingException {\r
+        IControllerRestClient restClient = getControllerRestClient(userId);\r
+        List itemList;\r
+        switch (option) {\r
+            case NODES:\r
+                itemList = restClient.getNodes();\r
+                itemList.sort(nodeHealthComparator);\r
+                break;\r
+            case DATACENTERS:\r
+                itemList = restClient.getDatacenters();\r
+                break;\r
+            default:\r
+                throw new DashboardControllerException(\r
+                    "getItemListForPage failed: unimplemented case: " + option.name());\r
+        }\r
+\r
+        // Shrink if needed\r
+        if (itemList.size() > pageSize) {\r
+            itemList = getPageOfList(pageNum, pageSize, itemList);\r
+        }\r
+        int pageCount = (int) Math.ceil((double) itemList.size() / pageSize);\r
+        RestResponsePage<List> model = new RestResponsePage<>(itemList.size(), pageCount, itemList);\r
+        return objectMapper.writeValueAsString(model);\r
+    }\r
+\r
+    /**\r
+     * Gets one page of the specified items. This method traps exceptions and\r
+     * constructs an appropriate JSON block to report errors.\r
+     *\r
+     * @param request\r
+     *            Inbound request\r
+     * @param option\r
+     *            Item type to get\r
+     * @return JSON with one page of objects; or an error.\r
+     */\r
+    protected String getItemListForPageWrapper(HttpServletRequest request, ConsulDataItem option) {\r
+        String outboundJson;\r
+        try {\r
+            User appUser = UserUtils.getUserSession(request);\r
+            if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0) {\r
+                throw new DashboardControllerException("getItemListForPageWrapper: Failed to get application user");\r
+            }\r
+            int pageNum = getRequestPageNumber(request);\r
+            int pageSize = getRequestPageSize(request);\r
+            outboundJson = getItemListForPage(appUser.getId(), option, pageNum, pageSize);\r
+        } catch (Exception ex) {\r
+            // Remote service failed; build descriptive error message\r
+            logger.error(EELFLoggerDelegate.errorLogger, "getItemListForPageWrapper caught exception", ex);\r
+            RestResponseError result = new RestResponseError("Failed to get " + option.name(), ex);\r
+            try {\r
+                outboundJson = objectMapper.writeValueAsString(result);\r
+            } catch (JsonProcessingException jpe) {\r
+                // Should never, ever happen\r
+                outboundJson = "{ \"error\" : \"" + jpe.toString() + "\"}";\r
+            }\r
+        }\r
+        return outboundJson;\r
+    }\r
+\r
+    /**\r
+     * Serves all service details.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return List of ConsulServiceInfo objects, as JSON\r
+     * @throws JsonProcessingException\r
+     *             if serialization fails\r
+     */\r
+    @RequestMapping(value = {SERVICES_PATH}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getServices(HttpServletRequest request) throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        Object result;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            List<ConsulServiceInfo> itemList = restClient.getServices();\r
+            itemList.sort(serviceInfoComparator);\r
+            result = itemList;\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("getServices failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Serves service health details - not paginated.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param serviceId\r
+     *            Service ID\r
+     * @return List of ConsulServiceHealth objects as JSON\r
+     * @throws JsonProcessingException\r
+     *             if serialization fails\r
+     */\r
+    @RequestMapping(value = {\r
+        SERVICES_PATH + "/{serviceId}"}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getServiceHealthDetails(HttpServletRequest request, @PathVariable String serviceId)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        Object result;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.getServiceHealth(serviceId);\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("getServiceHealthDetails failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Serves service health historical data - not paginated.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param serviceName\r
+     *            Service name as path parameter\r
+     * @param start\r
+     *            Earliest date-time as an ISO 8061 value, such as\r
+     *            2007-12-03T10:15:30+01:00\r
+     * @param end\r
+     *            Latest date-time as an ISO 8061 value, such as\r
+     *            2007-12-03T10:15:30+01:00\r
+     * @return List of ConsulServiceHealth objects as JSON\r
+     * @throws JsonProcessingException\r
+     *             if serialization fails\r
+     */\r
+    @RequestMapping(value = {"/svchist/{serviceName}"}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getServiceHealthHistory(HttpServletRequest request, //\r
+        @PathVariable String serviceName, //\r
+        @RequestParam String start, //\r
+        @RequestParam String end) throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        Object result = null;\r
+        try {\r
+            Instant startDateTime = Instant.parse(start);\r
+            Instant endDateTime = Instant.parse(end);\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.getServiceHealthHistory(serviceName, startDateTime, endDateTime);\r
+        } catch (HttpStatusCodeException e) {\r
+            // Rare, but can happen\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            // Work around the hack to report no-match.\r
+            result = new RestResponseError("getServiceHealthHistory failed: " + t.getMessage());\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Serves one page of service health information by getting all service names,\r
+     * then iterating over them to get the health of each service.\r
+     *\r
+     * ECOMP-C does NOT provide an API to get the health of all services in one\r
+     * request.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return List of ConsulServiceHealth objects, as JSON\r
+     * @throws JsonProcessingException\r
+     *             on serialization exception\r
+     */\r
+    @SuppressWarnings("unchecked")\r
+    @RequestMapping(value = {"/serviceshealth"}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getServicesHealth(HttpServletRequest request) throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            List<ConsulServiceHealth> itemList = new ArrayList<>();\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            List<ConsulServiceInfo> svcInfoList = restClient.getServices();\r
+            for (ConsulServiceInfo csi : svcInfoList) {\r
+                List<ConsulServiceHealth> csh = restClient.getServiceHealth(csi.name);\r
+                itemList.addAll(csh);\r
+            }\r
+            itemList.sort(serviceHealthComparator);\r
+            // Paginate\r
+            final int pageNum = getRequestPageNumber(request);\r
+            final int pageSize = getRequestPageSize(request);\r
+            final int totalItems = itemList.size();\r
+            final int pageCount = (int) Math.ceil((double) totalItems / pageSize);\r
+            // Shrink if needed\r
+            if (totalItems > pageSize) {\r
+                itemList = getPageOfList(pageNum, pageSize, itemList);\r
+            }\r
+            result = new RestResponsePage<>(totalItems, pageCount, itemList);\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("getServicesHealth failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Serves one page of node information.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return List of ConsulNodeInfo objects, as JSON\r
+     */\r
+    @RequestMapping(value = {NODES_PATH}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getNodesInfo(HttpServletRequest request) {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        String json = getItemListForPageWrapper(request, ConsulDataItem.NODES);\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return json;\r
+    }\r
+\r
+    /**\r
+     * Serves node services health details - not paginated.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param nodeName\r
+     *            Node name\r
+     * @return List of ConsulServiceHealth objects as JSON\r
+     * @throws JsonProcessingException\r
+     *             if serialization fails\r
+     */\r
+    @RequestMapping(value = {NODES_PATH + "/{nodeName}"}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getNodeServicesHealth(HttpServletRequest request, @PathVariable String nodeName)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        Object result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            result = restClient.getNodeServicesHealth(nodeName);\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("getNodeServicesHealth failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Serves one page of data centers health.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @return List of ConsulHealthStatus objects\r
+     */\r
+    @RequestMapping(value = {"/datacenters"}, method = RequestMethod.GET, produces = "application/json")\r
+    @ResponseBody\r
+    public String getDatacentersHealth(HttpServletRequest request) {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        String json = getItemListForPageWrapper(request, ConsulDataItem.DATACENTERS);\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return json;\r
+    }\r
+\r
+    /**\r
+     * Processes request to register a service for health checks.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param registration\r
+     *            Consul service registration\r
+     * @return URI of the newly registered resource\r
+     * @throws JsonProcessingException\r
+     *             on serialization error\r
+     */\r
+    @RequestMapping(value = {"/register"}, method = RequestMethod.POST, produces = "application/json")\r
+    @ResponseBody\r
+    public String registerService(HttpServletRequest request, @RequestBody ConsulHealthServiceRegistration registration)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            URI uri = restClient.registerService(registration);\r
+            result = new RestResponseSuccess(uri.toString());\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("registerService failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+\r
+    /**\r
+     * Processes request to deregister a service for health checks.\r
+     *\r
+     * @param request\r
+     *            HttpServletRequest\r
+     * @param serviceName\r
+     *            Consul service name to deregister\r
+     * @return Success or error indicator\r
+     * @throws JsonProcessingException\r
+     *             on serialization error\r
+     */\r
+    @RequestMapping(value = {\r
+        "/deregister" + "/{serviceName}"}, method = RequestMethod.POST, produces = "application/json")\r
+    @ResponseBody\r
+    public String deregisterService(HttpServletRequest request, @PathVariable String serviceName)\r
+        throws JsonProcessingException {\r
+        MDC.put(SystemProperties.AUDITLOG_BEGIN_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+        ECTransportModel result = null;\r
+        try {\r
+            IControllerRestClient restClient = getControllerRestClient(request);\r
+            int code = restClient.deregisterService(serviceName);\r
+            result = new RestResponseSuccess("Deregistration yielded code " + Integer.toString(code));\r
+        } catch (HttpStatusCodeException e) {\r
+            result = new RestResponseError(e.getResponseBodyAsString());\r
+        } catch (Exception t) {\r
+            result = new RestResponseError("deregisterService failed", t);\r
+        }\r
+        MDC.put(SystemProperties.AUDITLOG_END_TIMESTAMP, logDateFormat.format(new Date()));\r
+        logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+        return objectMapper.writeValueAsString(result);\r
+    }\r
+}\r
index 618e84d..8ec1d2c 100644 (file)
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.controller;
-
-import java.util.ArrayList;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.onap.ccsdk.dashboard.domain.ControllerEndpoint;
-import org.onap.ccsdk.dashboard.exception.DashboardControllerException;
-import org.onap.ccsdk.dashboard.model.ControllerEndpointCredentials;
-import org.onap.ccsdk.dashboard.model.ControllerEndpointTransport;
-import org.onap.ccsdk.dashboard.model.RestResponseError;
-import org.onap.ccsdk.dashboard.model.RestResponseSuccess;
-import org.onap.ccsdk.dashboard.service.ControllerEndpointService;
-import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-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.ResponseBody;
-import org.springframework.web.servlet.ModelAndView;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * This controller maps requests for the application's landing page, which is an
- * Angular single-page application.
- */
-@Controller
-@RequestMapping("/")
-public class DashboardHomeController extends DashboardRestrictedBaseController {
-
-       /**
-        * This path is embedded in the database, so it's nontrivial to change.
-        */
-       public static final String APP_CONTEXT_PATH = "/ecd";
-
-       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DashboardHomeController.class);
-
-       @Autowired
-       private ControllerEndpointService controllerEndpointService;
-
-       /**
-        * For general use in these methods
-        */
-       private final ObjectMapper mapper;
-
-       private static final String CONTROLLERS_PATH = "controllers";
-
-       /**
-        * Spring autowires fields AFTER the constructor is called.
-        */
-       public DashboardHomeController() {
-               mapper = new ObjectMapper();
-               // Do not serialize null values
-               mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
-       }
-
-       /**
-        * @return View name key, which is resolved to a file using an Apache tiles
-        *         "definitions.xml" file.
-        */
-       @RequestMapping(value = { APP_CONTEXT_PATH }, method = RequestMethod.GET)
-       public ModelAndView dbcDefaultController() {
-               // a model is only useful for JSP; this app is angular.
-               return new ModelAndView("oom_home_tdkey");
-       }
-
-       /**
-        * Gets the available controller endpoints.
-        * 
-        * @param request
-        *            HttpServletRequest
-        * @return List of ControllerEndpointTransport objects, or an error on failure
-        */
-       @RequestMapping(value = { CONTROLLERS_PATH }, method = RequestMethod.GET, produces = "application/json")
-       @ResponseBody
-       public String getControllers(HttpServletRequest request) {
-               logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-               logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-               String outboundJson = null;
-               // Static data
-               ControllerEndpointCredentials[] configured = getControllerEndpoints();
-               try {
-                       User appUser = UserUtils.getUserSession(request);
-                       if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0)
-                               throw new DashboardControllerException("getControllers: Failed to get application user");
-                       ControllerEndpointCredentials selectedInDb = getOrSetControllerEndpointSelection(appUser.getId());
-                       // Built result from properties
-                       ArrayList<ControllerEndpointTransport> list = new ArrayList<>();
-                       for (ControllerEndpointCredentials ctrl : configured) {
-                               // Check if this is the selected endpoint in DB
-                               boolean selected = (selectedInDb != null && selectedInDb.getUrl() != null
-                                               && selectedInDb.getUrl().equals(ctrl.getUrl()));
-                               // Result has no privileged information
-                               ControllerEndpointTransport transport = new ControllerEndpointTransport(selected, ctrl.getName(),
-                                               ctrl.getUrl());
-                               list.add(transport);
-                       }
-                       outboundJson = mapper.writeValueAsString(list);
-               } catch (Exception ex) {
-                       RestResponseError response = new RestResponseError("Failed to get controller endpoint list", ex);
-                       outboundJson = response.toJson();
-               }
-               return outboundJson;
-       }
-
-       /**
-        * Sets the controller endpoint selection for the user.
-        * 
-        * @param request
-        *            HttpServletRequest
-        * @param endpoint
-        *            Body with endpoint details
-        * @return Result indicating success or failure
-        * @throws DashboardControllerException,
-        *             if application user is not found
-        * @throws JsonProcessingException
-        *             If serialization fails
-        */
-       @RequestMapping(value = { CONTROLLERS_PATH }, method = RequestMethod.POST, produces = "application/json")
-       @ResponseBody
-       public String setControllerSelection(HttpServletRequest request, @RequestBody ControllerEndpointTransport endpoint)
-                       throws DashboardControllerException, JsonProcessingException {
-               logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);
-               logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-               String outboundJson = null;
-               User appUser = UserUtils.getUserSession(request);
-               if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0)
-                       throw new DashboardControllerException("setControllerSelection: Failed to get application user");
-               ControllerEndpoint dbEntry = new ControllerEndpoint(appUser.getId(), endpoint.getName(), endpoint.getUrl());
-               controllerEndpointService.updateControllerEndpointSelection(dbEntry);
-               RestResponseSuccess success = new RestResponseSuccess("Updated selection to " + endpoint.getName());
-               outboundJson = mapper.writeValueAsString(success);
-               return outboundJson;
-       }
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.controller;\r
+\r
+import java.util.ArrayList;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+import org.onap.ccsdk.dashboard.domain.ControllerEndpoint;\r
+import org.onap.ccsdk.dashboard.exception.DashboardControllerException;\r
+import org.onap.ccsdk.dashboard.model.ControllerEndpointCredentials;\r
+import org.onap.ccsdk.dashboard.model.ControllerEndpointTransport;\r
+import org.onap.ccsdk.dashboard.model.RestResponseError;\r
+import org.onap.ccsdk.dashboard.model.RestResponseSuccess;\r
+import org.onap.ccsdk.dashboard.service.ControllerEndpointService;\r
+import org.onap.portalsdk.core.domain.User;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.onap.portalsdk.core.web.support.UserUtils;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.stereotype.Controller;\r
+import org.springframework.web.bind.annotation.RequestBody;\r
+import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.bind.annotation.RequestMethod;\r
+import org.springframework.web.bind.annotation.ResponseBody;\r
+import org.springframework.web.servlet.ModelAndView;\r
+\r
+import com.fasterxml.jackson.annotation.JsonInclude;\r
+import com.fasterxml.jackson.core.JsonProcessingException;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+/**\r
+ * This controller maps requests for the application's landing page, which is an\r
+ * Angular single-page application.\r
+ */\r
+@Controller\r
+@RequestMapping("/")\r
+public class DashboardHomeController extends DashboardRestrictedBaseController {\r
+\r
+       /**\r
+        * This path is embedded in the database, so it's nontrivial to change.\r
+        */\r
+       public static final String APP_CONTEXT_PATH = "/ecd";\r
+\r
+       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DashboardHomeController.class);\r
+\r
+       @Autowired\r
+       private ControllerEndpointService controllerEndpointService;\r
+\r
+       /**\r
+        * For general use in these methods\r
+        */\r
+       private final ObjectMapper mapper;\r
+\r
+       private static final String CONTROLLERS_PATH = "controllers";\r
+\r
+       /**\r
+        * Spring autowires fields AFTER the constructor is called.\r
+        */\r
+       public DashboardHomeController() {\r
+               mapper = new ObjectMapper();\r
+               // Do not serialize null values\r
+               mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);\r
+       }\r
+\r
+       /**\r
+        * @return View name key, which is resolved to a file using an Apache tiles\r
+        *         "definitions.xml" file.\r
+        */\r
+       @RequestMapping(value = { APP_CONTEXT_PATH }, method = RequestMethod.GET)\r
+       public ModelAndView dbcDefaultController() {\r
+               // a model is only useful for JSP; this app is angular.\r
+               return new ModelAndView("oom_home_tdkey");\r
+       }\r
+\r
+       /**\r
+        * Gets the available controller endpoints.\r
+        * \r
+        * @param request\r
+        *            HttpServletRequest\r
+        * @return List of ControllerEndpointTransport objects, or an error on failure\r
+        */\r
+       @RequestMapping(value = { CONTROLLERS_PATH }, method = RequestMethod.GET, produces = "application/json")\r
+       @ResponseBody\r
+       public String getControllers(HttpServletRequest request) {\r
+               logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+               logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+               String outboundJson = null;\r
+               // Static data\r
+               ControllerEndpointCredentials[] configured = getControllerEndpoints();\r
+               try {\r
+                       User appUser = UserUtils.getUserSession(request);\r
+                       if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0)\r
+                               throw new DashboardControllerException("getControllers: Failed to get application user");\r
+                       ControllerEndpointCredentials selectedInDb = getOrSetControllerEndpointSelection(appUser.getId());\r
+                       // Built result from properties\r
+                       ArrayList<ControllerEndpointTransport> list = new ArrayList<>();\r
+                       for (ControllerEndpointCredentials ctrl : configured) {\r
+                               // Check if this is the selected endpoint in DB\r
+                               boolean selected = (selectedInDb != null && selectedInDb.getUrl() != null\r
+                                               && selectedInDb.getUrl().equals(ctrl.getUrl()));\r
+                               // Result has no privileged information\r
+                               ControllerEndpointTransport transport = new ControllerEndpointTransport(selected, ctrl.getName(),\r
+                                               ctrl.getUrl());\r
+                               list.add(transport);\r
+                       }\r
+                       outboundJson = mapper.writeValueAsString(list);\r
+               } catch (Exception ex) {\r
+                       RestResponseError response = new RestResponseError("Failed to get controller endpoint list", ex);\r
+                       outboundJson = response.toJson();\r
+               }\r
+               return outboundJson;\r
+       }\r
+\r
+       /**\r
+        * Sets the controller endpoint selection for the user.\r
+        * \r
+        * @param request\r
+        *            HttpServletRequest\r
+        * @param endpoint\r
+        *            Body with endpoint details\r
+        * @return Result indicating success or failure\r
+        * @throws DashboardControllerException,\r
+        *             if application user is not found\r
+        * @throws JsonProcessingException\r
+        *             If serialization fails\r
+        */\r
+       @RequestMapping(value = { CONTROLLERS_PATH }, method = RequestMethod.POST, produces = "application/json")\r
+       @ResponseBody\r
+       public String setControllerSelection(HttpServletRequest request, @RequestBody ControllerEndpointTransport endpoint)\r
+                       throws DashboardControllerException, JsonProcessingException {\r
+               logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, APP_NAME);\r
+               logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+               String outboundJson = null;\r
+               User appUser = UserUtils.getUserSession(request);\r
+               if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0)\r
+                       throw new DashboardControllerException("setControllerSelection: Failed to get application user");\r
+               ControllerEndpoint dbEntry = new ControllerEndpoint(appUser.getId(), endpoint.getName(), endpoint.getUrl());\r
+               controllerEndpointService.updateControllerEndpointSelection(dbEntry);\r
+               RestResponseSuccess success = new RestResponseSuccess("Updated selection to " + endpoint.getName());\r
+               outboundJson = mapper.writeValueAsString(success);\r
+               return outboundJson;\r
+       }\r
+}\r
index 6f80d22..02f8770 100644 (file)
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.controller;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.onap.ccsdk.dashboard.exception.DashboardControllerException;
-import org.onap.ccsdk.dashboard.rest.ControllerRestClientMockImpl;
-import org.onap.ccsdk.dashboard.service.ControllerEndpointService;
-import org.onap.ccsdk.dashboard.domain.ControllerEndpoint;
-import org.onap.ccsdk.dashboard.rest.IControllerRestClient;
-import org.onap.ccsdk.dashboard.util.DashboardProperties;
-import org.onap.ccsdk.dashboard.model.ControllerEndpointCredentials;
-import org.onap.ccsdk.dashboard.rest.ControllerRestClientImpl;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * This base class provides utility methods to child controllers.
- */
-public class DashboardRestrictedBaseController extends RestrictedBaseController {
-
-       /**
-        * Logger that conforms with ECOMP guidelines
-        */
-       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DashboardRestrictedBaseController.class);
-
-       /**
-        * Application name
-        */
-       protected static final String APP_NAME = "ecd-app";
-
-       /**
-        * EELF-approved format
-        */
-       protected static final DateFormat logDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
-
-       /**
-        * Query parameter for desired page number
-        */
-       protected static final String PAGE_NUM_QUERY_PARAM = "pageNum";
-
-       /**
-        * Query parameter for desired items per page
-        */
-       protected static final String PAGE_SIZE_QUERY_PARAM = "viewPerPage";
-
-       /**
-        * For general use in these methods and subclasses
-        */
-       protected final ObjectMapper objectMapper = new ObjectMapper();
-
-       /**
-        * Application properties - NOT available to constructor.
-        */
-       @Autowired
-       private DashboardProperties appProperties;
-
-       /**
-        * For getting selected controller
-        */
-       @Autowired
-       private ControllerEndpointService controllerEndpointService;
-
-       /**
-        * Hello Spring, here's your no-arg constructor.
-        */
-       public DashboardRestrictedBaseController() {
-               // Do not serialize null values
-               objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
-       }
-
-       /**
-        * Access method for subclasses.
-        * 
-        * @return DbcappProperties object that was autowired by Spring.
-        */
-       protected DashboardProperties getAppProperties() {
-               return appProperties;
-       }
-
-       /**
-        * Gets the requested page number from a query parameter in the
-        * HttpServletRequest. Defaults to 1, which is useful to allow manual
-        * testing of endpoints without supplying those pesky parameters.
-        * 
-        * @param request
-        *            HttpServletRequest
-        * @return Value of query parameter {@link #PAGE_NUM_QUERY_PARAM}; 1 if not
-        *         found.
-        */
-       protected int getRequestPageNumber(HttpServletRequest request) {
-               int pageNum = 1;
-               String param = request.getParameter(PAGE_NUM_QUERY_PARAM);
-               if (param != null)
-                       pageNum = Integer.parseInt(param);
-               return pageNum;
-       }
-
-       /**
-        * Gets the requested page size from a query parameter in the
-        * HttpServletRequest. Defaults to 50, which is useful to allow manual
-        * testing of endpoints without supplying those pesky parameters.
-        * 
-        * @param request
-        *            HttpServletRequest
-        * @return Value of query parameter {@link #PAGE_SIZE_QUERY_PARAM}; 50 if
-        *         not found.
-        */
-       protected int getRequestPageSize(HttpServletRequest request) {
-               int pageSize = 50;
-               String param = request.getParameter(PAGE_SIZE_QUERY_PARAM);
-               if (param != null)
-                       pageSize = Integer.parseInt(param);
-               return pageSize;
-       }
-
-       /**
-        * Gets the items for the specified page from the specified list.
-        * 
-        * @param pageNum
-        *            Page number requested by user, indexed from 1
-        * @param pageSize
-        *            Number of items per page
-        * @param itemList
-        *            List of items to adjust
-        * @return List of items; empty list if from==to
-        */
-       @SuppressWarnings("rawtypes")
-       protected static List getPageOfList(final int pageNum, final int pageSize, final List itemList) {
-               int firstIndexOnThisPage = pageSize * (pageNum - 1);
-               int firstIndexOnNextPage = pageSize * pageNum;
-               int fromIndex = firstIndexOnThisPage < itemList.size() ? firstIndexOnThisPage : itemList.size();
-               int toIndex = firstIndexOnNextPage < itemList.size() ? firstIndexOnNextPage : itemList.size();
-               return itemList.subList(fromIndex, toIndex);
-       }
-
-       /**
-        * Gets all configured controllers from properties.
-        * 
-        * @return Array of ControllerEndpointRestricted objects
-        * @throws IllegalStateException
-        *             if a required property is not found
-        */
-       protected ControllerEndpointCredentials[] getControllerEndpoints() {
-               final String[] controllerKeys = appProperties.getCsvListProperty(DashboardProperties.CONTROLLER_KEY_LIST);
-               ControllerEndpointCredentials[] controllers = new ControllerEndpointCredentials[controllerKeys.length];
-               for (int i = 0; i < controllerKeys.length; ++i) {
-                       String key = controllerKeys[i];
-                       final String name = appProperties.getControllerProperty(key, DashboardProperties.CONTROLLER_SUBKEY_NAME);
-                       final String url = appProperties.getControllerProperty(key, DashboardProperties.CONTROLLER_SUBKEY_URL);
-                       final String user = appProperties.getControllerProperty(key,
-                                       DashboardProperties.CONTROLLER_SUBKEY_USERNAME);
-                       final String pass = appProperties.getControllerProperty(key,
-                                       DashboardProperties.CONTROLLER_SUBKEY_PASSWORD);
-                       final boolean encr = Boolean.parseBoolean (
-                                       appProperties.getControllerProperty(key, DashboardProperties.CONTROLLER_SUBKEY_ENCRYPTED));
-                       logger.debug(EELFLoggerDelegate.debugLogger, "getConfiguredControllers: key {} yields url {}", key, url);
-                       controllers[i] = new ControllerEndpointCredentials(false, name, url, user, pass, encr);
-               }
-               return controllers;
-       }
-
-       /**
-        * Gets the controller endpoint for the specified user ID. Chooses the first
-        * one from properties if the user has not selected one previously.
-        * 
-        * @param userId
-        *            Database User ID
-        * @return ControllerEndpointCredentials for the specified user
-        */
-       protected ControllerEndpointCredentials getOrSetControllerEndpointSelection(long userId) {
-               // Always need the complete list from properties
-               ControllerEndpointCredentials[] configured = getControllerEndpoints();
-               // See if the database has an entry for this user
-               ControllerEndpoint dbEntry = controllerEndpointService.getControllerEndpointSelection(userId);
-               // If no row found DAO returns an object with null entries.
-               if (dbEntry == null || dbEntry.getName() == null) {
-                       // Arbitrarily choose the first one
-                       ControllerEndpointCredentials first = configured[0];
-                       dbEntry = new ControllerEndpoint(userId, first.getName(), first.getUrl());
-                       controllerEndpointService.updateControllerEndpointSelection(dbEntry);
-               }
-               // Fetch complete details for the selected item
-               ControllerEndpointCredentials selected = null;
-               for (ControllerEndpointCredentials cec : configured) {
-                       if (dbEntry.getUrl().equals(cec.getUrl())) {
-                               selected = cec;
-                               break;
-                       }
-               }
-               // Defend against a stale database entry.
-               if (selected == null) {
-                       selected = configured[0];
-                       dbEntry = new ControllerEndpoint(userId, selected.getName(), selected.getUrl());
-                       controllerEndpointService.updateControllerEndpointSelection(dbEntry);
-               }
-               return selected;
-       }
-
-       /**
-        * Convenience method that gets the user ID from the session and fetches the
-        * REST client. Factors code out of subclass methods.
-        * 
-        * @param request
-        *            HttpServletRequest
-        * @return REST client appropriate for the user
-        * @throws DashboardControllerException
-        */
-       protected IControllerRestClient getControllerRestClient(HttpServletRequest request) throws DashboardControllerException {
-               User appUser = UserUtils.getUserSession(request);
-               if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0)
-                       throw new DashboardControllerException("getControllerRestClient: Failed to get application user");
-               return getControllerRestClient(appUser.getId());
-       }
-
-       /**
-        * Gets a REST client; either a mock client (returns canned data), or a real
-        * client with appropriate credentials from properties.
-        * 
-        * @return REST client.
-        * @throws DashboardControllerException on any failure; e.g., if the password cannot be decrypted.
-        */
-       protected IControllerRestClient getControllerRestClient(long userId) throws DashboardControllerException {
-               IControllerRestClient result = null;
-               // Be robust to missing development-only property
-               boolean mock = false;
-               if (appProperties.containsProperty(DashboardProperties.CONTROLLER_MOCK_DATA))
-                       mock = appProperties.getBooleanProperty(DashboardProperties.CONTROLLER_MOCK_DATA);
-               if (mock) {
-                       result = new ControllerRestClientMockImpl();
-               } else {
-                       try {
-                       ControllerEndpointCredentials details = getOrSetControllerEndpointSelection(userId);
-                       final String clearText = details.getEncryptedPassword() ? details.decryptPassword() : details.getPassword();
-                       result = new ControllerRestClientImpl(details.getUrl(), details.getUsername(), clearText);
-                       }
-                       catch (Exception ex) {
-                               logger.error("getControllerRestClient failed", ex);
-                               throw new DashboardControllerException(ex);
-                       }
-               }
-               return result;
-       }
-
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.controller;\r
+\r
+import java.text.DateFormat;\r
+import java.text.SimpleDateFormat;\r
+import java.util.List;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+import org.onap.ccsdk.dashboard.exception.DashboardControllerException;\r
+import org.onap.ccsdk.dashboard.rest.ControllerRestClientMockImpl;\r
+import org.onap.ccsdk.dashboard.service.ControllerEndpointService;\r
+import org.onap.ccsdk.dashboard.domain.ControllerEndpoint;\r
+import org.onap.ccsdk.dashboard.rest.IControllerRestClient;\r
+import org.onap.ccsdk.dashboard.util.DashboardProperties;\r
+import org.onap.ccsdk.dashboard.model.ControllerEndpointCredentials;\r
+import org.onap.ccsdk.dashboard.rest.ControllerRestClientImpl;\r
+import org.onap.portalsdk.core.controller.RestrictedBaseController;\r
+import org.onap.portalsdk.core.domain.User;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.onap.portalsdk.core.web.support.UserUtils;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+\r
+import com.fasterxml.jackson.annotation.JsonInclude;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+/**\r
+ * This base class provides utility methods to child controllers.\r
+ */\r
+public class DashboardRestrictedBaseController extends RestrictedBaseController {\r
+\r
+       /**\r
+        * Logger that conforms with ECOMP guidelines\r
+        */\r
+       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(DashboardRestrictedBaseController.class);\r
+\r
+       /**\r
+        * Application name\r
+        */\r
+       protected static final String APP_NAME = "ecd-app";\r
+\r
+       /**\r
+        * EELF-approved format\r
+        */\r
+       protected static final DateFormat logDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");\r
+\r
+       /**\r
+        * Query parameter for desired page number\r
+        */\r
+       protected static final String PAGE_NUM_QUERY_PARAM = "pageNum";\r
+\r
+       /**\r
+        * Query parameter for desired items per page\r
+        */\r
+       protected static final String PAGE_SIZE_QUERY_PARAM = "viewPerPage";\r
+\r
+       /**\r
+        * For general use in these methods and subclasses\r
+        */\r
+       protected final ObjectMapper objectMapper = new ObjectMapper();\r
+\r
+       /**\r
+        * Application properties - NOT available to constructor.\r
+        */\r
+       @Autowired\r
+       private DashboardProperties appProperties;\r
+\r
+       /**\r
+        * For getting selected controller\r
+        */\r
+       @Autowired\r
+       private ControllerEndpointService controllerEndpointService;\r
+\r
+       /**\r
+        * Hello Spring, here's your no-arg constructor.\r
+        */\r
+       public DashboardRestrictedBaseController() {\r
+               // Do not serialize null values\r
+               objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);\r
+       }\r
+\r
+       /**\r
+        * Access method for subclasses.\r
+        * \r
+        * @return DbcappProperties object that was autowired by Spring.\r
+        */\r
+       protected DashboardProperties getAppProperties() {\r
+               return appProperties;\r
+       }\r
+\r
+       /**\r
+        * Gets the requested page number from a query parameter in the\r
+        * HttpServletRequest. Defaults to 1, which is useful to allow manual\r
+        * testing of endpoints without supplying those pesky parameters.\r
+        * \r
+        * @param request\r
+        *            HttpServletRequest\r
+        * @return Value of query parameter {@link #PAGE_NUM_QUERY_PARAM}; 1 if not\r
+        *         found.\r
+        */\r
+       protected int getRequestPageNumber(HttpServletRequest request) {\r
+               int pageNum = 1;\r
+               String param = request.getParameter(PAGE_NUM_QUERY_PARAM);\r
+               if (param != null)\r
+                       pageNum = Integer.parseInt(param);\r
+               return pageNum;\r
+       }\r
+\r
+       /**\r
+        * Gets the requested page size from a query parameter in the\r
+        * HttpServletRequest. Defaults to 50, which is useful to allow manual\r
+        * testing of endpoints without supplying those pesky parameters.\r
+        * \r
+        * @param request\r
+        *            HttpServletRequest\r
+        * @return Value of query parameter {@link #PAGE_SIZE_QUERY_PARAM}; 50 if\r
+        *         not found.\r
+        */\r
+       protected int getRequestPageSize(HttpServletRequest request) {\r
+               int pageSize = 50;\r
+               String param = request.getParameter(PAGE_SIZE_QUERY_PARAM);\r
+               if (param != null)\r
+                       pageSize = Integer.parseInt(param);\r
+               return pageSize;\r
+       }\r
+\r
+       /**\r
+        * Gets the items for the specified page from the specified list.\r
+        * \r
+        * @param pageNum\r
+        *            Page number requested by user, indexed from 1\r
+        * @param pageSize\r
+        *            Number of items per page\r
+        * @param itemList\r
+        *            List of items to adjust\r
+        * @return List of items; empty list if from==to\r
+        */\r
+       @SuppressWarnings("rawtypes")\r
+       protected static List getPageOfList(final int pageNum, final int pageSize, final List itemList) {\r
+               int firstIndexOnThisPage = pageSize * (pageNum - 1);\r
+               int firstIndexOnNextPage = pageSize * pageNum;\r
+               int fromIndex = firstIndexOnThisPage < itemList.size() ? firstIndexOnThisPage : itemList.size();\r
+               int toIndex = firstIndexOnNextPage < itemList.size() ? firstIndexOnNextPage : itemList.size();\r
+               return itemList.subList(fromIndex, toIndex);\r
+       }\r
+\r
+       /**\r
+        * Gets all configured controllers from properties.\r
+        * \r
+        * @return Array of ControllerEndpointRestricted objects\r
+        * @throws IllegalStateException\r
+        *             if a required property is not found\r
+        */\r
+       protected ControllerEndpointCredentials[] getControllerEndpoints() {\r
+               final String[] controllerKeys = appProperties.getCsvListProperty(DashboardProperties.CONTROLLER_KEY_LIST);\r
+               ControllerEndpointCredentials[] controllers = new ControllerEndpointCredentials[controllerKeys.length];\r
+               for (int i = 0; i < controllerKeys.length; ++i) {\r
+                       String key = controllerKeys[i];\r
+                       final String name = appProperties.getControllerProperty(key, DashboardProperties.CONTROLLER_SUBKEY_NAME);\r
+                       final String url = appProperties.getControllerProperty(key, DashboardProperties.CONTROLLER_SUBKEY_URL);\r
+                       final String user = appProperties.getControllerProperty(key,\r
+                                       DashboardProperties.CONTROLLER_SUBKEY_USERNAME);\r
+                       final String pass = appProperties.getControllerProperty(key,\r
+                                       DashboardProperties.CONTROLLER_SUBKEY_PASSWORD);\r
+                       final boolean encr = Boolean.parseBoolean (\r
+                                       appProperties.getControllerProperty(key, DashboardProperties.CONTROLLER_SUBKEY_ENCRYPTED));\r
+                       logger.debug(EELFLoggerDelegate.debugLogger, "getConfiguredControllers: key {} yields url {}", key, url);\r
+                       controllers[i] = new ControllerEndpointCredentials(false, name, url, user, pass, encr);\r
+               }\r
+               return controllers;\r
+       }\r
+\r
+       /**\r
+        * Gets the controller endpoint for the specified user ID. Chooses the first\r
+        * one from properties if the user has not selected one previously.\r
+        * \r
+        * @param userId\r
+        *            Database User ID\r
+        * @return ControllerEndpointCredentials for the specified user\r
+        */\r
+       protected ControllerEndpointCredentials getOrSetControllerEndpointSelection(long userId) {\r
+               // Always need the complete list from properties\r
+               ControllerEndpointCredentials[] configured = getControllerEndpoints();\r
+               // See if the database has an entry for this user\r
+               ControllerEndpoint dbEntry = controllerEndpointService.getControllerEndpointSelection(userId);\r
+               // If no row found DAO returns an object with null entries.\r
+               if (dbEntry == null || dbEntry.getName() == null) {\r
+                       // Arbitrarily choose the first one\r
+                       ControllerEndpointCredentials first = configured[0];\r
+                       dbEntry = new ControllerEndpoint(userId, first.getName(), first.getUrl());\r
+                       controllerEndpointService.updateControllerEndpointSelection(dbEntry);\r
+               }\r
+               // Fetch complete details for the selected item\r
+               ControllerEndpointCredentials selected = null;\r
+               for (ControllerEndpointCredentials cec : configured) {\r
+                       if (dbEntry.getUrl().equals(cec.getUrl())) {\r
+                               selected = cec;\r
+                               break;\r
+                       }\r
+               }\r
+               // Defend against a stale database entry.\r
+               if (selected == null) {\r
+                       selected = configured[0];\r
+                       dbEntry = new ControllerEndpoint(userId, selected.getName(), selected.getUrl());\r
+                       controllerEndpointService.updateControllerEndpointSelection(dbEntry);\r
+               }\r
+               return selected;\r
+       }\r
+\r
+       /**\r
+        * Convenience method that gets the user ID from the session and fetches the\r
+        * REST client. Factors code out of subclass methods.\r
+        * \r
+        * @param request\r
+        *            HttpServletRequest\r
+        * @return REST client appropriate for the user\r
+        * @throws DashboardControllerException\r
+        */\r
+       protected IControllerRestClient getControllerRestClient(HttpServletRequest request) throws DashboardControllerException {\r
+               User appUser = UserUtils.getUserSession(request);\r
+               if (appUser == null || appUser.getLoginId() == null || appUser.getLoginId().length() == 0)\r
+                       throw new DashboardControllerException("getControllerRestClient: Failed to get application user");\r
+               return getControllerRestClient(appUser.getId());\r
+       }\r
+\r
+       /**\r
+        * Gets a REST client; either a mock client (returns canned data), or a real\r
+        * client with appropriate credentials from properties.\r
+        * \r
+        * @return REST client.\r
+        * @throws DashboardControllerException on any failure; e.g., if the password cannot be decrypted.\r
+        */\r
+       protected IControllerRestClient getControllerRestClient(long userId) throws DashboardControllerException {\r
+               IControllerRestClient result = null;\r
+               // Be robust to missing development-only property\r
+               boolean mock = false;\r
+               if (appProperties.containsProperty(DashboardProperties.CONTROLLER_MOCK_DATA))\r
+                       mock = appProperties.getBooleanProperty(DashboardProperties.CONTROLLER_MOCK_DATA);\r
+               if (mock) {\r
+                       result = new ControllerRestClientMockImpl();\r
+               } else {\r
+                       try {\r
+                       ControllerEndpointCredentials details = getOrSetControllerEndpointSelection(userId);\r
+                       final String clearText = details.getEncryptedPassword() ? details.decryptPassword() : details.getPassword();\r
+                       result = new ControllerRestClientImpl(details.getUrl(), details.getUsername(), clearText);\r
+                       }\r
+                       catch (Exception ex) {\r
+                               logger.error("getControllerRestClient failed", ex);\r
+                               throw new DashboardControllerException(ex);\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+\r
+}\r
index 953adff..28f939c 100644 (file)
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed 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
- * 
- *      http://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.
- * ================================================================================
- */
-
-package org.onap.ccsdk.dashboard.controller;
-
-import java.io.UnsupportedEncodingException;
-
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
-import org.onap.ccsdk.dashboard.exception.DashboardControllerException;
-import org.openecomp.portalsdk.core.auth.LoginStrategy;
-import org.openecomp.portalsdk.core.command.LoginBean;
-import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
-import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.menu.MenuProperties;
-import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
-import org.openecomp.portalsdk.core.onboarding.listener.PortalTimeoutHandler;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
-import org.openecomp.portalsdk.core.service.LoginService;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.openecomp.portalsdk.core.web.support.AppUtils;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.client.RestClientException;
-import org.springframework.web.client.RestTemplate;
-import org.springframework.web.servlet.ModelAndView;
-import org.springframework.web.util.WebUtils;
-
-@Controller
-@RequestMapping("/")
-/**
- * Replicated from
- * org.openecomp.portalapp.controller.core.SingleSignOnController to modify the
- * behavior of sending user's browser on a detour of Portal app to get the
- * EPService cookie.
- */
-public class ECDSingleSignOnController extends UnRestrictedBaseController {
-
-       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ECDSingleSignOnController.class);
-    private static final String REDIRECT = "redirect:";
-
-       @Autowired
-       private LoginService loginService;
-
-       @Autowired
-       private LoginStrategy loginStrategy;
-
-       private String viewName;
-       private String welcomeView;
-
-       /**
-        * Handles requests directed to the single sign-on page by the session timeout
-        * interceptor.
-        * 
-        * @param request
-        *            HttpServletRequest
-        * @param response
-        *            HttpServletResponse
-        * @return Redirect to an appropriate address
-        * @throws DashboardControllerException
-        *             User not found
-        * @throws PortalAPIException
-        *             User ID can't be fetched
-        * @throws UnsupportedEncodingException
-        *             Encoding fails
-        */
-       @RequestMapping(value = { "/single_signon.htm" }, method = RequestMethod.GET)
-       public ModelAndView singleSignOnLogin(HttpServletRequest request, HttpServletResponse response)
-                       throws DashboardControllerException, PortalAPIException, UnsupportedEncodingException {
-
-               Map<String, String> model = new HashMap<>();
-               HashMap<String, String> additionalParamsMap = new HashMap<>();
-               LoginBean commandBean = new LoginBean();
-
-               // SessionTimeoutInterceptor sets these parameters
-               String forwardURL = URLDecoder.decode(request.getParameter("forwardURL"), "UTF-8");
-               String redirectToPortal = request.getParameter("redirectToPortal");
-
-               if (isLoginCookieExist(request) && redirectToPortal == null) {
-                       HttpSession session = null;
-                       session = AppUtils.getSession(request);
-                       User user = UserUtils.getUserSession(request);
-                       if (session == null || user == null) {
-
-                               final String authMech = SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM);
-                               String userId = loginStrategy.getUserId(request);
-                               commandBean.setUserid(userId);
-                               try {
-                                       commandBean = getLoginService().findUser(commandBean,
-                                                       (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY),
-                                                       additionalParamsMap);
-                               } catch (Exception ex) {
-                                       logger.error("singleSignOnLogin failed", ex);
-                                       throw new DashboardControllerException(ex);
-                               }
-                               if (commandBean.getUser() == null) {
-                                       String loginErrorMessage = (commandBean.getLoginErrorMessage() != null)
-                                                       ? commandBean.getLoginErrorMessage()
-                                                       : SystemProperties.MESSAGE_KEY_LOGIN_ERROR_USER_NOT_FOUND;
-                                       model.put(LoginStrategy.ERROR_MESSAGE_KEY, SystemProperties.getProperty(loginErrorMessage));
-                                       final String redirectUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL)
-                                                       + "?noUserError=Yes";
-                                       logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: user is null, redirect URL is {}",
-                                                       redirectUrl);
-                    return new ModelAndView(REDIRECT + redirectUrl);
-                               } else {
-                                       // store the user's information in the session
-                                       String loginMethod;
-                                       if (null == authMech || "".equals(authMech) || "BOTH".equals(authMech)) {
-                                               loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_CSP);
-                                       } else if ("CSP".equals(authMech)) {
-                                               loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_CSP);
-                                       } else {
-                                               loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_WEB_JUNCTION);
-                                       }
-                                       UserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(),
-                                                       commandBean.getBusinessDirectMenu(), loginMethod);
-                                       initateSessionMgtHandler(request);
-                                       logger.debug(EELFLoggerDelegate.debugLogger,
-                                                       "singleSignOnLogin: create new user session for expired user {}; user {} exists in the system",
-                                                       userId, commandBean.getUser().getOrgUserId());
-                    return new ModelAndView(REDIRECT + forwardURL);
-                               }
-                       } // user is null or session is null
-                       else {
-                               // both user and session are non-null.
-                               logger.info(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: redirecting to the forwardURL {}",
-                                               forwardURL);
-                return new ModelAndView(REDIRECT + forwardURL);
-                       }
-               } else {
-                       /*
-                        * Login cookie not found, or redirect-to-portal parameter was found.
-                        */
-                       if (isPortalAvailable()) {
-                               /*
-                                * Redirect the user to the portal with a suitable return URL. The forwardURL
-                                * parameter that arrives as a parameter is a partial (not absolute) request
-                                * path for a page in the application. The challenge here is to compute the
-                                * correct absolute path for the original request so the portal can redirect the
-                                * user back to the right place. If the application sits behind WebJunction, or
-                                * if separate FE-BE hosts are used, then the URL yielded by the request has a
-                                * host name that is not reachable by the user.
-                                */
-                               String returnToAppUrl = null;
-                               if (SystemProperties.containsProperty(SystemProperties.APP_BASE_URL)) {
-                                       // New feature as of 1610, release 3.3.3:
-                                       // application can publish a base URL in system.properties
-                                       String appUrl = SystemProperties.getProperty(SystemProperties.APP_BASE_URL);
-                                       returnToAppUrl = appUrl + (appUrl.endsWith("/") ? "" : "/") + forwardURL;
-                                       logger.debug(EELFLoggerDelegate.debugLogger,
-                                                       "singleSignOnLogin: using app base URL {} and redirectURL {}", appUrl, returnToAppUrl);
-                               } else {
-                                       /**
-                                        * Be backward compatible with applications that don't need this feature. This
-                                        * is the controller for the single_signon.htm page, so the replace should
-                                        * always find the specified token.
-                                        */
-                                       returnToAppUrl = request.getRequestURL().toString()
-                                                       .replace("single_signon.htm", forwardURL);
-                                       logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: computed redirectURL {}",
-                                                       returnToAppUrl);
-                               }
-                               final String encodedReturnToAppUrl = URLEncoder.encode(returnToAppUrl, "UTF-8");
-                               // Also send the application's UEB key so Portal can block URL
-                               // reflection attacks.
-                               final String uebAppKey = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);
-                               final String url = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);
-                               final String portalUrl = url.substring(0, url.lastIndexOf('/')) + "/process_csp";
-                               final String redirectUrl = portalUrl + "?uebAppKey=" + uebAppKey + "&redirectUrl="
-                                               + encodedReturnToAppUrl;
-                               logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: portal-bound redirect URL is {}",
-                                               redirectUrl);
-                return new ModelAndView(REDIRECT + redirectUrl);
-                       } // portal is available
-
-                       else {
-                               /*
-                                * Portal is not available. Redirect user to the login page, ignoring the
-                                * forwardURL parameter.
-                                */
-                               return new ModelAndView("redirect:login.htm");
-                       }
-
-               }
-       }
-
-       /**
-        * Discover if the portal is available by GET-ing a resource from the REST URL
-        * specified in portal.properties, using a very short timeout.
-        * 
-        * @return True if the portal answers, otherwise false.
-        */
-       private boolean isPortalAvailable() {
-               HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
-               final int oneSecond = 1000;
-               httpRequestFactory.setConnectionRequestTimeout(oneSecond);
-               httpRequestFactory.setConnectTimeout(oneSecond);
-               httpRequestFactory.setReadTimeout(oneSecond);
-               RestTemplate restTemplate = new RestTemplate(httpRequestFactory);
-               boolean avail = true;
-               try {
-                       final String portalUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL);
-                       String s = restTemplate.getForObject(portalUrl, String.class);
-                       logger.trace("isPortalAvailable got response {}", s);
-               } catch (RestClientException ex) {
-                       logger.debug("isPortalAvailable failed", ex);
-                       avail = false;
-               }
-               return avail;
-       }
-
-       protected void initateSessionMgtHandler(HttpServletRequest request) {
-               String portalJSessionId = getPortalJSessionId(request);
-               String jSessionId = getJessionId(request);
-               PortalTimeoutHandler.sessionCreated(portalJSessionId, jSessionId, AppUtils.getSession(request));
-       }
-
-       public boolean isLoginCookieExist(HttpServletRequest request) {
-               Cookie ep = WebUtils.getCookie(request, LoginStrategy.EP_SERVICE);
-               return (ep != null);
-       }
-
-       public String getPortalJSessionId(HttpServletRequest request) {
-               Cookie ep = WebUtils.getCookie(request, LoginStrategy.EP_SERVICE);
-               return ep.getValue();
-       }
-
-       public String getJessionId(HttpServletRequest request) {
-               return request.getSession().getId();
-       }
-
-       @Override
-       public String getViewName() {
-               return viewName;
-       }
-
-       @Override
-       public void setViewName(String viewName) {
-               this.viewName = viewName;
-       }
-
-       public String getWelcomeView() {
-               return welcomeView;
-       }
-
-       public void setWelcomeView(String welcomeView) {
-               this.welcomeView = welcomeView;
-       }
-
-       public LoginService getLoginService() {
-               return loginService;
-       }
-
-       public void setLoginService(LoginService loginService) {
-               this.loginService = loginService;
-       }
-
-}
+/*-\r
+ * ================================================================================\r
+ * ECOMP Portal SDK\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ================================================================================\r
+ */\r
+\r
+package org.onap.ccsdk.dashboard.controller;\r
+\r
+import java.io.UnsupportedEncodingException;\r
+\r
+import java.net.URLDecoder;\r
+import java.net.URLEncoder;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.servlet.http.Cookie;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+import javax.servlet.http.HttpSession;\r
+\r
+import org.onap.ccsdk.dashboard.exception.DashboardControllerException;\r
+import org.onap.portalsdk.core.auth.LoginStrategy;\r
+import org.onap.portalsdk.core.command.LoginBean;\r
+import org.onap.portalsdk.core.controller.UnRestrictedBaseController;\r
+import org.onap.portalsdk.core.domain.User;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.onap.portalsdk.core.menu.MenuProperties;\r
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;\r
+import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler;\r
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;\r
+import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;\r
+import org.onap.portalsdk.core.service.LoginService;\r
+import org.onap.portalsdk.core.util.SystemProperties;\r
+import org.onap.portalsdk.core.web.support.AppUtils;\r
+import org.onap.portalsdk.core.web.support.UserUtils;\r
+import org.onap.portalsdk.core.service.RoleService;\r
+import org.onap.portalsdk.core.domain.RoleFunction;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;\r
+import org.springframework.stereotype.Controller;\r
+import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.bind.annotation.RequestMethod;\r
+import org.springframework.web.client.RestClientException;\r
+import org.springframework.web.client.RestTemplate;\r
+import org.springframework.web.servlet.ModelAndView;\r
+import org.springframework.web.util.WebUtils;\r
+\r
+@Controller\r
+@RequestMapping("/")\r
+/**\r
+ * Replicated from\r
+ * org.onap.portalapp.controller.core.SingleSignOnController to modify the\r
+ * behavior of sending user's browser on a detour of Portal app to get the\r
+ * EPService cookie.\r
+ */\r
+public class ECDSingleSignOnController extends UnRestrictedBaseController {\r
+\r
+       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ECDSingleSignOnController.class);\r
+    private static final String REDIRECT = "redirect:";\r
+\r
+       @Autowired\r
+       private LoginService loginService;\r
+\r
+       @Autowired\r
+       private LoginStrategy loginStrategy;\r
+\r
+    @Autowired\r
+    private RoleService roleService;\r
+\r
+       private String viewName;\r
+       private String welcomeView;\r
+\r
+       /**\r
+        * Handles requests directed to the single sign-on page by the session timeout\r
+        * interceptor.\r
+        * \r
+        * @param request\r
+        *            HttpServletRequest\r
+        * @param response\r
+        *            HttpServletResponse\r
+        * @return Redirect to an appropriate address\r
+        * @throws DashboardControllerException\r
+        *             User not found\r
+        * @throws PortalAPIException\r
+        *             User ID can't be fetched\r
+        * @throws UnsupportedEncodingException\r
+        *             Encoding fails\r
+        */\r
+       @RequestMapping(value = { "/single_signon.htm" }, method = RequestMethod.GET)\r
+    public ModelAndView singleSignOnLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {\r
+        //throws DashboardControllerException, PortalAPIException, UnsupportedEncodingException {\r
+\r
+               Map<String, String> model = new HashMap<>();\r
+               HashMap<String, String> additionalParamsMap = new HashMap<>();\r
+               LoginBean commandBean = new LoginBean();\r
+\r
+               // SessionTimeoutInterceptor sets these parameters\r
+               String forwardURL = URLDecoder.decode(request.getParameter("forwardURL"), "UTF-8");\r
+               String redirectToPortal = request.getParameter("redirectToPortal");\r
+\r
+               if (isLoginCookieExist(request) && redirectToPortal == null) {\r
+                       HttpSession session = null;\r
+                       session = AppUtils.getSession(request);\r
+                       User user = UserUtils.getUserSession(request);\r
+                       if (session == null || user == null) {\r
+\r
+                               final String authMech = SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM);\r
+                               String userId = loginStrategy.getUserId(request);\r
+                               commandBean.setUserid(userId);\r
+                commandBean = getLoginService().findUser(commandBean,\r
+                        (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), additionalParamsMap);\r
+                List<RoleFunction> roleFunctionList = roleService.getRoleFunctions(userId);\r
+                               try {\r
+                                       commandBean = getLoginService().findUser(commandBean,\r
+                                                       (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY),\r
+                                                       additionalParamsMap);\r
+                               } catch (Exception ex) {\r
+                                       logger.error("singleSignOnLogin failed", ex);\r
+                                       throw new DashboardControllerException(ex);\r
+                               }\r
+                               if (commandBean.getUser() == null) {\r
+                                       String loginErrorMessage = (commandBean.getLoginErrorMessage() != null)\r
+                                                       ? commandBean.getLoginErrorMessage()\r
+                                                       : SystemProperties.MESSAGE_KEY_LOGIN_ERROR_USER_NOT_FOUND;\r
+                                       model.put(LoginStrategy.ERROR_MESSAGE_KEY, SystemProperties.getProperty(loginErrorMessage));\r
+                                       final String redirectUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL)\r
+                                                       + "?noUserError=Yes";\r
+                                       logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: user is null, redirect URL is {}",\r
+                                                       redirectUrl);\r
+                    return new ModelAndView(REDIRECT + redirectUrl);\r
+                               } else {\r
+                                       // store the user's information in the session\r
+                                       String loginMethod;\r
+                                       if (null == authMech || "".equals(authMech) || "BOTH".equals(authMech)) {\r
+                                               loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_CSP);\r
+                                       } else if ("CSP".equals(authMech)) {\r
+                                               loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_CSP);\r
+                                       } else {\r
+                                               loginMethod = SystemProperties.getProperty(SystemProperties.LOGIN_METHOD_WEB_JUNCTION);\r
+                                       }\r
+                                       UserUtils.setUserSession(request, commandBean.getUser(), commandBean.getMenu(),\r
+                            commandBean.getBusinessDirectMenu(), loginMethod, roleFunctionList);\r
+                                       initateSessionMgtHandler(request);\r
+                                       logger.debug(EELFLoggerDelegate.debugLogger,\r
+                                                       "singleSignOnLogin: create new user session for expired user {}; user {} exists in the system",\r
+                                                       userId, commandBean.getUser().getOrgUserId());\r
+                    return new ModelAndView(REDIRECT + forwardURL);\r
+                               }\r
+                       } // user is null or session is null\r
+                       else {\r
+                               // both user and session are non-null.\r
+                               logger.info(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: redirecting to the forwardURL {}",\r
+                                               forwardURL);\r
+                return new ModelAndView(REDIRECT + forwardURL);\r
+                       }\r
+               } else {\r
+                       /*\r
+                        * Login cookie not found, or redirect-to-portal parameter was found.\r
+                        */\r
+                       if (isPortalAvailable()) {\r
+                               /*\r
+                                * Redirect the user to the portal with a suitable return URL. The forwardURL\r
+                                * parameter that arrives as a parameter is a partial (not absolute) request\r
+                                * path for a page in the application. The challenge here is to compute the\r
+                                * correct absolute path for the original request so the portal can redirect the\r
+                                * user back to the right place. If the application sits behind WebJunction, or\r
+                                * if separate FE-BE hosts are used, then the URL yielded by the request has a\r
+                                * host name that is not reachable by the user.\r
+                                */\r
+                               String returnToAppUrl = null;\r
+                               if (SystemProperties.containsProperty(SystemProperties.APP_BASE_URL)) {\r
+                                       // New feature as of 1610, release 3.3.3:\r
+                                       // application can publish a base URL in system.properties\r
+                                       String appUrl = SystemProperties.getProperty(SystemProperties.APP_BASE_URL);\r
+                                       returnToAppUrl = appUrl + (appUrl.endsWith("/") ? "" : "/") + forwardURL;\r
+                                       logger.debug(EELFLoggerDelegate.debugLogger,\r
+                                                       "singleSignOnLogin: using app base URL {} and redirectURL {}", appUrl, returnToAppUrl);\r
+                               } else {\r
+                                       /**\r
+                                        * Be backward compatible with applications that don't need this feature. This\r
+                                        * is the controller for the single_signon.htm page, so the replace should\r
+                                        * always find the specified token.\r
+                                        */\r
+                                       returnToAppUrl = request.getRequestURL().toString()\r
+                                                       .replace("single_signon.htm", forwardURL);\r
+                                       logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: computed redirectURL {}",\r
+                                                       returnToAppUrl);\r
+                               }\r
+                               final String encodedReturnToAppUrl = URLEncoder.encode(returnToAppUrl, "UTF-8");\r
+                               // Also send the application's UEB key so Portal can block URL\r
+                               // reflection attacks.\r
+                               final String uebAppKey = PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY);\r
+                               final String url = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL);\r
+                               final String portalUrl = url.substring(0, url.lastIndexOf('/')) + "/process_csp";\r
+                               final String redirectUrl = portalUrl + "?uebAppKey=" + uebAppKey + "&redirectUrl="\r
+                                               + encodedReturnToAppUrl;\r
+                               logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: portal-bound redirect URL is {}",\r
+                                               redirectUrl);\r
+                return new ModelAndView(REDIRECT + redirectUrl);\r
+                       } // portal is available\r
+\r
+                       else {\r
+                               /*\r
+                                * Portal is not available. Redirect user to the login page, ignoring the\r
+                                * forwardURL parameter.\r
+                                */\r
+                               return new ModelAndView("redirect:login.htm");\r
+                       }\r
+\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Discover if the portal is available by GET-ing a resource from the REST URL\r
+        * specified in portal.properties, using a very short timeout.\r
+        * \r
+        * @return True if the portal answers, otherwise false.\r
+        */\r
+       private boolean isPortalAvailable() {\r
+               HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();\r
+               final int oneSecond = 1000;\r
+               httpRequestFactory.setConnectionRequestTimeout(oneSecond);\r
+               httpRequestFactory.setConnectTimeout(oneSecond);\r
+               httpRequestFactory.setReadTimeout(oneSecond);\r
+               RestTemplate restTemplate = new RestTemplate(httpRequestFactory);\r
+               boolean avail = true;\r
+               try {\r
+                       final String portalUrl = PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL);\r
+                       String s = restTemplate.getForObject(portalUrl, String.class);\r
+                       logger.trace("isPortalAvailable got response {}", s);\r
+               } catch (RestClientException ex) {\r
+                       logger.debug("isPortalAvailable failed", ex);\r
+                       avail = false;\r
+               }\r
+               return avail;\r
+       }\r
+\r
+       protected void initateSessionMgtHandler(HttpServletRequest request) {\r
+               String portalJSessionId = getPortalJSessionId(request);\r
+               String jSessionId = getJessionId(request);\r
+               PortalTimeoutHandler.sessionCreated(portalJSessionId, jSessionId, AppUtils.getSession(request));\r
+       }\r
+\r
+       public boolean isLoginCookieExist(HttpServletRequest request) {\r
+               Cookie ep = WebUtils.getCookie(request, LoginStrategy.EP_SERVICE);\r
+               return (ep != null);\r
+       }\r
+\r
+       public String getPortalJSessionId(HttpServletRequest request) {\r
+               Cookie ep = WebUtils.getCookie(request, LoginStrategy.EP_SERVICE);\r
+               return ep.getValue();\r
+       }\r
+\r
+       public String getJessionId(HttpServletRequest request) {\r
+               return request.getSession().getId();\r
+       }\r
+\r
+       @Override\r
+       public String getViewName() {\r
+               return viewName;\r
+       }\r
+\r
+       @Override\r
+       public void setViewName(String viewName) {\r
+               this.viewName = viewName;\r
+       }\r
+\r
+       public String getWelcomeView() {\r
+               return welcomeView;\r
+       }\r
+\r
+       public void setWelcomeView(String welcomeView) {\r
+               this.welcomeView = welcomeView;\r
+       }\r
+\r
+       public LoginService getLoginService() {\r
+               return loginService;\r
+       }\r
+\r
+       public void setLoginService(LoginService loginService) {\r
+               this.loginService = loginService;\r
+       }\r
+\r
+}\r
index 3393236..be099a7 100644 (file)
@@ -1,86 +1,86 @@
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.controller;
-
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.onap.ccsdk.dashboard.model.HealthStatus;
-import org.openecomp.portalsdk.core.controller.UnRestrictedBaseController;
-import org.openecomp.portalsdk.core.domain.App;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.service.DataAccessService;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * This controller responds to probes for application health, returning a JSON
- * body to indicate current status.
- */
-@RestController
-@Configuration
-@EnableAspectJAutoProxy
-@RequestMapping("/")
-public class HealthCheckController extends UnRestrictedBaseController {
-
-       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HealthCheckController.class);
-
-       private static final String HEALTH_CHECK_PATH = "/healthCheck";
-
-       @Autowired
-       private DataAccessService dataAccessService;
-       
-       /**
-        * Checks application health by making a trivial query to (what??).
-        * 
-        * @param request
-        *            HttpServletRequest
-        * @return 200 if database access succeeds, 500 if it fails.
-        */
-       @RequestMapping(value = { HEALTH_CHECK_PATH }, method = RequestMethod.GET, produces = "application/json")
-       public HealthStatus healthCheck(HttpServletRequest request) {
-               logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, DashboardRestrictedBaseController.APP_NAME);
-               logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());
-               HealthStatus healthStatus = null;
-               try {
-                       logger.debug(EELFLoggerDelegate.debugLogger, "Performing health check");
-                       @SuppressWarnings("unchecked")
-                       // Get the single app.
-                       List<App> list = dataAccessService.getList(App.class, null);
-                       if (!list.isEmpty())
-                               healthStatus = new HealthStatus(200, SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME) + " health check succeeded");
-                       else
-                               healthStatus = new HealthStatus(500, SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME) + " health check failed to run db query");
-               } catch (Exception ex) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex);
-                       healthStatus = new HealthStatus(500, "health check failed: " + ex.toString());
-               }
-               return healthStatus;
-       }
-
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.controller;\r
+\r
+import java.util.List;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+import org.onap.ccsdk.dashboard.model.HealthStatus;\r
+import org.onap.portalsdk.core.controller.UnRestrictedBaseController;\r
+import org.onap.portalsdk.core.domain.App;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.onap.portalsdk.core.service.DataAccessService;\r
+import org.onap.portalsdk.core.util.SystemProperties;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.context.annotation.Configuration;\r
+import org.springframework.context.annotation.EnableAspectJAutoProxy;\r
+import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.bind.annotation.RequestMethod;\r
+import org.springframework.web.bind.annotation.RestController;\r
+\r
+/**\r
+ * This controller responds to probes for application health, returning a JSON\r
+ * body to indicate current status.\r
+ */\r
+@RestController\r
+@Configuration\r
+@EnableAspectJAutoProxy\r
+@RequestMapping("/")\r
+public class HealthCheckController extends UnRestrictedBaseController {\r
+\r
+       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(HealthCheckController.class);\r
+\r
+       private static final String HEALTH_CHECK_PATH = "/healthCheck";\r
+\r
+       @Autowired\r
+       private DataAccessService dataAccessService;\r
+       \r
+       /**\r
+        * Checks application health by making a trivial query to (what??).\r
+        * \r
+        * @param request\r
+        *            HttpServletRequest\r
+        * @return 200 if database access succeeds, 500 if it fails.\r
+        */\r
+       @RequestMapping(value = { HEALTH_CHECK_PATH }, method = RequestMethod.GET, produces = "application/json")\r
+       public HealthStatus healthCheck(HttpServletRequest request) {\r
+               logger.setRequestBasedDefaultsIntoGlobalLoggingContext(request, DashboardRestrictedBaseController.APP_NAME);\r
+               logger.info(EELFLoggerDelegate.auditLogger, request.getMethod() + request.getRequestURI());\r
+               HealthStatus healthStatus = null;\r
+               try {\r
+                       logger.debug(EELFLoggerDelegate.debugLogger, "Performing health check");\r
+                       @SuppressWarnings("unchecked")\r
+                       // Get the single app.\r
+                       List<App> list = dataAccessService.getList(App.class, null);\r
+                       if (!list.isEmpty())\r
+                               healthStatus = new HealthStatus(200, SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME) + " health check succeeded");\r
+                       else\r
+                               healthStatus = new HealthStatus(500, SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME) + " health check failed to run db query");\r
+               } catch (Exception ex) {\r
+                       logger.error(EELFLoggerDelegate.errorLogger, "Failed to perform health check", ex);\r
+                       healthStatus = new HealthStatus(500, "health check failed: " + ex.toString());\r
+               }\r
+               return healthStatus;\r
+       }\r
+\r
+}\r
index 1e74611..397f2ed 100644 (file)
@@ -1,71 +1,71 @@
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.domain;
-
-import org.openecomp.portalsdk.core.domain.support.DomainVo;
-
-/**
- * Model for controller endpoint information stored in database. A single row
- * for a user represents a selected endpoint.
- */
-public class ControllerEndpoint extends DomainVo {
-
-       private static final long serialVersionUID = 8785223545128054402L;
-
-       private long userId;
-       private String name;
-       private String url;
-
-       public ControllerEndpoint() {
-       }
-
-       public ControllerEndpoint(long userId, String name, String url) {
-               this.userId = userId;
-               this.name = name;
-               this.url = url;
-       }
-
-       public long getUserId() {
-               return userId;
-       }
-
-       public void setUserId(long userId) {
-               this.userId = userId;
-       }
-
-       public String getName() {
-               return name;
-       }
-
-       public void setName(String name) {
-               this.name = name;
-       }
-
-       public String getUrl() {
-               return url;
-       }
-
-       public void setUrl(String url) {
-               this.url = url;
-       }
-
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.domain;\r
+\r
+import org.onap.portalsdk.core.domain.support.DomainVo;\r
+\r
+/**\r
+ * Model for controller endpoint information stored in database. A single row\r
+ * for a user represents a selected endpoint.\r
+ */\r
+public class ControllerEndpoint extends DomainVo {\r
+\r
+       private static final long serialVersionUID = 8785223545128054402L;\r
+\r
+       private long userId;\r
+       private String name;\r
+       private String url;\r
+\r
+       public ControllerEndpoint() {\r
+       }\r
+\r
+       public ControllerEndpoint(long userId, String name, String url) {\r
+               this.userId = userId;\r
+               this.name = name;\r
+               this.url = url;\r
+       }\r
+\r
+       public long getUserId() {\r
+               return userId;\r
+       }\r
+\r
+       public void setUserId(long userId) {\r
+               this.userId = userId;\r
+       }\r
+\r
+       public String getName() {\r
+               return name;\r
+       }\r
+\r
+       public void setName(String name) {\r
+               this.name = name;\r
+       }\r
+\r
+       public String getUrl() {\r
+               return url;\r
+       }\r
+\r
+       public void setUrl(String url) {\r
+               this.url = url;\r
+       }\r
+\r
+}\r
index 02c892f..7af9e49 100644 (file)
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.model;
-
-import org.onap.ccsdk.dashboard.exception.DashboardControllerException;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
-
-/**
- * Model with Controller username and password for use only within the back end;
- * never serialized as JSON.
- */
-public class ControllerEndpointCredentials extends ControllerEndpointTransport {
-
-       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ControllerEndpointCredentials.class);
-
-       public String username;
-       public String password;
-       public boolean isEncryptedPass;
-
-       public ControllerEndpointCredentials(boolean selected, String name, String url, String username, String password,
-                       boolean isEncryptedPass) {
-               super(selected, name, url);
-               this.username = username;
-               this.password = password;
-               this.isEncryptedPass = isEncryptedPass;
-       }
-
-       public String getUsername() {
-               return username;
-       }
-
-       public void setUsername(String username) {
-               this.username = username;
-       }
-
-       public String getPassword() {
-               return password;
-       }
-
-       public void setPassword(String password) {
-               this.password = password;
-       }
-
-       public boolean getEncryptedPassword() {
-               return isEncryptedPass;
-       }
-
-       public void setEncryptedPassword(boolean isEncryptedPass) {
-               this.isEncryptedPass = isEncryptedPass;
-       }
-
-       /**
-        * Convenience method to yield a ControllerEndpointTransport object.
-        * 
-        * @return ControllerEndpoint with copy of the non-privileged data
-        */
-       public ControllerEndpointTransport toControllerEndpointTransport() {
-               return new ControllerEndpointTransport(getSelected(), getName(), getUrl());
-       }
-
-       /**
-        * Accepts clear text and stores an encrypted value; as a side effect, sets the
-        * encrypted flag to true.
-        * 
-        * @param plainText
-        *            Clear-text password
-        * @throws DashboardControllerException
-        *             If encryption fails
-        */
-       public void encryptPassword(final String plainText) throws DashboardControllerException {
-               try {
-                       this.password = CipherUtil.encrypt(plainText);
-                       this.isEncryptedPass = true;
-               } catch (Exception ex) {
-                       logger.error("encryptPassword failed", ex);
-                       throw new DashboardControllerException(ex);
-               }
-       }
-
-       /**
-        * Client should call this method if {@link #getEncryptedPassword()} returns
-        * true.
-        * 
-        * @return Clear-text password.
-        * @throws DashboardControllerException
-        *             If decryption fails
-        */
-       public String decryptPassword() throws DashboardControllerException {
-               try {
-                       return CipherUtil.decrypt(password);
-               } catch (Exception ex) {
-                       logger.error("decryptPassword failed", ex);
-                       throw new DashboardControllerException(ex);
-               }
-       }
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.model;\r
+\r
+import org.onap.ccsdk.dashboard.exception.DashboardControllerException;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.onap.portalsdk.core.onboarding.util.CipherUtil;\r
+\r
+/**\r
+ * Model with Controller username and password for use only within the back end;\r
+ * never serialized as JSON.\r
+ */\r
+public class ControllerEndpointCredentials extends ControllerEndpointTransport {\r
+\r
+       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ControllerEndpointCredentials.class);\r
+\r
+       public String username;\r
+       public String password;\r
+       public boolean isEncryptedPass;\r
+\r
+       public ControllerEndpointCredentials(boolean selected, String name, String url, String username, String password,\r
+                       boolean isEncryptedPass) {\r
+               super(selected, name, url);\r
+               this.username = username;\r
+               this.password = password;\r
+               this.isEncryptedPass = isEncryptedPass;\r
+       }\r
+\r
+       public String getUsername() {\r
+               return username;\r
+       }\r
+\r
+       public void setUsername(String username) {\r
+               this.username = username;\r
+       }\r
+\r
+       public String getPassword() {\r
+               return password;\r
+       }\r
+\r
+       public void setPassword(String password) {\r
+               this.password = password;\r
+       }\r
+\r
+       public boolean getEncryptedPassword() {\r
+               return isEncryptedPass;\r
+       }\r
+\r
+       public void setEncryptedPassword(boolean isEncryptedPass) {\r
+               this.isEncryptedPass = isEncryptedPass;\r
+       }\r
+\r
+       /**\r
+        * Convenience method to yield a ControllerEndpointTransport object.\r
+        * \r
+        * @return ControllerEndpoint with copy of the non-privileged data\r
+        */\r
+       public ControllerEndpointTransport toControllerEndpointTransport() {\r
+               return new ControllerEndpointTransport(getSelected(), getName(), getUrl());\r
+       }\r
+\r
+       /**\r
+        * Accepts clear text and stores an encrypted value; as a side effect, sets the\r
+        * encrypted flag to true.\r
+        * \r
+        * @param plainText\r
+        *            Clear-text password\r
+        * @throws DashboardControllerException\r
+        *             If encryption fails\r
+        */\r
+       public void encryptPassword(final String plainText) throws DashboardControllerException {\r
+               try {\r
+                       this.password = CipherUtil.encrypt(plainText);\r
+                       this.isEncryptedPass = true;\r
+               } catch (Exception ex) {\r
+                       logger.error("encryptPassword failed", ex);\r
+                       throw new DashboardControllerException(ex);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Client should call this method if {@link #getEncryptedPassword()} returns\r
+        * true.\r
+        * \r
+        * @return Clear-text password.\r
+        * @throws DashboardControllerException\r
+        *             If decryption fails\r
+        */\r
+       public String decryptPassword() throws DashboardControllerException {\r
+               try {\r
+                       return CipherUtil.decrypt(password);\r
+               } catch (Exception ex) {\r
+                       logger.error("decryptPassword failed", ex);\r
+                       throw new DashboardControllerException(ex);\r
+               }\r
+       }\r
 }
\ No newline at end of file
index bb79c9f..2e28ad2 100644 (file)
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.rest;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.onap.ccsdk.dashboard.model.CloudifyBlueprintContent;
-import org.onap.ccsdk.dashboard.model.CloudifyBlueprintList;
-import org.onap.ccsdk.dashboard.model.CloudifyBlueprintUpload;
-import org.onap.ccsdk.dashboard.model.CloudifyDeploymentList;
-import org.onap.ccsdk.dashboard.model.CloudifyDeploymentRequest;
-import org.onap.ccsdk.dashboard.model.CloudifyExecution;
-import org.onap.ccsdk.dashboard.model.CloudifyExecutionList;
-import org.onap.ccsdk.dashboard.model.CloudifyExecutionRequest;
-import org.onap.ccsdk.dashboard.model.ConsulDatacenter;
-import org.onap.ccsdk.dashboard.model.ConsulHealthServiceRegistration;
-import org.onap.ccsdk.dashboard.model.ConsulNodeInfo;
-import org.onap.ccsdk.dashboard.model.ConsulServiceHealth;
-import org.onap.ccsdk.dashboard.model.ConsulServiceHealthHistory;
-import org.onap.ccsdk.dashboard.model.ConsulServiceInfo;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.springframework.core.ParameterizedTypeReference;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.RestTemplate;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Provides methods for accessing the ECOMP Controller API via REST. Most
- * methods are just simple proxies. Only the methods that fetch one page of data
- * have to do any real work.
- * 
- * Implemented using Spring RestTemplate. Supports basic HTTP authentication.
- * 
- */
-public class ControllerRestClientImpl implements IControllerRestClient {
-
-       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ControllerRestClientImpl.class);
-    private static final String DEPLOYMENT_ID = "deployment_id";
-
-       private final String baseUrl;
-       private final RestTemplate restTemplate;
-       private final ObjectMapper objectMapper = new ObjectMapper();
-
-       /**
-        * Builds a restTemplate. If username and password are supplied, uses basic
-        * HTTP authentication.
-        * 
-        * @param webapiUrl
-        *            URL of the web endpoint
-        * @param user
-        *            user name; ignored if null
-        * @param pass
-        *            password
-        */
-       public ControllerRestClientImpl(String webapiUrl, String user, String pass) {
-               if (webapiUrl == null)
-                       throw new IllegalArgumentException("Null URL not permitted");
-
-               URL url = null;
-               try {
-                       url = new URL(webapiUrl);
-                       baseUrl = url.toExternalForm();
-               } catch (MalformedURLException ex) {
-                       throw new RuntimeException("Failed to parse URL", ex);
-               }
-               final HttpHost httpHost = new HttpHost(url.getHost(), url.getPort());
-
-               // Build a client with a credentials provider
-               CloseableHttpClient httpClient = null;
-               if (user != null && pass != null) {
-                       CredentialsProvider credsProvider = new BasicCredentialsProvider();
-                       credsProvider.setCredentials(new AuthScope(httpHost), new UsernamePasswordCredentials(user, pass));
-                       httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(credsProvider).build();
-               } else {
-                       httpClient = HttpClientBuilder.create().build();
-               }
-               // Create request factory
-               HttpComponentsClientHttpRequestFactoryBasicAuth requestFactory = new HttpComponentsClientHttpRequestFactoryBasicAuth(
-                               httpHost);
-               requestFactory.setHttpClient(httpClient);
-
-               // Put the factory in the template
-               this.restTemplate = new RestTemplate();
-               restTemplate.setRequestFactory(requestFactory);
-       }
-
-       /**
-        * Builds URL ensuring appropriate separators. The base comes from
-        * properties file so could have many problems.
-        * 
-        * @param base
-        * @param suffix
-        * @param queryParams
-        *            key-value pairs; i.e. must have an even number of entries.
-        *            Ignored if null.
-        * @return
-        */
-       private String buildUrl(final String[] path, final String[] queryParams) {
-               StringBuilder sb = new StringBuilder(path[0]);
-               for (int p = 1; p < path.length; ++p) {
-                       if (!path[p - 1].endsWith("/") && !path[p].startsWith("/"))
-                               sb.append('/');
-                       sb.append(path[p]);
-               }
-               if (queryParams != null && queryParams.length > 0) {
-                       sb.append('?');
-                       int i = 0;
-                       while (i < queryParams.length) {
-                               if (i > 0)
-                                       sb.append('&');
-                               sb.append(queryParams[i]);
-                               sb.append('=');
-                               sb.append(queryParams[i + 1]);
-                               i += 2;
-                       }
-               }
-               return sb.toString();
-       }
-
-       @Override
-       public CloudifyBlueprintList getBlueprints() {
-               String url = buildUrl(new String[] { baseUrl, blueprintsPath }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "getBlueprints: url {}", url);
-               ResponseEntity<CloudifyBlueprintList> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<CloudifyBlueprintList>() {
-                               });
-        return response.getBody();
-    }
-
-       @Override
-       public CloudifyBlueprintList getBlueprint(final String id) {
-               String url = buildUrl(new String[] { baseUrl, blueprintsPath }, new String[] { "id", id });
-               logger.debug(EELFLoggerDelegate.debugLogger, "getBlueprint: url {}", url);
-               ResponseEntity<CloudifyBlueprintList> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<CloudifyBlueprintList>() {
-                               });
-        return response.getBody();
-       }
-
-       @Override
-       public CloudifyBlueprintContent viewBlueprint(final String id) {
-               String url = buildUrl(new String[] { baseUrl, viewBlueprintsPath }, new String[] { "id", id });
-               logger.debug(EELFLoggerDelegate.debugLogger, "viewBlueprint: url {}", url);
-               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, null, String.class);
-               String yaml = response.getBody();
-        return new CloudifyBlueprintContent(id, yaml);
-       }
-
-       @Override
-       public CloudifyBlueprintList uploadBlueprint(CloudifyBlueprintUpload blueprint) {
-               String url = buildUrl(new String[] { baseUrl, blueprintsPath }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "uploadBlueprint: url {}", url);
-        return restTemplate.postForObject(url, blueprint, CloudifyBlueprintList.class);
-       }
-
-       @Override
-       public int deleteBlueprint(final String id) {
-               String url = buildUrl(new String[] { baseUrl, blueprintsPath, id }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "deleteBlueprint: url {}", url);
-               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.DELETE, null,
-                               new ParameterizedTypeReference<String>() {
-                               });
-               return response.getStatusCode().value();
-       }
-
-       @Override
-       public CloudifyDeploymentList getDeployments() {
-               String url = buildUrl(new String[] { baseUrl, deploymentsPath }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "getDeployments: url {}", url);
-               ResponseEntity<CloudifyDeploymentList> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<CloudifyDeploymentList>() {
-                               });
-        return response.getBody();
-       }
-
-       @Override
-       public CloudifyDeploymentList getDeployment(final String id) {
-               String url = buildUrl(new String[] { baseUrl, deploymentsPath }, new String[] { "id", id });
-               logger.debug(EELFLoggerDelegate.debugLogger, "getDeployment: url {}", url);
-               ResponseEntity<CloudifyDeploymentList> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<CloudifyDeploymentList>() {
-            });
-        return response.getBody();
-       }
-
-       @Override
-       public CloudifyDeploymentList createDeployment(CloudifyDeploymentRequest deployment) {
-               String url = buildUrl(new String[] { baseUrl, deploymentsPath }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "createDeployment: url {}", url);
-        return restTemplate.postForObject(url, deployment, CloudifyDeploymentList.class);
-       }
-
-       @Override
-       public int deleteDeployment(final String id, boolean ignoreLiveNodes) {
-               String url = buildUrl(new String[] { baseUrl, deploymentsPath, id },
-                               new String[] { "ignore_live_nodes", Boolean.toString(ignoreLiveNodes) });
-               logger.debug(EELFLoggerDelegate.debugLogger, "deleteDeployment: url {}", url);
-               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.DELETE, null,
-                               new ParameterizedTypeReference<String>() {
-                               });
-               return response.getStatusCode().value();
-       }
-
-       @Override
-       public CloudifyExecutionList getExecutions(final String deploymentId) {
-        String url = buildUrl(new String[]{baseUrl, executionsPath}, new String[]{DEPLOYMENT_ID, deploymentId});
-               logger.debug(EELFLoggerDelegate.debugLogger, "getExecutions: url {}", url);
-               ResponseEntity<CloudifyExecutionList> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<CloudifyExecutionList>() {
-                               });
-        return response.getBody();
-       }
-
-       @Override
-       public CloudifyExecutionList getExecution(String executionId, String deploymentId) {
-               String url = buildUrl(new String[] { baseUrl, executionsPath, executionId },
-            new String[]{DEPLOYMENT_ID, deploymentId});
-               logger.debug(EELFLoggerDelegate.debugLogger, "getExecution: url {}", url);
-               ResponseEntity<CloudifyExecutionList> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<CloudifyExecutionList>() {
-                               });
-        return response.getBody();
-       }
-
-       @Override
-       public CloudifyExecution startExecution(CloudifyExecutionRequest execution) {
-               String url = buildUrl(new String[] { baseUrl, executionsPath }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "startExecution: url {}", url);
-        return restTemplate.postForObject(url, execution, CloudifyExecution.class);
-       }
-
-       @Override
-       public int cancelExecution(final String executionId, final String deploymentId, final String action) {
-               String url = buildUrl(new String[] { baseUrl, executionsPath, executionId },
-            new String[]{DEPLOYMENT_ID, deploymentId, "action", action});
-               logger.debug(EELFLoggerDelegate.debugLogger, "deleteExecution: url {}", url);
-               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.DELETE, null,
-                               new ParameterizedTypeReference<String>() {
-                               });
-               return response.getStatusCode().value();
-       }
-
-       @Override
-       public URI registerService(ConsulHealthServiceRegistration registration) {
-               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "register" }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "registerService: url {}", url);
-        return restTemplate.postForLocation(url, registration);
-       }
-
-       @Override
-       public int deregisterService(String serviceName) {
-               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "deregister" , serviceName}, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "deregisterService: url {}", url);
-               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, null,
-                               new ParameterizedTypeReference<String>() {
-                               });
-               return response.getStatusCode().value();
-       }
-
-       /**
-        * Translates the awkward map of String-to-List of IP into a list of
-        * ConsulServiceInfo objects
-        */
-       @SuppressWarnings("unchecked")
-       @Override
-       public List<ConsulServiceInfo> getServices() {
-               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "services" }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "getServicesHealth: url {}", url);
-               ResponseEntity<Map<String, Object>> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<Map<String, Object>>() {
-                               });
-               Map<String, Object> serviceInfo = response.getBody();
-               List<ConsulServiceInfo> list = new ArrayList<>();
-               for (Map.Entry<String, Object> entry : serviceInfo.entrySet()) {
-                       // Be defensive
-            List<String> addrs;
-                       if (entry.getValue() instanceof List<?>)
-                               addrs = (List<String>) entry.getValue();
-                       else
-                               addrs = new ArrayList<>();
-                       list.add(new ConsulServiceInfo(entry.getKey(), addrs));
-               }
-               return list;
-       }
-
-       @Override
-       public List<ConsulServiceHealth> getServiceHealth(String serviceName) {
-               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "services", serviceName }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "getServiceHealth: url {}", url);
-               ResponseEntity<List<ConsulServiceHealth>> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<List<ConsulServiceHealth>>() {
-                               });
-        return response.getBody();
-       }
-
-       @Override
-       public List<ConsulServiceHealthHistory> getServiceHealthHistory(String serviceName, Instant start,
-                       Instant end) {
-               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "svchist", serviceName },
-                               new String[] { "start", start.toString(), "end", end.toString() });
-               logger.debug(EELFLoggerDelegate.debugLogger, "getServiceHealthHistory: url {}", url);
-               // Hack around an odd interface that returns non-JSON on error:
-               // "No health Data found for the selected dates or service"
-               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<String>() { });
-               if (response.getBody().startsWith("No health"))
-                       throw new RuntimeException(response.getBody());         
-               List<ConsulServiceHealthHistory> result = null;
-               try {
-                       TypeReference<List<ConsulServiceHealthHistory>> typeRef = new TypeReference<List<ConsulServiceHealthHistory>>() {       };
-                       result = objectMapper.readValue(response.getBody(), typeRef);
-               } catch (Exception ex) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "getServiceHealthHistory failed to parse response body", ex);
-               }
-               return result;
-       }
-
-       @Override
-       public List<ConsulNodeInfo> getNodes() {
-               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "nodes" }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "getNodesHealth: url {}", url);
-               ResponseEntity<List<ConsulNodeInfo>> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<List<ConsulNodeInfo>>() {
-                               });
-        return response.getBody();
-       }
-
-       @Override
-       public List<ConsulServiceHealth> getNodeServicesHealth(String nodeId) {
-               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "nodes", nodeId }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "getNodeServicesHealth: url {}", url);
-               ResponseEntity<List<ConsulServiceHealth>> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<List<ConsulServiceHealth>>() {
-            });
-        return response.getBody();
-       }
-
-       @Override
-       public List<ConsulDatacenter> getDatacenters() {
-               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "datacenters" }, null);
-               logger.debug(EELFLoggerDelegate.debugLogger, "getDatacentersHealth: url {}", url);
-               ResponseEntity<List<String>> response = restTemplate.exchange(url, HttpMethod.GET, null,
-                               new ParameterizedTypeReference<List<String>>() {
-                               });
-               List<String> list = response.getBody();
-               List<ConsulDatacenter> result = new ArrayList<>();
-               for (String dc : list)
-                       result.add(new ConsulDatacenter(dc));
-               return result;
-       }
-
-       /**
-        * Simple test
-        * 
-        * @param args
-        *            blueprint ID
-        * @throws IllegalArgumentException
-        *             On bad arguments
-        */
-       public static void main(String[] args) throws IllegalArgumentException {
-               if (args.length != 1)
-                       throw new IllegalArgumentException("Single argument expected: blueprint-id");
-               ControllerRestClientImpl client = new ControllerRestClientImpl("http://localhost:8081/controller", "dbus_user",
-                               "dbus_pass");
-               final String id = args[0];
-        logger.info("Requesting blueprint for " + id);
-               CloudifyBlueprintList list = client.getBlueprint(id);
-               if (list == null)
-            logger.error("Received null");
-               else
-                       for (int i = 0; i < list.items.size(); ++i) {
-                logger.info("Blueprint " + Integer.toString(i));
-                logger.info(list.items.get(i).toString());
-                       }
-       }
-
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.rest;\r
+\r
+import java.net.MalformedURLException;\r
+import java.net.URI;\r
+import java.net.URL;\r
+import java.time.Instant;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.http.HttpHost;\r
+import org.apache.http.auth.AuthScope;\r
+import org.apache.http.auth.UsernamePasswordCredentials;\r
+import org.apache.http.client.CredentialsProvider;\r
+import org.apache.http.impl.client.BasicCredentialsProvider;\r
+import org.apache.http.impl.client.CloseableHttpClient;\r
+import org.apache.http.impl.client.HttpClientBuilder;\r
+import org.onap.ccsdk.dashboard.model.CloudifyBlueprintContent;\r
+import org.onap.ccsdk.dashboard.model.CloudifyBlueprintList;\r
+import org.onap.ccsdk.dashboard.model.CloudifyBlueprintUpload;\r
+import org.onap.ccsdk.dashboard.model.CloudifyDeploymentList;\r
+import org.onap.ccsdk.dashboard.model.CloudifyDeploymentRequest;\r
+import org.onap.ccsdk.dashboard.model.CloudifyExecution;\r
+import org.onap.ccsdk.dashboard.model.CloudifyExecutionList;\r
+import org.onap.ccsdk.dashboard.model.CloudifyExecutionRequest;\r
+import org.onap.ccsdk.dashboard.model.ConsulDatacenter;\r
+import org.onap.ccsdk.dashboard.model.ConsulHealthServiceRegistration;\r
+import org.onap.ccsdk.dashboard.model.ConsulNodeInfo;\r
+import org.onap.ccsdk.dashboard.model.ConsulServiceHealth;\r
+import org.onap.ccsdk.dashboard.model.ConsulServiceHealthHistory;\r
+import org.onap.ccsdk.dashboard.model.ConsulServiceInfo;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.springframework.core.ParameterizedTypeReference;\r
+import org.springframework.http.HttpMethod;\r
+import org.springframework.http.ResponseEntity;\r
+import org.springframework.web.client.RestTemplate;\r
+\r
+import com.fasterxml.jackson.core.type.TypeReference;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+/**\r
+ * Provides methods for accessing the ECOMP Controller API via REST. Most\r
+ * methods are just simple proxies. Only the methods that fetch one page of data\r
+ * have to do any real work.\r
+ * \r
+ * Implemented using Spring RestTemplate. Supports basic HTTP authentication.\r
+ * \r
+ */\r
+public class ControllerRestClientImpl implements IControllerRestClient {\r
+\r
+       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ControllerRestClientImpl.class);\r
+    private static final String DEPLOYMENT_ID = "deployment_id";\r
+\r
+       private final String baseUrl;\r
+       private final RestTemplate restTemplate;\r
+       private final ObjectMapper objectMapper = new ObjectMapper();\r
+\r
+       /**\r
+        * Builds a restTemplate. If username and password are supplied, uses basic\r
+        * HTTP authentication.\r
+        * \r
+        * @param webapiUrl\r
+        *            URL of the web endpoint\r
+        * @param user\r
+        *            user name; ignored if null\r
+        * @param pass\r
+        *            password\r
+        */\r
+       public ControllerRestClientImpl(String webapiUrl, String user, String pass) {\r
+               if (webapiUrl == null)\r
+                       throw new IllegalArgumentException("Null URL not permitted");\r
+\r
+               URL url = null;\r
+               try {\r
+                       url = new URL(webapiUrl);\r
+                       baseUrl = url.toExternalForm();\r
+               } catch (MalformedURLException ex) {\r
+                       throw new RuntimeException("Failed to parse URL", ex);\r
+               }\r
+               final HttpHost httpHost = new HttpHost(url.getHost(), url.getPort());\r
+\r
+               // Build a client with a credentials provider\r
+               CloseableHttpClient httpClient = null;\r
+               if (user != null && pass != null) {\r
+                       CredentialsProvider credsProvider = new BasicCredentialsProvider();\r
+                       credsProvider.setCredentials(new AuthScope(httpHost), new UsernamePasswordCredentials(user, pass));\r
+                       httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(credsProvider).build();\r
+               } else {\r
+                       httpClient = HttpClientBuilder.create().build();\r
+               }\r
+               // Create request factory\r
+               HttpComponentsClientHttpRequestFactoryBasicAuth requestFactory = new HttpComponentsClientHttpRequestFactoryBasicAuth(\r
+                               httpHost);\r
+               requestFactory.setHttpClient(httpClient);\r
+\r
+               // Put the factory in the template\r
+               this.restTemplate = new RestTemplate();\r
+               restTemplate.setRequestFactory(requestFactory);\r
+       }\r
+\r
+       /**\r
+        * Builds URL ensuring appropriate separators. The base comes from\r
+        * properties file so could have many problems.\r
+        * \r
+        * @param base\r
+        * @param suffix\r
+        * @param queryParams\r
+        *            key-value pairs; i.e. must have an even number of entries.\r
+        *            Ignored if null.\r
+        * @return\r
+        */\r
+       private String buildUrl(final String[] path, final String[] queryParams) {\r
+               StringBuilder sb = new StringBuilder(path[0]);\r
+               for (int p = 1; p < path.length; ++p) {\r
+                       if (!path[p - 1].endsWith("/") && !path[p].startsWith("/"))\r
+                               sb.append('/');\r
+                       sb.append(path[p]);\r
+               }\r
+               if (queryParams != null && queryParams.length > 0) {\r
+                       sb.append('?');\r
+                       int i = 0;\r
+                       while (i < queryParams.length) {\r
+                               if (i > 0)\r
+                                       sb.append('&');\r
+                               sb.append(queryParams[i]);\r
+                               sb.append('=');\r
+                               sb.append(queryParams[i + 1]);\r
+                               i += 2;\r
+                       }\r
+               }\r
+               return sb.toString();\r
+       }\r
+\r
+       @Override\r
+       public CloudifyBlueprintList getBlueprints() {\r
+               String url = buildUrl(new String[] { baseUrl, blueprintsPath }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getBlueprints: url {}", url);\r
+               ResponseEntity<CloudifyBlueprintList> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<CloudifyBlueprintList>() {\r
+                               });\r
+        return response.getBody();\r
+    }\r
+\r
+       @Override\r
+       public CloudifyBlueprintList getBlueprint(final String id) {\r
+               String url = buildUrl(new String[] { baseUrl, blueprintsPath }, new String[] { "id", id });\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getBlueprint: url {}", url);\r
+               ResponseEntity<CloudifyBlueprintList> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<CloudifyBlueprintList>() {\r
+                               });\r
+        return response.getBody();\r
+       }\r
+\r
+       @Override\r
+       public CloudifyBlueprintContent viewBlueprint(final String id) {\r
+               String url = buildUrl(new String[] { baseUrl, viewBlueprintsPath }, new String[] { "id", id });\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "viewBlueprint: url {}", url);\r
+               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, null, String.class);\r
+               String yaml = response.getBody();\r
+        return new CloudifyBlueprintContent(id, yaml);\r
+       }\r
+\r
+       @Override\r
+       public CloudifyBlueprintList uploadBlueprint(CloudifyBlueprintUpload blueprint) {\r
+               String url = buildUrl(new String[] { baseUrl, blueprintsPath }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "uploadBlueprint: url {}", url);\r
+        return restTemplate.postForObject(url, blueprint, CloudifyBlueprintList.class);\r
+       }\r
+\r
+       @Override\r
+       public int deleteBlueprint(final String id) {\r
+               String url = buildUrl(new String[] { baseUrl, blueprintsPath, id }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "deleteBlueprint: url {}", url);\r
+               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.DELETE, null,\r
+                               new ParameterizedTypeReference<String>() {\r
+                               });\r
+               return response.getStatusCode().value();\r
+       }\r
+\r
+       @Override\r
+       public CloudifyDeploymentList getDeployments() {\r
+               String url = buildUrl(new String[] { baseUrl, deploymentsPath }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getDeployments: url {}", url);\r
+               ResponseEntity<CloudifyDeploymentList> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<CloudifyDeploymentList>() {\r
+                               });\r
+        return response.getBody();\r
+       }\r
+\r
+       @Override\r
+       public CloudifyDeploymentList getDeployment(final String id) {\r
+               String url = buildUrl(new String[] { baseUrl, deploymentsPath }, new String[] { "id", id });\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getDeployment: url {}", url);\r
+               ResponseEntity<CloudifyDeploymentList> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<CloudifyDeploymentList>() {\r
+            });\r
+        return response.getBody();\r
+       }\r
+\r
+       @Override\r
+       public CloudifyDeploymentList createDeployment(CloudifyDeploymentRequest deployment) {\r
+               String url = buildUrl(new String[] { baseUrl, deploymentsPath }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "createDeployment: url {}", url);\r
+        return restTemplate.postForObject(url, deployment, CloudifyDeploymentList.class);\r
+       }\r
+\r
+       @Override\r
+       public int deleteDeployment(final String id, boolean ignoreLiveNodes) {\r
+               String url = buildUrl(new String[] { baseUrl, deploymentsPath, id },\r
+                               new String[] { "ignore_live_nodes", Boolean.toString(ignoreLiveNodes) });\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "deleteDeployment: url {}", url);\r
+               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.DELETE, null,\r
+                               new ParameterizedTypeReference<String>() {\r
+                               });\r
+               return response.getStatusCode().value();\r
+       }\r
+\r
+       @Override\r
+       public CloudifyExecutionList getExecutions(final String deploymentId) {\r
+        String url = buildUrl(new String[]{baseUrl, executionsPath}, new String[]{DEPLOYMENT_ID, deploymentId});\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getExecutions: url {}", url);\r
+               ResponseEntity<CloudifyExecutionList> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<CloudifyExecutionList>() {\r
+                               });\r
+        return response.getBody();\r
+       }\r
+\r
+       @Override\r
+       public CloudifyExecutionList getExecution(String executionId, String deploymentId) {\r
+               String url = buildUrl(new String[] { baseUrl, executionsPath, executionId },\r
+            new String[]{DEPLOYMENT_ID, deploymentId});\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getExecution: url {}", url);\r
+               ResponseEntity<CloudifyExecutionList> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<CloudifyExecutionList>() {\r
+                               });\r
+        return response.getBody();\r
+       }\r
+\r
+       @Override\r
+       public CloudifyExecution startExecution(CloudifyExecutionRequest execution) {\r
+               String url = buildUrl(new String[] { baseUrl, executionsPath }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "startExecution: url {}", url);\r
+        return restTemplate.postForObject(url, execution, CloudifyExecution.class);\r
+       }\r
+\r
+       @Override\r
+       public int cancelExecution(final String executionId, final String deploymentId, final String action) {\r
+               String url = buildUrl(new String[] { baseUrl, executionsPath, executionId },\r
+            new String[]{DEPLOYMENT_ID, deploymentId, "action", action});\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "deleteExecution: url {}", url);\r
+               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.DELETE, null,\r
+                               new ParameterizedTypeReference<String>() {\r
+                               });\r
+               return response.getStatusCode().value();\r
+       }\r
+\r
+       @Override\r
+       public URI registerService(ConsulHealthServiceRegistration registration) {\r
+               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "register" }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "registerService: url {}", url);\r
+        return restTemplate.postForLocation(url, registration);\r
+       }\r
+\r
+       @Override\r
+       public int deregisterService(String serviceName) {\r
+               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "deregister" , serviceName}, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "deregisterService: url {}", url);\r
+               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, null,\r
+                               new ParameterizedTypeReference<String>() {\r
+                               });\r
+               return response.getStatusCode().value();\r
+       }\r
+\r
+       /**\r
+        * Translates the awkward map of String-to-List of IP into a list of\r
+        * ConsulServiceInfo objects\r
+        */\r
+       @SuppressWarnings("unchecked")\r
+       @Override\r
+       public List<ConsulServiceInfo> getServices() {\r
+               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "services" }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getServicesHealth: url {}", url);\r
+               ResponseEntity<Map<String, Object>> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<Map<String, Object>>() {\r
+                               });\r
+               Map<String, Object> serviceInfo = response.getBody();\r
+               List<ConsulServiceInfo> list = new ArrayList<>();\r
+               for (Map.Entry<String, Object> entry : serviceInfo.entrySet()) {\r
+                       // Be defensive\r
+            List<String> addrs;\r
+                       if (entry.getValue() instanceof List<?>)\r
+                               addrs = (List<String>) entry.getValue();\r
+                       else\r
+                               addrs = new ArrayList<>();\r
+                       list.add(new ConsulServiceInfo(entry.getKey(), addrs));\r
+               }\r
+               return list;\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulServiceHealth> getServiceHealth(String serviceName) {\r
+               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "services", serviceName }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getServiceHealth: url {}", url);\r
+               ResponseEntity<List<ConsulServiceHealth>> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<List<ConsulServiceHealth>>() {\r
+                               });\r
+        return response.getBody();\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulServiceHealthHistory> getServiceHealthHistory(String serviceName, Instant start,\r
+                       Instant end) {\r
+               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "svchist", serviceName },\r
+                               new String[] { "start", start.toString(), "end", end.toString() });\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getServiceHealthHistory: url {}", url);\r
+               // Hack around an odd interface that returns non-JSON on error:\r
+               // "No health Data found for the selected dates or service"\r
+               ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<String>() { });\r
+               if (response.getBody().startsWith("No health"))\r
+                       throw new RuntimeException(response.getBody());         \r
+               List<ConsulServiceHealthHistory> result = null;\r
+               try {\r
+                       TypeReference<List<ConsulServiceHealthHistory>> typeRef = new TypeReference<List<ConsulServiceHealthHistory>>() {       };\r
+                       result = objectMapper.readValue(response.getBody(), typeRef);\r
+               } catch (Exception ex) {\r
+                       logger.error(EELFLoggerDelegate.errorLogger, "getServiceHealthHistory failed to parse response body", ex);\r
+               }\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulNodeInfo> getNodes() {\r
+               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "nodes" }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getNodesHealth: url {}", url);\r
+               ResponseEntity<List<ConsulNodeInfo>> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<List<ConsulNodeInfo>>() {\r
+                               });\r
+        return response.getBody();\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulServiceHealth> getNodeServicesHealth(String nodeId) {\r
+               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "nodes", nodeId }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getNodeServicesHealth: url {}", url);\r
+               ResponseEntity<List<ConsulServiceHealth>> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<List<ConsulServiceHealth>>() {\r
+            });\r
+        return response.getBody();\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulDatacenter> getDatacenters() {\r
+               String url = buildUrl(new String[] { baseUrl, healthServicesPath, "datacenters" }, null);\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getDatacentersHealth: url {}", url);\r
+               ResponseEntity<List<String>> response = restTemplate.exchange(url, HttpMethod.GET, null,\r
+                               new ParameterizedTypeReference<List<String>>() {\r
+                               });\r
+               List<String> list = response.getBody();\r
+               List<ConsulDatacenter> result = new ArrayList<>();\r
+               for (String dc : list)\r
+                       result.add(new ConsulDatacenter(dc));\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * Simple test\r
+        * \r
+        * @param args\r
+        *            blueprint ID\r
+        * @throws IllegalArgumentException\r
+        *             On bad arguments\r
+        */\r
+       public static void main(String[] args) throws IllegalArgumentException {\r
+               if (args.length != 1)\r
+                       throw new IllegalArgumentException("Single argument expected: blueprint-id");\r
+               ControllerRestClientImpl client = new ControllerRestClientImpl("http://localhost:8081/controller", "dbus_user",\r
+                               "dbus_pass");\r
+               final String id = args[0];\r
+        logger.info("Requesting blueprint for " + id);\r
+               CloudifyBlueprintList list = client.getBlueprint(id);\r
+               if (list == null)\r
+            logger.error("Received null");\r
+               else\r
+                       for (int i = 0; i < list.items.size(); ++i) {\r
+                logger.info("Blueprint " + Integer.toString(i));\r
+                logger.info(list.items.get(i).toString());\r
+                       }\r
+       }\r
+\r
+}\r
index 2523538..6b0f3d0 100644 (file)
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.rest;
-
-import java.io.InputStream;
-import java.net.URI;
-import java.time.Instant;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Scanner;
-
-import org.onap.ccsdk.dashboard.exception.DashboardControllerException;
-import org.onap.ccsdk.dashboard.model.CloudifyBlueprintContent;
-import org.onap.ccsdk.dashboard.model.CloudifyBlueprintList;
-import org.onap.ccsdk.dashboard.model.CloudifyBlueprintUpload;
-import org.onap.ccsdk.dashboard.model.CloudifyDeploymentList;
-import org.onap.ccsdk.dashboard.model.CloudifyDeploymentRequest;
-import org.onap.ccsdk.dashboard.model.CloudifyExecution;
-import org.onap.ccsdk.dashboard.model.CloudifyExecutionList;
-import org.onap.ccsdk.dashboard.model.CloudifyExecutionRequest;
-import org.onap.ccsdk.dashboard.model.ConsulDatacenter;
-import org.onap.ccsdk.dashboard.model.ConsulHealthServiceRegistration;
-import org.onap.ccsdk.dashboard.model.ConsulNodeInfo;
-import org.onap.ccsdk.dashboard.model.ConsulServiceHealth;
-import org.onap.ccsdk.dashboard.model.ConsulServiceHealthHistory;
-import org.onap.ccsdk.dashboard.model.ConsulServiceInfo;
-import org.onap.ccsdk.dashboard.model.ECTransportModel;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Provides mock implementations that return contents of files on the classpath.
- */
-public class ControllerRestClientMockImpl implements IControllerRestClient {
-
-       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ControllerRestClientMockImpl.class);
-
-       /**
-        * For mock outputs
-        */
-       private final ObjectMapper objectMapper = new ObjectMapper();
-
-       /**
-        * No-arg constructor
-        */
-       public ControllerRestClientMockImpl() {
-       }
-
-       private String getMockDataContent(final String path) {
-               String result = null;
-               try {
-                       InputStream is = getClass().getResourceAsStream(path);
-                       if (is == null)
-                               throw new DashboardControllerException("Failed to find resource at path " + path);
-                       Scanner scanner = new Scanner(is, "UTF-8");
-                       result = scanner.useDelimiter("\\A").next();
-                       scanner.close();
-                       is.close();
-               } catch (Exception ex) {
-                       logger.error("getMockDataContent failed", ex);
-                       throw new RuntimeException(ex);
-               }
-               return result;
-       }
-
-       /**
-        * Creates an input stream using the specified path and requests the mapper
-        * create an object of the specified type.
-        * 
-        * @param modelClass
-        *            Model class
-        * @param path
-        *            Path to classpath resource
-        * @return Instance of modelClass
-        */
-       private ECTransportModel getMockData(final Class<? extends ECTransportModel> modelClass, final String path) {
-        ECTransportModel result;
-               String json = getMockDataContent(path);
-               try {
-            result = objectMapper.readValue(json, modelClass);
-               } catch (Exception ex) {
-                       logger.error("getMockData failed", ex);
-                       throw new RuntimeException(ex);
-               }
-               return result;
-       }
-
-       @Override
-       public CloudifyBlueprintList getBlueprints() {
-               return (CloudifyBlueprintList) getMockData(CloudifyBlueprintList.class, "/blueprintList.json");
-       }
-
-       @Override
-       public CloudifyBlueprintList getBlueprint(final String id) {
-               return (CloudifyBlueprintList) getMockData(CloudifyBlueprintList.class, "/blueprintByID.json");
-       }
-
-       @Override
-       public CloudifyBlueprintContent viewBlueprint(final String id) {
-               String yaml = getMockDataContent("/blueprintContent.yaml");
-        return new CloudifyBlueprintContent(id, yaml);
-       }
-
-       @Override
-       public CloudifyBlueprintList uploadBlueprint(CloudifyBlueprintUpload blueprint) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "uploadBlueprint: {}", blueprint.toString());
-               return new CloudifyBlueprintList(null, null);
-       }
-
-       @Override
-       public int deleteBlueprint(final String id) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "deleteBlueprint: {}", id);
-               return 204;
-       }
-
-       @Override
-       public CloudifyDeploymentList getDeployments() {
-               return (CloudifyDeploymentList) getMockData(CloudifyDeploymentList.class, "/deploymentList.json");
-       }
-
-       @Override
-       public CloudifyDeploymentList getDeployment(final String id) {
-               return (CloudifyDeploymentList) getMockData(CloudifyDeploymentList.class, "/deploymentByID.json");
-       }
-
-       public CloudifyDeploymentList createDeployment(CloudifyDeploymentRequest deployment) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "createDeployment: {}", deployment.toString());
-               return new CloudifyDeploymentList(null, null);
-       }
-
-       @Override
-       public int deleteDeployment(final String id, boolean ignoreLiveNodes) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "deleteDeployment: id {}, ignoreLiveNodes", id, ignoreLiveNodes);
-               return 204;
-       }
-
-       @Override
-       public CloudifyExecutionList getExecutions(final String deploymentId) {
-               return (CloudifyExecutionList) getMockData(CloudifyExecutionList.class, "/listExecutionForDeploymentID.json");
-       }
-
-       @Override
-       public CloudifyExecutionList getExecution(String executionId, String deploymentId) {
-               return (CloudifyExecutionList) getMockData(CloudifyExecutionList.class, "/listExecutionForDeploymentID.json");
-       }
-
-       @Override
-       public CloudifyExecution startExecution(CloudifyExecutionRequest execution) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "startExecution: {}", execution.toString());
-               return new CloudifyExecution(null, null, null, null, null, null, null, null, null);
-       }
-
-       @Override
-       public int cancelExecution(String executionId, String deploymentId, String action) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "deleteExecution: executionId {}, deploymentId {}, action {}",
-                               executionId, deploymentId, action);
-               return 204;
-       }
-
-       @Override
-       public URI registerService(ConsulHealthServiceRegistration registration) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "registerService: {}", registration);
-               return null;
-       }
-
-       @Override
-       public int deregisterService(String serviceName) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "deregisterService: {}", serviceName);
-               return 200;
-       }
-
-       @Override
-       public List<ConsulServiceHealth> getServiceHealth(String serviceName) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "getServiceHealth: serviceName={}", serviceName);
-               String json = getMockDataContent("/serviceHealth.json");
-               TypeReference<List<ConsulServiceHealth>> typeRef = new TypeReference<List<ConsulServiceHealth>>() {
-               };
-               List<ConsulServiceHealth> result = null;
-               try {
-                       result = objectMapper.readValue(json, typeRef);
-               } catch (Exception ex) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "getServiceHealth failed", ex);
-               }
-               return result;
-       }
-
-       @Override
-       public List<ConsulServiceHealthHistory> getServiceHealthHistory(String serviceName, Instant start, Instant end) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "getServiceHealthHistory: serviceName={}", serviceName);
-               String json = getMockDataContent("/serviceHealthHistory.json");
-               TypeReference<List<ConsulServiceHealthHistory>> typeRef = new TypeReference<List<ConsulServiceHealthHistory>>() {
-               };
-               List<ConsulServiceHealthHistory> result = null;
-               try {
-                       result = objectMapper.readValue(json, typeRef);
-               } catch (Exception ex) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "getServiceHealthHistory failed", ex);
-               }
-               return result;
-       }
-
-       @Override
-       public List<ConsulServiceHealth> getNodeServicesHealth(String nodeId) {
-               logger.debug(EELFLoggerDelegate.debugLogger, "getNodeServicesHealth: nodeId={}", nodeId);
-               String json = getMockDataContent("/nodeServicesHealth.json");
-               TypeReference<List<ConsulServiceHealth>> typeRef = new TypeReference<List<ConsulServiceHealth>>() {
-               };
-               List<ConsulServiceHealth> result = null;
-               try {
-                       result = objectMapper.readValue(json, typeRef);
-               } catch (Exception ex) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "getNodeServicesHealth failed", ex);
-               }
-               return result;
-       }
-
-       @Override
-       public List<ConsulServiceInfo> getServices() {
-               logger.debug(EELFLoggerDelegate.debugLogger, "getServices");
-               String json = getMockDataContent("/services.json");
-               TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
-               };
-               HashMap<String, Object> map = null;
-               try {
-                       map = objectMapper.readValue(json, typeRef);
-               } catch (Exception ex) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "getNode failed", ex);
-               }
-               ArrayList<ConsulServiceInfo> result = new ArrayList<>();
-        if (map != null) {
-            for (Map.Entry<String, Object> entry : map.entrySet()) {
-                final String service = entry.getKey();
-                @SuppressWarnings("unchecked") final List<String> addrs = (List<String>) entry.getValue();
-                result.add(new ConsulServiceInfo(service, addrs));
-            }
-        }
-               return result;
-       }
-
-       @Override
-       public List<ConsulNodeInfo> getNodes() {
-               logger.debug(EELFLoggerDelegate.debugLogger, "getNodes");
-               String json = getMockDataContent("/nodesHealth.json");
-               TypeReference<List<ConsulNodeInfo>> typeRef = new TypeReference<List<ConsulNodeInfo>>() {
-               };
-               List<ConsulNodeInfo> result = null;
-               try {
-                       result = objectMapper.readValue(json, typeRef);
-               } catch (Exception ex) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "getNode failed", ex);
-
-               }
-               return result;
-       }
-
-       @Override
-       public List<ConsulDatacenter> getDatacenters() {
-               logger.debug(EELFLoggerDelegate.debugLogger, "getDatacentersHealth");
-               return null;
-       }
-
-       /**
-        * Simple test
-        * 
-        * @param args
-        *            blueprint ID
-        * @throws DashboardControllerException
-        *             On any failure
-        */
-       public static void main(String[] args) throws DashboardControllerException {
-        logger.info("Testing paths and parsing mock data");
-               ControllerRestClientMockImpl client = new ControllerRestClientMockImpl();
-               CloudifyBlueprintList list1 = client.getBlueprints();
-               CloudifyBlueprintList list2 = client.getBlueprint("mock");
-               CloudifyDeploymentList list3 = client.getDeployments();
-               CloudifyDeploymentList list4 = client.getDeployment("mock");
-               CloudifyExecutionList list5 = client.getExecutions("mock");
-               List<ConsulServiceInfo> list6 = client.getServices();
-               List<ConsulNodeInfo> list7 = client.getNodes();
-               List<ConsulServiceHealth> list8 = client.getServiceHealth("mock");
-               List<ConsulServiceHealthHistory> list9 = client.getServiceHealthHistory("mock", Instant.now(), Instant.now());
-               if (list1 == null || list2 == null || list3 == null || list4 == null || list5 == null || list6 == null
-                               || list7 == null || list8 == null || list9 == null)
-                       throw new DashboardControllerException("Failed");
-        logger.info("Pass.");
-       }
-
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.rest;\r
+\r
+import java.io.InputStream;\r
+import java.net.URI;\r
+import java.time.Instant;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Scanner;\r
+\r
+import org.onap.ccsdk.dashboard.exception.DashboardControllerException;\r
+import org.onap.ccsdk.dashboard.model.CloudifyBlueprintContent;\r
+import org.onap.ccsdk.dashboard.model.CloudifyBlueprintList;\r
+import org.onap.ccsdk.dashboard.model.CloudifyBlueprintUpload;\r
+import org.onap.ccsdk.dashboard.model.CloudifyDeploymentList;\r
+import org.onap.ccsdk.dashboard.model.CloudifyDeploymentRequest;\r
+import org.onap.ccsdk.dashboard.model.CloudifyExecution;\r
+import org.onap.ccsdk.dashboard.model.CloudifyExecutionList;\r
+import org.onap.ccsdk.dashboard.model.CloudifyExecutionRequest;\r
+import org.onap.ccsdk.dashboard.model.ConsulDatacenter;\r
+import org.onap.ccsdk.dashboard.model.ConsulHealthServiceRegistration;\r
+import org.onap.ccsdk.dashboard.model.ConsulNodeInfo;\r
+import org.onap.ccsdk.dashboard.model.ConsulServiceHealth;\r
+import org.onap.ccsdk.dashboard.model.ConsulServiceHealthHistory;\r
+import org.onap.ccsdk.dashboard.model.ConsulServiceInfo;\r
+import org.onap.ccsdk.dashboard.model.ECTransportModel;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+\r
+import com.fasterxml.jackson.core.type.TypeReference;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+/**\r
+ * Provides mock implementations that return contents of files on the classpath.\r
+ */\r
+public class ControllerRestClientMockImpl implements IControllerRestClient {\r
+\r
+       private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ControllerRestClientMockImpl.class);\r
+\r
+       /**\r
+        * For mock outputs\r
+        */\r
+       private final ObjectMapper objectMapper = new ObjectMapper();\r
+\r
+       /**\r
+        * No-arg constructor\r
+        */\r
+       public ControllerRestClientMockImpl() {\r
+       }\r
+\r
+       private String getMockDataContent(final String path) {\r
+               String result = null;\r
+               try {\r
+                       InputStream is = getClass().getResourceAsStream(path);\r
+                       if (is == null)\r
+                               throw new DashboardControllerException("Failed to find resource at path " + path);\r
+                       Scanner scanner = new Scanner(is, "UTF-8");\r
+                       result = scanner.useDelimiter("\\A").next();\r
+                       scanner.close();\r
+                       is.close();\r
+               } catch (Exception ex) {\r
+                       logger.error("getMockDataContent failed", ex);\r
+                       throw new RuntimeException(ex);\r
+               }\r
+               return result;\r
+       }\r
+\r
+       /**\r
+        * Creates an input stream using the specified path and requests the mapper\r
+        * create an object of the specified type.\r
+        * \r
+        * @param modelClass\r
+        *            Model class\r
+        * @param path\r
+        *            Path to classpath resource\r
+        * @return Instance of modelClass\r
+        */\r
+       private ECTransportModel getMockData(final Class<? extends ECTransportModel> modelClass, final String path) {\r
+        ECTransportModel result;\r
+               String json = getMockDataContent(path);\r
+               try {\r
+            result = objectMapper.readValue(json, modelClass);\r
+               } catch (Exception ex) {\r
+                       logger.error("getMockData failed", ex);\r
+                       throw new RuntimeException(ex);\r
+               }\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public CloudifyBlueprintList getBlueprints() {\r
+               return (CloudifyBlueprintList) getMockData(CloudifyBlueprintList.class, "/blueprintList.json");\r
+       }\r
+\r
+       @Override\r
+       public CloudifyBlueprintList getBlueprint(final String id) {\r
+               return (CloudifyBlueprintList) getMockData(CloudifyBlueprintList.class, "/blueprintByID.json");\r
+       }\r
+\r
+       @Override\r
+       public CloudifyBlueprintContent viewBlueprint(final String id) {\r
+               String yaml = getMockDataContent("/blueprintContent.yaml");\r
+        return new CloudifyBlueprintContent(id, yaml);\r
+       }\r
+\r
+       @Override\r
+       public CloudifyBlueprintList uploadBlueprint(CloudifyBlueprintUpload blueprint) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "uploadBlueprint: {}", blueprint.toString());\r
+               return new CloudifyBlueprintList(null, null);\r
+       }\r
+\r
+       @Override\r
+       public int deleteBlueprint(final String id) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "deleteBlueprint: {}", id);\r
+               return 204;\r
+       }\r
+\r
+       @Override\r
+       public CloudifyDeploymentList getDeployments() {\r
+               return (CloudifyDeploymentList) getMockData(CloudifyDeploymentList.class, "/deploymentList.json");\r
+       }\r
+\r
+       @Override\r
+       public CloudifyDeploymentList getDeployment(final String id) {\r
+               return (CloudifyDeploymentList) getMockData(CloudifyDeploymentList.class, "/deploymentByID.json");\r
+       }\r
+\r
+       public CloudifyDeploymentList createDeployment(CloudifyDeploymentRequest deployment) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "createDeployment: {}", deployment.toString());\r
+               return new CloudifyDeploymentList(null, null);\r
+       }\r
+\r
+       @Override\r
+       public int deleteDeployment(final String id, boolean ignoreLiveNodes) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "deleteDeployment: id {}, ignoreLiveNodes", id, ignoreLiveNodes);\r
+               return 204;\r
+       }\r
+\r
+       @Override\r
+       public CloudifyExecutionList getExecutions(final String deploymentId) {\r
+               return (CloudifyExecutionList) getMockData(CloudifyExecutionList.class, "/listExecutionForDeploymentID.json");\r
+       }\r
+\r
+       @Override\r
+       public CloudifyExecutionList getExecution(String executionId, String deploymentId) {\r
+               return (CloudifyExecutionList) getMockData(CloudifyExecutionList.class, "/listExecutionForDeploymentID.json");\r
+       }\r
+\r
+       @Override\r
+       public CloudifyExecution startExecution(CloudifyExecutionRequest execution) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "startExecution: {}", execution.toString());\r
+               return new CloudifyExecution(null, null, null, null, null, null, null, null, null);\r
+       }\r
+\r
+       @Override\r
+       public int cancelExecution(String executionId, String deploymentId, String action) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "deleteExecution: executionId {}, deploymentId {}, action {}",\r
+                               executionId, deploymentId, action);\r
+               return 204;\r
+       }\r
+\r
+       @Override\r
+       public URI registerService(ConsulHealthServiceRegistration registration) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "registerService: {}", registration);\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       public int deregisterService(String serviceName) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "deregisterService: {}", serviceName);\r
+               return 200;\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulServiceHealth> getServiceHealth(String serviceName) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getServiceHealth: serviceName={}", serviceName);\r
+               String json = getMockDataContent("/serviceHealth.json");\r
+               TypeReference<List<ConsulServiceHealth>> typeRef = new TypeReference<List<ConsulServiceHealth>>() {\r
+               };\r
+               List<ConsulServiceHealth> result = null;\r
+               try {\r
+                       result = objectMapper.readValue(json, typeRef);\r
+               } catch (Exception ex) {\r
+                       logger.error(EELFLoggerDelegate.errorLogger, "getServiceHealth failed", ex);\r
+               }\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulServiceHealthHistory> getServiceHealthHistory(String serviceName, Instant start, Instant end) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getServiceHealthHistory: serviceName={}", serviceName);\r
+               String json = getMockDataContent("/serviceHealthHistory.json");\r
+               TypeReference<List<ConsulServiceHealthHistory>> typeRef = new TypeReference<List<ConsulServiceHealthHistory>>() {\r
+               };\r
+               List<ConsulServiceHealthHistory> result = null;\r
+               try {\r
+                       result = objectMapper.readValue(json, typeRef);\r
+               } catch (Exception ex) {\r
+                       logger.error(EELFLoggerDelegate.errorLogger, "getServiceHealthHistory failed", ex);\r
+               }\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulServiceHealth> getNodeServicesHealth(String nodeId) {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getNodeServicesHealth: nodeId={}", nodeId);\r
+               String json = getMockDataContent("/nodeServicesHealth.json");\r
+               TypeReference<List<ConsulServiceHealth>> typeRef = new TypeReference<List<ConsulServiceHealth>>() {\r
+               };\r
+               List<ConsulServiceHealth> result = null;\r
+               try {\r
+                       result = objectMapper.readValue(json, typeRef);\r
+               } catch (Exception ex) {\r
+                       logger.error(EELFLoggerDelegate.errorLogger, "getNodeServicesHealth failed", ex);\r
+               }\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulServiceInfo> getServices() {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getServices");\r
+               String json = getMockDataContent("/services.json");\r
+               TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {\r
+               };\r
+               HashMap<String, Object> map = null;\r
+               try {\r
+                       map = objectMapper.readValue(json, typeRef);\r
+               } catch (Exception ex) {\r
+                       logger.error(EELFLoggerDelegate.errorLogger, "getNode failed", ex);\r
+               }\r
+               ArrayList<ConsulServiceInfo> result = new ArrayList<>();\r
+        if (map != null) {\r
+            for (Map.Entry<String, Object> entry : map.entrySet()) {\r
+                final String service = entry.getKey();\r
+                @SuppressWarnings("unchecked") final List<String> addrs = (List<String>) entry.getValue();\r
+                result.add(new ConsulServiceInfo(service, addrs));\r
+            }\r
+        }\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulNodeInfo> getNodes() {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getNodes");\r
+               String json = getMockDataContent("/nodesHealth.json");\r
+               TypeReference<List<ConsulNodeInfo>> typeRef = new TypeReference<List<ConsulNodeInfo>>() {\r
+               };\r
+               List<ConsulNodeInfo> result = null;\r
+               try {\r
+                       result = objectMapper.readValue(json, typeRef);\r
+               } catch (Exception ex) {\r
+                       logger.error(EELFLoggerDelegate.errorLogger, "getNode failed", ex);\r
+\r
+               }\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public List<ConsulDatacenter> getDatacenters() {\r
+               logger.debug(EELFLoggerDelegate.debugLogger, "getDatacentersHealth");\r
+               return null;\r
+       }\r
+\r
+       /**\r
+        * Simple test\r
+        * \r
+        * @param args\r
+        *            blueprint ID\r
+        * @throws DashboardControllerException\r
+        *             On any failure\r
+        */\r
+       public static void main(String[] args) throws DashboardControllerException {\r
+        logger.info("Testing paths and parsing mock data");\r
+               ControllerRestClientMockImpl client = new ControllerRestClientMockImpl();\r
+               CloudifyBlueprintList list1 = client.getBlueprints();\r
+               CloudifyBlueprintList list2 = client.getBlueprint("mock");\r
+               CloudifyDeploymentList list3 = client.getDeployments();\r
+               CloudifyDeploymentList list4 = client.getDeployment("mock");\r
+               CloudifyExecutionList list5 = client.getExecutions("mock");\r
+               List<ConsulServiceInfo> list6 = client.getServices();\r
+               List<ConsulNodeInfo> list7 = client.getNodes();\r
+               List<ConsulServiceHealth> list8 = client.getServiceHealth("mock");\r
+               List<ConsulServiceHealthHistory> list9 = client.getServiceHealthHistory("mock", Instant.now(), Instant.now());\r
+               if (list1 == null || list2 == null || list3 == null || list4 == null || list5 == null || list6 == null\r
+                               || list7 == null || list8 == null || list9 == null)\r
+                       throw new DashboardControllerException("Failed");\r
+        logger.info("Pass.");\r
+       }\r
+\r
+}\r
index b1c64b5..b4b3c97 100644 (file)
@@ -1,76 +1,76 @@
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.ccsdk.dashboard.service;
-
-import org.onap.ccsdk.dashboard.domain.ControllerEndpoint;
-import org.openecomp.portalsdk.core.service.DataAccessService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Complete controller endpoint information is in properties. The database just
- * stores the user's selection. Users are not expected to enter credentials so
- * this hybrid solution keeps credentials out of the database.
- */
-@Service("controllerEndpointService")
-@Transactional
-public class ControllerEndpointServiceImpl implements ControllerEndpointService {
-
-       @Autowired
-       private DataAccessService dataAccessService;
-
-       /**
-        * @return Data access service
-        */
-       public DataAccessService getDataAccessService() {
-               return dataAccessService;
-       }
-
-       /**
-        * @param dataAccessService
-        *            Data access service
-        */
-       public void setDataAccessService(DataAccessService dataAccessService) {
-               this.dataAccessService = dataAccessService;
-       }
-
-       @Override
-       public ControllerEndpoint getControllerEndpointSelection(long userId) {
-               return (ControllerEndpoint) getDataAccessService()
-                               .getDomainObject(ControllerEndpoint.class, userId, null);
-       }
-
-       @Override
-       public void updateControllerEndpointSelection(ControllerEndpoint endpoint) {
-               getDataAccessService().saveDomainObject(endpoint, null);
-       }
-
-       @Override
-       public void deleteControllerEndpointSelection(long userId) {
-               ControllerEndpoint dbEntry = (ControllerEndpoint) getDataAccessService()
-                               .getDomainObject(ControllerEndpoint.class, userId, null);
-               if (dbEntry != null)
-                       getDataAccessService().deleteDomainObject(dbEntry, null);
-       }
-
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.ccsdk.dashboard.service;\r
+\r
+import org.onap.ccsdk.dashboard.domain.ControllerEndpoint;\r
+import org.onap.portalsdk.core.service.DataAccessService;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.stereotype.Service;\r
+import org.springframework.transaction.annotation.Transactional;\r
+\r
+/**\r
+ * Complete controller endpoint information is in properties. The database just\r
+ * stores the user's selection. Users are not expected to enter credentials so\r
+ * this hybrid solution keeps credentials out of the database.\r
+ */\r
+@Service("controllerEndpointService")\r
+@Transactional\r
+public class ControllerEndpointServiceImpl implements ControllerEndpointService {\r
+\r
+       @Autowired\r
+       private DataAccessService dataAccessService;\r
+\r
+       /**\r
+        * @return Data access service\r
+        */\r
+       public DataAccessService getDataAccessService() {\r
+               return dataAccessService;\r
+       }\r
+\r
+       /**\r
+        * @param dataAccessService\r
+        *            Data access service\r
+        */\r
+       public void setDataAccessService(DataAccessService dataAccessService) {\r
+               this.dataAccessService = dataAccessService;\r
+       }\r
+\r
+       @Override\r
+       public ControllerEndpoint getControllerEndpointSelection(long userId) {\r
+               return (ControllerEndpoint) getDataAccessService()\r
+                               .getDomainObject(ControllerEndpoint.class, userId, null);\r
+       }\r
+\r
+       @Override\r
+       public void updateControllerEndpointSelection(ControllerEndpoint endpoint) {\r
+               getDataAccessService().saveDomainObject(endpoint, null);\r
+       }\r
+\r
+       @Override\r
+       public void deleteControllerEndpointSelection(long userId) {\r
+               ControllerEndpoint dbEntry = (ControllerEndpoint) getDataAccessService()\r
+                               .getDomainObject(ControllerEndpoint.class, userId, null);\r
+               if (dbEntry != null)\r
+                       getDataAccessService().deleteDomainObject(dbEntry, null);\r
+       }\r
+\r
+}\r
index 8a64ab5..365ee05 100644 (file)
@@ -1,42 +1,42 @@
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.fusionapp.service;
-
-import org.openecomp.portalsdk.core.domain.User;
-
-//@Service("adminAuthExtension")
-//@Transactional
-/**
- * Extension supporting action on authorization of user
- */
-public class AdminAuthExtension {
-
-       /**
-        * @param user
-        *            User who was authenticated
-        */
-       public void saveUserExtension(User user) {
-               // app's developer implement their own logic here, like updating app's
-               // related tables
-       }
-
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.fusionapp.service;\r
+\r
+import org.onap.portalsdk.core.domain.User;\r
+\r
+//@Service("adminAuthExtension")\r
+//@Transactional\r
+/**\r
+ * Extension supporting action on authorization of user\r
+ */\r
+public class AdminAuthExtension {\r
+\r
+       /**\r
+        * @param user\r
+        *            User who was authenticated\r
+        */\r
+       public void saveUserExtension(User user) {\r
+               // app's developer implement their own logic here, like updating app's\r
+               // related tables\r
+       }\r
+\r
+}\r
index f3d55e2..ccefdce 100644 (file)
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.fusion.core;
-
-import java.io.IOException;
-
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.openecomp.portalsdk.core.conf.AppConfig;
-import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager;
-import org.openecomp.portalsdk.core.util.CacheManager;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.AnnotationConfigWebContextLoader;
-import org.springframework.test.context.web.WebAppConfiguration;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import org.springframework.web.context.WebApplicationContext;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-
-/**
- * In order to write a unit test, 1. inherit this class - See SanityTest.java 2.
- * place the "war" folder on your test class's classpath 3. run the test with
- * the following VM argument; This is important because when starting the
- * application from Container, the System Properties file
- * (SystemProperties.java) can have the direct path but, when running from the
- * Mock Junit container, the path should be prefixed with "classpath" to enable
- * the mock container to search for the file in the classpath
- * -Dcontainer.classpath="classpath:"
- *
- */
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@WebAppConfiguration
-@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = { MockAppConfig.class })
-@ActiveProfiles(value = "test")
-public class MockApplicationContextTestSuite {
-
-       @Autowired
-       public WebApplicationContext wac;
-
-       private MockMvc mockMvc;
-
-       @Before
-       public void setup() {
-               if (mockMvc == null) {
-                       this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
-
-               }
-       }
-
-       public Object getBean(String name) {
-               return this.wac.getBean(name);
-       }
-
-       public MockMvc getMockMvc() {
-               return mockMvc;
-       }
-
-       public void setMockMvc(MockMvc mockMvc) {
-               this.mockMvc = mockMvc;
-       }
-
-       public WebApplicationContext getWebApplicationContext() {
-               return wac;
-       }
-
-}
-
-@Configuration
-@ComponentScan(basePackages = {"org.openecomp", "org.onap"}, excludeFilters = {
-               // see AppConfig class
-})
-@Profile("test")
-class MockAppConfig extends AppConfig {
-
-       @Bean
-       public SystemProperties systemProperties() {
-               return new MockSystemProperties();
-       }
-
-       @Bean
-       public AbstractCacheManager cacheManager() {
-               return new CacheManager() {
-
-                       public void configure() throws IOException {
-
-                       }
-               };
-       }
-
-       protected String[] tileDefinitions() {
-               return new String[] { "classpath:/WEB-INF/fusion/defs/definitions.xml",
-                               "classpath:/WEB-INF/defs/definitions.xml" };
-       }
-
-       @Override
-       public void addInterceptors(InterceptorRegistry registry) {
-               // registry.addInterceptor(new
-               // SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout());
-               // registry.addInterceptor(resourceInterceptor());
-       }
-
-       public static class MockSystemProperties extends SystemProperties {
-
-               public MockSystemProperties() {
-               }
-
-       }
-
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.fusion.core;\r
+\r
+import java.io.IOException;\r
+\r
+import org.junit.Before;\r
+import org.junit.runner.RunWith;\r
+import org.onap.portalsdk.core.conf.AppConfig;\r
+import org.onap.portalsdk.core.objectcache.AbstractCacheManager;\r
+import org.onap.portalsdk.core.util.CacheManager;\r
+import org.onap.portalsdk.core.util.SystemProperties;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.context.annotation.Bean;\r
+import org.springframework.context.annotation.ComponentScan;\r
+import org.springframework.context.annotation.Configuration;\r
+import org.springframework.context.annotation.Profile;\r
+import org.springframework.test.context.ActiveProfiles;\r
+import org.springframework.test.context.ContextConfiguration;\r
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\r
+import org.springframework.test.context.web.AnnotationConfigWebContextLoader;\r
+import org.springframework.test.context.web.WebAppConfiguration;\r
+import org.springframework.test.web.servlet.MockMvc;\r
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;\r
+import org.springframework.web.context.WebApplicationContext;\r
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;\r
+\r
+/**\r
+ * In order to write a unit test, 1. inherit this class - See SanityTest.java 2.\r
+ * place the "war" folder on your test class's classpath 3. run the test with\r
+ * the following VM argument; This is important because when starting the\r
+ * application from Container, the System Properties file\r
+ * (SystemProperties.java) can have the direct path but, when running from the\r
+ * Mock Junit container, the path should be prefixed with "classpath" to enable\r
+ * the mock container to search for the file in the classpath\r
+ * -Dcontainer.classpath="classpath:"\r
+ *\r
+ */\r
+\r
+@RunWith(SpringJUnit4ClassRunner.class)\r
+@WebAppConfiguration\r
+@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = { MockAppConfig.class })\r
+@ActiveProfiles(value = "test")\r
+public class MockApplicationContextTestSuite {\r
+\r
+       @Autowired\r
+       public WebApplicationContext wac;\r
+\r
+       private MockMvc mockMvc;\r
+\r
+       @Before\r
+       public void setup() {\r
+               if (mockMvc == null) {\r
+                       this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();\r
+\r
+               }\r
+       }\r
+\r
+       public Object getBean(String name) {\r
+               return this.wac.getBean(name);\r
+       }\r
+\r
+       public MockMvc getMockMvc() {\r
+               return mockMvc;\r
+       }\r
+\r
+       public void setMockMvc(MockMvc mockMvc) {\r
+               this.mockMvc = mockMvc;\r
+       }\r
+\r
+       public WebApplicationContext getWebApplicationContext() {\r
+               return wac;\r
+       }\r
+\r
+}\r
+\r
+@Configuration\r
+@ComponentScan(basePackages = {"org.openecomp", "org.onap"}, excludeFilters = {\r
+               // see AppConfig class\r
+})\r
+@Profile("test")\r
+class MockAppConfig extends AppConfig {\r
+\r
+       @Bean\r
+       public SystemProperties systemProperties() {\r
+               return new MockSystemProperties();\r
+       }\r
+\r
+       @Bean\r
+       public AbstractCacheManager cacheManager() {\r
+               return new CacheManager() {\r
+\r
+                       public void configure() throws IOException {\r
+\r
+                       }\r
+               };\r
+       }\r
+\r
+       protected String[] tileDefinitions() {\r
+               return new String[] { "classpath:/WEB-INF/fusion/defs/definitions.xml",\r
+                               "classpath:/WEB-INF/defs/definitions.xml" };\r
+       }\r
+\r
+       @Override\r
+       public void addInterceptors(InterceptorRegistry registry) {\r
+               // registry.addInterceptor(new\r
+               // SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout());\r
+               // registry.addInterceptor(resourceInterceptor());\r
+       }\r
+\r
+       public static class MockSystemProperties extends SystemProperties {\r
+\r
+               public MockSystemProperties() {\r
+               }\r
+\r
+       }\r
+\r
+}\r
index 4a661da..ce00583 100644 (file)
@@ -1,58 +1,58 @@
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.fusionapp.service;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onap.fusion.core.MockApplicationContextTestSuite;
-import org.openecomp.portalsdk.core.domain.Profile;
-import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.service.ProfileService;
-import org.openecomp.portalsdk.core.service.UserProfileService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-
-public class ProfileServiceTest extends MockApplicationContextTestSuite {
-       
-       @Autowired
-       ProfileService service;
-       
-       @Autowired
-       UserProfileService userProfileService;
-       
-       @Test
-       public void testFindAll() {
-               
-               List<Profile> profiles = service.findAll();
-               Assert.assertTrue(profiles.size() > 0);
-       }
-
-       @Test
-       public void testFindAllActive() {
-                               
-               List<User> users = userProfileService.findAllActive();
-               List<User> activeUsers = userProfileService.findAllActive();
-               Assert.assertTrue(users.size() - activeUsers.size() >= 0);
-       }
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.fusionapp.service;\r
+\r
+import java.util.List;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.fusion.core.MockApplicationContextTestSuite;\r
+import org.onap.portalsdk.core.domain.Profile;\r
+import org.onap.portalsdk.core.domain.User;\r
+import org.onap.portalsdk.core.service.ProfileService;\r
+import org.onap.portalsdk.core.service.UserProfileService;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+\r
+\r
+public class ProfileServiceTest extends MockApplicationContextTestSuite {\r
+       \r
+       @Autowired\r
+       ProfileService service;\r
+       \r
+       @Autowired\r
+       UserProfileService userProfileService;\r
+       \r
+       @Test\r
+    public void testFindAll() throws Exception {\r
+               \r
+               List<Profile> profiles = service.findAll();\r
+               Assert.assertTrue(profiles.size() > 0);\r
+       }\r
+\r
+       @Test\r
+       public void testFindAllActive() {\r
+                               \r
+               List<User> users = userProfileService.findAllActive();\r
+               List<User> activeUsers = userProfileService.findAllActive();\r
+               Assert.assertTrue(users.size() - activeUsers.size() >= 0);\r
+       }\r
+}\r
index 4d8975d..0efd176 100644 (file)
-<?xml version="1.0"?>
-<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>
-
-       <groupId>org.onap.ccsdk.dashboard</groupId>
-       <artifactId>ccsdk-app-os</artifactId>
-       <version>1.1.0-SNAPSHOT</version>
-       <packaging>war</packaging>
-       <name>ONAP Operations Manager Dashboard app</name>
-       <description>CCSDK Dashboard Web Application for external release</description>
-
-       <properties>
-               <encoding>UTF-8</encoding>
-               <springframework.version>4.2.0.RELEASE</springframework.version>
-               <hibernate.version>4.3.11.Final</hibernate.version>
-               <epsdk.version>1.1.0</epsdk.version>
-               <ccsdk.version>1.1.0-SNAPSHOT</ccsdk.version>
-               <nexusproxy>https://nexus.onap.org</nexusproxy>
-               <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>
-               <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>
-               <!-- supplied by Jenkins server -->
-               <build.version>${project.version}</build.version>
-               <!-- Tests usually require some setup that maven cannot do, so skip. -->
-               <skiptests>true</skiptests>
-       </properties>
-
-       <repositories>
-               <repository>
-                       <!-- Releases repository has ECOMP release artifacts -->
-                       <id>ecomp-releases</id>
-                       <name>OpenECOMP - Release Repository</name>
-                       <url>${nexusproxy}/${releaseNexusPath}</url>
-               </repository>
-               <repository>
-                       <!-- Snapshots repository has ECOMP snapshot artifacts -->
-                       <id>ecomp-snapshots</id>
-                       <name>OpenECOMP - Snapshot Repository</name>
-                       <url>${nexusproxy}/${snapshotNexusPath}</url>
-               </repository>
-       </repositories>
-
-       <build>
-
-               <!-- War files are labeled with build information, not POM version -->
-               <finalName>${project.artifactId}-${build.version}</finalName>
-
-               <plugins>
-                       <!-- Compile to Java 1.8 class output format -->
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-compiler-plugin</artifactId>
-                               <version>3.1</version>
-                               <configuration>
-                                       <source>1.8</source>
-                                       <target>1.8</target>
-                               </configuration>
-                       </plugin>
-
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-war-plugin</artifactId>
-                               <version>3.0.0</version>
-                               <configuration>
-                                       <archive>
-                                               <manifest>
-                                                       <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
-                                               </manifest>
-                                               <manifestEntries>
-                                                       <Build-Number>${build.version}</Build-Number>
-                                                       <Build-Time>${maven.build.timestamp}</Build-Time>
-                                               </manifestEntries>
-                                       </archive>
-                                       <overlays>
-                                               <overlay>
-                                                       <groupId>org.onap.ccsdk.dashboard</groupId>
-                                                       <artifactId>ccsdk-app-overlay</artifactId>
-                                               </overlay>
-                                               <overlay>
-                                                       <groupId>org.openecomp.ecompsdkos</groupId>
-                                                       <artifactId>epsdk-app-overlay</artifactId>
-                                                       <excludes>
-                                                               <exclude>app/fusionapp/**</exclude>
-                                                               <exclude>app/fusion/ase/**</exclude>
-                                                               <exclude>app/fusion/external/angular-1.5/**</exclude>
-                                                               <exclude>app/fusion/external/gis/**</exclude>
-                                                               <exclude>app/fusion/external/leaflet-0.7.3/**</exclude>
-                                                               <exclude>app/fusion/external/lodash/**</exclude>
-                                                               <exclude>app/fusion/external/samples/**</exclude>
-                                                               <exclude>app/fusion/external/showdown/**</exclude>
-                                                               <exclude>app/fusion/notebook-integration/**</exclude>
-                                                               <exclude>static/fusion/sample/**</exclude>
-                                                               <exclude>static/fusion/raptor/**</exclude>
-                                                       </excludes>
-                                               </overlay>
-                                       </overlays>
-                               </configuration>
-                       </plugin>
-                       <!-- no deployment needed -->
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-deploy-plugin</artifactId>
-                               <version>2.8</version>
-                               <configuration>
-                                       <skip>true</skip>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
-
-       <dependencies>
-               <!-- ECD webapp resources -->
-               <dependency>
-                       <groupId>org.onap.ccsdk.dashboard</groupId>
-                       <artifactId>ccsdk-app-overlay</artifactId>
-                       <version>${ccsdk.version}</version>
-                       <type>war</type>
-               </dependency>
-               <!-- ECD webapp controllers -->
-               <dependency>
-                       <groupId>org.onap.ccsdk.dashboard</groupId>
-                       <artifactId>ccsdk-app-common</artifactId>
-                       <version>${ccsdk.version}</version>
-               </dependency>
-               <!-- SDK webapp resources -->
-               <dependency>
-                       <groupId>org.openecomp.ecompsdkos</groupId>
-                       <artifactId>epsdk-app-overlay</artifactId>
-                       <version>${epsdk.version}</version>
-                       <type>war</type>
-               </dependency>
-               <!-- SDK webapp controllers -->
-               <dependency>
-                       <groupId>org.openecomp.ecompsdkos</groupId>
-                       <artifactId>epsdk-app-common</artifactId>
-                       <version>${epsdk.version}</version>
-                       <exclusions>
-                               <exclusion>
-                                       <groupId>org.openecomp.ecompsdkos</groupId>
-                                       <artifactId>epsdk-analytics</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>org.openecomp.ecompsdkos</groupId>
-                                       <artifactId>epsdk-workflow</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>mysql</groupId>
-                                       <artifactId>mysql-connector-java</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>org.elasticsearch</groupId>
-                                       <artifactId>elasticsearch</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>org.quartz-scheduler</groupId>
-                                       <artifactId>quartz</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>org.drools</groupId>
-                                       <artifactId>drools-compiler</artifactId>
-                               </exclusion>
-                               <exclusion>
-                                       <groupId>io.searchbox</groupId>
-                                       <artifactId>jest</artifactId>
-                               </exclusion>
-                       </exclusions>
-               </dependency>
-       </dependencies>
-</project>
+<?xml version="1.0"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+       <modelVersion>4.0.0</modelVersion>\r
+\r
+       <groupId>org.onap.ccsdk.dashboard</groupId>\r
+       <artifactId>ccsdk-app-os</artifactId>\r
+       <version>1.1.0-SNAPSHOT</version>\r
+       <packaging>war</packaging>\r
+       <name>ONAP Operations Manager Dashboard app</name>\r
+       <description>CCSDK Dashboard Web Application for external release</description>\r
+\r
+       <properties>\r
+               <encoding>UTF-8</encoding>\r
+               <springframework.version>4.2.0.RELEASE</springframework.version>\r
+               <hibernate.version>4.3.11.Final</hibernate.version>\r
+               <epsdk.version>2.1.0</epsdk.version>\r
+               <ccsdk.version>1.1.0-SNAPSHOT</ccsdk.version>\r
+               <nexusproxy>https://nexus.onap.org</nexusproxy>\r
+               <snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>\r
+               <releaseNexusPath>/content/repositories/releases/</releaseNexusPath>\r
+               <!-- supplied by Jenkins server -->\r
+               <build.version>${project.version}</build.version>\r
+               <!-- Tests usually require some setup that maven cannot do, so skip. -->\r
+               <skiptests>true</skiptests>\r
+       </properties>\r
+\r
+       <repositories>\r
+               <repository>\r
+                       <!-- Releases repository has ECOMP release artifacts -->\r
+                       <id>ecomp-releases</id>\r
+                       <name>OpenECOMP - Release Repository</name>\r
+                       <url>${nexusproxy}/${releaseNexusPath}</url>\r
+               </repository>\r
+               <repository>\r
+                       <!-- Snapshots repository has ECOMP snapshot artifacts -->\r
+                       <id>ecomp-snapshots</id>\r
+                       <name>OpenECOMP - Snapshot Repository</name>\r
+                       <url>${nexusproxy}/${snapshotNexusPath}</url>\r
+               </repository>\r
+       </repositories>\r
+\r
+       <build>\r
+\r
+               <!-- War files are labeled with build information, not POM version -->\r
+               <finalName>${project.artifactId}-${build.version}</finalName>\r
+\r
+               <plugins>\r
+                       <!-- Compile to Java 1.8 class output format -->\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-compiler-plugin</artifactId>\r
+                               <version>3.1</version>\r
+                               <configuration>\r
+                                       <source>1.8</source>\r
+                                       <target>1.8</target>\r
+                               </configuration>\r
+                       </plugin>\r
+\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-war-plugin</artifactId>\r
+                               <version>3.0.0</version>\r
+                               <configuration>\r
+                                       <archive>\r
+                                               <manifest>\r
+                                                       <addDefaultImplementationEntries>true</addDefaultImplementationEntries>\r
+                                               </manifest>\r
+                                               <manifestEntries>\r
+                                                       <Build-Number>${build.version}</Build-Number>\r
+                                                       <Build-Time>${maven.build.timestamp}</Build-Time>\r
+                                               </manifestEntries>\r
+                                       </archive>\r
+                                       <overlays>\r
+                                               <overlay>\r
+                                                       <groupId>org.onap.ccsdk.dashboard</groupId>\r
+                                                       <artifactId>ccsdk-app-overlay</artifactId>\r
+                                               </overlay>\r
+                                               <overlay>\r
+                                                       <groupId>org.onap.portal.sdk</groupId>\r
+                                                       <artifactId>epsdk-app-overlay</artifactId>\r
+                                                       <excludes>\r
+                                                               <exclude>app/fusionapp/**</exclude>\r
+                                                               <exclude>app/fusion/ase/**</exclude>\r
+                                                               <exclude>app/fusion/external/angular-1.5/**</exclude>\r
+                                                               <exclude>app/fusion/external/gis/**</exclude>\r
+                                                               <exclude>app/fusion/external/leaflet-0.7.3/**</exclude>\r
+                                                               <exclude>app/fusion/external/lodash/**</exclude>\r
+                                                               <exclude>app/fusion/external/samples/**</exclude>\r
+                                                               <exclude>app/fusion/external/showdown/**</exclude>\r
+                                                               <exclude>app/fusion/notebook-integration/**</exclude>\r
+                                                               <exclude>static/fusion/sample/**</exclude>\r
+                                                               <exclude>static/fusion/raptor/**</exclude>\r
+                                                       </excludes>\r
+                                               </overlay>\r
+                                       </overlays>\r
+                               </configuration>\r
+                       </plugin>\r
+                       <!-- no deployment needed -->\r
+                       <plugin>\r
+                               <groupId>org.apache.maven.plugins</groupId>\r
+                               <artifactId>maven-deploy-plugin</artifactId>\r
+                               <version>2.8</version>\r
+                               <configuration>\r
+                                       <skip>true</skip>\r
+                               </configuration>\r
+                       </plugin>\r
+               </plugins>\r
+       </build>\r
+\r
+       <dependencies>\r
+               <!-- ECD webapp resources -->\r
+               <dependency>\r
+                       <groupId>org.onap.ccsdk.dashboard</groupId>\r
+                       <artifactId>ccsdk-app-overlay</artifactId>\r
+                       <version>${ccsdk.version}</version>\r
+                       <type>war</type>\r
+               </dependency>\r
+               <!-- ECD webapp controllers -->\r
+               <dependency>\r
+                       <groupId>org.onap.ccsdk.dashboard</groupId>\r
+                       <artifactId>ccsdk-app-common</artifactId>\r
+                       <version>${ccsdk.version}</version>\r
+               </dependency>\r
+               <!-- SDK webapp resources -->\r
+               <dependency>\r
+                       <groupId>org.onap.portal.sdk</groupId>\r
+                       <artifactId>epsdk-app-overlay</artifactId>\r
+                       <version>${epsdk.version}</version>\r
+                       <type>war</type>\r
+               </dependency>\r
+               <!-- SDK webapp controllers -->\r
+               <dependency>\r
+                       <groupId>org.onap.portal.sdk</groupId>\r
+                       <artifactId>epsdk-app-common</artifactId>\r
+                       <version>${epsdk.version}</version>\r
+                       <exclusions>\r
+                               <exclusion>\r
+                                       <groupId>org.onap.portal.sdk</groupId>\r
+                                       <artifactId>epsdk-analytics</artifactId>\r
+                               </exclusion>\r
+                               <exclusion>\r
+                                       <groupId>org.onap.portal.sdk</groupId>\r
+                                       <artifactId>epsdk-workflow</artifactId>\r
+                               </exclusion>\r
+                               <exclusion>\r
+                                       <groupId>mysql</groupId>\r
+                                       <artifactId>mysql-connector-java</artifactId>\r
+                               </exclusion>\r
+                               <exclusion>\r
+                                       <groupId>org.elasticsearch</groupId>\r
+                                       <artifactId>elasticsearch</artifactId>\r
+                               </exclusion>\r
+                               <exclusion>\r
+                                       <groupId>org.quartz-scheduler</groupId>\r
+                                       <artifactId>quartz</artifactId>\r
+                               </exclusion>\r
+                               <exclusion>\r
+                                       <groupId>org.drools</groupId>\r
+                                       <artifactId>drools-compiler</artifactId>\r
+                               </exclusion>\r
+                               <exclusion>\r
+                                       <groupId>io.searchbox</groupId>\r
+                                       <artifactId>jest</artifactId>\r
+                               </exclusion>\r
+                       </exclusions>\r
+               </dependency>\r
+       </dependencies>\r
+</project>\r
index e532b5f..ecd312a 100644 (file)
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed 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
- * 
- *      http://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.
- * ================================================================================
- */
-package org.onap.portalapp.conf;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.onap.portalapp.lm.FusionLicenseManagerImpl;
-import org.onap.portalapp.login.LoginStrategyImpl;
-import org.openecomp.portalapp.controller.core.SingleSignOnController;
-import org.openecomp.portalapp.controller.sample.ElasticSearchController;
-import org.openecomp.portalapp.controller.sample.PostDroolsController;
-import org.openecomp.portalapp.scheduler.LogRegistry;
-import org.openecomp.portalsdk.core.auth.LoginStrategy;
-import org.openecomp.portalsdk.core.conf.AppConfig;
-import org.openecomp.portalsdk.core.conf.Configurable;
-import org.openecomp.portalsdk.core.lm.FusionLicenseManager;
-import org.openecomp.portalsdk.core.lm.FusionLicenseManagerUtils;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager;
-import org.openecomp.portalsdk.core.scheduler.CoreRegister;
-import org.openecomp.portalsdk.core.scheduler.CronRegistry;
-import org.openecomp.portalsdk.core.service.DataAccessService;
-import org.openecomp.portalsdk.core.service.PostDroolsService;
-import org.openecomp.portalsdk.core.util.CacheManager;
-import org.openecomp.portalsdk.core.util.SystemProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.FilterType;
-import org.springframework.context.annotation.Import;
-import org.springframework.context.annotation.Profile;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.web.servlet.ViewResolver;
-import org.springframework.web.servlet.config.annotation.EnableWebMvc;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
-
-/**
- * ECOMP Portal SDK sample application. ECOMP Portal SDK core AppConfig class to
- * reuse interceptors, view resolvers and other features defined there.
- */
-@Configuration
-@EnableWebMvc
-@ComponentScan(basePackages = { "org.onap", "org.openecomp" },
-               // Exclude unused annotated classes with heavy dependencies.
-               excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = { CoreRegister.class,
-                               CronRegistry.class, ElasticSearchController.class, LogRegistry.class, PostDroolsController.class,
-                               PostDroolsService.class, SingleSignOnController.class }))
-@Profile("src")
-@EnableAsync
-@EnableScheduling
-public class ExternalAppConfig extends AppConfig implements Configurable {
-
-       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAppConfig.class);
-
-       @Configuration
-       @Import(SystemProperties.class)
-       static class InnerConfiguration {
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see org.openecomp.portalsdk.core.conf.AppConfig#viewResolver()
-        */
-       public ViewResolver viewResolver() {
-               return super.viewResolver();
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see org.openecomp.portalsdk.core.conf.AppConfig#addResourceHandlers(org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry)
-        */
-       @Override
-       public void addResourceHandlers(ResourceHandlerRegistry registry) {
-               super.addResourceHandlers(registry);
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see org.openecomp.portalsdk.core.conf.AppConfig#dataAccessService()
-        */
-       @Override
-       public DataAccessService dataAccessService() {
-               // Echo the JDBC URL to assist developers when starting the app.
-               systemProperties();
-               System.out.println("ExternalAppConfig: " + SystemProperties.DB_CONNECTIONURL + " is "
-                               + SystemProperties.getProperty(SystemProperties.DB_CONNECTIONURL));
-               return super.dataAccessService();
-       }
-
-       /**
-        * Creates a new list with a single entry that is the external app
-        * definitions.xml path.
-        * 
-        * @return List of String, size 1
-        */
-       @Override
-       public List<String> addTileDefinitions() {
-               List<String> definitions = new ArrayList<String>();
-               // DBC does not need the sample page:
-               // definitions.add("/WEB-INF/defs/definitions.xml");
-               definitions.add("/WEB-INF/oom-app-definitions.xml");
-               if (logger.isDebugEnabled())
-                       logger.debug(EELFLoggerDelegate.debugLogger, "addTileDefinitions: list is " + definitions);
-               return definitions;
-       }
-
-       /**
-        * Adds request interceptors to the specified registry by calling
-        * {@link AppConfig#addInterceptors(InterceptorRegistry)}, but excludes
-        * certain paths from the session timeout interceptor.
-        */
-       @Override
-       public void addInterceptors(InterceptorRegistry registry) {
-               super.setExcludeUrlPathsForSessionTimeout("/login_external", "*/login_external.htm", "login", "/login.htm",
-                               "/api*", "/single_signon.htm", "/single_signon");
-               super.addInterceptors(registry);
-       }
-
-       /**
-        * Creates and returns a new instance of a {@link CacheManager} class.
-        * 
-        * @return New instance of {@link CacheManager}
-        */
-       @Bean
-       public AbstractCacheManager cacheManager() {
-               return new CacheManager();
-       }
-
-       @Bean
-       public FusionLicenseManager fusionLicenseManager() {
-               return new FusionLicenseManagerImpl();
-       }
-
-       @Bean
-       public FusionLicenseManagerUtils fusionLicenseManagerUtils() {
-               return new FusionLicenseManagerUtils();
-       }
-
-       @Bean
-       public LoginStrategy loginStrategy() {
-               return new LoginStrategyImpl();
-       }
-}
+/*-\r
+ * ================================================================================\r
+ * ECOMP Portal SDK\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ================================================================================\r
+ */\r
+package org.onap.portalapp.conf;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.onap.portalapp.lm.FusionLicenseManagerImpl;\r
+import org.onap.portalapp.login.LoginStrategyImpl;\r
+import org.onap.portalapp.controller.core.SingleSignOnController;\r
+import org.onap.portalapp.controller.sample.ElasticSearchController;\r
+import org.onap.portalapp.controller.sample.PostDroolsController;\r
+import org.onap.portalapp.scheduler.LogRegistry;\r
+import org.onap.portalsdk.core.auth.LoginStrategy;\r
+import org.onap.portalsdk.core.conf.AppConfig;\r
+import org.onap.portalsdk.core.conf.Configurable;\r
+//import org.onap.portalsdk.core.lm.FusionLicenseManager;\r
+//import org.onap.portalsdk.core.lm.FusionLicenseManagerUtils;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.onap.portalsdk.core.objectcache.AbstractCacheManager;\r
+import org.onap.portalsdk.core.scheduler.CoreRegister;\r
+import org.onap.portalsdk.core.scheduler.CronRegistry;\r
+import org.onap.portalsdk.core.service.DataAccessService;\r
+import org.onap.portalsdk.core.service.PostDroolsService;\r
+import org.onap.portalsdk.core.util.CacheManager;\r
+import org.onap.portalsdk.core.util.SystemProperties;\r
+import org.springframework.context.annotation.Bean;\r
+import org.springframework.context.annotation.ComponentScan;\r
+import org.springframework.context.annotation.Configuration;\r
+import org.springframework.context.annotation.FilterType;\r
+import org.springframework.context.annotation.Import;\r
+import org.springframework.context.annotation.Profile;\r
+import org.springframework.scheduling.annotation.EnableAsync;\r
+import org.springframework.scheduling.annotation.EnableScheduling;\r
+import org.springframework.web.servlet.ViewResolver;\r
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;\r
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;\r
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;\r
+\r
+/**\r
+ * ECOMP Portal SDK sample application. ECOMP Portal SDK core AppConfig class to\r
+ * reuse interceptors, view resolvers and other features defined there.\r
+ */\r
+@Configuration\r
+@EnableWebMvc\r
+@ComponentScan(basePackages = { "org.onap", "org.openecomp" },\r
+               // Exclude unused annotated classes with heavy dependencies.\r
+               excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = { CoreRegister.class,\r
+                               CronRegistry.class, ElasticSearchController.class, LogRegistry.class, PostDroolsController.class,\r
+                               PostDroolsService.class, SingleSignOnController.class }))\r
+@Profile("src")\r
+@EnableAsync\r
+@EnableScheduling\r
+public class ExternalAppConfig extends AppConfig implements Configurable {\r
+\r
+       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAppConfig.class);\r
+\r
+       @Configuration\r
+       @Import(SystemProperties.class)\r
+       static class InnerConfiguration {\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.onap.portalsdk.core.conf.AppConfig#viewResolver()\r
+        */\r
+       public ViewResolver viewResolver() {\r
+               return super.viewResolver();\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.onap.portalsdk.core.conf.AppConfig#addResourceHandlers(org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry)\r
+        */\r
+       @Override\r
+       public void addResourceHandlers(ResourceHandlerRegistry registry) {\r
+               super.addResourceHandlers(registry);\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.onap.portalsdk.core.conf.AppConfig#dataAccessService()\r
+        */\r
+       @Override\r
+       public DataAccessService dataAccessService() {\r
+               // Echo the JDBC URL to assist developers when starting the app.\r
+               systemProperties();\r
+               System.out.println("ExternalAppConfig: " + SystemProperties.DB_CONNECTIONURL + " is "\r
+                               + SystemProperties.getProperty(SystemProperties.DB_CONNECTIONURL));\r
+               return super.dataAccessService();\r
+       }\r
+\r
+       /**\r
+        * Creates a new list with a single entry that is the external app\r
+        * definitions.xml path.\r
+        * \r
+        * @return List of String, size 1\r
+        */\r
+       @Override\r
+       public List<String> addTileDefinitions() {\r
+               List<String> definitions = new ArrayList<String>();\r
+               // DBC does not need the sample page:\r
+               // definitions.add("/WEB-INF/defs/definitions.xml");\r
+               definitions.add("/WEB-INF/oom-app-definitions.xml");\r
+               if (logger.isDebugEnabled())\r
+                       logger.debug(EELFLoggerDelegate.debugLogger, "addTileDefinitions: list is " + definitions);\r
+               return definitions;\r
+       }\r
+\r
+       /**\r
+        * Adds request interceptors to the specified registry by calling\r
+        * {@link AppConfig#addInterceptors(InterceptorRegistry)}, but excludes\r
+        * certain paths from the session timeout interceptor.\r
+        */\r
+       @Override\r
+       public void addInterceptors(InterceptorRegistry registry) {\r
+               super.setExcludeUrlPathsForSessionTimeout("/login_external", "*/login_external.htm", "login", "/login.htm",\r
+                               "/api*", "/single_signon.htm", "/single_signon");\r
+               super.addInterceptors(registry);\r
+       }\r
+\r
+       /**\r
+        * Creates and returns a new instance of a {@link CacheManager} class.\r
+        * \r
+        * @return New instance of {@link CacheManager}\r
+        */\r
+       @Bean\r
+       public AbstractCacheManager cacheManager() {\r
+               return new CacheManager();\r
+       }\r
+\r
+       /*\r
+        @Bean\r
+        public FusionLicenseManager fusionLicenseManager() {\r
+            return new FusionLicenseManagerImpl();\r
+        }\r
+\r
+        @Bean\r
+        public FusionLicenseManagerUtils fusionLicenseManagerUtils() {\r
+            return new FusionLicenseManagerUtils();\r
+        }\r
+    */\r
+       @Bean\r
+       public LoginStrategy loginStrategy() {\r
+               return new LoginStrategyImpl();\r
+       }\r
+}\r
index 347bb51..3edcf23 100644 (file)
@@ -1,47 +1,47 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed 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
- * 
- *      http://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.
- * ================================================================================
- */
-package org.onap.portalapp.conf;
-
-import org.openecomp.portalsdk.core.conf.AppInitializer;
-
-public class ExternalAppInitializer extends AppInitializer {
-
-       @Override
-       protected Class<?>[] getRootConfigClasses() {
-               return super.getRootConfigClasses();
-       }
-
-       @Override
-       protected Class<?>[] getServletConfigClasses() {
-               Class<?> appConfigClass = ExternalAppConfig.class;
-               // Show something on stdout to indicate the app is starting.
-               System.out.println("ExternalAppInitializer: servlet configuration class is " + appConfigClass.getName());
-               return new Class[] { appConfigClass };
-       }
-
-       /*
-        * URL request will direct to the Spring dispatcher for processing
-        */
-       @Override
-       protected String[] getServletMappings() {
-               return super.getServletMappings();
-       }
-
-}
+/*-\r
+ * ================================================================================\r
+ * ECOMP Portal SDK\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ================================================================================\r
+ */\r
+package org.onap.portalapp.conf;\r
+\r
+import org.onap.portalsdk.core.conf.AppInitializer;\r
+\r
+public class ExternalAppInitializer extends AppInitializer {\r
+\r
+       @Override\r
+       protected Class<?>[] getRootConfigClasses() {\r
+               return super.getRootConfigClasses();\r
+       }\r
+\r
+       @Override\r
+       protected Class<?>[] getServletConfigClasses() {\r
+               Class<?> appConfigClass = ExternalAppConfig.class;\r
+               // Show something on stdout to indicate the app is starting.\r
+               System.out.println("ExternalAppInitializer: servlet configuration class is " + appConfigClass.getName());\r
+               return new Class[] { appConfigClass };\r
+       }\r
+\r
+       /*\r
+        * URL request will direct to the Spring dispatcher for processing\r
+        */\r
+       @Override\r
+       protected String[] getServletMappings() {\r
+               return super.getServletMappings();\r
+       }\r
+\r
+}\r
index 6432478..a4a1fa6 100644 (file)
@@ -1,62 +1,62 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed 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
- * 
- *      http://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.
- * ================================================================================
- */
-package org.onap.portalapp.conf;
-
-import org.springframework.context.annotation.Profile;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.springframework.stereotype.Component;
-
-import org.openecomp.portalsdk.core.conf.HibernateMappingLocatable;
-
-@Component
-@Profile("src")
-public class HibernateMappingLocations implements HibernateMappingLocatable {
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see org.openecomp.portalsdk.core.conf.HibernateMappingLocatable#
-        * getMappingLocations()
-        */
-       @Override
-       public Resource[] getMappingLocations() {
-               return new Resource[] {
-                               // Path is relative to WEB-INF/conf;
-                               // a leading slash gets stripped so don't bother.
-                               // new ClassPathResource("../fusion/orm/Fusion.hbm.xml"),
-                               // This is a COPY to work around a bug in the 1.1.0 release.
-                               new ClassPathResource("../fusion-110-copy.hbm.xml"),
-                               new ClassPathResource("../oom-app.hbm.xml")
-               };
-       }
-
-       /*
-        * (non-Javadoc)
-        * 
-        * @see org.openecomp.portalsdk.core.conf.HibernateMappingLocatable#
-        * getPackagesToScan()
-        */
-       @Override
-       public String[] getPackagesToScan() {
-               return new String[] { "org.onap", "org.openecomp" };
-       }
-
-}
+/*-\r
+ * ================================================================================\r
+ * ECOMP Portal SDK\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ================================================================================\r
+ */\r
+package org.onap.portalapp.conf;\r
+\r
+import org.springframework.context.annotation.Profile;\r
+import org.springframework.core.io.ClassPathResource;\r
+import org.springframework.core.io.Resource;\r
+import org.springframework.stereotype.Component;\r
+\r
+import org.onap.portalsdk.core.conf.HibernateMappingLocatable;\r
+\r
+@Component\r
+@Profile("src")\r
+public class HibernateMappingLocations implements HibernateMappingLocatable {\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        *\r
+        * @see org.onap.portalsdk.core.conf.HibernateMappingLocatable#\r
+        * getMappingLocations()\r
+        */\r
+       @Override\r
+       public Resource[] getMappingLocations() {\r
+               return new Resource[] {\r
+                               // Path is relative to WEB-INF/conf;\r
+                               // a leading slash gets stripped so don't bother.\r
+                               // new ClassPathResource("../fusion/orm/Fusion.hbm.xml"),\r
+                               // This is a COPY to work around a bug in the 1.1.0 release.\r
+                               new ClassPathResource("../fusion-110-copy.hbm.xml"),\r
+                               new ClassPathResource("../oom-app.hbm.xml")\r
+               };\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        *\r
+        * @see org.onap.portalsdk.core.conf.HibernateMappingLocatable#\r
+        * getPackagesToScan()\r
+        */\r
+       @Override\r
+       public String[] getPackagesToScan() {\r
+               return new String[] { "org.onap", "org.openecomp" };\r
+       }\r
+\r
+}\r
index e0da1c9..4eb00c6 100644 (file)
-/*******************************************************************************
- * =============LICENSE_START=========================================================
- *
- * =================================================================================
- *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- *  Licensed 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
- *  
- *      http://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.
- * ============LICENSE_END=========================================================
- *
- *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *******************************************************************************/
-package org.onap.portalapp.lm;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.ServletContext;
-
-import org.openecomp.portalsdk.core.lm.FusionLicenseManager;
-
-public class FusionLicenseManagerImpl implements FusionLicenseManager {
-
-       private Date expiredDate;
-
-       public FusionLicenseManagerImpl() {
-       }
-
-       /**
-        * An implementation of the KeyStoreParam interface that returns the
-        * information required to work with the keystore containing the private key.
-        */
-       @Override
-       public void initKeyStoreParam() {
-       }
-
-       @Override
-       public void initCipherParam() {
-       }
-
-       /**
-        * Create/populate the "licenseParm" field.
-        */
-       @Override
-       public void initLicenseParam() {
-       }
-
-       @Override
-       public void doInitWork() {
-       }
-
-       /**
-        * Prompt the user for the location of their license file, get the filename,
-        * then try to install the file.
-        * 
-        * @return true if the license installed properly, false otherwise.
-        */
-       @Override
-       public int installLicense() {
-               return INVALID_LICENSE;
-       }
-
-       @Override
-       public synchronized int verifyLicense(ServletContext context) {
-
-               return INVALID_LICENSE;
-       }
-
-       @Override
-       public void generateLicense(Map<String, String> clientInfoMap, List<String> ipAddressList) throws Exception {
-       }
-
-       @Override
-       public String nvl(String s) {
-               return (s == null) ? "" : s;
-       }
-
-       @Override
-       public Date getExpiredDate() {
-               return expiredDate;
-       }
-
-       @Override
-       public void setExpiredDate(Date expiredDate) {
-               this.expiredDate = expiredDate;
-       }
-
-}
+/*******************************************************************************\r
+ * =============LICENSE_START=========================================================\r
+ *\r
+ * =================================================================================\r
+ *  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *  \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *  \r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ *  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *******************************************************************************/\r
+package org.onap.portalapp.lm;\r
+\r
+import java.util.Date;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.servlet.ServletContext;\r
+\r
+//import org.onap.portalsdk.core.lm.FusionLicenseManager;\r
+interface FusionLicenseManager {\r
+       public void initKeyStoreParam();\r
+\r
+       public void initCipherParam();\r
+\r
+       public void initLicenseParam();\r
+\r
+       public int installLicense();\r
+\r
+       public int verifyLicense(ServletContext context);\r
+\r
+       public void setExpiredDate(Date expiredDate);\r
+\r
+       public void doInitWork();\r
+\r
+       public void generateLicense(Map<String, String> clientInfoMap, List<String> ipAddressList) throws Exception;\r
+\r
+       public String nvl(String s);\r
+\r
+       public Date getExpiredDate();\r
+}\r
+public class FusionLicenseManagerImpl implements FusionLicenseManager {\r
+\r
+       private Date expiredDate;\r
+\r
+       public FusionLicenseManagerImpl() {\r
+       }\r
+\r
+       /**\r
+        * An implementation of the KeyStoreParam interface that returns the\r
+        * information required to work with the keystore containing the private key.\r
+        */\r
+       @Override\r
+       public void initKeyStoreParam() {\r
+       }\r
+\r
+       @Override\r
+       public void initCipherParam() {\r
+       }\r
+\r
+       /**\r
+        * Create/populate the "licenseParm" field.\r
+        */\r
+       @Override\r
+       public void initLicenseParam() {\r
+       }\r
+\r
+       @Override\r
+       public void doInitWork() {\r
+       }\r
+\r
+       /**\r
+        * Prompt the user for the location of their license file, get the filename,\r
+        * then try to install the file.\r
+        * \r
+        * @return true if the license installed properly, false otherwise.\r
+        */\r
+       @Override\r
+       public int installLicense() {\r
+               //return INVALID_LICENSE;\r
+               return -1;\r
+       }\r
+\r
+       @Override\r
+       public synchronized int verifyLicense(ServletContext context) {\r
+\r
+               //return INVALID_LICENSE;\r
+               return -1;\r
+       }\r
+\r
+       @Override\r
+       public void generateLicense(Map<String, String> clientInfoMap, List<String> ipAddressList) throws Exception {\r
+       }\r
+\r
+       @Override\r
+       public String nvl(String s) {\r
+               return (s == null) ? "" : s;\r
+       }\r
+\r
+       @Override\r
+       public Date getExpiredDate() {\r
+               return expiredDate;\r
+       }\r
+\r
+       @Override\r
+       public void setExpiredDate(Date expiredDate) {\r
+               this.expiredDate = expiredDate;\r
+       }\r
+\r
+}\r
index 22fca6d..88bce2d 100644 (file)
@@ -1,91 +1,91 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed 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
- * 
- *      http://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.
- * ================================================================================
- */
-
-package org.onap.portalapp.login;
-
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.openecomp.portalsdk.core.auth.LoginStrategy;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
-import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants;
-import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties;
-import org.springframework.web.servlet.ModelAndView;
-
-public class LoginStrategyImpl extends LoginStrategy {
-
-       EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LoginStrategyImpl.class);
-
-       @Override
-       public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {
-               // 'login' for opensource is same as 'external' login.
-               return doExternalLogin(request, response);
-       }
-
-       @Override
-       public String getUserId(HttpServletRequest request) throws PortalAPIException {
-               // Check ECOMP Portal cookie
-               if (!isLoginCookieExist(request))
-                       return null;
-
-               String userid = null;
-               try {
-                       userid = getUserIdFromCookie(request);
-               } catch (Exception e) {
-                       logger.error(EELFLoggerDelegate.errorLogger, "getUserId failed", e);
-               }
-               return userid;
-       }
-
-       private static String getUserIdFromCookie(HttpServletRequest request) throws Exception {
-               String userId = "";
-               Cookie[] cookies = request.getCookies();
-               Cookie userIdcookie = null;
-               if (cookies != null)
-                       for (Cookie cookie : cookies)
-                               if (cookie.getName().equals(USER_ID))
-                                       userIdcookie = cookie;
-               if (userIdcookie != null) {
-                       userId = CipherUtil.decrypt(userIdcookie.getValue(),
-                                       PortalApiProperties.getProperty(PortalApiConstants.Decryption_Key));
-               }
-               return userId;
-
-       }
-
-       private static boolean isLoginCookieExist(HttpServletRequest request) {
-               Cookie ep = getCookie(request, EP_SERVICE);
-               return (ep != null);
-       }
-
-       private static Cookie getCookie(HttpServletRequest request, String cookieName) {
-               Cookie[] cookies = request.getCookies();
-               if (cookies != null)
-                       for (Cookie cookie : cookies)
-                               if (cookie.getName().equals(cookieName))
-                                       return cookie;
-
-               return null;
-       }
-
-}
+/*-\r
+ * ================================================================================\r
+ * ECOMP Portal SDK\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ================================================================================\r
+ */\r
+\r
+package org.onap.portalapp.login;\r
+\r
+import javax.servlet.http.Cookie;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.onap.portalsdk.core.auth.LoginStrategy;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;\r
+import org.onap.portalsdk.core.onboarding.util.CipherUtil;\r
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;\r
+import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;\r
+import org.springframework.web.servlet.ModelAndView;\r
+\r
+public class LoginStrategyImpl extends LoginStrategy {\r
+\r
+       EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LoginStrategyImpl.class);\r
+\r
+       @Override\r
+       public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) throws Exception {\r
+               // 'login' for opensource is same as 'external' login.\r
+               return doExternalLogin(request, response);\r
+       }\r
+\r
+       @Override\r
+       public String getUserId(HttpServletRequest request) throws PortalAPIException {\r
+               // Check ECOMP Portal cookie\r
+               if (!isLoginCookieExist(request))\r
+                       return null;\r
+\r
+               String userid = null;\r
+               try {\r
+                       userid = getUserIdFromCookie(request);\r
+               } catch (Exception e) {\r
+                       logger.error(EELFLoggerDelegate.errorLogger, "getUserId failed", e);\r
+               }\r
+               return userid;\r
+       }\r
+\r
+       private static String getUserIdFromCookie(HttpServletRequest request) throws Exception {\r
+               String userId = "";\r
+               Cookie[] cookies = request.getCookies();\r
+               Cookie userIdcookie = null;\r
+               if (cookies != null)\r
+                       for (Cookie cookie : cookies)\r
+                               if (cookie.getName().equals(USER_ID))\r
+                                       userIdcookie = cookie;\r
+               if (userIdcookie != null) {\r
+                       userId = ""; //CipherUtil.decrypt(userIdcookie.getValue(),\r
+                       //PortalApiProperties.getProperty(PortalApiConstants.Decryption_Key));\r
+               }\r
+               return userId;\r
+\r
+       }\r
+\r
+       private static boolean isLoginCookieExist(HttpServletRequest request) {\r
+               Cookie ep = getCookie(request, EP_SERVICE);\r
+               return (ep != null);\r
+       }\r
+\r
+       private static Cookie getCookie(HttpServletRequest request, String cookieName) {\r
+               Cookie[] cookies = request.getCookies();\r
+               if (cookies != null)\r
+                       for (Cookie cookie : cookies)\r
+                               if (cookie.getName().equals(cookieName))\r
+                                       return cookie;\r
+\r
+               return null;\r
+       }\r
+\r
+}\r
index 17fe4ee..fdda960 100644 (file)
@@ -1,68 +1,68 @@
-/*-
- * ================================================================================
- * ECOMP Portal SDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed 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
- * 
- *      http://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.
- * ================================================================================
- */
-package org.onap.portalapp.service;
-
-import java.util.Set;
-
-import org.openecomp.portalapp.service.IAdminAuthExtension;
-import org.openecomp.portalsdk.core.domain.Role;
-import org.openecomp.portalsdk.core.domain.User;
-import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-
-@Service("adminAuthExtension")
-@Transactional
-/**
- * Provides empty implementations of the methods in IAdminAuthExtension.
- */
-public class AdminAuthExtension implements IAdminAuthExtension {
-
-       EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AdminAuthExtension.class);
-
-       /*
-        * (non-Javadoc)
-        * @see org.openecomp.portalapp.service.IAdminAuthExtension#saveUserExtension(org.openecomp.portalsdk.core.domain.User)
-        */
-       @Override
-       public void saveUserExtension(User user) {
-               logger.debug("saveUserExtension");
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see org.openecomp.portalapp.service.IAdminAuthExtension#editUserExtension(org.openecomp.portalsdk.core.domain.User)
-        */
-       @Override
-       public void editUserExtension(User user) {
-               logger.debug("editUserExtension");
-       }
-
-       /*
-        * (non-Javadoc)
-        * @see org.openecomp.portalapp.service.IAdminAuthExtension#saveUserRoleExtension(java.util.Set, org.openecomp.portalsdk.core.domain.User)
-        */
-       @Override
-       public void saveUserRoleExtension(Set<Role> roles, User user) {
-               logger.debug("saveUserRoleExtension");
-       }
-
-}
+/*-\r
+ * ================================================================================\r
+ * ECOMP Portal SDK\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ================================================================================\r
+ */\r
+package org.onap.portalapp.service;\r
+\r
+import java.util.Set;\r
+\r
+import org.onap.portalapp.service.IAdminAuthExtension;\r
+import org.onap.portalsdk.core.domain.Role;\r
+import org.onap.portalsdk.core.domain.User;\r
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;\r
+import org.springframework.stereotype.Service;\r
+import org.springframework.transaction.annotation.Transactional;\r
+\r
+\r
+@Service("adminAuthExtension")\r
+@Transactional\r
+/**\r
+ * Provides empty implementations of the methods in IAdminAuthExtension.\r
+ */\r
+public class AdminAuthExtension implements IAdminAuthExtension {\r
+\r
+       EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AdminAuthExtension.class);\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.onap.portalapp.service.IAdminAuthExtension#saveUserExtension(org.onap.portalsdk.core.domain.User)\r
+        */\r
+       @Override\r
+       public void saveUserExtension(User user) {\r
+               logger.debug("saveUserExtension");\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.onap.portalapp.service.IAdminAuthExtension#editUserExtension(org.onap.portalsdk.core.domain.User)\r
+        */\r
+       @Override\r
+       public void editUserExtension(User user) {\r
+               logger.debug("editUserExtension");\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * @see org.onap.portalapp.service.IAdminAuthExtension#saveUserRoleExtension(java.util.Set, org.onap.portalsdk.core.domain.User)\r
+        */\r
+       @Override\r
+       public void saveUserRoleExtension(Set<Role> roles, User user) {\r
+               logger.debug("saveUserRoleExtension");\r
+       }\r
+\r
+}\r
index c9bde0a..88ef37c 100644 (file)
@@ -1,45 +1,44 @@
-###############################################################################
-# =============LICENSE_START=========================================================
-#
-# =================================================================================
-#  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-#  Licensed 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
-#  
-#      http://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.
-# ============LICENSE_END=========================================================
-#
-#  ECOMP is a trademark and service mark of AT&T Intellectual Property.
-###############################################################################
-# OS portal.properties
-
-# Properties read by ECOMP Framework library, ecompFW.jar
-
-portal.api.impl.class = org.openecomp.portalapp.service.OnBoardingApiServiceImpl
-portal.api.prefix = /api
-max.idle.time = 5
-user.attribute.name = user_attribute
-
-# URL of the ECOMP Portal REST API
-ecomp_rest_url = http://portal.api.simpledemo.openecomp.org/ecompportal/auxapi
-
-#Use REST API instead of UEB to fetch the functional menu data
-use_rest_for_functional_menu=true
-
-# Don't fetch functional menu via UEB in 1610.
-ueb_listeners_enable = false
-
-# Application key is used by session management
-ueb_app_key = cwMmLOCKSHPJUeVC                                 
-
-# The inbox name property should not be required when the REST API is used,
-# but in 1610 FuncMenuController logs ALARM if it cannot find this key.
-ecomp_portal_inbox_name = ECOMP-PORTAL-INBOX-TEST
+###############################################################################\r
+# =============LICENSE_START=========================================================\r
+#\r
+# =================================================================================\r
+#  Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.\r
+# ================================================================================\r
+#  Licensed under the Apache License, Version 2.0 (the "License");\r
+#  you may not use this file except in compliance with the License.\r
+#  You may obtain a copy of the License at\r
+#  \r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+#  \r
+#  Unless required by applicable law or agreed to in writing, software\r
+#  distributed under the License is distributed on an "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+#  See the License for the specific language governing permissions and\r
+#  limitations under the License.\r
+# ============LICENSE_END=========================================================\r
+#\r
+#  ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+###############################################################################\r
+# OS portal.properties\r
+\r
+# Properties read by ECOMP Framework library, ecompFW.jar\r
+portal.api.impl.class=org.onap.portalapp.service.OnBoardingApiServiceImpl\r
+portal.api.prefix = /api\r
+max.idle.time = 5\r
+user.attribute.name = user_attribute\r
+\r
+# URL of the ECOMP Portal REST API\r
+ecomp_rest_url = http://portal.api.simpledemo.openecomp.org/ecompportal/auxapi\r
+\r
+#Use REST API instead of UEB to fetch the functional menu data\r
+use_rest_for_functional_menu=true\r
+\r
+# Don't fetch functional menu via UEB in 1610.\r
+ueb_listeners_enable = false\r
+\r
+# Application key is used by session management\r
+ueb_app_key = cwMmLOCKSHPJUeVC                                 \r
+\r
+# The inbox name property should not be required when the REST API is used,\r
+# but in 1610 FuncMenuController logs ALARM if it cannot find this key.\r
+ecomp_portal_inbox_name = ECOMP-PORTAL-INBOX-TEST\r
index 935c6aa..a31937c 100644 (file)
-<%--
-  ================================================================================
-  ECOMP Portal SDK
-  ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property
-  ================================================================================
-  Licensed 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
-  
-       http://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.
-  ================================================================================
---%>
-<%@ page import="org.openecomp.portalsdk.core.util.SystemProperties"%>
-<!DOCTYPE html>
-<%
-       // Name is defined by app; do not throw if missing
-       final String appDisplayName = SystemProperties.containsProperty(SystemProperties.APP_DISPLAY_NAME)
-                       ? SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)
-                       : SystemProperties.APP_DISPLAY_NAME;
-%>
-
-<html>
-       <head>
-               <meta charset="utf-8">
-               <meta http-equiv="X-UA-Compatible" content="IE=edge">
-               <meta name="viewport" content="width=device-width, initial-scale=1">
-               <title>Login</title>
-               <style>
-               html {
-                       font-family: Verdana, Arial, Helvetica, sans-serif;
-               }
-               body {
-                       padding-top: 15px;
-               }
-               .logo {
-                       position: fixed;
-                       left: 15px;
-                       top: 15px;
-                       z-index: -1;
-               }
-               .loginError {
-                       font-size: 18px;
-                       color: red;
-                       text-align: center;
-               }
-               .login {
-                       font-size: 16px;
-                       display: block;
-                       margin-left: auto;
-                       margin-right: auto;
-                       text-align: center;
-                       width: 100%;
-               }
-               .login input[type=submit] {
-                       font-size: 16px;
-               }
-               .terms {
-                       font-size: 10px;
-                       text-align: center;
-                       margin-left: auto;
-                       margin-right: auto;
-               }
-               .terms a {
-                       font-size: 10px;
-                       text-align: center;
-                       margin-left: auto;
-                       margin-right: auto;
-               }
-               </style>
-       </head>
-       <body>
-               <div class="login">
-                       <img src="app/oom/images/onap_logo_2257x496.png" style="height: 150px;" />
-                       <h2>
-                               <%=appDisplayName%>
-                       </h2>
-                       <br />
-                       <form action="login_external" method="POST"> 
-                               <label for="loginId">Login ID:</label>
-                               <input id="loginId" name="loginId" type="text" style="width: 140px;height:25px;border-radius:7px;font-size:18px;padding-left:5px;" maxlength="30">
-                               <br/>
-                               <br/>
-                               <label for="password">Password:</label>
-                               <input id="password" name="password" type="password" style="width: 140px;height:25px;border-radius:7px;font-size:18px;padding-left:5px;"
-                                                       maxlength="30" >
-                               <br />
-                               <br />
-                               <input id="loginBtn" type="submit" alt="Login" value="Login">
-                       </form>
-               </div>
-               <br />
-               <br />
-               <div class="loginError">${model.error}</div>
-               <br />
-               <br />
-               <br />
-               <br />
-               <br />
-               <br />
-               <div id="footer">
-                       <div class="terms">
-                               Copyright 2017 Open ECOMP and Linux Foundation.
-                       </div>
-               </div>
-       </body>
-</html>
+<%--\r
+  ================================================================================\r
+  ECOMP Portal SDK\r
+  ================================================================================\r
+  Copyright (C) 2017 AT&T Intellectual Property\r
+  ================================================================================\r
+  Licensed under the Apache License, Version 2.0 (the "License");\r
+  you may not use this file except in compliance with the License.\r
+  You may obtain a copy of the License at\r
+  \r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+  \r
+  Unless required by applicable law or agreed to in writing, software\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+  ================================================================================\r
+--%>\r
+<%@ page import="org.onap.portalsdk.core.util.SystemProperties"%>\r
+<!DOCTYPE html>\r
+<%\r
+       // Name is defined by app; do not throw if missing\r
+       final String appDisplayName = SystemProperties.containsProperty(SystemProperties.APP_DISPLAY_NAME)\r
+                       ? SystemProperties.getProperty(SystemProperties.APP_DISPLAY_NAME)\r
+                       : SystemProperties.APP_DISPLAY_NAME;\r
+%>\r
+\r
+<html>\r
+       <head>\r
+               <meta charset="utf-8">\r
+               <meta http-equiv="X-UA-Compatible" content="IE=edge">\r
+               <meta name="viewport" content="width=device-width, initial-scale=1">\r
+               <title>Login</title>\r
+               <style>\r
+               html {\r
+                       font-family: Verdana, Arial, Helvetica, sans-serif;\r
+               }\r
+               body {\r
+                       padding-top: 15px;\r
+               }\r
+               .logo {\r
+                       position: fixed;\r
+                       left: 15px;\r
+                       top: 15px;\r
+                       z-index: -1;\r
+               }\r
+               .loginError {\r
+                       font-size: 18px;\r
+                       color: red;\r
+                       text-align: center;\r
+               }\r
+               .login {\r
+                       font-size: 16px;\r
+                       display: block;\r
+                       margin-left: auto;\r
+                       margin-right: auto;\r
+                       text-align: center;\r
+                       width: 100%;\r
+               }\r
+               .login input[type=submit] {\r
+                       font-size: 16px;\r
+               }\r
+               .terms {\r
+                       font-size: 10px;\r
+                       text-align: center;\r
+                       margin-left: auto;\r
+                       margin-right: auto;\r
+               }\r
+               .terms a {\r
+                       font-size: 10px;\r
+                       text-align: center;\r
+                       margin-left: auto;\r
+                       margin-right: auto;\r
+               }\r
+               </style>\r
+       </head>\r
+       <body>\r
+               <div class="login">\r
+                       <img src="app/oom/images/onap_logo_2257x496.png" style="height: 150px;" />\r
+                       <h2>\r
+                               <%=appDisplayName%>\r
+                       </h2>\r
+                       <br />\r
+                       <form action="login_external" method="POST"> \r
+                               <label for="loginId">Login ID:</label>\r
+                               <input id="loginId" name="loginId" type="text" style="width: 140px;height:25px;border-radius:7px;font-size:18px;padding-left:5px;" maxlength="30">\r
+                               <br/>\r
+                               <br/>\r
+                               <label for="password">Password:</label>\r
+                               <input id="password" name="password" type="password" style="width: 140px;height:25px;border-radius:7px;font-size:18px;padding-left:5px;"\r
+                                                       maxlength="30" >\r
+                               <br />\r
+                               <br />\r
+                               <input id="loginBtn" type="submit" alt="Login" value="Login">\r
+                       </form>\r
+               </div>\r
+               <br />\r
+               <br />\r
+               <div class="loginError">${model.error}</div>\r
+               <br />\r
+               <br />\r
+               <br />\r
+               <br />\r
+               <br />\r
+               <br />\r
+               <div id="footer">\r
+                       <div class="terms">\r
+                               Copyright 2017 Open ECOMP and Linux Foundation.\r
+                       </div>\r
+               </div>\r
+       </body>\r
+</html>\r
index a827e6c..1be0530 100644 (file)
-<?xml version="1.0"?>
-<!--
-  ================================================================================
-  ECOMP Portal SDK
-  ================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property
-  ================================================================================
-  Licensed 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
-  
-       http://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.
-  ================================================================================
-  -->
-
-<!-- This is a COPY, modifies the original to drop RAPTOR classes and queries not needed -->
-
-<!DOCTYPE hibernate-mapping PUBLIC
-        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.openecomp.portalsdk.core.domain">
-
-     <!-- User class mapping details -->
-    <class name="User" table="FN_USER">
-        <id name="id" column="user_id" > 
-          <generator class="native">
-             <param name="sequence">seq_fn_user</param> 
-          </generator>
-        </id>
-
-        <property name="orgId"         column="org_id"/>
-        <property name="managerId"     column="manager_id"/>
-        <property name="firstName"     column="first_name"/>
-        <property name="middleInitial" column="middle_name"/>
-        <property name="lastName"      column="last_name"/>
-        <property name="phone"         column="phone"/>
-        <property name="fax"           column="fax"/>
-        <property name="cellular"      column="cellular"/>
-        <property name="email"         column="email"/>
-        <property name="addressId"     column="address_id"/>
-        <property name="alertMethodCd" column="alert_method_cd"/>
-
-        <property name="address1"      column="address_line_1"/>
-        <property name="address2"      column="address_line_2"/>
-        <property name="city"          column="city"/>
-        <property name="state"         column="state_cd"/>
-        <property name="zipCode"       column="zip_code"/>
-        <property name="country"       column="country_cd"/>
-
-        <property name="hrid"          column="hrid"/>
-        <property name="orgUserId"     column="org_user_id"/>
-        <property name="orgCode"       column="org_code"/>
-        <property name="loginId"       column="login_id"/>
-        <property name="loginPwd"      column="login_pwd"/>
-        <property name="lastLoginDate" column="last_login_date"  type="timestamp"/>
-
-        <property name="locationClli"  column="location_clli" />
-        <property name="orgManagerUserId" column="org_manager_userid" />
-        <property name="company"       column="company" />
-        <property name="department"    column="department" />
-        <property name="departmentName"        column="department_name" />
-        <property name="businessUnit"                  column="business_unit" />
-        <property name="businessUnitName"   column="business_unit_name" />
-        <property name="jobTitle"                      column="job_title" />
-        <property name="siloStatus"                    column="silo_status" />
-        <property name="financialLocCode"   column="fin_loc_code" />
-
-        <property name="active"        column="active_yn"       type="yes_no"/>
-        <property name="internal"      column="is_internal_yn"  type="yes_no"/>
-
-        <property name="created"  type="timestamp" column="created_date"  />
-        <property name="modified" type="timestamp" column="modified_date" />
-
-        <property name="createdId"  column="created_id" />
-        <property name="modifiedId" column="modified_id" />
-               <property name="timeZoneId" column="timezone" />
-               
-        <set name="userApps" table="FN_USER_ROLE" lazy="false" sort="natural" inverse="true" cascade="all-delete-orphan">
-            <key column="user_id"/>
-            <one-to-many class="org.openecomp.portalsdk.core.domain.UserApp" />
-        </set>
-
-        <set name="pseudoRoles" table="FN_USER_PSEUDO_ROLE" lazy="false" sort="natural">
-            <key column="user_id"/>
-            <many-to-many column="pseudo_role_id" class="org.openecomp.portalsdk.core.domain.Role" />
-        </set>
-    </class>
-
-     <!-- Profile class mapping details;
-         dupe of User class, but fewer fields -->
-    <class name="Profile" table="FN_USER">
-        <id name="id" column="user_id" > 
-                       <generator class="increment"/>
-        </id>  
-        <property name="first_name"     column="first_name"/>
-        <property name="last_name"      column="last_name"/>
-        <property name="email"         column="email"/>
-        <property name="orgManagerUserId" column="org_manager_userid" />
-        <property name="active_yn"        column="active_yn"/>
-        <property name="orgUserId"         column="org_user_id"/>
-       </class>
-       
-       <class name="UserApp" table="fn_user_role">
-        <composite-id>
-            <key-property name="userId" type="long">
-                <column name="user_id" precision="11" scale="0" />
-            </key-property>
-               <key-many-to-one name="app" class="org.openecomp.portalsdk.core.domain.App" column="app_id" />
-               <key-many-to-one name="role" class="org.openecomp.portalsdk.core.domain.Role" column="role_id" />
-        </composite-id>
-        <property name="priority" type="java.lang.Short">
-            <column name="priority" precision="4" scale="0" />
-        </property>
-    </class>
-
-    <!-- App class mapping details -->
-    <class name="App" table="fn_app">
-        <id name="id" column="app_id"/>
-        <property name="name" column="app_name"/>
-        <property name="appPassword" column="app_password"/>
-        <property name="username" column="app_username"/>
-               <property name="imageUrl" column="app_image_url"/>
-               <property name="description" column="app_description"/>
-               <property name="notes" column="app_notes"/>
-               <property name="url" column="app_url"/>
-               <property name="alternateUrl" column="app_alternate_url"/>
-               <property name="restEndpoint" column="app_rest_endpoint"/>
-               <property name="mlAppName" column="ml_app_name"/>
-               <property name="mlAppAdminId" column="ml_app_admin_id"/>
-               <property name="motsId" column="mots_id"/>
-               <property name="open" column="open"/>
-               <property name="enabled" column="enabled"/>
-               <property name="thumbnail" column="thumbnail" type="blob"/>
-               <property name="uebKey" column="ueb_key"/>
-               <property name="uebSecret" column="ueb_secret"/>
-               <property name="uebTopicName" column="ueb_topic_name"/>
-    </class>
-
-
-       <!-- Audit Log class mapping details -->
-    <class name="AuditLog" table="fn_audit_log">
-        <id name="id" column="log_id">
-          <!-- <generator class="sequence">
-            <param name="sequence">seq_fn_audit_log</param>
-          </generator> -->
-          <generator class="native">
-                       <param name="sequence">seq_fn_audit_log</param>
-                 </generator>
-        </id>
-        <property name="activityCode"      column="activity_cd"/>
-        <property name="affectedRecordId"  column="affected_record_id"  />
-        <property name="comments"          column="comments"  />
-        <property name="createdId"         column="user_id" />
-    </class>
-    
-    <!-- User Role class mapping details -->
-    <class name="Role" table="FN_ROLE">
-        <id name="id" column="role_id">
-           <generator class="native">
-             <param name="sequence">seq_fn_role</param> 
-          </generator>
-        </id>
-
-        <property name="name"      column="role_name"/>
-        <property name="priority"  column="priority" />
-        <property name="active"    column="active_yn"  type="yes_no"/>
-
-        <set name="roleFunctions" table="FN_ROLE_FUNCTION" lazy="false" sort="natural">
-            <key column="role_id"/>
-            <many-to-many column="function_cd" class="org.openecomp.portalsdk.core.domain.RoleFunction"/>
-        </set>
-
-        <set name="childRoles" table="FN_ROLE_COMPOSITE" lazy="false" sort="natural">
-            <key column="parent_role_id"/>
-            <many-to-many column="child_role_id" class="org.openecomp.portalsdk.core.domain.Role"/>
-        </set>
-        
-        <set name="parentRoles" table="FN_ROLE_COMPOSITE" lazy="false" sort="natural">
-            <key column="child_role_id"/>
-            <many-to-many column="parent_role_id" class="org.openecomp.portalsdk.core.domain.Role"/>
-        </set>
-
-    </class>
-    
-
-    <!-- User Role Function class mapping details -->
-    <class name="RoleFunction" table="FN_FUNCTION">
-        <id        name="code"  column="function_cd"   />
-        <property  name="name"  column="function_name" />
-    </class>
-    
-    <!-- Menu class mapping details -->
-    <class name="Menu" table="FN_MENU">
-        <id name="id" column="menu_id">
-          <generator class="native">
-             <param name="sequence">seq_fn_menu</param> 
-          </generator>
-        </id>
-
-         <!-- <property name="menuLevel"   column="level-1"/> -->
-         <property name="label"       column="label"/>
-         <property name="parentId"    column="parent_id"/>
-         <property name="action"      column="action"/>
-         <property name="functionCd"  column="function_cd"/>
-         <property name="sortOrder"   column="sort_order"/>
-         <property name="servlet"     column="servlet"/>
-         <property name="queryString" column="query_string"/>
-         <property name="externalUrl" column="external_url"/>
-         <property name="target"      column="target"/>
-         <property name="menuSetCode" column="menu_set_cd"/>
-         <property name="active"      column="active_yn"    type="yes_no"/>
-         <property name="separator"   column="separator_yn" type="yes_no"/>
-         <property name="imageSrc"    column="image_src" />
-    </class>
-
-    <class name="MenuData" table="FN_MENU">
-        <!--  <id       name="id"          column="menu_id"/> -->
-        <id name="id" column="menu_id">
-          <generator class="native">
-             <param name="sequence">seq_fn_menu</param> 
-          </generator>
-        </id>
-        <property name="label"       column="label"/>
-        <property name="action"      column="action"/>
-        <property name="functionCd"  column="function_cd"/>
-        <property name="sortOrder"   column="sort_order"/>
-        <property name="servlet"     column="servlet"/>
-        <property name="queryString" column="query_string"/>
-        <property name="externalUrl" column="external_url"/>
-        <property name="target"      column="target"/>
-        <property name="active"      column="active_yn"    type="yes_no"/>
-        <property name="separator"   column="separator_yn" type="yes_no"/>
-        <property name="imageSrc"    column="image_src" />
-        <property name="menuSetCode" column="menu_set_cd"  />
-
-        <many-to-one name="parentMenu" column="parent_id" class="MenuData"/>
-
-        <set name="childMenus" lazy="false" sort="natural" inverse="true" where="active_yn = 'Y'">
-            <key column="parent_id"/>
-            <one-to-many class="MenuData"/>
-        </set>
-    </class>
-    
-    <!-- Broadcast Message class mapping details -->
-    <class name="BroadcastMessage" table="fn_broadcast_message">
-        <id name="id" column="message_id">
-            <generator class="native">
-              <param name="sequence">seq_fn_broadcast_message</param>
-            </generator>
-        </id>
-        <property name="messageText" column="message_text"/>
-        <property name="locationId"  column="message_location_id"/>
-
-        <property name="startDate"   column="broadcast_start_date"  type="timestamp"/>
-        <property name="endDate"     column="broadcast_end_date"    type="timestamp"/>
-
-        <property name="sortOrder"   column="sort_order"/>
-        <property name="active"      column="active_yn"             type="yes_no"/>
-
-        <property name="siteCd"      column="broadcast_site_cd"    />
-    </class>
-
-       <!-- 
-    <class name="org.openecomp.portalsdk.analytics.model.base.ReportUserRole" table="cr_report_access">
-               <composite-id>
-                       <key-property name="repId" column="rep_id" />
-                       <key-property name="orderNo" column="order_no" />
-               </composite-id>
-
-        <property name="roleId" column="role_id"/>
-        <property name="userId"  column="user_id"/>
-        <property name="readOnlyYn"  column="read_only_yn"/>
-    </class>    
-     -->
-     
-    <!-- State Lookup class mapping details -->
-    <class name="LuState" table="FN_LU_STATE">
-        <id       name="abbr"  column="state_cd" />
-        <property name="state"                   />
-    </class>
-    
-    <!-- Country Lookup class mapping details -->
-    <class name="LuCountry" table="FN_LU_COUNTRY">
-        <id       name="abbr"  column="country_cd" />
-        <property name="country"                   />
-        <property name="fullName" column="full_name" />
-        <property name="webphoneCountryLabel" column="fullwebphone_country_label_name" />
-    </class>
-    
-    <class name="LuTimeZone" table="FN_LU_TIMEZONE">
-        <id       name="timezoneId"  column="timezone_id" />
-        <property name="name" column="timezone_name" />
-        <property name="value" column="timezone_value" />
-    </class>
-
-
-    <!-- Lookup (id/value bean) class mapping details -->
-    <class name="Lookup">
-        <composite-id  name="nameValueId" class="org.openecomp.portalsdk.core.domain.support.NameValueId">
-          <key-property name="val"/>
-          <key-property name="lab" />
-        </composite-id>
-    </class>
-
-       <class name="UrlsAccessible" table="V_URL_ACCESS">
-      <composite-id  name="urlsAccessibleKey" class="org.openecomp.portalsdk.core.domain.UrlsAccessibleKey">
-       <key-property   name="url"      column="url"/>
-       <key-property   name="functionCd"       column="function_cd"/>
-      </composite-id>
-    </class>
-
-
-       <query name="ParentIdForLabelList">
-      select distinct md.parentMenu.id from MenuData as md where md.label = :paramLabel and md.label is not null
-    </query>
-    
-       <query name="IdForLabelList">
-      select distinct md.id from MenuData as md where md.label = :paramLabel
-    </query>    
-    
-       <query name="parentList">
-      select distinct md.id, md.label, md.parentMenu.id from MenuData as md where md.label is not null
-    </query>
-       
-       <query name="functionCDlistOld">
-      select distinct functionCd from MenuData 
-    </query>
-
-       <query name="functionCDlist">
-      select distinct code from RoleFunction 
-    </query>   
-     
-       <query name="menuData">
-      from MenuData where menuSetCode = :menu_set_cd and parentMenu is null
-    </query>
-       <query name="restrictedUrls">
-      FROM UrlsAccessible A where upper(A.urlsAccessibleKey.url) = upper(:current_url)
-    </query>
-
-    <query name="getUserNameById">
-      select firstName, lastName from User where id = :user_id
-    </query>
-
-    <query name="getUserEmail">
-      select email from User where id = :user_id
-    </query>
-
-    <query name="getAllUsers">
-      select id, firstName, lastName from User where active = true order by lastName, firstName
-    </query>
-       
-    <query name="getRoleNameById">
-      select name from Role where id = :role_id
-    </query>
-
-    <query name="getAllRoles">
-      select id, name from Role order by name
-    </query>   
-
-       <!-- 
-    <query name="getReportSecurityUsers">
-      select repId, orderNo, roleId, userId, readOnlyYn from ReportUserRole where repId = :report_id and userId is not null
-    </query>
-        
-    <query name="getReportSecurityRoles">
-      select repId, orderNo, roleId, userId, readOnlyYn from ReportUserRole where repId = :report_id and roleId is not null
-    </query>
-    -->    
-
-<!--     <query name="insertReportSecurityUsers">
-               insert into ReportUserRole (repId, roleId, userId, readOnlyYn) values (:report_id, :role_id, :user_id, :read_only_yn)
-    </query> -->
-    
-       <!--
-    <query name="deleteReportSecurityUsers">
-      delete from ReportUserRole where repId = :report_id and userId =:user_id
-    </query>
-
-    <query name="deleteReportSecurityRoles">
-      delete from ReportUserRole where repId = :report_id and roleId =:role_id
-    </query>
-    -->    
-
-</hibernate-mapping>
+<?xml version="1.0"?>\r
+<!--\r
+  ================================================================================\r
+  ECOMP Portal SDK\r
+  ================================================================================\r
+  Copyright (C) 2017 AT&T Intellectual Property\r
+  ================================================================================\r
+  Licensed under the Apache License, Version 2.0 (the "License");\r
+  you may not use this file except in compliance with the License.\r
+  You may obtain a copy of the License at\r
+  \r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+  \r
+  Unless required by applicable law or agreed to in writing, software\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+  ================================================================================\r
+  -->\r
+\r
+<!-- This is a COPY, modifies the original to drop RAPTOR classes and queries not needed -->\r
+\r
+<!DOCTYPE hibernate-mapping PUBLIC\r
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"\r
+        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">\r
+\r
+<hibernate-mapping package="org.onap.portalsdk.core.domain">\r
+\r
+     <!-- User class mapping details -->\r
+    <class name="User" table="FN_USER">\r
+        <id name="id" column="user_id" > \r
+          <generator class="native">\r
+             <param name="sequence">seq_fn_user</param> \r
+          </generator>\r
+        </id>\r
+\r
+        <property name="orgId"         column="org_id"/>\r
+        <property name="managerId"     column="manager_id"/>\r
+        <property name="firstName"     column="first_name"/>\r
+        <property name="middleInitial" column="middle_name"/>\r
+        <property name="lastName"      column="last_name"/>\r
+        <property name="phone"         column="phone"/>\r
+        <property name="fax"           column="fax"/>\r
+        <property name="cellular"      column="cellular"/>\r
+        <property name="email"         column="email"/>\r
+        <property name="addressId"     column="address_id"/>\r
+        <property name="alertMethodCd" column="alert_method_cd"/>\r
+\r
+        <property name="address1"      column="address_line_1"/>\r
+        <property name="address2"      column="address_line_2"/>\r
+        <property name="city"          column="city"/>\r
+        <property name="state"         column="state_cd"/>\r
+        <property name="zipCode"       column="zip_code"/>\r
+        <property name="country"       column="country_cd"/>\r
+\r
+        <property name="hrid"          column="hrid"/>\r
+        <property name="orgUserId"     column="org_user_id"/>\r
+        <property name="orgCode"       column="org_code"/>\r
+        <property name="loginId"       column="login_id"/>\r
+        <property name="loginPwd"      column="login_pwd"/>\r
+        <property name="lastLoginDate" column="last_login_date"  type="timestamp"/>\r
+\r
+        <property name="locationClli"  column="location_clli" />\r
+        <property name="orgManagerUserId" column="org_manager_userid" />\r
+        <property name="company"       column="company" />\r
+        <property name="department"    column="department" />\r
+        <property name="departmentName"        column="department_name" />\r
+        <property name="businessUnit"                  column="business_unit" />\r
+        <property name="businessUnitName"   column="business_unit_name" />\r
+        <property name="jobTitle"                      column="job_title" />\r
+        <property name="siloStatus"                    column="silo_status" />\r
+        <property name="financialLocCode"   column="fin_loc_code" />\r
+\r
+        <property name="active"        column="active_yn"       type="yes_no"/>\r
+        <property name="internal"      column="is_internal_yn"  type="yes_no"/>\r
+\r
+        <property name="created"  type="timestamp" column="created_date"  />\r
+        <property name="modified" type="timestamp" column="modified_date" />\r
+\r
+        <property name="createdId"  column="created_id" />\r
+        <property name="modifiedId" column="modified_id" />\r
+               <property name="timeZoneId" column="timezone" />\r
+               \r
+        <set name="userApps" table="FN_USER_ROLE" lazy="false" sort="natural" inverse="true" cascade="all-delete-orphan">\r
+            <key column="user_id"/>\r
+            <one-to-many class="org.onap.portalsdk.core.domain.UserApp"/>\r
+        </set>\r
+\r
+        <set name="pseudoRoles" table="FN_USER_PSEUDO_ROLE" lazy="false" sort="natural">\r
+            <key column="user_id"/>\r
+            <many-to-many column="pseudo_role_id" class="org.onap.portalsdk.core.domain.Role"/>\r
+        </set>\r
+    </class>\r
+\r
+     <!-- Profile class mapping details;\r
+         dupe of User class, but fewer fields -->\r
+    <class name="Profile" table="FN_USER">\r
+        <id name="id" column="user_id" > \r
+                       <generator class="increment"/>\r
+        </id>  \r
+        <property name="first_name"     column="first_name"/>\r
+        <property name="last_name"      column="last_name"/>\r
+        <property name="email"         column="email"/>\r
+        <property name="orgManagerUserId" column="org_manager_userid" />\r
+        <property name="active_yn"        column="active_yn"/>\r
+        <property name="orgUserId"         column="org_user_id"/>\r
+       </class>\r
+       \r
+       <class name="UserApp" table="fn_user_role">\r
+        <composite-id>\r
+            <key-property name="userId" type="long">\r
+                <column name="user_id" precision="11" scale="0" />\r
+            </key-property>\r
+            <key-many-to-one name="app" class="org.onap.portalsdk.core.domain.App" column="app_id"/>\r
+            <key-many-to-one name="role" class="org.onap.portalsdk.core.domain.Role" column="role_id"/>\r
+        </composite-id>\r
+        <property name="priority" type="java.lang.Short">\r
+            <column name="priority" precision="4" scale="0" />\r
+        </property>\r
+    </class>\r
+\r
+    <!-- App class mapping details -->\r
+    <class name="App" table="fn_app">\r
+        <id name="id" column="app_id"/>\r
+        <property name="name" column="app_name"/>\r
+        <property name="appPassword" column="app_password"/>\r
+        <property name="username" column="app_username"/>\r
+               <property name="imageUrl" column="app_image_url"/>\r
+               <property name="description" column="app_description"/>\r
+               <property name="notes" column="app_notes"/>\r
+               <property name="url" column="app_url"/>\r
+               <property name="alternateUrl" column="app_alternate_url"/>\r
+               <property name="restEndpoint" column="app_rest_endpoint"/>\r
+               <property name="mlAppName" column="ml_app_name"/>\r
+               <property name="mlAppAdminId" column="ml_app_admin_id"/>\r
+               <property name="motsId" column="mots_id"/>\r
+               <property name="open" column="open"/>\r
+               <property name="enabled" column="enabled"/>\r
+               <property name="thumbnail" column="thumbnail" type="blob"/>\r
+               <property name="uebKey" column="ueb_key"/>\r
+               <property name="uebSecret" column="ueb_secret"/>\r
+               <property name="uebTopicName" column="ueb_topic_name"/>\r
+    </class>\r
+\r
+\r
+       <!-- Audit Log class mapping details -->\r
+    <class name="AuditLog" table="fn_audit_log">\r
+        <id name="id" column="log_id">\r
+          <!-- <generator class="sequence">\r
+            <param name="sequence">seq_fn_audit_log</param>\r
+          </generator> -->\r
+          <generator class="native">\r
+                       <param name="sequence">seq_fn_audit_log</param>\r
+                 </generator>\r
+        </id>\r
+        <property name="activityCode"      column="activity_cd"/>\r
+        <property name="affectedRecordId"  column="affected_record_id"  />\r
+        <property name="comments"          column="comments"  />\r
+        <property name="createdId"         column="user_id" />\r
+    </class>\r
+    \r
+    <!-- User Role class mapping details -->\r
+    <class name="Role" table="FN_ROLE">\r
+        <id name="id" column="role_id">\r
+           <generator class="native">\r
+             <param name="sequence">seq_fn_role</param> \r
+          </generator>\r
+        </id>\r
+\r
+        <property name="name"      column="role_name"/>\r
+        <property name="priority"  column="priority" />\r
+        <property name="active"    column="active_yn"  type="yes_no"/>\r
+\r
+        <set name="roleFunctions" table="FN_ROLE_FUNCTION" lazy="false" sort="natural">\r
+            <key column="role_id"/>\r
+            <many-to-many column="function_cd" class="org.onap.portalsdk.core.domain.RoleFunction"/>\r
+        </set>\r
+\r
+        <set name="childRoles" table="FN_ROLE_COMPOSITE" lazy="false" sort="natural">\r
+            <key column="parent_role_id"/>\r
+            <many-to-many column="child_role_id" class="org.onap.portalsdk.core.domain.Role"/>\r
+        </set>\r
+        \r
+        <set name="parentRoles" table="FN_ROLE_COMPOSITE" lazy="false" sort="natural">\r
+            <key column="child_role_id"/>\r
+            <many-to-many column="parent_role_id" class="org.onap.portalsdk.core.domain.Role"/>\r
+        </set>\r
+\r
+    </class>\r
+    \r
\r
+\r
+    <!-- User Role Function class mapping details -->\r
+    <class name="RoleFunction" table="FN_FUNCTION">\r
+        <id        name="code"  column="function_cd"   />\r
+        <property  name="name"  column="function_name" />\r
+    </class>\r
+    \r
+    <!-- Menu class mapping details -->\r
+    <class name="Menu" table="FN_MENU">\r
+        <id name="id" column="menu_id">\r
+          <generator class="native">\r
+             <param name="sequence">seq_fn_menu</param> \r
+          </generator>\r
+        </id>\r
+\r
+         <!-- <property name="menuLevel"   column="level-1"/> -->\r
+         <property name="label"       column="label"/>\r
+         <property name="parentId"    column="parent_id"/>\r
+         <property name="action"      column="action"/>\r
+         <property name="functionCd"  column="function_cd"/>\r
+         <property name="sortOrder"   column="sort_order"/>\r
+         <property name="servlet"     column="servlet"/>\r
+         <property name="queryString" column="query_string"/>\r
+         <property name="externalUrl" column="external_url"/>\r
+         <property name="target"      column="target"/>\r
+         <property name="menuSetCode" column="menu_set_cd"/>\r
+         <property name="active"      column="active_yn"    type="yes_no"/>\r
+         <property name="separator"   column="separator_yn" type="yes_no"/>\r
+         <property name="imageSrc"    column="image_src" />\r
+    </class>\r
+\r
+    <class name="MenuData" table="FN_MENU">\r
+        <!--  <id       name="id"          column="menu_id"/> -->\r
+        <id name="id" column="menu_id">\r
+          <generator class="native">\r
+             <param name="sequence">seq_fn_menu</param> \r
+          </generator>\r
+        </id>\r
+        <property name="label"       column="label"/>\r
+        <property name="action"      column="action"/>\r
+        <property name="functionCd"  column="function_cd"/>\r
+        <property name="sortOrder"   column="sort_order"/>\r
+        <property name="servlet"     column="servlet"/>\r
+        <property name="queryString" column="query_string"/>\r
+        <property name="externalUrl" column="external_url"/>\r
+        <property name="target"      column="target"/>\r
+        <property name="active"      column="active_yn"    type="yes_no"/>\r
+        <property name="separator"   column="separator_yn" type="yes_no"/>\r
+        <property name="imageSrc"    column="image_src" />\r
+        <property name="menuSetCode" column="menu_set_cd"  />\r
+\r
+        <many-to-one name="parentMenu" column="parent_id" class="MenuData"/>\r
+\r
+        <set name="childMenus" lazy="false" sort="natural" inverse="true" where="active_yn = 'Y'">\r
+            <key column="parent_id"/>\r
+            <one-to-many class="MenuData"/>\r
+        </set>\r
+    </class>\r
+    \r
+    <!-- Broadcast Message class mapping details -->\r
+    <class name="BroadcastMessage" table="fn_broadcast_message">\r
+        <id name="id" column="message_id">\r
+            <generator class="native">\r
+              <param name="sequence">seq_fn_broadcast_message</param>\r
+            </generator>\r
+        </id>\r
+        <property name="messageText" column="message_text"/>\r
+        <property name="locationId"  column="message_location_id"/>\r
+\r
+        <property name="startDate"   column="broadcast_start_date"  type="timestamp"/>\r
+        <property name="endDate"     column="broadcast_end_date"    type="timestamp"/>\r
+\r
+        <property name="sortOrder"   column="sort_order"/>\r
+        <property name="active"      column="active_yn"             type="yes_no"/>\r
+\r
+        <property name="siteCd"      column="broadcast_site_cd"    />\r
+    </class>\r
+\r
+       <!-- \r
+    <class name="org.onap.portalsdk.analytics.model.base.ReportUserRole" table="cr_report_access">\r
+               <composite-id>\r
+                       <key-property name="repId" column="rep_id" />\r
+                       <key-property name="orderNo" column="order_no" />\r
+               </composite-id>\r
+\r
+        <property name="roleId" column="role_id"/>\r
+        <property name="userId"  column="user_id"/>\r
+        <property name="readOnlyYn"  column="read_only_yn"/>\r
+    </class>    \r
+     -->\r
+     \r
+    <!-- State Lookup class mapping details -->\r
+    <class name="LuState" table="FN_LU_STATE">\r
+        <id       name="abbr"  column="state_cd" />\r
+        <property name="state"                   />\r
+    </class>\r
+    \r
+    <!-- Country Lookup class mapping details -->\r
+    <class name="LuCountry" table="FN_LU_COUNTRY">\r
+        <id       name="abbr"  column="country_cd" />\r
+        <property name="country"                   />\r
+        <property name="fullName" column="full_name" />\r
+        <property name="webphoneCountryLabel" column="fullwebphone_country_label_name" />\r
+    </class>\r
+    \r
+    <class name="LuTimeZone" table="FN_LU_TIMEZONE">\r
+        <id       name="timezoneId"  column="timezone_id" />\r
+        <property name="name" column="timezone_name" />\r
+        <property name="value" column="timezone_value" />\r
+    </class>\r
+\r
+\r
+    <!-- Lookup (id/value bean) class mapping details -->\r
+    <class name="Lookup">\r
+        <composite-id name="nameValueId" class="org.onap.portalsdk.core.domain.support.NameValueId">\r
+          <key-property name="val"/>\r
+          <key-property name="lab" />\r
+        </composite-id>\r
+    </class>\r
+\r
+       <class name="UrlsAccessible" table="V_URL_ACCESS">\r
+        <composite-id name="urlsAccessibleKey" class="org.onap.portalsdk.core.domain.UrlsAccessibleKey">\r
+       <key-property   name="url"      column="url"/>\r
+       <key-property   name="functionCd"       column="function_cd"/>\r
+      </composite-id>\r
+    </class>\r
+\r
+\r
+       <query name="ParentIdForLabelList">\r
+      select distinct md.parentMenu.id from MenuData as md where md.label = :paramLabel and md.label is not null\r
+    </query>\r
+    \r
+       <query name="IdForLabelList">\r
+      select distinct md.id from MenuData as md where md.label = :paramLabel\r
+    </query>    \r
+    \r
+       <query name="parentList">\r
+      select distinct md.id, md.label, md.parentMenu.id from MenuData as md where md.label is not null\r
+    </query>\r
+       \r
+       <query name="functionCDlistOld">\r
+      select distinct functionCd from MenuData \r
+    </query>\r
+\r
+       <query name="functionCDlist">\r
+      select distinct code from RoleFunction \r
+    </query>   \r
+     \r
+       <query name="menuData">\r
+      from MenuData where menuSetCode = :menu_set_cd and parentMenu is null\r
+    </query>\r
+       <query name="restrictedUrls">\r
+      FROM UrlsAccessible A where upper(A.urlsAccessibleKey.url) = upper(:current_url)\r
+    </query>\r
+\r
+    <query name="getUserNameById">\r
+      select firstName, lastName from User where id = :user_id\r
+    </query>\r
+\r
+    <query name="getUserEmail">\r
+      select email from User where id = :user_id\r
+    </query>\r
+\r
+    <query name="getAllUsers">\r
+      select id, firstName, lastName from User where active = true order by lastName, firstName\r
+    </query>\r
+       \r
+    <query name="getRoleNameById">\r
+      select name from Role where id = :role_id\r
+    </query>\r
+\r
+    <query name="getAllRoles">\r
+      select id, name from Role order by name\r
+    </query>   \r
+\r
+       <!-- \r
+    <query name="getReportSecurityUsers">\r
+      select repId, orderNo, roleId, userId, readOnlyYn from ReportUserRole where repId = :report_id and userId is not null\r
+    </query>\r
+        \r
+    <query name="getReportSecurityRoles">\r
+      select repId, orderNo, roleId, userId, readOnlyYn from ReportUserRole where repId = :report_id and roleId is not null\r
+    </query>\r
+    -->    \r
+\r
+<!--     <query name="insertReportSecurityUsers">\r
+               insert into ReportUserRole (repId, roleId, userId, readOnlyYn) values (:report_id, :role_id, :user_id, :read_only_yn)\r
+    </query> -->\r
+    \r
+       <!--\r
+    <query name="deleteReportSecurityUsers">\r
+      delete from ReportUserRole where repId = :report_id and userId =:user_id\r
+    </query>\r
+\r
+    <query name="deleteReportSecurityRoles">\r
+      delete from ReportUserRole where repId = :report_id and roleId =:role_id\r
+    </query>\r
+    -->    \r
+\r
+</hibernate-mapping>\r
diff --git a/pom.xml b/pom.xml
index 571eeb7..3b55c1f 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -1,48 +1,48 @@
-<?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>
-
-    <!-- Add oparent parent -->
-    <parent>
-        <groupId>org.onap.oparent</groupId>
-        <artifactId>oparent</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
-    </parent>
-    <!-- Maven parent project for convenience of building and cleaning -->
-    <groupId>org.onap.ccsdk.dashboard</groupId>
-    <artifactId>ccsdk-app-parent</artifactId>
-    <version>0</version>
-    <packaging>pom</packaging>
-    <name>ccsdk-dashboard</name>
-
-    <modules>
-        <module>ccsdk-app-common</module>
-        <module>ccsdk-app-overlay</module>
-        <module>ccsdk-app-os</module>
-    </modules>
-  <distributionManagement>
-    <repository>
-      <id>ecomp-releases</id>
-      <url>${onap.nexus.url}/content/repositories/releases</url>
-    </repository>
-    <snapshotRepository>
-      <id>ecomp-snapshots</id>
-      <url>${onap.nexus.url}/content/repositories/snapshots</url>
-    </snapshotRepository>
-  </distributionManagement>
-
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-deploy-plugin</artifactId>
-                <version>2.8</version>
-                <configuration>
-                    <skip>true</skip>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+    <modelVersion>4.0.0</modelVersion>\r
+\r
+    <!-- Add oparent parent -->\r
+    <parent>\r
+        <groupId>org.onap.oparent</groupId>\r
+        <artifactId>oparent</artifactId>\r
+        <version>1.0.0-SNAPSHOT</version>\r
+    </parent>\r
+    <!-- Maven parent project for convenience of building and cleaning -->\r
+    <groupId>org.onap.ccsdk.dashboard</groupId>\r
+    <artifactId>ccsdk-app-parent</artifactId>\r
+    <version>0</version>\r
+    <packaging>pom</packaging>\r
+    <name>ccsdk-dashboard</name>\r
+\r
+    <modules>\r
+        <module>ccsdk-app-common</module>\r
+        <module>ccsdk-app-overlay</module>\r
+        <!-- <module>ccsdk-app-os</module> -->\r
+    </modules>\r
+    <distributionManagement>\r
+        <repository>\r
+            <id>ecomp-releases</id>\r
+            <url>${onap.nexus.url}/content/repositories/releases</url>\r
+        </repository>\r
+        <snapshotRepository>\r
+            <id>ecomp-snapshots</id>\r
+            <url>${onap.nexus.url}/content/repositories/snapshots</url>\r
+        </snapshotRepository>\r
+    </distributionManagement>\r
+\r
+    <build>\r
+        <plugins>\r
+            <plugin>\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-deploy-plugin</artifactId>\r
+                <version>2.8</version>\r
+                <configuration>\r
+                    <skip>true</skip>\r
+                </configuration>\r
+            </plugin>\r
+        </plugins>\r
+    </build>\r
+\r
+</project>\r