From: lizi00164331 Date: Mon, 7 Aug 2017 03:04:17 +0000 (+0800) Subject: Upload the ESR server seed code. X-Git-Tag: v1.0.0~105 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fesr-server.git;a=commitdiff_plain;h=aba957d99b0d0d21c77d80efe98a3450b6635c1a Upload the ESR server seed code. Issue-ID: AAI-67 Change-Id: Ie21ae7baebbb2ea8a35d8b51f75b7e21bcb78671 Signed-off-by: lizi00164331 --- diff --git a/esr-core/distribution/pom.xml b/esr-core/distribution/pom.xml new file mode 100644 index 0000000..0885982 --- /dev/null +++ b/esr-core/distribution/pom.xml @@ -0,0 +1,34 @@ + + + + + org.onap.aai.esr-server + esr-core-parent + 1.0.0-SNAPSHOT + + + 4.0.0 + distribution + esr-server/esr-core/distribution + pom + + + standalone + + diff --git a/esr-core/distribution/standalone/pom.xml b/esr-core/distribution/standalone/pom.xml new file mode 100644 index 0000000..686ff28 --- /dev/null +++ b/esr-core/distribution/standalone/pom.xml @@ -0,0 +1,177 @@ + + + + + org.onap.aai.esr-server + distribution + 1.0.0-SNAPSHOT + + + 4.0.0 + standalone + esr-server/esr-core/distribution/standalone + pom + + + esr-server + linux64 + win64 + target/assembly/${linux64id} + target/assembly/${win64id} + target/version + + + + + + maven-resources-plugin + + + copy-resources-${linux64id} + process-resources + + copy-resources + + + ${linux64outputdir} + + + src/main/assembly/ + false + + **/* + + + **/*.bat + + + + true + + + + copy-resources-${win64id} + process-resources + + copy-resources + + + ${win64outputdir} + + + src/main/assembly/ + false + + **/* + + + **/*.sh + + + + true + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-jar-${linux64id} + + copy + + prepare-package + + + + org.onap.aai.esr-server + esr-mgr + jar + true + ${linux64outputdir} + esr-service.jar + + + + + + copy-jar-${win64id} + + copy + + prepare-package + + + + org.onap.aai.esr-server + esr-mgr + jar + true + ${win64outputdir} + esr-service.jar + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + distribution + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + org.onap.aai.esr-server + esr-mgr + ${project.version} + + + diff --git a/esr-core/distribution/standalone/src/main/assembly/bin/find_kill_process.bat b/esr-core/distribution/standalone/src/main/assembly/bin/find_kill_process.bat new file mode 100644 index 0000000..1dffb1c --- /dev/null +++ b/esr-core/distribution/standalone/src/main/assembly/bin/find_kill_process.bat @@ -0,0 +1,24 @@ +@REM +@REM Copyright 2016 ZTE Corporation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +echo %1 | findstr %2 >NUL +echo ERRORLEVEL=%ERRORLEVEL% +IF ERRORLEVEL 1 goto findend +for /f "tokens=1" %%a in (%1) do ( + echo kill %1 + taskkill /F /pid %%a +) +:findend \ No newline at end of file diff --git a/esr-core/distribution/standalone/src/main/assembly/bin/initDB.bat b/esr-core/distribution/standalone/src/main/assembly/bin/initDB.bat new file mode 100644 index 0000000..dd86c3e --- /dev/null +++ b/esr-core/distribution/standalone/src/main/assembly/bin/initDB.bat @@ -0,0 +1,34 @@ +@REM +@REM Copyright 2016 ZTE Corporation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +@echo off +set HOME=%~dp0 +set user=%1 +set password=%2 +set port=%3 +set host=%4 +echo start init extsys db +echo HOME=%HOME% +set main_path=%HOME%..\ +cd /d %main_path% +mysql -u%user% -p%password% -P%port% -h%host% < dbscripts\mysql\openo-common-extsys-createobj.sql +set "err=%errorlevel%" +if "%err%"=="0" ( + echo init extsys db success + ) else ( + echo failed init extsys db + pause + ) \ No newline at end of file diff --git a/esr-core/distribution/standalone/src/main/assembly/bin/initDB.sh b/esr-core/distribution/standalone/src/main/assembly/bin/initDB.sh new file mode 100644 index 0000000..eb2dc24 --- /dev/null +++ b/esr-core/distribution/standalone/src/main/assembly/bin/initDB.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright 2016 ZTE Corporation. +# +# 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. +# + +DIRNAME=`dirname $0` +HOME=`cd $DIRNAME/; pwd` +user=$1 +password=$2 +port=$3 +host=$4 +echo "start init extsys db" +main_path=$HOME/../ +mysql -u$user -p$password -P$port -h$host <$main_path/dbscripts/mysql/openo-common-extsys-createobj.sql +sql_result=$? +if [ $sql_result != 0 ] ; then + echo "failed to init extsys database!" + exit 1 +fi +echo "init extsys database success!" +exit 0 + diff --git a/esr-core/distribution/standalone/src/main/assembly/bin/run.bat b/esr-core/distribution/standalone/src/main/assembly/bin/run.bat new file mode 100644 index 0000000..9de9ffa --- /dev/null +++ b/esr-core/distribution/standalone/src/main/assembly/bin/run.bat @@ -0,0 +1,41 @@ +@REM +@REM Copyright 2016 ZTE Corporation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +@echo off +title extsys-service + +set RUNHOME=%~dp0 +echo ### RUNHOME: %RUNHOME% +echo ### Starting extsys-service +set main_path=%RUNHOME%..\ +cd /d %main_path% +set JAVA="%JAVA_HOME%\bin\java.exe" +set port=8312 +set jvm_opts=-Xms50m -Xmx128m +rem set jvm_opts=%jvm_opts% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=%port%,server=y,suspend=n +set class_path=%main_path%;%main_path%extsys-service.jar +echo ### jvm_opts: %jvm_opts% +echo ### class_path: %class_path% + +%JAVA% -classpath %class_path% %jvm_opts% org.openo.commonservice.extsys.ExtsysApp server %main_path%conf/extsys.yml + +IF ERRORLEVEL 1 goto showerror +exit +:showerror +echo WARNING: Error occurred during startup or Server abnormally stopped by way of killing the process,Please check! +echo After checking, press any key to close +pause +exit \ No newline at end of file diff --git a/esr-core/distribution/standalone/src/main/assembly/bin/run.sh b/esr-core/distribution/standalone/src/main/assembly/bin/run.sh new file mode 100644 index 0000000..176fc69 --- /dev/null +++ b/esr-core/distribution/standalone/src/main/assembly/bin/run.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# Copyright 2016 ZTE Corporation. +# +# 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. +# + +DIRNAME=`dirname $0` +RUNHOME=`cd $DIRNAME/; pwd` +echo @RUNHOME@ $RUNHOME + +echo @JAVA_HOME@ $JAVA_HOME +JAVA="$JAVA_HOME/bin/java" +echo @JAVA@ $JAVA +main_path=$RUNHOME/../ +cd $main_path +JAVA_OPTS="-Xms50m -Xmx128m" +port=8312 +#JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$port,server=y,suspend=n" +echo @JAVA_OPTS@ $JAVA_OPTS + +class_path="$main_path/:$main_path/extsys-service.jar" +echo @class_path@ $class_path + +"$JAVA" $JAVA_OPTS -classpath "$class_path" org.openo.commonservice.extsys.ExtsysApp server "$main_path/conf/extsys.yml" + diff --git a/esr-core/distribution/standalone/src/main/assembly/bin/stop.bat b/esr-core/distribution/standalone/src/main/assembly/bin/stop.bat new file mode 100644 index 0000000..170f240 --- /dev/null +++ b/esr-core/distribution/standalone/src/main/assembly/bin/stop.bat @@ -0,0 +1,34 @@ +@REM +@REM Copyright 2016 ZTE Corporation. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +@echo off +title stopping extsys-service + +set HOME=%~dp0 +set Main_Class="org.openo.commonservice.extsys.ExtsysApp" + +echo ================== extsys-service info ============================================= +echo HOME=$HOME +echo Main_Class=%Main_Class% +echo =============================================================================== + +echo ### Stopping extsys-service +cd /d %HOME% + +for /f "delims=" %%i in ('"%JAVA_HOME%\bin\jcmd"') do ( + call find_kill_process "%%i" %Main_Class% +) +exit \ No newline at end of file diff --git a/esr-core/distribution/standalone/src/main/assembly/bin/stop.sh b/esr-core/distribution/standalone/src/main/assembly/bin/stop.sh new file mode 100644 index 0000000..0afe681 --- /dev/null +++ b/esr-core/distribution/standalone/src/main/assembly/bin/stop.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Copyright 2016 ZTE Corporation. +# +# 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. +# + +DIRNAME=`dirname $0` +HOME=`cd $DIRNAME/; pwd` +Main_Class="org.openo.commonservice.extsys.ExtsysApp" + +echo ================== catalog-service info ============================================= +echo HOME=$HOME +echo Main_Class=$Main_Class +echo =============================================================================== +cd $HOME; pwd + +echo @WORK_DIR@ $HOME + +function save_service_pid(){ + service_pid=`ps -ef | grep $Main_Class | grep -v grep | awk '{print $2}'` + echo @service_pid@ $service_pid +} + +function kill_service_process(){ + ps -p $service_pid + if [ $? == 0 ]; then + kill -9 $service_pid + fi +} + +save_service_pid; +echo @C_CMD@ kill -9 $service_pid +kill_service_process; diff --git a/esr-core/distribution/standalone/src/main/assembly/conf/extsys.yml b/esr-core/distribution/standalone/src/main/assembly/conf/extsys.yml new file mode 100644 index 0000000..33c939a --- /dev/null +++ b/esr-core/distribution/standalone/src/main/assembly/conf/extsys.yml @@ -0,0 +1,77 @@ +# +# Copyright 2016 ZTE Corporation. +# +# 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. +# + +template: Hello, %s! + +defaultName: ${DW_DEFAULT_NAME:-Stranger} +# the micro service ip +serviceIp: +msbServerAddr: http://127.0.0.1:80 +#database +database: + + # the name of your JDBC driver + driverClass: com.mysql.jdbc.Driver + + # the username + user: extsys + + # the password + password: extsys + + # the JDBC URL + url: jdbc:mysql://127.0.0.1:3306/extsys + +# use the simple server factory if you only want to run on a single port +#server: +# type: simple +# connector: +# type: http +# port: 8080 +server: + type: simple + rootPath: '/openoapi/extsys/v1/*' + applicationContextPath: / + adminContextPath: /admin + connector: + type: http + port: 8100 + +# Logging settings. +logging: + + # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL. + level: ALL + + # Logger-specific levels. + loggers: + + # Sets the level for 'com.example.app' to DEBUG. + org.openo.commonservice.extsys.ExtsysApp: INFO + + appenders: + - type: console + threshold: INFO + timeZone: UTC + logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n" + - type: file + threshold: INFO + logFormat: "%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %m%n" + currentLogFilename: ./works/logs/extsys.log + archivedLogFilenamePattern: ./works/logs/zip/extsys-%d{yyyy-MM-dd}.log.gz + archivedFileCount: 7 + timeZone: UTC + diff --git a/esr-core/distribution/standalone/src/main/assembly/dbscripts/mysql/openo-common-extsys-createobj.sql b/esr-core/distribution/standalone/src/main/assembly/dbscripts/mysql/openo-common-extsys-createobj.sql new file mode 100644 index 0000000..73f2ea0 --- /dev/null +++ b/esr-core/distribution/standalone/src/main/assembly/dbscripts/mysql/openo-common-extsys-createobj.sql @@ -0,0 +1,91 @@ +-- +-- Copyright 2016 ZTE Corporation. +-- +-- 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. +-- + +/******************drop old database and user***************************/ +use mysql; +drop database IF EXISTS extsys; +delete from user where User='extsys'; +FLUSH PRIVILEGES; + +/******************create new database and user***************************/ +create database extsys CHARACTER SET utf8; + +GRANT ALL PRIVILEGES ON extsys.* TO 'extsys'@'%' IDENTIFIED BY 'extsys' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON mysql.* TO 'extsys'@'%' IDENTIFIED BY 'extsys' WITH GRANT OPTION; + +GRANT ALL PRIVILEGES ON extsys.* TO 'extsys'@'localhost' IDENTIFIED BY 'extsys' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON mysql.* TO 'extsys'@'localhost' IDENTIFIED BY 'extsys' WITH GRANT OPTION; +FLUSH PRIVILEGES; + +use extsys; +set Names 'utf8'; +/******************drop old table and create new***************************/ +DROP TABLE IF EXISTS extsys_base_table; +CREATE TABLE extsys_base_table ( + ID VARCHAR(200) NOT NULL, + NAME VARCHAR(200) NULL, + TYPE VARCHAR(200) NULL, + VENDOR VARCHAR(100) NULL, + VERSION VARCHAR(100) NULL, + DESCRIPTION VARCHAR(100) NULL, + CREATETIME VARCHAR(200) NULL, + CATAGORY VARCHAR(200) NULL, + CONSTRAINT extsys_base_table PRIMARY KEY(ID) +); +DROP TABLE IF EXISTS extsys_ems_table; +CREATE TABLE extsys_ems_table ( + EMSID VARCHAR(200) NOT NULL, + URL VARCHAR(100) NULL, + PRODUCTNAME VARCHAR(100) NULL, + USERNAME VARCHAR(100) NULL, + PASSWORD VARCHAR(100) NULL, + CONSTRAINT extsys_ems_table PRIMARY KEY(EMSID) +); + +DROP TABLE IF EXISTS extsys_sdnc_table; +CREATE TABLE extsys_sdnc_table ( + SDNCONTROLLERID VARCHAR(200) NOT NULL, + URL VARCHAR(100) NULL, + USERNAME VARCHAR(100) NULL, + PASSWORD VARCHAR(100) NULL, + PRODUCTNAME VARCHAR(100) NULL, + PROTOCOL VARCHAR(100) NULL, + CONSTRAINT extsys_sdnc_table PRIMARY KEY(SDNCONTROLLERID) +); + +DROP TABLE IF EXISTS extsys_vim_table; +CREATE TABLE extsys_vim_table ( + VIMID VARCHAR(200) NOT NULL, + URL VARCHAR(100) NULL, + USERNAME VARCHAR(100) NULL, + PASSWORD VARCHAR(100) NULL, + DOMAIN VARCHAR(100) NULL, + TENANT VARCHAR(100) NULL, + CONSTRAINT extsys_vim_table PRIMARY KEY(VIMID) +); + +DROP TABLE IF EXISTS extsys_vnfm_table; +CREATE TABLE extsys_vnfm_table ( + VNFMID VARCHAR(200) NOT NULL, + URL VARCHAR(200) NULL, + USERNAME VARCHAR(100) NULL, + PASSWORD VARCHAR(100) NULL, + VIMID VARCHAR(100) NULL, + CERTIFICATEURL VARCHAR(200) NULL, + CONSTRAINT extsys_vnfm_table PRIMARY KEY(VNFMID) +); + + diff --git a/esr-core/esr-mgr/dependency-reduced-pom.xml b/esr-core/esr-mgr/dependency-reduced-pom.xml new file mode 100644 index 0000000..1091fc7 --- /dev/null +++ b/esr-core/esr-mgr/dependency-reduced-pom.xml @@ -0,0 +1,163 @@ + + + + esr-core-parent + org.onap.aai.esr-server + 1.0.0-SNAPSHOT + + 4.0.0 + esr-mgr + esr-server/esr-core/esr-mgr + + + + org.eclipse.m2e + lifecycle-mapping + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [2.0,) + + copy-dependencies + + + + + + + + + + + + maven-jar-plugin + + + + true + + + + + + maven-shade-plugin + + + package + + shade + + + + + + org.onap.aai.esr.extsysApp + + + + + + + true + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + + + io.dropwizard + dropwizard-core + ${dropwizard.version} + true + + + + + + + + + + + junit + junit + 4.10 + test + + + hamcrest-core + org.hamcrest + + + + + org.powermock + powermock-module-junit4 + 1.4.10 + test + + + powermock-module-junit4-common + org.powermock + + + + + org.powermock + powermock-api-mockito + 1.4.10 + test + + + mockito-all + org.mockito + + + powermock-api-support + org.powermock + + + + + com.h2database + h2 + 1.4.182 + test + + + org.apache.ant + ant + 1.8.2 + test + + + ant-launcher + org.apache.ant + + + + + + diff --git a/esr-core/esr-mgr/pom.xml b/esr-core/esr-mgr/pom.xml new file mode 100644 index 0000000..99cc729 --- /dev/null +++ b/esr-core/esr-mgr/pom.xml @@ -0,0 +1,210 @@ + + + + + + org.onap.aai.esr-server + esr-core-parent + 1.0.0-SNAPSHOT + + + 4.0.0 + esr-mgr + esr-server/esr-core/esr-mgr + jar + + + + + org.eclipse.m2e + lifecycle-mapping + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [2.0,) + + copy-dependencies + + + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + + + + + + org.apache.maven.plugins + maven-shade-plugin + + true + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + package + + shade + + + + + + org.onap.aai.esr.extsysApp + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + + + io.dropwizard + dropwizard-core + ${dropwizard.version} + true + + + + + + + + + + + + io.dropwizard + dropwizard-core + + + io.dropwizard + dropwizard-assets + + + io.dropwizard + dropwizard-hibernate + + + + org.projectlombok + lombok + + + io.swagger + swagger-jersey2-jaxrs + + + + org.glassfish.jersey.core + jersey-server + + + org.glassfish.jersey.media + jersey-media-multipart + + + org.glassfish.jersey.containers + jersey-container-servlet-core + + + + com.eclipsesource.jaxrs + consumer + + + com.eclipsesource.jaxrs + jersey-all + + + + + + com.google.code.gson + gson + + + mysql + mysql-connector-java + + + + junit + junit + test + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito + test + + + com.h2database + h2 + test + + + org.apache.ant + ant + test + + + + diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java new file mode 100644 index 0000000..3678922 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java @@ -0,0 +1,110 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.dropwizard.Application; +import io.dropwizard.assets.AssetsBundle; +import io.dropwizard.db.DataSourceFactory; +import io.dropwizard.hibernate.HibernateBundle; +import io.dropwizard.server.SimpleServerFactory; +import io.dropwizard.setup.Bootstrap; +import io.dropwizard.setup.Environment; +import io.swagger.jaxrs.config.BeanConfig; +import io.swagger.jaxrs.listing.ApiListingResource; + +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.onap.aai.esr.common.Config; +import org.onap.aai.esr.common.ServiceRegistrer; +import org.onap.aai.esr.dao.DaoManager; +import org.onap.aai.esr.entity.db.BaseData; +import org.onap.aai.esr.entity.db.EmsData; +import org.onap.aai.esr.entity.db.SdncData; +import org.onap.aai.esr.entity.db.VimData; +import org.onap.aai.esr.entity.db.VnfmData; +import org.onap.aai.esr.hibernate.HibernateBundleAgent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ExtsysApp extends Application { + + private static final Logger LOGGER = LoggerFactory.getLogger(ExtsysApp.class); + + public static void main(String[] args) throws Exception { + new ExtsysApp().run(args); + } + + @Override + public String getName() { + return "ONAP-ESR"; + } + + private final HibernateBundleAgent bundle = new HibernateBundleAgent(); + + @Override + public void initialize(Bootstrap bootstrap) { + bootstrap.addBundle(new AssetsBundle("/api-doc", "/api-doc", "index.html", "api-doc")); + initDb(bootstrap); + } + + private void initService() { + Thread registerExtsysService = new Thread(new ServiceRegistrer()); + registerExtsysService.setName("register extsys service to Microservice Bus"); + registerExtsysService.start(); + } + + private void initDb(Bootstrap bootstrap) { + bootstrap.addBundle(bundle); + } + + @Override + public void run(ExtsysAppConfiguration configuration, Environment environment) { + LOGGER.info("Start to initialize extsys."); + environment.jersey().packages("org.onap.aai.esr.resource"); + environment.jersey().register(MultiPartFeature.class); + initSwaggerConfig(environment, configuration); + Config.setConfigration(configuration); + initService(); + LOGGER.info("Initialize extsys finished."); + } + + /** + * initialize swagger configuration. + * + * @param environment environment information + * @param configuration configuration + */ + private void initSwaggerConfig(Environment environment, ExtsysAppConfiguration configuration) { + environment.jersey().register(new ApiListingResource()); + environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); + + BeanConfig config = new BeanConfig(); + config.setTitle("Open-o ExtSys Service rest API"); + config.setVersion("1.0.0"); + config.setResourcePackage("org.onap.aai.esr.resource"); + // set rest api basepath in swagger + SimpleServerFactory simpleServerFactory = + (SimpleServerFactory) configuration.getServerFactory(); + String basePath = simpleServerFactory.getApplicationContextPath(); + String rootPath = simpleServerFactory.getJerseyRootPath(); + rootPath = rootPath.substring(0, rootPath.indexOf("/*")); + basePath = basePath.equals("/") ? rootPath + : (new StringBuilder()).append(basePath).append(rootPath).toString(); + config.setBasePath(basePath); + config.setScan(true); + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java new file mode 100644 index 0000000..d687c01 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java @@ -0,0 +1,93 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.dropwizard.Configuration; +import io.dropwizard.db.DataSourceFactory; +import org.hibernate.validator.constraints.NotEmpty; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; + + + +public class ExtsysAppConfiguration extends Configuration { + @NotEmpty + private String template; + + @NotEmpty + private String defaultName = "OPENO-Extsys"; + + @NotEmpty + private String msbServerAddr; + @Valid + private String serviceIp; + + @Valid + @NotNull + private DataSourceFactory database = new DataSourceFactory(); + + @JsonProperty("database") + public DataSourceFactory getDataSourceFactory() { + return database; + } + + @JsonProperty("database") + public void setDataSourceFactory(DataSourceFactory dataSourceFactory) { + this.database = dataSourceFactory; + } + + @JsonProperty + public String getTemplate() { + return template; + } + + @JsonProperty + public void setTemplate(String template) { + this.template = template; + } + + @JsonProperty + public String getDefaultName() { + return defaultName; + } + + @JsonProperty + public void setDefaultName(String name) { + this.defaultName = name; + } + + @JsonProperty + public String getMsbServerAddr() { + return msbServerAddr; + } + + @JsonProperty + public void setMsbServerAddr(String msbServerAddr) { + this.msbServerAddr = msbServerAddr; + } + @JsonProperty + public String getServiceIp() { + return serviceIp; + } + + @JsonProperty + public void setServiceIp(String serviceIp) { + this.serviceIp = serviceIp; + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/Config.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/Config.java new file mode 100644 index 0000000..bb27dc2 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/Config.java @@ -0,0 +1,32 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.common; + +import org.onap.aai.esr.ExtsysAppConfiguration; + + +public class Config { + private static ExtsysAppConfiguration configration; + + public static ExtsysAppConfiguration getConfigration() { + return configration; + } + + public static void setConfigration(ExtsysAppConfiguration config) { + configration = config; + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/ExtSysResuorceType.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/ExtSysResuorceType.java new file mode 100644 index 0000000..cfde136 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/ExtSysResuorceType.java @@ -0,0 +1,26 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.common; + + +public enum ExtSysResuorceType { + VIM, SDNC, EMS, VNFM, BASE; + + public static ExtSysResuorceType getType(String type) { + return valueOf(type); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/Parameters.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/Parameters.java new file mode 100644 index 0000000..c97e97b --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/Parameters.java @@ -0,0 +1,27 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.common; + +/** + * Parameters.
+ * + * @author sun qi + * @version ESR V1 + */ +public enum Parameters { + emsId, sdnControllerId, vimId, vnfmId, id +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/ServiceRegistrer.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/ServiceRegistrer.java new file mode 100644 index 0000000..c8cb3cd --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/ServiceRegistrer.java @@ -0,0 +1,76 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.common; + +import org.onap.aai.esr.externalservice.entity.ServiceRegisterEntity; +import org.onap.aai.esr.externalservice.msb.MicroserviceBusConsumer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Parameters.
+ * + * @author sun qi + * @version ESR V1 + */ +public class ServiceRegistrer implements Runnable { + private final ServiceRegisterEntity extsysEntity = new ServiceRegisterEntity(); + private static final Logger LOG = LoggerFactory.getLogger(ServiceRegistrer.class); + + public ServiceRegistrer() { + initServiceEntity(); + } + + @Override + public void run() { + LOG.info("start extsys microservice register"); + boolean flag = false; + int retry = 0; + while (!flag && retry < 1000) { + LOG.info("extsys microservice register.retry:" + retry); + retry++; + flag = MicroserviceBusConsumer.registerService(extsysEntity); + if (flag == false) { + LOG.warn("microservice register failed, sleep 30S and try again."); + threadSleep(30000); + } else { + LOG.info("microservice register success!"); + break; + } + } + LOG.info("extsys microservice register end."); + } + + private void threadSleep(int second) { + LOG.info("start sleep ...."); + try { + Thread.sleep(second); + } catch (InterruptedException error) { + LOG.error("thread sleep error.errorMsg:" + error.getMessage()); + } + LOG.info("sleep end ."); + } + + private void initServiceEntity() { + extsysEntity.setServiceName("extsys"); + extsysEntity.setProtocol("REST"); + extsysEntity.setVersion("v1"); + extsysEntity.setUrl("/openoapi/extsys/v1"); + extsysEntity.setSingleNode(Config.getConfigration().getServiceIp(), "8100", 0); + extsysEntity.setVisualRange("1"); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/BaseDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/BaseDao.java new file mode 100644 index 0000000..5580911 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/BaseDao.java @@ -0,0 +1,216 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.dao; + +import io.dropwizard.hibernate.AbstractDAO; +import io.dropwizard.util.Generics; + +import org.hibernate.Criteria; +import org.hibernate.HibernateException; +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.criterion.Restrictions; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.util.HqlFactory; + +import java.util.List; +import java.util.Map; + +/** + * a base class for Hibernate DAO classes.
+ * provide the common methods to create,delete,update and query data + * + * + */ +public class BaseDao extends AbstractDAO { + + /** + * init session. + * + * @param sessionFactory session Factory + */ + public BaseDao(SessionFactory sessionFactory) { + super(sessionFactory); + this.sessionFactory = sessionFactory; + this.entityClass = Generics.getTypeParameter(getClass()); + } + + public String[] excludeProperties; + private SessionFactory sessionFactory; + protected Session session; + private final Class entityClass; + + @Override + protected Session currentSession() { + return this.session; + } + + /** + * update entity . + * + * @param data the object to update + * @throws ExtsysException when db abnormal + */ + public void update(T data, String filter) throws ExtsysException { + try { + String hql = HqlFactory.getUpdateHql(data, excludeProperties, filter); + beginTransaction(); + Query query = this.session.createQuery(hql); + query.executeUpdate(); + closeTransaction(); + } catch (Exception error) { + transactionRollBack(); + throw new ExtsysException("", "error while updating data.errorMsg:" + error.getMessage()); + } finally { + closeSession(); + } + } + + /** + * delete entity. + * + * @param data the object to delete + * @throws ExtsysException when db abnormal + */ + public void delete(T data) throws ExtsysException { + try { + beginTransaction(); + this.session.delete(data); + closeTransaction(); + } catch (Exception error) { + transactionRollBack(); + throw new ExtsysException("", "error while deleting data.errorMsg:" + error.getMessage()); + } finally { + closeSession(); + } + } + + /** + * create entity. + * + * @param data the object to create + * @return T + * @throws ExtsysException when db abnormal + * + */ + public T create(T data) throws ExtsysException { + try { + beginTransaction(); + session.save(data); + closeTransaction(); + } catch (HibernateException error) { + transactionRollBack(); + throw new ExtsysException("", "error while creating data.errorMsg:" + error.getMessage()); + } finally { + closeSession(); + } + return data; + } + + /** + * query entity by condition. + * + * @param unionHql query condition. + * @return T + * @throws ExtsysException when db abnormal + * + */ + public List unionQuery(String unionHql) throws ExtsysException { + List data; + try { + beginTransaction(); + Query query = this.session.createQuery(unionHql); + data = query.list(); + closeTransaction(); + } catch (Exception error) { + transactionRollBack(); + throw new ExtsysException("", "error while union query data.errorMsg:" + error.getMessage()); + } finally { + closeSession(); + } + return data; + } + + /** + * delete entity by condition. + * + * @param unionHql delete condition. + * @return T + * @throws ExtsysException when db abnormal + * + */ + public int unionDelete(String unionHql) throws ExtsysException { + int num = 0; + try { + beginTransaction(); + Query query = this.session.createQuery(unionHql); + num = query.executeUpdate(); + closeTransaction(); + } catch (Exception error) { + transactionRollBack(); + throw new ExtsysException("", "error while union query data.errorMsg:" + error.getMessage()); + } finally { + closeSession(); + } + return num; + } + + /** + * query entity by condition map. + * + * @param queryParams the condition map used to query objects + * @return List + * @throws ExtsysException when db abnormal + */ + @SuppressWarnings("unchecked") + public List query(Map queryParams) throws ExtsysException { + List result = null; + try { + beginTransaction(); + Criteria criteria = this.session.createCriteria(entityClass); + for (String key : queryParams.keySet()) { + criteria.add(Restrictions.eq(key, queryParams.get(key))); + } + result = (List) criteria.list(); + closeTransaction(); + } catch (HibernateException error) { + throw new ExtsysException("", "error while querying data.errorMsg:" + error.getMessage()); + } finally { + closeSession(); + } + return result; + } + + protected void beginTransaction() { + this.session = this.sessionFactory.openSession(); + this.session.beginTransaction(); + } + + protected void closeTransaction() { + this.session.getTransaction().commit(); + } + + protected void closeSession() { + this.session.close(); + } + + protected void transactionRollBack() { + this.session.getTransaction().rollback(); + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/CommonDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/CommonDao.java new file mode 100644 index 0000000..c536812 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/CommonDao.java @@ -0,0 +1,40 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.dao; + +import org.hibernate.SessionFactory; +import org.onap.aai.esr.entity.db.BaseData; + + +/** + * a common class for Hibernate DAO classes.
+ * + * @author 10159474 + * + */ +public class CommonDao extends BaseDao { + + /** + * init session. + * + * @param sessionFactory session Factory + */ + public CommonDao(SessionFactory sessionFactory) { + super(sessionFactory); + } + + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/DaoManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/DaoManager.java new file mode 100644 index 0000000..8c2f225 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/DaoManager.java @@ -0,0 +1,137 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.dao; + +import org.hibernate.SessionFactory; +import org.onap.aai.esr.common.ExtSysResuorceType; +import org.onap.aai.esr.exception.ExtsysException; + +/** + * DAO manager class.
+ * a class to store DAO instances and provide methods to get these instances + * + * + */ +public class DaoManager { + private static DaoManager instance = new DaoManager(); + + private VimDao vimDao; + private EmsDao emsDao; + private VnfmDao vnfmDao; + private SdncDao sdncDao; + private CommonDao commonDao; + private SessionFactory sessionFactory; + + private DaoManager() {} + + public static synchronized DaoManager getInstance() { + return instance; + } + + /** + * according to resource type and return proper DAO. + * + * @param type resource Type + * @return DAO + */ + public BaseDao getDao(String type) throws ExtsysException { + if (sessionFactory == null) { + throw new ExtsysException("", "errorMsg:database connect init faild!"); + } + switch (ExtSysResuorceType.getType(type)) { + case VIM: + return getVimDao(); + case SDNC: + return getSdncDao(); + case VNFM: + return getVnfmDao(); + case EMS: + return getEmsDao(); + default: + return getCommonDao(); + } + } + + public void setSessionFactory(SessionFactory sessionFactory) { + this.sessionFactory = sessionFactory; + } + + public SessionFactory getSessionFactory() { + return sessionFactory; + } + + /** + * @return Returns the vim dao. + */ + public VimDao getVimDao() { + vimDao = new VimDao(sessionFactory); + return vimDao; + } + + public void setVimDao(VimDao vimDao) { + this.vimDao = vimDao; + } + + /** + * @return Returns the ems dao. + */ + public EmsDao getEmsDao() { + emsDao = new EmsDao(sessionFactory); + return emsDao; + } + + public void setEmsDao(EmsDao emsDao) { + this.emsDao = emsDao; + } + + /** + * @return Returns the vnfm dao. + */ + public VnfmDao getVnfmDao() { + vnfmDao = new VnfmDao(sessionFactory); + return vnfmDao; + } + + public void setVnfmDao(VnfmDao vnfmDao) { + this.vnfmDao = vnfmDao; + } + + /** + * @return Returns the sdnc dao. + */ + public SdncDao getSdncDao() { + sdncDao = new SdncDao(sessionFactory); + return sdncDao; + } + + public void setSdncDao(SdncDao sdncDao) { + this.sdncDao = sdncDao; + } + + /** + * @return Returns the common dao. + */ + public CommonDao getCommonDao() { + commonDao = new CommonDao(sessionFactory); + return commonDao; + } + + public void setCommonDao(CommonDao commonDao) { + this.commonDao = commonDao; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/EmsDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/EmsDao.java new file mode 100644 index 0000000..bb65b3a --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/EmsDao.java @@ -0,0 +1,36 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.dao; + +import org.hibernate.SessionFactory; +import org.onap.aai.esr.entity.db.EmsData; + + + +/** + * ems for Hibernate DAO classes.
+ * + * @author 10159474 + * + */ +public class EmsDao extends BaseDao { + + public EmsDao(SessionFactory sessionFactory) { + super(sessionFactory); + } + + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/SdncDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/SdncDao.java new file mode 100644 index 0000000..7163959 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/SdncDao.java @@ -0,0 +1,37 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.dao; + +import org.hibernate.SessionFactory; +import org.onap.aai.esr.entity.db.SdncData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * sdnc for Hibernate DAO classes.
+ * + * @author 10159474 + * + */ +public class SdncDao extends BaseDao { + private static final Logger logger = LoggerFactory.getLogger(SdncDao.class); + + public SdncDao(SessionFactory sessionFactory) { + super(sessionFactory); + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VimDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VimDao.java new file mode 100644 index 0000000..11ed896 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VimDao.java @@ -0,0 +1,36 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.dao; + +import org.hibernate.SessionFactory; +import org.onap.aai.esr.entity.db.VimData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * vim for Hibernate DAO classes.
+ * + * @author 10159474 + * + */ +public class VimDao extends BaseDao { + private static final Logger logger = LoggerFactory.getLogger(VimDao.class); + + public VimDao(SessionFactory sessionFactory) { + super(sessionFactory); + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VnfmDao.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VnfmDao.java new file mode 100644 index 0000000..100e2a2 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/dao/VnfmDao.java @@ -0,0 +1,35 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.dao; + +import org.hibernate.SessionFactory; +import org.onap.aai.esr.entity.db.VnfmData; + + +/** + * vnfm for Hibernate DAO classes.
+ * + * @author 10159474 + * + */ +public class VnfmDao extends BaseDao { + + public VnfmDao(SessionFactory sessionFactory) { + super(sessionFactory); + } + + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/BaseData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/BaseData.java new file mode 100644 index 0000000..fd99b28 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/BaseData.java @@ -0,0 +1,116 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.db; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; + +@Entity +@Table(name = "extsys_base_table") +@Inheritance(strategy = InheritanceType.JOINED) +public class BaseData { + @Id + @Column(name = "ID") + private String id; + + @Column(name = "NAME") + private String name; + + @Column(name = "VENDOR") + private String vendor; + + @Column(name = "VERSION") + private String version; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "TYPE") + private String type; + @Column(name = "CREATETIME") + private String createTime; + @Column(name = "CATAGORY") + private String category; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVendor() { + return vendor; + } + + public void setVendor(String vendor) { + this.vendor = vendor; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/EmsData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/EmsData.java new file mode 100644 index 0000000..9b35a4a --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/EmsData.java @@ -0,0 +1,81 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.db; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.Table; + + + +@Entity +@Table(name = "extsys_ems_table") +@PrimaryKeyJoinColumn(name = "EMSID") +@JsonIgnoreProperties(ignoreUnknown = true) +public class EmsData extends BaseData { + + + @Column(name = "PRODUCTNAME") + private String productName; + + @Column(name = "URL") + private String url; + + @Column(name = "USERNAME") + private String userName; + + @Column(name = "PASSWORD") + private String password; + + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + 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 String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/SdncData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/SdncData.java new file mode 100644 index 0000000..3924910 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/SdncData.java @@ -0,0 +1,88 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.db; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.Table; + + + +@Entity +@Table(name = "extsys_sdnc_table") +@PrimaryKeyJoinColumn(name = "SDNCONTROLLERID") +@JsonIgnoreProperties(ignoreUnknown = true) +public class SdncData extends BaseData { + + @Column(name = "URL") + private String url; + + @Column(name = "USERNAME") + private String userName; + + @Column(name = "PASSWORD") + private String password; + + @Column(name = "PRODUCTNAME") + private String productName; + + @Column(name = "PROTOCOL") + private String protocol; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + 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 String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/VimData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/VimData.java new file mode 100644 index 0000000..1b1f1a4 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/VimData.java @@ -0,0 +1,87 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.db; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.Table; + +@Entity +@Table(name = "extsys_vim_table") +@PrimaryKeyJoinColumn(name = "VIMID") +@JsonIgnoreProperties(ignoreUnknown = true) +public class VimData extends BaseData { + + + @Column(name = "URL") + private String url; + + @Column(name = "USERNAME") + private String userName; + + @Column(name = "PASSWORD") + private String password; + + @Column(name = "DOMAIN") + private String domain; + + @Column(name = "TENANT") + private String tenant; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getTenant() { + return tenant; + } + + public void setTenant(String tenant) { + this.tenant = tenant; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + 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; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/VnfmData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/VnfmData.java new file mode 100644 index 0000000..312910a --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/db/VnfmData.java @@ -0,0 +1,85 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.db; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.PrimaryKeyJoinColumn; +import javax.persistence.Table; + +@Entity +@Table(name = "extsys_vnfm_table") +@PrimaryKeyJoinColumn(name = "VNFMID") +@JsonIgnoreProperties(ignoreUnknown = true) +public class VnfmData extends BaseData { + + @Column(name = "URL") + private String url; + @Column(name = "USERNAME") + private String userName; + + @Column(name = "PASSWORD") + private String password; + + @Column(name = "VIMID") + private String vimId; + + @Column(name = "CERTIFICATEURL") + private String certificateUrl; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + 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 String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public String getCertificateUrl() { + return certificateUrl; + } + + public void setCertificateUrl(String certificateUrl) { + this.certificateUrl = certificateUrl; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/BaseRestData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/BaseRestData.java new file mode 100644 index 0000000..e6c1d28 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/BaseRestData.java @@ -0,0 +1,120 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.rest; + +import org.onap.aai.esr.entity.db.BaseData; + +public class BaseRestData { + + private String instanceId; + + private String name; + + private String vendor; + + private String version; + + private String description; + + private String type; + + private String createTime; + + private String category; + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVendor() { + return vendor; + } + + public void setVendor(String vendor) { + this.vendor = vendor; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public BaseRestData() { + + } + + /** + * base esr entity. + */ + public BaseRestData(BaseData data) { + this.createTime = data.getCreateTime(); + this.description = data.getDescription(); + this.name = data.getName(); + this.type = data.getType(); + this.vendor = data.getVendor(); + this.version = data.getVersion(); + this.instanceId = data.getId(); + this.category = data.getCategory(); + + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/EmsRestData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/EmsRestData.java new file mode 100644 index 0000000..6229348 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/EmsRestData.java @@ -0,0 +1,84 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.rest; + +import org.onap.aai.esr.entity.db.EmsData; + +public class EmsRestData extends BaseRestData { + + private String productName; + + private String url; + private String userName; + private String password; + private String emsId; + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + 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 String getEmsId() { + return emsId; + } + + public void setEmsId(String emsId) { + this.emsId = emsId; + } + + /** + * ems rest result. + */ + public EmsRestData(EmsData data) { + super(data); + this.emsId = data.getId(); + this.password = data.getPassword(); + this.productName = data.getProductName(); + this.url = data.getUrl(); + this.userName = data.getUserName(); + this.setInstanceId(null); + this.setCategory(null); + } + + public EmsRestData() {} +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/SdncRestData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/SdncRestData.java new file mode 100644 index 0000000..5ae73d2 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/SdncRestData.java @@ -0,0 +1,98 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.rest; + +import org.onap.aai.esr.entity.db.SdncData; + +public class SdncRestData extends BaseRestData { + + private String sdnControllerId; + private String url; + private String userName; + private String password; + private String productName; + private String protocol; + + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + 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 String getSdnControllerId() { + return sdnControllerId; + } + + public void setSdnControllerId(String sdnControllerId) { + this.sdnControllerId = sdnControllerId; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + /** + * sdnc rest result. + */ + public SdncRestData(SdncData data) { + super(data); + this.password = data.getPassword(); + this.productName = data.getProductName(); + this.protocol = data.getProtocol(); + this.sdnControllerId = data.getId(); + this.url = data.getUrl(); + this.userName = data.getUserName(); + this.setInstanceId(null); + this.setCategory(null); + + + } + + public SdncRestData() { + + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/VimRestData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/VimRestData.java new file mode 100644 index 0000000..ffd31df --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/VimRestData.java @@ -0,0 +1,101 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.rest; + +import org.onap.aai.esr.entity.db.VimData; + +public class VimRestData extends BaseRestData { + + private String vimId; + + private String url; + + private String userName; + + private String password; + + private String domain; + + private String tenant; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getTenant() { + return tenant; + } + + public void setTenant(String tenant) { + this.tenant = tenant; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + 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 String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + /** + * vim rest result. + */ + public VimRestData(VimData data) { + super(data); + this.domain = data.getDomain(); + this.password = data.getPassword(); + this.url = data.getUrl(); + this.userName = data.getUserName(); + this.vimId = data.getId(); + this.tenant = data.getTenant(); + this.setInstanceId(null); + this.setCategory(null); + + } + + public VimRestData() { + + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/VnfmRestData.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/VnfmRestData.java new file mode 100644 index 0000000..9e93c95 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/VnfmRestData.java @@ -0,0 +1,96 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.entity.rest; + +import org.onap.aai.esr.entity.db.VnfmData; + +public class VnfmRestData extends BaseRestData { + + private String vnfmId; + private String url; + + private String userName; + private String password; + private String vimId; + private String certificateUrl; + + public String getVnfmId() { + return vnfmId; + } + + public void setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + 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 String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public String getCertificateUrl() { + return certificateUrl; + } + + public void setCertificateUrl(String certificateUrl) { + this.certificateUrl = certificateUrl; + } + + /** + * vnfm rest result. + */ + public VnfmRestData(VnfmData data) { + super(data); + this.certificateUrl = data.getCertificateUrl(); + this.password = data.getPassword(); + this.url = data.getUrl(); + this.userName = data.getUserName(); + this.vimId = data.getVimId(); + this.vnfmId = data.getId(); + this.setInstanceId(null); + this.setCategory(null); + } + + public VnfmRestData() { + + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExtsysException.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExtsysException.java new file mode 100644 index 0000000..0ac013e --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExtsysException.java @@ -0,0 +1,48 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.exception; + +public class ExtsysException extends Exception { + + private static final long serialVersionUID = 1L; + private String errorCode; + private String errorMsg; + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public ExtsysException() { + super(); + } + + public ExtsysException(String errorCode, String errorMsg) { + this.errorCode = errorCode; + this.errorMsg = errorMsg; + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/ServiceNode.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/ServiceNode.java new file mode 100644 index 0000000..234d262 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/ServiceNode.java @@ -0,0 +1,32 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.externalservice.entity; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ServiceNode { + private String ip; + private String port; + private int ttl; +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/ServiceRegisterEntity.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/ServiceRegisterEntity.java new file mode 100644 index 0000000..16e6a55 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/ServiceRegisterEntity.java @@ -0,0 +1,59 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.externalservice.entity; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class ServiceRegisterEntity { + private String serviceName; + private String version; + private String url; + private String protocol; + private String visualRange; + private ArrayList nodes = new ArrayList(); + + /** + * set service entity. + * + * @param ip node ip. can be null + * @param port service port + * @param ttl service survival time + */ + public void setSingleNode(String ip, String port, int ttl) { + ServiceNode node = new ServiceNode(); + if (ip != null && ip.length() > 0) { + node.setIp(ip); + } else { + node.setIp(null); + } + node.setPort(port); + node.setTtl(ttl); + nodes.add(node); + } + +} + diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java new file mode 100644 index 0000000..a72aed0 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java @@ -0,0 +1,50 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.externalservice.msb; + +import com.eclipsesource.jaxrs.consumer.ConsumerFactory; + +import org.glassfish.jersey.client.ClientConfig; +import org.onap.aai.esr.common.Config; +import org.onap.aai.esr.externalservice.entity.ServiceRegisterEntity; +import org.onap.aai.esr.util.ExtsysDbUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + + +public class MicroserviceBusConsumer { + private static final Logger LOG = LoggerFactory.getLogger(MicroserviceBusConsumer.class); + + /** + * @param entity service entity + * @return register service to msb success return true, else return false. + */ + public static boolean registerService(ServiceRegisterEntity entity) { + ClientConfig config = new ClientConfig(); + LOG.info("microservice register body:" + ExtsysDbUtil.objectToString(entity)); + try { + MicroserviceBusRest resourceserviceproxy = ConsumerFactory.createConsumer( + Config.getConfigration().getMsbServerAddr(), config, MicroserviceBusRest.class); + resourceserviceproxy.registerServce("false", entity); + } catch (Exception error) { + LOG.error("microservice register failed!" + error.getMessage()); + return false; + } + return true; + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusRest.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusRest.java new file mode 100644 index 0000000..a6a064f --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusRest.java @@ -0,0 +1,39 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.externalservice.msb; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.onap.aai.esr.externalservice.entity.ServiceRegisterEntity; + + + + +@Path("/openoapi/microservices/v1/services") +// @Path("/api/microservices/v1/services") +public interface MicroserviceBusRest { + @Path("") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate, + ServiceRegisterEntity entity)throws Exception; +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java new file mode 100644 index 0000000..3a76700 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/BaseHandler.java @@ -0,0 +1,225 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.handle; + +import com.google.gson.Gson; + +import org.onap.aai.esr.dao.BaseDao; +import org.onap.aai.esr.dao.DaoManager; +import org.onap.aai.esr.entity.db.BaseData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.util.ExtsysDbUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.Map; + +/** + * an abstract class for wrapper class.
+ * provide the common methods to process the DB request + * + * @author 10159474 + */ +public abstract class BaseHandler { + private static final Logger logger = LoggerFactory.getLogger(BaseHandler.class); + + public Gson gson = new Gson(); + + /** + * create entity. + * + * @param data entity + * @param resouceType resource type + * @return entity + * @throws ExtsysException when DAO exception + */ + @SuppressWarnings({"unchecked", "rawtypes"}) + public T create(T data, String resouceType) throws ExtsysException { + T rtnData = null; + boolean check = true; + logger.info("BaseHandler:start create data.info:" + ExtsysDbUtil.objectToString(data)); + try { + check = validity(data); + if (check) { + logger.error("validity check success!"); + } else { + logger.error("validity check failed"); + throw new ExtsysException("", "validity check failed"); + } + } catch (ExtsysException error) { + logger.error("validity check failed,errorMsg:" + error.getErrorMsg()); + throw error; + } + try { + data.setId(ExtsysDbUtil.generateId()); + data.setCreateTime(ExtsysDbUtil.getNowTime()); + data.setCategory(resouceType); + BaseDao dao = DaoManager.getInstance().getDao(resouceType); + rtnData = (T) dao.create(data); + } catch (ExtsysException error) { + logger.error("BaseHandler:error while creating " + resouceType, error); + throw error; + } + logger.info("BaseHandler:create data end.info:" + ExtsysDbUtil.objectToString(data)); + return rtnData; + } + + /** + * delete entity. + * @param data entity + * @param resouceType resource type + * @throws ExtsysException when DAO exception + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + public void delete(T data, String resouceType) throws ExtsysException { + logger.info("BaseHandler:start delete data.info:" + ExtsysDbUtil.objectToString(data)); + try { + BaseDao dao = DaoManager.getInstance().getDao(resouceType); + dao.delete(data); + } catch (ExtsysException error) { + logger.error("BaseHandler:error while deleting " + resouceType, error); + throw error; + } + logger.info("BaseHandler:delete data end"); + } + + /** + * delete entity by query condition. + * @param queryParam query parameter + * @param resouceType resource type + * @throws ExtsysException when DAO exception + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + public void delete(Map queryParam, String resouceType) throws ExtsysException { + logger.info("BaseHandler:start delete data by condition.info:" + + ExtsysDbUtil.objectToString(queryParam)); + List datas; + try { + BaseDao dao = DaoManager.getInstance().getDao(resouceType); + datas = dao.query(queryParam); + for (T data : datas) { + delete(data, resouceType); + } + } catch (ExtsysException error) { + logger.error("BaseHandler:error while deleting " + resouceType, error); + throw error; + } + + } + + /** + * update entity. + * @param data entity + * @param filter update condition + * @param resouceType resource type + * @throws ExtsysException when DAO exception + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + public void update(T data, String filter, String resouceType) throws ExtsysException { + logger.info("BaseHandler:start update data .info:" + ExtsysDbUtil.objectToString(data) + + " filter:" + filter); + try { + BaseDao dao = DaoManager.getInstance().getDao(resouceType); + data.setId(null); + dao.update(data, filter); + + } catch (ExtsysException error) { + logger.error("BaseHandler:error while updating " + resouceType, error); + throw error; + } + logger.info("BaseHandler:update data end "); + } + + /** + * query entity. + * @param queryParam query parameter + * @param resouceType resource type + * @return List entity list + * @throws ExtsysException when DAO exception + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + public List query(Map queryParam, String resouceType) throws ExtsysException { + logger.info("BaseHandler:start query data .info:" + ExtsysDbUtil.objectToString(queryParam)); + List datas = null; + try { + BaseDao dao = DaoManager.getInstance().getDao(resouceType); + datas = dao.query(queryParam); + + } catch (ExtsysException error) { + logger.error("BaseHandler:error while querying " + resouceType, error); + throw error; + } + logger.info("BaseHandler: query data end .info:" + ExtsysDbUtil.objectToString(datas)); + return datas; + } + + /** + * query entity. + * @param filter query condition + * @param resouceType resource type + * @return list entity + * @throws ExtsysException when DAO exception + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + public List unionQuery(String filter, String resouceType) throws ExtsysException { + logger.info("BaseHandler:start union query data.fliter:" + filter); + List datas = null; + try { + BaseDao dao = DaoManager.getInstance().getDao(resouceType); + datas = dao.unionQuery(filter); + + } catch (ExtsysException error) { + logger.error("BaseHandler:error while union querying " + resouceType, error); + throw error; + } + logger.info("BaseHandler:union query data end .info:" + ExtsysDbUtil.objectToString(datas)); + return datas; + } + + /** + * delete entity. + * @param filter delete condition + * @param resouceType resource type + * @return delete entity num + * @throws ExtsysException when DAO exception + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + public int unionDelete(String filter, String resouceType) throws ExtsysException { + logger.info("BaseHandler:start delete query data.fliter:" + filter); + int num; + try { + BaseDao dao = DaoManager.getInstance().getDao(resouceType); + num = dao.unionDelete(filter); + + } catch (ExtsysException error) { + logger.error("BaseHandler:error while union delete " + resouceType, error); + throw error; + } + logger.info("BaseHandler:union delete data end .num:" + num); + return num; + } + + /** + * check if the esr parameter is correct in the external system. + * @param data esr entity + * @return if esr parameter correct return true else return false + * @throws ExtsysException ExtsysException when external system error + */ + + public abstract boolean validity(T data) throws ExtsysException; + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/CommonHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/CommonHandler.java new file mode 100644 index 0000000..da563bb --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/CommonHandler.java @@ -0,0 +1,50 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.handle; + +import org.onap.aai.esr.common.ExtSysResuorceType; +import org.onap.aai.esr.common.Parameters; +import org.onap.aai.esr.entity.db.BaseData; +import org.onap.aai.esr.exception.ExtsysException; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class CommonHandler extends BaseHandler { + + public List getAll() throws ExtsysException { + Map query = new HashMap(); + return query(query, ExtSysResuorceType.BASE.name()); + } + + /** + * query instance list by id. + */ + public List getInstanceById(String id) throws ExtsysException { + Map query = new HashMap(); + query.put(Parameters.id.name(), id); + return query(query, ExtSysResuorceType.BASE.name()); + } + + @Override + public boolean validity(BaseData data) throws ExtsysException { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/EmsHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/EmsHandler.java new file mode 100644 index 0000000..6d6d724 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/EmsHandler.java @@ -0,0 +1,81 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.handle; + +import org.onap.aai.esr.common.ExtSysResuorceType; +import org.onap.aai.esr.common.Parameters; +import org.onap.aai.esr.entity.db.EmsData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.util.HqlFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class EmsHandler extends BaseHandler { + private static final Logger logger = LoggerFactory.getLogger(EmsHandler.class); + + @Override + public boolean validity(EmsData data) throws ExtsysException { + return true; + } + + public List getAll() throws ExtsysException { + Map query = new HashMap(); + return query(query, ExtSysResuorceType.EMS.name()); + } + + /** + * get ems list by id. + */ + public List getEmsById(String id) throws ExtsysException { + Map query = new HashMap(); + query.put(Parameters.id.name(), id); + return query(query, ExtSysResuorceType.EMS.name()); + } + + /** + * update ems list by id. + */ + public EmsData update(EmsData emsData, String id) throws ExtsysException { + update(emsData, HqlFactory.getOidFilter(Parameters.id.name(), id), + ExtSysResuorceType.EMS.name()); + List list = getEmsById(id); + if (list.size() <= 0) { + logger.error("update ems info error."); + throw new ExtsysException("0000", "update ems info error"); + } + return list.get(0); + } + + public EmsData add(EmsData emsData) throws ExtsysException { + + return create(emsData, ExtSysResuorceType.EMS.name()); + } + + /** + * delete ems list by id. + */ + public void delete(String id) throws ExtsysException { + EmsData ems = new EmsData(); + ems.setId(id); + delete(ems, ExtSysResuorceType.EMS.name()); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/SdncHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/SdncHandler.java new file mode 100644 index 0000000..60d0a9c --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/SdncHandler.java @@ -0,0 +1,79 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.handle; + +import org.onap.aai.esr.common.ExtSysResuorceType; +import org.onap.aai.esr.common.Parameters; +import org.onap.aai.esr.entity.db.SdncData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.util.HqlFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SdncHandler extends BaseHandler { + private static final Logger logger = LoggerFactory.getLogger(SdncHandler.class); + + @Override + public boolean validity(SdncData data) throws ExtsysException { + return true; + } + + public List getAll() throws ExtsysException { + Map query = new HashMap(); + return query(query, ExtSysResuorceType.SDNC.name()); + } + + /** + * get sdnc list by id. + */ + public List getSdncById(String id) throws ExtsysException { + Map query = new HashMap(); + query.put(Parameters.id.name(), id); + return query(query, ExtSysResuorceType.SDNC.name()); + } + + /** + * update sdnc list by id. + */ + public SdncData update(SdncData sdncData, String id) throws ExtsysException { + update(sdncData, HqlFactory.getOidFilter(Parameters.id.name(), id), + ExtSysResuorceType.SDNC.name()); + List list = getSdncById(id); + if (list.size() <= 0) { + logger.error("update sdn info error."); + throw new ExtsysException("0000", "update sdn info error"); + } + return list.get(0); + } + + public SdncData add(SdncData sdncData) throws ExtsysException { + return create(sdncData, ExtSysResuorceType.SDNC.name()); + } + + /** + * delete sdnc list by id. + */ + public void delete(String id) throws ExtsysException { + SdncData sdnc = new SdncData(); + sdnc.setId(id); + delete(sdnc, ExtSysResuorceType.SDNC.name()); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VimHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VimHandler.java new file mode 100644 index 0000000..c4c4d4d --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VimHandler.java @@ -0,0 +1,79 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.handle; + +import org.onap.aai.esr.common.ExtSysResuorceType; +import org.onap.aai.esr.common.Parameters; +import org.onap.aai.esr.entity.db.VimData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.util.HqlFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class VimHandler extends BaseHandler { + private static final Logger logger = LoggerFactory.getLogger(VimHandler.class); + + @Override + public boolean validity(VimData data) throws ExtsysException { + return true; + } + + public List getAll() throws ExtsysException { + Map query = new HashMap(); + return query(query, ExtSysResuorceType.VIM.name()); + } + + /** + * query vim list by id. + */ + public List getVimById(String id) throws ExtsysException { + Map query = new HashMap(); + query.put(Parameters.id.name(), id); + return query(query, ExtSysResuorceType.VIM.name()); + } + + /** + * update vim list by id. + */ + public VimData update(VimData vimData, String id) throws ExtsysException { + update(vimData, HqlFactory.getOidFilter(Parameters.id.name(), id), + ExtSysResuorceType.VIM.name()); + List list = getVimById(id); + if (list.size() <= 0) { + logger.error("update vim info error."); + throw new ExtsysException("0000", "update vim info error"); + } + return list.get(0); + } + + public VimData add(VimData vimData) throws ExtsysException { + return create(vimData, ExtSysResuorceType.VIM.name()); + } + + /** + * delete vim list by id. + */ + public void delete(String id) throws ExtsysException { + VimData vim = new VimData(); + vim.setId(id); + delete(vim, ExtSysResuorceType.VIM.name()); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VnfmHandler.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VnfmHandler.java new file mode 100644 index 0000000..94891f1 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/handle/VnfmHandler.java @@ -0,0 +1,79 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.handle; + +import org.onap.aai.esr.common.ExtSysResuorceType; +import org.onap.aai.esr.common.Parameters; +import org.onap.aai.esr.entity.db.VnfmData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.util.HqlFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +public class VnfmHandler extends BaseHandler { + private static final Logger logger = LoggerFactory.getLogger(VnfmHandler.class); + + @Override + public boolean validity(VnfmData data) throws ExtsysException { + return true; + } + + public List getAll() throws ExtsysException { + Map query = new HashMap(); + return query(query, ExtSysResuorceType.VNFM.name()); + } + + /** + * query vnfm list by id. + */ + public List getVnfmById(String id) throws ExtsysException { + Map query = new HashMap(); + query.put(Parameters.id.name(), id); + return query(query, ExtSysResuorceType.VNFM.name()); + } + + /** + * update vnfm list by id. + */ + public VnfmData update(VnfmData vnfmData, String id) throws ExtsysException { + update(vnfmData, HqlFactory.getOidFilter(Parameters.id.name(), id), + ExtSysResuorceType.VNFM.name()); + List list = getVnfmById(id); + if (list.size() <= 0) { + logger.error("update vnfm info error."); + throw new ExtsysException("0000", "update vnfm info error"); + } + return list.get(0); + } + + public VnfmData add(VnfmData vnfmData) throws ExtsysException { + return create(vnfmData, ExtSysResuorceType.VNFM.name()); + } + + /** + * delete vnfm list by id. + */ + public void delete(String id) throws ExtsysException { + VnfmData vnfm = new VnfmData(); + vnfm.setId(id); + delete(vnfm, ExtSysResuorceType.VNFM.name()); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleAgent.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleAgent.java new file mode 100644 index 0000000..131f199 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleAgent.java @@ -0,0 +1,91 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.aai.esr.hibernate; + +import io.dropwizard.ConfiguredBundle; +import io.dropwizard.setup.Bootstrap; +import io.dropwizard.setup.Environment; + +import org.onap.aai.esr.ExtsysAppConfiguration; +import org.onap.aai.esr.dao.DaoManager; +import org.onap.aai.esr.entity.db.BaseData; +import org.onap.aai.esr.entity.db.EmsData; +import org.onap.aai.esr.entity.db.SdncData; +import org.onap.aai.esr.entity.db.VimData; +import org.onap.aai.esr.entity.db.VnfmData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class HibernateBundleAgent implements ConfiguredBundle { + + private final HibernateBundleExt bundle = new HibernateBundleExt(EmsData.class, BaseData.class, VimData.class, + VnfmData.class, SdncData.class); + private static final Logger LOGGER = LoggerFactory.getLogger(HibernateBundleAgent.class); + + @Override + public void run(final ExtsysAppConfiguration configuration, final Environment environment) + throws Exception { + Thread thread = new Thread(new Runnable() { + int retry = 0; + boolean flag = true; + public void run() { + while (retry < 1000) { + LOGGER.info("init hibernateBundle.retry:" + retry); + retry++; + try { + bundle.runExt(configuration, environment); + } catch (Exception e1) { + flag = false; + LOGGER.warn( + "init hibernateBundle failed, sleep 15S and try again.errorMsg:" + e1.getMessage()); + threadSleep(15000); + } + if (flag) { + LOGGER.info("init hibernateBundle success!"); + initDao(); + break; + } + } + } + }); + thread.setName("init hibernateBundle"); + thread.start(); + } + + private void initDao() { + DaoManager.getInstance().setSessionFactory(bundle.getSessionFactory()); + } + + private void threadSleep(int second) { + LOGGER.info("start sleep ...."); + try { + Thread.sleep(second); + } catch (InterruptedException error) { + LOGGER.error("thread sleep error.errorMsg:" + error.getMessage()); + } + LOGGER.info("sleep end ."); + } + + @Override + public void initialize(Bootstrap bootstrap) { + bundle.initializeExt(bootstrap); + } +// +// public SessionFactory getSessionFactory() { +// return bundle.getSessionFactory(); +// } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleExt.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleExt.java new file mode 100644 index 0000000..3ec7732 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/hibernate/HibernateBundleExt.java @@ -0,0 +1,92 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.aai.esr.hibernate; + + +import com.google.common.collect.ImmutableList; + +import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module; +import io.dropwizard.db.DataSourceFactory; +import io.dropwizard.hibernate.HibernateBundle; +import io.dropwizard.hibernate.SessionFactoryFactory; +import io.dropwizard.setup.Bootstrap; +import io.dropwizard.setup.Environment; +import org.hibernate.SessionFactory; +import org.onap.aai.esr.ExtsysAppConfiguration; + + +public class HibernateBundleExt extends HibernateBundle { + + private static final String DEFAULT_NAME = "hibernate"; + + private SessionFactory sessionFactory; + + private final ImmutableList> entities; + private final SessionFactoryFactory sessionFactoryFactory; + + protected HibernateBundleExt(Class entity, Class... entities) { + this(ImmutableList.>builder().add(entity).add(entities).build(), + new SessionFactoryFactory()); + } + + protected HibernateBundleExt(ImmutableList> entities, + SessionFactoryFactory sessionFactoryFactory) { + super(entities, sessionFactoryFactory); + this.entities = entities; + this.sessionFactoryFactory = sessionFactoryFactory; + } + + public final void initializeExt(Bootstrap bootstrap) { + bootstrap.getObjectMapper().registerModule(createHibernate4Module()); + } + + /** + * Override to configure the {@link Hibernate4Module}. + */ + protected Hibernate4Module createHibernate4Module() { + return new Hibernate4Module(); + } + + protected String name() { + return DEFAULT_NAME; + } + + /** + * ext run function. + * @param configuration inventory configuration + * @param environment environment + * @throws Exception Exception + */ + public final void runExt(ExtsysAppConfiguration configuration, Environment environment) + throws Exception { + final DataSourceFactory dbConfig = getDataSourceFactory(configuration); + this.sessionFactory = + sessionFactoryFactory.build(this, environment, dbConfig, entities, name()); + + } + + public SessionFactory getSessionFactory() { + return sessionFactory; + } + + + @Override + public DataSourceFactory getDataSourceFactory(ExtsysAppConfiguration configuration) { + return configuration.getDataSourceFactory(); + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/CommonManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/CommonManager.java new file mode 100644 index 0000000..6fd3c64 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/CommonManager.java @@ -0,0 +1,124 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.resource; + +import com.codahale.metrics.annotation.Timed; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + +import org.eclipse.jetty.http.HttpStatus; +import org.onap.aai.esr.entity.db.BaseData; +import org.onap.aai.esr.entity.rest.BaseRestData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.handle.CommonHandler; +import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.RestResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/common") +@Api(tags = {" common Management "}) +public class CommonManager { + + CommonHandler handler = new CommonHandler(); + private static final Logger LOGGER = LoggerFactory.getLogger(CommonManager.class); + + /** + * query all exr instance. + */ + @Path("") + @GET + @ApiOperation(value = "get all instance ") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response queryInstanceList() { + LOGGER.info("start query all instance!"); + List list; + try { + list = handler.getAll(); + } catch (ExtsysException error) { + LOGGER.error("query all instance failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query all instance end.no match condition record"); + return RestResponseUtil.getSuccessResponse(new ArrayList()); + } else { + LOGGER.info("query all instance end.size:" + list.size()); + ArrayList restList = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + restList.add(new BaseRestData(list.get(i))); + } + return RestResponseUtil.getSuccessResponse(restList); + } + + } + + /** + * query exr instance by id. + */ + @Path("/{instanceId}") + @GET + @ApiOperation(value = "get instance by id") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response queryInstanceById( + @ApiParam(value = "instanceId") @PathParam("instanceId") String instanceId) { + LOGGER.info("start query instance by id." + instanceId); + List list; + try { + list = handler.getInstanceById(instanceId); + } catch (ExtsysException error) { + LOGGER.error("query instance failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query instance end.no match condition record"); + return RestResponseUtil.getSuccessResponse(null); + } else { + LOGGER.info("query ems end.info:" + ExtsysDbUtil.objectToString(list)); + return RestResponseUtil.getSuccessResponse(new BaseRestData(list.get(0))); + } + } + + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java new file mode 100644 index 0000000..37273b5 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java @@ -0,0 +1,210 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.resource; + +import com.codahale.metrics.annotation.Timed; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + +import org.eclipse.jetty.http.HttpStatus; +import org.onap.aai.esr.entity.db.EmsData; +import org.onap.aai.esr.entity.rest.EmsRestData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.handle.EmsHandler; +import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.RestResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/emses") +@Api(tags = {" ems Management "}) +public class EmsManager { + + EmsHandler handler = new EmsHandler(); + private static final Logger LOGGER = LoggerFactory.getLogger(EmsManager.class); + + /** + * query all ems. + */ + @Path("") + @GET + @ApiOperation(value = "get all ems ") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response queryEmsList() { + LOGGER.info("start query all ems!"); + List list; + try { + list = handler.getAll(); + } catch (ExtsysException error) { + LOGGER.error("query all ems failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query all ems end.no match condition record"); + return RestResponseUtil.getSuccessResponse(new ArrayList()); + } else { + LOGGER.info("query all ems end.size:" + list.size()); + ArrayList restList = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + restList.add(new EmsRestData(list.get(i))); + } + return RestResponseUtil.getSuccessResponse(restList); + } + + } + + /** + * query ems info by id. + */ + @Path("/{emsId}") + @GET + @ApiOperation(value = "get ems by id") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response queryemsById(@ApiParam(value = "ems id") @PathParam("emsId") String emsId) { + LOGGER.info("start query ems by id." + emsId); + List list; + try { + list = handler.getEmsById(emsId); + } catch (ExtsysException error) { + LOGGER.error("query ems failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query ems end.no match condition record"); + return RestResponseUtil.getSuccessResponse(null); + } else { + LOGGER.info("query ems end.info:" + ExtsysDbUtil.objectToString(list)); + return RestResponseUtil.getSuccessResponse(new EmsRestData(list.get(0))); + } + } + + /** + * delete ems by id. + */ + @Path("/{emsId}") + @DELETE + @ApiOperation(value = "delete a ems") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response delems(@ApiParam(value = "ems id") @PathParam("emsId") String emsId) { + LOGGER.info("start delete ems .id:" + emsId); + try { + handler.delete(emsId); + } catch (ExtsysException error) { + LOGGER.error("delete ems failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" delete ems end !"); + return Response.noContent().build(); + } + + /** + * update ems by id. + */ + @PUT + @Path("/{emsId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) + @ApiOperation(value = "update a ems") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response updateemss(@ApiParam(value = "ems", required = true) EmsData ems, + @ApiParam(value = "ems id", required = true) @PathParam("emsId") String emsId) { + LOGGER.info("start update ems .id:" + emsId + " info:" + ExtsysDbUtil.objectToString(ems)); + EmsData newData; + try { + newData = handler.update(ems, emsId); + } catch (ExtsysException error) { + LOGGER.error("update ems failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" update ems end !"); + return RestResponseUtil.getSuccessResponse(new EmsRestData(newData)); + } + + /** + * add ems. + */ + @POST + @Path("") + @Consumes(MediaType.APPLICATION_JSON) + @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) + @ApiOperation(value = "create a ems") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response addemss(@ApiParam(value = "ems", required = true) EmsData ems) { + LOGGER.info("start add ems" + " info:" + ExtsysDbUtil.objectToString(ems)); + EmsData emsData; + try { + emsData = handler.add(ems); + } catch (ExtsysException error) { + LOGGER.error("add ems failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" add ems end !"); + return RestResponseUtil.getCreateSussceeResponse(new EmsRestData(emsData)); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/SdncManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/SdncManager.java new file mode 100644 index 0000000..770cf5c --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/SdncManager.java @@ -0,0 +1,210 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.resource; + +import com.codahale.metrics.annotation.Timed; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + +import org.eclipse.jetty.http.HttpStatus; +import org.onap.aai.esr.entity.db.SdncData; +import org.onap.aai.esr.entity.rest.SdncRestData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.handle.SdncHandler; +import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.RestResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/sdncontrollers") +@Api(tags = {" sdnc Management "}) +public class SdncManager { + + SdncHandler handler = new SdncHandler(); + private static final Logger LOGGER = LoggerFactory.getLogger(SdncManager.class); + + /** + *query all sdnc. + */ + @Path("") + @GET + @ApiOperation(value = "get all sdnc ") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response querysdncList() { + LOGGER.info("start query all sdnc!"); + List list; + try { + list = handler.getAll(); + } catch (ExtsysException error) { + LOGGER.error("query all sdnc failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query all sdnc end.no match condition record"); + return RestResponseUtil.getSuccessResponse(new ArrayList()); + } else { + LOGGER.info("query all sdnc end.size:" + list.size()); + ArrayList restList = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + restList.add(new SdncRestData(list.get(i))); + } + return RestResponseUtil.getSuccessResponse(restList); + } + + } + + /** + *query sdnc by id. + */ + @Path("/{sdncId}") + @GET + @ApiOperation(value = "get sdnc by id") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response querysdncById(@ApiParam(value = "sdnc id") @PathParam("sdncId") String sdncId) { + LOGGER.info("start query sdnc by id." + sdncId); + List list; + try { + list = handler.getSdncById(sdncId); + } catch (ExtsysException error) { + LOGGER.error("query sdnc failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query sdnc end.no match condition record"); + return RestResponseUtil.getSuccessResponse(null); + } else { + LOGGER.info("query sdnc end.info:" + ExtsysDbUtil.objectToString(list)); + return RestResponseUtil.getSuccessResponse(new SdncRestData(list.get(0))); + } + } + + /** + *delete sdnc by id. + */ + @Path("/{sdncId}") + @DELETE + @ApiOperation(value = "delete a sdnc") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response delsdnc(@ApiParam(value = "sdnc id") @PathParam("sdncId") String sdncId) { + LOGGER.info("start delete sdnc .id:" + sdncId); + try { + handler.delete(sdncId); + } catch (ExtsysException error) { + LOGGER.error("delete sdnc failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" delete sdnc end !"); + return Response.noContent().build(); + } + + /** + *update sdnc by id. + */ + @PUT + @Path("/{sdncId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) + @ApiOperation(value = "update a sdnc") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response updatesdncs(@ApiParam(value = "sdnc", required = true) SdncData sdnc, + @ApiParam(value = "sdnc id", required = true) @PathParam("sdncId") String sdncId) { + LOGGER.info("start update sdnc .id:" + sdncId + " info:" + ExtsysDbUtil.objectToString(sdnc)); + SdncData newData; + try { + newData = handler.update(sdnc, sdncId); + } catch (ExtsysException error) { + LOGGER.error("update sdnc failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" update sdnc end !"); + return RestResponseUtil.getSuccessResponse(new SdncRestData(newData)); + } + + /** + *add sdnc. + */ + @POST + @Path("") + @Consumes(MediaType.APPLICATION_JSON) + @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) + @ApiOperation(value = "create a sdnc") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response addsdncs(@ApiParam(value = "sdnc", required = true) SdncData sdnc) { + LOGGER.info("start add sdnc" + " info:" + ExtsysDbUtil.objectToString(sdnc)); + SdncData sdncData; + try { + sdncData = handler.add(sdnc); + } catch (ExtsysException error) { + LOGGER.error("add sdnc failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" add sdnc end !"); + return RestResponseUtil.getCreateSussceeResponse(new SdncRestData(sdncData)); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java new file mode 100644 index 0000000..1103fb4 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java @@ -0,0 +1,209 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.resource; + +import com.codahale.metrics.annotation.Timed; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import org.eclipse.jetty.http.HttpStatus; +import org.onap.aai.esr.entity.db.VimData; +import org.onap.aai.esr.entity.rest.VimRestData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.handle.VimHandler; +import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.RestResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/vims") +@Api(tags = {" vim Management "}) +public class VimManager { + + VimHandler handler = new VimHandler(); + private static final Logger LOGGER = LoggerFactory.getLogger(VimManager.class); + + /** + * query all ems. + */ + @Path("") + @GET + @ApiOperation(value = "get all vim ") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response queryvimList() { + LOGGER.info("start query all vim!"); + List list; + try { + list = handler.getAll(); + } catch (ExtsysException error) { + LOGGER.error("query all vim failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query all vim end.no match condition record"); + return RestResponseUtil.getSuccessResponse(new ArrayList()); + } else { + LOGGER.info("query all vim end.size:" + list.size()); + ArrayList restList = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + restList.add(new VimRestData(list.get(i))); + } + return RestResponseUtil.getSuccessResponse(restList); + } + + } + + /** + * query vim by id. + */ + @Path("/{vimId}") + @GET + @ApiOperation(value = "get vim by id") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response queryvimById(@ApiParam(value = "vim id") @PathParam("vimId") String vimId) { + LOGGER.info("start query vim by id." + vimId); + List list; + try { + list = handler.getVimById(vimId); + } catch (ExtsysException error) { + LOGGER.error("query vim failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query vim end.no match condition record"); + return RestResponseUtil.getSuccessResponse(null); + } else { + LOGGER.info("query vim end.info:" + ExtsysDbUtil.objectToString(list)); + return RestResponseUtil.getSuccessResponse(new VimRestData(list.get(0))); + } + } + + /** + * delete vim by id. + */ + @Path("/{vimId}") + @DELETE + @ApiOperation(value = "delete a vim") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response delvim(@ApiParam(value = "vim id") @PathParam("vimId") String vimId) { + LOGGER.info("start delete vim .id:" + vimId); + try { + handler.delete(vimId); + } catch (ExtsysException error) { + LOGGER.error("delete vim failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" delete vim end !"); + return Response.noContent().build(); + } + + /** + * update vim by id. + */ + @PUT + @Path("/{vimId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "update a vim") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response updatevims(@ApiParam(value = "vim", required = true) VimData vim, + @ApiParam(value = "vim id", required = true) @PathParam("vimId") String vimId) { + LOGGER.info("start update vim .id:" + vimId + " info:" + ExtsysDbUtil.objectToString(vim)); + VimData newData; + try { + newData = handler.update(vim, vimId); + } catch (ExtsysException error) { + LOGGER.error("update vim failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" update vim end !"); + return RestResponseUtil.getSuccessResponse(new VimRestData(newData)); + } + + /** + * add vim . + */ + @POST + @Path("") + @Consumes(MediaType.APPLICATION_JSON) + @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) + @ApiOperation(value = "create a vim") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response addvims(@ApiParam(value = "vim", required = true) VimData vim) { + LOGGER.info("start add vim" + " info:" + ExtsysDbUtil.objectToString(vim)); + VimData vimData; + try { + vimData = handler.add(vim); + } catch (ExtsysException error) { + LOGGER.error("add vim failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" add vim end !"); + return RestResponseUtil.getCreateSussceeResponse(new VimRestData(vimData)); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java new file mode 100644 index 0000000..65e74cb --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/resource/VnfmManager.java @@ -0,0 +1,209 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.resource; + +import com.codahale.metrics.annotation.Timed; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import org.eclipse.jetty.http.HttpStatus; +import org.onap.aai.esr.entity.db.VnfmData; +import org.onap.aai.esr.entity.rest.VnfmRestData; +import org.onap.aai.esr.exception.ExtsysException; +import org.onap.aai.esr.handle.VnfmHandler; +import org.onap.aai.esr.util.ExtsysDbUtil; +import org.onap.aai.esr.util.RestResponseUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +@Path("/vnfms") +@Api(tags = {" vnfm Management "}) +public class VnfmManager { + + VnfmHandler handler = new VnfmHandler(); + private static final Logger LOGGER = LoggerFactory.getLogger(VnfmManager.class); + + /** + * query all vnfm. + */ + @Path("") + @GET + @ApiOperation(value = "get all vnfm ") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response queryVnfmList() { + LOGGER.info("start query all vnfm!"); + List list; + try { + list = handler.getAll(); + } catch (ExtsysException error) { + LOGGER.error("query all vnfm failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query all vnfm end.no match condition record"); + return RestResponseUtil.getSuccessResponse(new ArrayList()); + } else { + LOGGER.info("query all vnfm end.size:" + list.size()); + ArrayList restList = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + restList.add(new VnfmRestData(list.get(i))); + } + return RestResponseUtil.getSuccessResponse(restList); + } + + } + + /** + * query vnfm by id. + */ + @Path("/{vnfmId}") + @GET + @ApiOperation(value = "get vnfm by id") + @Produces(MediaType.APPLICATION_JSON) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response queryVnfmById(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) { + LOGGER.info("start query vnfm by id." + vnfmId); + List list; + try { + list = handler.getVnfmById(vnfmId); + } catch (ExtsysException error) { + LOGGER.error("query vnfm failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + if (list == null || list.size() <= 0) { + LOGGER.info("query vnfm end.no match condition record"); + return RestResponseUtil.getSuccessResponse(null); + } else { + LOGGER.info("query vnfm end.info:" + ExtsysDbUtil.objectToString(list)); + return RestResponseUtil.getSuccessResponse(new VnfmRestData(list.get(0))); + } + } + + /** + * delete vnfm by id. + */ + @Path("/{vnfmId}") + @DELETE + @ApiOperation(value = "delete a vnfm") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response delVnfm(@ApiParam(value = "vnfm id") @PathParam("vnfmId") String vnfmId) { + LOGGER.info("start delete vnfm .id:" + vnfmId); + try { + handler.delete(vnfmId); + } catch (ExtsysException error) { + LOGGER.error("delete vnfm failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" delete vnfm end !"); + return Response.noContent().build(); + } + + /** + * update vnfm by id. + */ + @PUT + @Path("/{vnfmId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) + @ApiOperation(value = "update a vnfm") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response updateVnfms(@ApiParam(value = "vnfm", required = true) VnfmData vnfm, + @ApiParam(value = "vnfm id", required = true) @PathParam("vnfmId") String vnfmId) { + LOGGER.info("start update vnfm .id:" + vnfmId + " info:" + ExtsysDbUtil.objectToString(vnfm)); + VnfmData newData; + try { + newData = handler.update(vnfm, vnfmId); + } catch (ExtsysException error) { + LOGGER.error("update vnfm failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" update vnfm end !"); + return RestResponseUtil.getSuccessResponse(new VnfmRestData(newData)); + } + + /** + * add vnfm . + */ + @POST + @Path("") + @Consumes(MediaType.APPLICATION_JSON) + @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON}) + @ApiOperation(value = "create a vnfm") + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", + response = String.class), + @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415, + message = "Unprocessable MicroServiceInfo Entity ", response = String.class), + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error", + response = String.class)}) + @Timed + public Response addVnfms(@ApiParam(value = "vnfm", required = true) VnfmData vnfm) { + LOGGER.info("start add vnfm" + " info:" + ExtsysDbUtil.objectToString(vnfm)); + VnfmData vnfmData; + try { + vnfmData = handler.add(vnfm); + } catch (ExtsysException error) { + LOGGER.error("add vnfm failed.errorMsg:" + error.getErrorMsg()); + return RestResponseUtil.getErrorResponse(error); + } + LOGGER.info(" add vnfm end !"); + return RestResponseUtil.getCreateSussceeResponse(new VnfmRestData(vnfmData)); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysDbUtil.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysDbUtil.java new file mode 100644 index 0000000..f87eb22 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysDbUtil.java @@ -0,0 +1,54 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.util; + +import com.google.gson.Gson; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.UUID; + +public class ExtsysDbUtil { + private final static Logger logger = LoggerFactory.getLogger(ExtsysDbUtil.class); + + public static String generateId() { + return UUID.randomUUID().toString(); + } + + public static boolean isNotEmpty(String str) { + return str != null && !"".equals(str) && str.length() > 0; + } + + /** + * change object to str. + */ + public static String objectToString(Object obj) { + Gson gson = new Gson(); + if (obj != null) { + return gson.toJson(obj); + } else { + return null; + } + } + + public static String getNowTime() { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return sdf.format(new Date()); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/HqlFactory.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/HqlFactory.java new file mode 100644 index 0000000..cff09e2 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/HqlFactory.java @@ -0,0 +1,164 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Arrays; + +public class HqlFactory { + + private static final Logger logger = LoggerFactory.getLogger(HqlFactory.class); + + /** + * get update hql. + * @param obj the object that used to be generate the hql + * @param excludeProperties the properties that need not to be used + * @param filter the condition after "where" + * @return hibernate hql + */ + public static String getUpdateHql(Object obj, String[] excludeProperties, String filter) { + StringBuffer hql = new StringBuffer(); + String objName = obj.getClass().getSimpleName(); + hql.append("update "); + hql.append(objName); + hql.append(" set "); + Field[] fields = obj.getClass().getDeclaredFields(); + if (obj.getClass().getGenericSuperclass() != null) { + Field[] parentFields = obj.getClass().getSuperclass().getDeclaredFields(); + fields = concat(fields, parentFields); + } + for (Field field : fields) { + String name = field.getName(); + Method method = null; + Object value = null; + if (!contain(excludeProperties, name)) { + String upperName = name.substring(0, 1).toUpperCase() + name.substring(1); + try { + method = obj.getClass().getMethod("get" + upperName); + value = method.invoke(obj); + if (value != null) { + if (value instanceof String) { + hql.append(name); + hql.append("="); + hql.append("'"); + hql.append(value); + hql.append("'"); + hql.append(","); + } else { + hql.append(name); + hql.append("="); + hql.append(value); + hql.append(","); + } + } + } catch (Exception error) { + logger.error("error while creating update hql", error); + } + } + } + + String sql = hql.toString(); + sql = sql.substring(0, sql.lastIndexOf(",")); + if (filter != null) { + sql = sql + " where " + filter; + } + logger.info("update hql is : " + sql); + return sql; + } + + /** + * identify whether or not to include target string in source string. + */ + public static boolean contain(String[] src, String target) { + if (src == null || src.length == 0 || target == null) { + return false; + } else { + for (String str : src) { + if (str.equals(target)) { + return true; + } + } + } + return false; + } + + /** + * concat str. + */ + public static T[] concat(T[] first, T[] second) { + T[] result = Arrays.copyOf(first, first.length + second.length); + System.arraycopy(second, 0, result, first.length, second.length); + return result; + } + + public static String getOidFilter(String key, String value) { + return key + "= '" + value + "'"; + } + + /** + * get query hql. + */ + public static String getQueryHql(Object data, String column) { + StringBuffer hql = new StringBuffer(); + String objName = data.getClass().getSimpleName(); + hql.append("select q."); + hql.append(column); + hql.append(" from "); + hql.append(objName); + hql.append(" as q where "); + Field[] fields = data.getClass().getDeclaredFields(); + if (data.getClass().getGenericSuperclass() != null) { + Field[] parentFields = data.getClass().getSuperclass().getDeclaredFields(); + fields = concat(fields, parentFields); + } + for (Field field : fields) { + String name = field.getName(); + Method method = null; + Object value = null; + String upperName = name.substring(0, 1).toUpperCase() + name.substring(1); + try { + method = data.getClass().getMethod("get" + upperName); + value = method.invoke(data); + if (value != null) { + if (value instanceof String) { + hql.append("q." + name); + hql.append("="); + hql.append("'"); + hql.append(value); + hql.append("'"); + hql.append(" and "); + } else { + hql.append("q." + name); + hql.append("="); + hql.append(value); + hql.append("and "); + } + } + } catch (Exception e) { + logger.error("error while creating update hql", e); + } + } + String sql = hql.toString(); + sql = sql.substring(0, sql.lastIndexOf("and")); + + logger.info("query hql is : " + sql); + return sql.trim(); + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/RestResponseUtil.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/RestResponseUtil.java new file mode 100644 index 0000000..8bcd7ee --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/util/RestResponseUtil.java @@ -0,0 +1,49 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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.aai.esr.util; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; + +public class RestResponseUtil { + + /** + * get http success entity. + */ + public static Response getSuccessResponse(Object obj) { + if (obj != null) { + return Response.ok(obj).build(); + } else { + return Response.ok().build(); + } + } + + public static Response getCreateSussceeResponse(Object obj) { + return Response.status(Status.CREATED).entity(obj).build(); + } + + /** + * get http error entity. + */ + public static Response getErrorResponse(Object obj) { + if (obj != null) { + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(obj).build(); + } else { + return Response.serverError().build(); + } + + } +} diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/META-INF/MANIFEST.MF b/esr-core/esr-mgr/src/main/resources/api-doc/META-INF/MANIFEST.MF new file mode 100644 index 0000000..eaf90a9 --- /dev/null +++ b/esr-core/esr-mgr/src/main/resources/api-doc/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Created-By: 1.7.0_72 (Oracle Corporation) + diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/WEB-INF/web.xml b/esr-core/esr-mgr/src/main/resources/api-doc/WEB-INF/web.xml new file mode 100644 index 0000000..2a5346c --- /dev/null +++ b/esr-core/esr-mgr/src/main/resources/api-doc/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + + ZENAP API-DOC. + + ZENAP API-DOC + + + + + index.html + index.xhtml + index.htm + index.jsp + + + + diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/css/reset.css b/esr-core/esr-mgr/src/main/resources/api-doc/css/reset.css new file mode 100644 index 0000000..2e11612 --- /dev/null +++ b/esr-core/esr-mgr/src/main/resources/api-doc/css/reset.css @@ -0,0 +1,140 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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. + */ +/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */ +html, +body, +div, +span, +applet, +object, +iframe, +h1, +h2, +h3, +h4, +h5, +h6, +p, +blockquote, +pre, +a, +abbr, +acronym, +address, +big, +cite, +code, +del, +dfn, +em, +img, +ins, +kbd, +q, +s, +samp, +small, +strike, +strong, +sub, +sup, +tt, +var, +b, +u, +i, +center, +dl, +dt, +dd, +ol, +ul, +li, +fieldset, +form, +label, +legend, +table, +caption, +tbody, +tfoot, +thead, +tr, +th, +td, +article, +aside, +canvas, +details, +embed, +figure, +figcaption, +footer, +header, +hgroup, +menu, +nav, +output, +ruby, +section, +summary, +time, +mark, +audio, +video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +menu, +nav, +section { + display: block; +} +body { + line-height: 1; +} +ol, +ul { + list-style: none; +} +blockquote, +q { + quotes: none; +} +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/css/screen.css b/esr-core/esr-mgr/src/main/resources/api-doc/css/screen.css new file mode 100644 index 0000000..2b982c2 --- /dev/null +++ b/esr-core/esr-mgr/src/main/resources/api-doc/css/screen.css @@ -0,0 +1,1271 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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. + */ +/* Original style from softwaremaniacs.org (c) Ivan Sagalaev */ +.swagger-section pre code { + display: block; + padding: 0.5em; + background: #F0F0F0; +} +.swagger-section pre code, +.swagger-section pre .subst, +.swagger-section pre .tag .title, +.swagger-section pre .lisp .title, +.swagger-section pre .clojure .built_in, +.swagger-section pre .nginx .title { + color: black; +} +.swagger-section pre .string, +.swagger-section pre .title, +.swagger-section pre .constant, +.swagger-section pre .parent, +.swagger-section pre .tag .value, +.swagger-section pre .rules .value, +.swagger-section pre .rules .value .number, +.swagger-section pre .preprocessor, +.swagger-section pre .ruby .symbol, +.swagger-section pre .ruby .symbol .string, +.swagger-section pre .aggregate, +.swagger-section pre .template_tag, +.swagger-section pre .django .variable, +.swagger-section pre .smalltalk .class, +.swagger-section pre .addition, +.swagger-section pre .flow, +.swagger-section pre .stream, +.swagger-section pre .bash .variable, +.swagger-section pre .apache .tag, +.swagger-section pre .apache .cbracket, +.swagger-section pre .tex .command, +.swagger-section pre .tex .special, +.swagger-section pre .erlang_repl .function_or_atom, +.swagger-section pre .markdown .header { + color: #800; +} +.swagger-section pre .comment, +.swagger-section pre .annotation, +.swagger-section pre .template_comment, +.swagger-section pre .diff .header, +.swagger-section pre .chunk, +.swagger-section pre .markdown .blockquote { + color: #888; +} +.swagger-section pre .number, +.swagger-section pre .date, +.swagger-section pre .regexp, +.swagger-section pre .literal, +.swagger-section pre .smalltalk .symbol, +.swagger-section pre .smalltalk .char, +.swagger-section pre .go .constant, +.swagger-section pre .change, +.swagger-section pre .markdown .bullet, +.swagger-section pre .markdown .link_url { + color: #080; +} +.swagger-section pre .label, +.swagger-section pre .javadoc, +.swagger-section pre .ruby .string, +.swagger-section pre .decorator, +.swagger-section pre .filter .argument, +.swagger-section pre .localvars, +.swagger-section pre .array, +.swagger-section pre .attr_selector, +.swagger-section pre .important, +.swagger-section pre .pseudo, +.swagger-section pre .pi, +.swagger-section pre .doctype, +.swagger-section pre .deletion, +.swagger-section pre .envvar, +.swagger-section pre .shebang, +.swagger-section pre .apache .sqbracket, +.swagger-section pre .nginx .built_in, +.swagger-section pre .tex .formula, +.swagger-section pre .erlang_repl .reserved, +.swagger-section pre .prompt, +.swagger-section pre .markdown .link_label, +.swagger-section pre .vhdl .attribute, +.swagger-section pre .clojure .attribute, +.swagger-section pre .coffeescript .property { + color: #8888ff; +} +.swagger-section pre .keyword, +.swagger-section pre .id, +.swagger-section pre .phpdoc, +.swagger-section pre .title, +.swagger-section pre .built_in, +.swagger-section pre .aggregate, +.swagger-section pre .css .tag, +.swagger-section pre .javadoctag, +.swagger-section pre .phpdoc, +.swagger-section pre .yardoctag, +.swagger-section pre .smalltalk .class, +.swagger-section pre .winutils, +.swagger-section pre .bash .variable, +.swagger-section pre .apache .tag, +.swagger-section pre .go .typename, +.swagger-section pre .tex .command, +.swagger-section pre .markdown .strong, +.swagger-section pre .request, +.swagger-section pre .status { + font-weight: bold; +} +.swagger-section pre .markdown .emphasis { + font-style: italic; +} +.swagger-section pre .nginx .built_in { + font-weight: normal; +} +.swagger-section pre .coffeescript .javascript, +.swagger-section pre .javascript .xml, +.swagger-section pre .tex .formula, +.swagger-section pre .xml .javascript, +.swagger-section pre .xml .vbscript, +.swagger-section pre .xml .css, +.swagger-section pre .xml .cdata { + opacity: 0.5; +} +.swagger-section .swagger-ui-wrap { + line-height: 1; + font-family: "Droid Sans", sans-serif; + max-width: 960px; + margin-left: auto; + margin-right: auto; +} +.swagger-section .swagger-ui-wrap b, +.swagger-section .swagger-ui-wrap strong { + font-family: "Droid Sans", sans-serif; + font-weight: bold; +} +.swagger-section .swagger-ui-wrap q, +.swagger-section .swagger-ui-wrap blockquote { + quotes: none; +} +.swagger-section .swagger-ui-wrap p { + line-height: 1.4em; + padding: 0 0 10px; + color: #333333; +} +.swagger-section .swagger-ui-wrap q:before, +.swagger-section .swagger-ui-wrap q:after, +.swagger-section .swagger-ui-wrap blockquote:before, +.swagger-section .swagger-ui-wrap blockquote:after { + content: none; +} +.swagger-section .swagger-ui-wrap .heading_with_menu h1, +.swagger-section .swagger-ui-wrap .heading_with_menu h2, +.swagger-section .swagger-ui-wrap .heading_with_menu h3, +.swagger-section .swagger-ui-wrap .heading_with_menu h4, +.swagger-section .swagger-ui-wrap .heading_with_menu h5, +.swagger-section .swagger-ui-wrap .heading_with_menu h6 { + display: block; + clear: none; + float: left; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + width: 60%; +} +.swagger-section .swagger-ui-wrap table { + border-collapse: collapse; + border-spacing: 0; +} +.swagger-section .swagger-ui-wrap table thead tr th { + padding: 5px; + font-size: 0.9em; + color: #666666; + border-bottom: 1px solid #999999; +} +.swagger-section .swagger-ui-wrap table tbody tr:last-child td { + border-bottom: none; +} +.swagger-section .swagger-ui-wrap table tbody tr.offset { + background-color: #f0f0f0; +} +.swagger-section .swagger-ui-wrap table tbody tr td { + padding: 6px; + font-size: 0.9em; + border-bottom: 1px solid #cccccc; + vertical-align: top; + line-height: 1.3em; +} +.swagger-section .swagger-ui-wrap ol { + margin: 0px 0 10px; + padding: 0 0 0 18px; + list-style-type: decimal; +} +.swagger-section .swagger-ui-wrap ol li { + padding: 5px 0px; + font-size: 0.9em; + color: #333333; +} +.swagger-section .swagger-ui-wrap ol, +.swagger-section .swagger-ui-wrap ul { + list-style: none; +} +.swagger-section .swagger-ui-wrap h1 a, +.swagger-section .swagger-ui-wrap h2 a, +.swagger-section .swagger-ui-wrap h3 a, +.swagger-section .swagger-ui-wrap h4 a, +.swagger-section .swagger-ui-wrap h5 a, +.swagger-section .swagger-ui-wrap h6 a { + text-decoration: none; +} +.swagger-section .swagger-ui-wrap h1 a:hover, +.swagger-section .swagger-ui-wrap h2 a:hover, +.swagger-section .swagger-ui-wrap h3 a:hover, +.swagger-section .swagger-ui-wrap h4 a:hover, +.swagger-section .swagger-ui-wrap h5 a:hover, +.swagger-section .swagger-ui-wrap h6 a:hover { + text-decoration: underline; +} +.swagger-section .swagger-ui-wrap h1 span.divider, +.swagger-section .swagger-ui-wrap h2 span.divider, +.swagger-section .swagger-ui-wrap h3 span.divider, +.swagger-section .swagger-ui-wrap h4 span.divider, +.swagger-section .swagger-ui-wrap h5 span.divider, +.swagger-section .swagger-ui-wrap h6 span.divider { + color: #aaaaaa; +} +.swagger-section .swagger-ui-wrap a { + color: #547f00; +} +.swagger-section .swagger-ui-wrap a img { + border: none; +} +.swagger-section .swagger-ui-wrap article, +.swagger-section .swagger-ui-wrap aside, +.swagger-section .swagger-ui-wrap details, +.swagger-section .swagger-ui-wrap figcaption, +.swagger-section .swagger-ui-wrap figure, +.swagger-section .swagger-ui-wrap footer, +.swagger-section .swagger-ui-wrap header, +.swagger-section .swagger-ui-wrap hgroup, +.swagger-section .swagger-ui-wrap menu, +.swagger-section .swagger-ui-wrap nav, +.swagger-section .swagger-ui-wrap section, +.swagger-section .swagger-ui-wrap summary { + display: block; +} +.swagger-section .swagger-ui-wrap pre { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; + background-color: #fcf6db; + border: 1px solid #e5e0c6; + padding: 10px; +} +.swagger-section .swagger-ui-wrap pre code { + line-height: 1.6em; + background: none; +} +.swagger-section .swagger-ui-wrap .content > .content-type > div > label { + clear: both; + display: block; + color: #0F6AB4; + font-size: 1.1em; + margin: 0; + padding: 15px 0 5px; +} +.swagger-section .swagger-ui-wrap .content pre { + font-size: 12px; + margin-top: 5px; + padding: 5px; +} +.swagger-section .swagger-ui-wrap .icon-btn { + cursor: pointer; +} +.swagger-section .swagger-ui-wrap .info_title { + padding-bottom: 10px; + font-weight: bold; + font-size: 25px; +} +.swagger-section .swagger-ui-wrap p.big, +.swagger-section .swagger-ui-wrap div.big p { + font-size: 1em; + margin-bottom: 10px; +} +.swagger-section .swagger-ui-wrap form.fullwidth ol li.string input, +.swagger-section .swagger-ui-wrap form.fullwidth ol li.url input, +.swagger-section .swagger-ui-wrap form.fullwidth ol li.text textarea, +.swagger-section .swagger-ui-wrap form.fullwidth ol li.numeric input { + width: 500px !important; +} +.swagger-section .swagger-ui-wrap .info_license { + padding-bottom: 5px; +} +.swagger-section .swagger-ui-wrap .info_tos { + padding-bottom: 5px; +} +.swagger-section .swagger-ui-wrap .message-fail { + color: #cc0000; +} +.swagger-section .swagger-ui-wrap .info_url { + padding-bottom: 5px; +} +.swagger-section .swagger-ui-wrap .info_email { + padding-bottom: 5px; +} +.swagger-section .swagger-ui-wrap .info_name { + padding-bottom: 5px; +} +.swagger-section .swagger-ui-wrap .info_description { + padding-bottom: 10px; + font-size: 15px; +} +.swagger-section .swagger-ui-wrap .markdown ol li, +.swagger-section .swagger-ui-wrap .markdown ul li { + padding: 3px 0px; + line-height: 1.4em; + color: #333333; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input, +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input, +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input { + display: block; + padding: 4px; + width: auto; + clear: both; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input.title, +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input.title, +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input.title { + font-size: 1.3em; +} +.swagger-section .swagger-ui-wrap table.fullwidth { + width: 100%; +} +.swagger-section .swagger-ui-wrap .model-signature { + font-family: "Droid Sans", sans-serif; + font-size: 1em; + line-height: 1.5em; +} +.swagger-section .swagger-ui-wrap .model-signature .signature-nav a { + text-decoration: none; + color: #AAA; +} +.swagger-section .swagger-ui-wrap .model-signature .signature-nav a:hover { + text-decoration: underline; + color: black; +} +.swagger-section .swagger-ui-wrap .model-signature .signature-nav .selected { + color: black; + text-decoration: none; +} +.swagger-section .swagger-ui-wrap .model-signature .propType { + color: #5555aa; +} +.swagger-section .swagger-ui-wrap .model-signature pre:hover { + background-color: #ffffdd; +} +.swagger-section .swagger-ui-wrap .model-signature pre { + font-size: .85em; + line-height: 1.2em; + overflow: auto; + max-height: 200px; + cursor: pointer; +} +.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav { + display: block; + margin: 0; + padding: 0; +} +.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav li:last-child { + padding-right: 0; + border-right: none; +} +.swagger-section .swagger-ui-wrap .model-signature ul.signature-nav li { + float: left; + margin: 0 5px 5px 0; + padding: 2px 5px 2px 0; + border-right: 1px solid #ddd; +} +.swagger-section .swagger-ui-wrap .model-signature .propOpt { + color: #555; +} +.swagger-section .swagger-ui-wrap .model-signature .snippet small { + font-size: 0.75em; +} +.swagger-section .swagger-ui-wrap .model-signature .propOptKey { + font-style: italic; +} +.swagger-section .swagger-ui-wrap .model-signature .description .strong { + font-weight: bold; + color: #000; + font-size: .9em; +} +.swagger-section .swagger-ui-wrap .model-signature .description div { + font-size: 0.9em; + line-height: 1.5em; + margin-left: 1em; +} +.swagger-section .swagger-ui-wrap .model-signature .description .stronger { + font-weight: bold; + color: #000; +} +.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper { + border-spacing: 0; + position: absolute; + background-color: #ffffff; + border: 1px solid #bbbbbb; + display: none; + font-size: 11px; + max-width: 400px; + line-height: 30px; + color: black; + padding: 5px; + margin-left: 10px; +} +.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper th { + text-align: center; + background-color: #eeeeee; + border: 1px solid #bbbbbb; + font-size: 11px; + color: #666666; + font-weight: bold; + padding: 5px; + line-height: 15px; +} +.swagger-section .swagger-ui-wrap .model-signature .description .propWrap .optionsWrapper .optionName { + font-weight: bold; +} +.swagger-section .swagger-ui-wrap .model-signature .propName { + font-weight: bold; +} +.swagger-section .swagger-ui-wrap .model-signature .signature-container { + clear: both; +} +.swagger-section .swagger-ui-wrap .body-textarea { + width: 300px; + height: 100px; + border: 1px solid #aaa; +} +.swagger-section .swagger-ui-wrap .markdown p code, +.swagger-section .swagger-ui-wrap .markdown li code { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; + background-color: #f0f0f0; + color: black; + padding: 1px 3px; +} +.swagger-section .swagger-ui-wrap .required { + font-weight: bold; +} +.swagger-section .swagger-ui-wrap input.parameter { + width: 300px; + border: 1px solid #aaa; +} +.swagger-section .swagger-ui-wrap h1 { + color: black; + font-size: 1.5em; + line-height: 1.3em; + padding: 10px 0 10px 0; + font-family: "Droid Sans", sans-serif; + font-weight: bold; +} +.swagger-section .swagger-ui-wrap .heading_with_menu { + float: none; + clear: both; + overflow: hidden; + display: block; +} +.swagger-section .swagger-ui-wrap .heading_with_menu ul { + display: block; + clear: none; + float: right; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + margin-top: 10px; +} +.swagger-section .swagger-ui-wrap h2 { + color: black; + font-size: 1.3em; + padding: 10px 0 10px 0; +} +.swagger-section .swagger-ui-wrap h2 a { + color: black; +} +.swagger-section .swagger-ui-wrap h2 span.sub { + font-size: 0.7em; + color: #999999; + font-style: italic; +} +.swagger-section .swagger-ui-wrap h2 span.sub a { + color: #777777; +} +.swagger-section .swagger-ui-wrap span.weak { + color: #666666; +} +.swagger-section .swagger-ui-wrap .message-success { + color: #89BF04; +} +.swagger-section .swagger-ui-wrap caption, +.swagger-section .swagger-ui-wrap th, +.swagger-section .swagger-ui-wrap td { + text-align: left; + font-weight: normal; + vertical-align: middle; +} +.swagger-section .swagger-ui-wrap .code { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.text textarea { + font-family: "Droid Sans", sans-serif; + height: 250px; + padding: 4px; + display: block; + clear: both; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.select select { + display: block; + clear: both; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean { + float: none; + clear: both; + overflow: hidden; + display: block; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean label { + display: block; + float: left; + clear: none; + margin: 0; + padding: 0; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean input { + display: block; + float: left; + clear: none; + margin: 0 5px 0 0; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li.required label { + color: black; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li label { + display: block; + clear: both; + width: auto; + padding: 0 0 3px; + color: #666666; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li label abbr { + padding-left: 3px; + color: #888888; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.inputs ol li p.inline-hints { + margin-left: 0; + font-style: italic; + font-size: 0.9em; + margin: 0; +} +.swagger-section .swagger-ui-wrap form.formtastic fieldset.buttons { + margin: 0; + padding: 0; +} +.swagger-section .swagger-ui-wrap span.blank, +.swagger-section .swagger-ui-wrap span.empty { + color: #888888; + font-style: italic; +} +.swagger-section .swagger-ui-wrap .markdown h3 { + color: #547f00; +} +.swagger-section .swagger-ui-wrap .markdown h4 { + color: #666666; +} +.swagger-section .swagger-ui-wrap .markdown pre { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; + background-color: #fcf6db; + border: 1px solid #e5e0c6; + padding: 10px; + margin: 0 0 10px 0; +} +.swagger-section .swagger-ui-wrap .markdown pre code { + line-height: 1.6em; +} +.swagger-section .swagger-ui-wrap div.gist { + margin: 20px 0 25px 0 !important; +} +.swagger-section .swagger-ui-wrap ul#resources { + font-family: "Droid Sans", sans-serif; + font-size: 0.9em; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource { + border-bottom: 1px solid #dddddd; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource:hover div.heading h2 a, +.swagger-section .swagger-ui-wrap ul#resources li.resource.active div.heading h2 a { + color: black; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource:hover div.heading ul.options li a, +.swagger-section .swagger-ui-wrap ul#resources li.resource.active div.heading ul.options li a { + color: #555555; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource:last-child { + border-bottom: none; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading { + border: 1px solid transparent; + float: none; + clear: both; + overflow: hidden; + display: block; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options { + overflow: hidden; + padding: 0; + display: block; + clear: none; + float: right; + margin: 14px 10px 0 0; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li { + float: left; + clear: none; + margin: 0; + padding: 2px 10px; + border-right: 1px solid #dddddd; + color: #666666; + font-size: 0.9em; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a { + color: #aaaaaa; + text-decoration: none; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover { + text-decoration: underline; + color: black; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover, +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:active, +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li a.active { + text-decoration: underline; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li:first-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li.first { + padding-left: 0; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li:last-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options li.last { + padding-right: 0; + border-right: none; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options:first-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading ul.options.first { + padding-left: 0; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 { + color: #999999; + padding-left: 0; + display: block; + clear: none; + float: left; + font-family: "Droid Sans", sans-serif; + font-weight: bold; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a { + color: #999999; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover { + color: black; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation { + float: none; + clear: both; + overflow: hidden; + display: block; + margin: 0 0 10px; + padding: 0; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading { + float: none; + clear: both; + overflow: hidden; + display: block; + margin: 0; + padding: 0; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 { + display: block; + clear: none; + float: left; + width: auto; + margin: 0; + padding: 0; + line-height: 1.1em; + color: black; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path { + padding-left: 10px; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a { + color: black; + text-decoration: none; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a:hover { + text-decoration: underline; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.http_method a { + text-transform: uppercase; + text-decoration: none; + color: white; + display: inline-block; + width: 50px; + font-size: 0.7em; + text-align: center; + padding: 7px 0 4px; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + -o-border-radius: 2px; + -ms-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span { + margin: 0; + padding: 0; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options { + overflow: hidden; + padding: 0; + display: block; + clear: none; + float: right; + margin: 6px 10px 0 0; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li { + float: left; + clear: none; + margin: 0; + padding: 2px 10px; + font-size: 0.9em; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li a { + text-decoration: none; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li.access { + color: black; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content { + border-top: none; + padding: 10px; + -moz-border-radius-bottomleft: 6px; + -webkit-border-bottom-left-radius: 6px; + -o-border-bottom-left-radius: 6px; + -ms-border-bottom-left-radius: 6px; + -khtml-border-bottom-left-radius: 6px; + border-bottom-left-radius: 6px; + -moz-border-radius-bottomright: 6px; + -webkit-border-bottom-right-radius: 6px; + -o-border-bottom-right-radius: 6px; + -ms-border-bottom-right-radius: 6px; + -khtml-border-bottom-right-radius: 6px; + border-bottom-right-radius: 6px; + margin: 0 0 20px; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content h4 { + font-size: 1.1em; + margin: 0; + padding: 15px 0 5px; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header { + float: none; + clear: both; + overflow: hidden; + display: block; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header a { + padding: 4px 0 0 10px; + display: inline-block; + font-size: 0.9em; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit { + display: block; + clear: none; + float: left; + padding: 6px 8px; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber { + background-image: url('../images/throbber.gif'); + width: 128px; + height: 16px; + display: block; + clear: none; + float: right; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error { + outline: 2px solid black; + outline-color: #cc0000; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; + padding: 10px; + font-size: 0.9em; + max-height: 400px; + overflow-y: auto; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading { + background-color: #f9f2e9; + border: 1px solid #f0e0ca; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.http_method a { + background-color: #c5862b; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #f0e0ca; + color: #c5862b; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a { + color: #c5862b; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content { + background-color: #faf5ee; + border: 1px solid #f0e0ca; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content h4 { + color: #c5862b; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a { + color: #dcb67f; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading { + background-color: #fcffcd; + border: 1px solid black; + border-color: #ffd20f; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading h3 span.http_method a { + text-transform: uppercase; + background-color: #ffd20f; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #ffd20f; + color: #ffd20f; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li a { + color: #ffd20f; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content { + background-color: #fcffcd; + border: 1px solid black; + border-color: #ffd20f; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content h4 { + color: #ffd20f; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content div.sandbox_header a { + color: #6fc992; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading { + background-color: #f5e8e8; + border: 1px solid #e8c6c7; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.http_method a { + text-transform: uppercase; + background-color: #a41e22; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #e8c6c7; + color: #a41e22; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a { + color: #a41e22; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content { + background-color: #f7eded; + border: 1px solid #e8c6c7; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content h4 { + color: #a41e22; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header a { + color: #c8787a; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading { + background-color: #e7f6ec; + border: 1px solid #c3e8d1; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.http_method a { + background-color: #10a54a; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #c3e8d1; + color: #10a54a; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a { + color: #10a54a; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content { + background-color: #ebf7f0; + border: 1px solid #c3e8d1; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content h4 { + color: #10a54a; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header a { + color: #6fc992; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading { + background-color: #FCE9E3; + border: 1px solid #F5D5C3; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.http_method a { + background-color: #D38042; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #f0cecb; + color: #D38042; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a { + color: #D38042; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content { + background-color: #faf0ef; + border: 1px solid #f0cecb; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content h4 { + color: #D38042; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header a { + color: #dcb67f; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading { + background-color: #e7f0f7; + border: 1px solid #c3d9ec; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.http_method a { + background-color: #0f6ab4; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #c3d9ec; + color: #0f6ab4; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a { + color: #0f6ab4; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content { + background-color: #ebf3f9; + border: 1px solid #c3d9ec; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content h4 { + color: #0f6ab4; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a { + color: #6fa5d2; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading { + background-color: #e7f0f7; + border: 1px solid #c3d9ec; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading h3 span.http_method a { + background-color: #0f6ab4; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #c3d9ec; + color: #0f6ab4; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.heading ul.options li a { + color: #0f6ab4; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content { + background-color: #ebf3f9; + border: 1px solid #c3d9ec; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content h4 { + color: #0f6ab4; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.options div.content div.sandbox_header a { + color: #6fa5d2; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content { + border-top: none; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:last-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:last-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li:last-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:last-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li:last-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:last-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.last, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.last, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li.last, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.last, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li.last, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.last { + padding-right: 0; + border-right: none; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:hover, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a.active { + text-decoration: underline; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li:first-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li.first { + padding-left: 0; +} +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations:first-child, +.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations.first { + padding-left: 0; +} +.swagger-section .swagger-ui-wrap p#colophon { + margin: 0 15px 40px 15px; + padding: 10px 0; + font-size: 0.8em; + border-top: 1px solid #dddddd; + font-family: "Droid Sans", sans-serif; + color: #999999; + font-style: italic; +} +.swagger-section .swagger-ui-wrap p#colophon a { + text-decoration: none; + color: #547f00; +} +.swagger-section .swagger-ui-wrap h3 { + color: black; + font-size: 1.1em; + padding: 10px 0 10px 0; +} +.swagger-section .swagger-ui-wrap .markdown ol, +.swagger-section .swagger-ui-wrap .markdown ul { + font-family: "Droid Sans", sans-serif; + margin: 5px 0 10px; + padding: 0 0 0 18px; + list-style-type: disc; +} +.swagger-section .swagger-ui-wrap form.form_box { + background-color: #ebf3f9; + border: 1px solid #c3d9ec; + padding: 10px; +} +.swagger-section .swagger-ui-wrap form.form_box label { + color: #0f6ab4 !important; +} +.swagger-section .swagger-ui-wrap form.form_box input[type=submit] { + display: block; + padding: 10px; +} +.swagger-section .swagger-ui-wrap form.form_box p.weak { + font-size: 0.8em; +} +.swagger-section .swagger-ui-wrap form.form_box p { + font-size: 0.9em; + padding: 0 0 15px; + color: #7e7b6d; +} +.swagger-section .swagger-ui-wrap form.form_box p a { + color: #646257; +} +.swagger-section .swagger-ui-wrap form.form_box p strong { + color: black; +} +.swagger-section .title { + font-style: bold; +} +.swagger-section .secondary_form { + display: none; +} +.swagger-section .main_image { + display: block; + margin-left: auto; + margin-right: auto; +} +.swagger-section .oauth_body { + margin-left: 100px; + margin-right: 100px; +} +.swagger-section .oauth_submit { + text-align: center; +} +.swagger-section .api-popup-dialog { + z-index: 10000; + position: absolute; + width: 500px; + background: #FFF; + padding: 20px; + border: 1px solid #ccc; + border-radius: 5px; + display: none; + font-size: 13px; + color: #777; +} +.swagger-section .api-popup-dialog .api-popup-title { + font-size: 24px; + padding: 10px 0; +} +.swagger-section .api-popup-dialog .api-popup-title { + font-size: 24px; + padding: 10px 0; +} +.swagger-section .api-popup-dialog p.error-msg { + padding-left: 5px; + padding-bottom: 5px; +} +.swagger-section .api-popup-dialog button.api-popup-authbtn { + height: 30px; +} +.swagger-section .api-popup-dialog button.api-popup-cancel { + height: 30px; +} +.swagger-section .api-popup-scopes { + padding: 10px 20px; +} +.swagger-section .api-popup-scopes li { + padding: 5px 0; + line-height: 20px; +} +.swagger-section .api-popup-scopes .api-scope-desc { + padding-left: 20px; + font-style: italic; +} +.swagger-section .api-popup-scopes li input { + position: relative; + top: 2px; +} +.swagger-section .api-popup-actions { + padding-top: 10px; +} +.swagger-section .access { + float: right; +} +.swagger-section .auth { + float: right; +} +.swagger-section #api_information_panel { + position: absolute; + background: #FFF; + border: 1px solid #ccc; + border-radius: 5px; + display: none; + font-size: 13px; + max-width: 300px; + line-height: 30px; + color: black; + padding: 5px; +} +.swagger-section #api_information_panel p .api-msg-enabled { + color: green; +} +.swagger-section #api_information_panel p .api-msg-disabled { + color: red; +} +.swagger-section .api-ic { + height: 18px; + vertical-align: middle; + display: inline-block; + background: url(../images/explorer_icons.png) no-repeat; +} +.swagger-section .ic-info { + background-position: 0 0; + width: 18px; + margin-top: -7px; + margin-left: 4px; +} +.swagger-section .ic-warning { + background-position: -60px 0; + width: 18px; + margin-top: -7px; + margin-left: 4px; +} +.swagger-section .ic-error { + background-position: -30px 0; + width: 18px; + margin-top: -7px; + margin-left: 4px; +} +.swagger-section .ic-off { + background-position: -90px 0; + width: 58px; + margin-top: -4px; + cursor: pointer; +} +.swagger-section .ic-on { + background-position: -160px 0; + width: 58px; + margin-top: -4px; + cursor: pointer; +} +.swagger-section #header { + background-color: #89bf04; + padding: 14px; +} +.swagger-section #header a#logo { + font-size: 1.5em; + font-weight: bold; + text-decoration: none; + background: transparent url(../images/logo_small.png) no-repeat left center; + padding: 20px 0 20px 40px; + color: white; +} +.swagger-section #header form#api_selector { + display: block; + clear: none; + float: right; +} +.swagger-section #header form#api_selector .input { + display: block; + clear: none; + float: left; + margin: 0 10px 0 0; +} +.swagger-section #header form#api_selector .input input#input_apiKey { + width: 200px; +} +.swagger-section #header form#api_selector .input input#input_baseUrl { + width: 400px; +} +.swagger-section #header form#api_selector .input a#explore { + display: block; + text-decoration: none; + font-weight: bold; + padding: 6px 8px; + font-size: 0.9em; + color: white; + background-color: #547f00; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + -o-border-radius: 4px; + -ms-border-radius: 4px; + -khtml-border-radius: 4px; + border-radius: 4px; +} +.swagger-section #header form#api_selector .input a#explore:hover { + background-color: #547f00; +} +.swagger-section #header form#api_selector .input input { + font-size: 0.9em; + padding: 3px; + margin: 0; +} +.swagger-section #content_message { + margin: 10px 15px; + font-style: italic; + color: #999999; +} +.swagger-section #message-bar { + min-height: 30px; + text-align: center; + padding-top: 10px; +} diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/css/typography.css b/esr-core/esr-mgr/src/main/resources/api-doc/css/typography.css new file mode 100644 index 0000000..991427a --- /dev/null +++ b/esr-core/esr-mgr/src/main/resources/api-doc/css/typography.css @@ -0,0 +1,41 @@ +/** + * Copyright 2016 ZTE Corporation. + * + * 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. + */ +/* droid-sans-regular - latin */ +@font-face { + font-family: 'Droid Sans'; + font-style: normal; + font-weight: 400; + src: url('../fonts/droid-sans-v6-latin-regular.eot'); /* IE9 Compat Modes */ + src: local('Droid Sans'), local('DroidSans'), + url('../fonts/droid-sans-v6-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ + url('../fonts/droid-sans-v6-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ + url('../fonts/droid-sans-v6-latin-regular.woff') format('woff'), /* Modern Browsers */ + url('../fonts/droid-sans-v6-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */ + url('../fonts/droid-sans-v6-latin-regular.svg#DroidSans') format('svg'); /* Legacy iOS */ +} +/* droid-sans-700 - latin */ +@font-face { + font-family: 'Droid Sans'; + font-style: normal; + font-weight: 700; + src: url('../fonts/droid-sans-v6-latin-700.eot'); /* IE9 Compat Modes */ + src: local('Droid Sans Bold'), local('DroidSans-Bold'), + url('../fonts/droid-sans-v6-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ + url('../fonts/droid-sans-v6-latin-700.woff2') format('woff2'), /* Super Modern Browsers */ + url('../fonts/droid-sans-v6-latin-700.woff') format('woff'), /* Modern Browsers */ + url('../fonts/droid-sans-v6-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */ + url('../fonts/droid-sans-v6-latin-700.svg#DroidSans') format('svg'); /* Legacy iOS */ +} diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.eot b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.eot new file mode 100644 index 0000000..2250b71 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.eot differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.svg b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.svg new file mode 100644 index 0000000..a54bbbb --- /dev/null +++ b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.svg @@ -0,0 +1,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.ttf b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.ttf new file mode 100644 index 0000000..523cb92 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.ttf differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.woff b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.woff new file mode 100644 index 0000000..67e3e25 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.woff differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.woff2 b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.woff2 new file mode 100644 index 0000000..1e726a7 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-700.woff2 differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.eot b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.eot new file mode 100644 index 0000000..ac2698e Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.eot differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.svg b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.svg new file mode 100644 index 0000000..d9f2a21 --- /dev/null +++ b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.svg @@ -0,0 +1,403 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.ttf b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.ttf new file mode 100644 index 0000000..76aede2 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.ttf differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.woff b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.woff new file mode 100644 index 0000000..abf1989 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.woff differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.woff2 b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.woff2 new file mode 100644 index 0000000..9f93f74 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/fonts/droid-sans-v6-latin-regular.woff2 differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/images/explorer_icons.png b/esr-core/esr-mgr/src/main/resources/api-doc/images/explorer_icons.png new file mode 100644 index 0000000..ed9d2ff Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/images/explorer_icons.png differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/images/logo_small.png b/esr-core/esr-mgr/src/main/resources/api-doc/images/logo_small.png new file mode 100644 index 0000000..5496a65 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/images/logo_small.png differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/images/pet_store_api.png b/esr-core/esr-mgr/src/main/resources/api-doc/images/pet_store_api.png new file mode 100644 index 0000000..f9f9cd4 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/images/pet_store_api.png differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/images/throbber.gif b/esr-core/esr-mgr/src/main/resources/api-doc/images/throbber.gif new file mode 100644 index 0000000..0639388 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/images/throbber.gif differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/images/wordnik_api.png b/esr-core/esr-mgr/src/main/resources/api-doc/images/wordnik_api.png new file mode 100644 index 0000000..dca4f14 Binary files /dev/null and b/esr-core/esr-mgr/src/main/resources/api-doc/images/wordnik_api.png differ diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/index.html b/esr-core/esr-mgr/src/main/resources/api-doc/index.html new file mode 100644 index 0000000..7cd76a3 --- /dev/null +++ b/esr-core/esr-mgr/src/main/resources/api-doc/index.html @@ -0,0 +1,115 @@ + + + + + Swagger UI + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
+
+ + diff --git a/esr-core/esr-mgr/src/main/resources/api-doc/lib/backbone-min.js b/esr-core/esr-mgr/src/main/resources/api-doc/lib/backbone-min.js new file mode 100644 index 0000000..c66d3a5 --- /dev/null +++ b/esr-core/esr-mgr/src/main/resources/api-doc/lib/backbone-min.js @@ -0,0 +1,30 @@ +/* + * Copyright 2016 ZTE Corporation. + * + * 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. + */ +// Backbone.js 1.1.2 + +(function(t,e){if(typeof define==="function"&&define.amd){define(["underscore","jquery","exports"],function(i,r,s){t.Backbone=e(t,s,i,r)})}else if(typeof exports!=="undefined"){var i=require("underscore");e(t,exports,i)}else{t.Backbone=e(t,{},t._,t.jQuery||t.Zepto||t.ender||t.$)}})(this,function(t,e,i,r){var s=t.Backbone;var n=[];var a=n.push;var o=n.slice;var h=n.splice;e.VERSION="1.1.2";e.$=r;e.noConflict=function(){t.Backbone=s;return this};e.emulateHTTP=false;e.emulateJSON=false;var u=e.Events={on:function(t,e,i){if(!c(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,r){if(!c(this,"once",t,[e,r])||!e)return this;var s=this;var n=i.once(function(){s.off(t,n);e.apply(this,arguments)});n._callback=e;return this.on(t,n,r)},off:function(t,e,r){var s,n,a,o,h,u,l,f;if(!this._events||!c(this,"off",t,[e,r]))return this;if(!t&&!e&&!r){this._events=void 0;return this}o=t?[t]:i.keys(this._events);for(h=0,u=o.length;h").attr(t);this.setElement(r,false)}else{this.setElement(i.result(this,"el"),false)}}});e.sync=function(t,r,s){var n=T[t];i.defaults(s||(s={}),{emulateHTTP:e.emulateHTTP,emulateJSON:e.emulateJSON});var a={type:n,dataType:"json"};if(!s.url){a.url=i.result(r,"url")||M()}if(s.data==null&&r&&(t==="create"||t==="update"||t==="patch")){a.contentType="application/json";a.data=JSON.stringify(s.attrs||r.toJSON(s))}if(s.emulateJSON){a.contentType="application/x-www-form-urlencoded";a.data=a.data?{model:a.data}:{}}if(s.emulateHTTP&&(n==="PUT"||n==="DELETE"||n==="PATCH")){a.type="POST";if(s.emulateJSON)a.data._method=n;var o=s.beforeSend;s.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",n);if(o)return o.apply(this,arguments)}}if(a.type!=="GET"&&!s.emulateJSON){a.processData=false}if(a.type==="PATCH"&&k){a.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var h=s.xhr=e.ajax(i.extend(a,s));r.trigger("request",r,h,s);return h};var k=typeof window!=="undefined"&&!!window.ActiveXObject&&!(window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent);var T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};e.ajax=function(){return e.$.ajax.apply(e.$,arguments)};var $=e.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var S=/\((.*?)\)/g;var H=/(\(\?)?:\w+/g;var A=/\*\w+/g;var I=/[\-{}\[\]+?.,\\\^$|#\s]/g;i.extend($.prototype,u,{initialize:function(){},route:function(t,r,s){if(!i.isRegExp(t))t=this._routeToRegExp(t);if(i.isFunction(r)){s=r;r=""}if(!s)s=this[r];var n=this;e.history.route(t,function(i){var a=n._extractParameters(t,i);n.execute(s,a);n.trigger.apply(n,["route:"+r].concat(a));n.trigger("route",r,a);e.history.trigger("route",n,r,a)});return this},execute:function(t,e){if(t)t.apply(this,e)},navigate:function(t,i){e.history.navigate(t,i);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=i.result(this,"routes");var t,e=i.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(I,"\\$&").replace(S,"(?:$1)?").replace(H,function(t,e){return e?t:"([^/?]+)"}).replace(A,"([^?]*?)");return new RegExp("^"+t+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(t,e){var r=t.exec(e).slice(1);return i.map(r,function(t,e){if(e===r.length-1)return t||null;return t?decodeURIComponent(t):null})}});var N=e.History=function(){this.handlers=[];i.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var R=/^[#\/]|\s+$/g;var O=/^\/+|\/+$/g;var P=/msie [\w.]+/;var C=/\/$/;var j=/#.*$/;N.started=false;i.extend(N.prototype,u,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=decodeURI(this.location.pathname+this.location.search);var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.slice(i.length)}else{t=this.getHash()}}return t.replace(R,"")},start:function(t){if(N.started)throw new Error("Backbone.history has already been started");N.started=true;this.options=i.extend({root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var r=this.getFragment();var s=document.documentMode;var n=P.exec(navigator.userAgent.toLowerCase())&&(!s||s<=7);this.root=("/"+this.root+"/").replace(O,"/");if(n&&this._wantsHashChange){var a=e.$('