diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2018-02-07 10:11:30 +0100 |
---|---|---|
committer | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2018-02-07 10:17:02 +0100 |
commit | 7e44fa716640f855fa066c7b0d8f7dca767837b0 (patch) | |
tree | 58503e80bbd5d4fc5997c2a00f18c347e50564e5 /src/main/java/org/onap | |
parent | c1e886ebabb05d113e5815885c4d0d96981a0ccc (diff) |
Remove AJSC container.
Remove AJSC container and adapt the dependencies & unit tests
Issue-ID: CLAMP-85
Change-Id: I4289dd8a13645df238f35d2791718639b04a509f
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java/org/onap')
-rw-r--r-- | src/main/java/org/onap/clamp/clds/Application.java | 56 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java | 8 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java | 81 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java | 27 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java | 49 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/config/SystemPropertiesLoader.java (renamed from src/main/java/org/onap/clamp/clds/Routes.java) | 25 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/dao/CldsDao.java | 41 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/model/CLDSMonitoringDetails.java | 104 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/service/CldsService.java | 110 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java | 11 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/service/JerseyConfig.java (renamed from src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java) | 44 |
11 files changed, 267 insertions, 289 deletions
diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index e2bfbd77f..2727535e4 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 385a4e41a..f13f42220 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 af9e695e6..000000000 --- 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 9367bc24c..b99d3a96c 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 5b48e8d88..000000000 --- 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 d9520e789..83325f3d9 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 7bef430d9..088d47332 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 000000000..be4f95096 --- /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 3c9e47046..1238236fb 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 070c06678..e64f74bb2 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 6aeadc546..0ffe41037 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 |