summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitreview2
-rw-r--r--ccsdk-app-common/pom.xml488
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/CloudifyController.java1274
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ConsulController.java890
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardHomeController.java324
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardRestrictedBaseController.java550
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ECDSingleSignOnController.java589
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/HealthCheckController.java172
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/domain/ControllerEndpoint.java142
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/ControllerEndpointCredentials.java230
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientImpl.java824
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientMockImpl.java622
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/service/ControllerEndpointServiceImpl.java152
-rw-r--r--ccsdk-app-common/src/main/java/org/onap/fusionapp/service/AdminAuthExtension.java84
-rw-r--r--ccsdk-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java274
-rw-r--r--ccsdk-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java116
-rw-r--r--ccsdk-app-os/pom.xml338
-rw-r--r--ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java327
-rw-r--r--ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java94
-rw-r--r--ccsdk-app-os/src/main/java/org/onap/portalapp/conf/HibernateMappingLocations.java124
-rw-r--r--ccsdk-app-os/src/main/java/org/onap/portalapp/lm/FusionLicenseManagerImpl.java218
-rw-r--r--ccsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java182
-rw-r--r--ccsdk-app-os/src/main/java/org/onap/portalapp/service/AdminAuthExtension.java136
-rw-r--r--ccsdk-app-os/src/main/resources/portal.properties89
-rw-r--r--ccsdk-app-os/src/main/webapp/WEB-INF/jsp/login_external.jsp226
-rw-r--r--ccsdk-app-overlay/src/main/webapp/WEB-INF/fusion-110-copy.hbm.xml784
-rw-r--r--pom.xml96
27 files changed, 4689 insertions, 4658 deletions
diff --git a/.gitreview b/.gitreview
index 04cdce7..327b31d 100644
--- a/.gitreview
+++ b/.gitreview
@@ -1,4 +1,4 @@
[gerrit]
-host=gerrit.openecomp.org
+host=gerrit.onap.org
port=29418
project=ccsdk/dashboard.git
diff --git a/ccsdk-app-common/pom.xml b/ccsdk-app-common/pom.xml
index b28b292..be05119 100644
--- a/ccsdk-app-common/pom.xml
+++ b/ccsdk-app-common/pom.xml
@@ -1,244 +1,244 @@
-<?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"?>
+<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>2.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.onap.portal.sdk</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>
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/CloudifyController.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/CloudifyController.java
index 1962c4f..7b05841 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/CloudifyController.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/CloudifyController.java
@@ -1,637 +1,637 @@
-/*******************************************************************************
- * =============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);
- }
- }
-}
+/*******************************************************************************
+ * =============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.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.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);
+ }
+ }
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ConsulController.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ConsulController.java
index 9f22456..8350737 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ConsulController.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ConsulController.java
@@ -1,445 +1,445 @@
-/*******************************************************************************
- * =============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);
- }
-}
+/*******************************************************************************
+ * =============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.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.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);
+ }
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardHomeController.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardHomeController.java
index 618e84d..8ec1d2c 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardHomeController.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardHomeController.java
@@ -1,162 +1,162 @@
-/*******************************************************************************
- * =============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;
- }
-}
+/*******************************************************************************
+ * =============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.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.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;
+ }
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardRestrictedBaseController.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardRestrictedBaseController.java
index 6f80d22..02f8770 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardRestrictedBaseController.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/DashboardRestrictedBaseController.java
@@ -1,275 +1,275 @@
-/*******************************************************************************
- * =============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;
- }
-
-}
+/*******************************************************************************
+ * =============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.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.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;
+ }
+
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ECDSingleSignOnController.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ECDSingleSignOnController.java
index 953adff..28f939c 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ECDSingleSignOnController.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/ECDSingleSignOnController.java
@@ -1,290 +1,299 @@
-/*-
- * ================================================================================
- * 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;
- }
-
-}
+/*-
+ * ================================================================================
+ * 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.List;
+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.onap.portalsdk.core.auth.LoginStrategy;
+import org.onap.portalsdk.core.command.LoginBean;
+import org.onap.portalsdk.core.controller.UnRestrictedBaseController;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.menu.MenuProperties;
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler;
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
+import org.onap.portalsdk.core.service.LoginService;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.portalsdk.core.web.support.AppUtils;
+import org.onap.portalsdk.core.web.support.UserUtils;
+import org.onap.portalsdk.core.service.RoleService;
+import org.onap.portalsdk.core.domain.RoleFunction;
+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.onap.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;
+
+ @Autowired
+ private RoleService roleService;
+
+ 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 Exception {
+ //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);
+ commandBean = getLoginService().findUser(commandBean,
+ (String) request.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY), additionalParamsMap);
+ List<RoleFunction> roleFunctionList = roleService.getRoleFunctions(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, roleFunctionList);
+ 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;
+ }
+
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/HealthCheckController.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/HealthCheckController.java
index 3393236..be099a7 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/HealthCheckController.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/controller/HealthCheckController.java
@@ -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;
- }
-
-}
+/*******************************************************************************
+ * =============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.onap.portalsdk.core.controller.UnRestrictedBaseController;
+import org.onap.portalsdk.core.domain.App;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.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;
+ }
+
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/domain/ControllerEndpoint.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/domain/ControllerEndpoint.java
index 1e74611..397f2ed 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/domain/ControllerEndpoint.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/domain/ControllerEndpoint.java
@@ -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;
- }
-
-}
+/*******************************************************************************
+ * =============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.onap.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;
+ }
+
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/ControllerEndpointCredentials.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/ControllerEndpointCredentials.java
index 02c892f..7af9e49 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/ControllerEndpointCredentials.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/ControllerEndpointCredentials.java
@@ -1,116 +1,116 @@
-/*******************************************************************************
- * =============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);
- }
- }
+/*******************************************************************************
+ * =============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.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.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);
+ }
+ }
} \ No newline at end of file
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientImpl.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientImpl.java
index bb79c9f..2e28ad2 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientImpl.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientImpl.java
@@ -1,412 +1,412 @@
-/*******************************************************************************
- * =============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());
- }
- }
-
-}
+/*******************************************************************************
+ * =============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.onap.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());
+ }
+ }
+
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientMockImpl.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientMockImpl.java
index 2523538..6b0f3d0 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientMockImpl.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/rest/ControllerRestClientMockImpl.java
@@ -1,311 +1,311 @@
-/*******************************************************************************
- * =============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.");
- }
-
-}
+/*******************************************************************************
+ * =============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.onap.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.");
+ }
+
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/service/ControllerEndpointServiceImpl.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/service/ControllerEndpointServiceImpl.java
index b1c64b5..b4b3c97 100644
--- a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/service/ControllerEndpointServiceImpl.java
+++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/service/ControllerEndpointServiceImpl.java
@@ -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);
- }
-
-}
+/*******************************************************************************
+ * =============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.onap.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);
+ }
+
+}
diff --git a/ccsdk-app-common/src/main/java/org/onap/fusionapp/service/AdminAuthExtension.java b/ccsdk-app-common/src/main/java/org/onap/fusionapp/service/AdminAuthExtension.java
index 8a64ab5..365ee05 100644
--- a/ccsdk-app-common/src/main/java/org/onap/fusionapp/service/AdminAuthExtension.java
+++ b/ccsdk-app-common/src/main/java/org/onap/fusionapp/service/AdminAuthExtension.java
@@ -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
- }
-
-}
+/*******************************************************************************
+ * =============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.onap.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
+ }
+
+}
diff --git a/ccsdk-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java b/ccsdk-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java
index f3d55e2..ccefdce 100644
--- a/ccsdk-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java
+++ b/ccsdk-app-common/src/test/java/org/onap/fusion/core/MockApplicationContextTestSuite.java
@@ -1,137 +1,137 @@
-/*******************************************************************************
- * =============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() {
- }
-
- }
-
-}
+/*******************************************************************************
+ * =============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.onap.portalsdk.core.conf.AppConfig;
+import org.onap.portalsdk.core.objectcache.AbstractCacheManager;
+import org.onap.portalsdk.core.util.CacheManager;
+import org.onap.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() {
+ }
+
+ }
+
+}
diff --git a/ccsdk-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java b/ccsdk-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java
index 4a661da..ce00583 100644
--- a/ccsdk-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java
+++ b/ccsdk-app-common/src/test/java/org/onap/fusionapp/service/ProfileServiceTest.java
@@ -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);
- }
-}
+/*******************************************************************************
+ * =============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.onap.portalsdk.core.domain.Profile;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.portalsdk.core.service.ProfileService;
+import org.onap.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() throws Exception {
+
+ 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);
+ }
+}
diff --git a/ccsdk-app-os/pom.xml b/ccsdk-app-os/pom.xml
index 4d8975d..0efd176 100644
--- a/ccsdk-app-os/pom.xml
+++ b/ccsdk-app-os/pom.xml
@@ -1,169 +1,169 @@
-<?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"?>
+<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>2.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.onap.portal.sdk</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.onap.portal.sdk</groupId>
+ <artifactId>epsdk-app-overlay</artifactId>
+ <version>${epsdk.version}</version>
+ <type>war</type>
+ </dependency>
+ <!-- SDK webapp controllers -->
+ <dependency>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-app-common</artifactId>
+ <version>${epsdk.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-analytics</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.onap.portal.sdk</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>
diff --git a/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java b/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
index e532b5f..ecd312a 100644
--- a/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
+++ b/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
@@ -1,163 +1,164 @@
-/*-
- * ================================================================================
- * 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();
- }
-}
+/*-
+ * ================================================================================
+ * 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.onap.portalapp.controller.core.SingleSignOnController;
+import org.onap.portalapp.controller.sample.ElasticSearchController;
+import org.onap.portalapp.controller.sample.PostDroolsController;
+import org.onap.portalapp.scheduler.LogRegistry;
+import org.onap.portalsdk.core.auth.LoginStrategy;
+import org.onap.portalsdk.core.conf.AppConfig;
+import org.onap.portalsdk.core.conf.Configurable;
+//import org.onap.portalsdk.core.lm.FusionLicenseManager;
+//import org.onap.portalsdk.core.lm.FusionLicenseManagerUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.objectcache.AbstractCacheManager;
+import org.onap.portalsdk.core.scheduler.CoreRegister;
+import org.onap.portalsdk.core.scheduler.CronRegistry;
+import org.onap.portalsdk.core.service.DataAccessService;
+import org.onap.portalsdk.core.service.PostDroolsService;
+import org.onap.portalsdk.core.util.CacheManager;
+import org.onap.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.onap.portalsdk.core.conf.AppConfig#viewResolver()
+ */
+ public ViewResolver viewResolver() {
+ return super.viewResolver();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.onap.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.onap.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();
+ }
+}
diff --git a/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java b/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java
index 347bb51..3edcf23 100644
--- a/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java
+++ b/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppInitializer.java
@@ -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();
- }
-
-}
+/*-
+ * ================================================================================
+ * 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.onap.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();
+ }
+
+}
diff --git a/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/HibernateMappingLocations.java b/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/HibernateMappingLocations.java
index 6432478..a4a1fa6 100644
--- a/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/HibernateMappingLocations.java
+++ b/ccsdk-app-os/src/main/java/org/onap/portalapp/conf/HibernateMappingLocations.java
@@ -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" };
- }
-
-}
+/*-
+ * ================================================================================
+ * 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.onap.portalsdk.core.conf.HibernateMappingLocatable;
+
+@Component
+@Profile("src")
+public class HibernateMappingLocations implements HibernateMappingLocatable {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.onap.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.onap.portalsdk.core.conf.HibernateMappingLocatable#
+ * getPackagesToScan()
+ */
+ @Override
+ public String[] getPackagesToScan() {
+ return new String[] { "org.onap", "org.openecomp" };
+ }
+
+}
diff --git a/ccsdk-app-os/src/main/java/org/onap/portalapp/lm/FusionLicenseManagerImpl.java b/ccsdk-app-os/src/main/java/org/onap/portalapp/lm/FusionLicenseManagerImpl.java
index e0da1c9..4eb00c6 100644
--- a/ccsdk-app-os/src/main/java/org/onap/portalapp/lm/FusionLicenseManagerImpl.java
+++ b/ccsdk-app-os/src/main/java/org/onap/portalapp/lm/FusionLicenseManagerImpl.java
@@ -1,98 +1,120 @@
-/*******************************************************************************
- * =============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;
- }
-
-}
+/*******************************************************************************
+ * =============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.onap.portalsdk.core.lm.FusionLicenseManager;
+interface FusionLicenseManager {
+ public void initKeyStoreParam();
+
+ public void initCipherParam();
+
+ public void initLicenseParam();
+
+ public int installLicense();
+
+ public int verifyLicense(ServletContext context);
+
+ public void setExpiredDate(Date expiredDate);
+
+ public void doInitWork();
+
+ public void generateLicense(Map<String, String> clientInfoMap, List<String> ipAddressList) throws Exception;
+
+ public String nvl(String s);
+
+ public Date getExpiredDate();
+}
+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;
+ return -1;
+ }
+
+ @Override
+ public synchronized int verifyLicense(ServletContext context) {
+
+ //return INVALID_LICENSE;
+ return -1;
+ }
+
+ @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;
+ }
+
+}
diff --git a/ccsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java b/ccsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java
index 22fca6d..88bce2d 100644
--- a/ccsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java
+++ b/ccsdk-app-os/src/main/java/org/onap/portalapp/login/LoginStrategyImpl.java
@@ -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;
- }
-
-}
+/*-
+ * ================================================================================
+ * 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.onap.portalsdk.core.auth.LoginStrategy;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.onap.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;
+ }
+
+}
diff --git a/ccsdk-app-os/src/main/java/org/onap/portalapp/service/AdminAuthExtension.java b/ccsdk-app-os/src/main/java/org/onap/portalapp/service/AdminAuthExtension.java
index 17fe4ee..fdda960 100644
--- a/ccsdk-app-os/src/main/java/org/onap/portalapp/service/AdminAuthExtension.java
+++ b/ccsdk-app-os/src/main/java/org/onap/portalapp/service/AdminAuthExtension.java
@@ -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");
- }
-
-}
+/*-
+ * ================================================================================
+ * 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.onap.portalapp.service.IAdminAuthExtension;
+import org.onap.portalsdk.core.domain.Role;
+import org.onap.portalsdk.core.domain.User;
+import org.onap.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.onap.portalapp.service.IAdminAuthExtension#saveUserExtension(org.onap.portalsdk.core.domain.User)
+ */
+ @Override
+ public void saveUserExtension(User user) {
+ logger.debug("saveUserExtension");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.onap.portalapp.service.IAdminAuthExtension#editUserExtension(org.onap.portalsdk.core.domain.User)
+ */
+ @Override
+ public void editUserExtension(User user) {
+ logger.debug("editUserExtension");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.onap.portalapp.service.IAdminAuthExtension#saveUserRoleExtension(java.util.Set, org.onap.portalsdk.core.domain.User)
+ */
+ @Override
+ public void saveUserRoleExtension(Set<Role> roles, User user) {
+ logger.debug("saveUserRoleExtension");
+ }
+
+}
diff --git a/ccsdk-app-os/src/main/resources/portal.properties b/ccsdk-app-os/src/main/resources/portal.properties
index c9bde0a..88ef37c 100644
--- a/ccsdk-app-os/src/main/resources/portal.properties
+++ b/ccsdk-app-os/src/main/resources/portal.properties
@@ -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
+###############################################################################
+# =============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.onap.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
diff --git a/ccsdk-app-os/src/main/webapp/WEB-INF/jsp/login_external.jsp b/ccsdk-app-os/src/main/webapp/WEB-INF/jsp/login_external.jsp
index 935c6aa..a31937c 100644
--- a/ccsdk-app-os/src/main/webapp/WEB-INF/jsp/login_external.jsp
+++ b/ccsdk-app-os/src/main/webapp/WEB-INF/jsp/login_external.jsp
@@ -1,113 +1,113 @@
-<%--
- ================================================================================
- 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>
+<%--
+ ================================================================================
+ 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.onap.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>
diff --git a/ccsdk-app-overlay/src/main/webapp/WEB-INF/fusion-110-copy.hbm.xml b/ccsdk-app-overlay/src/main/webapp/WEB-INF/fusion-110-copy.hbm.xml
index a827e6c..1be0530 100644
--- a/ccsdk-app-overlay/src/main/webapp/WEB-INF/fusion-110-copy.hbm.xml
+++ b/ccsdk-app-overlay/src/main/webapp/WEB-INF/fusion-110-copy.hbm.xml
@@ -1,392 +1,392 @@
-<?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"?>
+<!--
+ ================================================================================
+ 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.onap.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.onap.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.onap.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.onap.portalsdk.core.domain.App" column="app_id"/>
+ <key-many-to-one name="role" class="org.onap.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.onap.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.onap.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.onap.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.onap.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.onap.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.onap.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>
diff --git a/pom.xml b/pom.xml
index 571eeb7..3b55c1f 100644
--- 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"?>
+<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>