aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-core/catalog-mgr/pom.xml610
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java346
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java482
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/CommonErrorResponse.java84
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/Config.java64
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/FileUtil.java372
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerAddrConfig.java64
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerPathConfig.java60
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbAddrConfig.java62
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java112
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/RestUtil.java70
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ServiceRegistrer.java194
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ZipCompressor.java246
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/CsarQueryCondition.java78
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java62
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOperationalState.java42
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumProcessState.java42
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumType.java42
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumUsageState.java42
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/VnfPackage.java202
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/PackageBasicInfo.java78
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/UploadPackageFromFtpRequest.java76
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/CsarFileUriResponse.java64
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/PackageMeta.java124
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UpdatePackageResponse.java60
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UploadPackageResponse.java62
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusConsumer.java94
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusRest.java70
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceNode.java68
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceRegisterEntity.java108
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/Ftp.java76
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/FtpUtil.java416
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/health/ConsoleHealthCheck.java72
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaNodeTypeDefinition.java132
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaRelationShipDefinition.java94
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerSelfServiceProvider.java3
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServicePackageProvider.java4
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceTemplateProvider.java4
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerExtPackageRest.java5
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerSelfServiceRest.java4
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerTemplateRest.java6
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/NamespaceFilter.java202
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/ILifeCycleServiceRest.java70
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/LifeCycleServiceConsumer.java134
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/IResourceServiceRest.java74
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/ResourceServiceConsumer.java156
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java52
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumPackageFormat.java54
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumTemplateType.java42
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/ModelParserFactory.java116
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/IYamlParseRest.java70
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/YamlParseServiceConsumer.java104
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/EnumYamlServiceTemplateInfo.java82
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlRequestParemeter.java132
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlResult.java1780
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Iwso2RestService.java114
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java378
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java724
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/RestUtils.java74
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java1033
-rw-r--r--catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java847
-rw-r--r--catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java662
-rw-r--r--catalog-core/distribution/catalog-standalone/pom.xml276
-rw-r--r--catalog-core/httpserver/src/main/assembly/tomcat/conf/server.xml290
-rw-r--r--pom.xml88
65 files changed, 6235 insertions, 6215 deletions
diff --git a/catalog-core/catalog-mgr/pom.xml b/catalog-core/catalog-mgr/pom.xml
index 12fb85a4..efc1a26e 100644
--- a/catalog-core/catalog-mgr/pom.xml
+++ b/catalog-core/catalog-mgr/pom.xml
@@ -1,305 +1,305 @@
-<!--
-
- Copyright 2016 [ZTE] and others.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<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">
- <parent>
- <groupId>org.openo.common-tosca.catalog</groupId>
- <artifactId>catalog-core-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>catalog-mgr</artifactId>
- <name>openo/commontosca/catalog/catalog-mgr</name>
- <packaging>jar</packaging>
- <properties>
- <httpclient.version>4.4.1</httpclient.version>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <versionRange>[2.0,)</versionRange>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <configuration>
- <createDependencyReducedPom>true</createDependencyReducedPom>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.openo.commontosca.catalog.catalogApp</mainClass>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>package</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-core</artifactId>
- <version>${dropwizard.version}</version>
- <overWrite>true</overWrite>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <!-- dropwizard -->
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-core</artifactId>
- </dependency>
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-assets</artifactId>
- </dependency>
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-hibernate</artifactId>
- </dependency>
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-migrations</artifactId>
- </dependency>
- <!-- swagger -->
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-jersey2-jaxrs</artifactId>
- </dependency>
- <!-- lombok -->
- <dependency>
- <groupId>org.projectlombok</groupId>
- <artifactId>lombok</artifactId>
- </dependency>
- <!-- jersey -->
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-server</artifactId>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.media</groupId>
- <artifactId>jersey-media-multipart</artifactId>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.containers</groupId>
- <artifactId>jersey-container-servlet-core</artifactId>
- </dependency>
- <!-- consumer -->
- <dependency>
- <groupId>com.eclipsesource.jaxrs</groupId>
- <artifactId>consumer</artifactId>
- <exclusions>
- <exclusion>
- <groupId>com.eclipsesource.jaxrs</groupId>
- <artifactId>jersey-all</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <!-- jackson -->
- <dependency>
- <groupId>com.fasterxml.jackson.dataformat</groupId>
- <artifactId>jackson-dataformat-xml</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
- <!-- gson -->
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- </dependency>
- <!-- dom4j -->
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- </dependency>
- <!-- cometd -->
- <dependency>
- <groupId>org.cometd.java</groupId>
- <artifactId>bayeux-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.cometd.java</groupId>
- <artifactId>cometd-java-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.cometd.java</groupId>
- <artifactId>cometd-java-client</artifactId>
- <version>${cometd.version}</version>
- </dependency>
- <dependency>
- <groupId>org.cometd.java</groupId>
- <artifactId>cometd-java-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.cometd.java</groupId>
- <artifactId>cometd-java-oort</artifactId>
- </dependency>
- <dependency>
- <groupId>org.cometd.java</groupId>
- <artifactId>cometd-java-server</artifactId>
- </dependency>
- <!-- ftp -->
- <dependency>
- <groupId>commons-net</groupId>
- <artifactId>commons-net</artifactId>
- </dependency>
- <!-- mysql -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- </dependency>
- <!-- http server -->
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <!-- UT -->
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-testing</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- UT end -->
- <!-- httpclient-->
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>${httpclient.version}</version>
- <exclusions>
- <!-- provided by jcl-over-slf4j to enable logging via logback -->
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- <version>${httpclient.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpmime</artifactId>
- <version>${httpclient.version}</version>
- </dependency>
- </dependencies>
-</project>
+<!--
+
+ Copyright 2016 [ZTE] and others.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<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">
+ <parent>
+ <groupId>org.openo.common-tosca.catalog</groupId>
+ <artifactId>catalog-core-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>catalog-mgr</artifactId>
+ <name>openo/commontosca/catalog/catalog-mgr</name>
+ <packaging>jar</packaging>
+ <properties>
+ <httpclient.version>4.4.1</httpclient.version>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <versionRange>[2.0,)</versionRange>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <configuration>
+ <createDependencyReducedPom>true</createDependencyReducedPom>
+ <filters>
+ <filter>
+ <artifact>*:*</artifact>
+ <excludes>
+ <exclude>META-INF/*.SF</exclude>
+ <exclude>META-INF/*.DSA</exclude>
+ <exclude>META-INF/*.RSA</exclude>
+ </excludes>
+ </filter>
+ </filters>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.openo.commontosca.catalog.catalogApp</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-core</artifactId>
+ <version>${dropwizard.version}</version>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- dropwizard -->
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-assets</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-hibernate</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-migrations</artifactId>
+ </dependency>
+ <!-- swagger -->
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
+ </dependency>
+ <!-- lombok -->
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+ <!-- jersey -->
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-server</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-multipart</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet-core</artifactId>
+ </dependency>
+ <!-- consumer -->
+ <dependency>
+ <groupId>com.eclipsesource.jaxrs</groupId>
+ <artifactId>consumer</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>com.eclipsesource.jaxrs</groupId>
+ <artifactId>jersey-all</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <!-- jackson -->
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-xml</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+ <!-- gson -->
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
+ <!-- dom4j -->
+ <dependency>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </dependency>
+ <!-- cometd -->
+ <dependency>
+ <groupId>org.cometd.java</groupId>
+ <artifactId>bayeux-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.cometd.java</groupId>
+ <artifactId>cometd-java-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.cometd.java</groupId>
+ <artifactId>cometd-java-client</artifactId>
+ <version>${cometd.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.cometd.java</groupId>
+ <artifactId>cometd-java-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.cometd.java</groupId>
+ <artifactId>cometd-java-oort</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.cometd.java</groupId>
+ <artifactId>cometd-java-server</artifactId>
+ </dependency>
+ <!-- ftp -->
+ <dependency>
+ <groupId>commons-net</groupId>
+ <artifactId>commons-net</artifactId>
+ </dependency>
+ <!-- mysql -->
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ </dependency>
+ <!-- http server -->
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <!-- UT -->
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- UT end -->
+ <!-- httpclient-->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>${httpclient.version}</version>
+ <exclusions>
+ <!-- provided by jcl-over-slf4j to enable logging via logback -->
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>${httpclient.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ <version>${httpclient.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java
index 2cd532bf..8a00fbe6 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java
@@ -1,175 +1,171 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-import io.dropwizard.Application;
-import io.dropwizard.assets.AssetsBundle;
-import io.dropwizard.db.DataSourceFactory;
-import io.dropwizard.hibernate.HibernateBundle;
-import io.dropwizard.migrations.MigrationsBundle;
-import io.dropwizard.server.SimpleServerFactory;
-import io.dropwizard.setup.Bootstrap;
-import io.dropwizard.setup.Environment;
-import io.swagger.jaxrs.config.BeanConfig;
-import io.swagger.jaxrs.listing.ApiListingResource;
-
-import org.eclipse.jetty.servlets.CrossOriginFilter;
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
-import org.openo.commontosca.catalog.common.Config;
-import org.openo.commontosca.catalog.common.HttpServerAddrConfig;
-import org.openo.commontosca.catalog.common.HttpServerPathConfig;
-import org.openo.commontosca.catalog.common.MsbAddrConfig;
-import org.openo.commontosca.catalog.common.ServiceRegistrer;
-import org.openo.commontosca.catalog.db.dao.DaoManager;
-import org.openo.commontosca.catalog.db.entity.NodeTemplateData;
-import org.openo.commontosca.catalog.db.entity.PackageData;
-import org.openo.commontosca.catalog.db.entity.ServiceTemplateData;
-import org.openo.commontosca.catalog.db.entity.ServiceTemplateMappingData;
-import org.openo.commontosca.catalog.health.ConsoleHealthCheck;
-import org.openo.commontosca.catalog.resources.PackageResource;
-import org.openo.commontosca.catalog.resources.TemplateResource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.EnumSet;
-import javax.servlet.DispatcherType;
-
-
-public class CatalogApp extends Application<CatalogAppConfiguration> {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CatalogApp.class);
-
- public static void main(String[] args) throws Exception {
- new CatalogApp().run(args);
- }
-
- @Override
- public String getName() {
- return "OPENO-Catalog";
- }
-
- private final HibernateBundle<CatalogAppConfiguration> bundle =
- new HibernateBundle<CatalogAppConfiguration>(ServiceTemplateData.class, PackageData.class,
- NodeTemplateData.class, ServiceTemplateMappingData.class) {
- @Override
- public DataSourceFactory getDataSourceFactory(CatalogAppConfiguration configuration) {
- return configuration.getDataSourceFactory();
- }
- };
-
- @Override
- public void initialize(Bootstrap<CatalogAppConfiguration> bootstrap) {
- bootstrap.addBundle(new AssetsBundle("/api-doc", "/api-doc", "index.html", "api-doc"));
- initDb(bootstrap);
- }
-
- private void initDao() {
- DaoManager.getInstance().setSessionFactory(bundle.getSessionFactory());
- }
-
- private void initDb(Bootstrap<CatalogAppConfiguration> bootstrap) {
- bootstrap.addBundle(bundle);
- bootstrap.addBundle(new MigrationsBundle<CatalogAppConfiguration>() {
- @Override
- public DataSourceFactory getDataSourceFactory(CatalogAppConfiguration configuration) {
- return configuration.getDataSourceFactory();
- }
- });
- }
-
- @Override
- public void run(CatalogAppConfiguration configuration, Environment environment) {
- LOGGER.info("Start to initialize catalogue.");
- MsbAddrConfig.setMsbAddress(configuration.getMsbServerAddr());
- HttpServerAddrConfig.setHttpServerAddress(configuration.getHttpServerAddr());
- HttpServerPathConfig.setHttpServerPath(configuration.getHttpServerPath());
- initDao();
- final ConsoleHealthCheck healthCheck = new ConsoleHealthCheck(configuration.getTemplate());
- environment.healthChecks().register("template", healthCheck);
-
- environment.jersey().register(new PackageResource());
- environment.jersey().register(new TemplateResource());
- // environment.jersey().register(new VNFHostImageResource());
- // environment.jersey().register(new VNFSoftwareVersionResource());
-
- // register rest interface
- environment.jersey().packages("org.openo.commontosca.catalog.resources");
- // upload file by inputstream need to register MultiPartFeature
- environment.jersey().register(MultiPartFeature.class);
-
- initSwaggerConfig(environment, configuration);
-// initCometd(environment);
- Config.setConfigration(configuration);
- initService();
- LOGGER.info("Initialize catalogue finished.");
- }
-
- /**
- * initialize swagger configuration.
- *
- * @param environment environment information
- * @param configuration catalogue configuration
- */
- private void initSwaggerConfig(Environment environment, CatalogAppConfiguration configuration) {
- environment.jersey().register(new ApiListingResource());
- environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
-
- BeanConfig config = new BeanConfig();
- config.setTitle("Open-o Catalog Service rest API");
- config.setVersion("1.0.0");
- config.setResourcePackage("org.openo.commontosca.catalog.resources");
- // set rest api basepath in swagger
- SimpleServerFactory simpleServerFactory =
- (SimpleServerFactory) configuration.getServerFactory();
- String basePath = simpleServerFactory.getApplicationContextPath();
- String rootPath = simpleServerFactory.getJerseyRootPath();
- rootPath = rootPath.substring(0, rootPath.indexOf("/*"));
- basePath =
- basePath.equals("/") ? rootPath : (new StringBuilder()).append(basePath).append(rootPath)
- .toString();
- config.setBasePath(basePath);
- config.setScan(true);
- }
-
- private void initService() {
- Thread registerCatalogService = new Thread(new ServiceRegistrer());
- registerCatalogService.setName("register catalog service to Microservice Bus");
- registerCatalogService.start();
- }
-
- /**
- * initialize cometd server.
- *
- * @param environment environment information
- */
-// private void initCometd(Environment environment) {
-// // add filter
-// environment.getApplicationContext().addFilter(CrossOriginFilter.class,
-// "/api/nsoccataloguenotification/v1/*",
-// EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR));
-// // add servlet
-// environment.getApplicationContext()
-// .addServlet("org.cometd.server.CometDServlet", "/api/nsoccataloguenotification/v1/*")
-// .setInitOrder(1);
-// // add servlet
-// environment.getApplicationContext()
-// .addServlet("CometdServlet", "/api/nsoccataloguenotification/v1").setInitOrder(2);
-// }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import io.dropwizard.Application;
+import io.dropwizard.assets.AssetsBundle;
+import io.dropwizard.db.DataSourceFactory;
+import io.dropwizard.hibernate.HibernateBundle;
+import io.dropwizard.migrations.MigrationsBundle;
+import io.dropwizard.server.SimpleServerFactory;
+import io.dropwizard.setup.Bootstrap;
+import io.dropwizard.setup.Environment;
+import io.swagger.jaxrs.config.BeanConfig;
+import io.swagger.jaxrs.listing.ApiListingResource;
+
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import org.openo.commontosca.catalog.common.Config;
+import org.openo.commontosca.catalog.common.HttpServerAddrConfig;
+import org.openo.commontosca.catalog.common.HttpServerPathConfig;
+import org.openo.commontosca.catalog.common.MsbAddrConfig;
+import org.openo.commontosca.catalog.common.ServiceRegistrer;
+import org.openo.commontosca.catalog.db.dao.DaoManager;
+import org.openo.commontosca.catalog.db.entity.NodeTemplateData;
+import org.openo.commontosca.catalog.db.entity.PackageData;
+import org.openo.commontosca.catalog.db.entity.ServiceTemplateData;
+import org.openo.commontosca.catalog.db.entity.ServiceTemplateMappingData;
+import org.openo.commontosca.catalog.health.ConsoleHealthCheck;
+import org.openo.commontosca.catalog.resources.PackageResource;
+import org.openo.commontosca.catalog.resources.TemplateResource;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class CatalogApp extends Application<CatalogAppConfiguration> {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CatalogApp.class);
+
+ public static void main(String[] args) throws Exception {
+ new CatalogApp().run(args);
+ }
+
+ @Override
+ public String getName() {
+ return "OPENO-Catalog";
+ }
+
+ private final HibernateBundle<CatalogAppConfiguration> bundle =
+ new HibernateBundle<CatalogAppConfiguration>(ServiceTemplateData.class, PackageData.class,
+ NodeTemplateData.class, ServiceTemplateMappingData.class) {
+ @Override
+ public DataSourceFactory getDataSourceFactory(CatalogAppConfiguration configuration) {
+ return configuration.getDataSourceFactory();
+ }
+ };
+
+ @Override
+ public void initialize(Bootstrap<CatalogAppConfiguration> bootstrap) {
+ bootstrap.addBundle(new AssetsBundle("/api-doc", "/api-doc", "index.html", "api-doc"));
+ initDb(bootstrap);
+ }
+
+ private void initDao() {
+ DaoManager.getInstance().setSessionFactory(bundle.getSessionFactory());
+ }
+
+ private void initDb(Bootstrap<CatalogAppConfiguration> bootstrap) {
+ bootstrap.addBundle(bundle);
+ bootstrap.addBundle(new MigrationsBundle<CatalogAppConfiguration>() {
+ @Override
+ public DataSourceFactory getDataSourceFactory(CatalogAppConfiguration configuration) {
+ return configuration.getDataSourceFactory();
+ }
+ });
+ }
+
+ @Override
+ public void run(CatalogAppConfiguration configuration, Environment environment) {
+ LOGGER.info("Start to initialize catalogue.");
+ MsbAddrConfig.setMsbAddress(configuration.getMsbServerAddr());
+ HttpServerAddrConfig.setHttpServerAddress(configuration.getHttpServerAddr());
+ HttpServerPathConfig.setHttpServerPath(configuration.getHttpServerPath());
+ initDao();
+ final ConsoleHealthCheck healthCheck = new ConsoleHealthCheck(configuration.getTemplate());
+ environment.healthChecks().register("template", healthCheck);
+
+ environment.jersey().register(new PackageResource());
+ environment.jersey().register(new TemplateResource());
+ // environment.jersey().register(new VNFHostImageResource());
+ // environment.jersey().register(new VNFSoftwareVersionResource());
+
+ // register rest interface
+ environment.jersey().packages("org.openo.commontosca.catalog.resources");
+ // upload file by inputstream need to register MultiPartFeature
+ environment.jersey().register(MultiPartFeature.class);
+
+ initSwaggerConfig(environment, configuration);
+ // initCometd(environment);
+ Config.setConfigration(configuration);
+ initService();
+ LOGGER.info("Initialize catalogue finished.");
+ }
+
+ /**
+ * initialize swagger configuration.
+ *
+ * @param environment environment information
+ * @param configuration catalogue configuration
+ */
+ private void initSwaggerConfig(Environment environment, CatalogAppConfiguration configuration) {
+ environment.jersey().register(new ApiListingResource());
+ environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ BeanConfig config = new BeanConfig();
+ config.setTitle("Open-o Catalog Service rest API");
+ config.setVersion("1.0.0");
+ config.setResourcePackage("org.openo.commontosca.catalog.resources");
+ // set rest api basepath in swagger
+ SimpleServerFactory simpleServerFactory =
+ (SimpleServerFactory) configuration.getServerFactory();
+ String basePath = simpleServerFactory.getApplicationContextPath();
+ String rootPath = simpleServerFactory.getJerseyRootPath();
+ rootPath = rootPath.substring(0, rootPath.indexOf("/*"));
+ basePath =
+ basePath.equals("/") ? rootPath : (new StringBuilder()).append(basePath).append(rootPath)
+ .toString();
+ config.setBasePath(basePath);
+ config.setScan(true);
+ }
+
+ private void initService() {
+ Thread registerCatalogService = new Thread(new ServiceRegistrer());
+ registerCatalogService.setName("register catalog service to Microservice Bus");
+ registerCatalogService.start();
+ }
+
+// /**
+// * initialize cometd server.
+// *
+// * @param environment environment information
+// */
+// private void initCometd(Environment environment) {
+// // add filter
+// environment.getApplicationContext().addFilter(CrossOriginFilter.class,
+// "/api/nsoccataloguenotification/v1/*",
+// EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR));
+// // add servlet
+// environment.getApplicationContext()
+// .addServlet("org.cometd.server.CometDServlet", "/api/nsoccataloguenotification/v1/*")
+// .setInitOrder(1);
+// // add servlet
+// environment.getApplicationContext()
+// .addServlet("CometdServlet", "/api/nsoccataloguenotification/v1").setInitOrder(2);
+// }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java
index a951347f..d9a0eeac 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java
@@ -1,241 +1,241 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import io.dropwizard.Configuration;
-import io.dropwizard.db.DataSourceFactory;
-import org.hibernate.validator.constraints.NotEmpty;
-
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-
-
-
-
-public class CatalogAppConfiguration extends Configuration {
- @NotEmpty
- private String template;
-
- @NotEmpty
- private String defaultName = "OPENO-Catalog";
-
- @NotEmpty
- private String msbServerAddr;
-
- @NotEmpty
- private String httpServerAddr;
-
- @NotEmpty
- private String opentoscaServerAddr;
-
- @NotEmpty
- private String yamlParseAddr;
-
- @NotEmpty
- private String wso2HostIp;
-
- @NotEmpty
- private String wso2HostPort;
-
- @NotEmpty
- private String cataloguePath;
- @NotEmpty
- private String httpServerPath;
- @NotEmpty
- private String ldapServerIp;
-
- @NotEmpty
- private String ldapServerPort;
-
- @NotEmpty
- private String ldapLogindn;
-
- @NotEmpty
- private String ldapPassword;
-
- @NotEmpty
- private String ldapVersion;
- @Valid
- @NotNull
- private DataSourceFactory database = new DataSourceFactory();
-
- @JsonProperty("database")
- public DataSourceFactory getDataSourceFactory() {
- return database;
- }
-
- @JsonProperty("database")
- public void setDataSourceFactory(DataSourceFactory dataSourceFactory) {
- this.database = dataSourceFactory;
- }
-
- @JsonProperty
- public String getTemplate() {
- return template;
- }
-
- @JsonProperty
- public void setTemplate(String template) {
- this.template = template;
- }
-
- @JsonProperty
- public String getDefaultName() {
- return defaultName;
- }
-
- @JsonProperty
- public void setDefaultName(String name) {
- this.defaultName = name;
- }
-
- @JsonProperty
- public String getMsbServerAddr() {
- return msbServerAddr;
- }
-
- @JsonProperty
- public void setMsbServerAddr(String msbServerAddr) {
- this.msbServerAddr = msbServerAddr;
- }
-
- @JsonProperty
- public String getHttpServerAddr() {
- return httpServerAddr;
- }
-
- @JsonProperty
- public void setHttpServerAddr(String httpServerAddr) {
- this.httpServerAddr = httpServerAddr;
- }
-
- @JsonProperty
- public String getOpentoscaServerAddr() {
- return opentoscaServerAddr;
- }
-
- @JsonProperty
- public void setOpentoscaServerAddr(String opentoscaServerAddr) {
- this.opentoscaServerAddr = opentoscaServerAddr;
- }
-
- @JsonProperty
- public String getYamlParseAddr() {
- return yamlParseAddr;
- }
-
- @JsonProperty
- public void setYamlParseAddr(String yamlParseAddr) {
- this.yamlParseAddr = yamlParseAddr;
- }
-
- @JsonProperty
- public String getWso2HostIp() {
- return wso2HostIp;
- }
-
- @JsonProperty
- public void setWso2HostIp(String wso2HostIp) {
- this.wso2HostIp = wso2HostIp;
- }
-
- @JsonProperty
- public String getWso2HostPort() {
- return wso2HostPort;
- }
-
- @JsonProperty
- public void setWso2HostPort(String wso2HostPort) {
- this.wso2HostPort = wso2HostPort;
- }
-
- public String getWso2BaseUrl() {
- return "http://" + this.wso2HostIp + ":" + this.wso2HostPort;
- }
-
- @JsonProperty
- public String getCataloguePath() {
- return cataloguePath;
- }
-
- @JsonProperty
- public void setCataloguePath(String cataloguePath) {
- this.cataloguePath = cataloguePath;
- }
-
- @JsonProperty
- public String getLdapServerIp() {
- return ldapServerIp;
- }
-
- @JsonProperty
- public void setLdapServerIp(String ldapServerIp) {
- this.ldapServerIp = ldapServerIp;
- }
-
- @JsonProperty
- public String getLdapServerPort() {
- return ldapServerPort;
- }
-
- @JsonProperty
- public void setLdapServerPort(String ldapServerPort) {
- this.ldapServerPort = ldapServerPort;
- }
-
- @JsonProperty
- public String getLdapLogindn() {
- return ldapLogindn;
- }
-
- @JsonProperty
- public void setLdapLogindn(String ldapLogindn) {
- this.ldapLogindn = ldapLogindn;
- }
-
- @JsonProperty
- public String getLdapPassword() {
- return ldapPassword;
- }
-
- @JsonProperty
- public void setLdapPassword(String ldapPassword) {
- this.ldapPassword = ldapPassword;
- }
-
- @JsonProperty
- public String getLdapVersion() {
- return ldapVersion;
- }
-
- @JsonProperty
- public void setLdapVersion(String ldapVersion) {
- this.ldapVersion = ldapVersion;
- }
-
- @JsonProperty
- public String getHttpServerPath() {
- return httpServerPath;
- }
-
- @JsonProperty
- public void setHttpServerPath(String httpServerPath) {
- this.httpServerPath = httpServerPath;
- }
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.dropwizard.Configuration;
+import io.dropwizard.db.DataSourceFactory;
+import org.hibernate.validator.constraints.NotEmpty;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+
+
+
+public class CatalogAppConfiguration extends Configuration {
+ @NotEmpty
+ private String template;
+
+ @NotEmpty
+ private String defaultName = "OPENO-Catalog";
+
+ @NotEmpty
+ private String msbServerAddr;
+
+ @NotEmpty
+ private String httpServerAddr;
+
+ @NotEmpty
+ private String opentoscaServerAddr;
+
+ @NotEmpty
+ private String yamlParseAddr;
+
+ @NotEmpty
+ private String wso2HostIp;
+
+ @NotEmpty
+ private String wso2HostPort;
+
+ @NotEmpty
+ private String cataloguePath;
+ @NotEmpty
+ private String httpServerPath;
+ @NotEmpty
+ private String ldapServerIp;
+
+ @NotEmpty
+ private String ldapServerPort;
+
+ @NotEmpty
+ private String ldapLogindn;
+
+ @NotEmpty
+ private String ldapPassword;
+
+ @NotEmpty
+ private String ldapVersion;
+ @Valid
+ @NotNull
+ private DataSourceFactory database = new DataSourceFactory();
+
+ @JsonProperty("database")
+ public DataSourceFactory getDataSourceFactory() {
+ return database;
+ }
+
+ @JsonProperty("database")
+ public void setDataSourceFactory(DataSourceFactory dataSourceFactory) {
+ this.database = dataSourceFactory;
+ }
+
+ @JsonProperty
+ public String getTemplate() {
+ return template;
+ }
+
+ @JsonProperty
+ public void setTemplate(String template) {
+ this.template = template;
+ }
+
+ @JsonProperty
+ public String getDefaultName() {
+ return defaultName;
+ }
+
+ @JsonProperty
+ public void setDefaultName(String name) {
+ this.defaultName = name;
+ }
+
+ @JsonProperty
+ public String getMsbServerAddr() {
+ return msbServerAddr;
+ }
+
+ @JsonProperty
+ public void setMsbServerAddr(String msbServerAddr) {
+ this.msbServerAddr = msbServerAddr;
+ }
+
+ @JsonProperty
+ public String getHttpServerAddr() {
+ return httpServerAddr;
+ }
+
+ @JsonProperty
+ public void setHttpServerAddr(String httpServerAddr) {
+ this.httpServerAddr = httpServerAddr;
+ }
+
+ @JsonProperty
+ public String getOpentoscaServerAddr() {
+ return opentoscaServerAddr;
+ }
+
+ @JsonProperty
+ public void setOpentoscaServerAddr(String opentoscaServerAddr) {
+ this.opentoscaServerAddr = opentoscaServerAddr;
+ }
+
+ @JsonProperty
+ public String getYamlParseAddr() {
+ return yamlParseAddr;
+ }
+
+ @JsonProperty
+ public void setYamlParseAddr(String yamlParseAddr) {
+ this.yamlParseAddr = yamlParseAddr;
+ }
+
+ @JsonProperty
+ public String getWso2HostIp() {
+ return wso2HostIp;
+ }
+
+ @JsonProperty
+ public void setWso2HostIp(String wso2HostIp) {
+ this.wso2HostIp = wso2HostIp;
+ }
+
+ @JsonProperty
+ public String getWso2HostPort() {
+ return wso2HostPort;
+ }
+
+ @JsonProperty
+ public void setWso2HostPort(String wso2HostPort) {
+ this.wso2HostPort = wso2HostPort;
+ }
+
+ public String getWso2BaseUrl() {
+ return "http://" + this.wso2HostIp + ":" + this.wso2HostPort;
+ }
+
+ @JsonProperty
+ public String getCataloguePath() {
+ return cataloguePath;
+ }
+
+ @JsonProperty
+ public void setCataloguePath(String cataloguePath) {
+ this.cataloguePath = cataloguePath;
+ }
+
+ @JsonProperty
+ public String getLdapServerIp() {
+ return ldapServerIp;
+ }
+
+ @JsonProperty
+ public void setLdapServerIp(String ldapServerIp) {
+ this.ldapServerIp = ldapServerIp;
+ }
+
+ @JsonProperty
+ public String getLdapServerPort() {
+ return ldapServerPort;
+ }
+
+ @JsonProperty
+ public void setLdapServerPort(String ldapServerPort) {
+ this.ldapServerPort = ldapServerPort;
+ }
+
+ @JsonProperty
+ public String getLdapLogindn() {
+ return ldapLogindn;
+ }
+
+ @JsonProperty
+ public void setLdapLogindn(String ldapLogindn) {
+ this.ldapLogindn = ldapLogindn;
+ }
+
+ @JsonProperty
+ public String getLdapPassword() {
+ return ldapPassword;
+ }
+
+ @JsonProperty
+ public void setLdapPassword(String ldapPassword) {
+ this.ldapPassword = ldapPassword;
+ }
+
+ @JsonProperty
+ public String getLdapVersion() {
+ return ldapVersion;
+ }
+
+ @JsonProperty
+ public void setLdapVersion(String ldapVersion) {
+ this.ldapVersion = ldapVersion;
+ }
+
+ @JsonProperty
+ public String getHttpServerPath() {
+ return httpServerPath;
+ }
+
+ @JsonProperty
+ public void setHttpServerPath(String httpServerPath) {
+ this.httpServerPath = httpServerPath;
+ }
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/CommonErrorResponse.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/CommonErrorResponse.java
index 3d85ee31..c32cfa02 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/CommonErrorResponse.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/CommonErrorResponse.java
@@ -1,42 +1,42 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class CommonErrorResponse {
-
- private String code;
-
- private String message;
-
-
- public static Object failure(String message) {
- return message;
- }
-
- public CommonErrorResponse(String message) {
- super();
- this.message = message;
- }
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class CommonErrorResponse {
+
+ private String code;
+
+ private String message;
+
+
+ public static Object failure(String message) {
+ return message;
+ }
+
+ public CommonErrorResponse(String message) {
+ super();
+ this.message = message;
+ }
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/Config.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/Config.java
index d9076715..76cefc85 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/Config.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/Config.java
@@ -1,32 +1,32 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-import org.openo.commontosca.catalog.CatalogAppConfiguration;
-
-
-public class Config {
- private static CatalogAppConfiguration configration;
-
- public static CatalogAppConfiguration getConfigration() {
- return configration;
- }
-
- public static void setConfigration(CatalogAppConfiguration config) {
- configration = config;
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+import org.openo.commontosca.catalog.CatalogAppConfiguration;
+
+
+public class Config {
+ private static CatalogAppConfiguration configration;
+
+ public static CatalogAppConfiguration getConfigration() {
+ return configration;
+ }
+
+ public static void setConfigration(CatalogAppConfiguration config) {
+ configration = config;
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/FileUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/FileUtil.java
index a3370062..8408b97b 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/FileUtil.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/FileUtil.java
@@ -1,186 +1,186 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-
-public final class FileUtil {
-
- public static final Logger LOG = LoggerFactory.getLogger(FileUtil.class);
-
- private static final int BUFFER_SIZE = 2 * 1024 * 1024;
-
- private static final int TRY_COUNT = 3;
-
- private FileUtil() {
-
- }
-
-
- /**
- * create dir.
- * @param dir dir to create
- * @return boolean
- */
- public static boolean createDirectory(String dir) {
- File folder = new File(dir);
- int tryCount = 0;
- while (tryCount < TRY_COUNT) {
- tryCount++;
- if (!folder.exists() && !folder.mkdirs()) {
- continue;
- } else {
- return true;
- }
- }
-
- return folder.exists();
- }
-
- /**
- * delete file.
- * @param file the file to delete
- * @return boolean
- */
- public static boolean deleteFile(File file) {
- String hintInfo = file.isDirectory() ? "dir " : "file ";
- boolean isFileDeleted = file.delete();
- boolean isFileExist = file.exists();
- if (!isFileExist) {
- if (isFileDeleted) {
- LOG.info("delete " + hintInfo + file.getAbsolutePath());
- } else {
- isFileDeleted = true;
- LOG.info("file not exist. no need delete " + hintInfo + file.getAbsolutePath());
- }
- } else {
- LOG.info("fail to delete " + hintInfo + file.getAbsolutePath());
- }
- return isFileDeleted;
- }
-
-
- /**
- * unzip zip file.
- * @param zipFileName file name to zip
- * @param extPlace extPlace
- * @return unzip file name
- * @throws IOException e1
- */
- public static ArrayList<String> unzip(String zipFileName, String extPlace) throws IOException {
- ZipFile zipFile = null;
- ArrayList<String> unzipFileNams = new ArrayList<String>();
-
- try {
- zipFile = new ZipFile(zipFileName);
- Enumeration<?> fileEn = zipFile.entries();
- byte[] buffer = new byte[BUFFER_SIZE];
-
- while (fileEn.hasMoreElements()) {
- InputStream input = null;
- BufferedOutputStream bos = null;
- try {
- ZipEntry entry = (ZipEntry) fileEn.nextElement();
- if (entry.isDirectory()) {
- continue;
- }
-
- input = zipFile.getInputStream(entry);
- File file = new File(extPlace, entry.getName());
- if (!file.getParentFile().exists()) {
- createDirectory(file.getParentFile().getAbsolutePath());
- }
-
- bos = new BufferedOutputStream(new FileOutputStream(file));
- while (true) {
- int length = input.read(buffer);
- if (length == -1) {
- break;
- }
- bos.write(buffer, 0, length);
- }
- unzipFileNams.add(file.getAbsolutePath());
- } finally {
- closeOutputStream(bos);
- closeInputStream(input);
- }
- }
- } finally {
- closeZipFile(zipFile);
- }
- return unzipFileNams;
- }
-
- /**
- * close InputStream.
- *
- * @param inputStream the inputstream to close
- */
- private static void closeInputStream(InputStream inputStream) {
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- } catch (Exception e1) {
- LOG.info("close InputStream error!");
- }
- }
-
- /**
- * close OutputStream.
- *
- * @param outputStream the output stream to close
- */
- private static void closeOutputStream(OutputStream outputStream) {
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- } catch (Exception e1) {
- LOG.info("close OutputStream error!");
- }
- }
-
- /**
- * close zipFile.
- *
- * @param zipFile the zipFile to close
- */
- private static void closeZipFile(ZipFile zipFile) {
- try {
- if (zipFile != null) {
- zipFile.close();
- zipFile = null;
- }
- } catch (IOException e1) {
- LOG.info("close ZipFile error!");
- }
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+
+public final class FileUtil {
+
+ public static final Logger LOG = LoggerFactory.getLogger(FileUtil.class);
+
+ private static final int BUFFER_SIZE = 2 * 1024 * 1024;
+
+ private static final int TRY_COUNT = 3;
+
+ private FileUtil() {
+
+ }
+
+
+ /**
+ * create dir.
+ * @param dir dir to create
+ * @return boolean
+ */
+ public static boolean createDirectory(String dir) {
+ File folder = new File(dir);
+ int tryCount = 0;
+ while (tryCount < TRY_COUNT) {
+ tryCount++;
+ if (!folder.exists() && !folder.mkdirs()) {
+ continue;
+ } else {
+ return true;
+ }
+ }
+
+ return folder.exists();
+ }
+
+ /**
+ * delete file.
+ * @param file the file to delete
+ * @return boolean
+ */
+ public static boolean deleteFile(File file) {
+ String hintInfo = file.isDirectory() ? "dir " : "file ";
+ boolean isFileDeleted = file.delete();
+ boolean isFileExist = file.exists();
+ if (!isFileExist) {
+ if (isFileDeleted) {
+ LOG.info("delete " + hintInfo + file.getAbsolutePath());
+ } else {
+ isFileDeleted = true;
+ LOG.info("file not exist. no need delete " + hintInfo + file.getAbsolutePath());
+ }
+ } else {
+ LOG.info("fail to delete " + hintInfo + file.getAbsolutePath());
+ }
+ return isFileDeleted;
+ }
+
+
+ /**
+ * unzip zip file.
+ * @param zipFileName file name to zip
+ * @param extPlace extPlace
+ * @return unzip file name
+ * @throws IOException e1
+ */
+ public static ArrayList<String> unzip(String zipFileName, String extPlace) throws IOException {
+ ZipFile zipFile = null;
+ ArrayList<String> unzipFileNams = new ArrayList<String>();
+
+ try {
+ zipFile = new ZipFile(zipFileName);
+ Enumeration<?> fileEn = zipFile.entries();
+ byte[] buffer = new byte[BUFFER_SIZE];
+
+ while (fileEn.hasMoreElements()) {
+ InputStream input = null;
+ BufferedOutputStream bos = null;
+ try {
+ ZipEntry entry = (ZipEntry) fileEn.nextElement();
+ if (entry.isDirectory()) {
+ continue;
+ }
+
+ input = zipFile.getInputStream(entry);
+ File file = new File(extPlace, entry.getName());
+ if (!file.getParentFile().exists()) {
+ createDirectory(file.getParentFile().getAbsolutePath());
+ }
+
+ bos = new BufferedOutputStream(new FileOutputStream(file));
+ while (true) {
+ int length = input.read(buffer);
+ if (length == -1) {
+ break;
+ }
+ bos.write(buffer, 0, length);
+ }
+ unzipFileNams.add(file.getAbsolutePath());
+ } finally {
+ closeOutputStream(bos);
+ closeInputStream(input);
+ }
+ }
+ } finally {
+ closeZipFile(zipFile);
+ }
+ return unzipFileNams;
+ }
+
+ /**
+ * close InputStream.
+ *
+ * @param inputStream the inputstream to close
+ */
+ private static void closeInputStream(InputStream inputStream) {
+ try {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ } catch (Exception e1) {
+ LOG.info("close InputStream error!");
+ }
+ }
+
+ /**
+ * close OutputStream.
+ *
+ * @param outputStream the output stream to close
+ */
+ private static void closeOutputStream(OutputStream outputStream) {
+ try {
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ } catch (Exception e1) {
+ LOG.info("close OutputStream error!");
+ }
+ }
+
+ /**
+ * close zipFile.
+ *
+ * @param zipFile the zipFile to close
+ */
+ private static void closeZipFile(ZipFile zipFile) {
+ try {
+ if (zipFile != null) {
+ zipFile.close();
+ zipFile = null;
+ }
+ } catch (IOException e1) {
+ LOG.info("close ZipFile error!");
+ }
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerAddrConfig.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerAddrConfig.java
index ccae9adf..270ff395 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerAddrConfig.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerAddrConfig.java
@@ -1,32 +1,32 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-
-public class HttpServerAddrConfig {
-
- protected static String httpServerAddress;
-
- public static String getHttpServerAddress() {
- return httpServerAddress;
- }
-
- public static void setHttpServerAddress(String httpServerAddress) {
- HttpServerAddrConfig.httpServerAddress = httpServerAddress;
- }
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+
+public class HttpServerAddrConfig {
+
+ protected static String httpServerAddress;
+
+ public static String getHttpServerAddress() {
+ return httpServerAddress;
+ }
+
+ public static void setHttpServerAddress(String httpServerAddress) {
+ HttpServerAddrConfig.httpServerAddress = httpServerAddress;
+ }
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerPathConfig.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerPathConfig.java
index db66f935..b47a6cae 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerPathConfig.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/HttpServerPathConfig.java
@@ -1,30 +1,30 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-
-public class HttpServerPathConfig {
- protected static String httpServerPath;
-
- public static String getHttpServerPath() {
- return httpServerPath;
- }
-
- public static void setHttpServerPath(String httpServerPath) {
- HttpServerPathConfig.httpServerPath = httpServerPath;
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+
+public class HttpServerPathConfig {
+ protected static String httpServerPath;
+
+ public static String getHttpServerPath() {
+ return httpServerPath;
+ }
+
+ public static void setHttpServerPath(String httpServerPath) {
+ HttpServerPathConfig.httpServerPath = httpServerPath;
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbAddrConfig.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbAddrConfig.java
index caecbc09..14665f1c 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbAddrConfig.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbAddrConfig.java
@@ -1,31 +1,31 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-public class MsbAddrConfig {
-
- protected static String msbAddress;
-
- public static String getMsbAddress() {
- return msbAddress;
- }
-
- public static void setMsbAddress(String msbAddress) {
- MsbAddrConfig.msbAddress = msbAddress;
- }
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+public class MsbAddrConfig {
+
+ protected static String msbAddress;
+
+ public static String getMsbAddress() {
+ return msbAddress;
+ }
+
+ public static void setMsbAddress(String msbAddress) {
+ MsbAddrConfig.msbAddress = msbAddress;
+ }
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java
index ac2c2c07..1a5eac6c 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java
@@ -1,56 +1,56 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-/**
- * micro-service bus utility class.
- *
- */
-public class MsbUtil {
-
- public static String getRocBaseUrl() {
- return Config.getConfigration().getMsbServerAddr() + getRocApiRootDomain();
- }
-
- private static String getRocApiRootDomain() {
- return "/api/roc/v1";
- }
-
- public static String getNsocLifecycleBaseUrl() {
- return Config.getConfigration().getMsbServerAddr() + getNsocLifeCycleRootDomain();
- }
-
- private static String getNsocLifeCycleRootDomain() {
- return "/api/nsoc/v1";
- }
-
- public static String getVimBaseUrl() {
- return Config.getConfigration().getMsbServerAddr() + getVimRootDomain();
- }
-
- private static String getVimRootDomain() {
- return "/api/vim/v1";
- }
-
- public static String getPackageUrl() {
- return Config.getConfigration().getMsbServerAddr() + "/api/nsoc/v1/csar/";
- }
-
- public static String getYamlParseBaseUrl() {
- return Config.getConfigration().getYamlParseAddr() + "/api/yamlparser/v1";
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+/**
+ * micro-service bus utility class.
+ *
+ */
+public class MsbUtil {
+
+ public static String getRocBaseUrl() {
+ return Config.getConfigration().getMsbServerAddr() + getRocApiRootDomain();
+ }
+
+ private static String getRocApiRootDomain() {
+ return "/api/roc/v1";
+ }
+
+ public static String getNsocLifecycleBaseUrl() {
+ return Config.getConfigration().getMsbServerAddr() + getNsocLifeCycleRootDomain();
+ }
+
+ private static String getNsocLifeCycleRootDomain() {
+ return "/api/nsoc/v1";
+ }
+
+ public static String getVimBaseUrl() {
+ return Config.getConfigration().getMsbServerAddr() + getVimRootDomain();
+ }
+
+ private static String getVimRootDomain() {
+ return "/api/vim/v1";
+ }
+
+ public static String getPackageUrl() {
+ return Config.getConfigration().getMsbServerAddr() + "/api/nsoc/v1/csar/";
+ }
+
+ public static String getYamlParseBaseUrl() {
+ return Config.getConfigration().getYamlParseAddr() + "/api/yamlparser/v1";
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/RestUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/RestUtil.java
index 70a53f1f..57e24e0b 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/RestUtil.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/RestUtil.java
@@ -1,35 +1,35 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-import javax.ws.rs.core.Response;
-
-
-public class RestUtil {
-
- /**
- * get rest exception.
- * @param errorMsg error message
- * @return Response
- */
- public static Response getRestException(String errorMsg) {
- String code = "001";
- return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
- .entity(new CommonErrorResponse(code, errorMsg)).build();
- }
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+import javax.ws.rs.core.Response;
+
+
+public class RestUtil {
+
+ /**
+ * get rest exception.
+ * @param errorMsg error message
+ * @return Response
+ */
+ public static Response getRestException(String errorMsg) {
+ String code = "001";
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
+ .entity(new CommonErrorResponse(code, errorMsg)).build();
+ }
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ServiceRegistrer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ServiceRegistrer.java
index b83985f2..1312f2f0 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ServiceRegistrer.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ServiceRegistrer.java
@@ -1,97 +1,97 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-import org.openo.commontosca.catalog.externalservice.msb.MicroserviceBusConsumer;
-import org.openo.commontosca.catalog.externalservice.msb.ServiceRegisterEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-public class ServiceRegistrer implements Runnable {
- private final ArrayList<ServiceRegisterEntity> serviceEntityList =
- new ArrayList<ServiceRegisterEntity>();
- private static final Logger LOG = LoggerFactory.getLogger(ServiceRegistrer.class);
-
- public ServiceRegistrer() {
- initServiceEntity();
- }
-
- @Override
- public void run() {
- LOG.info("start microservice register");
- boolean flag = false;
- ServiceRegisterEntity entity = new ServiceRegisterEntity();
- int retry = 0;
- while (retry < 1000 && serviceEntityList.size() > 0) {
- Iterator<ServiceRegisterEntity> it = serviceEntityList.iterator();
- while (it.hasNext()) {
- entity = it.next();
- LOG.info("start" + entity.getServiceName() + " catalog microservice register.retry:"
- + retry);
- flag = MicroserviceBusConsumer.registerService(entity);
- if (flag == false) {
- LOG.warn(entity.getServiceName()
- + " microservice register failed, sleep 30S and try again.");
- threadSleep(30000);
- } else {
- LOG.info(entity.getServiceName() + " microservice register success!");
- it.remove();
- }
- }
- retry++;
-
- }
- LOG.info("catalog microservice register end.");
-
- }
-
- /**
- * sleep thread.
- * @param second sleep second
- */
- private void threadSleep(int seconds) {
- LOG.info("start sleep ....");
- try {
- Thread.sleep(seconds);
- } catch (InterruptedException e1) {
- LOG.error("thread sleep error.errorMsg:" + e1.getMessage());
- }
- LOG.info("sleep end .");
- }
-
- private void initServiceEntity() {
- ServiceRegisterEntity catalogEntity = new ServiceRegisterEntity();
- catalogEntity.setServiceName("catalog");
- catalogEntity.setProtocol("REST");
- catalogEntity.setVersion("v1");
- catalogEntity.setUrl("/openoapi/catalog/v1");
- catalogEntity.setSingleNode(null, "8200", 0);
- catalogEntity.setVisualRange("1");
- serviceEntityList.add(catalogEntity);
- ServiceRegisterEntity httpServiceEntity = new ServiceRegisterEntity();
- httpServiceEntity.setServiceName("/files/catalog-http");
- httpServiceEntity.setProtocol("REST");
- httpServiceEntity.setVersion("v1");
- httpServiceEntity.setUrl("/");
- httpServiceEntity.setSingleNode(null, "8201", 0);
- httpServiceEntity.setVisualRange("1");
- serviceEntityList.add(httpServiceEntity);
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+import org.openo.commontosca.catalog.externalservice.msb.MicroserviceBusConsumer;
+import org.openo.commontosca.catalog.externalservice.msb.ServiceRegisterEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class ServiceRegistrer implements Runnable {
+ private final ArrayList<ServiceRegisterEntity> serviceEntityList =
+ new ArrayList<ServiceRegisterEntity>();
+ private static final Logger LOG = LoggerFactory.getLogger(ServiceRegistrer.class);
+
+ public ServiceRegistrer() {
+ initServiceEntity();
+ }
+
+ @Override
+ public void run() {
+ LOG.info("start microservice register");
+ boolean flag = false;
+ ServiceRegisterEntity entity = new ServiceRegisterEntity();
+ int retry = 0;
+ while (retry < 1000 && serviceEntityList.size() > 0) {
+ Iterator<ServiceRegisterEntity> it = serviceEntityList.iterator();
+ while (it.hasNext()) {
+ entity = it.next();
+ LOG.info("start" + entity.getServiceName() + " catalog microservice register.retry:"
+ + retry);
+ flag = MicroserviceBusConsumer.registerService(entity);
+ if (flag == false) {
+ LOG.warn(entity.getServiceName()
+ + " microservice register failed, sleep 30S and try again.");
+ threadSleep(30000);
+ } else {
+ LOG.info(entity.getServiceName() + " microservice register success!");
+ it.remove();
+ }
+ }
+ retry++;
+
+ }
+ LOG.info("catalog microservice register end.");
+
+ }
+
+ /**
+ * sleep thread.
+ * @param second sleep second
+ */
+ private void threadSleep(int seconds) {
+ LOG.info("start sleep ....");
+ try {
+ Thread.sleep(seconds);
+ } catch (InterruptedException e1) {
+ LOG.error("thread sleep error.errorMsg:" + e1.getMessage());
+ }
+ LOG.info("sleep end .");
+ }
+
+ private void initServiceEntity() {
+ ServiceRegisterEntity catalogEntity = new ServiceRegisterEntity();
+ catalogEntity.setServiceName("catalog");
+ catalogEntity.setProtocol("REST");
+ catalogEntity.setVersion("v1");
+ catalogEntity.setUrl("/openoapi/catalog/v1");
+ catalogEntity.setSingleNode(null, "8200", 0);
+ catalogEntity.setVisualRange("1");
+ serviceEntityList.add(catalogEntity);
+ ServiceRegisterEntity httpServiceEntity = new ServiceRegisterEntity();
+ httpServiceEntity.setServiceName("/files/catalog-http");
+ httpServiceEntity.setProtocol("REST");
+ httpServiceEntity.setVersion("v1");
+ httpServiceEntity.setUrl("/");
+ httpServiceEntity.setSingleNode(null, "8201", 0);
+ httpServiceEntity.setVisualRange("1");
+ serviceEntityList.add(httpServiceEntity);
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ZipCompressor.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ZipCompressor.java
index e202e706..e378c36c 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ZipCompressor.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ZipCompressor.java
@@ -1,123 +1,123 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.zip.CRC32;
-import java.util.zip.CheckedOutputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-
-public class ZipCompressor {
-
- public static final Logger LOG = LoggerFactory.getLogger(ZipCompressor.class);
- static final int BUFFER = 8192;
-
- private File zipFile;
-
- public ZipCompressor(String pathName) {
- zipFile = new File(pathName);
- }
-
- /**
- * compress file according several path.
- * @param pathName file path name
- */
- public void compress(String... pathName) {
- ZipOutputStream out = null;
- try {
- FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
- CheckedOutputStream cos = new CheckedOutputStream(fileOutputStream, new CRC32());
- out = new ZipOutputStream(cos);
- String basedir = "";
- for (int i = 0; i < pathName.length; i++) {
- compress(new File(pathName[i]), out, basedir);
- }
- out.close();
- } catch (Exception e1) {
- throw new RuntimeException(e1);
- }
- }
-
- /**
- * compress file according file path.
- * @param srcPathName file path name
- */
- public void compress(String srcPathName) {
- File file = new File(srcPathName);
- if (!file.exists()) {
- throw new RuntimeException(srcPathName + "not exist!");
- }
- try {
- FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
- CheckedOutputStream cos = new CheckedOutputStream(fileOutputStream, new CRC32());
- ZipOutputStream out = new ZipOutputStream(cos);
- String basedir = "";
- compress(file, out, basedir);
- out.close();
- } catch (Exception e1) {
- throw new RuntimeException(e1);
- }
- }
-
- private void compress(File file, ZipOutputStream out, String basedir) {
- if (file.isDirectory()) {
- System.out.println("compress:" + basedir + file.getName());
- this.compressDirectory(file, out, basedir);
- } else {
- System.out.println("compress:" + basedir + file.getName());
- this.compressFile(file, out, basedir);
- }
- }
-
- private void compressDirectory(File dir, ZipOutputStream out, String basedir) {
- if (!dir.exists()) {
- return;
- }
-
- File[] files = dir.listFiles();
- for (int i = 0; i < files.length; i++) {
- compress(files[i], out, basedir + dir.getName() + "/");
- }
- }
-
- private void compressFile(File file, ZipOutputStream out, String basedir) {
- if (!file.exists()) {
- return;
- }
- try {
- byte data[] = new byte[BUFFER];
- BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
- ZipEntry entry = new ZipEntry(basedir + file.getName());
- out.putNextEntry(entry);
- int count;
- while ((count = bis.read(data, 0, BUFFER)) != -1) {
- out.write(data, 0, count);
- }
- bis.close();
- } catch (Exception e1) {
- throw new RuntimeException(e1);
- }
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.common;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.util.zip.CRC32;
+import java.util.zip.CheckedOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+
+public class ZipCompressor {
+
+ public static final Logger LOG = LoggerFactory.getLogger(ZipCompressor.class);
+ static final int BUFFER = 8192;
+
+ private File zipFile;
+
+ public ZipCompressor(String pathName) {
+ zipFile = new File(pathName);
+ }
+
+ /**
+ * compress file according several path.
+ * @param pathName file path name
+ */
+ public void compress(String... pathName) {
+ ZipOutputStream out = null;
+ try {
+ FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
+ CheckedOutputStream cos = new CheckedOutputStream(fileOutputStream, new CRC32());
+ out = new ZipOutputStream(cos);
+ String basedir = "";
+ for (int i = 0; i < pathName.length; i++) {
+ compress(new File(pathName[i]), out, basedir);
+ }
+ out.close();
+ } catch (Exception e1) {
+ throw new RuntimeException(e1);
+ }
+ }
+
+ /**
+ * compress file according file path.
+ * @param srcPathName file path name
+ */
+ public void compress(String srcPathName) {
+ File file = new File(srcPathName);
+ if (!file.exists()) {
+ throw new RuntimeException(srcPathName + "not exist!");
+ }
+ try {
+ FileOutputStream fileOutputStream = new FileOutputStream(zipFile);
+ CheckedOutputStream cos = new CheckedOutputStream(fileOutputStream, new CRC32());
+ ZipOutputStream out = new ZipOutputStream(cos);
+ String basedir = "";
+ compress(file, out, basedir);
+ out.close();
+ } catch (Exception e1) {
+ throw new RuntimeException(e1);
+ }
+ }
+
+ private void compress(File file, ZipOutputStream out, String basedir) {
+ if (file.isDirectory()) {
+ System.out.println("compress:" + basedir + file.getName());
+ this.compressDirectory(file, out, basedir);
+ } else {
+ System.out.println("compress:" + basedir + file.getName());
+ this.compressFile(file, out, basedir);
+ }
+ }
+
+ private void compressDirectory(File dir, ZipOutputStream out, String basedir) {
+ if (!dir.exists()) {
+ return;
+ }
+
+ File[] files = dir.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ compress(files[i], out, basedir + dir.getName() + "/");
+ }
+ }
+
+ private void compressFile(File file, ZipOutputStream out, String basedir) {
+ if (!file.exists()) {
+ return;
+ }
+ try {
+ byte data[] = new byte[BUFFER];
+ BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
+ ZipEntry entry = new ZipEntry(basedir + file.getName());
+ out.putNextEntry(entry);
+ int count;
+ while ((count = bis.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ }
+ bis.close();
+ } catch (Exception e1) {
+ throw new RuntimeException(e1);
+ }
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/CsarQueryCondition.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/CsarQueryCondition.java
index 1b8231ee..95b44681 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/CsarQueryCondition.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/CsarQueryCondition.java
@@ -1,39 +1,39 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class CsarQueryCondition {
-
- private String csarId;
-
- private String name;
-
- private String provider;
-
- private String version;
-
- private Boolean deletionPending;
-
- private EnumType type;
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class CsarQueryCondition {
+
+ private String csarId;
+
+ private String name;
+
+ private String provider;
+
+ private String version;
+
+ private Boolean deletionPending;
+
+ private EnumType type;
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java
index bbd87602..2fb83df1 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java
@@ -1,31 +1,31 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity;
-
-public enum EnumOnboardState {
- onBoarded("onBoarded"), nonOnBoarded("non-onBoarded");
-
- String value;
-
- EnumOnboardState(String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity;
+
+public enum EnumOnboardState {
+ onBoarded("onBoarded"), nonOnBoarded("non-onBoarded");
+
+ String value;
+
+ EnumOnboardState(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOperationalState.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOperationalState.java
index 1dd4acb5..fefa0692 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOperationalState.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOperationalState.java
@@ -1,21 +1,21 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity;
-
-public enum EnumOperationalState {
- Enabled, Disabled
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity;
+
+public enum EnumOperationalState {
+ Enabled, Disabled
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumProcessState.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumProcessState.java
index 2bcbd57e..84e85202 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumProcessState.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumProcessState.java
@@ -1,21 +1,21 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity;
-
-public enum EnumProcessState {
- normal, onBoarding, onBoardFailed, deleting, deleteFailed
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity;
+
+public enum EnumProcessState {
+ normal, onBoarding, onBoardFailed, deleting, deleteFailed
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumType.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumType.java
index 28e70fd7..23a0b66b 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumType.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumType.java
@@ -1,21 +1,21 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity;
-
-public enum EnumType {
- GSAR, SSAR, NSAR, NFAR
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity;
+
+public enum EnumType {
+ GSAR, SSAR, NSAR, NFAR
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumUsageState.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumUsageState.java
index 1f4a61ce..72fa680a 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumUsageState.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumUsageState.java
@@ -1,21 +1,21 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity;
-
-public enum EnumUsageState {
- InUse, NotInUse
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity;
+
+public enum EnumUsageState {
+ InUse, NotInUse
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/VnfPackage.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/VnfPackage.java
index 520ebe59..0344b301 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/VnfPackage.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/VnfPackage.java
@@ -1,101 +1,101 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity;
-
-public class VnfPackage {
- private String vnfPackageId;
- private String name;
- private String version;
- private String provider;
- private String vnfd;
- private EnumOperationalState operationalState = EnumOperationalState.Disabled;
- private EnumUsageState usageState = EnumUsageState.InUse;
- private String deletionPending;
- private String vnfPackageUrl;
-
- public String getVnfPackageId() {
- return vnfPackageId;
- }
-
- public void setVnfPackageId(String vnfPackageId) {
- this.vnfPackageId = vnfPackageId;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getProvider() {
- return provider;
- }
-
- public void setProvider(String provider) {
- this.provider = provider;
- }
-
- public String getVnfd() {
- return vnfd;
- }
-
- public void setVnfd(String vnfd) {
- this.vnfd = vnfd;
- }
-
- public EnumOperationalState getOperationalState() {
- return operationalState;
- }
-
- public void setOperationalState(EnumOperationalState operationalState) {
- this.operationalState = operationalState;
- }
-
- public EnumUsageState getUsageState() {
- return usageState;
- }
-
- public void setUsageState(EnumUsageState usageState) {
- this.usageState = usageState;
- }
-
- public String getVnfPackageUrl() {
- return vnfPackageUrl;
- }
-
- public void setVnfPackageUrl(String vnfPackageUrl) {
- this.vnfPackageUrl = vnfPackageUrl;
- }
-
- public String getDeletionPending() {
- return deletionPending;
- }
-
- public void setDeletionPending(String deletionPending) {
- this.deletionPending = deletionPending;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity;
+
+public class VnfPackage {
+ private String vnfPackageId;
+ private String name;
+ private String version;
+ private String provider;
+ private String vnfd;
+ private EnumOperationalState operationalState = EnumOperationalState.Disabled;
+ private EnumUsageState usageState = EnumUsageState.InUse;
+ private String deletionPending;
+ private String vnfPackageUrl;
+
+ public String getVnfPackageId() {
+ return vnfPackageId;
+ }
+
+ public void setVnfPackageId(String vnfPackageId) {
+ this.vnfPackageId = vnfPackageId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getProvider() {
+ return provider;
+ }
+
+ public void setProvider(String provider) {
+ this.provider = provider;
+ }
+
+ public String getVnfd() {
+ return vnfd;
+ }
+
+ public void setVnfd(String vnfd) {
+ this.vnfd = vnfd;
+ }
+
+ public EnumOperationalState getOperationalState() {
+ return operationalState;
+ }
+
+ public void setOperationalState(EnumOperationalState operationalState) {
+ this.operationalState = operationalState;
+ }
+
+ public EnumUsageState getUsageState() {
+ return usageState;
+ }
+
+ public void setUsageState(EnumUsageState usageState) {
+ this.usageState = usageState;
+ }
+
+ public String getVnfPackageUrl() {
+ return vnfPackageUrl;
+ }
+
+ public void setVnfPackageUrl(String vnfPackageUrl) {
+ this.vnfPackageUrl = vnfPackageUrl;
+ }
+
+ public String getDeletionPending() {
+ return deletionPending;
+ }
+
+ public void setDeletionPending(String deletionPending) {
+ this.deletionPending = deletionPending;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/PackageBasicInfo.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/PackageBasicInfo.java
index 31924c89..34c3de4d 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/PackageBasicInfo.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/PackageBasicInfo.java
@@ -1,39 +1,39 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity.request;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import org.openo.commontosca.catalog.entity.EnumType;
-
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class PackageBasicInfo {
-
- private String provider;
-
- private EnumType type;
-
- private String version;
-
- private String format;
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity.request;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import org.openo.commontosca.catalog.entity.EnumType;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class PackageBasicInfo {
+
+ private String provider;
+
+ private EnumType type;
+
+ private String version;
+
+ private String format;
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/UploadPackageFromFtpRequest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/UploadPackageFromFtpRequest.java
index 0bc271fc..074b418f 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/UploadPackageFromFtpRequest.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/request/UploadPackageFromFtpRequest.java
@@ -1,38 +1,38 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity.request;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import org.openo.commontosca.catalog.entity.EnumType;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class UploadPackageFromFtpRequest {
-
- private String provider;
-
- private EnumType type;
-
- private String version;
-
- private String ftpUrl;
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity.request;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import org.openo.commontosca.catalog.entity.EnumType;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class UploadPackageFromFtpRequest {
+
+ private String provider;
+
+ private EnumType type;
+
+ private String version;
+
+ private String ftpUrl;
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/CsarFileUriResponse.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/CsarFileUriResponse.java
index 158a68a2..bdfbe82c 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/CsarFileUriResponse.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/CsarFileUriResponse.java
@@ -1,32 +1,32 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity.response;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class CsarFileUriResponse {
-
- private String downloadUri;
-
- private String localPath;
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity.response;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class CsarFileUriResponse {
+
+ private String downloadUri;
+
+ private String localPath;
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/PackageMeta.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/PackageMeta.java
index 356bc07b..45ad7494 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/PackageMeta.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/PackageMeta.java
@@ -1,62 +1,62 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity.response;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import org.openo.commontosca.catalog.entity.EnumOperationalState;
-import org.openo.commontosca.catalog.entity.EnumProcessState;
-import org.openo.commontosca.catalog.entity.EnumUsageState;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class PackageMeta {
-
- private String csarId;
-
- private String name;
-
- private String downloadUri;
-
- private String size;
-
- private String version;
-
- private String provider;
-
- private String type;
-
- private String format;
-
- private boolean deletionPending;
-
- private String createTime;
-
- private String modifyTime;
-
- private EnumOperationalState operationalState;
-
- private EnumUsageState usageState;
-
- private String onBoardState;
-
- private EnumProcessState processState;
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity.response;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import org.openo.commontosca.catalog.entity.EnumOperationalState;
+import org.openo.commontosca.catalog.entity.EnumProcessState;
+import org.openo.commontosca.catalog.entity.EnumUsageState;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class PackageMeta {
+
+ private String csarId;
+
+ private String name;
+
+ private String downloadUri;
+
+ private String size;
+
+ private String version;
+
+ private String provider;
+
+ private String type;
+
+ private String format;
+
+ private boolean deletionPending;
+
+ private String createTime;
+
+ private String modifyTime;
+
+ private EnumOperationalState operationalState;
+
+ private EnumUsageState usageState;
+
+ private String onBoardState;
+
+ private EnumProcessState processState;
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UpdatePackageResponse.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UpdatePackageResponse.java
index 1713e705..30ca11b4 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UpdatePackageResponse.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UpdatePackageResponse.java
@@ -1,30 +1,30 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity.response;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class UpdatePackageResponse {
-
- private String usageState;
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity.response;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class UpdatePackageResponse {
+
+ private String usageState;
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UploadPackageResponse.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UploadPackageResponse.java
index 761bfe3b..1e800377 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UploadPackageResponse.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/response/UploadPackageResponse.java
@@ -1,31 +1,31 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.entity.response;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class UploadPackageResponse {
-
- private String csarId;
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.entity.response;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class UploadPackageResponse {
+
+ private String csarId;
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusConsumer.java
index 03e45af5..2bb6afca 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusConsumer.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusConsumer.java
@@ -1,47 +1,47 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.externalservice.msb;
-
-import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
-import org.glassfish.jersey.client.ClientConfig;
-import org.openo.commontosca.catalog.common.Config;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class MicroserviceBusConsumer {
- private static final Logger LOG = LoggerFactory.getLogger(MicroserviceBusConsumer.class);
-
- /**
- * register service to MSB.
- * @param entity ServiceRegisterEntity
- * @return boolean
- */
- public static boolean registerService(ServiceRegisterEntity entity) {
- ClientConfig config = new ClientConfig();
- try {
- MicroserviceBusRest resourceserviceproxy =
- ConsumerFactory.createConsumer(Config.getConfigration().getMsbServerAddr(), config,
- MicroserviceBusRest.class);
- resourceserviceproxy.registerServce("false", entity);
- } catch (Exception e1) {
- LOG.error("microservice register failed!" + e1.getMessage());
- return false;
- }
- return true;
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.externalservice.msb;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+import org.glassfish.jersey.client.ClientConfig;
+import org.openo.commontosca.catalog.common.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class MicroserviceBusConsumer {
+ private static final Logger LOG = LoggerFactory.getLogger(MicroserviceBusConsumer.class);
+
+ /**
+ * register service to MSB.
+ * @param entity ServiceRegisterEntity
+ * @return boolean
+ */
+ public static boolean registerService(ServiceRegisterEntity entity) {
+ ClientConfig config = new ClientConfig();
+ try {
+ MicroserviceBusRest resourceserviceproxy =
+ ConsumerFactory.createConsumer(Config.getConfigration().getMsbServerAddr(), config,
+ MicroserviceBusRest.class);
+ resourceserviceproxy.registerServce("false", entity);
+ } catch (Exception e1) {
+ LOG.error("microservice register failed!" + e1.getMessage());
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusRest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusRest.java
index 69e9b89f..b8a566f1 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusRest.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/MicroserviceBusRest.java
@@ -1,35 +1,35 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.externalservice.msb;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-
-@Path("/openoapi/microservices/v1/services")
-// @Path("/api/microservices/v1/services")
-public interface MicroserviceBusRest {
- @Path("")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate,
- ServiceRegisterEntity entity) throws Exception;
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.externalservice.msb;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+@Path("/openoapi/microservices/v1/services")
+// @Path("/api/microservices/v1/services")
+public interface MicroserviceBusRest {
+ @Path("")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate,
+ ServiceRegisterEntity entity) throws Exception;
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceNode.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceNode.java
index 4f251577..28b17f27 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceNode.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceNode.java
@@ -1,34 +1,34 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.externalservice.msb;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class ServiceNode {
- private String ip;
- private String port;
- private int ttl;
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.externalservice.msb;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceNode {
+ private String ip;
+ private String port;
+ private int ttl;
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceRegisterEntity.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceRegisterEntity.java
index 30bed2a0..513c30a8 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceRegisterEntity.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/externalservice/msb/ServiceRegisterEntity.java
@@ -1,54 +1,54 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.externalservice.msb;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.ArrayList;
-
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class ServiceRegisterEntity {
- private String serviceName;
- private String version;
- private String url;
- private String protocol;
- private String visualRange;
- private ArrayList<ServiceNode> nodes = new ArrayList<ServiceNode>();
-
- /**
- * set single node.
- * @param ip ip
- * @param port port
- * @param ttl ttl
- */
- public void setSingleNode(String ip, String port, int ttl) {
- ServiceNode node = new ServiceNode();
- node.setIp(ip);
- node.setPort(port);
- node.setTtl(ttl);
- nodes.add(node);
- }
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.externalservice.msb;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ServiceRegisterEntity {
+ private String serviceName;
+ private String version;
+ private String url;
+ private String protocol;
+ private String visualRange;
+ private ArrayList<ServiceNode> nodes = new ArrayList<ServiceNode>();
+
+ /**
+ * set single node.
+ * @param ip ip
+ * @param port port
+ * @param ttl ttl
+ */
+ public void setSingleNode(String ip, String port, int ttl) {
+ ServiceNode node = new ServiceNode();
+ node.setIp(ip);
+ node.setPort(port);
+ node.setTtl(ttl);
+ nodes.add(node);
+ }
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/Ftp.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/Ftp.java
index ed075ce2..8d6972eb 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/Ftp.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/Ftp.java
@@ -1,38 +1,38 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.ftp;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class Ftp {
-
- private String ipAddr;
-
- private Integer port;
-
- private String userName;
-
- private String pwd;
-
- private String path;
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.ftp;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Ftp {
+
+ private String ipAddr;
+
+ private Integer port;
+
+ private String userName;
+
+ private String pwd;
+
+ private String path;
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/FtpUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/FtpUtil.java
index 6f74bbf9..01ab5a24 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/FtpUtil.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/ftp/FtpUtil.java
@@ -1,208 +1,208 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.ftp;
-
-import org.apache.commons.net.ftp.FTPClient;
-import org.apache.commons.net.ftp.FTPFile;
-import org.apache.commons.net.ftp.FTPReply;
-import org.apache.log4j.Logger;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-public class FtpUtil {
-
- private static Logger logger = Logger.getLogger(FtpUtil.class);
-
- private static FTPClient ftp;
-
- /**
- * get ftp connection.
- *
- * @param conftp Ftp
- * @return boolean
- * @throws Exception e
- */
- public static boolean connectFtp(Ftp conftp) throws Exception {
- ftp = new FTPClient();
- boolean flag = false;
- if (conftp.getPort() == null) {
- ftp.connect(conftp.getIpAddr(), 21);
- } else {
- ftp.connect(conftp.getIpAddr(), conftp.getPort());
- }
- ftp.login(conftp.getUserName(), conftp.getPwd());
- ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
- int reply = ftp.getReplyCode();
- if (!FTPReply.isPositiveCompletion(reply)) {
- ftp.disconnect();
- return flag;
- }
- ftp.changeWorkingDirectory(conftp.getPath());
- flag = true;
- return flag;
- }
-
- /**
- * close ftp connection.
- */
- public static void closeFtp() {
- if (ftp != null && ftp.isConnected()) {
- try {
- ftp.logout();
- ftp.disconnect();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * upload file by ftp.
- *
- * @param file file to upload
- * @throws Exception e
- */
- public static void upload(File file) throws Exception {
- if (file.isDirectory()) {
- ftp.makeDirectory(file.getName());
- ftp.changeWorkingDirectory(file.getName());
- String[] files = file.list();
- for (String fstr : files) {
- File file1 = new File(file.getPath() + "/" + fstr);
- if (file1.isDirectory()) {
- upload(file1);
- ftp.changeToParentDirectory();
- } else {
- File file2 = new File(file.getPath() + "/" + fstr);
- FileInputStream input = new FileInputStream(file2);
- ftp.storeFile(file2.getName(), input);
- input.close();
- }
- }
- } else {
- File file2 = new File(file.getPath());
- FileInputStream input = new FileInputStream(file2);
- ftp.storeFile(file2.getName(), input);
- input.close();
- }
- }
-
- /**
- * download inline config.
- *
- * @param downftp ftp to download
- * @param localBaseDir local directory
- * @param remoteBaseDir remote directory
- * @throws Exception e
- */
- public static void startDown(Ftp downftp, String localBaseDir, String remoteBaseDir)
- throws Exception {
- if (FtpUtil.connectFtp(downftp)) {
-
- try {
- FTPFile[] files = null;
- boolean changedir = ftp.changeWorkingDirectory(remoteBaseDir);
- if (changedir) {
- ftp.setControlEncoding("GBK");
- files = ftp.listFiles();
- for (int i = 0; i < files.length; i++) {
- try {
- downloadFile(files[i], localBaseDir, remoteBaseDir);
- } catch (Exception e1) {
- logger.error(e1);
- logger.error("<" + files[i].getName() + ">download failed");
- }
- }
- }
- } catch (Exception e1) {
- logger.error(e1);
- logger.error("error occoured while download");
- }
- } else {
- logger.error("Connect failed !");
- }
-
- }
-
-
- /**
- * download ftp file.
- *
- * @param ftpFile ftp file to download
- * @param relativeLocalPath relative local path
- * @param relativeRemotePath relative remote path
- */
- private static void downloadFile(FTPFile ftpFile, String relativeLocalPath,
- String relativeRemotePath) {
- if (ftpFile.isFile()) {
- if (ftpFile.getName().indexOf("?") == -1) {
- OutputStream outputStream = null;
- try {
- File locaFile = new File(relativeLocalPath + ftpFile.getName());
- // 判断文件是否存在,存在则返回
- if (locaFile.exists()) {
- return;
- } else {
- outputStream = new FileOutputStream(relativeLocalPath + ftpFile.getName());
- ftp.retrieveFile(ftpFile.getName(), outputStream);
- outputStream.flush();
- outputStream.close();
- }
- } catch (Exception e1) {
- logger.error(e1);
- } finally {
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- } catch (IOException e1) {
- logger.error("输出文件流异常");
- }
- }
- }
- } else {
- String newlocalRelatePath = relativeLocalPath + ftpFile.getName();
- String newRemote = new String(relativeRemotePath + ftpFile.getName().toString());
- File fl = new File(newlocalRelatePath);
- if (!fl.exists()) {
- fl.mkdirs();
- }
- try {
- newlocalRelatePath = newlocalRelatePath + '/';
- newRemote = newRemote + "/";
- String currentWorkDir = ftpFile.getName().toString();
- boolean changedir = ftp.changeWorkingDirectory(currentWorkDir);
- if (changedir) {
- FTPFile[] files = null;
- files = ftp.listFiles();
- for (int i = 0; i < files.length; i++) {
- downloadFile(files[i], newlocalRelatePath, newRemote);
- }
- }
- if (changedir) {
- ftp.changeToParentDirectory();
- }
- } catch (Exception e1) {
- logger.error(e1);
- }
- }
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.ftp;
+
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+import org.apache.commons.net.ftp.FTPReply;
+import org.apache.log4j.Logger;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class FtpUtil {
+
+ private static Logger logger = Logger.getLogger(FtpUtil.class);
+
+ private static FTPClient ftp;
+
+ /**
+ * get ftp connection.
+ *
+ * @param conftp Ftp
+ * @return boolean
+ * @throws Exception e
+ */
+ public static boolean connectFtp(Ftp conftp) throws Exception {
+ ftp = new FTPClient();
+ boolean flag = false;
+ if (conftp.getPort() == null) {
+ ftp.connect(conftp.getIpAddr(), 21);
+ } else {
+ ftp.connect(conftp.getIpAddr(), conftp.getPort());
+ }
+ ftp.login(conftp.getUserName(), conftp.getPwd());
+ ftp.setFileType(FTPClient.BINARY_FILE_TYPE);
+ int reply = ftp.getReplyCode();
+ if (!FTPReply.isPositiveCompletion(reply)) {
+ ftp.disconnect();
+ return flag;
+ }
+ ftp.changeWorkingDirectory(conftp.getPath());
+ flag = true;
+ return flag;
+ }
+
+ /**
+ * close ftp connection.
+ */
+ public static void closeFtp() {
+ if (ftp != null && ftp.isConnected()) {
+ try {
+ ftp.logout();
+ ftp.disconnect();
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * upload file by ftp.
+ *
+ * @param file file to upload
+ * @throws Exception e
+ */
+ public static void upload(File file) throws Exception {
+ if (file.isDirectory()) {
+ ftp.makeDirectory(file.getName());
+ ftp.changeWorkingDirectory(file.getName());
+ String[] files = file.list();
+ for (String fstr : files) {
+ File file1 = new File(file.getPath() + "/" + fstr);
+ if (file1.isDirectory()) {
+ upload(file1);
+ ftp.changeToParentDirectory();
+ } else {
+ File file2 = new File(file.getPath() + "/" + fstr);
+ FileInputStream input = new FileInputStream(file2);
+ ftp.storeFile(file2.getName(), input);
+ input.close();
+ }
+ }
+ } else {
+ File file2 = new File(file.getPath());
+ FileInputStream input = new FileInputStream(file2);
+ ftp.storeFile(file2.getName(), input);
+ input.close();
+ }
+ }
+
+ /**
+ * download inline config.
+ *
+ * @param downftp ftp to download
+ * @param localBaseDir local directory
+ * @param remoteBaseDir remote directory
+ * @throws Exception e
+ */
+ public static void startDown(Ftp downftp, String localBaseDir, String remoteBaseDir)
+ throws Exception {
+ if (FtpUtil.connectFtp(downftp)) {
+
+ try {
+ FTPFile[] files = null;
+ boolean changedir = ftp.changeWorkingDirectory(remoteBaseDir);
+ if (changedir) {
+ ftp.setControlEncoding("GBK");
+ files = ftp.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ try {
+ downloadFile(files[i], localBaseDir, remoteBaseDir);
+ } catch (Exception e1) {
+ logger.error(e1);
+ logger.error("<" + files[i].getName() + ">download failed");
+ }
+ }
+ }
+ } catch (Exception e1) {
+ logger.error(e1);
+ logger.error("error occoured while download");
+ }
+ } else {
+ logger.error("Connect failed !");
+ }
+
+ }
+
+
+ /**
+ * download ftp file.
+ *
+ * @param ftpFile ftp file to download
+ * @param relativeLocalPath relative local path
+ * @param relativeRemotePath relative remote path
+ */
+ private static void downloadFile(FTPFile ftpFile, String relativeLocalPath,
+ String relativeRemotePath) {
+ if (ftpFile.isFile()) {
+ if (ftpFile.getName().indexOf("?") == -1) {
+ OutputStream outputStream = null;
+ try {
+ File locaFile = new File(relativeLocalPath + ftpFile.getName());
+ // 判断文件是否存在,存在则返回
+ if (locaFile.exists()) {
+ return;
+ } else {
+ outputStream = new FileOutputStream(relativeLocalPath + ftpFile.getName());
+ ftp.retrieveFile(ftpFile.getName(), outputStream);
+ outputStream.flush();
+ outputStream.close();
+ }
+ } catch (Exception e1) {
+ logger.error(e1);
+ } finally {
+ try {
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ } catch (IOException e1) {
+ logger.error("输出文件流异常");
+ }
+ }
+ }
+ } else {
+ String newlocalRelatePath = relativeLocalPath + ftpFile.getName();
+ String newRemote = new String(relativeRemotePath + ftpFile.getName().toString());
+ File fl = new File(newlocalRelatePath);
+ if (!fl.exists()) {
+ fl.mkdirs();
+ }
+ try {
+ newlocalRelatePath = newlocalRelatePath + '/';
+ newRemote = newRemote + "/";
+ String currentWorkDir = ftpFile.getName().toString();
+ boolean changedir = ftp.changeWorkingDirectory(currentWorkDir);
+ if (changedir) {
+ FTPFile[] files = null;
+ files = ftp.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ downloadFile(files[i], newlocalRelatePath, newRemote);
+ }
+ }
+ if (changedir) {
+ ftp.changeToParentDirectory();
+ }
+ } catch (Exception e1) {
+ logger.error(e1);
+ }
+ }
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/health/ConsoleHealthCheck.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/health/ConsoleHealthCheck.java
index a39428a6..14137c2a 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/health/ConsoleHealthCheck.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/health/ConsoleHealthCheck.java
@@ -1,36 +1,36 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.health;
-
-import com.codahale.metrics.health.HealthCheck;
-
-public class ConsoleHealthCheck extends HealthCheck {
- private final String template;
-
- public ConsoleHealthCheck(String template) {
- this.template = template;
- }
-
- @Override
- protected Result check() throws Exception {
- final String saying = String.format(template, "TEST");
- if (!saying.contains("TEST")) {
- return Result.unhealthy("template doesn't include a name");
- }
- return Result.healthy();
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.health;
+
+import com.codahale.metrics.health.HealthCheck;
+
+public class ConsoleHealthCheck extends HealthCheck {
+ private final String template;
+
+ public ConsoleHealthCheck(String template) {
+ this.template = template;
+ }
+
+ @Override
+ protected Result check() throws Exception {
+ final String saying = String.format(template, "TEST");
+ if (!saying.contains("TEST")) {
+ return Result.unhealthy("template doesn't include a name");
+ }
+ return Result.healthy();
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaNodeTypeDefinition.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaNodeTypeDefinition.java
index 6c519d93..085ec1e4 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaNodeTypeDefinition.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaNodeTypeDefinition.java
@@ -1,66 +1,66 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.common;
-
-public enum EnumToscaNodeTypeDefinition {
- VNF {
- @Override
- public String getName() {
- return "tosca.nodes.nfv.VNF";
- }
- },
- VDU {
- @Override
- public String getName() {
- return "tosca.nodes.nfv.VDU";
- }
- },
- VNFC {
- @Override
- public String getName() {
- return "tosca.nodes.nfv.VNFC";
- }
- },
- VL {
- @Override
- public String getName() {
- return "tosca.nodes.nfv.VL";
- }
- },
- CP {
- @Override
- public String getName() {
- return "tosca.nodes.nfv.CP";
- }
- };
-
- public abstract String getName();
-
- /**
- * judge wether is tosca node type definition or not.
- * @param type node type
- * @return boolean
- */
- public static boolean isToscaNodeTypeDef(String type) {
- for (EnumToscaNodeTypeDefinition enumDef : EnumToscaNodeTypeDefinition.values()) {
- if (type.indexOf(enumDef.getName()) != -1) {
- return true;
- }
- }
- return false;
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.common;
+
+public enum EnumToscaNodeTypeDefinition {
+ VNF {
+ @Override
+ public String getName() {
+ return "tosca.nodes.nfv.VNF";
+ }
+ },
+ VDU {
+ @Override
+ public String getName() {
+ return "tosca.nodes.nfv.VDU";
+ }
+ },
+ VNFC {
+ @Override
+ public String getName() {
+ return "tosca.nodes.nfv.VNFC";
+ }
+ },
+ VL {
+ @Override
+ public String getName() {
+ return "tosca.nodes.nfv.VL";
+ }
+ },
+ CP {
+ @Override
+ public String getName() {
+ return "tosca.nodes.nfv.CP";
+ }
+ };
+
+ public abstract String getName();
+
+ /**
+ * judge wether is tosca node type definition or not.
+ * @param type node type
+ * @return boolean
+ */
+ public static boolean isToscaNodeTypeDef(String type) {
+ for (EnumToscaNodeTypeDefinition enumDef : EnumToscaNodeTypeDefinition.values()) {
+ if (type.indexOf(enumDef.getName()) != -1) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaRelationShipDefinition.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaRelationShipDefinition.java
index 41998183..608fc9d2 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaRelationShipDefinition.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/common/EnumToscaRelationShipDefinition.java
@@ -1,47 +1,47 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.common;
-
-public enum EnumToscaRelationShipDefinition {
- VirtualBindsTo {
- @Override
- public String getName() {
- return "tosca.relationships.nfv.VirtualBindsTo";
- }
- },
- VirtualLinksTo {
- @Override
- public String getName() {
- return "tosca.relationships.nfv.VirtualLinksTo";
- }
- },
- DeployedOn {
- @Override
- public String getName() {
- return "tosca.relationships.nfv.DeployedOn";
- }
- },
- BelongTo {
- @Override
- public String getName() {
- return "tosca.relationships.nfv.BelongTo";
- }
- };
-
- public abstract String getName();
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.common;
+
+public enum EnumToscaRelationShipDefinition {
+ VirtualBindsTo {
+ @Override
+ public String getName() {
+ return "tosca.relationships.nfv.VirtualBindsTo";
+ }
+ },
+ VirtualLinksTo {
+ @Override
+ public String getName() {
+ return "tosca.relationships.nfv.VirtualLinksTo";
+ }
+ },
+ DeployedOn {
+ @Override
+ public String getName() {
+ return "tosca.relationships.nfv.DeployedOn";
+ }
+ },
+ BelongTo {
+ @Override
+ public String getName() {
+ return "tosca.relationships.nfv.BelongTo";
+ }
+ };
+
+ public abstract String getName();
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerSelfServiceProvider.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerSelfServiceProvider.java
index 66d14834..fab6e3c6 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerSelfServiceProvider.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerSelfServiceProvider.java
@@ -16,6 +16,8 @@
package org.openo.commontosca.catalog.model.externalservice.container;
+import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerSelfService;
+
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
@@ -29,7 +31,6 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
-import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerSelfService;
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServicePackageProvider.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServicePackageProvider.java
index a8f44d97..7e5ed60e 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServicePackageProvider.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServicePackageProvider.java
@@ -16,6 +16,8 @@
package org.openo.commontosca.catalog.model.externalservice.container;
+import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServicePackageList;
+
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
@@ -29,7 +31,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
-import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServicePackageList;
+
/**
* The opentosca container service returns data to the package entity.
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceTemplateProvider.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceTemplateProvider.java
index 9a0d70c8..d5becc9a 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceTemplateProvider.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceTemplateProvider.java
@@ -16,6 +16,8 @@
package org.openo.commontosca.catalog.model.externalservice.container;
+import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServiceTemplateList;
+
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
@@ -29,8 +31,6 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
-import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServiceTemplateList;
-
/**
* The opentosca container self service returns data to the service template entity.
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerExtPackageRest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerExtPackageRest.java
index 8be43c9f..11179138 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerExtPackageRest.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerExtPackageRest.java
@@ -16,6 +16,8 @@
package org.openo.commontosca.catalog.model.externalservice.container;
+import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServicePackageList;
+
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
@@ -26,9 +28,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServicePackageList;
-
-
/**
* The opentosca container interface for csar.
*
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerSelfServiceRest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerSelfServiceRest.java
index 36ffa8ab..91d9dd7a 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerSelfServiceRest.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerSelfServiceRest.java
@@ -16,13 +16,13 @@
package org.openo.commontosca.catalog.model.externalservice.container;
+import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerSelfService;
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerSelfService;
-
/**
* The opentosca container interface for self service.
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerTemplateRest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerTemplateRest.java
index b0cbec0b..02f9fbd9 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerTemplateRest.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/IContainerTemplateRest.java
@@ -16,6 +16,9 @@
package org.openo.commontosca.catalog.model.externalservice.container;
+import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServiceNodeTemplateList;
+import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServiceTemplateList;
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -23,9 +26,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServiceNodeTemplateList;
-import org.openo.commontosca.catalog.model.externalservice.entity.container.ContainerServiceTemplateList;
-
/**
* The opentosca container interface for service template.
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/NamespaceFilter.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/NamespaceFilter.java
index e5768b28..585240d3 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/NamespaceFilter.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/NamespaceFilter.java
@@ -1,101 +1,101 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.externalservice.container;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.XMLFilterImpl;
-
-/**
- * NamespaceFilter.
- *
- * @author 10189609
- *
- */
-public class NamespaceFilter extends XMLFilterImpl {
-
- private String usedNamespaceUri;
- private boolean addNamespace;
-
- // State variable
- private boolean addedNamespace = false;
-
- /**
- * constructor.
- * @param namespaceUri namspace uri
- * @param addNamespace add namespace or not
- */
- public NamespaceFilter(String namespaceUri, boolean addNamespace) {
- super();
-
- if (addNamespace) {
- this.usedNamespaceUri = namespaceUri;
- } else {
- this.usedNamespaceUri = "";
- }
- this.addNamespace = addNamespace;
- }
-
-
-
- @Override
- public void startDocument() throws SAXException {
- super.startDocument();
- if (addNamespace) {
- startControlledPrefixMapping();
- }
- }
-
-
-
- @Override
- public void startElement(String arg0, String arg1, String arg2, Attributes arg3)
- throws SAXException {
-
- super.startElement(this.usedNamespaceUri, arg1, arg2, arg3);
- }
-
- @Override
- public void endElement(String arg0, String arg1, String arg2) throws SAXException {
-
- super.endElement(this.usedNamespaceUri, arg1, arg2);
- }
-
- @Override
- public void startPrefixMapping(String prefix, String url) throws SAXException {
-
-
- if (addNamespace) {
- this.startControlledPrefixMapping();
- } else {
- // Remove the namespace, i.e. don´t call startPrefixMapping for parent!
- }
-
- }
-
- private void startControlledPrefixMapping() throws SAXException {
-
- if (this.addNamespace && !this.addedNamespace) {
- // We should add namespace since it is set and has not yet been done.
- super.startPrefixMapping("", this.usedNamespaceUri);
-
- // Make sure we dont do it twice
- this.addedNamespace = true;
- }
- }
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.externalservice.container;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+/**
+ * NamespaceFilter.
+ *
+ * @author 10189609
+ *
+ */
+public class NamespaceFilter extends XMLFilterImpl {
+
+ private String usedNamespaceUri;
+ private boolean addNamespace;
+
+ // State variable
+ private boolean addedNamespace = false;
+
+ /**
+ * constructor.
+ * @param namespaceUri namspace uri
+ * @param addNamespace add namespace or not
+ */
+ public NamespaceFilter(String namespaceUri, boolean addNamespace) {
+ super();
+
+ if (addNamespace) {
+ this.usedNamespaceUri = namespaceUri;
+ } else {
+ this.usedNamespaceUri = "";
+ }
+ this.addNamespace = addNamespace;
+ }
+
+
+
+ @Override
+ public void startDocument() throws SAXException {
+ super.startDocument();
+ if (addNamespace) {
+ startControlledPrefixMapping();
+ }
+ }
+
+
+
+ @Override
+ public void startElement(String arg0, String arg1, String arg2, Attributes arg3)
+ throws SAXException {
+
+ super.startElement(this.usedNamespaceUri, arg1, arg2, arg3);
+ }
+
+ @Override
+ public void endElement(String arg0, String arg1, String arg2) throws SAXException {
+
+ super.endElement(this.usedNamespaceUri, arg1, arg2);
+ }
+
+ @Override
+ public void startPrefixMapping(String prefix, String url) throws SAXException {
+
+
+ if (addNamespace) {
+ this.startControlledPrefixMapping();
+ } else {
+ // Remove the namespace, i.e. don´t call startPrefixMapping for parent!
+ }
+
+ }
+
+ private void startControlledPrefixMapping() throws SAXException {
+
+ if (this.addNamespace && !this.addedNamespace) {
+ // We should add namespace since it is set and has not yet been done.
+ super.startPrefixMapping("", this.usedNamespaceUri);
+
+ // Make sure we dont do it twice
+ this.addedNamespace = true;
+ }
+ }
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/ILifeCycleServiceRest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/ILifeCycleServiceRest.java
index fd370ec6..6c65fc81 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/ILifeCycleServiceRest.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/ILifeCycleServiceRest.java
@@ -1,35 +1,35 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.externalservice.lifecycle;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-/**
- * The lifecycle interface.
- *
- * @author 10189609
- *
- */
-@Path("/appinstances")
-public interface ILifeCycleServiceRest {
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public String getVnfInstances();
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.externalservice.lifecycle;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * The lifecycle interface.
+ *
+ * @author 10189609
+ *
+ */
+@Path("/appinstances")
+public interface ILifeCycleServiceRest {
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public String getVnfInstances();
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/LifeCycleServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/LifeCycleServiceConsumer.java
index f09170ff..3a99b7ee 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/LifeCycleServiceConsumer.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/lifecycle/LifeCycleServiceConsumer.java
@@ -1,67 +1,67 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.externalservice.lifecycle;
-
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-
-import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
-import org.openo.commontosca.catalog.common.MsbUtil;
-import org.openo.commontosca.catalog.common.ToolUtil;
-import org.openo.commontosca.catalog.model.externalservice.entity.lifecycle.InstanceEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-
-
-
-/**
- * The lifecycle service.
- *
- * @author 10189609
- *
- */
-public class LifeCycleServiceConsumer {
- private static final Logger LOG = LoggerFactory.getLogger(LifeCycleServiceConsumer.class);
-
- /**
- * get lifecycle application instances.
- *
- * @return instance entity
- */
- public static ArrayList<InstanceEntity> getInstances() {
- ILifeCycleServiceRest resourceserviceproxy =
- ConsumerFactory.createConsumer(MsbUtil.getNsocLifecycleBaseUrl(),
- ILifeCycleServiceRest.class);
- String result = "";
- try {
- result = resourceserviceproxy.getVnfInstances();
- } catch (Exception e1) {
- LOG.error("query vim info faild.", e1);
- return null;
- }
- if (ToolUtil.isEmptyString(result)) {
- return null;
- }
-
- Gson gson = new Gson();
- Type listType = new TypeToken<ArrayList<InstanceEntity>>() {}.getType();
- return gson.fromJson(result, listType);
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.externalservice.lifecycle;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+import org.openo.commontosca.catalog.common.MsbUtil;
+import org.openo.commontosca.catalog.common.ToolUtil;
+import org.openo.commontosca.catalog.model.externalservice.entity.lifecycle.InstanceEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+
+
+
+/**
+ * The lifecycle service.
+ *
+ * @author 10189609
+ *
+ */
+public class LifeCycleServiceConsumer {
+ private static final Logger LOG = LoggerFactory.getLogger(LifeCycleServiceConsumer.class);
+
+ /**
+ * get lifecycle application instances.
+ *
+ * @return instance entity
+ */
+ public static ArrayList<InstanceEntity> getInstances() {
+ ILifeCycleServiceRest resourceserviceproxy =
+ ConsumerFactory.createConsumer(MsbUtil.getNsocLifecycleBaseUrl(),
+ ILifeCycleServiceRest.class);
+ String result = "";
+ try {
+ result = resourceserviceproxy.getVnfInstances();
+ } catch (Exception e1) {
+ LOG.error("query vim info faild.", e1);
+ return null;
+ }
+ if (ToolUtil.isEmptyString(result)) {
+ return null;
+ }
+
+ Gson gson = new Gson();
+ Type listType = new TypeToken<ArrayList<InstanceEntity>>() {}.getType();
+ return gson.fromJson(result, listType);
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/IResourceServiceRest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/IResourceServiceRest.java
index 1f82eaf4..5aa6537f 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/IResourceServiceRest.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/IResourceServiceRest.java
@@ -1,37 +1,37 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.externalservice.ro;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-/**
- * The roc resource interface.
- *
- * @author 10189609
- *
- */
-@Path("/resource")
-public interface IResourceServiceRest {
- @Path("/vims/{vim_id}")
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public String getResourceVim(@PathParam("vim_id") String vimId) throws Exception;
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.externalservice.ro;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * The roc resource interface.
+ *
+ * @author 10189609
+ *
+ */
+@Path("/resource")
+public interface IResourceServiceRest {
+ @Path("/vims/{vim_id}")
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public String getResourceVim(@PathParam("vim_id") String vimId) throws Exception;
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/ResourceServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/ResourceServiceConsumer.java
index 198c0025..b951e952 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/ResourceServiceConsumer.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/ro/ResourceServiceConsumer.java
@@ -1,78 +1,78 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.externalservice.ro;
-
-import com.google.gson.Gson;
-
-import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
-
-import org.openo.commontosca.catalog.common.MsbUtil;
-import org.openo.commontosca.catalog.common.ToolUtil;
-import org.openo.commontosca.catalog.model.externalservice.entity.ro.ResourceResponseEntity;
-import org.openo.commontosca.catalog.model.externalservice.entity.ro.VimEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The roc resource service.
- *
- * @author 10189609
- *
- */
-public class ResourceServiceConsumer {
- private static final Logger LOG = LoggerFactory.getLogger(ResourceServiceConsumer.class);
-
- private static final String RESOURCE_REST_RESULT = "SUCCESS";
-
- /**
- * get vim entity from roc by vimid.
- *
- * @param vimId id
- * @return vim entity
- */
- public static VimEntity getResourceVim(String vimId) {
- LOG.info("begin query vim info from roc,vimId:" + vimId);
- IResourceServiceRest resourceserviceproxy =
- ConsumerFactory.createConsumer(MsbUtil.getRocBaseUrl(), IResourceServiceRest.class);
- String result = "";
- try {
- result = resourceserviceproxy.getResourceVim(vimId);
- } catch (Exception e1) {
- LOG.error("query vim info faild.", e1);
- return null;
- }
- if (ToolUtil.isEmptyString(result)) {
- LOG.error("query vim info faild, vim info is null, vimId:" + vimId);
- return null;
- }
-
- Gson gson = new Gson();
- ResourceResponseEntity responseEntity = gson.fromJson(result, ResourceResponseEntity.class);
- if (!RESOURCE_REST_RESULT.equalsIgnoreCase(responseEntity.getOperationResult())) {
- LOG.error("query vim info faild.vimId:" + vimId);
- return null;
- }
- if (responseEntity.getData().size() <= 0) {
- LOG.error("query vim info faild, vim info is empty, vimId:" + vimId);
- return null;
- }
-
- LOG.info("end query vim info from roc.");
- return responseEntity.getData().get(0);
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.externalservice.ro;
+
+import com.google.gson.Gson;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+
+import org.openo.commontosca.catalog.common.MsbUtil;
+import org.openo.commontosca.catalog.common.ToolUtil;
+import org.openo.commontosca.catalog.model.externalservice.entity.ro.ResourceResponseEntity;
+import org.openo.commontosca.catalog.model.externalservice.entity.ro.VimEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The roc resource service.
+ *
+ * @author 10189609
+ *
+ */
+public class ResourceServiceConsumer {
+ private static final Logger LOG = LoggerFactory.getLogger(ResourceServiceConsumer.class);
+
+ private static final String RESOURCE_REST_RESULT = "SUCCESS";
+
+ /**
+ * get vim entity from roc by vimid.
+ *
+ * @param vimId id
+ * @return vim entity
+ */
+ public static VimEntity getResourceVim(String vimId) {
+ LOG.info("begin query vim info from roc,vimId:" + vimId);
+ IResourceServiceRest resourceserviceproxy =
+ ConsumerFactory.createConsumer(MsbUtil.getRocBaseUrl(), IResourceServiceRest.class);
+ String result = "";
+ try {
+ result = resourceserviceproxy.getResourceVim(vimId);
+ } catch (Exception e1) {
+ LOG.error("query vim info faild.", e1);
+ return null;
+ }
+ if (ToolUtil.isEmptyString(result)) {
+ LOG.error("query vim info faild, vim info is null, vimId:" + vimId);
+ return null;
+ }
+
+ Gson gson = new Gson();
+ ResourceResponseEntity responseEntity = gson.fromJson(result, ResourceResponseEntity.class);
+ if (!RESOURCE_REST_RESULT.equalsIgnoreCase(responseEntity.getOperationResult())) {
+ LOG.error("query vim info faild.vimId:" + vimId);
+ return null;
+ }
+ if (responseEntity.getData().size() <= 0) {
+ LOG.error("query vim info faild, vim info is empty, vimId:" + vimId);
+ return null;
+ }
+
+ LOG.info("end query vim info from roc.");
+ return responseEntity.getData().get(0);
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
index 5bc5f14b..4bfcac04 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
@@ -1,26 +1,26 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.parser;
-
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-
-public abstract class AbstractModelParser {
-
- public abstract String parse(String packageId, String fileLocation)
- throws CatalogResourceException;
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.parser;
+
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+
+public abstract class AbstractModelParser {
+
+ public abstract String parse(String packageId, String fileLocation)
+ throws CatalogResourceException;
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumPackageFormat.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumPackageFormat.java
index ea245ecb..ba7b4968 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumPackageFormat.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumPackageFormat.java
@@ -1,27 +1,27 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.parser;
-
-/**
- * enum data.
- *
- * @author 10189609
- *
- */
-public enum EnumPackageFormat {
- TOSCA_XML, TOSCA_YAML
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.parser;
+
+/**
+ * enum data.
+ *
+ * @author 10189609
+ *
+ */
+public enum EnumPackageFormat {
+ TOSCA_XML, TOSCA_YAML
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumTemplateType.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumTemplateType.java
index 07cc2e5b..6530d156 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumTemplateType.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/EnumTemplateType.java
@@ -1,21 +1,21 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.parser;
-
-public enum EnumTemplateType {
- NS, VNF
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.parser;
+
+public enum EnumTemplateType {
+ NS, VNF
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/ModelParserFactory.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/ModelParserFactory.java
index f69e2ece..acd02068 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/ModelParserFactory.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/ModelParserFactory.java
@@ -1,58 +1,58 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.parser;
-
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-public class ModelParserFactory {
- private static final ModelParserFactory instance = new ModelParserFactory();
-
- public static ModelParserFactory getInstance() {
- return instance;
- }
-
- private Map<EnumPackageFormat, AbstractModelParser> pkgType2ParseMap =
- new HashMap<EnumPackageFormat, AbstractModelParser>();
-
- private ModelParserFactory() {
- // PackageParseMap.put(EnumPackageFormat.TOSCA_XML, new
- // ToscaXmlModelParser());
- pkgType2ParseMap.put(EnumPackageFormat.TOSCA_YAML, new ToscaYamlModelParser());
- }
-
- /**
- * parse package.
- * @param packageId package id
- * @param fileLocation package location
- * @param format package format
- * @return service template id
- * @throws CatalogResourceException e
- */
- public String parse(String packageId, String fileLocation, EnumPackageFormat format)
- throws CatalogResourceException {
- if (pkgType2ParseMap.get(format) == null) {
- throw new CatalogResourceException("Can't find its parser. package type = "
- + format.toString());
- }
-
- return pkgType2ParseMap.get(format).parse(packageId, fileLocation);
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.parser;
+
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class ModelParserFactory {
+ private static final ModelParserFactory instance = new ModelParserFactory();
+
+ public static ModelParserFactory getInstance() {
+ return instance;
+ }
+
+ private Map<EnumPackageFormat, AbstractModelParser> pkgType2ParseMap =
+ new HashMap<EnumPackageFormat, AbstractModelParser>();
+
+ private ModelParserFactory() {
+ // PackageParseMap.put(EnumPackageFormat.TOSCA_XML, new
+ // ToscaXmlModelParser());
+ pkgType2ParseMap.put(EnumPackageFormat.TOSCA_YAML, new ToscaYamlModelParser());
+ }
+
+ /**
+ * parse package.
+ * @param packageId package id
+ * @param fileLocation package location
+ * @param format package format
+ * @return service template id
+ * @throws CatalogResourceException e
+ */
+ public String parse(String packageId, String fileLocation, EnumPackageFormat format)
+ throws CatalogResourceException {
+ if (pkgType2ParseMap.get(format) == null) {
+ throw new CatalogResourceException("Can't find its parser. package type = "
+ + format.toString());
+ }
+
+ return pkgType2ParseMap.get(format).parse(packageId, fileLocation);
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/IYamlParseRest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/IYamlParseRest.java
index 82b1b47e..39e419cc 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/IYamlParseRest.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/IYamlParseRest.java
@@ -1,35 +1,35 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.parser.yaml;
-
-import org.openo.commontosca.catalog.model.parser.yaml.entity.ParseYamlRequestParemeter;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-
-@Path("/parse")
-public interface IYamlParseRest {
-
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- String parse(ParseYamlRequestParemeter request) throws Exception;
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.parser.yaml;
+
+import org.openo.commontosca.catalog.model.parser.yaml.entity.ParseYamlRequestParemeter;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+
+@Path("/parse")
+public interface IYamlParseRest {
+
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ String parse(ParseYamlRequestParemeter request) throws Exception;
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/YamlParseServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/YamlParseServiceConsumer.java
index b62bd166..2b5ee9aa 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/YamlParseServiceConsumer.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/YamlParseServiceConsumer.java
@@ -1,52 +1,52 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.parser.yaml;
-
-import com.google.gson.Gson;
-
-import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
-
-import org.glassfish.jersey.client.ClientConfig;
-import org.openo.commontosca.catalog.common.MsbUtil;
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-import org.openo.commontosca.catalog.model.parser.yaml.entity.ParseYamlRequestParemeter;
-import org.openo.commontosca.catalog.model.parser.yaml.entity.ParseYamlResult;
-
-
-public class YamlParseServiceConsumer {
- /**
- * get service template by template id from container service.
- *
- * @param request parse yaml request
- * @return parase yaml result
- * @throws CatalogResourceException e
- */
- public static ParseYamlResult getServiceTemplates(final ParseYamlRequestParemeter request)
- throws CatalogResourceException {
- try {
- ClientConfig config = new ClientConfig();
- IYamlParseRest yamlParseProxy =
- ConsumerFactory.createConsumer(MsbUtil.getYamlParseBaseUrl(), config,
- IYamlParseRest.class);
- String jsonStr = yamlParseProxy.parse(request);
- return new Gson().fromJson(jsonStr, ParseYamlResult.class);
- } catch (Exception e1) {
- throw new CatalogResourceException("Call parser api failed.", e1);
- }
-
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.parser.yaml;
+
+import com.google.gson.Gson;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.openo.commontosca.catalog.common.MsbUtil;
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+import org.openo.commontosca.catalog.model.parser.yaml.entity.ParseYamlRequestParemeter;
+import org.openo.commontosca.catalog.model.parser.yaml.entity.ParseYamlResult;
+
+
+public class YamlParseServiceConsumer {
+ /**
+ * get service template by template id from container service.
+ *
+ * @param request parse yaml request
+ * @return parase yaml result
+ * @throws CatalogResourceException e
+ */
+ public static ParseYamlResult getServiceTemplates(final ParseYamlRequestParemeter request)
+ throws CatalogResourceException {
+ try {
+ ClientConfig config = new ClientConfig();
+ IYamlParseRest yamlParseProxy =
+ ConsumerFactory.createConsumer(MsbUtil.getYamlParseBaseUrl(), config,
+ IYamlParseRest.class);
+ String jsonStr = yamlParseProxy.parse(request);
+ return new Gson().fromJson(jsonStr, ParseYamlResult.class);
+ } catch (Exception e1) {
+ throw new CatalogResourceException("Call parser api failed.", e1);
+ }
+
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/EnumYamlServiceTemplateInfo.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/EnumYamlServiceTemplateInfo.java
index ba31eee6..54540bf0 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/EnumYamlServiceTemplateInfo.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/EnumYamlServiceTemplateInfo.java
@@ -1,41 +1,41 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.parser.yaml.entity;
-
-
-public enum EnumYamlServiceTemplateInfo {
- ID {
- @Override
- public String getName() {
- return "id";
- }
- },
- VERSION {
- @Override
- public String getName() {
- return "version";
- }
- },
- PROVIDER {
- @Override
- public String getName() {
- return "vendor";
- }
- };
-
- public abstract String getName();
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.parser.yaml.entity;
+
+
+public enum EnumYamlServiceTemplateInfo {
+ ID {
+ @Override
+ public String getName() {
+ return "id";
+ }
+ },
+ VERSION {
+ @Override
+ public String getName() {
+ return "version";
+ }
+ },
+ PROVIDER {
+ @Override
+ public String getName() {
+ return "vendor";
+ }
+ };
+
+ public abstract String getName();
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlRequestParemeter.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlRequestParemeter.java
index 0ba640ac..8bfb1650 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlRequestParemeter.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlRequestParemeter.java
@@ -1,66 +1,66 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.parser.yaml.entity;
-
-import java.util.List;
-
-public class ParseYamlRequestParemeter {
- private String path = "E:\\NFVO\\130. yaml2xml\\0. tosca-parser\\sample\\ag-vnfd-floatingIp.zip";
-
- private List<Extension> extensionList;
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- public List<Extension> getExtensionList() {
- return extensionList;
- }
-
- public void setExtensionList(List<Extension> extensionList) {
- this.extensionList = extensionList;
- }
-
- public Extension createExtension() {
- return new Extension();
- }
-
- public class Extension {
- private String name;
- private String value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.parser.yaml.entity;
+
+import java.util.List;
+
+public class ParseYamlRequestParemeter {
+ private String path = "E:\\NFVO\\130. yaml2xml\\0. tosca-parser\\sample\\ag-vnfd-floatingIp.zip";
+
+ private List<Extension> extensionList;
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public List<Extension> getExtensionList() {
+ return extensionList;
+ }
+
+ public void setExtensionList(List<Extension> extensionList) {
+ this.extensionList = extensionList;
+ }
+
+ public Extension createExtension() {
+ return new Extension();
+ }
+
+ public class Extension {
+ private String name;
+ private String value;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlResult.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlResult.java
index e64a6abb..61014a1f 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlResult.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/entity/ParseYamlResult.java
@@ -1,890 +1,890 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.parser.yaml.entity;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.annotations.SerializedName;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-
-public class ParseYamlResult {
- private String toscaDefinitionsVersion;
- private String description;
- private JsonObject nodeTypes;
- private JsonObject capabilityTypes;
- private JsonObject relationshipTypes;
- private JsonObject policyTypes;
- private TopologyTemplate topologyTemplate;
- private Map<String, String> metadata;
- private JsonObject plans;
-
-
- public String getToscaDefinitionsVersion() {
- return toscaDefinitionsVersion;
- }
-
- public void setToscaDefinitionsVersion(String toscaDefinitionsVersion) {
- this.toscaDefinitionsVersion = toscaDefinitionsVersion;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public JsonObject getNodeTypes() {
- return nodeTypes;
- }
-
- public void setNodeTypes(JsonObject nodeTypes) {
- this.nodeTypes = nodeTypes;
- }
-
- public List<NodeType> getNodeTypeList() {
- return jsonObject2NodeTypes(nodeTypes);
- }
-
- private ArrayList<NodeType> jsonObject2NodeTypes(JsonObject nodeTypes) {
- ArrayList<NodeType> nodeTypeList = new ArrayList<NodeType>();
- Iterator<Entry<String, JsonElement>> iterator = nodeTypes.entrySet().iterator();
- while (iterator.hasNext()) {
- NodeType type = new NodeType();
- Entry<String, JsonElement> next = iterator.next();
- type.setType(next.getKey());
- type.setValue(new Gson().fromJson(next.getValue(), NodeType.NodeTypeValue.class));
- nodeTypeList.add(type);
- }
- return nodeTypeList;
- }
-
- public JsonObject getCapabilityTypes() {
- return capabilityTypes;
- }
-
- public void setCapabilityTypes(JsonObject capabilityTypes) {
- this.capabilityTypes = capabilityTypes;
- }
-
- public JsonObject getRelationshipTypes() {
- return relationshipTypes;
- }
-
- public void setRelationshipTypes(JsonObject relationshipTypes) {
- this.relationshipTypes = relationshipTypes;
- }
-
- public List<RelationshipType> getRelationshipTypeList() {
- return jsonObject2RelationshipTypes(relationshipTypes);
- }
-
- private ArrayList<RelationshipType> jsonObject2RelationshipTypes(JsonObject relationshipTypes) {
- ArrayList<RelationshipType> relationshipTypeList = new ArrayList<RelationshipType>();
- Iterator<Entry<String, JsonElement>> iterator = relationshipTypes.entrySet().iterator();
- while (iterator.hasNext()) {
- RelationshipType type = new RelationshipType();
- Entry<String, JsonElement> next = iterator.next();
- type.setType(next.getKey());
- type.setValue(new Gson().fromJson(next.getValue(), RelationshipType.RelationshipValue.class));
- relationshipTypeList.add(type);
- }
- return relationshipTypeList;
- }
-
- public JsonObject getPolicyTypes() {
- return policyTypes;
- }
-
- public void setPolicyTypes(JsonObject policyTypes) {
- this.policyTypes = policyTypes;
- }
-
- public TopologyTemplate getTopologyTemplate() {
- return topologyTemplate;
- }
-
- public void setTopologyTemplate(TopologyTemplate topologyTemplate) {
- this.topologyTemplate = topologyTemplate;
- }
-
- public Map<String, String> getMetadata() {
- return metadata;
- }
-
- public void setMetadata(Map<String, String> metadata) {
- this.metadata = metadata;
- }
-
- public JsonObject getPlans() {
- return plans;
- }
-
- public void setPlans(JsonObject plans) {
- this.plans = plans;
- }
-
- public List<Plan> getPlanList() {
- return jsonObject2PlanList(this.plans);
- }
-
- private List<Plan> jsonObject2PlanList(JsonObject plans) {
- if (plans == null) {
- return new ArrayList<>();
- }
- List<Plan> retList = new ArrayList<>();
- Iterator<Entry<String, JsonElement>> iterator = plans.entrySet().iterator();
- while (iterator.hasNext()) {
- Plan ret = new Plan();
- Entry<String, JsonElement> next = iterator.next();
- ret.setName(next.getKey());
- ret.setValue(new Gson().fromJson(next.getValue(), Plan.PlanValue.class));
- retList.add(ret);
- }
- return retList;
- }
-
- public class TopologyTemplate {
- private String description;
- private List<Input> inputs;
- private List<Output> outputs;
- private List<NodeTemplate> nodeTemplates;
- private SubstitutionMapping substitutionMappings;
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public List<Input> getInputs() {
- return inputs;
- }
-
- public void setInputs(List<Input> inputs) {
- this.inputs = inputs;
- }
-
- public List<Output> getOutputs() {
- return outputs;
- }
-
- public void setOutputs(List<Output> outputs) {
- this.outputs = outputs;
- }
-
- public List<NodeTemplate> getNodeTemplates() {
- return nodeTemplates;
- }
-
- public void setNodeTemplates(List<NodeTemplate> nodeTemplates) {
- this.nodeTemplates = nodeTemplates;
- }
-
- public SubstitutionMapping getSubstitutionMappings() {
- return substitutionMappings;
- }
-
- public void setSubstitutionMappings(SubstitutionMapping substitutionMappings) {
- this.substitutionMappings = substitutionMappings;
- }
-
- public class Input {
- private String name;
- private String type;
- private String description;
- private String defaultValue;
- private boolean required;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getDefault() {
- return defaultValue;
- }
-
- public void setDefault(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- public boolean isRequired() {
- return required;
- }
-
- public void setRequired(boolean required) {
- this.required = required;
- }
- }
-
- public class Output {
- private String name;
- private String description;
- private Object value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Object getValue() {
- return value;
- }
-
- public void setValue(Object value) {
- this.value = value;
- }
- }
-
- public class NodeTemplate {
- private String name;
- private String nodeType;
- private JsonObject properties;
- private JsonObject[] requirements;
- private JsonObject capabilities;
- private List<Relationship> relationships;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getNodeType() {
- return nodeType;
- }
-
- public void setNodeType(String nodeType) {
- this.nodeType = nodeType;
- }
-
- public JsonObject getProperties() {
- return properties;
- }
-
- public void setProperties(JsonObject properties) {
- this.properties = properties;
- }
-
- public Map<String, Object> getPropertyList() {
- return jsonObject2Properties(properties);
- }
-
- private Map<String, Object> jsonObject2Properties(JsonObject properties) {
- Map<String, Object> ret = new HashMap<>();
- Iterator<Entry<String, JsonElement>> iterator = properties.entrySet().iterator();
- while (iterator.hasNext()) {
- Entry<String, JsonElement> next = iterator.next();
- ret.put(next.getKey(), next.getValue().getAsString());
- }
- return ret;
- }
-
- public JsonObject[] getRequirements() {
- return requirements;
- }
-
- public void setRequirements(JsonObject[] requirements) {
- this.requirements = requirements;
- }
-
- public JsonObject getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(JsonObject capabilities) {
- this.capabilities = capabilities;
- }
-
- public List<Relationship> getRelationships() {
- return relationships;
- }
-
- public void setRelationships(List<Relationship> relationships) {
- this.relationships = relationships;
- }
-
- /**
- * get scalable.
- * @return NodeTemplateScalable
- */
- public NodeTemplateScalable getScalable() {
- if (capabilities == null) {
- return null;
- }
- JsonElement scaleableJson = capabilities.get("scalable");
- if (scaleableJson == null || !scaleableJson.isJsonObject()) {
- return null;
- }
- JsonElement propertyJson = scaleableJson.getAsJsonObject().get("properties");
- if (propertyJson == null || !propertyJson.isJsonObject()) {
- return null;
- }
-
- NodeTemplateScalable scalable = new NodeTemplateScalable();
- scalable
- .setMin_instances(propertyJson.getAsJsonObject().get("min_instances").getAsString());
- scalable
- .setMax_instances(propertyJson.getAsJsonObject().get("max_instances").getAsString());
- scalable.setDefault_instances(
- propertyJson.getAsJsonObject().get("default_instances").getAsString());
- return scalable;
- }
-
- public class Relationship {
- private String targetNodeName;
- private String type;
- private String sourceNodeName;
-
- public String getTargetNodeName() {
- return targetNodeName;
- }
-
- public void setTargetNodeName(String targetNodeName) {
- this.targetNodeName = targetNodeName;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getSourceNodeName() {
- return sourceNodeName;
- }
-
- public void setSourceNodeName(String sourceNodeName) {
- this.sourceNodeName = sourceNodeName;
- }
- }
-
- public class NodeTemplateScalable {
- private String minInstances;
- private String maxInstances;
- private String defaultInstances;
-
- public String getMin_instances() {
- return minInstances;
- }
-
- public void setMin_instances(String minInstances) {
- this.minInstances = minInstances;
- }
-
- public String getMax_instances() {
- return maxInstances;
- }
-
- public void setMax_instances(String maxInstances) {
- this.maxInstances = maxInstances;
- }
-
- public String getDefault_instances() {
- return defaultInstances;
- }
-
- public void setDefault_instances(String defaultInstances) {
- this.defaultInstances = defaultInstances;
- }
- }
- }
-
- public class SubstitutionMapping {
- private String nodeType;
- private JsonObject requirements;
- private JsonObject capabilities;
- private JsonObject properties;
-
- public String getNodeType() {
- return nodeType;
- }
-
- public void setNodeType(String nodeType) {
- this.nodeType = nodeType;
- }
-
- public JsonObject getRequirements() {
- return requirements;
- }
-
- public void setRequirements(JsonObject requirements) {
- this.requirements = requirements;
- }
-
- public Map<String, String[]> getRequirementList() {
- return jsonObjects2Requirements(this.requirements);
- }
-
- private Map<String, String[]> jsonObjects2Requirements(JsonObject requirements) {
- Map<String, String[]> ret = new HashMap<String, String[]>();
-
- Iterator<Entry<String, JsonElement>> iterator = requirements.entrySet().iterator();
- while (iterator.hasNext()) {
- Entry<String, JsonElement> next = iterator.next();
- if (next.getValue().isJsonPrimitive() || next.getValue().isJsonObject()) {
- ret.put(next.getKey(), new String[] {next.getValue().getAsString()});
- continue;
- }
-
- if (next.getValue().isJsonArray()) {
- String[] value = parseListValue((JsonArray) next.getValue());
- ret.put(next.getKey(), value);
- }
- }
-
- return ret;
- }
-
- private String[] parseListValue(JsonArray jsonArray) {
- String[] value = new String[jsonArray.size()];
- for (int i = 0, size = jsonArray.size(); i < size; i++) {
- value[i] = jsonArray.get(i).getAsString();
- }
- return value;
- }
-
- public JsonObject getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(JsonObject capabilities) {
- this.capabilities = capabilities;
- }
-
- public Map<String, String[]> getCapabilityList() {
- return jsonObject2Capabilities(this.capabilities);
- }
-
- private Map<String, String[]> jsonObject2Capabilities(JsonObject capabilities) {
- Map<String, String[]> ret = new HashMap<String, String[]>();
-
- Iterator<Entry<String, JsonElement>> iterator = capabilities.entrySet().iterator();
- while (iterator.hasNext()) {
- Entry<String, JsonElement> next = iterator.next();
-
- if (next.getValue().isJsonPrimitive() || next.getValue().isJsonObject()) {
- ret.put(next.getKey(), new String[] {next.getValue().getAsString()});
- continue;
- }
-
- if (next.getValue().isJsonArray()) {
- String[] value = parseListValue((JsonArray) next.getValue());
- ret.put(next.getKey(), value);
- }
- }
-
- return ret;
- }
-
- public JsonObject getProperties() {
- return properties;
- }
-
- public void setProperties(JsonObject properties) {
- this.properties = properties;
- }
-
- public Map<String, Object> getPropertyList() {
- return jsonObject2Properties(properties);
- }
-
- private Map<String, Object> jsonObject2Properties(JsonObject properties) {
- Map<String, Object> ret = new HashMap<>();
- Iterator<Entry<String, JsonElement>> iterator = properties.entrySet().iterator();
- while (iterator.hasNext()) {
- Entry<String, JsonElement> next = iterator.next();
- ret.put(next.getKey(), next.getValue().getAsString());
- }
- return ret;
- }
- }
- }
-
-
- public class RelationshipType {
- private String type;
- private RelationshipValue value;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public RelationshipValue getValue() {
- return value;
- }
-
- public void setValue(RelationshipValue value) {
- this.value = value;
- }
-
- public class RelationshipValue {
- private String derivedFrom;
- private String[] validTargetTypes;
-
- public String getDerivedFrom() {
- return derivedFrom;
- }
-
- public void setDerivedFrom(String derivedFrom) {
- this.derivedFrom = derivedFrom;
- }
-
- public String[] getValid_target_types() {
- return validTargetTypes;
- }
-
- public void setValid_target_types(String[] validTargetTypes) {
- this.validTargetTypes = validTargetTypes;
- }
- }
- }
-
-
- public class NodeType {
- private String type;
- private NodeTypeValue value;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public NodeTypeValue getValue() {
- return value;
- }
-
- public void setValue(NodeTypeValue value) {
- this.value = value;
- }
-
- public class NodeTypeValue {
- private String derivedFrom;
- private JsonObject properties;
- private JsonObject[] requirements;
- private JsonObject capabilities;
-
- public String getDerivedFrom() {
- return derivedFrom;
- }
-
- public void setDerived_from(String derivedFrom) {
- this.derivedFrom = derivedFrom;
- }
-
- public JsonObject getProperties() {
- return properties;
- }
-
- public void setProperties(JsonObject properties) {
- this.properties = properties;
- }
-
- public List<NodeTypeProperty> getPropertyList() {
- return jsonObject2Properties(properties);
- }
-
- private List<NodeTypeProperty> jsonObject2Properties(JsonObject properties) {
- List<NodeTypeProperty> propertieList = new ArrayList<NodeTypeProperty>();
- Iterator<Entry<String, JsonElement>> iterator = properties.entrySet().iterator();
- while (iterator.hasNext()) {
- NodeTypeProperty type = new NodeTypeProperty();
- Entry<String, JsonElement> next = iterator.next();
- type.setKey(next.getKey());
- type.setValue(new Gson().fromJson(next.getValue(), JsonObject.class));
- propertieList.add(type);
- }
- return propertieList;
- }
-
- public class NodeTypeProperty {
- private String key;
- private JsonObject value;
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- /**
- * get default value.
- * @return default value
- */
- public String getDefaultValue() {
- JsonElement defaultValue = value.get("default");
- if (defaultValue == null || defaultValue.isJsonObject()) {
- return "";
- }
-
- return defaultValue.getAsString();
- }
-
- public JsonObject getValue() {
- return value;
- }
-
- public void setValue(JsonObject value) {
- this.value = value;
- }
- }
-
- public JsonObject[] getRequirements() {
- return requirements;
- }
-
- public void setRequirements(JsonObject[] requirements) {
- this.requirements = requirements;
- }
-
- public JsonObject getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(JsonObject capabilities) {
- this.capabilities = capabilities;
- }
- }
- }
-
- public class Plan {
- private String name;
- private PlanValue value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return value.getDescription();
- }
-
- public String getReference() {
- return value.getReference();
- }
-
- public String getPlanLanguage() {
- return value.getPlanLanguage();
- }
-
- public List<PlanValue.PlanInput> getInputList() {
- return value.getInputList();
- }
-
- public PlanValue getValue() {
- return value;
- }
-
- public void setValue(PlanValue value) {
- this.value = value;
- }
-
- public class PlanValue {
- private String description;
- private String reference;
- private String planLanguage;
- private JsonObject inputs;
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getReference() {
- return reference;
- }
-
- public void setReference(String reference) {
- this.reference = reference;
- }
-
- public String getPlanLanguage() {
- return planLanguage;
- }
-
- public void setPlanLanguage(String planLanguage) {
- this.planLanguage = planLanguage;
- }
-
- public JsonObject getInputs() {
- return inputs;
- }
-
- public void setInputs(JsonObject inputs) {
- this.inputs = inputs;
- }
-
- public List<PlanInput> getInputList() {
- return jsonObject2PlanInputList(inputs);
-
- }
-
- private List<PlanInput> jsonObject2PlanInputList(JsonObject inputs) {
- List<PlanInput> retList = new ArrayList<PlanInput>();
- Iterator<Entry<String, JsonElement>> iterator = inputs.entrySet().iterator();
- while (iterator.hasNext()) {
- PlanInput ret = new PlanInput();
- Entry<String, JsonElement> next = iterator.next();
- ret.setName(next.getKey());
- ret.setValue(new Gson().fromJson(next.getValue(), PlanInput.PlanInputValue.class));
- retList.add(ret);
- }
- return retList;
- }
-
- public class PlanInput {
- private String name;
- private PlanInputValue value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return value.getType();
- }
-
- public String getDescription() {
- return value.getDescription();
- }
-
- public String getDefault() {
- return value.getDefaultValue();
- }
-
- public boolean isRequired() {
- return value.isRequired();
- }
-
- public PlanInputValue getValue() {
- return value;
- }
-
- public void setValue(PlanInputValue value) {
- this.value = value;
- }
-
- public class PlanInputValue {
- private String type;
- private String description;
- @SerializedName("default")
- private String defaultValue;
- private boolean required;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getDefaultValue() {
- return defaultValue;
- }
-
- public void setDefaultValue(String defaultValue) {
- this.defaultValue = defaultValue;
- }
-
- public boolean isRequired() {
- return required;
- }
-
- public void setRequired(boolean required) {
- this.required = required;
- }
- }
- }
- }
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.parser.yaml.entity;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+
+public class ParseYamlResult {
+ private String toscaDefinitionsVersion;
+ private String description;
+ private JsonObject nodeTypes;
+ private JsonObject capabilityTypes;
+ private JsonObject relationshipTypes;
+ private JsonObject policyTypes;
+ private TopologyTemplate topologyTemplate;
+ private Map<String, String> metadata;
+ private JsonObject plans;
+
+
+ public String getToscaDefinitionsVersion() {
+ return toscaDefinitionsVersion;
+ }
+
+ public void setToscaDefinitionsVersion(String toscaDefinitionsVersion) {
+ this.toscaDefinitionsVersion = toscaDefinitionsVersion;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public JsonObject getNodeTypes() {
+ return nodeTypes;
+ }
+
+ public void setNodeTypes(JsonObject nodeTypes) {
+ this.nodeTypes = nodeTypes;
+ }
+
+ public List<NodeType> getNodeTypeList() {
+ return jsonObject2NodeTypes(nodeTypes);
+ }
+
+ private ArrayList<NodeType> jsonObject2NodeTypes(JsonObject nodeTypes) {
+ ArrayList<NodeType> nodeTypeList = new ArrayList<NodeType>();
+ Iterator<Entry<String, JsonElement>> iterator = nodeTypes.entrySet().iterator();
+ while (iterator.hasNext()) {
+ NodeType type = new NodeType();
+ Entry<String, JsonElement> next = iterator.next();
+ type.setType(next.getKey());
+ type.setValue(new Gson().fromJson(next.getValue(), NodeType.NodeTypeValue.class));
+ nodeTypeList.add(type);
+ }
+ return nodeTypeList;
+ }
+
+ public JsonObject getCapabilityTypes() {
+ return capabilityTypes;
+ }
+
+ public void setCapabilityTypes(JsonObject capabilityTypes) {
+ this.capabilityTypes = capabilityTypes;
+ }
+
+ public JsonObject getRelationshipTypes() {
+ return relationshipTypes;
+ }
+
+ public void setRelationshipTypes(JsonObject relationshipTypes) {
+ this.relationshipTypes = relationshipTypes;
+ }
+
+ public List<RelationshipType> getRelationshipTypeList() {
+ return jsonObject2RelationshipTypes(relationshipTypes);
+ }
+
+ private ArrayList<RelationshipType> jsonObject2RelationshipTypes(JsonObject relationshipTypes) {
+ ArrayList<RelationshipType> relationshipTypeList = new ArrayList<RelationshipType>();
+ Iterator<Entry<String, JsonElement>> iterator = relationshipTypes.entrySet().iterator();
+ while (iterator.hasNext()) {
+ RelationshipType type = new RelationshipType();
+ Entry<String, JsonElement> next = iterator.next();
+ type.setType(next.getKey());
+ type.setValue(new Gson().fromJson(next.getValue(), RelationshipType.RelationshipValue.class));
+ relationshipTypeList.add(type);
+ }
+ return relationshipTypeList;
+ }
+
+ public JsonObject getPolicyTypes() {
+ return policyTypes;
+ }
+
+ public void setPolicyTypes(JsonObject policyTypes) {
+ this.policyTypes = policyTypes;
+ }
+
+ public TopologyTemplate getTopologyTemplate() {
+ return topologyTemplate;
+ }
+
+ public void setTopologyTemplate(TopologyTemplate topologyTemplate) {
+ this.topologyTemplate = topologyTemplate;
+ }
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ }
+
+ public JsonObject getPlans() {
+ return plans;
+ }
+
+ public void setPlans(JsonObject plans) {
+ this.plans = plans;
+ }
+
+ public List<Plan> getPlanList() {
+ return jsonObject2PlanList(this.plans);
+ }
+
+ private List<Plan> jsonObject2PlanList(JsonObject plans) {
+ if (plans == null) {
+ return new ArrayList<>();
+ }
+ List<Plan> retList = new ArrayList<>();
+ Iterator<Entry<String, JsonElement>> iterator = plans.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Plan ret = new Plan();
+ Entry<String, JsonElement> next = iterator.next();
+ ret.setName(next.getKey());
+ ret.setValue(new Gson().fromJson(next.getValue(), Plan.PlanValue.class));
+ retList.add(ret);
+ }
+ return retList;
+ }
+
+ public class TopologyTemplate {
+ private String description;
+ private List<Input> inputs;
+ private List<Output> outputs;
+ private List<NodeTemplate> nodeTemplates;
+ private SubstitutionMapping substitutionMappings;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public List<Input> getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(List<Input> inputs) {
+ this.inputs = inputs;
+ }
+
+ public List<Output> getOutputs() {
+ return outputs;
+ }
+
+ public void setOutputs(List<Output> outputs) {
+ this.outputs = outputs;
+ }
+
+ public List<NodeTemplate> getNodeTemplates() {
+ return nodeTemplates;
+ }
+
+ public void setNodeTemplates(List<NodeTemplate> nodeTemplates) {
+ this.nodeTemplates = nodeTemplates;
+ }
+
+ public SubstitutionMapping getSubstitutionMappings() {
+ return substitutionMappings;
+ }
+
+ public void setSubstitutionMappings(SubstitutionMapping substitutionMappings) {
+ this.substitutionMappings = substitutionMappings;
+ }
+
+ public class Input {
+ private String name;
+ private String type;
+ private String description;
+ private String defaultValue;
+ private boolean required;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDefault() {
+ return defaultValue;
+ }
+
+ public void setDefault(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public boolean isRequired() {
+ return required;
+ }
+
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+ }
+
+ public class Output {
+ private String name;
+ private String description;
+ private Object value;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+ }
+
+ public class NodeTemplate {
+ private String name;
+ private String nodeType;
+ private JsonObject properties;
+ private JsonObject[] requirements;
+ private JsonObject capabilities;
+ private List<Relationship> relationships;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNodeType() {
+ return nodeType;
+ }
+
+ public void setNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ public JsonObject getProperties() {
+ return properties;
+ }
+
+ public void setProperties(JsonObject properties) {
+ this.properties = properties;
+ }
+
+ public Map<String, Object> getPropertyList() {
+ return jsonObject2Properties(properties);
+ }
+
+ private Map<String, Object> jsonObject2Properties(JsonObject properties) {
+ Map<String, Object> ret = new HashMap<>();
+ Iterator<Entry<String, JsonElement>> iterator = properties.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry<String, JsonElement> next = iterator.next();
+ ret.put(next.getKey(), next.getValue().getAsString());
+ }
+ return ret;
+ }
+
+ public JsonObject[] getRequirements() {
+ return requirements;
+ }
+
+ public void setRequirements(JsonObject[] requirements) {
+ this.requirements = requirements;
+ }
+
+ public JsonObject getCapabilities() {
+ return capabilities;
+ }
+
+ public void setCapabilities(JsonObject capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ public List<Relationship> getRelationships() {
+ return relationships;
+ }
+
+ public void setRelationships(List<Relationship> relationships) {
+ this.relationships = relationships;
+ }
+
+ /**
+ * get scalable.
+ * @return NodeTemplateScalable
+ */
+ public NodeTemplateScalable getScalable() {
+ if (capabilities == null) {
+ return null;
+ }
+ JsonElement scaleableJson = capabilities.get("scalable");
+ if (scaleableJson == null || !scaleableJson.isJsonObject()) {
+ return null;
+ }
+ JsonElement propertyJson = scaleableJson.getAsJsonObject().get("properties");
+ if (propertyJson == null || !propertyJson.isJsonObject()) {
+ return null;
+ }
+
+ NodeTemplateScalable scalable = new NodeTemplateScalable();
+ scalable
+ .setMin_instances(propertyJson.getAsJsonObject().get("min_instances").getAsString());
+ scalable
+ .setMax_instances(propertyJson.getAsJsonObject().get("max_instances").getAsString());
+ scalable.setDefault_instances(
+ propertyJson.getAsJsonObject().get("default_instances").getAsString());
+ return scalable;
+ }
+
+ public class Relationship {
+ private String targetNodeName;
+ private String type;
+ private String sourceNodeName;
+
+ public String getTargetNodeName() {
+ return targetNodeName;
+ }
+
+ public void setTargetNodeName(String targetNodeName) {
+ this.targetNodeName = targetNodeName;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getSourceNodeName() {
+ return sourceNodeName;
+ }
+
+ public void setSourceNodeName(String sourceNodeName) {
+ this.sourceNodeName = sourceNodeName;
+ }
+ }
+
+ public class NodeTemplateScalable {
+ private String minInstances;
+ private String maxInstances;
+ private String defaultInstances;
+
+ public String getMin_instances() {
+ return minInstances;
+ }
+
+ public void setMin_instances(String minInstances) {
+ this.minInstances = minInstances;
+ }
+
+ public String getMax_instances() {
+ return maxInstances;
+ }
+
+ public void setMax_instances(String maxInstances) {
+ this.maxInstances = maxInstances;
+ }
+
+ public String getDefault_instances() {
+ return defaultInstances;
+ }
+
+ public void setDefault_instances(String defaultInstances) {
+ this.defaultInstances = defaultInstances;
+ }
+ }
+ }
+
+ public class SubstitutionMapping {
+ private String nodeType;
+ private JsonObject requirements;
+ private JsonObject capabilities;
+ private JsonObject properties;
+
+ public String getNodeType() {
+ return nodeType;
+ }
+
+ public void setNodeType(String nodeType) {
+ this.nodeType = nodeType;
+ }
+
+ public JsonObject getRequirements() {
+ return requirements;
+ }
+
+ public void setRequirements(JsonObject requirements) {
+ this.requirements = requirements;
+ }
+
+ public Map<String, String[]> getRequirementList() {
+ return jsonObjects2Requirements(this.requirements);
+ }
+
+ private Map<String, String[]> jsonObjects2Requirements(JsonObject requirements) {
+ Map<String, String[]> ret = new HashMap<String, String[]>();
+
+ Iterator<Entry<String, JsonElement>> iterator = requirements.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry<String, JsonElement> next = iterator.next();
+ if (next.getValue().isJsonPrimitive() || next.getValue().isJsonObject()) {
+ ret.put(next.getKey(), new String[] {next.getValue().getAsString()});
+ continue;
+ }
+
+ if (next.getValue().isJsonArray()) {
+ String[] value = parseListValue((JsonArray) next.getValue());
+ ret.put(next.getKey(), value);
+ }
+ }
+
+ return ret;
+ }
+
+ private String[] parseListValue(JsonArray jsonArray) {
+ String[] value = new String[jsonArray.size()];
+ for (int i = 0, size = jsonArray.size(); i < size; i++) {
+ value[i] = jsonArray.get(i).getAsString();
+ }
+ return value;
+ }
+
+ public JsonObject getCapabilities() {
+ return capabilities;
+ }
+
+ public void setCapabilities(JsonObject capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ public Map<String, String[]> getCapabilityList() {
+ return jsonObject2Capabilities(this.capabilities);
+ }
+
+ private Map<String, String[]> jsonObject2Capabilities(JsonObject capabilities) {
+ Map<String, String[]> ret = new HashMap<String, String[]>();
+
+ Iterator<Entry<String, JsonElement>> iterator = capabilities.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry<String, JsonElement> next = iterator.next();
+
+ if (next.getValue().isJsonPrimitive() || next.getValue().isJsonObject()) {
+ ret.put(next.getKey(), new String[] {next.getValue().getAsString()});
+ continue;
+ }
+
+ if (next.getValue().isJsonArray()) {
+ String[] value = parseListValue((JsonArray) next.getValue());
+ ret.put(next.getKey(), value);
+ }
+ }
+
+ return ret;
+ }
+
+ public JsonObject getProperties() {
+ return properties;
+ }
+
+ public void setProperties(JsonObject properties) {
+ this.properties = properties;
+ }
+
+ public Map<String, Object> getPropertyList() {
+ return jsonObject2Properties(properties);
+ }
+
+ private Map<String, Object> jsonObject2Properties(JsonObject properties) {
+ Map<String, Object> ret = new HashMap<>();
+ Iterator<Entry<String, JsonElement>> iterator = properties.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Entry<String, JsonElement> next = iterator.next();
+ ret.put(next.getKey(), next.getValue().getAsString());
+ }
+ return ret;
+ }
+ }
+ }
+
+
+ public class RelationshipType {
+ private String type;
+ private RelationshipValue value;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public RelationshipValue getValue() {
+ return value;
+ }
+
+ public void setValue(RelationshipValue value) {
+ this.value = value;
+ }
+
+ public class RelationshipValue {
+ private String derivedFrom;
+ private String[] validTargetTypes;
+
+ public String getDerivedFrom() {
+ return derivedFrom;
+ }
+
+ public void setDerivedFrom(String derivedFrom) {
+ this.derivedFrom = derivedFrom;
+ }
+
+ public String[] getValid_target_types() {
+ return validTargetTypes;
+ }
+
+ public void setValid_target_types(String[] validTargetTypes) {
+ this.validTargetTypes = validTargetTypes;
+ }
+ }
+ }
+
+
+ public class NodeType {
+ private String type;
+ private NodeTypeValue value;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public NodeTypeValue getValue() {
+ return value;
+ }
+
+ public void setValue(NodeTypeValue value) {
+ this.value = value;
+ }
+
+ public class NodeTypeValue {
+ private String derivedFrom;
+ private JsonObject properties;
+ private JsonObject[] requirements;
+ private JsonObject capabilities;
+
+ public String getDerivedFrom() {
+ return derivedFrom;
+ }
+
+ public void setDerived_from(String derivedFrom) {
+ this.derivedFrom = derivedFrom;
+ }
+
+ public JsonObject getProperties() {
+ return properties;
+ }
+
+ public void setProperties(JsonObject properties) {
+ this.properties = properties;
+ }
+
+ public List<NodeTypeProperty> getPropertyList() {
+ return jsonObject2Properties(properties);
+ }
+
+ private List<NodeTypeProperty> jsonObject2Properties(JsonObject properties) {
+ List<NodeTypeProperty> propertieList = new ArrayList<NodeTypeProperty>();
+ Iterator<Entry<String, JsonElement>> iterator = properties.entrySet().iterator();
+ while (iterator.hasNext()) {
+ NodeTypeProperty type = new NodeTypeProperty();
+ Entry<String, JsonElement> next = iterator.next();
+ type.setKey(next.getKey());
+ type.setValue(new Gson().fromJson(next.getValue(), JsonObject.class));
+ propertieList.add(type);
+ }
+ return propertieList;
+ }
+
+ public class NodeTypeProperty {
+ private String key;
+ private JsonObject value;
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ /**
+ * get default value.
+ * @return default value
+ */
+ public String getDefaultValue() {
+ JsonElement defaultValue = value.get("default");
+ if (defaultValue == null || defaultValue.isJsonObject()) {
+ return "";
+ }
+
+ return defaultValue.getAsString();
+ }
+
+ public JsonObject getValue() {
+ return value;
+ }
+
+ public void setValue(JsonObject value) {
+ this.value = value;
+ }
+ }
+
+ public JsonObject[] getRequirements() {
+ return requirements;
+ }
+
+ public void setRequirements(JsonObject[] requirements) {
+ this.requirements = requirements;
+ }
+
+ public JsonObject getCapabilities() {
+ return capabilities;
+ }
+
+ public void setCapabilities(JsonObject capabilities) {
+ this.capabilities = capabilities;
+ }
+ }
+ }
+
+ public class Plan {
+ private String name;
+ private PlanValue value;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return value.getDescription();
+ }
+
+ public String getReference() {
+ return value.getReference();
+ }
+
+ public String getPlanLanguage() {
+ return value.getPlanLanguage();
+ }
+
+ public List<PlanValue.PlanInput> getInputList() {
+ return value.getInputList();
+ }
+
+ public PlanValue getValue() {
+ return value;
+ }
+
+ public void setValue(PlanValue value) {
+ this.value = value;
+ }
+
+ public class PlanValue {
+ private String description;
+ private String reference;
+ private String planLanguage;
+ private JsonObject inputs;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getReference() {
+ return reference;
+ }
+
+ public void setReference(String reference) {
+ this.reference = reference;
+ }
+
+ public String getPlanLanguage() {
+ return planLanguage;
+ }
+
+ public void setPlanLanguage(String planLanguage) {
+ this.planLanguage = planLanguage;
+ }
+
+ public JsonObject getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(JsonObject inputs) {
+ this.inputs = inputs;
+ }
+
+ public List<PlanInput> getInputList() {
+ return jsonObject2PlanInputList(inputs);
+
+ }
+
+ private List<PlanInput> jsonObject2PlanInputList(JsonObject inputs) {
+ List<PlanInput> retList = new ArrayList<PlanInput>();
+ Iterator<Entry<String, JsonElement>> iterator = inputs.entrySet().iterator();
+ while (iterator.hasNext()) {
+ PlanInput ret = new PlanInput();
+ Entry<String, JsonElement> next = iterator.next();
+ ret.setName(next.getKey());
+ ret.setValue(new Gson().fromJson(next.getValue(), PlanInput.PlanInputValue.class));
+ retList.add(ret);
+ }
+ return retList;
+ }
+
+ public class PlanInput {
+ private String name;
+ private PlanInputValue value;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return value.getType();
+ }
+
+ public String getDescription() {
+ return value.getDescription();
+ }
+
+ public String getDefault() {
+ return value.getDefaultValue();
+ }
+
+ public boolean isRequired() {
+ return value.isRequired();
+ }
+
+ public PlanInputValue getValue() {
+ return value;
+ }
+
+ public void setValue(PlanInputValue value) {
+ this.value = value;
+ }
+
+ public class PlanInputValue {
+ private String type;
+ private String description;
+ @SerializedName("default")
+ private String defaultValue;
+ private boolean required;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public boolean isRequired() {
+ return required;
+ }
+
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Iwso2RestService.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Iwso2RestService.java
index 6600c06f..1f970664 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Iwso2RestService.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Iwso2RestService.java
@@ -1,57 +1,57 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.plan.wso2;
-
-import org.openo.commontosca.catalog.model.plan.wso2.entity.DeletePackageResponse;
-import org.openo.commontosca.catalog.model.plan.wso2.entity.StartProcessRequest;
-import org.openo.commontosca.catalog.model.plan.wso2.entity.StartProcessResponse;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-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.MediaType;
-
-@Path("/openoapi/wso2bpel/v1")
-public interface Iwso2RestService {
- // /**
- // * @param request
- // * @return
- // * @throws Exception
- // */
- // @Path("/package")
- // @POST
- // @Consumes(MediaType.APPLICATION_JSON)
- // @Produces(MediaType.APPLICATION_JSON)
- // DeployPackageResponse deployPackage(FormDataMultiPart request) throws Exception;
-
- @Path("/package/{packageName}")
- @DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- DeletePackageResponse deletePackage(
- @PathParam("packageName") String packageName) throws Exception;
-
- @Path("process/instance")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- StartProcessResponse startProcess(StartProcessRequest request)
- throws Exception;
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.plan.wso2;
+
+import org.openo.commontosca.catalog.model.plan.wso2.entity.DeletePackageResponse;
+import org.openo.commontosca.catalog.model.plan.wso2.entity.StartProcessRequest;
+import org.openo.commontosca.catalog.model.plan.wso2.entity.StartProcessResponse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+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.MediaType;
+
+@Path("/openoapi/wso2bpel/v1")
+public interface Iwso2RestService {
+ // /**
+ // * @param request
+ // * @return
+ // * @throws Exception
+ // */
+ // @Path("/package")
+ // @POST
+ // @Consumes(MediaType.APPLICATION_JSON)
+ // @Produces(MediaType.APPLICATION_JSON)
+ // DeployPackageResponse deployPackage(FormDataMultiPart request) throws Exception;
+
+ @Path("/package/{packageName}")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ DeletePackageResponse deletePackage(
+ @PathParam("packageName") String packageName) throws Exception;
+
+ @Path("process/instance")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ StartProcessResponse startProcess(StartProcessRequest request)
+ throws Exception;
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java
index 48b866e0..6cdda700 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java
@@ -1,189 +1,189 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.plan.wso2;
-
-import com.google.gson.Gson;
-
-import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
-import org.glassfish.jersey.client.ClientConfig;
-import org.openo.commontosca.catalog.common.Config;
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-import org.openo.commontosca.catalog.model.plan.wso2.entity.DeletePackageResponse;
-import org.openo.commontosca.catalog.model.plan.wso2.entity.DeployPackageResponse;
-import org.openo.commontosca.catalog.model.plan.wso2.entity.StartProcessRequest;
-import org.openo.commontosca.catalog.model.plan.wso2.entity.StartProcessResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
-
-
-
-public class Wso2ServiceConsumer {
- public static final String WSO2_APP_URL = "/openoapi/wso2bpel/v1/package";
- private static final Logger LOGGER = LoggerFactory.getLogger(Wso2ServiceConsumer.class);
-
- /**
- * deploy package.
- * @param zipFileLocation zip file location
- * @param planFilePath plan file path
- * @return DeployPackageResponse
- * @throws CatalogResourceException e1
- */
- public static DeployPackageResponse deployPackage(String zipFileLocation, String planFilePath)
- throws CatalogResourceException {
- InputStream ins = null;
- try {
- ins = getInputStream(zipFileLocation, planFilePath);
- RestResponse res = RestfulClient.post(Config.getConfigration().getWso2HostIp(),
- Integer.parseInt(Config.getConfigration().getWso2HostPort()), WSO2_APP_URL,
- buildRequest(ins, planFilePath));
-
- if (res.getStatusCode() == null || res.getResult() == null) {
- throw new CatalogResourceException(
- "Deploy Package return null. Response = " + res);
- }
-
- if (200 == res.getStatusCode() || 201 == res.getStatusCode()) {
- DeployPackageResponse response =
- new Gson().fromJson(res.getResult(), DeployPackageResponse.class);
- if (response.isSuccess()) {
- return response;
- }
- }
-
- throw new CatalogResourceException(
- "Deploy Package return fail. Response = " + res.getResult());
- } catch (FileNotFoundException e1) {
- throw new CatalogResourceException("Deploy Package failed.", e1);
- } finally {
- if (ins != null) {
- try {
- ins.close();
- } catch (IOException e1) {
- LOGGER.error("inputStream close failed !");
- }
- }
- }
- }
-
- private static HttpEntity buildRequest(InputStream inputStream, String filePath)
- throws FileNotFoundException {
- MultipartEntityBuilder builder = MultipartEntityBuilder.create();
- builder.seContentType(ContentType.MULTIPART_FORM_DATA);
- builder.addBinaryBody("file", inputStream, ContentType.APPLICATION_OCTET_STREAM,
- new File(filePath).getName());
- return builder.build();
- }
-
- @SuppressWarnings("resource")
- private static InputStream getInputStream(String zipFileLocation, String planFilePath)
- throws CatalogResourceException {
- ZipInputStream zin = null;
- try {
- InputStream in = new BufferedInputStream(new FileInputStream(zipFileLocation));
- zin = new ZipInputStream(in);
- ZipEntry ze;
- while ((ze = zin.getNextEntry()) != null) {
- if (planFilePath.equals(ze.getName())) {
- ZipFile zf = new ZipFile(zipFileLocation);
- return zf.getInputStream(ze);
- }
- }
- } catch (IOException e1) {
- throw new CatalogResourceException("Get InputStream failed. planFilePath = " + planFilePath,
- e1);
- } finally {
- closeStream(zin);
- }
-
- throw new CatalogResourceException("Get InputStream failed. planFilePath = " + planFilePath);
- }
-
- private static void closeStream(ZipInputStream zin) {
-
- if (zin != null) {
- try {
- zin.closeEntry();
- } catch (IOException e1) {
- LOGGER.error("zip inputStream close failed !");
- }
- }
- }
-
- /**
- * delet package.
- * @param packageName package to delete according packageName
- * @return DeletePackageResponse
- * @throws CatalogResourceException e1
- */
- public static DeletePackageResponse deletePackage(String packageName)
- throws CatalogResourceException {
- try {
- ClientConfig config = new ClientConfig();
- Iwso2RestService wso2Proxy = ConsumerFactory.createConsumer(
- Config.getConfigration().getWso2BaseUrl(), config, Iwso2RestService.class);
- DeletePackageResponse response = wso2Proxy.deletePackage(packageName);
- if (response.isSuccess()) {
- return response;
- }
- throw new CatalogResourceException(response.getException());
- } catch (Exception e1) {
- throw new CatalogResourceException(
- "Call Delete Package api failed. packageName = " + packageName, e1);
- }
- }
-
-
- /**
- * start process.
- * @param processId process id
- * @param params params
- * @return StartProcessResponse
- * @throws CatalogResourceException e1
- */
- public static StartProcessResponse startProcess(String processId, Map<String, Object> params)
- throws CatalogResourceException {
- try {
- ClientConfig config = new ClientConfig();
- Iwso2RestService wso2Proxy = ConsumerFactory.createConsumer(
- Config.getConfigration().getWso2BaseUrl(), config, Iwso2RestService.class);
- StartProcessResponse response =
- wso2Proxy.startProcess(new StartProcessRequest(processId, params));
- if (response.isSuccess()) {
- return response;
- }
- throw new CatalogResourceException(response.getException());
- } catch (Exception e1) {
- throw new CatalogResourceException("Call Start Process api failed.", e1);
- }
- }
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.plan.wso2;
+
+import com.google.gson.Gson;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.glassfish.jersey.client.ClientConfig;
+import org.openo.commontosca.catalog.common.Config;
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+import org.openo.commontosca.catalog.model.plan.wso2.entity.DeletePackageResponse;
+import org.openo.commontosca.catalog.model.plan.wso2.entity.DeployPackageResponse;
+import org.openo.commontosca.catalog.model.plan.wso2.entity.StartProcessRequest;
+import org.openo.commontosca.catalog.model.plan.wso2.entity.StartProcessResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
+
+
+
+public class Wso2ServiceConsumer {
+ public static final String WSO2_APP_URL = "/openoapi/wso2bpel/v1/package";
+ private static final Logger LOGGER = LoggerFactory.getLogger(Wso2ServiceConsumer.class);
+
+ /**
+ * deploy package.
+ * @param zipFileLocation zip file location
+ * @param planFilePath plan file path
+ * @return DeployPackageResponse
+ * @throws CatalogResourceException e1
+ */
+ public static DeployPackageResponse deployPackage(String zipFileLocation, String planFilePath)
+ throws CatalogResourceException {
+ InputStream ins = null;
+ try {
+ ins = getInputStream(zipFileLocation, planFilePath);
+ RestResponse res = RestfulClient.post(Config.getConfigration().getWso2HostIp(),
+ Integer.parseInt(Config.getConfigration().getWso2HostPort()), WSO2_APP_URL,
+ buildRequest(ins, planFilePath));
+
+ if (res.getStatusCode() == null || res.getResult() == null) {
+ throw new CatalogResourceException(
+ "Deploy Package return null. Response = " + res);
+ }
+
+ if (200 == res.getStatusCode() || 201 == res.getStatusCode()) {
+ DeployPackageResponse response =
+ new Gson().fromJson(res.getResult(), DeployPackageResponse.class);
+ if (response.isSuccess()) {
+ return response;
+ }
+ }
+
+ throw new CatalogResourceException(
+ "Deploy Package return fail. Response = " + res.getResult());
+ } catch (FileNotFoundException e1) {
+ throw new CatalogResourceException("Deploy Package failed.", e1);
+ } finally {
+ if (ins != null) {
+ try {
+ ins.close();
+ } catch (IOException e1) {
+ LOGGER.error("inputStream close failed !");
+ }
+ }
+ }
+ }
+
+ private static HttpEntity buildRequest(InputStream inputStream, String filePath)
+ throws FileNotFoundException {
+ MultipartEntityBuilder builder = MultipartEntityBuilder.create();
+ builder.seContentType(ContentType.MULTIPART_FORM_DATA);
+ builder.addBinaryBody("file", inputStream, ContentType.APPLICATION_OCTET_STREAM,
+ new File(filePath).getName());
+ return builder.build();
+ }
+
+ @SuppressWarnings("resource")
+ private static InputStream getInputStream(String zipFileLocation, String planFilePath)
+ throws CatalogResourceException {
+ ZipInputStream zin = null;
+ try {
+ InputStream in = new BufferedInputStream(new FileInputStream(zipFileLocation));
+ zin = new ZipInputStream(in);
+ ZipEntry ze;
+ while ((ze = zin.getNextEntry()) != null) {
+ if (planFilePath.equals(ze.getName())) {
+ ZipFile zf = new ZipFile(zipFileLocation);
+ return zf.getInputStream(ze);
+ }
+ }
+ } catch (IOException e1) {
+ throw new CatalogResourceException("Get InputStream failed. planFilePath = " + planFilePath,
+ e1);
+ } finally {
+ closeStream(zin);
+ }
+
+ throw new CatalogResourceException("Get InputStream failed. planFilePath = " + planFilePath);
+ }
+
+ private static void closeStream(ZipInputStream zin) {
+
+ if (zin != null) {
+ try {
+ zin.closeEntry();
+ } catch (IOException e1) {
+ LOGGER.error("zip inputStream close failed !");
+ }
+ }
+ }
+
+ /**
+ * delet package.
+ * @param packageName package to delete according packageName
+ * @return DeletePackageResponse
+ * @throws CatalogResourceException e1
+ */
+ public static DeletePackageResponse deletePackage(String packageName)
+ throws CatalogResourceException {
+ try {
+ ClientConfig config = new ClientConfig();
+ Iwso2RestService wso2Proxy = ConsumerFactory.createConsumer(
+ Config.getConfigration().getWso2BaseUrl(), config, Iwso2RestService.class);
+ DeletePackageResponse response = wso2Proxy.deletePackage(packageName);
+ if (response.isSuccess()) {
+ return response;
+ }
+ throw new CatalogResourceException(response.getException());
+ } catch (Exception e1) {
+ throw new CatalogResourceException(
+ "Call Delete Package api failed. packageName = " + packageName, e1);
+ }
+ }
+
+
+ /**
+ * start process.
+ * @param processId process id
+ * @param params params
+ * @return StartProcessResponse
+ * @throws CatalogResourceException e1
+ */
+ public static StartProcessResponse startProcess(String processId, Map<String, Object> params)
+ throws CatalogResourceException {
+ try {
+ ClientConfig config = new ClientConfig();
+ Iwso2RestService wso2Proxy = ConsumerFactory.createConsumer(
+ Config.getConfigration().getWso2BaseUrl(), config, Iwso2RestService.class);
+ StartProcessResponse response =
+ wso2Proxy.startProcess(new StartProcessRequest(processId, params));
+ if (response.isSuccess()) {
+ return response;
+ }
+ throw new CatalogResourceException(response.getException());
+ } catch (Exception e1) {
+ throw new CatalogResourceException("Call Start Process api failed.", e1);
+ }
+ }
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java
index 448c6a86..c0616e72 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/wrapper/ServiceTemplateWrapper.java
@@ -1,362 +1,362 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.model.wrapper;
-
-import org.openo.commontosca.catalog.common.ToolUtil;
-import org.openo.commontosca.catalog.db.entity.NodeTemplateData;
-import org.openo.commontosca.catalog.db.entity.PackageData;
-import org.openo.commontosca.catalog.db.entity.ServiceTemplateData;
-import org.openo.commontosca.catalog.db.entity.ServiceTemplateMappingData;
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-import org.openo.commontosca.catalog.db.resource.TemplateManager;
-import org.openo.commontosca.catalog.model.common.TemplateDataHelper;
-import org.openo.commontosca.catalog.model.entity.InputParameter;
-import org.openo.commontosca.catalog.model.entity.NfvTemplate;
-import org.openo.commontosca.catalog.model.entity.NodeTemplate;
-import org.openo.commontosca.catalog.model.entity.Parameters;
-import org.openo.commontosca.catalog.model.entity.QueryRawDataCondition;
-import org.openo.commontosca.catalog.model.entity.ServiceTemplate;
-import org.openo.commontosca.catalog.model.entity.ServiceTemplateOperation;
-import org.openo.commontosca.catalog.model.entity.ServiceTemplateRawData;
-import org.openo.commontosca.catalog.model.entity.SubstitutionMapping;
-import org.openo.commontosca.catalog.resources.CatalogBadRequestException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-
-public class ServiceTemplateWrapper {
- private static ServiceTemplateWrapper instance;
- private static final Logger logger = LoggerFactory.getLogger(ServiceTemplateWrapper.class);
-
- /**
- * get service template wrapper instance.
- * @return ServiceTemplateWrapper instance
- */
- public static ServiceTemplateWrapper getInstance() {
- if (instance == null) {
- instance = new ServiceTemplateWrapper();
- }
- return instance;
- }
-
- /**
- * get service template by id.
- * @param serviceTemplateId service template id
- * @return service template
- * @throws CatalogResourceException e1
- */
- public ServiceTemplate getServiceTemplateById(String serviceTemplateId)
- throws CatalogResourceException {
- logger.info("getServiceTemplateById. serviceTemplateId = " + serviceTemplateId);
-
- List<ServiceTemplateData> stdList =
- TemplateManager.getInstance().queryServiceTemplateById(serviceTemplateId);
- if (stdList == null || stdList.isEmpty()) {
- throw new CatalogResourceException("Can't find this servcie template");
- }
-
- return TemplateDataHelper.convert2ServiceTemplate(stdList.get(0));
- }
-
-
- /**
- * get service templates.
- * @param status usage status
- * @param deletionPending package's deletionPending
- * @return service template list
- * @throws CatalogResourceException e
- */
- public ServiceTemplate[] getServiceTemplates(String status, boolean deletionPending)
- throws CatalogResourceException {
- PackageData pd = new PackageData();
- pd.setUsageState(status);
- pd.setDeletionPending(String.valueOf(deletionPending));
-
- List<ServiceTemplateData> stdList =
- TemplateManager.getInstance().queryServiceTemplateByCsarPackageInfo(pd);
-
- return TemplateDataHelper.convert2ServiceTemplates(stdList);
- }
-
-
- /**
- * get nesting service template.
- * @param nodeTypeIds nodeType id list
- * @return service template list
- * @throws CatalogResourceException e
- */
- public ServiceTemplate[] getNestingServiceTemplate(String[] nodeTypeIds)
- throws CatalogResourceException {
- ServiceTemplate[] sts = new ServiceTemplate[nodeTypeIds.length];
- for (int i = 0; i < nodeTypeIds.length; i++) {
- SubstitutionMapping stm = getSubstitutionMappingsByNodeTypeId(nodeTypeIds[i]);
- if (stm == null) {
- sts[i] = null;
- } else {
- sts[i] = getServiceTemplateById(stm.getServiceTemplateId());
- }
- }
-
- return sts;
- }
-
- /**
- * get substitution mappings by nodeTpe id.
- * @param nodeTypeId nodeType id
- * @return SubstitutionMapping
- * @throws CatalogResourceException e
- */
- private SubstitutionMapping getSubstitutionMappingsByNodeTypeId(String nodeTypeId)
- throws CatalogResourceException {
- List<ServiceTemplateMappingData> stmDataList =
- TemplateManager.getInstance().queryServiceTemplateMapping(nodeTypeId, null);
- if (stmDataList == null || stmDataList.isEmpty()) {
- return null;
- }
-
- return TemplateDataHelper.convert2SubstitutionMapping(stmDataList.get(0));
- }
-
-
- /**
- * get service template raw data.
- * @param queryCondition query raw data condition
- * @return ServiceTemplateRawData
- * @throws CatalogResourceException e1
- * @throws CatalogBadRequestException e2
- */
- public ServiceTemplateRawData getServiceTemplateRawData(QueryRawDataCondition queryCondition)
- throws CatalogResourceException, CatalogBadRequestException {
- ServiceTemplateData std = getServiceTemplateDataByCsarId(queryCondition.getCsarId());
- return new ServiceTemplateRawData(std.getRowData());
- }
-
- /**
- * get service template data by package id.
- * @param csarId package id
- * @return ServiceTemplateData
- * @throws CatalogBadRequestException e1
- * @throws CatalogResourceException e2
- */
- private ServiceTemplateData getServiceTemplateDataByCsarId(String csarId)
- throws CatalogBadRequestException, CatalogResourceException {
- if (ToolUtil.isTrimedEmptyString(csarId)) {
- throw new CatalogBadRequestException("CsarId is null.");
- }
- PackageData pd = new PackageData();
- pd.setCsarId(csarId);
-
- List<ServiceTemplateData> stdList =
- TemplateManager.getInstance().queryServiceTemplateByCsarPackageInfo(pd);
-
- if (stdList == null || stdList.isEmpty()) {
- throw new CatalogResourceException("Can't find this servcie template");
- }
-
- return stdList.get(0);
- }
-
- /**
- * get service template by package id.
- * @param packageId package id
- * @return service template data
- * @throws CatalogBadRequestException e1
- * @throws CatalogResourceException e2
- */
- public ServiceTemplate getServiceTemplateByCsarId(String packageId)
- throws CatalogBadRequestException, CatalogResourceException {
- ServiceTemplateData std = getServiceTemplateDataByCsarId(packageId);
- ServiceTemplate st = TemplateDataHelper.convert2ServiceTemplate(std);
- return st;
- }
-
- /**
- * get service template parameters.
- * @param serviceTemplateId service template id
- * @return service template parameters
- * @throws CatalogResourceException e
- */
- public Parameters getServiceTemplateParameters(String serviceTemplateId)
- throws CatalogResourceException {
- ServiceTemplate st = getServiceTemplateById(serviceTemplateId);
- return new Parameters(st.getInputs(), st.getOutputs());
- }
-
- /**
- * get template operation.
- * @param serviceTemplateId service template id
- * @return service template operations
- */
- public ServiceTemplateOperation[] getTemplateOperations(String serviceTemplateId)
- throws CatalogResourceException {
- ServiceTemplate st = getServiceTemplateById(serviceTemplateId);
-
- if (st.getOperations() == null) {
- return new ServiceTemplateOperation[0];
- }
- return st.getOperations();
- }
-
- /**
- * get parameters by operation name.
- * @param serviceTemplateId service template id
- * @param operationName operation name
- * @return InputParameter list
- * @throws CatalogResourceException e
- */
- public InputParameter[] getParametersByOperationName(String serviceTemplateId,
- String operationName) throws CatalogResourceException {
- if (ToolUtil.isTrimedEmptyString(operationName)) {
- throw new CatalogResourceException("Operation Name is null.");
- }
-
- ServiceTemplateOperation[] operations = getTemplateOperations(serviceTemplateId);
- for (int i = 0; i < operations.length; i++) {
- if (operationName.equals(operations[i].getName())) {
- return operations[i].getInputs();
- }
- }
-
- throw new CatalogResourceException("Can't find this operation.");
- }
-
-
- /**
- * get nodeTemplate by id.
- * @param serviceTemplateId service template id
- * @param nodeTemplateId node template id
- * @return NodeTemplate
- * @throws CatalogResourceException e1
- */
- public NodeTemplate getNodeTemplateById(String serviceTemplateId, String nodeTemplateId)
- throws CatalogResourceException {
- List<NodeTemplateData> ntdList =
- TemplateManager.getInstance().queryNodeTemplateById(serviceTemplateId, nodeTemplateId);
-
- if (ntdList == null || ntdList.isEmpty()) {
- throw new CatalogResourceException("Can't find this node template.");
- }
-
- return TemplateDataHelper.convert2NodeTemplate(ntdList.get(0));
- }
-
- /**
- * get node templates.
- * @param serviceTemplateId service template id
- * @param types type list
- * @return NodeTemplate list
- * @throws CatalogResourceException e
- */
- public NodeTemplate[] getNodeTemplates(String serviceTemplateId, String[] types)
- throws CatalogResourceException {
- List<NodeTemplateData> ntdList =
- TemplateManager.getInstance().queryNodeTemplateBySeriviceTemplateId(serviceTemplateId);
- if (ntdList == null || ntdList.isEmpty()) {
- return new NodeTemplate[0];
- }
-
- if (ToolUtil.isTrimedEmptyArray(types)) { // return all node templates
- return TemplateDataHelper.convert2NodeTemplates(ntdList);
- }
-
- List<NodeTemplate> ntList = new ArrayList<>();
- for (String type : types) {
- if (!ToolUtil.isTrimedEmptyString(type)) {
- List<NodeTemplateData> typedNtdList = filterNodeTemplateDataListByType(ntdList, type);
- ntList.addAll(Arrays.asList(TemplateDataHelper.convert2NodeTemplates(typedNtdList)));
- }
- }
- return ntList.toArray(new NodeTemplate[0]);
- }
-
- /**
- * filter node template data list by type.
- * @param ntdList nodeTemplate list
- * @param type node type
- * @return node template data list
- */
- private List<NodeTemplateData> filterNodeTemplateDataListByType(List<NodeTemplateData> ntdList,
- String type) {
- List<NodeTemplateData> retList = new ArrayList<>();
- for (NodeTemplateData ntd : ntdList) {
- if (type.equals(ntd.getType())) {
- retList.add(ntd);
- }
- }
- return retList;
- }
-
-
- /**
- * get nfv template.
- * @param serviceTemlateId service template id
- * @return NfvTemplate
- * @throws CatalogResourceException e
- */
- public NfvTemplate getNfvTemplate(String serviceTemlateId) throws CatalogResourceException {
- NodeTemplate[] nts = getNodeTemplates(serviceTemlateId, null);
-
- List<NodeTemplate> vduNodes = new ArrayList<>();
- List<NodeTemplate> networkNodes = new ArrayList<>();
- List<NodeTemplate> vnfcNodes = new ArrayList<>();
- List<NodeTemplate> vnfNodes = new ArrayList<>();
- for (NodeTemplate nt : nts) {
- if (isVduNode(nt.getType())) {
- vduNodes.add(nt);
- continue;
- }
-
- if (isNetworkNode(nt.getType())) {
- networkNodes.add(nt);
- continue;
- }
-
- if (isVnfcNode(nt.getType())) {
- vnfcNodes.add(nt);
- continue;
- }
-
- if (isVnfNode(nt.getType())) {
- vnfNodes.add(nt);
- continue;
- }
- }
-
- return new NfvTemplate(vduNodes, networkNodes, vnfcNodes, vnfNodes);
- }
-
- private boolean isVnfNode(String type) {
- return type.toUpperCase().indexOf(".VNF") > 0;
- }
-
- private boolean isVnfcNode(String type) {
- return type.toUpperCase().indexOf(".VNFC") > 0;
- }
-
- private boolean isNetworkNode(String type) {
- return type.toUpperCase().indexOf(".VL") > 0 || type.toUpperCase().indexOf(".VIRTUALLINK") > 0;
- }
-
- private boolean isVduNode(String type) {
- return type.toUpperCase().indexOf(".VDU") > 0;
- }
-
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.model.wrapper;
+
+import org.openo.commontosca.catalog.common.ToolUtil;
+import org.openo.commontosca.catalog.db.entity.NodeTemplateData;
+import org.openo.commontosca.catalog.db.entity.PackageData;
+import org.openo.commontosca.catalog.db.entity.ServiceTemplateData;
+import org.openo.commontosca.catalog.db.entity.ServiceTemplateMappingData;
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+import org.openo.commontosca.catalog.db.resource.TemplateManager;
+import org.openo.commontosca.catalog.model.common.TemplateDataHelper;
+import org.openo.commontosca.catalog.model.entity.InputParameter;
+import org.openo.commontosca.catalog.model.entity.NfvTemplate;
+import org.openo.commontosca.catalog.model.entity.NodeTemplate;
+import org.openo.commontosca.catalog.model.entity.Parameters;
+import org.openo.commontosca.catalog.model.entity.QueryRawDataCondition;
+import org.openo.commontosca.catalog.model.entity.ServiceTemplate;
+import org.openo.commontosca.catalog.model.entity.ServiceTemplateOperation;
+import org.openo.commontosca.catalog.model.entity.ServiceTemplateRawData;
+import org.openo.commontosca.catalog.model.entity.SubstitutionMapping;
+import org.openo.commontosca.catalog.resources.CatalogBadRequestException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+
+public class ServiceTemplateWrapper {
+ private static ServiceTemplateWrapper instance;
+ private static final Logger logger = LoggerFactory.getLogger(ServiceTemplateWrapper.class);
+
+ /**
+ * get service template wrapper instance.
+ * @return ServiceTemplateWrapper instance
+ */
+ public static ServiceTemplateWrapper getInstance() {
+ if (instance == null) {
+ instance = new ServiceTemplateWrapper();
+ }
+ return instance;
+ }
+
+ /**
+ * get service template by id.
+ * @param serviceTemplateId service template id
+ * @return service template
+ * @throws CatalogResourceException e1
+ */
+ public ServiceTemplate getServiceTemplateById(String serviceTemplateId)
+ throws CatalogResourceException {
+ logger.info("getServiceTemplateById. serviceTemplateId = " + serviceTemplateId);
+
+ List<ServiceTemplateData> stdList =
+ TemplateManager.getInstance().queryServiceTemplateById(serviceTemplateId);
+ if (stdList == null || stdList.isEmpty()) {
+ throw new CatalogResourceException("Can't find this servcie template");
+ }
+
+ return TemplateDataHelper.convert2ServiceTemplate(stdList.get(0));
+ }
+
+
+ /**
+ * get service templates.
+ * @param status usage status
+ * @param deletionPending package's deletionPending
+ * @return service template list
+ * @throws CatalogResourceException e
+ */
+ public ServiceTemplate[] getServiceTemplates(String status, boolean deletionPending)
+ throws CatalogResourceException {
+ PackageData pd = new PackageData();
+ pd.setUsageState(status);
+ pd.setDeletionPending(String.valueOf(deletionPending));
+
+ List<ServiceTemplateData> stdList =
+ TemplateManager.getInstance().queryServiceTemplateByCsarPackageInfo(pd);
+
+ return TemplateDataHelper.convert2ServiceTemplates(stdList);
+ }
+
+
+ /**
+ * get nesting service template.
+ * @param nodeTypeIds nodeType id list
+ * @return service template list
+ * @throws CatalogResourceException e
+ */
+ public ServiceTemplate[] getNestingServiceTemplate(String[] nodeTypeIds)
+ throws CatalogResourceException {
+ ServiceTemplate[] sts = new ServiceTemplate[nodeTypeIds.length];
+ for (int i = 0; i < nodeTypeIds.length; i++) {
+ SubstitutionMapping stm = getSubstitutionMappingsByNodeTypeId(nodeTypeIds[i]);
+ if (stm == null) {
+ sts[i] = null;
+ } else {
+ sts[i] = getServiceTemplateById(stm.getServiceTemplateId());
+ }
+ }
+
+ return sts;
+ }
+
+ /**
+ * get substitution mappings by nodeTpe id.
+ * @param nodeTypeId nodeType id
+ * @return SubstitutionMapping
+ * @throws CatalogResourceException e
+ */
+ private SubstitutionMapping getSubstitutionMappingsByNodeTypeId(String nodeTypeId)
+ throws CatalogResourceException {
+ List<ServiceTemplateMappingData> stmDataList =
+ TemplateManager.getInstance().queryServiceTemplateMapping(nodeTypeId, null);
+ if (stmDataList == null || stmDataList.isEmpty()) {
+ return null;
+ }
+
+ return TemplateDataHelper.convert2SubstitutionMapping(stmDataList.get(0));
+ }
+
+
+ /**
+ * get service template raw data.
+ * @param queryCondition query raw data condition
+ * @return ServiceTemplateRawData
+ * @throws CatalogResourceException e1
+ * @throws CatalogBadRequestException e2
+ */
+ public ServiceTemplateRawData getServiceTemplateRawData(QueryRawDataCondition queryCondition)
+ throws CatalogResourceException, CatalogBadRequestException {
+ ServiceTemplateData std = getServiceTemplateDataByCsarId(queryCondition.getCsarId());
+ return new ServiceTemplateRawData(std.getRowData());
+ }
+
+ /**
+ * get service template data by package id.
+ * @param csarId package id
+ * @return ServiceTemplateData
+ * @throws CatalogBadRequestException e1
+ * @throws CatalogResourceException e2
+ */
+ private ServiceTemplateData getServiceTemplateDataByCsarId(String csarId)
+ throws CatalogBadRequestException, CatalogResourceException {
+ if (ToolUtil.isTrimedEmptyString(csarId)) {
+ throw new CatalogBadRequestException("CsarId is null.");
+ }
+ PackageData pd = new PackageData();
+ pd.setCsarId(csarId);
+
+ List<ServiceTemplateData> stdList =
+ TemplateManager.getInstance().queryServiceTemplateByCsarPackageInfo(pd);
+
+ if (stdList == null || stdList.isEmpty()) {
+ throw new CatalogResourceException("Can't find this servcie template");
+ }
+
+ return stdList.get(0);
+ }
+
+ /**
+ * get service template by package id.
+ * @param packageId package id
+ * @return service template data
+ * @throws CatalogBadRequestException e1
+ * @throws CatalogResourceException e2
+ */
+ public ServiceTemplate getServiceTemplateByCsarId(String packageId)
+ throws CatalogBadRequestException, CatalogResourceException {
+ ServiceTemplateData std = getServiceTemplateDataByCsarId(packageId);
+ ServiceTemplate st = TemplateDataHelper.convert2ServiceTemplate(std);
+ return st;
+ }
+
+ /**
+ * get service template parameters.
+ * @param serviceTemplateId service template id
+ * @return service template parameters
+ * @throws CatalogResourceException e
+ */
+ public Parameters getServiceTemplateParameters(String serviceTemplateId)
+ throws CatalogResourceException {
+ ServiceTemplate st = getServiceTemplateById(serviceTemplateId);
+ return new Parameters(st.getInputs(), st.getOutputs());
+ }
+
+ /**
+ * get template operation.
+ * @param serviceTemplateId service template id
+ * @return service template operations
+ */
+ public ServiceTemplateOperation[] getTemplateOperations(String serviceTemplateId)
+ throws CatalogResourceException {
+ ServiceTemplate st = getServiceTemplateById(serviceTemplateId);
+
+ if (st.getOperations() == null) {
+ return new ServiceTemplateOperation[0];
+ }
+ return st.getOperations();
+ }
+
+ /**
+ * get parameters by operation name.
+ * @param serviceTemplateId service template id
+ * @param operationName operation name
+ * @return InputParameter list
+ * @throws CatalogResourceException e
+ */
+ public InputParameter[] getParametersByOperationName(String serviceTemplateId,
+ String operationName) throws CatalogResourceException {
+ if (ToolUtil.isTrimedEmptyString(operationName)) {
+ throw new CatalogResourceException("Operation Name is null.");
+ }
+
+ ServiceTemplateOperation[] operations = getTemplateOperations(serviceTemplateId);
+ for (int i = 0; i < operations.length; i++) {
+ if (operationName.equals(operations[i].getName())) {
+ return operations[i].getInputs();
+ }
+ }
+
+ throw new CatalogResourceException("Can't find this operation.");
+ }
+
+
+ /**
+ * get nodeTemplate by id.
+ * @param serviceTemplateId service template id
+ * @param nodeTemplateId node template id
+ * @return NodeTemplate
+ * @throws CatalogResourceException e1
+ */
+ public NodeTemplate getNodeTemplateById(String serviceTemplateId, String nodeTemplateId)
+ throws CatalogResourceException {
+ List<NodeTemplateData> ntdList =
+ TemplateManager.getInstance().queryNodeTemplateById(serviceTemplateId, nodeTemplateId);
+
+ if (ntdList == null || ntdList.isEmpty()) {
+ throw new CatalogResourceException("Can't find this node template.");
+ }
+
+ return TemplateDataHelper.convert2NodeTemplate(ntdList.get(0));
+ }
+
+ /**
+ * get node templates.
+ * @param serviceTemplateId service template id
+ * @param types type list
+ * @return NodeTemplate list
+ * @throws CatalogResourceException e
+ */
+ public NodeTemplate[] getNodeTemplates(String serviceTemplateId, String[] types)
+ throws CatalogResourceException {
+ List<NodeTemplateData> ntdList =
+ TemplateManager.getInstance().queryNodeTemplateBySeriviceTemplateId(serviceTemplateId);
+ if (ntdList == null || ntdList.isEmpty()) {
+ return new NodeTemplate[0];
+ }
+
+ if (ToolUtil.isTrimedEmptyArray(types)) { // return all node templates
+ return TemplateDataHelper.convert2NodeTemplates(ntdList);
+ }
+
+ List<NodeTemplate> ntList = new ArrayList<>();
+ for (String type : types) {
+ if (!ToolUtil.isTrimedEmptyString(type)) {
+ List<NodeTemplateData> typedNtdList = filterNodeTemplateDataListByType(ntdList, type);
+ ntList.addAll(Arrays.asList(TemplateDataHelper.convert2NodeTemplates(typedNtdList)));
+ }
+ }
+ return ntList.toArray(new NodeTemplate[0]);
+ }
+
+ /**
+ * filter node template data list by type.
+ * @param ntdList nodeTemplate list
+ * @param type node type
+ * @return node template data list
+ */
+ private List<NodeTemplateData> filterNodeTemplateDataListByType(List<NodeTemplateData> ntdList,
+ String type) {
+ List<NodeTemplateData> retList = new ArrayList<>();
+ for (NodeTemplateData ntd : ntdList) {
+ if (type.equals(ntd.getType())) {
+ retList.add(ntd);
+ }
+ }
+ return retList;
+ }
+
+
+ /**
+ * get nfv template.
+ * @param serviceTemlateId service template id
+ * @return NfvTemplate
+ * @throws CatalogResourceException e
+ */
+ public NfvTemplate getNfvTemplate(String serviceTemlateId) throws CatalogResourceException {
+ NodeTemplate[] nts = getNodeTemplates(serviceTemlateId, null);
+
+ List<NodeTemplate> vduNodes = new ArrayList<>();
+ List<NodeTemplate> networkNodes = new ArrayList<>();
+ List<NodeTemplate> vnfcNodes = new ArrayList<>();
+ List<NodeTemplate> vnfNodes = new ArrayList<>();
+ for (NodeTemplate nt : nts) {
+ if (isVduNode(nt.getType())) {
+ vduNodes.add(nt);
+ continue;
+ }
+
+ if (isNetworkNode(nt.getType())) {
+ networkNodes.add(nt);
+ continue;
+ }
+
+ if (isVnfcNode(nt.getType())) {
+ vnfcNodes.add(nt);
+ continue;
+ }
+
+ if (isVnfNode(nt.getType())) {
+ vnfNodes.add(nt);
+ continue;
+ }
+ }
+
+ return new NfvTemplate(vduNodes, networkNodes, vnfcNodes, vnfNodes);
+ }
+
+ private boolean isVnfNode(String type) {
+ return type.toUpperCase().indexOf(".VNF") > 0;
+ }
+
+ private boolean isVnfcNode(String type) {
+ return type.toUpperCase().indexOf(".VNFC") > 0;
+ }
+
+ private boolean isNetworkNode(String type) {
+ return type.toUpperCase().indexOf(".VL") > 0 || type.toUpperCase().indexOf(".VIRTUALLINK") > 0;
+ }
+
+ private boolean isVduNode(String type) {
+ return type.toUpperCase().indexOf(".VDU") > 0;
+ }
+
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/RestUtils.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/RestUtils.java
index 57053f87..ff6f3331 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/RestUtils.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/resources/RestUtils.java
@@ -1,37 +1,37 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.resources;
-
-import org.openo.commontosca.catalog.common.CommonErrorResponse;
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-
-import javax.ws.rs.BadRequestException;
-import javax.ws.rs.InternalServerErrorException;
-import javax.ws.rs.core.Response;
-
-public class RestUtils {
- public static InternalServerErrorException newInternalServerErrorException(
- CatalogResourceException e1) {
- return new InternalServerErrorException(Response.status(Response.Status.INTERNAL_SERVER_ERROR)
- .entity(new CommonErrorResponse(e1.getErrcode() + "", e1.getMessage())).build(), e1);
- }
-
- public static BadRequestException newBadRequestException(CatalogBadRequestException e1) {
- return new BadRequestException(Response.status(Response.Status.BAD_REQUEST)
- .entity(new CommonErrorResponse(e1.getErrcode() + "", e1.getMessage())).build(), e1);
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.resources;
+
+import org.openo.commontosca.catalog.common.CommonErrorResponse;
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+
+import javax.ws.rs.BadRequestException;
+import javax.ws.rs.InternalServerErrorException;
+import javax.ws.rs.core.Response;
+
+public class RestUtils {
+ public static InternalServerErrorException newInternalServerErrorException(
+ CatalogResourceException e1) {
+ return new InternalServerErrorException(Response.status(Response.Status.INTERNAL_SERVER_ERROR)
+ .entity(new CommonErrorResponse(e1.getErrcode() + "", e1.getMessage())).build(), e1);
+ }
+
+ public static BadRequestException newBadRequestException(CatalogBadRequestException e1) {
+ return new BadRequestException(Response.status(Response.Status.BAD_REQUEST)
+ .entity(new CommonErrorResponse(e1.getErrcode() + "", e1.getMessage())).build(), e1);
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java
index 36b229b8..a7d9fcca 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapper.java
@@ -1,516 +1,517 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.wrapper;
-
-import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
-import org.openo.commontosca.catalog.common.CommonConstant;
-import org.openo.commontosca.catalog.common.HttpServerPathConfig;
-import org.openo.commontosca.catalog.common.RestUtil;
-import org.openo.commontosca.catalog.common.ToolUtil;
-import org.openo.commontosca.catalog.common.ZipCompressor;
-import org.openo.commontosca.catalog.db.entity.PackageData;
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-import org.openo.commontosca.catalog.db.resource.PackageManager;
-import org.openo.commontosca.catalog.db.resource.TemplateManager;
-import org.openo.commontosca.catalog.entity.EnumType;
-import org.openo.commontosca.catalog.entity.request.PackageBasicInfo;
-import org.openo.commontosca.catalog.entity.request.UploadPackageFromFtpRequest;
-import org.openo.commontosca.catalog.entity.response.CsarFileUriResponse;
-import org.openo.commontosca.catalog.entity.response.PackageMeta;
-import org.openo.commontosca.catalog.entity.response.UploadPackageResponse;
-import org.openo.commontosca.catalog.filemanage.FileManagerFactory;
-import org.openo.commontosca.catalog.filemanage.entity.FileLink;
-import org.openo.commontosca.catalog.model.parser.EnumPackageFormat;
-import org.openo.commontosca.catalog.model.parser.ModelParserFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-
-public class PackageWrapper {
- private static PackageWrapper packageWrapper;
- private static final Logger LOG = LoggerFactory.getLogger(PackageWrapper.class);
-
- /**
- * get PackageWrapper instance.
- * @return package wrapper instance
- */
- public static PackageWrapper getInstance() {
- if (packageWrapper == null) {
- packageWrapper = new PackageWrapper();
- }
- return packageWrapper;
- }
-
- /**
- * query package by id.
- * @param csarId package id
- * @return Response
- */
- public Response queryPackageById(String csarId) {
- ArrayList<PackageData> dbResult = new ArrayList<PackageData>();
- ArrayList<PackageMeta> result = new ArrayList<PackageMeta>();
- dbResult = PackageWrapperUtil.getPackageInfoById(csarId);
- if (dbResult.size() != 0) {
- result = PackageWrapperUtil.packageDataList2PackageMetaList(dbResult);
- return Response.ok(result).build();
- } else {
- String errorMsg = "get package info by Id error !";
- return RestUtil.getRestException(errorMsg);
- }
- }
-
- /**
- * upload package.
- * @param uploadedInputStream inputStream
- * @param fileDetail package detail
- * @param head http header
- * @return Response
- * @throws Exception e
- */
- public Response uploadPackage(InputStream uploadedInputStream,
- FormDataContentDisposition fileDetail, HttpHeaders head) throws Exception {
- PackageBasicInfo basicInfo = new PackageBasicInfo();
- String tempDirName = null;
- int fileSize = 0;
- String fileName = "";
- UploadPackageResponse result = new UploadPackageResponse();
- PackageMeta packageMeta = new PackageMeta();
- if (uploadedInputStream == null) {
- LOG.info("the uploadStream is null");
- return Response.serverError().build();
- }
- if (fileDetail == null) {
- LOG.info("the fileDetail is null");
- return Response.serverError().build();
- }
-
- try {
- String contentRange = null;
- fileName = ToolUtil.processFileName(fileDetail.getFileName());
- tempDirName = ToolUtil.getTempDir(CommonConstant.CATALOG_CSAR_DIR_NAME, fileName);
- if (head != null) {
- contentRange = head.getHeaderString(CommonConstant.HTTP_HEADER_CONTENT_RANGE);
- }
- LOG.debug("store package chunk file, fileName:" + fileName + ",contentRange:" + contentRange);
- if (ToolUtil.isEmptyString(contentRange)) {
- fileSize = uploadedInputStream.available();
- contentRange = "0-" + fileSize + "/" + fileSize;
- }
- String fileLocation =
- ToolUtil.storeChunkFileInLocal(tempDirName, fileName, uploadedInputStream);
- LOG.info("the fileLocation when upload package is :" + fileLocation);
- uploadedInputStream.close();
-
- basicInfo = PackageWrapperUtil.getPacageBasicInfo(fileLocation);
- String path =
- basicInfo.getType().toString() + File.separator + basicInfo.getProvider()
- + File.separator + fileName.replace(".csar", "") + File.separator
- + basicInfo.getVersion();
- LOG.info("dest path is : " + path);
- packageMeta = PackageWrapperUtil.getPackageMeta(fileName, fileLocation, basicInfo);
- String dowloadUri = File.separator + path + File.separator;
- String destPath = File.separator + path;
- packageMeta.setDownloadUri(dowloadUri);
- LOG.info("packageMeta = " + ToolUtil.objectToString(packageMeta));
- Boolean isEnd = PackageWrapperUtil.isUploadEnd(contentRange, fileName);
- if (isEnd) {
- boolean uploadResult = FileManagerFactory.createFileManager().upload(tempDirName, destPath);
- if (uploadResult == true) {
- // 调袁虎的接口,将fileLocation 和 packageId传给他,由他去解析包,并向数据库存储数据
- // String parseResult =
- // ModelParserFactory.getInstance().parse(packageMeta.getCsarId(),
- // fileLocation , EnumPackageFormat.valueOf(packageMeta.getFormat()));
- PackageData packageData = PackageWrapperUtil.getPackageData(packageMeta);
- PackageManager.getInstance().addPackage(packageData);
- }
- LOG.info("upload package file end, fileName:" + fileName);
- }
- result.setCsarId(packageMeta.getCsarId());
- return Response.ok(result).build();
- } catch (Exception e1) {
- LOG.error("upload package fail.", e1);
- String csarId = packageMeta.getCsarId();
- if (csarId != null) {
- PackageManager.getInstance().deletePackage(csarId);
- }
- return RestUtil.getRestException(e1.getMessage());
- } finally {
- if (tempDirName != null) {
- ToolUtil.deleteDir(new File(tempDirName));
- }
- }
- }
-
- /**
- * delete package by package id.
- * @param csarId package id
- * @return Response
- */
- public Response delPackage(String csarId) {
- LOG.info("delete package info.csarId:" + csarId);
- if (ToolUtil.isEmptyString(csarId)) {
- LOG.error("delete package fail, csarid is null");
- return Response.serverError().build();
- }
- try {
- DelCsarThread thread = new DelCsarThread(csarId, false);
- new Thread(thread).start();
- return Response.noContent().build();
- } catch (Exception e1) {
- LOG.error("delete fail.", e1);
- return RestUtil.getRestException(e1.getMessage());
- }
- }
-
- // public Response delPackageByServiceTemplateId(String serviceTemplateId) {
- // LOG.info("delete package info.serviceTemplateId:" + serviceTemplateId);
- // if (ToolUtil.isEmptyString(serviceTemplateId)) {
- // LOG.error("delete package fail, serviceTemplateId is null");
- // return Response.serverError().build();
- // }
- // ArrayList<PackageData> result = new ArrayList<PackageData>();
- // try {
- // result = PackageManager.getInstance().queryPackageByServiceTemplateId(serviceTemplateId);
- //
- // } catch (CatalogResourceException e) {
- // LOG.error("query package by csarId from db error ! " + e.getMessage());
- // return RestUtil.getRestException(e.getMessage());
- // }
- // if (result.size() <= 0) {
- // LOG.warn("not exist package by serviceTemplateId");
- // return Response.status(Status.NOT_FOUND).build();
- // }
- // if ("true".equals(result.get(0).getDeletionPending())) {
- // LOG.info("start delete package.csarId:" + result.get(0).getCsarId());
- // delCsarThread thread = new delCsarThread(result.get(0).getCsarId(), true);
- // new Thread(thread).start();
- // }
- // return Response.noContent().build();
- // }
-
- class DelCsarThread implements Runnable {
- private String csarid;
- private boolean isInstanceTemplate = false;
-
- public DelCsarThread(String csarid, boolean isInstanceTemplate) {
- this.csarid = csarid;
- this.isInstanceTemplate = isInstanceTemplate;
- }
-
- @Override
- public void run() {
- try {
- if (!ToolUtil.isEmptyString(csarid)) {
- delCsarData(csarid);
- }
- } catch (Exception e1) {
- LOG.error("del instance csar fail.", e1);
- updatePackageStatus(csarid, null, null, null, CommonConstant.PACKAGE_STATUS_DELETE_FAIL,
- null);
- // publishDelFinishCometdMessage(csarid, "false");
- }
- }
-
- private void delCsarData(String csarId) {
- updatePackageStatus(csarid, null, null, null, CommonConstant.PACKAGE_STATUS_DELETING, null);
- String packagePath = PackageWrapperUtil.getPackagePath(csarId);
- if (packagePath == null) {
- LOG.error("package path is null! ");
- return;
- }
- FileManagerFactory.createFileManager().delete(packagePath);
- try {
- PackageManager.getInstance().deletePackage(csarId);
- } catch (CatalogResourceException e1) {
- LOG.error("delete package by csarId from db error ! " + e1.getMessage());
- }
- // delete template data from db
- PackageData packageData = new PackageData();
- packageData.setCsarId(csarId);
- try {
- TemplateManager.getInstance().deleteServiceTemplateByCsarPackageInfo(packageData);
- } catch (CatalogResourceException e2) {
- LOG.error("delete template data from db error! csarId = " + csarId);
- }
- // publishDelFinishCometdMessage(csarid, "true");
- }
-
- // private void publishDelFinishCometdMessage(String csarid, String csarDelStatus) {
- // if (isInstanceTemplate) {
- // LOG.info("delete instance Template finish. csarid:{}", csarid);
- // return;
- // }
- // try {
- // Map<String, Object> cometdMessage = new HashMap<String, Object>();
- // cometdMessage.put("csarid", csarid);
- // cometdMessage.put("status", csarDelStatus);
- // CometdService.getInstance().publish(CommonConstant.COMETD_CHANNEL_PACKAGE_DELETE,
- // cometdMessage);
- // } catch (CometdException e) {
- // LOG.error("publish delfinish cometdmsg fail.", e);
- // }
- // }
- }
-
- /**
- * update package status.
- * @param csarId package id
- * @param operationalState package operational state
- * @param usageState package usage state
- * @param onBoardState package onboard state
- * @param processState package process state
- * @param deletionPending package deletionPending status
- * @return Response
- */
- public Response updatePackageStatus(String csarId, String operationalState, String usageState,
- String onBoardState, String processState, String deletionPending) {
- LOG.info("update package status info.csarId:" + csarId + " operationalState:"
- + operationalState);
- if (ToolUtil.isEmptyString(csarId)) {
- LOG.error("update csar status fail, csarid is null");
- return Response.serverError().build();
- }
- try {
- // UpdatePackageResponse result = new UpdatePackageResponse();
- PackageData packageInfo = new PackageData();
- if (operationalState != null) {
- packageInfo.setOperationalState(operationalState);
- }
- if (usageState != null) {
- packageInfo.setUsageState(usageState);
- }
- if (onBoardState != null) {
- packageInfo.setOnBoardState(onBoardState);
- }
- if (processState != null) {
- packageInfo.setProcessState(processState);
- }
- if (deletionPending != null) {
- packageInfo.setDeletionPending(deletionPending);
- }
- SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String currentTime = sdf1.format(new Date());
- packageInfo.setModifyTime(currentTime);
- PackageManager.getInstance().updatePackage(packageInfo, csarId);
- // ArrayList<PackageData> pacackgeList = PackageWrapperUtil.getPackageInfoById(csarId);
- // String finalUsageState = pacackgeList.get(0).getUsageState();
- // result.setUsageState(finalUsageState);
- return Response.ok().build();
- } catch (CatalogResourceException e1) {
- LOG.error("update package status by csarId from db error ! " + e1.getMessage());
- return RestUtil.getRestException(e1.getMessage());
- }
- }
-
- /**
- * download package by package id.
- * @param csarId package id
- * @return Response
- */
- public Response downloadCsarPackagesById(String csarId) {
- ArrayList<PackageData> packageList = PackageWrapperUtil.getPackageInfoById(csarId);
- String packageName = null;
- if (null != packageList && packageList.size() > 0) {
- packageName = packageList.get(0).getName();
- }
- String path = ToolUtil.getCatalogueCsarPath() + File.separator + packageName;
- File csarFile = new File(path);
- if (!csarFile.exists()) {
- return Response.status(Status.NOT_FOUND).build();
- }
-
- try {
- InputStream fis = new BufferedInputStream(new FileInputStream(path));
- return Response.ok(fis)
- .header("Content-Disposition", "attachment; filename=\"" + csarFile.getName() + "\"")
- .build();
- } catch (Exception e1) {
- LOG.error("download vnf package fail.", e1);
- return RestUtil.getRestException(e1.getMessage());
- }
- }
-
- /**
- * query package list by condition.
- * @param name package name
- * @param provider package provider
- * @param version package version
- * @param deletionPending package deletionPending
- * @param type package type
- * @return Response
- */
- public Response queryPackageListByCond(String name, String provider, String version,
- String deletionPending, String type) {
- ArrayList<PackageData> dbresult = new ArrayList<PackageData>();
- ArrayList<PackageMeta> result = new ArrayList<PackageMeta>();
- LOG.info("query package info.name:" + name + " provider:" + provider + " version" + version
- + " deletionPending" + deletionPending + " type:" + type);
- try {
- dbresult =
- PackageManager.getInstance().queryPackage(name, provider, version, deletionPending, type);
- result = PackageWrapperUtil.packageDataList2PackageMetaList(dbresult);
- return Response.ok(result).build();
- } catch (CatalogResourceException e1) {
- LOG.error("query package by csarId from db error ! " + e1.getMessage());
- return RestUtil.getRestException(e1.getMessage());
- }
- }
-
- /**
- * get package file uri.
- * @param csarId package id
- * @param relativePath file relative path
- * @return Response
- */
- public Response getCsarFileUri(String csarId, String relativePath) {
- try {
- CsarFileUriResponse result = getCsarFileDownloadUri(csarId, relativePath);
- return Response.ok(result).build();
- } catch (CatalogResourceException e1) {
- LOG.error("Query CSAR package by ID failed ! csarId = " + csarId);
- }
-
- return Response.serverError().build();
- }
-
- /**
- * get package file download uri.
- * @param csarId package id
- * @param relativePath package file relative path
- * @return CsarFileUriResponse
- * @throws CatalogResourceException
- */
- public CsarFileUriResponse getCsarFileDownloadUri(String csarId, String relativePath)
- throws CatalogResourceException {
- CsarFileUriResponse result = new CsarFileUriResponse();
- String downloadUrl = null;
- String downloadUri = null;
- String localPath = null;
- ArrayList<PackageData> packageList = PackageManager.getInstance().queryPackageByCsarId(csarId);
- if (packageList != null && packageList.size() != 0) {
- String packageName = packageList.get(0).getName();
- String relativeUri = packageList.get(0).getDownloadUri() + packageName;
- downloadUri = relativeUri + relativePath;
- downloadUrl = PackageWrapperUtil.getUrl(downloadUri);
- String httpUri = HttpServerPathConfig.getHttpServerPath() + downloadUri;
- localPath = PackageWrapperUtil.getLocalPath(httpUri);
- }
- result.setDownloadUri(downloadUrl);
- result.setLocalPath(localPath);
- return result;
- }
-
- /**
- * upload package from ftp.
- * @param request package basic information
- * @return Response
- */
- public Response uploadPackageFromFtp(UploadPackageFromFtpRequest request) {
- PackageBasicInfo basicInfo = new PackageBasicInfo();
- String tempDirName = null;
- String fileName = "";
- UploadPackageResponse result = new UploadPackageResponse();
- basicInfo.setProvider("zte");
- basicInfo.setType(EnumType.NSAR);
- basicInfo.setVersion("v1.0");
- PackageMeta packageMeta = new PackageMeta();
-
- try {
- String ftpUrl = request.getFtpUrl();
- String packageName = PackageWrapperUtil.getPackageName(ftpUrl);
- fileName = ToolUtil.processFileName(packageName);
- tempDirName = ToolUtil.getTempDir(CommonConstant.CATALOG_CSAR_DIR_NAME, fileName);
- PackageWrapperUtil.downPackageFromFtp(ftpUrl, tempDirName);
- String path =
- basicInfo.getType().toString() + File.separator + basicInfo.getProvider()
- + File.separator + fileName.replace(".csar", "") + File.separator
- + basicInfo.getVersion();
- LOG.info("dest path is : " + path);
- packageMeta = PackageWrapperUtil.getPackageMeta(fileName, tempDirName, basicInfo);
- String dowloadUri = File.separator + path + File.separator + fileName;
- packageMeta.setDownloadUri(dowloadUri);
- LOG.info("packageMeta = " + ToolUtil.objectToString(packageMeta));
- String destPath = File.separator + path;
- boolean uploadResult = FileManagerFactory.createFileManager().upload(tempDirName, destPath);
- if (uploadResult == true) {
- String newZipPath = tempDirName + fileName.replace(".csar", ".zip");
- ZipCompressor zc = new ZipCompressor(newZipPath);
- String metadataPath = tempDirName + File.separator + CommonConstant.TOSCA_METADATA;
- String definitions = tempDirName + File.separator + CommonConstant.DEFINITIONS;
- zc.compress(metadataPath, definitions);
- // 调袁虎的接口,将fileLocation 和 packageId传给他,由他去解析包,并向数据库存储数据
-// String parseResult =
- ModelParserFactory.getInstance().parse(packageMeta.getCsarId(), newZipPath,
- EnumPackageFormat.valueOf(packageMeta.getFormat()));
- PackageData packageData = PackageWrapperUtil.getPackageData(packageMeta);
- PackageManager.getInstance().addPackage(packageData);
- }
- LOG.info("upload package file end, fileName:" + fileName);
- result.setCsarId(packageMeta.getCsarId());
- return Response.ok(result).build();
- } catch (Exception e1) {
- LOG.error("upload package fail.", e1);
- String csarId = packageMeta.getCsarId();
- if (csarId != null) {
- try {
- PackageManager.getInstance().deletePackage(csarId);
- } catch (CatalogResourceException e2) {
- LOG.error("delete package failed !");
- }
- }
- return RestUtil.getRestException(e1.getMessage());
- } finally {
- if (tempDirName != null) {
- ToolUtil.deleteDir(new File(tempDirName));
- }
- }
- }
-
- /**
- * get csar plan uri.
- * @param csarId package id
- * @return Response
- */
- public Response getCsarPlansUri(String csarId) {
- ArrayList<FileLink> fileLinks = new ArrayList<FileLink>();
- LOG.info("start query plans of package.csarId:" + csarId);
- ArrayList<PackageData> packageList = new ArrayList<PackageData>();
- try {
- packageList = PackageManager.getInstance().queryPackageByCsarId(csarId);
- if (packageList != null && packageList.size() != 0) {
- String downloadUri = packageList.get(0).getDownloadUri();
- fileLinks = FileManagerFactory.createFileManager().queryWorkFlow(downloadUri);
- }
- return Response.ok(fileLinks).build();
- } catch (CatalogResourceException e1) {
- LOG.error("Query plans of package by ID failed ! csarId = " + csarId);
- return RestUtil.getRestException(e1.getMessage());
- }
- // return Response.serverError().build();
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.wrapper;
+
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+import org.openo.commontosca.catalog.common.CommonConstant;
+import org.openo.commontosca.catalog.common.HttpServerPathConfig;
+import org.openo.commontosca.catalog.common.RestUtil;
+import org.openo.commontosca.catalog.common.ToolUtil;
+import org.openo.commontosca.catalog.common.ZipCompressor;
+import org.openo.commontosca.catalog.db.entity.PackageData;
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+import org.openo.commontosca.catalog.db.resource.PackageManager;
+import org.openo.commontosca.catalog.db.resource.TemplateManager;
+import org.openo.commontosca.catalog.entity.EnumType;
+import org.openo.commontosca.catalog.entity.request.PackageBasicInfo;
+import org.openo.commontosca.catalog.entity.request.UploadPackageFromFtpRequest;
+import org.openo.commontosca.catalog.entity.response.CsarFileUriResponse;
+import org.openo.commontosca.catalog.entity.response.PackageMeta;
+import org.openo.commontosca.catalog.entity.response.UploadPackageResponse;
+import org.openo.commontosca.catalog.filemanage.FileManagerFactory;
+import org.openo.commontosca.catalog.filemanage.entity.FileLink;
+import org.openo.commontosca.catalog.model.parser.EnumPackageFormat;
+import org.openo.commontosca.catalog.model.parser.ModelParserFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+public class PackageWrapper {
+ private static PackageWrapper packageWrapper;
+ private static final Logger LOG = LoggerFactory.getLogger(PackageWrapper.class);
+
+ /**
+ * get PackageWrapper instance.
+ * @return package wrapper instance
+ */
+ public static PackageWrapper getInstance() {
+ if (packageWrapper == null) {
+ packageWrapper = new PackageWrapper();
+ }
+ return packageWrapper;
+ }
+
+ /**
+ * query package by id.
+ * @param csarId package id
+ * @return Response
+ */
+ public Response queryPackageById(String csarId) {
+ ArrayList<PackageData> dbResult = new ArrayList<PackageData>();
+ ArrayList<PackageMeta> result = new ArrayList<PackageMeta>();
+ dbResult = PackageWrapperUtil.getPackageInfoById(csarId);
+ if (dbResult.size() != 0) {
+ result = PackageWrapperUtil.packageDataList2PackageMetaList(dbResult);
+ return Response.ok(result).build();
+ } else {
+ String errorMsg = "get package info by Id error !";
+ return RestUtil.getRestException(errorMsg);
+ }
+ }
+
+ /**
+ * upload package.
+ * @param uploadedInputStream inputStream
+ * @param fileDetail package detail
+ * @param head http header
+ * @return Response
+ * @throws Exception e
+ */
+ public Response uploadPackage(InputStream uploadedInputStream,
+ FormDataContentDisposition fileDetail, HttpHeaders head) throws Exception {
+ PackageBasicInfo basicInfo = new PackageBasicInfo();
+ String tempDirName = null;
+ int fileSize = 0;
+ String fileName = "";
+ UploadPackageResponse result = new UploadPackageResponse();
+ PackageMeta packageMeta = new PackageMeta();
+ if (uploadedInputStream == null) {
+ LOG.info("the uploadStream is null");
+ return Response.serverError().build();
+ }
+ if (fileDetail == null) {
+ LOG.info("the fileDetail is null");
+ return Response.serverError().build();
+ }
+
+ try {
+ String contentRange = null;
+ fileName = ToolUtil.processFileName(fileDetail.getFileName());
+ tempDirName = ToolUtil.getTempDir(CommonConstant.CATALOG_CSAR_DIR_NAME, fileName);
+ if (head != null) {
+ contentRange = head.getHeaderString(CommonConstant.HTTP_HEADER_CONTENT_RANGE);
+ }
+ LOG.debug("store package chunk file, fileName:" + fileName + ",contentRange:" + contentRange);
+ if (ToolUtil.isEmptyString(contentRange)) {
+ fileSize = uploadedInputStream.available();
+ contentRange = "0-" + fileSize + "/" + fileSize;
+ }
+ String fileLocation =
+ ToolUtil.storeChunkFileInLocal(tempDirName, fileName, uploadedInputStream);
+ LOG.info("the fileLocation when upload package is :" + fileLocation);
+ uploadedInputStream.close();
+
+ basicInfo = PackageWrapperUtil.getPacageBasicInfo(fileLocation);
+ String path =
+ basicInfo.getType().toString() + File.separator + basicInfo.getProvider()
+ + File.separator + fileName.replace(".csar", "") + File.separator
+ + basicInfo.getVersion();
+ LOG.info("dest path is : " + path);
+ packageMeta = PackageWrapperUtil.getPackageMeta(fileName, fileLocation, basicInfo);
+ String dowloadUri = File.separator + path + File.separator;
+ String destPath = File.separator + path;
+ packageMeta.setDownloadUri(dowloadUri);
+ LOG.info("packageMeta = " + ToolUtil.objectToString(packageMeta));
+ Boolean isEnd = PackageWrapperUtil.isUploadEnd(contentRange, fileName);
+ if (isEnd) {
+ boolean uploadResult = FileManagerFactory.createFileManager().upload(tempDirName, destPath);
+ if (uploadResult == true) {
+ try {
+ String tempCsarPath = tempDirName + File.separator + fileName;
+ ModelParserFactory.getInstance().parse(packageMeta.getCsarId(),
+ tempCsarPath , PackageWrapperUtil.getPackageFormat(packageMeta.getFormat()));
+ } catch (CatalogResourceException e1) {
+ LOG.error("parse package error ! " + e1.getMessage());
+ }
+ PackageData packageData = PackageWrapperUtil.getPackageData(packageMeta);
+ PackageManager.getInstance().addPackage(packageData);
+ }
+ LOG.info("upload package file end, fileName:" + fileName);
+ }
+ result.setCsarId(packageMeta.getCsarId());
+ return Response.ok(result).build();
+ } catch (Exception e1) {
+ LOG.error("upload package fail.", e1);
+ String csarId = packageMeta.getCsarId();
+ if (csarId != null) {
+ PackageManager.getInstance().deletePackage(csarId);
+ }
+ return RestUtil.getRestException(e1.getMessage());
+ } finally {
+ if (tempDirName != null) {
+ ToolUtil.deleteDir(new File(tempDirName));
+ }
+ }
+ }
+
+ /**
+ * delete package by package id.
+ * @param csarId package id
+ * @return Response
+ */
+ public Response delPackage(String csarId) {
+ LOG.info("delete package info.csarId:" + csarId);
+ if (ToolUtil.isEmptyString(csarId)) {
+ LOG.error("delete package fail, csarid is null");
+ return Response.serverError().build();
+ }
+ try {
+ DelCsarThread thread = new DelCsarThread(csarId, false);
+ new Thread(thread).start();
+ return Response.noContent().build();
+ } catch (Exception e1) {
+ LOG.error("delete fail.", e1);
+ return RestUtil.getRestException(e1.getMessage());
+ }
+ }
+
+ // public Response delPackageByServiceTemplateId(String serviceTemplateId) {
+ // LOG.info("delete package info.serviceTemplateId:" + serviceTemplateId);
+ // if (ToolUtil.isEmptyString(serviceTemplateId)) {
+ // LOG.error("delete package fail, serviceTemplateId is null");
+ // return Response.serverError().build();
+ // }
+ // ArrayList<PackageData> result = new ArrayList<PackageData>();
+ // try {
+ // result = PackageManager.getInstance().queryPackageByServiceTemplateId(serviceTemplateId);
+ //
+ // } catch (CatalogResourceException e) {
+ // LOG.error("query package by csarId from db error ! " + e.getMessage());
+ // return RestUtil.getRestException(e.getMessage());
+ // }
+ // if (result.size() <= 0) {
+ // LOG.warn("not exist package by serviceTemplateId");
+ // return Response.status(Status.NOT_FOUND).build();
+ // }
+ // if ("true".equals(result.get(0).getDeletionPending())) {
+ // LOG.info("start delete package.csarId:" + result.get(0).getCsarId());
+ // delCsarThread thread = new delCsarThread(result.get(0).getCsarId(), true);
+ // new Thread(thread).start();
+ // }
+ // return Response.noContent().build();
+ // }
+
+ class DelCsarThread implements Runnable {
+ private String csarid;
+ private boolean isInstanceTemplate = false;
+
+ public DelCsarThread(String csarid, boolean isInstanceTemplate) {
+ this.csarid = csarid;
+ this.isInstanceTemplate = isInstanceTemplate;
+ }
+
+ @Override
+ public void run() {
+ try {
+ if (!ToolUtil.isEmptyString(csarid)) {
+ delCsarData(csarid);
+ }
+ } catch (Exception e1) {
+ LOG.error("del instance csar fail.", e1);
+ updatePackageStatus(csarid, null, null, null, CommonConstant.PACKAGE_STATUS_DELETE_FAIL,
+ null);
+ // publishDelFinishCometdMessage(csarid, "false");
+ }
+ }
+
+ private void delCsarData(String csarId) {
+ updatePackageStatus(csarid, null, null, null, CommonConstant.PACKAGE_STATUS_DELETING, null);
+ String packagePath = PackageWrapperUtil.getPackagePath(csarId);
+ if (packagePath == null) {
+ LOG.error("package path is null! ");
+ return;
+ }
+ FileManagerFactory.createFileManager().delete(packagePath);
+ try {
+ PackageManager.getInstance().deletePackage(csarId);
+ } catch (CatalogResourceException e1) {
+ LOG.error("delete package by csarId from db error ! " + e1.getMessage());
+ }
+ // delete template data from db
+ PackageData packageData = new PackageData();
+ packageData.setCsarId(csarId);
+ try {
+ TemplateManager.getInstance().deleteServiceTemplateByCsarPackageInfo(packageData);
+ } catch (CatalogResourceException e2) {
+ LOG.error("delete template data from db error! csarId = " + csarId);
+ }
+ // publishDelFinishCometdMessage(csarid, "true");
+ }
+
+ // private void publishDelFinishCometdMessage(String csarid, String csarDelStatus) {
+ // if (isInstanceTemplate) {
+ // LOG.info("delete instance Template finish. csarid:{}", csarid);
+ // return;
+ // }
+ // try {
+ // Map<String, Object> cometdMessage = new HashMap<String, Object>();
+ // cometdMessage.put("csarid", csarid);
+ // cometdMessage.put("status", csarDelStatus);
+ // CometdService.getInstance().publish(CommonConstant.COMETD_CHANNEL_PACKAGE_DELETE,
+ // cometdMessage);
+ // } catch (CometdException e) {
+ // LOG.error("publish delfinish cometdmsg fail.", e);
+ // }
+ // }
+ }
+
+ /**
+ * update package status.
+ * @param csarId package id
+ * @param operationalState package operational state
+ * @param usageState package usage state
+ * @param onBoardState package onboard state
+ * @param processState package process state
+ * @param deletionPending package deletionPending status
+ * @return Response
+ */
+ public Response updatePackageStatus(String csarId, String operationalState, String usageState,
+ String onBoardState, String processState, String deletionPending) {
+ LOG.info("update package status info.csarId:" + csarId + " operationalState:"
+ + operationalState);
+ if (ToolUtil.isEmptyString(csarId)) {
+ LOG.error("update csar status fail, csarid is null");
+ return Response.serverError().build();
+ }
+ try {
+ // UpdatePackageResponse result = new UpdatePackageResponse();
+ PackageData packageInfo = new PackageData();
+ if (operationalState != null) {
+ packageInfo.setOperationalState(operationalState);
+ }
+ if (usageState != null) {
+ packageInfo.setUsageState(usageState);
+ }
+ if (onBoardState != null) {
+ packageInfo.setOnBoardState(onBoardState);
+ }
+ if (processState != null) {
+ packageInfo.setProcessState(processState);
+ }
+ if (deletionPending != null) {
+ packageInfo.setDeletionPending(deletionPending);
+ }
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String currentTime = sdf1.format(new Date());
+ packageInfo.setModifyTime(currentTime);
+ PackageManager.getInstance().updatePackage(packageInfo, csarId);
+ // ArrayList<PackageData> pacackgeList = PackageWrapperUtil.getPackageInfoById(csarId);
+ // String finalUsageState = pacackgeList.get(0).getUsageState();
+ // result.setUsageState(finalUsageState);
+ return Response.ok().build();
+ } catch (CatalogResourceException e1) {
+ LOG.error("update package status by csarId from db error ! " + e1.getMessage());
+ return RestUtil.getRestException(e1.getMessage());
+ }
+ }
+
+ /**
+ * download package by package id.
+ * @param csarId package id
+ * @return Response
+ */
+ public Response downloadCsarPackagesById(String csarId) {
+ ArrayList<PackageData> packageList = PackageWrapperUtil.getPackageInfoById(csarId);
+ String packageName = null;
+ if (null != packageList && packageList.size() > 0) {
+ packageName = packageList.get(0).getName();
+ }
+ String path = ToolUtil.getCatalogueCsarPath() + File.separator + packageName;
+ File csarFile = new File(path);
+ if (!csarFile.exists()) {
+ return Response.status(Status.NOT_FOUND).build();
+ }
+
+ try {
+ InputStream fis = new BufferedInputStream(new FileInputStream(path));
+ return Response.ok(fis)
+ .header("Content-Disposition", "attachment; filename=\"" + csarFile.getName() + "\"")
+ .build();
+ } catch (Exception e1) {
+ LOG.error("download vnf package fail.", e1);
+ return RestUtil.getRestException(e1.getMessage());
+ }
+ }
+
+ /**
+ * query package list by condition.
+ * @param name package name
+ * @param provider package provider
+ * @param version package version
+ * @param deletionPending package deletionPending
+ * @param type package type
+ * @return Response
+ */
+ public Response queryPackageListByCond(String name, String provider, String version,
+ String deletionPending, String type) {
+ ArrayList<PackageData> dbresult = new ArrayList<PackageData>();
+ ArrayList<PackageMeta> result = new ArrayList<PackageMeta>();
+ LOG.info("query package info.name:" + name + " provider:" + provider + " version" + version
+ + " deletionPending" + deletionPending + " type:" + type);
+ try {
+ dbresult =
+ PackageManager.getInstance().queryPackage(name, provider, version, deletionPending, type);
+ result = PackageWrapperUtil.packageDataList2PackageMetaList(dbresult);
+ return Response.ok(result).build();
+ } catch (CatalogResourceException e1) {
+ LOG.error("query package by csarId from db error ! " + e1.getMessage());
+ return RestUtil.getRestException(e1.getMessage());
+ }
+ }
+
+ /**
+ * get package file uri.
+ * @param csarId package id
+ * @param relativePath file relative path
+ * @return Response
+ */
+ public Response getCsarFileUri(String csarId, String relativePath) {
+ try {
+ CsarFileUriResponse result = getCsarFileDownloadUri(csarId, relativePath);
+ return Response.ok(result).build();
+ } catch (CatalogResourceException e1) {
+ LOG.error("Query CSAR package by ID failed ! csarId = " + csarId);
+ }
+
+ return Response.serverError().build();
+ }
+
+ /**
+ * get package file download uri.
+ * @param csarId package id
+ * @param relativePath package file relative path
+ * @return CsarFileUriResponse
+ * @throws CatalogResourceException e
+ */
+ public CsarFileUriResponse getCsarFileDownloadUri(String csarId, String relativePath)
+ throws CatalogResourceException {
+ CsarFileUriResponse result = new CsarFileUriResponse();
+ String downloadUrl = null;
+ String downloadUri = null;
+ String localPath = null;
+ ArrayList<PackageData> packageList = PackageManager.getInstance().queryPackageByCsarId(csarId);
+ if (packageList != null && packageList.size() != 0) {
+ String packageName = packageList.get(0).getName();
+ String relativeUri = packageList.get(0).getDownloadUri() + packageName;
+ downloadUri = relativeUri + relativePath;
+ downloadUrl = PackageWrapperUtil.getUrl(downloadUri);
+ String httpUri = HttpServerPathConfig.getHttpServerPath() + downloadUri;
+ localPath = PackageWrapperUtil.getLocalPath(httpUri);
+ }
+ result.setDownloadUri(downloadUrl);
+ result.setLocalPath(localPath);
+ return result;
+ }
+
+ /**
+ * upload package from ftp.
+ * @param request package basic information
+ * @return Response
+ */
+ public Response uploadPackageFromFtp(UploadPackageFromFtpRequest request) {
+ PackageBasicInfo basicInfo = new PackageBasicInfo();
+ String tempDirName = null;
+ String fileName = "";
+ UploadPackageResponse result = new UploadPackageResponse();
+ basicInfo.setProvider("zte");
+ basicInfo.setType(EnumType.NSAR);
+ basicInfo.setVersion("v1.0");
+ PackageMeta packageMeta = new PackageMeta();
+
+ try {
+ String ftpUrl = request.getFtpUrl();
+ String packageName = PackageWrapperUtil.getPackageName(ftpUrl);
+ fileName = ToolUtil.processFileName(packageName);
+ tempDirName = ToolUtil.getTempDir(CommonConstant.CATALOG_CSAR_DIR_NAME, fileName);
+ PackageWrapperUtil.downPackageFromFtp(ftpUrl, tempDirName);
+ String path =
+ basicInfo.getType().toString() + File.separator + basicInfo.getProvider()
+ + File.separator + fileName.replace(".csar", "") + File.separator
+ + basicInfo.getVersion();
+ LOG.info("dest path is : " + path);
+ packageMeta = PackageWrapperUtil.getPackageMeta(fileName, tempDirName, basicInfo);
+ String dowloadUri = File.separator + path + File.separator + fileName;
+ packageMeta.setDownloadUri(dowloadUri);
+ LOG.info("packageMeta = " + ToolUtil.objectToString(packageMeta));
+ String destPath = File.separator + path;
+ boolean uploadResult = FileManagerFactory.createFileManager().upload(tempDirName, destPath);
+ if (uploadResult == true) {
+ String newZipPath = tempDirName + fileName.replace(".csar", ".zip");
+ ZipCompressor zc = new ZipCompressor(newZipPath);
+ String metadataPath = tempDirName + File.separator + CommonConstant.TOSCA_METADATA;
+ String definitions = tempDirName + File.separator + CommonConstant.DEFINITIONS;
+ zc.compress(metadataPath, definitions);
+ String parseResult = ModelParserFactory.getInstance().parse(packageMeta.getCsarId(),
+ newZipPath, EnumPackageFormat.valueOf(packageMeta.getFormat()));
+ PackageData packageData = PackageWrapperUtil.getPackageData(packageMeta);
+ PackageManager.getInstance().addPackage(packageData);
+ }
+ LOG.info("upload package file end, fileName:" + fileName);
+ result.setCsarId(packageMeta.getCsarId());
+ return Response.ok(result).build();
+ } catch (Exception e1) {
+ LOG.error("upload package fail.", e1);
+ String csarId = packageMeta.getCsarId();
+ if (csarId != null) {
+ try {
+ PackageManager.getInstance().deletePackage(csarId);
+ } catch (CatalogResourceException e2) {
+ LOG.error("delete package failed !");
+ }
+ }
+ return RestUtil.getRestException(e1.getMessage());
+ } finally {
+ if (tempDirName != null) {
+ ToolUtil.deleteDir(new File(tempDirName));
+ }
+ }
+ }
+
+ /**
+ * get csar plan uri.
+ * @param csarId package id
+ * @return Response
+ */
+ public Response getCsarPlansUri(String csarId) {
+ ArrayList<FileLink> fileLinks = new ArrayList<FileLink>();
+ LOG.info("start query plans of package.csarId:" + csarId);
+ ArrayList<PackageData> packageList = new ArrayList<PackageData>();
+ try {
+ packageList = PackageManager.getInstance().queryPackageByCsarId(csarId);
+ if (packageList != null && packageList.size() != 0) {
+ String downloadUri = packageList.get(0).getDownloadUri();
+ fileLinks = FileManagerFactory.createFileManager().queryWorkFlow(downloadUri);
+ }
+ return Response.ok(fileLinks).build();
+ } catch (CatalogResourceException e1) {
+ LOG.error("Query plans of package by ID failed ! csarId = " + csarId);
+ return RestUtil.getRestException(e1.getMessage());
+ }
+ // return Response.serverError().build();
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java
index 2837fd36..6354e6a1 100644
--- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java
+++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java
@@ -1,413 +1,434 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.openo.commontosca.catalog.wrapper;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-
-import javax.ws.rs.NotFoundException;
-
-import org.openo.commontosca.catalog.common.CommonConstant;
-import org.openo.commontosca.catalog.common.FileUtil;
-import org.openo.commontosca.catalog.common.MsbAddrConfig;
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-import org.openo.commontosca.catalog.db.resource.PackageManager;
-import org.openo.commontosca.catalog.entity.EnumProcessState;
-import org.openo.commontosca.catalog.entity.EnumType;
-import org.openo.commontosca.catalog.entity.request.PackageBasicInfo;
-import org.openo.commontosca.catalog.ftp.Ftp;
-import org.openo.commontosca.catalog.model.entity.ServiceTemplate;
-import org.openo.commontosca.catalog.model.externalservice.entity.lifecycle.InstanceEntity;
-import org.openo.commontosca.catalog.model.externalservice.lifecycle.LifeCycleServiceConsumer;
-import org.openo.commontosca.catalog.common.ToolUtil;
-import org.openo.commontosca.catalog.db.entity.PackageData;
-import org.openo.commontosca.catalog.entity.CsarPackage;
-import org.openo.commontosca.catalog.entity.EnumOnboardState;
-import org.openo.commontosca.catalog.entity.EnumOperationalState;
-import org.openo.commontosca.catalog.entity.EnumUsageState;
-import org.openo.commontosca.catalog.entity.response.PackageMeta;
-import org.openo.commontosca.catalog.ftp.FtpUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-
-/**
- * @author 00164331
- *
- */
-public class PackageWrapperUtil {
- private static final Logger LOG = LoggerFactory.getLogger(PackageWrapperUtil.class);
-
-
- public static List<CsarPackage> formJson2Packages(String packageJson) {
- List<CsarPackage> packageList =
- new Gson().fromJson(packageJson, new TypeToken<List<CsarPackage>>() {}.getType());
- if (null == packageList || packageList.size() == 0) {
- throw new NotFoundException("Package do not exist");
- }
- return packageList;
- }
-
- public static long getPacakgeSize(String fileLocation) {
- File file = new File(fileLocation);
- return file.length();
- }
-
- public static PackageData getPackageData(PackageMeta meta) {
- PackageData packageData = new PackageData();
- packageData.setCreateTime(meta.getCreateTime());
- packageData.setDeletionPending(String.valueOf(meta.isDeletionPending()));
- packageData.setDownloadUri(meta.getDownloadUri());
- packageData.setFormat(meta.getFormat());
- packageData.setModifyTime(meta.getModifyTime());
- packageData.setName(meta.getName());
- packageData.setCsarId(meta.getCsarId());
- packageData.setOperationalState(meta.getOperationalState().toString());
- packageData.setProvider(meta.getProvider());
- String fileSize = meta.getSize();
- packageData.setSize(fileSize);
- packageData.setType(meta.getType());
- packageData.setUsageState(meta.getUsageState().toString());
- packageData.setVersion(meta.getVersion());
- packageData.setOnBoardState(meta.getOnBoardState());
- packageData.setProcessState(meta.getProcessState().toString());
- return packageData;
- }
-
- public static boolean isUploadEnd(String contentRange, String csarName) {
- String range = contentRange;
- range = range.replace("bytes", "").trim();
- range = range.substring(0, range.indexOf("/"));
- String size =
- contentRange.substring(contentRange.indexOf("/") + 1, contentRange.length()).trim();
- int fileSize = Integer.parseInt(size);
- String[] ranges = range.split("-");
- int startPosition = Integer.parseInt(ranges[0]);
- if (startPosition == 0) {
- // delPackageBySync(csarName);
- }
- // index start from 0
- int endPosition = Integer.parseInt(ranges[1]) + 1;
- if (endPosition >= fileSize) {
- return true;
- }
- return false;
- }
-
- public static ArrayList<PackageData> getPackageInfoById(String csarId) {
- ArrayList<PackageData> result = new ArrayList<PackageData>();
- try {
- result = PackageManager.getInstance().queryPackageByCsarId(csarId);
- } catch (CatalogResourceException e) {
- LOG.error("query package by csarId from db error ! " + e.getMessage());
- }
- return result;
- }
-
- public static PackageMeta getPackageMeta(String fileName, String fileLocation,
- PackageBasicInfo basic) {
- PackageMeta packageMeta = new PackageMeta();
- long size = getPacakgeSize(fileLocation);
- packageMeta.setFormat(basic.getFormat());
- String packageId = ToolUtil.generateId();
- packageMeta.setName(fileName.replace(CommonConstant.CSAR_SUFFIX, ""));
- packageMeta.setCsarId(packageId);
- packageMeta.setType(basic.getType().toString());
- packageMeta.setVersion(basic.getVersion());
- packageMeta.setProvider(basic.getProvider());
- packageMeta.setDeletionPending(false);
- String sizeStr = ToolUtil.getFormatFileSize(size);
- packageMeta.setSize(sizeStr);
- SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String currentTime = sdf1.format(new Date());
- packageMeta.setCreateTime(currentTime);
- packageMeta.setModifyTime(currentTime);
- packageMeta.setOperationalState(EnumOperationalState.Disabled);
- packageMeta.setUsageState(EnumUsageState.NotInUse);
- packageMeta.setOnBoardState(EnumOnboardState.nonOnBoarded.getValue());
- packageMeta.setProcessState(EnumProcessState.normal);
- return packageMeta;
- }
-
- public static String getPackagePath(String csarId) {
- ArrayList<PackageData> packageList = new ArrayList<PackageData>();
- String downloadUri = null;
- try {
- packageList = PackageManager.getInstance().queryPackageByCsarId(csarId);
- downloadUri = packageList.get(0).getDownloadUri();
- } catch (CatalogResourceException e) {
- LOG.error("Query CSAR package by ID failed ! csarId = " + csarId);
- }
- return downloadUri;
- }
-
-
- public static HashSet<String> instanceConvertToHashSet(ArrayList<InstanceEntity> instancelist) {
- HashSet<String> result = new HashSet<String>();
- if (instancelist != null) {
- for (InstanceEntity instance : instancelist) {
- result.add(instance.getServiceTemplateId());
- }
- }
- return result;
- }
-
- public static boolean isExistInstanceCSAR(String csarId) {
- // 查询各O(GSO、NFVO、SDNO)的资源实例数据库,查询指定csarId对应的服务模版
- ArrayList<ServiceTemplate> templateList = queryAvailableTemplatesByCsar(csarId);
- // 调生命周期的接口查询所有实例,查询实例中是否包含指定csarId对应的服务模析ID
- HashSet<String> templateSet = instanceConvertToHashSet(LifeCycleServiceConsumer.getInstances());
- if (templateList != null && templateList.size() > 0 && templateSet.size() > 0) {
- for (ServiceTemplate temp : templateList) {
- if (templateSet.contains(temp.getServiceTemplateId())) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static ArrayList<ServiceTemplate> queryAvailableTemplatesByCsar(String csarId) {
- return null;
- // ArrayList<ServiceTemplate> resultlist = new ArrayList<ServiceTemplate>();
- // String filter = LDAPUtil.getObjectClassFilter(LDAPConstant.OBJECTCLASS_CSAR);
- // String result =
- // LDAPDataFactory.getInstance().queryData(EnumLDAPData.SERVICETEMPLATE, null, false,
- // filter);
- // Type type = new TypeToken<ArrayList<ServiceTemplate>>() {}.getType();
- // ArrayList<ServiceTemplate> templateList = new Gson().fromJson(result, type);
- // for (ServiceTemplate temp : templateList) {
- // if (temp.getCsarid().equals(csarId)) {
- // resultlist.add(temp);
- // }
- // }
- // return resultlist;
- }
-
- // public static void publishDeletionPendingStatusCometdMessage(String csarid) {
- // try {
- // Map<String, Object> cometdMessage = new HashMap<String, Object>();
- // cometdMessage.put("csarid", csarid);
- // cometdMessage.put("status", "deletionPending");
- // CometdService.getInstance().publish(CommonConstant.COMETD_CHANNEL_PACKAGE_DELETE,
- // cometdMessage);
- // } catch (CometdException e) {
- // LOG.error("publish delfinish cometdmsg fail.", e);
- // }
- // }
-
- /**
- * @param ftpUrl
- * @return
- */
- public static Ftp getFtpDetail(String ftpUrl) {
- Ftp ftp = new Ftp();
- int index1 = ftpUrl.indexOf("ftp://");
- int index2 = ftpUrl.indexOf("@");
- String userPassSubString = ftpUrl.substring(index1, index2);
- int index3 = userPassSubString.indexOf(":");
- String userName = userPassSubString.substring(0, index3);
- String pass = userPassSubString.substring(index3 + 1);
- String subString1 = ftpUrl.substring(index2 + 1);
- int index4 = subString1.indexOf("/");
- String ipPortSubString = subString1.substring(0, index4);
- int index5 = ipPortSubString.indexOf(":");
- String ip = ipPortSubString.substring(0, index5);
- String port = ipPortSubString.substring(index5 + 1);
- int index6 = ftpUrl.lastIndexOf("/");
- String path = ftpUrl.substring(0, index6);
- ftp.setIpAddr(ip);
- ftp.setPath(path);
- ftp.setPort(Integer.valueOf(port));
- ftp.setPwd(pass);
- ftp.setUserName(userName);
- return ftp;
- }
-
- /**
- * @param ftpUrl
- * @return
- */
- // public static String getFtpDir(String ftpUrl) {
- // // TODO Auto-generated method stub
- // return null;
- // }
-
- /**
- * @param ftpUrl
- * @return
- */
- public static String getPackageName(String ftpUrl) {
- int index = ftpUrl.lastIndexOf("/");
- String packageName = ftpUrl.substring(index);
- return packageName;
- }
-
- public static void downPackageFromFtp(String ftpUrl, String tempDirName) {
- Ftp ftp = new Ftp();
- ftp = PackageWrapperUtil.getFtpDetail(ftpUrl);
- String remoteBaseDir = ftp.getPath();
- try {
- FtpUtil.startDown(ftp, tempDirName, remoteBaseDir);
- } catch (Exception e) {
- LOG.error("Down package from ftp failed !");
- }
- }
-
- /**
- * @param dbResult
- * @return
- */
- public static ArrayList<PackageMeta> packageDataList2PackageMetaList(
- ArrayList<PackageData> dbResult) {
- ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
- PackageMeta meta = new PackageMeta();
- for (int i = 0; i < dbResult.size(); i++) {
- PackageData data = dbResult.get(i);
- meta = packageData2PackageMeta(data);
- metas.add(meta);
- }
- return metas;
- }
-
- public static EnumOnboardState getEnumByValue(String value) {
- if (value == "non-onBoarded") {
- return EnumOnboardState.nonOnBoarded;
- } else {
- return EnumOnboardState.onBoarded;
- }
- }
-
- private static PackageMeta packageData2PackageMeta(PackageData packageData) {
- PackageMeta meta = new PackageMeta();
- meta.setCsarId(packageData.getCsarId());
- meta.setCreateTime(packageData.getCreateTime());
- meta.setDeletionPending(Boolean.getBoolean(packageData.getDeletionPending()));
- String packageUri =
- packageData.getDownloadUri() + packageData.getName() + CommonConstant.CSAR_SUFFIX;
- String packageUrl = getUrl(packageUri);
- meta.setDownloadUri(packageUrl);
- meta.setFormat(packageData.getFormat());
- meta.setModifyTime(packageData.getModifyTime());
- meta.setName(packageData.getName());
- meta.setOperationalState(EnumOperationalState.valueOf(packageData.getOperationalState()));
- meta.setProvider(packageData.getProvider());
- meta.setSize(packageData.getSize());
- meta.setType(packageData.getType());
- meta.setUsageState(EnumUsageState.valueOf(packageData.getUsageState()));
- meta.setVersion(packageData.getVersion());
- meta.setOnBoardState(packageData.getOnBoardState());
- meta.setProcessState(EnumProcessState.valueOf(packageData.getProcessState()));
- return meta;
- }
-
- public static String getUrl(String uri) {
- String url = null;
- if ((MsbAddrConfig.getMsbAddress().endsWith("/")) && uri.startsWith("/")) {
- url = MsbAddrConfig.getMsbAddress() + uri.substring(1);
- }
- url = MsbAddrConfig.getMsbAddress() + uri;
- String urlresult = url.replace("\\", "/");
- return urlresult;
- }
-
- public static String getLocalPath(String uri) {
- File srcDir = new File(uri);
- String localPath = srcDir.getAbsolutePath();
- return localPath.replace("\\", "/");
- }
-
- /**
- * @param fileLocation
- * @return
- */
- public static PackageBasicInfo getPacageBasicInfo(String fileLocation) {
- PackageBasicInfo basicInfo = new PackageBasicInfo();
- String unzipDir = ToolUtil.getUnzipDir(fileLocation);
- boolean isXmlCsar = false;
- try {
- String tempfolder = unzipDir;
- ArrayList<String> unzipFiles = FileUtil.unzip(fileLocation, tempfolder);
- if (unzipFiles.isEmpty()) {
- isXmlCsar = true;
- }
- for (String unzipFile : unzipFiles) {
- if (unzipFile.endsWith(CommonConstant.CSAR_META)) {
- basicInfo = readCsarMeta(unzipFile);
- }
- if (ToolUtil.isYamlFile(new File(unzipFile))) {
- isXmlCsar = false;
- }
- }
- } catch (IOException e) {
- LOG.error("judge package type error !");
- }
- if (isXmlCsar) {
- basicInfo.setFormat(CommonConstant.PACKAGE_XML_FORMAT);
- } else {
- basicInfo.setFormat(CommonConstant.PACKAGE_YAML_FORMAT);
- }
- return basicInfo;
- }
-
- /**
- * @param unzipFile
- * @return
- */
- private static PackageBasicInfo readCsarMeta(String unzipFile) {
- PackageBasicInfo basicInfo = new PackageBasicInfo();
- File file = new File(unzipFile);
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new FileReader(file));
- String tempString = null;
- while ((tempString = reader.readLine()) != null) {
- if (tempString.startsWith(CommonConstant.CSAR_TYPE_META)) {
- int count = tempString.indexOf(":") + 1;
- basicInfo.setType(EnumType.valueOf(tempString.substring(count)));
- }
- if (tempString.startsWith(CommonConstant.CSAR_PROVIDER_META)) {
- int count = tempString.indexOf(":") + 1;
- basicInfo.setProvider(tempString.substring(count));
- }
- if (tempString.startsWith(CommonConstant.CSAR_VERSION_META)) {
- int count = tempString.indexOf(":") + 1;
- basicInfo.setVersion(tempString.substring(count));
- }
- }
- reader.close();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e1) {
- }
- }
- }
- return basicInfo;
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.wrapper;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import org.openo.commontosca.catalog.common.CommonConstant;
+import org.openo.commontosca.catalog.common.FileUtil;
+import org.openo.commontosca.catalog.common.MsbAddrConfig;
+import org.openo.commontosca.catalog.common.ToolUtil;
+import org.openo.commontosca.catalog.db.entity.PackageData;
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+import org.openo.commontosca.catalog.db.resource.PackageManager;
+import org.openo.commontosca.catalog.entity.CsarPackage;
+import org.openo.commontosca.catalog.entity.EnumOnboardState;
+import org.openo.commontosca.catalog.entity.EnumOperationalState;
+import org.openo.commontosca.catalog.entity.EnumProcessState;
+import org.openo.commontosca.catalog.entity.EnumType;
+import org.openo.commontosca.catalog.entity.EnumUsageState;
+import org.openo.commontosca.catalog.entity.request.PackageBasicInfo;
+import org.openo.commontosca.catalog.entity.response.PackageMeta;
+import org.openo.commontosca.catalog.ftp.Ftp;
+import org.openo.commontosca.catalog.ftp.FtpUtil;
+import org.openo.commontosca.catalog.model.entity.ServiceTemplate;
+import org.openo.commontosca.catalog.model.externalservice.entity.lifecycle.InstanceEntity;
+import org.openo.commontosca.catalog.model.externalservice.lifecycle.LifeCycleServiceConsumer;
+import org.openo.commontosca.catalog.model.parser.EnumPackageFormat;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.ws.rs.NotFoundException;
+
+public class PackageWrapperUtil {
+ private static final Logger LOG = LoggerFactory.getLogger(PackageWrapperUtil.class);
+
+
+ /**
+ * change json to object list.
+ * @param packageJson json
+ * @return package list
+ */
+ public static List<CsarPackage> formJson2Packages(String packageJson) {
+ List<CsarPackage> packageList =
+ new Gson().fromJson(packageJson, new TypeToken<List<CsarPackage>>() {}.getType());
+ if (null == packageList || packageList.size() == 0) {
+ throw new NotFoundException("Package do not exist");
+ }
+ return packageList;
+ }
+
+ public static long getPacakgeSize(String fileLocation) {
+ File file = new File(fileLocation);
+ return file.length();
+ }
+
+ /**
+ * change package metadata to fix database.
+ * @param meta package metadata
+ * @return package data in database
+ */
+ public static PackageData getPackageData(PackageMeta meta) {
+ PackageData packageData = new PackageData();
+ packageData.setCreateTime(meta.getCreateTime());
+ packageData.setDeletionPending(String.valueOf(meta.isDeletionPending()));
+ packageData.setDownloadUri(meta.getDownloadUri());
+ packageData.setFormat(meta.getFormat());
+ packageData.setModifyTime(meta.getModifyTime());
+ packageData.setName(meta.getName());
+ packageData.setCsarId(meta.getCsarId());
+ packageData.setOperationalState(meta.getOperationalState().toString());
+ packageData.setProvider(meta.getProvider());
+ String fileSize = meta.getSize();
+ packageData.setSize(fileSize);
+ packageData.setType(meta.getType());
+ packageData.setUsageState(meta.getUsageState().toString());
+ packageData.setVersion(meta.getVersion());
+ packageData.setOnBoardState(meta.getOnBoardState());
+ packageData.setProcessState(meta.getProcessState().toString());
+ return packageData;
+ }
+
+ /**
+ * judge wether is the end of upload package.
+ * @param contentRange package sise range
+ * @param csarName package name
+ * @return boolean
+ */
+ public static boolean isUploadEnd(String contentRange, String csarName) {
+ String range = contentRange;
+ range = range.replace("bytes", "").trim();
+ range = range.substring(0, range.indexOf("/"));
+ String size =
+ contentRange.substring(contentRange.indexOf("/") + 1, contentRange.length()).trim();
+ int fileSize = Integer.parseInt(size);
+ String[] ranges = range.split("-");
+ int startPosition = Integer.parseInt(ranges[0]);
+ if (startPosition == 0) {
+ // delPackageBySync(csarName);
+ }
+ // index start from 0
+ int endPosition = Integer.parseInt(ranges[1]) + 1;
+ if (endPosition >= fileSize) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * get package detail by package id.
+ * @param csarId package id
+ * @return package detail
+ */
+ public static ArrayList<PackageData> getPackageInfoById(String csarId) {
+ ArrayList<PackageData> result = new ArrayList<PackageData>();
+ try {
+ result = PackageManager.getInstance().queryPackageByCsarId(csarId);
+ } catch (CatalogResourceException e1) {
+ LOG.error("query package by csarId from db error ! " + e1.getMessage());
+ }
+ return result;
+ }
+
+ /**
+ * get package metadata from basic info.
+ * @param fileName package name
+ * @param fileLocation the location of package
+ * @param basic basic infomation of package. include version, type and provider
+ * @return package metadata
+ */
+ public static PackageMeta getPackageMeta(String fileName, String fileLocation,
+ PackageBasicInfo basic) {
+ PackageMeta packageMeta = new PackageMeta();
+ long size = getPacakgeSize(fileLocation);
+ packageMeta.setFormat(basic.getFormat());
+ String packageId = ToolUtil.generateId();
+ packageMeta.setName(fileName.replace(CommonConstant.CSAR_SUFFIX, ""));
+ packageMeta.setCsarId(packageId);
+ packageMeta.setType(basic.getType().toString());
+ packageMeta.setVersion(basic.getVersion());
+ packageMeta.setProvider(basic.getProvider());
+ packageMeta.setDeletionPending(false);
+ String sizeStr = ToolUtil.getFormatFileSize(size);
+ packageMeta.setSize(sizeStr);
+ SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String currentTime = sdf1.format(new Date());
+ packageMeta.setCreateTime(currentTime);
+ packageMeta.setModifyTime(currentTime);
+ packageMeta.setOperationalState(EnumOperationalState.Disabled);
+ packageMeta.setUsageState(EnumUsageState.NotInUse);
+ packageMeta.setOnBoardState(EnumOnboardState.nonOnBoarded.getValue());
+ packageMeta.setProcessState(EnumProcessState.normal);
+ return packageMeta;
+ }
+
+ /**
+ * get downloadUri from package metadata.
+ * @param csarId package id
+ * @return download uri
+ */
+ public static String getPackagePath(String csarId) {
+ ArrayList<PackageData> packageList = new ArrayList<PackageData>();
+ String downloadUri = null;
+ try {
+ packageList = PackageManager.getInstance().queryPackageByCsarId(csarId);
+ downloadUri = packageList.get(0).getDownloadUri();
+ } catch (CatalogResourceException e1) {
+ LOG.error("Query CSAR package by ID failed ! csarId = " + csarId);
+ }
+ return downloadUri;
+ }
+
+
+ /**
+ * convert instance to hashset.
+ * @param instancelist instance list
+ * @return HashSet
+ */
+ public static HashSet<String> instanceConvertToHashSet(ArrayList<InstanceEntity> instancelist) {
+ HashSet<String> result = new HashSet<String>();
+ if (instancelist != null) {
+ for (InstanceEntity instance : instancelist) {
+ result.add(instance.getServiceTemplateId());
+ }
+ }
+ return result;
+ }
+
+ /**
+ * get ftp detail information.
+ * @param ftpUrl ftp url
+ * @return ftp detail
+ */
+ public static Ftp getFtpDetail(String ftpUrl) {
+ Ftp ftp = new Ftp();
+ int index1 = ftpUrl.indexOf("ftp://");
+ int index2 = ftpUrl.indexOf("@");
+ String userPassSubString = ftpUrl.substring(index1, index2);
+ int index3 = userPassSubString.indexOf(":");
+ String userName = userPassSubString.substring(0, index3);
+ String pass = userPassSubString.substring(index3 + 1);
+ String subString1 = ftpUrl.substring(index2 + 1);
+ int index4 = subString1.indexOf("/");
+ String ipPortSubString = subString1.substring(0, index4);
+ int index5 = ipPortSubString.indexOf(":");
+ String ip = ipPortSubString.substring(0, index5);
+ String port = ipPortSubString.substring(index5 + 1);
+ int index6 = ftpUrl.lastIndexOf("/");
+ String path = ftpUrl.substring(0, index6);
+ ftp.setIpAddr(ip);
+ ftp.setPath(path);
+ ftp.setPort(Integer.valueOf(port));
+ ftp.setPwd(pass);
+ ftp.setUserName(userName);
+ return ftp;
+ }
+
+ /**
+ * get package name from ftpUrl.
+ * @param ftpUrl ftp url
+ * @return package name
+ */
+ public static String getPackageName(String ftpUrl) {
+ int index = ftpUrl.lastIndexOf("/");
+ String packageName = ftpUrl.substring(index);
+ return packageName;
+ }
+
+ /**
+ * download package from ftp.
+ * @param ftpUrl ftp url
+ * @param tempDirName temp directory
+ */
+ public static void downPackageFromFtp(String ftpUrl, String tempDirName) {
+ Ftp ftp = new Ftp();
+ ftp = PackageWrapperUtil.getFtpDetail(ftpUrl);
+ String remoteBaseDir = ftp.getPath();
+ try {
+ FtpUtil.startDown(ftp, tempDirName, remoteBaseDir);
+ } catch (Exception e1) {
+ LOG.error("Down package from ftp failed !");
+ }
+ }
+
+ /**
+ * translate package data from database to package metadata.
+ * @param dbResult data from database
+ * @return package metadata list
+ */
+ public static ArrayList<PackageMeta> packageDataList2PackageMetaList(
+ ArrayList<PackageData> dbResult) {
+ ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
+ PackageMeta meta = new PackageMeta();
+ for (int i = 0; i < dbResult.size(); i++) {
+ PackageData data = dbResult.get(i);
+ meta = packageData2PackageMeta(data);
+ metas.add(meta);
+ }
+ return metas;
+ }
+
+ /**
+ * get onboarded enum value.
+ * @param value onboard value
+ * @return enum
+ */
+ public static EnumOnboardState getEnumByValue(String value) {
+ if (value == "non-onBoarded") {
+ return EnumOnboardState.nonOnBoarded;
+ } else {
+ return EnumOnboardState.onBoarded;
+ }
+ }
+
+ private static PackageMeta packageData2PackageMeta(PackageData packageData) {
+ PackageMeta meta = new PackageMeta();
+ meta.setCsarId(packageData.getCsarId());
+ meta.setCreateTime(packageData.getCreateTime());
+ meta.setDeletionPending(Boolean.getBoolean(packageData.getDeletionPending()));
+ String packageUri =
+ packageData.getDownloadUri() + packageData.getName() + CommonConstant.CSAR_SUFFIX;
+ String packageUrl = getUrl(packageUri);
+ meta.setDownloadUri(packageUrl);
+ meta.setFormat(packageData.getFormat());
+ meta.setModifyTime(packageData.getModifyTime());
+ meta.setName(packageData.getName());
+ meta.setOperationalState(EnumOperationalState.valueOf(packageData.getOperationalState()));
+ meta.setProvider(packageData.getProvider());
+ meta.setSize(packageData.getSize());
+ meta.setType(packageData.getType());
+ meta.setUsageState(EnumUsageState.valueOf(packageData.getUsageState()));
+ meta.setVersion(packageData.getVersion());
+ meta.setOnBoardState(packageData.getOnBoardState());
+ meta.setProcessState(EnumProcessState.valueOf(packageData.getProcessState()));
+ return meta;
+ }
+
+ /**
+ * add msb address as prefix to uri.
+ * @param uri uri
+ * @return url
+ */
+ public static String getUrl(String uri) {
+ String url = null;
+ if ((MsbAddrConfig.getMsbAddress().endsWith("/")) && uri.startsWith("/")) {
+ url = MsbAddrConfig.getMsbAddress() + uri.substring(1);
+ }
+ url = MsbAddrConfig.getMsbAddress() + uri;
+ String urlresult = url.replace("\\", "/");
+ return urlresult;
+ }
+
+ /**
+ * get local path.
+ * @param uri uri
+ * @return local path
+ */
+ public static String getLocalPath(String uri) {
+ File srcDir = new File(uri);
+ String localPath = srcDir.getAbsolutePath();
+ return localPath.replace("\\", "/");
+ }
+
+ /**
+ * get package basic information.
+ * @param fileLocation package location
+ * @return package basic information
+ */
+ public static PackageBasicInfo getPacageBasicInfo(String fileLocation) {
+ PackageBasicInfo basicInfo = new PackageBasicInfo();
+ String unzipDir = ToolUtil.getUnzipDir(fileLocation);
+ boolean isXmlCsar = false;
+ try {
+ String tempfolder = unzipDir;
+ ArrayList<String> unzipFiles = FileUtil.unzip(fileLocation, tempfolder);
+ if (unzipFiles.isEmpty()) {
+ isXmlCsar = true;
+ }
+ for (String unzipFile : unzipFiles) {
+ if (unzipFile.endsWith(CommonConstant.CSAR_META)) {
+ basicInfo = readCsarMeta(unzipFile);
+ }
+ if (ToolUtil.isYamlFile(new File(unzipFile))) {
+ isXmlCsar = false;
+ }
+ }
+ } catch (IOException e1) {
+ LOG.error("judge package type error !");
+ }
+ if (isXmlCsar) {
+ basicInfo.setFormat(CommonConstant.PACKAGE_XML_FORMAT);
+ } else {
+ basicInfo.setFormat(CommonConstant.PACKAGE_YAML_FORMAT);
+ }
+ return basicInfo;
+ }
+
+ private static PackageBasicInfo readCsarMeta(String unzipFile) {
+ PackageBasicInfo basicInfo = new PackageBasicInfo();
+ File file = new File(unzipFile);
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(file));
+ String tempString = null;
+ while ((tempString = reader.readLine()) != null) {
+ if (tempString.startsWith(CommonConstant.CSAR_TYPE_META)) {
+ int count = tempString.indexOf(":") + 1;
+ basicInfo.setType(EnumType.valueOf(tempString.substring(count)));
+ }
+ if (tempString.startsWith(CommonConstant.CSAR_PROVIDER_META)) {
+ int count = tempString.indexOf(":") + 1;
+ basicInfo.setProvider(tempString.substring(count));
+ }
+ if (tempString.startsWith(CommonConstant.CSAR_VERSION_META)) {
+ int count = tempString.indexOf(":") + 1;
+ basicInfo.setVersion(tempString.substring(count));
+ }
+ }
+ reader.close();
+ } catch (IOException e2) {
+ e2.printStackTrace();
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e1) {
+ LOG.error("close reader failed ! " + e1.getMessage());
+ }
+ }
+ }
+ return basicInfo;
+ }
+
+ /**
+ * get package format enum.
+ * @param format package format
+ * @return package format enum
+ */
+ public static EnumPackageFormat getPackageFormat(String format) {
+ if (format.equals("xml")) {
+ return EnumPackageFormat.TOSCA_XML;
+ } else if (format.equals("yml") || format.equals("yaml")) {
+ return EnumPackageFormat.TOSCA_YAML;
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java
index 20a0d355..b8e3367e 100644
--- a/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java
+++ b/catalog-core/catalog-mgr/src/test/java/org/openo/commontosca/catalog/wrapper/PackageWrapperTest.java
@@ -1,331 +1,331 @@
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.wrapper;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openo.commontosca.catalog.CatalogAppConfiguration;
-import org.openo.commontosca.catalog.common.Config;
-import org.openo.commontosca.catalog.common.HttpServerAddrConfig;
-import org.openo.commontosca.catalog.common.HttpServerPathConfig;
-import org.openo.commontosca.catalog.common.MsbAddrConfig;
-import org.openo.commontosca.catalog.db.dao.DaoManager;
-import org.openo.commontosca.catalog.db.entity.PackageData;
-import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
-import org.openo.commontosca.catalog.db.resource.PackageManager;
-import org.openo.commontosca.catalog.db.util.H2DbServer;
-import org.openo.commontosca.catalog.db.util.HibernateSession;
-import org.openo.commontosca.catalog.entity.EnumOnboardState;
-import org.openo.commontosca.catalog.entity.EnumOperationalState;
-import org.openo.commontosca.catalog.entity.EnumProcessState;
-import org.openo.commontosca.catalog.entity.EnumUsageState;
-import org.openo.commontosca.catalog.entity.response.CsarFileUriResponse;
-import org.openo.commontosca.catalog.entity.response.PackageMeta;
-import org.openo.commontosca.catalog.filemanage.entity.FileLink;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-
-import javax.ws.rs.core.Response;
-
-public class PackageWrapperTest {
- private static String resourcePath;
-
- static {
- MsbAddrConfig.setMsbAddress("http://127.0.0.1:80");
- }
-
- static {
- HttpServerAddrConfig.setHttpServerAddress("http://127.0.0.1:8080");
- }
-
- static {
- HttpServerPathConfig.setHttpServerPath("../tomcat/webapps/ROOT/");
- }
-
- private static PackageManager manager;
-
-
- /**
- * startup db session before class.
- * @throws Exception e
- */
- @BeforeClass
- public static void setUpBeforeClass() throws CatalogResourceException {
- H2DbServer.startUp();
- DaoManager.getInstance().setSessionFactory(HibernateSession.init());
- manager = PackageManager.getInstance();
- CatalogAppConfiguration configuration = new CatalogAppConfiguration();
- Config.setConfigration(configuration);
- System.out.println("Set up before class");
- }
-
- /**
- * create data before test.
- */
- @Before
- public void setUp() throws Exception {
- ArrayList<PackageData> packageList = manager.queryPackage(null, null, null, null, null);
- if (packageList != null && packageList.size() > 0) {
- for (int i = 0; i < packageList.size(); i++) {
- String packageOid = packageList.get(i).getCsarId();
- manager.deletePackage(packageOid);
- }
- }
-
- // PowerMockito.mockStatic(PackageManager.class);
- // PowerMockito.when(manager.addPackage(packageData)).thenReturn(packageData);
- // PowerMock.replayAll();
- PackageData packageData = new PackageData();
- packageData = getPackageData();
- manager.addPackage(packageData);
- }
-
- // @Ignore
- @Test
- public void testUploadPackage() throws Exception {
- InputStream ins = null;
- Response result = null;
- Response result1 = null;
- Response result2 = null;
- // PackageData packageData = new PackageData();
- // packageData = getPackageData();
-
- FormDataContentDisposition fileDetail =
- FormDataContentDisposition.name("fileName").fileName("NanocellGW.csar").build();
-
- try {
- resourcePath = HibernateSession.class.getResource("/").toURI().getPath();
- } catch (URISyntaxException e1) {
- e1.printStackTrace();
- }
- final String filename = "NanocellGW.csar";
- File packageFile = new File(resourcePath + filename);
- try {
- ins = new FileInputStream(packageFile);
- } catch (FileNotFoundException e2) {
- e2.printStackTrace();
- }
- if (ins != null) {
- try {
- result = PackageWrapper.getInstance().uploadPackage(ins, fileDetail, null);
- } catch (Exception e3) {
- e3.printStackTrace();
- }
- }
- assertEquals(200, result.getStatus());
- assertNotNull(result.getEntity());
-
- try {
- result1 = PackageWrapper.getInstance().uploadPackage(null, fileDetail, null);
- } catch (Exception e4) {
- e4.printStackTrace();
- }
- assertEquals(500, result1.getStatus());
-
- try {
- result2 = PackageWrapper.getInstance().uploadPackage(ins, null, null);
- } catch (Exception e5) {
- e5.printStackTrace();
- }
- assertEquals(500, result2.getStatus());
- }
-
- @Test
- public void testQueryPackageById() throws Exception {
- ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
- metas = getPackageMetaList();
- // PackageManager packageManager = mock(PackageManager.class);
- // when(packageManager.queryPackageByCsarId(anyString())).thenThrow(new Exception());
- // PowerMockito.whenNew(PackageManager.class).withNoArguments().thenReturn(packageManager);
- // PowerMockito.mockStatic(PackageManager.class);
- // PowerMockito.when(PackageManager.getInstance()).thenReturn(manager);
- // PowerMock.replayAll();
- // when(manager.queryPackageByCsarId(anyString())).thenThrow(new Exception());
- // PowerMockito.whenNew(PackageManager.class).withNoArguments().thenReturn(manager);
-
- Response result = PackageWrapper.getInstance().queryPackageById("1");
- assertEquals(200, result.getStatus());
- assertEquals(metas, result.getEntity());
-
- }
-
- @Test
- public void testQueryPackageByCond() {
- ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
- metas = getPackageMetaList();
- System.out.println("Test query package by Id");
- Response result =
- PackageWrapper.getInstance().queryPackageListByCond("NanocellGW", "ZTE", "V1.0", "false",
- "NSAR");
- assertEquals(200, result.getStatus());
- assertEquals(metas, result.getEntity());
- }
-
- @Test
- public void testUpdatePackageStatus() {
- System.out.println("Test update package status");
- Response result =
- PackageWrapper.getInstance().updatePackageStatus("1", "Enabled", "NotInUse", "true",
- "onBoarding", "true");
- assertEquals(200, result.getStatus());
- }
-
- @Test
- public void testGetCsarFileUri() {
- System.out.println("Test get csar file uri ");
- CsarFileUriResponse expectResult = new CsarFileUriResponse();
- String csarFileUri =
- MsbAddrConfig.getMsbAddress() + "/NSAR/ZTE/NanocellGW/v1.0/NanocellGW/images/segw.img";
- String localUri =
- HttpServerPathConfig.getHttpServerPath()
- + "NSAR/ZTE/NanocellGW/v1.0/NanocellGW/images/segw.img";
- File srcDir = new File(localUri);
- String localPath = srcDir.getAbsolutePath().replace("\\", "/");
-
- expectResult.setDownloadUri(csarFileUri);
- expectResult.setLocalPath(localPath);
- Response result = PackageWrapper.getInstance().getCsarFileUri("1", "/images/segw.img");
- assertEquals(200, result.getStatus());
- assertEquals(expectResult, result.getEntity());
- }
-
- @Ignore
- @Test
- public void testGetPlansUri() {
- System.out.println("Test get csar plans uri ");
- ArrayList<FileLink> expectResult = new ArrayList<FileLink>();
- FileLink fileLink1 = new FileLink();
- fileLink1.setFileName("init.zip");
- fileLink1.setDownloadUri(MsbAddrConfig.getMsbAddress()
- + "/NSAR/ZTE/NanocellGW/v1.0/Plans/init.zip");
- expectResult.add(fileLink1);
- FileLink fileLink2 = new FileLink();
- fileLink2.setFileName("delete.zip");
- fileLink2.setDownloadUri(MsbAddrConfig.getMsbAddress()
- + "/NSAR/ZTE/NanocellGW/v1.0/Plans/delete.zip");
- expectResult.add(fileLink2);
- Response result = PackageWrapper.getInstance().getCsarPlansUri("1");
- assertEquals(200, result.getStatus());
- assertEquals(expectResult, result.getEntity());
- }
-
- @Test
- public void testDelPackage() {
- System.out.println("Test delete package ");
- Response result = PackageWrapper.getInstance().delPackage("1");
- assertEquals(204, result.getStatus());
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- }
-
- /**
- * delete data after test.
- */
- @After
- public void tearDown() throws Exception {
- ArrayList<PackageData> packageList = manager.queryPackageByCsarId("1");
- if (packageList != null && packageList.size() != 0) {
- manager.deletePackage("1");
- } else {
- return;
- }
- System.out.println("Tear down");
- }
-
- /**
- * destory db session after class.
- * @throws Exception e
- */
- @AfterClass
- public static void tearDownAfterClass() {
- try {
- HibernateSession.destory();
- DaoManager.getInstance().setDaoNull();
- H2DbServer.shutDown();
- } catch (Exception e1) {
- Assert.fail("Exception" + e1.getMessage());
- }
- }
-
- private PackageData getPackageData() {
- PackageData packageData = new PackageData();
- packageData.setCsarId("1");
- packageData.setCreateTime("2016-06-29 03:33:15");
- packageData.setDeletionPending("false");
- packageData.setDownloadUri("/NSAR/ZTE/NanocellGW/v1.0/");
- packageData.setFormat("yml");
- packageData.setModifyTime("2016-06-29 03:33:15");
- packageData.setName("NanocellGW");
- packageData.setOnBoardState("non-onBoarded");
- packageData.setOperationalState("Disabled");
- packageData.setProvider("ZTE");
- packageData.setSize("0.93M");
- packageData.setType("NSAR");
- packageData.setUsageState("InUse");
- packageData.setVersion("V1.0");
- packageData.setProcessState("normal");
- return packageData;
- }
-
- private ArrayList<PackageData> getPackageDataList() {
- ArrayList<PackageData> packageDataList = new ArrayList<PackageData>();
- PackageData packageData = new PackageData();
- packageData = getPackageData();
- packageDataList.add(packageData);
- return packageDataList;
- }
-
- private ArrayList<PackageMeta> getPackageMetaList() {
- PackageMeta meta = new PackageMeta();
- meta.setCreateTime("2016-06-29 03:33:15");
- meta.setCsarId("1");
- meta.setDeletionPending(false);
- meta.setDownloadUri(MsbAddrConfig.getMsbAddress()
- + "/NSAR/ZTE/NanocellGW/v1.0/NanocellGW.csar");
- meta.setFormat("yml");
- meta.setModifyTime("2016-06-29 03:33:15");
- meta.setName("NanocellGW");
- meta.setOperationalState(EnumOperationalState.valueOf("Disabled"));
- meta.setProvider("ZTE");
- meta.setSize("0.93M");
- meta.setType("NSAR");
- meta.setUsageState(EnumUsageState.valueOf("InUse"));
- meta.setVersion("V1.0");
- meta.setOnBoardState(EnumOnboardState.nonOnBoarded.getValue());
- meta.setProcessState(EnumProcessState.valueOf("normal"));
- ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
- metas.add(meta);
- return metas;
- }
-}
+/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.commontosca.catalog.wrapper;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.openo.commontosca.catalog.CatalogAppConfiguration;
+import org.openo.commontosca.catalog.common.Config;
+import org.openo.commontosca.catalog.common.HttpServerAddrConfig;
+import org.openo.commontosca.catalog.common.HttpServerPathConfig;
+import org.openo.commontosca.catalog.common.MsbAddrConfig;
+import org.openo.commontosca.catalog.db.dao.DaoManager;
+import org.openo.commontosca.catalog.db.entity.PackageData;
+import org.openo.commontosca.catalog.db.exception.CatalogResourceException;
+import org.openo.commontosca.catalog.db.resource.PackageManager;
+import org.openo.commontosca.catalog.db.util.H2DbServer;
+import org.openo.commontosca.catalog.db.util.HibernateSession;
+import org.openo.commontosca.catalog.entity.EnumOnboardState;
+import org.openo.commontosca.catalog.entity.EnumOperationalState;
+import org.openo.commontosca.catalog.entity.EnumProcessState;
+import org.openo.commontosca.catalog.entity.EnumUsageState;
+import org.openo.commontosca.catalog.entity.response.CsarFileUriResponse;
+import org.openo.commontosca.catalog.entity.response.PackageMeta;
+import org.openo.commontosca.catalog.filemanage.entity.FileLink;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+
+import javax.ws.rs.core.Response;
+
+public class PackageWrapperTest {
+ private static String resourcePath;
+
+ static {
+ MsbAddrConfig.setMsbAddress("http://127.0.0.1:80");
+ }
+
+ static {
+ HttpServerAddrConfig.setHttpServerAddress("http://127.0.0.1:8080");
+ }
+
+ static {
+ HttpServerPathConfig.setHttpServerPath("../tomcat/webapps/ROOT/");
+ }
+
+ private static PackageManager manager;
+
+
+ /**
+ * startup db session before class.
+ * @throws Exception e
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws CatalogResourceException {
+ H2DbServer.startUp();
+ DaoManager.getInstance().setSessionFactory(HibernateSession.init());
+ manager = PackageManager.getInstance();
+ CatalogAppConfiguration configuration = new CatalogAppConfiguration();
+ Config.setConfigration(configuration);
+ System.out.println("Set up before class");
+ }
+
+ /**
+ * create data before test.
+ */
+ @Before
+ public void setUp() throws Exception {
+ ArrayList<PackageData> packageList = manager.queryPackage(null, null, null, null, null);
+ if (packageList != null && packageList.size() > 0) {
+ for (int i = 0; i < packageList.size(); i++) {
+ String packageOid = packageList.get(i).getCsarId();
+ manager.deletePackage(packageOid);
+ }
+ }
+
+ // PowerMockito.mockStatic(PackageManager.class);
+ // PowerMockito.when(manager.addPackage(packageData)).thenReturn(packageData);
+ // PowerMock.replayAll();
+ PackageData packageData = new PackageData();
+ packageData = getPackageData();
+ manager.addPackage(packageData);
+ }
+
+ // @Ignore
+ @Test
+ public void testUploadPackage() throws Exception {
+ InputStream ins = null;
+ Response result = null;
+ Response result1 = null;
+ Response result2 = null;
+ // PackageData packageData = new PackageData();
+ // packageData = getPackageData();
+
+ FormDataContentDisposition fileDetail =
+ FormDataContentDisposition.name("fileName").fileName("NanocellGW.csar").build();
+
+ try {
+ resourcePath = HibernateSession.class.getResource("/").toURI().getPath();
+ } catch (URISyntaxException e1) {
+ e1.printStackTrace();
+ }
+ final String filename = "NanocellGW.csar";
+ File packageFile = new File(resourcePath + filename);
+ try {
+ ins = new FileInputStream(packageFile);
+ } catch (FileNotFoundException e2) {
+ e2.printStackTrace();
+ }
+ if (ins != null) {
+ try {
+ result = PackageWrapper.getInstance().uploadPackage(ins, fileDetail, null);
+ } catch (Exception e3) {
+ e3.printStackTrace();
+ }
+ }
+ assertEquals(200, result.getStatus());
+ assertNotNull(result.getEntity());
+
+ try {
+ result1 = PackageWrapper.getInstance().uploadPackage(null, fileDetail, null);
+ } catch (Exception e4) {
+ e4.printStackTrace();
+ }
+ assertEquals(500, result1.getStatus());
+
+ try {
+ result2 = PackageWrapper.getInstance().uploadPackage(ins, null, null);
+ } catch (Exception e5) {
+ e5.printStackTrace();
+ }
+ assertEquals(500, result2.getStatus());
+ }
+
+ @Test
+ public void testQueryPackageById() throws Exception {
+ ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
+ metas = getPackageMetaList();
+ // PackageManager packageManager = mock(PackageManager.class);
+ // when(packageManager.queryPackageByCsarId(anyString())).thenThrow(new Exception());
+ // PowerMockito.whenNew(PackageManager.class).withNoArguments().thenReturn(packageManager);
+ // PowerMockito.mockStatic(PackageManager.class);
+ // PowerMockito.when(PackageManager.getInstance()).thenReturn(manager);
+ // PowerMock.replayAll();
+ // when(manager.queryPackageByCsarId(anyString())).thenThrow(new Exception());
+ // PowerMockito.whenNew(PackageManager.class).withNoArguments().thenReturn(manager);
+
+ Response result = PackageWrapper.getInstance().queryPackageById("1");
+ assertEquals(200, result.getStatus());
+ assertEquals(metas, result.getEntity());
+
+ }
+
+ @Test
+ public void testQueryPackageByCond() {
+ ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
+ metas = getPackageMetaList();
+ System.out.println("Test query package by Id");
+ Response result =
+ PackageWrapper.getInstance().queryPackageListByCond("NanocellGW", "ZTE", "V1.0", "false",
+ "NSAR");
+ assertEquals(200, result.getStatus());
+ assertEquals(metas, result.getEntity());
+ }
+
+ @Test
+ public void testUpdatePackageStatus() {
+ System.out.println("Test update package status");
+ Response result =
+ PackageWrapper.getInstance().updatePackageStatus("1", "Enabled", "NotInUse", "true",
+ "onBoarding", "true");
+ assertEquals(200, result.getStatus());
+ }
+
+ @Test
+ public void testGetCsarFileUri() {
+ System.out.println("Test get csar file uri ");
+ CsarFileUriResponse expectResult = new CsarFileUriResponse();
+ String csarFileUri =
+ MsbAddrConfig.getMsbAddress() + "/NSAR/ZTE/NanocellGW/v1.0/NanocellGW/images/segw.img";
+ String localUri =
+ HttpServerPathConfig.getHttpServerPath()
+ + "NSAR/ZTE/NanocellGW/v1.0/NanocellGW/images/segw.img";
+ File srcDir = new File(localUri);
+ String localPath = srcDir.getAbsolutePath().replace("\\", "/");
+
+ expectResult.setDownloadUri(csarFileUri);
+ expectResult.setLocalPath(localPath);
+ Response result = PackageWrapper.getInstance().getCsarFileUri("1", "/images/segw.img");
+ assertEquals(200, result.getStatus());
+ assertEquals(expectResult, result.getEntity());
+ }
+
+ @Ignore
+ @Test
+ public void testGetPlansUri() {
+ System.out.println("Test get csar plans uri ");
+ ArrayList<FileLink> expectResult = new ArrayList<FileLink>();
+ FileLink fileLink1 = new FileLink();
+ fileLink1.setFileName("init.zip");
+ fileLink1.setDownloadUri(MsbAddrConfig.getMsbAddress()
+ + "/NSAR/ZTE/NanocellGW/v1.0/Plans/init.zip");
+ expectResult.add(fileLink1);
+ FileLink fileLink2 = new FileLink();
+ fileLink2.setFileName("delete.zip");
+ fileLink2.setDownloadUri(MsbAddrConfig.getMsbAddress()
+ + "/NSAR/ZTE/NanocellGW/v1.0/Plans/delete.zip");
+ expectResult.add(fileLink2);
+ Response result = PackageWrapper.getInstance().getCsarPlansUri("1");
+ assertEquals(200, result.getStatus());
+ assertEquals(expectResult, result.getEntity());
+ }
+
+ @Test
+ public void testDelPackage() {
+ System.out.println("Test delete package ");
+ Response result = PackageWrapper.getInstance().delPackage("1");
+ assertEquals(204, result.getStatus());
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ /**
+ * delete data after test.
+ */
+ @After
+ public void tearDown() throws Exception {
+ ArrayList<PackageData> packageList = manager.queryPackageByCsarId("1");
+ if (packageList != null && packageList.size() != 0) {
+ manager.deletePackage("1");
+ } else {
+ return;
+ }
+ System.out.println("Tear down");
+ }
+
+ /**
+ * destory db session after class.
+ * @throws Exception e
+ */
+ @AfterClass
+ public static void tearDownAfterClass() {
+ try {
+ HibernateSession.destory();
+ DaoManager.getInstance().setDaoNull();
+ H2DbServer.shutDown();
+ } catch (Exception e1) {
+ Assert.fail("Exception" + e1.getMessage());
+ }
+ }
+
+ private PackageData getPackageData() {
+ PackageData packageData = new PackageData();
+ packageData.setCsarId("1");
+ packageData.setCreateTime("2016-06-29 03:33:15");
+ packageData.setDeletionPending("false");
+ packageData.setDownloadUri("/NSAR/ZTE/NanocellGW/v1.0/");
+ packageData.setFormat("yml");
+ packageData.setModifyTime("2016-06-29 03:33:15");
+ packageData.setName("NanocellGW");
+ packageData.setOnBoardState("non-onBoarded");
+ packageData.setOperationalState("Disabled");
+ packageData.setProvider("ZTE");
+ packageData.setSize("0.93M");
+ packageData.setType("NSAR");
+ packageData.setUsageState("InUse");
+ packageData.setVersion("V1.0");
+ packageData.setProcessState("normal");
+ return packageData;
+ }
+
+ private ArrayList<PackageData> getPackageDataList() {
+ ArrayList<PackageData> packageDataList = new ArrayList<PackageData>();
+ PackageData packageData = new PackageData();
+ packageData = getPackageData();
+ packageDataList.add(packageData);
+ return packageDataList;
+ }
+
+ private ArrayList<PackageMeta> getPackageMetaList() {
+ PackageMeta meta = new PackageMeta();
+ meta.setCreateTime("2016-06-29 03:33:15");
+ meta.setCsarId("1");
+ meta.setDeletionPending(false);
+ meta.setDownloadUri(MsbAddrConfig.getMsbAddress()
+ + "/NSAR/ZTE/NanocellGW/v1.0/NanocellGW.csar");
+ meta.setFormat("yml");
+ meta.setModifyTime("2016-06-29 03:33:15");
+ meta.setName("NanocellGW");
+ meta.setOperationalState(EnumOperationalState.valueOf("Disabled"));
+ meta.setProvider("ZTE");
+ meta.setSize("0.93M");
+ meta.setType("NSAR");
+ meta.setUsageState(EnumUsageState.valueOf("InUse"));
+ meta.setVersion("V1.0");
+ meta.setOnBoardState(EnumOnboardState.nonOnBoarded.getValue());
+ meta.setProcessState(EnumProcessState.valueOf("normal"));
+ ArrayList<PackageMeta> metas = new ArrayList<PackageMeta>();
+ metas.add(meta);
+ return metas;
+ }
+}
diff --git a/catalog-core/distribution/catalog-standalone/pom.xml b/catalog-core/distribution/catalog-standalone/pom.xml
index d2904951..dc8efdf3 100644
--- a/catalog-core/distribution/catalog-standalone/pom.xml
+++ b/catalog-core/distribution/catalog-standalone/pom.xml
@@ -1,138 +1,138 @@
-<!--
-
- Copyright 2016 [ZTE] and others.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<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">
- <parent>
- <groupId>org.openo.common-tosca.catalog</groupId>
- <artifactId>distribution</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>catalog-standalone</artifactId>
- <name>openo/commontosca/catalog/distribution/catalog-standalone</name>
- <packaging>pom</packaging>
-
- <properties>
- <packagename>openo-catalog</packagename>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-resources</id>
- <phase>process-resources</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${basedir}/target/assembly/</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/assembly/</directory>
- <filtering>false</filtering>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
- <overwrite>true</overwrite>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-jar</id>
- <goals>
- <goal>copy</goal>
- </goals>
- <phase>prepare-package</phase>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.openo.common-tosca.catalog</groupId>
- <artifactId>catalog-mgr</artifactId>
- <type>jar</type>
- <overWrite>true</overWrite>
- <outputDirectory>target/assembly/</outputDirectory>
- <destFileName>catalog-service.jar</destFileName>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>zip</id>
- <phase>package</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks name="${project.artifactId}">
- <zip destfile="target/${packagename}-${project.version}.zip" update="true">
- <zipfileset dir="target/assembly" includes="**" />
- </zip>
- </tasks>
- </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>target/${packagename}-${project.version}.zip</file>
- <type>zip</type>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.openo.common-tosca.catalog</groupId>
- <artifactId>catalog-mgr</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
-
+<!--
+
+ Copyright 2016 [ZTE] and others.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<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">
+ <parent>
+ <groupId>org.openo.common-tosca.catalog</groupId>
+ <artifactId>distribution</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>catalog-standalone</artifactId>
+ <name>openo/commontosca/catalog/distribution/catalog-standalone</name>
+ <packaging>pom</packaging>
+
+ <properties>
+ <packagename>openo-catalog</packagename>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${basedir}/target/assembly/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/assembly/</directory>
+ <filtering>false</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <overwrite>true</overwrite>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-jar</id>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.openo.common-tosca.catalog</groupId>
+ <artifactId>catalog-mgr</artifactId>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>target/assembly/</outputDirectory>
+ <destFileName>catalog-service.jar</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>zip</id>
+ <phase>package</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks name="${project.artifactId}">
+ <zip destfile="target/${packagename}-${project.version}.zip" update="true">
+ <zipfileset dir="target/assembly" includes="**" />
+ </zip>
+ </tasks>
+ </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>target/${packagename}-${project.version}.zip</file>
+ <type>zip</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openo.common-tosca.catalog</groupId>
+ <artifactId>catalog-mgr</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
+
diff --git a/catalog-core/httpserver/src/main/assembly/tomcat/conf/server.xml b/catalog-core/httpserver/src/main/assembly/tomcat/conf/server.xml
index 00d22b87..2c34c9d6 100644
--- a/catalog-core/httpserver/src/main/assembly/tomcat/conf/server.xml
+++ b/catalog-core/httpserver/src/main/assembly/tomcat/conf/server.xml
@@ -1,145 +1,145 @@
-<?xml version='1.0' encoding='utf-8'?>
-<!--
-
- Copyright 2016 [ZTE] and others.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<!-- 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="8005" shutdown="SHUTDOWN">
- <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
- <!-- Security listener. Documentation at /docs/config/listeners.html
- <Listener className="org.apache.catalina.security.SecurityListener" />
- -->
- <!--APR library loader. Documentation at /docs/apr.html -->
- <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
- <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
- <Listener className="org.apache.catalina.core.JasperListener" />
- <!-- Prevent memory leaks due to use of particular java/javax APIs-->
- <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
- <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
- <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
-
- <!-- Global JNDI resources
- Documentation at /docs/jndi-resources-howto.html
- -->
- <GlobalNamingResources>
- <!-- Editable user database that can also be used by
- UserDatabaseRealm to authenticate users
- -->
- <Resource name="UserDatabase" auth="Container"
- type="org.apache.catalina.UserDatabase"
- description="User database that can be updated and saved"
- factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
- pathname="conf/tomcat-users.xml" />
- </GlobalNamingResources>
-
- <!-- A "Service" is a collection of one or more "Connectors" that share
- a single "Container" Note: A "Service" is not itself a "Container",
- so you may not define subcomponents such as "Valves" at this level.
- Documentation at /docs/config/service.html
- -->
- <Service name="Catalina">
-
- <!--The connectors can use a shared executor, you can define one or more named thread pools-->
- <!--
- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
- maxThreads="150" minSpareThreads="4"/>
- -->
-
-
- <!-- A "Connector" represents an endpoint by which requests are received
- and responses are returned. Documentation at :
- Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
- Java AJP Connector: /docs/config/ajp.html
- APR (HTTP/AJP) Connector: /docs/apr.html
- Define a non-SSL HTTP/1.1 Connector on port 8080
- -->
- <Connector port="8201" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" />
- <!-- A "Connector" using the shared thread pool-->
- <!--
- <Connector executor="tomcatThreadPool"
- port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443" />
- -->
- <!-- Define a SSL HTTP/1.1 Connector on port 8443
- This connector uses the BIO implementation that requires the JSSE
- style configuration. When using the APR/native implementation, the
- OpenSSL style configuration is required as described in the APR/native
- documentation -->
- <!--
- <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
- maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
- clientAuth="false" sslProtocol="TLS" />
- -->
-
- <!-- Define an AJP 1.3 Connector on port 8009 -->
- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
-
-
- <!-- An Engine represents the entry point (within Catalina) that processes
- every request. The Engine implementation for Tomcat stand alone
- analyzes the HTTP headers included with the request, and passes them
- on to the appropriate Host (virtual host).
- Documentation at /docs/config/engine.html -->
-
- <!-- You should set jvmRoute to support load-balancing via AJP ie :
- <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
- -->
- <Engine name="Catalina" defaultHost="localhost">
-
- <!--For clustering, please take a look at documentation at:
- /docs/cluster-howto.html (simple how to)
- /docs/config/cluster.html (reference documentation) -->
- <!--
- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
- -->
-
- <!-- Use the LockOutRealm to prevent attempts to guess user passwords
- via a brute-force attack -->
- <Realm className="org.apache.catalina.realm.LockOutRealm">
- <!-- This Realm uses the UserDatabase configured in the global JNDI
- resources under the key "UserDatabase". Any edits
- that are performed against this UserDatabase are immediately
- available for use by the Realm. -->
- <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
- resourceName="UserDatabase"/>
- </Realm>
-
- <Host name="localhost" appBase="webapps"
- unpackWARs="true" autoDeploy="true">
-
- <!-- SingleSignOn valve, share authentication between web applications
- Documentation at: /docs/config/valve.html -->
- <!--
- <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
- -->
-
- <!-- Access log processes all example.
- Documentation at: /docs/config/valve.html
- Note: The pattern used is equivalent to using pattern="common" -->
- <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="localhost_access_log." suffix=".txt"
- pattern="%h %l %u %t &quot;%r&quot; %s %b" />
-
- </Host>
- </Engine>
- </Service>
-</Server>
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+
+ Copyright 2016 [ZTE] and others.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!-- 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="8005" shutdown="SHUTDOWN">
+ <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
+ <!-- Security listener. Documentation at /docs/config/listeners.html
+ <Listener className="org.apache.catalina.security.SecurityListener" />
+ -->
+ <!--APR library loader. Documentation at /docs/apr.html -->
+ <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
+ <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
+ <Listener className="org.apache.catalina.core.JasperListener" />
+ <!-- Prevent memory leaks due to use of particular java/javax APIs-->
+ <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
+ <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
+ <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
+
+ <!-- Global JNDI resources
+ Documentation at /docs/jndi-resources-howto.html
+ -->
+ <GlobalNamingResources>
+ <!-- Editable user database that can also be used by
+ UserDatabaseRealm to authenticate users
+ -->
+ <Resource name="UserDatabase" auth="Container"
+ type="org.apache.catalina.UserDatabase"
+ description="User database that can be updated and saved"
+ factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
+ pathname="conf/tomcat-users.xml" />
+ </GlobalNamingResources>
+
+ <!-- A "Service" is a collection of one or more "Connectors" that share
+ a single "Container" Note: A "Service" is not itself a "Container",
+ so you may not define subcomponents such as "Valves" at this level.
+ Documentation at /docs/config/service.html
+ -->
+ <Service name="Catalina">
+
+ <!--The connectors can use a shared executor, you can define one or more named thread pools-->
+ <!--
+ <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
+ maxThreads="150" minSpareThreads="4"/>
+ -->
+
+
+ <!-- A "Connector" represents an endpoint by which requests are received
+ and responses are returned. Documentation at :
+ Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
+ Java AJP Connector: /docs/config/ajp.html
+ APR (HTTP/AJP) Connector: /docs/apr.html
+ Define a non-SSL HTTP/1.1 Connector on port 8080
+ -->
+ <Connector port="8201" protocol="HTTP/1.1"
+ connectionTimeout="20000"
+ redirectPort="8443" />
+ <!-- A "Connector" using the shared thread pool-->
+ <!--
+ <Connector executor="tomcatThreadPool"
+ port="8080" protocol="HTTP/1.1"
+ connectionTimeout="20000"
+ redirectPort="8443" />
+ -->
+ <!-- Define a SSL HTTP/1.1 Connector on port 8443
+ This connector uses the BIO implementation that requires the JSSE
+ style configuration. When using the APR/native implementation, the
+ OpenSSL style configuration is required as described in the APR/native
+ documentation -->
+ <!--
+ <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
+ maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
+ clientAuth="false" sslProtocol="TLS" />
+ -->
+
+ <!-- Define an AJP 1.3 Connector on port 8009 -->
+ <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
+
+
+ <!-- An Engine represents the entry point (within Catalina) that processes
+ every request. The Engine implementation for Tomcat stand alone
+ analyzes the HTTP headers included with the request, and passes them
+ on to the appropriate Host (virtual host).
+ Documentation at /docs/config/engine.html -->
+
+ <!-- You should set jvmRoute to support load-balancing via AJP ie :
+ <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
+ -->
+ <Engine name="Catalina" defaultHost="localhost">
+
+ <!--For clustering, please take a look at documentation at:
+ /docs/cluster-howto.html (simple how to)
+ /docs/config/cluster.html (reference documentation) -->
+ <!--
+ <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
+ -->
+
+ <!-- Use the LockOutRealm to prevent attempts to guess user passwords
+ via a brute-force attack -->
+ <Realm className="org.apache.catalina.realm.LockOutRealm">
+ <!-- This Realm uses the UserDatabase configured in the global JNDI
+ resources under the key "UserDatabase". Any edits
+ that are performed against this UserDatabase are immediately
+ available for use by the Realm. -->
+ <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
+ resourceName="UserDatabase"/>
+ </Realm>
+
+ <Host name="localhost" appBase="webapps"
+ unpackWARs="true" autoDeploy="true">
+
+ <!-- SingleSignOn valve, share authentication between web applications
+ Documentation at: /docs/config/valve.html -->
+ <!--
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+ -->
+
+ <!-- Access log processes all example.
+ Documentation at: /docs/config/valve.html
+ Note: The pattern used is equivalent to using pattern="common" -->
+ <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
+ prefix="localhost_access_log." suffix=".txt"
+ pattern="%h %l %u %t &quot;%r&quot; %s %b" />
+
+ </Host>
+ </Engine>
+ </Service>
+</Server>
diff --git a/pom.xml b/pom.xml
index 5d112c8f..e1fbb455 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,44 +1,44 @@
-<!--
-
- Copyright 2016 [ZTE] and others.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<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">
- <parent>
- <groupId>org.openo.common-tosca.catalog</groupId>
- <artifactId>catalogparent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>catalog-parent/catalogparent</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>catalog-root</artifactId>
- <name>openo/commontosca/catalog/catalog-root</name>
- <packaging>pom</packaging>
-
- <modules>
- <module>catalog-parent</module>
- <module>catalog-core</module>
- </modules>
-
- <build>
- <plugins>
- <plugin>
- <groupId>com.mycila</groupId>
- <artifactId>license-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
+<!--
+
+ Copyright 2016 [ZTE] and others.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<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">
+ <parent>
+ <groupId>org.openo.common-tosca.catalog</groupId>
+ <artifactId>catalogparent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>catalog-parent/catalogparent</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>catalog-root</artifactId>
+ <name>openo/commontosca/catalog/catalog-root</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>catalog-parent</module>
+ <module>catalog-core</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.mycila</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>