diff options
21 files changed, 381 insertions, 569 deletions
@@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP CLAMP ================================================================================ - Copyright (C) 2017 AT&T Intellectual Property. All rights + Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,11 +33,11 @@ <parent> <groupId>org.onap.oparent</groupId> <artifactId>oparent</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>1.1.0-SNAPSHOT</version> </parent> <description> - This project build the ONAP CLAMP JAR that contains AJSC + CLAMP code. + This project build the ONAP CLAMP JAR that contains CLAMP back-end code and its UI part. By Default "mvn clean install" command will execute also the unit tests and the integration tests. The integration tests require a docker engine running. @@ -54,7 +54,7 @@ - org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json - org.onap.clamp.config.files.globalClds=classpath:/clds/globalClds.properties - </description> + </description> <properties> <maven.build.timestamp.format>yyyy.MM.dd'T'hh.mm.ss'Z'</maven.build.timestamp.format> @@ -66,12 +66,12 @@ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <docker.mariadb.port.host>3306</docker.mariadb.port.host> - <sdk.java.common.logging>0.0.3-oss</sdk.java.common.logging> <project.scm.id>git-server</project.scm.id> <java.version>1.8</java.version> - <csi.logging>6.1.0.6-oss</csi.logging> - <sdk.camel.rest>6.2.0.6-oss</sdk.camel.rest> - <sdk.camunda.core>6.1.0.3-oss</sdk.camunda.core> + + <eelf.core.version>1.0.0</eelf.core.version> + <camel.version>2.20.1</camel.version> + <springboot.version>1.5.9.RELEASE</springboot.version> <sonar.language>java</sonar.language> <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin> @@ -145,11 +145,27 @@ <dependencyManagement> <dependencies> + <!-- Spring Boot BOM --> <dependency> - <!-- Import dependency management from Spring Boot --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> - <version>1.4.1.RELEASE</version> + <version>${springboot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <!-- Camunda BOM --> + <dependency> + <groupId>org.camunda.bpm</groupId> + <artifactId>camunda-bom</artifactId> + <version>7.6.0</version> + <scope>import</scope> + <type>pom</type> + </dependency> + <!-- Camel BOM --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-dependencies</artifactId> + <version>${camel.version}</version> <type>pom</type> <scope>import</scope> </dependency> @@ -158,43 +174,40 @@ <dependencies> <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>2.6</version> + <groupId>com.att.eelf</groupId> + <artifactId>eelf-core</artifactId> + <version>${eelf.core.version}</version> </dependency> + <!-- For CAMEL --> <dependency> - <groupId>com.googlecode.json-simple</groupId> - <artifactId>json-simple</artifactId> - <version>1.1</version> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring-boot-starter</artifactId> + </dependency> <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-vfs2</artifactId> - <version>2.0</version> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jaxb-starter</artifactId> </dependency> - <dependency> - <groupId>org.springframework.security</groupId> - <artifactId>spring-security-test</artifactId> - - <scope>test</scope> + <groupId>org.apache.camel</groupId> + <artifactId>camel-cxf-starter</artifactId> </dependency> - - - <!-- Dependencies of parent pom start --> + <!-- Spring famework --> <dependency> - <groupId>com.att.ajsc</groupId> - <artifactId>sdk-java-common-logging</artifactId> - <version>${sdk.java.common.logging}</version> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> - <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> + <artifactId>spring-boot-starter-jersey</artifactId> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -202,16 +215,42 @@ </dependency> <dependency> <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> + + <!-- For CAmunda --> <dependency> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> + <groupId>org.camunda.bpm.extension.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter</artifactId> + <version>2.0.0</version> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> + <groupId>org.camunda.bpm.extension.springboot</groupId> + <artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId> + <version>2.0.0</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.6</version> + </dependency> + <dependency> + <groupId>com.googlecode.json-simple</groupId> + <artifactId>json-simple</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-vfs2</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>joda-time</groupId> + <artifactId>joda-time</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> @@ -223,10 +262,6 @@ <version>2.0</version> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - </dependency> - <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> @@ -236,15 +271,6 @@ <version>1.9.5</version> </dependency> <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>1.1.1</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-aspects</artifactId> - </dependency> - <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> </dependency> @@ -253,27 +279,6 @@ <artifactId>jackson-databind</artifactId> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-webmvc</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.17</version> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-autoconfigure</artifactId> - </dependency> - <dependency> <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <version>1.1</version> @@ -288,57 +293,16 @@ <artifactId>hibernate-annotations</artifactId> <version>3.5.6-Final</version> </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jpa_2.0_spec</artifactId> - <version>1.1</version> - </dependency> + <!-- <dependency> --> + <!-- <groupId>org.apache.geronimo.specs</groupId> --> + <!-- <artifactId>geronimo-jpa_2.0_spec</artifactId> --> + <!-- <version>1.1</version> --> + <!-- </dependency> --> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> - <version>1.6.1</version> - </dependency> - <!-- Dependencies of parent pom end --> - <dependency> - <groupId>com.att.ajsc</groupId> - <artifactId>sdk-java-camel-rest</artifactId> - <version>${sdk.camel.rest}</version> </dependency> - <!-- Camunda Core --> - <dependency> - <groupId>com.att.ajsc</groupId> - <artifactId>sdk-java-camunda-core</artifactId> - <version>${sdk.camunda.core}</version> - <exclusions> - <exclusion> - <groupId>mysql</groupId> - <artifactId>mysql-connector-java</artifactId> - </exclusion> - </exclusions> - </dependency> - <!-- Spring Mail --> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context-support</artifactId> - </dependency> - <!-- CSI Logging --> - <dependency> - <groupId>com.att.ajsc</groupId> - <artifactId>sdk-java-common-interceptors</artifactId> - <version>${csi.logging}</version> - <exclusions> - <exclusion> - <groupId>org.eclipse.jetty.orbit</groupId> - <artifactId>javax.servlet</artifactId> - </exclusion> - <exclusion> - <groupId>com.att.ajsc</groupId> - <artifactId>ajsc-core</artifactId> - </exclusion> - </exclusions> - </dependency> - <!-- CSI Logging End --> <dependency> <groupId>org.onap.policy.engine</groupId> <artifactId>PolicyEngineAPI</artifactId> @@ -364,6 +328,10 @@ <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </exclusion> + <exclusion> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </exclusion> </exclusions> </dependency> <dependency> @@ -402,6 +370,14 @@ <artifactId>apache-log4j-extras</artifactId> <groupId>log4j</groupId> </exclusion> + <exclusion> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + </exclusion> + <exclusion> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + </exclusion> </exclusions> </dependency> <dependency> @@ -464,12 +440,10 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> - <version>2.6.3</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-yaml</artifactId> - <version>2.6.3</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> @@ -477,11 +451,6 @@ <version>1.3</version> </dependency> <dependency> - <groupId>org.jboss.resteasy</groupId> - <artifactId>resteasy-client</artifactId> - <version>3.0.8.Final</version> - </dependency> - <dependency> <groupId>com.sun.faces</groupId> <artifactId>jsf-api</artifactId> <version>2.1.7</version> @@ -596,7 +565,7 @@ <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> - <version>1.5.3.RELEASE</version> + <version>${springboot.version}</version> <executions> <execution> <goals> diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index e2bfbd77..2727535e 100644 --- a/src/main/java/org/onap/clamp/clds/Application.java +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,22 +23,12 @@ package org.onap.clamp.clds; -import com.att.ajsc.common.utility.SystemPropertiesLoader; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import java.util.ArrayList; -import java.util.Collection; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; - -import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.apache.catalina.connector.Connector; -import org.camunda.bpm.spring.boot.starter.webapp.CamundaBpmWebappAutoConfiguration; import org.onap.clamp.clds.model.prop.Holmes; import org.onap.clamp.clds.model.prop.ModelProperties; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration; @@ -51,38 +41,36 @@ import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; -import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.support.SpringBootServletInitializer; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableAsync; @SpringBootApplication -@ComponentScan(basePackages = { "org.onap.clamp.clds", "com.att.ajsc" }) -@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, CamundaBpmWebappAutoConfiguration.class, - HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, SecurityAutoConfiguration.class, - ManagementWebSecurityAutoConfiguration.class }) +@ComponentScan(basePackages = { + "org.onap.clamp.clds" +}) +@EnableAutoConfiguration(exclude = { + DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, + SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class +}) @EnableAsync public class Application extends SpringBootServletInitializer { - protected static final EELFLogger EELF_LOGGER = EELFManager.getInstance().getLogger(Application.class); - @Autowired - private ApplicationContext appContext; - private static final String CAMEL_SERVLET_NAME = "CamelServlet"; - private static final String CAMEL_URL_MAPPING = "/restservices/clds/v1/*"; + + protected static final EELFLogger EELF_LOGGER = EELFManager.getInstance().getLogger(Application.class); // This settings is an additional one to Spring config, // only if we want to have an additional port automatically redirected to // HTTPS @Value("${server.http-to-https-redirection.port:none}") - private String httpRedirectedPort; + private String httpRedirectedPort; /** * This 8080 is the default port used by spring if this parameter is not * specified in application.properties. */ @Value("${server.port:8080}") - private String springServerPort; + private String springServerPort; @Value("${server.ssl.key-store:none}") - private String sslKeystoreFile; + private String sslKeystoreFile; @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { @@ -90,8 +78,6 @@ public class Application extends SpringBootServletInitializer { } public static void main(String[] args) { - // This is to load the system.properties file parameters - SystemPropertiesLoader.addSystemProperties(); // This is to initialize some Onap Clamp components initializeComponents(); // Start the Spring application @@ -102,22 +88,6 @@ public class Application extends SpringBootServletInitializer { ModelProperties.registerModelElement(Holmes.class, Holmes.getType()); } - @Bean - public ServletRegistrationBean servletRegistrationBean() { - ServletRegistrationBean registration = new ServletRegistrationBean(); - registration.setName(CAMEL_SERVLET_NAME); - registration.setServlet(new CamelHttpTransportServlet()); - Collection<String> urlMappings = new ArrayList<>(); - urlMappings.add(CAMEL_URL_MAPPING); - registration.setUrlMappings(urlMappings); - return registration; - } - - @Bean - public Client restClient() { - return ClientBuilder.newClient(); - } - /** * This method is used by Spring to create the servlet container factory. * diff --git a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java index 385a4e41..f13f4222 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java +++ b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +28,6 @@ import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; import java.io.IOException; import java.util.Map; @@ -39,13 +38,14 @@ import org.onap.clamp.clds.model.prop.Tca; import org.onap.clamp.clds.model.prop.TcaItem; import org.onap.clamp.clds.model.prop.TcaThreshold; import org.onap.clamp.clds.model.refprop.RefProp; +import org.yaml.snakeyaml.Yaml; /** * Construct the requests for TCA policy and SDC. - * */ public class TcaRequestFormatter { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaRequestFormatter.class); + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaRequestFormatter.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); /** diff --git a/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java b/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java deleted file mode 100644 index af9e695e..00000000 --- a/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * 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============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.config; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import java.util.EnumSet; -import java.util.Map; - -import javax.servlet.DispatcherType; -import javax.servlet.Filter; -import javax.servlet.FilterRegistration; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; - -import org.camunda.bpm.spring.boot.starter.CamundaBpmAutoConfiguration; -import org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; -import org.springframework.boot.web.servlet.ServletContextInitializer; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ConditionalOnWebApplication -@AutoConfigureAfter(CamundaBpmAutoConfiguration.class) -public class CamundaAuthFilterInitializer implements ServletContextInitializer { - private static final EnumSet<DispatcherType> DISPATCHER_TYPES = EnumSet.of(DispatcherType.REQUEST); - private ServletContext servletContext; - @Value("${com.att.ajsc.camunda.contextPath:/camunda}") - private String camundaSuffix; - protected static final EELFLogger logger = EELFManager.getInstance() - .getLogger(CamundaAuthFilterInitializer.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - - @Override - public void onStartup(ServletContext servletContext) throws ServletException { - this.servletContext = servletContext; - registerFilter("Authentication Filter", AuthenticationFilter.class, camundaSuffix + "/*"); - } - - private FilterRegistration registerFilter(final String filterName, final Class<? extends Filter> filterClass, - final String... urlPatterns) { - return registerFilter(filterName, filterClass, null, urlPatterns); - } - - private FilterRegistration registerFilter(final String filterName, final Class<? extends Filter> filterClass, - final Map<String, String> initParameters, final String... urlPatterns) { - FilterRegistration filterRegistration = servletContext.getFilterRegistration(filterName); - if (filterRegistration == null) { - filterRegistration = servletContext.addFilter(filterName, filterClass); - filterRegistration.addMappingForUrlPatterns(DISPATCHER_TYPES, true, urlPatterns); - if (initParameters != null) { - filterRegistration.setInitParameters(initParameters); - } - } - return filterRegistration; - } -} diff --git a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java index 9367bc24..b99d3a96 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,12 +23,6 @@ package org.onap.clamp.clds.config; -import com.att.ajsc.common.AjscProvider; -import com.att.ajsc.common.AjscService; - -import java.util.ArrayList; -import java.util.List; - import javax.sql.DataSource; import javax.xml.transform.TransformerConfigurationException; @@ -48,19 +42,17 @@ import org.onap.clamp.clds.client.req.sdc.SdcReq; import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.model.refprop.RefProp; import org.onap.clamp.clds.transform.XslTransformer; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.config.PropertiesFactoryBean; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; +import org.springframework.core.io.ClassPathResource; @Configuration @Profile("clamp-default") public class CldsConfiguration { - @Autowired - private ApplicationContext context; /** * Clds Identity database DataSource configuration @@ -73,14 +65,11 @@ public class CldsConfiguration { return new EncodedPasswordBasicDataSource(); } - @Bean(name = "jaxrsProviders") - public List<?> jaxrsProviders() { - return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values()); - } - - @Bean(name = "jaxrsServices") - public List<?> jaxrsServices() { - return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values()); + @Bean(name = "mapper") + public PropertiesFactoryBean mapper() { + PropertiesFactoryBean bean = new PropertiesFactoryBean(); + bean.setLocation(new ClassPathResource("system.properties")); + return bean; } @Bean(name = "cldsDao") diff --git a/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java deleted file mode 100644 index 5b48e8d8..00000000 --- a/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * 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============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.att.ajsc.csilogging.common.AsyncSupport; -import com.att.ajsc.csilogging.interceptors.CsiLoggingCamelPostInterceptor; -import com.att.ajsc.csilogging.interceptors.CsiLoggingCamelPreInterceptor; - -@Configuration -public class CsiLoggingConfiguration { - @Bean - public CsiLoggingCamelPreInterceptor csiLoggingCamelPreInterceptor() { - return new CsiLoggingCamelPreInterceptor(); - } - - @Bean - public CsiLoggingCamelPostInterceptor csiLoggingCamelPostInterceptor() { - return new CsiLoggingCamelPostInterceptor(); - } - - @Bean - public AsyncSupport asyncsupport() { - return new AsyncSupport(); - } -} diff --git a/src/main/java/org/onap/clamp/clds/Routes.java b/src/main/java/org/onap/clamp/clds/config/SystemPropertiesLoader.java index d9520e78..83325f3d 100644 --- a/src/main/java/org/onap/clamp/clds/Routes.java +++ b/src/main/java/org/onap/clamp/clds/config/SystemPropertiesLoader.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,23 +21,24 @@ * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ -package org.onap.clamp.clds; +package org.onap.clamp.clds.config; -import com.att.ajsc.common.camel.AjscRouteBuilder; +import java.util.Properties; -import org.apache.camel.builder.RouteBuilder; -import org.springframework.beans.factory.annotation.Autowired; +import javax.annotation.Resource; + +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.stereotype.Component; @Component -public class Routes extends RouteBuilder { - @Autowired - private AjscRouteBuilder ajscRoute; +public class SystemPropertiesLoader implements ApplicationListener<ContextRefreshedEvent> { + + @Resource(name = "mapper") + private Properties myTranslator; @Override - public void configure() { - ajscRoute.initialize(this); - ajscRoute - .setRoute(from("servlet:/?matchOnUriPrefix=true").to("cxfbean:jaxrsServices?providers=jaxrsProviders")); + public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { + System.getProperties().putAll(myTranslator); } } diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java index 7bef430d..088d4733 100644 --- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,6 +27,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import java.io.InputStream; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -34,6 +35,7 @@ import java.util.Map; import javax.sql.DataSource; +import org.onap.clamp.clds.model.CLDSMonitoringDetails; import org.onap.clamp.clds.model.CldsDBServiceCache; import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.CldsModel; @@ -54,6 +56,7 @@ import org.springframework.stereotype.Repository; */ @Repository("cldsDao") public class CldsDao { + private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class); private JdbcTemplate jdbcTemplateObject; private SimpleJdbcCall procGetModel; @@ -413,4 +416,40 @@ public class CldsDao { } return cldsModelPropList; } + + /** + * Method to get deployed/active models with model properties. + * + * @return list of CLDS-Monitoring-Details: CLOSELOOP_NAME | Close loop name + * used in the CLDS application (prefix: ClosedLoop- + unique + * ClosedLoop ID) MODEL_NAME | Model Name in CLDS application + * SERVICE_TYPE_ID | TypeId returned from the DCAE application when + * the ClosedLoop is submitted (DCAEServiceTypeRequest generated in + * DCAE application). DEPLOYMENT_ID | Id generated when the + * ClosedLoop is deployed in DCAE. TEMPLATE_NAME | Template used to + * generate the ClosedLoop model. ACTION_CD | Current state of the + * ClosedLoop in CLDS application. + */ + public List<CLDSMonitoringDetails> getCLDSMonitoringDetails() { + SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss"); + List<CLDSMonitoringDetails> cldsMonitoringDetailsList = new ArrayList<CLDSMonitoringDetails>(); + String modelsSql = "SELECT CONCAT(M.CONTROL_NAME_PREFIX, M.CONTROL_NAME_UUID) AS CLOSELOOP_NAME , M.MODEL_NAME, M.SERVICE_TYPE_ID, M.DEPLOYMENT_ID, T.TEMPLATE_NAME, E.ACTION_CD, E.USER_ID, E.TIMESTAMP " + + "FROM MODEL M, TEMPLATE T, EVENT E " + + "WHERE M.TEMPLATE_ID = T.TEMPLATE_ID AND M.EVENT_ID = E.EVENT_ID " + "ORDER BY ACTION_CD"; + List<Map<String, Object>> rows = jdbcTemplateObject.queryForList(modelsSql); + CLDSMonitoringDetails cldsMonitoringDetails = null; + for (Map<String, Object> row : rows) { + cldsMonitoringDetails = new CLDSMonitoringDetails(); + cldsMonitoringDetails.setCloseloopName((String) row.get("CLOSELOOP_NAME")); + cldsMonitoringDetails.setModelName((String) row.get("MODEL_NAME")); + cldsMonitoringDetails.setServiceTypeId((String) row.get("SERVICE_TYPE_ID")); + cldsMonitoringDetails.setDeploymentId((String) row.get("DEPLOYMENT_ID")); + cldsMonitoringDetails.setTemplateName((String) row.get("TEMPLATE_NAME")); + cldsMonitoringDetails.setAction((String) row.get("ACTION_CD")); + cldsMonitoringDetails.setUserid((String) row.get("USER_ID")); + cldsMonitoringDetails.setTimestamp(sdf.format(row.get("TIMESTAMP"))); + cldsMonitoringDetailsList.add(cldsMonitoringDetails); + } + return cldsMonitoringDetailsList; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CLDSMonitoringDetails.java b/src/main/java/org/onap/clamp/clds/model/CLDSMonitoringDetails.java new file mode 100644 index 00000000..be4f9509 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CLDSMonitoringDetails.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 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============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.model; + +/** + * Maintains model and template details. + */ +public class CLDSMonitoringDetails { + + private String closeloopName; + private String modelName; + private String serviceTypeId; + private String deploymentId; + private String templateName; + private String action; + private String userid; + private String timestamp; + + public String getCloseloopName() { + return closeloopName; + } + + public void setCloseloopName(String closeloopName) { + this.closeloopName = closeloopName; + } + + public String getModelName() { + return modelName; + } + + public void setModelName(String modelName) { + this.modelName = modelName; + } + + public String getServiceTypeId() { + return serviceTypeId; + } + + public void setServiceTypeId(String serviceTypeId) { + this.serviceTypeId = serviceTypeId; + } + + public String getDeploymentId() { + return deploymentId; + } + + public void setDeploymentId(String deploymentId) { + this.deploymentId = deploymentId; + } + + public String getTemplateName() { + return templateName; + } + + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getUserid() { + return userid; + } + + public void setUserid(String userid) { + this.userid = userid; + } + + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String time) { + this.timestamp = time; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java index 3c9e4704..1238236f 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,6 @@ package org.onap.clamp.clds.service; -import com.att.ajsc.common.AjscService; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; @@ -33,6 +32,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import java.io.IOException; import java.io.InputStream; import java.security.GeneralSecurityException; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -68,6 +68,7 @@ import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.exception.CldsConfigException; import org.onap.clamp.clds.exception.SdcCommunicationException; import org.onap.clamp.clds.exception.policy.PolicyClientException; +import org.onap.clamp.clds.model.CLDSMonitoringDetails; import org.onap.clamp.clds.model.CldsDBServiceCache; import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.CldsHealthCheck; @@ -90,38 +91,36 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - /** * Service to save and retrieve the CLDS model attributes. */ -@AjscService -@Api(value = "/clds") +@Component @Path("/clds") public class CldsService extends SecureServiceBase { + protected static final EELFLogger securityLogger = EELFManager.getInstance().getSecurityLogger(); @Autowired - private ApplicationContext appContext; - private static final String RESOURCE_NAME = "clds-version.properties"; + private ApplicationContext appContext; + private static final String RESOURCE_NAME = "clds-version.properties"; @Value("${CLDS_PERMISSION_TYPE_CL:permission-type-cl}") - private String cldsPersmissionTypeCl; + private String cldsPersmissionTypeCl; @Value("${CLDS_PERMISSION_TYPE_CL_MANAGE:permission-type-cl-manage}") - private String cldsPermissionTypeClManage; + private String cldsPermissionTypeClManage; @Value("${CLDS_PERMISSION_TYPE_CL_EVENT:permission-type-cl-event}") - private String cldsPermissionTypeClEvent; + private String cldsPermissionTypeClEvent; @Value("${CLDS_PERMISSION_TYPE_FILTER_VF:permission-type-filter-vf}") - private String cldsPermissionTypeFilterVf; + private String cldsPermissionTypeFilterVf; @Value("${CLDS_PERMISSION_TYPE_TEMPLATE:permission-type-template}") - private String cldsPermissionTypeTemplate; + private String cldsPermissionTypeTemplate; @Value("${CLDS_PERMISSION_INSTANCE:dev}") - private String cldsPermissionInstance; - private SecureServicePermission permissionReadCl; - private SecureServicePermission permissionUpdateCl; - private SecureServicePermission permissionReadTemplate; - private SecureServicePermission permissionUpdateTemplate; + private String cldsPermissionInstance; + private SecureServicePermission permissionReadCl; + private SecureServicePermission permissionUpdateCl; + private SecureServicePermission permissionReadTemplate; + private SecureServicePermission permissionUpdateTemplate; @PostConstruct private final void afterConstruction() { @@ -134,28 +133,51 @@ public class CldsService extends SecureServiceBase { } @Value("${org.onap.clamp.config.files.globalClds:'classpath:/clds/globalClds.properties'}") - private String globalClds; - private Properties globalCldsProperties; + private String globalClds; + private Properties globalCldsProperties; @Autowired - private CldsDao cldsDao; + private CldsDao cldsDao; @Autowired - private RuntimeService runtimeService; + private RuntimeService runtimeService; @Autowired - private XslTransformer cldsBpmnTransformer; + private XslTransformer cldsBpmnTransformer; @Autowired - private RefProp refProp; + private RefProp refProp; @Autowired - private SdcCatalogServices sdcCatalogServices; + private SdcCatalogServices sdcCatalogServices; @Autowired private DcaeDispatcherServices dcaeDispatcherServices; @Autowired - private DcaeInventoryServices dcaeInventoryServices; + private DcaeInventoryServices dcaeInventoryServices; + + /* + * @return list of CLDS-Monitoring-Details: CLOSELOOP_NAME | Close loop name + * used in the CLDS application (prefix: ClosedLoop- + unique ClosedLoop ID) + * MODEL_NAME | Model Name in CLDS application SERVICE_TYPE_ID | TypeId + * returned from the DCAE application when the ClosedLoop is submitted + * (DCAEServiceTypeRequest generated in DCAE application). DEPLOYMENT_ID | + * Id generated when the ClosedLoop is deployed in DCAE. TEMPLATE_NAME | + * Template used to generate the ClosedLoop model. ACTION_CD | Current state + * of the ClosedLoop in CLDS application. + */ + @GET + @Path("/cldsDetails") + @Produces(MediaType.APPLICATION_JSON) + public List<CLDSMonitoringDetails> getCLDSDetails() { + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: GET model details", getPrincipalName()); + List<CLDSMonitoringDetails> cldsMonitoringDetailsList = new ArrayList<CLDSMonitoringDetails>(); + cldsMonitoringDetailsList = cldsDao.getCLDSMonitoringDetails(); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get cldsDetails success", this.getClass().getName()); + auditLogger.info("GET cldsDetails completed"); + return cldsMonitoringDetailsList; + } /* - * * CLDS IFO service will return 3 things 1. User Name 2. CLDS code version * that is currently installed from pom.xml file 3. User permissions - * */ @GET @Path("/cldsInfo") @@ -229,7 +251,6 @@ public class CldsService extends SecureServiceBase { * @param modelName * @return bpmn xml text - content of bpmn given name */ - @ApiOperation(value = "Retrieves BPMN for a CLDS model name from the database", notes = "This is only expected to be used for testing purposes, not by the UI", response = String.class) @GET @Path("/model/bpmn/{modelName}") @Produces(MediaType.TEXT_XML) @@ -254,7 +275,6 @@ public class CldsService extends SecureServiceBase { * @param modelName * @return image xml text - content of image given name */ - @ApiOperation(value = "Retrieves image for a CLDS model name from the database", notes = "This is only expected to be used for testing purposes, not by the UI", response = String.class) @GET @Path("/model/image/{modelName}") @Produces(MediaType.TEXT_XML) @@ -277,7 +297,6 @@ public class CldsService extends SecureServiceBase { * @param modelName * @return clds model - clds model for the given model name */ - @ApiOperation(value = "Retrieves a CLDS model by name from the database", notes = "", response = String.class) @GET @Path("/model/{modelName}") @Produces(MediaType.APPLICATION_JSON) @@ -288,15 +307,10 @@ public class CldsService extends SecureServiceBase { logger.debug("GET model for modelName={}", modelName); CldsModel cldsModel = CldsModel.retrieve(cldsDao, modelName, false); isAuthorizedForVf(cldsModel); - /** - * Checking condition whether our CLDS model can call INventory Method - */ + // Checking condition whether our CLDS model can call Inventory Method if (cldsModel.canInventoryCall()) { try { - /* - * Below is the method to for inventory call and DB insert for - * event methods - */ + // Method to call dcae inventory and invoke insert event method dcaeInventoryServices.setEventInventory(cldsModel, getUserId()); } catch (Exception e) { LoggingUtils.setErrorContext("900", "Set event inventory error"); @@ -315,7 +329,6 @@ public class CldsService extends SecureServiceBase { * * @param modelName */ - @ApiOperation(value = "Saves a CLDS model by name in the database", notes = "", response = String.class) @PUT @Path("/model/{modelName}") @Consumes(MediaType.APPLICATION_JSON) @@ -350,7 +363,6 @@ public class CldsService extends SecureServiceBase { * * @return model names in JSON */ - @ApiOperation(value = "Retrieves a list of CLDS model names", notes = "", response = String.class) @GET @Path("/model-names") @Produces(MediaType.APPLICATION_JSON) @@ -384,7 +396,6 @@ public class CldsService extends SecureServiceBase { * @throws DecoderException * In case of issues with the Hex String decoding */ - @ApiOperation(value = "Saves and processes an action for a CLDS model by name", notes = "", response = String.class) @PUT @Path("/action/{action}/{modelName}") @Consumes(MediaType.APPLICATION_JSON) @@ -476,8 +487,9 @@ public class CldsService extends SecureServiceBase { } // refresh model info from db (get fresh event info) CldsModel retreivedModel = CldsModel.retrieve(cldsDao, modelName, false); - if (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT) - || actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT)) { + if (!isTest && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT) + || actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT) + || actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE))) { // To verify inventory status and modify model status to distribute dcaeInventoryServices.setEventInventory(retreivedModel, getUserId()); retreivedModel.save(cldsDao, getUserId()); @@ -495,7 +507,6 @@ public class CldsService extends SecureServiceBase { * @param test * @param dcaeEvent */ - @ApiOperation(value = "Accepts events for a model", notes = "", response = String.class) @POST @Path("/dcae/event") @Consumes(MediaType.APPLICATION_JSON) @@ -550,9 +561,7 @@ public class CldsService extends SecureServiceBase { * In case of issue when decryting the SDC password * @throws DecoderException * In case of issues with the decoding of the Hex String - * */ - @ApiOperation(value = "Retrieves sdc services", notes = "", response = String.class) @GET @Path("/sdc/services") @Produces(MediaType.APPLICATION_JSON) @@ -580,9 +589,7 @@ public class CldsService extends SecureServiceBase { * * @throws IOException * In case of issues - * */ - @ApiOperation(value = "Retrieves total properties required by UI", notes = "", response = String.class) @GET @Path("/properties") @Produces(MediaType.APPLICATION_JSON) @@ -598,9 +605,7 @@ public class CldsService extends SecureServiceBase { * In case of issues with the decryting the encrypted password * @throws DecoderException * In case of issues with the decoding of the Hex String - * */ - @ApiOperation(value = "Retrieves total properties by using invariantUUID based on refresh and non refresh", notes = "", response = String.class) @GET @Path("/properties/{serviceInvariantUUID}") @Produces(MediaType.APPLICATION_JSON) @@ -950,10 +955,9 @@ public class CldsService extends SecureServiceBase { && resourceVf.get(0).equalsIgnoreCase(currentVf.get(0))) { throw new BadRequestException("Same Service/VF already exists in " + cldsModelProp.getName() + " model, please select different Service/VF."); - } } } } } -} +}
\ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java b/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java index 070c0667..e64f74bb 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +23,6 @@ package org.onap.clamp.clds.service; -import com.att.ajsc.common.AjscService; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -47,17 +46,19 @@ import org.onap.clamp.clds.model.ValueItem; import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; /** * Service to save and retrieve the CLDS model attributes. */ -@AjscService +@Component @Path("/cldsTempate") public class CldsTemplateService extends SecureServiceBase { + @Value("${CLDS_PERMISSION_TYPE_TEMPLATE:permission-type-template}") - private String cldsPermissionTypeTemplate; + private String cldsPermissionTypeTemplate; @Value("${CLDS_PERMISSION_INSTANCE:dev}") - private String cldsPermissionInstance; + private String cldsPermissionInstance; private SecureServicePermission permissionReadTemplate; private SecureServicePermission permissionUpdateTemplate; diff --git a/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java b/src/main/java/org/onap/clamp/clds/service/JerseyConfig.java index 6aeadc54..0ffe4103 100644 --- a/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java +++ b/src/main/java/org/onap/clamp/clds/service/JerseyConfig.java @@ -2,40 +2,40 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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============================================ * =================================================================== * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ -package org.onap.clamp.clds.exception; +package org.onap.clamp.clds.service; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; +import org.glassfish.jersey.server.ResourceConfig; +import org.springframework.stereotype.Component; -import com.att.ajsc.common.AjscProvider; -import com.att.ajsc.common.exception.ServerErrorException; -import com.att.ajsc.common.exception.ServiceException; +@Component +public class JerseyConfig extends ResourceConfig { -@AjscProvider -public class AjscExceptionMapper implements ExceptionMapper<Exception> { + public JerseyConfig() { + registerEndpoints(); + } - @Override - public Response toResponse(final Exception exception) { - return exception instanceof ServiceException ? ((ServiceException) exception).toResponse() - : new ServerErrorException(exception.getMessage()).toResponse(); + private void registerEndpoints() { + register(CldsService.class); + register(UserService.class); + register(CldsTemplateService.class); } -} +}
\ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 321d88e1..1db0875a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,7 +2,7 @@ # ============LICENSE_START=======================================================
# ONAP CLAMP
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
# reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -62,7 +62,8 @@ server.port=8080 server.contextPath=/
#Modified engine-rest applicationpath
-spring.jersey.application-path=/engine-rest
+#camel.component.servlet.mapping.context-path=/restservices/clds/v1/*
+spring.jersey.application-path=/restservices/clds/v1
spring.profiles.active=clamp-default,clamp-spring-authentication
#The max number of active threads in this pool
@@ -72,11 +73,6 @@ server.tomcat.min-Spare-Threads=25 #The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads
server.tomcat.max-idle-time=60000
-
-#Add this properties only if you want to change the URL, AJSC Framework interceptors will intercept
-#com.att.ajsc.common.interceptors.PreInterceptor.url=/**
-#com.att.ajsc.common.interceptors.PostInterceptor.url=/**
-
#Servlet context parameters
server.context_parameters.p-name=value #context parameter with p-name as key and value as value.
@@ -89,8 +85,6 @@ camel.defaultthreadpool.maxqueuesize=1000 camel.defaultthreadpool.keepaliveTime=60
camel.defaultthreadpool.rejectpolicy=CallerRuns
-kubernetes.namespace=com-att-ajsc
-
#server.port=0
#Camunda Process Engine DataSource connection Details
spring.datasource.camunda.driverClassName=org.mariadb.jdbc.Driver
@@ -111,7 +105,7 @@ spring.datasource.camunda.ignoreExceptionOnPreLoad=true #Camunda history level
camunda.bpm.history-level=auto
camunda.bpm.database.type=mariadb
-camunda.bpm.database.schema-update=false
+camunda.bpm.database.schema-update=true
#clds datasource connection details
spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver
@@ -133,13 +127,6 @@ async.core.pool.size=10 async.max.pool.size=20
async.queue.capacity=500
-#GRM Edge endpoint details
-service.name=ajsc6camundademo
-service.version=1.0.0.0
-routeoffer=TEST
-#Update with your application name
-application.name=AJSC6CAMUNDA
-
org.onap.clamp.config.files.cldsReference=classpath:/clds/clds-reference.properties
org.onap.clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties
org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json
diff --git a/src/main/resources/bootstrap.properties b/src/main/resources/bootstrap.properties deleted file mode 100644 index b0cfde57..00000000 --- a/src/main/resources/bootstrap.properties +++ /dev/null @@ -1,34 +0,0 @@ -### -# ============LICENSE_START======================================================= -# ONAP CLAMP -# ================================================================================ -# 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============================================ -# =================================================================== -# ECOMP is a trademark and service mark of AT&T Intellectual Property. -### - -spring.cloud.config.discovery.enabled=false -spring.cloud.config.enabled=false - -# Allow Spring Cloud properties configuration to override properties set from System Properties and ENV Properties -spring.cloud.config.overrideSystemProperties=true - -# Path to the file containing the dynamic logger levels -com.att.ajsc.dynamic.logging.path=./logging.properties - -# File watcher polling frequency in milliseconds -com.att.ajsc.dynamic.watcher.delay=5000 diff --git a/src/main/resources/clds/clds-reference.properties b/src/main/resources/clds/clds-reference.properties index 998bf7c7..95ba919c 100644 --- a/src/main/resources/clds/clds-reference.properties +++ b/src/main/resources/clds/clds-reference.properties @@ -2,7 +2,7 @@ # ============LICENSE_START=======================================================
# ONAP CLAMP
# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights
+# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
# reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -88,7 +88,7 @@ sdc.artifactType=DCAE_INVENTORY_BLUEPRINT sdc.locationArtifactLabel=locationclampcockpit
sdc.locationArtifactType=DCAE_INVENTORY_JSON
sdc.InstanceID=X-ECOMP-InstanceID
-sdc.header.requestId=X-ECOMP-RequestID
+sdc.header.requestId = X-ECOMP-RequestID
#
#
ui.location.default={"DC1":"Data Center 1","DC2":"Data Center 2","DC3":"Data Center 3"}
@@ -106,4 +106,3 @@ DCAE_INVENTORY_URL = http://dcae.api.simpledemo.onap.org:8080 #DCAE Dispatcher Url Properties
DCAE_DISPATCHER_URL = http://dcae.api.simpledemo.onap.org:8080
dcae.header.requestId = X-ECOMP-RequestID -
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index e02a320d..b898998c 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,5 +1,4 @@ <configuration scan="true" scanPeriod="10 seconds" debug="false"> - <contextName>${module.ajsc.namespace.name}</contextName> <jmxConfigurator /> <property name="logDirectory" value="log" /> <!-- Example evaluator filter applied against console appender --> @@ -149,29 +148,6 @@ <logger name="org.springframework.web" level="WARN" /> <logger name="com.blog.spring.jms" level="WARN" /> - <!-- AJSC Services (bootstrap services) --> - <logger name="ajsc" level="WARN" /> - <logger name="ajsc.RouteMgmtService" level="INFO" /> - <logger name="ajsc.ComputeService" level="INFO" /> - <logger name="ajsc.VandelayService" level="WARN" /> - <logger name="ajsc.FilePersistenceService" level="WARN" /> - <logger name="ajsc.UserDefinedJarService" level="WARN" /> - <logger name="ajsc.UserDefinedBeansDefService" level="WARN" /> - <logger name="ajsc.LoggingConfigurationService" level="WARN" /> - - <!-- AJSC related loggers (DME2 Registration, csi logging, restlet, servlet - logging) --> - <logger name="ajsc.utils" level="WARN" /> - <logger name="ajsc.utils.DME2Helper" level="INFO" /> - <logger name="ajsc.filters" level="DEBUG" /> - <logger name="ajsc.beans.interceptors" level="DEBUG" /> - <logger name="ajsc.restlet" level="DEBUG" /> - <logger name="ajsc.servlet" level="DEBUG" /> - <logger name="com.att" level="WARN" /> - <logger name="com.att.ajsc.csi.logging" level="DEBUG" /> - <logger name="com.att.ajsc.filemonitor" level="WARN" /> - <logger name="com.att.ajsc.introscope" level="info" /> - <!-- Other Loggers that may help troubleshoot --> <logger name="net.sf" level="WARN" /> <logger name="org.apache.commons.httpclient" level="WARN" /> diff --git a/src/main/resources/system.properties b/src/main/resources/system.properties index 9d6386f4..08b9b19c 100644 --- a/src/main/resources/system.properties +++ b/src/main/resources/system.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP CLAMP # ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights +# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights # reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,8 +29,6 @@ com.att.eelf.logging.file=classpath:/logback.xml com.att.eelf.logging.path=./ logging.config=classpath:/logback.xml -com.att.ajsc.app.prop.path=./ - # # JVM SSL/TLS properties jdk.tls.client.protocols=TLSv1.1,TLSv1.2 diff --git a/src/test/java/org/onap/clamp/clds/AbstractItCase.java b/src/test/java/org/onap/clamp/clds/AbstractItCase.java index d3f64240..2903248b 100644 --- a/src/test/java/org/onap/clamp/clds/AbstractItCase.java +++ b/src/test/java/org/onap/clamp/clds/AbstractItCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,13 +33,12 @@ import org.springframework.test.context.ActiveProfiles; public abstract class AbstractItCase { @Autowired - protected RefProp refProp; + protected RefProp refProp; @Autowired protected PolicyClient policyClient; @BeforeClass public static void oneTimeSetUp() { - System.setProperty("AJSC_CONF_HOME", System.getProperty("user.dir") + "/src/it/resources/"); System.setProperty("CLDS_DCAE_URL", "http://localhost:13786/cl-dcae-services"); } } diff --git a/src/test/resources/application-no-camunda.properties b/src/test/resources/application-no-camunda.properties index ece42484..f7b2bade 100644 --- a/src/test/resources/application-no-camunda.properties +++ b/src/test/resources/application-no-camunda.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP CLAMP # ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights +# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights # reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,6 @@ server.port=10443 server.ssl.key-store=classpath:https/keystore-test.jks server.ssl.key-store-password=testpass server.ssl.key-password=testpass -spring.autoconfigure.exclude=com.att.ajsc.camunda.config.CamundaBpmWebappInitializer,com.att.ajsc.camunda.config.CamundaBpmWebappAutoConfiguration ### In order to be user friendly when HTTPS is enabled, ### you can add another HTTP port that will be automatically redirected to HTTPS ### by enabling this parameter (server.http.port) and set it to another port (80 or 8080, 8090, etc ...) @@ -62,7 +61,7 @@ spring.autoconfigure.exclude=com.att.ajsc.camunda.config.CamundaBpmWebappInitial server.contextPath=/ #Modified engine-rest applicationpath -spring.jersey.application-path=/engine-rest +spring.jersey.application-path=/restservices/clds/v1 spring.profiles.active=clamp-default,clamp-spring-authentication #The max number of active threads in this pool @@ -72,11 +71,6 @@ server.tomcat.min-Spare-Threads=25 #The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads server.tomcat.max-idle-time=60000 - -#Add this properties only if you want to change the URL, AJSC Framework interceptors will intercept -#com.att.ajsc.common.interceptors.PreInterceptor.url=/** -#com.att.ajsc.common.interceptors.PostInterceptor.url=/** - #Servlet context parameters server.context_parameters.p-name=value #context parameter with p-name as key and value as value. @@ -89,8 +83,6 @@ camel.defaultthreadpool.maxqueuesize=1000 camel.defaultthreadpool.keepaliveTime=60 camel.defaultthreadpool.rejectpolicy=CallerRuns -kubernetes.namespace=com-att-ajsc - #server.port=0 #Camunda Process Engine DataSource connection Details @@ -110,13 +102,16 @@ spring.datasource.camunda.ignoreExceptionOnPreLoad=true #Camunda application properties #Camunda history level -camunda.bpm.history-level=auto +camunda.bpm.history-level=none camunda.bpm.enabled=false +camunda.bpm.jpa.enabled=false camunda.bpm.auto-deployment-enabled=false camunda.bpm.job-execution.active=false camunda.bpm.job-execution.enabled=false camunda.bpm.management.health.camunda.enabled=false camunda.bpm.metrics.enabled=false +camunda.bpm.management.health.camunda.enabled=false +camunda.bpm.database.schema-update=true #clds datasource connection details spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver @@ -138,13 +133,6 @@ async.core.pool.size=10 async.max.pool.size=20 async.queue.capacity=500 -#GRM Edge endpoint details -service.name=ajsc6camundademo -service.version=1.0.0.0 -routeoffer=TEST -#Update with your application name -application.name=AJSC6CAMUNDA - org.onap.clamp.config.files.cldsReference=classpath:/clds/clds-reference.properties org.onap.clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties index bd84242e..54005ef2 100644 --- a/src/test/resources/https/https-test.properties +++ b/src/test/resources/https/https-test.properties @@ -2,7 +2,7 @@ # ============LICENSE_START======================================================= # ONAP CLAMP # ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights +# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights # reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -62,7 +62,7 @@ server.http-to-https-redirection.port=10080 server.contextPath=/ #Modified engine-rest applicationpath -spring.jersey.application-path=/engine-rest +spring.jersey.application-path=/restservices/clds/v1 spring.profiles.active=clamp-default,clamp-spring-authentication #The max number of active threads in this pool @@ -72,11 +72,6 @@ server.tomcat.min-Spare-Threads=25 #The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads server.tomcat.max-idle-time=60000 - -#Add this properties only if you want to change the URL, AJSC Framework interceptors will intercept -#com.att.ajsc.common.interceptors.PreInterceptor.url=/** -#com.att.ajsc.common.interceptors.PostInterceptor.url=/** - #Servlet context parameters server.context_parameters.p-name=value #context parameter with p-name as key and value as value. @@ -89,8 +84,6 @@ camel.defaultthreadpool.maxqueuesize=1000 camel.defaultthreadpool.keepaliveTime=60 camel.defaultthreadpool.rejectpolicy=CallerRuns -kubernetes.namespace=com-att-ajsc - #server.port=0 #Camunda Process Engine DataSource connection Details spring.datasource.camunda.driverClassName=org.mariadb.jdbc.Driver @@ -110,13 +103,16 @@ spring.datasource.camunda.ignoreExceptionOnPreLoad=true #Camunda application properties #Camunda history level -camunda.bpm.history-level=auto +camunda.bpm.history-level=none camunda.bpm.enabled=false +camunda.bpm.jpa.enabled=false camunda.bpm.auto-deployment-enabled=false camunda.bpm.job-execution.active=false camunda.bpm.job-execution.enabled=false camunda.bpm.management.health.camunda.enabled=false camunda.bpm.metrics.enabled=false +camunda.bpm.management.health.camunda.enabled=false +camunda.bpm.database.schema-update=true #clds datasource connection details spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver @@ -138,13 +134,6 @@ async.core.pool.size=10 async.max.pool.size=20 async.queue.capacity=500 -#GRM Edge endpoint details -service.name=ajsc6camundademo -service.version=1.0.0.0 -routeoffer=TEST -#Update with your application name -application.name=AJSC6CAMUNDA - org.onap.clamp.config.files.cldsReference=classpath:/clds/clds-reference.properties org.onap.clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json diff --git a/src/test/resources/processes.xml b/src/test/resources/processes.xml deleted file mode 100644 index fddc60d1..00000000 --- a/src/test/resources/processes.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - ONAP CLAMP - ================================================================================ - 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============================================ - =================================================================== - ECOMP is a trademark and service mark of AT&T Intellectual Property. - --> - -<process-application - xmlns="http://www.camunda.org/schema/1.0/ProcessApplication" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - <process-archive name="example-process-archive"> - <process-engine>default</process-engine> - <resource>bpmn/log-message.bpmn</resource> - <properties> - <property name="isDeleteUponUndeploy">true</property> - <property name="isScanForProcessDefinitions">false</property> - </properties> - </process-archive> - -</process-application> |