aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-requests-db-adapter
diff options
context:
space:
mode:
authorChrisC <cc697w@intl.att.com>2017-01-31 11:40:03 +0100
committerChrisC <cc697w@intl.att.com>2017-01-31 12:59:33 +0100
commit025301d08b061482c1f046d562bf017c8cbcfe8d (patch)
tree68a2a549736c9bf0f7cd4e71c76e40ef7e2606f2 /adapters/mso-requests-db-adapter
parent2754ad52f833278a5c925bd788a16d1dce16a598 (diff)
Initial OpenECOMP MSO commit
Change-Id: Ia6a7574859480717402cc2f22534d9973a78fa6d Signed-off-by: ChrisC <cc697w@intl.att.com>
Diffstat (limited to 'adapters/mso-requests-db-adapter')
-rw-r--r--adapters/mso-requests-db-adapter/WebContent/META-INF/MANIFEST.MF3
-rw-r--r--adapters/mso-requests-db-adapter/WebContent/WEB-INF/beans.xml0
-rw-r--r--adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml17
-rw-r--r--adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-web.xml3
-rw-r--r--adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml77
-rw-r--r--adapters/mso-requests-db-adapter/WebContent/index.xhtml19
-rw-r--r--adapters/mso-requests-db-adapter/pom.xml96
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java60
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java58
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java246
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/RequestStatusType.java69
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/ResponseStatus.java33
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java40
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbException.java62
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java48
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/resources/application.properties28
16 files changed, 859 insertions, 0 deletions
diff --git a/adapters/mso-requests-db-adapter/WebContent/META-INF/MANIFEST.MF b/adapters/mso-requests-db-adapter/WebContent/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5e9495128c
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/WebContent/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/beans.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/beans.xml
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/beans.xml
diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml
new file mode 100644
index 0000000000..88d5024f0d
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-deployment-structure.xml
@@ -0,0 +1,17 @@
+<jboss-deployment-structure>
+ <deployment>
+ <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->
+ <exclusions>
+ <module name="org.apache.log4j" />
+ <module name="org.slf4j" />
+ <module name="org.slf4j.impl" />
+ </exclusions>
+ <dependencies>
+ <module name="org.jboss.jandex" slot="main" />
+ <module name="org.javassist" slot="main" />
+ <module name="org.antlr" slot="main" />
+ <module name="org.dom4j" slot="main" />
+ </dependencies>
+ </deployment>
+</jboss-deployment-structure>
+
diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-web.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-web.xml
new file mode 100644
index 0000000000..a39d506225
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/jboss-web.xml
@@ -0,0 +1,3 @@
+<jboss-web>
+ <context-root>dbadapters</context-root>
+</jboss-web> \ No newline at end of file
diff --git a/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml
new file mode 100644
index 0000000000..7fa3f2a24c
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/WebContent/WEB-INF/web.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ id="WebApp_ID" version="3.0">
+ <display-name>mso-requests-db-adapter</display-name>
+ <context-param>
+ <param-name>resteasy.scan</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan.providers</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan.resources</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>mso.configuration</param-name>
+ <param-value>MSO_PROP_TOPOLOGY=topology.properties</param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>Resteasy</servlet-name>
+ <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Resteasy</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <filter>
+ <filter-name>LogFilter</filter-name>
+ <filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>LogFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <context-param>
+ <param-name>log.configuration</param-name>
+ <param-value>logback.msorequestsdbadapter.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan.providers</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan.resources</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>SiteStatus</web-resource-name>
+ <description>SiteStatus APIs</description>
+ <url-pattern>/setStatus/*</url-pattern>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>SiteControl-Client</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>ApplicationRealm</realm-name>
+ </login-config>
+ <security-role>
+ <role-name>SiteControl-Client</role-name>
+ </security-role>
+</web-app>
diff --git a/adapters/mso-requests-db-adapter/WebContent/index.xhtml b/adapters/mso-requests-db-adapter/WebContent/index.xhtml
new file mode 100644
index 0000000000..f902af8cc0
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/WebContent/index.xhtml
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+<f:loadBundle basename="resources.application" var="msg"/>
+
+<head>
+ <title><h:outputText value="#{msg.welcomeTitle}" /></title>
+</head>
+
+<body>
+<h3><h:outputText value="#{msg.welcomeHeading}" /></h3>
+<p><h:outputText value="#{msg.welcomeMessage}" /></p>
+</body>
+</html>
diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml
new file mode 100644
index 0000000000..b14cde1657
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/pom.xml
@@ -0,0 +1,96 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.openecomp.mso</groupId>
+ <artifactId>adapters</artifactId>
+ <version>0.0.4-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.mso.adapters</groupId>
+ <artifactId>mso-requests-db-adapter</artifactId>
+ <packaging>war</packaging>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.mso</groupId>
+ <artifactId>mso-requests-db</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>3.0.19.Final</version>
+ <scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.mso</groupId>
+ <artifactId>status-control</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <warSourceDirectory>WebContent</warSourceDirectory>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ <attachClasses>true</attachClasses>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.jvnet.jax-ws-commons</groupId>
+ <artifactId>jaxws-maven-plugin</artifactId>
+ <version>2.3</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>wsgen</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <verbose>true</verbose>
+ <sei>org.openecomp.mso.adapters.requestsdb.MsoRequestsDbAdapterImpl</sei>
+ <genWsdl>true</genWsdl>
+ <inlineSchemas>true</inlineSchemas>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>jaxws-tools</artifactId>
+ <version>2.2.7</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.mso.adapters</groupId>
+ <artifactId>mso-adapter-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+</project> \ No newline at end of file
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java
new file mode 100644
index 0000000000..22fcdda416
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/HealthCheckHandler.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.adapters.requestsdb;
+
+
+import javax.ws.rs.GET;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.HealthCheckUtils;
+import org.openecomp.mso.utils.UUIDChecker;
+
+
+@Path("/")
+ public class HealthCheckHandler {
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
+
+ @HEAD
+ @GET
+ @Path("/healthcheck")
+ @Produces("text/html")
+ public Response healthcheck (@QueryParam("requestId") String requestId) {
+ long startTime = System.currentTimeMillis ();
+ MsoLogger.setServiceName ("Healthcheck");
+ UUIDChecker.verifyOldUUID(requestId, msoLogger);
+ HealthCheckUtils healthCheck = new HealthCheckUtils ();
+ if (!healthCheck.siteStatusCheck(msoLogger, startTime)) {
+ return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
+ }
+
+ if (!healthCheck.requestDBCheck (msoLogger, startTime)) {
+ return HealthCheckUtils.NOT_STARTED_RESPONSE;
+ }
+ msoLogger.debug("healthcheck - Successful");
+ return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
+ }
+
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java
new file mode 100644
index 0000000000..5b4009fb77
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapter.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.adapters.requestsdb;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.SiteStatus;
+
+/**
+ * MSO Request DB Adapter Web Service
+ */
+@WebService(name = "RequestsDbAdapter", targetNamespace = "http://com.att.mso/requestsdb")
+public interface MsoRequestsDbAdapter {
+
+ @WebMethod
+ public void updateInfraRequest (@WebParam(name = "requestId") @XmlElement(required = true) String requestId,
+ @WebParam(name = "lastModifiedBy") @XmlElement(required = true) String lastModifiedBy,
+ @WebParam(name = "statusMessage") @XmlElement(required = false) String statusMessage,
+ @WebParam(name = "responseBody") @XmlElement(required = false) String responseBody,
+ @WebParam(name = "requestStatus") @XmlElement(required = false) RequestStatusType requestStatus,
+ @WebParam(name = "progress") @XmlElement(required = false) String progress,
+ @WebParam(name = "vnfOutputs") @XmlElement(required = false) String vnfOutputs,
+ @WebParam(name = "serviceInstanceId") @XmlElement(required = false) String serviceInstanceId,
+ @WebParam(name = "networkId") @XmlElement(required = false) String networkId,
+ @WebParam(name = "vnfId") @XmlElement(required = false) String vnfId,
+ @WebParam(name = "vfModuleId") @XmlElement(required = false) String vfModuleId,
+ @WebParam(name = "volumeGroupId") @XmlElement(required = false) String volumeGroupId) throws MsoRequestsDbException;
+
+ @WebMethod
+ public InfraActiveRequests getInfraRequest (@WebParam(name="requestId") @XmlElement(required = true) String requestId) throws MsoRequestsDbException;
+
+ @WebMethod
+ public boolean getSiteStatus (@WebParam(name="siteName") @XmlElement(required = true) String siteName);
+
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
new file mode 100644
index 0000000000..e1b752af24
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/MsoRequestsDbAdapterImpl.java
@@ -0,0 +1,246 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.adapters.requestsdb;
+
+import java.sql.Timestamp;
+import java.util.List;
+
+import javax.jws.WebService;
+
+import org.openecomp.mso.requestsdb.SiteStatus;
+import org.openecomp.mso.utils.UUIDChecker;
+import org.hibernate.HibernateException;
+import org.hibernate.Query;
+import org.hibernate.Session;
+
+import org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbException;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.requestsdb.HibernateUtil;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+
+@WebService(serviceName = "RequestsDbAdapter", endpointInterface = "org.openecomp.mso.adapters.requestsdb.MsoRequestsDbAdapter", targetNamespace = "http://com.att.mso/requestsdb")
+public class MsoRequestsDbAdapterImpl implements MsoRequestsDbAdapter {
+
+ private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+
+ @Override
+ public void updateInfraRequest (String requestId,
+ String lastModifiedBy,
+ String statusMessage,
+ String responseBody,
+ RequestStatusType requestStatus,
+ String progress,
+ String vnfOutputs,
+ String serviceInstanceId,
+ String networkId,
+ String vnfId,
+ String vfModuleId,
+ String volumeGroupId) throws MsoRequestsDbException {
+ MsoLogger.setLogContext (requestId, null);
+ Session session = HibernateUtil.getSessionFactory ().openSession ();
+ int result = 0;
+ long startTime = System.currentTimeMillis ();
+ try {
+ session.beginTransaction ();
+ String queryString = "update InfraActiveRequests set ";
+ if (statusMessage != null) {
+ queryString += "statusMessage = :statusMessage, ";
+ }
+ if (responseBody != null) {
+ queryString += "responseBody = :responseBody, ";
+ }
+ if (requestStatus != null) {
+ queryString += "requestStatus = :requestStatus, ";
+ }
+ if (progress != null) {
+ queryString += "progress = :progress, ";
+ }
+ if (vnfOutputs != null) {
+ queryString += "vnfOutputs = :vnfOutputs, ";
+ }
+ if (serviceInstanceId != null) {
+ queryString += "serviceInstanceId = :serviceInstanceId, ";
+ }
+ if (networkId != null) {
+ queryString += "networkId = :networkId, ";
+ }
+ if (vnfId != null) {
+ queryString += "vnfId = :vnfId, ";
+ }
+ if (vfModuleId != null) {
+ queryString += "vfModuleId = :vfModuleId, ";
+ }
+ if (volumeGroupId != null) {
+ queryString += "volumeGroupId = :volumeGroupId, ";
+ }
+ if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) {
+ queryString += "endTime = :endTime, ";
+ } else {
+ queryString += "modifyTime = :modifyTime, ";
+ }
+ queryString += "lastModifiedBy = :lastModifiedBy where requestId = :requestId OR clientRequestId = :requestId";
+
+ LOGGER.debug("Executing update: " + queryString);
+
+ Query query = session.createQuery (queryString);
+ query.setParameter ("requestId", requestId);
+ if (statusMessage != null) {
+ query.setParameter ("statusMessage", statusMessage);
+ LOGGER.debug ("StatusMessage in updateInfraRequest is set to: " + statusMessage);
+ }
+ if (responseBody != null) {
+ query.setParameter ("responseBody", responseBody);
+ LOGGER.debug ("ResponseBody in updateInfraRequest is set to: " + responseBody);
+ }
+ if (requestStatus != null) {
+ query.setParameter ("requestStatus", requestStatus.toString ());
+ LOGGER.debug ("RequestStatus in updateInfraRequest is set to: " + requestStatus.toString());
+ }
+
+ if (progress != null) {
+ query.setParameter ("progress", Long.parseLong (progress));
+ LOGGER.debug ("Progress in updateInfraRequest is set to: " + progress);
+ }
+ if (vnfOutputs != null) {
+ query.setParameter ("vnfOutputs", vnfOutputs);
+ LOGGER.debug ("VnfOutputs in updateInfraRequest is set to: " + vnfOutputs);
+ }
+ if (serviceInstanceId != null) {
+ query.setParameter ("serviceInstanceId", serviceInstanceId);
+ LOGGER.debug ("ServiceInstanceId in updateInfraRequest is set to: " + serviceInstanceId);
+ }
+ if (networkId != null) {
+ query.setParameter ("networkId", networkId);
+ LOGGER.debug ("NetworkId in updateInfraRequest is set to: " + networkId);
+ }
+ if (vnfId != null) {
+ query.setParameter ("vnfId", vnfId);
+ LOGGER.debug ("VnfId in updateInfraRequest is set to: " + vnfId);
+ }
+ if (vfModuleId != null) {
+ query.setParameter ("vfModuleId", vfModuleId);
+ LOGGER.debug ("vfModuleId in updateInfraRequest is set to: " + vfModuleId);
+ }
+ if (volumeGroupId != null) {
+ query.setParameter ("volumeGroupId", volumeGroupId);
+ LOGGER.debug ("VolumeGroupId in updateInfraRequest is set to: " + volumeGroupId);
+ }
+ Timestamp nowTimeStamp = new Timestamp (System.currentTimeMillis ());
+ if (requestStatus == RequestStatusType.COMPLETE || requestStatus == RequestStatusType.FAILED) {
+ query.setParameter ("endTime", nowTimeStamp);
+ LOGGER.debug ("EndTime in updateInfraRequest is set to: " + nowTimeStamp);
+ } else {
+ query.setParameter ("modifyTime", nowTimeStamp);
+ LOGGER.debug ("ModifyTime in updateInfraRequest is set to: " + nowTimeStamp);
+ }
+ query.setParameter ("lastModifiedBy", lastModifiedBy);
+ LOGGER.debug ("LastModifiedBy in updateInfraRequest is set to: " + lastModifiedBy);
+ result = query.executeUpdate ();
+ checkIfExists (result, requestId, startTime);
+ session.getTransaction ().commit ();
+ } catch (HibernateException e) {
+ String error = "Unable to update MSO Requests DB: " + e.getMessage ();
+ LOGGER.error (MessageEnum.RA_CANT_UPDATE_REQUEST, "infra request parameters", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e);
+ LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error);
+ throw new MsoRequestsDbException (error, e);
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ }
+ LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ }
+
+
+ private void checkIfExists (int result, String requestId, long startTime) throws MsoRequestsDbException {
+ if (result == 0) {
+ String error = "Request ID does not exist in MSO Requests DB: " + requestId;
+ LOGGER.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, requestId, "", "", MsoLogger.ErrorCode.DataError, error);
+ throw new MsoRequestsDbException (error);
+ }
+ }
+
+
+ @Override
+ public InfraActiveRequests getInfraRequest (String requestId) throws MsoRequestsDbException {
+ long startTime = System.currentTimeMillis ();
+ MsoLogger.setLogContext (requestId, null);
+ Session session = HibernateUtil.getSessionFactory ().openSession ();
+
+ LOGGER.debug ("Call to MSO Infra RequestsDb adapter get method with request Id: " + requestId);
+
+ InfraActiveRequests request = null;
+ try {
+ session.beginTransaction ();
+ Query query = session.createQuery ("FROM InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId");
+ query.setParameter ("requestId", requestId);
+ request = (InfraActiveRequests) query.uniqueResult();
+ } catch (HibernateException e) {
+ String error = "Unable to retrieve MSO Infra Requests DB for Request ID "
+ + requestId;
+ LOGGER.error (MessageEnum.RA_DB_REQUEST_NOT_EXIST, "Get Infra request", requestId, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "HibernateException - " + error, e);
+ LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, error);
+ throw new MsoRequestsDbException (error, e);
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ }
+ LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ return request;
+ }
+
+
+ /**
+ * Get SiteStatus by SiteName.
+ *
+ * @param siteName The unique name of the site
+ * @return Status of that site
+ */
+ public boolean getSiteStatus (String siteName) {
+ UUIDChecker.generateUUID (LOGGER);
+ Session session = HibernateUtil.getSessionFactory ().openSession ();
+
+ long startTime = System.currentTimeMillis ();
+ SiteStatus siteStatus = null;
+ LOGGER.debug ("Request database - get Site Status with Site name:" + siteName);
+ try {
+ String hql = "FROM SiteStatus WHERE siteName = :site_name";
+ Query query = session.createQuery (hql);
+ query.setParameter ("site_name", siteName);
+
+ siteStatus = (SiteStatus) query.uniqueResult ();
+ } finally {
+ if (session != null && session.isOpen ()) {
+ session.close ();
+ }
+ }
+ if (siteStatus == null) {
+ // if not exist in DB, it means the site is not disabled, thus return true
+ LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ return true;
+ } else {
+ LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ return siteStatus.getStatus();
+ }
+ }
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/RequestStatusType.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/RequestStatusType.java
new file mode 100644
index 0000000000..706142f366
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/RequestStatusType.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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=========================================================
+ */
+
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2015.07.24 at 11:49:17 AM EDT
+//
+
+
+package org.openecomp.mso.adapters.requestsdb;
+
+
+
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for request-status-type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * <pre>
+ * &lt;simpleType name="request-status-type">
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
+ * &lt;enumeration value="COMPLETE"/>
+ * &lt;enumeration value="FAILED"/>
+ * &lt;enumeration value="IN_PROGRESS"/>
+ * &lt;/restriction>
+ * &lt;/simpleType>
+ * </pre>
+ *
+ */
+@XmlType(name = "request-status-type")
+@XmlEnum
+public enum RequestStatusType {
+
+ COMPLETE,
+ FAILED,
+ IN_PROGRESS;
+
+ public String value() {
+ return name();
+ }
+
+ public static RequestStatusType fromValue(String v) {
+ return valueOf(v);
+ }
+
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/ResponseStatus.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/ResponseStatus.java
new file mode 100644
index 0000000000..5b943e2aec
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/ResponseStatus.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.adapters.requestsdb;
+
+
+
+/*
+ * Enum for Status values returned by API Handler to Tail-F
+*/
+public enum ResponseStatus {
+ SENDING_FINAL_NOTIFY,
+ SUCCESS,
+ FAILED,
+ TIMEOUT
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java
new file mode 100644
index 0000000000..0b4db4bbc3
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/Status.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.adapters.requestsdb;
+
+
+/*
+ * Enum for Status values returned by API Handler to Tail-F
+*/
+public enum Status {
+ PENDING, INPROGRESS, COMPLETED, FAILED, TIMEOUT;
+
+ public boolean isFinished () {
+ switch (this) {
+ case COMPLETED:
+ case FAILED:
+ case TIMEOUT:
+ return true;
+ default:
+ return false;
+ }
+ }
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbException.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbException.java
new file mode 100644
index 0000000000..8e4fcf4083
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbException.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.adapters.requestsdb.exceptions;
+
+
+
+import javax.xml.ws.WebFault;
+
+/**
+ * This class simply extends Exception (without addition additional functionality)
+ * to provide an identifier for RequestsDB related exceptions on create, delete, query.
+ *
+ *
+ */
+@WebFault (name="MsoRequestsDbException", faultBean="org.openecomp.mso.adapters.requestsdb.exceptions.MsoRequestsDbExceptionBean", targetNamespace="http://com.att.mso/requestsdb")
+public class MsoRequestsDbException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ private MsoRequestsDbExceptionBean faultInfo;
+
+ public MsoRequestsDbException (String msg) {
+ super(msg);
+ faultInfo = new MsoRequestsDbExceptionBean (msg);
+ }
+
+ public MsoRequestsDbException (Throwable e) {
+ super(e);
+ faultInfo = new MsoRequestsDbExceptionBean (e.getMessage());
+ }
+
+ public MsoRequestsDbException (String msg, Throwable e) {
+ super (msg, e);
+ faultInfo = new MsoRequestsDbExceptionBean (msg);
+ }
+
+ public MsoRequestsDbExceptionBean getFaultInfo() {
+ return faultInfo;
+ }
+
+ public void setFaultInfo(MsoRequestsDbExceptionBean faultInfo) {
+ this.faultInfo = faultInfo;
+ }
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java
new file mode 100644
index 0000000000..8701e5b06e
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/openecomp/mso/adapters/requestsdb/exceptions/MsoRequestsDbExceptionBean.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.adapters.requestsdb.exceptions;
+
+
+import java.io.Serializable;
+
+/**
+ * Jax-WS Fault Bean for MsoRequestsDB Exception
+ */
+public class MsoRequestsDbExceptionBean implements Serializable {
+
+ private static final long serialVersionUID = 1360000062602372639L;
+
+ private String message;
+
+ public MsoRequestsDbExceptionBean () {}
+
+ public MsoRequestsDbExceptionBean (String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/resources/application.properties b/adapters/mso-requests-db-adapter/src/main/java/resources/application.properties
new file mode 100644
index 0000000000..c9345389c9
--- /dev/null
+++ b/adapters/mso-requests-db-adapter/src/main/java/resources/application.properties
@@ -0,0 +1,28 @@
+###
+# ============LICENSE_START=======================================================
+# ECOMP MSO
+# ================================================================================
+# 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=========================================================
+###
+
+
+# -- welcome --
+welcomeTitle=JSF Blank Application
+
+welcomeHeading=Welcome!
+
+welcomeMessage=This is a JSF blank application. \
+ You can find the application.properties file with this message in the src/resources folder.