diff options
Diffstat (limited to 'ResmanagementService')
288 files changed, 35451 insertions, 0 deletions
diff --git a/ResmanagementService/deployment/pom.xml b/ResmanagementService/deployment/pom.xml new file mode 100644 index 0000000..01ec749 --- /dev/null +++ b/ResmanagementService/deployment/pom.xml @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2016, Huawei Technologies Co., Ltd. + + 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openo.nfvo</groupId> + <artifactId>resmanagement-service-root</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>resmanagement-deployment</artifactId> + <packaging>pom</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.gmaven</groupId> + <artifactId>gmaven-plugin</artifactId> + <version>1.5</version> + <executions> + <execution> + <id>resmanagement package</id> + <phase>package</phase> + <goals> + <goal>execute</goal> + </goals> + <configuration> + <source> + System.out.println("******** Going to make release zip ********") + + deployFolder = + "${project.build.directory}/deployoutput" + deployUnzip = + "${project.build.directory}/deployunzip" + outfileName = + "${package.name}-${project.version}.zip" + ant.delete(dir: "${deployFolder}") + ant.mkdir(dir: + "${deployFolder}") + + ant.delete(dir: "${deployUnzip}") + ant.mkdir(dir: "${deployUnzip}") + + ant.mkdir(dir: + "${deployUnzip}/webapps/") + ant.mkdir(dir: "${deployUnzip}/webapps/ROOT") + ant.mkdir(dir: + "${deployUnzip}/logs") + + ant.copy(todir: "${deployUnzip}") { + fileset(dir: "${basedir}/src/main/release"){ + exclude(name: "**/.gitignore") + } + } + ant.copy(todir: + "${deployUnzip}/webapps/ROOT") { + fileset(dir: + "${project.build.directory}/../../service/target/${package.name}-${project.version}") + } + + ant.zip(destfile: + "${deployFolder}/${outfileName}") { + fileset(dir: "${deployUnzip}") + } + System.out.println("******** completed. ************") + </source> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-artifacts</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file>${project.build.directory}/deployoutput/${package.name}-${project.version}.zip</file> + <type>zip</type> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + + + + </plugins> + </build> +<name>nfvo/resmanagement/ResmanagementService/deployment</name></project> diff --git a/ResmanagementService/deployment/src/main/release/README.txt b/ResmanagementService/deployment/src/main/release/README.txt new file mode 100644 index 0000000..e4e797c --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/README.txt @@ -0,0 +1,55 @@ +Introduction: +============= + This document provides the required steps for installation + and configuration this service. + +Installation steps: +==================== + Install following software: + - Java 1.8 or lattest + - MySql Server 5.7 or lattest. + - Apache Tomcat Server 8.0 or lattest + + Set the following environment variables: + - JAVA_HOME: Set to JAVA JDK installed location + - CATALINIA_HOME: Set to Tomcat installed location + - CATALINIA_BASE: Set to the location, where this + service installer is unzipped, its optional + - PATH: Update it with the location of command 'mysql' + + - In command console, cd to 'bin' directory under the location, + where this service installer is unzipped and + run ./init_db.sh <db user> <db password> <db server ip> <db port> + CAUTION: Existing resmanagementdb will be cleaned before + initializing the schema, so please take a back-up of it + before executing it next time. + +Configuration steps: +==================== + - Update the db credetials in bean with id="source" in 'services.xml' + under webapps spring directory. + - Update the MSB address in $PATH/etc/conf/restclient.json + - Update the resmangement service ip address in $PATH/etc/adapterInfo/resmgradapterinfo.json + +How to run? +=========== + - In command console, cd to 'bin' directory under the location, + where this service installer is unzipped and + run ./start.sh + NOTE: It starts the tomcat at predefined http port. To change + default port, update the port in tomcat configuration file + 'conf/server.xml' + - Verify that 'Tomcat started.' is reported on the console. + - Once service is started, please verify below details: + - from MSB service, verify that "resmgr" is reported from GET request on "/openoapi/microservices/v1/services" + - from this service, run one of the supported REST API mentioned in open-o NFVO wiki and verify that the + expected response is returned. + +How to stop? +============= + - In command console, cd to 'bin' directory under the location, + where this service installer is unzipped and + run ./stop.sh + + + diff --git a/ResmanagementService/deployment/src/main/release/bin/init_db.sh b/ResmanagementService/deployment/src/main/release/bin/init_db.sh new file mode 100644 index 0000000..0c29d73 --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/bin/init_db.sh @@ -0,0 +1,61 @@ +#******************************************************************************* +# Copyright 2016 Huawei Technologies Co., Ltd. +# +# 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. +#******************************************************************************* +#!/bin/bash + +cd .. + +if [ -z "$1" ] +then + echo "usage: init_db.sh <db user> <db password> <db server ip> <db port> " + exit 1 +fi + +if [ -z "$2" ] +then + echo "usage: init_db.sh <db user> <db password> <db server ip> <db port> " + exit 1 +fi + +if [ -z "$3" ] +then + echo "usage: init_db.sh <db user> <db password> <db server ip> <db port> " + exit 1 +fi + +if [ -z "$4" ] +then + echo "usage: init_db.sh <db user> <db password> <db server ip> <db port> " + exit 1 +fi + +echo +echo "DB-INIT [resmanagementdb] : START" + +mysql -u$1 -p$2 -h$3 -P$4 <$(cd `dirname $0`; pwd)/db/mysql/db-schema.sql + +if [ $? != 0 ] ; then + echo "DB-INIT [resmanagementdb] : FAILED !" + exit 1 +fi + +echo "DB-INIT [resmanagementdb] : PASSED" +echo +echo "*************************************************************" +echo "CAUTION: Existing resmanagementdb will be cleaned before" +echo "initializing the schema, so please take a back-up of it" +echo "before executing it next time." +echo "*************************************************************" +exit 0
\ No newline at end of file diff --git a/ResmanagementService/deployment/src/main/release/bin/start.sh b/ResmanagementService/deployment/src/main/release/bin/start.sh new file mode 100644 index 0000000..ddd7d58 --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/bin/start.sh @@ -0,0 +1,47 @@ +# +# Copyright 2016 Huawei Technologies Co., Ltd. +# +# 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. + +#!/bin/bash +cd .. +export CATALINA_BASE=$(cd `dirname $0`; pwd) + +if [ -z "$JAVA_HOME" ] +then + echo "There is no JAVA_HOME" + exit 1 +fi + +if [ -z "$CATALINA_HOME" ] +then + echo "There is no CATALINA_HOME" + exit 1 +fi + +if [ -z "$CATALINA_BASE" ] +then + echo "There is no CATALINA_BASE" + exit 1 +fi + +export CATALINA_PID="$CATALINA_BASE/bin/catalina.pid" + +LOG_DIR=$CATALINA_BASE/logs +if [ ! -d "$LOG_DIR" ]; then + mkdir $LOG_DIR +fi + +$CATALINA_HOME/bin/catalina.sh start + + diff --git a/ResmanagementService/deployment/src/main/release/bin/stop.sh b/ResmanagementService/deployment/src/main/release/bin/stop.sh new file mode 100644 index 0000000..a0acfe6 --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/bin/stop.sh @@ -0,0 +1,41 @@ +# +# Copyright 2016 Huawei Technologies Co., Ltd. +# +# 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. +# + +#!/bin/bash +cd .. +export CATALINA_BASE=$(cd `dirname $0`; pwd) + +if [ -z "$JAVA_HOME" ] +then + echo "There is no JAVA_HOME" + exit 1 +fi + +if [ -z "$CATALINA_HOME" ] +then + echo "There is no CATALINA_HOME" + exit 1 +fi + +export CATALINA_PID="$CATALINA_BASE/bin/catalina.pid" + +if [ -z "$CATALINA_BASE" ] +then + echo "There is no CATALINA_BASE" + exit 1 +fi + +$CATALINA_HOME/bin/catalina.sh stop -force diff --git a/ResmanagementService/deployment/src/main/release/conf/catalina.policy b/ResmanagementService/deployment/src/main/release/conf/catalina.policy new file mode 100644 index 0000000..9f99104 --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/conf/catalina.policy @@ -0,0 +1,212 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You 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. + +// ============================================================================ +// catalina.policy - Security Policy Permissions for Tomcat 7 +// +// This file contains a default set of security policies to be enforced (by the +// JVM) when Catalina is executed with the "-security" option. In addition +// to the permissions granted here, the following additional permissions are +// granted to each web application: +// +// * Read access to the web application's document root directory +// * Read, write and delete access to the web application's working directory +// ============================================================================ + + +// ========== SYSTEM CODE PERMISSIONS ========================================= + + +// These permissions apply to javac +grant codeBase "file:${java.home}/lib/-" { + permission java.security.AllPermission; +}; + +// These permissions apply to all shared system extensions +grant codeBase "file:${java.home}/jre/lib/ext/-" { + permission java.security.AllPermission; +}; + +// These permissions apply to javac when ${java.home] points at $JAVA_HOME/jre +grant codeBase "file:${java.home}/../lib/-" { + permission java.security.AllPermission; +}; + +// These permissions apply to all shared system extensions when +// ${java.home} points at $JAVA_HOME/jre +grant codeBase "file:${java.home}/lib/ext/-" { + permission java.security.AllPermission; +}; + + +// ========== CATALINA CODE PERMISSIONS ======================================= + + +// These permissions apply to the daemon code +grant codeBase "file:${catalina.home}/bin/commons-daemon.jar" { + permission java.security.AllPermission; +}; + + +grant codeBase "file:${catalina.home}/bin/tomcat-juli.jar" { + permission java.io.FilePermission + "${java.home}${file.separator}lib${file.separator}logging.properties", "read"; + + permission java.io.FilePermission + "${catalina.base}${file.separator}conf${file.separator}logging.properties", "read"; + permission java.io.FilePermission + "${catalina.base}${file.separator}logs", "read, write"; + permission java.io.FilePermission + "${catalina.base}${file.separator}logs${file.separator}*", "read, write"; + + permission java.lang.RuntimePermission "shutdownHooks"; + permission java.lang.RuntimePermission "getClassLoader"; + permission java.lang.RuntimePermission "setContextClassLoader"; + + permission java.util.logging.LoggingPermission "control"; + + permission java.util.PropertyPermission "java.util.logging.config.class", "read"; + permission java.util.PropertyPermission "java.util.logging.config.file", "read"; + permission java.util.PropertyPermission "org.apache.juli.ClassLoaderLogManager.debug", "read"; + permission java.util.PropertyPermission "catalina.base", "read"; + + +}; + +// These permissions apply to the server startup code +grant codeBase "file:${catalina.home}/bin/bootstrap.jar" { + permission java.security.AllPermission; +}; + +// These permissions apply to the servlet API classes +// and those that are shared across all class loaders +// located in the "lib" directory +grant codeBase "file:${catalina.home}/lib/-" { + permission java.security.AllPermission; +}; + + + +// ========== WEB APPLICATION PERMISSIONS ===================================== + + +// These permissions are granted by default to all web applications +// In addition, a web application will be given a read FilePermission +// and JndiPermission for all files and directories in its document root. +grant { + // Required for JNDI lookup of named JDBC DataSource's and + // javamail named MimePart DataSource used to send mail + permission java.util.PropertyPermission "java.home", "read"; + permission java.util.PropertyPermission "java.naming.*", "read"; + permission java.util.PropertyPermission "javax.sql.*", "read"; + + // OS Specific properties to allow read access + permission java.util.PropertyPermission "os.name", "read"; + permission java.util.PropertyPermission "os.version", "read"; + permission java.util.PropertyPermission "os.arch", "read"; + permission java.util.PropertyPermission "file.separator", "read"; + permission java.util.PropertyPermission "path.separator", "read"; + permission java.util.PropertyPermission "line.separator", "read"; + + // JVM properties to allow read access + permission java.util.PropertyPermission "java.version", "read"; + permission java.util.PropertyPermission "java.vendor", "read"; + permission java.util.PropertyPermission "java.vendor.url", "read"; + permission java.util.PropertyPermission "java.class.version", "read"; + permission java.util.PropertyPermission "java.specification.version", "read"; + permission java.util.PropertyPermission "java.specification.vendor", "read"; + permission java.util.PropertyPermission "java.specification.name", "read"; + + permission java.util.PropertyPermission "java.vm.specification.version", "read"; + permission java.util.PropertyPermission "java.vm.specification.vendor", "read"; + permission java.util.PropertyPermission "java.vm.specification.name", "read"; + permission java.util.PropertyPermission "java.vm.version", "read"; + permission java.util.PropertyPermission "java.vm.vendor", "read"; + permission java.util.PropertyPermission "java.vm.name", "read"; + + // Required for OpenJMX + permission java.lang.RuntimePermission "getAttribute"; + + // Allow read of JAXP compliant XML parser debug + permission java.util.PropertyPermission "jaxp.debug", "read"; + + // All JSPs need to be able to read this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat"; + + // Precompiled JSPs need access to these packages. + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.el"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.jasper.runtime"; + permission java.lang.RuntimePermission + "accessClassInPackage.org.apache.jasper.runtime.*"; + + // Precompiled JSPs need access to these system properties. + permission java.util.PropertyPermission + "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "read"; + permission java.util.PropertyPermission + "org.apache.el.parser.COERCE_TO_ZERO", "read"; + + // The cookie code needs these. + permission java.util.PropertyPermission + "org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "read"; + permission java.util.PropertyPermission + "org.apache.tomcat.util.http.ServerCookie.STRICT_NAMING", "read"; + permission java.util.PropertyPermission + "org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR", "read"; + + // Applications using Comet need to be able to access this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.comet"; + + // Applications using the legacy WebSocket implementation need to be able to access this package + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.websocket"; + + // Applications using the JSR-356 WebSocket implementation need to be able to access these packages + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.websocket"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.tomcat.websocket.server"; +}; + + +// The Manager application needs access to the following packages to support the +// session display functionality. These settings support the following +// configurations: +// - default CATALINA_HOME == CATALINA_BASE +// - CATALINA_HOME != CATALINA_BASE, per instance Manager in CATALINA_BASE +// - CATALINA_HOME != CATALINA_BASE, shared Manager in CATALINA_HOME +grant codeBase "file:${catalina.base}/webapps/manager/-" { + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; +}; +grant codeBase "file:${catalina.home}/webapps/manager/-" { + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.ha.session"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.manager.util"; + permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.util"; +}; + +// You can assign additional permissions to particular web applications by +// adding additional "grant" entries here, based on the code base for that +// application, /WEB-INF/classes/, or /WEB-INF/lib/ jar files. +// +// Different permissions can be granted to JSP pages, classes loaded from +// the /WEB-INF/classes/ directory, all jar files in the /WEB-INF/lib/ +// directory, or even to individual jar files in the /WEB-INF/lib/ directory. +// +// For instance, assume that the standard "examples" application +// included a JDBC driver that needed to establish a network connection to the +// corresponding database and used the scrape taglib to get the weather from +// the NOAA web server. You might create a "grant" entries like this: diff --git a/ResmanagementService/deployment/src/main/release/conf/catalina.properties b/ResmanagementService/deployment/src/main/release/conf/catalina.properties new file mode 100644 index 0000000..a2393bb --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/conf/catalina.properties @@ -0,0 +1,130 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +# +# List of comma-separated packages that start with or equal this string +# will cause a security exception to be thrown when +# passed to checkPackageAccess unless the +# corresponding RuntimePermission ("accessClassInPackage."+package) has +# been granted. +package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.jasper.,\ +org.apache.naming.resources.,org.apache.tomcat. +# +# List of comma-separated packages that start with or equal this string +# will cause a security exception to be thrown when +# passed to checkPackageDefinition unless the +# corresponding RuntimePermission ("defineClassInPackage."+package) has +# been granted. +# +# by default, no packages are restricted for definition, and none of +# the class loaders supplied with the JDK call checkPackageDefinition. +# +package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,\ +org.apache.jasper.,org.apache.naming.,org.apache.tomcat. + +# +# +# List of comma-separated paths defining the contents of the "common" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. +# If left as blank,the JVM system loader will be used as Catalina's "common" +# loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar + +# +# List of comma-separated paths defining the contents of the "server" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute. +# If left as blank, the "common" loader will be used as Catalina's "server" +# loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +server.loader= + +# +# List of comma-separated paths defining the contents of the "shared" +# classloader. Prefixes should be used to define what is the repository type. +# Path may be relative to the CATALINA_BASE path or absolute. If left as blank, +# the "common" loader will be used as Catalina's "shared" loader. +# Examples: +# "foo": Add this folder as a class repository +# "foo/*.jar": Add all the JARs of the specified folder as class +# repositories +# "foo/bar.jar": Add bar.jar as a class repository +# Please note that for single jars, e.g. bar.jar, you need the URL form +# starting with file:. +shared.loader= + +# List of JAR files that should not be scanned using the JarScanner +# functionality. This is typically used to scan JARs for configuration +# information. JARs that do not contain such information may be excluded from +# the scan to speed up the scanning process. This is the default list. JARs on +# this list are excluded from all scans. Scan specific lists (to exclude JARs +# from individual scans) follow this. The list must be a comma separated list of +# JAR file names. +# The JARs listed below include: +# - Tomcat Bootstrap JARs +# - Tomcat API JARs +# - Catalina JARs +# - Jasper JARs +# - Tomcat JARs +# - Common non-Tomcat JARs +# - Test JARs (JUnit, Cobertura and dependencies) +tomcat.util.scan.DefaultJarScanner.jarsToSkip=\ +bootstrap.jar,commons-daemon.jar,tomcat-juli.jar,\ +annotations-api.jar,el-api.jar,jsp-api.jar,servlet-api.jar,websocket-api.jar,\ +catalina.jar,catalina-ant.jar,catalina-ha.jar,catalina-tribes.jar,\ +jasper.jar,jasper-el.jar,ecj-*.jar,\ +tomcat-api.jar,tomcat-util.jar,tomcat-coyote.jar,tomcat-dbcp.jar,\ +tomcat-jni.jar,tomcat-spdy.jar,\ +tomcat-i18n-en.jar,tomcat-i18n-es.jar,tomcat-i18n-fr.jar,tomcat-i18n-ja.jar,\ +tomcat-juli-adapters.jar,catalina-jmx-remote.jar,catalina-ws.jar,\ +tomcat-jdbc.jar,\ +tools.jar,\ +commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar,\ +commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,\ +commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar,commons-logging*.jar,\ +commons-math*.jar,commons-pool*.jar,\ +jstl.jar,\ +geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,\ +ant.jar,ant-junit*.jar,aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,\ +jmx-tools.jar,jta*.jar,log4j.jar,log4j-1*.jar,mail*.jar,slf4j*.jar,\ +xercesImpl.jar,xmlParserAPIs.jar,xml-apis.jar,\ +junit.jar,junit-*.jar,hamcrest*.jar,org.hamcrest*.jar,ant-launcher.jar,\ +cobertura-*.jar,asm-*.jar,dom4j-*.jar,icu4j-*.jar,jaxen-*.jar,jdom-*.jar,\ +jetty-*.jar,oro-*.jar,servlet-api-*.jar,tagsoup-*.jar,xmlParserAPIs-*.jar,\ +xom-*.jar + +# Additional JARs (over and above the default JARs listed above) to skip when +# scanning for Servlet 3.0 pluggability features. These features include web +# fragments, annotations, SCIs and classes that match @HandlesTypes. The list +# must be a comma separated list of JAR file names. +org.apache.catalina.startup.ContextConfig.jarsToSkip= + +# Additional JARs (over and above the default JARs listed above) to skip when +# scanning for TLDs. The list must be a comma separated list of JAR file names. +org.apache.catalina.startup.TldConfig.jarsToSkip=tomcat7-websocket.jar + +# +# String cache configuration. +tomcat.util.buf.StringCache.byte.enabled=true diff --git a/ResmanagementService/deployment/src/main/release/conf/context.xml b/ResmanagementService/deployment/src/main/release/conf/context.xml new file mode 100644 index 0000000..64de61f --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/conf/context.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +--> +<!-- The contents of this file will be loaded for each web application --> +<Context> + + <!-- Default set of monitored resources. If one of these changes, the --> + <!-- web application will be reloaded. --> + <WatchedResource>WEB-INF/web.xml</WatchedResource> + <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> + + <!-- Uncomment this to disable session persistence across Tomcat restarts --> + <!-- + <Manager pathname="" /> + --> +</Context> diff --git a/ResmanagementService/deployment/src/main/release/conf/logging.properties b/ResmanagementService/deployment/src/main/release/conf/logging.properties new file mode 100644 index 0000000..a2ad9c2 --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/conf/logging.properties @@ -0,0 +1,70 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler + +.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler + +############################################################ +# Handler specific properties. +# Describes specific configuration info for Handlers. +############################################################ + +1catalina.org.apache.juli.AsyncFileHandler.level = FINE +1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs +1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina. + +2localhost.org.apache.juli.AsyncFileHandler.level = FINE +2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs +2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost. + +3manager.org.apache.juli.AsyncFileHandler.level = FINE +3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs +3manager.org.apache.juli.AsyncFileHandler.prefix = manager. + +4host-manager.org.apache.juli.AsyncFileHandler.level = FINE +4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs +4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager. + +java.util.logging.ConsoleHandler.level = FINE +java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter + + +############################################################ +# Facility specific properties. +# Provides extra control for each logger. +############################################################ + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler + +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler + +# For example, set the org.apache.catalina.util.LifecycleBase logger to log +# each component that extends LifecycleBase changing state: +#org.apache.catalina.util.LifecycleBase.level = FINE + +# To see debug messages in TldLocationsCache, uncomment the following line: +#org.apache.jasper.compiler.TldLocationsCache.level = FINE + +# To see debug messages for HTTP/2 handling, uncomment the following line: +#org.apache.coyote.http2.level = FINE + +# To see debug messages for WebSocket handling, uncomment the following line: +#org.apache.tomcat.websocket.level = FINE diff --git a/ResmanagementService/deployment/src/main/release/conf/server.xml b/ResmanagementService/deployment/src/main/release/conf/server.xml new file mode 100644 index 0000000..ef644f8 --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/conf/server.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +--> +<!-- Note: A "Server" is not itself a "Container", so you may not + define subcomponents such as "Valves" at this level. + Documentation at /docs/config/server.html + --> +<Server port="9480" shutdown="SHUTDOWN"> + <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> + <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener" /> + <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> + <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> + <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> + <GlobalNamingResources> + <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" + name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase" /> + </GlobalNamingResources> + <Service name="Catalina"> + <Connector connectionTimeout="20000" port="8480" protocol="HTTP/1.1" redirectPort="8443" /> + <Connector port="8821" protocol="AJP/1.3" redirectPort="8443" /> + <Engine defaultHost="localhost" name="Catalina"> + <Realm className="org.apache.catalina.realm.LockOutRealm"> + <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" /> + </Realm> + + <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true"> + <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" + pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt" /> + <Context docBase="ROOT" path="" reloadable="true" /> + </Host> + </Engine> + </Service> +</Server>
\ No newline at end of file diff --git a/ResmanagementService/deployment/src/main/release/conf/web.xml b/ResmanagementService/deployment/src/main/release/conf/web.xml new file mode 100644 index 0000000..793a8a8 --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/conf/web.xml @@ -0,0 +1,4689 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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. +--> +<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee + http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" + version="3.1"> + + <!-- ======================== Introduction ============================== --> + <!-- This document defines default values for *all* web applications --> + <!-- loaded into this instance of Tomcat. As each application is --> + <!-- deployed, this file is processed, followed by the --> + <!-- "/WEB-INF/web.xml" deployment descriptor from your own --> + <!-- applications. --> + <!-- --> + <!-- WARNING: Do not configure application-specific resources here! --> + <!-- They should go in the "/WEB-INF/web.xml" file in your application. --> + + + <!-- ================== Built In Servlet Definitions ==================== --> + + + <!-- The default servlet for all web applications, that serves static --> + <!-- resources. It processes all requests that are not mapped to other --> + <!-- servlets with servlet mappings (defined either here or in your own --> + <!-- web.xml file). This servlet supports the following initialization --> + <!-- parameters (default values are in square brackets): --> + <!-- --> + <!-- debug Debugging detail level for messages logged --> + <!-- by this servlet. Useful values are 0, 1, and --> + <!-- 11 where higher values mean more detail. [0] --> + <!-- --> + <!-- fileEncoding Encoding to be used to read static resources --> + <!-- [platform default] --> + <!-- --> + <!-- input Input buffer size (in bytes) when reading --> + <!-- resources to be served. [2048] --> + <!-- --> + <!-- listings Should directory listings be produced if there --> + <!-- is no welcome file in this directory? [false] --> + <!-- WARNING: Listings for directories with many --> + <!-- entries can be slow and may consume --> + <!-- significant proportions of server resources. --> + <!-- --> + <!-- output Output buffer size (in bytes) when writing --> + <!-- resources to be served. [2048] --> + <!-- --> + <!-- readonly Is this context "read only", so HTTP --> + <!-- commands like PUT and DELETE are --> + <!-- rejected? [true] --> + <!-- --> + <!-- readmeFile File to display together with the directory --> + <!-- contents. [null] --> + <!-- --> + <!-- sendfileSize If the connector used supports sendfile, this --> + <!-- represents the minimal file size in KB for --> + <!-- which sendfile will be used. Use a negative --> + <!-- value to always disable sendfile. [48] --> + <!-- --> + <!-- useAcceptRanges Should the Accept-Ranges header be included --> + <!-- in responses where appropriate? [true] --> + <!-- --> + <!-- For directory listing customization. Checks localXsltFile, then --> + <!-- globalXsltFile, then defaults to original behavior. --> + <!-- --> + <!-- localXsltFile Make directory listings an XML doc and --> + <!-- pass the result to this style sheet residing --> + <!-- in that directory. This overrides --> + <!-- contextXsltFile and globalXsltFile[null] --> + <!-- --> + <!-- contextXsltFile Make directory listings an XML doc and --> + <!-- pass the result to this style sheet which is --> + <!-- relative to the context root. This overrides --> + <!-- globalXsltFile[null] --> + <!-- --> + <!-- globalXsltFile Site wide configuration version of --> + <!-- localXsltFile. This argument must either be an --> + <!-- absolute or relative (to either --> + <!-- $CATALINA_BASE/conf or $CATALINA_HOME/conf) --> + <!-- path that points to a location below either --> + <!-- $CATALINA_BASE/conf (checked first) or --> + <!-- $CATALINA_HOME/conf (checked second).[null] --> + <!-- --> + <!-- showServerInfo Should server information be presented in the --> + <!-- response sent to clients when directory --> + <!-- listings is enabled? [true] --> + + <servlet> + <servlet-name>default</servlet-name> + <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> + <init-param> + <param-name>debug</param-name> + <param-value>0</param-value> + </init-param> + <init-param> + <param-name>listings</param-name> + <param-value>false</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + + + <!-- The JSP page compiler and execution servlet, which is the mechanism --> + <!-- used by Tomcat to support JSP pages. Traditionally, this servlet --> + <!-- is mapped to the URL pattern "*.jsp". This servlet supports the --> + <!-- following initialization parameters (default values are in square --> + <!-- brackets): --> + <!-- --> + <!-- checkInterval If development is false and checkInterval is --> + <!-- greater than zero, background compilations are --> + <!-- enabled. checkInterval is the time in seconds --> + <!-- between checks to see if a JSP page (and its --> + <!-- dependent files) needs to be recompiled. [0] --> + <!-- --> + <!-- classdebuginfo Should the class file be compiled with --> + <!-- debugging information? [true] --> + <!-- --> + <!-- classpath What class path should I use while compiling --> + <!-- generated servlets? [Created dynamically --> + <!-- based on the current web application] --> + <!-- --> + <!-- compiler Which compiler Ant should use to compile JSP --> + <!-- pages. See the jasper documentation for more --> + <!-- information. --> + <!-- --> + <!-- compilerSourceVM Compiler source VM. [1.7] --> + <!-- --> + <!-- compilerTargetVM Compiler target VM. [1.7] --> + <!-- --> + <!-- development Is Jasper used in development mode? If true, --> + <!-- the frequency at which JSPs are checked for --> + <!-- modification may be specified via the --> + <!-- modificationTestInterval parameter. [true] --> + <!-- --> + <!-- displaySourceFragment --> + <!-- Should a source fragment be included in --> + <!-- exception messages? [true] --> + <!-- --> + <!-- dumpSmap Should the SMAP info for JSR45 debugging be --> + <!-- dumped to a file? [false] --> + <!-- False if suppressSmap is true --> + <!-- --> + <!-- enablePooling Determines whether tag handler pooling is --> + <!-- enabled. This is a compilation option. It will --> + <!-- not alter the behaviour of JSPs that have --> + <!-- already been compiled. [true] --> + <!-- --> + <!-- engineOptionsClass Allows specifying the Options class used to --> + <!-- configure Jasper. If not present, the default --> + <!-- EmbeddedServletOptions will be used. --> + <!-- --> + <!-- errorOnUseBeanInvalidClassAttribute --> + <!-- Should Jasper issue an error when the value of --> + <!-- the class attribute in an useBean action is --> + <!-- not a valid bean class? [true] --> + <!-- --> + <!-- fork Tell Ant to fork compiles of JSP pages so that --> + <!-- a separate JVM is used for JSP page compiles --> + <!-- from the one Tomcat is running in. [true] --> + <!-- --> + <!-- genStringAsCharArray --> + <!-- Should text strings be generated as char --> + <!-- arrays, to improve performance in some cases? --> + <!-- [false] --> + <!-- --> + <!-- ieClassId The class-id value to be sent to Internet --> + <!-- Explorer when using <jsp:plugin> tags. --> + <!-- [clsid:8AD9C840-044E-11D1-B3E9-00805F499D93] --> + <!-- --> + <!-- javaEncoding Java file encoding to use for generating java --> + <!-- source files. [UTF8] --> + <!-- --> + <!-- keepgenerated Should we keep the generated Java source code --> + <!-- for each page instead of deleting it? [true] --> + <!-- --> + <!-- mappedfile Should we generate static content with one --> + <!-- print statement per input line, to ease --> + <!-- debugging? [true] --> + <!-- --> + <!-- maxLoadedJsps The maximum number of JSPs that will be loaded --> + <!-- for a web application. If more than this --> + <!-- number of JSPs are loaded, the least recently --> + <!-- used JSPs will be unloaded so that the number --> + <!-- of JSPs loaded at any one time does not exceed --> + <!-- this limit. A value of zero or less indicates --> + <!-- no limit. [-1] --> + <!-- --> + <!-- jspIdleTimeout The amount of time in seconds a JSP can be --> + <!-- idle before it is unloaded. A value of zero --> + <!-- or less indicates never unload. [-1] --> + <!-- --> + <!-- modificationTestInterval --> + <!-- Causes a JSP (and its dependent files) to not --> + <!-- be checked for modification during the --> + <!-- specified time interval (in seconds) from the --> + <!-- last time the JSP was checked for --> + <!-- modification. A value of 0 will cause the JSP --> + <!-- to be checked on every access. --> + <!-- Used in development mode only. [4] --> + <!-- --> + <!-- recompileOnFail If a JSP compilation fails should the --> + <!-- modificationTestInterval be ignored and the --> + <!-- next access trigger a re-compilation attempt? --> + <!-- Used in development mode only and is disabled --> + <!-- by default as compilation may be expensive and --> + <!-- could lead to excessive resource usage. --> + <!-- [false] --> + <!-- --> + <!-- scratchdir What scratch directory should we use when --> + <!-- compiling JSP pages? [default work directory --> + <!-- for the current web application] --> + <!-- --> + <!-- suppressSmap Should the generation of SMAP info for JSR45 --> + <!-- debugging be suppressed? [false] --> + <!-- --> + <!-- trimSpaces Should white spaces in template text between --> + <!-- actions or directives be trimmed? [false] --> + <!-- --> + <!-- xpoweredBy Determines whether X-Powered-By response --> + <!-- header is added by generated servlet. [false] --> + <!-- --> + <!-- strictQuoteEscaping When scriptlet expressions are used for --> + <!-- attribute values, should the rules in JSP.1.6 --> + <!-- for the escaping of quote characters be --> + <!-- strictly applied? [true] --> + <!-- --> + <!-- quoteAttributeEL When EL is used in an attribute value on a --> + <!-- JSP page should the rules for quoting of --> + <!-- attributes described in JSP.1.6 be applied to --> + <!-- the expression? [true] --> + + <servlet> + <servlet-name>jsp</servlet-name> + <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> + <init-param> + <param-name>fork</param-name> + <param-value>false</param-value> + </init-param> + <init-param> + <param-name>xpoweredBy</param-name> + <param-value>false</param-value> + </init-param> + <load-on-startup>3</load-on-startup> + </servlet> + + + <!-- NOTE: An SSI Filter is also available as an alternative SSI --> + <!-- implementation. Use either the Servlet or the Filter but NOT both. --> + <!-- --> + <!-- Server Side Includes processing servlet, which processes SSI --> + <!-- directives in HTML pages consistent with similar support in web --> + <!-- servers like Apache. Traditionally, this servlet is mapped to the --> + <!-- URL pattern "*.shtml". This servlet supports the following --> + <!-- initialization parameters (default values are in square brackets): --> + <!-- --> + <!-- buffered Should output from this servlet be buffered? --> + <!-- (0=false, 1=true) [0] --> + <!-- --> + <!-- debug Debugging detail level for messages logged --> + <!-- by this servlet. [0] --> + <!-- --> + <!-- expires The number of seconds before a page with SSI --> + <!-- directives will expire. [No default] --> + <!-- --> + <!-- isVirtualWebappRelative --> + <!-- Should "virtual" paths be interpreted as --> + <!-- relative to the context root, instead of --> + <!-- the server root? [false] --> + <!-- --> + <!-- inputEncoding The encoding to assume for SSI resources if --> + <!-- one is not available from the resource. --> + <!-- [Platform default] --> + <!-- --> + <!-- outputEncoding The encoding to use for the page that results --> + <!-- from the SSI processing. [UTF-8] --> + <!-- --> + <!-- allowExec Is use of the exec command enabled? [false] --> + +<!-- + <servlet> + <servlet-name>ssi</servlet-name> + <servlet-class> + org.apache.catalina.ssi.SSIServlet + </servlet-class> + <init-param> + <param-name>buffered</param-name> + <param-value>1</param-value> + </init-param> + <init-param> + <param-name>debug</param-name> + <param-value>0</param-value> + </init-param> + <init-param> + <param-name>expires</param-name> + <param-value>666</param-value> + </init-param> + <init-param> + <param-name>isVirtualWebappRelative</param-name> + <param-value>false</param-value> + </init-param> + <load-on-startup>4</load-on-startup> + </servlet> +--> + + + <!-- Common Gateway Includes (CGI) processing servlet, which supports --> + <!-- execution of external applications that conform to the CGI spec --> + <!-- requirements. Typically, this servlet is mapped to the URL pattern --> + <!-- "/cgi-bin/*", which means that any CGI applications that are --> + <!-- executed must be present within the web application. This servlet --> + <!-- supports the following initialization parameters (default values --> + <!-- are in square brackets): --> + <!-- --> + <!-- cgiPathPrefix The CGI search path will start at --> + <!-- webAppRootDir + File.separator + this prefix. --> + <!-- If not set, then webAppRootDir is used. --> + <!-- Recommended value: WEB-INF/cgi --> + <!-- --> + <!-- debug Debugging detail level for messages logged --> + <!-- by this servlet. Useful values range from 0 --> + <!-- to 5 where 0 means no logging and 5 means --> + <!-- maximum logging. Values of 10 or more mean --> + <!-- maximum logging plus debug info added to the --> + <!-- HTTP response. If an error occurs and debug --> + <!-- is 10 or more the standard error page --> + <!-- mechanism will be disabled and a response --> + <!-- body with debug information will be produced. --> + <!-- Note that any value of 10 or more has the --> + <!-- same effect as a value of 10. If set to 10 or --> + <!-- more the standard error page mechanism will --> + <!-- be disabled and a debug page shown instead. --> + <!-- The debug page is not considered secure and --> + <!-- should not be enabled for production systems. --> + <!-- [0] --> + <!-- --> + <!-- executable Name of the executable used to run the --> + <!-- script. [perl] --> + <!-- --> + <!-- parameterEncoding Name of parameter encoding to be used with --> + <!-- CGI servlet. --> + <!-- [System.getProperty("file.encoding","UTF-8")] --> + <!-- --> + <!-- passShellEnvironment Should the shell environment variables (if --> + <!-- any) be passed to the CGI script? [false] --> + <!-- --> + <!-- stderrTimeout The time (in milliseconds) to wait for the --> + <!-- reading of stderr to complete before --> + <!-- terminating the CGI process. [2000] --> + +<!-- + <servlet> + <servlet-name>cgi</servlet-name> + <servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class> + <init-param> + <param-name>debug</param-name> + <param-value>0</param-value> + </init-param> + <init-param> + <param-name>cgiPathPrefix</param-name> + <param-value>WEB-INF/cgi</param-value> + </init-param> + <load-on-startup>5</load-on-startup> + </servlet> +--> + + + <!-- ================ Built In Servlet Mappings ========================= --> + + + <!-- The servlet mappings for the built in servlets defined above. Note --> + <!-- that, by default, the CGI and SSI servlets are *not* mapped. You --> + <!-- must uncomment these mappings (or add them to your application's own --> + <!-- web.xml deployment descriptor) to enable these services --> + + <!-- The mapping for the default servlet --> + <servlet-mapping> + <servlet-name>default</servlet-name> + <url-pattern>/</url-pattern> + </servlet-mapping> + + <!-- The mappings for the JSP servlet --> + <servlet-mapping> + <servlet-name>jsp</servlet-name> + <url-pattern>*.jsp</url-pattern> + <url-pattern>*.jspx</url-pattern> + </servlet-mapping> + + <!-- The mapping for the SSI servlet --> +<!-- + <servlet-mapping> + <servlet-name>ssi</servlet-name> + <url-pattern>*.shtml</url-pattern> + </servlet-mapping> +--> + + <!-- The mapping for the CGI Gateway servlet --> + +<!-- + <servlet-mapping> + <servlet-name>cgi</servlet-name> + <url-pattern>/cgi-bin/*</url-pattern> + </servlet-mapping> +--> + + + <!-- ================== Built In Filter Definitions ===================== --> + + <!-- A filter that sets various security related HTTP Response headers. --> + <!-- This filter supports the following initialization parameters --> + <!-- (default values are in square brackets): --> + <!-- --> + <!-- hstsEnabled Should the HTTP Strict Transport Security --> + <!-- (HSTS) header be added to the response? See --> + <!-- RFC 6797 for more information on HSTS. [true] --> + <!-- --> + <!-- hstsMaxAgeSeconds The max age value that should be used in the --> + <!-- HSTS header. Negative values will be treated --> + <!-- as zero. [0] --> + <!-- --> + <!-- hstsIncludeSubDomains --> + <!-- Should the includeSubDomains parameter be --> + <!-- included in the HSTS header. --> + <!-- --> + <!-- antiClickJackingEnabled --> + <!-- Should the anti click-jacking header --> + <!-- X-Frame-Options be added to every response? --> + <!-- [true] --> + <!-- --> + <!-- antiClickJackingOption --> + <!-- What value should be used for the header. Must --> + <!-- be one of DENY, SAMEORIGIN, ALLOW-FROM --> + <!-- (case-insensitive). [DENY] --> + <!-- --> + <!-- antiClickJackingUri IF ALLOW-FROM is used, what URI should be --> + <!-- allowed? [] --> + <!-- --> + <!-- blockContentTypeSniffingEnabled --> + <!-- Should the header that blocks content type --> + <!-- sniffing be added to every response? [true] --> +<!-- + <filter> + <filter-name>httpHeaderSecurity</filter-name> + <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class> + <async-supported>true</async-supported> + </filter> +--> + + <!-- A filter that sets character encoding that is used to decode --> + <!-- parameters in a POST request --> +<!-- + <filter> + <filter-name>setCharacterEncodingFilter</filter-name> + <filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class> + <init-param> + <param-name>encoding</param-name> + <param-value>UTF-8</param-value> + </init-param> + <async-supported>true</async-supported> + </filter> +--> + + <!-- A filter that triggers request parameters parsing and rejects the --> + <!-- request if some parameters were skipped because of parsing errors or --> + <!-- request size limitations. --> +<!-- + <filter> + <filter-name>failedRequestFilter</filter-name> + <filter-class> + org.apache.catalina.filters.FailedRequestFilter + </filter-class> + <async-supported>true</async-supported> + </filter> +--> + + + <!-- NOTE: An SSI Servlet is also available as an alternative SSI --> + <!-- implementation. Use either the Servlet or the Filter but NOT both. --> + <!-- --> + <!-- Server Side Includes processing filter, which processes SSI --> + <!-- directives in HTML pages consistent with similar support in web --> + <!-- servers like Apache. Traditionally, this filter is mapped to the --> + <!-- URL pattern "*.shtml", though it can be mapped to "*" as it will --> + <!-- selectively enable/disable SSI processing based on mime types. For --> + <!-- this to work you will need to uncomment the .shtml mime type --> + <!-- definition towards the bottom of this file. --> + <!-- The contentType init param allows you to apply SSI processing to JSP --> + <!-- pages, javascript, or any other content you wish. This filter --> + <!-- supports the following initialization parameters (default values are --> + <!-- in square brackets): --> + <!-- --> + <!-- contentType A regex pattern that must be matched before --> + <!-- SSI processing is applied. --> + <!-- [text/x-server-parsed-html(;.*)?] --> + <!-- --> + <!-- debug Debugging detail level for messages logged --> + <!-- by this servlet. [0] --> + <!-- --> + <!-- expires The number of seconds before a page with SSI --> + <!-- directives will expire. [No default] --> + <!-- --> + <!-- isVirtualWebappRelative --> + <!-- Should "virtual" paths be interpreted as --> + <!-- relative to the context root, instead of --> + <!-- the server root? [false] --> + <!-- --> + <!-- allowExec Is use of the exec command enabled? [false] --> + +<!-- + <filter> + <filter-name>ssi</filter-name> + <filter-class> + org.apache.catalina.ssi.SSIFilter + </filter-class> + <init-param> + <param-name>contentType</param-name> + <param-value>text/x-server-parsed-html(;.*)?</param-value> + </init-param> + <init-param> + <param-name>debug</param-name> + <param-value>0</param-value> + </init-param> + <init-param> + <param-name>expires</param-name> + <param-value>666</param-value> + </init-param> + <init-param> + <param-name>isVirtualWebappRelative</param-name> + <param-value>false</param-value> + </init-param> + </filter> +--> + + + <!-- ==================== Built In Filter Mappings ====================== --> + + <!-- The mapping for the HTTP header security Filter --> +<!-- + <filter-mapping> + <filter-name>httpHeaderSecurity</filter-name> + <url-pattern>/*</url-pattern> + <dispatcher>REQUEST</dispatcher> + </filter-mapping> +--> + + <!-- The mapping for the Set Character Encoding Filter --> +<!-- + <filter-mapping> + <filter-name>setCharacterEncodingFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> +--> + + <!-- The mapping for the Failed Request Filter --> +<!-- + <filter-mapping> + <filter-name>failedRequestFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> +--> + + <!-- The mapping for the SSI Filter --> +<!-- + <filter-mapping> + <filter-name>ssi</filter-name> + <url-pattern>*.shtml</url-pattern> + </filter-mapping> +--> + + + <!-- ==================== Default Session Configuration ================= --> + <!-- You can set the default session timeout (in minutes) for all newly --> + <!-- created sessions by modifying the value below. --> + + <session-config> + <session-timeout>30</session-timeout> + </session-config> + + + <!-- ===================== Default MIME Type Mappings =================== --> + <!-- When serving static resources, Tomcat will automatically generate --> + <!-- a "Content-Type" header based on the resource's filename extension, --> + <!-- based on these mappings. Additional mappings can be added here (to --> + <!-- apply to all web applications), or in your own application's web.xml --> + <!-- deployment descriptor. --> + <!-- Note: Extensions are always matched in a case-insensitive manner. --> + + <mime-mapping> + <extension>123</extension> + <mime-type>application/vnd.lotus-1-2-3</mime-type> + </mime-mapping> + <mime-mapping> + <extension>3dml</extension> + <mime-type>text/vnd.in3d.3dml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>3ds</extension> + <mime-type>image/x-3ds</mime-type> + </mime-mapping> + <mime-mapping> + <extension>3g2</extension> + <mime-type>video/3gpp2</mime-type> + </mime-mapping> + <mime-mapping> + <extension>3gp</extension> + <mime-type>video/3gpp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>7z</extension> + <mime-type>application/x-7z-compressed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aab</extension> + <mime-type>application/x-authorware-bin</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aac</extension> + <mime-type>audio/x-aac</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aam</extension> + <mime-type>application/x-authorware-map</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aas</extension> + <mime-type>application/x-authorware-seg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>abs</extension> + <mime-type>audio/x-mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>abw</extension> + <mime-type>application/x-abiword</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ac</extension> + <mime-type>application/pkix-attr-cert</mime-type> + </mime-mapping> + <mime-mapping> + <extension>acc</extension> + <mime-type>application/vnd.americandynamics.acc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ace</extension> + <mime-type>application/x-ace-compressed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>acu</extension> + <mime-type>application/vnd.acucobol</mime-type> + </mime-mapping> + <mime-mapping> + <extension>acutc</extension> + <mime-type>application/vnd.acucorp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>adp</extension> + <mime-type>audio/adpcm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aep</extension> + <mime-type>application/vnd.audiograph</mime-type> + </mime-mapping> + <mime-mapping> + <extension>afm</extension> + <mime-type>application/x-font-type1</mime-type> + </mime-mapping> + <mime-mapping> + <extension>afp</extension> + <mime-type>application/vnd.ibm.modcap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ahead</extension> + <mime-type>application/vnd.ahead.space</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ai</extension> + <mime-type>application/postscript</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aif</extension> + <mime-type>audio/x-aiff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aifc</extension> + <mime-type>audio/x-aiff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aiff</extension> + <mime-type>audio/x-aiff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aim</extension> + <mime-type>application/x-aim</mime-type> + </mime-mapping> + <mime-mapping> + <extension>air</extension> + <mime-type>application/vnd.adobe.air-application-installer-package+zip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ait</extension> + <mime-type>application/vnd.dvb.ait</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ami</extension> + <mime-type>application/vnd.amiga.ami</mime-type> + </mime-mapping> + <mime-mapping> + <extension>anx</extension> + <mime-type>application/annodex</mime-type> + </mime-mapping> + <mime-mapping> + <extension>apk</extension> + <mime-type>application/vnd.android.package-archive</mime-type> + </mime-mapping> + <mime-mapping> + <extension>appcache</extension> + <mime-type>text/cache-manifest</mime-type> + </mime-mapping> + <mime-mapping> + <extension>application</extension> + <mime-type>application/x-ms-application</mime-type> + </mime-mapping> + <mime-mapping> + <extension>apr</extension> + <mime-type>application/vnd.lotus-approach</mime-type> + </mime-mapping> + <mime-mapping> + <extension>arc</extension> + <mime-type>application/x-freearc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>art</extension> + <mime-type>image/x-jg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>asc</extension> + <mime-type>application/pgp-signature</mime-type> + </mime-mapping> + <mime-mapping> + <extension>asf</extension> + <mime-type>video/x-ms-asf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>asm</extension> + <mime-type>text/x-asm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aso</extension> + <mime-type>application/vnd.accpac.simply.aso</mime-type> + </mime-mapping> + <mime-mapping> + <extension>asx</extension> + <mime-type>video/x-ms-asf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>atc</extension> + <mime-type>application/vnd.acucorp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>atom</extension> + <mime-type>application/atom+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>atomcat</extension> + <mime-type>application/atomcat+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>atomsvc</extension> + <mime-type>application/atomsvc+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>atx</extension> + <mime-type>application/vnd.antix.game-component</mime-type> + </mime-mapping> + <mime-mapping> + <extension>au</extension> + <mime-type>audio/basic</mime-type> + </mime-mapping> + <mime-mapping> + <extension>avi</extension> + <mime-type>video/x-msvideo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>avx</extension> + <mime-type>video/x-rad-screenplay</mime-type> + </mime-mapping> + <mime-mapping> + <extension>aw</extension> + <mime-type>application/applixware</mime-type> + </mime-mapping> + <mime-mapping> + <extension>axa</extension> + <mime-type>audio/annodex</mime-type> + </mime-mapping> + <mime-mapping> + <extension>axv</extension> + <mime-type>video/annodex</mime-type> + </mime-mapping> + <mime-mapping> + <extension>azf</extension> + <mime-type>application/vnd.airzip.filesecure.azf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>azs</extension> + <mime-type>application/vnd.airzip.filesecure.azs</mime-type> + </mime-mapping> + <mime-mapping> + <extension>azw</extension> + <mime-type>application/vnd.amazon.ebook</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bat</extension> + <mime-type>application/x-msdownload</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bcpio</extension> + <mime-type>application/x-bcpio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bdf</extension> + <mime-type>application/x-font-bdf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bdm</extension> + <mime-type>application/vnd.syncml.dm+wbxml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bed</extension> + <mime-type>application/vnd.realvnc.bed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bh2</extension> + <mime-type>application/vnd.fujitsu.oasysprs</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bin</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>blb</extension> + <mime-type>application/x-blorb</mime-type> + </mime-mapping> + <mime-mapping> + <extension>blorb</extension> + <mime-type>application/x-blorb</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bmi</extension> + <mime-type>application/vnd.bmi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bmp</extension> + <mime-type>image/bmp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>body</extension> + <mime-type>text/html</mime-type> + </mime-mapping> + <mime-mapping> + <extension>book</extension> + <mime-type>application/vnd.framemaker</mime-type> + </mime-mapping> + <mime-mapping> + <extension>box</extension> + <mime-type>application/vnd.previewsystems.box</mime-type> + </mime-mapping> + <mime-mapping> + <extension>boz</extension> + <mime-type>application/x-bzip2</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bpk</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>btif</extension> + <mime-type>image/prs.btif</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bz</extension> + <mime-type>application/x-bzip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>bz2</extension> + <mime-type>application/x-bzip2</mime-type> + </mime-mapping> + <mime-mapping> + <extension>c</extension> + <mime-type>text/x-c</mime-type> + </mime-mapping> + <mime-mapping> + <extension>c11amc</extension> + <mime-type>application/vnd.cluetrust.cartomobile-config</mime-type> + </mime-mapping> + <mime-mapping> + <extension>c11amz</extension> + <mime-type>application/vnd.cluetrust.cartomobile-config-pkg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>c4d</extension> + <mime-type>application/vnd.clonk.c4group</mime-type> + </mime-mapping> + <mime-mapping> + <extension>c4f</extension> + <mime-type>application/vnd.clonk.c4group</mime-type> + </mime-mapping> + <mime-mapping> + <extension>c4g</extension> + <mime-type>application/vnd.clonk.c4group</mime-type> + </mime-mapping> + <mime-mapping> + <extension>c4p</extension> + <mime-type>application/vnd.clonk.c4group</mime-type> + </mime-mapping> + <mime-mapping> + <extension>c4u</extension> + <mime-type>application/vnd.clonk.c4group</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cab</extension> + <mime-type>application/vnd.ms-cab-compressed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>caf</extension> + <mime-type>audio/x-caf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cap</extension> + <mime-type>application/vnd.tcpdump.pcap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>car</extension> + <mime-type>application/vnd.curl.car</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cat</extension> + <mime-type>application/vnd.ms-pki.seccat</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cb7</extension> + <mime-type>application/x-cbr</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cba</extension> + <mime-type>application/x-cbr</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cbr</extension> + <mime-type>application/x-cbr</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cbt</extension> + <mime-type>application/x-cbr</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cbz</extension> + <mime-type>application/x-cbr</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cc</extension> + <mime-type>text/x-c</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cct</extension> + <mime-type>application/x-director</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ccxml</extension> + <mime-type>application/ccxml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdbcmsg</extension> + <mime-type>application/vnd.contact.cmsg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdf</extension> + <mime-type>application/x-cdf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdkey</extension> + <mime-type>application/vnd.mediastation.cdkey</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdmia</extension> + <mime-type>application/cdmi-capability</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdmic</extension> + <mime-type>application/cdmi-container</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdmid</extension> + <mime-type>application/cdmi-domain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdmio</extension> + <mime-type>application/cdmi-object</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdmiq</extension> + <mime-type>application/cdmi-queue</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdx</extension> + <mime-type>chemical/x-cdx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdxml</extension> + <mime-type>application/vnd.chemdraw+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cdy</extension> + <mime-type>application/vnd.cinderella</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cer</extension> + <mime-type>application/pkix-cert</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cfs</extension> + <mime-type>application/x-cfs-compressed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cgm</extension> + <mime-type>image/cgm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>chat</extension> + <mime-type>application/x-chat</mime-type> + </mime-mapping> + <mime-mapping> + <extension>chm</extension> + <mime-type>application/vnd.ms-htmlhelp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>chrt</extension> + <mime-type>application/vnd.kde.kchart</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cif</extension> + <mime-type>chemical/x-cif</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cii</extension> + <mime-type>application/vnd.anser-web-certificate-issue-initiation</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cil</extension> + <mime-type>application/vnd.ms-artgalry</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cla</extension> + <mime-type>application/vnd.claymore</mime-type> + </mime-mapping> + <mime-mapping> + <extension>class</extension> + <mime-type>application/java</mime-type> + </mime-mapping> + <mime-mapping> + <extension>clkk</extension> + <mime-type>application/vnd.crick.clicker.keyboard</mime-type> + </mime-mapping> + <mime-mapping> + <extension>clkp</extension> + <mime-type>application/vnd.crick.clicker.palette</mime-type> + </mime-mapping> + <mime-mapping> + <extension>clkt</extension> + <mime-type>application/vnd.crick.clicker.template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>clkw</extension> + <mime-type>application/vnd.crick.clicker.wordbank</mime-type> + </mime-mapping> + <mime-mapping> + <extension>clkx</extension> + <mime-type>application/vnd.crick.clicker</mime-type> + </mime-mapping> + <mime-mapping> + <extension>clp</extension> + <mime-type>application/x-msclip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cmc</extension> + <mime-type>application/vnd.cosmocaller</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cmdf</extension> + <mime-type>chemical/x-cmdf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cml</extension> + <mime-type>chemical/x-cml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cmp</extension> + <mime-type>application/vnd.yellowriver-custom-menu</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cmx</extension> + <mime-type>image/x-cmx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cod</extension> + <mime-type>application/vnd.rim.cod</mime-type> + </mime-mapping> + <mime-mapping> + <extension>com</extension> + <mime-type>application/x-msdownload</mime-type> + </mime-mapping> + <mime-mapping> + <extension>conf</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cpio</extension> + <mime-type>application/x-cpio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cpp</extension> + <mime-type>text/x-c</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cpt</extension> + <mime-type>application/mac-compactpro</mime-type> + </mime-mapping> + <mime-mapping> + <extension>crd</extension> + <mime-type>application/x-mscardfile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>crl</extension> + <mime-type>application/pkix-crl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>crt</extension> + <mime-type>application/x-x509-ca-cert</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cryptonote</extension> + <mime-type>application/vnd.rig.cryptonote</mime-type> + </mime-mapping> + <mime-mapping> + <extension>csh</extension> + <mime-type>application/x-csh</mime-type> + </mime-mapping> + <mime-mapping> + <extension>csml</extension> + <mime-type>chemical/x-csml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>csp</extension> + <mime-type>application/vnd.commonspace</mime-type> + </mime-mapping> + <mime-mapping> + <extension>css</extension> + <mime-type>text/css</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cst</extension> + <mime-type>application/x-director</mime-type> + </mime-mapping> + <mime-mapping> + <extension>csv</extension> + <mime-type>text/csv</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cu</extension> + <mime-type>application/cu-seeme</mime-type> + </mime-mapping> + <mime-mapping> + <extension>curl</extension> + <mime-type>text/vnd.curl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cww</extension> + <mime-type>application/prs.cww</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cxt</extension> + <mime-type>application/x-director</mime-type> + </mime-mapping> + <mime-mapping> + <extension>cxx</extension> + <mime-type>text/x-c</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dae</extension> + <mime-type>model/vnd.collada+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>daf</extension> + <mime-type>application/vnd.mobius.daf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dart</extension> + <mime-type>application/vnd.dart</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dataless</extension> + <mime-type>application/vnd.fdsn.seed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>davmount</extension> + <mime-type>application/davmount+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dbk</extension> + <mime-type>application/docbook+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dcr</extension> + <mime-type>application/x-director</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dcurl</extension> + <mime-type>text/vnd.curl.dcurl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dd2</extension> + <mime-type>application/vnd.oma.dd2+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ddd</extension> + <mime-type>application/vnd.fujixerox.ddd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>deb</extension> + <mime-type>application/x-debian-package</mime-type> + </mime-mapping> + <mime-mapping> + <extension>def</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>deploy</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>der</extension> + <mime-type>application/x-x509-ca-cert</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dfac</extension> + <mime-type>application/vnd.dreamfactory</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dgc</extension> + <mime-type>application/x-dgc-compressed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dib</extension> + <mime-type>image/bmp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dic</extension> + <mime-type>text/x-c</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dir</extension> + <mime-type>application/x-director</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dis</extension> + <mime-type>application/vnd.mobius.dis</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dist</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>distz</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>djv</extension> + <mime-type>image/vnd.djvu</mime-type> + </mime-mapping> + <mime-mapping> + <extension>djvu</extension> + <mime-type>image/vnd.djvu</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dll</extension> + <mime-type>application/x-msdownload</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dmg</extension> + <mime-type>application/x-apple-diskimage</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dmp</extension> + <mime-type>application/vnd.tcpdump.pcap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dms</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dna</extension> + <mime-type>application/vnd.dna</mime-type> + </mime-mapping> + <mime-mapping> + <extension>doc</extension> + <mime-type>application/msword</mime-type> + </mime-mapping> + <mime-mapping> + <extension>docm</extension> + <mime-type>application/vnd.ms-word.document.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>docx</extension> + <mime-type>application/vnd.openxmlformats-officedocument.wordprocessingml.document</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dot</extension> + <mime-type>application/msword</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dotm</extension> + <mime-type>application/vnd.ms-word.template.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dotx</extension> + <mime-type>application/vnd.openxmlformats-officedocument.wordprocessingml.template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dp</extension> + <mime-type>application/vnd.osgi.dp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dpg</extension> + <mime-type>application/vnd.dpgraph</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dra</extension> + <mime-type>audio/vnd.dra</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dsc</extension> + <mime-type>text/prs.lines.tag</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dssc</extension> + <mime-type>application/dssc+der</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dtb</extension> + <mime-type>application/x-dtbook+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dtd</extension> + <mime-type>application/xml-dtd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dts</extension> + <mime-type>audio/vnd.dts</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dtshd</extension> + <mime-type>audio/vnd.dts.hd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dump</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dv</extension> + <mime-type>video/x-dv</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dvb</extension> + <mime-type>video/vnd.dvb.file</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dvi</extension> + <mime-type>application/x-dvi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dwf</extension> + <mime-type>model/vnd.dwf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dwg</extension> + <mime-type>image/vnd.dwg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dxf</extension> + <mime-type>image/vnd.dxf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dxp</extension> + <mime-type>application/vnd.spotfire.dxp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>dxr</extension> + <mime-type>application/x-director</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ecelp4800</extension> + <mime-type>audio/vnd.nuera.ecelp4800</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ecelp7470</extension> + <mime-type>audio/vnd.nuera.ecelp7470</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ecelp9600</extension> + <mime-type>audio/vnd.nuera.ecelp9600</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ecma</extension> + <mime-type>application/ecmascript</mime-type> + </mime-mapping> + <mime-mapping> + <extension>edm</extension> + <mime-type>application/vnd.novadigm.edm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>edx</extension> + <mime-type>application/vnd.novadigm.edx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>efif</extension> + <mime-type>application/vnd.picsel</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ei6</extension> + <mime-type>application/vnd.pg.osasli</mime-type> + </mime-mapping> + <mime-mapping> + <extension>elc</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>emf</extension> + <mime-type>application/x-msmetafile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>eml</extension> + <mime-type>message/rfc822</mime-type> + </mime-mapping> + <mime-mapping> + <extension>emma</extension> + <mime-type>application/emma+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>emz</extension> + <mime-type>application/x-msmetafile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>eol</extension> + <mime-type>audio/vnd.digital-winds</mime-type> + </mime-mapping> + <mime-mapping> + <extension>eot</extension> + <mime-type>application/vnd.ms-fontobject</mime-type> + </mime-mapping> + <mime-mapping> + <extension>eps</extension> + <mime-type>application/postscript</mime-type> + </mime-mapping> + <mime-mapping> + <extension>epub</extension> + <mime-type>application/epub+zip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>es3</extension> + <mime-type>application/vnd.eszigno3+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>esa</extension> + <mime-type>application/vnd.osgi.subsystem</mime-type> + </mime-mapping> + <mime-mapping> + <extension>esf</extension> + <mime-type>application/vnd.epson.esf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>et3</extension> + <mime-type>application/vnd.eszigno3+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>etx</extension> + <mime-type>text/x-setext</mime-type> + </mime-mapping> + <mime-mapping> + <extension>eva</extension> + <mime-type>application/x-eva</mime-type> + </mime-mapping> + <mime-mapping> + <extension>evy</extension> + <mime-type>application/x-envoy</mime-type> + </mime-mapping> + <mime-mapping> + <extension>exe</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>exi</extension> + <mime-type>application/exi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ext</extension> + <mime-type>application/vnd.novadigm.ext</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ez</extension> + <mime-type>application/andrew-inset</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ez2</extension> + <mime-type>application/vnd.ezpix-album</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ez3</extension> + <mime-type>application/vnd.ezpix-package</mime-type> + </mime-mapping> + <mime-mapping> + <extension>f</extension> + <mime-type>text/x-fortran</mime-type> + </mime-mapping> + <mime-mapping> + <extension>f4v</extension> + <mime-type>video/x-f4v</mime-type> + </mime-mapping> + <mime-mapping> + <extension>f77</extension> + <mime-type>text/x-fortran</mime-type> + </mime-mapping> + <mime-mapping> + <extension>f90</extension> + <mime-type>text/x-fortran</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fbs</extension> + <mime-type>image/vnd.fastbidsheet</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fcdt</extension> + <mime-type>application/vnd.adobe.formscentral.fcdt</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fcs</extension> + <mime-type>application/vnd.isac.fcs</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fdf</extension> + <mime-type>application/vnd.fdf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fe_launch</extension> + <mime-type>application/vnd.denovo.fcselayout-link</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fg5</extension> + <mime-type>application/vnd.fujitsu.oasysgp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fgd</extension> + <mime-type>application/x-director</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fh</extension> + <mime-type>image/x-freehand</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fh4</extension> + <mime-type>image/x-freehand</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fh5</extension> + <mime-type>image/x-freehand</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fh7</extension> + <mime-type>image/x-freehand</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fhc</extension> + <mime-type>image/x-freehand</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fig</extension> + <mime-type>application/x-xfig</mime-type> + </mime-mapping> + <mime-mapping> + <extension>flac</extension> + <mime-type>audio/flac</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fli</extension> + <mime-type>video/x-fli</mime-type> + </mime-mapping> + <mime-mapping> + <extension>flo</extension> + <mime-type>application/vnd.micrografx.flo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>flv</extension> + <mime-type>video/x-flv</mime-type> + </mime-mapping> + <mime-mapping> + <extension>flw</extension> + <mime-type>application/vnd.kde.kivio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>flx</extension> + <mime-type>text/vnd.fmi.flexstor</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fly</extension> + <mime-type>text/vnd.fly</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fm</extension> + <mime-type>application/vnd.framemaker</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fnc</extension> + <mime-type>application/vnd.frogans.fnc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>for</extension> + <mime-type>text/x-fortran</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fpx</extension> + <mime-type>image/vnd.fpx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>frame</extension> + <mime-type>application/vnd.framemaker</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fsc</extension> + <mime-type>application/vnd.fsc.weblaunch</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fst</extension> + <mime-type>image/vnd.fst</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ftc</extension> + <mime-type>application/vnd.fluxtime.clip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fti</extension> + <mime-type>application/vnd.anser-web-funds-transfer-initiation</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fvt</extension> + <mime-type>video/vnd.fvt</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fxp</extension> + <mime-type>application/vnd.adobe.fxp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fxpl</extension> + <mime-type>application/vnd.adobe.fxp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>fzs</extension> + <mime-type>application/vnd.fuzzysheet</mime-type> + </mime-mapping> + <mime-mapping> + <extension>g2w</extension> + <mime-type>application/vnd.geoplan</mime-type> + </mime-mapping> + <mime-mapping> + <extension>g3</extension> + <mime-type>image/g3fax</mime-type> + </mime-mapping> + <mime-mapping> + <extension>g3w</extension> + <mime-type>application/vnd.geospace</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gac</extension> + <mime-type>application/vnd.groove-account</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gam</extension> + <mime-type>application/x-tads</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gbr</extension> + <mime-type>application/rpki-ghostbusters</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gca</extension> + <mime-type>application/x-gca-compressed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gdl</extension> + <mime-type>model/vnd.gdl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>geo</extension> + <mime-type>application/vnd.dynageo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gex</extension> + <mime-type>application/vnd.geometry-explorer</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ggb</extension> + <mime-type>application/vnd.geogebra.file</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ggt</extension> + <mime-type>application/vnd.geogebra.tool</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ghf</extension> + <mime-type>application/vnd.groove-help</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gif</extension> + <mime-type>image/gif</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gim</extension> + <mime-type>application/vnd.groove-identity-message</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gml</extension> + <mime-type>application/gml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gmx</extension> + <mime-type>application/vnd.gmx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gnumeric</extension> + <mime-type>application/x-gnumeric</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gph</extension> + <mime-type>application/vnd.flographit</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gpx</extension> + <mime-type>application/gpx+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gqf</extension> + <mime-type>application/vnd.grafeq</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gqs</extension> + <mime-type>application/vnd.grafeq</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gram</extension> + <mime-type>application/srgs</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gramps</extension> + <mime-type>application/x-gramps-xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gre</extension> + <mime-type>application/vnd.geometry-explorer</mime-type> + </mime-mapping> + <mime-mapping> + <extension>grv</extension> + <mime-type>application/vnd.groove-injector</mime-type> + </mime-mapping> + <mime-mapping> + <extension>grxml</extension> + <mime-type>application/srgs+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gsf</extension> + <mime-type>application/x-font-ghostscript</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gtar</extension> + <mime-type>application/x-gtar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gtm</extension> + <mime-type>application/vnd.groove-tool-message</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gtw</extension> + <mime-type>model/vnd.gtw</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gv</extension> + <mime-type>text/vnd.graphviz</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gxf</extension> + <mime-type>application/gxf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gxt</extension> + <mime-type>application/vnd.geonext</mime-type> + </mime-mapping> + <mime-mapping> + <extension>gz</extension> + <mime-type>application/x-gzip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>h</extension> + <mime-type>text/x-c</mime-type> + </mime-mapping> + <mime-mapping> + <extension>h261</extension> + <mime-type>video/h261</mime-type> + </mime-mapping> + <mime-mapping> + <extension>h263</extension> + <mime-type>video/h263</mime-type> + </mime-mapping> + <mime-mapping> + <extension>h264</extension> + <mime-type>video/h264</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hal</extension> + <mime-type>application/vnd.hal+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hbci</extension> + <mime-type>application/vnd.hbci</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hdf</extension> + <mime-type>application/x-hdf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hh</extension> + <mime-type>text/x-c</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hlp</extension> + <mime-type>application/winhlp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hpgl</extension> + <mime-type>application/vnd.hp-hpgl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hpid</extension> + <mime-type>application/vnd.hp-hpid</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hps</extension> + <mime-type>application/vnd.hp-hps</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hqx</extension> + <mime-type>application/mac-binhex40</mime-type> + </mime-mapping> + <mime-mapping> + <extension>htc</extension> + <mime-type>text/x-component</mime-type> + </mime-mapping> + <mime-mapping> + <extension>htke</extension> + <mime-type>application/vnd.kenameaapp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>htm</extension> + <mime-type>text/html</mime-type> + </mime-mapping> + <mime-mapping> + <extension>html</extension> + <mime-type>text/html</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hvd</extension> + <mime-type>application/vnd.yamaha.hv-dic</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hvp</extension> + <mime-type>application/vnd.yamaha.hv-voice</mime-type> + </mime-mapping> + <mime-mapping> + <extension>hvs</extension> + <mime-type>application/vnd.yamaha.hv-script</mime-type> + </mime-mapping> + <mime-mapping> + <extension>i2g</extension> + <mime-type>application/vnd.intergeo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>icc</extension> + <mime-type>application/vnd.iccprofile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ice</extension> + <mime-type>x-conference/x-cooltalk</mime-type> + </mime-mapping> + <mime-mapping> + <extension>icm</extension> + <mime-type>application/vnd.iccprofile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ico</extension> + <mime-type>image/x-icon</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ics</extension> + <mime-type>text/calendar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ief</extension> + <mime-type>image/ief</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ifb</extension> + <mime-type>text/calendar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ifm</extension> + <mime-type>application/vnd.shana.informed.formdata</mime-type> + </mime-mapping> + <mime-mapping> + <extension>iges</extension> + <mime-type>model/iges</mime-type> + </mime-mapping> + <mime-mapping> + <extension>igl</extension> + <mime-type>application/vnd.igloader</mime-type> + </mime-mapping> + <mime-mapping> + <extension>igm</extension> + <mime-type>application/vnd.insors.igm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>igs</extension> + <mime-type>model/iges</mime-type> + </mime-mapping> + <mime-mapping> + <extension>igx</extension> + <mime-type>application/vnd.micrografx.igx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>iif</extension> + <mime-type>application/vnd.shana.informed.interchange</mime-type> + </mime-mapping> + <mime-mapping> + <extension>imp</extension> + <mime-type>application/vnd.accpac.simply.imp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ims</extension> + <mime-type>application/vnd.ms-ims</mime-type> + </mime-mapping> + <mime-mapping> + <extension>in</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ink</extension> + <mime-type>application/inkml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>inkml</extension> + <mime-type>application/inkml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>install</extension> + <mime-type>application/x-install-instructions</mime-type> + </mime-mapping> + <mime-mapping> + <extension>iota</extension> + <mime-type>application/vnd.astraea-software.iota</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ipfix</extension> + <mime-type>application/ipfix</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ipk</extension> + <mime-type>application/vnd.shana.informed.package</mime-type> + </mime-mapping> + <mime-mapping> + <extension>irm</extension> + <mime-type>application/vnd.ibm.rights-management</mime-type> + </mime-mapping> + <mime-mapping> + <extension>irp</extension> + <mime-type>application/vnd.irepository.package+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>iso</extension> + <mime-type>application/x-iso9660-image</mime-type> + </mime-mapping> + <mime-mapping> + <extension>itp</extension> + <mime-type>application/vnd.shana.informed.formtemplate</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ivp</extension> + <mime-type>application/vnd.immervision-ivp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ivu</extension> + <mime-type>application/vnd.immervision-ivu</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jad</extension> + <mime-type>text/vnd.sun.j2me.app-descriptor</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jam</extension> + <mime-type>application/vnd.jam</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jar</extension> + <mime-type>application/java-archive</mime-type> + </mime-mapping> + <mime-mapping> + <extension>java</extension> + <mime-type>text/x-java-source</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jisp</extension> + <mime-type>application/vnd.jisp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jlt</extension> + <mime-type>application/vnd.hp-jlyt</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jnlp</extension> + <mime-type>application/x-java-jnlp-file</mime-type> + </mime-mapping> + <mime-mapping> + <extension>joda</extension> + <mime-type>application/vnd.joost.joda-archive</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jpe</extension> + <mime-type>image/jpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jpeg</extension> + <mime-type>image/jpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jpg</extension> + <mime-type>image/jpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jpgm</extension> + <mime-type>video/jpm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jpgv</extension> + <mime-type>video/jpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jpm</extension> + <mime-type>video/jpm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>js</extension> + <mime-type>application/javascript</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jsf</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>json</extension> + <mime-type>application/json</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jsonml</extension> + <mime-type>application/jsonml+json</mime-type> + </mime-mapping> + <mime-mapping> + <extension>jspf</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kar</extension> + <mime-type>audio/midi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>karbon</extension> + <mime-type>application/vnd.kde.karbon</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kfo</extension> + <mime-type>application/vnd.kde.kformula</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kia</extension> + <mime-type>application/vnd.kidspiration</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kml</extension> + <mime-type>application/vnd.google-earth.kml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kmz</extension> + <mime-type>application/vnd.google-earth.kmz</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kne</extension> + <mime-type>application/vnd.kinar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>knp</extension> + <mime-type>application/vnd.kinar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kon</extension> + <mime-type>application/vnd.kde.kontour</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kpr</extension> + <mime-type>application/vnd.kde.kpresenter</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kpt</extension> + <mime-type>application/vnd.kde.kpresenter</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kpxx</extension> + <mime-type>application/vnd.ds-keypoint</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ksp</extension> + <mime-type>application/vnd.kde.kspread</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ktr</extension> + <mime-type>application/vnd.kahootz</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ktx</extension> + <mime-type>image/ktx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ktz</extension> + <mime-type>application/vnd.kahootz</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kwd</extension> + <mime-type>application/vnd.kde.kword</mime-type> + </mime-mapping> + <mime-mapping> + <extension>kwt</extension> + <mime-type>application/vnd.kde.kword</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lasxml</extension> + <mime-type>application/vnd.las.las+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>latex</extension> + <mime-type>application/x-latex</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lbd</extension> + <mime-type>application/vnd.llamagraphics.life-balance.desktop</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lbe</extension> + <mime-type>application/vnd.llamagraphics.life-balance.exchange+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>les</extension> + <mime-type>application/vnd.hhe.lesson-player</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lha</extension> + <mime-type>application/x-lzh-compressed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>link66</extension> + <mime-type>application/vnd.route66.link66+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>list</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>list3820</extension> + <mime-type>application/vnd.ibm.modcap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>listafp</extension> + <mime-type>application/vnd.ibm.modcap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lnk</extension> + <mime-type>application/x-ms-shortcut</mime-type> + </mime-mapping> + <mime-mapping> + <extension>log</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lostxml</extension> + <mime-type>application/lost+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lrf</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lrm</extension> + <mime-type>application/vnd.ms-lrm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ltf</extension> + <mime-type>application/vnd.frogans.ltf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lvp</extension> + <mime-type>audio/vnd.lucent.voice</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lwp</extension> + <mime-type>application/vnd.lotus-wordpro</mime-type> + </mime-mapping> + <mime-mapping> + <extension>lzh</extension> + <mime-type>application/x-lzh-compressed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m13</extension> + <mime-type>application/x-msmediaview</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m14</extension> + <mime-type>application/x-msmediaview</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m1v</extension> + <mime-type>video/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m21</extension> + <mime-type>application/mp21</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m2a</extension> + <mime-type>audio/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m2v</extension> + <mime-type>video/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m3a</extension> + <mime-type>audio/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m3u</extension> + <mime-type>audio/x-mpegurl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m3u8</extension> + <mime-type>application/vnd.apple.mpegurl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m4a</extension> + <mime-type>audio/mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m4b</extension> + <mime-type>audio/mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m4r</extension> + <mime-type>audio/mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m4u</extension> + <mime-type>video/vnd.mpegurl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>m4v</extension> + <mime-type>video/mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ma</extension> + <mime-type>application/mathematica</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mac</extension> + <mime-type>image/x-macpaint</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mads</extension> + <mime-type>application/mads+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mag</extension> + <mime-type>application/vnd.ecowin.chart</mime-type> + </mime-mapping> + <mime-mapping> + <extension>maker</extension> + <mime-type>application/vnd.framemaker</mime-type> + </mime-mapping> + <mime-mapping> + <extension>man</extension> + <mime-type>text/troff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mar</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mathml</extension> + <mime-type>application/mathml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mb</extension> + <mime-type>application/mathematica</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mbk</extension> + <mime-type>application/vnd.mobius.mbk</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mbox</extension> + <mime-type>application/mbox</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mc1</extension> + <mime-type>application/vnd.medcalcdata</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mcd</extension> + <mime-type>application/vnd.mcd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mcurl</extension> + <mime-type>text/vnd.curl.mcurl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mdb</extension> + <mime-type>application/x-msaccess</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mdi</extension> + <mime-type>image/vnd.ms-modi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>me</extension> + <mime-type>text/troff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mesh</extension> + <mime-type>model/mesh</mime-type> + </mime-mapping> + <mime-mapping> + <extension>meta4</extension> + <mime-type>application/metalink4+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>metalink</extension> + <mime-type>application/metalink+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mets</extension> + <mime-type>application/mets+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mfm</extension> + <mime-type>application/vnd.mfmp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mft</extension> + <mime-type>application/rpki-manifest</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mgp</extension> + <mime-type>application/vnd.osgeo.mapguide.package</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mgz</extension> + <mime-type>application/vnd.proteus.magazine</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mid</extension> + <mime-type>audio/midi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>midi</extension> + <mime-type>audio/midi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mie</extension> + <mime-type>application/x-mie</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mif</extension> + <mime-type>application/x-mif</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mime</extension> + <mime-type>message/rfc822</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mj2</extension> + <mime-type>video/mj2</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mjp2</extension> + <mime-type>video/mj2</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mk3d</extension> + <mime-type>video/x-matroska</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mka</extension> + <mime-type>audio/x-matroska</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mks</extension> + <mime-type>video/x-matroska</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mkv</extension> + <mime-type>video/x-matroska</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mlp</extension> + <mime-type>application/vnd.dolby.mlp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mmd</extension> + <mime-type>application/vnd.chipnuts.karaoke-mmd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mmf</extension> + <mime-type>application/vnd.smaf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mmr</extension> + <mime-type>image/vnd.fujixerox.edmics-mmr</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mng</extension> + <mime-type>video/x-mng</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mny</extension> + <mime-type>application/x-msmoney</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mobi</extension> + <mime-type>application/x-mobipocket-ebook</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mods</extension> + <mime-type>application/mods+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mov</extension> + <mime-type>video/quicktime</mime-type> + </mime-mapping> + <mime-mapping> + <extension>movie</extension> + <mime-type>video/x-sgi-movie</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mp1</extension> + <mime-type>audio/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mp2</extension> + <mime-type>audio/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mp21</extension> + <mime-type>application/mp21</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mp2a</extension> + <mime-type>audio/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mp3</extension> + <mime-type>audio/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mp4</extension> + <mime-type>video/mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mp4a</extension> + <mime-type>audio/mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mp4s</extension> + <mime-type>application/mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mp4v</extension> + <mime-type>video/mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpa</extension> + <mime-type>audio/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpc</extension> + <mime-type>application/vnd.mophun.certificate</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpe</extension> + <mime-type>video/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpeg</extension> + <mime-type>video/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpega</extension> + <mime-type>audio/x-mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpg</extension> + <mime-type>video/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpg4</extension> + <mime-type>video/mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpga</extension> + <mime-type>audio/mpeg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpkg</extension> + <mime-type>application/vnd.apple.installer+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpm</extension> + <mime-type>application/vnd.blueice.multipass</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpn</extension> + <mime-type>application/vnd.mophun.application</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpp</extension> + <mime-type>application/vnd.ms-project</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpt</extension> + <mime-type>application/vnd.ms-project</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpv2</extension> + <mime-type>video/mpeg2</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mpy</extension> + <mime-type>application/vnd.ibm.minipay</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mqy</extension> + <mime-type>application/vnd.mobius.mqy</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mrc</extension> + <mime-type>application/marc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mrcx</extension> + <mime-type>application/marcxml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ms</extension> + <mime-type>text/troff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mscml</extension> + <mime-type>application/mediaservercontrol+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mseed</extension> + <mime-type>application/vnd.fdsn.mseed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mseq</extension> + <mime-type>application/vnd.mseq</mime-type> + </mime-mapping> + <mime-mapping> + <extension>msf</extension> + <mime-type>application/vnd.epson.msf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>msh</extension> + <mime-type>model/mesh</mime-type> + </mime-mapping> + <mime-mapping> + <extension>msi</extension> + <mime-type>application/x-msdownload</mime-type> + </mime-mapping> + <mime-mapping> + <extension>msl</extension> + <mime-type>application/vnd.mobius.msl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>msty</extension> + <mime-type>application/vnd.muvee.style</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mts</extension> + <mime-type>model/vnd.mts</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mus</extension> + <mime-type>application/vnd.musician</mime-type> + </mime-mapping> + <mime-mapping> + <extension>musicxml</extension> + <mime-type>application/vnd.recordare.musicxml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mvb</extension> + <mime-type>application/x-msmediaview</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mwf</extension> + <mime-type>application/vnd.mfer</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mxf</extension> + <mime-type>application/mxf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mxl</extension> + <mime-type>application/vnd.recordare.musicxml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mxml</extension> + <mime-type>application/xv+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mxs</extension> + <mime-type>application/vnd.triscape.mxs</mime-type> + </mime-mapping> + <mime-mapping> + <extension>mxu</extension> + <mime-type>video/vnd.mpegurl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>n-gage</extension> + <mime-type>application/vnd.nokia.n-gage.symbian.install</mime-type> + </mime-mapping> + <mime-mapping> + <extension>n3</extension> + <mime-type>text/n3</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nb</extension> + <mime-type>application/mathematica</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nbp</extension> + <mime-type>application/vnd.wolfram.player</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nc</extension> + <mime-type>application/x-netcdf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ncx</extension> + <mime-type>application/x-dtbncx+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nfo</extension> + <mime-type>text/x-nfo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ngdat</extension> + <mime-type>application/vnd.nokia.n-gage.data</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nitf</extension> + <mime-type>application/vnd.nitf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nlu</extension> + <mime-type>application/vnd.neurolanguage.nlu</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nml</extension> + <mime-type>application/vnd.enliven</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nnd</extension> + <mime-type>application/vnd.noblenet-directory</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nns</extension> + <mime-type>application/vnd.noblenet-sealer</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nnw</extension> + <mime-type>application/vnd.noblenet-web</mime-type> + </mime-mapping> + <mime-mapping> + <extension>npx</extension> + <mime-type>image/vnd.net-fpx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nsc</extension> + <mime-type>application/x-conference</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nsf</extension> + <mime-type>application/vnd.lotus-notes</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ntf</extension> + <mime-type>application/vnd.nitf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>nzb</extension> + <mime-type>application/x-nzb</mime-type> + </mime-mapping> + <mime-mapping> + <extension>oa2</extension> + <mime-type>application/vnd.fujitsu.oasys2</mime-type> + </mime-mapping> + <mime-mapping> + <extension>oa3</extension> + <mime-type>application/vnd.fujitsu.oasys3</mime-type> + </mime-mapping> + <mime-mapping> + <extension>oas</extension> + <mime-type>application/vnd.fujitsu.oasys</mime-type> + </mime-mapping> + <mime-mapping> + <extension>obd</extension> + <mime-type>application/x-msbinder</mime-type> + </mime-mapping> + <mime-mapping> + <extension>obj</extension> + <mime-type>application/x-tgif</mime-type> + </mime-mapping> + <mime-mapping> + <extension>oda</extension> + <mime-type>application/oda</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Database --> + <extension>odb</extension> + <mime-type>application/vnd.oasis.opendocument.database</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Chart --> + <extension>odc</extension> + <mime-type>application/vnd.oasis.opendocument.chart</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Formula --> + <extension>odf</extension> + <mime-type>application/vnd.oasis.opendocument.formula</mime-type> + </mime-mapping> + <mime-mapping> + <extension>odft</extension> + <mime-type>application/vnd.oasis.opendocument.formula-template</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Drawing --> + <extension>odg</extension> + <mime-type>application/vnd.oasis.opendocument.graphics</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Image --> + <extension>odi</extension> + <mime-type>application/vnd.oasis.opendocument.image</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Master Document --> + <extension>odm</extension> + <mime-type>application/vnd.oasis.opendocument.text-master</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Presentation --> + <extension>odp</extension> + <mime-type>application/vnd.oasis.opendocument.presentation</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Spreadsheet --> + <extension>ods</extension> + <mime-type>application/vnd.oasis.opendocument.spreadsheet</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Text --> + <extension>odt</extension> + <mime-type>application/vnd.oasis.opendocument.text</mime-type> + </mime-mapping> + <mime-mapping> + <extension>oga</extension> + <mime-type>audio/ogg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ogg</extension> + <mime-type>audio/ogg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ogv</extension> + <mime-type>video/ogg</mime-type> + </mime-mapping> + <mime-mapping> + <!-- xiph mime types --> + <extension>ogx</extension> + <mime-type>application/ogg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>omdoc</extension> + <mime-type>application/omdoc+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>onepkg</extension> + <mime-type>application/onenote</mime-type> + </mime-mapping> + <mime-mapping> + <extension>onetmp</extension> + <mime-type>application/onenote</mime-type> + </mime-mapping> + <mime-mapping> + <extension>onetoc</extension> + <mime-type>application/onenote</mime-type> + </mime-mapping> + <mime-mapping> + <extension>onetoc2</extension> + <mime-type>application/onenote</mime-type> + </mime-mapping> + <mime-mapping> + <extension>opf</extension> + <mime-type>application/oebps-package+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>opml</extension> + <mime-type>text/x-opml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>oprc</extension> + <mime-type>application/vnd.palm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>org</extension> + <mime-type>application/vnd.lotus-organizer</mime-type> + </mime-mapping> + <mime-mapping> + <extension>osf</extension> + <mime-type>application/vnd.yamaha.openscoreformat</mime-type> + </mime-mapping> + <mime-mapping> + <extension>osfpvg</extension> + <mime-type>application/vnd.yamaha.openscoreformat.osfpvg+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>otc</extension> + <mime-type>application/vnd.oasis.opendocument.chart-template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>otf</extension> + <mime-type>application/x-font-otf</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Drawing Template --> + <extension>otg</extension> + <mime-type>application/vnd.oasis.opendocument.graphics-template</mime-type> + </mime-mapping> + <mime-mapping> + <!-- HTML Document Template --> + <extension>oth</extension> + <mime-type>application/vnd.oasis.opendocument.text-web</mime-type> + </mime-mapping> + <mime-mapping> + <extension>oti</extension> + <mime-type>application/vnd.oasis.opendocument.image-template</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Presentation Template --> + <extension>otp</extension> + <mime-type>application/vnd.oasis.opendocument.presentation-template</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Spreadsheet Template --> + <extension>ots</extension> + <mime-type>application/vnd.oasis.opendocument.spreadsheet-template</mime-type> + </mime-mapping> + <mime-mapping> + <!-- OpenDocument Text Template --> + <extension>ott</extension> + <mime-type>application/vnd.oasis.opendocument.text-template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>oxps</extension> + <mime-type>application/oxps</mime-type> + </mime-mapping> + <mime-mapping> + <extension>oxt</extension> + <mime-type>application/vnd.openofficeorg.extension</mime-type> + </mime-mapping> + <mime-mapping> + <extension>p</extension> + <mime-type>text/x-pascal</mime-type> + </mime-mapping> + <mime-mapping> + <extension>p10</extension> + <mime-type>application/pkcs10</mime-type> + </mime-mapping> + <mime-mapping> + <extension>p12</extension> + <mime-type>application/x-pkcs12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>p7b</extension> + <mime-type>application/x-pkcs7-certificates</mime-type> + </mime-mapping> + <mime-mapping> + <extension>p7c</extension> + <mime-type>application/pkcs7-mime</mime-type> + </mime-mapping> + <mime-mapping> + <extension>p7m</extension> + <mime-type>application/pkcs7-mime</mime-type> + </mime-mapping> + <mime-mapping> + <extension>p7r</extension> + <mime-type>application/x-pkcs7-certreqresp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>p7s</extension> + <mime-type>application/pkcs7-signature</mime-type> + </mime-mapping> + <mime-mapping> + <extension>p8</extension> + <mime-type>application/pkcs8</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pas</extension> + <mime-type>text/x-pascal</mime-type> + </mime-mapping> + <mime-mapping> + <extension>paw</extension> + <mime-type>application/vnd.pawaafile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pbd</extension> + <mime-type>application/vnd.powerbuilder6</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pbm</extension> + <mime-type>image/x-portable-bitmap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pcap</extension> + <mime-type>application/vnd.tcpdump.pcap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pcf</extension> + <mime-type>application/x-font-pcf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pcl</extension> + <mime-type>application/vnd.hp-pcl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pclxl</extension> + <mime-type>application/vnd.hp-pclxl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pct</extension> + <mime-type>image/pict</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pcurl</extension> + <mime-type>application/vnd.curl.pcurl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pcx</extension> + <mime-type>image/x-pcx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pdb</extension> + <mime-type>application/vnd.palm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pdf</extension> + <mime-type>application/pdf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pfa</extension> + <mime-type>application/x-font-type1</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pfb</extension> + <mime-type>application/x-font-type1</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pfm</extension> + <mime-type>application/x-font-type1</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pfr</extension> + <mime-type>application/font-tdpfr</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pfx</extension> + <mime-type>application/x-pkcs12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pgm</extension> + <mime-type>image/x-portable-graymap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pgn</extension> + <mime-type>application/x-chess-pgn</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pgp</extension> + <mime-type>application/pgp-encrypted</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pic</extension> + <mime-type>image/pict</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pict</extension> + <mime-type>image/pict</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pkg</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pki</extension> + <mime-type>application/pkixcmp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pkipath</extension> + <mime-type>application/pkix-pkipath</mime-type> + </mime-mapping> + <mime-mapping> + <extension>plb</extension> + <mime-type>application/vnd.3gpp.pic-bw-large</mime-type> + </mime-mapping> + <mime-mapping> + <extension>plc</extension> + <mime-type>application/vnd.mobius.plc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>plf</extension> + <mime-type>application/vnd.pocketlearn</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pls</extension> + <mime-type>audio/x-scpls</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pml</extension> + <mime-type>application/vnd.ctc-posml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>png</extension> + <mime-type>image/png</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pnm</extension> + <mime-type>image/x-portable-anymap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pnt</extension> + <mime-type>image/x-macpaint</mime-type> + </mime-mapping> + <mime-mapping> + <extension>portpkg</extension> + <mime-type>application/vnd.macports.portpkg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pot</extension> + <mime-type>application/vnd.ms-powerpoint</mime-type> + </mime-mapping> + <mime-mapping> + <extension>potm</extension> + <mime-type>application/vnd.ms-powerpoint.template.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>potx</extension> + <mime-type>application/vnd.openxmlformats-officedocument.presentationml.template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ppam</extension> + <mime-type>application/vnd.ms-powerpoint.addin.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ppd</extension> + <mime-type>application/vnd.cups-ppd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ppm</extension> + <mime-type>image/x-portable-pixmap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pps</extension> + <mime-type>application/vnd.ms-powerpoint</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ppsm</extension> + <mime-type>application/vnd.ms-powerpoint.slideshow.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ppsx</extension> + <mime-type>application/vnd.openxmlformats-officedocument.presentationml.slideshow</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ppt</extension> + <mime-type>application/vnd.ms-powerpoint</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pptm</extension> + <mime-type>application/vnd.ms-powerpoint.presentation.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pptx</extension> + <mime-type>application/vnd.openxmlformats-officedocument.presentationml.presentation</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pqa</extension> + <mime-type>application/vnd.palm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>prc</extension> + <mime-type>application/x-mobipocket-ebook</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pre</extension> + <mime-type>application/vnd.lotus-freelance</mime-type> + </mime-mapping> + <mime-mapping> + <extension>prf</extension> + <mime-type>application/pics-rules</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ps</extension> + <mime-type>application/postscript</mime-type> + </mime-mapping> + <mime-mapping> + <extension>psb</extension> + <mime-type>application/vnd.3gpp.pic-bw-small</mime-type> + </mime-mapping> + <mime-mapping> + <extension>psd</extension> + <mime-type>image/vnd.adobe.photoshop</mime-type> + </mime-mapping> + <mime-mapping> + <extension>psf</extension> + <mime-type>application/x-font-linux-psf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pskcxml</extension> + <mime-type>application/pskc+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ptid</extension> + <mime-type>application/vnd.pvi.ptid1</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pub</extension> + <mime-type>application/x-mspublisher</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pvb</extension> + <mime-type>application/vnd.3gpp.pic-bw-var</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pwn</extension> + <mime-type>application/vnd.3m.post-it-notes</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pya</extension> + <mime-type>audio/vnd.ms-playready.media.pya</mime-type> + </mime-mapping> + <mime-mapping> + <extension>pyv</extension> + <mime-type>video/vnd.ms-playready.media.pyv</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qam</extension> + <mime-type>application/vnd.epson.quickanime</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qbo</extension> + <mime-type>application/vnd.intu.qbo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qfx</extension> + <mime-type>application/vnd.intu.qfx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qps</extension> + <mime-type>application/vnd.publishare-delta-tree</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qt</extension> + <mime-type>video/quicktime</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qti</extension> + <mime-type>image/x-quicktime</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qtif</extension> + <mime-type>image/x-quicktime</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qwd</extension> + <mime-type>application/vnd.quark.quarkxpress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qwt</extension> + <mime-type>application/vnd.quark.quarkxpress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qxb</extension> + <mime-type>application/vnd.quark.quarkxpress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qxd</extension> + <mime-type>application/vnd.quark.quarkxpress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qxl</extension> + <mime-type>application/vnd.quark.quarkxpress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>qxt</extension> + <mime-type>application/vnd.quark.quarkxpress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ra</extension> + <mime-type>audio/x-pn-realaudio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ram</extension> + <mime-type>audio/x-pn-realaudio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rar</extension> + <mime-type>application/x-rar-compressed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ras</extension> + <mime-type>image/x-cmu-raster</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rcprofile</extension> + <mime-type>application/vnd.ipunplugged.rcprofile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rdf</extension> + <mime-type>application/rdf+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rdz</extension> + <mime-type>application/vnd.data-vision.rdz</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rep</extension> + <mime-type>application/vnd.businessobjects</mime-type> + </mime-mapping> + <mime-mapping> + <extension>res</extension> + <mime-type>application/x-dtbresource+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rgb</extension> + <mime-type>image/x-rgb</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rif</extension> + <mime-type>application/reginfo+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rip</extension> + <mime-type>audio/vnd.rip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ris</extension> + <mime-type>application/x-research-info-systems</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rl</extension> + <mime-type>application/resource-lists+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rlc</extension> + <mime-type>image/vnd.fujixerox.edmics-rlc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rld</extension> + <mime-type>application/resource-lists-diff+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rm</extension> + <mime-type>application/vnd.rn-realmedia</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rmi</extension> + <mime-type>audio/midi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rmp</extension> + <mime-type>audio/x-pn-realaudio-plugin</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rms</extension> + <mime-type>application/vnd.jcp.javame.midlet-rms</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rmvb</extension> + <mime-type>application/vnd.rn-realmedia-vbr</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rnc</extension> + <mime-type>application/relax-ng-compact-syntax</mime-type> + </mime-mapping> + <mime-mapping> + <extension>roa</extension> + <mime-type>application/rpki-roa</mime-type> + </mime-mapping> + <mime-mapping> + <extension>roff</extension> + <mime-type>text/troff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rp9</extension> + <mime-type>application/vnd.cloanto.rp9</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rpss</extension> + <mime-type>application/vnd.nokia.radio-presets</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rpst</extension> + <mime-type>application/vnd.nokia.radio-preset</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rq</extension> + <mime-type>application/sparql-query</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rs</extension> + <mime-type>application/rls-services+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rsd</extension> + <mime-type>application/rsd+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rss</extension> + <mime-type>application/rss+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rtf</extension> + <mime-type>application/rtf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>rtx</extension> + <mime-type>text/richtext</mime-type> + </mime-mapping> + <mime-mapping> + <extension>s</extension> + <mime-type>text/x-asm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>s3m</extension> + <mime-type>audio/s3m</mime-type> + </mime-mapping> + <mime-mapping> + <extension>saf</extension> + <mime-type>application/vnd.yamaha.smaf-audio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sbml</extension> + <mime-type>application/sbml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sc</extension> + <mime-type>application/vnd.ibm.secure-container</mime-type> + </mime-mapping> + <mime-mapping> + <extension>scd</extension> + <mime-type>application/x-msschedule</mime-type> + </mime-mapping> + <mime-mapping> + <extension>scm</extension> + <mime-type>application/vnd.lotus-screencam</mime-type> + </mime-mapping> + <mime-mapping> + <extension>scq</extension> + <mime-type>application/scvp-cv-request</mime-type> + </mime-mapping> + <mime-mapping> + <extension>scs</extension> + <mime-type>application/scvp-cv-response</mime-type> + </mime-mapping> + <mime-mapping> + <extension>scurl</extension> + <mime-type>text/vnd.curl.scurl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sda</extension> + <mime-type>application/vnd.stardivision.draw</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sdc</extension> + <mime-type>application/vnd.stardivision.calc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sdd</extension> + <mime-type>application/vnd.stardivision.impress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sdkd</extension> + <mime-type>application/vnd.solent.sdkm+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sdkm</extension> + <mime-type>application/vnd.solent.sdkm+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sdp</extension> + <mime-type>application/sdp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sdw</extension> + <mime-type>application/vnd.stardivision.writer</mime-type> + </mime-mapping> + <mime-mapping> + <extension>see</extension> + <mime-type>application/vnd.seemail</mime-type> + </mime-mapping> + <mime-mapping> + <extension>seed</extension> + <mime-type>application/vnd.fdsn.seed</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sema</extension> + <mime-type>application/vnd.sema</mime-type> + </mime-mapping> + <mime-mapping> + <extension>semd</extension> + <mime-type>application/vnd.semd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>semf</extension> + <mime-type>application/vnd.semf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ser</extension> + <mime-type>application/java-serialized-object</mime-type> + </mime-mapping> + <mime-mapping> + <extension>setpay</extension> + <mime-type>application/set-payment-initiation</mime-type> + </mime-mapping> + <mime-mapping> + <extension>setreg</extension> + <mime-type>application/set-registration-initiation</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sfd-hdstx</extension> + <mime-type>application/vnd.hydrostatix.sof-data</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sfs</extension> + <mime-type>application/vnd.spotfire.sfs</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sfv</extension> + <mime-type>text/x-sfv</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sgi</extension> + <mime-type>image/sgi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sgl</extension> + <mime-type>application/vnd.stardivision.writer-global</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sgm</extension> + <mime-type>text/sgml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sgml</extension> + <mime-type>text/sgml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sh</extension> + <mime-type>application/x-sh</mime-type> + </mime-mapping> + <mime-mapping> + <extension>shar</extension> + <mime-type>application/x-shar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>shf</extension> + <mime-type>application/shf+xml</mime-type> + </mime-mapping> + <!-- + <mime-mapping> + <extension>shtml</extension> + <mime-type>text/x-server-parsed-html</mime-type> + </mime-mapping> + --> + <mime-mapping> + <extension>sid</extension> + <mime-type>image/x-mrsid-image</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sig</extension> + <mime-type>application/pgp-signature</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sil</extension> + <mime-type>audio/silk</mime-type> + </mime-mapping> + <mime-mapping> + <extension>silo</extension> + <mime-type>model/mesh</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sis</extension> + <mime-type>application/vnd.symbian.install</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sisx</extension> + <mime-type>application/vnd.symbian.install</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sit</extension> + <mime-type>application/x-stuffit</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sitx</extension> + <mime-type>application/x-stuffitx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>skd</extension> + <mime-type>application/vnd.koan</mime-type> + </mime-mapping> + <mime-mapping> + <extension>skm</extension> + <mime-type>application/vnd.koan</mime-type> + </mime-mapping> + <mime-mapping> + <extension>skp</extension> + <mime-type>application/vnd.koan</mime-type> + </mime-mapping> + <mime-mapping> + <extension>skt</extension> + <mime-type>application/vnd.koan</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sldm</extension> + <mime-type>application/vnd.ms-powerpoint.slide.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sldx</extension> + <mime-type>application/vnd.openxmlformats-officedocument.presentationml.slide</mime-type> + </mime-mapping> + <mime-mapping> + <extension>slt</extension> + <mime-type>application/vnd.epson.salt</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sm</extension> + <mime-type>application/vnd.stepmania.stepchart</mime-type> + </mime-mapping> + <mime-mapping> + <extension>smf</extension> + <mime-type>application/vnd.stardivision.math</mime-type> + </mime-mapping> + <mime-mapping> + <extension>smi</extension> + <mime-type>application/smil+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>smil</extension> + <mime-type>application/smil+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>smv</extension> + <mime-type>video/x-smv</mime-type> + </mime-mapping> + <mime-mapping> + <extension>smzip</extension> + <mime-type>application/vnd.stepmania.package</mime-type> + </mime-mapping> + <mime-mapping> + <extension>snd</extension> + <mime-type>audio/basic</mime-type> + </mime-mapping> + <mime-mapping> + <extension>snf</extension> + <mime-type>application/x-font-snf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>so</extension> + <mime-type>application/octet-stream</mime-type> + </mime-mapping> + <mime-mapping> + <extension>spc</extension> + <mime-type>application/x-pkcs7-certificates</mime-type> + </mime-mapping> + <mime-mapping> + <extension>spf</extension> + <mime-type>application/vnd.yamaha.smaf-phrase</mime-type> + </mime-mapping> + <mime-mapping> + <extension>spl</extension> + <mime-type>application/x-futuresplash</mime-type> + </mime-mapping> + <mime-mapping> + <extension>spot</extension> + <mime-type>text/vnd.in3d.spot</mime-type> + </mime-mapping> + <mime-mapping> + <extension>spp</extension> + <mime-type>application/scvp-vp-response</mime-type> + </mime-mapping> + <mime-mapping> + <extension>spq</extension> + <mime-type>application/scvp-vp-request</mime-type> + </mime-mapping> + <mime-mapping> + <extension>spx</extension> + <mime-type>audio/ogg</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sql</extension> + <mime-type>application/x-sql</mime-type> + </mime-mapping> + <mime-mapping> + <extension>src</extension> + <mime-type>application/x-wais-source</mime-type> + </mime-mapping> + <mime-mapping> + <extension>srt</extension> + <mime-type>application/x-subrip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sru</extension> + <mime-type>application/sru+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>srx</extension> + <mime-type>application/sparql-results+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ssdl</extension> + <mime-type>application/ssdl+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sse</extension> + <mime-type>application/vnd.kodak-descriptor</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ssf</extension> + <mime-type>application/vnd.epson.ssf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ssml</extension> + <mime-type>application/ssml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>st</extension> + <mime-type>application/vnd.sailingtracker.track</mime-type> + </mime-mapping> + <mime-mapping> + <extension>stc</extension> + <mime-type>application/vnd.sun.xml.calc.template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>std</extension> + <mime-type>application/vnd.sun.xml.draw.template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>stf</extension> + <mime-type>application/vnd.wt.stf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sti</extension> + <mime-type>application/vnd.sun.xml.impress.template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>stk</extension> + <mime-type>application/hyperstudio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>stl</extension> + <mime-type>application/vnd.ms-pki.stl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>str</extension> + <mime-type>application/vnd.pg.format</mime-type> + </mime-mapping> + <mime-mapping> + <extension>stw</extension> + <mime-type>application/vnd.sun.xml.writer.template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sub</extension> + <mime-type>text/vnd.dvb.subtitle</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sus</extension> + <mime-type>application/vnd.sus-calendar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>susp</extension> + <mime-type>application/vnd.sus-calendar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sv4cpio</extension> + <mime-type>application/x-sv4cpio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sv4crc</extension> + <mime-type>application/x-sv4crc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>svc</extension> + <mime-type>application/vnd.dvb.service</mime-type> + </mime-mapping> + <mime-mapping> + <extension>svd</extension> + <mime-type>application/vnd.svd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>svg</extension> + <mime-type>image/svg+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>svgz</extension> + <mime-type>image/svg+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>swa</extension> + <mime-type>application/x-director</mime-type> + </mime-mapping> + <mime-mapping> + <extension>swf</extension> + <mime-type>application/x-shockwave-flash</mime-type> + </mime-mapping> + <mime-mapping> + <extension>swi</extension> + <mime-type>application/vnd.aristanetworks.swi</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sxc</extension> + <mime-type>application/vnd.sun.xml.calc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sxd</extension> + <mime-type>application/vnd.sun.xml.draw</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sxg</extension> + <mime-type>application/vnd.sun.xml.writer.global</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sxi</extension> + <mime-type>application/vnd.sun.xml.impress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sxm</extension> + <mime-type>application/vnd.sun.xml.math</mime-type> + </mime-mapping> + <mime-mapping> + <extension>sxw</extension> + <mime-type>application/vnd.sun.xml.writer</mime-type> + </mime-mapping> + <mime-mapping> + <extension>t</extension> + <mime-type>text/troff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>t3</extension> + <mime-type>application/x-t3vm-image</mime-type> + </mime-mapping> + <mime-mapping> + <extension>taglet</extension> + <mime-type>application/vnd.mynfc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tao</extension> + <mime-type>application/vnd.tao.intent-module-archive</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tar</extension> + <mime-type>application/x-tar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tcap</extension> + <mime-type>application/vnd.3gpp2.tcap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tcl</extension> + <mime-type>application/x-tcl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>teacher</extension> + <mime-type>application/vnd.smart.teacher</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tei</extension> + <mime-type>application/tei+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>teicorpus</extension> + <mime-type>application/tei+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tex</extension> + <mime-type>application/x-tex</mime-type> + </mime-mapping> + <mime-mapping> + <extension>texi</extension> + <mime-type>application/x-texinfo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>texinfo</extension> + <mime-type>application/x-texinfo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>text</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tfi</extension> + <mime-type>application/thraud+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tfm</extension> + <mime-type>application/x-tex-tfm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tga</extension> + <mime-type>image/x-tga</mime-type> + </mime-mapping> + <mime-mapping> + <extension>thmx</extension> + <mime-type>application/vnd.ms-officetheme</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tif</extension> + <mime-type>image/tiff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tiff</extension> + <mime-type>image/tiff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tmo</extension> + <mime-type>application/vnd.tmobile-livetv</mime-type> + </mime-mapping> + <mime-mapping> + <extension>torrent</extension> + <mime-type>application/x-bittorrent</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tpl</extension> + <mime-type>application/vnd.groove-tool-template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tpt</extension> + <mime-type>application/vnd.trid.tpt</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tr</extension> + <mime-type>text/troff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tra</extension> + <mime-type>application/vnd.trueapp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>trm</extension> + <mime-type>application/x-msterminal</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tsd</extension> + <mime-type>application/timestamped-data</mime-type> + </mime-mapping> + <mime-mapping> + <extension>tsv</extension> + <mime-type>text/tab-separated-values</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ttc</extension> + <mime-type>application/x-font-ttf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ttf</extension> + <mime-type>application/x-font-ttf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ttl</extension> + <mime-type>text/turtle</mime-type> + </mime-mapping> + <mime-mapping> + <extension>twd</extension> + <mime-type>application/vnd.simtech-mindmapper</mime-type> + </mime-mapping> + <mime-mapping> + <extension>twds</extension> + <mime-type>application/vnd.simtech-mindmapper</mime-type> + </mime-mapping> + <mime-mapping> + <extension>txd</extension> + <mime-type>application/vnd.genomatix.tuxedo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>txf</extension> + <mime-type>application/vnd.mobius.txf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>txt</extension> + <mime-type>text/plain</mime-type> + </mime-mapping> + <mime-mapping> + <extension>u32</extension> + <mime-type>application/x-authorware-bin</mime-type> + </mime-mapping> + <mime-mapping> + <extension>udeb</extension> + <mime-type>application/x-debian-package</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ufd</extension> + <mime-type>application/vnd.ufdl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ufdl</extension> + <mime-type>application/vnd.ufdl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ulw</extension> + <mime-type>audio/basic</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ulx</extension> + <mime-type>application/x-glulx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>umj</extension> + <mime-type>application/vnd.umajin</mime-type> + </mime-mapping> + <mime-mapping> + <extension>unityweb</extension> + <mime-type>application/vnd.unity</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uoml</extension> + <mime-type>application/vnd.uoml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uri</extension> + <mime-type>text/uri-list</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uris</extension> + <mime-type>text/uri-list</mime-type> + </mime-mapping> + <mime-mapping> + <extension>urls</extension> + <mime-type>text/uri-list</mime-type> + </mime-mapping> + <mime-mapping> + <extension>ustar</extension> + <mime-type>application/x-ustar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>utz</extension> + <mime-type>application/vnd.uiq.theme</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uu</extension> + <mime-type>text/x-uuencode</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uva</extension> + <mime-type>audio/vnd.dece.audio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvd</extension> + <mime-type>application/vnd.dece.data</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvf</extension> + <mime-type>application/vnd.dece.data</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvg</extension> + <mime-type>image/vnd.dece.graphic</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvh</extension> + <mime-type>video/vnd.dece.hd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvi</extension> + <mime-type>image/vnd.dece.graphic</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvm</extension> + <mime-type>video/vnd.dece.mobile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvp</extension> + <mime-type>video/vnd.dece.pd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvs</extension> + <mime-type>video/vnd.dece.sd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvt</extension> + <mime-type>application/vnd.dece.ttml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvu</extension> + <mime-type>video/vnd.uvvu.mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvv</extension> + <mime-type>video/vnd.dece.video</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvva</extension> + <mime-type>audio/vnd.dece.audio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvd</extension> + <mime-type>application/vnd.dece.data</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvf</extension> + <mime-type>application/vnd.dece.data</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvg</extension> + <mime-type>image/vnd.dece.graphic</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvh</extension> + <mime-type>video/vnd.dece.hd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvi</extension> + <mime-type>image/vnd.dece.graphic</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvm</extension> + <mime-type>video/vnd.dece.mobile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvp</extension> + <mime-type>video/vnd.dece.pd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvs</extension> + <mime-type>video/vnd.dece.sd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvt</extension> + <mime-type>application/vnd.dece.ttml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvu</extension> + <mime-type>video/vnd.uvvu.mp4</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvv</extension> + <mime-type>video/vnd.dece.video</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvx</extension> + <mime-type>application/vnd.dece.unspecified</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvvz</extension> + <mime-type>application/vnd.dece.zip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvx</extension> + <mime-type>application/vnd.dece.unspecified</mime-type> + </mime-mapping> + <mime-mapping> + <extension>uvz</extension> + <mime-type>application/vnd.dece.zip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vcard</extension> + <mime-type>text/vcard</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vcd</extension> + <mime-type>application/x-cdlink</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vcf</extension> + <mime-type>text/x-vcard</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vcg</extension> + <mime-type>application/vnd.groove-vcard</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vcs</extension> + <mime-type>text/x-vcalendar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vcx</extension> + <mime-type>application/vnd.vcx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vis</extension> + <mime-type>application/vnd.visionary</mime-type> + </mime-mapping> + <mime-mapping> + <extension>viv</extension> + <mime-type>video/vnd.vivo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vob</extension> + <mime-type>video/x-ms-vob</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vor</extension> + <mime-type>application/vnd.stardivision.writer</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vox</extension> + <mime-type>application/x-authorware-bin</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vrml</extension> + <mime-type>model/vrml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vsd</extension> + <mime-type>application/vnd.visio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vsf</extension> + <mime-type>application/vnd.vsf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vss</extension> + <mime-type>application/vnd.visio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vst</extension> + <mime-type>application/vnd.visio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vsw</extension> + <mime-type>application/vnd.visio</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vtu</extension> + <mime-type>model/vnd.vtu</mime-type> + </mime-mapping> + <mime-mapping> + <extension>vxml</extension> + <mime-type>application/voicexml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>w3d</extension> + <mime-type>application/x-director</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wad</extension> + <mime-type>application/x-doom</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wav</extension> + <mime-type>audio/x-wav</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wax</extension> + <mime-type>audio/x-ms-wax</mime-type> + </mime-mapping> + <mime-mapping> + <!-- Wireless Bitmap --> + <extension>wbmp</extension> + <mime-type>image/vnd.wap.wbmp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wbs</extension> + <mime-type>application/vnd.criticaltools.wbs+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wbxml</extension> + <mime-type>application/vnd.wap.wbxml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wcm</extension> + <mime-type>application/vnd.ms-works</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wdb</extension> + <mime-type>application/vnd.ms-works</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wdp</extension> + <mime-type>image/vnd.ms-photo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>weba</extension> + <mime-type>audio/webm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>webm</extension> + <mime-type>video/webm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>webp</extension> + <mime-type>image/webp</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wg</extension> + <mime-type>application/vnd.pmi.widget</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wgt</extension> + <mime-type>application/widget</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wks</extension> + <mime-type>application/vnd.ms-works</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wm</extension> + <mime-type>video/x-ms-wm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wma</extension> + <mime-type>audio/x-ms-wma</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wmd</extension> + <mime-type>application/x-ms-wmd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wmf</extension> + <mime-type>application/x-msmetafile</mime-type> + </mime-mapping> + <mime-mapping> + <!-- WML Source --> + <extension>wml</extension> + <mime-type>text/vnd.wap.wml</mime-type> + </mime-mapping> + <mime-mapping> + <!-- Compiled WML --> + <extension>wmlc</extension> + <mime-type>application/vnd.wap.wmlc</mime-type> + </mime-mapping> + <mime-mapping> + <!-- WML Script Source --> + <extension>wmls</extension> + <mime-type>text/vnd.wap.wmlscript</mime-type> + </mime-mapping> + <mime-mapping> + <!-- Compiled WML Script --> + <extension>wmlsc</extension> + <mime-type>application/vnd.wap.wmlscriptc</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wmv</extension> + <mime-type>video/x-ms-wmv</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wmx</extension> + <mime-type>video/x-ms-wmx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wmz</extension> + <mime-type>application/x-msmetafile</mime-type> + </mime-mapping> + <mime-mapping> + <extension>woff</extension> + <mime-type>application/x-font-woff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wpd</extension> + <mime-type>application/vnd.wordperfect</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wpl</extension> + <mime-type>application/vnd.ms-wpl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wps</extension> + <mime-type>application/vnd.ms-works</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wqd</extension> + <mime-type>application/vnd.wqd</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wri</extension> + <mime-type>application/x-mswrite</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wrl</extension> + <mime-type>model/vrml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wsdl</extension> + <mime-type>application/wsdl+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wspolicy</extension> + <mime-type>application/wspolicy+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wtb</extension> + <mime-type>application/vnd.webturbo</mime-type> + </mime-mapping> + <mime-mapping> + <extension>wvx</extension> + <mime-type>video/x-ms-wvx</mime-type> + </mime-mapping> + <mime-mapping> + <extension>x32</extension> + <mime-type>application/x-authorware-bin</mime-type> + </mime-mapping> + <mime-mapping> + <extension>x3d</extension> + <mime-type>model/x3d+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>x3db</extension> + <mime-type>model/x3d+binary</mime-type> + </mime-mapping> + <mime-mapping> + <extension>x3dbz</extension> + <mime-type>model/x3d+binary</mime-type> + </mime-mapping> + <mime-mapping> + <extension>x3dv</extension> + <mime-type>model/x3d+vrml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>x3dvz</extension> + <mime-type>model/x3d+vrml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>x3dz</extension> + <mime-type>model/x3d+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xaml</extension> + <mime-type>application/xaml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xap</extension> + <mime-type>application/x-silverlight-app</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xar</extension> + <mime-type>application/vnd.xara</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xbap</extension> + <mime-type>application/x-ms-xbap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xbd</extension> + <mime-type>application/vnd.fujixerox.docuworks.binder</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xbm</extension> + <mime-type>image/x-xbitmap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xdf</extension> + <mime-type>application/xcap-diff+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xdm</extension> + <mime-type>application/vnd.syncml.dm+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xdp</extension> + <mime-type>application/vnd.adobe.xdp+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xdssc</extension> + <mime-type>application/dssc+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xdw</extension> + <mime-type>application/vnd.fujixerox.docuworks</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xenc</extension> + <mime-type>application/xenc+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xer</extension> + <mime-type>application/patch-ops-error+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xfdf</extension> + <mime-type>application/vnd.adobe.xfdf</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xfdl</extension> + <mime-type>application/vnd.xfdl</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xht</extension> + <mime-type>application/xhtml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xhtml</extension> + <mime-type>application/xhtml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xhvml</extension> + <mime-type>application/xv+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xif</extension> + <mime-type>image/vnd.xiff</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xla</extension> + <mime-type>application/vnd.ms-excel</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xlam</extension> + <mime-type>application/vnd.ms-excel.addin.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xlc</extension> + <mime-type>application/vnd.ms-excel</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xlf</extension> + <mime-type>application/x-xliff+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xlm</extension> + <mime-type>application/vnd.ms-excel</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xls</extension> + <mime-type>application/vnd.ms-excel</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xlsb</extension> + <mime-type>application/vnd.ms-excel.sheet.binary.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xlsm</extension> + <mime-type>application/vnd.ms-excel.sheet.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xlsx</extension> + <mime-type>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xlt</extension> + <mime-type>application/vnd.ms-excel</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xltm</extension> + <mime-type>application/vnd.ms-excel.template.macroenabled.12</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xltx</extension> + <mime-type>application/vnd.openxmlformats-officedocument.spreadsheetml.template</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xlw</extension> + <mime-type>application/vnd.ms-excel</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xm</extension> + <mime-type>audio/xm</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xml</extension> + <mime-type>application/xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xo</extension> + <mime-type>application/vnd.olpc-sugar</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xop</extension> + <mime-type>application/xop+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xpi</extension> + <mime-type>application/x-xpinstall</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xpl</extension> + <mime-type>application/xproc+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xpm</extension> + <mime-type>image/x-xpixmap</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xpr</extension> + <mime-type>application/vnd.is-xpr</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xps</extension> + <mime-type>application/vnd.ms-xpsdocument</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xpw</extension> + <mime-type>application/vnd.intercon.formnet</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xpx</extension> + <mime-type>application/vnd.intercon.formnet</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xsl</extension> + <mime-type>application/xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xslt</extension> + <mime-type>application/xslt+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xsm</extension> + <mime-type>application/vnd.syncml+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xspf</extension> + <mime-type>application/xspf+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xul</extension> + <mime-type>application/vnd.mozilla.xul+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xvm</extension> + <mime-type>application/xv+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xvml</extension> + <mime-type>application/xv+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xwd</extension> + <mime-type>image/x-xwindowdump</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xyz</extension> + <mime-type>chemical/x-xyz</mime-type> + </mime-mapping> + <mime-mapping> + <extension>xz</extension> + <mime-type>application/x-xz</mime-type> + </mime-mapping> + <mime-mapping> + <extension>yang</extension> + <mime-type>application/yang</mime-type> + </mime-mapping> + <mime-mapping> + <extension>yin</extension> + <mime-type>application/yin+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>z</extension> + <mime-type>application/x-compress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>Z</extension> + <mime-type>application/x-compress</mime-type> + </mime-mapping> + <mime-mapping> + <extension>z1</extension> + <mime-type>application/x-zmachine</mime-type> + </mime-mapping> + <mime-mapping> + <extension>z2</extension> + <mime-type>application/x-zmachine</mime-type> + </mime-mapping> + <mime-mapping> + <extension>z3</extension> + <mime-type>application/x-zmachine</mime-type> + </mime-mapping> + <mime-mapping> + <extension>z4</extension> + <mime-type>application/x-zmachine</mime-type> + </mime-mapping> + <mime-mapping> + <extension>z5</extension> + <mime-type>application/x-zmachine</mime-type> + </mime-mapping> + <mime-mapping> + <extension>z6</extension> + <mime-type>application/x-zmachine</mime-type> + </mime-mapping> + <mime-mapping> + <extension>z7</extension> + <mime-type>application/x-zmachine</mime-type> + </mime-mapping> + <mime-mapping> + <extension>z8</extension> + <mime-type>application/x-zmachine</mime-type> + </mime-mapping> + <mime-mapping> + <extension>zaz</extension> + <mime-type>application/vnd.zzazz.deck+xml</mime-type> + </mime-mapping> + <mime-mapping> + <extension>zip</extension> + <mime-type>application/zip</mime-type> + </mime-mapping> + <mime-mapping> + <extension>zir</extension> + <mime-type>application/vnd.zul</mime-type> + </mime-mapping> + <mime-mapping> + <extension>zirz</extension> + <mime-type>application/vnd.zul</mime-type> + </mime-mapping> + <mime-mapping> + <extension>zmm</extension> + <mime-type>application/vnd.handheld-entertainment+xml</mime-type> + </mime-mapping> + + <!-- ==================== Default Welcome File List ===================== --> + <!-- When a request URI refers to a directory, the default servlet looks --> + <!-- for a "welcome file" within that directory and, if present, to the --> + <!-- corresponding resource URI for display. --> + <!-- If no welcome files are present, the default servlet either serves a --> + <!-- directory listing (see default servlet configuration on how to --> + <!-- customize) or returns a 404 status, depending on the value of the --> + <!-- listings setting. --> + <!-- --> + <!-- If you define welcome files in your own application's web.xml --> + <!-- deployment descriptor, that list *replaces* the list configured --> + <!-- here, so be sure to include any of the default values that you wish --> + <!-- to use within your application. --> + + <welcome-file-list> + <welcome-file>index.html</welcome-file> + <welcome-file>index.htm</welcome-file> + <welcome-file>index.jsp</welcome-file> + </welcome-file-list> + +</web-app> diff --git a/ResmanagementService/deployment/src/main/release/db/mysql/db-schema.sql b/ResmanagementService/deployment/src/main/release/db/mysql/db-schema.sql new file mode 100644 index 0000000..af5e0a3 --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/db/mysql/db-schema.sql @@ -0,0 +1,195 @@ +#******************************************************************************* +# Copyright 2016 Huawei Technologies Co., Ltd. +# +# 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 resmanagementdb; +delete from user where User='resmanagement'; +FLUSH PRIVILEGES; + +/******************create new database and user***************************/ +create database resmanagementdb CHARACTER SET utf8; + +GRANT ALL PRIVILEGES ON resmanagementdb.* TO 'resmanagement'@'%' IDENTIFIED BY 'resmanagement' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON mysql.* TO 'resmanagement'@'%' IDENTIFIED BY 'resmanagement' WITH GRANT OPTION; + +GRANT ALL PRIVILEGES ON resmanagementdb.* TO 'resmanagement'@'localhost' IDENTIFIED BY 'resmanagement' WITH GRANT OPTION; +GRANT ALL PRIVILEGES ON mysql.* TO 'resmanagement'@'localhost' IDENTIFIED BY 'resmanagement' WITH GRANT OPTION; +FLUSH PRIVILEGES; + +use resmanagementdb; +set Names 'utf8'; + +/******************drop old table and create new***************************/ + +DROP TABLE IF EXISTS host; +CREATE TABLE host ( + ID VARCHAR(128) NOT NULL, + NAME VARCHAR(256) NULL, + CPU VARCHAR(256) NULL, + MEMORY VARCHAR(256) NULL, + DISK VARCHAR(256) NULL, + VIM_ID VARCHAR(256) NULL, + VIM_NAME VARCHAR(256) NULL, + CONSTRAINT host PRIMARY KEY(ID) +); + +DROP TABLE IF EXISTS location; +CREATE TABLE location ( + ID VARCHAR(128) NOT NULL, + COUNTRY VARCHAR(256) NULL, + LOCATION VARCHAR(256) NULL, + LATITUDE VARCHAR(256) NULL, + LONGITUDE VARCHAR(256) NULL, + DESCRIPTION VARCHAR(256) NULL, + CONSTRAINT location PRIMARY KEY(ID) +); + +DROP TABLE IF EXISTS network; +CREATE TABLE network ( + ID VARCHAR(128) NOT NULL, + NAME VARCHAR(256) NULL, + TENANT_ID VARCHAR(256) NULL, + VIM_ID VARCHAR(256) NULL, + VIM_NAME VARCHAR(256) NULL, + STATUS VARCHAR(256) NULL, + PHYSICAL_NETWORK VARCHAR(256) NULL, + NETWORK_TYPE VARCHAR(256) NULL, + SEGMENTATION_ID VARCHAR(256) NULL, + CONSTRAINT network PRIMARY KEY(ID) +); + +DROP TABLE IF EXISTS port; +CREATE TABLE port ( + ID VARCHAR(128) NOT NULL, + NAME VARCHAR(256) NULL, + NWTWORK_ID VARCHAR(256) NULL, + STATUS VARCHAR(256) NULL, + TENANT_ID VARCHAR(256) NULL, + VIM_ID VARCHAR(256) NULL, + VIM_NAME VARCHAR(256) NULL, + CONSTRAINT port PRIMARY KEY(ID) +); + +DROP TABLE IF EXISTS site; +CREATE TABLE site ( + ID VARCHAR(128) NOT NULL, + NAME VARCHAR(256) NULL, + LOCATION VARCHAR(256) NULL, + COUNTRY VARCHAR(256) NULL, + VIM_ID VARCHAR(256) NULL, + VIM_NAME VARCHAR(256) NULL, + STATUS VARCHAR(256) NULL, + TOTAL_CPU VARCHAR(256) NULL, + TOTAL_MEMORY VARCHAR(256) NULL, + TOTAL_DISK VARCHAR(256) NULL, + USED_CPU VARCHAR(256) NULL, + USED_MEMORY VARCHAR(256) NULL, + USED_DISK VARCHAR(256) NULL, + CONSTRAINT site PRIMARY KEY(ID) +); + +DROP TABLE IF EXISTS vim; +CREATE TABLE vim ( + ID VARCHAR(128) NOT NULL, + CONSTRAINT vim PRIMARY KEY(ID) +); + +DROP TABLE IF EXISTS vl; +CREATE TABLE vl ( + ID VARCHAR(128) NOT NULL, + NAME VARCHAR(256) NULL, + BACKEND_ID VARCHAR(256) NULL, + IS_PUBLIC VARCHAR(256) NULL, + DC_NAME VARCHAR(256) NULL, + VIM_ID VARCHAR(256) NULL, + VIM_NAME VARCHAR(256) NULL, + PHYSICIAL_NET VARCHAR(256) NULL, + NS_ID VARCHAR(256) NULL, + NS_NAME VARCHAR(256) NULL, + DESCRIPTION VARCHAR(256) NULL, + NETWORK_TYPE VARCHAR(256) NULL, + SEGMENTATION VARCHAR(256) NULL, + MTU VARCHAR(256) NULL, + VLAN_TRANSPARENT VARCHAR(256) NULL, + ROUTER_EXTERNAL VARCHAR(256) NULL, + RESOURCE_PROVIDER_TYPE VARCHAR(256) NULL, + RESOURCE_PROVIDER_ID VARCHAR(256) NULL, + CONSTRAINT vl PRIMARY KEY (ID) +); + +DROP TABLE IF EXISTS vnf; +CREATE TABLE vnf ( + ID VARCHAR(128) NOT NULL, + VNF_INSTANCE_ID VARCHAR(256) NULL, + VNF_INSTANCE_NAME VARCHAR(256) NULL, + NS_ID VARCHAR(256) NULL, + NS_NAME VARCHAR(256) NULL, + VNFM_ID VARCHAR(256) NULL, + VNFM_NAME VARCHAR(256) NULL, + VNF_PACKAGE_NAME VARCHAR(256) NULL, + VNF_DESCRIPTOR_NAME VARCHAR(256) NULL, + VIM_ID VARCHAR(256) NULL, + VIM_NAME VARCHAR(256) NULL, + VIM_TENANT VARCHAR(256) NULL, + JOB_ID VARCHAR(256) NULL, + VNF_STATUS VARCHAR(256) NULL, + VNF_TYPE VARCHAR(256) NULL, + MAX_VM INT NULL, + MAX_CPU INT NULL, + MAX_DISK INT NULL, + MAX_RAM INT NULL, + MAX_SHD INT NULL, + MAX_NET INT NULL, + NAME VARCHAR(256) NULL, + CONSTRAINT vnf PRIMARY KEY (ID) +); + +DROP TABLE IF EXISTS vm; +CREATE TABLE vm ( + VM_ID VARCHAR(128) NOT NULL, + VM_NAME VARCHAR(256) NULL, + VM_STATUS VARCHAR(256) NULL, + VNF_INSTANCE_ID VARCHAR(256) NULL, + CONSTRAINT vm PRIMARY KEY (VM_ID) +); + +DROP TABLE IF EXISTS vnfinfo; +CREATE TABLE vnfinfo ( + VNF_INSTANCE_ID VARCHAR(128) NOT NULL, + NS_ID VARCHAR(256) NULL, + VNFM_ID VARCHAR(256) NULL, + CONSTRAINT vnfinfo PRIMARY KEY (VNF_INSTANCE_ID) +); + +DROP TABLE IF EXISTS vnfstatus; +CREATE TABLE vnfstatus ( + VNF_INSTANCE_ID VARCHAR(128) NOT NULL, + JOB_ID VARCHAR(256) NULL, + NS_ID VARCHAR(256) NULL, + VNFM_ID VARCHAR(256) NULL, + RESPONSE_DESCRIPTOR VARCHAR(1024) NULL, + STATUS VARCHAR(256) NULL, + PROGRESS VARCHAR(256) NULL, + STATUS_DESCRIPTION VARCHAR(256) NULL, + ERROR_CODE VARCHAR(256) NULL, + RESPONSE_ID VARCHAR(256) NULL, + RESPONSE_HISTORY_LIST VARCHAR(1024) NULL, + ADD_VM VARCHAR(1024) NULL, + DEL_VM VARCHAR(1024) NULL, + CONSTRAINT vnfstatus PRIMARY KEY (VNF_INSTANCE_ID) +); + diff --git a/ResmanagementService/deployment/src/main/release/etc/adapterInfo/resmgradapterinfo.json b/ResmanagementService/deployment/src/main/release/etc/adapterInfo/resmgradapterinfo.json new file mode 100644 index 0000000..ab7f71c --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/etc/adapterInfo/resmgradapterinfo.json @@ -0,0 +1,12 @@ +{ + "serviceName": "resmgr", + "version": "v1", + "url": "/openoapi/resmgr/v1", + "protocol": "REST", + "visualRange": "1", + "nodes": [{ + "ip": "127.0.0.1", + "port": "8480", + "ttl": 0 + }] +}
\ No newline at end of file diff --git a/ResmanagementService/deployment/src/main/release/etc/conf/restclient.json b/ResmanagementService/deployment/src/main/release/etc/conf/restclient.json new file mode 100644 index 0000000..9cc37e0 --- /dev/null +++ b/ResmanagementService/deployment/src/main/release/etc/conf/restclient.json @@ -0,0 +1,10 @@ +{ + "defaultServer": { + "host": "127.0.0.1", + "port": "80" + }, + "ConnectTimeout": "300000", + "thread": "10", + "idletimeout": "500000", + "timeout": "300000" +}
\ No newline at end of file diff --git a/ResmanagementService/pom.xml b/ResmanagementService/pom.xml new file mode 100644 index 0000000..a532c9e --- /dev/null +++ b/ResmanagementService/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<!-- + Copyright (c) 2016, Huawei Technologies Co., Ltd. + + 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>resmanagement</artifactId> + <groupId>org.openo.nfvo</groupId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <artifactId>resmanagement-service-root</artifactId> + <version>1.1.0-SNAPSHOT</version> + <name>nfvo/resmanagement/ResmanagementService</name> + <packaging>pom</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <package.name>resmanagement-service</package.name> + </properties> + + <modules> + <module>service</module> + <module>deployment</module> + </modules> +</project> diff --git a/ResmanagementService/service/pom.xml b/ResmanagementService/service/pom.xml new file mode 100644 index 0000000..ce4f32d --- /dev/null +++ b/ResmanagementService/service/pom.xml @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 2016-2017, Huawei Technologies Co., Ltd. + + 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openo.nfvo</groupId> + <artifactId>resmanagement-service-root</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>resmanagement-service</artifactId> + <name>nfvo/resmanagement/ResmanagementService/service</name> + <packaging>war</packaging> + + <dependencies> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>5.1.36</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-tx</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.mybatis</groupId> + <artifactId>mybatis-spring</artifactId> + <version>1.2.0</version> + </dependency> + <dependency> + <groupId>org.mybatis</groupId> + <artifactId>mybatis</artifactId> + <version>3.2.7</version> + </dependency> + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + <version>1.15</version> + </dependency> + <dependency> + <groupId>org.openo.common-services.common-utilities</groupId> + <artifactId>commonlib-cbb</artifactId> + <version>1.1.0-SNAPSHOT</version> + </dependency> + + <dependency> + <groupId>org.openo.common-services.common-utilities</groupId> + <artifactId>commonlib-restclient</artifactId> + <version>1.1.0-SNAPSHOT</version> + </dependency> + + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.6.1</version> + </dependency> + <!--dependency> + <groupId>org.apache.log4j</groupId> + <artifactId>com.springsource.org.apache.log4j</artifactId> + <version>1.2.16</version> + </dependency--> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito</artifactId> + <version>1.5.4</version> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.9.5</version> + </dependency> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-module-junit4</artifactId> + <version>1.5.4</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-jdbc</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-asm</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-expression</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> + <version>3.1.0.RELEASE</version> + </dependency> + + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>3.1.6</version> + </dependency> + <!-- UT coverage dependency start --> + <dependency> + <groupId>org.jmockit</groupId> + <artifactId>jmockit</artifactId> + <version>1.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.12</version> + </dependency> + <dependency> + <groupId>org.jmockit</groupId> + <artifactId>jmockit-coverage</artifactId> + <version>1.19</version> + <scope>test</scope> + </dependency> + + <!-- UT coverage dependency end --> + + </dependencies> + +</project> diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/mocoserver/VimDriverSuccessServer.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/mocoserver/VimDriverSuccessServer.java new file mode 100644 index 0000000..1d6123f --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/mocoserver/VimDriverSuccessServer.java @@ -0,0 +1,72 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.mocoserver; + +import org.openo.sdno.testframework.moco.MocoHttpServer; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 28, 2016 + */ +public class VimDriverSuccessServer extends MocoHttpServer { + + private static final String GET_CPU_LIMITS = "src/integration-test/resources/mocoserver/getcpulimits.json"; + + private static final String GET_DISK_LIMITS = "src/integration-test/resources/mocoserver/getdisklimits.json"; + + private static final String GET_HOSTS_FILE = "src/integration-test/resources/mocoserver/gethosts.json"; + + private static final String GET_HOST_FILE = "src/integration-test/resources/mocoserver/gethost.json"; + + private static final String GET_NETWORKS_FILE = "src/integration-test/resources/mocoserver/getnetworks.json"; + + private static final String GET_PORTS_FILE = "src/integration-test/resources/mocoserver/getports.json"; + + private static final String SEND_ADD_MONITOR_FILE = + "src/integration-test/resources/mocoserver/sendmsgmonitor1.json"; + + private static final String SEND_MOD_MONITOR_FILE = + "src/integration-test/resources/mocoserver/sendmsgmonitor2.json"; + + private static final String SEND_DEL_MONITOR_FILE = + "src/integration-test/resources/mocoserver/sendmsgmonitor3.json"; + + public VimDriverSuccessServer() { + super(); + } + + public VimDriverSuccessServer(int port) { + super(port); + } + + @Override + public void addRequestResponsePairs() { + this.addRequestResponsePair(GET_CPU_LIMITS); + this.addRequestResponsePair(GET_DISK_LIMITS); + this.addRequestResponsePair(GET_HOSTS_FILE); + this.addRequestResponsePair(GET_HOST_FILE); + this.addRequestResponsePair(GET_NETWORKS_FILE); + this.addRequestResponsePair(GET_PORTS_FILE); + this.addRequestResponsePair(SEND_ADD_MONITOR_FILE); + this.addRequestResponsePair(SEND_MOD_MONITOR_FILE); + this.addRequestResponsePair(SEND_DEL_MONITOR_FILE); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITHostRoaFail.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITHostRoaFail.java new file mode 100644 index 0000000..27e4c59 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITHostRoaFail.java @@ -0,0 +1,58 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 24, 2016 + */ +public class ITHostRoaFail extends MyTestManager { + + private static final String GET_PATH = "src/integration-test/resources/testcase/hostroa/queryhostsbyidfail1.json"; + + private static final String POST_PATH = "src/integration-test/resources/testcase/hostroa/createhostsfail1.json"; + + private static final String PUT_PATH = "src/integration-test/resources/testcase/hostroa/modhostsfail1.json"; + + private static final String DEL_PATH = "src/integration-test/resources/testcase/hostroa/deletehostsfail1.json"; + + private static final String POST_SUCCESS_PATH = + "src/integration-test/resources/testcase/hostroa/createhostssuccess1.json"; + + private static final String DEL_SUCCESS_PATH = + "src/integration-test/resources/testcase/hostroa/deletehostssuccess1.json"; + + @Test + public void testOperateFail() throws ServiceException { + execTestCase(new File(POST_SUCCESS_PATH)); + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + execTestCase(new File(DEL_SUCCESS_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITHostRoaSuccess.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITHostRoaSuccess.java new file mode 100644 index 0000000..72ac04d --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITHostRoaSuccess.java @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 20, 2016 + */ +public class ITHostRoaSuccess extends MyTestManager { + + private static final String GET_PATH = + "src/integration-test/resources/testcase/hostroa/queryhostsbyidsuccess1.json"; + + private static final String POST_PATH = "src/integration-test/resources/testcase/hostroa/createhostssuccess1.json"; + + private static final String PUT_PATH = "src/integration-test/resources/testcase/hostroa/modhostssuccess1.json"; + + private static final String DEL_PATH = "src/integration-test/resources/testcase/hostroa/deletehostssuccess1.json"; + + @Test + public void testOperateSuccess() throws ServiceException { + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITLimitsRoa.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITLimitsRoa.java new file mode 100644 index 0000000..f9ef461 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITLimitsRoa.java @@ -0,0 +1,62 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.mocoserver.VimDriverSuccessServer; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 28, 2016 + */ +public class ITLimitsRoa extends MyTestManager { + + private VimDriverSuccessServer driver = new VimDriverSuccessServer(); + + private static final String GET_CPU_PATH = + "src/integration-test/resources/testcase/limitsroa/querycpulimitssuccess1.json"; + + private static final String GET_DISK_PATH = + "src/integration-test/resources/testcase/limitsroa/querydisklimitssuccess1.json"; + + @Before + public void setup() throws ServiceException, InterruptedException { + driver.start(); + // Thread.sleep(60 * 1000); + } + + @After + public void tearDown() throws ServiceException { + driver.stop(); + } + + @Test + public void testGetLimitsSuccess() throws ServiceException { + execTestCase(new File(GET_CPU_PATH)); + execTestCase(new File(GET_DISK_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITLocationRoaFail.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITLocationRoaFail.java new file mode 100644 index 0000000..3d8b67d --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITLocationRoaFail.java @@ -0,0 +1,61 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +public class ITLocationRoaFail extends MyTestManager { + + private static final String GET_PATH = + "src/integration-test/resources/testcase/locationroa/querylocationsbyidfail1.json"; + + private static final String POST_PATH = + "src/integration-test/resources/testcase/locationroa/createlocationsfail1.json"; + + private static final String PUT_PATH = "src/integration-test/resources/testcase/locationroa/modlocationsfail1.json"; + + private static final String DEL_PATH = + "src/integration-test/resources/testcase/locationroa/deletelocationsfail1.json"; + + private static final String POST_SUCCESS_PATH = + "src/integration-test/resources/testcase/locationroa/createlocationssuccess1.json"; + + private static final String DEL_SUCCESS_PATH = + "src/integration-test/resources/testcase/locationroa/deletelocationssuccess1.json"; + + @Test + public void testOperateSuccess() throws ServiceException { + execTestCase(new File(POST_SUCCESS_PATH)); + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + execTestCase(new File(DEL_SUCCESS_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITLocationRoaSuccess.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITLocationRoaSuccess.java new file mode 100644 index 0000000..c3641b2 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITLocationRoaSuccess.java @@ -0,0 +1,54 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 26, 2016 + */ +public class ITLocationRoaSuccess extends MyTestManager { + + private static final String GET_PATH = + "src/integration-test/resources/testcase/locationroa/querylocationsbyidsuccess1.json"; + + private static final String POST_PATH = + "src/integration-test/resources/testcase/locationroa/createlocationssuccess1.json"; + + private static final String PUT_PATH = + "src/integration-test/resources/testcase/locationroa/modlocationssuccess1.json"; + + private static final String DEL_PATH = + "src/integration-test/resources/testcase/locationroa/deletelocationssuccess1.json"; + + @Test + public void testOperateSuccess() throws ServiceException { + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITNetworkRoaFail.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITNetworkRoaFail.java new file mode 100644 index 0000000..7b9cb54 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITNetworkRoaFail.java @@ -0,0 +1,61 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +public class ITNetworkRoaFail extends MyTestManager { + + private static final String GET_PATH = + "src/integration-test/resources/testcase/networkroa/querynetworksbyidfail1.json"; + + private static final String POST_PATH = + "src/integration-test/resources/testcase/networkroa/createnetworksfail1.json"; + + private static final String PUT_PATH = "src/integration-test/resources/testcase/networkroa/modnetworksfail1.json"; + + private static final String DEL_PATH = + "src/integration-test/resources/testcase/networkroa/deletenetworksfail1.json"; + + private static final String POST_SUCCESS_PATH = + "src/integration-test/resources/testcase/networkroa/createnetworkssuccess1.json"; + + private static final String DEL_SUCCESS_PATH = + "src/integration-test/resources/testcase/networkroa/deletenetworkssuccess1.json"; + + @Test + public void testOperateSuccess() throws ServiceException { + execTestCase(new File(POST_SUCCESS_PATH)); + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + execTestCase(new File(DEL_SUCCESS_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITNetworkRoaSuccess.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITNetworkRoaSuccess.java new file mode 100644 index 0000000..50f0aeb --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITNetworkRoaSuccess.java @@ -0,0 +1,54 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +public class ITNetworkRoaSuccess extends MyTestManager { + + private static final String GET_PATH = + "src/integration-test/resources/testcase/networkroa/querynetworksbyidsuccess1.json"; + + private static final String POST_PATH = + "src/integration-test/resources/testcase/networkroa/createnetworkssuccess1.json"; + + private static final String PUT_PATH = + "src/integration-test/resources/testcase/networkroa/modnetworkssuccess1.json"; + + private static final String DEL_PATH = + "src/integration-test/resources/testcase/networkroa/deletenetworkssuccess1.json"; + + @Test + public void testOperateSuccess() throws ServiceException { + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITPortRoaFail.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITPortRoaFail.java new file mode 100644 index 0000000..d4b9d34 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITPortRoaFail.java @@ -0,0 +1,58 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 26, 2016 + */ +public class ITPortRoaFail extends MyTestManager { + + private static final String GET_PATH = "src/integration-test/resources/testcase/portroa/queryportsbyidfail1.json"; + + private static final String POST_PATH = "src/integration-test/resources/testcase/portroa/createportsfail1.json"; + + private static final String PUT_PATH = "src/integration-test/resources/testcase/portroa/modportsfail1.json"; + + private static final String DEL_PATH = "src/integration-test/resources/testcase/portroa/deleteportsfail1.json"; + + private static final String POST_SUCCESS_PATH = + "src/integration-test/resources/testcase/portroa/createportssuccess1.json"; + + private static final String DEL_SUCCESS_PATH = + "src/integration-test/resources/testcase/portroa/deleteportssuccess1.json"; + + @Test + public void testOperateFail() throws ServiceException { + execTestCase(new File(POST_SUCCESS_PATH)); + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + execTestCase(new File(DEL_SUCCESS_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITPortRoaSuccess.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITPortRoaSuccess.java new file mode 100644 index 0000000..fadf854 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITPortRoaSuccess.java @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 26, 2016 + */ +public class ITPortRoaSuccess extends MyTestManager { + + private static final String GET_PATH = + "src/integration-test/resources/testcase/portroa/queryportsbyidsuccess1.json"; + + private static final String POST_PATH = "src/integration-test/resources/testcase/portroa/createportssuccess1.json"; + + private static final String PUT_PATH = "src/integration-test/resources/testcase/portroa/modportssuccess1.json"; + + private static final String DEL_PATH = "src/integration-test/resources/testcase/portroa/deleteportssuccess1.json"; + + @Test + public void testOperateSuccess() throws ServiceException { + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITResOperateRoaFail.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITResOperateRoaFail.java new file mode 100644 index 0000000..dcb3dd9 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITResOperateRoaFail.java @@ -0,0 +1,50 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 15, 2016 + */ +public class ITResOperateRoaFail extends MyTestManager { + + private static final String POST_PATH = + "src/integration-test/resources/testcase/resoperateroa/addresourcefail1.json"; + + private static final String PUT_PATH = + "src/integration-test/resources/testcase/resoperateroa/modresourcefail1.json"; + + private static final String DEL_PATH = + "src/integration-test/resources/testcase/resoperateroa/deleteresourcefail1.json"; + + @Test + public void testOperateFail() throws ServiceException { + execTestCase(new File(POST_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITResOperateRoaSuccess.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITResOperateRoaSuccess.java new file mode 100644 index 0000000..718d688 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITResOperateRoaSuccess.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.mocoserver.VimDriverSuccessServer; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 15, 2016 + */ +public class ITResOperateRoaSuccess extends MyTestManager { + + private VimDriverSuccessServer driver = new VimDriverSuccessServer(); + + private static final String POST_PATH = + "src/integration-test/resources/testcase/resoperateroa/addresourcesuccess1.json"; + + private static final String PUT_PATH = + "src/integration-test/resources/testcase/resoperateroa/modresourcesuccess1.json"; + + private static final String DEL_PATH = + "src/integration-test/resources/testcase/resoperateroa/deleteresourcesuccess1.json"; + + @Before + public void setup() throws ServiceException, InterruptedException { + driver.start(); + // Thread.sleep(30 * 1000); + } + + @After + public void tearDown() throws ServiceException { + driver.stop(); + } + + @Test + public void testOperateSuccess() throws ServiceException { + execTestCase(new File(POST_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITSitesRoaFail.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITSitesRoaFail.java new file mode 100644 index 0000000..a96c451 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITSitesRoaFail.java @@ -0,0 +1,58 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +public class ITSitesRoaFail extends MyTestManager { + + private static final String GET_PATH = "src/integration-test/resources/testcase/siteroa/querysitesbyidfail1.json"; + + private static final String POST_PATH = "src/integration-test/resources/testcase/siteroa/createsitesfail1.json"; + + private static final String PUT_PATH = "src/integration-test/resources/testcase/siteroa/modsitesfail1.json"; + + private static final String DEL_PATH = "src/integration-test/resources/testcase/siteroa/deletesitesfail1.json"; + + private static final String POST_SUSCCESS_PATH = + "src/integration-test/resources/testcase/siteroa/createsitessuccess1.json"; + + private static final String DEL_SUCCESS_PATH = + "src/integration-test/resources/testcase/siteroa/deletesitessuccess1.json"; + + @Test + public void testOperateFail() throws ServiceException { + execTestCase(new File(POST_SUSCCESS_PATH)); + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + execTestCase(new File(DEL_SUCCESS_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITSitesRoaSuccess.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITSitesRoaSuccess.java new file mode 100644 index 0000000..b7736c3 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/test/ITSitesRoaSuccess.java @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.test; + +import java.io.File; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.util.MyTestManager; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +public class ITSitesRoaSuccess extends MyTestManager { + + private static final String GET_PATH = + "src/integration-test/resources/testcase/siteroa/querysitesbyidsuccess1.json"; + + private static final String POST_PATH = "src/integration-test/resources/testcase/siteroa/createsitessuccess1.json"; + + private static final String PUT_PATH = "src/integration-test/resources/testcase/siteroa/modsitessuccess1.json"; + + private static final String DEL_PATH = "src/integration-test/resources/testcase/siteroa/deletesitessuccess1.json"; + + @Test + public void testOperateSuccess() throws ServiceException { + execTestCase(new File(POST_PATH)); + execTestCase(new File(GET_PATH)); + execTestCase(new File(PUT_PATH)); + execTestCase(new File(DEL_PATH)); + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/AddSuccessChecker.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/AddSuccessChecker.java new file mode 100644 index 0000000..48bc3a2 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/AddSuccessChecker.java @@ -0,0 +1,46 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.util; + +import org.openo.sdno.testframework.checker.IChecker; +import org.openo.sdno.testframework.http.model.HttpResponse; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 21, 2016 + */ +public class AddSuccessChecker implements IChecker { + + String addMsg = "org.openo.nfvo.resmanage.common.update.success"; + + @Override + public boolean check(HttpResponse response) { + String data = response.getData(); + System.out.println(data); + JSONObject dataObj = JSONObject.fromObject(data); + if(response.getStatus() == 200 && addMsg.equals(dataObj.getString("msg"))) { + return true; + } + return false; + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/FailureChecker.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/FailureChecker.java new file mode 100644 index 0000000..dc9f7e8 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/FailureChecker.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.util; + +import org.openo.sdno.testframework.checker.IChecker; +import org.openo.sdno.testframework.http.model.HttpResponse; + +import net.sf.json.JSONObject; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 16, 2016 + */ +public class FailureChecker implements IChecker { + + @Override + public boolean check(HttpResponse response) { + String data = response.getData(); + if(response.getStatus() != 200) { + return true; + } + JSONObject dataObj = JSONObject.fromObject(data); + int retCode = (int)dataObj.get("retCode"); + return retCode == -1; + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/GetSuccessChecker.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/GetSuccessChecker.java new file mode 100644 index 0000000..87e9a51 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/GetSuccessChecker.java @@ -0,0 +1,48 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.util; + +import org.openo.sdno.testframework.checker.IChecker; +import org.openo.sdno.testframework.http.model.HttpResponse; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 21, 2016 + */ +public class GetSuccessChecker implements IChecker { + + String addMsg = "org.openo.nfvo.resmanage.common.add.success"; + + @Override + public boolean check(HttpResponse response) { + System.out.println(response); + String data = response.getData(); + System.out.println(data); + JSONObject dataObj = JSONObject.fromObject(data); + if(response.getStatus() == 200 && !dataObj.isEmpty()) { + System.out.println(dataObj.isEmpty()); + return true; + } + return false; + } +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/MyChecker.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/MyChecker.java new file mode 100644 index 0000000..00fd5b6 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/MyChecker.java @@ -0,0 +1,59 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.util; + +import org.openo.sdno.testframework.checker.DefaultChecker; +import org.openo.sdno.testframework.http.model.HttpResponse; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 21, 2016 + */ +public class MyChecker extends DefaultChecker { + + private HttpResponse expectedResponse; + + /** + * Constructor<br> + * <p> + * </p> + * + * @param expectedResponse + * @since NFVO 0.5 + */ + public MyChecker(HttpResponse expectedResponse) { + super(expectedResponse); + this.expectedResponse = expectedResponse; + } + + /** + * <br> + * + * @param response + * @return + * @since NFVO 0.5 + */ + @Override + public boolean check(HttpResponse response) { + return expectedResponse.equals(response); + } + +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/MyTestManager.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/MyTestManager.java new file mode 100644 index 0000000..97ebe50 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/MyTestManager.java @@ -0,0 +1,163 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.util; + +import java.io.File; +import java.util.Iterator; +import java.util.Map; + +import org.junit.Assert; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.openo.sdno.testframework.checker.DefaultChecker; +import org.openo.sdno.testframework.http.model.HttpModelUtils; +import org.openo.sdno.testframework.http.model.HttpRequest; +import org.openo.sdno.testframework.http.model.HttpResponse; +import org.openo.sdno.testframework.http.model.HttpRquestResponse; +import org.openo.sdno.testframework.restclient.HttpRestClient; +import org.openo.sdno.testframework.testmanager.TestManager; +import org.openo.sdno.testframework.util.file.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 21, 2016 + */ +public class MyTestManager extends TestManager { + + private HttpRestClient restClient; + + public MyTestManager() { + restClient = new HttpRestClient(); + } + + private static final Logger LOGGER = LoggerFactory.getLogger(MyTestManager.class); + + /** + * <br> + * + * @param file + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public HttpResponse execTestCase(File file) throws ServiceException { + String content = FileUtils.readFromJson(file); + HttpRquestResponse httpObject = HttpModelUtils.praseHttpRquestResponse(content); + return send(httpObject.getRequest(), httpObject.getResponse()); + } + + private HttpResponse send(HttpRequest request, HttpResponse response) { + try { + RestfulResponse responseResult = doSend(request); + DefaultChecker checker = new MyChecker(response); + HttpResponse httpResponse = HttpModelUtils.convertResponse(responseResult); + Assert.assertEquals(Boolean.valueOf(checker.check(httpResponse)), Boolean.valueOf(true)); + return httpResponse; + } catch(ServiceException e) { + LOGGER.error("call the restful interface failed.", e); + } + return null; + } + + private RestfulResponse doSend(HttpRequest request) throws ServiceException { + String url = request.getUri(); + String method = request.getMethod(); + String body = request.getData(); + RestfulParametes restfulParametes = new RestfulParametes(); + Map requestHeaders = request.getHeaders(); + if(null != requestHeaders) { + java.util.Map.Entry curEntity; + for(Iterator iterator = requestHeaders.entrySet().iterator(); iterator.hasNext(); restfulParametes + .putHttpContextHeader((String)curEntity.getKey(), (String)curEntity.getValue())) + curEntity = (java.util.Map.Entry)iterator.next(); + + } + Map paramMap = request.getQueries(); + if(null != paramMap) + restfulParametes.setParamMap(paramMap); + if(null != body) + restfulParametes.setRawData(body); + return callRestfulMotheds(url, method, restfulParametes); + } + + private RestfulResponse callRestfulMotheds(String url, String method, RestfulParametes restfulParametes) + throws ServiceException { + String s = method; + byte byte0 = -1; + switch(s.hashCode()) { + case 3446944: + if(s.equals("post")) + byte0 = 0; + break; + + case 102230: + if(s.equals("get")) + byte0 = 1; + break; + + case 111375: + if(s.equals("put")) + byte0 = 2; + break; + + case -1335458389: + if(s.equals("delete")) + byte0 = 3; + break; + + case 3198432: + if(s.equals("head")) + byte0 = 4; + break; + + case 106438728: + if(s.equals("patch")) + byte0 = 5; + break; + } + switch(byte0) { + case 0: // '\0' + return restClient.post(url, restfulParametes); + + case 1: // '\001' + return restClient.get(url, restfulParametes); + + case 2: // '\002' + return restClient.put(url, restfulParametes); + + case 3: // '\003' + return restClient.delete(url, restfulParametes); + + case 4: // '\004' + return restClient.head(url, restfulParametes); + + case 5: // '\005' + return restClient.patch(url, restfulParametes); + } + LOGGER.error("The method is unsupported."); + throw new ServiceException("The method is unsupported."); + } + +} diff --git a/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/SuccessChecker.java b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/SuccessChecker.java new file mode 100644 index 0000000..7817e76 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/java/org/openo/nfvo/resmanagement/util/SuccessChecker.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.util; + +import org.openo.sdno.testframework.checker.IChecker; +import org.openo.sdno.testframework.http.model.HttpResponse; + +import net.sf.json.JSONObject; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 16, 2016 + */ +public class SuccessChecker implements IChecker { + + String addMsg = "org.openo.nfvo.resmanage.common.add.success"; + + @Override + public boolean check(HttpResponse response) { + String data = response.getData(); + System.out.println(data); + JSONObject dataObj = JSONObject.fromObject(data); + if(response.getStatus() == 200 && addMsg.equals(dataObj.getString("msg"))) { + return true; + } + return false; + } +} diff --git a/ResmanagementService/service/src/integration-test/resources/mocoserver/getcpulimits.json b/ResmanagementService/service/src/integration-test/resources/mocoserver/getcpulimits.json new file mode 100644 index 0000000..c2eb426 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/mocoserver/getcpulimits.json @@ -0,0 +1,26 @@ +{ + "request": { + "uri": "/openoapi/vimdriver/v1/limits/1234/cpumemory", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "query": { + "vimId": "123" + } + }, + "response": { + "status": 200, + "json": { + "limits": { + "rate": [], + "absolute": { + "maxTotalVolumes": 1000, + "totalVolumesUsed": 14, + "maxTotalVolumeGigabytes": 42000, + "totalGigabytesUsed":1054 + } + } + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/mocoserver/getdisklimits.json b/ResmanagementService/service/src/integration-test/resources/mocoserver/getdisklimits.json new file mode 100644 index 0000000..a99b0df --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/mocoserver/getdisklimits.json @@ -0,0 +1,24 @@ +{ + "request": { + "uri": "/openoapi/vimdriver/v1/limits/1234/disk", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "query": { + "vimId": "123" + } + }, + "response": { + "status": 200, + "json": { + "vimId": "123", + "vimName": "vim1", + "limits": { + "volumes": 1000, + "gigabytes": 42000, + "snapshots": 100 + } + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/mocoserver/gethost.json b/ResmanagementService/service/src/integration-test/resources/mocoserver/gethost.json new file mode 100644 index 0000000..427d208 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/mocoserver/gethost.json @@ -0,0 +1,51 @@ +{
+ "request": {
+ "uri": "/openoapi/vimdriver/v1/[a-zA-Z0-9\\-\\_]{1,36}/hosts/[a-zA-Z0-9\\-\\_]{1,36}",
+ "method": "get",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "query": {
+ "vimId": "123",
+ "tenantId": "1234"
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "hosts": [{
+ "resource": {
+ "cpu": 1,
+ "disk_gb": 1028,
+ "host": "c1a7de0ac9d94e4baceae031d05caae3",
+ "memory_mb": 8192,
+ "project": "(total)"
+ },
+ "vimId": "123",
+ "vimName": "vim"
+ },
+ {
+ "resource": {
+ "cpu": 0,
+ "disk_gb": 0,
+ "host": "c1a7de0ac9d94e4baceae031d05caae3",
+ "memory_mb": 512,
+ "project": "(used_now)"
+ },
+ "vimId": "123",
+ "vimName": "vim"
+ },
+ {
+ "resource": {
+ "cpu": 0,
+ "disk_gb": 0,
+ "host": "c1a7de0ac9d94e4baceae031d05caae3",
+ "memory_mb": 0,
+ "project": "(used_max)"
+ },
+ "vimId": "123",
+ "vimName": "vim"
+ }]
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/mocoserver/gethosts.json b/ResmanagementService/service/src/integration-test/resources/mocoserver/gethosts.json new file mode 100644 index 0000000..58d315b --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/mocoserver/gethosts.json @@ -0,0 +1,26 @@ +{
+ "request": {
+ "uri": "/openoapi/vimdriver/v1/[a-zA-Z0-9\\-\\_]{1,36}/hosts",
+ "method": "get",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "query": {
+ "vimId": "123",
+ "tenantId": "1234"
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "hosts": [
+ {
+ "host_name": "09c025b0efc64211bd23fc50fa974cdf",
+ "service": "compute",
+ "zone": "nova",
+ "vimId": "123",
+ "vimName": "vim"
+ }]
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/mocoserver/getnetworks.json b/ResmanagementService/service/src/integration-test/resources/mocoserver/getnetworks.json new file mode 100644 index 0000000..e8afa28 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/mocoserver/getnetworks.json @@ -0,0 +1,54 @@ +{
+ "request": {
+ "uri": "/openoapi/vimdriver/v1/networks",
+ "method": "get",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "query": {
+ "vimId": "123",
+ "tenantId": "1234"
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "networks": [{
+ "status": "ACTIVE",
+ "subnets": ["54d6f61d-db07-451c-9ab3-b9609b6b6f0b"],
+ "name": "private-network",
+ "provider:physical_network": null,
+ "admin_state_up": true,
+ "project_id": "4fd44f30292945e481c7b8a0c8908869",
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "qos_policy_id": "6a8454ade84346f59e8d40665f878b2e",
+ "provider:network_type": "local",
+ "router:external": true,
+ "mtu": 0,
+ "shared": true,
+ "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
+ "provider:segmentation_id": null,
+ "vimId": "123",
+ "vimName": "vim"
+ },
+ {
+ "status": "ACTIVE",
+ "subnets": ["08eae331-0402-425a-923c-34f7cfe39c1b"],
+ "name": "private",
+ "provider:physical_network": null,
+ "admin_state_up": true,
+ "project_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
+ "tenant_id": "26a7980765d0414dbc1fc1f88cdb7e6e",
+ "qos_policy_id": "bfdb6c39f71e4d44b1dfbda245c50819",
+ "provider:network_type": "local",
+ "router:external": true,
+ "mtu": 0,
+ "shared": true,
+ "id": "db193ab3-96e3-4cb3-8fc5-05f4296d0324",
+ "provider:segmentation_id": null,
+ "vimId": "123",
+ "vimName": "vim"
+ }]
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/mocoserver/getports.json b/ResmanagementService/service/src/integration-test/resources/mocoserver/getports.json new file mode 100644 index 0000000..37902ca --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/mocoserver/getports.json @@ -0,0 +1,60 @@ +{
+ "request": {
+ "uri": "/openoapi/vimdriver/v1/ports",
+ "method": "get",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "query": {
+ "vimId": "123",
+ "tenantId": "1234"
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "ports": [{
+ "status": "ACTIVE",
+ "name": "",
+ "allowed_address_pairs": [],
+ "admin_state_up": true,
+ "network_id": "70c1db1f-b701-45bd-96e0-a313ee3430b3",
+ "project_id": "",
+ "tenant_id": "",
+ "extra_dhcp_opts": [],
+ "device_owner": "network:router_gateway",
+ "mac_address": "fa:16:3e:58:42:ed",
+ "fixed_ips": [{
+ "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062",
+ "ip_address": "172.24.4.2"
+ }],
+ "id": "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b",
+ "security_groups": [],
+ "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824",
+ "vimId": "123",
+ "vimName": "vim"
+ },
+ {
+ "status": "ACTIVE",
+ "name": "",
+ "allowed_address_pairs": [],
+ "admin_state_up": true,
+ "network_id": "f27aa545-cbdd-4907-b0c6-c9e8b039dcc2",
+ "project_id": "d397de8a63f341818f198abb0966f6f3",
+ "tenant_id": "d397de8a63f341818f198abb0966f6f3",
+ "extra_dhcp_opts": [],
+ "device_owner": "network:router_interface",
+ "mac_address": "fa:16:3e:bb:3c:e4",
+ "fixed_ips": [{
+ "subnet_id": "288bf4a1-51ba-43b6-9d0a-520e9005db17",
+ "ip_address": "10.0.0.1"
+ }],
+ "id": "f71a6703-d6de-4be1-a91a-a570ede1d159",
+ "security_groups": [],
+ "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824",
+ "vimId": "123",
+ "vimName": "vim"
+ }]
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/mocoserver/sendmsgmonitor1.json b/ResmanagementService/service/src/integration-test/resources/mocoserver/sendmsgmonitor1.json new file mode 100644 index 0000000..9cbc812 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/mocoserver/sendmsgmonitor1.json @@ -0,0 +1,31 @@ +{
+ "request": {
+ "uri": "/openoapi/umcres/v1/resinfo",
+ "method": "post",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "json": {
+ "operationType": "create",
+ "resourceType": "HOST",
+ "label": "09c025b0efc64211bd23fc50fa974cdf",
+ "data": [{
+ "cpu": "1",
+ "disk": "1028",
+ "id": "12345678",
+ "memory": "8192",
+ "name": "09c025b0efc64211bd23fc50fa974cdf",
+ "vimId": "123",
+ "vimName": "vim"
+ }]
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "result": "SUCCESS",
+ "info": "resource monitor info add ok",
+ "oid": ["12345678"]
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/mocoserver/sendmsgmonitor2.json b/ResmanagementService/service/src/integration-test/resources/mocoserver/sendmsgmonitor2.json new file mode 100644 index 0000000..631cf55 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/mocoserver/sendmsgmonitor2.json @@ -0,0 +1,31 @@ +{
+ "request": {
+ "uri": "/openoapi/umcres/v1/resinfo",
+ "method": "post",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "json": {
+ "operationType": "update",
+ "resourceType": "HOST",
+ "label": "09c025b0efc64211bd23fc50fa974cdf",
+ "data": [{
+ "cpu": "20",
+ "disk": "100",
+ "id": "12345678",
+ "memory": "8",
+ "name": "09c025b0efc64211bd23fc50fa974cdf",
+ "vimId": "123",
+ "vimName": "456"
+ }]
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "result":"SUCCESS",
+ "info":"resource monitor info update ok",
+ "oid":["12345678"]
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/mocoserver/sendmsgmonitor3.json b/ResmanagementService/service/src/integration-test/resources/mocoserver/sendmsgmonitor3.json new file mode 100644 index 0000000..4452178 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/mocoserver/sendmsgmonitor3.json @@ -0,0 +1,23 @@ +{
+ "request": {
+ "uri": "/openoapi/umcres/v1/resinfo",
+ "method": "delete",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "json": {
+ "operationType": "delete",
+ "resourceType": "HOST",
+ "label": "09c025b0efc64211bd23fc50fa974cdf",
+ "deleteIds": ["12345678"]
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "result":"SUCCESS",
+ "info":"resource monitor info delete ok",
+ "oid":["12345678"]
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/server.properties b/ResmanagementService/service/src/integration-test/resources/server.properties new file mode 100644 index 0000000..44f3fdf --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/server.properties @@ -0,0 +1,14 @@ + +## Integration Test Server Configuration File + +## Server IpAddress +serverip=127.0.0.1 + +## Server Port +serverport=8080 + +## Http Moco Server Port +mocohttpport=12306 + +## Https Moco Server Port +mocohttpsport=12307
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/createhostsfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/createhostsfail1.json new file mode 100644 index 0000000..2966f48 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/createhostsfail1.json @@ -0,0 +1,24 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/hosts", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id":"12345678", + "name": "hostName", + "cpu": "20", + "memory": "8", + "disk": "100", + "vimId": "123", + "vimName": "456" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.service.host.add.id.check" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/createhostssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/createhostssuccess1.json new file mode 100644 index 0000000..4573a0c --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/createhostssuccess1.json @@ -0,0 +1,24 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/hosts", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id":"12345678", + "name": "hostName", + "cpu": "20", + "memory": "8", + "disk": "100", + "vimId": "123", + "vimName": "456" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.add.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/deletehostsfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/deletehostsfail1.json new file mode 100644 index 0000000..5144c9a --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/deletehostsfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/hosts?id=aaaa", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.error" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/deletehostssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/deletehostssuccess1.json new file mode 100644 index 0000000..98f3d13 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/deletehostssuccess1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/hosts?id=12345678", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/modhostsfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/modhostsfail1.json new file mode 100644 index 0000000..de24b26 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/modhostsfail1.json @@ -0,0 +1,24 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/hosts", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id":"aaaa", + "name": "newName", + "cpu": "20", + "memory": "8", + "disk": "100", + "vimId": "123", + "vimName": "456" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.update.error" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/modhostssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/modhostssuccess1.json new file mode 100644 index 0000000..3280951 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/modhostssuccess1.json @@ -0,0 +1,24 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/hosts", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id":"12345678", + "name": "hostName", + "cpu": "20", + "memory": "8", + "disk": "100", + "vimId": "123", + "vimName": "456" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.update.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/queryhostsbyidfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/queryhostsbyidfail1.json new file mode 100644 index 0000000..fe528b2 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/queryhostsbyidfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/hosts/aaaa", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "hosts": [] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/queryhostsbyidsuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/queryhostsbyidsuccess1.json new file mode 100644 index 0000000..0cccaa0 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/hostroa/queryhostsbyidsuccess1.json @@ -0,0 +1,23 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/hosts/12345678", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "hosts": [{ + "cpu": "20", + "disk": "100", + "id": "12345678", + "memory": "8", + "name": "hostName", + "vimId": "123", + "vimName": "456" + }] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/limitsroa/querycpulimitssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/limitsroa/querycpulimitssuccess1.json new file mode 100644 index 0000000..8b24164 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/limitsroa/querycpulimitssuccess1.json @@ -0,0 +1,23 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/limits/1234/cpu?vimId=123", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "limits": { + "rate": [], + "absolute": { + "maxTotalVolumes": 1000, + "totalVolumesUsed": 14, + "maxTotalVolumeGigabytes": 42000, + "totalGigabytesUsed":1054 + } + } + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/limitsroa/querydisklimitssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/limitsroa/querydisklimitssuccess1.json new file mode 100644 index 0000000..7da9cdb --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/limitsroa/querydisklimitssuccess1.json @@ -0,0 +1,21 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/limits/1234/disk?vimId=123", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "vimId": "123", + "vimName": "vim1", + "limits": { + "volumes": 1000, + "gigabytes": 42000, + "snapshots": 100 + } + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/createlocationsfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/createlocationsfail1.json new file mode 100644 index 0000000..c490bc9 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/createlocationsfail1.json @@ -0,0 +1,23 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/locations", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "12345678", + "country": "china", + "location": "shenzhen", + "latitude": "11", + "longitude": "22.2", + "description": "" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.service.base.location.add.entity.check" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/createlocationssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/createlocationssuccess1.json new file mode 100644 index 0000000..fb4b97a --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/createlocationssuccess1.json @@ -0,0 +1,23 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/locations", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "12345678", + "country": "china", + "location": "shenzhen", + "latitude": "11", + "longitude": "22.2", + "description": "" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.add.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/deletelocationsfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/deletelocationsfail1.json new file mode 100644 index 0000000..136096d --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/deletelocationsfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/locations/aaaa", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.error" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/deletelocationssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/deletelocationssuccess1.json new file mode 100644 index 0000000..eaaf8d9 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/deletelocationssuccess1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/locations/12345678", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/modlocationsfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/modlocationsfail1.json new file mode 100644 index 0000000..d362898 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/modlocationsfail1.json @@ -0,0 +1,23 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/locations", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "aaaa", + "country": "china", + "location": "shenzhen", + "latitude": "11.1", + "longitude": "22.2", + "description": "" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.service.base.location.update.modified.check" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/modlocationssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/modlocationssuccess1.json new file mode 100644 index 0000000..3205272 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/modlocationssuccess1.json @@ -0,0 +1,23 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/locations", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "12345678", + "country": "china", + "location": "shenzhen", + "latitude": "11.1", + "longitude": "22.2", + "description": "" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.update.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/querylocationsbyidfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/querylocationsbyidfail1.json new file mode 100644 index 0000000..b49a37d --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/querylocationsbyidfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/locations/aaaa", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "locations": [] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/querylocationsbyidsuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/querylocationsbyidsuccess1.json new file mode 100644 index 0000000..387adc9 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/locationroa/querylocationsbyidsuccess1.json @@ -0,0 +1,22 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/locations/12345678", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "locations": [{ + "country": "china", + "description": "", + "id": "12345678", + "latitude": "11", + "location": "shenzhen", + "longitude": "22.2" + }] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/createnetworksfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/createnetworksfail1.json new file mode 100644 index 0000000..014d49f --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/createnetworksfail1.json @@ -0,0 +1,26 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/networks", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "12345678", + "name": "name1", + "tenantId": "111111", + "status": "active", + "vimId": "123", + "vimName": "vimName", + "physicalNetwork": "physnet1", + "networkType": "vlan", + "segmentationId": "26" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.service.base.network.add.entity.check" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/createnetworkssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/createnetworkssuccess1.json new file mode 100644 index 0000000..b909858 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/createnetworkssuccess1.json @@ -0,0 +1,26 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/networks", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "12345678", + "name": "name1", + "tenantId": "111111", + "status": "active", + "vimId": "123", + "vimName": "vimName", + "physicalNetwork": "physnet1", + "networkType": "vlan", + "segmentationId": "26" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.add.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/deletenetworksfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/deletenetworksfail1.json new file mode 100644 index 0000000..d3a5e5a --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/deletenetworksfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/networks?id=aaaa", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.error" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/deletenetworkssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/deletenetworkssuccess1.json new file mode 100644 index 0000000..1e56c4b --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/deletenetworkssuccess1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/networks?id=12345678", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/modnetworksfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/modnetworksfail1.json new file mode 100644 index 0000000..2852a2a --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/modnetworksfail1.json @@ -0,0 +1,26 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/networks", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "aaaa", + "name": "newName1", + "tenantId": "111111", + "status": "active", + "vimId": "123", + "vimName": "vimName", + "physicalNetwork": "physnet1", + "networkType": "vlan", + "segmentationId": "26" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.update.error" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/modnetworkssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/modnetworkssuccess1.json new file mode 100644 index 0000000..fc6aed8 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/modnetworkssuccess1.json @@ -0,0 +1,26 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/networks", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "12345678", + "name": "newName1", + "tenantId": "111111", + "status": "active", + "vimId": "123", + "vimName": "vimName", + "physicalNetwork": "physnet1", + "networkType": "vlan", + "segmentationId": "26" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.update.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/querynetworksbyidfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/querynetworksbyidfail1.json new file mode 100644 index 0000000..ae888cf --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/querynetworksbyidfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/networks/aaaa", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "networks": [] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/querynetworksbyidsuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/querynetworksbyidsuccess1.json new file mode 100644 index 0000000..b933eb4 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/networkroa/querynetworksbyidsuccess1.json @@ -0,0 +1,25 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/networks/12345678", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "networks": [{ + "id": "12345678", + "name": "name1", + "tenant_id": "111111", + "status": "active", + "vimId": "123", + "vimName": "vimName", + "provider:physical_network": "physnet1", + "provider:network_type": "vlan", + "provider:segmentation_id": "26" + }] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/portroa/createportsfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/createportsfail1.json new file mode 100644 index 0000000..7270bf4 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/createportsfail1.json @@ -0,0 +1,24 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/ports", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "12345678", + "name": "portName", + "networkId": "1111", + "status": "ACTIVE", + "tenantId": "123456", + "vimId": "11", + "vimName": "22" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.service.port.add.id.check" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/portroa/createportssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/createportssuccess1.json new file mode 100644 index 0000000..b31d469 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/createportssuccess1.json @@ -0,0 +1,24 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/ports", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "12345678", + "name": "portName", + "networkId": "1111", + "status": "ACTIVE", + "tenantId": "123456", + "vimId": "11", + "vimName": "22" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.add.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/portroa/deleteportsfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/deleteportsfail1.json new file mode 100644 index 0000000..c4e3659 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/deleteportsfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/ports?id=aaaa", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.error" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/portroa/deleteportssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/deleteportssuccess1.json new file mode 100644 index 0000000..843593d --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/deleteportssuccess1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/ports?id=12345678", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/portroa/modportsfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/modportsfail1.json new file mode 100644 index 0000000..6c3f521 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/modportsfail1.json @@ -0,0 +1,24 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/ports", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "aaaa", + "name": "portName", + "networkId": "1111", + "status": "ACTIVE", + "tenantId": "123456", + "vimId": "11", + "vimName": "22" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.update.error" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/portroa/modportssuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/modportssuccess1.json new file mode 100644 index 0000000..583764c --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/modportssuccess1.json @@ -0,0 +1,24 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/ports", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "id": "12345678", + "name": "newName", + "networkId": "1111", + "status": "ACTIVE", + "tenantId": "123456", + "vimId": "11", + "vimName": "22" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.update.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/portroa/queryportsbyidfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/queryportsbyidfail1.json new file mode 100644 index 0000000..6a1007f --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/queryportsbyidfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/ports/aaaa", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "ports": [] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/portroa/queryportsbyidsuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/queryportsbyidsuccess1.json new file mode 100644 index 0000000..4fe360f --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/portroa/queryportsbyidsuccess1.json @@ -0,0 +1,23 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/ports/12345678", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "ports": [{ + "id": "12345678", + "name": "portName", + "networkId": "1111", + "status": "ACTIVE", + "tenantId": "123456", + "vimId": "11", + "vimName": "22" + }] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/addresourcefail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/addresourcefail1.json new file mode 100644 index 0000000..a604f52 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/addresourcefail1.json @@ -0,0 +1,18 @@ +{
+ "request": {
+ "uri": "/openoapi/resmgr/v1/resoperate/resmgr/vims?tenantId=1234",
+ "method": "post",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "json": {
+
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "msg": "org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.vimId"
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/addresourcesuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/addresourcesuccess1.json new file mode 100644 index 0000000..b23f38f --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/addresourcesuccess1.json @@ -0,0 +1,18 @@ +{
+ "request": {
+ "uri": "/openoapi/resmgr/v1/resoperate/resmgr/vims?tenantId=1234&vimId=123",
+ "method": "post",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "json": {
+
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "msg": "org.openo.nfvo.resmanage.common.add.success"
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/deleteresourcefail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/deleteresourcefail1.json new file mode 100644 index 0000000..d60484c --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/deleteresourcefail1.json @@ -0,0 +1,15 @@ +{
+ "request": {
+ "uri": "/openoapi/resmgr/v1/resoperate",
+ "method": "delete",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "msg": "org.openo.nfvo.resmanage.service.group.resoperate.res.no.vimId"
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/deleteresourcesuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/deleteresourcesuccess1.json new file mode 100644 index 0000000..4b099ae --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/deleteresourcesuccess1.json @@ -0,0 +1,15 @@ +{
+ "request": {
+ "uri": "/openoapi/resmgr/v1/resoperate?vimId=123",
+ "method": "delete",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "msg": "org.openo.nfvo.resmanage.common.del.success"
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/modresourcefail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/modresourcefail1.json new file mode 100644 index 0000000..0a54e89 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/modresourcefail1.json @@ -0,0 +1,17 @@ +{
+ "request": {
+ "uri": "/openoapi/resmgr/v1/resoperate/updateres?tenantId=1234",
+ "method": "put",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "json": {
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "msg": "org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result"
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/modresourcesuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/modresourcesuccess1.json new file mode 100644 index 0000000..c3196c1 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/resoperateroa/modresourcesuccess1.json @@ -0,0 +1,17 @@ +{
+ "request": {
+ "uri": "/openoapi/resmgr/v1/resoperate/updateres?tenantId=1234&vimId=123",
+ "method": "put",
+ "headers": {
+ "Content-Type": "application/json;charset=UTF-8"
+ },
+ "json": {
+ }
+ },
+ "response": {
+ "status": 200,
+ "json": {
+ "msg": "org.openo.nfvo.resmanage.common.update.success"
+ }
+ }
+}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/createsitesfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/createsitesfail1.json new file mode 100644 index 0000000..5584c1e --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/createsitesfail1.json @@ -0,0 +1,30 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/datacenters", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "country": "china", + "id": "12345678", + "location": "shanghai", + "name": "shanghai", + "status": "active", + "totalCPU": "100", + "totalDisk": "100", + "totalMemory": "100", + "usedCPU": "10", + "usedDisk": "10", + "usedMemory": "10", + "vimId": "123", + "vimName": "vimName" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.service.base.site.add.id.check" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/createsitessuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/createsitessuccess1.json new file mode 100644 index 0000000..af0d3af --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/createsitessuccess1.json @@ -0,0 +1,30 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/datacenters", + "method": "post", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "country": "china", + "id": "12345678", + "location": "shanghai", + "name": "shanghai", + "status": "active", + "totalCPU": "100", + "totalDisk": "100", + "totalMemory": "100", + "usedCPU": "0", + "usedDisk": "0", + "usedMemory": "0", + "vimId": "123", + "vimName": "vimName" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.add.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/deletesitesfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/deletesitesfail1.json new file mode 100644 index 0000000..aacd3fe --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/deletesitesfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/datacenters/aaaa", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.error" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/deletesitessuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/deletesitessuccess1.json new file mode 100644 index 0000000..d4b083b --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/deletesitessuccess1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/datacenters/12345678", + "method": "delete", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.del.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/modsitesfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/modsitesfail1.json new file mode 100644 index 0000000..2c1be4e --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/modsitesfail1.json @@ -0,0 +1,30 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/datacenters", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "country": "china", + "id": "aaaa", + "location": "shanghai", + "name": "newName", + "status": "active", + "totalCPU": "100", + "totalDisk": "100", + "totalMemory": "100", + "usedCPU": "0", + "usedDisk": "0", + "usedMemory": "0", + "vimId": "123", + "vimName": "vimName" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.update.error" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/modsitessuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/modsitessuccess1.json new file mode 100644 index 0000000..da19356 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/modsitessuccess1.json @@ -0,0 +1,30 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/datacenters", + "method": "put", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + }, + "json": { + "country": "china", + "id": "12345678", + "location": "shanghai", + "name": "newName", + "status": "active", + "totalCPU": "100", + "totalDisk": "100", + "totalMemory": "100", + "usedCPU": "0", + "usedDisk": "0", + "usedMemory": "0", + "vimId": "123", + "vimName": "vimName" + } + }, + "response": { + "status": 200, + "json": { + "msg": "org.openo.nfvo.resmanage.common.update.success" + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/querysitesbyidfail1.json b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/querysitesbyidfail1.json new file mode 100644 index 0000000..b12b02c --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/querysitesbyidfail1.json @@ -0,0 +1,15 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/datacenters/aaaa", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "datacenters": [] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/querysitesbyidsuccess1.json b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/querysitesbyidsuccess1.json new file mode 100644 index 0000000..984a7eb --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/testcase/siteroa/querysitesbyidsuccess1.json @@ -0,0 +1,29 @@ +{ + "request": { + "uri": "/openoapi/resmgr/v1/datacenters/12345678", + "method": "get", + "headers": { + "Content-Type": "application/json;charset=UTF-8" + } + }, + "response": { + "status": 200, + "json": { + "datacenters": [{ + "country": "china", + "id": "12345678", + "location": "shanghai", + "name": "shanghai", + "status": "active", + "totalCPU": "100", + "totalDisk": "100", + "totalMemory": "100", + "usedCPU": "0", + "usedDisk": "0", + "usedMemory": "0", + "vimId": "123", + "vimName": "vimName" + }] + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/integration-test/resources/urlconfig.json b/ResmanagementService/service/src/integration-test/resources/urlconfig.json new file mode 100644 index 0000000..9d07650 --- /dev/null +++ b/ResmanagementService/service/src/integration-test/resources/urlconfig.json @@ -0,0 +1,18 @@ +[ + { + "url": "/svc/ipsec/v1", + "prefix": "/org.openo.sdno.ipsecservice" + }, + { + "url": "/v2.0/tokens", + "prefix": "" + }, + { + "url": "/v2.0/networks", + "prefix": "" + }, + { + "url": "/rest/v1/resmanage/virtualnetworks", + "prefix": "" + } +]
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java new file mode 100644 index 0000000..572de2b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class ResourceUtil { + + private ResourceUtil() { + + } + + /** + * It is used to get Message<br/> + * + * @param key + * @return + * @since NFVO 0.5 + */ + public static String getMessage(String key) { + return key; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java new file mode 100644 index 0000000..5f2d417 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java @@ -0,0 +1,141 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common; + +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.RestfulUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 30, 2016 + */ +public class VimUtil { + + private static final Logger LOG = LoggerFactory.getLogger(VimUtil.class); + + private VimUtil() { + + } + + /** + * Get VIMs. + * + * @return + */ + public static JSONArray getVims() { + String esrResponse = + RestfulUtil.getResponseContent(UrlConstant.ESR_GET_VIMS_URL, new RestfulParametes(), "get"); + LOG.info("Get vims from ESR! EsrResponse:{}", esrResponse); + if(null == esrResponse) { + LOG.error("ESR return fail."); + return null; + } else { + return JSONArray.fromObject(esrResponse); + } + + } + + /** + * Get vimId by vimName. + * + * @return + */ + public static String getVimIdByName(String name) { + JSONArray vims = getVims(); + for(int i = 0; i < vims.size(); i++) { + JSONObject vim = vims.getJSONObject(i); + LOG.info("vimInfo: " + vim); + String vimName = vim.getString("name"); + String vimId = vim.getString("vimId"); + LOG.info("name:" + name + ", vimName:" + vimName + ", vimId:" + vimId); + if(name.trim().equalsIgnoreCase(vimName)) { + return vimId; + } + } + LOG.error("No vim with this vimName"); + return ""; + + } + + /** + * Get VIM. + * + * @param vimId + * @return + */ + public static JSONObject getVimById(String vimId) { + if(vimId == null || "".equals(vimId.trim())) { + LOG.error("Get vim ERROR, VimId is null. "); + return null; + } + JSONObject esrResponse = RestfulUtil.getResponseObj(String.format(UrlConstant.ESR_GET_VIM_URL, vimId), "get"); + LOG.info("Get vims from ESR! EsrResponse:{}", esrResponse); + if(null == esrResponse) { + LOG.error("ESR return fail."); + return null; + } else { + return esrResponse; + } + } + + /** + * Get tenants. + * + * @param vimId + * @return + */ + public static JSONArray getTenants(String vimId) { + String url = String.format(UrlConstant.GET_TENANT_URL, vimId); + JSONObject resultObj = RestfulUtil.getResponseObj(url, ParamConstant.PARAM_GET); + JSONArray tenants = resultObj.getJSONArray("tenants"); + LOG.info("Get tenants from multivim! tenants:{}", tenants); + return tenants; + } + + /** + * <br> + * + * @param tenant + * @param vimId + * @return + * @since NFVO 0.5 + */ + public static String getTenantIdByName(String tenant, String vimId) { + JSONArray tenants = VimUtil.getTenants(vimId); + String tenantId = ""; + for(int i = 0; i < tenants.size(); i++) { + JSONObject obj = tenants.getJSONObject(i); + String name = obj.getString("name"); + if(name.equalsIgnoreCase(tenant)) { + tenantId = obj.getString("id"); + } + } + LOG.info("GetTenantIdByName tenantId:{}", tenantId); + return tenantId; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java new file mode 100644 index 0000000..1e5941d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java @@ -0,0 +1,93 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.constant; + +/** + * HTTP constants<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class Constant { + + public static final String RES_MANAGEMENT_DB = "resmanagementdb"; + + /** + * Database Delete/Modify/Add fail. + */ + public static final int ERROR_CODE = -1; + + /** + * Database Delete/Modify/Add success. + */ + public static final int OK_CODE = 1; + + /** + * Lack of resource. + */ + public static final int RES_NOT_ENOUGH_CODE = -2; + + /** + * Module name. + */ + public static final String MODULE_NAME = "Resmanagement"; + + public static final String RESPONSE_CONTENT = "responseContent"; + + public static final String STATUS_CODE = "statusCode"; + + /** + * Format Time + */ + public static final String DATE_FORMATE = "yyyy-MM-dd HH:mm:ss"; + + public static final String DATE_UTC_FORMATE = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + + public static final String UTC_FORMATE = "UTC"; + + public static final String DATE_DAY_FORMATE = "yyyy-MM-dd 00:00:00"; + + /** + * IAM + */ + + public static final String HTTP_CONTENT_TYPE = "Content-Type"; + + public static final String HTTP_CONTENT_TYPE_VALUE = "application/json;charset=UTF-8"; + + public static final String X_TENANT_ID = "X-Tenant-Id"; + + public static final String IAM_TOKEN = "x-auth-token"; + + public static final String IAM_AUTH_TOKEN = "X-Auth-Token"; + + public static final String IAM_USER_ID = "X-User-Id"; + + public static final String IAM_USER_NAME = "X-User-Name"; + + public static final String IAM_DOMAIN_NAME = "X-Domain-Name"; + + public static final String HEADER_SUBJECT_TOKEN = "X-Subject-Token"; + + public static final int REPEAT_REG_TIME = 60 * 1000; + + private Constant() { + // private constants + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java new file mode 100644 index 0000000..f480b70 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java @@ -0,0 +1,79 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.constant; + +/** + * + * Http constant class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class HttpConstant { + + public static final int ERROR_CODE = -1; + + public static final int OK_CODE = 1; + + public static final int HTTP_OK = 200; + + public static final int HTTP_CREATED = 201; + + public static final int HTTP_ACCEPTED = 202; + + public static final int HTTP_NOCONTENT = 204; + + public static final int HTTP_UNAUTHORIZED = 401; + + public static final int HTTP_BAD_REQUEST = 400; + + public static final int HTTP_NOTFOUND_CODE = 404; + + public static final int HTTP_CONFLICT_CODE = 409; + + public static final int HTTP_INVALID_PARAMETERS = 415; + + public static final int HTTP_INNERERROR_CODE = 500; + + public static final int INTERNAL_EXCEPTION_CODE = 600; + + public static final int TOKEN_HEAD_NULL_CODE = 601; + + public static final int TOKEN_USER_NULL_CODE = 602; + + public static final int SERVICE_URL_ERROR_CODE = 603; + + public static final int ACCESS_OBJ_NULL_CODE = 604; + + public static final int CONNECT_NOT_FOUND_CODE = 605; + + public static final int VCENTER_PARA_ERROR_CODE = 606; + + public static final int TYPE_PARA_ERROR_CODE = 607; + + public static final int CONNECT_FAIL_CODE = 608; + + public static final int DIS_CONNECT_FAIL_CODE = 609; + + public static final int HANDSHAKE_FAIL_CODE = 610; + + private HttpConstant() { + //private constructor + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java new file mode 100644 index 0000000..9ba0c4c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java @@ -0,0 +1,370 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.constant; + +/** + * <br/> + * <p> + * Contstant for System interactive. + * </p> + * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public class ParamConstant { + + /** + * param key: vimId. + */ + public static final String PARAM_VIMID = "vimId"; + + /** + * param key: vimName + */ + public static final String PARAM_VIMNAME = "vimName"; + + /** + * param key: tenantId. + */ + public static final String PARAM_TENANTID = "tenantId"; + + public static final String TOTAL_CPU = "totalCPU"; + + public static final String USED_CPU = "usedCPU"; + + public static final String TOTAL_MEMORY = "totalMemory"; + + public static final String USED_MEMORY = "usedMemory"; + + public static final String TOTAL_DISK = "totalDisk"; + + public static final String USED_DISK = "usedDisk"; + + /** + * param key: data. + */ + public static final String PARAM_DATA = "data"; + + /** + * param key: id. + */ + public static final String PARAM_ID = "id"; + + /** + * param key: vimId + */ + public static final String PARAM_IP = "ip"; + + /** + * param key: role. + */ + public static final String PARAM_ROLE = "role"; + + /** + * param key: roleId. + */ + public static final String PARAM_ROLEID = "roleId"; + + /** + * param key: total. + */ + public static final String PARAM_TOTAL = "total"; + + /** + * param key: used. + */ + public static final String PARAM_USED = "used"; + + /** + * param key: vcpus. + */ + public static final String PARAM_VCPUS = "vcpus"; + + /** + * param key: disk. + */ + public static final String PARAM_DISK = "disk"; + + /** + * param key: cpumhz. + */ + public static final String PARAM_CPUMHZ = "cpumhz"; + + /** + * param key: countyr + */ + public static final String PARAM_COUNTRY = "country"; + + /** + * param key: vendorId + */ + public static final String PARAM_VENDORID = "vendorId"; + + /** + * param key: vendorName + */ + public static final String PARAM_VENDORNAME = "vendorName"; + + /** + * param key: memory. + */ + public static final String PARAM_MEMORY = "memory"; + + /** + * param key: name. + */ + public static final String PARAM_NAME = "name"; + + /** + * param key: status. + */ + public static final String PARAM_STATUS = "status"; + + /** + * param key: parent. + */ + public static final String PARAM_PARENT = "parent"; + + /** + * param key: location. + */ + public static final String PARAM_LOCATION = "location"; + + /** + * param key: siteName. + */ + public static final String PARAM_SITENAME = "siteName"; + + /** + * param key: vendor. + */ + public static final String PARAM_VENDOR = "vendor"; + + /** + * param key: vendors. + */ + public static final String PARAM_VENDORS = "vendors"; + + /** + * param key: tenantSites. + */ + public static final String PARAM_TENANTSITES = "tenantSites"; + + /** + * param key: siteId. + */ + public static final String PARAM_SITEID = "siteId"; + + /** + * param key: resArbitration. + */ + public static final String PARAM_RESARBITRATION = "resArbitration"; + + /** + * param key: userRole. + */ + public static final String PARAM_USERROLE = "userRole"; + + /** + * param key: admin. + */ + public static final String PARAM_ADMIN = "admin"; + + /** + * param key: tenant. + */ + public static final String PARAM_TENANT = "tenant"; + + /** + * param key: type. + */ + public static final String PARAM_TYPE = "type"; + + /** + * param key: action. + */ + public static final String PARAM_ACTION = "action"; + + /** + * param key: offline. + */ + public static final String PARAM_OFFLINE = "offline"; + + /** + * param key: online. + */ + public static final String PARAM_ONLINE = "online"; + + /** + * param key: drexecute. + */ + public static final String PARAM_DREXECUTE = "drexecute"; + + /** + * param key: drRollBack. + */ + public static final String PARAM_DRROLLBACK = "drrollback"; + + /** + * param key: scaleOut. + */ + public static final String PARAM_SCALEOUT = "scaleout"; + + /** + * param key: scaleIn. + */ + public static final String PARAM_SCALEIN = "scalein"; + + /** + * param key: network. + */ + public static final String PARAM_NETWORK = "networks"; + + /** + * param key: host. + */ + public static final String PARAM_HOST = "hosts"; + + /** + * param key: network. + */ + public static final String PARAM_PORT = "ports"; + + /** + * param key: providernetworks. + */ + public static final String PARAM_PROVIDERNETWORKS = "providernetworks"; + + /** + * param key: vims. + */ + public static final String PARAM_VIMS = "vims"; + + /** + * param key: vms. + */ + public static final String PARAM_VMS = "vms"; + + /** + * param key: vapps. + */ + public static final String PARAM_VAPPS = "vapps"; + + /** + * param key: vapp. + */ + public static final String PARAM_VAPP = "vapp"; + + /** + * param key: sites. + */ + public static final String PARAM_SITES = "sites"; + + /** + * param key: vduId. + */ + public static final String PARAM_VDUID = "vduId"; + + /** + * param key: vappId. + */ + public static final String PARAM_VAPPID = "vappId"; + + /** + * param key: hostId. + */ + public static final String PARAM_HOSTID = "hostId"; + + /** + * param key: projectId. + */ + public static final String PARAM_PROJECTID = "projectId"; + + /** + * param key: vnfmId. + */ + public static final String PARAM_VNFMID = "vnfmId"; + + /** + * param key: params. + */ + public static final String PARAM_PARAMS = "params"; + + /** + * param key: url. + */ + public static final String PARAM_URL = "url"; + + /** + * param key: post. + */ + public static final String PARAM_POST = "post"; + + /** + * param key: put. + */ + public static final String PARAM_PUT = "put"; + + /** + * param key: del. + */ + public static final String PARAM_DEL = "del"; + + /** + * param key: get. + */ + public static final String PARAM_GET = "get"; + + /** + * param key: retCode. + */ + public static final String PARAM_RETCODE = "retCode"; + + /** + * param key: ADD. + */ + public static final String PARAM_ADD = "add"; + + /** + * param key: active. + */ + public static final String PARAM_ACTIVE = "active"; + + /** + * param key: deleted. + */ + public static final String PARAM_DELETED = "deleted"; + + /** + * param key: deleting. + */ + public static final String PARAM_DELETING = "deleting"; + + /** + * param key: response + */ + public static final String PARAM_RESPONSE = "response"; + + /** + * param key: info + */ + public static final String PARAM_INFO = "info"; + + private ParamConstant() { + // private constructor + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java new file mode 100644 index 0000000..a4fe9e0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java @@ -0,0 +1,60 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.constant; + +import org.openo.nfvo.resmanagement.common.ResourceUtil; + +/** + * Response constants.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class ResponseConstant { + + public static final String ADD_SUCESS_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.add.success"); + + public static final String ADD_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.add.error"); + + public static final String DEL_SUCESS_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.del.success"); + + public static final String DEL_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.del.error"); + + public static final String MOD_SUCESS_MSG = + ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.update.success"); + + public static final String MOD_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.update.error"); + + public static final String QUERY_SUCESS_MSG = + ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.query.success"); + + public static final String QUERY_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.query.error"); + + public static final String DELSODORES_FAIL_MSG = "delete sodores error"; + + public static final String DELVNFMINFO_FAIL_MSG = "delete vnfm error"; + + public static final String RES_VERIFY_SUCESS_MSG = "nsdata verify sucessfully"; + + public static final String RES_VERIFY_FAIL_MSG = "res verify failed"; + + private ResponseConstant() { + // private constructor + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java new file mode 100644 index 0000000..b9a93a1 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java @@ -0,0 +1,258 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.constant; + +/** + * <br/> + * <p> + * Constant for REST URL. + * </p> + * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public class UrlConstant { + + /** + * networks target. + */ + public static final String LOCATION_TARGET = "location"; + + /** + * MSB register url. + */ + public static final String REST_MSB_REGISTER = "/openoapi/microservices/v1/services"; + + public static final String ESR_GET_VIM_URL = "/openoapi/extsys/v1/vims/%s"; + + public static final String ESR_GET_VIMS_URL = "/openoapi/extsys/v1/vims"; + + /** + * send resource info to monitor url + */ + public static final String SEND_MSG_MONITOR = "/openoapi/umc/v1/resinfo"; + + /** + * networks url. + */ + public static final String LOCATION_URL = "/v1/locations"; + + /** + * port url. + */ + public static final String PORT_URL = "/v1/ports"; + + /** + * host url. + */ + public static final String HOST_URL = "/v1/hosts"; + + /** + * vl url. + */ + public static final String VL_URL = "/v1/vl"; + + /** + * vnf url. + */ + public static final String VNF_URL = "/v1/vnf"; + + /** + * vnfinfo url. + */ + public static final String VNFINFO_URL = "/v1/vnfinfo"; + + /** + * vnfstatus url. + */ + public static final String VNFSTATUS_URL = "/v1/vnfstatus"; + + /** + * grant resource url. + */ + public static final String GRANTRES_URL = "/v1/resource/grant"; + + /** + * vm url. + */ + public static final String VM_URL = "/v1/vm"; + + /** + * sites target. + */ + public static final String SITES_TARGET = "sites"; + + /** + * sites url. + */ + public static final String SITES_URL = "/v1/datacenters"; + + /** + * networks target. + */ + public static final String NETWORKS_TARGET = "networks"; + + /** + * networks url. + */ + public static final String NETWORKS_URL = "/v1/networks"; + + /** + * updateres. + */ + public static final String MODRES_URL = "/updateres"; + + /** + * resoperate target. + */ + public static final String RESOPERATE_TARGET = "resoperate"; + + /** + * APPLICATION_TYPE. + */ + public static final String APPLICATION_TYPE = "application/json"; + + /** + * ADDRES. + */ + public static final String ADDRES_URL = "/resmgr/vims"; + + /** + * updatebytenant. + */ + public static final String UPDATE_BY_TENANT = "updatebytenant"; + + /** + * updatebyvapp. + */ + public static final String UPDATE_BY_VAPP = "updatebyvapp"; + + /** + * getNetworkURL. + */ + public static final String GET_NETWORK_URL = "/openoapi/multivim/v1/%s/%s/networks"; + + /** + * getTenantURL. + */ + public static final String GET_TENANT_URL = "/openoapi/multivim/v1/%s/tenants"; + + /** + * getHostURL. + */ + public static final String GET_HOST_URL = "/openoapi/multivim/v1/%s/%s/hosts"; + + /** + * getHostDetailURL. + */ + public static final String GET_HOSTDETAIL_URL = "/openoapi/multivim/v1/%s/%s/hosts/%s"; + + /** + * getNetworkURL. + */ + public static final String GET_PORT_URL = "/openoapi/multivim/v1/%s/%s/ports"; + + /** + * getLimitsURL. + */ + public static final String GET_LIMITS_URL = "/openoapi/multivim/v1/%s/%s/limits"; + + /** + * template notify M url. + */ + public static final String TEMPLATE_NOTIFY_M_URL = ""; + + /** + * tenantsite allot url. + */ + public static final String TENANTSITE_ALLOT_URL = "/v1/resmanage/tenantsite/allot"; + + /** + * tenantsite allot target. + */ + public static final String TENANTSITE_ALLOT_TARGET = "tenantsite/allot"; + + /** + * tenant url. + */ + public static final String TENANT_URL = "/v1/resmanage/tenant"; + + /** + * tenant target. + */ + public static final String TENANT_TARGET = "tenant"; + + /** + * rollback url. + */ + public static final String ROLLBACK_URL = "/v1/resmanage/rollback"; + + /** + * rollback target. + */ + public static final String ROLLBACK_TARGET = "rollback"; + + /** + * vms target. + */ + public static final String VIM_TARGET = "vim"; + + /** + * vms url. + */ + public static final String VIM_URL = "/v1/resmanage/vim"; + + /** + * https + */ + public static final String GET_HTTPS = "https://"; + + /** + * get token + */ + public static final String GET_IAM_TOKEN = "/v3/auth/tokens"; + + /** + * rest. + */ + public static final String REST = "/rest"; + + /** + * donsdata url. + */ + public static final String INSTALL_URL = "install"; + + /** + * donsdata url. + */ + public static final String UNINSTALL_URL = "uninstall"; + + /** + * respool url. + */ + public static final String RESOPERATE_URL = "/v1/resoperate"; + + /** + * limits url. + */ + public static final String LIMITS_URL = "/v1/limits"; + + private UrlConstant() { + // private constructor + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java new file mode 100644 index 0000000..5440a7a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java @@ -0,0 +1,290 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util; + +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONException; +import net.sf.json.JSONObject; + +/** + * + * Json Utility Class.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public final class JsonUtil { + + private static final Logger LOG = LoggerFactory.getLogger(StringUtil.class); + + private static final int TYPE_STRING = 0; + + private static final int TYPE_INT = 1; + + private static final int TYPE_JSONA = 2; + + private static final int TYPE_JSONO = 3; + + private static final int TYPE_LONG = 4; + + private JsonUtil() { + } + + /** + * + * Get Json Field String.<br> + * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static String getJsonFieldStr(JSONObject jsonObj, String fieldName) { + return (String)getJsonFieldObject(jsonObj, fieldName, TYPE_STRING); + } + + /** + * + * Get Json Field Integer.<br> + * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static Integer getJsonFieldInt(JSONObject jsonObj, String fieldName) { + return (Integer)getJsonFieldObject(jsonObj, fieldName, TYPE_INT); + } + + /** + * + * Get Json Field array.<br> + * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static JSONArray getJsonFieldArr(JSONObject jsonObj, String fieldName) { + return (JSONArray)getJsonFieldObject(jsonObj, fieldName, TYPE_JSONA); + } + + /** + * + * Get Json Field Json.<br> + * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static JSONObject getJsonFieldJson(JSONObject jsonObj, String fieldName) { + return (JSONObject)getJsonFieldObject(jsonObj, fieldName, TYPE_JSONO); + } + + /** + * + * Get Json Field Long.<br> + * + * @param jsonObj + * @param fieldName + * @return + * @since NFVO 0.5 + */ + public static Long getJsonFieldLong(JSONObject jsonObj, String fieldName) { + return (Long)getJsonFieldObject(jsonObj, fieldName, TYPE_LONG); + } + + /** + * + * Get Json Field Object.<br> + * + * @param jsonObj + * @param fieldName + * @param classType + * @return + * @since NFVO 0.5 + */ + private static Object getJsonFieldObject(JSONObject jsonObj, String fieldName, int classType) { + try { + if(null != jsonObj && jsonObj.has(fieldName)) { + Object result = new Object(); + switch(classType) { + case TYPE_STRING: + result = "null".equals(jsonObj.getString(fieldName)) ? "" : jsonObj.getString(fieldName); + break; + case TYPE_INT: + result = jsonObj.getInt(fieldName); + break; + case TYPE_JSONA: + result = jsonObj.getJSONArray(fieldName); + break; + case TYPE_JSONO: + result = jsonObj.getJSONObject(fieldName); + break; + case TYPE_LONG: + result = jsonObj.getLong(fieldName); + break; + default: + result = null; + break; + } + return result; + } + } catch(JSONException e) { + LOG.error("function=getJsonFieldLong, exception: {} ", e); + return null; + } + return null; + } + + /** + * + * Check whether the Json Object is empty.<br> + * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static boolean isNullJson(JSONObject jsonObject) { + if(null == jsonObject || jsonObject.isEmpty()) { + return true; + } + return false; + } + + /** + * + * Get String value by Json.<br> + * + * @param json + * @param key + * @return + * @since NFVO 0.5 + */ + public static String getStrValueByjson(JSONObject json, String key) { + JSONArray names = json.names(); + String result = null; + for(int i = 0; i < names.size(); i++) { + String nodeName = names.getString(i); + if(json.optJSONObject(nodeName) != null) { + result = getStrValueByjson(json.getJSONObject(nodeName), key); + } + if(json.optJSONArray(nodeName) != null) { + result = getStrValueByJArray(json.getJSONArray(nodeName), key); + } + if(nodeName.equals(key)) { + result = json.getString(nodeName); + break; + } + } + return result; + } + + private static String getStrValueByJArray(JSONArray json, String key) { + String result = null; + for(int i = 0; i < json.size(); i++) { + if(json.optJSONObject(i) != null) { + result = getStrValueByjson(json.getJSONObject(i), key); + } + if(json.optJSONArray(i) != null) { + result = getStrValueByJArray(json.getJSONArray(i), key); + } + } + return result; + } + + /** + * + * Get Json Value by Json object.<br> + * + * @param json + * @param key + * @return + * @since NFVO 0.5 + */ + public static JSONObject getJsonValueByjson(JSONObject json, String key) { + JSONObject resultJson = new JSONObject(); + String result = getStrValueByjson(json, key); + if(null == result) { + return null; + } + resultJson.element(key, result); + return resultJson; + + } + + /** + * + * Get String Value by Json object.<br> + * + * @param json + * @param parentKey + * @param key + * @return + * @since NFVO 0.5 + */ + public static String getStrValueByJson(JSONObject json, String parentKey, String key) { + if(parentKey.isEmpty()) { + return getStrValueByjson(json, key); + } + JSONObject parentJson = getJsonValueByjson(json, parentKey); + if(isNullJson(parentJson)) { + return null; + } + return getStrValueByjson(parentJson, key); + + } + + /** + * + * Get response Data.<br> + * + * @param obj + * @return + * @since NFVO 0.5 + */ + public static JSONObject getResponseData(JSONObject obj) { + JSONObject result = new JSONObject(); + + Integer retCode = getJsonFieldInt(obj, ParamConstant.PARAM_RETCODE); + if(null == retCode || retCode == -1) { + return null; + } + + if(obj.optJSONObject(ParamConstant.PARAM_DATA) != null) { + result = obj.getJSONObject(ParamConstant.PARAM_DATA); + } else if(obj.optJSONArray(ParamConstant.PARAM_DATA) != null) { + result = obj.getJSONArray(ParamConstant.PARAM_DATA).getJSONObject(0); + } + if(result.isEmpty()) { + return null; + } + + if(result.containsKey(ParamConstant.PARAM_RETCODE)) { + result = getResponseData(result); + } + return result; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java new file mode 100644 index 0000000..e644e27 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java @@ -0,0 +1,371 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util; + +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.Restful; +import org.openo.baseservice.roa.util.restclient.RestfulAsyncCallback; +import org.openo.baseservice.roa.util.restclient.RestfulFactory; +import org.openo.baseservice.roa.util.restclient.RestfulOptions; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.Constant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONException; +import net.sf.json.JSONObject; + +/** + * Restful Utility Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class RestfulUtil { + + public static final String TYPE_GET = "get"; + + public static final String TYPE_PUT = "put"; + + public static final String TYPE_POST = "post"; + + public static final String TYPE_DEL = "delete"; + + public static final String CONTENT_TYPE = "Content-type"; + + public static final String APPLICATION = "application/json"; + + private static final Logger LOGGER = LoggerFactory.getLogger(RestfulUtil.class); + + private static final Restful REST_CLIENT = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); + + private RestfulUtil() { + } + + /** + * Get response object.<br> + * + * @param url + * @param type + * @return + * @since NFVO 0.5 + */ + public static JSONObject getResponseObj(String url, String type) { + return getResponseObj(url, new RestfulParametes(), type); + } + + /** + * Get response object.<br> + * + * @param url + * @param parametes + * @param type + * @return + * @since NFVO 0.5 + */ + public static JSONObject getResponseObj(String url, RestfulParametes parametes, String type) { + try { + String content = RestfulUtil.getResponseContent(url, parametes, null, type); + LOGGER.error("function=getResponseObj, content : {}", content); + if(StringUtils.isEmpty(content)) { + return null; + } + return JSONObject.fromObject(content); + } catch(JSONException e) { + LOGGER.error("function=getResponseObj, exception : {}", e); + return null; + } + } + + /** + * Get response content.<br> + * + * @param url + * @param restParametes + * @param type + * @return + * @since NFVO 0.5 + */ + public static String getResponseContent(String url, RestfulParametes restParametes, String type) { + return getResponseContent(url, restParametes, null, type); + } + + /** + * Get response map.<br> + * + * @param url + * @param restParametes + * @param opt + * @param type + * @return + * @since NFVO 0.5 + */ + public static Map<String, Object> getResponseMap(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + RestfulResponse response = restfulResponse(url, restParametes, opt, type); + return getResponseMap(response); + } + + /** + * Get response content map.<br> + * + * @param url + * @param type + * @return + * @since NFVO 0.5 + */ + public static Map<String, Object> getResponseContentMap(String url, String type) { + RestfulResponse response = restfulResponse(url, new RestfulParametes(), null, type); + return getResponseMap(response); + } + + private static Map<String, Object> getResponseMap(RestfulResponse response) { + Map<String, Object> resMap = new HashMap<>(10); + if(null != response) { + resMap.put(Constant.RESPONSE_CONTENT, response.getResponseContent()); + resMap.put(Constant.STATUS_CODE, response.getStatus()); + } + return resMap; + } + + /** + * Get response content.<br> + * + * @param url + * @param restParametes + * @param opt + * @param type + * @return + * @since NFVO 0.5 + */ + public static String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + String responseContent = null; + RestfulResponse rsp = restfulResponse(url, restParametes, opt, type); + if(rsp != null) { + int httpStatus = rsp.getStatus(); + LOGGER.warn("function=getResponseContent, get response httpStatusCode : {} ", httpStatus); + if(httpStatus < HttpServletResponse.SC_BAD_REQUEST && httpStatus > 0) { + responseContent = rsp.getResponseContent(); + LOGGER.warn("function=getResponseContent, get response data success!responseContent={}", + responseContent); + } + } + return responseContent; + } + + /** + * Get restful response.<br> + * + * @param url + * @param restParametes + * @param type + * @return + * @since NFVO 0.5 + */ + public static RestfulResponse getRestfulResponse(String url, RestfulParametes restParametes, String type) { + return restfulResponse(url, restParametes, null, type); + } + + private static RestfulResponse restfulResponse(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + RestfulResponse rsp = new RestfulResponse(); + try { + + if(REST_CLIENT != null) { + if(TYPE_GET.equals(type)) { + rsp = REST_CLIENT.get(url, restParametes, opt); + } else if(TYPE_POST.equals(type)) { + rsp = REST_CLIENT.post(url, restParametes, opt); + } else if(TYPE_PUT.equals(type)) { + rsp = REST_CLIENT.put(url, restParametes, opt); + } else if(TYPE_DEL.equals(type)) { + rsp = REST_CLIENT.delete(url, restParametes, opt); + } + } + } catch(ServiceException e) { + LOGGER.error("function=restfulResponse, get restful response catch exception {} ", e); + } + LOGGER.warn("function=restfulResponse, response status is {} ", rsp.getStatus()); + return rsp; + } + + /** + * encapsulate the java reflect exception.<br> + * + * @param methodName, Restful's method. + * @param objects, method param array. + * @return + * @since NFVO 0.5 + */ + public static RestfulResponse getRestRes(String methodName, Object... objects) { + try { + if(objects == null || REST_CLIENT == null) { + return null; + } + + Class<?>[] classes = new Class[objects.length]; + for(int i = 0; i < objects.length; i++) { + classes[i] = objects[i].getClass(); + } + if(methodName.startsWith("async")) { + classes[classes.length - 1] = RestfulAsyncCallback.class; + } + + Class<?> rtType = methodName.startsWith("async") ? void.class : RestfulResponse.class; + MethodType mt = MethodType.methodType(rtType, classes); + Object result = MethodHandles.lookup().findVirtual(REST_CLIENT.getClass(), methodName, mt) + .bindTo(REST_CLIENT).invokeWithArguments(objects); + if(result != null) { + return (RestfulResponse)result; + } + LOGGER.warn("function=getRestRes, msg: invoke Restful async {} method which return type is Void.", + methodName); + return null; + } catch(ReflectiveOperationException e) { + LOGGER.error("function=getRestRes, msg=error occurs, e={}.", e); + } catch(Throwable e) {// NOSONAR + LOGGER.error("function=getRestRes, msg=Throwable, e={}.", e); + try { + throw (ServiceException)new ServiceException().initCause(e.getCause()); + } catch(ServiceException se) { + LOGGER.error("function=getRestRes, msg=ServiceException occurs, e={}.", se); + } + } + return null; + } + + /** + * Get response.<br> + * + * @param restParametes + * @param url + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public static JSONArray getResponseRes(RestfulParametes restParametes, String url) throws ServiceException { + String result = getResponseContent(url, restParametes, RestfulUtil.TYPE_GET); + if(null == result || result.isEmpty()) { + LOGGER.error("result from url:" + url + " result:" + result); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); + } + + JSONArray rsArray = null; + try { + JSONObject rsJson = JSONObject.fromObject(result); + rsArray = rsJson.getJSONArray(ParamConstant.PARAM_DATA); + } catch(JSONException e) { + LOGGER.error("getResources error:" + e); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); + } + return rsArray; + } + + /** + * Get response.<br> + * + * @param restParametes + * @param url + * @param iResName + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public static JSONArray getResponseRes(RestfulParametes restParametes, String url, String iResName) + throws ServiceException { + String result = getResponseContent(url, restParametes, RestfulUtil.TYPE_GET); + if(null == result || result.isEmpty()) { + LOGGER.error("result from url:" + url + " result:" + result); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); + } + + JSONArray rsArray = null; + try { + JSONObject rsJson = JSONObject.fromObject(result); + rsArray = rsJson.getJSONArray(iResName); + String vimId = rsJson.getString(ParamConstant.PARAM_VIMID); + String vimName = rsJson.getString(ParamConstant.PARAM_VIMNAME); + for(int i = 0; i < rsArray.size(); i++) { + JSONObject jsonObj = rsArray.getJSONObject(i); + jsonObj.put(ParamConstant.PARAM_VIMID, vimId); + jsonObj.put(ParamConstant.PARAM_VIMNAME, vimName); + } + } catch(JSONException e) { + LOGGER.error("getResources error:" + e); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result")); + } + return rsArray; + } + + /** + * <br> + * + * @param paramsMap + * @param params + * @return + * @since NFVO 0.5 + */ + public static RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + String url = paramsMap.get("url"); + String methodType = paramsMap.get("methodType"); + + RestfulResponse rsp = null; + Restful rest = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP); + try { + + RestfulParametes restfulParametes = new RestfulParametes(); + Map<String, String> headerMap = new HashMap<>(3); + headerMap.put(CONTENT_TYPE, APPLICATION); + restfulParametes.setHeaderMap(headerMap); + restfulParametes.setRawData(params); + + if(rest != null) { + if(TYPE_GET.equalsIgnoreCase(methodType)) { + rsp = rest.get(url, restfulParametes); + } else if(TYPE_POST.equalsIgnoreCase(methodType)) { + rsp = rest.post(url, restfulParametes); + } else if(TYPE_PUT.equalsIgnoreCase(methodType)) { + rsp = rest.put(url, restfulParametes); + } else if(TYPE_DEL.equalsIgnoreCase(methodType)) { + rsp = rest.delete(url, restfulParametes); + } + } + } catch(ServiceException e) { + LOGGER.error("function=getRemoteResponse, get restful response catch exception {}", e); + } + return rsp; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java new file mode 100644 index 0000000..fd8f09f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java @@ -0,0 +1,215 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util; + +import java.math.BigDecimal; +import java.text.DecimalFormat; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * String Utility Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public final class StringUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(StringUtil.class); + + private StringUtil() { + } + + /** + * + * Check whether thestring is valid.<br> + * + * @param str + * @return + * @since NFVO 0.5 + */ + public static boolean isValidString(String str) { + if(null == str || str.isEmpty()) { + return false; + } + return true; + } + + /** + * + * Check whether the value is larger than zero.<br> + * + * @param strs + * @return + * @since NFVO 0.5 + */ + public static boolean isAnyLargeThanZero(String... strs) { + for(String str : strs) { + if(!StringUtils.isEmpty(str) && Float.parseFloat(str) > 0) { + LOGGER.info("isAnyLargeThanZero : {} is > 0", str); + return true; + } + } + return false; + } + + /** + * + * Check whether the value is Integer.<br> + * + * @param strs + * @return + * @since NFVO 0.5 + */ + public static boolean isInteger(String... strs) { + try { + for(String str : strs) { + if(!StringUtils.isEmpty(str)) { + int value = Integer.parseInt(str); + if(value < 0) { + return false; + } + } + } + } catch(NumberFormatException e) { + return false; + } + return true; + } + + /** + * + * Check whether the input is Numeric.<br> + * + * @param strs + * @return + * @since NFVO 0.5 + */ + public static boolean isNumeric(String... strs) { + try { + for(String str : strs) { + if(!StringUtils.isEmpty(str)) { + float value = Float.parseFloat(str); + if(value < 0) { + return false; + } + } + } + } catch(NumberFormatException e) { + return false; + } + return true; + } + + /** + * + * Compare zero by float.<br> + * + * @param tatol + * @param used + * @param drTotal + * @return + * @since NFVO 0.5 + */ + public static boolean compareZeroByFloat(String tatol, String used, String drTotal) { + Float ftotal = (float)0; + Float fused = (float)0; + Float fdrTotal = (float)0; + if(!StringUtils.isEmpty(tatol)) { + ftotal = new Float(tatol); + } + if(!StringUtils.isEmpty(used)) { + fused = new Float(used); + } + if(!StringUtils.isEmpty(drTotal)) { + fdrTotal = new Float(drTotal); + } + if(ftotal < fused + fdrTotal) { + return false; + } + + return true; + } + + /** + * + * Compare zero by integer.<br> + * + * @param tatol + * @param used + * @param drTotal + * @return + * @since NFVO 0.5 + */ + public static boolean compareZeroByInteger(String tatol, String used, String drTotal) { + Integer ftotal = (int)0; + Integer fused = (int)0; + Integer fdrTotal = (int)0; + if(!StringUtils.isEmpty(tatol)) { + ftotal = Integer.valueOf(tatol); + } + if(!StringUtils.isEmpty(used)) { + fused = Integer.valueOf(used); + } + if(!StringUtils.isEmpty(drTotal)) { + fdrTotal = Integer.valueOf(drTotal); + } + if(ftotal < fused + fdrTotal) { + return false; + } + return true; + } + + /** + * + * Number format.<br> + * + * @param data + * @return + * @since NFVO 0.5 + */ + public static String numFormat(String data) { + if(null != data && !("".equals(data))) { + BigDecimal var = new BigDecimal(data); + DecimalFormat formatWithoutFraction = new DecimalFormat("############"); + DecimalFormat formatWithFraction = new DecimalFormat("############.############"); + if(new BigDecimal(var.intValue()).compareTo(var) == 0) { + return formatWithoutFraction.format(var); + } + return formatWithFraction.format(var); + } + return null; + } + + /** + * + * <br> + * + * @param inputStr + * @return + * @since NFVO 0.5 + */ + public static boolean checkXss(String inputStr) { + return inputStr.matches("[A-Za-z0-9_.']+"); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java new file mode 100644 index 0000000..5eae4e3 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util.request; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONException; +import net.sf.json.JSONObject; + +/** + * <br/> + * <p> + * Utility used for request + * </p> + * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public final class RequestUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(RequestUtil.class); + + /** + * Constructor<br/> + * <p> + * </p> + * + * @since NFVO 0.5 + */ + private RequestUtil() { + } + + /** + * Get context string from http context + * + * @param context + * http context + * @return the needed string in http context + */ + public static String getStringRequestBody(HttpServletRequest context) { + try { + InputStream input = context.getInputStream(); + return IOUtils.toString(input); + } catch(IOException e) { + LOGGER.error("function=getStringRequestBody, get httpservletrequest body exception: {}", e); + return null; + } + } + + /** + * Get json parameter from http context + * + * @param context + * http context + * @return JSONObject + */ + public static JSONObject getJsonRequestBody(HttpServletRequest context) { + try { + String bodyStr = getStringRequestBody(context); + return JSONObject.fromObject(bodyStr); + } catch(JSONException e) { + LOGGER.error("function=getJsonRequestBody, maybe request param is not a jsonobject exception: {}", e); + return null; + } + } + + /** + * Get the body of all request in json format<br/> + * + * @param context + * The http context + * @return JSONObject The body of all request in json format + * @since NFVO 0.5 + */ + public static JSONObject getAllJsonRequestBody(HttpServletRequest context) { + JSONObject requestBody = getJsonRequestBody(context); + if(null == requestBody) { + LOGGER.error("get httpservletrequest body exception"); + requestBody = new JSONObject(); + } + LOGGER.warn("function=getAllJsonRequestBody; msg=get request data is:[{}]", requestBody.toString()); + requestBody.put("header", getContextHeader(context)); + return requestBody; + } + + /** + * Get the context header<br/> + * + * @param context + * The http context + * @return Map context header + * @since NFVO 0.5 + */ + @SuppressWarnings("unchecked") + private static Map<String, String> getContextHeader(HttpServletRequest context) { + Map<String, String> header = new HashMap<String, String>(); + Enumeration<String> headerNames = context.getHeaderNames(); + while(headerNames.hasMoreElements()) { + String headerName = headerNames.nextElement(); + String value = context.getHeader(headerName); + header.put(headerName, value); + } + return header; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java new file mode 100644 index 0000000..d6b1415 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java @@ -0,0 +1,133 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util.response; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import javax.servlet.http.HttpServletRequest; + +import net.sf.json.JSONObject; + +/** + * + * Response utility class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public final class ResponseUtil { + + private ResponseUtil() { + } + + /** + * Roa request common return function, default return code 200 <br/> + * + * @param retCode + * The request return code + * @param msg + * The request message + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static JSONObject genHttpResponse(int retCode, String msg) { + return genHttpResponse(null, createCodeMap(-1, retCode), msg, null); + } + + /** + * Roa request common return function, default return code 200<br/> + * + * @param retCode + * The request return code + * @param msg + * The request message + * @param map + * Other request info of this request + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static JSONObject genHttpResponse(int retCode, String msg, Map<String, Object> map) { + return genHttpResponse(null, createCodeMap(-1, retCode), msg, map); + } + + /** + * Roa request common return method <br/> + * + * @param context + * The http request context + * @param httpStatusCode + * The http response code + * @param retCode + * The http request return code + * @param msg + * The message of request + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static JSONObject genHttpResponse(HttpServletRequest context, int httpStatusCode, int retCode, String msg) { + return genHttpResponse(context, createCodeMap(httpStatusCode, retCode), msg, null); + } + + /** + * + * Roa request common return method.<br> + * + * @param context, The http request context + * @param codeMap + * @param msg, The message of request + * @param map, Other message of request + * @return + * @since NFVO 0.5 + */ + public static JSONObject genHttpResponse(HttpServletRequest context, Map<String, Integer> codeMap, String msg, + Map<String, Object> map) { + JSONObject object = new JSONObject(); + + object.put("msg", msg); + if(null != map) { + Iterator<Entry<String, Object>> ite = map.entrySet().iterator(); + if(ite.hasNext()) { + Map.Entry<String, Object> entry = ite.next(); + object.put(entry.getKey(), entry.getValue().toString()); + } + } + return object; + } + + /** + * Create code map to maintenance the relationship between return code and + * http status code <br/> + * + * @param httpStatusCode + * The http response code + * @param retCode + * The http request return code + * @return Map + * @since NFVO 0.5 + */ + private static Map<String, Integer> createCodeMap(int httpStatusCode, int retCode) { + Map<String, Integer> codeMap = new HashMap<>(5); + codeMap.put("httpStatusCode", httpStatusCode); + codeMap.put("retCode", retCode); + return codeMap; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java new file mode 100644 index 0000000..dbb034d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java @@ -0,0 +1,113 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util.response; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.ResponseConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br/> + * <p> + * Utility for generate Roa get/add/update/delete method status + * </p> + * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public final class RoaResponseUtil { + + private static final Logger LOGGER = LoggerFactory.getLogger(RoaResponseUtil.class); + + private RoaResponseUtil() { + + } + + /** + * Generate get method response<br/> + * + * @param list + * The basic response for get method + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static <T> JSONObject get(List<T> list) { + Map<String, Object> map = new HashMap<String, Object>(10); + map.put(ParamConstant.PARAM_DATA, list); + LOGGER.info("function=get; msg=get map:{}", map.toString()); + return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.QUERY_SUCESS_MSG, map); + } + + /** + * Generate different response by different parameter for add method <br/> + * + * @param result + * The result + * @return JSONObject + * @since NFVO 0.5 + */ + public static JSONObject add(int result) { + LOGGER.info("function=add; msg=add result{}", result); + if(result <= 0) { + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.ADD_FAIL_MSG); + } else { + return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.ADD_SUCESS_MSG); + } + } + + /** + * Generate different response by different parameter for update method <br/> + * + * @param result + * The result + * @return JSONObject The response for http request + * @since NFVO 0.5 + */ + public static JSONObject update(int result) { + LOGGER.info("function=update; msg=update result{}", result); + if(result <= 0) { + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.MOD_FAIL_MSG); + } else { + return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.MOD_SUCESS_MSG); + } + } + + /** + * Generate different response by different parameter for delete method <br/> + * + * @param result + * The result + * @return delete JSONObject of the response for http request + * @since NFVO 0.5 + */ + public static JSONObject delete(int result) { + LOGGER.info("function=delete; msg=delete result{}", result); + if(result <= 0) { + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.DEL_FAIL_MSG); + } else { + return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.DEL_SUCESS_MSG); + } + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java new file mode 100644 index 0000000..ad66303 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java @@ -0,0 +1,60 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.activator; + +import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapterMgrService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +public class ROAResmgrServicePostProcessor implements DestructionAwareBeanPostProcessor { + + private static final Logger LOG = LoggerFactory.getLogger(ROAResmgrServicePostProcessor.class); + + @Override + public Object postProcessAfterInitialization(Object bean, String name) throws BeansException { + if(bean instanceof IResmgrAdapterMgrService) { + LOG.warn("Register to Microservice BUS!"); + IResmgrAdapterMgrService resmgrAdapterSvc = (IResmgrAdapterMgrService)bean; + resmgrAdapterSvc.register(); + } + + return bean; + } + + @Override + public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException { + // TODO Auto-generated method stub + return bean; + } + + @Override + public void postProcessBeforeDestruction(Object bean, String name) throws BeansException { + // TODO Auto-generated method stub + + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java new file mode 100644 index 0000000..9e523e3 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java @@ -0,0 +1,111 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.adapter.impl; + +import java.util.Map; + +import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.openo.nfvo.resmanagement.common.constant.Constant; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.util.RestfulUtil; +import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapter2MSBManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +public class ResmgrAdapter2MSBManager implements IResmgrAdapter2MSBManager { + + private static final Logger LOG = LoggerFactory.getLogger(ResmgrAdapter2MSBManager.class); + + @Override + public JSONObject registerResmgr(Map<String, String> paramsMap, JSONObject driverInfo) { + JSONObject resultObj = new JSONObject(); + + RestfulResponse rsp = RestfulUtil.getRemoteResponse(paramsMap, driverInfo.toString()); + if(null == rsp) { + LOG.error("function=registerResmgr, RestfulResponse is null"); + resultObj.put("reason", "RestfulResponse is null."); + resultObj.put("retCode", Constant.ERROR_CODE); + return resultObj; + } + LOG.warn("function=registerResmgr, status={}, content={}.", rsp.getStatus(), rsp.getResponseContent()); + String resultCreate = rsp.getResponseContent(); + + if(rsp.getStatus() == HttpConstant.HTTP_CREATED) { + LOG.warn("function=registerResmgr, msg= status={}, result={}.", rsp.getStatus(), resultCreate); + resultObj = JSONObject.fromObject(resultCreate); + resultObj.put("retCode", HttpConstant.HTTP_CREATED); + return resultObj; + } else if(rsp.getStatus() == HttpConstant.HTTP_INVALID_PARAMETERS) { + LOG.error("function=registerResmgr, msg=MSB return fail,invalid parameters,status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,invalid parameters."); + } else if(rsp.getStatus() == HttpConstant.HTTP_INNERERROR_CODE) { + LOG.error("function=registerResmgr, msg=MSB return fail,internal system error,status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,internal system error."); + } + resultObj.put("retCode", Constant.ERROR_CODE); + return resultObj; + } + + @Override + public JSONObject unregisterResmgr(Map<String, String> paramsMap) { + JSONObject resultObj = new JSONObject(); + + RestfulResponse rsp = RestfulUtil.getRemoteResponse(paramsMap, ""); + if(null == rsp) { + LOG.error("function=unregisterResmgr, RestfulResponse is null"); + resultObj.put("reason", "RestfulResponse is null."); + resultObj.put("retCode", Constant.ERROR_CODE); + return resultObj; + } + String resultCreate = rsp.getResponseContent(); + + if(rsp.getStatus() == HttpConstant.HTTP_NOCONTENT) { + LOG.warn("function=unregisterResmgr, msg= status={}, result={}.", rsp.getStatus(), resultCreate); + resultObj = JSONObject.fromObject(resultCreate); + resultObj.put("retCode", HttpConstant.HTTP_NOCONTENT); + return resultObj; + } else if(rsp.getStatus() == HttpConstant.HTTP_NOTFOUND_CODE) { + LOG.error( + "function=unregisterResmgr, msg=MSB return fail,can't find the service instance.status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,can't find the service instance."); + } else if(rsp.getStatus() == HttpConstant.HTTP_INVALID_PARAMETERS) { + LOG.error("function=unregisterResmgr, msg=MSB return fail,invalid parameters,status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,invalid parameters."); + } else if(rsp.getStatus() == HttpConstant.HTTP_INNERERROR_CODE) { + LOG.error("function=unregisterResmgr, msg=MSB return fail,internal system error,status={}, result={}.", + rsp.getStatus(), resultCreate); + resultObj.put("reason", "MSB return fail,internal system error."); + } + resultObj.put("retCode", Constant.ERROR_CODE); + return resultObj; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java new file mode 100644 index 0000000..ea9a53d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java @@ -0,0 +1,185 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.adapter.impl; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.Executors; + +import org.openo.baseservice.util.impl.SystemEnvVariablesFactory; +import org.openo.nfvo.resmanagement.common.constant.Constant; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapter2MSBManager; +import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapterMgrService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +@Service +public class ResmgrAdapterMgrService implements IResmgrAdapterMgrService { + + private static final Logger LOG = LoggerFactory.getLogger(ResmgrAdapterMgrService.class); + + public static final String RESMGRADAPTERINFO = "resmgradapterinfo.json"; + + @Override + public void register() { + // set BUS URL and mothedtype + Map<String, String> paramsMap = new HashMap<>(); + paramsMap.put("url", UrlConstant.REST_MSB_REGISTER); + paramsMap.put("methodType", ParamConstant.PARAM_POST); + + // get resmgr info and raise registration + try { + String resmgrInfo = readVimAdapterInfoFromJson(); + if(!"".equals(resmgrInfo)) { + JSONObject adapterObject = JSONObject.fromObject(resmgrInfo); + RegisterResmgrThread resmgrThread = new RegisterResmgrThread(paramsMap, adapterObject); + Executors.newSingleThreadExecutor().submit(resmgrThread); + } else { + LOG.error("Resmgr info is null,please check!"); + } + + } catch(IOException e) { + LOG.error("Failed to read Resmgr info! " + e.getMessage(), e); + } + + } + + /** + * Retrieve VIM driver information. + * + * @return + * @throws IOException + */ + public static String readVimAdapterInfoFromJson() throws IOException { + InputStream ins = null; + BufferedInputStream bins = null; + String fileContent = ""; + + String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty("file.separator") + + "etc" + System.getProperty("file.separator") + "adapterInfo" + System.getProperty("file.separator") + + RESMGRADAPTERINFO; + + try { + ins = new FileInputStream(fileName); + bins = new BufferedInputStream(ins); + + byte[] contentByte = new byte[ins.available()]; + int num = bins.read(contentByte); + + if(num > 0) { + fileContent = new String(contentByte); + } + } catch(FileNotFoundException e) { + LOG.error(fileName + "is not found!", e); + } finally { + if(ins != null) { + ins.close(); + } + if(bins != null) { + bins.close(); + } + } + + return fileContent; + } + + private static class RegisterResmgrThread implements Runnable { + + // Thread lock Object + private final Object lockObject = new Object(); + + private IResmgrAdapter2MSBManager adapter2MSBMgr = new ResmgrAdapter2MSBManager(); + + // url and mothedtype + private Map<String, String> paramsMap; + + // driver body + private JSONObject adapterInfo; + + public RegisterResmgrThread(Map<String, String> paramsMap, JSONObject adapterInfo) { + this.paramsMap = paramsMap; + this.adapterInfo = adapterInfo; + } + + @Override + public void run() { + LOG.info("start register resmgr", RegisterResmgrThread.class); + + if(paramsMap == null || adapterInfo == null) { + LOG.error("parameter is null,please check!", RegisterResmgrThread.class); + return; + } + + // catch Runtime Exception + try { + sendRequest(paramsMap, adapterInfo); + } catch(RuntimeException e) { + LOG.error(e.getMessage(), e); + } + + } + + private void sendRequest(Map<String, String> paramsMap, JSONObject driverInfo) { + JSONObject resultObj = adapter2MSBMgr.registerResmgr(paramsMap, driverInfo); + + if(Integer.valueOf(resultObj.get("retCode").toString()) == HttpConstant.HTTP_CREATED) { + LOG.info("Resmgr has now Successfully Registered to the Microservice BUS!"); + } else { + LOG.error("Resmgr failed to Register to the Microservice BUS! Reason:" + + resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString()); + + // if registration fails,wait one minute and try again + try { + synchronized(lockObject) { + lockObject.wait(Constant.REPEAT_REG_TIME); + } + } catch(InterruptedException e) { + LOG.error(e.getMessage(), e); + } + + sendRequest(this.paramsMap, this.adapterInfo); + } + + } + + } + + @Override + public void unregister() { + // unregister + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java new file mode 100644 index 0000000..df00261 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java @@ -0,0 +1,52 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.adapter.inf; + +import java.util.Map; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +public interface IResmgrAdapter2MSBManager { + + /** + * <br> + * + * @param paramsMap + * @param driverInfo + * @return + * @since NFVO 0.5 + */ + JSONObject registerResmgr(Map<String, String> paramsMap, JSONObject driverInfo); + + /** + * <br> + * + * @param paramsMap + * @return + * @since NFVO 0.5 + */ + JSONObject unregisterResmgr(Map<String, String> paramsMap); + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java new file mode 100644 index 0000000..05d4739 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.adapter.inf; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 22, 2016 + */ +public interface IResmgrAdapterMgrService { + + /** + * Resmgr register interface. + */ + void register(); + + /** + * Resmgr unregister interface. + */ + void unregister(); + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java new file mode 100644 index 0000000..131d7c7 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java @@ -0,0 +1,80 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host; +import org.openo.nfvo.resmanagement.service.business.inf.HostBusiness; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; + +import net.sf.json.JSONObject; + +/** + * + * Host implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class HostImpl implements Host { + + private HostBusiness hostBusiness; + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + return hostBusiness.addHost(HostEntity.toEntity(jsonObject)); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return hostBusiness.updateHostSelective(HostEntity.toEntity(jsonObject)); + } + + @Override + public int update(HostEntity portEntity) throws ServiceException { + return hostBusiness.updateHostSelective(portEntity); + } + + @Override + public int delete(String id) throws ServiceException { + return hostBusiness.deleteHost(id); + } + + @Override + public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { + return hostBusiness.updateHostByVimId(HostEntity.toEntity(jsonObject)); + } + + @Override + public int deleteResByVimId(String vimId) throws ServiceException { + return hostBusiness.deleteHostByVimId(vimId); + } + + @Override + public List<HostEntity> getList(Map<String, Object> condition) throws ServiceException { + return hostBusiness.getHosts(condition); + } + + public void setHostBusiness(HostBusiness hostBusiness) { + this.hostBusiness = hostBusiness; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java new file mode 100644 index 0000000..346ac84 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java @@ -0,0 +1,186 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.VimUtil; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Location; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; +import org.openo.nfvo.resmanagement.service.business.inf.LocationBusiness; +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * Location Implementation Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LocationImpl implements Location { + + private LocationBusiness locationBusiness; + + private Sites sites; + + private static final Logger LOGGER = LoggerFactory.getLogger(LocationImpl.class); + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + return locationBusiness.addLocation(LocationEntity.toEntity(jsonObject)); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return locationBusiness.updateLocationSelective(LocationEntity.toEntity(jsonObject)); + } + + @Override + public int delete(String location) throws ServiceException { + return locationBusiness.deleteLocation(location); + } + + @Override + public Map<String, Object> get(String id) throws ServiceException { + Map<String, Object> map = new HashMap<>(); + map.put(ParamConstant.PARAM_ID, id); + List<LocationEntity> sodores = locationBusiness.getLocations(map); + map.clear(); + map.put(ParamConstant.PARAM_DATA, sodores); + return map; + } + + @Override + public List<LocationEntity> get(Map<String, Object> condition) throws ServiceException { + return locationBusiness.getLocations(condition); + } + + @Override + public List<String> getCountry() throws ServiceException { + return locationBusiness.getCountry(); + } + + @Override + public List<String> getCloudservice() throws ServiceException { + LOGGER.info("get cloud service from external system"); + JSONArray vims = VimUtil.getVims(); + LOGGER.info("vims: " + vims.toString()); + List<String> cloudService = new ArrayList<>(); + for(int i = 0; i < vims.size(); i++) { + String vimName = vims.getJSONObject(i).getString("name"); + cloudService.add(vimName); + } + return cloudService; + } + + @Override + public List<String> getLocationByCountry(Map<String, Object> condition) throws ServiceException { + return locationBusiness.getLocationByCountry(condition); + } + + @Override + public LocationEntity getLocation(Map<String, Object> condition) throws ServiceException { + List<LocationEntity> locationlist = locationBusiness.getLocations(condition); + if(null == locationlist || locationlist.isEmpty()) { + return null; + } + return locationlist.get(0); + } + + @Override + public List<JSONObject> getLocationInfo(List<LocationEntity> locationInfo) throws ServiceException { + ArrayList<JSONObject> newSites = new ArrayList<>(); + Map<String, Object> condition = new HashMap<>(); + for(int i = 0; i < locationInfo.size(); i++) { + LocationEntity locationEntity = locationInfo.get(i); + String latitude = locationEntity.getLatitude(); + String longitude = locationEntity.getLongitude(); + String locatSite = locationEntity.getLocation(); + condition.put(ParamConstant.PARAM_LOCATION, locatSite); + LOGGER.info("LocationRoa::getLocation condition:{}", condition); + List<SitesEntity> sitesEntity = sites.getList(condition); + LOGGER.info("LocationRoa::getLocation sitesEntity:{}", sitesEntity); + if(null != sitesEntity && !sitesEntity.isEmpty()) { + for(SitesEntity entity : sitesEntity) { + JSONObject site = JSONObject.fromObject(entity.toString()); + JSONObject resTotalJo = site.getJSONObject("total"); + JSONObject resUsedlJo = site.getJSONObject("used"); + JSONObject ressiteJo = computingSite(resTotalJo, resUsedlJo); + site.element("latitude", latitude); + site.element("longitude", longitude); + site.element("siteDetail", ressiteJo); + LOGGER.info("LocationRoa::getLocation latitude:{}, longitude:{}", latitude, longitude); + LOGGER.info("LocationRoa::getLocation site:{}", site); + newSites.add(site); + } + } + } + return newSites; + } + + /** + * Computing site.<br> + * + * @param total + * @param used + * @return + * @since NFVO 0.5 + */ + public JSONObject computingSite(JSONObject total, JSONObject used) { + String vcpus = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_VCPUS); + String memorys = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_MEMORY); + String disks = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_DISK); + String vcpusused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_VCPUS); + String memoryused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_MEMORY); + String diskused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_DISK); + float cpu = Float.parseFloat(vcpusused) / Float.parseFloat(vcpus); + float memory = Float.parseFloat(memoryused) / Integer.parseInt(memorys); + float disk = Float.parseFloat(diskused) / Float.parseFloat(disks); + JSONObject resTotalJo = new JSONObject(); + resTotalJo.put(ParamConstant.PARAM_VCPUS, String.valueOf(Math.round(cpu * 100)) + "%"); + resTotalJo.put(ParamConstant.PARAM_MEMORY, String.valueOf(Math.round(memory * 100)) + "%"); + resTotalJo.put(ParamConstant.PARAM_DISK, String.valueOf(Math.round(disk * 100)) + "%"); + + return resTotalJo; + } + + public LocationBusiness getLocationBusiness() { + return locationBusiness; + } + + public void setLocationBusiness(LocationBusiness locationBusiness) { + this.locationBusiness = locationBusiness; + } + + public void setSites(Sites sites) { + this.sites = sites; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java new file mode 100644 index 0000000..b9ec757 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java @@ -0,0 +1,101 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network; +import org.openo.nfvo.resmanagement.service.business.inf.NetworkBusiness; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * Network implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class NetworkImpl implements Network { + + private static final Logger LOGGER = LoggerFactory.getLogger(NetworkImpl.class); + + private NetworkBusiness networkBusiness; + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + LOGGER.warn("function=addPort; jsonObject={}", jsonObject); + JSONObject networkObj = dataParse(jsonObject); + return networkBusiness.addNetwork(NetworkEntity.toEntity(networkObj)); + } + + private JSONObject dataParse(JSONObject jsonObject) { + JSONObject portObj = new JSONObject(); + portObj.put("id", JsonUtil.getJsonFieldStr(jsonObject, "id")); + portObj.put("name", JsonUtil.getJsonFieldStr(jsonObject, "name")); + portObj.put("status", JsonUtil.getJsonFieldStr(jsonObject, "status")); + portObj.put("tenantId", JsonUtil.getJsonFieldStr(jsonObject, "tenant_id")); + portObj.put("vimId", JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + portObj.put("vimName", JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + portObj.put("physicalNetwork", JsonUtil.getJsonFieldStr(jsonObject, "physicalNetwork")); + portObj.put("networkType", JsonUtil.getJsonFieldStr(jsonObject, "networkType")); + portObj.put("segmentationId", JsonUtil.getJsonFieldStr(jsonObject, "segmentationId")); + return portObj; + } + + @Override + public int add(NetworkEntity entity) throws ServiceException { + return networkBusiness.addNetwork(entity); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return networkBusiness.updateNetworkSelective(NetworkEntity.toEntity(jsonObject)); + } + + @Override + public int delete(String id) throws ServiceException { + return networkBusiness.deleteNetwork(id); + } + + @Override + public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { + return networkBusiness.updateNetworkByVimId(NetworkEntity.toEntity(jsonObject)); + } + + @Override + public List<NetworkEntity> getList(Map<String, Object> condition) throws ServiceException { + return networkBusiness.getNetworks(condition); + } + + @Override + public int deleteResByVimId(String vimId) throws ServiceException { + return networkBusiness.deleteNetworkByVimId(vimId); + } + + public void setNetworkBusiness(NetworkBusiness networkBusiness) { + this.networkBusiness = networkBusiness; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java new file mode 100644 index 0000000..3dee172 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java @@ -0,0 +1,103 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port; +import org.openo.nfvo.resmanagement.service.business.inf.PortBusiness; +import org.openo.nfvo.resmanagement.service.entity.PortEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * Port implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class PortImpl implements Port { + + private static final Logger LOGGER = LoggerFactory.getLogger(PortImpl.class); + + private PortBusiness portBusiness; + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + LOGGER.warn("function=addPort; jsonObject={}", jsonObject); + JSONObject portObj = dataParse(jsonObject); + return portBusiness.addPort(PortEntity.toEntity(portObj)); + } + + private JSONObject dataParse(JSONObject jsonObject) { + JSONObject portObj = new JSONObject(); + portObj.put("id", JsonUtil.getJsonFieldStr(jsonObject, "id")); + portObj.put("name", JsonUtil.getJsonFieldStr(jsonObject, "name")); + portObj.put("networkId", JsonUtil.getJsonFieldStr(jsonObject, "networkId")); + portObj.put("status", JsonUtil.getJsonFieldStr(jsonObject, "status")); + portObj.put("tenantId", JsonUtil.getJsonFieldStr(jsonObject, "tenant_id")); + portObj.put("vimId", JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + portObj.put("vimName", JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + return portObj; + } + + @Override + public int add(PortEntity portEntity) throws ServiceException { + return portBusiness.addPort(portEntity); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return portBusiness.updatePortSelective(PortEntity.toEntity(jsonObject)); + } + + @Override + public int update(PortEntity portEntity) throws ServiceException { + return portBusiness.updatePortSelective(portEntity); + } + + @Override + public int delete(String id) throws ServiceException { + return portBusiness.deletePort(id); + } + + @Override + public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { + return portBusiness.updatePortByVimId(PortEntity.toEntity(jsonObject)); + } + + @Override + public int deleteResByVimId(String vimId) throws ServiceException { + return portBusiness.deletePortByVimId(vimId); + } + + @Override + public List<PortEntity> getList(Map<String, Object> condition) throws ServiceException { + return portBusiness.getPorts(condition); + } + + public void setPortBusiness(PortBusiness portBusiness) { + this.portBusiness = portBusiness; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java new file mode 100644 index 0000000..6b9345e --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java @@ -0,0 +1,231 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.VimUtil; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; +import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness; +import org.openo.nfvo.resmanagement.service.business.inf.SitesBusiness; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; +import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * DC info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public class SitesImpl implements Sites { + + private static final Logger LOGGER = LoggerFactory.getLogger(SitesImpl.class); + + private SitesBusiness sitesBusiness; + + private LimitsBusiness limitsBusiness; + + private ResOperateService resOperateService; + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + LOGGER.info("Add datacenter jsonObject: {}", jsonObject); + SitesEntity sitesEntity = SitesEntity.toEntity(jsonObject); + sitesEntity.setStatus(ParamConstant.PARAM_ACTIVE); + String vimName = jsonObject.getString(ParamConstant.PARAM_VIMNAME); + String vimId = VimUtil.getVimIdByName(vimName); + sitesEntity.setVimId(vimId); + JSONObject resource = limitsBusiness.getLimits(vimId); + sitesEntity.setVimName(resource.getString(ParamConstant.PARAM_VIMNAME)); + sitesEntity.setTotalCPU(resource.getString(ParamConstant.TOTAL_CPU)); + sitesEntity.setUsedCPU(resource.getString(ParamConstant.USED_CPU)); + sitesEntity.setTotalMemory(resource.getString(ParamConstant.TOTAL_MEMORY)); + sitesEntity.setUsedMemory(resource.getString(ParamConstant.USED_MEMORY)); + sitesEntity.setTotalDisk(resource.getString(ParamConstant.TOTAL_DISK)); + sitesEntity.setUsedDisk(resource.getString(ParamConstant.USED_DISK)); + if(StringUtils.isEmpty(sitesEntity.getId())) { + sitesEntity.setId(UUID.randomUUID().toString()); + jsonObject.put(ParamConstant.PARAM_ID, sitesEntity.getId()); + } + LOGGER.info("Add datacenter sitesEntity: {}", sitesEntity.toString()); + return sitesBusiness.addSite(sitesEntity); + } + + /** + * <br> + * + * @param json + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public void sendToMonitor(JSONObject jsonObject) throws ServiceException { + LOGGER.info("SitesImpl sendToMonitor jsonObject: {}", jsonObject); + String vimName = jsonObject.getString(ParamConstant.PARAM_VIMNAME); + String vimId = VimUtil.getVimIdByName(vimName); + JSONObject vimInfo = VimUtil.getVimById(vimId); + LOGGER.info("SitesImpl sendToMonitor vimInfo: {}", vimInfo); + String tenant = vimInfo.getString("tenant"); + String tenantId = VimUtil.getTenantIdByName(tenant, vimId); + JSONObject json = new JSONObject(); + json.put("header", null); + LOGGER.info("tenantId:{}, vimId:{}", tenantId, vimId); + resOperateService.addIRes(tenantId, vimId, json); + resOperateService.sendMsgMonitor("create", vimId); + } + + @Override + public int update(SitesEntity sitesEntity) throws ServiceException { + return sitesBusiness.updateSiteSelective(sitesEntity); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + LOGGER.info("grantResource jsonObject: {}", jsonObject); + JSONObject sitesObj = dataParse(jsonObject); + return sitesBusiness.updateSiteSelective(SitesEntity.toEntity(sitesObj)); + } + + private JSONObject dataParse(JSONObject jsonObject) throws ServiceException { + String vimId = jsonObject.getString(ParamConstant.PARAM_VIMID); + Map<String, Object> condition = new HashMap<>(); + condition.put("vimId", vimId); + SitesEntity sitesEntity = get(condition); + if(null == sitesEntity) { + LOGGER.error("Get sites null, vimId={}", vimId); + return null; + } + return computeSiteUsed(jsonObject, sitesEntity); + } + + private JSONObject computeSiteUsed(JSONObject jsonObject, SitesEntity sitesEntity) throws ServiceException { + String action = JsonUtil.getJsonFieldStr(jsonObject, "action"); + String usedCpu = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_CPU); + String usedMemory = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_MEMORY); + String usedDisk = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_DISK); + String oldCpu = sitesEntity.getUsedCPU(); + String oldMemory = sitesEntity.getUsedMemory(); + String oldDisk = sitesEntity.getUsedDisk(); + String newCpu = accumOrFreeRes(usedCpu, oldCpu, action, sitesEntity.getTotalCPU(), "cpu"); + String newMemory = accumOrFreeRes(usedMemory, oldMemory, action, sitesEntity.getTotalMemory(), "memory"); + String newDisk = accumOrFreeRes(usedDisk, oldDisk, action, sitesEntity.getTotalDisk(), "disk"); + + JSONObject resUsed = new JSONObject(); + resUsed.put(ParamConstant.USED_CPU, newCpu); + resUsed.put(ParamConstant.USED_MEMORY, newMemory); + resUsed.put(ParamConstant.USED_DISK, newDisk); + resUsed.put("id", sitesEntity.getId()); + resUsed.put("name", sitesEntity.getName()); + resUsed.put("status", sitesEntity.getStatus()); + resUsed.put("location", sitesEntity.getLocation()); + resUsed.put("country", sitesEntity.getCountry()); + resUsed.put(ParamConstant.PARAM_VIMID, sitesEntity.getVimId()); + resUsed.put(ParamConstant.PARAM_VIMNAME, sitesEntity.getVimName()); + resUsed.put(ParamConstant.TOTAL_CPU, sitesEntity.getTotalCPU()); + resUsed.put(ParamConstant.TOTAL_MEMORY, sitesEntity.getTotalMemory()); + resUsed.put(ParamConstant.TOTAL_DISK, sitesEntity.getTotalDisk()); + return resUsed; + } + + private String accumOrFreeRes(String resUsed, String resOld, String action, String total, String type) + throws ServiceException { + BigDecimal iResUsed = new BigDecimal(resUsed); + BigDecimal iResOld = new BigDecimal(resOld); + BigDecimal itotal = new BigDecimal(total); + if("online".equals(action)) { + if(iResOld.add(iResUsed).compareTo(itotal) > 0) { + throw new ServiceException("Grant resource fail! The " + type + " resource not enough."); + } + return String.valueOf(iResOld.add(iResUsed)); + } else { + if(iResOld.subtract(iResUsed).compareTo(BigDecimal.ZERO) < 0) { + throw new ServiceException("Grant resource fail! The " + type + " resource used below zero."); + } + return String.valueOf(iResOld.subtract(iResUsed)); + } + } + + @Override + public int updateResource(JSONObject jsonObject) throws ServiceException { + return sitesBusiness.updateSiteResource(SitesEntity.toEntity(jsonObject)); + } + + @Override + public int delete(String id) throws ServiceException { + Map<String, Object> map = new HashMap<String, Object>(10); + map.put(ParamConstant.PARAM_ID, id); + List<SitesEntity> datacenters = getList(map); + SitesEntity site = datacenters.get(0); + LOGGER.info("site: {}", site); + String vimId = site.getVimId(); + LOGGER.info("vimId: {}", vimId); + resOperateService.sendMsgMonitor("delete", vimId); + resOperateService.deleteIRes(vimId); + return sitesBusiness.deleteSite(id); + } + + @Override + public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException { + return sitesBusiness.updateSiteByVimId(SitesEntity.toEntity(jsonObject)); + } + + @Override + public List<SitesEntity> getList(Map<String, Object> condition) throws ServiceException { + return sitesBusiness.getSites(condition); + } + + @Override + public SitesEntity get(Map<String, Object> condition) throws ServiceException { + List<SitesEntity> siteList = sitesBusiness.getSites(condition); + if(null == siteList || siteList.isEmpty()) { + return null; + } + return siteList.get(0); + } + + @Override + public int deleteResByVimId(String vimId) throws ServiceException { + return 0; + } + + public void setSitesBusiness(SitesBusiness sitesBusiness) { + this.sitesBusiness = sitesBusiness; + } + + public void setLimitsBusiness(LimitsBusiness limitsBusiness) { + this.limitsBusiness = limitsBusiness; + } + + public void setResOperateService(ResOperateService resOperateService) { + this.resOperateService = resOperateService; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java new file mode 100644 index 0000000..d1405a2 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java @@ -0,0 +1,82 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Vim; +import org.openo.nfvo.resmanagement.service.business.inf.VimBusiness; +import org.openo.nfvo.resmanagement.service.entity.VimEntity; + +import net.sf.json.JSONObject; + +/** + * Vim info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public class VimImpl implements Vim { + + private VimBusiness vimBusiness; + + @Override + public int add(String id) throws ServiceException { + return vimBusiness.addVim(id); + } + + @Override + public int add(JSONObject jsonObject) throws ServiceException { + return add(jsonObject.getString("id")); + } + + @Override + public int update(JSONObject jsonObject) throws ServiceException { + return 0; + } + + @Override + public int delete(String id) throws ServiceException { + return vimBusiness.deleteVim(id); + } + + @Override + public VimEntity getVim(String id) throws ServiceException { + return vimBusiness.getVim(id); + } + + @Override + public List<VimEntity> getList() throws ServiceException { + return vimBusiness.getVims(); + } + + @Override + public List<JSONObject> getVimInfo(Map<String, Object> condition) throws ServiceException { + // get vim from vimadapter + return new ArrayList<JSONObject>(); + } + + public void setVimBusiness(VimBusiness vimBusiness) { + this.vimBusiness = vimBusiness; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java new file mode 100644 index 0000000..44adb19 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; + +import net.sf.json.JSONObject; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface Host extends InterfaceResManagement { + + /** + * <br/> + * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; + + /** + * <br/> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<HostEntity> getList(Map<String, Object> condition) throws ServiceException; + + /** + * <br/> + * + * @param resPoolEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int update(HostEntity resPoolEntity) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java new file mode 100644 index 0000000..a89e48e --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java @@ -0,0 +1,40 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface InterfaceResManagement extends ResManagement { + + /** + * <br/> + * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteResByVimId(String vimId) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java new file mode 100644 index 0000000..7ee574c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java @@ -0,0 +1,104 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; + +import net.sf.json.JSONObject; + +/** + * Location details class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface Location extends ResManagement { + + /** + * <br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + Map<String, Object> get(String id) throws ServiceException; + + /** + * Get list of locations.<br> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<LocationEntity> get(Map<String, Object> condition) throws ServiceException; + + /** + * Get location details.<br> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + LocationEntity getLocation(Map<String, Object> condition) throws ServiceException; + + /** + * Get location info.<br> + * + * @param locationInfo + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<JSONObject> getLocationInfo(List<LocationEntity> locationInfo) throws ServiceException; + + /** + * Get Country.<br> + * + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<String> getCountry() throws ServiceException; + + /** + * Get location by country.<br> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<String> getLocationByCountry(Map<String, Object> condition) throws ServiceException; + + /** + * Get cloud services.<br> + * + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<String> getCloudservice() throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java new file mode 100644 index 0000000..bd00e1a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; + +import net.sf.json.JSONObject; + +/** + * + * Network class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface Network extends InterfaceResManagement { + + /** + * + * Update status by VIM Id.<br> + * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; + + /** + * + * Get list of networks.<br> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<NetworkEntity> getList(Map<String, Object> condition) throws ServiceException; + + /** + * <br> + * + * @param entity + * @return + * @since NFVO 0.5 + */ + int add(NetworkEntity entity) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java new file mode 100644 index 0000000..3ef79b3 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java @@ -0,0 +1,76 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.PortEntity; + +import net.sf.json.JSONObject; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface Port extends InterfaceResManagement { + + /** + * <br/> + * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; + + /** + * <br/> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<PortEntity> getList(Map<String, Object> condition) throws ServiceException; + + /** + * <br/> + * + * @param resPoolEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int update(PortEntity resPoolEntity) throws ServiceException; + + /** + * <br> + * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int add(PortEntity portEntity) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java new file mode 100644 index 0000000..8acbf77 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface ResManagement { + + /** + * <br/> + * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int add(JSONObject jsonObject) throws ServiceException; + + /** + * <br/> + * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int update(JSONObject jsonObject) throws ServiceException; + + /* + * key : parameter key value : parameter value + */ + /** + * <br/> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int delete(String id) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java new file mode 100644 index 0000000..ab2e104 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java @@ -0,0 +1,95 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; + +import net.sf.json.JSONObject; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface Sites extends InterfaceResManagement { + + /** + * <br/> + * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateStatusByVimId(JSONObject jsonObject) throws ServiceException; + + /** + * <br/> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<SitesEntity> getList(Map<String, Object> condition) throws ServiceException; + + /** + * <br/> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + SitesEntity get(Map<String, Object> condition) throws ServiceException; + + /** + * <br/> + * + * @param jsonObject + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateResource(JSONObject jsonObject) throws ServiceException; + + /** + * <br/> + * + * @param sitesEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int update(SitesEntity sitesEntity) throws ServiceException; + + /** + * <br> + * + * @param json + * @throws ServiceException + * @since NFVO 0.5 + */ + void sendToMonitor(JSONObject json) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java new file mode 100644 index 0000000..f923e0f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java @@ -0,0 +1,76 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.VimEntity; + +import net.sf.json.JSONObject; + +/** + * Virtualised Infrastructure Manager.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public interface Vim extends ResManagement { + + /** + * <br/> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + VimEntity getVim(String id) throws ServiceException; + + /** + * <br/> + * + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<VimEntity> getList() throws ServiceException; + + /** + * + * Get VIM information.<br> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<JSONObject> getVimInfo(Map<String, Object> condition) throws ServiceException; + + /** + * <br/> + * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int add(String vimId) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java new file mode 100644 index 0000000..6da2657 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java @@ -0,0 +1,162 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.service.business.inf.HostBusiness; +import org.openo.nfvo.resmanagement.service.dao.inf.HostDao; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * Host business implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class HostBusinessImpl implements HostBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(HostBusinessImpl.class); + + private HostDao hostDao; + + @Override + public HostEntity getHost(String id) { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getHost; msg=get error, because id is empty."); + return null; + } + return hostDao.getHost(id); + } + + @Override + public List<HostEntity> getHosts(Map<String, Object> condition) { + return hostDao.getHosts(condition); + } + + @Override + public int deleteHost(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deleteHost; msg=delete error, because id is empty."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.delete.id.null")); + } + HostEntity rp = hostDao.getHost(id); + if(null == rp) { + return hostDao.deleteHost(id); + } + + return hostDao.deleteHost(id); + } + + @Override + public int addHost(HostEntity hostEntity) throws ServiceException { + if(null == hostEntity) { + LOGGER.error("function=addHost; msg=add error, because hostEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.entity.null")); + } + + if(!checkId(hostEntity.getId())) { + LOGGER.error("function=addHost; msg=add error, because id is already exist."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.id.check")); + } + if(StringUtils.isEmpty(hostEntity.getId())) { + hostEntity.setId(UUID.randomUUID().toString()); + } + return hostDao.addHost(hostEntity); + } + + @Override + public int addHostSelective(HostEntity hostEntity) throws ServiceException { + if(null == hostEntity) { + LOGGER.error("function=addHostSelective; msg=add error, because hostEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.entity.null")); + } + if(!checkId(hostEntity.getId())) { + LOGGER.error("function=addHostSelective; msg=add error, because id is allready exist."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.id.check")); + } + + if(StringUtils.isEmpty(hostEntity.getId())) { + hostEntity.setId(UUID.randomUUID().toString()); + } + return hostDao.addHostSelective(hostEntity); + } + + private boolean checkId(String id) { + HostEntity respool = hostDao.getHost(id); + if(null == respool) { + return true; + } + return false; + } + + @Override + public int updateHostSelective(HostEntity hostEntity) throws ServiceException { + if(!checkId(hostEntity.getId())) { + return hostDao.updateHostSelective(hostEntity); + } else { + return addHostSelective(hostEntity); + } + } + + @Override + public int updateHost(HostEntity hostEntity) throws ServiceException { + if(null == hostEntity) { + LOGGER.error("function=updateHost; msg=update error, because hostEntity is null."); + throw new ServiceException("update error, because hostEntity is null."); + } + + return hostDao.updateHost(hostEntity); + } + + @Override + public int updateHostByVimId(HostEntity hostEntity) throws ServiceException { + if(null == hostEntity) { + LOGGER.error("function=updateHostByVimId; msg=update error, because hostEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.update.entity.null")); + } + return hostDao.updateHostByVimId(hostEntity); + } + + @Override + public int deleteHostByVimId(String vimId) throws ServiceException { + if(StringUtils.isEmpty(vimId)) { + LOGGER.error("function=deleteHostByVimId; msg=delete error, because VimId is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.delete.vimid.check")); + } + return hostDao.deleteHostByVimId(vimId); + } + + public void setHostDao(HostDao hostDao) { + this.hostDao = hostDao; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java new file mode 100644 index 0000000..eeb2de0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java @@ -0,0 +1,93 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.VimUtil; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.RestfulUtil; +import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LimitsBusinessImpl implements LimitsBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(LimitsBusinessImpl.class); + + /** + * <br> + * + * @param vimId + * @param tenantId + * @return + * @since NFVO 0.5 + */ + private JSONObject getResponse(String vimId, String tenantId) { + LOGGER.info("function=getResponse; vimId={}, tenantId={}", vimId, tenantId); + String url = String.format(UrlConstant.GET_LIMITS_URL, vimId, tenantId); + JSONObject result = RestfulUtil.getResponseObj(url, ParamConstant.PARAM_GET); + LOGGER.warn("function=getResponse; result={}", result); + if(null == result) { + JSONObject obj = new JSONObject(); + obj.put("msg", "getLimits fail!"); + return obj; + } + return result; + } + + @Override + public JSONObject getLimits(String vimId) throws ServiceException { + JSONObject vimInfo = VimUtil.getVimById(vimId); + LOGGER.info("GetLimits vimInfo: {}", vimInfo); + String vimName = vimInfo.getString("name"); + String tenant = vimInfo.getString("tenant"); + String tenantId = VimUtil.getTenantIdByName(tenant, vimId); + + JSONObject limits = getResponse(vimId, tenantId); + + String totalCPU = String.valueOf(limits.get("maxTotalCores")); + String totalMemory = String.valueOf(limits.get("maxTotalRAMSize")); + String totalDisk = String.valueOf(limits.get("maxTotalVolumeGigabytes")); + String usedCPU = String.valueOf(limits.get("totalCoresUsed")); + String usedMemory = String.valueOf(limits.get("totalRAMUsed")); + String usedDisk = String.valueOf(limits.get("totalGigabytesUsed")); + + JSONObject result = new JSONObject(); + result.put("vimId", vimId); + result.put("vimName", vimName); + result.put("totalCPU", totalCPU); + result.put("totalMemory", totalMemory); + result.put("totalDisk", totalDisk); + result.put("usedCPU", usedCPU); + result.put("usedMemory", usedMemory); + result.put("usedDisk", usedDisk); + LOGGER.info("getLimits result:{}", result); + return result; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java new file mode 100644 index 0000000..76ee2a0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java @@ -0,0 +1,242 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.util.StringUtil; +import org.openo.nfvo.resmanagement.service.business.inf.LocationBusiness; +import org.openo.nfvo.resmanagement.service.dao.inf.LocationDao; +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * Location Business implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LocationBusinessImpl implements LocationBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(LocationBusinessImpl.class); + + private LocationDao locationDao; + + /** + * + * Check location.<br> + * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public boolean checkLocation(LocationEntity locationEntity) throws ServiceException { + String location = locationEntity.getLocation(); + Map<String, Object> map = new HashMap<>(); + map.put(ParamConstant.PARAM_LOCATION, location); + List<LocationEntity> locationList = getLocations(map); + if(locationList == null || locationList.isEmpty()) { + return false; + } + return true; + } + + /** + * + * Check Latitude.;<br> + * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public boolean checkLatitude(LocationEntity locationEntity) throws ServiceException { + String latitu = locationEntity.getLatitude(); + String longitu = locationEntity.getLongitude(); + if("-0".equals(locationEntity.getLatitude())) { + locationEntity.setLatitude("0"); + } + if("-0".equals(locationEntity.getLongitude())) { + locationEntity.setLongitude("0"); + } + float latitude = Float.parseFloat(latitu); + float longitude = Float.parseFloat(longitu); + if((latitude >= -90 && latitude <= 90) && (longitude >= -180 && longitude <= 180)) { + return true; + } + return false; + } + + private boolean checkModified(LocationEntity locationEntity) { + String newCountry = locationEntity.getCountry(); + String newLocation = locationEntity.getLocation(); + String id = locationEntity.getId(); + LocationEntity selectLocation = locationDao.getLocation(id); + if(null == selectLocation) { + return false; + } + String oldCountry = selectLocation.getCountry(); + String oldLocation = selectLocation.getLocation(); + if(newCountry.equals(oldCountry) && newLocation.equals(oldLocation)) { + return true; + } + return false; + } + + @Override + public LocationEntity getLocation(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getLocation; msg=get error, because id is empty."); + return null; + } + return locationDao.getLocation(id); + } + + @Override + public List<String> getCountry() throws ServiceException { + return locationDao.getCountry(); + } + + @Override + public List<String> getLocationByCountry(Map<String, Object> condition) throws ServiceException { + return locationDao.getLocationByCountry(condition); + } + + @Override + public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException { + return locationDao.getLocations(condition); + } + + @Override + public int deleteLocation(String location) throws ServiceException { + if(StringUtils.isEmpty(location)) { + LOGGER.error("function=deleteLocation; msg=delete error, because location is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.delete.base.entity.check")); + } + return locationDao.deleteLocation(location); + } + + @Override + public int addLocation(LocationEntity locationEntity) throws ServiceException { + if(null == locationEntity) { + LOGGER.error("function=addLocation; msg=add error, because locationEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.null")); + } + if(!StringUtil.checkXss(locationEntity.getCountry()) || !StringUtil.checkXss(locationEntity.getLocation()) + || !StringUtil.checkXss(locationEntity.getLatitude()) + || !StringUtil.checkXss(locationEntity.getLongitude())) { + LOGGER.error("function=addLocation; msg=add Location error, because XSS injection."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check")); + } + if(checkLocation(locationEntity)) { + LOGGER.error("function=addLocation; msg=add Location error, because location exist."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.check")); + } + if(!checkLatitude(locationEntity)) { + LOGGER.error("function=addLocation; msg=add Location error, because latitude or longitude illegal."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.latitude.check")); + } + if(null == locationEntity.getId() || locationEntity.getId().isEmpty()) { + locationEntity.setId(UUID.randomUUID().toString()); + } + LOGGER.error("function=addLocation; msg=add DO success, : " + locationEntity); + return locationDao.addLocation(locationEntity); + + } + + @Override + public int addLocationSelective(LocationEntity locationEntity) throws ServiceException { + if(null == locationEntity) { + LOGGER.error("function=addLocationSelective; msg=add error, because locationEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.null")); + } + if(!StringUtil.checkXss(locationEntity.getCountry()) || !StringUtil.checkXss(locationEntity.getLocation()) + || !StringUtil.checkXss(locationEntity.getLatitude()) + || !StringUtil.checkXss(locationEntity.getLongitude())) { + LOGGER.error("function=addLocation; msg=add Location error, because XSS injection."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check")); + } + if(null == locationEntity.getId() || locationEntity.getId().isEmpty()) { + locationEntity.setId(UUID.randomUUID().toString()); + } + return locationDao.addLocationSelective(locationEntity); + } + + @Override + public int updateLocationSelective(LocationEntity locationEntity) throws ServiceException { + if(null == locationEntity) { + LOGGER.error("function=updateLocationSelective; msg=update error, because locationEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.entity.check")); + } + if(!checkLatitude(locationEntity)) { + LOGGER.error("function=updateLocationSelective; msg=update Location error, " + + "because latitude or longitude illegal."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.latitude.check")); + } + if(!checkModified(locationEntity)) { + LOGGER.error("function=updateLocationSelective; msg=update Location error, " + + "because country or location be modified."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.modified.check")); + } + return locationDao.updateLocationSelective(locationEntity); + } + + @Override + public int updateLocation(LocationEntity locationEntity) throws ServiceException { + if(null == locationEntity) { + LOGGER.error("function=updateLocation; msg=update error, because locationEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.entity.null")); + } + if(!checkLatitude(locationEntity)) { + LOGGER.error("function=updateLocation; msg=update Location error, because latitude or longitude illegal."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.latitude.check")); + } + return locationDao.updateLocation(locationEntity); + } + + public LocationDao getLocationDao() { + return locationDao; + } + + public void setLocationDao(LocationDao locationDao) { + this.locationDao = locationDao; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java new file mode 100644 index 0000000..811c3e4 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java @@ -0,0 +1,153 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.service.business.inf.NetworkBusiness; +import org.openo.nfvo.resmanagement.service.dao.inf.NetworkDao; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Network business implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class NetworkBusinessImpl implements NetworkBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(NetworkBusinessImpl.class); + + private NetworkDao networkDao; + + @Override + public NetworkEntity getNetwork(String id) { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getNetwork; msg=get error, because id is empty."); + return null; + } + return networkDao.getNetwork(id); + } + + @Override + public List<NetworkEntity> getNetworks(Map<String, Object> condition) { + return networkDao.getNetworks(condition); + } + + @Override + public int deleteNetwork(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deleteNetwork; msg=delete error, because id is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.delete.id.null")); + } + return networkDao.deleteNetwork(id); + } + + @Override + public int addNetwork(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=addNetwork; msg=add error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.add.entity.null")); + } + if(!checkId(networkEntity.getId())) { + return networkDao.updateNetworkSelective(networkEntity); + } + if(StringUtils.isEmpty(networkEntity.getId())) { + networkEntity.setId(UUID.randomUUID().toString()); + } + return networkDao.addNetwork(networkEntity); + } + + @Override + public int addNetworkSelective(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=addNetworkSelective; msg=add error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.add.entity.null")); + } + if(!checkId(networkEntity.getId())) { + return networkDao.updateNetworkSelective(networkEntity); + } + if(StringUtils.isEmpty(networkEntity.getId())) { + networkEntity.setId(UUID.randomUUID().toString()); + } + return networkDao.addNetworkSelective(networkEntity); + } + + private boolean checkId(String id) { + NetworkEntity network = networkDao.getNetwork(id); + if(null == network) { + return true; + } + return false; + } + + @Override + public int updateNetworkSelective(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=updateNetworkSelective; msg=update error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null")); + } + return networkDao.updateNetworkSelective(networkEntity); + } + + @Override + public int updateNetwork(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=updateNetwork; msg=update error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null")); + } + return networkDao.updateNetwork(networkEntity); + } + + @Override + public int updateNetworkByVimId(NetworkEntity networkEntity) throws ServiceException { + if(null == networkEntity) { + LOGGER.error("function=updateNetworkByVimId; msg=update error, because networkEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null")); + } + return networkDao.updateNetworkByVimId(networkEntity); + } + + @Override + public int deleteNetworkByVimId(String vimId) throws ServiceException { + if(StringUtils.isEmpty(vimId)) { + LOGGER.error("function=deleteNetworkByVimId; msg=delete error, because VimId is empty."); + throw new ServiceException(ResourceUtil.getMessage("")); + } + return networkDao.deleteNetworkByVimId(vimId); + } + + public void setNetworkDao(NetworkDao networkDao) { + this.networkDao = networkDao; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java new file mode 100644 index 0000000..ce715d9 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java @@ -0,0 +1,161 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.service.business.inf.PortBusiness; +import org.openo.nfvo.resmanagement.service.dao.inf.PortDao; +import org.openo.nfvo.resmanagement.service.entity.PortEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Port business implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class PortBusinessImpl implements PortBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(PortBusinessImpl.class); + + private PortDao portDao; + + @Override + public PortEntity getPort(String id) { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getPort; msg=get error, because id is empty."); + return null; + } + return portDao.getPort(id); + } + + @Override + public List<PortEntity> getPorts(Map<String, Object> condition) { + return portDao.getPorts(condition); + } + + @Override + public int deletePort(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deletePort; msg=delete error, because id is empty."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.delete.id.null")); + } + PortEntity rp = portDao.getPort(id); + if(null == rp) { + return portDao.deletePort(id); + } + + return portDao.deletePort(id); + } + + @Override + public int addPort(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=addPort; msg=add error, because portEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.add.entity.null")); + } + + if(!checkId(portEntity.getId())) { + return portDao.updatePortSelective(portEntity); + } + if(StringUtils.isEmpty(portEntity.getId())) { + portEntity.setId(UUID.randomUUID().toString()); + } + return portDao.addPort(portEntity); + } + + @Override + public int addPortSelective(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=addPortSelective; msg=add error, because portEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.add.entity.null")); + } + if(!checkId(portEntity.getId())) { + return portDao.updatePortSelective(portEntity); + } + + if(StringUtils.isEmpty(portEntity.getId())) { + portEntity.setId(UUID.randomUUID().toString()); + } + return portDao.addPortSelective(portEntity); + } + + private boolean checkId(String id) { + PortEntity respool = portDao.getPort(id); + if(null == respool) { + return true; + } + return false; + } + + @Override + public int updatePortSelective(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=updatePortSelective; msg=update error, because portEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.update.entity.null")); + } + + return portDao.updatePortSelective(portEntity); + } + + @Override + public int updatePort(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=updatePort; msg=update error, because portEntity is null."); + throw new ServiceException("update error, because portEntity is null."); + } + + return portDao.updatePort(portEntity); + } + + @Override + public int updatePortByVimId(PortEntity portEntity) throws ServiceException { + if(null == portEntity) { + LOGGER.error("function=updatePortByVimId; msg=update error, because portEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.update.entity.null")); + } + return portDao.updatePortByVimId(portEntity); + } + + @Override + public int deletePortByVimId(String vimId) throws ServiceException { + if(StringUtils.isEmpty(vimId)) { + LOGGER.error("function=deletePortByVimId; msg=delete error, because VimId is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.delete.vimid.check")); + } + return portDao.deletePortByVimId(vimId); + } + + public void setPortDao(PortDao portDao) { + this.portDao = portDao; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java new file mode 100644 index 0000000..6ffb3fc --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java @@ -0,0 +1,200 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.service.business.inf.SitesBusiness; +import org.openo.nfvo.resmanagement.service.dao.inf.SitesDao; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Sites info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public class SitesBusinessImpl implements SitesBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(SitesBusinessImpl.class); + + private SitesDao sitesDao; + + private static final String TYPE_ADD = "add"; + + private static final String TYPE_UPDATE = "update"; + + private static final String TYPE_DELETE = "delete"; + + @Override + public SitesEntity getSite(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getSite; msg=get error, because id is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.id.null")); + } + return sitesDao.getSite(id); + } + + @Override + public List<SitesEntity> getSites(Map<String, Object> condition) { + return sitesDao.getSites(condition); + } + + @Override + public int deleteSite(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deleteSite; msg=delete error, because id is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.delete.id.null")); + } + + return sitesDao.deleteSite(id); + } + + @Override + public int addSite(SitesEntity sitesEntity) throws ServiceException { + LOGGER.info("addSite sitesEntity"); + if(null == sitesEntity) { + LOGGER.error("function=addSite; msg=add error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.entity.null")); + } + // if(!StringUtil.checkXss(sitesEntity.getName()) || + // !StringUtil.checkXss(sitesEntity.getCountry()) + // || !StringUtil.checkXss(sitesEntity.getLocation())) { + // LOGGER.error("function=addLocation; msg=add site error, because XSS injection."); + // throw new ServiceException( + // ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check")); + // } + LOGGER.info("sitesEntity: " + sitesEntity.toString()); + this.checkSite(sitesEntity, TYPE_ADD); + SitesEntity.dataFramat(sitesEntity); + LOGGER.info("Add datacenter data into DB."); + return sitesDao.addSite(sitesEntity); + } + + private void checkSite(SitesEntity sitesEntity, String type) throws ServiceException { + if(TYPE_ADD.equals(type)) { + checkId(sitesEntity.getId()); + checkSiteName(sitesEntity.getName()); + if(!SitesEntity.checkResource(sitesEntity)) { + LOGGER.error("function=checkRespool; msg=site{} resource error", sitesEntity.toString()); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.resource.check")); + } + } + } + + private void checkSiteName(String siteName) throws ServiceException { + Map<String, Object> siteMap = new HashMap<>(10); + siteMap.put(ParamConstant.PARAM_NAME, siteName); + List<SitesEntity> siteList = sitesDao.getSites(siteMap); + if(null != siteList && !siteList.isEmpty()) { + LOGGER.error("function=checkSiteName; msg=site: {} has already exist.", siteName); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.name.check")); + } + } + + private void checkId(String id) throws ServiceException { + SitesEntity site = sitesDao.getSite(id); + if(null != site) { + LOGGER.error("function=checkId; msg=add error, because id is already exist."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.id.check")); + } + } + + @Override + public int addSiteSelective(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=addSiteSelective; msg=add error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.entity.null")); + } + this.checkSite(sitesEntity, TYPE_ADD); + + if(StringUtils.isEmpty(sitesEntity.getId())) { + sitesEntity.setId(UUID.randomUUID().toString()); + } + SitesEntity.dataFramat(sitesEntity); + return sitesDao.addSiteSelective(sitesEntity); + } + + @Override + public int updateSiteSelective(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=updateSiteSelective; msg=update error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); + } + + this.checkSite(sitesEntity, TYPE_UPDATE); + SitesEntity.dataFramat(sitesEntity); + return sitesDao.updateSiteSelective(sitesEntity); + } + + @Override + public int updateSite(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=updateSite; msg=update error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); + } + this.checkSite(sitesEntity, TYPE_UPDATE); + SitesEntity.dataFramat(sitesEntity); + return sitesDao.updateSite(sitesEntity); + } + + @Override + public int updateSiteByVimId(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=updateSiteByVimId; msg=update error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); + } + SitesEntity.dataFramat(sitesEntity); + return sitesDao.updateSiteByVimId(sitesEntity); + } + + @Override + public int updateSiteResource(SitesEntity sitesEntity) throws ServiceException { + if(null == sitesEntity) { + LOGGER.error("function=updateSiteResource; msg=update error, because sitesEntity is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null")); + } + SitesEntity.dataFramat(sitesEntity); + return sitesDao.updateSiteSelective(sitesEntity); + } + + public void setSitesDao(SitesDao sitesDao) { + this.sitesDao = sitesDao; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java new file mode 100644 index 0000000..6cbcfc4 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java @@ -0,0 +1,99 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import java.util.List; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.util.StringUtil; +import org.openo.nfvo.resmanagement.service.business.inf.VimBusiness; +import org.openo.nfvo.resmanagement.service.dao.inf.VimDao; +import org.openo.nfvo.resmanagement.service.entity.VimEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Vim info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public class VimBusinessImpl implements VimBusiness { + + private static final Logger LOGGER = LoggerFactory.getLogger(VimBusinessImpl.class); + + private VimDao vimDao; + + @Override + public VimEntity getVim(String id) { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=getVim; msg=get error, because id is empty."); + return null; + } + return vimDao.getVim(id); + } + + @Override + public List<VimEntity> getVims() { + return vimDao.getVims(); + } + + @Override + public int deleteVim(String id) throws ServiceException { + if(StringUtils.isEmpty(id)) { + LOGGER.error("function=deleteVim; msg=deleteVim error, because id is empty."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.del.id.check")); + } + return vimDao.deleteVim(id); + } + + @Override + public int addVim(String id) throws ServiceException { + if(!StringUtil.isValidString(id)) { + LOGGER.error("function=addVim; msg=add error, because id is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.null")); + } + if(!checkId(id)) { + LOGGER.error("function=addVim; msg=add error, because id is already exist."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.check")); + } + + VimEntity vimEntity = new VimEntity(); + vimEntity.setId(id); + return vimDao.addVim(vimEntity); + } + + private boolean checkId(String id) { + VimEntity vim = vimDao.getVim(id); + if(null == vim) { + return true; + } + return false; + } + + public void setVimDao(VimDao vimDao) { + this.vimDao = vimDao; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java new file mode 100644 index 0000000..803c96e --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java @@ -0,0 +1,131 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; + +/** + * Host Buisiness Class.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 31, 2016 + */ +public interface HostBusiness { + + /** + * + * Get host.<br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + HostEntity getHost(String id); + + /** + * + * Get details of hosts.<br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<HostEntity> getHosts(Map<String, Object> condition); + + /** + * + * Delete host.<br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteHost(String id) throws ServiceException; + + /** + * + * Delete host by VIM Id.<br> + * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteHostByVimId(String vimId) throws ServiceException; + + /** + * + * Add host.<br> + * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addHost(HostEntity hostEntity) throws ServiceException; + + /** + * + * Add selective host.<br> + * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addHostSelective(HostEntity hostEntity) throws ServiceException; + + /** + * + * Update selective host.<br> + * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateHostSelective(HostEntity hostEntity) throws ServiceException; + + /** + * + * Update host.<br> + * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateHost(HostEntity hostEntity) throws ServiceException; + + /** + * + * Update host by VIM Id.<br> + * + * @param hostEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateHostByVimId(HostEntity hostEntity) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java new file mode 100644 index 0000000..b78b6a8 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface LimitsBusiness { + + /** + * <br> + * + * @param paramJson + * @return + * @since NFVO 0.5 + */ + JSONObject getLimits(String vimId) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java new file mode 100644 index 0000000..fd5cef2 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java @@ -0,0 +1,134 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; + +/** + * + * Location Business Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface LocationBusiness { + + /** + * + * Get Location.<br> + * + * @param location + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + LocationEntity getLocation(String location) throws ServiceException; + + /** + * + * Get Locations.<br> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException; + + /** + * + * Delete Location.<br> + * + * @param location + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteLocation(String location) throws ServiceException; + + /** + * + * Add Location.<br> + * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addLocation(LocationEntity locationEntity) throws ServiceException; + + /** + * + * Add Selective Location.<br> + * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addLocationSelective(LocationEntity locationEntity) throws ServiceException; + + /** + * + * Update Selective Location.<br> + * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateLocationSelective(LocationEntity locationEntity) throws ServiceException; + + /** + * + * Update Location.<br> + * + * @param locationEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateLocation(LocationEntity locationEntity) throws ServiceException; + + /** + * + * Get Country.<br> + * + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<String> getCountry() throws ServiceException; + + /** + * + * Get Location By Country.<br> + * + * @param condition + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<String> getLocationByCountry(Map<String, Object> condition) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java new file mode 100644 index 0000000..be0c9dc --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java @@ -0,0 +1,133 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; + +/** + * + * Network Business class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface NetworkBusiness { + + /** + * + * Get network details.<br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + NetworkEntity getNetwork(String id); + + /** + * + * Get details of available networks.<br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<NetworkEntity> getNetworks(Map<String, Object> condition); + + /** + * + * Delete Network.<br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteNetwork(String id) throws ServiceException; + + /** + * + * Delete network by Virtual Infrastructure Manager ID.<br> + * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteNetworkByVimId(String vimId) throws ServiceException; + + /** + * + * Add Network.<br> + * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addNetwork(NetworkEntity networkEntity) throws ServiceException; + + /** + * + * Add Selective Network.<br> + * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addNetworkSelective(NetworkEntity networkEntity) throws ServiceException; + + /** + * + * Update Selective Network.<br> + * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateNetworkSelective(NetworkEntity networkEntity) throws ServiceException; + + /** + * + * Update Network.<br> + * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateNetwork(NetworkEntity networkEntity) throws ServiceException; + + /** + * + * Update network by Virtual Infrastructure Manager ID.<br> + * + * @param networkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updateNetworkByVimId(NetworkEntity networkEntity) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java new file mode 100644 index 0000000..b81a3e1 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java @@ -0,0 +1,131 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.PortEntity; + +/** + * Port Buisiness Class.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 31, 2016 + */ +public interface PortBusiness { + + /** + * + * Get Port.<br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + PortEntity getPort(String id); + + /** + * + * Get details of ports.<br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<PortEntity> getPorts(Map<String, Object> condition); + + /** + * + * Delete Port.<br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deletePort(String id) throws ServiceException; + + /** + * + * Delete port by VIM ID.<br> + * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deletePortByVimId(String vimId) throws ServiceException; + + /** + * + * Add port.<br> + * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addPort(PortEntity portEntity) throws ServiceException; + + /** + * + * Add selective port.<br> + * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int addPortSelective(PortEntity portEntity) throws ServiceException; + + /** + * + * Update selective port.<br> + * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updatePortSelective(PortEntity portEntity) throws ServiceException; + + /** + * + * Update port.<br> + * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updatePort(PortEntity portEntity) throws ServiceException; + + /** + * + * Update port by VIM Id.<br> + * + * @param portEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int updatePortByVimId(PortEntity portEntity) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java new file mode 100644 index 0000000..8d11a39 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java @@ -0,0 +1,124 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; + +/** + * DC info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface SitesBusiness { + + /** + * It is used to get Site info.<br/> + * + * @param id + * @return The get result + * @throws ServiceException When get failed. + * @since NFVO 0.5 + */ + SitesEntity getSite(String id) throws ServiceException; + + /** + * It is used to get Sites info.<br/> + * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List<SitesEntity> getSites(Map<String, Object> condition); + + /** + * It is used to delete Site info.<br/> + * + * @param id + * @return The delete result + * @throws ServiceException When delete failed. + * @since NFVO 0.5 + */ + int deleteSite(String id) throws ServiceException; + + /** + * It is used to add Site info.<br/> + * + * @param sitesEntity + * @return The add result + * @throws ServiceException When add failed. + * @since NFVO 0.5 + */ + int addSite(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to add Site info.<br/> + * + * @param sitesEntity + * @return The add result + * @throws ServiceException When add failed. + * @since NFVO 0.5 + */ + int addSiteSelective(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to update Site info.<br/> + * + * @param sitesEntity + * @return The update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + int updateSiteSelective(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to create update Site info.<br/> + * + * @param sitesEntity + * @return The update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + int updateSite(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to update Site info.<br/> + * + * @param sitesEntity + * @return The update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + int updateSiteByVimId(SitesEntity sitesEntity) throws ServiceException; + + /** + * It is used to update Site info.<br/> + * + * @param sitesEntity + * @return The update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + int updateSiteResource(SitesEntity sitesEntity) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java new file mode 100644 index 0000000..8806e7a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java @@ -0,0 +1,72 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.inf; + +import java.util.List; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.VimEntity; + +/** + * Vim info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface VimBusiness { + + /** + * It is used to get Vim info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + VimEntity getVim(String id); + + /** + * It is used to get Vim info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + List<VimEntity> getVims(); + + /** + * It is used to delete Vim info.<br/> + * + * @param id + * @return the delete result + * @throws ServiceException When delete failed. + * @since NFVO 0.5 + */ + int deleteVim(String id) throws ServiceException; + + /** + * It is used to add Vim info.<br/> + * + * @param id + * @return the add result + * @throws ServiceException When add failed. + * @since NFVO 0.5 + */ + int addVim(String id) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java new file mode 100644 index 0000000..e3a76ca --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java @@ -0,0 +1,57 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import org.apache.ibatis.session.SqlSession; + +/** + * <br/> + * <p> + * Database abstract class to get the MapperManager + * </p> + * + * @author + * @version NFVO 0.5 2016-3-17 + */ +public class AbstractDao { + + private SqlSession session; + + protected AbstractDao() { + //added this private costructor to fix static errors. + } + + public SqlSession getSession() { + return session; + } + + public void setSession(SqlSession session) { + this.session = session; + } + + /** + * get Mybatis Mapper<br/> + * + * @param type + * The type of Class + * @return Mapper + * @since NFVO 0.5 + */ + public <T> T getMapperManager(Class<T> type) { + return (T)getSession().getMapper(type); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java new file mode 100644 index 0000000..1c5c03c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; +import org.openo.nfvo.resmanagement.service.dao.inf.HostDao; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; +import org.openo.nfvo.resmanagement.service.mapper.HostMapper; + +/** + * + * Host DAO implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class HostDaoImpl extends AbstractDao implements HostDao { + + @Override + public HostEntity getHost(String id) { + return getMapperManager(HostMapper.class).getHost(id); + } + + @Override + public List<HostEntity> getHosts(Map<String, Object> condition) { + return getMapperManager(HostMapper.class).getHosts(condition); + } + + @Override + public int deleteHost(String id) { + return getMapperManager(HostMapper.class).deleteHost(id); + } + + @Override + public int deleteHostByVimId(String vimId) { + return getMapperManager(HostMapper.class).deleteHostByVimId(vimId); + } + + @Override + public int addHost(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).addHost(hostEntity); + } + + @Override + public int addHostSelective(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).addHostSelective(hostEntity); + } + + @Override + public int updateHostSelective(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).updateHostSelective(hostEntity); + } + + @Override + public int updateHost(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).updateHost(hostEntity); + } + + @Override + public int updateHostByVimId(HostEntity hostEntity) { + return getMapperManager(HostMapper.class).updateHostByVimId(hostEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java new file mode 100644 index 0000000..949f19f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; +import org.openo.nfvo.resmanagement.service.dao.inf.LocationDao; +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; +import org.openo.nfvo.resmanagement.service.mapper.LocationMapper; + +/** + * + * Location DAO implemetation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LocationDaoImpl extends AbstractDao implements LocationDao { + + @Override + public LocationEntity getLocation(String id) { + return getMapperManager(LocationMapper.class).getLocation(id); + } + + @Override + public List<String> getCountry() { + return getMapperManager(LocationMapper.class).getCountry(); + } + + @Override + public List<String> getLocationByCountry(Map<String, Object> condition) { + return getMapperManager(LocationMapper.class).getLocationByCountry(condition); + } + + @Override + public List<LocationEntity> getLocations(Map<String, Object> condition) { + return getMapperManager(LocationMapper.class).getLocations(condition); + } + + @Override + public int deleteLocation(String id) { + return getMapperManager(LocationMapper.class).deleteLocation(id); + } + + @Override + public int addLocation(LocationEntity locationEntity) { + return getMapperManager(LocationMapper.class).addLocation(locationEntity); + } + + @Override + public int addLocationSelective(LocationEntity locationEntity) { + return getMapperManager(LocationMapper.class).addLocationSelective(locationEntity); + } + + @Override + public int updateLocationSelective(LocationEntity locationEntity) { + return getMapperManager(LocationMapper.class).updateLocationSelective(locationEntity); + } + + @Override + public int updateLocation(LocationEntity locationEntity) { + return getMapperManager(LocationMapper.class).updateLocation(locationEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java new file mode 100644 index 0000000..12769a2 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; +import org.openo.nfvo.resmanagement.service.dao.inf.NetworkDao; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper; + +/** + * + * Network DAO implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class NetworkDaoImpl extends AbstractDao implements NetworkDao { + + @Override + public NetworkEntity getNetwork(String id) { + return getMapperManager(NetworkMapper.class).getNetwork(id); + } + + @Override + public List<NetworkEntity> getNetworks(Map<String, Object> condition) { + return getMapperManager(NetworkMapper.class).getNetworks(condition); + } + + @Override + public int deleteNetwork(String id) { + return getMapperManager(NetworkMapper.class).deleteNetwork(id); + } + + @Override + public int deleteNetworkByVimId(String vimId) { + return getMapperManager(NetworkMapper.class).deleteNetworkByVimId(vimId); + } + + @Override + public int addNetwork(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).addNetwork(networkEntity); + } + + @Override + public int addNetworkSelective(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).addNetworkSelective(networkEntity); + } + + @Override + public int updateNetworkSelective(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).updateNetworkSelective(networkEntity); + } + + @Override + public int updateNetwork(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).updateNetwork(networkEntity); + } + + @Override + public int updateNetworkByVimId(NetworkEntity networkEntity) { + return getMapperManager(NetworkMapper.class).updateNetworkByVimId(networkEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java new file mode 100644 index 0000000..e113c7a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; +import org.openo.nfvo.resmanagement.service.dao.inf.PortDao; +import org.openo.nfvo.resmanagement.service.entity.PortEntity; +import org.openo.nfvo.resmanagement.service.mapper.PortMapper; + +/** + * + * Port DAO implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class PortDaoImpl extends AbstractDao implements PortDao { + + @Override + public PortEntity getPort(String id) { + return getMapperManager(PortMapper.class).getPort(id); + } + + @Override + public List<PortEntity> getPorts(Map<String, Object> condition) { + return getMapperManager(PortMapper.class).getPorts(condition); + } + + @Override + public int deletePort(String id) { + return getMapperManager(PortMapper.class).deletePort(id); + } + + @Override + public int deletePortByVimId(String vimId) { + return getMapperManager(PortMapper.class).deletePortByVimId(vimId); + } + + @Override + public int addPort(PortEntity portEntity) { + return getMapperManager(PortMapper.class).addPort(portEntity); + } + + @Override + public int addPortSelective(PortEntity portEntity) { + return getMapperManager(PortMapper.class).addPortSelective(portEntity); + } + + @Override + public int updatePortSelective(PortEntity portEntity) { + return getMapperManager(PortMapper.class).updatePortSelective(portEntity); + } + + @Override + public int updatePort(PortEntity portEntity) { + return getMapperManager(PortMapper.class).updatePort(portEntity); + } + + @Override + public int updatePortByVimId(PortEntity portEntity) { + return getMapperManager(PortMapper.class).updatePortByVimId(portEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java new file mode 100644 index 0000000..2d29d7b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java @@ -0,0 +1,77 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; +import org.openo.nfvo.resmanagement.service.dao.inf.SitesDao; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; +import org.openo.nfvo.resmanagement.service.mapper.SitesMapper; + +/** + * DC interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class SitesDaoImpl extends AbstractDao implements SitesDao { + + @Override + public SitesEntity getSite(String id) { + return getMapperManager(SitesMapper.class).getSite(id); + } + + @Override + public List<SitesEntity> getSites(Map<String, Object> condition) { + return getMapperManager(SitesMapper.class).getSites(condition); + } + + @Override + public int deleteSite(String id) { + return getMapperManager(SitesMapper.class).deleteSite(id); + } + + @Override + public int addSite(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).addSite(sitesEntity); + } + + @Override + public int addSiteSelective(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).addSiteSelective(sitesEntity); + } + + @Override + public int updateSiteSelective(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).updateSiteSelective(sitesEntity); + } + + @Override + public int updateSite(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).updateSite(sitesEntity); + } + + @Override + public int updateSiteByVimId(SitesEntity sitesEntity) { + return getMapperManager(SitesMapper.class).updateSiteByVimId(sitesEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java new file mode 100644 index 0000000..e73b251 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java @@ -0,0 +1,55 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; + +import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao; +import org.openo.nfvo.resmanagement.service.dao.inf.VimDao; +import org.openo.nfvo.resmanagement.service.entity.VimEntity; +import org.openo.nfvo.resmanagement.service.mapper.VimMapper; + +/** + * Vim interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 25, 2016 + */ +public class VimDaoImpl extends AbstractDao implements VimDao { + + @Override + public VimEntity getVim(String id) { + return getMapperManager(VimMapper.class).getVim(id); + } + + @Override + public List<VimEntity> getVims() { + return getMapperManager(VimMapper.class).getVims(); + } + + @Override + public int deleteVim(String id) { + return getMapperManager(VimMapper.class).deleteVim(id); + } + + @Override + public int addVim(VimEntity vimEntity) { + return getMapperManager(VimMapper.class).addVim(vimEntity); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java new file mode 100644 index 0000000..96ed906 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java @@ -0,0 +1,84 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.inf.VirtualLinkDao; +import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; +import org.openo.nfvo.resmanagement.service.mapper.VirtualLinkMapper; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VirtualLinkDaoImpl extends AbstractDao implements VirtualLinkDao { + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VirtualLinkEntity getVl(String id) { + return getMapperManager(VirtualLinkMapper.class).selectByPrimaryKey(id); + } + + /** + * <br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List<VirtualLinkEntity> getVls(Map<String, Object> condition) { + return getMapperManager(VirtualLinkMapper.class).getVls(condition); + } + + /** + * <br> + * + * @param virtualLinkEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVl(VirtualLinkEntity virtualLinkEntity) { + return getMapperManager(VirtualLinkMapper.class).insert(virtualLinkEntity); + } + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVlById(String id) { + return getMapperManager(VirtualLinkMapper.class).deleteByPrimaryKey(id); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java new file mode 100644 index 0000000..ee3806c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java @@ -0,0 +1,108 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.inf.VmDao; +import org.openo.nfvo.resmanagement.service.entity.VmEntity; +import org.openo.nfvo.resmanagement.service.mapper.VmMapper; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VmDaoImpl extends AbstractDao implements VmDao { + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VmEntity getVm(String id) { + return getMapperManager(VmMapper.class).selectByPrimaryKey(id); + } + + /** + * <br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List<VmEntity> getVms(Map<String, Object> condition) { + return getMapperManager(VmMapper.class).getVms(condition); + } + + /** + * <br> + * + * @param vmEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVm(VmEntity vmEntity) { + return getMapperManager(VmMapper.class).insert(vmEntity); + } + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVmById(String id) { + return getMapperManager(VmMapper.class).deleteByPrimaryKey(id); + } + + /** + * <br> + * + * @param vmEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int updateVm(VmEntity vmEntity) { + return getMapperManager(VmMapper.class).updateByPrimaryKeySelective(vmEntity); + } + + /** + * <br> + * + * @param vnfInstanceId + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVmByVnfId(String vnfInstanceId) { + return getMapperManager(VmMapper.class).deleteByVnfId(vnfInstanceId); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java new file mode 100644 index 0000000..42bb5b5 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java @@ -0,0 +1,84 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.inf.VnfDao; +import org.openo.nfvo.resmanagement.service.entity.VnfEntity; +import org.openo.nfvo.resmanagement.service.mapper.VnfMapper; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VnfDaoImpl extends AbstractDao implements VnfDao { + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VnfEntity getVnf(String id) { + return getMapperManager(VnfMapper.class).selectByPrimaryKey(id); + } + + /** + * <br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List<VnfEntity> getVnfs(Map<String, Object> condition) { + return getMapperManager(VnfMapper.class).getVnfs(condition); + } + + /** + * <br> + * + * @param vnfEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVnf(VnfEntity vnfEntity) { + return getMapperManager(VnfMapper.class).insert(vnfEntity); + } + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVnfById(String id) { + return getMapperManager(VnfMapper.class).deleteByPrimaryKey(id); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java new file mode 100644 index 0000000..6e8d32b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java @@ -0,0 +1,96 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.inf.VnfInfoDao; +import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; +import org.openo.nfvo.resmanagement.service.mapper.VnfInfoMapper; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VnfInfoDaoImpl extends AbstractDao implements VnfInfoDao { + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VnfInfoEntity getVnfInfo(String id) { + return getMapperManager(VnfInfoMapper.class).selectByPrimaryKey(id); + } + + /** + * <br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List<VnfInfoEntity> getVnfInfos(Map<String, Object> condition) { + return getMapperManager(VnfInfoMapper.class).getVnfInfos(condition); + } + + /** + * <br> + * + * @param vmEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVnfInfo(VnfInfoEntity vnfInfoEntity) { + return getMapperManager(VnfInfoMapper.class).insert(vnfInfoEntity); + } + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVnfInfoById(String id) { + return getMapperManager(VnfInfoMapper.class).deleteByPrimaryKey(id); + } + + /** + * <br> + * + * @param vnfInfoEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int updateVnfInfo(VnfInfoEntity vnfInfoEntity) { + return getMapperManager(VnfInfoMapper.class).updateByPrimaryKeySelective(vnfInfoEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java new file mode 100644 index 0000000..ed7db95 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java @@ -0,0 +1,96 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.dao.inf.VnfStatusDao; +import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; +import org.openo.nfvo.resmanagement.service.mapper.VnfStatusMapper; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public class VnfStatusDaoImpl extends AbstractDao implements VnfStatusDao { + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public VnfStatusEntity getVnfStatus(String id) { + return getMapperManager(VnfStatusMapper.class).selectByPrimaryKey(id); + } + + /** + * <br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + @Override + public List<VnfStatusEntity> getVnfStatuss(Map<String, Object> condition) { + return getMapperManager(VnfStatusMapper.class).getVnfStatuss(condition); + } + + /** + * <br> + * + * @param vnfStatusEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int addVnfStatus(VnfStatusEntity vnfStatusEntity) { + return getMapperManager(VnfStatusMapper.class).insert(vnfStatusEntity); + } + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + @Override + public int deleteVnfStatusById(String id) { + return getMapperManager(VnfStatusMapper.class).deleteByPrimaryKey(id); + } + + /** + * <br> + * + * @param vnfStatusEntity + * @return + * @since NFVO 0.5 + */ + @Override + public int updateVnfStatus(VnfStatusEntity vnfStatusEntity) { + return getMapperManager(VnfStatusMapper.class).updateByPrimaryKeySelective(vnfStatusEntity); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java new file mode 100644 index 0000000..a48c6aa --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.HostEntity; + +/** + * Host info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface HostDao { + + /** + * It is used to get Host info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + HostEntity getHost(String id); + + /** + * It is used to get Hosts info.<br/> + * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List<HostEntity> getHosts(Map<String, Object> condition); + + /** + * It is used to delete Hosts info.<br/> + * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deleteHost(String id); + + /** + * It is used to delete Hosts info.<br/> + * + * @param vimId + * @return The delete result + * @since NFVO 0.5 + */ + int deleteHostByVimId(String vimId); + + /** + * It is used to add Hosts info. <br/> + * + * @param hostEntity + * @return The add result + * @since NFVO 0.5 + */ + int addHost(HostEntity hostEntity); + + /** + * It is used to add Hosts info. <br/> + * + * @param hostEntity + * @return The add result + * @since NFVO 0.5 + */ + int addHostSelective(HostEntity hostEntity); + + /** + * It is used to update Hosts info. <br/> + * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHostSelective(HostEntity hostEntity); + + /** + * It is used to update Hosts info. <br/> + * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHost(HostEntity hostEntity); + + /** + * It is used to update Hosts info. <br/> + * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHostByVimId(HostEntity hostEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java new file mode 100644 index 0000000..dcf2c9f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java @@ -0,0 +1,123 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; + +/** + * + * Location DAO Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface LocationDao { + + /** + * + * Get Location.<br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + LocationEntity getLocation(String id); + + /** + * + * Get Locations.<br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<LocationEntity> getLocations(Map<String, Object> condition); + + /** + * + * Delete Location.<br> + * + * @param location + * @return + * @since NFVO 0.5 + */ + int deleteLocation(String location); + + /** + * + * Add Location.<br> + * + * @param sodoResEntity + * @return + * @since NFVO 0.5 + */ + int addLocation(LocationEntity sodoResEntity); + + /** + * + * Add Selective Location.<br> + * + * @param sodoResEntity + * @return + * @since NFVO 0.5 + */ + int addLocationSelective(LocationEntity sodoResEntity); + + /** + * + * Update selective location.<br> + * + * @param sodoResEntity + * @return + * @since NFVO 0.5 + */ + int updateLocationSelective(LocationEntity sodoResEntity); + + /** + * + * Update Location.<br> + * + * @param sodoResEntity + * @return + * @since NFVO 0.5 + */ + int updateLocation(LocationEntity sodoResEntity); + + /** + * + * Get Country.<br> + * + * @return + * @since NFVO 0.5 + */ + List<String> getCountry(); + + /** + * + * Get Location by Country.<br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<String> getLocationByCountry(Map<String, Object> condition); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java new file mode 100644 index 0000000..0725bd9 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java @@ -0,0 +1,125 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; + +/** + * + * Network DOA Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface NetworkDao { + + /** + * + * Get Network Details.<br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + NetworkEntity getNetwork(String id); + + /** + * + * Get details of available networks.<br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<NetworkEntity> getNetworks(Map<String, Object> condition); + + /** + * + * Delete Network.<br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + int deleteNetwork(String id); + + /** + * + * Delete network by VIM ID.<br> + * + * @param vimId + * @return + * @since NFVO 0.5 + */ + int deleteNetworkByVimId(String vimId); + + /** + * + * Add Network.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int addNetwork(NetworkEntity networkEntity); + + /** + * + * Add selective network.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int addNetworkSelective(NetworkEntity networkEntity); + + /** + * + * Update selective network.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetworkSelective(NetworkEntity networkEntity); + + /** + * + * Update network.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetwork(NetworkEntity networkEntity); + + /** + * + * Update network by VIM ID.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetworkByVimId(NetworkEntity networkEntity); + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java new file mode 100644 index 0000000..f558b5d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.PortEntity; + +/** + * Port info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface PortDao { + + /** + * It is used to get Port info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + PortEntity getPort(String id); + + /** + * It is used to get Ports info.<br/> + * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List<PortEntity> getPorts(Map<String, Object> condition); + + /** + * It is used to delete Ports info.<br/> + * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deletePort(String id); + + /** + * It is used to delete Ports info.<br/> + * + * @param vimId + * @return The delete result + * @since NFVO 0.5 + */ + int deletePortByVimId(String vimId); + + /** + * It is used to add Ports info. <br/> + * + * @param portEntity + * @return The add result + * @since NFVO 0.5 + */ + int addPort(PortEntity portEntity); + + /** + * It is used to add Ports info. <br/> + * + * @param portEntity + * @return The add result + * @since NFVO 0.5 + */ + int addPortSelective(PortEntity portEntity); + + /** + * It is used to update Ports info. <br/> + * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePortSelective(PortEntity portEntity); + + /** + * It is used to update Ports info. <br/> + * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePort(PortEntity portEntity); + + /** + * It is used to update Ports info. <br/> + * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePortByVimId(PortEntity portEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java new file mode 100644 index 0000000..f978c8b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java @@ -0,0 +1,105 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; + +/** + * Sites info interface. <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface SitesDao { + + /** + * It is used to get Sites info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + SitesEntity getSite(String id); + + /** + * It is used to get Sites info.<br/> + * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List<SitesEntity> getSites(Map<String, Object> condition); + + /** + * It is used to get Sites info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + int deleteSite(String id); + + /** + * It is used to delete Sites info.<br/> + * + * @param sitesEntity + * @return The delete result + * @since NFVO 0.5 + */ + int addSite(SitesEntity sitesEntity); + + /** + * It is used to add Sites info.<br/> + * + * @param sitesEntity + * @return The add result + * @since NFVO 0.5 + */ + int addSiteSelective(SitesEntity sitesEntity); + + /** + * It is used to add Sites info.<br/> + * + * @param sitesEntity + * @return The add result + * @since NFVO 0.5 + */ + int updateSiteSelective(SitesEntity sitesEntity); + + /** + * It is used to update Sites info.<br/> + * + * @param sitesEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateSite(SitesEntity sitesEntity); + + /** + * It is used to update Sites info.<br/> + * + * @param sitesEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateSiteByVimId(SitesEntity sitesEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java new file mode 100644 index 0000000..1b17a46 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java @@ -0,0 +1,68 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; + +import org.openo.nfvo.resmanagement.service.entity.VimEntity; + +/** + * Vim info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface VimDao { + + /** + * It is used to get Vim info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + VimEntity getVim(String id); + + /** + * It is used to get Vims info.<br/> + * + * @return The get result + * @since NFVO 0.5 + */ + List<VimEntity> getVims(); + + /** + * It is used to delete Vim info.<br/> + * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deleteVim(String id); + + /** + * It is used to add Vim info.<br/> + * + * @param vimEntity + * @return The add result + * @since NFVO 0.5 + */ + int addVim(VimEntity vimEntity); + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java new file mode 100644 index 0000000..ead3975 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VirtualLinkDao { + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + VirtualLinkEntity getVl(String id); + + /** + * <br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<VirtualLinkEntity> getVls(Map<String, Object> condition); + + /** + * <br> + * + * @param virtualLinkEntity + * @return + * @since NFVO 0.5 + */ + int addVl(VirtualLinkEntity virtualLinkEntity); + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + int deleteVlById(String id); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java new file mode 100644 index 0000000..6d2b6b6 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java @@ -0,0 +1,45 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VmEntity; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VmDao { + + VmEntity getVm(String id); + + List<VmEntity> getVms(Map<String, Object> condition); + + int addVm(VmEntity vmEntity); + + int deleteVmById(String id); + + int updateVm(VmEntity vmEntity); + + int deleteVmByVnfId(String vnfInstanceId); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java new file mode 100644 index 0000000..7f72ce3 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VnfEntity; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VnfDao { + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + VnfEntity getVnf(String id); + + /** + * <br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<VnfEntity> getVnfs(Map<String, Object> condition); + + /** + * <br> + * + * @param vnfEntity + * @return + * @since NFVO 0.5 + */ + int addVnf(VnfEntity vnfEntity); + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + int deleteVnfById(String id); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java new file mode 100644 index 0000000..9e2aade --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VnfInfoDao { + + VnfInfoEntity getVnfInfo(String id); + + List<VnfInfoEntity> getVnfInfos(Map<String, Object> condition); + + int addVnfInfo(VnfInfoEntity vnfInfoEntity); + + int deleteVnfInfoById(String id); + + int updateVnfInfo(VnfInfoEntity vnfInfoEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java new file mode 100644 index 0000000..ef5ba9b --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public interface VnfStatusDao { + + VnfStatusEntity getVnfStatus(String id); + + List<VnfStatusEntity> getVnfStatuss(Map<String, Object> condition); + + int addVnfStatus(VnfStatusEntity vnfStatusEntity); + + int deleteVnfStatusById(String id); + + int updateVnfStatus(VnfStatusEntity vnfStatusEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java new file mode 100644 index 0000000..f8166da --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java @@ -0,0 +1,179 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * Host entity class.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 31, 2016 + */ +public class HostEntity { + + private String id; + + private String name; + + private String cpu; + + private String memory; + + private String disk; + + private String vimId; + + private String vimName; + + /** + * @return Returns the id. + */ + public String getId() { + return id; + } + + /** + * @param id The id to set. + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return Returns the cpu. + */ + public String getCpu() { + return cpu; + } + + /** + * @param cpu The cpu to set. + */ + public void setCpu(String cpu) { + this.cpu = cpu; + } + + /** + * @return Returns the memory. + */ + public String getMemory() { + return memory; + } + + /** + * @param memory The memory to set. + */ + public void setMemory(String memory) { + this.memory = memory; + } + + /** + * @return Returns the disk. + */ + public String getDisk() { + return disk; + } + + /** + * @param disk The disk to set. + */ + public void setDisk(String disk) { + this.disk = disk; + } + + /** + * @return Returns the vimId. + */ + public String getVimId() { + return vimId; + } + + /** + * @param vimId The vimId to set. + */ + public void setVimId(String vimId) { + this.vimId = vimId; + } + + /** + * @return Returns the vimName. + */ + public String getVimName() { + return vimName; + } + + /** + * @param vimName The vimName to set. + */ + public void setVimName(String vimName) { + this.vimName = vimName; + } + + /** + * + * To entity.<br> + * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static HostEntity toEntity(JSONObject jsonObject) { + HostEntity hostEntity = new HostEntity(); + hostEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + hostEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + hostEntity.setCpu(JsonUtil.getJsonFieldStr(jsonObject, "cpu")); + hostEntity.setMemory(JsonUtil.getJsonFieldStr(jsonObject, "memory")); + hostEntity.setDisk(JsonUtil.getJsonFieldStr(jsonObject, "disk")); + hostEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + hostEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + return hostEntity; + } + + @Override + public String toString() { + JSONObject hostResJson = new JSONObject(); + hostResJson.put("id", StringUtils.trimToEmpty(this.getId())); + hostResJson.put("name", StringUtils.trimToEmpty(this.getName())); + hostResJson.put("cpu", StringUtils.trimToEmpty(this.getCpu())); + hostResJson.put("memory", StringUtils.trimToEmpty(this.getMemory())); + hostResJson.put("disk", StringUtils.trimToEmpty(this.getDisk())); + hostResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + hostResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + return hostResJson.toString(); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java new file mode 100644 index 0000000..eab8ca0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java @@ -0,0 +1,236 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * + * Location entity class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class LocationEntity { + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.ID + * + * @mbggenerated + */ + private String id; + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.COUNTRY + * + * @mbggenerated + */ + private String country; + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.LOCATION + * + * @mbggenerated + */ + private String location; + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.LATITUDE + * + * @mbggenerated + */ + private String latitude; + + /** + * This field was generated by MyBatis Generator. This field corresponds to + * the database column location.LONGITUDE + * + * @mbggenerated + */ + private String longitude; + + private String description; + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.ID + * + * @return the value of location.ID + * @mbggenerated + */ + public String getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.ID + * + * @param id + * the value for location.ID + * @mbggenerated + */ + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.COUNTRY + * + * @return the value of location.COUNTRY + * @mbggenerated + */ + public String getCountry() { + return country; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.COUNTRY + * + * @param country + * the value for location.COUNTRY + * @mbggenerated + */ + public void setCountry(String country) { + this.country = country == null ? null : country.trim(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.LOCATION + * + * @return the value of location.LOCATION + * @mbggenerated + */ + public String getLocation() { + return location; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.LOCATION + * + * @param location + * the value for location.LOCATION + * @mbggenerated + */ + public void setLocation(String location) { + this.location = location == null ? null : location.trim(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.LATITUDE + * + * @return the value of location.LATITUDE + * @mbggenerated + */ + public String getLatitude() { + return latitude; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.LATITUDE + * + * @param latitude + * the value for location.LATITUDE + * @mbggenerated + */ + public void setLatitude(String latitude) { + this.latitude = latitude == null ? null : latitude.trim(); + } + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column location.LONGITUDE + * + * @return the value of location.LONGITUDE + * @mbggenerated + */ + public String getLongitude() { + return longitude; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column location.LONGITUDE + * + * @param longitude + * the value for location.LONGITUDE + * @mbggenerated + */ + public void setLongitude(String longitude) { + this.longitude = longitude == null ? null : longitude.trim(); + } + + /** + * @return Returns the description. + */ + public String getDescription() { + return description; + } + + /** + * @param description The description to set. + */ + public void setDescription(String description) { + this.description = description == null ? null : description.trim(); + } + + /** + * + * To Entity.<br> + * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static LocationEntity toEntity(JSONObject jsonObject) { + LocationEntity sodoresesEntity = new LocationEntity(); + sodoresesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + sodoresesEntity.setCountry(JsonUtil.getJsonFieldStr(jsonObject, "country")); + sodoresesEntity.setLocation(JsonUtil.getJsonFieldStr(jsonObject, "location")); + sodoresesEntity.setLatitude(JsonUtil.getJsonFieldStr(jsonObject, "latitude")); + sodoresesEntity.setLongitude(JsonUtil.getJsonFieldStr(jsonObject, "longitude")); + sodoresesEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description")); + return sodoresesEntity; + } + + @Override + public String toString() { + JSONObject locationJson = new JSONObject(); + locationJson.put("id", StringUtils.trimToEmpty(this.getId())); + locationJson.put("country", StringUtils.trimToEmpty(this.getCountry())); + locationJson.put("location", StringUtils.trimToEmpty(this.getLocation())); + locationJson.put("latitude", StringUtils.trimToEmpty(this.getLatitude())); + locationJson.put("longitude", StringUtils.trimToEmpty(this.getLongitude())); + locationJson.put("description", StringUtils.trimToEmpty(this.getDescription())); + return locationJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java new file mode 100644 index 0000000..f65ad37 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java @@ -0,0 +1,271 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * + * Network entity class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class NetworkEntity { + + /** + * This field corresponds to the database column network.ID + */ + private String id; + + /** + * This field corresponds to the database column network.NAME + */ + private String name; + + /** + * This field corresponds to the database column network.TENANT_ID + */ + private String tenantId; + + /** + * This field corresponds to the database column network.VIM_ID + */ + private String vimId; + + /** + * This field corresponds to the database column ivm.VIM_NAME + */ + private String vimName; + + /** + * This field corresponds to the database column network.STATUS + */ + private String status; + + /** + * This field corresponds to the database column network.PHYSICAL_NETWORK + */ + + private String physicalNetwork; + + /** + * This field corresponds to the database column network.NETWORK_TYPE + */ + private String networkType; + + /** + * This field corresponds to the database column network.SEGMENTATION_ID + */ + private String segmentationId; + + /** + * return the value of network.ID + */ + public String getId() { + return id; + } + + /** + * This method sets the value of the database column network.ID + * + * @param id + * the value for network.ID + */ + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + /** + * return the value of network.NAME + */ + public String getName() { + return name; + } + + /** + * This method sets the value of the database column network.NAME + * + * @param name + * the value for network.NAME + */ + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + /** + * return the value of network.TENANT_ID + */ + public String getTenantId() { + return tenantId; + } + + /** + * This method sets the value of the database column network.TENANT_ID + * + * @param tenantId + * the value for network.TENANT_ID + */ + public void setTenantId(String tenantId) { + this.tenantId = tenantId == null ? null : tenantId.trim(); + } + + /** + * return the value of network.VIM_ID + */ + public String getVimId() { + return vimId; + } + + /** + * This method sets the value of the database column network.VIM_ID + * + * @param networkVimId + * the value for network.VIM_ID + */ + public void setVimId(String networkVimId) { + this.vimId = networkVimId == null ? null : networkVimId.trim(); + } + + /** + * return the value of ivm.VIM_NAME + */ + public String getVimName() { + return vimName; + } + + /** + * This method sets the value of the database column ivm.VIM_NAME + * + * @param networkVimName + * the value for ivm.VIM_NAME + */ + public void setVimName(String networkVimName) { + this.vimName = networkVimName == null ? null : networkVimName.trim(); + } + + /** + * return the value of network.STATUS + */ + public String getStatus() { + return status; + } + + /** + * This method sets the value of the database column network.STATUS + * + * @param networkStatus + * the value for network.STATUS + */ + public void setStatus(String networkStatus) { + this.status = networkStatus == null ? null : networkStatus.trim().toLowerCase(); + } + + /** + * return the value of network.PHYSICAL_NETWORK + */ + public String getPhysicalNetwork() { + return physicalNetwork; + } + + /** + * This method sets the value of the database column + * network.PHYSICAL_NETWORK + * + * @param physicalNetwork + * the value for network.PHYSICAL_NETWORK + */ + public void setPhysicalNetwork(String physicalNetwork) { + this.physicalNetwork = physicalNetwork == null ? null : physicalNetwork.trim(); + } + + /** + * return the value of network.NETWORK_TYPE + */ + public String getNetworkType() { + return networkType; + } + + /** + * This method sets the value of the database column network.NETWORK_TYPE + * + * @param networkType + * the value for network.NETWORK_TYPE + */ + public void setNetworkType(String networkType) { + this.networkType = networkType == null ? null : networkType.trim(); + } + + /** + * return the value of network.SEGMENTATION_ID + */ + public String getSegmentationId() { + return segmentationId; + } + + /** + * This method sets the value of the database column network.SEGMENTATION_ID + * + * @param segmentationId + * the value for network.SEGMENTATION_ID + */ + public void setSegmentationId(String segmentationId) { + this.segmentationId = segmentationId == null ? null : segmentationId.trim(); + } + + /** + * + * To Entity.<br> + * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static NetworkEntity toEntity(JSONObject jsonObject) { + NetworkEntity sitesEntity = new NetworkEntity(); + sitesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + sitesEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + sitesEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId")); + sitesEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); + sitesEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + sitesEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + sitesEntity.setPhysicalNetwork(JsonUtil.getJsonFieldStr(jsonObject, "physicalNetwork")); + sitesEntity.setNetworkType(JsonUtil.getJsonFieldStr(jsonObject, "networkType")); + sitesEntity.setSegmentationId(JsonUtil.getJsonFieldStr(jsonObject, "segmentationId")); + return sitesEntity; + } + + @Override + public String toString() { + JSONObject networkJson = new JSONObject(); + networkJson.put("id", StringUtils.trimToEmpty(this.getId())); + networkJson.put("name", StringUtils.trimToEmpty(this.getName())); + networkJson.put("tenant_id", StringUtils.trimToEmpty(this.getTenantId())); + networkJson.put("status", StringUtils.trimToEmpty(this.getStatus())); + networkJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + networkJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + networkJson.put("provider:physical_network", StringUtils.trimToEmpty(this.getPhysicalNetwork())); + networkJson.put("provider:network_type", StringUtils.trimToEmpty(this.getNetworkType())); + networkJson.put("provider:segmentation_id", StringUtils.trimToEmpty(this.getSegmentationId())); + return networkJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java new file mode 100644 index 0000000..4700554 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java @@ -0,0 +1,179 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * Port Entity Class.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 31, 2016 + */ +public class PortEntity { + + private String id; + + private String name; + + private String networkId; + + private String status; + + private String tenantId; + + private String vimId; + + private String vimName; + + /** + * @return Returns the id. + */ + public String getId() { + return id; + } + + /** + * @param id The id to set. + */ + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return Returns the networkId. + */ + public String getNetworkId() { + return networkId; + } + + /** + * @param networkId The networkId to set. + */ + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + /** + * @return Returns the status. + */ + public String getStatus() { + return status; + } + + /** + * @param status The status to set. + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * @return Returns the tenantId. + */ + public String getTenantId() { + return tenantId; + } + + /** + * @param tenantId The tenantId to set. + */ + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + /** + * @return Returns the vimId. + */ + public String getVimId() { + return vimId; + } + + /** + * @param vimId The vimId to set. + */ + public void setVimId(String vimId) { + this.vimId = vimId; + } + + /** + * @return Returns the vimName. + */ + public String getVimName() { + return vimName; + } + + /** + * @param vimName The vimName to set. + */ + public void setVimName(String vimName) { + this.vimName = vimName; + } + + /** + * + * To Entity.<br> + * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static PortEntity toEntity(JSONObject jsonObject) { + PortEntity portEntity = new PortEntity(); + portEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + portEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + portEntity.setNetworkId(JsonUtil.getJsonFieldStr(jsonObject, "networkId")); + portEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); + portEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId")); + portEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + portEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + return portEntity; + } + + @Override + public String toString() { + JSONObject portResJson = new JSONObject(); + portResJson.put("id", StringUtils.trimToEmpty(this.getId())); + portResJson.put("name", StringUtils.trimToEmpty(this.getName())); + portResJson.put("networkId", StringUtils.trimToEmpty(this.getNetworkId())); + portResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); + portResJson.put("tenantId", StringUtils.trimToEmpty(this.getTenantId())); + portResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + portResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + return portResJson.toString(); + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java new file mode 100644 index 0000000..33c1942 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java @@ -0,0 +1,309 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; +import org.openo.nfvo.resmanagement.common.util.StringUtil; + +import net.sf.json.JSONObject; + +/** + * + * Sites entity class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class SitesEntity { + + private String id; + + private String name; + + private String location; + + private String country; + + private String vimId; + + private String vimName; + + private String status; + + private String totalCPU = "0"; + + private String totalMemory = "0"; + + private String totalDisk = "0"; + + private String usedCPU = "0"; + + private String usedMemory = "0"; + + private String usedDisk = "0"; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name == null ? null : name.trim(); + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location == null ? null : location.trim(); + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country == null ? null : country.trim(); + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String siteVimId) { + this.vimId = siteVimId == null ? null : siteVimId.trim(); + } + + public String getVimName() { + return vimName; + } + + public void setVimName(String siteVimName) { + this.vimName = siteVimName == null ? null : siteVimName.trim(); + } + + public String getStatus() { + return status; + } + + public void setStatus(String siteStatus) { + this.status = siteStatus == null ? null : siteStatus.trim().toLowerCase(); + } + + /** + * @return Returns the totalCPU. + */ + public String getTotalCPU() { + return totalCPU; + } + + /** + * @param totalCPU The totalCPU to set. + */ + public void setTotalCPU(String totalCPU) { + this.totalCPU = totalCPU == null ? null : totalCPU.trim(); + } + + /** + * @return Returns the totalMemory. + */ + public String getTotalMemory() { + return totalMemory; + } + + /** + * @param totalMemory The totalMemory to set. + */ + public void setTotalMemory(String totalMemory) { + this.totalMemory = totalMemory == null ? null : totalMemory.trim(); + } + + /** + * @return Returns the totalDisk. + */ + public String getTotalDisk() { + return totalDisk; + } + + /** + * @param totalDisk The totalDisk to set. + */ + public void setTotalDisk(String totalDisk) { + this.totalDisk = totalDisk == null ? null : totalDisk.trim(); + } + + /** + * @return Returns the usedCPU. + */ + public String getUsedCPU() { + return usedCPU; + } + + /** + * @param usedCPU The usedCPU to set. + */ + public void setUsedCPU(String usedCPU) { + this.usedCPU = usedCPU == null ? null : usedCPU.trim(); + } + + /** + * @return Returns the usedMemory. + */ + public String getUsedMemory() { + return usedMemory; + } + + /** + * @param usedMemory The usedMemory to set. + */ + public void setUsedMemory(String usedMemory) { + this.usedMemory = usedMemory == null ? null : usedMemory.trim(); + } + + /** + * @return Returns the usedDisk. + */ + public String getUsedDisk() { + return usedDisk; + } + + /** + * @param usedDisk The usedDisk to set. + */ + public void setUsedDisk(String usedDisk) { + this.usedDisk = usedDisk == null ? null : usedDisk.trim(); + } + + /** + * + * To Entity.<br> + * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static SitesEntity toEntity(JSONObject jsonObject) { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + sitesEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + sitesEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); + sitesEntity.setLocation(JsonUtil.getJsonFieldStr(jsonObject, "location")); + sitesEntity.setCountry(JsonUtil.getJsonFieldStr(jsonObject, "country")); + sitesEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + sitesEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + sitesEntity.setTotalCPU(JsonUtil.getJsonFieldStr(jsonObject, "totalCPU")); + sitesEntity.setTotalMemory(JsonUtil.getJsonFieldStr(jsonObject, "totalMemory")); + sitesEntity.setTotalDisk(JsonUtil.getJsonFieldStr(jsonObject, "totalDisk")); + sitesEntity.setUsedCPU(JsonUtil.getJsonFieldStr(jsonObject, "usedCPU")); + sitesEntity.setUsedMemory(JsonUtil.getJsonFieldStr(jsonObject, "usedMemory")); + sitesEntity.setUsedDisk(JsonUtil.getJsonFieldStr(jsonObject, "usedDisk")); + return sitesEntity; + } + + @Override + public String toString() { + JSONObject siteResJson = new JSONObject(); + siteResJson.put("id", StringUtils.trimToEmpty(this.getId())); + siteResJson.put("name", StringUtils.trimToEmpty(this.getName())); + siteResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); + siteResJson.put("location", StringUtils.trimToEmpty(this.getLocation())); + siteResJson.put("country", StringUtils.trimToEmpty(this.getCountry())); + siteResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + siteResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + siteResJson.put("totalCPU", StringUtils.trimToEmpty(this.getTotalCPU())); + siteResJson.put("totalMemory", StringUtils.trimToEmpty(this.getTotalMemory())); + siteResJson.put("totalDisk", StringUtils.trimToEmpty(this.getTotalDisk())); + siteResJson.put("usedCPU", StringUtils.trimToEmpty(this.getUsedCPU())); + siteResJson.put("usedMemory", StringUtils.trimToEmpty(this.getUsedMemory())); + siteResJson.put("usedDisk", StringUtils.trimToEmpty(this.getUsedDisk())); + + return siteResJson.toString(); + } + + /** + * + * Check whther the resource is zero.<br> + * + * @param siteEntity + * @return + * @since NFVO 0.5 + */ + public static boolean checkResourceIsZero(SitesEntity siteEntity) { + + if(StringUtil.isAnyLargeThanZero(siteEntity.getUsedCPU(), siteEntity.getUsedMemory(), + siteEntity.getUsedDisk())) { + return false; + } + + return true; + } + + /** + * + * Check resource.<br> + * + * @param siteEntity + * @return + * @since NFVO 0.5 + */ + public static boolean checkResource(SitesEntity siteEntity) { + String cpu = siteEntity.getTotalCPU(); + String memory = siteEntity.getTotalMemory(); + String disk = siteEntity.getTotalDisk(); + String cpuUsed = siteEntity.getUsedCPU(); + String memoryUsed = siteEntity.getUsedMemory(); + String diskUsed = siteEntity.getUsedDisk(); + + if(!StringUtil.isInteger(cpu, cpuUsed)) { + return false; + } + + if(!StringUtil.isNumeric(memory, disk, memoryUsed, diskUsed)) { + return false; + } + return true; + } + + /** + * + * Format data.<br> + * + * @param siteEntity + * @since NFVO 0.5 + */ + public static void dataFramat(SitesEntity siteEntity) { + siteEntity.setTotalCPU(StringUtil.numFormat(siteEntity.getTotalCPU())); + siteEntity.setTotalMemory(StringUtil.numFormat(siteEntity.getTotalMemory())); + siteEntity.setTotalDisk(StringUtil.numFormat(siteEntity.getTotalDisk())); + siteEntity.setUsedCPU(StringUtil.numFormat(siteEntity.getUsedCPU())); + siteEntity.setUsedMemory(StringUtil.numFormat(siteEntity.getUsedMemory())); + siteEntity.setUsedDisk(StringUtil.numFormat(siteEntity.getUsedDisk())); + + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java new file mode 100644 index 0000000..9959101 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java @@ -0,0 +1,106 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * + * Virtualised infrastructure manager entity class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class VimEntity { + + /** + * This field corresponds to the database column vim.ID + * + * @mbggenerated + */ + private String id; + + /** + * This field corresponds to the database column vim.ID + * + * @mbggenerated + */ + private String name; + + /** + * This method was generated by MyBatis Generator. This method returns the + * value of the database column vim.ID + * + * @return the value of vim.ID + */ + public String getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. This method sets the + * value of the database column vim.ID + * + * @param id + * the value for vim.ID + */ + public void setId(String id) { + this.id = id == null ? null : id.trim(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * + * To Entity.<br> + * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static VimEntity toEntity(JSONObject jsonObject) { + VimEntity vimEntity = new VimEntity(); + vimEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + vimEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + return vimEntity; + } + + /** + * + * To String.<br> + * + * @return + * @since NFVO 0.5 + */ + public String toString() { + JSONObject resJson = new JSONObject(); + resJson.put("id", StringUtils.trimToEmpty(this.getId())); + resJson.put("name", StringUtils.trimToEmpty(this.getName())); + return resJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java new file mode 100644 index 0000000..c9a38d9 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java @@ -0,0 +1,285 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-27 + */ +public class VirtualLinkEntity implements Serializable { + + /** */ + private String id; + + /** */ + private String name; + + /** */ + private String backendId; + + /** */ + private String isPublic; + + /** */ + private String dcName; + + /** */ + private String vimId; + + /** */ + private String vimName; + + /** */ + private String physicialNet; + + /** */ + private String nsId; + + /** */ + private String nsName; + + /** */ + private String description; + + /** */ + private String networkType; + + /** */ + private String segmentation; + + /** */ + private String mtu; + + /** */ + private String vlanTransparent; + + /** */ + private String routerExternal; + + /** */ + private String resourceProviderType; + + /** */ + private String resourceProviderId; + + private static final long serialVersionUID = 1L; + + 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 getBackendId() { + return backendId; + } + + public void setBackendId(String backendId) { + this.backendId = backendId; + } + + public String getIsPublic() { + return isPublic; + } + + public void setIsPublic(String isPublic) { + this.isPublic = isPublic; + } + + public String getDcName() { + return dcName; + } + + public void setDcName(String dcName) { + this.dcName = dcName; + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public String getVimName() { + return vimName; + } + + public void setVimName(String vimName) { + this.vimName = vimName; + } + + public String getPhysicialNet() { + return physicialNet; + } + + public void setPhysicialNet(String physicialNet) { + this.physicialNet = physicialNet; + } + + public String getNsId() { + return nsId; + } + + public void setNsId(String nsId) { + this.nsId = nsId; + } + + public String getNsName() { + return nsName; + } + + public void setNsName(String nsName) { + this.nsName = nsName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getNetworkType() { + return networkType; + } + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + public String getSegmentation() { + return segmentation; + } + + public void setSegmentation(String segmentation) { + this.segmentation = segmentation; + } + + public String getMtu() { + return mtu; + } + + public void setMtu(String mtu) { + this.mtu = mtu; + } + + public String getVlanTransparent() { + return vlanTransparent; + } + + public void setVlanTransparent(String vlanTransparent) { + this.vlanTransparent = vlanTransparent; + } + + public String getRouterExternal() { + return routerExternal; + } + + public void setRouterExternal(String routerExternal) { + this.routerExternal = routerExternal; + } + + public String getResourceProviderType() { + return resourceProviderType; + } + + public void setResourceProviderType(String resourceProviderType) { + this.resourceProviderType = resourceProviderType; + } + + public String getResourceProviderId() { + return resourceProviderId; + } + + public void setResourceProviderId(String resourceProviderId) { + this.resourceProviderId = resourceProviderId; + } + + /** + * <br> + * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static VirtualLinkEntity toEntity(JSONObject jsonObject) { + VirtualLinkEntity virtualLinkEntity = new VirtualLinkEntity(); + virtualLinkEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "vlInstanceId")); + virtualLinkEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + virtualLinkEntity.setBackendId(JsonUtil.getJsonFieldStr(jsonObject, "backendId")); + virtualLinkEntity.setIsPublic(JsonUtil.getJsonFieldStr(jsonObject, "isPublic")); + virtualLinkEntity.setDcName(JsonUtil.getJsonFieldStr(jsonObject, "dcName")); + virtualLinkEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + virtualLinkEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + virtualLinkEntity.setPhysicialNet(JsonUtil.getJsonFieldStr(jsonObject, "physicialNet")); + virtualLinkEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); + virtualLinkEntity.setNsName(JsonUtil.getJsonFieldStr(jsonObject, "nsName")); + virtualLinkEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description")); + virtualLinkEntity.setNetworkType(JsonUtil.getJsonFieldStr(jsonObject, "networkType")); + virtualLinkEntity.setSegmentation(JsonUtil.getJsonFieldStr(jsonObject, "segmentation")); + virtualLinkEntity.setMtu(JsonUtil.getJsonFieldStr(jsonObject, "mtu")); + virtualLinkEntity.setVlanTransparent(JsonUtil.getJsonFieldStr(jsonObject, "vlanTransparent")); + virtualLinkEntity.setRouterExternal(JsonUtil.getJsonFieldStr(jsonObject, "routerExternal")); + virtualLinkEntity.setResourceProviderId(JsonUtil.getJsonFieldStr(jsonObject, "resourceProviderId")); + virtualLinkEntity.setResourceProviderType(JsonUtil.getJsonFieldStr(jsonObject, "resourceProviderType")); + return virtualLinkEntity; + } + + @Override + public String toString() { + JSONObject virtualLinkResJson = new JSONObject(); + virtualLinkResJson.put("id", StringUtils.trimToEmpty(this.getId())); + virtualLinkResJson.put("name", StringUtils.trimToEmpty(this.getName())); + virtualLinkResJson.put("backendId", StringUtils.trimToEmpty(this.getBackendId())); + virtualLinkResJson.put("isPublic", StringUtils.trimToEmpty(this.getIsPublic())); + virtualLinkResJson.put("dcName", StringUtils.trimToEmpty(this.getDcName())); + virtualLinkResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId())); + virtualLinkResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName())); + virtualLinkResJson.put("physicialNet", StringUtils.trimToEmpty(this.getPhysicialNet())); + virtualLinkResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId())); + virtualLinkResJson.put("nsName", StringUtils.trimToEmpty(this.getNsName())); + virtualLinkResJson.put("description", StringUtils.trimToEmpty(this.getDescription())); + virtualLinkResJson.put("networkType", StringUtils.trimToEmpty(this.getNetworkType())); + virtualLinkResJson.put("segmentation", StringUtils.trimToEmpty(this.getSegmentation())); + virtualLinkResJson.put("mtu", StringUtils.trimToEmpty(this.getMtu())); + virtualLinkResJson.put("vlanTransparent", StringUtils.trimToEmpty(this.getVlanTransparent())); + virtualLinkResJson.put("routerExternal", StringUtils.trimToEmpty(this.getRouterExternal())); + virtualLinkResJson.put("resourceProviderId", StringUtils.trimToEmpty(this.getResourceProviderId())); + virtualLinkResJson.put("resourceProviderType", StringUtils.trimToEmpty(this.getResourceProviderType())); + return virtualLinkResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java new file mode 100644 index 0000000..e01cabd --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java @@ -0,0 +1,96 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-28 + */ +public class VmEntity implements Serializable { + + /** */ + private String vmId; + + /** */ + private String vmName; + + /** */ + private String vmStatus; + + /** */ + private String vnfInstanceId; + + private static final long serialVersionUID = 1L; + + public String getVmId() { + return vmId; + } + + public void setVmId(String vmId) { + this.vmId = vmId; + } + + public String getVmName() { + return vmName; + } + + public void setVmName(String vmName) { + this.vmName = vmName; + } + + public String getVmStatus() { + return vmStatus; + } + + public void setVmStatus(String vmStatus) { + this.vmStatus = vmStatus; + } + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public static VmEntity toEntity(JSONObject jsonObject) { + VmEntity vmEntity = new VmEntity(); + vmEntity.setVmId(JsonUtil.getJsonFieldStr(jsonObject, "vmId")); + vmEntity.setVmName(JsonUtil.getJsonFieldStr(jsonObject, "vmName")); + vmEntity.setVmStatus(JsonUtil.getJsonFieldStr(jsonObject, "vmStatus")); + vmEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); + return vmEntity; + } + + @Override + public String toString() { + JSONObject vmResJson = new JSONObject(); + vmResJson.put("vmId", StringUtils.trimToEmpty(this.getVmId())); + vmResJson.put("vmName", StringUtils.trimToEmpty(this.getVmName())); + vmResJson.put("vmStatus", StringUtils.trimToEmpty(this.getVmStatus())); + vmResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId())); + return vmResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java new file mode 100644 index 0000000..3a18524 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java @@ -0,0 +1,337 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-28 + */ +public class VnfEntity implements Serializable { + + /** */ + private String id; + + /** */ + private String vnfInstanceId; + + /** */ + private String vnfInstanceName; + + /** */ + private String nsId; + + /** */ + private String nsName; + + /** */ + private String vnfmId; + + /** */ + private String vnfmName; + + /** */ + private String vnfPackageName; + + /** */ + private String vnfDescriptorName; + + /** */ + private String vimId; + + /** */ + private String vimName; + + /** */ + private String vimTenant; + + /** */ + private String jobId; + + /** */ + private String vnfStatus; + + /** */ + private String vnfType; + + /** */ + private Integer maxVm; + + /** */ + private Integer maxCpu; + + /** */ + private Integer maxDisk; + + /** */ + private Integer maxRam; + + /** */ + private Integer maxShd; + + /** */ + private Integer maxNet; + + /** */ + private String name; + + private static final long serialVersionUID = 1L; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getVnfInstanceName() { + return vnfInstanceName; + } + + public void setVnfInstanceName(String vnfInstanceName) { + this.vnfInstanceName = vnfInstanceName; + } + + public String getNsId() { + return nsId; + } + + public void setNsId(String nsId) { + this.nsId = nsId; + } + + public String getNsName() { + return nsName; + } + + public void setNsName(String nsName) { + this.nsName = nsName; + } + + public String getVnfmId() { + return vnfmId; + } + + public void setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + } + + public String getVnfmName() { + return vnfmName; + } + + public void setVnfmName(String vnfmName) { + this.vnfmName = vnfmName; + } + + public String getVnfPackageName() { + return vnfPackageName; + } + + public void setVnfPackageName(String vnfPackageName) { + this.vnfPackageName = vnfPackageName; + } + + public String getVnfDescriptorName() { + return vnfDescriptorName; + } + + public void setVnfDescriptorName(String vnfDescriptorName) { + this.vnfDescriptorName = vnfDescriptorName; + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public String getVimName() { + return vimName; + } + + public void setVimName(String vimName) { + this.vimName = vimName; + } + + public String getVimTenant() { + return vimTenant; + } + + public void setVimTenant(String vimTenant) { + this.vimTenant = vimTenant; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getVnfStatus() { + return vnfStatus; + } + + public void setVnfStatus(String vnfStatus) { + this.vnfStatus = vnfStatus; + } + + public String getVnfType() { + return vnfType; + } + + public void setVnfType(String vnfType) { + this.vnfType = vnfType; + } + + public Integer getMaxVm() { + return maxVm; + } + + public void setMaxVm(Integer maxVm) { + this.maxVm = maxVm; + } + + public Integer getMaxCpu() { + return maxCpu; + } + + public void setMaxCpu(Integer maxCpu) { + this.maxCpu = maxCpu; + } + + public Integer getMaxDisk() { + return maxDisk; + } + + public void setMaxDisk(Integer maxDisk) { + this.maxDisk = maxDisk; + } + + public Integer getMaxRam() { + return maxRam; + } + + public void setMaxRam(Integer maxRam) { + this.maxRam = maxRam; + } + + public Integer getMaxShd() { + return maxShd; + } + + public void setMaxShd(Integer maxShd) { + this.maxShd = maxShd; + } + + public Integer getMaxNet() { + return maxNet; + } + + public void setMaxNet(Integer maxNet) { + this.maxNet = maxNet; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * <br> + * + * @param jsonObject + * @return + * @since NFVO 0.5 + */ + public static VnfEntity toEntity(JSONObject jsonObject) { + VnfEntity vnfEntity = new VnfEntity(); + vnfEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id")); + vnfEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name")); + vnfEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); + vnfEntity.setVnfInstanceName(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceName")); + vnfEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); + vnfEntity.setNsName(JsonUtil.getJsonFieldStr(jsonObject, "nsName")); + vnfEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId")); + vnfEntity.setVnfmName(JsonUtil.getJsonFieldStr(jsonObject, "vnfmName")); + vnfEntity.setVnfPackageName(JsonUtil.getJsonFieldStr(jsonObject, "vnfPackageName")); + vnfEntity.setVnfDescriptorName(JsonUtil.getJsonFieldStr(jsonObject, "vnfDescriptorName")); + vnfEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId")); + vnfEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName")); + vnfEntity.setVimTenant(JsonUtil.getJsonFieldStr(jsonObject, "vimTenant")); + vnfEntity.setJobId(JsonUtil.getJsonFieldStr(jsonObject, "jobId")); + vnfEntity.setVnfStatus(JsonUtil.getJsonFieldStr(jsonObject, "vnfStatus")); + vnfEntity.setVnfType(JsonUtil.getJsonFieldStr(jsonObject, "vnfType")); + vnfEntity.setMaxVm(JsonUtil.getJsonFieldInt(jsonObject, "maxVm")); + vnfEntity.setMaxCpu(JsonUtil.getJsonFieldInt(jsonObject, "maxCpu")); + vnfEntity.setMaxDisk(JsonUtil.getJsonFieldInt(jsonObject, "maxDisk")); + vnfEntity.setMaxRam(JsonUtil.getJsonFieldInt(jsonObject, "maxRam")); + vnfEntity.setMaxShd(JsonUtil.getJsonFieldInt(jsonObject, "maxShd")); + vnfEntity.setMaxNet(JsonUtil.getJsonFieldInt(jsonObject, "maxNet")); + return vnfEntity; + } + + @Override + public String toString() { + JSONObject vnfResJson = new JSONObject(); + vnfResJson.put("id", StringUtils.trimToEmpty(this.getId())); + vnfResJson.put("name", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfInstanceName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("nsId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("nsName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfmId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfmName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfPackageName", StringUtils.trimToEmpty(this.getId())); + vnfResJson.put("vnfDescriptorName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vimId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vimName", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vimTenant", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("jobId", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfStatus", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("vnfType", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxVm", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxCpu", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxDisk", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxRam", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxShd", StringUtils.trimToEmpty(this.getName())); + vnfResJson.put("maxNet", StringUtils.trimToEmpty(this.getName())); + return vnfResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java new file mode 100644 index 0000000..023f491 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java @@ -0,0 +1,83 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-28 + */ +public class VnfInfoEntity implements Serializable { + + /** */ + private String vnfInstanceId; + + /** */ + private String nsId; + + /** */ + private String vnfmId; + + private static final long serialVersionUID = 1L; + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getNsId() { + return nsId; + } + + public void setNsId(String nsId) { + this.nsId = nsId; + } + + public String getVnfmId() { + return vnfmId; + } + + public void setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + } + + public static VnfInfoEntity toEntity(JSONObject jsonObject) { + VnfInfoEntity vnfInfoEntity = new VnfInfoEntity(); + vnfInfoEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); + vnfInfoEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); + vnfInfoEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId")); + return vnfInfoEntity; + } + + @Override + public String toString() { + JSONObject vnfInfoResJson = new JSONObject(); + vnfInfoResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId())); + vnfInfoResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId())); + vnfInfoResJson.put("vnfmId", StringUtils.trimToEmpty(this.getVnfmId())); + return vnfInfoResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java new file mode 100644 index 0000000..290f264 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java @@ -0,0 +1,213 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; + +import net.sf.json.JSONObject; + +/** + * @author l00345485 + * @date 2016-10-29 + */ +public class VnfStatusEntity implements Serializable { + + /** */ + private String vnfInstanceId; + + /** */ + private String jobId; + + /** */ + private String nsId; + + /** */ + private String vnfmId; + + /** */ + private String responseDescriptor; + + /** */ + private String status; + + /** */ + private String progress; + + /** */ + private String statusDescription; + + /** */ + private String errorCode; + + /** */ + private String responseId; + + /** */ + private String responseHistoryList; + + /** */ + private String addVm; + + /** */ + private String delVm; + + private static final long serialVersionUID = 1L; + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getNsId() { + return nsId; + } + + public void setNsId(String nsId) { + this.nsId = nsId; + } + + public String getVnfmId() { + return vnfmId; + } + + public void setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + } + + public String getResponseDescriptor() { + return responseDescriptor; + } + + public void setResponseDescriptor(String responseDescriptor) { + this.responseDescriptor = responseDescriptor; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getProgress() { + return progress; + } + + public void setProgress(String progress) { + this.progress = progress; + } + + public String getStatusDescription() { + return statusDescription; + } + + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getResponseId() { + return responseId; + } + + public void setResponseId(String responseId) { + this.responseId = responseId; + } + + public String getResponseHistoryList() { + return responseHistoryList; + } + + public void setResponseHistoryList(String responseHistoryList) { + this.responseHistoryList = responseHistoryList; + } + + public String getAddVm() { + return addVm; + } + + public void setAddVm(String addVm) { + this.addVm = addVm; + } + + public String getDelVm() { + return delVm; + } + + public void setDelVm(String delVm) { + this.delVm = delVm; + } + + public static VnfStatusEntity toEntity(JSONObject jsonObject) { + VnfStatusEntity vnfStatusEntity = new VnfStatusEntity(); + vnfStatusEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId")); + vnfStatusEntity.setJobId(JsonUtil.getJsonFieldStr(jsonObject, "jobId")); + vnfStatusEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId")); + vnfStatusEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId")); + vnfStatusEntity.setResponseDescriptor(JsonUtil.getJsonFieldStr(jsonObject, "responseDescriptor")); + vnfStatusEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status")); + vnfStatusEntity.setProgress(JsonUtil.getJsonFieldStr(jsonObject, "progress")); + vnfStatusEntity.setStatusDescription(JsonUtil.getJsonFieldStr(jsonObject, "statusDescription")); + vnfStatusEntity.setErrorCode(JsonUtil.getJsonFieldStr(jsonObject, "errorCode")); + vnfStatusEntity.setResponseId(JsonUtil.getJsonFieldStr(jsonObject, "responseId")); + vnfStatusEntity.setResponseHistoryList(JsonUtil.getJsonFieldStr(jsonObject, "responseHistoryList")); + vnfStatusEntity.setAddVm(JsonUtil.getJsonFieldStr(jsonObject, "addVm")); + vnfStatusEntity.setDelVm(JsonUtil.getJsonFieldStr(jsonObject, "delVm")); + return vnfStatusEntity; + } + + @Override + public String toString() { + JSONObject vnfStatusResJson = new JSONObject(); + vnfStatusResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId())); + vnfStatusResJson.put("jobId", StringUtils.trimToEmpty(this.getJobId())); + vnfStatusResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId())); + vnfStatusResJson.put("vnfmId", StringUtils.trimToEmpty(this.getVnfmId())); + vnfStatusResJson.put("responseDescriptor", StringUtils.trimToEmpty(this.getResponseDescriptor())); + vnfStatusResJson.put("status", StringUtils.trimToEmpty(this.getStatus())); + vnfStatusResJson.put("progress", StringUtils.trimToEmpty(this.getProgress())); + vnfStatusResJson.put("statusDescription", StringUtils.trimToEmpty(this.getStatusDescription())); + vnfStatusResJson.put("errorCode", StringUtils.trimToEmpty(this.getErrorCode())); + vnfStatusResJson.put("responseId", StringUtils.trimToEmpty(this.getResponseId())); + vnfStatusResJson.put("responseHistoryList", StringUtils.trimToEmpty(this.getResponseHistoryList())); + vnfStatusResJson.put("addVm", StringUtils.trimToEmpty(this.getAddVm())); + vnfStatusResJson.put("delVm", StringUtils.trimToEmpty(this.getDelVm())); + return vnfStatusResJson.toString(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java new file mode 100644 index 0000000..4a8a633 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java @@ -0,0 +1,206 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.VimUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; +import org.openo.nfvo.resmanagement.service.group.inf.GrantResService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public class GrantResServiceImpl implements GrantResService { + + private static final Logger LOGGER = LoggerFactory.getLogger(GrantResServiceImpl.class); + + private Sites sites; + + /** + * <br> + * + * @param object + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject grantResource(JSONObject object) throws ServiceException { + LOGGER.info("function=grantResource; object: {}", object.toString()); + JSONObject additionalparam = object.getJSONObject("additionalParam"); + String vimId = additionalparam.getString("vimid"); + JSONObject vimJson = VimUtil.getVimById(vimId); + String tenant = vimJson.getString("tenant"); + JSONObject accessinfo = new JSONObject(); + accessinfo.put("tenant", tenant); + JSONObject vim = new JSONObject(); + vim.put("vimid", vimId); + vim.put("accessinfo", accessinfo); + LOGGER.info("function=grantResource; vim: {}", vim.toString()); + JSONObject result = new JSONObject(); + result.put("vim", vim); + return result; + } + + @Override + public JSONObject grantResourceReal(JSONObject object) throws ServiceException { + LOGGER.info("function=grantResource; object: {}", object.toString()); + String vimId = object.getString("vimId"); + JSONObject vimJson = VimUtil.getVimById(vimId); + JSONObject vim = parseVim(vimJson); + String resType = ""; + JSONArray resArr = new JSONArray(); + if(object.containsKey("addResource")) { + resType = "addResource"; + resArr = parseResource(object, resType); + } else if(object.containsKey("removeResource")) { + resType = "removeResource"; + resArr = parseResource(object, resType); + } + JSONObject resInfo = getResInfo(object, resType); + resInfo.put("vimId", vimId); + sites.update(resInfo); + + JSONObject result = new JSONObject(); + result.put("vim", vim); + result.put("zone", ""); + result.put("zoneGroup", ""); + result.put(resType, resArr); + result.put("tempResource", ""); + result.put("updateResource", ""); + result.put("vimAssets", new JSONObject()); + result.put("additionalParam", ""); + LOGGER.info("function=grantResource; result: {}", result.toString()); + return result; + } + + private JSONObject getResInfo(JSONObject object, String type) { + JSONArray arr = object.getJSONArray(type); + LOGGER.info("function=getResInfo; arr: {}, type: {}", arr, type); + JSONObject resourceObj = new JSONObject(); + if("addResource".equals(type)) { + resourceObj = getGrantResource(arr); + resourceObj.put("action", "online"); + } else if("removeResource".equals(type)) { + resourceObj = getGrantResource(arr); + resourceObj.put("action", "offline"); + } + LOGGER.info("function=getResInfo; resutl: {}", resourceObj.toString()); + return resourceObj; + } + + /** + * <br> + * + * @param addResource + * @return + * @since NFVO 0.5 + */ + private JSONObject getGrantResource(JSONArray resource) { + int cpuNum = 0; + int memNum = 0; + int diskNum = 0; + for(int i = 0; i < resource.size(); i++) { + JSONObject res = resource.getJSONObject(i); + JSONObject vCpu = res.getJSONObject("resourceTemplate").getJSONObject("virtualComputeDescriptor") + .getJSONObject("virtualCpu"); + int vCpuNum = vCpu.getInt("numVirtualCpu"); + JSONObject vMem = res.getJSONObject("resourceTemplate").getJSONObject("virtualComputeDescriptor") + .getJSONObject("virtualMemory"); + int vMemNum = vMem.getInt("virtualMemSize"); + JSONObject vDisk = res.getJSONObject("resourceTemplate").getJSONObject("virtualStorageDescriptor"); + int vDiskNum = vDisk.getInt("sizeOfStorage"); + cpuNum = cpuNum + vCpuNum; + memNum = memNum + vMemNum; + diskNum = diskNum + vDiskNum; + } + JSONObject obj = new JSONObject(); + obj.put("usedCPU", String.valueOf(cpuNum)); + obj.put("usedMemory", String.valueOf(memNum)); + obj.put("usedDisk", String.valueOf(diskNum)); + return obj; + } + + /** + * <br> + * + * @param object + * @return + * @since NFVO 0.5 + */ + private JSONArray parseResource(JSONObject object, String key) { + JSONArray newResources = new JSONArray(); + JSONArray oldResource = object.getJSONArray(key); + LOGGER.info("function=parseResource; Resource: {}", oldResource.toString()); + for(int i = 0; i < oldResource.size(); i++) { + JSONObject res = oldResource.getJSONObject(i); + JSONObject obj = new JSONObject(); + obj.put("reservationId", ""); + obj.put("resourceProviderId", ""); + obj.put("zoneId", ""); + obj.put("vimId", object.getString("vimId")); + obj.put("resourceDefinitionId", res.getString("resourceDefinitionId")); + newResources.add(obj); + } + LOGGER.info("function=parseResource; Parse Resource result: {}", newResources.toString()); + return newResources; + } + + /** + * <br> + * + * @param vimJson + * @return + * @since NFVO 0.5 + */ + private JSONObject parseVim(JSONObject vimJson) { + LOGGER.info("function=grantResource; vimJson: {}", vimJson.toString()); + JSONObject interfaceInfo = new JSONObject(); + interfaceInfo.put("vimType", vimJson.getString("type")); + interfaceInfo.put("apiVersion", "v2"); + interfaceInfo.put("protocolType", "http"); + JSONObject accessInfo = new JSONObject(); + accessInfo.put("tenant", vimJson.getString("tenant")); + accessInfo.put("username", vimJson.getString("userName")); + accessInfo.put("password", vimJson.getString("password")); + JSONObject vim = new JSONObject(); + vim.put("vimInfoId", vimJson.getString("vimId")); + vim.put("vimId", vimJson.getString("vimId")); + vim.put("interfaceInfo", interfaceInfo); + vim.put("accessInfo", accessInfo); + vim.put("interfaceEndpoint", vimJson.getString("url")); + return vim; + } + + /** + * @param sites The sites to set. + */ + public void setSites(Sites sites) { + this.sites = sites; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java new file mode 100644 index 0000000..0699b98 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java @@ -0,0 +1,159 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; +import org.openo.nfvo.resmanagement.common.util.RestfulUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.transaction.annotation.Transactional; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * iResource add service implementation.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class IResourceAddServiceImpl { + + private static final Logger LOGGER = LoggerFactory.getLogger(IResourceAddServiceImpl.class); + + /** + * Add iResource.<br> + * + * @param restParametes + * @param iResMap + * @throws ServiceException + * @since NFVO 0.5 + */ + @Transactional(rollbackFor = ServiceException.class) + public void addIRes(RestfulParametes restParametes, Map<String, InterfaceResManagement> iResMap) + throws ServiceException { + addIResources(iResMap, createResUrlMap(), restParametes); + } + + private void addIResources(Map<String, InterfaceResManagement> iResMap, HashMap<String, String> urlMap, + RestfulParametes restParametes) throws ServiceException { + for(String iResName : iResMap.keySet()) { + if(ParamConstant.PARAM_HOST.equals(iResName)) { + addHostResource(iResMap, restParametes, String.format(urlMap.get(iResName), + restParametes.get(ParamConstant.PARAM_VIMID), restParametes.get(ParamConstant.PARAM_TENANTID)), + iResName); + } else { + String url = String.format(urlMap.get(iResName), restParametes.get(ParamConstant.PARAM_VIMID), + restParametes.get(ParamConstant.PARAM_TENANTID)); + JSONArray iResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName); + LOGGER.warn("function=addIResources; iResArray={}", iResArray); + for(Object object : iResArray) { + JSONObject iRes = JSONObject.fromObject(object); + int result = iResMap.get(iResName).add(iRes); + LOGGER.warn("function=addIResources; msg=iRes name is [{}],result is [{}]", iResName, result); + } + } + } + } + + /** + * Add Host Resource.<br> + * + * @param iResMap + * @param restParametes + * @param url + * @param iResName + * @throws ServiceException + * @since NFVO 0.5 + */ + public static void addHostResource(Map<String, InterfaceResManagement> iResMap, RestfulParametes restParametes, + String url, String iResName) throws ServiceException { + JSONArray hostResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName); + LOGGER.warn("function=addHostResource; hostResArray={}", hostResArray); + for(Object object : hostResArray) { + JSONObject hostRes = JSONObject.fromObject(object); + String hostZone = hostRes.getString("zone"); + if("internal".equals(hostZone)) { + continue; + } + String hostName = hostRes.getString("name"); + String hostUrl = String.format(UrlConstant.GET_HOSTDETAIL_URL, restParametes.get(ParamConstant.PARAM_VIMID), + restParametes.get(ParamConstant.PARAM_TENANTID), hostName); + + String result = RestfulUtil.getResponseContent(hostUrl, new RestfulParametes(), ParamConstant.PARAM_GET); + if(result == null) { + continue; + } + JSONObject hostObj = JSONObject.fromObject(result); + JSONObject host = hostDataParse(hostObj, hostName); + int res = iResMap.get(iResName).add(host); + LOGGER.warn("function=addHostResource; result={}, res={}", result, res); + if(res < 0) { + LOGGER.error("function=addHostResource; add into DB fail!"); + } + + } + } + + /** + * <br> + * + * @param hostObj + * @param hostName + * @return + * @since NFVO 0.5 + */ + public static JSONObject hostDataParse(JSONObject hostObj, String hostName) { + LOGGER.warn("function=hostDataParse; hostObj={}, hostName={}", hostObj, hostName); + JSONArray hostArray = hostObj.getJSONArray("host"); + for(Object object : hostArray) { + JSONObject hostObject = JSONObject.fromObject(object); + if(hostObject.getString("project").contains("total")) { + String vimId = JsonUtil.getJsonFieldStr(hostObj, "vimId"); + String hostId = vimId + hostName; + JSONObject host = new JSONObject(); + host.put("id", hostId); + host.put("name", hostName); + host.put("cpu", JsonUtil.getJsonFieldStr(hostObject, "cpu")); + host.put("memory", JsonUtil.getJsonFieldStr(hostObject, "memory_mb")); + host.put("disk", JsonUtil.getJsonFieldStr(hostObject, "disk_gb")); + host.put("vimId", JsonUtil.getJsonFieldStr(hostObj, "vimId")); + host.put("vimName", JsonUtil.getJsonFieldStr(hostObj, "vimName")); + return host; + } + } + return new JSONObject(); + } + + private HashMap<String, String> createResUrlMap() { + HashMap<String, String> urlMap = new HashMap<String, String>(10); + urlMap.put(ParamConstant.PARAM_NETWORK, UrlConstant.GET_NETWORK_URL); + urlMap.put(ParamConstant.PARAM_HOST, UrlConstant.GET_HOST_URL); + urlMap.put(ParamConstant.PARAM_PORT, UrlConstant.GET_PORT_URL); + return urlMap; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java new file mode 100644 index 0000000..59cff09 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java @@ -0,0 +1,75 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Vim; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * iResource delete service implementation.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class IResourceDelServiceImpl { + + private static final Logger LOGGER = LoggerFactory.getLogger(IResourceDelServiceImpl.class); + + /** + * + * Delete iResource.<br> + * + * @param vimId + * @param iResMap + * @param vim + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + public int deleteIRes(String vimId, Map<String, InterfaceResManagement> iResMap, Vim vim) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + map.put(ParamConstant.PARAM_VIMID, vimId); + + checkIResDelResult(vimId, iResMap); + return vim.delete(vimId); + } + + private void checkIResDelResult(String vimId, Map<String, InterfaceResManagement> iResMap) throws ServiceException { + for(String keyName : iResMap.keySet()) { + if(iResMap.get(keyName).deleteResByVimId(vimId) < 0) { + LOGGER.error("function=checkIResDelResult; msg=delete {} failed,", keyName); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.delete.fail") + + keyName); + } + LOGGER.warn("function=checkIResDelResult; msg=delete {} success", keyName); + } + + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java new file mode 100644 index 0000000..b789bf9 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java @@ -0,0 +1,120 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import java.util.HashMap; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.RestfulUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.transaction.annotation.Transactional; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * iResource update service implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class IResourceUpdateServiceImpl { + + private static final Logger LOGGER = LoggerFactory.getLogger(IResourceUpdateServiceImpl.class); + + /** + * Update iResource.<br> + * + * @param vimId + * @param restParametes + * @param iResMap + * @param sites + * @throws ServiceException + * @since NFVO 0.5 + */ + @Transactional(rollbackFor = ServiceException.class) + public void updateIRes(String vimId, RestfulParametes restParametes, Map<String, InterfaceResManagement> iResMap) + throws ServiceException { + + updateIResByName(iResMap, createResUrlMap(), restParametes, vimId); + } + + private void updateIResByName(Map<String, InterfaceResManagement> iResMap, HashMap<String, String> updateUrlMap, + RestfulParametes restParametes, String vimId) throws ServiceException { + for(String resName : updateUrlMap.keySet()) { + if(ParamConstant.PARAM_HOST.equals(resName)) { + updateHostResource(iResMap, restParametes, String.format(updateUrlMap.get(resName), + restParametes.get(ParamConstant.PARAM_VIMID), restParametes.get(ParamConstant.PARAM_TENANTID)), + resName); + } else if(iResMap.get(resName).deleteResByVimId(vimId) >= 0) { + String url = String.format(updateUrlMap.get(resName), restParametes.get(ParamConstant.PARAM_VIMID), + restParametes.get(ParamConstant.PARAM_TENANTID)); + JSONArray iResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, resName); + LOGGER.warn("function=addIResources; iResArray={}", iResArray); + for(Object object : iResArray) { + JSONObject iRes = JSONObject.fromObject(object); + int result = iResMap.get(resName).add(iRes); + LOGGER.warn("function=updateIResByName; msg=iRes name is [{}],result is [{}]", resName, result); + + } + } + } + } + + private void updateHostResource(Map<String, InterfaceResManagement> iResMap, RestfulParametes restParametes, + String url, String iResName) throws ServiceException { + + JSONArray hostResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName); + LOGGER.warn("function=updateHostResource; hostResArray={}", hostResArray); + for(Object object : hostResArray) { + JSONObject hostRes = JSONObject.fromObject(object); + String hostZone = hostRes.getString("zone"); + if("internal".equals(hostZone)) { + continue; + } + String hostName = hostRes.getString("name"); + String hostUrl = String.format(UrlConstant.GET_HOSTDETAIL_URL, restParametes.get(ParamConstant.PARAM_VIMID), + restParametes.get(ParamConstant.PARAM_TENANTID), hostName); + + String result = RestfulUtil.getResponseContent(hostUrl, new RestfulParametes(), ParamConstant.PARAM_GET); + JSONObject hostObj = JSONObject.fromObject(result); + JSONObject host = IResourceAddServiceImpl.hostDataParse(hostObj, hostName); + int res = iResMap.get(ParamConstant.PARAM_HOST).update(host); + LOGGER.warn("function=updateHostResource; result={}, res={}", result, res); + if(res < 0) { + LOGGER.error("function=updateHostResource; add into DB fail!"); + } + + } + } + + private HashMap<String, String> createResUrlMap() { + HashMap<String, String> updateUrlMap = new HashMap<String, String>(10); + updateUrlMap.put(ParamConstant.PARAM_NETWORK, UrlConstant.GET_NETWORK_URL); + updateUrlMap.put(ParamConstant.PARAM_HOST, UrlConstant.GET_HOST_URL); + updateUrlMap.put(ParamConstant.PARAM_PORT, UrlConstant.GET_PORT_URL); + return updateUrlMap; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java new file mode 100644 index 0000000..788e487 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java @@ -0,0 +1,257 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.Constant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; +import org.openo.nfvo.resmanagement.common.util.RestfulUtil; +import org.openo.nfvo.resmanagement.common.util.StringUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Vim; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; +import org.openo.nfvo.resmanagement.service.entity.VimEntity; +import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.transaction.annotation.Transactional; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * Resource operation service implementation class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public class ResOperateServiceImpl implements ResOperateService { + + private static final Logger LOGGER = LoggerFactory.getLogger(ResOperateServiceImpl.class); + + private Sites sites; + + private Network network; + + private Host host; + + private Port port; + + private Vim vim; + + private IResourceAddServiceImpl iResourceAddServiceImpl; + + private IResourceUpdateServiceImpl iResourceUpdateServiceImpl; + + private IResourceDelServiceImpl iResourceDelServiceImpl; + + @Override + @Transactional(rollbackFor = ServiceException.class) + public void addIRes(String tenantId, String vimId, JSONObject header) throws ServiceException { + LOGGER.warn("function=addIRes; msg=add IResource by vimId:[{}], tenantId:[{}]", vimId, tenantId); + if(!StringUtil.isValidString(vimId) || !StringUtil.isValidString(tenantId)) { + LOGGER.warn("function=addIRes; msg=vimId[{}] is valid", vimId); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.vimId")); + } + + RestfulParametes restParametes = createRestfulParametes(tenantId, vimId, header); + HashMap<String, InterfaceResManagement> iResMap = createMap(); + + if(vim.add(vimId) <= 0) { + LOGGER.error("VimId exists"); + throw new ServiceException("VimId exists"); + } + + iResourceAddServiceImpl.addIRes(restParametes, iResMap); + } + + @Override + @Transactional(rollbackFor = ServiceException.class) + public void updateIRes(String tenantId, String vimId, JSONObject header) throws ServiceException { + if(!StringUtil.isValidString(vimId)) { + LOGGER.error("function=updateIRes; msg=vimId is not exist"); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.update.res.no.vimId")); + } + + RestfulParametes restParametes = createRestfulParametes(tenantId, vimId, header); + HashMap<String, InterfaceResManagement> iResMap = createMap(); + iResourceUpdateServiceImpl.updateIRes(vimId, restParametes, iResMap); + } + + @Override + public void updateAllIRes() throws ServiceException { + LOGGER.warn("function=updateAllIRes; msg=update all IResource"); + List<VimEntity> vims = vim.getList(); + if(vims.isEmpty()) { + LOGGER.error("function=updateAllIRes; msg=vimId is not exist"); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.update.res.no.vimId")); + } + for(VimEntity vimEntity : vims) { + String vimId = vimEntity.getId(); + LOGGER.warn("function=updateAllIRes; msg=start update vimId:{}", vimId); + updateIRes(null, vimId, new JSONObject()); + } + } + + @Override + @Transactional(rollbackFor = ServiceException.class) + public int deleteIRes(String vimId) throws ServiceException { + LOGGER.warn("function=deleteAllRes; msg=deleteResPool vimId: {}", vimId); + if(StringUtils.isEmpty(vimId)) { + LOGGER.error("function=deleteAllRes; msg=vimId is null"); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.res.no.vimId")); + } + + return iResourceDelServiceImpl.deleteIRes(vimId, createMap(), vim); + } + + private RestfulParametes createRestfulParametes(String tenantId, String vimId, JSONObject header) { + RestfulParametes restParametes = new RestfulParametes(); + restParametes.put("vimId", vimId); + restParametes.put("tenantId", tenantId); + restParametes.putHttpContextHeader("Content-Type", "application/json"); + JSONObject headers = JsonUtil.getJsonFieldJson(header, "header"); + if(null == headers || !headers.has("x-auth-token")) { + String token = "TestToken"; + LOGGER.warn("function=createRestfulParametes; msg=create token."); + restParametes.putHttpContextHeader(Constant.IAM_AUTH_TOKEN, token); + return restParametes; + } + restParametes.putHttpContextHeader(Constant.IAM_AUTH_TOKEN, + JsonUtil.getJsonFieldStr(headers, Constant.IAM_AUTH_TOKEN)); + return restParametes; + } + + private HashMap<String, InterfaceResManagement> createMap() { + HashMap<String, InterfaceResManagement> iResMap = new HashMap<String, InterfaceResManagement>(10); + iResMap.put(ParamConstant.PARAM_NETWORK, network); + iResMap.put(ParamConstant.PARAM_HOST, host); + iResMap.put(ParamConstant.PARAM_PORT, port); + return iResMap; + } + + public void setSites(Sites sites) { + this.sites = sites; + } + + public void setNetwork(Network network) { + this.network = network; + } + + public void setHost(Host host) { + this.host = host; + } + + public void setPort(Port port) { + this.port = port; + } + + public void setVim(Vim vim) { + this.vim = vim; + } + + /** + * Set iResource Add service implemtation.<br> + * + * @param iResourceAddServiceImpl + * @since NFVO 0.5 + */ + public void setiResourceAddServiceImpl(IResourceAddServiceImpl iResourceAddServiceImpl) { + this.iResourceAddServiceImpl = iResourceAddServiceImpl; + } + + /** + * Set iResource update service implementation.<br> + * + * @param iResourceUpdateServiceImpl + * @since NFVO 0.5 + */ + public void setiResourceUpdateServiceImpl(IResourceUpdateServiceImpl iResourceUpdateServiceImpl) { + this.iResourceUpdateServiceImpl = iResourceUpdateServiceImpl; + } + + /** + * Set iresource delete service implementation.<br> + * + * @param iResourceDelServiceImpl + * @since NFVO 0.5 + */ + public void setiResourceDelServiceImpl(IResourceDelServiceImpl iResourceDelServiceImpl) { + this.iResourceDelServiceImpl = iResourceDelServiceImpl; + } + + /** + * <br> + * + * @param string + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public void sendMsgMonitor(String operateType, String vimId) throws ServiceException { + LOGGER.info("Enter sendMsgMonitor!"); + Map<String, Object> map = new HashMap<>(10); + map.put("vimId", vimId); + List<HostEntity> hosts = host.getList(map); + for(HostEntity entity : hosts) { + JSONObject msgObj = new JSONObject(); + msgObj.put("operationType", operateType); + msgObj.put("resourceType", "HOST"); + msgObj.put("label", entity.getName()); + if("delete".equals(operateType)) { + JSONArray deleteIds = new JSONArray(); + deleteIds.add(entity.getId()); + msgObj.put("deleteIds", deleteIds); + } else { + JSONArray data = new JSONArray(); + JSONObject obj = JSONObject.fromObject(entity); + obj.put("oid", entity.getId()); + obj.put("moc", "nfv.host.linux"); + data.add(obj); + msgObj.put("data", data); + } + RestfulParametes restfulParametes = new RestfulParametes(); + Map<String, String> headerMap = new HashMap<>(3); + headerMap.put("Content-Type", "application/json"); + restfulParametes.setHeaderMap(headerMap); + restfulParametes.setRawData(msgObj.toString()); + LOGGER.info("sendMsgMonitor msgObj: {}", msgObj); + String result = RestfulUtil.getResponseContent(UrlConstant.SEND_MSG_MONITOR, restfulParametes, + ParamConstant.PARAM_POST); + LOGGER.warn(result); + } + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java new file mode 100644 index 0000000..5dd726c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java @@ -0,0 +1,123 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.service.dao.inf.VirtualLinkDao; +import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VirtualLinkService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 27, 2016 + */ +public class VirtualLinkServiceImpl implements VirtualLinkService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkServiceImpl.class); + + private VirtualLinkDao virtualLinkDao; + + /** + * <br> + * + * @param virtualLinkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException { + if(!checkId(virtualLinkEntity.getId())) { + LOGGER.error("function=addVl; msg=add error, because id is already exist."); + throw new ServiceException(ResourceUtil + .getMessage("org.openo.nfvo.resmanagement.service.group.impl.VirtualLinkServiceImpl.add.id.check")); + } + if(StringUtils.isEmpty(virtualLinkEntity.getId())) { + virtualLinkEntity.setId(UUID.randomUUID().toString()); + } + int result = virtualLinkDao.addVl(virtualLinkEntity); + JSONObject restJson = new JSONObject(); + if(result > 0) { + restJson.put("id", virtualLinkEntity.getId()); + restJson.put("name", virtualLinkEntity.getName()); + } else { + LOGGER.error("function=addVl; msg=add vl into DB error."); + restJson.put("message", "Add Vl into DB error."); + } + return restJson; + + } + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String id) { + VirtualLinkEntity vl = virtualLinkDao.getVl(id); + if(null == vl) { + return true; + } + return false; + } + + /** + * <br> + * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List<VirtualLinkEntity> getList(Map<String, Object> map) throws ServiceException { + return virtualLinkDao.getVls(map); + } + + /** + * <br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + return virtualLinkDao.deleteVlById(id); + } + + public void setVirtualLinkDao(VirtualLinkDao virtualLinkDao) { + this.virtualLinkDao = virtualLinkDao; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java new file mode 100644 index 0000000..51ec0dd --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java @@ -0,0 +1,177 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.RestfulUtil; +import org.openo.nfvo.resmanagement.service.dao.inf.VmDao; +import org.openo.nfvo.resmanagement.service.entity.VmEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VmService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public class VmServiceImpl implements VmService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VmServiceImpl.class); + + private VmDao vmDao; + + /** + * <br> + * + * @param vmEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVm(VmEntity vmEntity) throws ServiceException { + int result; + if(!checkId(vmEntity.getVmId())) { + result = vmDao.updateVm(vmEntity); + sendMsgMonitor("create", vmEntity); + } else { + if(StringUtils.isEmpty(vmEntity.getVmId())) { + vmEntity.setVmId(UUID.randomUUID().toString()); + } + result = vmDao.addVm(vmEntity); + sendMsgMonitor("update", vmEntity); + } + JSONObject restJson = new JSONObject(); + if(result > 0) { + restJson.put("id", vmEntity.getVmId()); + restJson.put("name", vmEntity.getVmName()); + } else { + LOGGER.error("function=addVm; msg=add vm into DB error."); + restJson.put("message", "Add vm into DB error."); + } + return restJson; + } + + /** + * <br> + * + * @param vmId + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String vmId) { + VmEntity vm = vmDao.getVm(vmId); + if(null == vm) { + return true; + } + return false; + } + + public void sendMsgMonitor(String operateType, VmEntity vmEntity) throws ServiceException { + JSONObject msgObj = new JSONObject(); + msgObj.put("operationType", operateType); + msgObj.put("resourceType", "VDU"); + msgObj.put("label", vmEntity.getVmName()); + if("delete".equals(operateType)) { + JSONArray deleteIds = new JSONArray(); + deleteIds.add(vmEntity.getVmId()); + msgObj.put("deleteIds", deleteIds); + } else { + JSONArray data = new JSONArray(); + JSONObject obj = JSONObject.fromObject(vmEntity); + obj.put("oid", vmEntity.getVmId()); + obj.put("moc", "nfv.vdu.linux"); + data.add(obj); + msgObj.put("data", data); + } + LOGGER.info("sendMsgMonitor msgObj: {}", msgObj); + RestfulParametes restfulParametes = new RestfulParametes(); + Map<String, String> headerMap = new HashMap<>(3); + headerMap.put("Content-Type", "application/json"); + restfulParametes.setHeaderMap(headerMap); + restfulParametes.setRawData(msgObj.toString()); + String result = RestfulUtil.getResponseContent(UrlConstant.SEND_MSG_MONITOR, restfulParametes, + ParamConstant.PARAM_POST); + LOGGER.warn(result); + + } + + /** + * <br> + * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List<VmEntity> getList(Map<String, Object> map) throws ServiceException { + return vmDao.getVms(map); + } + + /** + * <br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + return vmDao.deleteVmById(id); + } + + public void setVmDao(VmDao vmDao) { + this.vmDao = vmDao; + } + + /** + * <br> + * + * @param vnfInstanceId + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int deleteByVnfId(String vnfInstanceId) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + map.put("vnfInstanceId", vnfInstanceId); + List<VmEntity> vms = vmDao.getVms(map); + for(int i = 0; i < vms.size(); i++) { + VmEntity vm = vms.get(i); + sendMsgMonitor("delete", vm); + } + return vmDao.deleteVmByVnfId(vnfInstanceId); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java new file mode 100644 index 0000000..fb34127 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java @@ -0,0 +1,150 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.dao.inf.VnfInfoDao; +import org.openo.nfvo.resmanagement.service.entity.VmEntity; +import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VmService; +import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VnfInfoServiceImpl implements VnfInfoService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfInfoServiceImpl.class); + + private VnfInfoDao vnfInfoDao; + + private VmService vmService; + + /** + * <br> + * + * @param object + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVnfInfo(JSONObject object) throws ServiceException { + LOGGER.info("function=addVnfInfo; object: {}", object); + saveVm(object); + JSONObject vnf = new JSONObject(); + vnf.put("vnfInstanceId", object.get("vnfInstanceId")); + vnf.put("nsId", object.get("nsId")); + vnf.put("vnfmId", object.get("vnfmId")); + VnfInfoEntity vnfInfoEntity = VnfInfoEntity.toEntity(vnf); + int result; + if(!checkId(vnfInfoEntity.getVnfInstanceId())) { + result = vnfInfoDao.updateVnfInfo(vnfInfoEntity); + } else { + result = vnfInfoDao.addVnfInfo(vnfInfoEntity); + } + JSONObject resultObj = new JSONObject(); + if(result > 0) { + resultObj.put("vnfInstanceId", object.get("vnfInstanceId")); + } else { + LOGGER.error("function=addVnfInfo; msg=add vnfInfo into DB error."); + resultObj.put("message", "Add vnfInfo into DB error."); + } + return resultObj; + } + + /** + * <br> + * + * @param vnfInstanceId + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String vnfInstanceId) { + VnfInfoEntity vnf = vnfInfoDao.getVnfInfo(vnfInstanceId); + if(null == vnf) { + return true; + } + return false; + } + + /** + * <br> + * + * @param object + * @throws ServiceException + * @since NFVO 0.5 + */ + private void saveVm(JSONObject object) throws ServiceException { + String vnfInstanceId = object.getString("vnfInstanceId"); + JSONArray vms = object.getJSONArray("vms"); + for(int i = 0; i < vms.size(); i++) { + JSONObject vmObj = vms.getJSONObject(i); + vmObj.put("vnfInstanceId", vnfInstanceId); + vmService.addVm(VmEntity.toEntity(vmObj)); + } + + } + + /** + * <br> + * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List<VnfInfoEntity> getList(Map<String, Object> map) throws ServiceException { + return vnfInfoDao.getVnfInfos(map); + } + + /** + * <br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + vmService.deleteByVnfId(id); + return vnfInfoDao.deleteVnfInfoById(id); + } + + public void setVnfInfoDao(VnfInfoDao vnfInfoDao) { + this.vnfInfoDao = vnfInfoDao; + } + + public void setVmService(VmService vmService) { + this.vmService = vmService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java new file mode 100644 index 0000000..3a1a02e --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java @@ -0,0 +1,141 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.apache.commons.lang3.StringUtils; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.service.dao.inf.VnfDao; +import org.openo.nfvo.resmanagement.service.entity.VnfEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService; +import org.openo.nfvo.resmanagement.service.group.inf.VnfService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public class VnfServiceImpl implements VnfService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfServiceImpl.class); + + private VnfDao vnfDao; + + private VnfInfoService vnfInfoService; + + /** + * <br> + * + * @param vnfEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException { + if(!checkId(vnfEntity.getId())) { + LOGGER.error("function=addVnf; msg=add error, because id is already exist."); + throw new ServiceException(ResourceUtil + .getMessage("org.openo.nfvo.resmanagement.service.group.impl.VnfServiceImpl.add.id.check")); + } + if(StringUtils.isEmpty(vnfEntity.getId())) { + vnfEntity.setId(UUID.randomUUID().toString()); + } + int result = vnfDao.addVnf(vnfEntity); + JSONObject restJson = new JSONObject(); + if(result > 0) { + restJson.put("id", vnfEntity.getId()); + restJson.put("name", vnfEntity.getName()); + } else { + LOGGER.error("function=addVnf; msg=add vnf into DB error."); + restJson.put("message", "Add vnf into DB error."); + } + return restJson; + } + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String id) { + VnfEntity vnf = vnfDao.getVnf(id); + if(null == vnf) { + return true; + } + return false; + } + + /** + * <br> + * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List<VnfEntity> getList(Map<String, Object> map) throws ServiceException { + return vnfDao.getVnfs(map); + } + + /** + * <br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + deleteVnfInfo(id); + return vnfDao.deleteVnfById(id); + } + + /** + * <br> + * + * @param id + * @throws ServiceException + * @since NFVO 0.5 + */ + private void deleteVnfInfo(String vnfInstanceId) throws ServiceException { + vnfInfoService.delete(vnfInstanceId); + } + + public void setVnfDao(VnfDao vnfDao) { + this.vnfDao = vnfDao; + } + + public void setVnfInfoService(VnfInfoService vnfInfoService) { + this.vnfInfoService = vnfInfoService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java new file mode 100644 index 0000000..7e37561 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java @@ -0,0 +1,117 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.impl; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.dao.inf.VnfStatusDao; +import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VnfStatusService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public class VnfStatusServiceImpl implements VnfStatusService { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfStatusServiceImpl.class); + + private VnfStatusDao vnfStatusDao; + + /** + * <br> + * + * @param object + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public JSONObject addVnfStatus(JSONObject object) throws ServiceException { + LOGGER.info("function=addVnfStatus; object: {}", object); + VnfStatusEntity vnfStatusEntity = VnfStatusEntity.toEntity(object); + int result; + if(!checkId(vnfStatusEntity.getVnfInstanceId())) { + result = vnfStatusDao.updateVnfStatus(vnfStatusEntity); + } else { + result = vnfStatusDao.addVnfStatus(vnfStatusEntity); + } + JSONObject resultObj = new JSONObject(); + if(result > 0) { + resultObj.put("vnfInstanceId", object.get("vnfInstanceId")); + } else { + LOGGER.error("function=addVnfStatus; msg=add vnfStatus into DB error."); + resultObj.put("message", "Add vnfStatus into DB error."); + } + return resultObj; + } + + /** + * <br> + * + * @param vnfInstanceId + * @return + * @since NFVO 0.5 + */ + private boolean checkId(String vnfInstanceId) { + VnfStatusEntity vnfStatus = vnfStatusDao.getVnfStatus(vnfInstanceId); + if(null == vnfStatus) { + return true; + } + return false; + } + + /** + * <br> + * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public List<VnfStatusEntity> getList(Map<String, Object> map) throws ServiceException { + return vnfStatusDao.getVnfStatuss(map); + } + + /** + * <br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @Override + public int delete(String id) throws ServiceException { + return vnfStatusDao.deleteVnfStatusById(id); + } + + public void setVnfStatusDao(VnfStatusDao vnfStatusDao) { + this.vnfStatusDao = vnfStatusDao; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java new file mode 100644 index 0000000..4c52b9c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public interface GrantResService { + + /** + * <br> + * + * @param object + * @return + * @since NFVO 0.5 + */ + JSONObject grantResource(JSONObject object) throws ServiceException; + + JSONObject grantResourceReal(JSONObject object) throws ServiceException; + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java new file mode 100644 index 0000000..7e2069f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java @@ -0,0 +1,82 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.inf; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +import net.sf.json.JSONObject; + +/** + * resource operational service class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface ResOperateService { + + /** + * Update iresource.<br> + * + * @param tenantId + * @param vimId + * @param header + * @throws ServiceException + * @since NFVO 0.5 + */ + void updateIRes(String tenantId, String vimId, JSONObject header) throws ServiceException; + + /** + * Update all iResource.<br> + * + * @throws ServiceException + * @since NFVO 0.5 + */ + void updateAllIRes() throws ServiceException; + + /** + * Add iResource.<br> + * + * @param tenantId + * @param vimId + * @param header + * @throws ServiceException + * @since NFVO 0.5 + */ + void addIRes(String tenantId, String vimId, JSONObject header) throws ServiceException; + + /** + * Delete iResource.<br> + * + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int deleteIRes(String vimId) throws ServiceException; + + /** + * <br> + * + * @param operateType + * @param vimId + * @throws ServiceException + * @since NFVO 0.5 + */ + void sendMsgMonitor(String operateType, String vimId) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java new file mode 100644 index 0000000..cd1ea93 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java @@ -0,0 +1,64 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 27, 2016 + */ +public interface VirtualLinkService { + + /** + * <br> + * + * @param virtualLinkEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException; + + /** + * <br> + * + * @param map + * @return + * @since NFVO 0.5 + */ + List<VirtualLinkEntity> getList(Map<String, Object> map) throws ServiceException; + + /** + * <br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + int delete(String id) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java new file mode 100644 index 0000000..668f9d3 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.VmEntity; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public interface VmService { + + JSONObject addVm(VmEntity vmEntity) throws ServiceException; + + List<VmEntity> getList(Map<String, Object> map) throws ServiceException; + + int delete(String id) throws ServiceException; + + int deleteByVnfId(String vnfInstanceId) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java new file mode 100644 index 0000000..6e736d6 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VnfInfoService { + + JSONObject addVnfInfo(JSONObject object) throws ServiceException; + + List<VnfInfoEntity> getList(Map<String, Object> map) throws ServiceException; + + int delete(String id) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java new file mode 100644 index 0000000..4fbe45e --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.VnfEntity; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +public interface VnfService { + + /** + * <br> + * + * @param vnfEntity + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException; + + /** + * <br> + * + * @param map + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + List<VnfEntity> getList(Map<String, Object> map) throws ServiceException; + + /** + * <br> + * + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + int delete(String id) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java new file mode 100644 index 0000000..cdc826c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.group.inf; + +import java.util.List; +import java.util.Map; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +public interface VnfStatusService { + + JSONObject addVnfStatus(JSONObject object) throws ServiceException; + + List<VnfStatusEntity> getList(Map<String, Object> map) throws ServiceException; + + int delete(String id) throws ServiceException; +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java new file mode 100644 index 0000000..643c581 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.HostEntity; + +/** + * Host info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface HostMapper { + + /** + * It is used to get Host info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + HostEntity getHost(String id); + + /** + * It is used to get Hosts info.<br/> + * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List<HostEntity> getHosts(Map<String, Object> condition); + + /** + * It is used to delete Hosts info.<br/> + * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deleteHost(String id); + + /** + * It is used to delete Hosts info.<br/> + * + * @param vimId + * @return The delete result + * @since NFVO 0.5 + */ + int deleteHostByVimId(String vimId); + + /** + * It is used to add Hosts info. <br/> + * + * @param hostEntity + * @return The add result + * @since NFVO 0.5 + */ + int addHost(HostEntity hostEntity); + + /** + * It is used to add Hosts info. <br/> + * + * @param hostEntity + * @return The add result + * @since NFVO 0.5 + */ + int addHostSelective(HostEntity hostEntity); + + /** + * It is used to update Hosts info. <br/> + * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHostSelective(HostEntity hostEntity); + + /** + * It is used to update Hosts info. <br/> + * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHost(HostEntity hostEntity); + + /** + * It is used to update Hosts info. <br/> + * + * @param hostEntity + * @return The update result + * @since NFVO 0.5 + */ + int updateHostByVimId(HostEntity hostEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java new file mode 100644 index 0000000..2a2ec5c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java @@ -0,0 +1,123 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; + +/** + * + * Location Mapper Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface LocationMapper { + + /** + * + * Get location.<br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + LocationEntity getLocation(String id); + + /** + * + * Get Country.<br> + * + * @return + * @since NFVO 0.5 + */ + List<String> getCountry(); + + /** + * + * Get location by country.<br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<String> getLocationByCountry(Map<String, Object> condition); + + /** + * + * get locations.<br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<LocationEntity> getLocations(Map<String, Object> condition); + + /** + * + * Delete location.<br> + * + * @param location + * @return + * @since NFVO 0.5 + */ + int deleteLocation(String location); + + /** + * + * Add location.<br> + * + * @param locationEntity + * @return + * @since NFVO 0.5 + */ + int addLocation(LocationEntity locationEntity); + + /** + * + * Add selective location.<br> + * + * @param locationEntity + * @return + * @since NFVO 0.5 + */ + int addLocationSelective(LocationEntity locationEntity); + + /** + * + * Update selective location.<br> + * + * @param locationEntity + * @return + * @since NFVO 0.5 + */ + int updateLocationSelective(LocationEntity locationEntity); + + /** + * + * Update location.<br> + * + * @param locationEntity + * @return + * @since NFVO 0.5 + */ + int updateLocation(LocationEntity locationEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java new file mode 100644 index 0000000..b727f4f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java @@ -0,0 +1,125 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; + +/** + * + * Network Mapper Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +public interface NetworkMapper { + + /** + * + * Get network details.<br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + NetworkEntity getNetwork(String id); + + /** + * + * Get details of networks.<br> + * + * @param condition + * @return + * @since NFVO 0.5 + */ + List<NetworkEntity> getNetworks(Map<String, Object> condition); + + /** + * + * Delete network.<br> + * + * @param id + * @return + * @since NFVO 0.5 + */ + int deleteNetwork(String id); + + /** + * + * Delete network by VIM ID.<br> + * + * @param vimId + * @return + * @since NFVO 0.5 + */ + int deleteNetworkByVimId(String vimId); + + /** + * + * Add network.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int addNetwork(NetworkEntity networkEntity); + + /** + * + * Add selective network.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int addNetworkSelective(NetworkEntity networkEntity); + + /** + * + * Update selective network.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetworkSelective(NetworkEntity networkEntity); + + /** + * + * Update network.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetwork(NetworkEntity networkEntity); + + /** + * + * Update network by VIM Id.<br> + * + * @param networkEntity + * @return + * @since NFVO 0.5 + */ + int updateNetworkByVimId(NetworkEntity networkEntity); + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java new file mode 100644 index 0000000..9cae421 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java @@ -0,0 +1,114 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.PortEntity; + +/** + * Port info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface PortMapper { + + /** + * It is used to get Port info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + PortEntity getPort(String id); + + /** + * It is used to get Ports info.<br/> + * + * @param condition + * @return The get result + * @since NFVO 0.5 + */ + List<PortEntity> getPorts(Map<String, Object> condition); + + /** + * It is used to delete Ports info.<br/> + * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deletePort(String id); + + /** + * It is used to delete Ports info.<br/> + * + * @param vimId + * @return The delete result + * @since NFVO 0.5 + */ + int deletePortByVimId(String vimId); + + /** + * It is used to add Ports info. <br/> + * + * @param portEntity + * @return The add result + * @since NFVO 0.5 + */ + int addPort(PortEntity portEntity); + + /** + * It is used to add Ports info. <br/> + * + * @param portEntity + * @return The add result + * @since NFVO 0.5 + */ + int addPortSelective(PortEntity portEntity); + + /** + * It is used to update Ports info. <br/> + * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePortSelective(PortEntity portEntity); + + /** + * It is used to update Ports info. <br/> + * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePort(PortEntity portEntity); + + /** + * It is used to update Ports info. <br/> + * + * @param portEntity + * @return The update result + * @since NFVO 0.5 + */ + int updatePortByVimId(PortEntity portEntity); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java new file mode 100644 index 0000000..e86d5e1 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java @@ -0,0 +1,111 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; + +/** + * ResPool info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface SitesMapper { + + /** + * It is used to get Sites info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + SitesEntity getSite(String id); + + /** + * + * It is used to get Sites info.<br> + * + * @param map + * @return + * @since NFVO 0.5 + */ + List<SitesEntity> getSites(Map<String, Object> map); + + /** + * It is used to get Sites info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + int deleteSite(String id); + + /** + * + * It is used to delete Site info.<br> + * + * @param entity + * @return + * @since NFVO 0.5 + */ + int addSite(SitesEntity entity); + + /** + * + * It is used to add Sites info.<br> + * + * @param entity + * @return + * @since NFVO 0.5 + */ + int addSiteSelective(SitesEntity entity); + + /** + * + * It is used to add Site info.<br> + * + * @param entity + * @return + * @since NFVO 0.5 + */ + int updateSiteSelective(SitesEntity entity); + + /** + * + * It is used to update Sites info.<br> + * + * @param entity + * @return + * @since NFVO 0.5 + */ + int updateSite(SitesEntity entity); + + /** + * + * It is used to update Site info.<br> + * + * @param entity + * @return + * @since NFVO 0.5 + */ + int updateSiteByVimId(SitesEntity entity); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java new file mode 100644 index 0000000..1c4573a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java @@ -0,0 +1,68 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; + +import org.openo.nfvo.resmanagement.service.entity.VimEntity; + +/** + * Vim info interface.<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +public interface VimMapper { + + /** + * It is used to get Vim info.<br/> + * + * @param id + * @return The get result + * @since NFVO 0.5 + */ + VimEntity getVim(String id); + + /** + * It is used to get Vims info.<br/> + * + * @return The get result + * @since NFVO 0.5 + */ + List<VimEntity> getVims(); + + /** + * It is used to delete Vim info.<br/> + * + * @param id + * @return The delete result + * @since NFVO 0.5 + */ + int deleteVim(String id); + + /** + * It is used to add Vim info.<br/> + * + * @param vimEntity + * @return The add result + * @since NFVO 0.5 + */ + int addVim(VimEntity vimEntity); + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java new file mode 100644 index 0000000..c4cba74 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; + +public interface VirtualLinkMapper { + + int deleteByPrimaryKey(String id); + + int insert(VirtualLinkEntity record); + + int insertSelective(VirtualLinkEntity record); + + VirtualLinkEntity selectByPrimaryKey(String id); + + List<VirtualLinkEntity> getVls(Map<String, Object> condition); + + int updateByPrimaryKeySelective(VirtualLinkEntity record); + + int updateByPrimaryKey(VirtualLinkEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java new file mode 100644 index 0000000..4cb4878 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java @@ -0,0 +1,41 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VmEntity; + +public interface VmMapper { + + int deleteByPrimaryKey(String vmId); + + int deleteByVnfId(String vnfInstanceId); + + int insert(VmEntity record); + + int insertSelective(VmEntity record); + + VmEntity selectByPrimaryKey(String vmId); + + List<VmEntity> getVms(Map<String, Object> condition); + + int updateByPrimaryKeySelective(VmEntity record); + + int updateByPrimaryKey(VmEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java new file mode 100644 index 0000000..45d4f45 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; + +public interface VnfInfoMapper { + + int deleteByPrimaryKey(String vnfInstanceId); + + int insert(VnfInfoEntity record); + + int insertSelective(VnfInfoEntity record); + + VnfInfoEntity selectByPrimaryKey(String vnfInstanceId); + + List<VnfInfoEntity> getVnfInfos(Map<String, Object> condition); + + int updateByPrimaryKeySelective(VnfInfoEntity record); + + int updateByPrimaryKey(VnfInfoEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java new file mode 100644 index 0000000..5d0078f --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VnfEntity; + +public interface VnfMapper { + + int deleteByPrimaryKey(String vnfInstanceId); + + int insert(VnfEntity record); + + int insertSelective(VnfEntity record); + + VnfEntity selectByPrimaryKey(String id); + + List<VnfEntity> getVnfs(Map<String, Object> condition); + + int updateByPrimaryKeySelective(VnfEntity record); + + int updateByPrimaryKey(VnfEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java new file mode 100644 index 0000000..c7e5c7a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.mapper; + +import java.util.List; +import java.util.Map; + +import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; + +public interface VnfStatusMapper { + + int deleteByPrimaryKey(String vnfInstanceId); + + int insert(VnfStatusEntity record); + + int insertSelective(VnfStatusEntity record); + + VnfStatusEntity selectByPrimaryKey(String vnfInstanceId); + + List<VnfStatusEntity> getVnfStatuss(Map<String, Object> condition); + + int updateByPrimaryKeySelective(VnfStatusEntity record); + + int updateByPrimaryKey(VnfStatusEntity record); +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java new file mode 100644 index 0000000..47a9a02 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java @@ -0,0 +1,94 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.service.group.inf.GrantResService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +@Path(UrlConstant.GRANTRES_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class GrantResourseRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(GrantResourseRoa.class); + + private GrantResService grantResService; + + @PUT + @Path("/stub") + public JSONObject grantResource(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=grantResource; msg=grantResource error, because body is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.grantResource.null")); + } + + LOGGER.info("GrantResourseRoa::grantResource:{}", object.toString()); + try { + return grantResService.grantResource(object); + } catch(ServiceException se) { + LOGGER.error("GrantResourseRoa::grantResource error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @PUT + public JSONObject grantResourceReal(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=grantResource; msg=grantResource error, because body is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.grantResource.null")); + } + + LOGGER.info("GrantResourseRoa::grantResource:{}", object.toString()); + try { + return grantResService.grantResourceReal(object); + } catch(ServiceException se) { + LOGGER.error("GrantResourseRoa::grantResource error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setGrantResService(GrantResService grantResService) { + this.grantResService = grantResService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java new file mode 100644 index 0000000..98e7da0 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java @@ -0,0 +1,183 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +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.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * + * Host ROA Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.HOST_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class HostRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(HostRoa.class); + + private Host host; + + /** + * + * Get hosts.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getHosts(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + List<HostEntity> hosts = host.getList(map); + + JSONObject result = new JSONObject(); + result.put("hosts", hosts); + return result; + } + + /** + * + * Get host.<br> + * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/{hostId}") + public JSONObject getHost(@Context HttpServletRequest context, @PathParam("hostId") String id) + throws ServiceException { + LOGGER.info("HostRoa::getHost id:{}", id); + Map<String, Object> map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List<HostEntity> hosts = host.getList(map); + + JSONObject result = new JSONObject(); + result.put("hosts", hosts); + return result; + } + + /** + * + * Add host.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + public JSONObject addHost(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("HostRoa::addHost:{}", object.toString()); + try { + int result = host.add(object); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("HostRoa::addHost error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Delete host.<br> + * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + public JSONObject deleteHost(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + LOGGER.info("HostRoa::deleteHost id:{}", id); + try { + int result = host.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("HostRoa::deleteHost error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Update host.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + public JSONObject updateHost(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("HostRoa::updateHost:{}", object.toString()); + try { + int result = host.update(object); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("HostRoa::updateHost error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setHost(Host host) { + this.host = host; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java new file mode 100644 index 0000000..5275dfe --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java @@ -0,0 +1,73 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.LIMITS_URL) +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class LimitsRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(LimitsRoa.class); + + private LimitsBusiness limitsBusiness; + + /** + * <br> + * + * @param context + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getLimits(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { + LOGGER.warn("function=getLimits, vimId={}", vimId); + return limitsBusiness.getLimits(vimId); + } + + public void setLimitsBusiness(LimitsBusiness limitsBusiness) { + this.limitsBusiness = limitsBusiness; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java new file mode 100644 index 0000000..f3bb351 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java @@ -0,0 +1,316 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +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.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Location; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * Location ROA Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.LOCATION_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class LocationRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(LocationRoa.class); + + private Location location; + + private Sites sites; + + /** + * Get Locations Base.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getLocationsbase(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> condition = new HashMap<>(); + List<LocationEntity> locations = location.get(condition); + + JSONObject result = new JSONObject(); + result.put("locations", locations); + return result; + } + + /** + * Get Locations Base.<br> + * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/{locationId}") + public JSONObject getLocationbase(@Context HttpServletRequest context, @PathParam("locationId") String id) + throws ServiceException { + LOGGER.info("LocationRoa::getLocationbase id:{}", id); + Map<String, Object> map = new HashMap<>(); + map.put(ParamConstant.PARAM_ID, id); + List<LocationEntity> locations = location.get(map); + + JSONObject result = new JSONObject(); + result.put("locations", locations); + return result; + } + + /** + * Get Country.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/country") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject getCountry(@Context HttpServletRequest context) throws ServiceException { + return RoaResponseUtil.get(location.getCountry()); + } + + /** + * Get Location by Country.<br> + * + * @param context + * @param country + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/locationbycountry") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject getLocationByCountry(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_COUNTRY) String country) throws ServiceException { + LOGGER.info("LocationRoa::getLocationByCountry country:{}", country); + Map<String, Object> condition = new HashMap<>(); + condition.put(ParamConstant.PARAM_COUNTRY, country); + return RoaResponseUtil.get(location.getLocationByCountry(condition)); + } + + /** + * Get Cloud Service.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/cloudservice") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject getCloudservice(@Context HttpServletRequest context) throws ServiceException { + return RoaResponseUtil.get(location.getCloudservice()); + } + + /** + * Get location details.<br> + * + * @param context + * @param locations + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/site") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject getLocation(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_LOCATION) String locations) throws ServiceException { + LOGGER.info("LocationRoa::getLocation locations:{}", locations); + Map<String, Object> condition = new HashMap<>(); + List<LocationEntity> loca = new ArrayList<LocationEntity>(); + condition.put(ParamConstant.PARAM_LOCATION, locations); + loca = location.get(condition); + LOGGER.info("LocationRoa::getLocation loca:{}", loca); + return RoaResponseUtil.get(location.getLocationInfo(loca)); + } + + /** + * Add Location.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject addLocation(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("LocationRoa::addLocation : " + object.toString()); + try { + int result = location.add(object); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("LocationRoa::addLocation error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Delete Location Base.<br> + * + * @param context + * @param locations + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + @Path("/{location}") + public JSONObject deleteLocationbase(@Context HttpServletRequest context, + @PathParam(ParamConstant.PARAM_LOCATION) String locations) throws ServiceException { + LOGGER.info("LocationRoa::deleteLocation locations:{}", locations); + Map<String, Object> condition = new HashMap<>(); + condition.put(ParamConstant.PARAM_LOCATION, locations); + try { + int result = location.delete(locations); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("LocationRoa::deleteLocationbase error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Delete Location.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject deleteLocation(@Context HttpServletRequest context) throws ServiceException { + + JSONObject object = RequestUtil.getJsonRequestBody(context); + String locations = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_LOCATION); + String id = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_ID); + LOGGER.info("LocationRoa::deleteLocation locations:{}", locations); + + Map<String, Object> condition = new HashMap<>(); + condition.put(ParamConstant.PARAM_LOCATION, locations); + SitesEntity sitesEntity = sites.get(condition); + try { + if(sitesEntity != null) { + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.delete.used.check")); + } + int result = location.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("LocationRoa::deleteLocation error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Update Location.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject updateLocation(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + String local = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_LOCATION); + Map<String, Object> localInfo = new HashMap<>(); + localInfo.put(ParamConstant.PARAM_LOCATION, local); + SitesEntity sitesEntity = sites.get(localInfo); + if(sitesEntity != null) { + LOGGER.error("function=updateLocation; msg=update error, because location is used."); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.used.check")); + } + LOGGER.info("LocationRoa::updateLocation : " + object.toString()); + + try { + int result = location.update(object); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("LocationRoa::update Location error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setLocation(Location location) { + this.location = location; + } + + public void setSites(Sites sites) { + this.sites = sites; + } + +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java new file mode 100644 index 0000000..8a3e0bd --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java @@ -0,0 +1,189 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +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.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * + * Network ROA Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.NETWORKS_URL) +@Consumes({MediaType.APPLICATION_JSON}) +@Produces({MediaType.APPLICATION_JSON}) +public class NetworkRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(NetworkRoa.class); + + private Network network; + + /** + * + * Get details of networks.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getNetworks(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + List<NetworkEntity> networks = network.getList(map); + + JSONObject result = new JSONObject(); + result.put("networks", networks.toString()); + return result; + } + + /** + * + * Get network details.<br> + * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/{networkId}") + public JSONObject getNetwork(@Context HttpServletRequest context, @PathParam("networkId") String id) + throws ServiceException { + LOGGER.info("NetworkRoa::getNetwork id:{}", id); + Map<String, Object> map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List<NetworkEntity> networks = network.getList(map); + + JSONObject result = new JSONObject(); + result.put("networks", networks.toString()); + return result; + } + + /** + * + * Add network.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + public JSONObject addNetwork(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("NetworkRoa::addNetwork:{}", object.toString()); + try { + int result = network.add(NetworkEntity.toEntity(object)); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("NetworkRoa::addNetwork error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Delete network.<br> + * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + public JSONObject deleteNetwork(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + LOGGER.info("NetworkRoa::deleteNetwork id:{}", id); + try { + int result = network.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("NetworkRoa::deleteNetwork error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Update network.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + public JSONObject updateNetwork(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("NetworkRoa::updateNetwork:{}", object.toString()); + try { + int result = network.update(object); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("NetworkRoa::updateNetwork error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setNetwork(Network network) { + this.network = network; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java new file mode 100644 index 0000000..1d79f93 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java @@ -0,0 +1,183 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +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.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port; +import org.openo.nfvo.resmanagement.service.entity.PortEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * + * Port ROA Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.PORT_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class PortRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(PortRoa.class); + + private Port port; + + /** + * + * Get details of Ports.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + public JSONObject getPorts(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + List<PortEntity> ports = port.getList(map); + + JSONObject result = new JSONObject(); + result.put("ports", ports); + return result; + } + + /** + * + * Get port details.<br> + * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @GET + @Path("/{portId}") + public JSONObject getPort(@Context HttpServletRequest context, @PathParam("portId") String id) + throws ServiceException { + LOGGER.info("PortRoa::getPort id:{}", id); + Map<String, Object> map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List<PortEntity> ports = port.getList(map); + + JSONObject result = new JSONObject(); + result.put("ports", ports); + return result; + } + + /** + * + * Add port.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + public JSONObject addPort(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("PortRoa::addPort:{}", object.toString()); + try { + int result = port.add(PortEntity.toEntity(object)); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("PortRoa::addPort error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Delete port.<br> + * + * @param context + * @param id + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + public JSONObject deletePort(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + LOGGER.info("PortRoa::deletePort id:{}", id); + try { + int result = port.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("PortRoa::deletePort error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * + * Update port.<br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + public JSONObject updatePort(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + + LOGGER.info("PortRoa::updatePort:{}", object.toString()); + try { + int result = port.update(object); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("PortRoa::updatePort error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setPort(Port port) { + this.port = port; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java new file mode 100644 index 0000000..1e68e83 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java @@ -0,0 +1,151 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.VimUtil; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * Resource Operate ROA Class.<br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 10, 2016 + */ +@Path(UrlConstant.RESOPERATE_URL) +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class ResOperateRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(ResOperateRoa.class); + + private ResOperateService resOperateService; + + /** + * Update iResource pool.<br> + * + * @param context + * @param tenantId + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + @Path(UrlConstant.MODRES_URL) + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject updateIResPool(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + LOGGER.warn("ResPoolRoa::modVimId :{}", vimId); + JSONObject vimInfo = VimUtil.getVimById(vimId); + String tenant = vimInfo.getString("tenant"); + String tenantId = VimUtil.getTenantIdByName(tenant, vimId); + try { + resOperateService.updateIRes(tenantId, vimId, json); + resOperateService.sendMsgMonitor("update", vimId); + return RoaResponseUtil.update(HttpConstant.OK_CODE); + } catch(ServiceException se) { + LOGGER.error("ResOperateRoa::updateIResPool error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Add all resource pool.<br> + * + * @param context + * @param tenantId + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @POST + @Path(UrlConstant.ADDRES_URL) + @Consumes(UrlConstant.APPLICATION_TYPE) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject addAllResPool(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_TENANTID) String tenantId, + @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + LOGGER.warn("ResOperateRoa::vimId :{}", vimId); + + try { + resOperateService.addIRes(tenantId, vimId, json); + resOperateService.sendMsgMonitor("create", vimId); + return RoaResponseUtil.add(HttpConstant.OK_CODE); + } catch(ServiceException se) { + LOGGER.error("ResOperateRoa::addAllResPool error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * Delete iResource.<br> + * + * @param context + * @param vimId + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public JSONObject deleteIRes(@Context HttpServletRequest context, + @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException { + LOGGER.warn("ResOperateRoa::deleteIResource vimId:{}", vimId); + + try { + resOperateService.sendMsgMonitor("delete", vimId); + int result = resOperateService.deleteIRes(vimId); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("ResOperateRoa::deleteIRes error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setResOperateService(ResOperateService resOperateService) { + this.resOperateService = resOperateService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java new file mode 100644 index 0000000..192d33d --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java @@ -0,0 +1,224 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +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.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.VimUtil; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * Sites ROA method<br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Aug 24, 2016 + */ +@Path(UrlConstant.SITES_URL) +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class SitesRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(SitesRoa.class); + + private Sites sites; + + /** + * getSites ROA method<br/> + * + * @param context + * @return the get result + * @throws ServiceException When get failed. + * @since NFVO 0.5 + */ + @GET + public JSONObject getSites(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> map = new HashMap<String, Object>(10); + List<SitesEntity> datacenters = sites.getList(map); + + JSONObject result = new JSONObject(); + result.put("datacenters", datacenters); + return result; + } + + /** + * getSite ROA method<br/> + * + * @param context + * @param id + * @return the get result + * @throws ServiceException When get failed. + * @since NFVO 0.5 + */ + @GET + @Path("/{datacenterId}") + public JSONObject getSite(@Context HttpServletRequest context, @PathParam("datacenterId") String id) + throws ServiceException { + LOGGER.warn("SitesRoa::getSitesById id:{}", id); + Map<String, Object> map = new HashMap<String, Object>(10); + map.put(ParamConstant.PARAM_ID, id); + List<SitesEntity> datacenters = sites.getList(map); + + JSONObject result = new JSONObject(); + result.put("datacenters", datacenters); + return result; + } + + /** + * addSites ROA method<br/> + * + * @param context + * @param id + * @return the add result + * @throws ServiceException When add failed. + * @since NFVO 0.5 + */ + @POST + public JSONObject addSites(@Context HttpServletRequest context) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + + LOGGER.warn("SitesRoa:: start add Sites"); + try { + int result = sites.add(json); + sites.sendToMonitor(json); + return RoaResponseUtil.add(result); + } catch(ServiceException se) { + LOGGER.error("SitesRoa::addSites error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * deleteSites ROA method<br/> + * + * @param context + * @param id + * @return the delete result + * @throws ServiceException When delete failed. + * @since NFVO 0.5 + */ + @DELETE + @Path("/{datacenterId}") + public JSONObject deleteSites(@Context HttpServletRequest context, @PathParam("datacenterId") String id) + throws ServiceException { + LOGGER.warn("SitesRoa::deleteSites siteId:{}", id); + try { + int result = sites.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("SitesRoa::deleteSites error: " + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * updateSites ROA method<br/> + * + * @param context + * @param id + * @return the update result + * @throws ServiceException When update failed. + * @since NFVO 0.5 + */ + @PUT + public JSONObject updateSites(@Context HttpServletRequest context) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + + LOGGER.warn("SitesRoa::start update Sites"); + try { + int result = sites.update(SitesEntity.toEntity(json)); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("SitesRoa::updateSites error:" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + /** + * grant resource method + * <br> + * + * @param context + * @return + * @throws ServiceException + * @since NFVO 0.5 + */ + @PUT + @Path("/grant") + public JSONObject grantResource(@Context HttpServletRequest context) throws ServiceException { + JSONObject json = RequestUtil.getAllJsonRequestBody(context); + + LOGGER.warn("SitesRoa::grant resource"); + try { + int result = sites.update(json); + return RoaResponseUtil.update(result); + } catch(ServiceException se) { + LOGGER.error("SitesRoa::grant resource:" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @GET + @Path("/vims") + public String getVims(@Context HttpServletRequest context) throws ServiceException { + LOGGER.info("SitesRoa::get vims"); + JSONArray vims = VimUtil.getVims(); + JSONObject result = new JSONObject(); + result.put("data", vims); + return result.toString(); + } + + @GET + @Path("/vims/{vimId}") + public String getVim(@Context HttpServletRequest context, @PathParam("vimId") String vimId) + throws ServiceException { + LOGGER.info("SitesRoa::get vim by id: {}", vimId); + return VimUtil.getVimById(vimId).toString(); + } + + public void setSites(Sites sites) { + this.sites = sites; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java new file mode 100644 index 0000000..0e9bf48 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java @@ -0,0 +1,49 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.io.IOException; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.apache.commons.io.IOUtils; + +/** + * Swagger API Doc.<br/> + * + * @author + * @version NFVO 0.5 Oct 24, 2016 + */ +@Path("/v1") +@Produces({MediaType.APPLICATION_JSON}) +public class SwaggerRoa { + /** + * API doc. + * @param filename + * @return + * @throws IOException + */ + @GET + @Path("/swagger.json") + public String apidoc() throws IOException{ + ClassLoader classLoader = getClass().getClassLoader(); + return IOUtils.toString(classLoader.getResourceAsStream("swagger.json")); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java new file mode 100644 index 0000000..524a474 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VirtualLinkService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 27, 2016 + */ +@Path(UrlConstant.VL_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VirtualLinkRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkRoa.class); + + private VirtualLinkService virtualLink; + + @GET + public JSONObject getVls(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + List<VirtualLinkEntity> vls = virtualLink.getList(map); + LOGGER.info("VirtualLinkRoa::getVls:{}", vls.toString()); + JSONObject result = new JSONObject(); + result.put("vls", vls); + return result; + } + + @GET + @Path("/{vlId}") + public JSONObject getVl(@Context HttpServletRequest context, @PathParam("vlId") String id) throws ServiceException { + LOGGER.info("VirtualLinkRoa::getVl id:{}", id); + Map<String, Object> map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List<VirtualLinkEntity> vls = virtualLink.getList(map); + LOGGER.info("VirtualLinkRoa::getVl:{}", vls.toString()); + JSONObject result = new JSONObject(); + result.put("vls", vls); + return result; + } + + @POST + public JSONObject addVl(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVl; msg=add error, because vl is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.virtualLink.add.null")); + } + + LOGGER.info("VirtualLinkRoa::addVl:{}", object.toString()); + try { + return virtualLink.addVl(VirtualLinkEntity.toEntity(object)); + } catch(ServiceException se) { + LOGGER.error("VirtualLinkRoa::addVl error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVl(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVl; msg=delete error, because vlId is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.virtualLink.delete.vlId.null")); + } + LOGGER.info("VirtualLinkRoa::deleteVl id:{}", id); + try { + int result = virtualLink.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VirtualLinkRoa::deleteVl error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVirtualLink(VirtualLinkService virtualLink) { + this.virtualLink = virtualLink; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java new file mode 100644 index 0000000..cb9d2b6 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java @@ -0,0 +1,127 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.entity.VmEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VmService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +@Path(UrlConstant.VM_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VmRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VmRoa.class); + + private VmService vmService; + + @GET + public JSONObject getVms(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + List<VmEntity> vms = vmService.getList(map); + LOGGER.info("VmRoa::getVms:{}", vms.toString()); + JSONObject result = new JSONObject(); + result.put("vms", vms); + return result; + } + + @GET + @Path("/{vmId}") + public JSONObject getVm(@Context HttpServletRequest context, @PathParam("vmId") String id) throws ServiceException { + LOGGER.info("VmRoa::getVm id:{}", id); + Map<String, Object> map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List<VmEntity> vms = vmService.getList(map); + LOGGER.info("VmRoa::getVm:{}", vms.toString()); + JSONObject result = new JSONObject(); + result.put("vms", vms); + return result; + } + + @POST + public JSONObject addVm(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVm; msg=add error, because vm is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vm.add.null")); + } + + LOGGER.info("VmRoa::addVm:{}", object.toString()); + try { + return vmService.addVm(VmEntity.toEntity(object)); + } catch(ServiceException se) { + LOGGER.error("VmRoa::addVm error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVm(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVm; msg=delete error, because id is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vm.delete.id.null")); + } + LOGGER.info("VmRoa::deleteVm id:{}", id); + try { + int result = vmService.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VmRoa::deleteVm error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVmService(VmService vmService) { + this.vmService = vmService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java new file mode 100644 index 0000000..b6fd5a5 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +@Path(UrlConstant.VNFINFO_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VnfInfoRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfInfoRoa.class); + + private VnfInfoService vnfInfoService; + + @GET + public JSONObject getVnfInfos(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + List<VnfInfoEntity> vnfInfos = vnfInfoService.getList(map); + LOGGER.info("VnfInfoRoa::getVnfInfos:{}", vnfInfos.toString()); + JSONObject result = new JSONObject(); + result.put("vnfInfos", vnfInfos); + return result; + } + + @GET + @Path("/{id}") + public JSONObject getVnfInfo(@Context HttpServletRequest context, @PathParam("id") String id) + throws ServiceException { + LOGGER.info("VnfInfoRoa::getVnfInfo id:{}", id); + Map<String, Object> map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List<VnfInfoEntity> vnfInfos = vnfInfoService.getList(map); + LOGGER.info("VnfInfoRoa::getVnfInfo:{}", vnfInfos.toString()); + JSONObject result = new JSONObject(); + result.put("vnfInfos", vnfInfos); + return result; + } + + @POST + public JSONObject addVnfInfo(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVnfInfo; msg=add error, because vnfInfo is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfInfo.add.null")); + } + + LOGGER.info("VnfInfoRoa::addVnfInfo:{}", object.toString()); + try { + return vnfInfoService.addVnfInfo(object); + } catch(ServiceException se) { + LOGGER.error("VnfInfoRoa::addVnfInfo error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVnfInfo(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVnfInfo; msg=delete error, because id is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfInfo.delete.id.null")); + } + LOGGER.info("VnfInfoRoa::deleteVnfInfo id:{}", id); + try { + int result = vnfInfoService.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VnfInfoRoa::deleteVnfInfo error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVnfInfoService(VnfInfoService vnfInfoService) { + this.vnfInfoService = vnfInfoService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java new file mode 100644 index 0000000..4d5fc47 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java @@ -0,0 +1,128 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.entity.VnfEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VnfService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 28, 2016 + */ +@Path(UrlConstant.VNF_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VnfRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkRoa.class); + + private VnfService vnfService; + + @GET + public JSONObject getVnfs(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + List<VnfEntity> vnfs = vnfService.getList(map); + LOGGER.info("VnfRoa::getVnfs:{}", vnfs.toString()); + JSONObject result = new JSONObject(); + result.put("vnfs", vnfs); + return result; + } + + @GET + @Path("/{vnfId}") + public JSONObject getVnf(@Context HttpServletRequest context, @PathParam("vnfId") String id) + throws ServiceException { + LOGGER.info("VnfRoa::getVnf id:{}", id); + Map<String, Object> map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List<VnfEntity> vnfs = vnfService.getList(map); + LOGGER.info("VnfRoa::getVnf:{}", vnfs.toString()); + JSONObject result = new JSONObject(); + result.put("vnfs", vnfs); + return result; + } + + @POST + public JSONObject addVnf(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVnf; msg=add error, because vnf is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnf.add.null")); + } + + LOGGER.info("VnfRoa::addVnf:{}", object.toString()); + try { + return vnfService.addVnf(VnfEntity.toEntity(object)); + } catch(ServiceException se) { + LOGGER.error("VnfRoa::addVnf error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVnf(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVnf; msg=delete error, because id is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnf.delete.id.null")); + } + LOGGER.info("VnfRoa::deleteVnf id:{}", id); + try { + int result = vnfService.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VnfRoa::deleteVnf error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVnfService(VnfService vnfService) { + this.vnfService = vnfService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java new file mode 100644 index 0000000..1e7d9f4 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java @@ -0,0 +1,129 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.ResourceUtil; +import org.openo.nfvo.resmanagement.common.constant.HttpConstant; +import org.openo.nfvo.resmanagement.common.constant.ParamConstant; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil; +import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil; +import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity; +import org.openo.nfvo.resmanagement.service.group.inf.VnfStatusService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Oct 29, 2016 + */ +@Path(UrlConstant.VNFSTATUS_URL) +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class VnfStatusRoa { + + private static final Logger LOGGER = LoggerFactory.getLogger(VnfStatusRoa.class); + + private VnfStatusService vnfStatusService; + + @GET + public JSONObject getVnfStatuss(@Context HttpServletRequest context) throws ServiceException { + Map<String, Object> map = new HashMap<>(10); + List<VnfStatusEntity> vnfStatus = vnfStatusService.getList(map); + LOGGER.info("VnfStatusRoa::getVnfStatuss:{}", vnfStatus.toString()); + JSONObject result = new JSONObject(); + result.put("vnfStatus", vnfStatus); + return result; + } + + @GET + @Path("/{id}") + public JSONObject getVnfStatus(@Context HttpServletRequest context, @PathParam("id") String id) + throws ServiceException { + LOGGER.info("VnfStatusRoa::getVnfStatus id:{}", id); + Map<String, Object> map = new HashMap<>(10); + map.put(ParamConstant.PARAM_ID, id); + List<VnfStatusEntity> vnfStatus = vnfStatusService.getList(map); + LOGGER.info("VnfStatusRoa::getVnfStatus:{}", vnfStatus.toString()); + JSONObject result = new JSONObject(); + result.put("vnfStatus", vnfStatus); + return result; + } + + @POST + public JSONObject addVnfStatus(@Context HttpServletRequest context) throws ServiceException { + JSONObject object = RequestUtil.getJsonRequestBody(context); + if(null == object) { + LOGGER.error("function=addVnfInfo; msg=add error, because vnfStatus is null."); + throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfStatus.add.null")); + } + + LOGGER.info("VnfStatusRoa::addVnfStatus:{}", object.toString()); + try { + return vnfStatusService.addVnfStatus(object); + } catch(ServiceException se) { + LOGGER.error("VnfStatusRoa::addVnfStatus error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + @DELETE + @Path("/{id}") + public JSONObject deleteVnfStatus(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id) + throws ServiceException { + if(id == null) { + LOGGER.error("function=deleteVnfStatus; msg=delete error, because id is null."); + throw new ServiceException( + ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfStatus.delete.id.null")); + } + LOGGER.info("VnfStatusRoa::deleteVnfStatus id:{}", id); + try { + int result = vnfStatusService.delete(id); + return RoaResponseUtil.delete(result); + } catch(ServiceException se) { + LOGGER.error("VnfStatusRoa::deleteVnfStatys error:{}" + se); + return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage()); + } + } + + public void setVnfStatusService(VnfStatusService vnfStatusService) { + this.vnfStatusService = vnfStatusService; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java new file mode 100644 index 0000000..8f57345 --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java @@ -0,0 +1,64 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper; + +import org.apache.http.HttpStatus; + +/** + * Exception response model.<br> + * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +public class ExceptionMessage { + + private String errorCode = "unknown.error"; + + private int httpCode = HttpStatus.SC_INTERNAL_SERVER_ERROR; + + private String message; + + @Override + public String toString() { + return "Error {errorCode=" + this.errorCode + ", httpCode=" + this.httpCode + ", message=" + + this.message + "}"; + } + + public String getErrorCode() { + return this.errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getMessage() { + return this.message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int getHttpCode() { + return this.httpCode; + } + + public void setHttpCode(int httpCode) { + this.httpCode = httpCode; + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java new file mode 100644 index 0000000..d557e0c --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java @@ -0,0 +1,41 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +/** + * Generic exception response provider.<br> + * + * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +@Provider +public class GenericExceptionMapper implements ExceptionMapper<Exception>{ + + @Override + public Response toResponse(Exception exception) { + ExceptionMessage message = new ExceptionMessage(); + message.setMessage(exception.getMessage()); + return Response.status(message.getHttpCode()).type( + MediaType.APPLICATION_JSON).entity(message).build(); + } +} diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java new file mode 100644 index 0000000..a45852a --- /dev/null +++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java @@ -0,0 +1,45 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + +import org.openo.baseservice.remoteservice.exception.ServiceException; + +/** + * ServiceException response provider.<br> + * + * @author + * @version NFVO 0.5 Sep 27, 2016 + */ +@Provider +public class ServiceExceptionMapper implements ExceptionMapper<ServiceException>{ + + @Override + public Response toResponse(ServiceException exception) { + ExceptionMessage message = new ExceptionMessage(); + message.setErrorCode(exception.getId()); + message.setHttpCode(exception.getHttpCode()); + message.setMessage(exception.getMessage()); + return Response.status(message.getHttpCode()). + type(MediaType.APPLICATION_JSON).entity(message).build(); + } + +} diff --git a/ResmanagementService/service/src/main/resources/log4j.properties b/ResmanagementService/service/src/main/resources/log4j.properties new file mode 100644 index 0000000..d371d16 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/log4j.properties @@ -0,0 +1,23 @@ +############################################################################### +# Copyright 2016, Huawei Technologies Co., Ltd. +# +# 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. +############################################################################### +log4j.rootLogger=INFO,root +log4j.appender.root.Append=true +log4j.appender.root.File=${catalina.base}/logs/resmanagement.log +log4j.appender.root.layout.ConversionPattern=%d %-5p [%t][%X{moduleID}][%C %L] %m%n +log4j.appender.root.layout=org.apache.log4j.PatternLayout +log4j.appender.root.MaxBackupIndex=50 +log4j.appender.root.MaxFileSize=20MB +log4j.appender.root=org.apache.log4j.RollingFileAppender
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/HostMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/HostMapper.xml new file mode 100644 index 0000000..850eef4 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/HostMapper.xml @@ -0,0 +1,189 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +Copyright 2016 Huawei Technologies Co., Ltd. + +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. +--> + +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.HostMapper"> + <resultMap id="BaseResultMap" + type="org.openo.nfvo.resmanagement.service.entity.HostEntity"> + <id column="ID" property="id" jdbcType="VARCHAR" /> + <result column="NAME" property="name" jdbcType="VARCHAR" /> + <result column="CPU" property="cpu" jdbcType="VARCHAR" /> + <result column="MEMORY" property="memory" jdbcType="VARCHAR" /> + <result column="DISK" property="disk" jdbcType="VARCHAR" /> + <result column="VIM_ID" property="vimId" jdbcType="VARCHAR" /> + <result column="VIM_NAME" property="vimName" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List"> + ID, NAME, CPU, MEMORY, DISK, VIM_ID, VIM_NAME + </sql> + <select id="getHost" resultMap="BaseResultMap" parameterType="java.lang.String"> + select + <include refid="Base_Column_List" /> + from host + where ID = #{id,jdbcType=VARCHAR} + </select> + <select id="getHosts" resultMap="BaseResultMap" parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from host + <where> + <if test="id != null"> + AND ID = #{id,jdbcType=VARCHAR} + </if> + <if test="vimId != null"> + AND VIM_ID = #{vimId,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteHost" parameterType="java.lang.String"> + delete from host + where ID = #{id,jdbcType=VARCHAR} + </delete> + <delete id="deleteHostByVimId" parameterType="java.lang.String"> + delete from host + where VIM_ID = #{vimId,jdbcType=VARCHAR} + </delete> + <insert id="addHost" + parameterType="org.openo.nfvo.resmanagement.service.entity.HostEntity"> + insert into host (ID, NAME, CPU, MEMORY, DISK, VIM_ID, VIM_NAME) + values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, + #{cpu,jdbcType=VARCHAR}, + #{memory,jdbcType=VARCHAR}, #{disk,jdbcType=VARCHAR}, #{vimId,jdbcType=VARCHAR} + , #{vimName,jdbcType=VARCHAR}) + </insert> + <insert id="addHostSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.HostEntity"> + insert into host + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + ID, + </if> + <if test="name != null"> + NAME, + </if> + <if test="cpu != null"> + CPU, + </if> + <if test="memory != null"> + MEMORY, + </if> + <if test="disk != null"> + DISK, + </if> + <if test="vimId != null"> + VIM_ID, + </if> + <if test="vimName != null"> + VIM_NAME, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=VARCHAR}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="cpu != null"> + #{cpu,jdbcType=VARCHAR}, + </if> + <if test="memory != null"> + #{memory,jdbcType=VARCHAR}, + </if> + <if test="disk != null"> + #{disk,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + #{vimName,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateHostSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.HostEntity"> + update host + <set> + <if test="name != null"> + NAME = #{name,jdbcType=VARCHAR}, + </if> + <if test="cpu != null"> + CPU = #{cpu,jdbcType=VARCHAR}, + </if> + <if test="memory != null"> + MEMORY = #{memory,jdbcType=VARCHAR}, + </if> + <if test="disk != null"> + DISK = #{disk,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + VIM_ID = #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + VIM_NAME = #{vimName,jdbcType=VARCHAR}, + </if> + </set> + <where> + <if test="name != null"> + NAME = #{name,jdbcType=VARCHAR} + </if> + <if test="vimId != null"> + AND VIM_ID = #{vimId,jdbcType=VARCHAR} + </if> + </where> + </update> + <update id="updateHost" + parameterType="org.openo.nfvo.resmanagement.service.entity.HostEntity"> + update host + set NAME = #{name,jdbcType=VARCHAR}, + CPU = #{cpu,jdbcType=VARCHAR}, + MEMORY = #{memory,jdbcType=VARCHAR}, + DISK = #{disk,jdbcType=VARCHAR}, + VIM_ID = #{vimId,jdbcType=VARCHAR}, + VIM_NAME = #{vimName,jdbcType=VARCHAR} + where ID = #{id,jdbcType=VARCHAR} + </update> + <update id="updateHostByVimId" + parameterType="org.openo.nfvo.resmanagement.service.entity.HostEntity"> + update host + <set> + <if test="id != null"> + ID = #{id,jdbcType=VARCHAR}, + </if> + <if test="name != null"> + NAME = #{name,jdbcType=VARCHAR}, + </if> + <if test="cpu != null"> + CPU = #{cpu,jdbcType=VARCHAR}, + </if> + <if test="memory != null"> + MEMORY = #{memory,jdbcType=VARCHAR}, + </if> + <if test="disk != null"> + DISK = #{disk,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + VIM_ID = #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + VIM_NAME = #{vimName,jdbcType=VARCHAR}, + </if> + </set> + where VIM_ID = #{vimId,jdbcType=VARCHAR} + </update> +</mapper> diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/LocationMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/LocationMapper.xml new file mode 100644 index 0000000..b0ecba2 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/LocationMapper.xml @@ -0,0 +1,158 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +Copyright 2016 Huawei Technologies Co., Ltd. + +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. +--> + +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.LocationMapper"> + <resultMap id="BaseResultMap" + type="org.openo.nfvo.resmanagement.service.entity.LocationEntity"> + + <id column="ID" property="id" jdbcType="VARCHAR" /> + <result column="COUNTRY" property="country" jdbcType="VARCHAR" /> + <result column="LOCATION" property="location" jdbcType="VARCHAR" /> + <result column="LATITUDE" property="latitude" jdbcType="VARCHAR" /> + <result column="LONGITUDE" property="longitude" jdbcType="VARCHAR" /> + <result column="DESCRIPTION" property="description" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List"> + ID, COUNTRY, LOCATION, LATITUDE, LONGITUDE, DESCRIPTION + </sql> + <select id="getLocation" resultMap="BaseResultMap" + parameterType="java.lang.String"> + select + <include refid="Base_Column_List" /> + from location + where ID = #{id,jdbcType=VARCHAR} + </select> + <select id="getCountry" resultType="java.lang.String"> + select distinct COUNTRY from location + </select> + <select id="getLocationByCountry" resultType="java.lang.String" + parameterType="java.util.Map"> + select distinct LOCATION from location + <where> + <if test="country != null"> + AND COUNTRY = #{country,jdbcType=VARCHAR} + </if> + </where> + </select> + <select id="getLocations" resultMap="BaseResultMap" + parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from location + <where> + <if test="id != null"> + AND ID = #{id,jdbcType=VARCHAR} + </if> + <if test="location !=null"> + AND LOCATION = #{location,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteLocation" parameterType="java.lang.String"> + delete from location + where ID = #{id,jdbcType=VARCHAR} + </delete> + <insert id="addLocation" + parameterType="org.openo.nfvo.resmanagement.service.entity.LocationEntity"> + + insert into location (ID, COUNTRY, LOCATION, + LATITUDE, LONGITUDE, DESCRIPTION) + values (#{id,jdbcType=VARCHAR}, #{country,jdbcType=VARCHAR}, + #{location,jdbcType=VARCHAR}, + #{latitude,jdbcType=VARCHAR}, #{longitude,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}) + </insert> + <insert id="addLocationSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.LocationEntity"> + + insert into location + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + ID, + </if> + <if test="country != null"> + COUNTRY, + </if> + <if test="location != null"> + LOCATION, + </if> + <if test="latitude != null"> + LATITUDE, + </if> + <if test="longitude != null"> + LONGITUDE, + </if> + <if test="description != null"> + DESCRIPTION, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=VARCHAR}, + </if> + <if test="country != null"> + #{country,jdbcType=VARCHAR}, + </if> + <if test="location != null"> + #{location,jdbcType=VARCHAR}, + </if> + <if test="latitude != null"> + #{latitude,jdbcType=VARCHAR}, + </if> + <if test="longitude != null"> + #{longitude,jdbcType=VARCHAR}, + </if> + <if test="description != null"> + #{description,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateLocationSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.LocationEntity"> + + update location + <set> + <if test="country != null"> + COUNTRY = #{country,jdbcType=VARCHAR}, + </if> + <if test="location != null"> + LOCATION = #{location,jdbcType=VARCHAR}, + </if> + <if test="latitude != null"> + LATITUDE = #{latitude,jdbcType=VARCHAR}, + </if> + <if test="longitude != null"> + LONGITUDE = #{longitude,jdbcType=VARCHAR}, + </if> + <if test="description != null"> + DESCRIPTION = #{description,jdbcType=VARCHAR}, + </if> + </set> + where ID = #{id,jdbcType=VARCHAR} + </update> + <update id="updateLocation" + parameterType="org.openo.nfvo.resmanagement.service.entity.LocationEntity"> + + update location + set COUNTRY = #{country,jdbcType=VARCHAR}, + LOCATION = #{location,jdbcType=VARCHAR}, + LATITUDE = #{latitude,jdbcType=VARCHAR}, + LONGITUDE = #{longitude,jdbcType=VARCHAR}, + DESCRIPTION = #{description,jdbcType=VARCHAR} + where ID = #{id,jdbcType=VARCHAR} + </update> +</mapper>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/NetworkMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/NetworkMapper.xml new file mode 100644 index 0000000..65e4d67 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/NetworkMapper.xml @@ -0,0 +1,216 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +Copyright 2016 Huawei Technologies Co., Ltd. + +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. +--> + +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.NetworkMapper"> + <resultMap id="BaseResultMap" + type="org.openo.nfvo.resmanagement.service.entity.NetworkEntity"> + <id column="ID" property="id" jdbcType="VARCHAR" /> + <result column="NAME" property="name" jdbcType="VARCHAR" /> + <result column="TENANT_ID" property="tenantId" jdbcType="VARCHAR" /> + <result column="VIM_ID" property="vimId" jdbcType="VARCHAR" /> + <result column="VIM_NAME" property="vimName" jdbcType="VARCHAR" /> + <result column="STATUS" property="status" jdbcType="VARCHAR" /> + <result column="PHYSICAL_NETWORK" property="physicalNetwork" + jdbcType="VARCHAR" /> + <result column="NETWORK_TYPE" property="networkType" jdbcType="VARCHAR" /> + <result column="SEGMENTATION_ID" property="segmentationId" + jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List"> + ID, NAME, TENANT_ID, VIM_ID, VIM_NAME, STATUS, + PHYSICAL_NETWORK, NETWORK_TYPE, SEGMENTATION_ID + </sql> + <select id="getNetwork" resultMap="BaseResultMap" parameterType="java.lang.String"> + select + <include refid="Base_Column_List" /> + from network + where ID = #{id,jdbcType=VARCHAR} + </select> + <select id="getNetworks" resultMap="BaseResultMap" + parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from network + <where> + <if test="id != null"> + AND ID = #{id,jdbcType=VARCHAR} + </if> + <if test="vimId != null"> + AND VIM_ID = #{vimId,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteNetwork" parameterType="java.lang.String"> + delete from network + where ID = #{id,jdbcType=VARCHAR} + </delete> + <delete id="deleteNetworkByVimId" parameterType="java.lang.String"> + delete from network + where VIM_ID = #{vimId,jdbcType=VARCHAR} + </delete> + <insert id="addNetwork" + parameterType="org.openo.nfvo.resmanagement.service.entity.NetworkEntity"> + insert into network (ID, NAME, TENANT_ID, + VIM_ID, VIM_NAME, STATUS, + PHYSICAL_NETWORK, NETWORK_TYPE, SEGMENTATION_ID + ) + values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, + #{tenantId,jdbcType=VARCHAR}, + #{vimId,jdbcType=VARCHAR}, #{vimName,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, + #{physicalNetwork,jdbcType=VARCHAR}, #{networkType,jdbcType=VARCHAR}, + #{segmentationId,jdbcType=VARCHAR} + ) + </insert> + <insert id="addNetworkSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.NetworkEntity"> + insert into network + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + ID, + </if> + <if test="name != null"> + NAME, + </if> + <if test="tenantId != null"> + TENANT_ID, + </if> + <if test="vimId != null"> + VIM_ID, + </if> + <if test="vimName != null"> + VIM_NAME, + </if> + <if test="status != null"> + STATUS, + </if> + <if test="physicalNetwork != null"> + PHYSICAL_NETWORK, + </if> + <if test="networkType != null"> + NETWORK_TYPE, + </if> + <if test="segmentationId != null"> + SEGMENTATION_ID, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=VARCHAR}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="tenantId != null"> + #{tenantId,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + #{vimName,jdbcType=VARCHAR}, + </if> + <if test="status != null"> + #{status,jdbcType=VARCHAR}, + </if> + <if test="physicalNetwork != null"> + #{physicalNetwork,jdbcType=VARCHAR}, + </if> + <if test="networkType != null"> + #{networkType,jdbcType=VARCHAR}, + </if> + <if test="segmentationId != null"> + #{segmentationId,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateNetworkSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.NetworkEntity"> + update network + <set> + <if test="name != null"> + NAME = #{name,jdbcType=VARCHAR}, + </if> + <if test="tenantId != null"> + TENANT_ID = #{tenantId,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + VIM_ID = #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + VIM_NAME = #{vimName,jdbcType=VARCHAR}, + </if> + <if test="status != null"> + STATUS = #{status,jdbcType=VARCHAR}, + </if> + <if test="physicalNetwork != null"> + PHYSICAL_NETWORK = #{physicalNetwork,jdbcType=VARCHAR}, + </if> + <if test="networkType != null"> + NETWORK_TYPE = #{networkType,jdbcType=VARCHAR}, + </if> + <if test="segmentationId != null"> + SEGMENTATION_ID = #{segmentationId,jdbcType=VARCHAR}, + </if> + </set> + where ID = #{id,jdbcType=VARCHAR} + </update> + <update id="updateNetwork" + parameterType="org.openo.nfvo.resmanagement.service.entity.NetworkEntity"> + update network + set NAME = #{name,jdbcType=VARCHAR}, + TENANT_ID = #{tenantId,jdbcType=VARCHAR}, + VIM_ID = #{vimId,jdbcType=VARCHAR}, + VIM_NAME = #{vimName,jdbcType=VARCHAR}, + STATUS = #{status,jdbcType=VARCHAR}, + PHYSICAL_NETWORK = #{physicalNetwork,jdbcType=VARCHAR}, + NETWORK_TYPE = #{networkType,jdbcType=VARCHAR}, + SEGMENTATION_ID = #{segmentationId,jdbcType=VARCHAR} + where ID = #{id,jdbcType=VARCHAR} + </update> + <update id="updateNetworkByVimId" + parameterType="org.openo.nfvo.resmanagement.service.entity.NetworkEntity"> + update network + <set> + <if test="id != null"> + ID = #{id,jdbcType=VARCHAR}, + </if> + <if test="name != null"> + NAME = #{name,jdbcType=VARCHAR}, + </if> + <if test="tenantId != null"> + TENANT_ID = #{tenantId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + VIM_NAME = #{vimName,jdbcType=VARCHAR}, + </if> + <if test="status != null"> + STATUS = #{status,jdbcType=VARCHAR}, + </if> + <if test="physicalNetwork != null"> + PHYSICAL_NETWORK = #{physicalNetwork,jdbcType=VARCHAR}, + </if> + <if test="networkType != null"> + NETWORK_TYPE = #{networkType,jdbcType=VARCHAR}, + </if> + <if test="segmentationId != null"> + SEGMENTATION_ID = #{segmentationId,jdbcType=VARCHAR}, + </if> + </set> + where VIM_ID = #{vimId,jdbcType=VARCHAR} + </update> +</mapper>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/PortMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/PortMapper.xml new file mode 100644 index 0000000..765dcfe --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/PortMapper.xml @@ -0,0 +1,180 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +Copyright 2016 Huawei Technologies Co., Ltd. + +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. +--> + +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.PortMapper"> + <resultMap id="BaseResultMap" + type="org.openo.nfvo.resmanagement.service.entity.PortEntity"> + <id column="ID" property="id" jdbcType="VARCHAR" /> + <result column="NAME" property="name" jdbcType="VARCHAR" /> + <result column="NWTWORK_ID" property="networkId" jdbcType="VARCHAR" /> + <result column="STATUS" property="status" jdbcType="VARCHAR" /> + <result column="TENANT_ID" property="tenantId" jdbcType="VARCHAR" /> + <result column="VIM_ID" property="vimId" jdbcType="VARCHAR" /> + <result column="VIM_NAME" property="vimName" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List"> + ID, NAME, NWTWORK_ID, STATUS, TENANT_ID, VIM_ID, VIM_NAME + </sql> + <select id="getPort" resultMap="BaseResultMap" parameterType="java.lang.String"> + select + <include refid="Base_Column_List" /> + from port + where ID = #{id,jdbcType=VARCHAR} + </select> + <select id="getPorts" resultMap="BaseResultMap" parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from port + <where> + <if test="id != null"> + AND ID = #{id,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deletePort" parameterType="java.lang.String"> + delete from port + where ID = #{id,jdbcType=VARCHAR} + </delete> + <delete id="deletePortByVimId" parameterType="java.lang.String"> + delete from port + where VIM_ID = #{vimId,jdbcType=VARCHAR} + </delete> + <insert id="addPort" + parameterType="org.openo.nfvo.resmanagement.service.entity.PortEntity"> + insert into port (ID, NAME, NWTWORK_ID, STATUS, TENANT_ID, VIM_ID, + VIM_NAME) + values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, + #{networkId,jdbcType=VARCHAR}, + #{status,jdbcType=VARCHAR}, #{tenantId,jdbcType=VARCHAR}, #{vimId,jdbcType=VARCHAR} + , #{vimName,jdbcType=VARCHAR}) + </insert> + <insert id="addPortSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.PortEntity"> + insert into port + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + ID, + </if> + <if test="name != null"> + NAME, + </if> + <if test="networkId != null"> + NWTWORK_ID, + </if> + <if test="status != null"> + STATUS, + </if> + <if test="tenantId != null"> + TENANT_ID, + </if> + <if test="vimId != null"> + VIM_ID, + </if> + <if test="vimName != null"> + VIM_NAME, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=VARCHAR}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="networkId != null"> + #{networkId,jdbcType=VARCHAR}, + </if> + <if test="status != null"> + #{status,jdbcType=VARCHAR}, + </if> + <if test="tenantId != null"> + #{tenantId,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + #{vimName,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updatePortSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.PortEntity"> + update port + <set> + <if test="name != null"> + NAME = #{name,jdbcType=VARCHAR}, + </if> + <if test="networkId != null"> + NWTWORK_ID = #{networkId,jdbcType=VARCHAR}, + </if> + <if test="status != null"> + STATUS = #{status,jdbcType=VARCHAR}, + </if> + <if test="tenantId != null"> + TENANT_ID = #{tenantId,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + VIM_ID = #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + VIM_NAME = #{vimName,jdbcType=VARCHAR}, + </if> + </set> + where ID = #{id,jdbcType=VARCHAR} + </update> + <update id="updatePort" + parameterType="org.openo.nfvo.resmanagement.service.entity.PortEntity"> + update port + set NAME = #{name,jdbcType=VARCHAR}, + NWTWORK_ID = #{networkId,jdbcType=VARCHAR}, + STATUS = #{status,jdbcType=VARCHAR}, + TENANT_ID = #{tenantId,jdbcType=VARCHAR}, + VIM_ID = #{vimId,jdbcType=VARCHAR}, + VIM_NAME = #{vimName,jdbcType=VARCHAR} + where ID = #{id,jdbcType=VARCHAR} + </update> + <update id="updatePortByVimId" + parameterType="org.openo.nfvo.resmanagement.service.entity.PortEntity"> + update port + <set> + <if test="id != null"> + ID = #{id,jdbcType=VARCHAR}, + </if> + <if test="name != null"> + NAME = #{name,jdbcType=VARCHAR}, + </if> + <if test="networkId != null"> + NWTWORK_ID = #{networkId,jdbcType=VARCHAR}, + </if> + <if test="status != null"> + STATUS = #{status,jdbcType=VARCHAR}, + </if> + <if test="tenantId != null"> + TENANT_ID = #{tenantId,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + VIM_ID = #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + VIM_NAME = #{vimName,jdbcType=VARCHAR}, + </if> + </set> + where ID = #{id,jdbcType=VARCHAR} + </update> +</mapper> diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/SitesMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/SitesMapper.xml new file mode 100644 index 0000000..14f7b52 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/SitesMapper.xml @@ -0,0 +1,286 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +Copyright 2016 Huawei Technologies Co., Ltd. + +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. +--> + +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.SitesMapper"> + <resultMap id="BaseResultMap" + type="org.openo.nfvo.resmanagement.service.entity.SitesEntity"> + <id column="ID" property="id" jdbcType="VARCHAR" /> + <result column="NAME" property="name" jdbcType="VARCHAR" /> + <result column="LOCATION" property="location" jdbcType="VARCHAR" /> + <result column="COUNTRY" property="country" jdbcType="VARCHAR" /> + <result column="VIM_ID" property="vimId" jdbcType="VARCHAR" /> + <result column="VIM_NAME" property="vimName" jdbcType="VARCHAR" /> + <result column="STATUS" property="status" jdbcType="VARCHAR" /> + <result column="TOTAL_CPU" property="totalCPU" jdbcType="VARCHAR" /> + <result column="TOTAL_MEMORY" property="totalMemory" jdbcType="VARCHAR" /> + <result column="TOTAL_DISK" property="totalDisk" jdbcType="VARCHAR" /> + <result column="USED_CPU" property="usedCPU" jdbcType="VARCHAR" /> + <result column="USED_MEMORY" property="usedMemory" jdbcType="VARCHAR" /> + <result column="USED_DISK" property="usedDisk" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List"> + ID, NAME, LOCATION, COUNTRY, VIM_ID, VIM_NAME, STATUS, + TOTAL_CPU, + TOTAL_MEMORY, TOTAL_DISK, + USED_CPU, USED_MEMORY, USED_DISK + </sql> + <select id="getSite" resultMap="BaseResultMap" parameterType="java.lang.String"> + select + <include refid="Base_Column_List" /> + from site + where ID = #{id,jdbcType=VARCHAR} + </select> + <select id="getSites" resultMap="BaseResultMap" parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from site + <where> + <if test="id != null"> + AND ID = #{id,jdbcType=VARCHAR} + </if> + <if test="name != null"> + AND NAME = #{name,jdbcType=VARCHAR} + </if> + <if test="location != null"> + AND LOCATION = #{location,jdbcType=VARCHAR} + </if> + <if test="vimId != null"> + AND VIM_ID = #{vimId,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteSite" parameterType="java.lang.String"> + delete from site + where ID = + #{id,jdbcType=VARCHAR} + </delete> + <insert id="addSite" + parameterType="org.openo.nfvo.resmanagement.service.entity.SitesEntity"> + insert into site (ID, NAME, LOCATION, + COUNTRY, VIM_ID, + VIM_NAME, STATUS,TOTAL_CPU, TOTAL_MEMORY, TOTAL_DISK, + USED_CPU, + USED_MEMORY, USED_DISK) + values (#{id,jdbcType=VARCHAR}, + #{name,jdbcType=VARCHAR}, + #{location,jdbcType=VARCHAR}, + #{country,jdbcType=VARCHAR}, #{vimId,jdbcType=VARCHAR}, + #{vimName,jdbcType=VARCHAR}, + #{status,jdbcType=VARCHAR}, + #{totalCPU,jdbcType=VARCHAR}, #{totalMemory,jdbcType=VARCHAR}, + #{totalDisk,jdbcType=VARCHAR}, + #{usedCPU,jdbcType=VARCHAR}, + #{usedMemory,jdbcType=VARCHAR}, + #{usedDisk,jdbcType=VARCHAR}) + </insert> + <insert id="addSiteSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.SitesEntity"> + insert into site + <trim prefix="(" suffix=")" suffixOverrides=","> + <if test="id != null"> + ID, + </if> + <if test="name != null"> + NAME, + </if> + <if test="location != null"> + LOCATION, + </if> + <if test="country != null"> + COUNTRY, + </if> + <if test="vimId != null"> + VIM_ID, + </if> + <if test="vimName != null"> + VIM_NAME, + </if> + <if test="status != null"> + STATUS, + </if> + <if test="totalCPU != null"> + TOTAL_CPU, + </if> + <if test="totalMemory != null"> + TOTAL_MEMORY, + </if> + <if test="totalDisk != null"> + TOTAL_DISK, + </if> + <if test="usedCPU != null"> + USED_CPU, + </if> + <if test="usedMemory != null"> + USED_MEMORY, + </if> + <if test="usedDisk != null"> + USED_DISK, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides=","> + <if test="id != null"> + #{id,jdbcType=VARCHAR}, + </if> + <if test="name != null"> + #{name,jdbcType=VARCHAR}, + </if> + <if test="location != null"> + #{location,jdbcType=VARCHAR}, + </if> + <if test="country != null"> + #{country,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + #{vimName,jdbcType=VARCHAR}, + </if> + <if test="status != null"> + #{status,jdbcType=VARCHAR}, + </if> + <if test="totalCPU != null"> + #{totalCPU,jdbcType=VARCHAR}, + </if> + <if test="totalMemory != null"> + #{totalMemory,jdbcType=VARCHAR}, + </if> + <if test="totalDisk != null"> + #{totalDisk,jdbcType=VARCHAR}, + </if> + <if test="usedCPU != null"> + #{usedCPU,jdbcType=VARCHAR}, + </if> + <if test="usedMemory != null"> + #{usedMemory,jdbcType=VARCHAR}, + </if> + <if test="usedDisk != null"> + #{usedDisk,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateSiteSelective" + parameterType="org.openo.nfvo.resmanagement.service.entity.SitesEntity"> + update site + <set> + <if test="name != null"> + NAME = #{name,jdbcType=VARCHAR}, + </if> + <if test="location != null"> + LOCATION = #{location,jdbcType=VARCHAR}, + </if> + <if test="country != null"> + COUNTRY = #{country,jdbcType=VARCHAR}, + </if> + <if test="vimId != null"> + VIM_ID = #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + VIM_NAME = #{vimName,jdbcType=VARCHAR}, + </if> + <if test="status != null"> + STATUS = #{status,jdbcType=VARCHAR}, + </if> + <if test="totalCPU != null"> + TOTAL_CPU = #{totalCPU,jdbcType=VARCHAR}, + </if> + <if test="totalMemory != null"> + TOTAL_MEMORY = #{totalMemory,jdbcType=VARCHAR}, + </if> + <if test="totalDisk != null"> + TOTAL_DISK = #{totalDisk,jdbcType=VARCHAR}, + </if> + <if test="usedCPU != null"> + USED_CPU = #{usedCPU,jdbcType=VARCHAR}, + </if> + <if test="usedMemory != null"> + USED_MEMORY = #{usedMemory,jdbcType=VARCHAR}, + </if> + <if test="usedDisk != null"> + USED_DISK = #{usedDisk,jdbcType=VARCHAR}, + </if> + </set> + where ID = #{id,jdbcType=VARCHAR} + </update> + <update id="updateSite" + parameterType="org.openo.nfvo.resmanagement.service.entity.SitesEntity"> + update site + set NAME = #{name,jdbcType=VARCHAR}, + LOCATION + = #{location,jdbcType=VARCHAR}, + COUNTRY = #{country,jdbcType=VARCHAR}, + VIM_ID = #{vimId,jdbcType=VARCHAR}, + VIM_NAME = + #{vimName,jdbcType=VARCHAR}, + STATUS = #{status,jdbcType=VARCHAR}, + TOTAL_CPU = #{totalCPU,jdbcType=VARCHAR}, + TOTAL_MEMORY = + #{totalMemory,jdbcType=VARCHAR}, + TOTAL_DISK = + #{totalDisk,jdbcType=VARCHAR}, + USED_CPU = #{usedCPU,jdbcType=VARCHAR}, + USED_MEMORY = #{usedMemory,jdbcType=VARCHAR}, + USED_DISK = + #{usedDisk,jdbcType=VARCHAR} + where ID = #{id,jdbcType=VARCHAR} + </update> + <update id="updateSiteByVimId" + parameterType="org.openo.nfvo.resmanagement.service.entity.SitesEntity"> + update site + <set> + <if test="id != null"> + ID = #{id,jdbcType=VARCHAR}, + </if> + <if test="name != null"> + NAME = #{name,jdbcType=VARCHAR}, + </if> + <if test="location != null"> + LOCATION = #{location,jdbcType=VARCHAR}, + </if> + <if test="country != null"> + COUNTRY = #{country,jdbcType=VARCHAR}, + </if> + <if test="vimName != null"> + VIM_NAME = #{vimName,jdbcType=VARCHAR}, + </if> + <if test="status != null"> + STATUS = #{status,jdbcType=VARCHAR}, + </if> + <if test="totalCPU != null"> + TOTAL_CPU = #{totalCPU,jdbcType=VARCHAR}, + </if> + <if test="totalMemory != null"> + TOTAL_MEMORY = #{totalMemory,jdbcType=VARCHAR}, + </if> + <if test="totalDisk != null"> + TOTAL_DISK = #{totalDisk,jdbcType=VARCHAR}, + </if> + <if test="usedCPU != null"> + USED_CPU = #{usedCPU,jdbcType=VARCHAR}, + </if> + <if test="usedMemory != null"> + USED_MEMORY = #{usedMemory,jdbcType=VARCHAR}, + </if> + <if test="usedDisk != null"> + USED_DISK = #{usedDisk,jdbcType=VARCHAR}, + </if> + </set> + where VIM_ID = #{vimId,jdbcType=VARCHAR} + </update> + +</mapper>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VimMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VimMapper.xml new file mode 100644 index 0000000..e6f38ef --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VimMapper.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- +Copyright 2016 Huawei Technologies Co., Ltd. + +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. +--> + +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.VimMapper"> + <resultMap id="BaseResultMap" + type="org.openo.nfvo.resmanagement.service.entity.VimEntity"> + <id column="ID" property="id" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List"> + ID + </sql> + <select id="getVim" resultMap="BaseResultMap" parameterType="java.lang.String"> + select + <include refid="Base_Column_List" /> + from vim + where ID = #{id,jdbcType=VARCHAR} + </select> + <select id="getVims" resultMap="BaseResultMap" parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from vim + <where> + <if test="id != null"> + AND ID = #{id,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteVim" parameterType="java.lang.String"> + delete from vim + where ID = #{id,jdbcType=VARCHAR} + </delete> + <insert id="addVim" + parameterType="org.openo.nfvo.resmanagement.service.entity.VimEntity"> + insert into vim (ID) + values (#{id,jdbcType=VARCHAR}) + </insert> +</mapper>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VirtualLinkMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VirtualLinkMapper.xml new file mode 100644 index 0000000..b4d2394 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VirtualLinkMapper.xml @@ -0,0 +1,273 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + Copyright 2016-2017, Huawei Technologies Co., Ltd. + + 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. + --> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.VirtualLinkMapper" > + <resultMap id="BaseResultMap" type="org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity" > + <id column="id" property="id" jdbcType="VARCHAR" /> + <result column="name" property="name" jdbcType="VARCHAR" /> + <result column="backend_id" property="backendId" jdbcType="VARCHAR" /> + <result column="is_public" property="isPublic" jdbcType="VARCHAR" /> + <result column="dc_name" property="dcName" jdbcType="VARCHAR" /> + <result column="vim_id" property="vimId" jdbcType="VARCHAR" /> + <result column="vim_name" property="vimName" jdbcType="VARCHAR" /> + <result column="physicial_net" property="physicialNet" jdbcType="VARCHAR" /> + <result column="ns_id" property="nsId" jdbcType="VARCHAR" /> + <result column="ns_name" property="nsName" jdbcType="VARCHAR" /> + <result column="description" property="description" jdbcType="VARCHAR" /> + <result column="network_type" property="networkType" jdbcType="VARCHAR" /> + <result column="segmentation" property="segmentation" jdbcType="VARCHAR" /> + <result column="mtu" property="mtu" jdbcType="VARCHAR" /> + <result column="vlan_transparent" property="vlanTransparent" jdbcType="VARCHAR" /> + <result column="router_external" property="routerExternal" jdbcType="VARCHAR" /> + <result column="resource_provider_type" property="resourceProviderType" jdbcType="VARCHAR" /> + <result column="resource_provider_id" property="resourceProviderId" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List" > + id, name, backend_id, is_public, dc_name, vim_id, vim_name, physicial_net, ns_id, + ns_name, description, network_type, segmentation, mtu, vlan_transparent, router_external, + resource_provider_type, resource_provider_id + </sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > + select + <include refid="Base_Column_List" /> + from vl + where id = #{id,jdbcType=VARCHAR} + </select> + <select id="getVls" resultMap="BaseResultMap" parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from vl + <where> + <if test="id != null"> + AND ID = #{id,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > + delete from vl + where id = #{id,jdbcType=VARCHAR} + </delete> + <insert id="insert" parameterType="org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity" > + insert into vl (id, name, backend_id, + is_public, dc_name, vim_id, + vim_name, physicial_net, ns_id, + ns_name, description, network_type, + segmentation, mtu, vlan_transparent, + router_external, resource_provider_type, resource_provider_id + ) + values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{backendId,jdbcType=VARCHAR}, + #{isPublic,jdbcType=VARCHAR}, #{dcName,jdbcType=VARCHAR}, #{vimId,jdbcType=VARCHAR}, + #{vimName,jdbcType=VARCHAR}, #{physicialNet,jdbcType=VARCHAR}, #{nsId,jdbcType=VARCHAR}, + #{nsName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{networkType,jdbcType=VARCHAR}, + #{segmentation,jdbcType=VARCHAR}, #{mtu,jdbcType=VARCHAR}, #{vlanTransparent,jdbcType=VARCHAR}, + #{routerExternal,jdbcType=VARCHAR}, #{resourceProviderType,jdbcType=VARCHAR}, #{resourceProviderId,jdbcType=VARCHAR} + ) + </insert> + <insert id="insertSelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity" > + insert into vl + <trim prefix="(" suffix=")" suffixOverrides="," > + <if test="id != null" > + id, + </if> + <if test="name != null" > + name, + </if> + <if test="backendId != null" > + backend_id, + </if> + <if test="isPublic != null" > + is_public, + </if> + <if test="dcName != null" > + dc_name, + </if> + <if test="vimId != null" > + vim_id, + </if> + <if test="vimName != null" > + vim_name, + </if> + <if test="physicialNet != null" > + physicial_net, + </if> + <if test="nsId != null" > + ns_id, + </if> + <if test="nsName != null" > + ns_name, + </if> + <if test="description != null" > + description, + </if> + <if test="networkType != null" > + network_type, + </if> + <if test="segmentation != null" > + segmentation, + </if> + <if test="mtu != null" > + mtu, + </if> + <if test="vlanTransparent != null" > + vlan_transparent, + </if> + <if test="routerExternal != null" > + router_external, + </if> + <if test="resourceProviderType != null" > + resource_provider_type, + </if> + <if test="resourceProviderId != null" > + resource_provider_id, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides="," > + <if test="id != null" > + #{id,jdbcType=VARCHAR}, + </if> + <if test="name != null" > + #{name,jdbcType=VARCHAR}, + </if> + <if test="backendId != null" > + #{backendId,jdbcType=VARCHAR}, + </if> + <if test="isPublic != null" > + #{isPublic,jdbcType=VARCHAR}, + </if> + <if test="dcName != null" > + #{dcName,jdbcType=VARCHAR}, + </if> + <if test="vimId != null" > + #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null" > + #{vimName,jdbcType=VARCHAR}, + </if> + <if test="physicialNet != null" > + #{physicialNet,jdbcType=VARCHAR}, + </if> + <if test="nsId != null" > + #{nsId,jdbcType=VARCHAR}, + </if> + <if test="nsName != null" > + #{nsName,jdbcType=VARCHAR}, + </if> + <if test="description != null" > + #{description,jdbcType=VARCHAR}, + </if> + <if test="networkType != null" > + #{networkType,jdbcType=VARCHAR}, + </if> + <if test="segmentation != null" > + #{segmentation,jdbcType=VARCHAR}, + </if> + <if test="mtu != null" > + #{mtu,jdbcType=VARCHAR}, + </if> + <if test="vlanTransparent != null" > + #{vlanTransparent,jdbcType=VARCHAR}, + </if> + <if test="routerExternal != null" > + #{routerExternal,jdbcType=VARCHAR}, + </if> + <if test="resourceProviderType != null" > + #{resourceProviderType,jdbcType=VARCHAR}, + </if> + <if test="resourceProviderId != null" > + #{resourceProviderId,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity" > + update vl + <set > + <if test="name != null" > + name = #{name,jdbcType=VARCHAR}, + </if> + <if test="backendId != null" > + backend_id = #{backendId,jdbcType=VARCHAR}, + </if> + <if test="isPublic != null" > + is_public = #{isPublic,jdbcType=VARCHAR}, + </if> + <if test="dcName != null" > + dc_name = #{dcName,jdbcType=VARCHAR}, + </if> + <if test="vimId != null" > + vim_id = #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null" > + vim_name = #{vimName,jdbcType=VARCHAR}, + </if> + <if test="physicialNet != null" > + physicial_net = #{physicialNet,jdbcType=VARCHAR}, + </if> + <if test="nsId != null" > + ns_id = #{nsId,jdbcType=VARCHAR}, + </if> + <if test="nsName != null" > + ns_name = #{nsName,jdbcType=VARCHAR}, + </if> + <if test="description != null" > + description = #{description,jdbcType=VARCHAR}, + </if> + <if test="networkType != null" > + network_type = #{networkType,jdbcType=VARCHAR}, + </if> + <if test="segmentation != null" > + segmentation = #{segmentation,jdbcType=VARCHAR}, + </if> + <if test="mtu != null" > + mtu = #{mtu,jdbcType=VARCHAR}, + </if> + <if test="vlanTransparent != null" > + vlan_transparent = #{vlanTransparent,jdbcType=VARCHAR}, + </if> + <if test="routerExternal != null" > + router_external = #{routerExternal,jdbcType=VARCHAR}, + </if> + <if test="resourceProviderType != null" > + resource_provider_type = #{resourceProviderType,jdbcType=VARCHAR}, + </if> + <if test="resourceProviderId != null" > + resource_provider_id = #{resourceProviderId,jdbcType=VARCHAR}, + </if> + </set> + where id = #{id,jdbcType=VARCHAR} + </update> + <update id="updateByPrimaryKey" parameterType="org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity" > + update vl + set name = #{name,jdbcType=VARCHAR}, + backend_id = #{backendId,jdbcType=VARCHAR}, + is_public = #{isPublic,jdbcType=VARCHAR}, + dc_name = #{dcName,jdbcType=VARCHAR}, + vim_id = #{vimId,jdbcType=VARCHAR}, + vim_name = #{vimName,jdbcType=VARCHAR}, + physicial_net = #{physicialNet,jdbcType=VARCHAR}, + ns_id = #{nsId,jdbcType=VARCHAR}, + ns_name = #{nsName,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + network_type = #{networkType,jdbcType=VARCHAR}, + segmentation = #{segmentation,jdbcType=VARCHAR}, + mtu = #{mtu,jdbcType=VARCHAR}, + vlan_transparent = #{vlanTransparent,jdbcType=VARCHAR}, + router_external = #{routerExternal,jdbcType=VARCHAR}, + resource_provider_type = #{resourceProviderType,jdbcType=VARCHAR}, + resource_provider_id = #{resourceProviderId,jdbcType=VARCHAR} + where id = #{id,jdbcType=VARCHAR} + </update> +</mapper>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VmMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VmMapper.xml new file mode 100644 index 0000000..dc2376c --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VmMapper.xml @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + Copyright 2016-2017, Huawei Technologies Co., Ltd. + + 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. + --> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.VmMapper" > + <resultMap id="BaseResultMap" type="org.openo.nfvo.resmanagement.service.entity.VmEntity" > + <id column="vm_id" property="vmId" jdbcType="VARCHAR" /> + <result column="vm_name" property="vmName" jdbcType="VARCHAR" /> + <result column="vm_status" property="vmStatus" jdbcType="VARCHAR" /> + <result column="vnf_instance_id" property="vnfInstanceId" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List" > + vm_id, vm_name, vm_status, vnf_instance_id + </sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > + select + <include refid="Base_Column_List" /> + from vm + where vm_id = #{vmId,jdbcType=VARCHAR} + </select> + <select id="getVms" resultMap="BaseResultMap" parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from vm + <where> + <if test="vmId != null"> + AND vm_id = #{vmId,jdbcType=VARCHAR} + </if> + <if test="vnfInstanceId != null"> + AND vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > + delete from vm + where vm_id = #{vmId,jdbcType=VARCHAR} + </delete> + <delete id="deleteByVnfId" parameterType="java.lang.String" > + delete from vm + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </delete> + <insert id="insert" parameterType="org.openo.nfvo.resmanagement.service.entity.VmEntity" > + insert into vm (vm_id, vm_name, vm_status, + vnf_instance_id) + values (#{vmId,jdbcType=VARCHAR}, #{vmName,jdbcType=VARCHAR}, #{vmStatus,jdbcType=VARCHAR}, + #{vnfInstanceId,jdbcType=VARCHAR}) + </insert> + <insert id="insertSelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VmEntity" > + insert into vm + <trim prefix="(" suffix=")" suffixOverrides="," > + <if test="vmId != null" > + vm_id, + </if> + <if test="vmName != null" > + vm_name, + </if> + <if test="vmStatus != null" > + vm_status, + </if> + <if test="vnfInstanceId != null" > + vnf_instance_id, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides="," > + <if test="vmId != null" > + #{vmId,jdbcType=VARCHAR}, + </if> + <if test="vmName != null" > + #{vmName,jdbcType=VARCHAR}, + </if> + <if test="vmStatus != null" > + #{vmStatus,jdbcType=VARCHAR}, + </if> + <if test="vnfInstanceId != null" > + #{vnfInstanceId,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VmEntity" > + update vm + <set > + <if test="vmName != null" > + vm_name = #{vmName,jdbcType=VARCHAR}, + </if> + <if test="vmStatus != null" > + vm_status = #{vmStatus,jdbcType=VARCHAR}, + </if> + <if test="vnfInstanceId != null" > + vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR}, + </if> + </set> + where vm_id = #{vmId,jdbcType=VARCHAR} + </update> + <update id="updateByPrimaryKey" parameterType="org.openo.nfvo.resmanagement.service.entity.VmEntity" > + update vm + set vm_name = #{vmName,jdbcType=VARCHAR}, + vm_status = #{vmStatus,jdbcType=VARCHAR}, + vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + where vm_id = #{vmId,jdbcType=VARCHAR} + </update> +</mapper>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfInfoMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfInfoMapper.xml new file mode 100644 index 0000000..135ccc1 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfInfoMapper.xml @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + Copyright 2016-2017, Huawei Technologies Co., Ltd. + + 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. + --> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.VnfInfoMapper" > + <resultMap id="BaseResultMap" type="org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity" > + <id column="vnf_instance_id" property="vnfInstanceId" jdbcType="VARCHAR" /> + <result column="ns_id" property="nsId" jdbcType="VARCHAR" /> + <result column="vnfm_id" property="vnfmId" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List" > + vnf_instance_id, ns_id, vnfm_id + </sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > + select + <include refid="Base_Column_List" /> + from vnfinfo + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </select> + <select id="getVnfInfos" resultMap="BaseResultMap" parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from vnf + <where> + <if test="vnfInstanceId != null"> + AND vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > + delete from vnfinfo + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </delete> + <insert id="insert" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity" > + insert into vnfinfo (vnf_instance_id, ns_id, vnfm_id + ) + values (#{vnfInstanceId,jdbcType=VARCHAR}, #{nsId,jdbcType=VARCHAR}, #{vnfmId,jdbcType=VARCHAR} + ) + </insert> + <insert id="insertSelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity" > + insert into vnfinfo + <trim prefix="(" suffix=")" suffixOverrides="," > + <if test="vnfInstanceId != null" > + vnf_instance_id, + </if> + <if test="nsId != null" > + ns_id, + </if> + <if test="vnfmId != null" > + vnfm_id, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides="," > + <if test="vnfInstanceId != null" > + #{vnfInstanceId,jdbcType=VARCHAR}, + </if> + <if test="nsId != null" > + #{nsId,jdbcType=VARCHAR}, + </if> + <if test="vnfmId != null" > + #{vnfmId,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity" > + update vnfinfo + <set > + <if test="nsId != null" > + ns_id = #{nsId,jdbcType=VARCHAR}, + </if> + <if test="vnfmId != null" > + vnfm_id = #{vnfmId,jdbcType=VARCHAR}, + </if> + </set> + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </update> + <update id="updateByPrimaryKey" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity" > + update vnfinfo + set ns_id = #{nsId,jdbcType=VARCHAR}, + vnfm_id = #{vnfmId,jdbcType=VARCHAR} + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </update> +</mapper>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfMapper.xml new file mode 100644 index 0000000..cd187c3 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfMapper.xml @@ -0,0 +1,319 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + Copyright 2016-2017, Huawei Technologies Co., Ltd. + + 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. + --> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.VnfMapper" > + <resultMap id="BaseResultMap" type="org.openo.nfvo.resmanagement.service.entity.VnfEntity" > + <id column="id" property="id" jdbcType="VARCHAR" /> + <result column="vnf_instance_id" property="vnfInstanceId" jdbcType="VARCHAR" /> + <result column="vnf_instance_name" property="vnfInstanceName" jdbcType="VARCHAR" /> + <result column="ns_id" property="nsId" jdbcType="VARCHAR" /> + <result column="ns_name" property="nsName" jdbcType="VARCHAR" /> + <result column="vnfm_id" property="vnfmId" jdbcType="VARCHAR" /> + <result column="vnfm_name" property="vnfmName" jdbcType="VARCHAR" /> + <result column="vnf_package_name" property="vnfPackageName" jdbcType="VARCHAR" /> + <result column="vnf_descriptor_name" property="vnfDescriptorName" jdbcType="VARCHAR" /> + <result column="vim_id" property="vimId" jdbcType="VARCHAR" /> + <result column="vim_name" property="vimName" jdbcType="VARCHAR" /> + <result column="vim_tenant" property="vimTenant" jdbcType="VARCHAR" /> + <result column="job_id" property="jobId" jdbcType="VARCHAR" /> + <result column="vnf_status" property="vnfStatus" jdbcType="VARCHAR" /> + <result column="vnf_type" property="vnfType" jdbcType="VARCHAR" /> + <result column="max_vm" property="maxVm" jdbcType="INTEGER" /> + <result column="max_cpu" property="maxCpu" jdbcType="INTEGER" /> + <result column="max_disk" property="maxDisk" jdbcType="INTEGER" /> + <result column="max_ram" property="maxRam" jdbcType="INTEGER" /> + <result column="max_shd" property="maxShd" jdbcType="INTEGER" /> + <result column="max_net" property="maxNet" jdbcType="INTEGER" /> + <result column="name" property="name" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List" > + id, vnf_instance_id, vnf_instance_name, ns_id, ns_name, vnfm_id, vnfm_name, vnf_package_name, + vnf_descriptor_name, vim_id, vim_name, vim_tenant, job_id, vnf_status, vnf_type, + max_vm, max_cpu, max_disk, max_ram, max_shd, max_net, name + </sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > + select + <include refid="Base_Column_List" /> + from vnf + where id = #{id,jdbcType=VARCHAR} + </select> + <select id="getVnfs" resultMap="BaseResultMap" parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from vnf + <where> + <if test="id != null"> + AND ID = #{id,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > + delete from vnf + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </delete> + <insert id="insert" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfEntity" > + insert into vnf (id, vnf_instance_id, vnf_instance_name, + ns_id, ns_name, vnfm_id, + vnfm_name, vnf_package_name, vnf_descriptor_name, + vim_id, vim_name, vim_tenant, + job_id, vnf_status, vnf_type, + max_vm, max_cpu, max_disk, + max_ram, max_shd, max_net, + name) + values (#{id,jdbcType=VARCHAR}, #{vnfInstanceId,jdbcType=VARCHAR}, #{vnfInstanceName,jdbcType=VARCHAR}, + #{nsId,jdbcType=VARCHAR}, #{nsName,jdbcType=VARCHAR}, #{vnfmId,jdbcType=VARCHAR}, + #{vnfmName,jdbcType=VARCHAR}, #{vnfPackageName,jdbcType=VARCHAR}, #{vnfDescriptorName,jdbcType=VARCHAR}, + #{vimId,jdbcType=VARCHAR}, #{vimName,jdbcType=VARCHAR}, #{vimTenant,jdbcType=VARCHAR}, + #{jobId,jdbcType=VARCHAR}, #{vnfStatus,jdbcType=VARCHAR}, #{vnfType,jdbcType=VARCHAR}, + #{maxVm,jdbcType=INTEGER}, #{maxCpu,jdbcType=INTEGER}, #{maxDisk,jdbcType=INTEGER}, + #{maxRam,jdbcType=INTEGER}, #{maxShd,jdbcType=INTEGER}, #{maxNet,jdbcType=INTEGER}, + #{name,jdbcType=VARCHAR}) + </insert> + <insert id="insertSelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfEntity" > + insert into vnf + <trim prefix="(" suffix=")" suffixOverrides="," > + <if test="id != null" > + id, + </if> + <if test="vnfInstanceId != null" > + vnf_instance_id, + </if> + <if test="vnfInstanceName != null" > + vnf_instance_name, + </if> + <if test="nsId != null" > + ns_id, + </if> + <if test="nsName != null" > + ns_name, + </if> + <if test="vnfmId != null" > + vnfm_id, + </if> + <if test="vnfmName != null" > + vnfm_name, + </if> + <if test="vnfPackageName != null" > + vnf_package_name, + </if> + <if test="vnfDescriptorName != null" > + vnf_descriptor_name, + </if> + <if test="vimId != null" > + vim_id, + </if> + <if test="vimName != null" > + vim_name, + </if> + <if test="vimTenant != null" > + vim_tenant, + </if> + <if test="jobId != null" > + job_id, + </if> + <if test="vnfStatus != null" > + vnf_status, + </if> + <if test="vnfType != null" > + vnf_type, + </if> + <if test="maxVm != null" > + max_vm, + </if> + <if test="maxCpu != null" > + max_cpu, + </if> + <if test="maxDisk != null" > + max_disk, + </if> + <if test="maxRam != null" > + max_ram, + </if> + <if test="maxShd != null" > + max_shd, + </if> + <if test="maxNet != null" > + max_net, + </if> + <if test="name != null" > + name, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides="," > + <if test="id != null" > + #{id,jdbcType=VARCHAR}, + </if> + <if test="vnfInstanceId != null" > + #{vnfInstanceId,jdbcType=VARCHAR}, + </if> + <if test="vnfInstanceName != null" > + #{vnfInstanceName,jdbcType=VARCHAR}, + </if> + <if test="nsId != null" > + #{nsId,jdbcType=VARCHAR}, + </if> + <if test="nsName != null" > + #{nsName,jdbcType=VARCHAR}, + </if> + <if test="vnfmId != null" > + #{vnfmId,jdbcType=VARCHAR}, + </if> + <if test="vnfmName != null" > + #{vnfmName,jdbcType=VARCHAR}, + </if> + <if test="vnfPackageName != null" > + #{vnfPackageName,jdbcType=VARCHAR}, + </if> + <if test="vnfDescriptorName != null" > + #{vnfDescriptorName,jdbcType=VARCHAR}, + </if> + <if test="vimId != null" > + #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null" > + #{vimName,jdbcType=VARCHAR}, + </if> + <if test="vimTenant != null" > + #{vimTenant,jdbcType=VARCHAR}, + </if> + <if test="jobId != null" > + #{jobId,jdbcType=VARCHAR}, + </if> + <if test="vnfStatus != null" > + #{vnfStatus,jdbcType=VARCHAR}, + </if> + <if test="vnfType != null" > + #{vnfType,jdbcType=VARCHAR}, + </if> + <if test="maxVm != null" > + #{maxVm,jdbcType=INTEGER}, + </if> + <if test="maxCpu != null" > + #{maxCpu,jdbcType=INTEGER}, + </if> + <if test="maxDisk != null" > + #{maxDisk,jdbcType=INTEGER}, + </if> + <if test="maxRam != null" > + #{maxRam,jdbcType=INTEGER}, + </if> + <if test="maxShd != null" > + #{maxShd,jdbcType=INTEGER}, + </if> + <if test="maxNet != null" > + #{maxNet,jdbcType=INTEGER}, + </if> + <if test="name != null" > + #{name,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfEntity" > + update vnf + <set > + <if test="vnfInstanceId != null" > + vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR}, + </if> + <if test="vnfInstanceName != null" > + vnf_instance_name = #{vnfInstanceName,jdbcType=VARCHAR}, + </if> + <if test="nsId != null" > + ns_id = #{nsId,jdbcType=VARCHAR}, + </if> + <if test="nsName != null" > + ns_name = #{nsName,jdbcType=VARCHAR}, + </if> + <if test="vnfmId != null" > + vnfm_id = #{vnfmId,jdbcType=VARCHAR}, + </if> + <if test="vnfmName != null" > + vnfm_name = #{vnfmName,jdbcType=VARCHAR}, + </if> + <if test="vnfPackageName != null" > + vnf_package_name = #{vnfPackageName,jdbcType=VARCHAR}, + </if> + <if test="vnfDescriptorName != null" > + vnf_descriptor_name = #{vnfDescriptorName,jdbcType=VARCHAR}, + </if> + <if test="vimId != null" > + vim_id = #{vimId,jdbcType=VARCHAR}, + </if> + <if test="vimName != null" > + vim_name = #{vimName,jdbcType=VARCHAR}, + </if> + <if test="vimTenant != null" > + vim_tenant = #{vimTenant,jdbcType=VARCHAR}, + </if> + <if test="jobId != null" > + job_id = #{jobId,jdbcType=VARCHAR}, + </if> + <if test="vnfStatus != null" > + vnf_status = #{vnfStatus,jdbcType=VARCHAR}, + </if> + <if test="vnfType != null" > + vnf_type = #{vnfType,jdbcType=VARCHAR}, + </if> + <if test="maxVm != null" > + max_vm = #{maxVm,jdbcType=INTEGER}, + </if> + <if test="maxCpu != null" > + max_cpu = #{maxCpu,jdbcType=INTEGER}, + </if> + <if test="maxDisk != null" > + max_disk = #{maxDisk,jdbcType=INTEGER}, + </if> + <if test="maxRam != null" > + max_ram = #{maxRam,jdbcType=INTEGER}, + </if> + <if test="maxShd != null" > + max_shd = #{maxShd,jdbcType=INTEGER}, + </if> + <if test="maxNet != null" > + max_net = #{maxNet,jdbcType=INTEGER}, + </if> + <if test="name != null" > + name = #{name,jdbcType=VARCHAR}, + </if> + </set> + where id = #{id,jdbcType=VARCHAR} + </update> + <update id="updateByPrimaryKey" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfEntity" > + update vnf + set vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR}, + vnf_instance_name = #{vnfInstanceName,jdbcType=VARCHAR}, + ns_id = #{nsId,jdbcType=VARCHAR}, + ns_name = #{nsName,jdbcType=VARCHAR}, + vnfm_id = #{vnfmId,jdbcType=VARCHAR}, + vnfm_name = #{vnfmName,jdbcType=VARCHAR}, + vnf_package_name = #{vnfPackageName,jdbcType=VARCHAR}, + vnf_descriptor_name = #{vnfDescriptorName,jdbcType=VARCHAR}, + vim_id = #{vimId,jdbcType=VARCHAR}, + vim_name = #{vimName,jdbcType=VARCHAR}, + vim_tenant = #{vimTenant,jdbcType=VARCHAR}, + job_id = #{jobId,jdbcType=VARCHAR}, + vnf_status = #{vnfStatus,jdbcType=VARCHAR}, + vnf_type = #{vnfType,jdbcType=VARCHAR}, + max_vm = #{maxVm,jdbcType=INTEGER}, + max_cpu = #{maxCpu,jdbcType=INTEGER}, + max_disk = #{maxDisk,jdbcType=INTEGER}, + max_ram = #{maxRam,jdbcType=INTEGER}, + max_shd = #{maxShd,jdbcType=INTEGER}, + max_net = #{maxNet,jdbcType=INTEGER}, + name = #{name,jdbcType=VARCHAR} + where id = #{id,jdbcType=VARCHAR} + </update> +</mapper>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfStatusMapper.xml b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfStatusMapper.xml new file mode 100644 index 0000000..08a5101 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/mybatis/mysql/VnfStatusMapper.xml @@ -0,0 +1,213 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + Copyright 2016-2017, Huawei Technologies Co., Ltd. + + 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. + --> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > +<mapper namespace="org.openo.nfvo.resmanagement.service.mapper.VnfStatusMapper" > + <resultMap id="BaseResultMap" type="org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity" > + <id column="vnf_instance_id" property="vnfInstanceId" jdbcType="VARCHAR" /> + <result column="job_id" property="jobId" jdbcType="VARCHAR" /> + <result column="ns_id" property="nsId" jdbcType="VARCHAR" /> + <result column="vnfm_id" property="vnfmId" jdbcType="VARCHAR" /> + <result column="response_descriptor" property="responseDescriptor" jdbcType="VARCHAR" /> + <result column="status" property="status" jdbcType="VARCHAR" /> + <result column="progress" property="progress" jdbcType="VARCHAR" /> + <result column="status_description" property="statusDescription" jdbcType="VARCHAR" /> + <result column="error_code" property="errorCode" jdbcType="VARCHAR" /> + <result column="response_id" property="responseId" jdbcType="VARCHAR" /> + <result column="response_history_list" property="responseHistoryList" jdbcType="VARCHAR" /> + <result column="add_vm" property="addVm" jdbcType="VARCHAR" /> + <result column="del_vm" property="delVm" jdbcType="VARCHAR" /> + </resultMap> + <sql id="Base_Column_List" > + vnf_instance_id, job_id, ns_id, vnfm_id, response_descriptor, status, progress, status_description, + error_code, response_id, response_history_list, add_vm, del_vm + </sql> + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" > + select + <include refid="Base_Column_List" /> + from vnfstatus + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </select> + <select id="getVnfStatuss" resultMap="BaseResultMap" parameterType="java.util.Map"> + select + <include refid="Base_Column_List" /> + from vnfstatus + <where> + <if test="vnfInstanceId != null"> + AND vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </if> + </where> + </select> + <delete id="deleteByPrimaryKey" parameterType="java.lang.String" > + delete from vnfstatus + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </delete> + <insert id="insert" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity" > + insert into vnfstatus (vnf_instance_id, job_id, ns_id, + vnfm_id, response_descriptor, status, + progress, status_description, error_code, + response_id, response_history_list, add_vm, + del_vm) + values (#{vnfInstanceId,jdbcType=VARCHAR}, #{jobId,jdbcType=VARCHAR}, #{nsId,jdbcType=VARCHAR}, + #{vnfmId,jdbcType=VARCHAR}, #{responseDescriptor,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, + #{progress,jdbcType=VARCHAR}, #{statusDescription,jdbcType=VARCHAR}, #{errorCode,jdbcType=VARCHAR}, + #{responseId,jdbcType=VARCHAR}, #{responseHistoryList,jdbcType=VARCHAR}, #{addVm,jdbcType=VARCHAR}, + #{delVm,jdbcType=VARCHAR}) + </insert> + <insert id="insertSelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity" > + insert into vnfstatus + <trim prefix="(" suffix=")" suffixOverrides="," > + <if test="vnfInstanceId != null" > + vnf_instance_id, + </if> + <if test="jobId != null" > + job_id, + </if> + <if test="nsId != null" > + ns_id, + </if> + <if test="vnfmId != null" > + vnfm_id, + </if> + <if test="responseDescriptor != null" > + response_descriptor, + </if> + <if test="status != null" > + status, + </if> + <if test="progress != null" > + progress, + </if> + <if test="statusDescription != null" > + status_description, + </if> + <if test="errorCode != null" > + error_code, + </if> + <if test="responseId != null" > + response_id, + </if> + <if test="responseHistoryList != null" > + response_history_list, + </if> + <if test="addVm != null" > + add_vm, + </if> + <if test="delVm != null" > + del_vm, + </if> + </trim> + <trim prefix="values (" suffix=")" suffixOverrides="," > + <if test="vnfInstanceId != null" > + #{vnfInstanceId,jdbcType=VARCHAR}, + </if> + <if test="jobId != null" > + #{jobId,jdbcType=VARCHAR}, + </if> + <if test="nsId != null" > + #{nsId,jdbcType=VARCHAR}, + </if> + <if test="vnfmId != null" > + #{vnfmId,jdbcType=VARCHAR}, + </if> + <if test="responseDescriptor != null" > + #{responseDescriptor,jdbcType=VARCHAR}, + </if> + <if test="status != null" > + #{status,jdbcType=VARCHAR}, + </if> + <if test="progress != null" > + #{progress,jdbcType=VARCHAR}, + </if> + <if test="statusDescription != null" > + #{statusDescription,jdbcType=VARCHAR}, + </if> + <if test="errorCode != null" > + #{errorCode,jdbcType=VARCHAR}, + </if> + <if test="responseId != null" > + #{responseId,jdbcType=VARCHAR}, + </if> + <if test="responseHistoryList != null" > + #{responseHistoryList,jdbcType=VARCHAR}, + </if> + <if test="addVm != null" > + #{addVm,jdbcType=VARCHAR}, + </if> + <if test="delVm != null" > + #{delVm,jdbcType=VARCHAR}, + </if> + </trim> + </insert> + <update id="updateByPrimaryKeySelective" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity" > + update vnfstatus + <set > + <if test="jobId != null" > + job_id = #{jobId,jdbcType=VARCHAR}, + </if> + <if test="nsId != null" > + ns_id = #{nsId,jdbcType=VARCHAR}, + </if> + <if test="vnfmId != null" > + vnfm_id = #{vnfmId,jdbcType=VARCHAR}, + </if> + <if test="responseDescriptor != null" > + response_descriptor = #{responseDescriptor,jdbcType=VARCHAR}, + </if> + <if test="status != null" > + status = #{status,jdbcType=VARCHAR}, + </if> + <if test="progress != null" > + progress = #{progress,jdbcType=VARCHAR}, + </if> + <if test="statusDescription != null" > + status_description = #{statusDescription,jdbcType=VARCHAR}, + </if> + <if test="errorCode != null" > + error_code = #{errorCode,jdbcType=VARCHAR}, + </if> + <if test="responseId != null" > + response_id = #{responseId,jdbcType=VARCHAR}, + </if> + <if test="responseHistoryList != null" > + response_history_list = #{responseHistoryList,jdbcType=VARCHAR}, + </if> + <if test="addVm != null" > + add_vm = #{addVm,jdbcType=VARCHAR}, + </if> + <if test="delVm != null" > + del_vm = #{delVm,jdbcType=VARCHAR}, + </if> + </set> + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </update> + <update id="updateByPrimaryKey" parameterType="org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity" > + update vnfstatus + set job_id = #{jobId,jdbcType=VARCHAR}, + ns_id = #{nsId,jdbcType=VARCHAR}, + vnfm_id = #{vnfmId,jdbcType=VARCHAR}, + response_descriptor = #{responseDescriptor,jdbcType=VARCHAR}, + status = #{status,jdbcType=VARCHAR}, + progress = #{progress,jdbcType=VARCHAR}, + status_description = #{statusDescription,jdbcType=VARCHAR}, + error_code = #{errorCode,jdbcType=VARCHAR}, + response_id = #{responseId,jdbcType=VARCHAR}, + response_history_list = #{responseHistoryList,jdbcType=VARCHAR}, + add_vm = #{addVm,jdbcType=VARCHAR}, + del_vm = #{delVm,jdbcType=VARCHAR} + where vnf_instance_id = #{vnfInstanceId,jdbcType=VARCHAR} + </update> +</mapper>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/spring/Resmanagement/services.xml b/ResmanagementService/service/src/main/resources/spring/Resmanagement/services.xml new file mode 100644 index 0000000..a24efd5 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/spring/Resmanagement/services.xml @@ -0,0 +1,331 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 2016, Huawei Technologies Co., Ltd. + + 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. + --> + +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:aop="http://www.springframework.org/schema/aop" + xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:osgix="http://www.springframework.org/schema/osgi-compendium" + xmlns:ctx="http://www.springframework.org/schema/context" + xmlns:jaxrs="http://cxf.apache.org/jaxrs" + xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/osgi + http://www.springframework.org/schema/osgi/spring-osgi.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/osgi-compendium + http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd + http://cxf.apache.org/jaxrs + http://cxf.apache.org/schemas/jaxrs.xsd + http://cxf.apache.org/transports/http/configuration + http://cxf.apache.org/schemas/configuration/http-conf.xsd + http://www.springframework.org/schema/aop + http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> + + <!-- these are included in the dependency jar --> + <import resource="classpath:META-INF/cxf/cxf.xml" /> + <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> + + <bean id="jsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" /> + + <bean id="source" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> + <property name="driverClassName" value="com.mysql.jdbc.Driver"/> + <property name="url" value="jdbc:mysql://127.0.0.1:3306/resmanagementdb"/> + <property name="username" value="root"/> + <property name="password" value="rootpass"/> + </bean> + + <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> + <property name="dataSource" ref="source" /> + <property name="mapperLocations" value="classpath*:mybatis/mysql/*.xml" /> + <!-- <property name="configLocation" value="classpath:mybatis-config.xml" /> --> + </bean> + + <bean id="session" class="org.mybatis.spring.SqlSessionTemplate"> + <constructor-arg index="0" ref="sessionFactory" /> + </bean> + + <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> + <property name="dataSource" ref="source" /> + </bean> + + <!--location --> + <bean id="locationDao" + class="org.openo.nfvo.resmanagement.service.dao.impl.LocationDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="locationBusiness" + class="org.openo.nfvo.resmanagement.service.business.impl.LocationBusinessImpl"> + <property name="locationDao" ref="locationDao"></property> + </bean> + + <bean id="location" + class="org.openo.nfvo.resmanagement.service.base.openstack.impl.LocationImpl"> + <property name="locationBusiness" ref="locationBusiness"></property> + </bean> + + <bean id="locationRoa" class="org.openo.nfvo.resmanagement.service.rest.LocationRoa"> + <property name="location" ref="location"></property> + <property name="sites" ref="sites"></property> + </bean> + + <!--port --> + <bean id="portDao" + class="org.openo.nfvo.resmanagement.service.dao.impl.PortDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="portBusiness" + class="org.openo.nfvo.resmanagement.service.business.impl.PortBusinessImpl"> + <property name="portDao" ref="portDao"></property> + </bean> + + <bean id="port" + class="org.openo.nfvo.resmanagement.service.base.openstack.impl.PortImpl"> + <property name="portBusiness" ref="portBusiness"></property> + </bean> + + <bean id="portRoa" class="org.openo.nfvo.resmanagement.service.rest.PortRoa"> + <property name="port" ref="port"></property> + </bean> + + <!--host --> + <bean id="hostDao" + class="org.openo.nfvo.resmanagement.service.dao.impl.HostDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="hostBusiness" + class="org.openo.nfvo.resmanagement.service.business.impl.HostBusinessImpl"> + <property name="hostDao" ref="hostDao"></property> + </bean> + + <bean id="host" + class="org.openo.nfvo.resmanagement.service.base.openstack.impl.HostImpl"> + <property name="hostBusiness" ref="hostBusiness"></property> + </bean> + + <bean id="hostRoa" class="org.openo.nfvo.resmanagement.service.rest.HostRoa"> + <property name="host" ref="host"></property> + </bean> + + <!--network --> + <bean id="networkDao" + class="org.openo.nfvo.resmanagement.service.dao.impl.NetworkDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="networkBusiness" + class="org.openo.nfvo.resmanagement.service.business.impl.NetworkBusinessImpl"> + <property name="networkDao" ref="networkDao"></property> + </bean> + + <bean id="network" + class="org.openo.nfvo.resmanagement.service.base.openstack.impl.NetworkImpl"> + <property name="networkBusiness" ref="networkBusiness"></property> + </bean> + + <bean id="networkRoa" class="org.openo.nfvo.resmanagement.service.rest.NetworkRoa"> + <property name="network" ref="network"></property> + </bean> + + <!--sites --> + <bean id="sitesDao" + class="org.openo.nfvo.resmanagement.service.dao.impl.SitesDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="sitesBusiness" + class="org.openo.nfvo.resmanagement.service.business.impl.SitesBusinessImpl"> + <property name="sitesDao" ref="sitesDao"></property> + </bean> + + <bean id="sites" + class="org.openo.nfvo.resmanagement.service.base.openstack.impl.SitesImpl"> + <property name="sitesBusiness" ref="sitesBusiness"></property> + <property name="limitsBusiness" ref="limitsBusiness"></property> + <property name="resOperateService" ref="resOperateService"></property> + </bean> + + <bean id="sitesRoa" class="org.openo.nfvo.resmanagement.service.rest.SitesRoa"> + <property name="sites" ref="sites"></property> + </bean> + + <!--vim --> + <bean id="vimDao" + class="org.openo.nfvo.resmanagement.service.dao.impl.VimDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="vimBusiness" + class="org.openo.nfvo.resmanagement.service.business.impl.VimBusinessImpl"> + <property name="vimDao" ref="vimDao"></property> + </bean> + + <bean id="vim" + class="org.openo.nfvo.resmanagement.service.base.openstack.impl.VimImpl"> + <property name="vimBusiness" ref="vimBusiness"></property> + </bean> + + <!-- limits --> + <bean id="limitsBusiness" + class="org.openo.nfvo.resmanagement.service.business.impl.LimitsBusinessImpl"> + </bean> + + <bean id="limitsRoa" class="org.openo.nfvo.resmanagement.service.rest.LimitsRoa"> + <property name="limitsBusiness" ref="limitsBusiness"></property> + </bean> + + <!-- vl --> + <bean id="virtualLinkDao" + class="org.openo.nfvo.resmanagement.service.dao.impl.VirtualLinkDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="virtualLink" + class="org.openo.nfvo.resmanagement.service.group.impl.VirtualLinkServiceImpl"> + <property name="virtualLinkDao" ref="virtualLinkDao"></property> + </bean> + + <bean id="virtualLinkRoa" class="org.openo.nfvo.resmanagement.service.rest.VirtualLinkRoa"> + <property name="virtualLink" ref="virtualLink"></property> + </bean> + + <!-- vnf --> + <bean id="vnfDao" + class="org.openo.nfvo.resmanagement.service.dao.impl.VnfDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="vnfService" + class="org.openo.nfvo.resmanagement.service.group.impl.VnfServiceImpl"> + <property name="vnfDao" ref="vnfDao"></property> + <property name="vnfInfoService" ref="vnfInfoService"></property> + </bean> + + <bean id="vnfRoa" class="org.openo.nfvo.resmanagement.service.rest.VnfRoa"> + <property name="vnfService" ref="vnfService"></property> + </bean> + + <!-- vm --> + <bean id="vmDao" class="org.openo.nfvo.resmanagement.service.dao.impl.VmDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="vmService" class="org.openo.nfvo.resmanagement.service.group.impl.VmServiceImpl"> + <property name="vmDao" ref="vmDao"></property> + </bean> + + <bean id="vmRoa" class="org.openo.nfvo.resmanagement.service.rest.VmRoa"> + <property name="vmService" ref="vmService"></property> + </bean> + + <!-- vnfInfo --> + <bean id="vnfInfoDao" + class="org.openo.nfvo.resmanagement.service.dao.impl.VnfInfoDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="vnfInfoService" + class="org.openo.nfvo.resmanagement.service.group.impl.VnfInfoServiceImpl"> + <property name="vnfInfoDao" ref="vnfInfoDao"></property> + <property name="vmService" ref="vmService"></property> + </bean> + + <bean id="vnfInfoRoa" class="org.openo.nfvo.resmanagement.service.rest.VnfInfoRoa"> + <property name="vnfInfoService" ref="vnfInfoService"></property> + </bean> + + <!-- vnfstatus --> + <bean id="vnfStatusDao" class="org.openo.nfvo.resmanagement.service.dao.impl.VnfStatusDaoImpl"> + <property name="session" ref="session"></property> + </bean> + + <bean id="vnfStatusService" class="org.openo.nfvo.resmanagement.service.group.impl.VnfStatusServiceImpl"> + <property name="vnfStatusDao" ref="vnfStatusDao"></property> + </bean> + + <bean id="vnfStatusRoa" class="org.openo.nfvo.resmanagement.service.rest.VnfStatusRoa"> + <property name="vnfStatusService" ref="vnfStatusService"></property> + </bean> + + <!-- grantResource --> + <bean id="grantResService" class="org.openo.nfvo.resmanagement.service.group.impl.GrantResServiceImpl"> + <property name="sites" ref="sites"></property> + </bean> + + <bean id="grantResourseRoa" class="org.openo.nfvo.resmanagement.service.rest.GrantResourseRoa"> + <property name="grantResService" ref="grantResService"></property> + </bean> + + <!--group_resoperate --> + <bean id="resOperateService" + class="org.openo.nfvo.resmanagement.service.group.impl.ResOperateServiceImpl"> + <property name="host" ref="host"></property> + <property name="port" ref="port"></property> + <property name="sites" ref="sites"></property> + <property name="network" ref="network"></property> + <property name="vim" ref="vim"></property> + <property name="iResourceUpdateServiceImpl" ref="iResourceUpdateServiceImpl"></property> + <property name="iResourceAddServiceImpl" ref="iResourceAddServiceImpl"></property> + <property name="iResourceDelServiceImpl" ref="iResourceDelServiceImpl"></property> + </bean> + + <bean id="iResourceUpdateServiceImpl" + class="org.openo.nfvo.resmanagement.service.group.impl.IResourceUpdateServiceImpl"> + </bean> + + <bean id="iResourceAddServiceImpl" + class="org.openo.nfvo.resmanagement.service.group.impl.IResourceAddServiceImpl"> + </bean> + + <bean id="iResourceDelServiceImpl" + class="org.openo.nfvo.resmanagement.service.group.impl.IResourceDelServiceImpl"> + </bean> + + <bean id="resOperateRoa" class="org.openo.nfvo.resmanagement.service.rest.ResOperateRoa"> + <property name="resOperateService" ref="resOperateService"></property> + </bean> + + <bean id="SwaggerRoa" class="org.openo.nfvo.resmanagement.service.rest.SwaggerRoa"></bean> + + <jaxrs:server id="restContainer" address="/"> + <jaxrs:serviceBeans> + <ref bean="locationRoa" /> + <ref bean="portRoa" /> + <ref bean="hostRoa" /> + <ref bean="networkRoa" /> + <ref bean="sitesRoa" /> + <ref bean="resOperateRoa" /> + <ref bean="limitsRoa" /> + <ref bean="virtualLinkRoa" /> + <ref bean="vnfRoa" /> + <ref bean="vmRoa" /> + <ref bean="vnfInfoRoa" /> + <ref bean="vnfStatusRoa" /> + <ref bean="grantResourseRoa" /> + <ref bean="SwaggerRoa" /> + </jaxrs:serviceBeans> + <jaxrs:providers> + <ref bean="jsonProvider" /> + <bean class="org.openo.nfvo.resmanagement.service.rest.exceptionmapper.ServiceExceptionMapper" /> + <bean class="org.openo.nfvo.resmanagement.service.rest.exceptionmapper.GenericExceptionMapper" /> + </jaxrs:providers> + </jaxrs:server> +</beans> diff --git a/ResmanagementService/service/src/main/resources/spring/Resmanagement/svc_register.xml b/ResmanagementService/service/src/main/resources/spring/Resmanagement/svc_register.xml new file mode 100644 index 0000000..38394ae --- /dev/null +++ b/ResmanagementService/service/src/main/resources/spring/Resmanagement/svc_register.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 2016 Huawei Technologies Co., Ltd. + + 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. + --> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi" + xmlns:osgix="http://www.springframework.org/schema/osgi-compendium" + xmlns:ctx="http://www.springframework.org/schema/context" xmlns:jaxrs="http://cxf.apache.org/jaxrs" + xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/osgi + http://www.springframework.org/schema/osgi/spring-osgi.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/osgi-compendium + http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd + http://cxf.apache.org/jaxrs + http://cxf.apache.org/schemas/jaxrs.xsd + http://cxf.apache.org/transports/http/configuration + http://cxf.apache.org/schemas/configuration/http-conf.xsd + http://www.springframework.org/schema/aop + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd + http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> + <bean class="org.openo.nfvo.resmanagement.service.activator.ROAResmgrServicePostProcessor"></bean> + <bean class="org.openo.nfvo.resmanagement.service.adapter.impl.ResmgrAdapterMgrService"></bean> +</beans>
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/resources/swagger.json b/ResmanagementService/service/src/main/resources/swagger.json new file mode 100644 index 0000000..6273c04 --- /dev/null +++ b/ResmanagementService/service/src/main/resources/swagger.json @@ -0,0 +1,1100 @@ +{ + "swagger": "2.0", + "info": { + "title": "Resource Management API", + "description": "Resource Management API", + "version": "1.0.0" + }, + "tags": [ + { + "name": "Resource Management services" + } + ], + "basePath": "/openoapi/resmgr/v1", + "paths": { + "/limits": { + "get": { + "summary": "Query limits information", + "description": "Query limits information", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimId", + "in": "query", + "description": "vim Id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Successfully Query limits information", + "schema": { + "$ref": "#/definitions/QueryLimts" + } + }, + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "Limits Not Found" + }, + "500": { + "description": "Limits failed to process the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/resource/grant": { + "put": { + "summary": "Grant VNF Life Cycle Operation", + "description": "Grant Resource", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "open-o", + "description": "OPEN-O Interface.", + "required": true, + "schema": { + "$ref": "#/definitions/GrantResource" + } + } + ], + "responses": { + "200": { + "description": "VNF Resource Response", + "schema": { + "$ref": "#/definitions/GrantResourceResponse" + } + }, + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "VNF Resource Not Found" + }, + "500": { + "description": "VNF resource failed to process the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/vl": { + "post": { + "summary": "Create virtual link resource", + "description": "virtual link Resource", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "open-o", + "description": "OPEN-O Interface.", + "required": true, + "schema": { + "$ref": "#/definitions/VirtualLink" + } + } + ], + "responses": { + "202": { + "description": "Successfully Created VNF Resource", + "schema": { + "$ref": "#/definitions/VirtualLinkResponse" + } + }, + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "VNF Resource Not Found" + }, + "500": { + "description": "VNF resource failed to process the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/vl/{id}": { + "delete": { + "summary": "Delete virtual link resource", + "description": "Delete virtual link Resource", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "description": "VNF Resource Id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Successfully Deleted VNF Resource" + }, + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "VNF Resource Not Found" + }, + "500": { + "description": "VNF resource failed to process the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/vnf": { + "post": { + "summary": "Create VNF instance resource", + "description": "Create VNF Resource", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "open-o", + "description": "OPEN-O Interface.", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVNFResource" + } + } + ], + "responses": { + "201": { + "description": "Successfully Created VNF Resource", + "schema": { + "$ref": "#/definitions/CreateVNFResponse" + } + }, + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "VNF Resource Not Found" + }, + "500": { + "description": "VNF resource failed to process the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/vnfinfo": { + "post": { + "summary": "Write VNF status information", + "description": "VNF Status", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "open-o", + "description": "OPEN-O Interface.", + "required": true, + "schema": { + "$ref": "#/definitions/VNFStatusInfo" + } + } + ], + "responses": { + "201": { + "description": "Successfully write VNF status" + }, + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "VNF Resource Not Found" + }, + "500": { + "description": "VNF resource failed to process the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/vnfdetailinfo": { + "post": { + "summary": "Write VNF detail information", + "description": "VNF detail info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "open-o", + "description": "OPEN-O Interface", + "required": true, + "schema": { + "$ref": "#/definitions/VNFDetailInfo" + } + } + ], + "responses": { + "201": { + "description": "Successfully write VNF detail Info" + }, + "401": { + "description": "Unauthorized" + }, + "404": { + "description": "VNF Resource Not Found" + }, + "500": { + "description": "VNF resource failed to process the request", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + } + }, + "definitions": { + "QueryLimts": { + "type": "object", + "description": "Query Limits Response.", + "required": [ + "vimId", + "vimName", + "totalCPU", + "totalMemory", + "totalDisk", + "usedCPU", + "usedMemory", + "usedDisk" + ], + "properties": { + "vimId": { + "type": "string", + "description": "Identifier of vimId." + }, + "vimName": { + "type": "string", + "description": "Name." + }, + "totalCPU": { + "type": "string" + }, + "totalMemory": { + "type": "string" + }, + "totalDisk": { + "type": "string" + }, + "usedCPU": { + "type": "string" + }, + "usedMemory": { + "type": "string" + }, + "usedDisk": { + "type": "string" + } + } + }, + "VirtualLinkResponse": { + "type": "object", + "description": "Virtual Link Response.", + "required": [ + "Id", + "Name" + ], + "properties": { + "Id": { + "type": "string", + "description": "Identifier of VL." + }, + "Name": { + "type": "string", + "description": "Name of VL." + } + } + }, + "CreateVNFResponse": { + "type": "object", + "description": "Create VNF Response.", + "required": [ + "Id", + "Name" + ], + "properties": { + "Id": { + "type": "string", + "description": "UUID." + }, + "Name": { + "type": "string", + "description": "Instance Name." + } + } + }, + "VNFDetailInfo": { + "type": "object", + "description": "List of Vm to be added or deleted", + "required": [ + "vnfInstanceId", + "nsId", + "vnfmId", + "Vms" + ], + "properties": { + "vnfInstanceId": { + "type": "string", + "description": "The id of VNF instance" + }, + "nsId": { + "type": "string", + "description": "NS ID" + }, + "vnfmId": { + "type": "string", + "description": "VNFM ID" + }, + "Vms": { + "type": "array", + "items": { + "$ref": "#/definitions/Vm" + } + } + } + }, + "VNFStatusInfo": { + "type": "object", + "description": "Write VNF Status.", + "required": [ + "vnfInstanceId", + "jobId", + "nsId", + "vnfmId", + "responseDescriptor", + "status", + "progress", + "sStatusDescription", + "errorCode", + "responseId", + "responseHistoryList", + "addVm", + "delVm" + ], + "properties": { + "vnfInstanceId": { + "type": "string", + "description": "The Id of VNF Instance." + }, + "jobId": { + "type": "string", + "description": "The ID of workflow." + }, + "nsId": { + "type": "string", + "description": "NS ID." + }, + "vnfmId": { + "type": "string", + "description": "The VNFM ID." + }, + "responseDescriptor": { + "type": "string", + "description": "The name of VNFM." + }, + "status": { + "type": "string", + "description": "Status of VNF - started processing finished error." + }, + "progress": { + "type": "integer", + "description": "progress (1-100)." + }, + "sStatusDescription": { + "type": "string", + "description": "current Progress Description." + }, + "errorCode": { + "type": "integer", + "description": "Error code." + }, + "responseId": { + "type": "integer", + "description": "Message Number." + }, + "responseHistoryList": { + "type": "array", + "items": { + "$ref": "#/definitions/progressInfo" + } + }, + "addVm": { + "type": "array", + "items": { + "$ref": "#/definitions/Vm" + } + }, + "delVm": { + "type": "array", + "items": { + "$ref": "#/definitions/Vm" + } + } + } + }, + "progressInfo": { + "type": "object", + "description": "List of Vm to be added or deleted", + "required": [ + "progress", + "status", + "statusDescription", + "errorCode", + "responseId", + "responseHistoryList" + ], + "properties": { + "progress": { + "type": "integer", + "description": "progress (1 - 100)" + }, + "status": { + "type": "string", + "description": "status" + }, + "statusDescription": { + "type": "string", + "description": "status description" + }, + "errorCode": { + "type": "integer", + "description": "Error Code" + }, + "responseId": { + "type": "integer", + "description": "Id" + }, + "responseHistoryList": { + "type": "array", + "items": { + "$ref": "#/definitions/historyInfo" + } + } + } + }, + "historyInfo": { + "type": "object", + "description": "List of Vm to be added or deleted", + "required": [ + "progress", + "status", + "statusDescription", + "errorCode", + "responseId" + ], + "properties": { + "progress": { + "type": "integer", + "description": "progress (1 - 100)" + }, + "status": { + "type": "string", + "description": "status" + }, + "statusDescription": { + "type": "string", + "description": "status description" + }, + "errorCode": { + "type": "integer", + "description": "Error Code" + }, + "responseId": { + "type": "integer", + "description": "Id" + } + } + }, + "Vm": { + "type": "object", + "description": "List of Vm to be added or deleted", + "required": [ + "vmId", + "vmName", + "vmStatus" + ], + "properties": { + "vmId": { + "type": "string", + "description": "The ID of VM" + }, + "vmName": { + "type": "string", + "description": "The name of VM" + }, + "vmStatus": { + "type": "string", + "description": "The Status of VM" + } + } + }, + "CreateVNFResource": { + "type": "object", + "description": "Create VNF Resource.", + "required": [ + "vnfInstanceId", + "vnfInstanceName", + "nsId", + "nsName", + "vnfmId", + "vnfmName", + "vnfPackageName", + "vnfDescriptorName", + "vimId", + "vimName", + "vimTenant", + "jobId", + "vnfStatus", + "vnfType", + "maxVm", + "maxCpu", + "maxDisk", + "maxRam", + "maxShd", + "maxNet" + ], + "properties": { + "vnfInstanceId": { + "type": "string", + "description": "The Identifier of VNF Instance." + }, + "vnfInstanceName": { + "type": "string", + "description": "The name of VNF." + }, + "nsId": { + "type": "string", + "description": "NS ID." + }, + "nsName": { + "type": "string", + "description": "NS name." + }, + "vnfmId": { + "type": "string", + "description": "The ID of VNFM." + }, + "vnfmName": { + "type": "string", + "description": "The name of VNFM." + }, + "vnfPackageName": { + "type": "string", + "description": "The description of VNF Package." + }, + "vnfDescriptorName": { + "type": "string", + "description": "The Description of VNFD." + }, + "vimId": { + "type": "string", + "description": "Vim ID." + }, + "vimName": { + "type": "string", + "description": "The Name of VIM." + }, + "vimTenant": { + "type": "string", + "description": "The tenant of VIM." + }, + "jobId": { + "type": "string", + "description": "The ID of workflow." + }, + "vnfStatus": { + "type": "string", + "description": "The status of VNF." + }, + "vnfType": { + "type": "string", + "description": "The type of VNF." + }, + "maxVm": { + "type": "integer", + "description": "Max Vm in this VNF." + }, + "maxCpu": { + "type": "integer", + "description": "Max CPU in this VNF." + }, + "maxDisk": { + "type": "integer", + "description": "Max Disk in this VNF." + }, + "maxRam": { + "type": "integer", + "description": "Max Memory in this VNF." + }, + "maxShd": { + "type": "integer", + "description": "Max Share Disk in this VNF." + }, + "maxNet": { + "type": "integer", + "description": "Max logical Network in this VNF." + } + } + }, + "VirtualLink": { + "type": "object", + "description": "Virtual Link Resource.", + "required": [ + "name", + "backendId", + "isPublic", + "dcName", + "vimId", + "vimName", + "physicialNet", + "nsId", + "nsName", + "description", + "networkType", + "segmentation", + "mtu", + "vlanTransparent", + "routerExternal", + "resourceProviderType", + "resourceProviderId" + ], + "properties": { + "name": { + "type": "string", + "description": "Logical Network Name." + }, + "backendId": { + "type": "string", + "description": "The backend id on VIM." + }, + "isPublic": { + "type": "string", + "description": "Sharable - True or False." + }, + "dcName": { + "type": "string", + "description": "The DataCenter name." + }, + "vimId": { + "type": "string", + "description": "vim Id." + }, + "vimName": { + "type": "string", + "description": "The name of VIM." + }, + "physicialNet": { + "type": "string", + "description": "Physicial Network." + }, + "nsId": { + "type": "string", + "description": "NsId." + }, + "nsName": { + "type": "string", + "description": "The name of NS." + }, + "description": { + "type": "string", + "description": "Description." + }, + "networkType": { + "type": "string", + "description": "Network Type - gre/vlan/vxlan." + }, + "segmentation": { + "type": "string", + "description": "Segmentation Id just like vlan id." + }, + "mtu": { + "type": "string", + "description": "MTU value." + }, + "vlanTransparent": { + "type": "string", + "description": "Support vlan transparent- True/False." + }, + "routerExternal": { + "type": "string", + "description": "Support External Router - True / False." + }, + "resourceProviderType": { + "type": "string", + "description": "The location to be deployed in one of the list - VIM/DC/Zone/Host." + }, + "resourceProviderId": { + "type": "string", + "description": "The location ID to be deployed." + } + } + }, + "GrantResourceResponse": { + "type": "object", + "description": "Resource Response.", + "required": [ + "vim", + "zone", + "zoneGroup", + "addResource", + "tempResource", + "removeResource", + "updateResource", + "vimAssets", + "additionalParam" + ], + "properties": { + "vim": { + "$ref": "#/definitions/VimInfo" + }, + "zone": { + "type": "string" + }, + "zoneGroup": { + "type": "string" + }, + "addResource": { + "$ref": "#/definitions/GrantInfo" + }, + "tempResource": { + "$ref": "#/definitions/GrantInfo" + }, + "removeResource": { + "$ref": "#/definitions/GrantInfo" + }, + "updateResource": { + "$ref": "#/definitions/GrantInfo" + }, + "vimAssets": { + "type": "string" + }, + "additionalParam": { + "type": "string" + } + } + }, + "VimInfo": { + "type": "object", + "description": "Information about the VIM that manages this resource.", + "required": [ + "vimInfoId", + "vimId", + "interfaceInfo", + "accessInfo", + "interfaceEndpoint" + ], + "properties": { + "vimInfoId": { + "type": "string", + "description": "The identifier of this VimInfo instance, for the purpose of referencing it from other information elements." + }, + "vimId": { + "type": "string", + "description": "The identifier of the VIM.." + }, + "interfaceInfo": { + "$ref": "#/definitions/interfaceInfo" + }, + "accessInfo": { + "$ref": "#/definitions/accessInfo" + }, + "interfaceEndpoint": { + "type": "string", + "description": "Information about the interface endpoint. An example is a URL." + } + } + }, + "interfaceInfo": { + "type": "object", + "description": "Information about the interface to the VIM, including VIM provider type, API version, and protocol type..", + "required": [ + "vimType", + "apiVersion", + "protocolType" + ], + "properties": { + "vimType": { + "type": "string", + "description": "vim" + }, + "apiVersion": { + "type": "string", + "description": "api version" + }, + "protocolType": { + "type": "string", + "description": "Type of the protocol" + } + } + }, + "accessInfo": { + "type": "object", + "description": "Authentication credentials for accessing the VIM. Examples may include those to support different authentication schemes, e.g., OAuth, Token, etc..", + "required": [ + "tenant", + "username", + "password" + ], + "properties": { + "tenant": { + "type": "string", + "description": "Tenant Name of tenant" + }, + "username": { + "type": "string", + "description": "Username for login" + }, + "password": { + "type": "string", + "description": "Password of login user" + } + } + }, + "GrantInfo": { + "type": "object", + "description": "Grant Information.", + "required": [ + "resourceDefinitionId", + "reservationId", + "vimId", + "resourceProviderId", + "zoneId" + ], + "properties": { + "resourceDefinitionId": { + "type": "string", + "description": "Identifier of the related ResourceDefinition information from Grant Request" + }, + "reservationId": { + "type": "string", + "description": "Reservation Identifier applicable to the VNFC/VL." + }, + "vimId": { + "type": "string", + "description": "Reference to the identifier of the VimInfo information element defining the VIM under whose control this resource to be placed." + }, + "resourceProviderId": { + "type": "string", + "description": "Identifies the entity responsible for the management of the virtualized resource." + }, + "zoneId": { + "type": "string", + "description": "Reference of the identifier of the zoneInfo information element defining the resource zone in which resource to be placed." + } + } + }, + "GrantResource": { + "type": "object", + "description": "Grant Resource Request Body.", + "required": [ + "vnfInstanceId", + "addResource", + "vimId", + "additionalParam" + ], + "properties": { + "vnfInstanceId": { + "type": "string", + "description": "Identifier Instance." + }, + "vimId": { + "type": "string", + "description": "Identifier vim." + }, + "addResource": { + "type": "array", + "items": { + "$ref": "#/definitions/ResourceDefinition" + }, + "description": "Information sufficient to identify the VNF Descriptor which defines the VNF to be created." + }, + "removeResource": { + "type": "array", + "items": { + "$ref": "#/definitions/ResourceDefinition" + } + }, + "additionalParam": { + "type": "object", + "description": "additionalParam.", + "required": [ + "vnfmid" + ], + "properties": { + "vnfmid": { + "type": "string" + }, + "vimid": { + "type": "string" + }, + "tenant": { + "type": "string" + } + } + } + } + }, + "ResourceDefinition": { + "type": "object", + "description": "List of resources to be added / deleted / updated.", + "required": [ + "resourceDefinitionId", + "resourceTemplate", + "type", + "vdu" + ], + "properties": { + "resourceDefinitionId": { + "type": "string", + "description": "Identifier of this ResourceDefinition information element, unique at least within the scope of the Grant request." + }, + "resourceTemplate": { + "$ref": "#/definitions/ResourceTemplate" + }, + "type": { + "default": "compute", + "enum": [ + "compute", + "VL", + "CP", + "Storage" + ], + "description": "Currently only support tosca.nodes.nfv.VDU." + }, + "vdu": { + "type": "string", + "description": "Reference to the related Vdu applicable to this resource in the VNFD." + } + } + }, + "ResourceTemplate": { + "type": "object", + "description": "Resource templates.", + "required": [ + "VirtualComputeDescriptor", + "VirtualStorageDescriptor" + ], + "properties": { + "VirtualComputeDescriptor": { + "$ref": "#/definitions/VirtualComputeDescriptor" + }, + "VirtualStorageDescriptor": { + "$ref": "#/definitions/VirtualStorageDescriptor" + } + } + }, + "VirtualComputeDescriptor": { + "type": "object", + "description": "Reference to a resource template.", + "required": [ + "virtualCpu", + "virtualMemory" + ], + "properties": { + "virtualCpu": { + "type": "integer", + "format": "int32", + "description": "Number of virtual CPUs" + }, + "virtualMemory": { + "type": "integer", + "format": "int32", + "description": "Amount of virtual Memory" + } + } + }, + "VirtualStorageDescriptor": { + "type": "object", + "description": "Reference to a resource template.", + "required": [ + "typeOfStorage", + "sizeOfStorage", + "swImageDescriptor" + ], + "properties": { + "typeOfStorage": { + "type": "string", + "description": "Type of virtualized storage resource" + }, + "sizeOfStorage": { + "type": "integer", + "format": "int32", + "description": "Size of virtualized storage resource" + }, + "swImageDescriptor": { + "type": "string", + "description": "Software image to be loaded on the Virtual Storage" + } + } + }, + "Error": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/main/webapp/WEB-INF/web.xml b/ResmanagementService/service/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..5e7e6bd --- /dev/null +++ b/ResmanagementService/service/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright 2016 Huawei Technologies Co., Ltd. + + 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. + --> + +<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee + http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> + <listener> + <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> + </listener> + <servlet> + <servlet-name>CXFServlet</servlet-name> + <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <servlet-name>CXFServlet</servlet-name> + <url-pattern>/openoapi/resmgr/*</url-pattern> + </servlet-mapping> + + <context-param> + <param-name>contextConfigLocation</param-name> + <param-value>WEB-INF/classes/spring/Resmanagement/*.xml + </param-value> + </context-param> + + <session-config> + <session-timeout>10000000</session-timeout> + </session-config> + + <display-name>resmanagement-service</display-name> + +</web-app>
\ No newline at end of file diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/ResourceUtilTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/ResourceUtilTest.java new file mode 100644 index 0000000..d162713 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/ResourceUtilTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + + +public class ResourceUtilTest { + + + @Test + public void testGetMessage() throws NoSuchMethodException, SecurityException { + + + String key = "huawei"; + String result = ResourceUtil.getMessage(key); + String expectedResult = "huawei"; + assertEquals(expectedResult, result); + } + @Test + public void testPrivateConstructor() throws Exception { + Constructor constructor = ResourceUtil.class.getDeclaredConstructor(); + assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers())); + + constructor.setAccessible(true); + constructor.newInstance(); + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/VimUtilTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/VimUtilTest.java new file mode 100644 index 0000000..13e12e5 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/VimUtilTest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common; + +import static org.junit.Assert.*; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; + +import org.junit.Test; +import org.openo.baseservice.roa.util.restclient.RestfulOptions; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.openo.nfvo.resmanagement.common.constant.UrlConstant; +import org.openo.nfvo.resmanagement.common.util.RestfulUtil; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class VimUtilTest { + + + + @Test + public void testPrivateConstructor() throws Exception { + Constructor constructor = VimUtil.class.getDeclaredConstructor(); + assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers())); + + constructor.setAccessible(true); + constructor.newInstance(); + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/JsonUtilTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/JsonUtilTest.java new file mode 100644 index 0000000..92b499d --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/JsonUtilTest.java @@ -0,0 +1,435 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; + +import org.junit.Test; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class JsonUtilTest { + + @Test + public void testGetJsonFieldStr() { + JSONObject jsonObj = new JSONObject(); + String fieldName = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + String result = JsonUtil.getJsonFieldStr(jsonObj, fieldName); + String expectedResult = "1"; + assertEquals(expectedResult, result); + + } + + @Test + public void testGetJsonFieldInt() { + JSONObject jsonObj = new JSONObject(); + String fieldName = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + int result = JsonUtil.getJsonFieldInt(jsonObj, fieldName); + int expectedResult = 1; + assertEquals(expectedResult, result); + + } + + @Test + public void testGetJsonFieldArr() { + JSONObject jsonObj = new JSONObject(); + String fieldName = "a"; + jsonObj.put("a", new JSONArray()); + jsonObj.put("b", "2"); + JSONArray result = JsonUtil.getJsonFieldArr(jsonObj, fieldName); + JSONArray expectedResult = new JSONArray(); + assertEquals(expectedResult, result); + + } + + @Test + public void testGetJsonFieldJson() { + JSONObject jsonObj = new JSONObject(); + String fieldName = "a"; + jsonObj.put("a", new JSONObject()); + jsonObj.put("b", "2"); + JSONObject result = JsonUtil.getJsonFieldJson(jsonObj, fieldName); + JSONObject expectedResult = new JSONObject(); + assertEquals(expectedResult, result); + + } + + @Test + public void testGetJsonFieldLong() { + JSONObject jsonObj = new JSONObject(); + String fieldName = "a"; + jsonObj.put("a", 1); + jsonObj.put("b", 2); + Long result = JsonUtil.getJsonFieldLong(jsonObj, fieldName); + Long expectedResult = new Long(1); + assertEquals(expectedResult, result); + + } + + @Test + public void testGetJsonFieldObjectException() { + JSONObject jsonObj = new JSONObject(); + String fieldName = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + JSONObject result = JsonUtil.getJsonFieldJson(jsonObj, fieldName); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + + } + + @Test + public void testIsNullJson1() { + JSONObject jsonObj = new JSONObject(); + assertTrue(JsonUtil.isNullJson(jsonObj)); + } + + @Test + public void testIsNullJson2() { + assertTrue(JsonUtil.isNullJson(null)); + } + + @Test + public void testIsNullJson3() { + JSONObject jsonObj = new JSONObject(); + jsonObj.put("a", "1"); + assertFalse(JsonUtil.isNullJson(jsonObj)); + } + + @Test + public void testGetStrValueByjsonNULL() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + String result = JsonUtil.getStrValueByjson(jsonObj, key); + String expectedResult = null; + assertEquals(expectedResult, result); + + } + + @Test + public void testGetStrValueByjson() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + new MockUp<JSONObject>() { + + @SuppressWarnings("static-access") + @Mock + public JSONObject optJSONObject(String key) { + return new JSONObject().fromObject("{\"a\":\"1\"}"); + } + + @Mock + public JSONObject getJSONObject(String key) { + return new JSONObject(); + } + }; + String result = JsonUtil.getStrValueByjson(jsonObj, key); + String expectedResult = "1"; + assertEquals(expectedResult, result); + + } + + @Test + public void testGetStrValueByjson1() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + new MockUp<JSONObject>() { + + @Mock + public JSONObject optJSONObject(String key) { + return null; + } + + @SuppressWarnings("static-access") + @Mock + public JSONArray optJSONArray(String key) { + return new JSONArray().fromObject("[\"a\",\"1\"]"); + } + + @Mock + public JSONArray getJSONArray(String key) { + return new JSONArray(); + } + }; + String result = JsonUtil.getStrValueByjson(jsonObj, key); + String expectedResult = "1"; + assertEquals(expectedResult, result); + + } + + @Test + public void testGetStrValueByjson2() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + String result = JsonUtil.getStrValueByjson(jsonObj, key); + String expectedResult = "1"; + assertEquals(expectedResult, result); + + } + + @Test + public void testGetStrValueByJArray() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + new MockUp<JSONObject>() { + + @Mock + public JSONObject optJSONObject(String key) { + return null; + } + + @SuppressWarnings("static-access") + @Mock + public JSONArray optJSONArray(String key) { + return new JSONArray().fromObject("[\"a\",\"1\"]"); + } + + @SuppressWarnings("static-access") + @Mock + public JSONArray getJSONArray(String key) { + return new JSONArray().fromObject("[\"a\",\"1\"]"); + } + + + }; + + String result = JsonUtil.getStrValueByjson(jsonObj, key); + + } + + @Test + public void testGetStrValueByJArray1() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + new MockUp<JSONObject>() { + + int count = 1; + + @SuppressWarnings("static-access") + @Mock + public JSONObject optJSONObject(String key) { + if (count == 1) { + count += 1; + return null; + } else + return new JSONObject().fromObject("{\"a\":\"1\"}"); + } + + @SuppressWarnings("static-access") + @Mock + public JSONArray optJSONArray(String key) { + return new JSONArray().fromObject("[\"a\",\"1\"]"); + } + + @SuppressWarnings("static-access") + @Mock + public JSONArray getJSONArray(String key) { + return new JSONArray().fromObject("[\"a\",\"1\"]"); + } + }; + String result = JsonUtil.getStrValueByjson(jsonObj, key); + String expectedResult = "1"; + assertEquals(expectedResult, result); + + } + + @Test + public void testGetJsonValueByjson() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + String result = JsonUtil.getJsonValueByjson(jsonObj, key).toString(); + String expectedResult = "{\"a\":\"1\"}"; + assertEquals(expectedResult, result); + } + + @Test + public void testGetJsonValueByjsonResultIsNull() { + JSONObject jsonObj = new JSONObject(); + String key = "c"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + JSONObject result = JsonUtil.getJsonValueByjson(jsonObj, key); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetStrValueByJsonParentKeyIsNull() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + String parentKey = ""; + String result = JsonUtil.getStrValueByJson(jsonObj, parentKey, key); + String expectedResult = "1"; + assertEquals(expectedResult, result); + } + + @Test + public void testGetStrValueByJsonParentJsonIsNull() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + String parentKey = "b"; + new MockUp<JsonUtil>() { + + @Mock + public JSONObject getJsonValueByjson(JSONObject json, String key) { + return new JSONObject(); + } + }; + String result = JsonUtil.getStrValueByJson(jsonObj, parentKey, key); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetStrValueByJson() { + JSONObject jsonObj = new JSONObject(); + String key = "a"; + jsonObj.put("a", "1"); + jsonObj.put("b", "2"); + String parentKey = "b"; + String result = JsonUtil.getStrValueByJson(jsonObj, parentKey, key); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseDataRetcodeError1() { + new MockUp<JsonUtil>() { + + @Mock + public Integer getJsonFieldInt(JSONObject jsonObj, String fieldName) { + return null; + } + }; + JSONObject result = JsonUtil.getResponseData(null); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseDataRetcodeError2() { + new MockUp<JsonUtil>() { + + @Mock + public Integer getJsonFieldInt(JSONObject jsonObj, String fieldName) { + return -1; + } + }; + JSONObject result = JsonUtil.getResponseData(null); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseDataResultIsEmpty() { + JSONObject obj = new JSONObject(); + obj.put("data", "1"); + obj.put("retCode", "1"); + JSONObject result = JsonUtil.getResponseData(obj); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseData() { + JSONObject obj = new JSONObject(); + obj.put("data", new JSONObject()); + obj.put("retCode", "1"); + new MockUp<JSONObject>() { + + @SuppressWarnings("static-access") + @Mock + public JSONObject optJSONObject(String key) { + return new JSONObject().fromObject("{\"a\":\"1\"}"); + } + }; + JSONObject result = JsonUtil.getResponseData(obj); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseData1() { + JSONObject obj = new JSONObject(); + obj.put("data", JSONArray.fromObject("[{\"a\":\"1\"},\"1\"]")); + obj.put("retCode", "1"); + new MockUp<JSONObject>() { + + @Mock + public JSONObject optJSONObject(String key) { + return null; + } + + @SuppressWarnings("static-access") + @Mock + public JSONArray optJSONArray(String key) { + return new JSONArray().fromObject("[\"a\",\"1\"]"); + } + }; + JSONObject result = JsonUtil.getResponseData(obj); + String expectedResult = "{\"a\":\"1\"}"; + assertEquals(expectedResult, result.toString()); + } + + @Test + public void testGetResponseData2() { + JSONObject obj = new JSONObject(); + JSONObject json = new JSONObject(); + json.put("retCode", "1"); + obj.put("data", json); + obj.put("retCode", "1"); + JSONObject result = JsonUtil.getResponseData(obj); + String expectedResult = null; + assertEquals(expectedResult, result); + } + @Test + public void testPrivateConstructor() throws Exception { + Constructor constructor = JsonUtil.class.getDeclaredConstructor(); + assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers())); + + constructor.setAccessible(true); + constructor.newInstance(); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/RestfulUtilTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/RestfulUtilTest.java new file mode 100644 index 0000000..69bfd74 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/RestfulUtilTest.java @@ -0,0 +1,244 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.RestfulOptions; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.openo.nfvo.resmanagement.common.constant.Constant; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONArray; +import net.sf.json.JSONException; +import net.sf.json.JSONObject; + +public class RestfulUtilTest { + + @Test + public void testGetResponseObjWithTwoParams() { + JSONObject result = RestfulUtil.getResponseObj(null, null); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseObjWithThreeParams() { + new MockUp<RestfulUtil>() { + + @Mock + public String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + return "{\"ResponseContent\":\"123\"}"; + } + }; + JSONObject result = RestfulUtil.getResponseObj(null, null, null); + @SuppressWarnings("static-access") + JSONObject expectedResult = new JSONObject().fromObject("{\"ResponseContent\":\"123\"}"); + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseObjExpections() { + new MockUp<RestfulUtil>() { + + @Mock + public String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt, + String type) { + throw new JSONException(); + } + }; + JSONObject result = RestfulUtil.getResponseObj(null, null, null); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseContent() { + String result = RestfulUtil.getResponseContent(null, null, null); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseMap() { + Map<String, Object> result = RestfulUtil.getResponseMap(null, null, null, null); + Map<String, Object> expectedResult = new HashMap<String, Object>(10); + expectedResult.put(Constant.RESPONSE_CONTENT, null); + expectedResult.put(Constant.STATUS_CODE, -1); + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseContentMap() { + Map<String, Object> result = RestfulUtil.getResponseContentMap(null, null); + Map<String, Object> expectedResult = new HashMap<String, Object>(10); + expectedResult.put(Constant.RESPONSE_CONTENT, null); + expectedResult.put(Constant.STATUS_CODE, -1); + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseContentWithFourParams() { + new MockUp<RestfulResponse>() { + + @Mock + public int getStatus() { + return 200; + } + }; + String result = RestfulUtil.getResponseContent(null, null, null); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetRestfulResponse() { + RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, null); + RestfulResponse expectedResult = new RestfulResponse(); + assertEquals(expectedResult.getStatus(), result.getStatus()); + } + + @Test + public void testRestfulResponse() { + RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, "get"); + RestfulResponse expectedResult = new RestfulResponse(); + assertEquals(expectedResult.getStatus(), result.getStatus()); + } + + @Test + public void testRestfulResponse1() { + RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, "add"); + RestfulResponse expectedResult = new RestfulResponse(); + assertEquals(expectedResult.getStatus(), result.getStatus()); + } + + @Test + public void testRestfulResponse2() { + RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, "put"); + RestfulResponse expectedResult = new RestfulResponse(); + assertEquals(expectedResult.getStatus(), result.getStatus()); + } + + @Test + public void testRestfulResponse3() { + RestfulResponse result = RestfulUtil.getRestfulResponse(null, null, "delete"); + RestfulResponse expectedResult = new RestfulResponse(); + assertEquals(expectedResult.getStatus(), result.getStatus()); + } + + @Test + public void testGetRestResObjectsIsNull() { + RestfulResponse result = RestfulUtil.getRestRes(null, null); + RestfulResponse expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetRestResReflectiveOperationException() { + RestfulResponse result = RestfulUtil.getRestRes("123", "get"); + RestfulResponse expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetRestRes() { + RestfulResponse result = RestfulUtil.getRestRes("async123", new RestfulResponse()); + RestfulResponse expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseResResultIsNull() throws ServiceException { + try { + RestfulUtil.getResponseRes(null, null); + } catch (ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testGetResponse() throws ServiceException { + new MockUp<RestfulUtil>() { + + @Mock + public String getResponseContent(String url, RestfulParametes restParametes, String type) { + return "{\"ResponseContent\":\"123\",\"data\":[\"datas\"]}"; + } + }; + JSONArray result = RestfulUtil.getResponseRes(null, null); + JSONArray expectedResult = JSONArray.fromObject("[\"datas\"]"); + assertEquals(expectedResult, result); + } + + @Test + public void testGetResponseExceptions() throws ServiceException { + new MockUp<RestfulUtil>() { + + @Mock + public String getResponseContent(String url, RestfulParametes restParametes, String type) { + return "{\"ResponseContent\":\"123\",}"; + } + }; + try { + RestfulUtil.getResponseRes(null, null); + } catch (ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testGgetResponseRes() throws ServiceException { + new MockUp<RestfulUtil>() { + + @Mock + public String getResponseContent(String url, RestfulParametes restParametes, String type) { + return "{\"ResponseContent\":\"123\",}"; + } + }; + try { + RestfulUtil.getResponseRes(null, null, null); + } catch (ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testGgetResponseResException() throws ServiceException { + new MockUp<RestfulUtil>() { + + @Mock + public String getResponseContent(String url, RestfulParametes restParametes, String type) { + return null; + } + }; + try { + RestfulUtil.getResponseRes(null, null, null); + } catch (ServiceException e) { + assertTrue(true); + } + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/StringUtilTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/StringUtilTest.java new file mode 100644 index 0000000..9fb9ef1 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/StringUtilTest.java @@ -0,0 +1,143 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; + +import org.junit.Test; + +public class StringUtilTest { + + @Test + public void testisValidString() { + assertTrue(StringUtil.isValidString("abc")); + } + + @Test + public void testisValidString1() { + assertFalse(StringUtil.isValidString(null)); + } + + @Test + public void testisValidString2() { + assertFalse(StringUtil.isValidString("")); + } + + @Test + public void testIsAnyLargeThanZero() { + assertFalse(StringUtil.isAnyLargeThanZero("")); + } + + @Test + public void testIsAnyLargeThanZero1() { + assertTrue(StringUtil.isAnyLargeThanZero("123")); + } + + @Test + public void testIsIntegerExceptions() { + assertFalse(StringUtil.isInteger("asd")); + } + + @Test + public void testIsInteger() { + assertTrue(StringUtil.isInteger("123")); + } + + @Test + public void testIsInteger1() { + assertFalse(StringUtil.isInteger("-1")); + } + + @Test + public void testIsNumericExceptions() { + assertFalse(StringUtil.isNumeric("abc")); + } + + @Test + public void testIsNumeric() { + assertTrue(StringUtil.isNumeric("1.456")); + } + + @Test + public void testIsNumeric1() { + assertFalse(StringUtil.isNumeric("-1.456")); + } + + @Test + public void testCompareZeroByFloat() { + assertTrue(StringUtil.compareZeroByFloat("3.0", "1.0", "2.0")); + } + + @Test + public void testCompareZeroByFloat1() { + assertFalse(StringUtil.compareZeroByFloat("3.0", "1.2", "2.5")); + } + + @Test + public void testCompareZeroByInteger() { + assertTrue(StringUtil.compareZeroByInteger("3", "1", "2")); + } + + @Test + public void testCompareZeroByInteger1() { + assertFalse(StringUtil.compareZeroByInteger("3", "1", "3")); + } + + @Test + public void testNumFormatDataIsNull() { + String result = StringUtil.numFormat(null); + assertEquals(null, result); + } + + @Test + public void testNumFormatDataIsEmpty() { + String result = StringUtil.numFormat(""); + assertEquals(null, result); + } + + @Test + public void testNumFormatInteger() { + String result = StringUtil.numFormat("12"); + String expectedResult = "12"; + assertEquals(expectedResult, result); + } + + @Test + public void testNumFormatFloat() { + String result = StringUtil.numFormat("12.5"); + String expectedResult = "12.5"; + assertEquals(expectedResult, result); + } + + @Test + public void testCheckXss() { + assertTrue(StringUtil.checkXss("123")); + } + @Test + public void testPrivateConstructor() throws Exception { + Constructor<StringUtil> constructor = StringUtil.class.getDeclaredConstructor(); + assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers())); + + constructor.setAccessible(true); + constructor.newInstance(); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtilTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtilTest.java new file mode 100644 index 0000000..e4d34b8 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtilTest.java @@ -0,0 +1,252 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util.request; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Constructor; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.io.IOUtils; +import org.apache.cxf.jaxrs.impl.HttpServletRequestFilter; +import org.junit.Test; + +import javassist.Modifier; +import mockit.Mock; +import mockit.MockUp; +import mockit.Mocked; +import net.sf.json.JSONException; +import net.sf.json.JSONObject; + +public class RequestUtilTest { + + @Test + public void testGetStringRequestBody() { + HttpServletRequestFilter context = new MockUp<HttpServletRequestFilter>() { + + @Mocked + ServletInputStream input; + + @Mock + public ServletInputStream getInputStream() throws IOException { + return input; + } + }.getMockInstance(); + new MockUp<IOUtils>() { + + String data = "{\"NETWORK\":{\"id\": \"123\"}}"; + + @Mock + public String toString(InputStream input) throws IOException { + return data; + } + }; + String result = RequestUtil.getStringRequestBody(context); + String expectedResult = "{\"NETWORK\":{\"id\": \"123\"}}"; + assertEquals(expectedResult, result); + } + + @Test + public void testGetStringRequestBodyException() { + HttpServletRequestFilter context = new MockUp<HttpServletRequestFilter>() { + + @Mock + public ServletInputStream getInputStream() throws IOException { + throw new IOException(); + } + }.getMockInstance(); + String result = RequestUtil.getStringRequestBody(context); + String expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetJsonRequestBody() { + HttpServletRequestFilter context = new MockUp<HttpServletRequestFilter>() { + + @Mocked + ServletInputStream input; + + @Mock + public ServletInputStream getInputStream() throws IOException { + return input; + } + }.getMockInstance(); + new MockUp<IOUtils>() { + + String data = "{\"NETWORK\":{\"id\": \"123\"}}"; + + @Mock + public String toString(InputStream input) throws IOException { + return data; + } + }; + JSONObject result = RequestUtil.getJsonRequestBody(context); + String data1 = "{\"NETWORK\":{\"id\": \"123\"}}"; + JSONObject expectedResult = JSONObject.fromObject(data1); + assertEquals(expectedResult, result); + } + + @Test + public void testGetJsonRequestBody1() { + new MockUp<RequestUtil>() { + + String data1 = "{\"NETWORK\":{\"id\": \"123\"}}"; + + @Mock + public String getStringRequestBody(HttpServletRequest context) { + return data1; + } + }; + JSONObject result = RequestUtil.getJsonRequestBody(null); + String data1 = "{\"NETWORK\":{\"id\": \"123\"}}"; + JSONObject expectedResult = JSONObject.fromObject(data1); + assertEquals(expectedResult, result); + } + + @Test + public void testGetJsonRequestBodyException() { + HttpServletRequestFilter context = new MockUp<HttpServletRequestFilter>() { + + @Mocked + ServletInputStream input; + + @Mock + public ServletInputStream getInputStream() throws JSONException { + throw new JSONException(); + } + }.getMockInstance(); + JSONObject result = RequestUtil.getJsonRequestBody(context); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @SuppressWarnings("rawtypes") + @Test + public void testGetAllJsonRequestBodyRequestBodyIsNull() { + HttpServletRequestFilter context = new MockUp<HttpServletRequestFilter>() { + + @Mocked + ServletInputStream input; + + @Mock + public ServletInputStream getInputStream() throws IOException { + return input; + } + + @Mock + public Enumeration getHeaderNames() { + return new Enumeration() { + + List<String> a = Arrays.asList(new String[] { "1", "2" }); + + @Override + public boolean hasMoreElements() { + return false; + } + + @Override + public Object nextElement() { + return null; + } + + }; + } + + }.getMockInstance(); + new MockUp<RequestUtil>() { + + @Mock + public JSONObject getJsonRequestBody(HttpServletRequest context) { + return null; + } + }; + JSONObject result = RequestUtil.getAllJsonRequestBody(context); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("header", new HashMap<String, String>()); + assertEquals(expectedResult, result); + } + + @SuppressWarnings("rawtypes") + @Test + public void testGetContextHeader() { + HttpServletRequestFilter context = new MockUp<HttpServletRequestFilter>() { + + @Mock + public String getHeader(String name) { + return "1"; + } + + @Mock + public Enumeration getHeaderNames() { + return new Enumeration() { + + List<String> a = Arrays.asList(new String[] { "1", "2" }); + + int count = 1; + + @Override + public boolean hasMoreElements() { + if (count == 1) { + count += 1; + return true; + } else + return false; + } + + @Override + public Object nextElement() { + return "1"; + } + + }; + } + + }.getMockInstance(); + new MockUp<RequestUtil>() { + + @Mock + public JSONObject getJsonRequestBody(HttpServletRequest context) { + return null; + } + }; + JSONObject result = RequestUtil.getAllJsonRequestBody(context); + JSONObject expectedResult = new JSONObject(); + Map<String, String> map = new HashMap<String, String>(); + map.put("1", "1"); + expectedResult.put("header", map); + assertEquals(expectedResult, result); + } + @Test + public void testPrivateConstructor() throws Exception { + Constructor constructor = RequestUtil.class.getDeclaredConstructor(); + assertTrue("Constructor is private", Modifier.isPrivate(constructor.getModifiers())); + + constructor.setAccessible(true); + constructor.newInstance(); + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtilTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtilTest.java new file mode 100644 index 0000000..b3258f5 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtilTest.java @@ -0,0 +1,90 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util.response; + +import static org.junit.Assert.*; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +import net.sf.json.JSONObject; + +public class ResponseUtilTest { + + @Test + public void TestGenHttpResponseWithTwoParam() { + int retCode1 = -1; + String msg1 = "123"; + JSONObject result = ResponseUtil.genHttpResponse(retCode1, msg1); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("msg", "123"); + assertEquals(result.toString(), expectedResult.toString()); + ; + } + + @Test + public void TestGenHttpResponseWithThreeParam() { + int retCode1 = -1; + String msg1 = "123"; + JSONObject result = ResponseUtil.genHttpResponse(retCode1, msg1, null); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("msg", "123"); + assertEquals(result.toString(), expectedResult.toString()); + ; + } + + @Test + public void TestGenHttpResponseWithFourParam1() { + int httpStatusCode = -1; + int retCode1 = -1; + String msg1 = "123"; + JSONObject result = ResponseUtil.genHttpResponse(null, httpStatusCode, retCode1, msg1); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("msg", "123"); + assertEquals(result.toString(), expectedResult.toString()); + ; + } + + @Test + public void TestGenHttpResponseWithFourParam2() { + Map<String, Integer> codeMap = new HashMap<String, Integer>(5); + codeMap.put("httpStatusCode", -1); + codeMap.put("retCode", 1); + Map<String, Object> map = new HashMap<String, Object>(5); + map.put("a", -1); + map.put("b", 1); + String msg1 = "123"; + JSONObject result = ResponseUtil.genHttpResponse(null, codeMap, msg1, map); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("msg", "123"); + expectedResult.put("a", "-1"); + assertEquals(result.toString(), expectedResult.toString()); + ; + } + @Test + public void testPrivateConstructor() throws Exception { + Constructor constructor = ResponseUtil.class.getDeclaredConstructor(); + assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers())); + + constructor.setAccessible(true); + constructor.newInstance(); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtilTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtilTest.java new file mode 100644 index 0000000..1e30587 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtilTest.java @@ -0,0 +1,146 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.common.util.response; + +import static org.junit.Assert.*; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Modifier; +import java.util.Map; + +import org.junit.Test; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONObject; + +public class RoaResponseUtilTest { + + @Test + public void testGet() { + new MockUp<ResponseUtil>() { + + @Mock + public JSONObject genHttpResponse(int retCode, String msg, Map<String, Object> map) { + return null; + } + }; + JSONObject result = RoaResponseUtil.get(null); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testAdd() { + int a = 0; + new MockUp<ResponseUtil>() { + + @Mock + public JSONObject genHttpResponse(int retCode, String msg) { + return null; + } + }; + JSONObject result = RoaResponseUtil.add(a); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testAdd1() { + int a = 2; + new MockUp<ResponseUtil>() { + + @Mock + public JSONObject genHttpResponse(int retCode, String msg) { + return null; + } + }; + JSONObject result = RoaResponseUtil.add(a); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testUpdate() { + int a = 0; + new MockUp<ResponseUtil>() { + + @Mock + public JSONObject genHttpResponse(int retCode, String msg) { + return null; + } + }; + JSONObject result = RoaResponseUtil.update(a); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testUpdate1() { + int a = 2; + new MockUp<ResponseUtil>() { + + @Mock + public JSONObject genHttpResponse(int retCode, String msg) { + return null; + } + }; + JSONObject result = RoaResponseUtil.update(a); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testDelete() { + int a = -1; + new MockUp<ResponseUtil>() { + + @Mock + public JSONObject genHttpResponse(int retCode, String msg) { + return null; + } + }; + JSONObject result = RoaResponseUtil.delete(a); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testDelete1() { + int a = 0; + new MockUp<ResponseUtil>() { + + @Mock + public JSONObject genHttpResponse(int retCode, String msg) { + return null; + } + }; + JSONObject result = RoaResponseUtil.delete(a); + JSONObject expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testPrivateConstructor() throws Exception { + Constructor constructor = RoaResponseUtil.class.getDeclaredConstructor(); + assertTrue("Constructor is not private", Modifier.isPrivate(constructor.getModifiers())); + + constructor.setAccessible(true); + constructor.newInstance(); + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManagerTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManagerTest.java new file mode 100644 index 0000000..511e509 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManagerTest.java @@ -0,0 +1,240 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.adapter.impl; + +import static org.junit.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.openo.baseservice.roa.util.restclient.RestfulResponse; +import org.openo.nfvo.resmanagement.common.util.RestfulUtil; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONObject; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 24, 2016 + */ +public class ResmgrAdapter2MSBManagerTest { + + @Test + public void testRegisterResmgr() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(201); + rsp.setResponseJson("{\"msg\":\"success!\"}"); + return rsp; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.registerResmgr(paramsMap, new JSONObject()); + assertNotNull(resultObj); + } + + @Test + public void testRegisterResmgrByInvalid() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(415); + rsp.setResponseJson("{\"msg\":\"invalid parameters\"}"); + return rsp; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.registerResmgr(paramsMap, new JSONObject()); + assertNotNull(resultObj); + } + + @Test + public void testRegisterResmgrByInternalError() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(500); + rsp.setResponseJson("{\"msg\":\"internal system error\"}"); + return rsp; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.registerResmgr(paramsMap, new JSONObject()); + assertNotNull(resultObj); + } + + @Test + public void testRegisterResmgrByFail() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(404); + rsp.setResponseJson("{\"msg\":\"not found\"}"); + return rsp; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.registerResmgr(paramsMap, new JSONObject()); + assertNotNull(resultObj); + } + + @Test + public void testRegisterResmgrByNull() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + return null; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.registerResmgr(paramsMap, new JSONObject()); + assertNotNull(resultObj); + } + + @Test + public void testUnRegisterResmgr() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(204); + rsp.setResponseJson("{\"msg\":\"success!\"}"); + return rsp; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.unregisterResmgr(paramsMap); + assertNotNull(resultObj); + } + + @Test + public void testUnRegisterResmgrByNotFound() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(404); + rsp.setResponseJson("{\"msg\":\"not found!\"}"); + return rsp; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.unregisterResmgr(paramsMap); + assertNotNull(resultObj); + } + + @Test + public void testUnRegisterResmgrByInvalid() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(415); + rsp.setResponseJson("{\"msg\":\"invalid parameters!\"}"); + return rsp; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.unregisterResmgr(paramsMap); + assertNotNull(resultObj); + } + + @Test + public void testUnRegisterResmgrByInternalError() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(500); + rsp.setResponseJson("{\"msg\":\"internal system error!\"}"); + return rsp; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.unregisterResmgr(paramsMap); + assertNotNull(resultObj); + } + + @Test + public void testUnRegisterResmgrByFail() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(203); + rsp.setResponseJson("{\"msg\":\"fail!\"}"); + return rsp; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.unregisterResmgr(paramsMap); + assertNotNull(resultObj); + } + + @Test + public void testUnRegisterResmgrByNull() { + new MockUp<RestfulUtil>() { + + @Mock + public RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) { + return null; + } + }; + Map<String, String> paramsMap = getHashMap(); + ResmgrAdapter2MSBManager resmgr = new ResmgrAdapter2MSBManager(); + JSONObject resultObj = resmgr.unregisterResmgr(paramsMap); + assertNotNull(resultObj); + } + + private Map<String, String> getHashMap() { + Map<String, String> paramsMap = new HashMap<>(); + paramsMap.put("url", "/openoapi/microservices/v1/services"); + paramsMap.put("methodType", "post"); + return paramsMap; + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrServiceTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrServiceTest.java new file mode 100644 index 0000000..4ed114d --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrServiceTest.java @@ -0,0 +1,68 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.adapter.impl; + +import java.io.IOException; + +import org.junit.Test; + +import mockit.Mock; +import mockit.MockUp; + +/** + * <br> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 Sep 24, 2016 + */ +public class ResmgrAdapterMgrServiceTest { + + @Test + public void testRegister() { + new MockUp<ResmgrAdapterMgrService>() { + + @Mock + public String readVimAdapterInfoFromJson() throws IOException { + return "{\"serviceName\": \"resmgr\",\"version\": \"v1\",\"url\": \"/openoapi/resmgr/v1\",\"protocol\": \"REST\",\"visualRange\": \"1\",\"nodes\": [{\"ip\": \"127.0.0.1\",\"port\": \"8080\",\"ttl\": 0}]}"; + } + }; + + ResmgrAdapterMgrService resmgrService = new ResmgrAdapterMgrService(); + resmgrService.register(); + } + + @Test + public void testRegisterByIOException() { + new MockUp<ResmgrAdapterMgrService>() { + + @Mock + public String readVimAdapterInfoFromJson() throws IOException { + throw new IOException(); + } + }; + ResmgrAdapterMgrService resmgrService = new ResmgrAdapterMgrService(); + resmgrService.register(); + } + + @Test + public void testRegisterByNoFile() { + ResmgrAdapterMgrService resmgrService = new ResmgrAdapterMgrService(); + resmgrService.register(); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImplTest.java new file mode 100644 index 0000000..446c29f --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImplTest.java @@ -0,0 +1,161 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.business.impl.HostBusinessImpl; +import org.openo.nfvo.resmanagement.service.dao.impl.HostDaoImpl; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONObject; + +public class HostImplTest { + + @Test + public void testdeleteHostByVimId() throws ServiceException { + new MockUp<HostDaoImpl>() { + + @Mock + public int deleteHostByVimId(String vimId) { + return 1; + } + + }; + HostImpl hostImpl = new HostImpl(); + HostBusinessImpl hostBusiness = new HostBusinessImpl(); + hostBusiness.setHostDao(new HostDaoImpl()); + hostImpl.setHostBusiness(hostBusiness); + + assertTrue(hostImpl.deleteResByVimId("vimId") == 1); + } + @Test + public void testupdateStatusByVimId() throws ServiceException { + HostImpl hostImpl = new HostImpl(); + hostImpl.setHostBusiness(new HostBusinessImpl()); + JSONObject json = new JSONObject(); + json.put("id", "123"); + json.put("vimId", "vim123"); + new MockUp<HostBusinessImpl>() { + + @Mock + public int updateHostByVimId(HostEntity hostEntity) throws ServiceException { + return 1; + } + }; + int result = hostImpl.updateStatusByVimId(json); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testDelete() throws ServiceException { + HostImpl hostImpl = new HostImpl(); + hostImpl.setHostBusiness(new HostBusinessImpl()); + new MockUp<HostBusinessImpl>() { + @Mock + public int deleteHost(String id) throws ServiceException { + return 1; + } + }; + + int result = hostImpl.delete("id"); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + + } + + @Test + public void testAdd1() throws ServiceException { + HostImpl hostImpl = new HostImpl(); + hostImpl.setHostBusiness(new HostBusinessImpl()); + JSONObject json = new JSONObject(); + json.put("id", "1"); + new MockUp<HostBusinessImpl>() { + @Mock + public int addHost(HostEntity hostEntity) throws ServiceException { + return 1; + } + + }; + int result = hostImpl.add(json); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testupdate() throws ServiceException { + HostImpl hostImpl = new HostImpl(); + hostImpl.setHostBusiness(new HostBusinessImpl()); + HostEntity hostEntity = new HostEntity(); + hostEntity.setId("123"); + new MockUp<HostBusinessImpl>() { + @Mock + public int updateHostSelective(HostEntity hostEntity) throws ServiceException { + return 1; + } + + }; + int result = hostImpl.update(hostEntity); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testUpdateResource() throws ServiceException { + HostImpl hostImpl = new HostImpl(); + hostImpl.setHostBusiness(new HostBusinessImpl()); + JSONObject json = new JSONObject(); + json.put("id", "123"); + json.put("vimId", "vim123"); + new MockUp<HostBusinessImpl>() { + + @Mock + public int updateHostSelective(HostEntity hostEntity) throws ServiceException { + return 1; + } + }; + int result = hostImpl.update(json); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testGetList() throws ServiceException { + Map<String, Object> condition = new HashMap<>(); + HostImpl hostImpl = new HostImpl(); + hostImpl.setHostBusiness(new HostBusinessImpl()); + new MockUp<HostBusinessImpl>() { + + @Mock + public List<HostEntity> getHosts(Map<String, Object> condition) { + return null; + } + }; + List<HostEntity> result = hostImpl.getList(condition); + List<HostEntity> exceptedResult = null; + assertEquals(exceptedResult, result); + } + +}
\ No newline at end of file diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImplTest.java new file mode 100644 index 0000000..74dfe99 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImplTest.java @@ -0,0 +1,499 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.business.impl.LocationBusinessImpl; +import org.openo.nfvo.resmanagement.service.business.impl.SitesBusinessImpl; +import org.openo.nfvo.resmanagement.service.dao.impl.LocationDaoImpl; +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONObject; + +public class LocationImplTest { + + private LocationImpl locationImpl; + + @Before + public void setUp() throws ServiceException { + locationImpl = new LocationImpl(); + LocationBusinessImpl locationBusinessImpl = new LocationBusinessImpl(); + locationBusinessImpl.setLocationDao(new LocationDaoImpl()); + SitesImpl sitesImpl = new SitesImpl(); + sitesImpl.setSitesBusiness(new SitesBusinessImpl()); + locationImpl.setSites(sitesImpl); + locationImpl.setLocationBusiness(locationBusinessImpl); + + } + + @Test + public void testLocationImpl() throws ServiceException { + new MockUp<LocationBusinessImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException { + List<LocationEntity> list = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + + list.add(localEntity); + return null; + } + }; + new MockUp<LocationDaoImpl>() { + + @Mock + public int addLocation(LocationEntity locationEntity) { + return 1; + } + }; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", "id"); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "3"); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + assertTrue(locationImpl.add(jsonObject) == 1); + } + + @Test + public void testLocationImplBranch() throws ServiceException { + new MockUp<LocationBusinessImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException { + List<LocationEntity> list = new ArrayList<>(); + + // list.add(localEntity); + return list; + } + }; + new MockUp<LocationDaoImpl>() { + + @Mock + public int addLocation(LocationEntity locationEntity) { + return 1; + } + }; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", ""); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "90"); + jsonObject.put("longitude", "180"); + jsonObject.put("description", "description"); + assertTrue(locationImpl.add(jsonObject) == 1); + } + + @Test + public void testLocationImplBranch1() throws ServiceException { + new MockUp<LocationBusinessImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException { + List<LocationEntity> list = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + + list.add(localEntity); + return null; + } + }; + new MockUp<LocationDaoImpl>() { + + @Mock + public int addLocation(LocationEntity locationEntity) { + return 1; + } + }; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", null); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "3"); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + assertTrue(locationImpl.add(jsonObject) == 1); + } + + @Test(expected = ServiceException.class) + public void testLocationImplException() throws ServiceException { + new MockUp<LocationBusinessImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException { + List<LocationEntity> list = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + + list.add(localEntity); + return list; + } + }; + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", "2"); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "3"); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + locationImpl.add(jsonObject); + } + + @Test(expected = ServiceException.class) + public void testLocationImplException1() throws ServiceException { + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", null); + jsonObject.put("country", ""); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "81"); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + locationImpl.add(jsonObject); + + } + + @Test(expected = ServiceException.class) + public void testLocationImplException2() throws ServiceException { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", null); + jsonObject.put("country", "country"); + jsonObject.put("location", ""); + jsonObject.put("latitude", "81"); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + locationImpl.add(jsonObject); + } + + @Test(expected = ServiceException.class) + public void testLocationImplException3() throws ServiceException { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", null); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", ""); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + locationImpl.add(jsonObject); + } + + @Test(expected = ServiceException.class) + public void testLocationImplException4() throws ServiceException { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", null); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "latitude"); + jsonObject.put("longitude", ""); + jsonObject.put("description", "description"); + locationImpl.add(jsonObject); + } + + @Test(expected = ServiceException.class) + public void testLocationImplException5() throws ServiceException { + new MockUp<LocationBusinessImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException { + List<LocationEntity> list = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + + list.add(localEntity); + return null; + } + }; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", "id"); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "95"); + jsonObject.put("longitude", "185"); + jsonObject.put("description", "description"); + locationImpl.add(jsonObject); + } + + @Test(expected = ServiceException.class) + public void testLocationImplException6() throws ServiceException { + new MockUp<LocationBusinessImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException { + List<LocationEntity> list = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + + list.add(localEntity); + return null; + } + }; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", "id"); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "80"); + jsonObject.put("longitude", "185"); + jsonObject.put("description", "description"); + locationImpl.add(jsonObject); + } + + @Test(expected = ServiceException.class) + public void testLocationImplException7() throws ServiceException { + new MockUp<LocationBusinessImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException { + List<LocationEntity> list = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + + list.add(localEntity); + return null; + } + }; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", "id"); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "95"); + jsonObject.put("longitude", "175"); + jsonObject.put("description", "description"); + locationImpl.add(jsonObject); + } + + @Test + public void testUpdate() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public LocationEntity getLocation(String id) { + LocationEntity localEntity = new LocationEntity(); + localEntity.setCountry("country"); + localEntity.setLocation("location"); + + return localEntity; + } + }; + new MockUp<LocationDaoImpl>() { + + @Mock + public int updateLocationSelective(LocationEntity locationEntity) { + return 1; + } + }; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", "id"); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "14"); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + locationImpl.update(jsonObject); + } + + @Test(expected = ServiceException.class) + public void testUpdateException() throws ServiceException { + + new MockUp<LocationDaoImpl>() { + + @Mock + public int updateLocationSelective(LocationEntity locationEntity) { + return 1; + } + }; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", "id"); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "91"); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + locationImpl.update(jsonObject); + } + + @Test(expected = ServiceException.class) + public void testUpdateException1() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public LocationEntity getLocation(String id) { + LocationEntity localEntity = new LocationEntity(); + localEntity.setCountry("countryNew"); + localEntity.setLocation("location"); + + return localEntity; + } + }; + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", "id"); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "10"); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + locationImpl.update(jsonObject); + } + + @Test(expected = ServiceException.class) + public void testUpdateException2() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public LocationEntity getLocation(String id) { + LocationEntity localEntity = new LocationEntity(); + localEntity.setCountry("country"); + localEntity.setLocation("locationNew"); + + return localEntity; + } + }; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", "id"); + jsonObject.put("country", "country"); + jsonObject.put("location", "location"); + jsonObject.put("latitude", "10"); + jsonObject.put("longitude", "12"); + jsonObject.put("description", "description"); + locationImpl.update(jsonObject); + } + + @Test + public void testDelete() throws ServiceException { + + new MockUp<LocationDaoImpl>() { + + @Mock + public int deleteLocation(String id) { + return 1; + } + }; + assertTrue(locationImpl.delete("location") == 1); + } + + @Test(expected = ServiceException.class) + public void testDeleteException() throws ServiceException { + + locationImpl.delete(""); + } + + @Test + public void testComputeSite() { + JSONObject total = new JSONObject(); + total.put("vcpus", "12"); + total.put("memory", "23"); + total.put("disk", "23"); + JSONObject used = new JSONObject(); + used.put("vcpus", "12"); + used.put("memory", "23"); + used.put("disk", "23"); + locationImpl.getLocationBusiness(); + + assertTrue(locationImpl.computingSite(total, used) != null); + } + + @Test + public void testGetLocation() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) { + List<LocationEntity> list = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + localEntity.setCountry("country"); + localEntity.setLocation("locationNew"); + list.add(localEntity); + return list; + } + }; + assertTrue(locationImpl.getLocation(new HashMap<>()) != null); + } + + @Test + public void testGetLocationBranch() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) { + List<LocationEntity> list = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + localEntity.setCountry("country"); + localEntity.setLocation("locationNew"); + return list; + } + }; + locationImpl.getLocation(new HashMap<>()); + } + + @Test + public void testGetLocationInfo() throws ServiceException { + new MockUp<SitesBusinessImpl>() { + + @Mock + public List<SitesEntity> getSites(Map<String, Object> condition) { + List<SitesEntity> siteList = new ArrayList<>(); + SitesEntity site = new SitesEntity(); + + siteList.add(site); + return siteList; + } + }; + + new MockUp<JSONObject>() { + + @Mock + public JSONObject getJSONObject(String key) { + JSONObject total = new JSONObject(); + total.put("vcpus", "12"); + total.put("memory", "23"); + total.put("disk", "23"); + return total; + } + }; + List<LocationEntity> locationInfo = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + locationInfo.add(localEntity); + locationImpl.getLocationInfo(locationInfo); + } + + @Test + public void testGet() throws ServiceException { + new MockUp<LocationBusinessImpl>() { + + @Mock + public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException { + List<LocationEntity> list = new ArrayList<>(); + LocationEntity localEntity = new LocationEntity(); + + list.add(localEntity); + return null; + } + }; + locationImpl.get(new HashMap<>()); + assertTrue(locationImpl.get("id") != null); + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImplTest.java new file mode 100644 index 0000000..6222005 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImplTest.java @@ -0,0 +1,275 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.business.impl.NetworkBusinessImpl; +import org.openo.nfvo.resmanagement.service.dao.impl.NetworkDaoImpl; +import org.openo.nfvo.resmanagement.service.dao.inf.NetworkDao; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONObject; + +public class NetworkImplTest { + + + @Test + public void testAddBranch() throws ServiceException { + new MockUp<NetworkDaoImpl>() { + + @Mock + public NetworkEntity getNetwork(String id) { + return null; + } + + @Mock + public int addNetwork(NetworkEntity networkEntity) { + return 1; + } + }; + NetworkImpl networkImpl = new NetworkImpl(); + NetworkBusinessImpl networkBusiness = new NetworkBusinessImpl(); + NetworkDao networkDao = new NetworkDaoImpl(); + networkBusiness.setNetworkDao(networkDao); + networkImpl.setNetworkBusiness(networkBusiness); + JSONObject json = new JSONObject(); + json.put("id", "id"); + json.put("name", "name"); + json.put("status", "status"); + json.put("tenant_id", "tenant_id"); + json.put("vimId", "vimId"); + json.put("vimName", "vimName"); + json.put("provider:physical_network", "provider:physical_network"); + json.put("provider:network_type", "provider:network_type"); + json.put("provider:segmentation_id", "provider:segmentation_id"); + assertTrue(networkImpl.add(json) == 1); + } + + @Test + public void testAddBranch1() throws ServiceException { + new MockUp<NetworkDaoImpl>() { + + @Mock + public NetworkEntity getNetwork(String id) { + return null; + } + + @Mock + public int addNetwork(NetworkEntity networkEntity) { + return 1; + } + }; + NetworkImpl networkImpl = new NetworkImpl(); + NetworkBusinessImpl networkBusiness = new NetworkBusinessImpl(); + NetworkDao networkDao = new NetworkDaoImpl(); + networkBusiness.setNetworkDao(networkDao); + networkImpl.setNetworkBusiness(networkBusiness); + JSONObject json = new JSONObject(); + json.put("id", ""); + json.put("name", "name"); + json.put("status", "status"); + json.put("tenant_id", "tenant_id"); + json.put("vimId", "vimId"); + json.put("vimName", "vimName"); + json.put("provider:physical_network", "provider:physical_network"); + json.put("provider:network_type", "provider:network_type"); + json.put("provider:segmentation_id", "provider:segmentation_id"); + assertTrue(networkImpl.add(json) == 1); + } + + @Test(expected = ServiceException.class) + public void testAddBranch2() throws ServiceException { + new MockUp<NetworkDaoImpl>() { + @Mock + public NetworkEntity getNetwork(String id) { + return null; + } + + @Mock + public int addNetwork(NetworkEntity networkEntity) { + return 1; + } + }; + NetworkImpl networkImpl = new NetworkImpl(); + NetworkBusinessImpl networkBusiness = new NetworkBusinessImpl(); + NetworkDao networkDao = new NetworkDaoImpl(); + networkBusiness.setNetworkDao(networkDao); + networkImpl.setNetworkBusiness(networkBusiness); + NetworkEntity entity = null; + networkImpl.add(entity); + + } + + + @Test + public void testDelete() throws ServiceException { + new MockUp<NetworkDaoImpl>() { + + @Mock + public int deleteNetwork(String id) { + return 1; + } + }; + NetworkImpl networkImpl = new NetworkImpl(); + NetworkBusinessImpl networkBusiness = new NetworkBusinessImpl(); + NetworkDao networkDao = new NetworkDaoImpl(); + networkBusiness.setNetworkDao(networkDao); + networkImpl.setNetworkBusiness(networkBusiness); + assertTrue(networkImpl.delete("id") == 1); + } + + @Test(expected = ServiceException.class) + public void testDelete1() throws ServiceException { + + NetworkImpl networkImpl = new NetworkImpl(); + NetworkBusinessImpl networkBusiness = new NetworkBusinessImpl(); + NetworkDao networkDao = new NetworkDaoImpl(); + networkBusiness.setNetworkDao(networkDao); + networkImpl.setNetworkBusiness(networkBusiness); + networkImpl.delete(""); + } + + @Test(expected = ServiceException.class) + public void testDeleteVimByIdException() throws ServiceException { + + NetworkImpl networkImpl = new NetworkImpl(); + NetworkBusinessImpl networkBusiness = new NetworkBusinessImpl(); + NetworkDao networkDao = new NetworkDaoImpl(); + networkBusiness.setNetworkDao(networkDao); + networkImpl.setNetworkBusiness(networkBusiness); + networkImpl.deleteResByVimId(""); + } + + @Test + public void testDeleteVimById() throws ServiceException { + new MockUp<NetworkDaoImpl>() { + + @Mock + public int deleteNetworkByVimId(String vimId) { + return 1; + } + }; + NetworkImpl networkImpl = new NetworkImpl(); + NetworkBusinessImpl networkBusiness = new NetworkBusinessImpl(); + NetworkDao networkDao = new NetworkDaoImpl(); + networkBusiness.setNetworkDao(networkDao); + networkImpl.setNetworkBusiness(networkBusiness); + assertTrue(networkImpl.deleteResByVimId("vimId") == 1); + } + + + @Test + public void testUpdate() throws ServiceException { + new MockUp<NetworkDaoImpl>() { + + @Mock + public int updateNetworkSelective(NetworkEntity networkEntity) { + return 1; + } + }; + NetworkImpl networkImpl = new NetworkImpl(); + NetworkBusinessImpl networkBusiness = new NetworkBusinessImpl(); + NetworkDao networkDao = new NetworkDaoImpl(); + networkBusiness.setNetworkDao(networkDao); + networkImpl.setNetworkBusiness(networkBusiness); + + JSONObject json = new JSONObject(); + json.put("id", ""); + json.put("name", "name"); + json.put("status", "status"); + json.put("tenant_id", "tenant_id"); + json.put("vimId", "vimId"); + json.put("vimName", "vimName"); + json.put("provider:physical_network", "provider:physical_network"); + json.put("provider:network_type", "provider:network_type"); + json.put("provider:segmentation_id", "provider:segmentation_id"); + assertTrue(networkImpl.update(json)==1); + } + + + + @Test + public void testUpdateVimById() throws ServiceException { + new MockUp<NetworkDaoImpl>() { + + @Mock + public int updateNetworkByVimId(NetworkEntity NetworkEntity) { + return 1; + } + }; + NetworkImpl networkImpl = new NetworkImpl(); + NetworkBusinessImpl networkBusiness = new NetworkBusinessImpl(); + NetworkDao networkDao = new NetworkDaoImpl(); + networkBusiness.setNetworkDao(networkDao); + networkImpl.setNetworkBusiness(networkBusiness); + JSONObject json = new JSONObject(); + json.put("id", ""); + json.put("name", "name"); + json.put("status", "status"); + json.put("tenant_id", "tenant_id"); + json.put("vimId", "vimId"); + json.put("vimName", "vimName"); + json.put("provider:physical_network", "provider:physical_network"); + json.put("provider:network_type", "provider:network_type"); + json.put("provider:segmentation_id", "provider:segmentation_id"); + assertTrue(networkImpl.updateStatusByVimId(json)==1); + + } + + @Test + public void testgetList() throws ServiceException { + Map<String, Object> condition = new HashMap<>(); + NetworkImpl networkImpl = new NetworkImpl(); + networkImpl.setNetworkBusiness(new NetworkBusinessImpl()); + new MockUp<NetworkBusinessImpl>() { + + @Mock + public List<NetworkEntity> getNetworks(Map<String, Object> condition) { + return null; + } + }; + List<NetworkEntity> result = networkImpl.getList(condition); + List<NetworkEntity> exceptedResult = null; + assertEquals(exceptedResult, result); + } + @Test + public void testadd() throws ServiceException { + NetworkImpl networkImpl = new NetworkImpl(); + networkImpl.setNetworkBusiness(new NetworkBusinessImpl()); + NetworkEntity networkEntity =new NetworkEntity(); + networkEntity.setId("1"); + new MockUp<NetworkBusinessImpl>() { + + @Mock + public int addNetwork(NetworkEntity networkEntity ) { + return 1; + } + }; + int result = networkImpl.add(networkEntity); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + } diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImplTest.java new file mode 100644 index 0000000..3d36011 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImplTest.java @@ -0,0 +1,153 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.util.JsonUtil; +import org.openo.nfvo.resmanagement.service.business.impl.PortBusinessImpl; +import org.openo.nfvo.resmanagement.service.dao.impl.PortDaoImpl; +import org.openo.nfvo.resmanagement.service.entity.PortEntity; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONObject; + +public class PortImplTest { + + @Test + public void testAddBranch() throws ServiceException { + new MockUp<PortDaoImpl>() { + + @Mock + public PortEntity getPort(String id) { + return null; + } + + @Mock + public int addPort(PortEntity portEntity) { + return 1; + } + }; + PortImpl portImpl = new PortImpl(); + PortBusinessImpl portBusiness = new PortBusinessImpl(); + portBusiness.setPortDao(new PortDaoImpl()); + portImpl.setPortBusiness(portBusiness); + JSONObject json = new JSONObject(); + json.put("id", ""); + json.put("name", "name"); + json.put("status", "status"); + json.put("tenant_id", "tenant_id"); + json.put("vimId", "vimId"); + json.put("vimName", "vimName"); + json.put("network_id", "network_id"); + assertTrue(portImpl.add(json) == 1); + } + + @Test(expected = ServiceException.class) + public void testAddBranch1() throws ServiceException { + + PortImpl portImpl = new PortImpl(); + PortBusinessImpl portBusiness = new PortBusinessImpl(); + portBusiness.setPortDao(new PortDaoImpl()); + portImpl.setPortBusiness(portBusiness); + PortEntity portEntity = null; + portImpl.add(portEntity); + } + + @Test(expected = ServiceException.class) + public void testUpdateException() throws ServiceException { + + PortImpl portImpl = new PortImpl(); + PortBusinessImpl portBusiness = new PortBusinessImpl(); + portBusiness.setPortDao(new PortDaoImpl()); + portImpl.setPortBusiness(portBusiness); + PortEntity portEntity = null; + portImpl.update(portEntity); + } + + @Test + public void testUpdate() throws ServiceException { + new MockUp<PortDaoImpl>() { + + @Mock + public int updatePortSelective(PortEntity portEntity) { + return 1; + } + + }; + PortImpl portImpl = new PortImpl(); + PortBusinessImpl portBusiness = new PortBusinessImpl(); + portBusiness.setPortDao(new PortDaoImpl()); + portImpl.setPortBusiness(portBusiness); + assertTrue(portImpl.update(new JSONObject()) == 1); + } + + @Test + public void testdelete() throws ServiceException { + new MockUp<PortDaoImpl>() { + + @Mock + public int deletePort(String id) { + return 1; + } + + }; + PortImpl portImpl = new PortImpl(); + PortBusinessImpl portBusiness = new PortBusinessImpl(); + portBusiness.setPortDao(new PortDaoImpl()); + portImpl.setPortBusiness(portBusiness); + + } + + @Test + public void testDeleteResByVimId() throws ServiceException { + new MockUp<PortDaoImpl>() { + + @Mock + public int deletePortByVimId(String vimId) { + return 1; + } + + }; + PortImpl portImpl = new PortImpl(); + PortBusinessImpl portBusiness = new PortBusinessImpl(); + portBusiness.setPortDao(new PortDaoImpl()); + portImpl.setPortBusiness(portBusiness); + assertTrue(portImpl.deleteResByVimId("vimId") == 1); + } + + @Test(expected = ServiceException.class) + public void testDeleteResByVimIdException() throws ServiceException { + PortImpl portImpl = new PortImpl(); + PortBusinessImpl portBusiness = new PortBusinessImpl(); + portBusiness.setPortDao(new PortDaoImpl()); + portImpl.setPortBusiness(portBusiness); + portImpl.deleteResByVimId(""); + } + + @Test(expected = ServiceException.class) + public void testDelete() throws ServiceException { + PortImpl portImpl = new PortImpl(); + PortBusinessImpl portBusiness = new PortBusinessImpl(); + portBusiness.setPortDao(new PortDaoImpl()); + portImpl.setPortBusiness(portBusiness); + portImpl.delete(""); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImplTest.java new file mode 100644 index 0000000..5db06a8 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImplTest.java @@ -0,0 +1,148 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.business.impl.SitesBusinessImpl; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONObject; + +public class SitesImplTest { + + + + @Test + public void testUpdate1() throws ServiceException { + SitesImpl sitesImpl = new SitesImpl(); + sitesImpl.setSitesBusiness(new SitesBusinessImpl()); + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setId("123"); + new MockUp<SitesBusinessImpl>() { + + @Mock + public int updateSiteSelective(SitesEntity sitesEntity) throws ServiceException { + return 1; + } + }; + int result = sitesImpl.update(sitesEntity); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testUpdateResource() throws ServiceException { + SitesImpl sitesImpl = new SitesImpl(); + sitesImpl.setSitesBusiness(new SitesBusinessImpl()); + JSONObject json = new JSONObject(); + json.put("id", "123"); + json.put("vimId", "vim123"); + new MockUp<SitesBusinessImpl>() { + + @Mock + public int updateSiteResource(SitesEntity sitesEntity) throws ServiceException { + return 1; + } + }; + int result = sitesImpl.updateResource(json); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testUpdateStatusByVimId() throws ServiceException { + SitesImpl sitesImpl = new SitesImpl(); + sitesImpl.setSitesBusiness(new SitesBusinessImpl()); + JSONObject json = new JSONObject(); + json.put("id", "123"); + json.put("vimId", "vim123"); + new MockUp<SitesBusinessImpl>() { + + @Mock + public int updateSiteByVimId(SitesEntity sitesEntity) throws ServiceException { + return 1; + } + }; + int result = sitesImpl.updateStatusByVimId(json); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testGetList() throws ServiceException { + Map<String, Object> condition = new HashMap<>(); + SitesImpl sitesImpl = new SitesImpl(); + sitesImpl.setSitesBusiness(new SitesBusinessImpl()); + new MockUp<SitesBusinessImpl>() { + + @Mock + public List<SitesEntity> getSites(Map<String, Object> condition) { + return null; + } + }; + List<SitesEntity> result = sitesImpl.getList(condition); + List<SitesEntity> exceptedResult = null; + assertEquals(exceptedResult, result); + } + + @Test + public void testGetNull() throws ServiceException { + Map<String, Object> condition = new HashMap<>(); + SitesImpl sitesImpl = new SitesImpl(); + sitesImpl.setSitesBusiness(new SitesBusinessImpl()); + new MockUp<SitesBusinessImpl>() { + + @Mock + public List<SitesEntity> getSites(Map<String, Object> condition) { + return null; + } + }; + SitesEntity result = sitesImpl.get(condition); + SitesEntity exceptedResult = null; + assertEquals(exceptedResult, result); + } + + @Test + public void testGet() throws ServiceException { + Map<String, Object> condition = new HashMap<>(); + SitesImpl sitesImpl = new SitesImpl(); + sitesImpl.setSitesBusiness(new SitesBusinessImpl()); + new MockUp<SitesBusinessImpl>() { + + @Mock + public List<SitesEntity> getSites(Map<String, Object> condition) { + List<SitesEntity> list = new ArrayList<SitesEntity>(); + return list; + } + }; + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setId("123"); + sitesImpl.deleteResByVimId("vimId"); + SitesEntity result = sitesImpl.get(condition); + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImplTest.java new file mode 100644 index 0000000..b21525c --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImplTest.java @@ -0,0 +1,135 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.base.openstack.impl; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.base.openstack.impl.VimImpl; +import org.openo.nfvo.resmanagement.service.business.impl.VimBusinessImpl; +import org.openo.nfvo.resmanagement.service.entity.VimEntity; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONObject; + +public class VimImplTest { + + @Test + public void testAdd() throws ServiceException { + VimImpl vimImpl = new VimImpl(); + vimImpl.setVimBusiness(new VimBusinessImpl()); + new MockUp<VimBusinessImpl>() { + + @Mock + public int addVim(String id) throws ServiceException { + return 1; + } + }; + int result = vimImpl.add("id"); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testAdd1() throws ServiceException { + VimImpl vimImpl = new VimImpl(); + vimImpl.setVimBusiness(new VimBusinessImpl()); + JSONObject json = new JSONObject(); + json.put("id", "123"); + new MockUp<VimBusinessImpl>() { + + @Mock + public int addVim(String id) throws ServiceException { + return 1; + } + }; + int result = vimImpl.add(json); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testUpdate() throws ServiceException { + VimImpl vimImpl = new VimImpl(); + vimImpl.setVimBusiness(new VimBusinessImpl()); + JSONObject json = new JSONObject(); + json.put("id", "123"); + json.put("vimId", "vim123"); + int result = vimImpl.update(json); + int exceptedResult = 0; + assertEquals(exceptedResult, result); + } + + @Test + public void testDelete() throws ServiceException { + VimImpl vimImpl = new VimImpl(); + vimImpl.setVimBusiness(new VimBusinessImpl()); + new MockUp<VimBusinessImpl>() { + + @Mock + public int deleteVim(String id) throws ServiceException { + return 1; + } + }; + int result = vimImpl.delete("id"); + int exceptedResult = 1; + assertEquals(exceptedResult, result); + } + + @Test + public void testGetVim() throws ServiceException { + VimImpl vimImpl = new VimImpl(); + vimImpl.setVimBusiness(new VimBusinessImpl()); + new MockUp<VimBusinessImpl>() { + + @Mock + public VimEntity getVim(String id) { + return null; + } + }; + VimEntity result = vimImpl.getVim("id"); + VimEntity exceptedResult = null; + assertEquals(exceptedResult, result); + } + + @Test + public void testGetList() throws ServiceException { + VimImpl vimImpl = new VimImpl(); + vimImpl.setVimBusiness(new VimBusinessImpl()); + new MockUp<VimBusinessImpl>() { + + @Mock + public List<VimEntity> getVims() { + return null; + } + }; + List<VimEntity> result = vimImpl.getList(); + List<VimEntity> exceptedResult = null; + assertEquals(exceptedResult, result); + } + + @Test + public void testSetVimBusiness() throws ServiceException { + VimImpl vimImpl = new VimImpl(); + vimImpl.setVimBusiness(new VimBusinessImpl()); + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImplTest.java new file mode 100644 index 0000000..1a1d142 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImplTest.java @@ -0,0 +1,87 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.dao.impl.HostDaoImpl; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; + +import mockit.Mock; +import mockit.MockUp; + +public class HostBusinessImplTest { + + @Test + public void testGetHost() { + HostBusinessImpl hostBussinessImp = new HostBusinessImpl(); + assertTrue(hostBussinessImp.getHost("") == null); + } + + @Test + public void testGetHostBranch() { + new MockUp<HostDaoImpl>() { + + @Mock + public HostEntity getHost(String id) { + return new HostEntity(); + } + + }; + HostBusinessImpl hostBussinessImp = new HostBusinessImpl(); + hostBussinessImp.setHostDao(new HostDaoImpl()); + assertTrue(hostBussinessImp.getHost("id") != null); + } + + @Test(expected = ServiceException.class) + public void testDelete() throws ServiceException { + HostBusinessImpl hostBussinessImp = new HostBusinessImpl(); + hostBussinessImp.deleteHost(""); + } + + @Test(expected = ServiceException.class) + public void testUpdateHost() throws ServiceException { + HostBusinessImpl hostBussinessImp = new HostBusinessImpl(); + hostBussinessImp.updateHost(null); + } + + @Test(expected = ServiceException.class) + public void testDeleteHostByVimId() throws ServiceException { + HostBusinessImpl hostBussinessImp = new HostBusinessImpl(); + hostBussinessImp.deleteHostByVimId(""); + } + + @Test(expected = ServiceException.class) + public void testUpdateHostByVimId() throws ServiceException { + HostBusinessImpl hostBussinessImp = new HostBusinessImpl(); + hostBussinessImp.updateHostByVimId(null); + } + + @Test(expected = ServiceException.class) + public void testAddHost() throws ServiceException { + HostBusinessImpl hostBussinessImp = new HostBusinessImpl(); + hostBussinessImp.addHost(null); + } + + @Test(expected = ServiceException.class) + public void testAddHostSelective() throws ServiceException { + HostBusinessImpl hostBussinessImp = new HostBusinessImpl(); + hostBussinessImp.addHostSelective(null); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImplTest.java new file mode 100644 index 0000000..32ec28a --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImplTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import org.junit.Before; +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.baseservice.roa.util.restclient.HttpRest; +import org.openo.baseservice.roa.util.restclient.RestfulOptions; +import org.openo.baseservice.roa.util.restclient.RestfulParametes; +import org.openo.baseservice.roa.util.restclient.RestfulResponse; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONObject; + +public class LimitsBusinessImplTest { + + private LimitsBusinessImpl limitsBusinessImpl; + + @Before + public void setUp() throws ServiceException { + limitsBusinessImpl = new LimitsBusinessImpl(); + } + + @Test + public void testGetCpuLimits() throws ServiceException { + new MockUp<HttpRest>() { + + @Mock + public RestfulResponse get(String servicePath, RestfulParametes restParametes, RestfulOptions option) + throws ServiceException { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(200); + return rsp; + } + }; + JSONObject paramJson = new JSONObject(); + paramJson.put("vimId", "vimId"); + paramJson.put("tenantId", "tenantId"); + } + + @Test + public void testgetLimits() throws ServiceException { + new MockUp<HttpRest>() { + + @Mock + public RestfulResponse get(String servicePath, RestfulParametes restParametes, RestfulOptions option) + throws ServiceException { + RestfulResponse rsp = new RestfulResponse(); + rsp.setStatus(200); + return rsp; + } + + }; + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImplTest.java new file mode 100644 index 0000000..03f17b3 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImplTest.java @@ -0,0 +1,219 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.dao.impl.LocationDaoImpl; +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; + +import mockit.Mock; +import mockit.MockUp; + +public class LocationBusinessImplTest { + + private LocationBusinessImpl locationBusinessImpl; + + @Before + public void setUp() throws ServiceException { + locationBusinessImpl = new LocationBusinessImpl(); + locationBusinessImpl.setLocationDao(new LocationDaoImpl()); + } + + @Test + public void testGet() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public LocationEntity getLocation(String id) { + LocationEntity localEntity = new LocationEntity(); + localEntity.setCountry("country"); + localEntity.setLocation("location"); + + return localEntity; + } + }; + assertTrue(locationBusinessImpl.getLocation("id") != null); + } + + @Test + public void testGetBranch() throws ServiceException { + + assertTrue(locationBusinessImpl.getLocation("") == null); + } + + @Test(expected = ServiceException.class) + public void testAddLocationSelectiveExceptio() throws ServiceException { + locationBusinessImpl.addLocationSelective(null); + } + + @Test + public void testAddLocationSelective() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public int addLocationSelective(LocationEntity locationEntity) { + return 1; + } + }; + LocationEntity locationEntity = new LocationEntity(); + locationEntity.setCountry("country"); + locationEntity.setDescription("description"); + locationEntity.setId("id"); + locationEntity.setLatitude("1"); + locationEntity.setLongitude("12"); + locationEntity.setLocation("location"); + locationBusinessImpl.addLocationSelective(locationEntity); + } + + @Test + public void testAddLocationSelectiveBranch() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public int addLocationSelective(LocationEntity locationEntity) { + return 1; + } + }; + LocationEntity locationEntity = new LocationEntity(); + locationEntity.setCountry("country"); + locationEntity.setDescription("description"); + locationEntity.setId(""); + locationEntity.setLatitude("1"); + locationEntity.setLongitude("12"); + locationEntity.setLocation("location"); + locationBusinessImpl.addLocationSelective(locationEntity); + } + + @Test + public void testAddLocationSelectiveBranch1() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public int addLocationSelective(LocationEntity locationEntity) { + return 1; + } + }; + LocationEntity locationEntity = new LocationEntity(); + locationEntity.setCountry("country"); + locationEntity.setDescription("description"); + locationEntity.setId(null); + locationEntity.setLatitude("1"); + locationEntity.setLongitude("12"); + locationEntity.setLocation("location"); + locationBusinessImpl.addLocationSelective(locationEntity); + } + + @Test(expected = ServiceException.class) + public void testAddLocationSelectiveException1() throws ServiceException { + LocationEntity locationEntity = new LocationEntity(); + locationEntity.setCountry(""); + locationEntity.setDescription("description"); + locationEntity.setId("id"); + locationEntity.setLatitude("1"); + locationEntity.setLongitude("12"); + locationEntity.setLocation("location"); + locationBusinessImpl.addLocationSelective(locationEntity); + } + + @Test(expected = ServiceException.class) + public void testAddLocationSelectiveException2() throws ServiceException { + LocationEntity locationEntity = new LocationEntity(); + locationEntity.setCountry("country"); + locationEntity.setDescription("description"); + locationEntity.setId("id"); + locationEntity.setLatitude("1"); + locationEntity.setLongitude("12"); + locationEntity.setLocation(""); + locationBusinessImpl.addLocationSelective(locationEntity); + } + + @Test(expected = ServiceException.class) + public void testAddLocationSelectiveException3() throws ServiceException { + LocationEntity locationEntity = new LocationEntity(); + locationEntity.setCountry("country"); + locationEntity.setDescription("description"); + locationEntity.setId("id"); + locationEntity.setLatitude(""); + locationEntity.setLongitude("12"); + locationEntity.setLocation("location"); + locationBusinessImpl.addLocationSelective(locationEntity); + } + + @Test(expected = ServiceException.class) + public void testAddLocationSelectiveException4() throws ServiceException { + LocationEntity locationEntity = new LocationEntity(); + locationEntity.setCountry("country"); + locationEntity.setDescription("description"); + locationEntity.setId("id"); + locationEntity.setLatitude("1"); + locationEntity.setLongitude(""); + locationEntity.setLocation("location"); + locationBusinessImpl.addLocationSelective(locationEntity); + } + + @Test(expected = ServiceException.class) + public void testUpdateLocationSelective() throws ServiceException { + locationBusinessImpl.updateLocationSelective(null); + } + + @Test(expected = ServiceException.class) + public void testAddLocation() throws ServiceException { + locationBusinessImpl.addLocation(null); + } + + @Test + public void testUpdateLocation() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public int updateLocation(LocationEntity locationEntity) { + return 1; + } + }; + locationBusinessImpl.getLocationDao(); + LocationEntity locationEntity = new LocationEntity(); + locationEntity.setLatitude("1"); + locationEntity.setLongitude("2"); + locationBusinessImpl.updateLocation(locationEntity); + } + + @Test(expected = ServiceException.class) + public void testUpdateLocationException() throws ServiceException { + new MockUp<LocationDaoImpl>() { + + @Mock + public int updateLocation(LocationEntity locationEntity) { + return 1; + } + }; + locationBusinessImpl.getLocationDao(); + LocationEntity locationEntity = new LocationEntity(); + locationEntity.setLatitude("100"); + locationEntity.setLongitude("2"); + locationBusinessImpl.updateLocation(locationEntity); + } + + @Test(expected = ServiceException.class) + public void testUpdateLocationException1() throws ServiceException { + locationBusinessImpl.getLocationDao(); + locationBusinessImpl.updateLocation(null); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImplTest.java new file mode 100644 index 0000000..94a0dad --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImplTest.java @@ -0,0 +1,408 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.dao.impl.SitesDaoImpl; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; + +import mockit.Mock; +import mockit.MockUp; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 2016年8月16日 + */ +public class SitesBusinessImplTest { + + private SitesBusinessImpl sitesBusinessImpl; + + @Before + public void setUp() { + sitesBusinessImpl = new SitesBusinessImpl(); + sitesBusinessImpl.setSitesDao(new SitesDaoImpl()); + } + + @Test + public void testGetSitesIdIsNull() throws ServiceException { + try { + sitesBusinessImpl.getSite(null); + } catch(ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testGetSite() throws ServiceException { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setId("123"); + new MockUp<SitesDaoImpl>() { + + @Mock + public SitesEntity getSite(String id) { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setId("123"); + return sitesEntity; + } + }; + SitesEntity result = sitesBusinessImpl.getSite("id"); + SitesEntity expectedResult = sitesEntity; + assertEquals(expectedResult.toString(), result.toString()); + } + + @Test + public void testGetSites() throws ServiceException { + Map<String, Object> condition = new HashMap<String, Object>(); + SitesBusinessImpl sitesBusinessImpl = new SitesBusinessImpl(); + sitesBusinessImpl.setSitesDao(new SitesDaoImpl()); + new MockUp<SitesDaoImpl>() { + + @Mock + public List<SitesEntity> getSites(Map<String, Object> condition) { + return null; + } + }; + List<SitesEntity> result = sitesBusinessImpl.getSites(condition); + assertNull(result); + } + + @Test + public void testDeleteSiteEmpty() throws ServiceException { + SitesBusinessImpl sitesBusinessImpl = new SitesBusinessImpl(); + sitesBusinessImpl.setSitesDao(new SitesDaoImpl()); + try { + sitesBusinessImpl.deleteSite(""); + } catch(ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testDeleteSite() throws ServiceException { + new MockUp<SitesDaoImpl>() { + + @Mock + public SitesEntity getSite(String id) { + return null; + } + + @Mock + public int deleteSite(String id) { + return 1; + } + }; + int result = sitesBusinessImpl.deleteSite("007"); + int expectedResult = 1; + assertEquals(expectedResult, result); + } + + @Test + public void testAddSiteSitesEntityIsNull() throws ServiceException { + try { + sitesBusinessImpl.addSite(null); + } catch(ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testCheckSiteExceptions() throws ServiceException { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setCountry("country"); + sitesEntity.setId("id"); + sitesEntity.setLocation("location"); + sitesEntity.setName("name"); + sitesEntity.setStatus("siteStatus"); + sitesEntity.setTotalCPU("12"); + sitesEntity.setTotalDisk("12"); + sitesEntity.setTotalMemory("134"); + sitesEntity.setUsedCPU("12"); + sitesEntity.setUsedDisk("23"); + sitesEntity.setUsedMemory("10"); + sitesEntity.setVimId("siteVimId"); + sitesEntity.setVimName("siteVimName"); + new MockUp<SitesDaoImpl>() { + + int count1 = 0; + + @Mock + public SitesEntity getSite(String id) { + return null; + } + + @Mock + public List<SitesEntity> getSites(Map<String, Object> condition) { + if(count1 == 0) { + count1 += 1; + return null; + } + return new ArrayList<SitesEntity>(); + + } + }; + new MockUp<SitesEntity>() { + + @Mock + public boolean checkResource(SitesEntity siteEntity) { + return false; + } + }; + try { + sitesBusinessImpl.addSite(sitesEntity); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testCheckSiteExceptions1() throws ServiceException { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setCountry("country"); + sitesEntity.setId("id"); + sitesEntity.setLocation("location"); + sitesEntity.setName("name"); + sitesEntity.setStatus("siteStatus"); + sitesEntity.setTotalCPU("12"); + sitesEntity.setTotalDisk("12"); + sitesEntity.setTotalMemory("134"); + sitesEntity.setUsedCPU("12"); + sitesEntity.setUsedDisk("23"); + sitesEntity.setUsedMemory("10"); + sitesEntity.setVimId("siteVimId"); + sitesEntity.setVimName("siteVimName"); + new MockUp<SitesDaoImpl>() { + + int count1 = 0; + + @Mock + public SitesEntity getSite(String id) { + return null; + } + + @Mock + public List<SitesEntity> getSites(Map<String, Object> condition) { + + return null; + + } + }; + new MockUp<SitesEntity>() { + + @Mock + public boolean checkResource(SitesEntity siteEntity) { + return false; + } + }; + try { + sitesBusinessImpl.addSite(sitesEntity); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testCheckSiteExceptions2() throws ServiceException { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setCountry(""); + sitesEntity.setId("id"); + sitesEntity.setLocation(""); + sitesEntity.setName(""); + sitesEntity.setStatus("siteStatus"); + sitesEntity.setTotalCPU("12"); + sitesEntity.setTotalDisk("12"); + sitesEntity.setTotalMemory("134"); + sitesEntity.setUsedCPU("12"); + sitesEntity.setUsedDisk("23"); + sitesEntity.setUsedMemory("10"); + sitesEntity.setVimId("siteVimId"); + sitesEntity.setVimName("siteVimName"); + new MockUp<SitesDaoImpl>() { + + int count1 = 0; + + @Mock + public SitesEntity getSite(String id) { + return null; + } + + @Mock + public List<SitesEntity> getSites(Map<String, Object> condition) { + + return null; + + } + }; + new MockUp<SitesEntity>() { + + @Mock + public boolean checkResource(SitesEntity siteEntity) { + return false; + } + }; + try { + sitesBusinessImpl.addSite(sitesEntity); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testCheckSiteNameExceptions() throws ServiceException { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setId("123"); + sitesEntity.setCountry("china"); + sitesEntity.setName("openstack"); + sitesEntity.setLocation("xian"); + new MockUp<SitesDaoImpl>() { + + @Mock + public SitesEntity getSite(String id) { + return null; + } + + @Mock + public List<SitesEntity> getSites(Map<String, Object> condition) { + List<SitesEntity> list = new ArrayList<SitesEntity>(); + list.add(new SitesEntity()); + return list; + + } + }; + try { + sitesBusinessImpl.addSite(sitesEntity); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testCheckIdExceptions() throws ServiceException { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setId("123"); + sitesEntity.setCountry("china"); + sitesEntity.setName("openstack"); + sitesEntity.setLocation("xian"); + new MockUp<SitesDaoImpl>() { + + @Mock + public SitesEntity getSite(String id) { + return new SitesEntity(); + } + }; + try { + sitesBusinessImpl.addSite(sitesEntity); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testAddSiteSelectiveSitesEntityIsNull() throws ServiceException { + try { + sitesBusinessImpl.addSiteSelective(null); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testUpdateSiteSelectiveSitesEntityIsNull() throws ServiceException { + try { + sitesBusinessImpl.updateSiteSelective(null); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testUpdateSiteSitesEntityIsNull() throws ServiceException { + try { + sitesBusinessImpl.updateSite(null); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testUpdateSiteByVimIdSitesEntityIsNull() throws ServiceException { + try { + sitesBusinessImpl.updateSiteByVimId(null); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testUpdateSiteByVimId() throws ServiceException { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setCountry("china"); + sitesEntity.setName("openstack"); + sitesEntity.setLocation("xian"); + new MockUp<SitesDaoImpl>() { + + @Mock + public int updateSiteByVimId(SitesEntity sitesEntity) { + return 1; + } + }; + int result = sitesBusinessImpl.updateSiteByVimId(sitesEntity); + int expectedResult = 1; + assertEquals(expectedResult, result); + } + + @Test + public void testUpdateSiteResourceSitesEntityIsNull() throws ServiceException { + try { + sitesBusinessImpl.updateSiteResource(null); + } catch(ServiceException se) { + assertTrue(true); + } + } + + @Test + public void testUpdateSiteResource() throws ServiceException { + SitesEntity sitesEntity = new SitesEntity(); + sitesEntity.setCountry("china"); + sitesEntity.setName("openstack"); + sitesEntity.setLocation("xian"); + new MockUp<SitesDaoImpl>() { + + @Mock + public int updateSiteSelective(SitesEntity sitesEntity) { + return 1; + } + }; + int result = sitesBusinessImpl.updateSiteResource(sitesEntity); + int expectedResult = 1; + assertEquals(expectedResult, result); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImplTest.java new file mode 100644 index 0000000..1e35569 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImplTest.java @@ -0,0 +1,177 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.business.impl; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.dao.impl.VimDaoImpl; +import org.openo.nfvo.resmanagement.service.entity.VimEntity; + +import mockit.Mock; +import mockit.MockUp; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 2016年8月18日 + */ +public class VimBusinessImplTest { + + @Test + public void testGetVimIdIsNull() { + VimBusinessImpl vimBusinessImpl = new VimBusinessImpl(); + vimBusinessImpl.setVimDao(new VimDaoImpl()); + VimEntity result = vimBusinessImpl.getVim(null); + VimEntity expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testGetVim() { + VimBusinessImpl vimBusinessImpl = new VimBusinessImpl(); + vimBusinessImpl.setVimDao(new VimDaoImpl()); + VimEntity vimEntity = new VimEntity(); + vimEntity.setId("123"); + new MockUp<VimDaoImpl>() { + + @Mock + public VimEntity getVim(String id) { + VimEntity vimEntity = new VimEntity(); + vimEntity.setId("123"); + return vimEntity; + } + }; + VimEntity result = vimBusinessImpl.getVim("id"); + VimEntity expectedResult = vimEntity; + assertEquals(expectedResult.toString(), result.toString()); + } + + @Test + public void testGetVims() throws ServiceException { + VimBusinessImpl vimBusinessImpl = new VimBusinessImpl(); + vimBusinessImpl.setVimDao(new VimDaoImpl()); + new MockUp<VimDaoImpl>() { + + @Mock + public List<VimEntity> getVims() { + return null; + } + }; + List<VimEntity> result = vimBusinessImpl.getVims(); + List<VimEntity> expectedResult = null; + assertEquals(expectedResult, result); + } + + @Test + public void testDeleteVimEmpty() throws ServiceException { + VimBusinessImpl vimBusinessImpl = new VimBusinessImpl(); + vimBusinessImpl.setVimDao(new VimDaoImpl()); + try { + vimBusinessImpl.deleteVim(""); + } catch (ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testDeleteVim() throws ServiceException { + VimBusinessImpl vimBusinessImpl = new VimBusinessImpl(); + vimBusinessImpl.setVimDao(new VimDaoImpl()); + new MockUp<VimDaoImpl>() { + + @Mock + public int deleteVim(String id) { + return 1; + } + }; + int result = vimBusinessImpl.deleteVim("xian"); + int expectedResult = 1; + assertEquals(expectedResult, result); + } + + @Test + public void testAddVimExceptions() throws ServiceException { + VimBusinessImpl vimBusinessImpl = new VimBusinessImpl(); + vimBusinessImpl.setVimDao(new VimDaoImpl()); + try { + vimBusinessImpl.addVim(null); + } catch (ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testAddVimExceptions1() throws ServiceException { + VimBusinessImpl vimBusinessImpl = new VimBusinessImpl(); + vimBusinessImpl.setVimDao(new VimDaoImpl()); + new MockUp<VimDaoImpl>() { + + @Mock + public VimEntity getVim(String id) { + return new VimEntity(); + } + }; + try { + vimBusinessImpl.addVim("id"); + } catch (ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testAddVimExceptions2() throws ServiceException { + VimBusinessImpl vimBusinessImpl = new VimBusinessImpl(); + vimBusinessImpl.setVimDao(new VimDaoImpl()); + VimEntity vimEntity = new VimEntity(); + vimEntity.setId("123"); + try { + vimBusinessImpl.addVim(""); + } catch (ServiceException e) { + assertTrue(true); + } + } + + @Test + public void testAddVim() throws ServiceException { + VimBusinessImpl vimBusinessImpl = new VimBusinessImpl(); + vimBusinessImpl.setVimDao(new VimDaoImpl()); + new MockUp<VimDaoImpl>() { + + @Mock + public VimEntity getVim(String id) { + return null; + } + + @Mock + public int addVim(VimEntity vimEntity) { + return 1; + } + }; + int result = vimBusinessImpl.addVim("123"); + int expectedResult = 1; + assertEquals(expectedResult, result); + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImplTest.java new file mode 100644 index 0000000..65e7b97 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImplTest.java @@ -0,0 +1,155 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.openo.nfvo.resmanagement.service.mapper.HostMapper; +import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper; + +import mockit.Expectations; +import mockit.Mock; +import mockit.MockUp; +import mockit.Mocked; + +public class HostDaoImplTest { + @Mocked + HostMapper mapper; + @Test + public void testdeleteHost() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + HostDaoImpl impl = new HostDaoImpl(); + assertEquals(0, impl.deleteHost("123")); + } + + @Test + public void testdeleteHostByVimId() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + HostDaoImpl impl = new HostDaoImpl(); + assertEquals(0, impl.deleteHostByVimId("123")); + } + + @Test + public void testaddHost() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + HostDaoImpl impl = new HostDaoImpl(); + HostEntity hostEntity =new HostEntity(); + hostEntity.setId("1"); + assertEquals(0, impl.addHost(hostEntity)); + + } + + @Test + public void testaddHostSelective() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + HostDaoImpl impl = new HostDaoImpl(); + HostEntity hostEntity =new HostEntity(); + hostEntity.setId("1"); + assertEquals(0, impl.addHostSelective(hostEntity)); + + } + + @Test + public void testupdateHostSelective() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + HostDaoImpl impl = new HostDaoImpl(); + HostEntity hostEntity =new HostEntity(); + hostEntity.setId("1"); + assertEquals(0, impl.updateHostSelective(hostEntity)); + + } + + @Test + public void testupdateHost() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + HostDaoImpl impl = new HostDaoImpl(); + HostEntity hostEntity =new HostEntity(); + hostEntity.setId("1"); + assertEquals(0, impl.updateHost(hostEntity)); + + } + + @Test + public void testupdateHostByVimId() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + HostDaoImpl impl = new HostDaoImpl(); + HostEntity hostEntity =new HostEntity(); + hostEntity.setId("1"); + assertEquals(0, impl.updateHostByVimId(hostEntity)); + + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImplTest.java new file mode 100644 index 0000000..fa56c24 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImplTest.java @@ -0,0 +1,85 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.LocationEntity; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.openo.nfvo.resmanagement.service.mapper.LocationMapper; + +import mockit.Mock; +import mockit.MockUp; + +public class LocationDaoImplTest { + LocationMapper mapper; + @Test + public void testaddHost() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + LocationDaoImpl impl = new LocationDaoImpl(); + LocationEntity locationEntity =new LocationEntity(); + locationEntity.setId("locationEntity"); + + + } + + @Test + public void testaddLocationSelective() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + LocationDaoImpl impl = new LocationDaoImpl(); + LocationEntity locationEntity =new LocationEntity(); + locationEntity.setId("1"); + + + } + + @Test + public void testupdateNetwork() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + NetworkDaoImpl impl = new NetworkDaoImpl(); + NetworkEntity networkEntity =new NetworkEntity(); + networkEntity.setId("1"); + + } + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImplTest.java new file mode 100644 index 0000000..d0fd3fe --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImplTest.java @@ -0,0 +1,152 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import static org.junit.Assert.*; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper; +import mockit.Expectations; +import mockit.Mock; +import mockit.MockUp; +import mockit.Mocked; + +public class NetworkDaoImplTest { + @Mocked + NetworkMapper mapper; + @Test + public void testdeleteNetwork() throws ServiceException { + + new Expectations() {{ + mapper.deleteNetwork("123"); + }}; + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + NetworkDaoImpl impl = new NetworkDaoImpl(); + assertEquals(0, impl.deleteNetwork("123")); + + } + @Test + public void testdeleteNetworkByVimId() throws ServiceException { + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + NetworkDaoImpl impl = new NetworkDaoImpl(); + assertEquals(0, impl.deleteNetworkByVimId("123")); + + } + @Test + public void testaddNetwork() throws ServiceException { + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + NetworkDaoImpl impl = new NetworkDaoImpl(); + NetworkEntity networkEntity =new NetworkEntity(); + networkEntity.setId("1"); + assertEquals(0, impl.addNetwork(networkEntity)); + + } + + @Test + public void testaddNetworkSelective() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + NetworkDaoImpl impl = new NetworkDaoImpl(); + NetworkEntity networkEntity =new NetworkEntity(); + networkEntity.setId("1"); + assertEquals(0, impl.addNetworkSelective(networkEntity)); + } + @Test + public void testupdateNetworkSelective() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + NetworkDaoImpl impl = new NetworkDaoImpl(); + NetworkEntity networkEntity =new NetworkEntity(); + networkEntity.setId("1"); + assertEquals(0, impl.updateNetworkSelective(networkEntity)); + } + @Test + public void testupdateNetwork() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + NetworkDaoImpl impl = new NetworkDaoImpl(); + NetworkEntity networkEntity =new NetworkEntity(); + networkEntity.setId("1"); + assertEquals(0, impl.updateNetwork(networkEntity)); + + } + @Test + public void testupdateNetworkByVimId() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + NetworkDaoImpl impl = new NetworkDaoImpl(); + NetworkEntity networkEntity =new NetworkEntity(); + networkEntity.setId("1"); + assertEquals(0, impl.updateNetworkByVimId(networkEntity)); + + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImplTest.java new file mode 100644 index 0000000..4edcdf3 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImplTest.java @@ -0,0 +1,158 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.HostEntity; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.openo.nfvo.resmanagement.service.entity.PortEntity; +import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper; +import org.openo.nfvo.resmanagement.service.mapper.PortMapper; + +import mockit.Expectations; +import mockit.Mock; +import mockit.MockUp; +import mockit.Mocked; + +public class PortDaoImplTest { + @Mocked + PortMapper mapper; + + + @Test + public void testdeletePort() throws ServiceException { + + new Expectations() {{ + mapper.deletePort("123"); + }}; + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + PortDaoImpl impl = new PortDaoImpl(); + assertEquals(0, impl.deletePort("123")); + + + } + @Test + public void testdeletePortByVimId() throws ServiceException { + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + PortDaoImpl impl = new PortDaoImpl(); + assertEquals(0, impl.deletePortByVimId("123")); + + } + + @Test + public void testaddPort() throws ServiceException { + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + PortDaoImpl impl = new PortDaoImpl(); + PortEntity portEntity =new PortEntity(); + portEntity.setId("1"); + assertEquals(0, impl.addPort(portEntity)); + + } + + @Test + public void testaddPortSelective() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + PortDaoImpl impl = new PortDaoImpl(); + PortEntity portEntity =new PortEntity(); + portEntity.setId("1"); + assertEquals(0, impl.addPortSelective(portEntity)); + + } + + @Test + public void testupdatePortSelective() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + PortDaoImpl impl = new PortDaoImpl(); + PortEntity portEntity =new PortEntity(); + portEntity.setId("1"); + assertEquals(0, impl.updatePortSelective(portEntity)); + } + @Test + public void testupdatePort() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + PortDaoImpl impl = new PortDaoImpl(); + PortEntity portEntity =new PortEntity(); + portEntity.setId("1"); + assertEquals(0, impl.updatePort(portEntity)); + + } + @Test + public void testupdatePortByVimId() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + PortDaoImpl impl = new PortDaoImpl(); + PortEntity portEntity =new PortEntity(); + portEntity.setId("1"); + assertEquals(0, impl.updatePortByVimId(portEntity)); + + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImplTest.java new file mode 100644 index 0000000..4deb71e --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImplTest.java @@ -0,0 +1,132 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; +import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper; +import org.openo.nfvo.resmanagement.service.mapper.SitesMapper; + +import mockit.Expectations; +import mockit.Mock; +import mockit.MockUp; +import mockit.Mocked; + +public class SitesDaoImplTest { + @Mocked + SitesMapper mapper; + @Test + public void testdeleteSite() throws ServiceException { + + new Expectations() {{ + mapper.deleteSite("123"); + }}; + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + SitesDaoImpl impl = new SitesDaoImpl(); + assertEquals(0, impl.deleteSite("123")); + } + @Test + public void testaddSite() throws ServiceException { + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + SitesDaoImpl impl = new SitesDaoImpl(); + SitesEntity sitesEntity =new SitesEntity(); + sitesEntity.setId("1"); + assertEquals(0, impl.addSite(sitesEntity)); + } + @Test + public void testaddSiteSelective() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + SitesDaoImpl impl = new SitesDaoImpl(); + SitesEntity sitesEntity =new SitesEntity(); + sitesEntity.setId("1"); + assertEquals(0, impl.addSiteSelective(sitesEntity)); + } + @Test + public void testupdateSiteSelective() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + SitesDaoImpl impl = new SitesDaoImpl(); + SitesEntity sitesEntity =new SitesEntity(); + sitesEntity.setId("1"); + assertEquals(0, impl.updateSiteSelective(sitesEntity)); + } + @Test + public void testupdateNetwork() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + SitesDaoImpl impl = new SitesDaoImpl(); + SitesEntity sitesEntity =new SitesEntity(); + sitesEntity.setId("1"); + assertEquals(0, impl.updateSite(sitesEntity)); + } + @Test + public void testupdateSiteByVimId() throws ServiceException { + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + SitesDaoImpl impl = new SitesDaoImpl(); + SitesEntity sitesEntity =new SitesEntity(); + sitesEntity.setId("1"); + assertEquals(0, impl.updateSiteByVimId(sitesEntity)); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImplTest.java new file mode 100644 index 0000000..736a844 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImplTest.java @@ -0,0 +1,77 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.openo.nfvo.resmanagement.service.entity.VimEntity; +import org.openo.nfvo.resmanagement.service.mapper.VimMapper; + +import mockit.Expectations; +import mockit.Mock; +import mockit.MockUp; +import mockit.Mocked; + +public class VimDaoImplTest { + + @Mocked + VimMapper mapper; + + + @Test + public void testdeleteVim() throws ServiceException { + + new Expectations() {{ + mapper.deleteVim("123"); + }}; + + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + VimDaoImpl impl = new VimDaoImpl(); + assertEquals(0, impl.deleteVim("123")); + + + } + + @Test + public void testaddVim() throws ServiceException { + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + VimDaoImpl impl = new VimDaoImpl(); + VimEntity vimEntity =new VimEntity(); + vimEntity.setId("1"); + assertEquals(0, impl.addVim(vimEntity)); + + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImplTest.java new file mode 100644 index 0000000..c3a3b98 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImplTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.NetworkEntity; +import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity; +import org.openo.nfvo.resmanagement.service.mapper.SitesMapper; +import org.openo.nfvo.resmanagement.service.mapper.VirtualLinkMapper; + +import mockit.Mock; +import mockit.MockUp; +import mockit.Mocked; + +public class VirtualLinkDaoImplTest { + @Mocked + VirtualLinkMapper mapper; + @Test + public void testdeleteVlById() throws ServiceException { + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + VirtualLinkDaoImpl impl = new VirtualLinkDaoImpl(); + + assertEquals(0, impl.deleteVlById("1")); + + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImplTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImplTest.java new file mode 100644 index 0000000..afb9917 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImplTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.dao.impl; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.service.entity.VmEntity; +import org.openo.nfvo.resmanagement.service.mapper.SitesMapper; +import org.openo.nfvo.resmanagement.service.mapper.VmMapper; + +import mockit.Mock; +import mockit.MockUp; +import mockit.Mocked; + +public class VmDaoImplTest { + @Mocked + VmMapper mapper; + @Test + public void TestaddVm() throws ServiceException { + new MockUp<AbstractDao>() { + + @Mock + public <T> T getMapperManager(Class<T> type) { + return (T) mapper; + + } + }; + VmDaoImpl impl = new VmDaoImpl(); + VmEntity vmEntity =new VmEntity(); + vmEntity.setVmId("1"); + //assertEquals(0, impl.addVm(vmEntity)); + + } + + +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/HostEntityTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/HostEntityTest.java new file mode 100644 index 0000000..119d4f2 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/HostEntityTest.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +import net.sf.json.JSONObject; + +public class HostEntityTest { + private HostEntity hostEntity; + + @Before + public void setUp() { + hostEntity = new HostEntity(); + } + + @Test + public void testHostEntity() { + assertTrue(hostEntity.toString() != null); + assertTrue(HostEntity.toEntity(new JSONObject()) != null); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/LocationEntityTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/LocationEntityTest.java new file mode 100644 index 0000000..7998905 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/LocationEntityTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +import net.sf.json.JSONObject; + +public class LocationEntityTest { + + private LocationEntity locationEntity; + + @Before + public void setUp() { + locationEntity = new LocationEntity(); + } + + @Test + public void testLocationEntity() { + locationEntity.setCountry("country"); + locationEntity.setDescription("description"); + locationEntity.setLocation("location"); + locationEntity.setLatitude("latitude"); + locationEntity.setLongitude("longitude"); + assertTrue(locationEntity.toString() != null); + assertTrue(LocationEntity.toEntity(new JSONObject()) != null); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntityTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntityTest.java new file mode 100644 index 0000000..35f1fdc --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntityTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +import net.sf.json.JSONObject; + +public class NetworkEntityTest { + + private NetworkEntity networkEntity; + + @Before + public void setUp() { + networkEntity = new NetworkEntity(); + } + + @Test + public void testSetId() { + networkEntity.setId("123"); + networkEntity.setName("name"); + networkEntity.setNetworkType("networkType"); + networkEntity.setPhysicalNetwork("physicalNetwork"); + networkEntity.setSegmentationId("segmentationId"); + networkEntity.setStatus("networkStatus"); + networkEntity.setTenantId("tenantId"); + networkEntity.setVimId("networkVimId"); + networkEntity.setVimName("networkVimName"); + assertTrue(networkEntity.toString() != null); + assertTrue(NetworkEntity.toEntity(new JSONObject()) != null); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/PortEntityTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/PortEntityTest.java new file mode 100644 index 0000000..70fa7ad --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/PortEntityTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +import net.sf.json.JSONObject; + +public class PortEntityTest { + + private PortEntity portEntity; + + @Before + public void setUp() { + portEntity = new PortEntity(); + } + + @Test + public void testPortEntiry() { + portEntity.setId("id:"); + portEntity.setName("name"); + portEntity.setNetworkId("networkId"); + portEntity.setTenantId("tenantId"); + portEntity.setVimId("vimID"); + portEntity.setVimName("vimName"); + assertTrue(portEntity.toString() != null); + assertTrue(PortEntity.toEntity(new JSONObject()) != null); + + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/SitesEntityTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/SitesEntityTest.java new file mode 100644 index 0000000..44d4dce --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/SitesEntityTest.java @@ -0,0 +1,110 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +import net.sf.json.JSONObject; + +public class SitesEntityTest { + + private SitesEntity sitesEntity; + + @Before + public void setUp() { + sitesEntity = new SitesEntity(); + } + + @Test + public void testSitesEntity() { + sitesEntity.setCountry("country"); + sitesEntity.setId("id"); + sitesEntity.setLocation("location"); + sitesEntity.setName("name"); + sitesEntity.setStatus("siteStatus"); + sitesEntity.setTotalCPU("12"); + sitesEntity.setTotalDisk("12"); + sitesEntity.setTotalMemory("134"); + sitesEntity.setUsedCPU("12"); + sitesEntity.setUsedDisk("23"); + sitesEntity.setUsedMemory("10"); + sitesEntity.setVimId("siteVimId"); + sitesEntity.setVimName("siteVimName"); + assertTrue(sitesEntity.toString() != null); + assertTrue(SitesEntity.toEntity(new JSONObject()) != null); + SitesEntity.checkResource(sitesEntity); + SitesEntity.checkResourceIsZero(sitesEntity); + } + + @Test + public void testSitesEntityBranch() { + sitesEntity.setCountry("country"); + sitesEntity.setId("id"); + sitesEntity.setLocation("location"); + sitesEntity.setName("name"); + sitesEntity.setStatus("siteStatus"); + sitesEntity.setTotalCPU(""); + sitesEntity.setTotalDisk(""); + sitesEntity.setTotalMemory(""); + sitesEntity.setUsedCPU(""); + sitesEntity.setUsedDisk(""); + sitesEntity.setUsedMemory(""); + sitesEntity.setVimId("siteVimId"); + sitesEntity.setVimName("siteVimName"); + SitesEntity.checkResource(sitesEntity); + SitesEntity.checkResourceIsZero(sitesEntity); + } + + @Test + public void testSitesEntityBranch1() { + sitesEntity.setCountry("country"); + sitesEntity.setId("id"); + sitesEntity.setLocation("location"); + sitesEntity.setName("name"); + sitesEntity.setStatus("siteStatus"); + sitesEntity.setTotalCPU("s"); + sitesEntity.setTotalDisk(""); + sitesEntity.setTotalMemory("s"); + sitesEntity.setUsedCPU("s"); + sitesEntity.setUsedDisk("s"); + sitesEntity.setUsedMemory("s"); + sitesEntity.setVimId("siteVimId"); + sitesEntity.setVimName("siteVimName"); + SitesEntity.checkResource(sitesEntity); + } + + @Test + public void testSitesEntityBranch2() { + sitesEntity.setCountry("country"); + sitesEntity.setId("id"); + sitesEntity.setLocation("location"); + sitesEntity.setName("name"); + sitesEntity.setStatus("siteStatus"); + sitesEntity.setTotalCPU("23"); + sitesEntity.setTotalDisk(""); + sitesEntity.setTotalMemory("s"); + sitesEntity.setUsedCPU("1"); + sitesEntity.setUsedDisk("s"); + sitesEntity.setUsedMemory("s"); + sitesEntity.setVimId("siteVimId"); + sitesEntity.setVimName("siteVimName"); + SitesEntity.checkResource(sitesEntity); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/VimEntityTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/VimEntityTest.java new file mode 100644 index 0000000..a21642d --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/entity/VimEntityTest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2016 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.entity; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +import net.sf.json.JSONObject; + +public class VimEntityTest { + + private VimEntity vimEntity; + + @Before + public void setUp() { + vimEntity = new VimEntity(); + } + + @Test + public void testSitesEntity() { + vimEntity.setId("id"); + vimEntity.setName("name"); + assertTrue(vimEntity.toString() != null); + assertTrue(VimEntity.toEntity(new JSONObject()) != null); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoaTest.java new file mode 100644 index 0000000..1629f8e --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoaTest.java @@ -0,0 +1,166 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.group.impl.GrantResServiceImpl;
+import org.openo.nfvo.resmanagement.service.group.inf.GrantResService;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 16, 2017
+ */
+public class GrantResourseRoaTest {
+
+ private GrantResourseRoa roa;
+
+ private GrantResService grantResService;
+
+ @Before
+ public void setUp() {
+ roa = new GrantResourseRoa();
+ grantResService = new GrantResServiceImpl();
+ roa.setGrantResService(grantResService);
+ }
+
+ @Test
+ public void testGrantResource() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<GrantResServiceImpl>() {
+
+ @Mock
+ public JSONObject grantResource(JSONObject object) throws ServiceException {
+ return new JSONObject();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.grantResource(mock);
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testGrantResourceByNull() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return null;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.grantResource(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGrantResourceFail() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<GrantResServiceImpl>() {
+
+ @Mock
+ public JSONObject grantResource(JSONObject object) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.grantResource(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGrantResourceReal() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<GrantResServiceImpl>() {
+
+ @Mock
+ public JSONObject grantResourceReal(JSONObject object) throws ServiceException {
+ return new JSONObject();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.grantResourceReal(mock);
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testGrantResourceRealByNull() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return null;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.grantResourceReal(mock);
+ }
+
+ @Test
+ public void testGrantResourceRealFail() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<GrantResServiceImpl>() {
+
+ @Mock
+ public JSONObject grantResourceReal(JSONObject object) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.grantResourceReal(mock);
+ assertNotNull(result);
+ }
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/HostRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/HostRoaTest.java new file mode 100644 index 0000000..bc0b8b7 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/HostRoaTest.java @@ -0,0 +1,200 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.impl.HostImpl;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host;
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class HostRoaTest {
+
+ private HostRoa roa;
+
+ private Host host;
+
+ @Before
+ public void setUp() {
+ roa = new HostRoa();
+ host = new HostImpl();
+ roa.setHost(host);
+ }
+
+ @Test
+ public void testGetHosts() throws ServiceException {
+ new MockUp<HostImpl>() {
+
+ @Mock
+ public List<HostEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<HostEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getHosts(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetHost() throws ServiceException {
+ new MockUp<HostImpl>() {
+
+ @Mock
+ public List<HostEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<HostEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getHost(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddHost() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<HostImpl>() {
+
+ @Mock
+ public int add(JSONObject jsonObject) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addHost(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddHostByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<HostImpl>() {
+
+ @Mock
+ public int add(JSONObject jsonObject) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addHost(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteHost() throws ServiceException {
+ new MockUp<HostImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteHost(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteHostByException() throws ServiceException {
+ new MockUp<HostImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteHost(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdateHost() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<HostImpl>() {
+
+ @Mock
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updateHost(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdateHostByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<HostImpl>() {
+
+ @Mock
+ public int update(JSONObject jsonObject) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updateHost(mock);
+ assertNotNull(result);
+ }
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoaTest.java new file mode 100644 index 0000000..3c028dc --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoaTest.java @@ -0,0 +1,68 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.business.impl.LimitsBusinessImpl;
+import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class LimitsRoaTest {
+
+ private LimitsRoa roa;
+
+ private LimitsBusiness limitsBusiness;
+
+ @Before
+ public void setUp() {
+ roa = new LimitsRoa();
+ limitsBusiness = new LimitsBusinessImpl();
+ roa.setLimitsBusiness(limitsBusiness);
+ }
+
+ @Test
+ public void testGetLimitsResource() throws ServiceException {
+ new MockUp<LimitsBusinessImpl>() {
+
+ @Mock
+ public JSONObject getLimits(String vimId) throws ServiceException {
+ return new JSONObject();
+ }
+ };
+ HttpServletRequest context = new MockHttpServletRequest();
+ JSONObject result = roa.getLimits(context, "vimId");
+ assertNotNull(result);
+ }
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/LocationRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/LocationRoaTest.java new file mode 100644 index 0000000..2a3c062 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/LocationRoaTest.java @@ -0,0 +1,389 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.impl.LocationImpl;
+import org.openo.nfvo.resmanagement.service.base.openstack.impl.SitesImpl;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Location;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites;
+import org.openo.nfvo.resmanagement.service.entity.LocationEntity;
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class LocationRoaTest {
+
+ private LocationRoa roa;
+
+ private Location location;
+
+ private Sites sites;
+
+ @Before
+ public void setUp() {
+ roa = new LocationRoa();
+ location = new LocationImpl();
+ sites = new SitesImpl();
+ roa.setLocation(location);
+ roa.setSites(sites);
+ }
+
+ @Test
+ public void testGetLocationsbase() throws ServiceException {
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public List<LocationEntity> get(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<LocationEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getLocationsbase(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetLocationbase() throws ServiceException {
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public List<LocationEntity> get(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<LocationEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getLocationbase(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetCountry() throws ServiceException {
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public List<String> getCountry() throws ServiceException {
+ return new ArrayList<String>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getCountry(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetLocationByCountry() throws ServiceException {
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public List<String> getLocationByCountry(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<String>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getLocationByCountry(mock, "country");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetLocation() throws ServiceException {
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public List<LocationEntity> get(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<LocationEntity>();
+ }
+
+ @Mock
+ public List<JSONObject> getLocationInfo(List<LocationEntity> locationInfo) throws ServiceException {
+ return new ArrayList<JSONObject>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getLocation(mock, "locations");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddLocation() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public int add(JSONObject jsonObject) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addLocation(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddLocationByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public int add(JSONObject jsonObject) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addLocation(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteLocationbase() throws ServiceException {
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public int delete(String location) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteLocationbase(mock, "locations");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteLocationbaseByException() throws ServiceException {
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public int delete(String location) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteLocationbase(mock, "locations");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteLocation() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ JSONObject object = new JSONObject();
+ object.put("location", "location");
+ object.put("id", "id");
+ return object;
+ }
+ };
+ new MockUp<SitesImpl>() {
+
+ @Mock
+ public SitesEntity get(Map<String, Object> condition) throws ServiceException {
+ return null;
+ }
+ };
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public int delete(String location) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteLocation(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteLocationByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ JSONObject object = new JSONObject();
+ object.put("location", "location");
+ object.put("id", "id");
+ return object;
+ }
+ };
+ new MockUp<SitesImpl>() {
+
+ @Mock
+ public SitesEntity get(Map<String, Object> condition) throws ServiceException {
+ return null;
+ }
+ };
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public int delete(String location) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteLocation(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteLocationBySitesEntity() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ JSONObject object = new JSONObject();
+ object.put("location", "location");
+ object.put("id", "id");
+ return object;
+ }
+ };
+ new MockUp<SitesImpl>() {
+
+ @Mock
+ public SitesEntity get(Map<String, Object> condition) throws ServiceException {
+ return new SitesEntity();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteLocation(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdateLocation() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ JSONObject object = new JSONObject();
+ object.put("location", "location");
+ return object;
+ }
+ };
+ new MockUp<SitesImpl>() {
+
+ @Mock
+ public SitesEntity get(Map<String, Object> condition) throws ServiceException {
+ return null;
+ }
+ };
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updateLocation(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdateLocationByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ JSONObject object = new JSONObject();
+ object.put("location", "location");
+ return object;
+ }
+ };
+ new MockUp<SitesImpl>() {
+
+ @Mock
+ public SitesEntity get(Map<String, Object> condition) throws ServiceException {
+ return null;
+ }
+ };
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public int update(JSONObject jsonObject) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updateLocation(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdateLocationBySitesEntity() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ JSONObject object = new JSONObject();
+ object.put("location", "location");
+ return object;
+ }
+ };
+ new MockUp<SitesImpl>() {
+
+ @Mock
+ public SitesEntity get(Map<String, Object> condition) throws ServiceException {
+ return new SitesEntity();
+ }
+ };
+ new MockUp<LocationImpl>() {
+
+ @Mock
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updateLocation(mock);
+ assertNotNull(result);
+ }
+
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoaTest.java new file mode 100644 index 0000000..b838e27 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoaTest.java @@ -0,0 +1,214 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.impl.NetworkImpl;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network;
+import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class NetworkRoaTest {
+
+ private NetworkRoa roa;
+
+ private Network network;
+
+ @Before
+ public void setUp() {
+ roa = new NetworkRoa();
+ network = new NetworkImpl();
+ roa.setNetwork(network);
+ }
+
+ @Test
+ public void testGetNetworks() throws ServiceException {
+ new MockUp<NetworkImpl>() {
+
+ @Mock
+ public List<NetworkEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<NetworkEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getNetworks(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetNetwork() throws ServiceException {
+ new MockUp<NetworkImpl>() {
+
+ @Mock
+ public List<NetworkEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<NetworkEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getNetwork(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddNetwork() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<NetworkEntity>() {
+
+ @Mock
+ public NetworkEntity toEntity(JSONObject jsonObject) {
+ return new NetworkEntity();
+ }
+ };
+ new MockUp<NetworkImpl>() {
+
+ @Mock
+ public int add(NetworkEntity entity) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addNetwork(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddNetworkByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<NetworkEntity>() {
+
+ @Mock
+ public NetworkEntity toEntity(JSONObject jsonObject) {
+ return new NetworkEntity();
+ }
+ };
+ new MockUp<NetworkImpl>() {
+
+ @Mock
+ public int add(NetworkEntity entity) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addNetwork(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteNetwork() throws ServiceException {
+ new MockUp<NetworkImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteNetwork(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteNetworkByException() throws ServiceException {
+ new MockUp<NetworkImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteNetwork(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdateNetwork() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<NetworkImpl>() {
+
+ @Mock
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updateNetwork(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdateNetworkByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<NetworkImpl>() {
+
+ @Mock
+ public int update(JSONObject jsonObject) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updateNetwork(mock);
+ assertNotNull(result);
+ }
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/PortRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/PortRoaTest.java new file mode 100644 index 0000000..9e4d127 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/PortRoaTest.java @@ -0,0 +1,214 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.impl.PortImpl;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port;
+import org.openo.nfvo.resmanagement.service.entity.PortEntity;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class PortRoaTest {
+
+ private PortRoa roa;
+
+ private Port port;
+
+ @Before
+ public void setUp() {
+ roa = new PortRoa();
+ port = new PortImpl();
+ roa.setPort(port);
+ }
+
+ @Test
+ public void testGetPorts() throws ServiceException {
+ new MockUp<PortImpl>() {
+
+ @Mock
+ public List<PortEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<PortEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getPorts(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetPort() throws ServiceException {
+ new MockUp<PortImpl>() {
+
+ @Mock
+ public List<PortEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return new ArrayList<PortEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getPort(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddPort() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<PortEntity>() {
+
+ @Mock
+ public PortEntity toEntity(JSONObject jsonObject) {
+ return new PortEntity();
+ }
+ };
+ new MockUp<PortImpl>() {
+
+ @Mock
+ public int add(PortEntity portEntity) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addPort(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddPortByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<PortEntity>() {
+
+ @Mock
+ public PortEntity toEntity(JSONObject jsonObject) {
+ return new PortEntity();
+ }
+ };
+ new MockUp<PortImpl>() {
+
+ @Mock
+ public int add(PortEntity portEntity) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addPort(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeletePort() throws ServiceException {
+ new MockUp<PortImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deletePort(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeletePortByException() throws ServiceException {
+ new MockUp<PortImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deletePort(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdatePort() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<PortImpl>() {
+
+ @Mock
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updatePort(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdatePortByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<PortImpl>() {
+
+ @Mock
+ public int update(JSONObject jsonObject) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updatePort(mock);
+ assertNotNull(result);
+ }
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoaTest.java new file mode 100644 index 0000000..eddd61d --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoaTest.java @@ -0,0 +1,197 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.VimUtil;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.group.impl.ResOperateServiceImpl;
+import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Mar 16, 2017
+ */
+public class ResOperateRoaTest {
+
+ private ResOperateRoa roa;
+
+ private ResOperateService resOperateService;
+
+ @Before
+ public void setUp() {
+ roa = new ResOperateRoa();
+ resOperateService = new ResOperateServiceImpl();
+ roa.setResOperateService(resOperateService);
+ }
+
+ @Test
+ public void testUpdateIResPool() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VimUtil>() {
+
+ @Mock
+ public JSONObject getVimById(String vimId) {
+ JSONObject vimInfo = new JSONObject();
+ vimInfo.put("tenant", "tenant");
+ return vimInfo;
+ }
+
+ @Mock
+ public String getTenantIdByName(String tenant, String vimId) {
+ return "";
+ }
+ };
+ new MockUp<ResOperateServiceImpl>() {
+
+ @Mock
+ public void updateIRes(String tenantId, String vimId, JSONObject header) throws ServiceException {
+ }
+
+ @Mock
+ public void sendMsgMonitor(String operateType, String vimId) throws ServiceException {
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updateIResPool(mock, "vimId");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testUpdateIResPoolFail() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VimUtil>() {
+
+ @Mock
+ public JSONObject getVimById(String vimId) {
+ JSONObject vimInfo = new JSONObject();
+ vimInfo.put("tenant", "tenant");
+ return vimInfo;
+ }
+
+ @Mock
+ public String getTenantIdByName(String tenant, String vimId) {
+ return "";
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.updateIResPool(mock, null);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddAllResPool() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<ResOperateServiceImpl>() {
+
+ @Mock
+ public void addIRes(String tenantId, String vimId, JSONObject header) throws ServiceException {
+ }
+
+ @Mock
+ public void sendMsgMonitor(String operateType, String vimId) throws ServiceException {
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addAllResPool(mock, "tenantId", "vimId");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddAllResPoolFail() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addAllResPool(mock, null, null);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteIRes() throws ServiceException {
+ new MockUp<ResOperateServiceImpl>() {
+
+ @Mock
+ public int deleteIRes(String vimId) throws ServiceException {
+ return 1;
+ }
+
+ @Mock
+ public void sendMsgMonitor(String operateType, String vimId) throws ServiceException {
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteIRes(mock, "vimId");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteIResFail() throws ServiceException {
+ new MockUp<ResOperateServiceImpl>() {
+
+ @Mock
+ public int deleteIRes(String vimId) throws ServiceException {
+ throw new ServiceException();
+ }
+
+ @Mock
+ public void sendMsgMonitor(String operateType, String vimId) throws ServiceException {
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteIRes(mock, null);
+ assertNotNull(result);
+ }
+
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/SitesRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/SitesRoaTest.java new file mode 100644 index 0000000..ad21b19 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/SitesRoaTest.java @@ -0,0 +1,279 @@ +/* + * Copyright 2016-2017 Huawei Technologies Co., Ltd. + * + * 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.openo.nfvo.resmanagement.service.rest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.junit.Before; +import org.junit.Test; +import org.openo.baseservice.remoteservice.exception.ServiceException; +import org.openo.nfvo.resmanagement.common.VimUtil; +import org.openo.nfvo.resmanagement.common.util.request.RequestUtil; +import org.openo.nfvo.resmanagement.service.base.openstack.impl.SitesImpl; +import org.openo.nfvo.resmanagement.service.entity.SitesEntity; +import org.springframework.mock.web.MockHttpServletRequest; + +import mockit.Mock; +import mockit.MockUp; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +/** + * <br/> + * <p> + * </p> + * + * @author + * @version NFVO 0.5 2016年8月16日 + */ +public class SitesRoaTest { + + private SitesRoa sitesRoa; + + @Before + public void setUp() { + sitesRoa = new SitesRoa(); + sitesRoa.setSites(new SitesImpl()); + } + + @Test + public void testGetSites() throws ServiceException { + new MockUp<SitesImpl>() { + + @Mock + public List<SitesEntity> getList(Map<String, Object> condition) throws ServiceException { + return new ArrayList<SitesEntity>(); + } + }; + HttpServletRequest mock = new MockHttpServletRequest(); + JSONObject result = sitesRoa.getSites(mock); + assertNotNull(result); + } + + @Test + public void testGetSite() throws ServiceException { + new MockUp<SitesImpl>() { + + @Mock + public List<SitesEntity> getList(Map<String, Object> condition) throws ServiceException { + return new ArrayList<SitesEntity>(); + } + }; + HttpServletRequest mock = new MockHttpServletRequest(); + JSONObject result = sitesRoa.getSite(mock, "id"); + assertNotNull(result); + } + + @Test + public void testAddSites() throws ServiceException { + new MockUp<RequestUtil>() { + + @Mock + public JSONObject getAllJsonRequestBody(HttpServletRequest context) { + return new JSONObject(); + } + }; + new MockUp<SitesImpl>() { + + @Mock + public int add(JSONObject jsonObject) throws ServiceException { + return 1; + } + + @Mock + public void sendToMonitor(JSONObject jsonObject) throws ServiceException { + + } + }; + HttpServletRequest mock = new MockHttpServletRequest(); + JSONObject result = sitesRoa.addSites(mock); + assertNotNull(result); + } + + @Test + public void testAddSitesExceptions() throws ServiceException { + new MockUp<RequestUtil>() { + + @Mock + public JSONObject getAllJsonRequestBody(HttpServletRequest context) { + return new JSONObject(); + } + }; + new MockUp<SitesImpl>() { + + @Mock + public int add(JSONObject jsonObject) throws ServiceException { + throw new ServiceException(); + } + }; + JSONObject result = sitesRoa.addSites(null); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("msg", ""); + assertEquals(expectedResult.toString(), result.toString()); + } + + @Test + public void testDeleteSites() throws ServiceException { + new MockUp<SitesImpl>() { + + @Mock + public int delete(String id) throws ServiceException { + return 1; + } + }; + JSONObject result = sitesRoa.deleteSites(null, "123"); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("msg", "org.openo.nfvo.resmanage.common.del.success"); + assertEquals(expectedResult.toString(), result.toString()); + } + + @Test + public void testDeleteSitesExceptions() throws ServiceException { + new MockUp<SitesImpl>() { + + @Mock + public int delete(String id) throws ServiceException { + throw new ServiceException(); + } + }; + JSONObject result = sitesRoa.deleteSites(null, "123"); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("msg", ""); + assertEquals(expectedResult.toString(), result.toString()); + } + + @Test + public void testUpdateSites() throws ServiceException { + new MockUp<RequestUtil>() { + + @Mock + public JSONObject getAllJsonRequestBody(HttpServletRequest context) { + return new JSONObject(); + } + }; + new MockUp<SitesImpl>() { + + @Mock + public int update(SitesEntity sitesEntity) throws ServiceException { + return 1; + } + }; + JSONObject result = sitesRoa.updateSites(null); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("msg", "org.openo.nfvo.resmanage.common.update.success"); + assertEquals(expectedResult.toString(), result.toString()); + } + + @Test + public void testUpdateISitesExceptions() throws ServiceException { + new MockUp<RequestUtil>() { + + @Mock + public JSONObject getAllJsonRequestBody(HttpServletRequest context) { + return new JSONObject(); + } + }; + new MockUp<SitesImpl>() { + + @Mock + public int update(SitesEntity sitesEntity) throws ServiceException { + throw new ServiceException(); + } + }; + JSONObject result = sitesRoa.updateSites(null); + JSONObject expectedResult = new JSONObject(); + expectedResult.put("msg", ""); + assertEquals(expectedResult.toString(), result.toString()); + } + + @Test + public void testGrantResource() throws ServiceException { + new MockUp<RequestUtil>() { + + @Mock + public JSONObject getAllJsonRequestBody(HttpServletRequest context) { + return new JSONObject(); + } + }; + new MockUp<SitesImpl>() { + + @Mock + public int update(JSONObject jsonObject) throws ServiceException { + return 1; + } + }; + HttpServletRequest mock = new MockHttpServletRequest(); + JSONObject result = sitesRoa.grantResource(mock); + assertNotNull(result); + } + + @Test + public void testGrantResourceByException() throws ServiceException { + new MockUp<RequestUtil>() { + + @Mock + public JSONObject getAllJsonRequestBody(HttpServletRequest context) { + return new JSONObject(); + } + }; + new MockUp<SitesImpl>() { + + @Mock + public int update(JSONObject jsonObject) throws ServiceException { + throw new ServiceException(); + } + }; + HttpServletRequest mock = new MockHttpServletRequest(); + JSONObject result = sitesRoa.grantResource(mock); + assertNotNull(result); + } + + @Test + public void testGetVims() throws ServiceException { + new MockUp<VimUtil>() { + + @Mock + public JSONArray getVims() { + return new JSONArray(); + } + }; + HttpServletRequest mock = new MockHttpServletRequest(); + String result = sitesRoa.getVims(mock); + assertNotNull(result); + } + + @Test + public void testGetVim() throws ServiceException { + new MockUp<VimUtil>() { + + @Mock + public JSONObject getVimById(String vimId) { + return new JSONObject(); + } + }; + HttpServletRequest mock = new MockHttpServletRequest(); + String result = sitesRoa.getVim(mock, "id"); + assertNotNull(result); + } +} diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoaTest.java new file mode 100644 index 0000000..7cd0b97 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoaTest.java @@ -0,0 +1,56 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+
+import mockit.Mock;
+import mockit.MockUp;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class SwaggerRoaTest {
+
+ private SwaggerRoa roa;
+
+ @Test
+ public void testApidoc() throws IOException {
+ new MockUp<IOUtils>() {
+
+ @Mock
+ public String toString(InputStream input) {
+ return "";
+ }
+ };
+ roa = new SwaggerRoa();
+ String result = roa.apidoc();
+ assertNotNull(result);
+ }
+
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoaTest.java new file mode 100644 index 0000000..f8054ae --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoaTest.java @@ -0,0 +1,192 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity;
+import org.openo.nfvo.resmanagement.service.group.impl.VirtualLinkServiceImpl;
+import org.openo.nfvo.resmanagement.service.group.inf.VirtualLinkService;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class VirtualLinkRoaTest {
+
+ private VirtualLinkRoa roa;
+
+ private VirtualLinkService virtualLink;
+
+ @Before
+ public void setUp() {
+ roa = new VirtualLinkRoa();
+ virtualLink = new VirtualLinkServiceImpl();
+ roa.setVirtualLink(virtualLink);
+ }
+
+ @Test
+ public void testGetVls() throws ServiceException {
+ new MockUp<VirtualLinkServiceImpl>() {
+
+ @Mock
+ public List<VirtualLinkEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VirtualLinkEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVls(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetVl() throws ServiceException {
+ new MockUp<VirtualLinkServiceImpl>() {
+
+ @Mock
+ public List<VirtualLinkEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VirtualLinkEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVl(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVl() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VirtualLinkEntity>() {
+
+ @Mock
+ public VirtualLinkEntity toEntity(JSONObject jsonObject) {
+ return new VirtualLinkEntity();
+ }
+ };
+ new MockUp<VirtualLinkServiceImpl>() {
+
+ @Mock
+ public JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException {
+ return new JSONObject();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVl(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVlByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VirtualLinkEntity>() {
+
+ @Mock
+ public VirtualLinkEntity toEntity(JSONObject jsonObject) {
+ return new VirtualLinkEntity();
+ }
+ };
+ new MockUp<VirtualLinkServiceImpl>() {
+
+ @Mock
+ public JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVl(mock);
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testAddVlByExceptionByNull() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return null;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.addVl(mock);
+ }
+
+ @Test
+ public void testDeleteVl() throws ServiceException {
+ new MockUp<VirtualLinkServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVl(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteVlByException() throws ServiceException {
+ new MockUp<VirtualLinkServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVl(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testDeleteVlByNull() throws ServiceException {
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.deleteVl(mock, null);
+ }
+
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VmRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VmRoaTest.java new file mode 100644 index 0000000..111a330 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VmRoaTest.java @@ -0,0 +1,193 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.entity.VmEntity;
+import org.openo.nfvo.resmanagement.service.group.impl.VmServiceImpl;
+import org.openo.nfvo.resmanagement.service.group.inf.VmService;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class VmRoaTest {
+
+ private VmRoa roa;
+
+ private VmService vmService;
+
+ @Before
+ public void setUp() {
+ roa = new VmRoa();
+ vmService = new VmServiceImpl();
+ roa.setVmService(vmService);
+ }
+
+ @Test
+ public void testGetVms() throws ServiceException {
+ new MockUp<VmServiceImpl>() {
+
+ @Mock
+ public List<VmEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VmEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVms(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetVm() throws ServiceException {
+ new MockUp<VmServiceImpl>() {
+
+ @Mock
+ public List<VmEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VmEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVm(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVm() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VmEntity>() {
+
+ @Mock
+ public VmEntity toEntity(JSONObject jsonObject) {
+ return new VmEntity();
+ }
+ };
+ new MockUp<VmServiceImpl>() {
+
+ @Mock
+ public JSONObject addVm(VmEntity vmEntity) throws ServiceException {
+ return new JSONObject();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVm(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVmByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VmEntity>() {
+
+ @Mock
+ public VmEntity toEntity(JSONObject jsonObject) {
+ return new VmEntity();
+ }
+ };
+ new MockUp<VmServiceImpl>() {
+
+ @Mock
+ public JSONObject addVm(VmEntity vmEntity) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVm(mock);
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testAddVmByNull() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return null;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.addVm(mock);
+ }
+
+ @Test
+ public void testDeleteVm() throws ServiceException {
+ new MockUp<VmServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVm(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteVmByException() throws ServiceException {
+ new MockUp<VmServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVm(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testDeleteVmByNull() throws ServiceException {
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVm(mock, null);
+ assertNotNull(result);
+ }
+
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoaTest.java new file mode 100644 index 0000000..2128d3a --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoaTest.java @@ -0,0 +1,178 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity;
+import org.openo.nfvo.resmanagement.service.group.impl.VnfInfoServiceImpl;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class VnfInfoRoaTest {
+
+ private VnfInfoRoa roa;
+
+ private VnfInfoService vnfInfoService;
+
+ @Before
+ public void setUp() {
+ roa = new VnfInfoRoa();
+ vnfInfoService = new VnfInfoServiceImpl();
+ roa.setVnfInfoService(vnfInfoService);
+ }
+
+ @Test
+ public void testGetVnfInfos() throws ServiceException {
+ new MockUp<VnfInfoServiceImpl>() {
+
+ @Mock
+ public List<VnfInfoEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VnfInfoEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVnfInfos(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetVnfInfo() throws ServiceException {
+ new MockUp<VnfInfoServiceImpl>() {
+
+ @Mock
+ public List<VnfInfoEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VnfInfoEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVnfInfo(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVnfInfo() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VnfInfoServiceImpl>() {
+
+ @Mock
+ public JSONObject addVnfInfo(JSONObject object) throws ServiceException {
+ return new JSONObject();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVnfInfo(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVnfInfoByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VnfInfoServiceImpl>() {
+
+ @Mock
+ public JSONObject addVnfInfo(JSONObject object) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVnfInfo(mock);
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testAddVnfInfoByNull() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return null;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.addVnfInfo(mock);
+ }
+
+ @Test
+ public void testDeleteVnfInfo() throws ServiceException {
+ new MockUp<VnfInfoServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVnfInfo(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteVnfInfoByException() throws ServiceException {
+ new MockUp<VnfInfoServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVnfInfo(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testDeleteVnfInfoByNull() throws ServiceException {
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.deleteVnfInfo(mock, null);
+ }
+
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VnfRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VnfRoaTest.java new file mode 100644 index 0000000..332cf2d --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VnfRoaTest.java @@ -0,0 +1,191 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.entity.VnfEntity;
+import org.openo.nfvo.resmanagement.service.group.impl.VnfServiceImpl;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfService;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 10, 2017
+ */
+public class VnfRoaTest {
+
+ private VnfRoa roa;
+
+ private VnfService vnfService;
+
+ @Before
+ public void setUp() {
+ roa = new VnfRoa();
+ vnfService = new VnfServiceImpl();
+ roa.setVnfService(vnfService);
+ }
+
+ @Test
+ public void testGetVnfs() throws ServiceException {
+ new MockUp<VnfServiceImpl>() {
+
+ @Mock
+ public List<VnfEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VnfEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVnfs(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetVnf() throws ServiceException {
+ new MockUp<VnfServiceImpl>() {
+
+ @Mock
+ public List<VnfEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VnfEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVnf(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVnf() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VnfEntity>() {
+
+ @Mock
+ public VnfEntity toEntity(JSONObject jsonObject) {
+ return new VnfEntity();
+ }
+ };
+ new MockUp<VnfServiceImpl>() {
+
+ @Mock
+ public JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException {
+ return new JSONObject();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVnf(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVnfByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VnfEntity>() {
+
+ @Mock
+ public VnfEntity toEntity(JSONObject jsonObject) {
+ return new VnfEntity();
+ }
+ };
+ new MockUp<VnfServiceImpl>() {
+
+ @Mock
+ public JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVnf(mock);
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testAddVnfByNull() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return null;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.addVnf(mock);
+ }
+
+ @Test
+ public void testDeleteVnf() throws ServiceException {
+ new MockUp<VnfServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVnf(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteVnfByException() throws ServiceException {
+ new MockUp<VnfServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVnf(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testDeleteVnfByNull() throws ServiceException {
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.deleteVnf(mock, null);
+ }
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoaTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoaTest.java new file mode 100644 index 0000000..1629271 --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoaTest.java @@ -0,0 +1,178 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity;
+import org.openo.nfvo.resmanagement.service.group.impl.VnfStatusServiceImpl;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfStatusService;
+import org.springframework.mock.web.MockHttpServletRequest;
+
+import mockit.Mock;
+import mockit.MockUp;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 10, 2017
+ */
+public class VnfStatusRoaTest {
+
+ private VnfStatusRoa roa;
+
+ private VnfStatusService vnfStatusService;
+
+ @Before
+ public void setUp() {
+ roa = new VnfStatusRoa();
+ vnfStatusService = new VnfStatusServiceImpl();
+ roa.setVnfStatusService(vnfStatusService);
+ }
+
+ @Test
+ public void testGetVnfStatuss() throws ServiceException {
+ new MockUp<VnfStatusServiceImpl>() {
+
+ @Mock
+ public List<VnfStatusEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VnfStatusEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVnfStatuss(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testGetVnfStatus() throws ServiceException {
+ new MockUp<VnfStatusServiceImpl>() {
+
+ @Mock
+ public List<VnfStatusEntity> getList(Map<String, Object> map) throws ServiceException {
+ return new ArrayList<VnfStatusEntity>();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.getVnfStatus(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVnfStatus() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VnfStatusServiceImpl>() {
+
+ @Mock
+ public JSONObject addVnfStatus(JSONObject object) throws ServiceException {
+ return new JSONObject();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVnfStatus(mock);
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testAddVnfStatusByException() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return new JSONObject();
+ }
+ };
+ new MockUp<VnfStatusServiceImpl>() {
+
+ @Mock
+ public JSONObject addVnfStatus(JSONObject object) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.addVnfStatus(mock);
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testAddVnfStatusByNull() throws ServiceException {
+ new MockUp<RequestUtil>() {
+
+ @Mock
+ public JSONObject getJsonRequestBody(HttpServletRequest context) {
+ return null;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.addVnfStatus(mock);
+ }
+
+ @Test
+ public void testDeleteVnfStatus() throws ServiceException {
+ new MockUp<VnfStatusServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ return 1;
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVnfStatus(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test
+ public void testDeleteVnfStatusByException() throws ServiceException {
+ new MockUp<VnfStatusServiceImpl>() {
+
+ @Mock
+ public int delete(String id) throws ServiceException {
+ throw new ServiceException();
+ }
+ };
+ HttpServletRequest mock = new MockHttpServletRequest();
+ JSONObject result = roa.deleteVnfStatus(mock, "id");
+ assertNotNull(result);
+ }
+
+ @Test(expected = ServiceException.class)
+ public void testDeleteVnfStatusByNull() throws ServiceException {
+ HttpServletRequest mock = new MockHttpServletRequest();
+ roa.deleteVnfStatus(mock, null);
+ }
+
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessageTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessageTest.java new file mode 100644 index 0000000..5409ada --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessageTest.java @@ -0,0 +1,68 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class ExceptionMessageTest {
+
+ @Test
+ public void testToString() {
+ ExceptionMessage message = new ExceptionMessage();
+ message.setErrorCode("1");
+ message.setHttpCode(200);
+ message.setMessage("Success!");
+ String str = message.toString();
+ assertNotNull(str);
+ }
+
+ @Test
+ public void testGetErrorCode() {
+ ExceptionMessage message = new ExceptionMessage();
+ message.setErrorCode("1");
+ String str = message.getErrorCode();
+ assertEquals("1", str);
+ }
+
+ @Test
+ public void testHttpCode() {
+ ExceptionMessage message = new ExceptionMessage();
+ message.setHttpCode(200);
+ int str = message.getHttpCode();
+ assertEquals(200, str);
+ }
+
+ @Test
+ public void testGetMessage() {
+ ExceptionMessage message = new ExceptionMessage();
+ message.setMessage("Success!");
+ String str = message.getMessage();
+ assertEquals("Success!", str);
+ }
+
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapperTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapperTest.java new file mode 100644 index 0000000..7a90d9e --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapperTest.java @@ -0,0 +1,43 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class GenericExceptionMapperTest {
+
+ @Test
+ public void testToResponse() {
+ GenericExceptionMapper excep = new GenericExceptionMapper();
+ Exception exception = new Exception("message");
+ Response res = excep.toResponse(exception);
+ assertNotNull(res);
+ }
+
+}
diff --git a/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapperTest.java b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapperTest.java new file mode 100644 index 0000000..fc4378b --- /dev/null +++ b/ResmanagementService/service/src/test/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapperTest.java @@ -0,0 +1,44 @@ +/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.ws.rs.core.Response;
+
+import org.junit.Test;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Feb 9, 2017
+ */
+public class ServiceExceptionMapperTest {
+
+ @Test
+ public void testToResponse() {
+ ServiceExceptionMapper mapper = new ServiceExceptionMapper();
+ ServiceException exception = new ServiceException();
+ Response res = mapper.toResponse(exception);
+ assertNotNull(res);
+ }
+
+}
|