Initial OpenECOMP SDC commit

Change-Id: I0924d5a6ae9cdc161ae17c68d3689a30d10f407b
Signed-off-by: Michael Lando <ml636r@att.com>
diff --git a/catalog-fe/src/main/resources/application-context.xml b/catalog-fe/src/main/resources/application-context.xml
new file mode 100644
index 0000000..a5ec926
--- /dev/null
+++ b/catalog-fe/src/main/resources/application-context.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
+  xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util"
+  xsi:schemaLocation="
+        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
+        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
+
+  <context:annotation-config />
+  <aop:aspectj-autoproxy proxy-target-class="true" />
+
+  <context:component-scan
+    base-package="org.openecomp.sdnc.catalog.backend.dao,	   
+		org.elasticsearch.mapping,		
+		org.openecomp.sdnc.catalog.backend.artifacts">
+ 
+  </context:component-scan>
+
+ 
+
+  <!-- <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" /> -->
+</beans>
diff --git a/catalog-fe/src/main/resources/config/configuration.yaml b/catalog-fe/src/main/resources/config/configuration.yaml
new file mode 100644
index 0000000..6be93b3
--- /dev/null
+++ b/catalog-fe/src/main/resources/config/configuration.yaml
@@ -0,0 +1,78 @@
+# Needed for logging purposes. To be populated by DevOps - currently dummy
+feFqdn: asdcFe.att.com
+
+# catalog backend hostname
+beHost: localhost
+
+# catalog backend http port
+beHttpPort: 8080
+
+# catalog backend http context
+beContext: /sdc2/rest/v1/catalog/upload/resources
+
+# catalog backend protocol
+beProtocol: http
+
+# catalog backend ssl port
+beSslPort: 8443
+
+# threadpool size for handling requests
+threadpoolSize: 50 
+
+# request processing timeout (seconds)
+requestTimeout: 10
+
+healthCheckSocketTimeoutInMs: 5000
+
+healthCheckIntervalInSeconds: 5
+
+identificationHeaderFields: 
+   -
+        - &HTTP_IV_USER HTTP_IV_USER
+        - &iv-user iv-user
+   -
+        - &USER_ID USER_ID
+        - &user-id user-id
+   -
+        - &HTTP_CSP_ATTUID HTTP_CSP_ATTUID
+        - &csp-attuid csp-attuid
+   -
+        - &HTTP_CSP_WSTYPE HTTP_CSP_WSTYPE 
+        - &csp-wstype csp-wstype
+
+optionalHeaderFields: 
+   -
+        - &HTTP_CSP_FIRSTNAME HTTP_CSP_FIRSTNAME
+        - &csp-firstname csp-firstname
+   -
+        - &HTTP_CSP_LASTNAME HTTP_CSP_LASTNAME
+        - &csp-lastname csp-lastname
+   -
+        - &HTTP_IV_REMOTE_ADDRESS HTTP_IV_REMOTE_ADDRESS
+        - &iv-remote-address iv-remote-address
+   -
+        - &HTTP_CSP_EMAIL HTTP_CSP_EMAIL
+        - &csp-email csp-email
+
+version: 1.0
+released: 2012-11-30
+
+# Connection parameters
+connection:
+    url: jdbc:mysql://localhost:3306/db
+    poolSize: 17
+
+# Protocols
+protocols:
+   - http
+   - https
+
+
+systemMonitoring:
+    enabled: false
+    isProxy: true
+    probeIntervalInSeconds: 15
+
+kibanaHost: localhost
+kibanaPort: 5601
+kibanaProtocol: http
diff --git a/catalog-fe/src/main/resources/config/ecomp-error-configuration.yaml b/catalog-fe/src/main/resources/config/ecomp-error-configuration.yaml
new file mode 100644
index 0000000..8982b24
--- /dev/null
+++ b/catalog-fe/src/main/resources/config/ecomp-error-configuration.yaml
@@ -0,0 +1,48 @@
+###########################################
+# Note the conventions of the field values:
+# type can be one of: CONFIG_ERROR, SYSTEM_ERROR, DATA_ERROR, CONNECTION_PROBLEM
+# severity can be one of: WARN, ERROR, FATAL
+# alarmSeverity can be one of: CRITICAL,MAJOR,MINOR,INFORMATIONAL,NONE
+# code is a unique integer in range of 3003-9999 (3000-3002 are occupied for internal usage)
+# The above enumeration values are out-of-the-box and can be changed in code. 
+# In case of config and code mismatch, the appropriate error will be printed to log
+#
+# Range of FE codes - 8000-9999
+
+
+errors:
+    FeHealthCheckConnectionError: {
+        type: CONNECTION_PROBLEM,
+        code: ASDC_8000,
+        severity: ERROR,
+        description: "Connection error during FE Health Check",
+        alarmSeverity: CRITICAL
+    }
+    FeHttpLoggingError: {
+        type: SYSTEM_ERROR,
+        code: ASDC_8001,
+        severity: ERROR,
+        description: "Error when logging FE HTTP request/response",
+        alarmSeverity: MINOR
+    }
+    FePortalServletError: {
+        type: SYSTEM_ERROR,
+        code: ASDC_8002,
+        severity: ERROR,
+        description: "Error when trying to access FE Portal page",
+        alarmSeverity: MAJOR
+    }
+    FeHealthCheckGeneralError: {
+        type: SYSTEM_ERROR,
+        code: ASDC_8004,
+        severity: ERROR,
+        description: "General error during FE Health Check",
+        alarmSeverity: CRITICAL
+    }
+    FeHealthCheckRecovery: {
+        type: RECOVERY,
+        code: ASDC_8005,
+        severity: INFO,
+        description: "BE Health Check Recovery",
+        alarmSeverity: INFORMATIONAL
+    }    
\ No newline at end of file
diff --git a/catalog-fe/src/main/resources/config/logback.xml b/catalog-fe/src/main/resources/config/logback.xml
new file mode 100644
index 0000000..fd2e13c
--- /dev/null
+++ b/catalog-fe/src/main/resources/config/logback.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration scan="true" scanPeriod="5 seconds">
+
+	<property scope="system" name="ECOMP-component-name" value="ASDC" />
+	<property scope="system" name="ECOMP-subcomponent-name" value="ASDC-FE" />
+	<property scope="context" name="enable-all-log" value="false" />
+	<property file="${config.home}/catalog-fe/configuration.yaml" />
+	<!-- value used by pattern field list (| - is inter-field separator, || - unavailable or not applicable field value) (m - mandatory, o- optional)-->
+	<!--timestamp(m)| requestID(m)| serviceInstanceID(o)| threadID(m)| physicalServerName(o)| serviceName(m)| userID(m)| logLevel(m)| severity(o)| serverIpAddress(m)| serverName(m)| clientIpAddress(o)| className(m)| timer(o)| detailedMessage(o)-->
+	<property name="default-log-pattern"
+		value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{uuid}|%X{serviceInstanceID}|%thread||${ECOMP-subcomponent-name}|%X{userId}|%level|%X{alarmSeverity}|%X{localAddr}|${feFqdn}|%X{remoteAddr}|%logger{35}|%X{timer}|ActivityType=&lt;%M&gt;, Desc=&lt;%msg&gt;%n" />
+
+	<!-- All log -->
+	<if condition='property("enable-all-log").equalsIgnoreCase("true")'>
+		<then>
+			<appender name="ALL_ROLLING"
+				class="ch.qos.logback.core.rolling.RollingFileAppender">
+				<file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/all.log
+				</file>
+
+				<rollingPolicy
+					class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+					<fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/all.log.%i
+					</fileNamePattern>
+					<minIndex>1</minIndex>
+					<maxIndex>10</maxIndex>
+				</rollingPolicy>
+
+				<triggeringPolicy
+					class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+					<maxFileSize>20MB</maxFileSize>
+				</triggeringPolicy>
+				<encoder>
+					<pattern>${default-log-pattern}</pattern>
+				</encoder>
+			</appender>
+			
+		  <appender name="ASYNC_ERROR" class="ch.qos.logback.classic.AsyncAppender">
+	      <appender-ref ref="ALL_ROLLING" />
+	</appender>
+	
+		</then>
+	</if>
+
+	<!-- Error log -->
+	<appender name="ERROR_ROLLING"
+		class="ch.qos.logback.core.rolling.RollingFileAppender">
+		<file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/error.log
+		</file>
+
+		<!-- deny all events with a level below INFO, that is TRACE and DEBUG -->
+		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+			<level>INFO</level>
+		</filter>
+
+		<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+			<fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/error.log.%i
+			</fileNamePattern>
+			<minIndex>1</minIndex>
+			<maxIndex>10</maxIndex>
+		</rollingPolicy>
+
+		<triggeringPolicy
+			class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+			<maxFileSize>20MB</maxFileSize>
+		</triggeringPolicy>
+		<encoder>
+			<pattern>${default-log-pattern}</pattern>
+		</encoder>
+	</appender>
+
+	<!-- Debug log -->
+	<appender name="DEBUG_ROLLING"
+		class="ch.qos.logback.core.rolling.RollingFileAppender">
+		<file>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/debug.log
+		</file>
+
+		<!-- accept DEBUG and TRACE level -->
+		<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
+			<evaluator class="ch.qos.logback.classic.boolex.GEventEvaluator">
+				<expression>
+					e.level.toInt() &lt;= DEBUG.toInt()
+				</expression>
+			</evaluator>
+			<OnMismatch>DENY</OnMismatch>
+			<OnMatch>NEUTRAL</OnMatch>
+		</filter>
+
+		<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+			<fileNamePattern>${log.home}/${ECOMP-component-name}/${ECOMP-subcomponent-name}/debug.log.%i
+			</fileNamePattern>
+			<minIndex>1</minIndex>
+			<maxIndex>10</maxIndex>
+		</rollingPolicy>
+
+		<triggeringPolicy
+			class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+			<maxFileSize>20MB</maxFileSize>
+		</triggeringPolicy>
+		<encoder>
+			<pattern>${default-log-pattern}</pattern>
+		</encoder>
+	</appender>
+	
+		<!-- Asynchronicity Configurations -->
+	<appender name="ASYNC_DEBUG" class="ch.qos.logback.classic.AsyncAppender">
+	      <appender-ref ref="DEBUG_ROLLING" />
+	</appender>
+
+	<appender name="ASYNC_ERROR" class="ch.qos.logback.classic.AsyncAppender">
+	      <appender-ref ref="ERROR_ROLLING" />
+	</appender>
+
+	<root level="INFO">
+		<appender-ref ref="ASYNC_ERROR" />
+		<appender-ref ref="ASYNC_DEBUG" />
+		<if condition='property("enable-all-log").equalsIgnoreCase("true")'>
+			<then>
+				<appender-ref ref="ALL_ROLLING" />
+			</then>
+		</if>
+	</root>
+
+	<logger name="org.openecomp.sdc" level="INFO" />
+</configuration>
\ No newline at end of file
diff --git a/catalog-fe/src/main/resources/config/rest-configuration-info.yaml b/catalog-fe/src/main/resources/config/rest-configuration-info.yaml
new file mode 100644
index 0000000..083adcf
--- /dev/null
+++ b/catalog-fe/src/main/resources/config/rest-configuration-info.yaml
@@ -0,0 +1,12 @@
+# rest read timeout - means no timeout
+readTimeoutInSec: 0
+
+# whether to ignore certificate
+ignoreCertificate: false
+
+# the connection pool size
+connectionPoolSize: 10 
+
+# create connection timeout
+connectTimeoutInSec: 10
+
diff --git a/catalog-fe/src/main/resources/jetty-ipaccess.xml b/catalog-fe/src/main/resources/jetty-ipaccess.xml
new file mode 100644
index 0000000..97db551
--- /dev/null
+++ b/catalog-fe/src/main/resources/jetty-ipaccess.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
+
+<!-- =============================================================== -->
+<!-- Mixin the Statistics Handler                                    -->
+<!-- =============================================================== -->
+
+
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+
+    <Get id="oldhandler" name="handler"/>
+
+    <Set name="handler">
+     <New id="IPAccessHandler" class="org.eclipse.jetty.server.handler.IPAccessHandler">
+      <Set name="handler"><Ref refid="oldhandler"/></Set>
+      <Set name="white">
+        <Array type="String">
+	      <Item>0-255.0-255.0-255.0-255</Item>
+	</Array>
+      </Set>
+      <Set name="black">
+        <Array type="String">
+	      <Item>127.0.0.1/blacklisted</Item>
+	      <Item>127.0.0.2/black.html</Item>
+	    </Array>
+      </Set>
+      <Set name="whiteListByPath">false</Set>
+     </New>
+    </Set>
+</Configure>
diff --git a/catalog-fe/src/main/resources/portal.properties b/catalog-fe/src/main/resources/portal.properties
new file mode 100644
index 0000000..880c4fe
--- /dev/null
+++ b/catalog-fe/src/main/resources/portal.properties
@@ -0,0 +1,28 @@
+# Portal REST URL, ends "/auxapi"
+ecomp_rest_url = https://portal.api.simpledemo.openecomp.org/ecompportal/auxapi
+ 
+# Java implementation of interface
+portal.api.impl.class = org.openecomp.sdc.be.ecomp.EcompIntImpl
+
+# CSP-SSO URL
+ecomp_redirect_url = http://portal.api.simpledemo.openecomp.org:8989/ECOMPPORTAL/login.htm
+ 
+# Cookie set by CSP-SSO
+csp_cookie_name = attESSec
+# CSP setting, most use PROD; DEV also recognized
+csp_gate_keeper_prod_key = PROD
+
+# Comma-separated list of UEB server names
+ueb_url_list = 
+# UEB topic where Portal listens
+ecomp_portal_inbox_name = ECOMP-PORTAL-INBOX-TEST
+# UEB key generated while on-boarding
+ueb_app_key = app_key_here
+# UEB secret generated while on-boarding
+ueb_app_secret = app_secret_here
+# UEB topic where App listens
+ueb_app_mailbox_name = app_topic_name_here
+# Consumer group name; most Apps should use {UUID}
+ueb_app_consumer_group_name = {UUID}
+
+decryption_key = AGLDdG4D04BKm2IxIWEr8o==
\ No newline at end of file
diff --git a/catalog-fe/src/main/resources/scripts/install.sh b/catalog-fe/src/main/resources/scripts/install.sh
new file mode 100644
index 0000000..bed9411
--- /dev/null
+++ b/catalog-fe/src/main/resources/scripts/install.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+export JETTY_BASE=/home/jetty/base
+
+COMP=$1
+
+function usage() {
+	echo "$0 <fe | be>"
+}
+
+function exitOnError() {
+	if [ $1 -ne 0 ]
+	then
+		echo "Failed running task $2"
+		exit 2
+	fi
+}
+
+if [ $# -ne 1 ]
+then
+	usage
+	exit 1
+
+fi
+
+/opt/app/sdc/catalog-${COMP}/scripts/installJettyBase.sh
+exitOnError $? "installJettyBase"
+
+cd ${JETTY_BASE}
+exitOnError $? "move_to_base_dir"
+
+mkdir -p scripts
+
+cp /opt/app/sdc/catalog-${COMP}/scripts/* scripts
+exitOnError $? "copy_scripts_from_rpm"
+
+cp /opt/app/sdc/catalog-${COMP}/ext/jetty-ipaccess.xml etc
+exitOnError $? "override_jetty-ipaccess_module."
+
+cp /opt/app/sdc/catalog-${COMP}/catalog-${COMP}-*.war webapps
+exitOnError $? "copy_war"
+
+cp /opt/app/sdc/catalog-${COMP}/scripts/startJetty.sh .
+exitOnError $? "copy_startJetty"
+
+cp /opt/app/sdc/catalog-${COMP}/scripts/jvm.properties .
+exitOnError $? "copy_jvm_properties"
+
+./scripts/updateSslParams.sh ${JETTY_BASE}
+exitOnError $? "updateSslParams_script"
+	 
+#ONLY FOR BE	 
+#cp /opt/app/sdc/config/catalog-${COMP}/elasticsearch.yml config
+#exitOnError $? "copy_elasticsearch_yaml_to_config"
+
+mkdir -p ${JETTY_BASE}/config/catalog-${COMP}
+cp -r /opt/app/sdc/config/catalog-${COMP}/*.xml ${JETTY_BASE}/config/catalog-${COMP}
+exitOnError $? "copy_xml_files_to_config"
+
+cp -r /opt/app/sdc/config/catalog-${COMP}/*.yaml ${JETTY_BASE}/config/catalog-${COMP}
+exitOnError $? "copy_yaml_files_to_config"
diff --git a/catalog-fe/src/main/resources/scripts/installJettyBase.sh b/catalog-fe/src/main/resources/scripts/installJettyBase.sh
new file mode 100644
index 0000000..0f8ac7e
--- /dev/null
+++ b/catalog-fe/src/main/resources/scripts/installJettyBase.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+export JETTY_HOME=/home/jetty/jetty-distribution-9.2.7.v20150116
+export JETTY_BASE=/home/jetty/base
+
+mkdir -p ${JETTY_BASE}
+mkdir -p ${JETTY_BASE}/config
+
+cd ${JETTY_BASE}
+
+java -jar $JETTY_HOME/start.jar --add-to-start=deploy
+java -jar $JETTY_HOME/start.jar --add-to-startd=http,https,logging,ipaccess
+
+cd -
diff --git a/catalog-fe/src/main/resources/scripts/jvm.properties b/catalog-fe/src/main/resources/scripts/jvm.properties
new file mode 100644
index 0000000..52b5134
--- /dev/null
+++ b/catalog-fe/src/main/resources/scripts/jvm.properties
@@ -0,0 +1,5 @@
+-XX:MaxPermSize=256m
+-Xmx1500m
+-Dconfig.home=${JETTY_BASE}/config
+-Dlog.home=${JETTY_BASE}/logs
+-Dlogback.configurationFile=${JETTY_BASE}/config/catalog-fe/logback.xml
\ No newline at end of file
diff --git a/catalog-fe/src/main/resources/scripts/startJetty.sh b/catalog-fe/src/main/resources/scripts/startJetty.sh
new file mode 100644
index 0000000..074d91d
--- /dev/null
+++ b/catalog-fe/src/main/resources/scripts/startJetty.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+export JETTY_HOME=/home/jetty/jetty-distribution-9.2.7.v20150116
+export JETTY_BASE=/home/jetty/base
+
+eval "jvmargs=`sed '/^#/d'  jvm.properties | paste -s -d"#"`"
+jvmargs=`echo $jvmargs | sed 's/#/ /g'`
+echo $jvmargs
+
+java  -jar $JETTY_HOME/start.jar $jvmargs $@
\ No newline at end of file
diff --git a/catalog-fe/src/main/resources/scripts/updateSslParams.sh b/catalog-fe/src/main/resources/scripts/updateSslParams.sh
new file mode 100644
index 0000000..d9e955e
--- /dev/null
+++ b/catalog-fe/src/main/resources/scripts/updateSslParams.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+function usage() {
+        echo "$0 <working dir>"
+}
+
+function exitOnError() {
+        if [ $1 -ne 0 ]
+        then
+                echo "Failed running task $2"
+                exit 2
+        fi
+}
+
+if [ $# -ne 1 ]
+then
+        usage
+	if [ ${#OLDPWD} -ne 0 ]
+	then
+		cd -
+	fi
+        exit 1
+
+fi
+
+WORK_DIR=$1
+
+cd $WORK_DIR
+
+sed -i 's/\(^https.port=\)\(.*\)/\1443/g' start.d/https.ini
+exitOnError $? "update_port_in_https_ini"
+
+cd -