summaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/main/java')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java47
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java43
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java55
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebSecurityConfigImpl.java51
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java)19
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryException.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryException.java)12
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java)7
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java)24
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java)28
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java)150
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsar.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java)144
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java)24
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java)18
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java)23
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModule.java (renamed from adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java)24
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java600
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/package-info.java28
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java573
18 files changed, 1077 insertions, 793 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java
new file mode 100644
index 0000000000..ce98b74fab
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+
+@SpringBootApplication(scanBasePackages = {"org.onap.so.adapters.catalogdb", "org.onap.so.db.catalog.client"})
+@EnableJpaRepositories("org.onap.so.db.catalog.data.repository")
+@EntityScan("org.onap.so.db.catalog.beans")
+public class CatalogDBApplication {
+
+ private static final String LOGS_DIR = "logs_dir";
+
+ private static void setLogsDir() {
+ if (System.getProperty(LOGS_DIR) == null) {
+ System.getProperties().setProperty(LOGS_DIR, "./logs/catdb/");
+ }
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(CatalogDBApplication.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+ System.getProperties().setProperty("server.name", "Springboot");
+ setLogsDir();
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java
new file mode 100644
index 0000000000..3906762e60
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb;
+
+import java.util.stream.Collectors;
+
+import javax.persistence.EntityManager;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
+import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerAdapter;
+
+@Configuration
+public class CatalogDbRepositoryConfiguration extends RepositoryRestConfigurerAdapter {
+
+ @Autowired
+ private EntityManager entityManager;
+
+ @Override
+ public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
+ config.exposeIdsFor(entityManager.getMetamodel().getEntities().stream().map(e -> e.getJavaType()).collect(Collectors.toList()).toArray(new Class[0]));
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
new file mode 100644
index 0000000000..dcd668f2c8
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb;
+
+import javax.annotation.PostConstruct;
+import javax.ws.rs.ApplicationPath;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.onap.so.adapters.catalogdb.rest.CatalogDbAdapterRest;
+import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging;
+import org.springframework.context.annotation.Configuration;
+
+import io.swagger.jaxrs.config.BeanConfig;
+import io.swagger.jaxrs.listing.ApiListingResource;
+import io.swagger.jaxrs.listing.SwaggerSerializers;
+
+@Configuration
+@ApplicationPath("/ecomp/mso/catalog")
+public class JerseyConfiguration extends ResourceConfig {
+
+ @PostConstruct
+ public void setUp() {
+ register(CatalogDbAdapterRest.class);
+ register(ApiListingResource.class);
+ register(SwaggerSerializers.class);
+ register(JaxRsFilterLogging.class);
+ BeanConfig beanConfig = new BeanConfig();
+ beanConfig.setVersion("1.0.2");
+ beanConfig.setSchemes(new String[]{"http"});
+ beanConfig.setHost("localhost:8080");
+ beanConfig.setBasePath("/ecomp/mso/catalog");
+ beanConfig.setResourcePackage("org.onap.so.adapters.catalogdb");
+ beanConfig.setPrettyPrint(true);
+ beanConfig.setScan(true);
+ }
+}
+
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebSecurityConfigImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebSecurityConfigImpl.java
new file mode 100644
index 0000000000..144df5fe6a
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebSecurityConfigImpl.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb;
+
+import org.onap.so.security.MSOSpringFirewall;
+import org.onap.so.security.WebSecurityConfig;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.web.firewall.StrictHttpFirewall;
+import org.springframework.util.StringUtils;
+
+@EnableWebSecurity
+public class WebSecurityConfigImpl extends WebSecurityConfig {
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.csrf().disable()
+ .authorizeRequests()
+ .antMatchers("/manage/health","/manage/info").permitAll()
+ .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString())
+ .and()
+ .httpBasic();
+ }
+
+ @Override
+ public void configure(WebSecurity web) throws Exception {
+ super.configure(web);
+ StrictHttpFirewall firewall = new MSOSpringFirewall();
+ web.httpFirewall(firewall);
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java
index 10d76f145b..6b0d901cb4 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQuery.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQuery.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,17 +18,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
-import org.openecomp.mso.logger.MsoLogger;
-import com.fasterxml.jackson.databind.ObjectMapper;
+package org.onap.so.adapters.catalogdb.catalogrest;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.onap.so.logger.MsoLogger;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
public abstract class CatalogQuery {
- protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+ protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,CatalogQuery.class);
private static final boolean IS_EMBED = true;
public abstract String JSON2(boolean isArray, boolean isEmbed);
@@ -89,4 +91,9 @@ public abstract class CatalogQuery {
return "invalid version: "+ version;
}
}
+ @Override
+ public String toString(){
+ return smartToJSON();
+
+ }
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryException.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryException.java
index a35bc78229..890347344c 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryException.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryException.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,11 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
-import javax.xml.bind.annotation.XmlRootElement;
+package org.onap.so.adapters.catalogdb.catalogrest;
+
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlRootElement;
+
@XmlRootElement(name = "catalogQueryException")
public class CatalogQueryException extends CatalogQueryExceptionCommon implements Serializable {
private static final long serialVersionUID = -9062290006520066109L;
@@ -51,4 +53,6 @@ public class CatalogQueryException extends CatalogQueryExceptionCommon implement
public Boolean getRolledBack() { return rolledBack; }
public void setRolledBack(Boolean rolledBack) { this.rolledBack = rolledBack; }
+
+
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java
index 2364ccc667..687cc7d3e0 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCategory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
+
+package org.onap.so.adapters.catalogdb.catalogrest;
public enum CatalogQueryExceptionCategory { OPENSTACK, IO, INTERNAL, USERDATA }
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java
index a1414e08bd..67f337e039 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionCommon.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,19 +18,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import java.io.ByteArrayOutputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
-import java.io.ByteArrayOutputStream;
-import org.openecomp.mso.logger.MsoLogger;
+
+import org.onap.so.logger.MsoLogger;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
public abstract class CatalogQueryExceptionCommon {
private String messageId;
- protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
+ protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,CatalogQueryExceptionCommon.class);
public CatalogQueryExceptionCommon() { messageId = null; }
public CatalogQueryExceptionCommon(String messageId) { this.messageId = messageId; }
@@ -64,4 +67,9 @@ public abstract class CatalogQueryExceptionCommon {
return "";
}
}
+
+ @Override
+ public String toString(){
+ return toJsonString();
+ }
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java
index b249b58d48..2deada5754 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,18 +17,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
+package org.onap.so.adapters.catalogdb.catalogrest;
-import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
+import org.onap.so.logger.MsoLogger;
+
@XmlRootElement(name = "serviceAllottedResources")
public class QueryAllottedResourceCustomization extends CatalogQuery {
+ protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,QueryAllottedResourceCustomization.class);
private List<AllottedResourceCustomization> allottedResourceCustomization;
private final String template =
"\t{\n"+
@@ -90,20 +94,20 @@ public class QueryAllottedResourceCustomization extends CatalogQuery {
boolean arNull = o.getAllottedResource() == null ? true : false;
put(valueMap, "MODEL_NAME", arNull ? null : o.getAllottedResource().getModelName());
- put(valueMap, "MODEL_UUID", arNull ? null : o.getAllottedResource().getModelUuid());
- put(valueMap, "MODEL_INVARIANT_ID", arNull ? null : o.getAllottedResource().getModelInvariantUuid());
+ put(valueMap, "MODEL_UUID", arNull ? null : o.getAllottedResource().getModelUUID());
+ put(valueMap, "MODEL_INVARIANT_ID", arNull ? null : o.getAllottedResource().getModelInvariantUUID());
put(valueMap, "MODEL_VERSION", arNull ? null : o.getAllottedResource().getModelVersion());
- put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid());
+ put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID());
put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName());
put(valueMap, "TOSCA_NODE_TYPE", arNull ? null : o.getAllottedResource().getToscaNodeType());
- put(valueMap, "ALLOTTED_RESOURCE_TYPE", o.getNfType());
- put(valueMap, "ALLOTTED_RESOURCE_ROLE", o.getNfRole());
+ put(valueMap, "ALLOTTED_RESOURCE_TYPE", arNull ? null : o.getAllottedResource().getSubcategory());
+ put(valueMap, "ALLOTTED_RESOURCE_ROLE", o.getTargetNetworkRole());
put(valueMap, "NF_TYPE", o.getNfType());
put(valueMap, "NF_ROLE", o.getNfRole());
put(valueMap, "NF_FUNCTION", o.getNfFunction());
put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode());
- put(valueMap, "PROVIDING_SERVICE_MODEL_INVARIANT_UUID", o.getProvidingServiceModelInvariantUuid());
- put(valueMap, "PROVIDING_SERVICE_MODEL_UUID", o.getProvidingServiceModelUuid());
+ put(valueMap, "PROVIDING_SERVICE_MODEL_INVARIANT_UUID", o.getProvidingServiceModelInvariantUUID());
+ put(valueMap, "PROVIDING_SERVICE_MODEL_UUID", o.getProvidingServiceModelUUID());
put(valueMap, "PROVIDING_SERVICE_MODEL_NAME", o.getProvidingServiceModelName());
sb.append(sep).append(this.setTemplate(template, valueMap));
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java
index 4d8b65a0c8..e0d187500e 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipe.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipe.java
@@ -1,75 +1,75 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.openecomp.mso.db.catalog.beans.Recipe;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
-/**
- * serivce csar query support
- * <br>
- * <p>
- * </p>
- *
- * @author
- * @version ONAP Beijing Release 2018-02-28
- */
-public class QueryResourceRecipe extends CatalogQuery{
-
- private Recipe resourceRecipe;
-
- public QueryResourceRecipe(Recipe resourceRecipe){
- this.resourceRecipe =resourceRecipe;
- }
-
- @Override
- public String toString() {
-
- return resourceRecipe.toString();
- }
-
- @Override
- public String JSON2(boolean isArray, boolean isEmbed) {
-
- Map<String, String> valueMap = new HashMap<>();
- valueMap.put("id", null == resourceRecipe ? null :String.valueOf(resourceRecipe.getId()));
- valueMap.put("action", null == resourceRecipe ? null :resourceRecipe.getAction());
- valueMap.put("orchestrationUri", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri());
- valueMap.put("recipeTimeout", null == resourceRecipe ? null : String.valueOf(resourceRecipe.getRecipeTimeout()));
- valueMap.put("paramXSD", null == resourceRecipe ? null : resourceRecipe.getParamXSD());
- valueMap.put("description", null == resourceRecipe ? null : resourceRecipe.getDescription());
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
- String jsonStr = "";
- try {
- jsonStr = mapper.writeValueAsString(valueMap);
- } catch(JsonProcessingException e) {
- LOGGER.error("JsonProcessingException", e);
- }
- return jsonStr;
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onap.so.db.catalog.beans.Recipe;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+/**
+ * serivce csar query support
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Beijing Release 2018-02-28
+ */
+public class QueryResourceRecipe extends CatalogQuery{
+
+ private Recipe resourceRecipe;
+
+ public QueryResourceRecipe(Recipe resourceRecipe){
+ this.resourceRecipe =resourceRecipe;
+ }
+
+ @Override
+ public String toString() {
+
+ return resourceRecipe.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ Map<String, String> valueMap = new HashMap<>();
+ valueMap.put("id", null == resourceRecipe ? null :String.valueOf(resourceRecipe.getId()));
+ valueMap.put("action", null == resourceRecipe ? null :resourceRecipe.getAction());
+ valueMap.put("orchestrationUri", null == resourceRecipe ? null : resourceRecipe.getOrchestrationUri());
+ valueMap.put("recipeTimeout", null == resourceRecipe ? null : String.valueOf(resourceRecipe.getRecipeTimeout()));
+ valueMap.put("paramXSD", null == resourceRecipe ? null : resourceRecipe.getParamXsd());
+ valueMap.put("description", null == resourceRecipe ? null : resourceRecipe.getDescription());
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+ String jsonStr = "";
+ try {
+ jsonStr = mapper.writeValueAsString(valueMap);
+ } catch(JsonProcessingException e) {
+
+ e.printStackTrace();
+ }
+ return jsonStr;
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsar.java
index 6b1eb836d9..d49f8965fb 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsar.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsar.java
@@ -1,72 +1,72 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.openecomp.mso.db.catalog.beans.ToscaCsar;
-
-/**
- * serivce csar query support
- * <br>
- * <p>
- * </p>
- *
- * @author
- * @version ONAP Beijing Release 2018-02-28
- */
-public class QueryServiceCsar extends CatalogQuery{
-
- private ToscaCsar toscaCsar;
-
- public QueryServiceCsar(ToscaCsar toscaCsar){
- this.toscaCsar = toscaCsar;
- }
-
- private final String template =
- "\t{\n"+
- "\t\t\"artifactUUID\" : <ARTIFACT_UUID>,\n"+
- "\t\t\"name\" : <NAME>,\n"+
- "\t\t\"version\" : <VERSION>,\n"+
- "\t\t\"artifactChecksum\" : <ARTIFACT_CHECK_SUM>,\n"+
- "\t\t\"url\" : <URL>,\n"+
- "\t\t\"description\" : <DESCRIPTION>\n"+
- "\t}";
-
- @Override
- public String toString() {
-
- return toscaCsar.toString();
- }
-
- @Override
- public String JSON2(boolean isArray, boolean isEmbed) {
- Map<String, String> valueMap = new HashMap<>();
- put(valueMap, "ARTIFACT_UUID", null == toscaCsar ? null : toscaCsar.getArtifactUUID());
- put(valueMap, "NAME", null == toscaCsar ? null : toscaCsar.getName());
- put(valueMap, "VERSION", null == toscaCsar ? null : toscaCsar.getVersion());
- put(valueMap, "ARTIFACT_CHECK_SUM", null == toscaCsar ? null : toscaCsar.getArtifactChecksum());
- put(valueMap, "URL", null == toscaCsar ? null : toscaCsar.getUrl());
- put(valueMap, "DESCRIPTION", null == toscaCsar ? null : toscaCsar.getDescription());
- return this.setTemplate(template, valueMap);
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onap.so.db.catalog.beans.ToscaCsar;
+
+/**
+ * serivce csar query support
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Beijing Release 2018-02-28
+ */
+public class QueryServiceCsar extends CatalogQuery{
+
+ private ToscaCsar toscaCsar;
+
+ public QueryServiceCsar(ToscaCsar toscaCsar){
+ this.toscaCsar = toscaCsar;
+ }
+
+ private final String template =
+ "\t{\n"+
+ "\t\t\"artifactUUID\" : <ARTIFACT_UUID>,\n"+
+ "\t\t\"name\" : <NAME>,\n"+
+ "\t\t\"version\" : <VERSION>,\n"+
+ "\t\t\"artifactChecksum\" : <ARTIFACT_CHECK_SUM>,\n"+
+ "\t\t\"url\" : <URL>,\n"+
+ "\t\t\"description\" : <DESCRIPTION>\n"+
+ "\t}";
+
+ @Override
+ public String toString() {
+
+ return toscaCsar.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ Map<String, String> valueMap = new HashMap<>();
+ put(valueMap, "ARTIFACT_UUID", null == toscaCsar ? null : toscaCsar.getArtifactUUID());
+ put(valueMap, "NAME", null == toscaCsar ? null : toscaCsar.getName());
+ put(valueMap, "VERSION", null == toscaCsar ? null : toscaCsar.getVersion());
+ put(valueMap, "ARTIFACT_CHECK_SUM", null == toscaCsar ? null : toscaCsar.getArtifactChecksum());
+ put(valueMap, "URL", null == toscaCsar ? null : toscaCsar.getUrl());
+ put(valueMap, "DESCRIPTION", null == toscaCsar ? null : toscaCsar.getDescription());
+ return this.setTemplate(template, valueMap);
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java
index e683a9fd8d..12ba4c0598 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,15 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
+
+package org.onap.so.adapters.catalogdb.catalogrest;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
-
-import javax.xml.bind.annotation.XmlRootElement;
import java.util.HashMap;
import java.util.Map;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
+
@XmlRootElement(name = "serviceResources")
public class QueryServiceMacroHolder extends CatalogQuery {
private ServiceMacroHolder serviceMacroHolder;
@@ -72,20 +74,20 @@ public class QueryServiceMacroHolder extends CatalogQuery {
put(valueMap, "SERVICE_MODEL_NAME", service.getModelName()); //getServiceModelName());
put(valueMap, "SERVICE_MODEL_UUID", service.getModelUUID()); //getServiceModelUuid());
put(valueMap, "SERVICE_MODEL_INVARIANT_ID", service.getModelInvariantUUID()); //getServiceModelInvariantId());
- put(valueMap, "SERVICE_MODEL_VERSION", service.getVersion()); //getServiceModelVersion());
+ put(valueMap, "SERVICE_MODEL_VERSION", service.getModelVersion()); //getServiceModelVersion());
put(valueMap, "SERVICE_TYPE", service.getServiceType());
put(valueMap, "SERVICE_ROLE", service.getServiceRole());
put(valueMap, "ENVIRONMENT_CONTEXT", service.getEnvironmentContext());
put(valueMap, "WORKLOAD_CONTEXT", service.getWorkloadContext());
String subitem;
- subitem = new QueryServiceVnfs(serviceMacroHolder.getVnfResourceCustomizations()).JSON2(true, true);
+ subitem = new QueryServiceVnfs(service.getVnfCustomizations()).JSON2(true, true);
valueMap.put("_SERVICEVNFS_", subitem.replaceAll(LINE_BEGINNING, "\t"));
- subitem = new QueryServiceNetworks(serviceMacroHolder.getNetworkResourceCustomization()).JSON2(true, true);
+ subitem = new QueryServiceNetworks(service.getNetworkCustomizations()).JSON2(true, true);
valueMap.put("_SERVICENETWORKS_", subitem.replaceAll(LINE_BEGINNING, "\t"));
- subitem = new QueryAllottedResourceCustomization(serviceMacroHolder.getAllottedResourceCustomization()).JSON2(true, true);
+ subitem = new QueryAllottedResourceCustomization(service.getAllottedCustomizations()).JSON2(true, true);
valueMap.put("_SERVICEALLOTTEDRESOURCES_", subitem.replaceAll(LINE_BEGINNING, "\t"));
buf.append(this.setTemplate(template, valueMap));
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java
index 9795deec54..b213d33af0 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworks.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,18 +17,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
+package org.onap.so.adapters.catalogdb.catalogrest;
-import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.logger.MsoLogger;
+
@XmlRootElement(name = "serviceNetworks")
public class QueryServiceNetworks extends CatalogQuery {
+ protected static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,QueryServiceNetworks.class);
private List<NetworkResourceCustomization> serviceNetworks;
private final String template =
"\t{\n"+
@@ -93,8 +97,8 @@ public class QueryServiceNetworks extends CatalogQuery {
put(valueMap, "MODEL_NAME", nrNull ? null : o.getNetworkResource().getModelName());
put(valueMap, "MODEL_UUID", nrNull ? null : o.getNetworkResource().getModelUUID());
put(valueMap, "MODEL_INVARIANT_ID", nrNull ? null : o.getNetworkResource().getModelInvariantUUID());
- put(valueMap, "MODEL_VERSION", nrNull ? null : o.getNetworkResource().getVersion());
- put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid());
+ put(valueMap, "MODEL_VERSION", nrNull ? null : o.getNetworkResource().getModelVersion());
+ put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID());
put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName());
put(valueMap, "TOSCA_NODE_TYPE", nrNull ? null : o.getNetworkResource().getToscaNodeType());
put(valueMap, "NETWORK_TYPE", o.getNetworkType());
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
index 383a106b18..ff52daf880 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
+
+package org.onap.so.adapters.catalogdb.catalogrest;
/* should be called QueryVnfResource.java */
import java.util.ArrayList;
@@ -27,7 +28,7 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlRootElement;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
@XmlRootElement(name = "serviceVnfs")
public class QueryServiceVnfs extends CatalogQuery {
@@ -92,15 +93,15 @@ public class QueryServiceVnfs extends CatalogQuery {
for (VnfResourceCustomization o : serviceVnfs) {
if (first) sb.append("\n"); first = false;
- boolean vrNull = o.getVnfResource() == null ? true : false;
+ boolean vrNull = o.getVnfResources() == null ? true : false;
- put(valueMap, "MODEL_NAME", vrNull ? null : o.getVnfResource().getModelName());
- put(valueMap, "MODEL_UUID", vrNull ? null : o.getVnfResource().getModelUuid());
- put(valueMap, "MODEL_INVARIANT_ID", vrNull ? null : o.getVnfResource().getModelInvariantId());
- put(valueMap, "MODEL_VERSION", vrNull ? null : o.getVnfResource().getVersion());
- put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid());
+ put(valueMap, "MODEL_NAME", vrNull ? null : o.getVnfResources().getModelName());
+ put(valueMap, "MODEL_UUID", vrNull ? null : o.getVnfResources().getModelUUID());
+ put(valueMap, "MODEL_INVARIANT_ID", vrNull ? null : o.getVnfResources().getModelInvariantId());
+ put(valueMap, "MODEL_VERSION", vrNull ? null : o.getVnfResources().getModelVersion());
+ put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID());
put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName());
- put(valueMap, "TOSCA_NODE_TYPE", vrNull ? null : o.getVnfResource().getToscaNodeType());
+ put(valueMap, "TOSCA_NODE_TYPE", vrNull ? null : o.getVnfResources().getToscaNodeType());
put(valueMap, "NF_FUNCTION", o.getNfFunction());
put(valueMap, "NF_TYPE", o.getNfType());
put(valueMap, "NF_ROLE", o.getNfRole());
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModule.java
index 9215c38706..e5fa14376b 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModule.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModule.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.adapters.catalogdb.catalogrest;
+
+package org.onap.so.adapters.catalogdb.catalogrest;
import java.util.ArrayList;
import java.util.HashMap;
@@ -26,7 +27,8 @@ import java.util.Map;
import javax.xml.bind.annotation.XmlRootElement;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.HeatEnvironment;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
@XmlRootElement(name = "vfModules")
public class QueryVfModule extends CatalogQuery {
@@ -93,20 +95,20 @@ public class QueryVfModule extends CatalogQuery {
boolean vfNull = o.getVfModule() == null ? true : false;
boolean hasVolumeGroup = false;
- String envt = o.getHeatEnvironmentArtifactUuid();
- if (envt != null && !"".equals(envt)) {
+ HeatEnvironment envt = o.getVolumeHeatEnv();
+ if (envt != null) {
hasVolumeGroup = true;
}
put(valueMap, "MODEL_NAME", vfNull ? null : o.getVfModule().getModelName());
put(valueMap, "MODEL_UUID", vfNull ? null : o.getVfModule().getModelUUID());
- put(valueMap, "MODEL_INVARIANT_ID", vfNull ? null : o.getVfModule().getModelInvariantUuid());
- put(valueMap, "MODEL_VERSION", vfNull ? null : o.getVfModule().getVersion());
- put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid());
- put(valueMap, "IS_BASE", vfNull ? false : o.getVfModule().isBase() ? true : false);
+ put(valueMap, "MODEL_INVARIANT_ID", vfNull ? null : o.getVfModule().getModelInvariantUUID());
+ put(valueMap, "MODEL_VERSION", vfNull ? null : o.getVfModule().getModelVersion());
+ put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID());
+ put(valueMap, "IS_BASE", vfNull ? false : o.getVfModule().getIsBase() ? true : false);
put(valueMap, "VF_MODULE_LABEL", o.getLabel());
put(valueMap, "INITIAL_COUNT", o.getInitialCount());
- put(valueMap, "HAS_VOLUME_GROUP", hasVolumeGroup);
+ put(valueMap, "HAS_VOLUME_GROUP", new Boolean(hasVolumeGroup));
sb.append(sep).append(this.setTemplate(template, valueMap));
sep = ",\n";
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
new file mode 100644
index 0000000000..0eeaa6a72c
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
@@ -0,0 +1,600 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.rest;
+
+/*
+Create an initial query to retrieve a VNF Resource definition (including a list of possible module types)
+within the context of a given service. Input is a vnf resource model customization ID (new field for 1702),
+or a composite key (from 1610) of service name, service version, vnf instance name
+
+Returns a structure (JSON?) containing VNF RESOURCE attributes, plus a list of VF Module structures.
+
+Query a NETWORK_RESOURCE from the MSO Catalog, based on a networkModelCustomizationUUID (new for 1702),
+a network type (unique type identifier in 1610), or based on network role within a service.
+
+Create Adapter framework for access to Catalog DB, including connection management,
+login/password access, transaction logic, etc. This can be modeled after the Request DB Adapter
+
+Update the MSO Catalog DB schema to include the new fields defined in this user story.
+
+Note that the resourceModelCustomizationUUID (or vfModuleModelCustomizationUUID) will be unique keys (indexes)
+on the VNF_RESOURCE and VF_MODULE tables respectively.
+The previously constructed "vnf-type" and "vf-module-type" field may continue to be populated,
+but should no longer be needed and can deprecate in future release.
+
+For migration, a new randomly generated UUID field may be generated for the *ModelCustomizationUUID" fields
+until such time that the model is redistributed from ASDC.
+
+All other fields Check with Mike Z for appropriate value for the vfModuleLabel.
+We might be able to derive it's value from the current vnf-type (using the "middle" piece that identifies the module type).
+
+min and initial counts can be 0. max can be null to indicate no maximum.
+
+Once the network-level distribution artifacts are defined, similar updates can be made to the NETWORK_RESOURCE table.
+*/
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.GenericEntity;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpStatus;
+import org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery;
+import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException;
+import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory;
+import org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization;
+import org.onap.so.adapters.catalogdb.catalogrest.QueryResourceRecipe;
+import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar;
+import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
+import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks;
+import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs;
+import org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule;
+import org.onap.so.db.catalog.beans.AllottedResource;
+import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.Recipe;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.ToscaCsar;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfResource;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
+import org.onap.so.db.catalog.data.repository.ArRecipeRepository;
+import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository;
+import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
+import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
+import org.onap.so.db.catalog.data.repository.VFModuleRepository;
+import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
+import org.onap.so.db.catalog.data.repository.VnfRecipeRepository;
+import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
+import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
+import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1)
+ * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
+ * Requests respond synchronously only
+ */
+@Path("/{version: v[0-9]+}")
+@Component
+public class CatalogDbAdapterRest {
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,CatalogDbAdapterRest.class);
+ private static final boolean IS_ARRAY = true;
+
+ @Autowired
+ private VnfCustomizationRepository vnfCustomizationRepo;
+
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Autowired
+ private NetworkResourceCustomizationRepository networkCustomizationRepo;
+
+ @Autowired
+ private NetworkResourceRepository networkResourceRepo;
+
+ @Autowired
+ private AllottedResourceCustomizationRepository allottedCustomizationRepo;
+
+ @Autowired
+ private ToscaCsarRepository toscaCsarRepo;
+
+ @Autowired
+ private VFModuleRepository vfModuleRepo;
+
+ @Autowired
+ private VnfRecipeRepository vnfRecipeRepo;
+
+ @Autowired
+ private NetworkRecipeRepository networkRecipeRepo;
+
+ @Autowired
+ private ArRecipeRepository arRecipeRepo;
+
+ @Autowired
+ private VnfResourceRepository vnfResourceRepo;
+
+ @Autowired
+ private AllottedResourceRepository arResourceRepo;
+
+ private static final String NO_MATCHING_PARAMETERS = "no matching parameters";
+
+ public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
+ return Response
+ .status(respStatus)
+ //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {})
+ .entity(qryResp.toJsonString(version, isArray))
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ }
+
+ @GET
+ @Path("vnfResources/{vnfModelCustomizationUuid}")
+ @Transactional( readOnly = true)
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public Response serviceVnfs (
+ @PathParam("version") String version,
+ @PathParam("vnfModelCustomizationUuid") String vnfUuid
+ ) {
+ return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null);
+ }
+
+ @GET
+ @Path("serviceVnfs")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Transactional( readOnly = true)
+ public Response serviceVnfs(
+ @PathParam("version") String version,
+ @QueryParam("vnfModelCustomizationUuid") String vnfUuid,
+ @QueryParam("serviceModelUuid") String smUuid,
+ @QueryParam("serviceModelInvariantUuid") String smiUuid,
+ @QueryParam("serviceModelVersion") String smVer,
+ @QueryParam("serviceModelName") String smName
+ ) {
+ return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName);
+ }
+
+ public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, String smiUuid, String smVer, String smName) {
+ QueryServiceVnfs qryResp = null;
+ int respStatus = HttpStatus.SC_OK;
+ List<VnfResourceCustomization> ret = new ArrayList<>();
+ Service service = null;
+ try {
+ if (vnfUuid != null && !"".equals(vnfUuid))
+ ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid);
+ else if (serviceModelUUID != null && !"".equals(serviceModelUUID))
+ service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID);
+ else if (smiUuid != null && !"".equals(smiUuid))
+ if (smVer != null && !"".equals(smVer))
+ service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer,smiUuid);
+ else
+ service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid);
+ else if (smName != null && !"".equals(smName)) {
+ if (smVer != null && !"".equals(smVer))
+ service = serviceRepo.findByModelNameAndModelVersion(smName, smVer);
+ else
+ service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName);
+ }
+ else {
+ throw(new Exception(NO_MATCHING_PARAMETERS));
+ }
+
+ if (service == null && ret.isEmpty()) {
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ qryResp = new QueryServiceVnfs();
+ }else if( service == null && !ret.isEmpty()){
+ qryResp = new QueryServiceVnfs(ret);
+ } else if (service != null) {
+ qryResp = new QueryServiceVnfs(service.getVnfCustomizations());
+ }
+ LOGGER.debug ("serviceVnfs qryResp="+ qryResp);
+ return respond(version, respStatus, isArray, qryResp);
+ } catch (Exception e) {
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, "", "", "queryServiceVnfs", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceVnfs", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {})
+ .build();
+ }
+ }
+
+ @GET
+ @Path("networkResources/{networkModelCustomizationUuid}")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Transactional( readOnly = true)
+ public Response serviceNetworks (
+ @PathParam("version") String version,
+ @PathParam("networkModelCustomizationUuid") String nUuid
+ ) {
+ return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null);
+ }
+
+ @GET
+ @Path("serviceNetworks")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Transactional( readOnly = true)
+ public Response serviceNetworks (
+ @PathParam("version") String version,
+ @QueryParam("networkModelCustomizationUuid") String networkModelCustomizationUuid,
+ @QueryParam("networkType") String networkType,
+ @QueryParam("networkModelName") String networkModelName,
+ @QueryParam("serviceModelUuid") String serviceModelUuid,
+ @QueryParam("serviceModelInvariantUuid") String serviceModelInvariantUuid,
+ @QueryParam("serviceModelVersion") String serviceModelVersion,
+ @QueryParam("networkModelVersion") String networkModelVersion
+ ) {
+ if (networkModelName != null && !"".equals(networkModelName)) {
+ networkType = networkModelName;
+ }
+ return serviceNetworksImpl (version, IS_ARRAY, networkModelCustomizationUuid, networkType, serviceModelUuid, serviceModelInvariantUuid, serviceModelVersion);
+ }
+
+ public Response serviceNetworksImpl (String version, boolean isArray, String networkModelCustomizationUuid, String networkType, String serviceModelUuid, String serviceModelInvariantUuid, String serviceModelVersion) {
+ QueryServiceNetworks qryResp;
+ int respStatus = HttpStatus.SC_OK;
+ String uuid = "";
+ List<NetworkResourceCustomization> ret = new ArrayList<>();
+ Service service = null;
+
+ try{
+ if (networkModelCustomizationUuid != null && !"".equals(networkModelCustomizationUuid)) {
+ uuid = networkModelCustomizationUuid;
+ ret = networkCustomizationRepo.findByModelCustomizationUUID(networkModelCustomizationUuid);
+ }else if (networkType != null && !"".equals(networkType)) {
+ uuid = networkType;
+ NetworkResource networkResources = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
+ if(networkResources != null)
+ ret=networkResources.getNetworkResourceCustomization();
+ }
+ else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
+ uuid = serviceModelInvariantUuid;
+ if (serviceModelVersion != null && !"".equals(serviceModelVersion)) {
+ service = serviceRepo.findByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid);
+ }
+ else {
+ service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
+ }
+ }else if (serviceModelUuid != null && !"".equals(serviceModelUuid)) {
+ uuid = serviceModelUuid;
+ service = serviceRepo.findOneByModelUUID(serviceModelUuid);
+ }
+ else {
+ throw(new Exception(NO_MATCHING_PARAMETERS));
+ }
+
+ if(service != null)
+ ret = service.getNetworkCustomizations();
+
+ if (ret == null || ret.isEmpty()) {
+ LOGGER.debug ("serviceNetworks not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ qryResp = new QueryServiceNetworks();
+ } else {
+ LOGGER.debug ("serviceNetworks found");
+ qryResp = new QueryServiceNetworks(ret);
+ LOGGER.debug ("serviceNetworks qryResp="+ qryResp);
+ }
+ LOGGER.debug ("Query serviceNetworks exit");
+ return respond(version, respStatus, isArray, qryResp);
+ } catch (Exception e) {
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceNetworks", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceNetworks", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {})
+ .build();
+ }
+ }
+
+ @GET
+ @Path("serviceResources")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Transactional(readOnly = true)
+ public Response serviceResources(
+ @PathParam("version") String version,
+ @QueryParam("serviceModelUuid") String modelUUID,
+ @QueryParam("serviceModelInvariantUuid") String modelInvariantUUID,
+ @QueryParam("serviceModelVersion") String modelVersion) {
+ QueryServiceMacroHolder qryResp;
+ int respStatus = HttpStatus.SC_OK;
+ String uuid = "";
+ ServiceMacroHolder ret = new ServiceMacroHolder();
+
+ try{
+ if (modelUUID != null && !"".equals(modelUUID)) {
+ uuid = modelUUID;
+ LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: " + uuid);
+ Service serv =serviceRepo.findOneByModelUUID(uuid);
+ ret.setService(serv);
+ }
+ else if (modelInvariantUUID != null && !"".equals(modelInvariantUUID)) {
+ uuid = modelInvariantUUID;
+ if (modelVersion != null && !"".equals(modelVersion)) {
+ LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ modelVersion);
+ Service serv = serviceRepo.findByModelVersionAndModelInvariantUUID(modelVersion, uuid);
+ ret.setService(serv);
+ }
+ else {
+ LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid);
+ Service serv = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
+ ret.setService(serv);
+ }
+ }
+ else {
+ throw(new Exception(NO_MATCHING_PARAMETERS));
+ }
+
+ if (ret.getService() == null) {
+ LOGGER.debug ("serviceMacroHolder not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ qryResp = new QueryServiceMacroHolder();
+ } else {
+ LOGGER.debug ("serviceMacroHolder found");
+ qryResp = new QueryServiceMacroHolder(ret);
+ LOGGER.debug ("serviceMacroHolder qryResp="+ qryResp);
+ }
+ LOGGER.debug ("Query serviceMacroHolder exit");
+ return respond(version, respStatus, IS_ARRAY, qryResp);
+ } catch (Exception e) {
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceMacroHolder", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceMacroHolder", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp){} )
+ .build();
+ }
+ }
+
+
+ @GET
+ @Path("allottedResources/{arModelCustomizationUuid}")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Transactional( readOnly = true)
+ public Response serviceAllottedResources (
+ @PathParam("version") String version,
+ @PathParam("arModelCustomizationUuid") String aUuid
+ ) {
+ return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null);
+ }
+
+ @GET
+ @Path("serviceAllottedResources")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Transactional( readOnly = true)
+ public Response serviceAllottedResources(
+ @PathParam("version") String version,
+ @QueryParam("serviceModelUuid") String smUuid,
+ @QueryParam("serviceModelInvariantUuid") String smiUuid,
+ @QueryParam("serviceModelVersion") String smVer,
+ @QueryParam("arModelCustomizationUuid") String aUuid
+ ) {
+ return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer);
+ }
+
+ public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) {
+ QueryAllottedResourceCustomization qryResp;
+ int respStatus = HttpStatus.SC_OK;
+ String uuid = "";
+ List<AllottedResourceCustomization> ret = new ArrayList<>();
+ Service service = null;
+ try{
+ if (smUuid != null && !"".equals(smUuid)) {
+ uuid = smUuid;
+ service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid);
+ }
+ else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
+ uuid = serviceModelInvariantUuid;
+ if (smVer != null && !"".equals(smVer)) {
+ service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer, uuid);
+ }
+ else {
+ service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
+ }
+ }
+ else if (aUuid != null && !"".equals(aUuid)) {
+ uuid = aUuid;
+ ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid);
+ }
+ else {
+ throw(new Exception(NO_MATCHING_PARAMETERS));
+ }
+
+ if(service != null)
+ ret=service.getAllottedCustomizations();
+
+ if (ret == null || ret.isEmpty()) {
+ LOGGER.debug ("AllottedResourceCustomization not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ qryResp = new QueryAllottedResourceCustomization();
+ } else {
+ qryResp = new QueryAllottedResourceCustomization(ret);
+ LOGGER.debug ("AllottedResourceCustomization qryResp="+ qryResp);
+ }
+ return respond(version, respStatus, isArray, qryResp);
+ } catch (Exception e) {
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryAllottedResourceCustomization", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryAllottedResourceCustomization", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {})
+ .build();
+ }
+ }
+
+ @GET
+ @Path("vfModules")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ @Transactional( readOnly = true)
+ public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) {
+ QueryVfModule qryResp;
+ int respStatus = HttpStatus.SC_OK;
+ List<VfModuleCustomization> ret = null;
+ try{
+ if(vfModuleModelName != null && !"".equals(vfModuleModelName)){
+ VfModule vfModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc(vfModuleModelName);
+ if(vfModule != null)
+ ret = vfModule.getVfModuleCustomization();
+ }else{
+ throw(new Exception(NO_MATCHING_PARAMETERS));
+ }
+
+ if(ret == null || ret.isEmpty()){
+ LOGGER.debug ("vfModules not found");
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ qryResp = new QueryVfModule();
+ }else{
+ qryResp = new QueryVfModule(ret);
+ LOGGER.debug ("vfModules tojsonstring is: "+ qryResp.JSON2(false, false));
+ }
+ return Response
+ .status(respStatus)
+ .entity(qryResp.JSON2(false, false))
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ }catch(Exception e){
+ LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {})
+ .build();
+ }
+ }
+ /**
+ * Get the tosca csar info from catalog
+ * <br>
+ *
+ * @param smUuid service model uuid
+ * @return the tosca csar information of the serivce.
+ * @since ONAP Beijing Release
+ */
+ @GET
+ @Path("serviceToscaCsar")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
+ int respStatus = HttpStatus.SC_OK;
+ String entity = "";
+ try {
+ if (smUuid != null && !"".equals(smUuid)) {
+ LOGGER.debug("Query Csar by service model uuid: " + smUuid);
+ ToscaCsar toscaCsar = toscaCsarRepo.findOne(smUuid);
+ if (toscaCsar != null) {
+ QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
+ entity = serviceCsar.JSON2(false, false);
+ } else {
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ }
+ } else {
+ throw (new Exception("Incoming parameter is null or blank"));
+ }
+ LOGGER.debug("Query Csar exit");
+ return Response
+ .status(respStatus)
+ .entity(entity)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ } catch (Exception e) {
+ LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {
+ })
+ .build();
+ }
+ }
+
+ /**
+ * Get the resource recipe info from catalog
+ * <br>
+ *
+ * @param rmUuid resource model uuid
+ * @return the recipe information of the resource.
+ * @since ONAP Beijing Release
+ */
+ @GET
+ @Path("resourceRecipe")
+ @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+ public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) {
+ int respStatus = HttpStatus.SC_OK;
+ String entity = "";
+ try {
+ if (rmUuid != null && !"".equals(rmUuid)) {
+ LOGGER.debug("Query recipe by resource model uuid: " + rmUuid);
+ //check vnf and network and ar, the resource could be any resource.
+ VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid);
+ Recipe recipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(vnf.getModelName(), action);
+ if (null == recipe) {
+ NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid);
+ recipe = networkRecipeRepo.findByModelNameAndAction(nResource.getModelName(), action);
+ }
+ if (null == recipe) {
+ AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid);
+ recipe = arRecipeRepo.findByModelNameAndAction(arResource.getModelName(), action);
+ }
+ if (recipe != null) {
+ QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
+ entity = resourceRecipe.JSON2(false, false);
+ } else {
+ respStatus = HttpStatus.SC_NOT_FOUND;
+ }
+ } else {
+ throw (new Exception("Incoming parameter is null or blank"));
+ }
+ LOGGER.debug("Query recipe exit");
+ return Response
+ .status(respStatus)
+ .entity(entity)
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .build();
+ } catch (Exception e) {
+ LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, rmUuid, "", "resourceRecipe",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query recipe by resource model uuid: ", e);
+ CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
+ CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
+ return Response
+ .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
+ .entity(new GenericEntity<CatalogQueryException>(excResp) {
+ })
+ .build();
+ }
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/package-info.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/package-info.java
new file mode 100644
index 0000000000..8f75008aef
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/package-info.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+/**
+ *
+ */
+/**
+ *
+ *
+ */
+
+package org.onap.so.adapters.catalogdb.rest;
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
deleted file mode 100644
index c1c5aee8f1..0000000000
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRest.java
+++ /dev/null
@@ -1,573 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.adapters.catalogdb;
-
-/*
-Create an initial query to retrieve a VNF Resource definition (including a list of possible module types)
-within the context of a given service. Input is a vnf resource model customization ID (new field for 1702),
-or a composite key (from 1610) of service name, service version, vnf instance name
-
-Returns a structure (JSON?) containing VNF RESOURCE attributes, plus a list of VF Module structures.
-
-Query a NETWORK_RESOURCE from the MSO Catalog, based on a networkModelCustomizationUUID (new for 1702),
-a network type (unique type identifier in 1610), or based on network role within a service.
-
-Create Adapter framework for access to Catalog DB, including connection management,
-login/password access, transaction logic, etc. This can be modeled after the Request DB Adapter
-
-Update the MSO Catalog DB schema to include the new fields defined in this user story.
-
-Note that the resourceModelCustomizationUUID (or vfModuleModelCustomizationUUID) will be unique keys (indexes)
-on the VNF_RESOURCE and VF_MODULE tables respectively.
-The previously constructed "vnf-type" and "vf-module-type" field may continue to be populated,
-but should no longer be needed and can deprecate in future release.
-
-For migration, a new randomly generated UUID field may be generated for the *ModelCustomizationUUID" fields
-until such time that the model is redistributed from ASDC.
-
-All other fields Check with Mike Z for appropriate value for the vfModuleLabel.
-We might be able to derive it's value from the current vnf-type (using the "middle" piece that identifies the module type).
-
-min and initial counts can be 0. max can be null to indicate no maximum.
-
-Once the network-level distribution artifacts are defined, similar updates can be made to the NETWORK_RESOURCE table.
-*/
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.GenericEntity;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.http.HttpStatus;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQuery;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryException;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryResourceRecipe;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceCsar;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceNetworks;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs;
-import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryVfModule;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.Recipe;
-import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
-import org.openecomp.mso.db.catalog.beans.ToscaCsar;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-
-/**
- * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1)
- * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
- * Requests respond synchronously only
- */
-@Path("/{version: v[0-9]+}")
-public class CatalogDbAdapterRest {
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
- private static final boolean IS_ARRAY = true;
-
- public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
- return Response
- .status(respStatus)
- //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {})
- .entity(qryResp.toJsonString(version, isArray))
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
- }
-
- @HEAD
- @GET
- @Path("healthcheck")
- @Produces(MediaType.TEXT_HTML)
- public Response healthcheck (
- @PathParam("version") String version
- ) {
- String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application "+ version+ " ready</body></html>";
- return Response.ok().entity(CHECK_HTML).build();
- }
-
- @GET
- @Path("vnfResources/{vnfModelCustomizationUuid}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response serviceVnfs (
- @PathParam("version") String version,
- @PathParam("vnfModelCustomizationUuid") String vnfUuid
- ) {
- return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null);
- }
-
- @GET
- @Path("serviceVnfs")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response serviceVnfs(
- @PathParam("version") String version,
- @QueryParam("vnfModelCustomizationUuid") String vnfUuid,
- @QueryParam("serviceModelUuid") String smUuid,
- @QueryParam("serviceModelInvariantUuid") String smiUuid,
- @QueryParam("serviceModelVersion") String smVer,
- @QueryParam("serviceModelName") String smName
- ) {
- return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName);
- }
-
- public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String smUuid, String smiUuid, String smVer, String smName) {
- QueryServiceVnfs qryResp;
- int respStatus = HttpStatus.SC_OK;
- String uuid = "";
- List<VnfResourceCustomization> ret;
-
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- if (vnfUuid != null && !"".equals(vnfUuid)) {
- uuid = vnfUuid;
- LOGGER.debug ("Query serviceVnfs getAllVnfsByVnfModelCustomizationUuid vnfModelCustomizationUuid: " + uuid);
- ret = db.getAllVnfsByVnfModelCustomizationUuid(uuid);
- }
- else if (smUuid != null && !"".equals(smUuid)) {
- uuid = smUuid;
- LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceModelUuid serviceModelUuid: " + uuid);
- ret = db.getAllVnfsByServiceModelUuid(uuid);
- }
- else if (smiUuid != null && !"".equals(smiUuid)) {
- uuid = smiUuid;
- if (smVer != null && !"".equals(smVer)) {
- LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
- ret = db.getAllVnfsByServiceModelInvariantUuid(uuid, smVer);
- }
- else {
- LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid);
- ret = db.getAllVnfsByServiceModelInvariantUuid(uuid);
- }
- }
- else if (smName != null && !"".equals(smName)) {
- if (smVer != null && !"".equals(smVer)) {
- LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelInvariantName: " + smName+ " serviceModelVersion: "+ smVer);
- ret = db.getAllVnfsByServiceName(smName, smVer);
- }
- else {
- LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelName: " + smName);
- ret = db.getAllVnfsByServiceName(smName);
- }
- }
- else {
- throw(new Exception("no matching parameters"));
- }
-
- if (ret == null || ret.isEmpty()) {
- LOGGER.debug ("serviceVnfs not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- qryResp = new QueryServiceVnfs();
- } else {
- LOGGER.debug ("serviceVnfs found");
- qryResp = new QueryServiceVnfs(ret);
- LOGGER.debug ("serviceVnfs qryResp="+ qryResp);
- }
- LOGGER.debug ("Query serviceVnfs exit");
- return respond(version, respStatus, isArray, qryResp);
- } catch (Exception e) {
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceVnfs", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceVnfs", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {})
- .build();
- }
- }
-
- @GET
- @Path("networkResources/{networkModelCustomizationUuid}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response serviceNetworks (
- @PathParam("version") String version,
- @PathParam("networkModelCustomizationUuid") String nUuid
- ) {
- return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null);
- }
-
- @GET
- @Path("serviceNetworks")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response serviceNetworks (
- @PathParam("version") String version,
- @QueryParam("networkModelCustomizationUuid") String nUuid,
- @QueryParam("networkType") String nType,
- @QueryParam("networkModelName") String nModelName,
- @QueryParam("serviceModelUuid") String smUuid,
- @QueryParam("serviceModelInvariantUuid") String smiUuid,
- @QueryParam("serviceModelVersion") String smVer,
- @QueryParam("networkModelVersion") String nmVer
- ) {
- if (nModelName != null && !"".equals(nModelName)) {
- nType = nModelName;
- }
- return serviceNetworksImpl (version, IS_ARRAY, nUuid, nType, smUuid, smiUuid, smVer);
- }
-
- public Response serviceNetworksImpl (String version, boolean isArray, String nUuid, String nType, String smUuid, String smiUuid, String smVer) {
- QueryServiceNetworks qryResp;
- int respStatus = HttpStatus.SC_OK;
- String uuid = "";
- List<NetworkResourceCustomization> ret;
-
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- if (nUuid != null && !"".equals(nUuid)) {
- uuid = nUuid;
- LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkModelCustomizationUuid networkModelCustomizationUuid: " + uuid);
- ret = db.getAllNetworksByNetworkModelCustomizationUuid(uuid);
- }
- else if (smUuid != null && !"".equals(smUuid)) {
- uuid = smUuid;
- LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelUuid serviceModelUuid: " + uuid);
- ret = db.getAllNetworksByServiceModelUuid(uuid);
- }
- else if (nType != null && !"".equals(nType)) {
- uuid = nType;
- LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkType serviceModelUuid: " + uuid);
- ret = db.getAllNetworksByNetworkType(uuid);
- }
- else if (smiUuid != null && !"".equals(smiUuid)) {
- uuid = smiUuid;
- if (smVer != null && !"".equals(smVer)) {
- LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
- ret = db.getAllNetworksByServiceModelInvariantUuid(uuid, smVer);
- }
- else {
- LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid);
- ret = db.getAllNetworksByServiceModelInvariantUuid(uuid);
- }
- }
- else {
- throw(new Exception("no matching parameters"));
- }
-
- if (ret == null || ret.isEmpty()) {
- LOGGER.debug ("serviceNetworks not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- qryResp = new QueryServiceNetworks();
- } else {
- LOGGER.debug ("serviceNetworks found");
- qryResp = new QueryServiceNetworks(ret);
- LOGGER.debug ("serviceNetworks qryResp="+ qryResp);
- }
- LOGGER.debug ("Query serviceNetworks exit");
- return respond(version, respStatus, isArray, qryResp);
- } catch (Exception e) {
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceNetworks", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceNetworks", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {})
- .build();
- }
- }
-
- @GET
- @Path("serviceResources")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response serviceResources(
- @PathParam("version") String version,
- @QueryParam("serviceModelUuid") String smUuid,
- @QueryParam("serviceModelInvariantUuid") String smiUuid,
- @QueryParam("serviceModelVersion") String smVer) {
- QueryServiceMacroHolder qryResp;
- int respStatus = HttpStatus.SC_OK;
- String uuid = "";
- ServiceMacroHolder ret;
-
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- if (smUuid != null && !"".equals(smUuid)) {
- uuid = smUuid;
- LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: " + uuid);
- ret = db.getAllResourcesByServiceModelUuid(uuid);
- }
- else if (smiUuid != null && !"".equals(smiUuid)) {
- uuid = smiUuid;
- if (smVer != null && !"".equals(smVer)) {
- LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
- ret = db.getAllResourcesByServiceModelInvariantUuid(uuid, smVer);
- }
- else {
- LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid);
- ret = db.getAllResourcesByServiceModelInvariantUuid(uuid);
- }
- }
- else {
- throw(new Exception("no matching parameters"));
- }
-
- if (ret == null) {
- LOGGER.debug ("serviceMacroHolder not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- qryResp = new QueryServiceMacroHolder();
- } else {
- LOGGER.debug ("serviceMacroHolder found");
- qryResp = new QueryServiceMacroHolder(ret);
- LOGGER.debug ("serviceMacroHolder qryResp="+ qryResp);
- }
- LOGGER.debug ("Query serviceMacroHolder exit");
- return respond(version, respStatus, IS_ARRAY, qryResp);
- } catch (Exception e) {
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceMacroHolder", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceMacroHolder", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {})
- .build();
- }
- }
-
- @GET
- @Path("allottedResources/{arModelCustomizationUuid}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response serviceAllottedResources (
- @PathParam("version") String version,
- @PathParam("arModelCustomizationUuid") String aUuid
- ) {
- return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null);
- }
-
- @GET
- @Path("serviceAllottedResources")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response serviceAllottedResources(
- @PathParam("version") String version,
- @QueryParam("serviceModelUuid") String smUuid,
- @QueryParam("serviceModelInvariantUuid") String smiUuid,
- @QueryParam("serviceModelVersion") String smVer,
- @QueryParam("arModelCustomizationUuid") String aUuid
- ) {
- return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer);
- }
-
- public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String smiUuid, String smVer) {
- QueryAllottedResourceCustomization qryResp;
- int respStatus = HttpStatus.SC_OK;
- String uuid = "";
- List<AllottedResourceCustomization > ret;
-
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- if (smUuid != null && !"".equals(smUuid)) {
- uuid = smUuid;
- LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelUuid serviceModelUuid: " + uuid);
- ret = db.getAllAllottedResourcesByServiceModelUuid(uuid);
- }
- else if (smiUuid != null && !"".equals(smiUuid)) {
- uuid = smiUuid;
- if (smVer != null && !"".equals(smVer)) {
- LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
- ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid, smVer);
- }
- else {
- LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid);
- ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid);
- }
- }
- else if (aUuid != null && !"".equals(aUuid)) {
- uuid = aUuid;
- LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByArModelCustomizationUuid serviceModelUuid: " + uuid);
- ret = db.getAllAllottedResourcesByArModelCustomizationUuid(uuid);
- }
- else {
- throw(new Exception("no matching parameters"));
- }
-
- if (ret == null || ret.isEmpty()) {
- LOGGER.debug ("AllottedResourceCustomization not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- qryResp = new QueryAllottedResourceCustomization();
- } else {
- LOGGER.debug ("AllottedResourceCustomization found");
- qryResp = new QueryAllottedResourceCustomization(ret);
- LOGGER.debug ("AllottedResourceCustomization qryResp="+ qryResp);
- }
- LOGGER.debug ("Query AllottedResourceCustomization exit");
- return respond(version, respStatus, isArray, qryResp);
- } catch (Exception e) {
- LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryAllottedResourceCustomization", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryAllottedResourceCustomization", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {})
- .build();
- }
- }
-
- // Added for DHV in 1702. Might be a temporary solution!
- // Changing to use QueryVfModule so the modelCustomizationUuid is included in response
- @GET
- @Path("vfModules")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) {
- QueryVfModule qryResp;
- int respStatus = HttpStatus.SC_OK;
- List<VfModuleCustomization> ret = null;
-
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- if (vfModuleModelName != null && !"".equals(vfModuleModelName)) {
- LOGGER.debug("Query vfModules by vfModuleModuleName: " + vfModuleModelName);
- VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName);
- if (vfModule != null) {
- ret = new ArrayList<>(1);
- ret.add(vfModule);
- }
- } else {
- throw (new Exception("Incoming parameter is null or blank"));
- }
- if (ret == null || ret.isEmpty()) {
- LOGGER.debug("vfModules not found");
- respStatus = HttpStatus.SC_NOT_FOUND;
- qryResp = new QueryVfModule();
- } else {
- LOGGER.debug("vfModules found");
- qryResp = new QueryVfModule(ret);
- LOGGER.debug("vfModules query Results is: " + qryResp);
- LOGGER.debug("vfModules tojsonstring is: " + qryResp.JSON2(false, false));
- }
- LOGGER.debug("Query vfModules exit");
- return Response
- .status(respStatus)
- .entity(qryResp.JSON2(false, false))
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
- } catch (Exception e) {
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules",
- MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ",
- e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
- CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {
- })
- .build();
- }
- }
-
- /**
- * Get the tosca csar info from catalog
- * <br>
- *
- * @param smUuid service model uuid
- * @return the tosca csar information of the serivce.
- * @since ONAP Beijing Release
- */
- @GET
- @Path("serviceToscaCsar")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
- int respStatus = HttpStatus.SC_OK;
- String entity = "";
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- if (smUuid != null && !"".equals(smUuid)) {
- LOGGER.debug("Query Csar by service model uuid: " + smUuid);
- ToscaCsar toscaCsar = db.getToscaCsarByServiceModelUUID(smUuid);
- if (toscaCsar != null) {
- QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
- entity = serviceCsar.JSON2(false, false);
- } else {
- respStatus = HttpStatus.SC_NOT_FOUND;
- }
- } else {
- throw (new Exception("Incoming parameter is null or blank"));
- }
- LOGGER.debug("Query Csar exit");
- return Response
- .status(respStatus)
- .entity(entity)
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
- } catch (Exception e) {
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar",
- MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
- CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {
- })
- .build();
- }
- }
-
- /**
- * Get the resource recipe info from catalog
- * <br>
- *
- * @param rmUuid resource model uuid
- * @return the recipe information of the resource.
- * @since ONAP Beijing Release
- */
- @GET
- @Path("resourceRecipe")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) {
- int respStatus = HttpStatus.SC_OK;
- String entity = "";
- try (CatalogDatabase db = CatalogDatabase.getInstance()) {
- if (rmUuid != null && !"".equals(rmUuid)) {
- LOGGER.debug("Query recipe by resource model uuid: " + rmUuid);
- //check vnf and network and ar, the resource could be any resource.
- Recipe recipe = db.getVnfRecipeByModuleUuid(rmUuid, action);
- if (null == recipe) {
- recipe = db.getNetworkRecipeByModuleUuid(rmUuid, action);
- }
- if (null == recipe) {
- recipe = db.getArRecipeByModuleUuid(rmUuid, action);
- }
- if (recipe != null) {
- QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
- entity = resourceRecipe.JSON2(false, false);
- } else {
- respStatus = HttpStatus.SC_NOT_FOUND;
- }
- } else {
- throw (new Exception("Incoming parameter is null or blank"));
- }
- LOGGER.debug("Query recipe exit");
- return Response
- .status(respStatus)
- .entity(entity)
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- .build();
- } catch (Exception e) {
- LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, rmUuid, "", "resourceRecipe",
- MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query recipe by resource model uuid: ", e);
- CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
- CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
- return Response
- .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
- .entity(new GenericEntity<CatalogQueryException>(excResp) {
- })
- .build();
- }
- }
-}