summaryrefslogtreecommitdiffstats
path: root/sliapi/springboot/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sliapi/springboot/src/main')
-rw-r--r--sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java12
-rw-r--r--sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java (renamed from sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/ExecuteGraphController.java)23
-rw-r--r--sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java (renamed from sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java)73
-rw-r--r--sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java71
-rw-r--r--sliapi/springboot/src/main/resources/application.properties4
5 files changed, 108 insertions, 75 deletions
diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java
new file mode 100644
index 00000000..941c1d51
--- /dev/null
+++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/App.java
@@ -0,0 +1,12 @@
+package org.onap.ccsdk.sli.core.sliapi.springboot;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class App {
+
+ public static void main(String[] args) throws Exception {
+ SpringApplication.run(App.class, args);
+ }
+}
diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/ExecuteGraphController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java
index 79499d56..efdefbd6 100644
--- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/ExecuteGraphController.java
+++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/ExecuteGraphController.java
@@ -1,26 +1,19 @@
-package org.onap.ccsdk.sli.core.sliapi.springboot;
+package org.onap.ccsdk.sli.core.sliapi.springboot.controllers;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Properties;
-
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicLoader;
-import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver;
-import org.onap.ccsdk.sli.core.sli.provider.base.InMemorySvcLogicStore;
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver;
import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase;
-import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.boot.SpringApplication;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
-
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@@ -30,7 +23,8 @@ import com.google.gson.JsonParser;
@Controller
@EnableAutoConfiguration
public class ExecuteGraphController {
- static SvcLogicServiceBase svc;
+ @Autowired
+ protected SvcLogicServiceBase svc;
private static final Logger LOGGER = LoggerFactory.getLogger(ExecuteGraphController.class);
@RequestMapping(value = "/executeGraph", method = RequestMethod.POST)
@@ -98,12 +92,5 @@ public class ExecuteGraphController {
}
}
- public static void main(String[] args) throws Exception {
- InMemorySvcLogicStore store = new InMemorySvcLogicStore();
- SvcLogicLoader loader = new SvcLogicLoader(System.getProperty("serviceLogicDirectory"), store);
- loader.loadAndActivate();
- SvcLogicResolver resolver = new HashMapResolver();
- svc = new SvcLogicServiceImplBase(store, resolver);
- SpringApplication.run(ExecuteGraphController.class, args);
- }
+
}
diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java
index 2da5490a..10442d43 100644
--- a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/RestconfApiController.java
+++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/controllers/swagger/RestconfApiController.java
@@ -1,25 +1,26 @@
-package org.onap.ccsdk.sli.core.sliapi.springboot;
+package org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.*;
-import org.onap.ccsdk.sli.core.sli.*;
-import org.onap.ccsdk.sli.core.sli.provider.base.*;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase;
import org.onap.ccsdk.sli.core.sliapi.model.ExecuteGraphInput;
import org.onap.ccsdk.sli.core.sliapi.model.ResponseFields;
+import org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.RestconfApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.validation.Valid;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Properties;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-02-20T12:50:11.207-05:00")
@@ -29,54 +30,14 @@ public class RestconfApiController implements RestconfApi {
private final ObjectMapper objectMapper;
private final HttpServletRequest request;
-
- private static SvcLogicServiceBase svc;
+ @Autowired
+ protected SvcLogicServiceBase svc;
private static final Logger log = LoggerFactory.getLogger(RestconfApiController.class);
@org.springframework.beans.factory.annotation.Autowired
public RestconfApiController(ObjectMapper objectMapper, HttpServletRequest request) {
this.objectMapper = objectMapper;
this.request = request;
-
- SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() {
-
- @Override
- public Properties getProperties() {
- Properties props = new Properties();
- String propPath = "src/main/resources/svclogic.properties";
- System.out.println(propPath);
- try (FileInputStream fileInputStream = new FileInputStream(propPath)) {
- props = new Properties();
- props.load(fileInputStream);
- } catch (final IOException e) {
- log.error("Failed to load properties for file: {}", propPath,
- new ConfigurationException("Failed to load properties for file: " + propPath, e));
- }
- return props;
- }
- };
-
- SvcLogicStore store = null;
- try {
- store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties());
- } catch (SvcLogicException e) {
- log.error("Cannot create SvcLogicStore", e);
- return;
- }
-
- String serviceLogicDirectory = System.getProperty("serviceLogicDirectory", "src/main/resources");
- System.out.println("serviceLogicDirectory is " + serviceLogicDirectory);
- SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, store);
-
- try {
- loader.loadAndActivate();
- } catch (IOException e) {
- log.error("Cannot load directed graphs", e);
- }
- SvcLogicResolver resolver = new HashMapResolver();
-
- svc = new SvcLogicServiceImplBase(store, resolver);
-
}
@Override
diff --git a/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java
new file mode 100644
index 00000000..f39fc229
--- /dev/null
+++ b/sliapi/springboot/src/main/java/org/onap/ccsdk/sli/core/sliapi/springboot/core/SvcLogicFactory.java
@@ -0,0 +1,71 @@
+package org.onap.ccsdk.sli.core.sliapi.springboot.core;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+import org.onap.ccsdk.sli.core.sli.ConfigurationException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicLoader;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
+import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
+import org.onap.ccsdk.sli.core.sli.provider.base.HashMapResolver;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicResolver;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceBase;
+import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class SvcLogicFactory {
+ private static final Logger log = LoggerFactory.getLogger(SvcLogicFactory.class);
+
+ @Bean
+ public SvcLogicStore getStore() throws Exception {
+ SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() {
+
+ @Override
+ public Properties getProperties() {
+ Properties props = new Properties();
+ String propPath = "src/main/resources/svclogic.properties";
+ System.out.println(propPath);
+ try (FileInputStream fileInputStream = new FileInputStream(propPath)) {
+ props = new Properties();
+ props.load(fileInputStream);
+ } catch (final IOException e) {
+ log.error("Failed to load properties for file: {}", propPath,
+ new ConfigurationException("Failed to load properties for file: " + propPath, e));
+ }
+ return props;
+ }
+ };
+ SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties());
+ return store;
+ }
+
+ @Bean
+ public SvcLogicLoader createLoader() throws Exception {
+ String serviceLogicDirectory = System.getProperty("serviceLogicDirectory");
+ if (serviceLogicDirectory == null) {
+ serviceLogicDirectory = "src/main/resources";
+ }
+
+ System.out.println("serviceLogicDirectory is " + serviceLogicDirectory);
+ SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, getStore());
+
+ try {
+ loader.loadAndActivate();
+ } catch (IOException e) {
+ log.error("Cannot load directed graphs", e);
+ }
+ return loader;
+ }
+
+ @Bean
+ public SvcLogicServiceBase createService() throws Exception {
+ SvcLogicResolver resolver = new HashMapResolver();
+ return new SvcLogicServiceImplBase(getStore(), resolver);
+ }
+
+}
diff --git a/sliapi/springboot/src/main/resources/application.properties b/sliapi/springboot/src/main/resources/application.properties
index 64415bd3..851488b9 100644
--- a/sliapi/springboot/src/main/resources/application.properties
+++ b/sliapi/springboot/src/main/resources/application.properties
@@ -1,8 +1,10 @@
springfox.documentation.swagger.v2.path=/api-docs
server.contextPath=/restconf
server.port=8080
-spring.jackson.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.RFC3339DateFormat
+spring.jackson.date-format=org.onap.ccsdk.sli.core.sliapi.springboot.controllers.swagger.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
spring.datasource.url=jdbc:derby:sdnctl;create=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DerbyTenSevenDialect
spring.jpa.hibernate.ddl-auto=update
+logging.level.com.att=TRACE
+logging.level.org.onap=TRACE \ No newline at end of file