summaryrefslogtreecommitdiffstats
path: root/dcaedt_catalog/service
diff options
context:
space:
mode:
authorEran (ev672n), Vosk <ev672n@att.com>2018-08-06 17:02:39 +0300
committerEran (ev672n), Vosk <ev672n@att.com>2018-08-06 17:02:39 +0300
commit86457ed120fc236b1485ad3251589aedad2401bd (patch)
treea473c2faf16ffbb34aad75d4fef8afc3b2541f21 /dcaedt_catalog/service
parent735b58119b37ead5013c40afd941d63ef28ca053 (diff)
Changing the dcae dt main code
Updating DCAE-dt-main code for Dockerizing the DCAE-CI code Change-Id: Ia50d24e60e9ddc9bbc58dd8651d7a4f7e0dc8270 Issue-ID: SDC-1605 Signed-off-by: Eran (ev672n), Vosk <ev672n@att.com>
Diffstat (limited to 'dcaedt_catalog/service')
-rw-r--r--dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogController.java79
-rw-r--r--dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogEngine.java14
2 files changed, 5 insertions, 88 deletions
diff --git a/dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogController.java b/dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogController.java
index b42f8cf..b364087 100644
--- a/dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogController.java
+++ b/dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogController.java
@@ -18,27 +18,16 @@ under the License.
*/
package org.onap.sdc.dcae.catalog.engine;
-import org.json.JSONObject;
import org.onap.sdc.common.onaplog.Enums.LogLevel;
import org.onap.sdc.common.onaplog.OnapLoggerDebug;
-import org.onap.sdc.dcae.catalog.Catalog;
import org.onap.sdc.dcae.catalog.asdc.ASDCCatalog;
import org.onap.sdc.dcae.catalog.commons.Future;
import org.onap.sdc.dcae.catalog.commons.FutureHandler;
-import org.onap.sdc.dcae.composition.util.DcaeBeConstants;
-import org.onap.sdc.dcae.composition.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.DeferredResult;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* All requests body:
* {
@@ -94,73 +83,11 @@ public class CatalogController {
private static OnapLoggerDebug debugLogger = OnapLoggerDebug.getInstance();
-
@Autowired
- private SystemProperties systemProperties;
-
- private URI defaultCatalog;
- private static Map<URI, Catalog> catalogs = new HashMap<>();
-
-
- public void setDefaultCatalog(URI theUri) {
- debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "set default catalog at {}", theUri);
- this.defaultCatalog = theUri;
- }
-
- @PostConstruct
- public void initCatalog() {
- // Dump some info and construct our configuration objects
- debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "initCatalog");
-
- this.defaultCatalog = URI.create(systemProperties.getProperties().getProperty(DcaeBeConstants.Config.ASDC_CATALOG_URL));
- // Initialize default catalog connection
- debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "default catalog at {}", this.defaultCatalog);
- getCatalog(null);
-
- // Done
- debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "CatalogEngine started");
- }
-
- @PreDestroy
- public void cleanupCatalog() {
- debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "destroyCatalog");
- }
-
- public Catalog getCatalog(URI theCatalogUri) {
- //TODO: Thread safety! Check catalog is alive!
- if (theCatalogUri == null) {
- theCatalogUri = this.defaultCatalog;
- }
-
- Catalog cat = catalogs.get(theCatalogUri);
- if (cat == null && theCatalogUri != null) {
- String scheme = theCatalogUri.getScheme();
- URI catalogUri;
- try {
- catalogUri = new URI(theCatalogUri.getSchemeSpecificPart() + "#" + theCatalogUri.getFragment());
- }
- catch (URISyntaxException urisx) {
- throw new IllegalArgumentException("Invalid catalog reference '" + theCatalogUri.getSchemeSpecificPart() + "'");
- }
- debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Build catalog for {}", catalogUri);
-
- if ("asdc".equals(scheme)) {
- cat = new ASDCCatalog(catalogUri);
- }
- else {
- return null;
- }
-
- catalogs.put(theCatalogUri, cat);
- }
- return cat;
- }
+ private ASDCCatalog catalog;
- public JSONObject patchData(Catalog theCat, JSONObject theData) {
- theData.put("catalog", theCat.getUri());
- theData.put("catalogId", theData.optLong("id"));
- theData.put("id", theData.optLong("itemId"));
- return theData;
+ public ASDCCatalog getCatalog() {
+ return catalog;
}
public abstract class CatalogHandler<T> implements FutureHandler<T> {
diff --git a/dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogEngine.java b/dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogEngine.java
index 042798f..98db815 100644
--- a/dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogEngine.java
+++ b/dcaedt_catalog/service/src/main/java/org/onap/sdc/dcae/catalog/engine/CatalogEngine.java
@@ -1,21 +1,11 @@
package org.onap.sdc.dcae.catalog.engine;
-import org.onap.sdc.dcae.catalog.engine.CatalogEngine;
import org.springframework.boot.SpringApplication;
-import org.springframework.context.ApplicationContext;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.ImportResource;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-
-import java.util.Arrays;
-
-
+import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
-
+@ComponentScan("org.onap.sdc.dcae")
public class CatalogEngine {
public static void main(String[] args) {