From 5e9feb2a8e360b82dc2b6e4145e0fd847d2924ce Mon Sep 17 00:00:00 2001 From: ChrisC Date: Wed, 21 Jun 2017 02:38:57 -0700 Subject: [CLAMP-1] Initial ONAP CLAMP seed code commit Change-Id: I2e8070a590618a06070f393d7b2c011029af5e8a Signed-off-by: ChrisC --- src/main/java/org/onap/clamp/clds/Application.java | 83 ++ src/main/java/org/onap/clamp/clds/Routes.java | 42 + src/main/java/org/onap/clamp/clds/WebConfig.java | 45 ++ .../onap/clamp/clds/client/CldsEventDelegate.java | 62 ++ .../onap/clamp/clds/client/DcaeReqDelegate.java | 59 ++ .../clamp/clds/client/DcaeReqDeleteDelegate.java | 54 ++ .../clds/client/OperationalPolicyDelegate.java | 69 ++ .../client/OperationalPolicyDeleteDelegate.java | 61 ++ .../org/onap/clamp/clds/client/PolicyClient.java | 342 ++++++++ .../onap/clamp/clds/client/SdcCatalogServices.java | 864 +++++++++++++++++++++ .../onap/clamp/clds/client/SdcSendReqDelegate.java | 138 ++++ .../clds/client/StringMatchPolicyDelegate.java | 67 ++ .../client/StringMatchPolicyDeleteDelegate.java | 58 ++ .../onap/clamp/clds/client/TcaPolicyDelegate.java | 53 ++ .../clamp/clds/client/TcaPolicyDeleteDelegate.java | 48 ++ .../org/onap/clamp/clds/client/req/DcaeReq.java | 97 +++ .../org/onap/clamp/clds/client/req/JsonUtil.java | 66 ++ .../clds/client/req/OperationalPolicyReq.java | 299 +++++++ .../org/onap/clamp/clds/client/req/SdcReq.java | 360 +++++++++ .../clds/client/req/StringMatchPolicyReq.java | 138 ++++ .../onap/clamp/clds/client/req/TcaMPolicyReq.java | 93 +++ .../org/onap/clamp/clds/common/LogMessages.java | 37 + .../clds/config/CamundaAuthFilterInitializer.java | 87 +++ .../clds/config/CamundaEngineConfiguration.java | 49 ++ .../onap/clamp/clds/config/CldsConfiguration.java | 142 ++++ .../onap/clamp/clds/config/CldsSecurityConfig.java | 117 +++ .../clamp/clds/config/CsiLoggingConfiguration.java | 48 ++ src/main/java/org/onap/clamp/clds/dao/CldsDao.java | 485 ++++++++++++ .../clamp/clds/exception/AjscExceptionMapper.java | 40 + .../org/onap/clamp/clds/jsf/JsfExampleBean.java | 61 ++ .../onap/clamp/clds/model/CldsAlarmCondition.java | 59 ++ .../onap/clamp/clds/model/CldsAsdcArtifact.java | 112 +++ .../onap/clamp/clds/model/CldsAsdcResource.java | 131 ++++ .../clds/model/CldsAsdcResourceBasicInfo.java | 160 ++++ .../clamp/clds/model/CldsAsdcServiceDetail.java | 142 ++++ .../onap/clamp/clds/model/CldsAsdcServiceInfo.java | 148 ++++ .../onap/clamp/clds/model/CldsDBServiceCache.java | 66 ++ .../java/org/onap/clamp/clds/model/CldsEvent.java | 183 +++++ .../java/org/onap/clamp/clds/model/CldsModel.java | 570 ++++++++++++++ .../onap/clamp/clds/model/CldsModelInstance.java | 59 ++ .../org/onap/clamp/clds/model/CldsServiceData.java | 112 +++ .../org/onap/clamp/clds/model/CldsTemplate.java | 186 +++++ .../java/org/onap/clamp/clds/model/CldsVfData.java | 61 ++ .../org/onap/clamp/clds/model/CldsVfcData.java | 61 ++ .../java/org/onap/clamp/clds/model/DcaeEvent.java | 149 ++++ .../java/org/onap/clamp/clds/model/HelloWorld.java | 50 ++ .../java/org/onap/clamp/clds/model/ValueItem.java | 58 ++ .../org/onap/clamp/clds/model/prop/Collector.java | 47 ++ .../org/onap/clamp/clds/model/prop/Global.java | 113 +++ .../org/onap/clamp/clds/model/prop/ModelBpmn.java | 153 ++++ .../onap/clamp/clds/model/prop/ModelBpmnEntry.java | 95 +++ .../onap/clamp/clds/model/prop/ModelElement.java | 232 ++++++ .../clamp/clds/model/prop/ModelProperties.java | 320 ++++++++ .../org/onap/clamp/clds/model/prop/Policy.java | 78 ++ .../org/onap/clamp/clds/model/prop/PolicyItem.java | 103 +++ .../clds/model/prop/ServiceConfiguration.java | 156 ++++ .../onap/clamp/clds/model/prop/StringMatch.java | 70 ++ .../java/org/onap/clamp/clds/model/prop/Tca.java | 47 ++ .../org/onap/clamp/clds/model/prop/TcaItem.java | 128 +++ .../onap/clamp/clds/model/prop/TcaThreshhold.java | 76 ++ .../org/onap/clamp/clds/model/refprop/RefProp.java | 139 ++++ .../org/onap/clamp/clds/service/CldsService.java | 646 +++++++++++++++ .../clamp/clds/service/CldsTemplateService.java | 275 +++++++ .../org/onap/clamp/clds/service/LogService.java | 38 + .../onap/clamp/clds/service/LogServiceImpl.java | 276 +++++++ .../onap/clamp/clds/service/SecureServiceBase.java | 105 +++ .../clds/service/SecureServicePermission.java | 190 +++++ .../clamp/clds/service/rs/JaxrsLogService.java | 101 +++ .../clamp/clds/service/rs/JaxrsLogServiceImpl.java | 94 +++ .../onap/clamp/clds/transform/TransformUtil.java | 66 ++ .../onap/clamp/clds/transform/XslTransformer.java | 59 ++ .../clamp/clds/workflow/LogMessageDelegate.java | 46 ++ .../clds/workflow/ProcessRequestDelegate.java | 57 ++ .../clamp/clds/workflow/RestMessageDelegate.java | 59 ++ 74 files changed, 10240 insertions(+) create mode 100644 src/main/java/org/onap/clamp/clds/Application.java create mode 100644 src/main/java/org/onap/clamp/clds/Routes.java create mode 100644 src/main/java/org/onap/clamp/clds/WebConfig.java create mode 100644 src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/PolicyClient.java create mode 100644 src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java create mode 100644 src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDeleteDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java create mode 100644 src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java create mode 100644 src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java create mode 100644 src/main/java/org/onap/clamp/clds/client/req/SdcReq.java create mode 100644 src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java create mode 100644 src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java create mode 100644 src/main/java/org/onap/clamp/clds/common/LogMessages.java create mode 100644 src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java create mode 100644 src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java create mode 100644 src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java create mode 100644 src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java create mode 100644 src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java create mode 100644 src/main/java/org/onap/clamp/clds/dao/CldsDao.java create mode 100644 src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java create mode 100644 src/main/java/org/onap/clamp/clds/jsf/JsfExampleBean.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcArtifact.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcResource.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcResourceBasicInfo.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceDetail.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceInfo.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsEvent.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsModel.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsServiceData.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsTemplate.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsVfData.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsVfcData.java create mode 100644 src/main/java/org/onap/clamp/clds/model/DcaeEvent.java create mode 100644 src/main/java/org/onap/clamp/clds/model/HelloWorld.java create mode 100644 src/main/java/org/onap/clamp/clds/model/ValueItem.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Collector.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Global.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Policy.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Tca.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java create mode 100644 src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java create mode 100644 src/main/java/org/onap/clamp/clds/service/CldsService.java create mode 100644 src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java create mode 100644 src/main/java/org/onap/clamp/clds/service/LogService.java create mode 100644 src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java create mode 100644 src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java create mode 100644 src/main/java/org/onap/clamp/clds/service/SecureServicePermission.java create mode 100644 src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogService.java create mode 100644 src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogServiceImpl.java create mode 100644 src/main/java/org/onap/clamp/clds/transform/TransformUtil.java create mode 100644 src/main/java/org/onap/clamp/clds/transform/XslTransformer.java create mode 100644 src/main/java/org/onap/clamp/clds/workflow/LogMessageDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/workflow/ProcessRequestDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/workflow/RestMessageDelegate.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java new file mode 100644 index 000000000..8459027f3 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -0,0 +1,83 @@ +/*- + * ============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; + +import com.att.ajsc.common.utility.SystemPropertiesLoader; +import org.apache.camel.component.servlet.CamelHttpTransportServlet; +import org.camunda.bpm.spring.boot.starter.webapp.CamundaBpmWebappAutoConfiguration; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration; +import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; +import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.scheduling.annotation.EnableAsync; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import java.util.ArrayList; +import java.util.Collection; + +@SpringBootApplication +@ComponentScan(basePackages = {"org.onap.clamp.clds","com.att.ajsc"}) +@EnableAutoConfiguration(exclude = {CamundaBpmWebappAutoConfiguration.class, HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class}) +@EnableAsync +public class Application extends SpringBootServletInitializer { + + private static final String CAMEL_SERVLET_NAME = "CamelServlet"; + private static final String CAMEL_URL_MAPPING = "/restservices/clds/v1/*"; + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(Application.class); + } + + public static void main(String[] args) throws Exception { + SystemPropertiesLoader.addSystemProperties(); + SpringApplication.run(Application.class, args); + } + + @Bean + public ServletRegistrationBean servletRegistrationBean() { + ServletRegistrationBean registration = new ServletRegistrationBean(); + registration.setName(CAMEL_SERVLET_NAME); + registration.setServlet(new CamelHttpTransportServlet()); + Collection urlMappings = new ArrayList<>(); + urlMappings.add(CAMEL_URL_MAPPING); + registration.setUrlMappings(urlMappings); + return registration; + } + + @Bean + public Client restClient() { + return ClientBuilder.newClient(); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/Routes.java b/src/main/java/org/onap/clamp/clds/Routes.java new file mode 100644 index 000000000..6fcb93078 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/Routes.java @@ -0,0 +1,42 @@ +/*- + * ============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; + +import com.att.ajsc.common.camel.AjscRouteBuilder; +import org.apache.camel.builder.RouteBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class Routes extends RouteBuilder { + @Autowired + private AjscRouteBuilder ajscRoute; + + @Override + public void configure() throws Exception { + ajscRoute.initialize(this); + ajscRoute.setRoute(from("servlet:/?matchOnUriPrefix=true").to("cxfbean:jaxrsServices?providers=jaxrsProviders")); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/WebConfig.java b/src/main/java/org/onap/clamp/clds/WebConfig.java new file mode 100644 index 000000000..38bd62e97 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/WebConfig.java @@ -0,0 +1,45 @@ +/*- + * ============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; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +public class WebConfig { + + @Bean + public WebMvcConfigurerAdapter forwardToIndex() { + return new WebMvcConfigurerAdapter() { + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/swagger").setViewName("redirect:/icd/index.html"); + registry.addViewController("/icd/").setViewName("redirect:/icd/index.html"); + registry.addViewController("/login").setViewName("login.html"); + } + }; + } +} diff --git a/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java b/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java new file mode 100644 index 000000000..0f4d30d00 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java @@ -0,0 +1,62 @@ +/*- + * ============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.client; + +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.model.CldsEvent; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.logging.Logger; + +/** + * Create CLDS Event. + */ +public class CldsEventDelegate implements JavaDelegate { + private static final Logger logger = Logger.getLogger(CldsEventDelegate.class.getName()); + @Autowired + private CldsDao cldsDao; + + /** + * Insert event using process variables. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + String controlName = (String) execution.getVariable("controlName"); + String actionCd = (String) execution.getVariable("actionCd"); + String actionStateCd = (String) execution.getVariable("actionStateCd"); + boolean isTest = (boolean) execution.getVariable("isTest"); + boolean isInsertTestEvent = (boolean) execution.getVariable("isInsertTestEvent"); + String userid = (String) execution.getVariable("userid"); + + // do not insert events for test actions unless flag set to insert them + if (!isTest || isInsertTestEvent) { + // won't really have userid here... + CldsEvent.insEvent(cldsDao, controlName, userid, actionCd, actionStateCd, execution.getProcessInstanceId()); + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java b/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java new file mode 100644 index 000000000..5583cf936 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java @@ -0,0 +1,59 @@ +/*- + * ============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.client; + +import org.onap.clamp.clds.client.req.DcaeReq; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.logging.Logger; + + +/** + * Send control loop model to dcae proxy. + */ +public class DcaeReqDelegate implements JavaDelegate { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(DcaeReqDelegate.class.getName()); + + @Autowired + private RefProp refProp; + + /** + * Perform activity. Send to dcae proxy. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + ModelProperties prop = ModelProperties.create(execution); + String dcaeReq = DcaeReq.format(refProp, prop); + if (dcaeReq != null) { + execution.setVariable("dcaeReq", dcaeReq.getBytes()); + } + execution.setVariable("dcaeUrl", System.getProperty("CLDS_DCAE_URL") + "/" + prop.getControlName()); + } +} diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java new file mode 100644 index 000000000..28dd6f1d6 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java @@ -0,0 +1,54 @@ +/*- + * ============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.client; + +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.logging.Logger; + + +/** + * Send control loop model to dcae proxy. + */ +public class DcaeReqDeleteDelegate implements JavaDelegate { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(DcaeReqDeleteDelegate.class.getName()); + + @Autowired + private RefProp refProp; + + /** + * Perform activity. Send to dcae proxy. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + ModelProperties prop = ModelProperties.create(execution); + execution.setVariable("dcaeUrl", System.getProperty("CLDS_DCAE_URL") + "/" + prop.getControlName()); + } +} diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java new file mode 100644 index 000000000..fc3ea2ab2 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java @@ -0,0 +1,69 @@ +/*- + * ============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.client; + +import org.onap.clamp.clds.client.req.OperationalPolicyReq; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.openecomp.policy.api.AttributeType; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Map; +import java.util.UUID; +import java.util.logging.Logger; + + +/** + * Send Operational Policy info to policy api. + */ +public class OperationalPolicyDelegate implements JavaDelegate { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(OperationalPolicyDelegate.class.getName()); + + @Autowired + private PolicyClient policyClient; + + @Autowired + private RefProp refProp; + + /** + * Perform activity. Send Operational Policy info to policy api. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + String operationalPolicyRequestUuid = UUID.randomUUID().toString(); + execution.setVariable("operationalPolicyRequestUuid", operationalPolicyRequestUuid); + + ModelProperties prop = ModelProperties.create(execution); + Map> attributes = OperationalPolicyReq.formatAttributes(refProp, prop); + String responseMessage = policyClient.sendBrms(attributes, prop, operationalPolicyRequestUuid); + if (responseMessage != null) { + execution.setVariable("operationalPolicyResponseMessage", responseMessage.getBytes()); + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java new file mode 100644 index 000000000..816b2142a --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java @@ -0,0 +1,61 @@ +/*- + * ============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.client; + +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.Policy; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.logging.Logger; + + +/** + * Delete Operational Policy via policy api. + */ +public class OperationalPolicyDeleteDelegate implements JavaDelegate { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(OperationalPolicyDeleteDelegate.class.getName()); + + @Autowired + private PolicyClient policyClient; + + /** + * Perform activity. Delete Operational Policy via policy api. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + ModelProperties prop = ModelProperties.create(execution); + Policy policy = prop.getPolicy(); + prop.setCurrentModelElementId(policy.getId()); + + String responseMessage = policyClient.deleteBrms(prop); + if (responseMessage != null) { + execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes()); + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java new file mode 100644 index 000000000..95e60ea2e --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java @@ -0,0 +1,342 @@ +/*- + * ============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.client; + +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.openecomp.policy.api.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; + +import java.util.*; +import java.util.logging.Logger; + + +/** + * Policy utility methods - specifically, send the policy. + */ +public class PolicyClient { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(PolicyClient.class.getName()); + + @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:etc/clds/clds-policy-config.properties'}") + private String cldsPolicyConfigFile; + + @Autowired + private ApplicationContext appContext; + + @Autowired + private RefProp refProp; + + public PolicyClient() { + + } + + /** + * Perform send of microservice policy + * + * @param attributes + * @param prop + * @param policyRequestUUID + * @return + * @throws Exception + */ + public String sendBrms(Map> attributes, ModelProperties prop, String policyRequestUUID) throws Exception { + + PolicyParameters policyParameters = new PolicyParameters(); + + // Set Policy Type(Mandatory) + policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); + + // Set Policy Name(Mandatory) + policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); + //Set Scope folder where the policy needs to be created(Mandatory) + //policyParameters.setPolicyScope(policyScope); + + // documentation says this is options, but when tested, got the following failure: java.lang.Exception: Policy send failed: PE300 - Data Issue: No policyDescription given. + policyParameters.setPolicyDescription(refProp.getStringValue("op.policyDescription")); + + policyParameters.setAttributes(attributes); + + //Set a random UUID(Mandatory) + policyParameters.setRequestID(UUID.fromString(policyRequestUUID)); + + String rtnMsg = send(policyParameters, prop); + + String policyType = refProp.getStringValue("policy.op.type"); + push(policyType, prop); + + return rtnMsg; + } + + /** + * Perform send of microservice policy + * + * @param policyJson + * @param prop + * @param policyRequestUUID + * @return + * @throws Exception + */ + public String sendMicroService(String policyJson, ModelProperties prop, String policyRequestUUID) throws Exception { + + PolicyParameters policyParameters = new PolicyParameters(); + + // Set Policy Type + policyParameters.setPolicyConfigType(PolicyConfigType.MicroService); + policyParameters.setEcompName(refProp.getStringValue("policy.ecomp.name")); + policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); + + policyParameters.setConfigBody(policyJson); + policyParameters.setConfigBodyType(PolicyType.JSON); + + policyParameters.setRequestID(UUID.fromString(policyRequestUUID)); + + String rtnMsg = send(policyParameters, prop); + + String policyType = refProp.getStringValue("policy.ms.type"); + push(policyType, prop); + + return rtnMsg; + } + + /** + * Perform send of policy. + * + * @param policyParameters + * @param prop + * @return + * @throws Exception + */ + private String send(PolicyParameters policyParameters, ModelProperties prop) throws Exception { + PolicyEngine policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + + // API method to create or update Policy. + PolicyChangeResponse response = null; + String responseMessage; + try { + if (prop.isCreateRequest()) { + logger.info("Attempting to create policy for action=" + prop.getActionCd()); + response = policyEngine.createPolicy(policyParameters); + responseMessage = response.getResponseMessage(); + } else { + logger.info("Attempting to update policy for action=" + prop.getActionCd()); + response = policyEngine.updatePolicy(policyParameters); + responseMessage = response.getResponseMessage(); + } + } catch (Exception e) { + responseMessage = e.toString(); + } + logger.info("response is " + responseMessage); + + if (response != null && response.getResponseCode() == 200) { + logger.info("Policy send successful"); + } else { + logger.warning("Policy send failed: " + responseMessage); + throw new Exception("Policy send failed: " + responseMessage); + } + + return responseMessage; + } + + /** + * Format and send push of policy. + * + * @param policyType + * @param prop + * @return + * @throws Exception + */ + private String push(String policyType, ModelProperties prop) throws Exception { + PushPolicyParameters pushPolicyParameters = new PushPolicyParameters(); + + //Parameter arguments + pushPolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); + pushPolicyParameters.setPolicyType(policyType); + //pushPolicyParameters.setPolicyScope(policyScope); + pushPolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group")); + pushPolicyParameters.setRequestID(null); + + PolicyEngine policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + + // API method to create or update Policy. + PolicyChangeResponse response = null; + String responseMessage; + try { + logger.info("Attempting to push policy..."); + response = policyEngine.pushPolicy(pushPolicyParameters); + responseMessage = response.getResponseMessage(); + } catch (Exception e) { + responseMessage = e.toString(); + } + logger.info("response is " + responseMessage); + + if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) { + logger.info("Policy push successful"); + } else { + logger.warning("Policy push failed: " + responseMessage); + throw new Exception("Policy push failed: " + responseMessage); + } + + return responseMessage; + } + + /** + * Use Get Config Policy API to retrieve the versions for a policy. + * Return versions in sorted order. + * Return empty list if none found. + * + * @param policyNamePrefix + * @param prop + * @return + * @throws Exception + */ + private List getVersions(String policyNamePrefix, ModelProperties prop) throws Exception { + + ArrayList versions = new ArrayList<>(); + ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); + String policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix); + logger.info("policyName=" + policyName); + configRequestParameters.setPolicyName(policyName); + + PolicyEngine policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + + Collection response = policyEngine.getConfig(configRequestParameters); + + Iterator itrResp = response.iterator(); + + while (itrResp.hasNext()) { + PolicyConfig policyConfig = itrResp.next(); + try { + Integer version = new Integer(policyConfig.getPolicyVersion()); + versions.add(version); + } catch (Exception e) { + // just print warning - if n;o policies, version may be null + logger.warning("warning: failed to parse policyConfig.getPolicyVersion()=" + policyConfig.getPolicyVersion()); + } + } + Collections.sort(versions); + logger.info("versions.size()=" + versions.size()); + + return versions; + } + + /** + * Format and send delete Micro Service requests to Policy + * + * @param prop + * @return + * @throws Exception + */ + public String deleteMicrosService(ModelProperties prop) throws Exception { + String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); + return deletePolicy(policyNamePrefix, prop); + } + + /** + * Format and send delete BRMS requests to Policy + * + * @param prop + * @return + * @throws Exception + */ + public String deleteBrms(ModelProperties prop) throws Exception { + String policyNamePrefix = refProp.getStringValue("policy.op.policyNamePrefix"); + return deletePolicy(policyNamePrefix, prop); + } + + /** + * Format and send delete PAP and PDP requests to Policy + * + * @param policyNamePrefix + * @param prop + * @return + * @throws Exception + */ + private String deletePolicy(String policyNamePrefix, ModelProperties prop) throws Exception { + String responseMessage = null; + + DeletePolicyParameters deletePolicyParameters = new DeletePolicyParameters(); + + List versions = getVersions(policyNamePrefix, prop); + if (versions.size() > 0) { + int maxVersion = Collections.max(versions); + + // format delete all PAP request + deletePolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndFullPolicyNameWithVersion(policyNamePrefix, maxVersion)); + deletePolicyParameters.setPolicyComponent("PAP"); + deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL); + String policyType = refProp.getStringValue("policy.ms.type"); + deletePolicyParameters.setPolicyType(policyType); + + //send delete request + responseMessage = sendDeletePolicy(deletePolicyParameters, prop); + } + + for (Integer version : versions) { + // format delete all PDP request + deletePolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndFullPolicyNameWithVersion(policyNamePrefix, version)); + deletePolicyParameters.setPolicyComponent("PDP"); + deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group")); + //send delete request + responseMessage = responseMessage + "; " + sendDeletePolicy(deletePolicyParameters, prop); + } + + return responseMessage; + } + + /** + * Send delete request to Policy + * + * @param deletePolicyParameters + * @param prop + * @return + * @throws Exception + */ + private String sendDeletePolicy(DeletePolicyParameters deletePolicyParameters, ModelProperties prop) throws Exception { + PolicyEngine policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + + // API method to create or update Policy. + PolicyChangeResponse response = null; + String responseMessage; + try { + logger.info("Attempting to delete policy..."); + response = policyEngine.deletePolicy(deletePolicyParameters); + responseMessage = response.getResponseMessage(); + } catch (Exception e) { + responseMessage = e.toString(); + } + logger.info("response is " + responseMessage); + + if (response != null && response.getResponseCode() == 200) { + logger.info("Policy delete successful"); + } else { + logger.warning("Policy delete failed: " + responseMessage); + throw new Exception("Policy delete failed: " + responseMessage); + } + + return responseMessage; + } +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java new file mode 100644 index 000000000..58bba3c9d --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -0,0 +1,864 @@ +/*- + * ============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.client; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; +import org.onap.clamp.clds.client.req.SdcReq; +import org.onap.clamp.clds.model.*; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVRecord; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +public class SdcCatalogServices { + private static final Logger logger = LoggerFactory.getLogger(SdcSendReqDelegate.class); + + @Autowired + private RefProp refProp; + + public String getAsdcServicesInformation(String uuid) throws Exception { + String baseUrl = refProp.getStringValue("asdc.serviceUrl"); + String basicAuth = SdcReq.getAsdcBasicAuth(refProp); + try { + String url = baseUrl; + if (uuid != null) { + url = baseUrl + "/" + uuid + "/metadata"; + } + URL urlObj = new URL(url); + + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + + conn.setRequestProperty("X-ONAP-InstanceID", "CLAMP-Tool"); + conn.setRequestProperty("Authorization", basicAuth); + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestMethod("GET"); + + String resp = getResponse(conn); + if (resp != null) { + logger.info(resp.toString()); + return resp; + } + } catch (Exception e) { + logger.error("not able to ger any service information from asdc for uuid:" + uuid); + } + return ""; + } + + /** + * To remove duplicate serviceUUIDs from asdc services List + * + * @param rawCldsAsdcServiceList + * @return + */ + public List removeDuplicateServices(List rawCldsAsdcServiceList) { + List cldsAsdcServiceInfoList = null; + if (rawCldsAsdcServiceList != null && rawCldsAsdcServiceList.size() > 0) { + // sort list + Collections.sort(rawCldsAsdcServiceList); + // and then take only the services with the max version (last in the list with the same name) + cldsAsdcServiceInfoList = new ArrayList<>(); + for (int i = 1; i < rawCldsAsdcServiceList.size(); i++) { + // compare name with previous - if not equal, then keep the previous (it's the last with that name) + CldsAsdcServiceInfo prev = rawCldsAsdcServiceList.get(i - 1); + if (!rawCldsAsdcServiceList.get(i).getName().equals(prev.getName())) { + cldsAsdcServiceInfoList.add(prev); + } + } + // add the last in the list + cldsAsdcServiceInfoList.add(rawCldsAsdcServiceList.get(rawCldsAsdcServiceList.size() - 1)); + } + return cldsAsdcServiceInfoList; + } + + /** + * To remove duplicate serviceUUIDs from asdc resources List + * + * @param rawCldsAsdcResourceList + * @return + */ + public List removeDuplicateAsdcResourceInstances(List rawCldsAsdcResourceList) { + List cldsAsdcResourceList = null; + if (rawCldsAsdcResourceList != null && rawCldsAsdcResourceList.size() > 0) { + // sort list + Collections.sort(rawCldsAsdcResourceList); + // and then take only the resources with the max version (last in the list with the same name) + cldsAsdcResourceList = new ArrayList<>(); + for (int i = 1; i < rawCldsAsdcResourceList.size(); i++) { + // compare name with previous - if not equal, then keep the previous (it's the last with that name) + CldsAsdcResource prev = rawCldsAsdcResourceList.get(i - 1); + if (!rawCldsAsdcResourceList.get(i).getResourceInstanceName().equals(prev.getResourceInstanceName())) { + cldsAsdcResourceList.add(prev); + } + } + // add the last in the list + cldsAsdcResourceList.add(rawCldsAsdcResourceList.get(rawCldsAsdcResourceList.size() - 1)); + } + return cldsAsdcResourceList; + } + + + /** + * To remove duplicate basic resources with same resourceUUIDs + * + * @param rawCldsAsdcResourceListBasicList + * @return + */ + public List removeDuplicateAsdcResourceBasicInfo(List rawCldsAsdcResourceListBasicList) { + List cldsAsdcResourceBasicInfoList = null; + if (rawCldsAsdcResourceListBasicList != null && rawCldsAsdcResourceListBasicList.size() > 0) { + // sort list + Collections.sort(rawCldsAsdcResourceListBasicList); + // and then take only the resources with the max version (last in the list with the same name) + cldsAsdcResourceBasicInfoList = new ArrayList<>(); + for (int i = 1; i < rawCldsAsdcResourceListBasicList.size(); i++) { + // compare name with previous - if not equal, then keep the previous (it's the last with that name) + CldsAsdcResourceBasicInfo prev = rawCldsAsdcResourceListBasicList.get(i - 1); + if (!rawCldsAsdcResourceListBasicList.get(i).getName().equals(prev.getName())) { + cldsAsdcResourceBasicInfoList.add(prev); + } + } + // add the last in the list + cldsAsdcResourceBasicInfoList.add(rawCldsAsdcResourceListBasicList.get(rawCldsAsdcResourceListBasicList.size() - 1)); + } + return cldsAsdcResourceBasicInfoList; + } + + /** + * To get ServiceUUID by using serviceInvariantUUID + * + * @param invariantID + * @return + * @throws Exception + */ + public String getServiceUUIDFromServiceInvariantID(String invariantID) throws Exception { + String serviceUUID = ""; + String responseStr = getAsdcServicesInformation(null); + List rawCldsAsdcServicesList = getCldsAsdcServicesListFromJson(responseStr); + List cldsAsdcServicesList = removeDuplicateServices(rawCldsAsdcServicesList); + if (cldsAsdcServicesList != null && cldsAsdcServicesList.size() > 0) { + for (CldsAsdcServiceInfo currCldsAsdcServiceInfo : cldsAsdcServicesList) { + if (currCldsAsdcServiceInfo != null && currCldsAsdcServiceInfo.getInvariantUUID() != null + && currCldsAsdcServiceInfo.getInvariantUUID().equalsIgnoreCase(invariantID)) { + serviceUUID = currCldsAsdcServiceInfo.getUuid(); + break; + } + } + } + return serviceUUID; + } + + /** + * To get CldsAsdsServiceInfo class by parsing json string + * + * @param jsonStr + * @return + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public List getCldsAsdcServicesListFromJson(String jsonStr) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + if (StringUtils.isBlank(jsonStr)) { + return null; + } + return objectMapper.readValue(jsonStr, objectMapper.getTypeFactory().constructCollectionType(List.class, CldsAsdcServiceInfo.class)); + } + + /** + * To get List class by parsing json string + * + * @param jsonStr + * @return + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public List getAllAsdcResourcesListFromJson(String jsonStr) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + if (StringUtils.isBlank(jsonStr)) { + return null; + } + return objectMapper.readValue(jsonStr, objectMapper.getTypeFactory().constructCollectionType(List.class, CldsAsdcResourceBasicInfo.class)); + } + + /** + * To get CldsAsdsResource class by parsing json string + * + * @param jsonStr + * @return + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public CldsAsdcResource getCldsAsdcResourceFromJson(String jsonStr) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(jsonStr, CldsAsdcResource.class); + } + + /** + * To get CldsAsdcServiceDetail by parsing json string + * + * @param jsonStr + * @return + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public CldsAsdcServiceDetail getCldsAsdcServiceDetailFromJson(String jsonStr) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(jsonStr, CldsAsdcServiceDetail.class); + } + + /** + * To upload artifact to asdc based on serviceUUID and resourcename on url + * @param prop + * @param userid + * @param url + * @param formatttedAsdcReq + * @return + * @throws Exception + */ + public String uploadArtifactToAsdc(ModelProperties prop, String userid, String url, String formatttedAsdcReq) throws Exception { + logger.info("userid=" + userid); + String md5Text = SdcReq.calculateMD5ByString(formatttedAsdcReq); + byte[] postData = SdcReq.stringToByteArray(formatttedAsdcReq); + int postDataLength = postData.length; + HttpURLConnection conn = getAsdcHttpUrlConnection(userid, postDataLength, url, md5Text); + try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { + wr.write(postData); + } + boolean requestFailed = true; + int responseCode = conn.getResponseCode(); + logger.info("responseCode=" + responseCode); + if (responseCode == 200) { + requestFailed = false; + } + + String responseStr = getResponse(conn); + if (responseStr != null) { + if (requestFailed) { + logger.error("requestFailed - responseStr=" + responseStr); + throw new Exception(responseStr); + } + } + return responseStr; + } + + private HttpURLConnection getAsdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text) throws IOException { + logger.info("userid=" + userid); + String basicAuth = SdcReq.getAsdcBasicAuth(refProp); + String asdcXONAPInstanceID = refProp.getStringValue("asdc.asdcX-ONAP-InstanceID"); + URL urlObj = new URL(url); + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + conn.setDoOutput(true); + conn.setRequestProperty("X-ONAP-InstanceID", asdcXONAPInstanceID); + conn.setRequestProperty("Authorization", basicAuth); + conn.setRequestProperty("Content-Type", "application/json"); + conn.setRequestProperty("Content-MD5", md5Text); + conn.setRequestProperty("HTTP_CSP_USERID", userid); + conn.setRequestMethod("POST"); + conn.setRequestProperty("charset", "utf-8"); + conn.setRequestProperty("Content-Length", Integer.toString(postDataLength)); + conn.setUseCaches(false); + return conn; + } + + private String getResponse(HttpURLConnection conn) throws IOException { + try (InputStream is = getInputStream(conn)) { + if (is != null) { + try (BufferedReader in = new BufferedReader(new InputStreamReader(is))) { + StringBuffer response = new StringBuffer(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + return response.toString(); + } + } + } + return null; + } + + private InputStream getInputStream(HttpURLConnection conn) throws IOException { + InputStream inStream = conn.getErrorStream(); + if (inStream == null) { + inStream = conn.getInputStream(); + } + return inStream; + } + + + public CldsDBServiceCache getCldsDBServiceCacheUsingCldsServiceData(CldsServiceData cldsServiceData) throws IOException { + CldsDBServiceCache cldsDbServiceCache = new CldsDBServiceCache(); + cldsDbServiceCache.setCldsDataInstream(cldsServiceData); + cldsDbServiceCache.setInvariantId(cldsServiceData.getServiceInvariantUUID()); + cldsDbServiceCache.setServiceId(cldsServiceData.getServiceUUID()); + return cldsDbServiceCache; + } + + public boolean isCldsAsdcCacheDataExpired(CldsServiceData cldsServiceData) throws Exception { + boolean expired = false; + if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) { + String cachedServiceUUID = cldsServiceData.getServiceUUID(); + String latestServiceUUID = getServiceUUIDFromServiceInvariantID(cldsServiceData.getServiceInvariantUUID()); + String defaultRecordAge = refProp.getStringValue("CLDS_SERVICE_CACHE_MAX_SECONDS"); + if ((!cachedServiceUUID.equalsIgnoreCase(latestServiceUUID)) || + (cldsServiceData.getAgeOfRecord() != null && cldsServiceData.getAgeOfRecord() > Long.parseLong(defaultRecordAge))) { + expired = true; + } + } else { + expired = true; + } + return expired; + } + + public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUUID) throws Exception { + String url = refProp.getStringValue("asdc.serviceUrl"); + String catalogUrl = refProp.getStringValue("asdc.catalog.url"); + String serviceUUID = getServiceUUIDFromServiceInvariantID(invariantServiceUUID); + String serviceDetailUrl = url + "/" + serviceUUID + "/metadata"; + String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl, false); + ObjectMapper objectMapper = new ObjectMapper(); + CldsServiceData cldsServiceData = new CldsServiceData(); + if (responseStr != null) { + CldsAsdcServiceDetail cldsAsdcServiceDetail = objectMapper.readValue(responseStr, CldsAsdcServiceDetail.class); + cldsServiceData.setServiceUUID(cldsAsdcServiceDetail.getUuid()); + cldsServiceData.setServiceInvariantUUID(cldsAsdcServiceDetail.getInvariantUUID()); + + // To remove duplicate resources from serviceDetail and add valid vfs to service + if (cldsAsdcServiceDetail != null && cldsAsdcServiceDetail.getResources() != null) { + List cldsAsdcResourceList = removeDuplicateAsdcResourceInstances(cldsAsdcServiceDetail.getResources()); + if (cldsAsdcResourceList != null && cldsAsdcResourceList.size() > 0) { + List cldsVfDataList = new ArrayList<>(); + for (CldsAsdcResource currCldsAsdcResource : cldsAsdcResourceList) { + if (currCldsAsdcResource != null && currCldsAsdcResource.getResoucreType() != null && currCldsAsdcResource.getResoucreType().equalsIgnoreCase("VF")) { + CldsVfData currCldsVfData = new CldsVfData(); + currCldsVfData.setVfName(currCldsAsdcResource.getResourceInstanceName()); + currCldsVfData.setVfInvariantResourceUUID(currCldsAsdcResource.getResourceInvariantUUID()); + cldsVfDataList.add(currCldsVfData); + } + } + cldsServiceData.setCldsVfs(cldsVfDataList); + // For each vf in the list , add all vfc's + getAllVfcForVfList(cldsVfDataList, catalogUrl); + logger.info("value of cldsServiceData:" + cldsServiceData); + logger.info("value of cldsServiceData:" + cldsServiceData.getServiceInvariantUUID()); + } + } + } + return cldsServiceData; + } + + /** + * @param cldsVfDataList + * @throws IOException + */ + private void getAllVfcForVfList(List cldsVfDataList, String catalogUrl) throws IOException { + // todo : refact this.. + if (cldsVfDataList != null && cldsVfDataList.size() > 0) { + List allAsdcResources = getAllAsdcResources(); + String resourceVFType = "VF"; + List allVfResources = getAllAsdcVForVFCResourcesBasedOnResourceType(resourceVFType, allAsdcResources); + String resourceVFCType = "VFC"; + List allVfcResources = getAllAsdcVForVFCResourcesBasedOnResourceType(resourceVFCType, allAsdcResources); + for (CldsVfData currCldsVfData : cldsVfDataList) { + if (currCldsVfData != null && currCldsVfData.getVfInvariantResourceUUID() != null) { + String resourceUUID = getResourceUUIDFromResourceInvariantUUID(currCldsVfData.getVfInvariantResourceUUID(), allVfResources); + if (resourceUUID != null) { + String vfResourceUUIDUrl = catalogUrl + "resources" + "/" + resourceUUID + "/metadata"; + String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUUIDUrl, false); + if (vfResponse != null) { + List vfcDataListFromVfResponse = getVFCDataListFromVfResponse(vfResponse); + if (vfcDataListFromVfResponse != null) { + currCldsVfData.setCldsVfcs(vfcDataListFromVfResponse); + if (vfcDataListFromVfResponse.size() > 0) { + // To get artifacts for every VFC and get alarm conditions from artifact + for (CldsVfcData currCldsVfcData : vfcDataListFromVfResponse) { + if (currCldsVfcData != null && currCldsVfcData.getVfcInvariantResourceUUID() != null) { + String resourceVFCUUID = getResourceUUIDFromResourceInvariantUUID(currCldsVfcData.getVfcInvariantResourceUUID(), allVfcResources); + if (resourceVFCUUID != null) { + String vfcResourceUUIDUrl = catalogUrl + "resources" + "/" + resourceVFCUUID + "/metadata"; + String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl, false); + if (vfcResponse != null) { + List alarmCondtionsFromVfc = getAlarmCondtionsFromVfc(vfcResponse); + currCldsVfcData.setCldsAlarmConditions(alarmCondtionsFromVfc); + } + } else { + logger.info("No resourceVFC UUID found for given invariantID:" + currCldsVfcData.getVfcInvariantResourceUUID()); + } + } + } + } + } + } + } else { + logger.info("No resourceUUID found for given invariantREsourceUUID:" + currCldsVfData.getVfInvariantResourceUUID()); + } + } + } + } + } + + private List getVFCDataListFromVfResponse(String vfResponse) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); + ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources"); + List cldsVfcDataList = new ArrayList<>(); + if (vfcArrayNode != null && vfcArrayNode.size() > 0) { + for (int index = 0; index < vfcArrayNode.size(); index++) { + CldsVfcData currCldsVfcData = new CldsVfcData(); + ObjectNode currVfcNode = (ObjectNode) vfcArrayNode.get(index); + TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType"); + if (resourceTypeNode != null && resourceTypeNode.textValue().equalsIgnoreCase("VFC")) { + TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName"); + TextNode vfcInvariantResourceUUID = (TextNode) currVfcNode.get("resourceInvariantUUID"); + currCldsVfcData.setVfcName(vfcResourceName.textValue()); + currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUUID.textValue()); + cldsVfcDataList.add(currCldsVfcData); + } + } + } + return cldsVfcDataList; + } + + private String removeUnwantedBracesFromString(String id) { + if (id != null && id.contains("\"")) { + id = id.replaceAll("\"", ""); + } + return id; + } + + private List getAlarmCondtionsFromVfc(String vfcResponse) throws IOException { + List cldsAlarmConditionList = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + ObjectNode vfcResponseNode = (ObjectNode) mapper.readTree(vfcResponse); + ArrayNode artifactsArrayNode = (ArrayNode) vfcResponseNode.get("artifacts"); + + if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) { + for (int index = 0; index < artifactsArrayNode.size(); index++) { + ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index); + TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL"); + if (artifactUrlNode != null) { + String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue()); + cldsAlarmConditionList.addAll(parseCsvToGetAlarmConditions(responsesFromArtifactUrl)); + logger.info(responsesFromArtifactUrl); + } + } + } + return cldsAlarmConditionList; + } + + private List parseCsvToGetAlarmConditions(String allAlarmCondsValues) throws IOException { + List cldsAlarmConditionList = new ArrayList<>(); + Reader alarmReader = new StringReader(allAlarmCondsValues); + Iterable records = CSVFormat.RFC4180.parse(alarmReader); + if (records != null) { + Iterator it = records.iterator(); + if (it.hasNext()) { + it.next(); + } + it.forEachRemaining(record -> processRecord(cldsAlarmConditionList, record)); + } + return cldsAlarmConditionList; + } + + private void processRecord(List cldsAlarmConditionList, CSVRecord record) { + if (record == null) { + return; + } + if (record.size() < 5) { + logger.debug("invalid csv alarm Record,total columns less than 5: " + record); + return; + } + if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3)) || StringUtils.isBlank(record.get(4))) { + logger.debug("invalid csv alarm Record,one of column is having blank value : " + record); + return; + } + CldsAlarmCondition cldsAlarmCondition = new CldsAlarmCondition(); + cldsAlarmCondition.setEventSourceType(record.get(1)); + cldsAlarmCondition.setAlarmConditionKey(record.get(3)); + cldsAlarmCondition.setSeverity(record.get(4)); + cldsAlarmConditionList.add(cldsAlarmCondition); + } + + private String getResponsesFromArtifactUrl(String artifactsUrl) throws IOException { + String hostUrl = refProp.getStringValue("asdc.hostUrl"); + artifactsUrl = artifactsUrl.replaceAll("\"", ""); + String artifactUrl = hostUrl + artifactsUrl; + logger.info("value of artifactURl:" + artifactUrl); + String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl, true); + logger.info("value of artifactResponse:" + currArtifactResponse); + return currArtifactResponse; + } + + /** + * Service to services/resources/artifacts from asdc.Pass alarmConditions as true to get alarmconditons from artifact url and else it is false + * + * @param url + * @param alarmConditions + * @return + * @throws IOException + */ + private String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions) throws IOException { + String responseStr; + try { + url = removeUnwantedBracesFromString(url); + URL urlObj = new URL(url); + + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + String basicAuth = SdcReq.getAsdcBasicAuth(refProp); + conn.setRequestProperty("X-ONAP-InstanceID", "CLAMP-Tool"); + conn.setRequestProperty("Authorization", basicAuth); + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestMethod("GET"); + + int responseCode = conn.getResponseCode(); + logger.info("responseCode=" + responseCode); + + BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + StringBuffer response = new StringBuffer(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + if (alarmConditions) { + response.append("\n"); + } + } + responseStr = response.toString(); + in.close(); + } catch (Exception e) { + logger.error("Exception occured :" + e.getMessage()); + throw e; + } + return responseStr; + } + + /** + * To create properties object by using cldsServicedata + * + * @param globalProps + * @param cldsServiceData + * @return + * @throws IOException + */ + public String createPropertiesObjectByUUID(String globalProps, CldsServiceData cldsServiceData) throws IOException { + String totalPropsStr; + ObjectMapper mapper = new ObjectMapper(); + ObjectNode globalPropsJson; + if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) { + + /** + * Objectnode to save all byservice, byvf , byvfc and byalarm nodes + */ + ObjectNode byIdObjectNode = mapper.createObjectNode(); + /** + * To create vf ResourceUUID node with serviceInvariantUUID + * + */ + ObjectNode invariantUUIDObjectNodeWithVF = createVFObjectNodeByServiceInvariantUUID(mapper, cldsServiceData); + byIdObjectNode.putPOJO("byService", invariantUUIDObjectNodeWithVF); + + /** + * To create byVf and vfcResourceNode with vfResourceUUID + */ + ObjectNode vfcObjectNodeByVfUUID = createVFCObjectNodeByVfUUID(mapper, cldsServiceData.getCldsVfs()); + byIdObjectNode.putPOJO("byVf", vfcObjectNodeByVfUUID); + + + /** + * To create byVfc and alarmCondition with vfcResourceUUID + */ + ObjectNode vfcResourceUUIDObjectNode = mapper.createObjectNode(); + if (cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { + for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { + if (currCldsVfData != null) { + createAlarmCondObjectNodeByVfcUUID(mapper, vfcResourceUUIDObjectNode, currCldsVfData.getCldsVfcs()); + } + } + } + byIdObjectNode.putPOJO("byVfc", vfcResourceUUIDObjectNode); + + /** + * To create byAlarmCondition with alarmConditionKey + */ + List allAlarmConditions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData); + ObjectNode alarmCondObjectNodeByAlarmKey = createAlarmCondObjectNodeByAlarmKey(mapper, allAlarmConditions); + + byIdObjectNode.putPOJO("byAlarmCondition", alarmCondObjectNodeByAlarmKey); + + globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); + + globalPropsJson.putPOJO("shared", byIdObjectNode); + logger.info("valuie of objNode:" + globalPropsJson); + } else { + /** + * to create json with total properties when no serviceUUID passed + */ + globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); + } + totalPropsStr = globalPropsJson.toString(); + return totalPropsStr; + } + + private List getAllAlarmConditionsFromCldsServiceData(CldsServiceData cldsServiceData) { + List alarmCondList = new ArrayList<>(); + if (cldsServiceData != null && cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { + for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { + if (currCldsVfData != null && currCldsVfData.getCldsVfcs() != null && currCldsVfData.getCldsVfcs().size() > 0) { + for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { + if (currCldsVfcData != null && currCldsVfcData.getCldsAlarmConditions() != null && currCldsVfcData.getCldsAlarmConditions().size() > 0) { + for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) { + if (currCldsAlarmCondition != null) { + alarmCondList.add(currCldsAlarmCondition); + } + } + } + } + } + } + } + return alarmCondList; + } + + private ObjectNode createAlarmCondObjectNodeByAlarmKey(ObjectMapper mapper, List cldsAlarmCondList) { + ObjectNode alarmCondKeyNode = mapper.createObjectNode(); + + if (cldsAlarmCondList != null && cldsAlarmCondList.size() > 0) { + for (CldsAlarmCondition currCldsAlarmCondition : cldsAlarmCondList) { + if (currCldsAlarmCondition != null) { + ObjectNode alarmCondNode = mapper.createObjectNode(); + alarmCondNode.put("eventSourceType", currCldsAlarmCondition.getEventSourceType()); + alarmCondNode.put("eventSeverity", currCldsAlarmCondition.getSeverity()); + alarmCondKeyNode.putPOJO(currCldsAlarmCondition.getAlarmConditionKey(), alarmCondNode); + } + } + } else { + ObjectNode alarmCondNode = mapper.createObjectNode(); + alarmCondNode.put("eventSourceType", ""); + alarmCondNode.put("eventSeverity", ""); + alarmCondKeyNode.putPOJO("", alarmCondNode); + } + return alarmCondKeyNode; + } + + private ObjectNode createVFObjectNodeByServiceInvariantUUID(ObjectMapper mapper, CldsServiceData cldsServiceData) { + ObjectNode invariantUUIDObjectNode = mapper.createObjectNode(); + ObjectNode vfObjectNode = mapper.createObjectNode(); + ObjectNode vfUUIDNode = mapper.createObjectNode(); + List cldsVfsList = cldsServiceData.getCldsVfs(); + if (cldsVfsList != null && cldsVfsList.size() > 0) { + for (CldsVfData currCldsVfData : cldsVfsList) { + if (currCldsVfData != null) { + vfUUIDNode.put(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName()); + } + } + } else { + vfUUIDNode.put("", ""); + } + vfObjectNode.putPOJO("vf", vfUUIDNode); + invariantUUIDObjectNode.putPOJO(cldsServiceData.getServiceInvariantUUID(), vfObjectNode); + return invariantUUIDObjectNode; + } + + private void createAlarmCondObjectNodeByVfcUUID(ObjectMapper mapper, ObjectNode vfcResourceUUIDObjectNode, List cldsVfcDataList) { + ObjectNode alarmCondContsObjectNode = mapper.createObjectNode(); + ObjectNode alarmCondNode = mapper.createObjectNode(); + // alarmCondNode.put("", ""); + if (cldsVfcDataList != null && cldsVfcDataList.size() > 0) { + for (CldsVfcData currCldsVfcData : cldsVfcDataList) { + if (currCldsVfcData != null) { + if (currCldsVfcData.getCldsAlarmConditions() != null && currCldsVfcData.getCldsAlarmConditions().size() > 0) { + for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) { + alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(), currCldsAlarmCondition.getAlarmConditionKey()); + } + alarmCondContsObjectNode.putPOJO("alarmCondition", alarmCondNode); + } + alarmCondContsObjectNode.putPOJO("alarmCondition", alarmCondNode); + vfcResourceUUIDObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), alarmCondContsObjectNode); + } + } + } else { + alarmCondNode.put("", ""); + alarmCondContsObjectNode.putPOJO("alarmCondition", alarmCondNode); + vfcResourceUUIDObjectNode.putPOJO("", alarmCondContsObjectNode); + } + } + + private ObjectNode createVFCObjectNodeByVfUUID(ObjectMapper mapper, List cldsVfDataList) { + ObjectNode vfUUIDObjectNode = mapper.createObjectNode(); + + if (cldsVfDataList != null && cldsVfDataList.size() > 0) { + for (CldsVfData currCldsVfData : cldsVfDataList) { + if (currCldsVfData != null) { + ObjectNode vfcObjectNode = mapper.createObjectNode(); + ObjectNode vfcUUIDNode = mapper.createObjectNode(); + if (currCldsVfData.getCldsVfcs() != null && currCldsVfData.getCldsVfcs().size() > 0) { + for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { + vfcUUIDNode.put(currCldsVfcData.getVfcInvariantResourceUUID(), currCldsVfcData.getVfcName()); + } + } else { + vfcUUIDNode.put("", ""); + } + vfcObjectNode.putPOJO("vfc", vfcUUIDNode); + vfUUIDObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfcObjectNode); + } + } + } else { + ObjectNode vfcUUIDNode = mapper.createObjectNode(); + vfcUUIDNode.put("", ""); + ObjectNode vfcObjectNode = mapper.createObjectNode(); + vfcObjectNode.putPOJO("vfc", vfcUUIDNode); + vfUUIDObjectNode.putPOJO("", vfcObjectNode); + } + return vfUUIDObjectNode; + } + + public String getArtifactIdIfArtifactAlreadyExists(CldsAsdcServiceDetail cldsAsdcServiceDetail, String artifactName) { + String artifactUUId = null; + boolean artifactxists = false; + if (cldsAsdcServiceDetail != null && cldsAsdcServiceDetail.getResources() != null && cldsAsdcServiceDetail.getResources().size() > 0) { + for (CldsAsdcResource currCldsAsdcResource : cldsAsdcServiceDetail.getResources()) { + if (artifactxists) { + break; + } + if (currCldsAsdcResource != null && currCldsAsdcResource.getArtifacts() != null && currCldsAsdcResource.getArtifacts().size() > 0) { + for (CldsAsdcArtifact currCldsAsdcArtifact : currCldsAsdcResource.getArtifacts()) { + if (currCldsAsdcArtifact != null && currCldsAsdcArtifact.getArtifactName() != null) { + if (currCldsAsdcArtifact.getArtifactName().equalsIgnoreCase(artifactName)) { + artifactUUId = currCldsAsdcArtifact.getArtifactUUID(); + artifactxists = true; + break; + } + } + } + } + } + } + return artifactUUId; + } + + public String updateControlLoopStatusToDCAE(String dcaeUrl, String invariantResourceUUID, String invariantServiceUUID, String artifactName) { + String baseUrl = refProp.getStringValue("asdc.serviceUrl"); + String basicAuth = SdcReq.getAsdcBasicAuth(refProp); + String postStatusData = "{ \n" + + "\"event\" : \"" + "Created" + "\",\n" + + "\"serviceUUID\" : \"" + invariantServiceUUID + "\",\n" + + "\"resourceUUID\" :\"" + invariantResourceUUID + "\",\n" + + "\"artifactName\" : \"" + artifactName + "\",\n" + + "} \n"; + try { + String url = baseUrl; + if (invariantServiceUUID != null) { + url = dcaeUrl + "/closed-loops"; + } + URL urlObj = new URL(url); + + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + conn.setRequestProperty("X-ONAP-InstanceID", "CLAMP-Tool"); + conn.setRequestProperty("Authorization", basicAuth); + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestMethod("POST"); + + byte[] postData = SdcReq.stringToByteArray(postStatusData); + try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { + wr.write(postData); + } + + int responseCode = conn.getResponseCode(); + logger.info("responseCode=" + responseCode); + + String resp = getResponse(conn); + if (resp != null) { + return resp; + } + } catch (Exception e) { + logger.error("not able to ger any service information from asdc for uuid:" + invariantServiceUUID); + } + return ""; + } + + /** + * To get all asdc VF/VFC Resources basic info + * + * @return + * @throws IOException + */ + private List getAllAsdcVForVFCResourcesBasedOnResourceType(String resourceType, List allAsdcResources) throws IOException { + List allAsdcVFResources = new ArrayList<>(); + if (allAsdcResources != null && allAsdcResources.size() > 0) { + for (CldsAsdcResourceBasicInfo currResource : allAsdcResources) { + if (currResource != null && currResource.getResourceType() != null && currResource.getResourceType().equalsIgnoreCase(resourceType)) { + allAsdcVFResources.add(currResource); + } + } + } + return allAsdcVFResources; + } + + private String getResourceUUIDFromResourceInvariantUUID(String resourceInvariantUUID, List resourceInfoList) throws IOException { + String resourceUUID = null; + if (resourceInfoList != null && resourceInfoList.size() > 0) { + for (CldsAsdcResourceBasicInfo currResource : resourceInfoList) { + if (currResource != null && currResource.getInvariantUUID() != null && currResource.getUuid() != null + && currResource.getInvariantUUID().equalsIgnoreCase(resourceInvariantUUID)) { + resourceUUID = currResource.getUuid(); + break; + } + } + } + return resourceUUID; + } + + /** + * To get all asdc Resources basic info + * + * @return + * @throws IOException + */ + private List getAllAsdcResources() throws IOException { + String catalogUrl = refProp.getStringValue("asdc.catalog.url"); + String resourceUrl = catalogUrl + "resources"; + String allAsdcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false); + List allAsdcResourceBasicInfo = getAllAsdcResourcesListFromJson(allAsdcResources); + return removeDuplicateAsdcResourceBasicInfo(allAsdcResourceBasicInfo); + } +} diff --git a/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java new file mode 100644 index 000000000..93b6e954d --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java @@ -0,0 +1,138 @@ +/*- + * ============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.client; + +import org.onap.clamp.clds.client.req.SdcReq; +import org.onap.clamp.clds.model.CldsAsdcServiceDetail; +import org.onap.clamp.clds.model.DcaeEvent; +import org.onap.clamp.clds.model.prop.Global; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +/** + * Send control loop model to dcae proxy. + */ +public class SdcSendReqDelegate implements JavaDelegate { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = LoggerFactory.getLogger(SdcSendReqDelegate.class); + + @Autowired + private RefProp refProp; + + @Autowired + private SdcCatalogServices asdcCatalogServices; + + private String baseUrl; + private String artifactType; + private String locationArtifactType; + private String artifactLabel; + private String locationArtifactLabel; + + /** + * Perform activity. Send to asdc proxy. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + String userid = (String) execution.getVariable("userid"); + logger.info("userid=" + userid); + String docText = (String) execution.getVariable("docText"); + String artifactName = execution.getVariable("controlName") + DcaeEvent.ARTIFACT_NAME_SUFFIX; + execution.setVariable("artifactName", artifactName); + getAsdcAttributes(); + ModelProperties prop = ModelProperties.create(execution); + String bluprintPayload = SdcReq.formatBlueprint(refProp, prop, docText); + String formatttedAsdcReq = SdcReq.formatAsdcReq(bluprintPayload, artifactName, artifactLabel, artifactType); + if (formatttedAsdcReq != null) { + execution.setVariable("formattedArtifactReq", formatttedAsdcReq.getBytes()); + } + List asdcReqUrlsList = SdcReq.getAsdcReqUrlsList(prop, baseUrl, asdcCatalogServices, execution); + + String asdcLocationsPayload = SdcReq.formatAsdcLocationsReq(prop, artifactName); + String locationArtifactName = execution.getVariable("controlName") + "-location.json"; + String formattedAsdcLocationReq = SdcReq.formatAsdcReq(asdcLocationsPayload, locationArtifactName, locationArtifactLabel, locationArtifactType); + if (formattedAsdcLocationReq != null) { + execution.setVariable("formattedLocationReq", formattedAsdcLocationReq.getBytes()); + } + String serviceInvariantUUID = getServiceInvariantUUIDFromProps(prop); + uploadToAsdc(prop, serviceInvariantUUID, userid, asdcReqUrlsList, formatttedAsdcReq, formattedAsdcLocationReq, artifactName, locationArtifactName); + } + + private String getServiceInvariantUUIDFromProps(ModelProperties props) { + String invariantUUID = ""; + Global globalProps = props.getGlobal(); + if (globalProps != null) { + if (globalProps.getService() != null) { + invariantUUID = globalProps.getService(); + } + } + return invariantUUID; + } + + private void uploadToAsdc(ModelProperties prop, String serviceInvariantUUID, String userid, List asdcReqUrlsList, String formatttedAsdcReq, String formattedAsdcLocationReq, String artifactName, String locationArtifactName) throws Exception { + logger.info("userid=" + userid); + if (asdcReqUrlsList != null && asdcReqUrlsList.size() > 0) { + for (String url : asdcReqUrlsList) { + if (url != null) { + String originalServiceUUID = asdcCatalogServices.getServiceUUIDFromServiceInvariantID(serviceInvariantUUID); + logger.info("ServiceUUID used before upload in url:" + originalServiceUUID); + String asdcServicesInformation = asdcCatalogServices.getAsdcServicesInformation(originalServiceUUID); + CldsAsdcServiceDetail cldsAsdcServiceDetail = asdcCatalogServices.getCldsAsdcServiceDetailFromJson(asdcServicesInformation); + String uploadedArtifactUUID = asdcCatalogServices.getArtifactIdIfArtifactAlreadyExists(cldsAsdcServiceDetail, artifactName); + // Upload artifacts to asdc + String updateUrl = uploadedArtifactUUID != null ? url + "/" + uploadedArtifactUUID : url; + String responseStr = asdcCatalogServices.uploadArtifactToAsdc(prop, userid, updateUrl, formatttedAsdcReq); + logger.info("value of asdc Response of uploading to asdc :" + responseStr); + String updatedServiceUUID = asdcCatalogServices.getServiceUUIDFromServiceInvariantID(serviceInvariantUUID); + if (!originalServiceUUID.equalsIgnoreCase(updatedServiceUUID)) { + url = url.replace(originalServiceUUID, updatedServiceUUID); + } + logger.info("ServiceUUID used after upload in ulr:" + updatedServiceUUID); + asdcServicesInformation = asdcCatalogServices.getAsdcServicesInformation(updatedServiceUUID); + cldsAsdcServiceDetail = asdcCatalogServices.getCldsAsdcServiceDetailFromJson(asdcServicesInformation); + uploadedArtifactUUID = asdcCatalogServices.getArtifactIdIfArtifactAlreadyExists(cldsAsdcServiceDetail, locationArtifactName); + // To send location information also to asdc + updateUrl = uploadedArtifactUUID != null ? url + "/" + uploadedArtifactUUID : url; + responseStr = asdcCatalogServices.uploadArtifactToAsdc(prop, userid, updateUrl, formattedAsdcLocationReq); + logger.info("value of asdc Response of uploading location to asdc :" + responseStr); + } + } + } + } + + private void getAsdcAttributes() { + baseUrl = refProp.getStringValue("asdc.serviceUrl"); + artifactLabel = refProp.getStringValue("asdc.artifactLabel"); + locationArtifactLabel = refProp.getStringValue("asdc.locationArtifactLabel"); + artifactType = refProp.getStringValue("asdc.artifactType"); + locationArtifactType = refProp.getStringValue("asdc.locationArtifactType"); + } +} diff --git a/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java new file mode 100644 index 000000000..90e259f8c --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java @@ -0,0 +1,67 @@ +/*- + * ============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.client; + +import org.onap.clamp.clds.client.req.StringMatchPolicyReq; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.UUID; +import java.util.logging.Logger; + + +/** + * Send String Match info to policy api. + */ +public class StringMatchPolicyDelegate implements JavaDelegate { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(StringMatchPolicyDelegate.class.getName()); + + @Autowired + private PolicyClient policyClient; + + @Autowired + private RefProp refProp; + + /** + * Perform activity. Send String Match info to policy api. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + String stringMatchPolicyRequestUuid = UUID.randomUUID().toString(); + execution.setVariable("stringMatchPolicyRequestUuid", stringMatchPolicyRequestUuid); + + ModelProperties prop = ModelProperties.create(execution); + String policyJson = StringMatchPolicyReq.format(refProp, prop); + String responseMessage = policyClient.sendMicroService(policyJson, prop, stringMatchPolicyRequestUuid); + if (responseMessage != null) { + execution.setVariable("stringMatchPolicyResponseMessage", responseMessage.getBytes()); + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDeleteDelegate.java new file mode 100644 index 000000000..9efd358d7 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDeleteDelegate.java @@ -0,0 +1,58 @@ +/*- + * ============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.client; + +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.StringMatch; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.logging.Logger; + + +/** + * Delete String Match Policy via policy api. + */ +public class StringMatchPolicyDeleteDelegate implements JavaDelegate { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(StringMatchPolicyDeleteDelegate.class.getName()); + + @Autowired + private PolicyClient policyClient; + + /** + * Perform activity. Delete String Match Policy via policy api. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + ModelProperties prop = ModelProperties.create(execution); + StringMatch stringMatch = prop.getStringMatch(); + prop.setCurrentModelElementId(stringMatch.getId()); + + policyClient.deleteMicrosService(prop); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java new file mode 100644 index 000000000..58843d9bf --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java @@ -0,0 +1,53 @@ +package org.onap.clamp.clds.client; + +import java.util.UUID; +import java.util.logging.Logger; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; + +import org.onap.clamp.clds.client.req.TcaMPolicyReq; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.refprop.RefProp; + + +/** + * Send Tca info to policy api. + * + * + */ +public class TcaPolicyDelegate implements JavaDelegate { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(TcaPolicyDelegate.class.getName()); + + @Autowired + private RefProp refProp; + + @Autowired PolicyClient policyClient; + + /** + * Perform activity. Send Tca info to policy api. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + String tcaPolicyRequestUuid = UUID.randomUUID().toString(); + execution.setVariable("tcaPolicyRequestUuid", tcaPolicyRequestUuid); + + ModelProperties prop = ModelProperties.create(execution); + Tca tca = prop.getTca(); + if(tca.isFound()){ + String policyJson = TcaMPolicyReq.formatTca(refProp, prop); + String responseMessage = policyClient.sendMicroService(policyJson, prop, tcaPolicyRequestUuid); + if(responseMessage != null) + { + execution.setVariable("tcaPolicyResponseMessage", responseMessage.getBytes()); + } + } + } + + + +} diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java new file mode 100644 index 000000000..31e05d7dd --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java @@ -0,0 +1,48 @@ +package org.onap.clamp.clds.client; + +import java.util.logging.Logger; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.beans.factory.annotation.Autowired; + +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.refprop.RefProp; + + +/** + * Delete Tca Policy via policy api. + * + * + */ +public class TcaPolicyDeleteDelegate implements JavaDelegate { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(TcaPolicyDeleteDelegate.class.getName()); + + @Autowired + private PolicyClient policyClient; + + /** + * Perform activity. Delete Tca Policy via policy api. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + + ModelProperties prop = ModelProperties.create(execution); + Tca tca = prop.getTca(); + if(tca.isFound()){ + prop.setCurrentModelElementId(tca.getId()); + + String responseMessage = policyClient.deleteMicrosService(prop); + if(responseMessage != null) + { + execution.setVariable("tcaPolicyDeleteResponseMessage", responseMessage.getBytes()); + } + } + } + + + +} diff --git a/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java b/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java new file mode 100644 index 000000000..35d6c9f5f --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java @@ -0,0 +1,97 @@ +/*- + * ============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.client.req; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.onap.clamp.clds.model.prop.Global; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.StringMatch; +import org.onap.clamp.clds.model.refprop.RefProp; + +import java.io.IOException; +import java.util.List; +import java.util.logging.Logger; + + +/** + * Construct a DCAE request given CLDS objects. + */ +public class DcaeReq { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(DcaeReq.class.getName()); + + /** + * Format DCAE request. + * + * @param refProp + * @param prop + * @return + * @throws IOException + * @throws JsonMappingException + * @throws JsonParseException + */ + public static String format(RefProp refProp, ModelProperties prop) throws IOException { + Global globalProp = prop.getGlobal(); + String service = globalProp.getService(); + + StringMatch smProp = prop.getStringMatch(); + prop.setCurrentModelElementId(smProp.getId()); + + ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.template"); + + // "properties":{ + ObjectNode properties = rootNode.with("properties"); + // "service_name": + properties.put("service_name", globalProp.getService()); + // "service_ids":[ + List service_ids = refProp.decodeToList("dcae.decode.service_ids", globalProp.getService()); + JsonUtil.addArrayField(properties, "service_ids", service_ids); + // "vnf_ids":[ + JsonUtil.addArrayField(properties, "vnf_ids", globalProp.getResourceVf()); + // "location_ids":[ + JsonUtil.addArrayField(properties, "location_ids", globalProp.getLocation()); + + // "template":{ + ObjectNode template = rootNode.with("template"); + // "string_matching":{ + ObjectNode string_matching = template.with("string_matching"); + // "dcae":{ + ObjectNode dcae = string_matching.with("dcae"); + + dcae.put("inputTopic", smProp.getTopicSubscribes()); + dcae.put("outputTopic", smProp.getTopicPublishes()); + dcae.put("closedLoopControlName", prop.getControlName()); + dcae.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); + + // "serviceConfigurations":[ + StringMatchPolicyReq.appendServiceConfigurations(refProp, service, dcae, smProp); + + String dcaeReq = rootNode.toString(); + logger.info("dcaeReq=" + dcaeReq); + return dcaeReq; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java b/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java new file mode 100644 index 000000000..6aba683bc --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java @@ -0,0 +1,66 @@ +/*- + * ============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.client.req; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; + +import java.util.Iterator; +import java.util.List; + +/** + * Utility methods for formatting json + */ +public class JsonUtil { + + /** + * Add list of values to json array node + * + * @param list + * @param node + */ + public static void addListToArrayNode(List list, ArrayNode node) { + for (String aList : list) { + node.add(aList); + } + } + + /** + * Add list of values to json array node + * + * @param json + * @param name + * @param list + */ + public static void addArrayField(JsonNode json, String name, List list) { + if (list != null) { + ArrayNode node = (ArrayNode) json.withArray(name); + for (String aList : list) { + node.add(aList); + } + } + + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java new file mode 100644 index 000000000..90b9ff8ad --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -0,0 +1,299 @@ +/*- + * ============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.client.req; + +import org.onap.clamp.clds.model.prop.Global; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.Policy; +import org.onap.clamp.clds.model.prop.PolicyItem; +import org.openecomp.policy.controlloop.policy.TargetType; +import org.openecomp.policy.controlloop.policy.PolicyResult; +import org.openecomp.policy.controlloop.policy.Target; +import org.openecomp.policy.controlloop.policy.builder.BuilderException; +import org.openecomp.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; +import org.openecomp.policy.controlloop.policy.builder.Message; +import org.openecomp.policy.controlloop.policy.builder.Results; +import org.openecomp.policy.api.AttributeType; +import org.openecomp.policy.asdc.Resource; +import org.openecomp.policy.asdc.ResourceType; +import org.openecomp.policy.asdc.Service; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.jboss.resteasy.spi.BadRequestException; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.*; +import java.util.logging.Logger; + + +/** + * Construct an Operational Policy request given CLDS objects. + */ +public class OperationalPolicyReq { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(OperationalPolicyReq.class.getName()); + + + /** + * Format Operational Policy attributes. + * + * @param refProp + * @param prop + * @return + * @throws BuilderException + * @throws UnsupportedEncodingException + */ + public static Map> formatAttributes(RefProp refProp, ModelProperties prop) throws BuilderException, UnsupportedEncodingException { + Global global = prop.getGlobal(); + Policy policy = prop.getPolicy(); + prop.setCurrentModelElementId(policy.getId()); + + String templateName = refProp.getStringValue("op.templateName", global.getService()); + String recipeTopic = refProp.getStringValue("op.recipeTopic", global.getService()); + String operationTopic = refProp.getStringValue("op.operationTopic", global.getService()); + String notificationTopic = refProp.getStringValue("op.notificationTopic", global.getService()); + + // ruleAttributes + Map ruleAttributes = new HashMap<>(); + + if (operationTopic == null || operationTopic.length() == 0) { + logger.info("templateName=" + templateName); + logger.info("recipeTopic=" + recipeTopic); + logger.info("notificationTopic=" + notificationTopic); + + // if no operationTopic, then don't format yaml - use first policy from list + PolicyItem policyItem = policy.getPolicyItems().get(0); + + ruleAttributes.put("templateName", templateName); + ruleAttributes.put("ClosedLoopControlName", prop.getControlName()); + ruleAttributes.put("RecipeTopic", recipeTopic); + ruleAttributes.put("NotificationTopic", notificationTopic); + + String recipe = policyItem.getRecipe(); + String maxRetries = String.valueOf(policyItem.getMaxRetries()); + String retryTimeLimit = String.valueOf(policyItem.getRetryTimeLimit()); + logger.info("recipe=" + recipe); + logger.info("maxRetries=" + maxRetries); + logger.info("retryTimeLimit=" + retryTimeLimit); + ruleAttributes.put("Recipe", recipe); + ruleAttributes.put("MaxRetries", maxRetries); + ruleAttributes.put("RetryTimeLimit", retryTimeLimit); + } else { + logger.info("templateName=" + templateName); + logger.info("operationTopic=" + operationTopic); + logger.info("notificationTopic=" + notificationTopic); + + // format yaml + String yaml = formatYaml(refProp, prop); + + ruleAttributes.put("templateName", templateName); + ruleAttributes.put("ClosedLoopControlName", prop.getControlName()); + ruleAttributes.put("OperationTopic", operationTopic); + ruleAttributes.put("NotificationTopic", notificationTopic); + + ruleAttributes.put("ControlLoopYaml", yaml); + } + + // matchingAttributes + String controller = refProp.getStringValue("op.controller", global.getService()); + + Map matchingAttributes = new HashMap<>(); + matchingAttributes.put("controller", controller); + + Map> attributes = new HashMap<>(); + attributes.put(AttributeType.RULE, ruleAttributes); + attributes.put(AttributeType.MATCHING, matchingAttributes); + + + return attributes; + } + + + /** + * Format Operational Policy yaml. + * + * @param refProp + * @param prop + * @return + * @throws BuilderException + * @throws UnsupportedEncodingException + */ + private static String formatYaml(RefProp refProp, ModelProperties prop) throws BuilderException, UnsupportedEncodingException { + // get property objects + Global global = prop.getGlobal(); + Policy policy = prop.getPolicy(); + prop.setCurrentModelElementId(policy.getId()); + + // convert values to ASDC objects + Service service = new Service(global.getService()); + Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF); + Resource[] vfcResources = convertToResource(global.getResourceVfc(), ResourceType.VFC); + + // create builder + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(), policy.getTimeout(), service, vfResources); + builder.addResource(vfcResources); + + // process each policy + HashMap policyObjMap = new HashMap<>(); + List policyItemList = orderParentFirst(policy.getPolicyItems()); + for (int i = 0; i < policyItemList.size(); i++) { + org.openecomp.policy.controlloop.policy.Policy policyObj; + PolicyItem policyItem = policyItemList.get(i); + String policyName = policyItem.getRecipe() + " Policy"; + if (i == 0) { + String policyDescription = policyItem.getRecipe() + " Policy - the trigger (no parent) policy - created by CLDS"; + policyObj = builder.setTriggerPolicy( + policyName, + policyDescription, + "APPC", + new Target(TargetType.VM), + policyItem.getRecipe(), + new HashMap<>(), //TODO To verify ! + policyItem.getMaxRetries(), + policyItem.getRetryTimeLimit()); + } else { + org.openecomp.policy.controlloop.policy.Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy()); + String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + parentPolicyObj.getName() + " - created by CLDS"; + policyObj = builder.setPolicyForPolicyResult( + policyName, + policyDescription, + "APPC", + new Target(TargetType.VM), + policyItem.getRecipe(), + new HashMap<>(), //TODO To verify ! + policyItem.getMaxRetries(), + policyItem.getRetryTimeLimit(), + parentPolicyObj.getId(), + convertToPolicyResult(policyItem.getParentPolicyConditions())); + logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId()); + } + policyObjMap.put(policyItem.getId(), policyObj); + } + + // + // Build the specification + // + Results results = builder.buildSpecification(); + if (results.isValid()) { + logger.info("results.getSpecification()=" + results.getSpecification()); + } else { + // throw exception with error info + StringBuilder sb = new StringBuilder(); + sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: "); + for (Message message : results.getMessages()) { + sb.append(message.getMessage()); + sb.append("; "); + } + throw new BadRequestException(sb.toString()); + } + return URLEncoder.encode(results.getSpecification(), "UTF-8"); + } + + /** + * Order list of PolicyItems so that parents come before any of their children + * + * @param inOrigList + * @return + */ + private static List orderParentFirst(List inOrigList) { + List inList = new ArrayList<>(); + inList.addAll(inOrigList); + List outList = new ArrayList<>(); + int prevSize = 0; + while (!inList.isEmpty()) { + // check if there's a loop in the policy chain (the inList should have been reduced by at least one) + if (inList.size() == prevSize) { + throw new BadRequestException("Operation Policy validation problem: loop in Operation Policy chain"); + } + prevSize = inList.size(); + // the following loop should remove at least one PolicyItem from the inList + Iterator inListItr = inList.iterator(); + while (inListItr.hasNext()) { + PolicyItem inItem = inListItr.next(); + // check for trigger policy (no parent) + String parent = inItem.getParentPolicy(); + if (parent == null || parent.length() == 0) { + if (outList.size() > 0) { + throw new BadRequestException("Operation Policy validation problem: more than one trigger policy"); + } else { + outList.add(inItem); + inListItr.remove(); + } + } else { + // check if this PolicyItem's parent has been processed + for (PolicyItem outItem : outList) { + if (outItem.getId().equals(parent)) { + // if the inItem parent is already in the outList, then add inItem to outList and remove from inList + outList.add(inItem); + inListItr.remove(); + break; + } + } + } + } + } + return outList; + } + + + /** + * Convert a List of resource strings to an array of Resource objects. + * + * @param rList + * @param resourceType + * @return + */ + private static Resource[] convertToResource(List rList, ResourceType resourceType) { + int size = 0; + if (rList != null) { + size = rList.size(); + } + Resource[] rArray = new Resource[size]; + for (int i = 0; i < size; i++) { + String rString = rList.get(i); + rArray[i] = new Resource(rString, resourceType); + } + return rArray; + } + + /** + * Convert a List of policy result strings to an array of PolicyResult objects. + * + * @param prList + * @return + */ + private static PolicyResult[] convertToPolicyResult(List prList) { + int size = 0; + if (prList != null) { + size = prList.size(); + } + PolicyResult[] prArray = new PolicyResult[size]; + for (int i = 0; i < size; i++) { + String prString = prList.get(i); + prArray[i] = PolicyResult.toResult(prString); + } + return prArray; + } + +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java new file mode 100644 index 000000000..45f17164a --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java @@ -0,0 +1,360 @@ +/*- + * ============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.client.req; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; +import org.onap.clamp.clds.client.SdcCatalogServices; +import org.onap.clamp.clds.model.CldsAsdcResource; +import org.onap.clamp.clds.model.CldsAsdcServiceDetail; +import org.onap.clamp.clds.model.prop.Global; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.StringMatch; +import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.apache.commons.codec.digest.DigestUtils; +import org.camunda.bpm.engine.delegate.DelegateExecution; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.Map.Entry; +import java.util.logging.Logger; + +/** + * Construct a Asdc request given CLDS objects. + */ +public class SdcReq { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(SdcReq.class.getName()); + + /** + * @param refProp + * @param prop + * @return + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public static String formatBlueprint(RefProp refProp, ModelProperties prop, String docText) + throws JsonParseException, JsonMappingException, IOException { + + Global globalProp = prop.getGlobal(); + String service = globalProp.getService(); + + String yamlvalue = getYamlvalue(docText); + + String updatedBlueprint = ""; + StringMatch stringMatch = prop.getStringMatch(); + Tca tca = prop.getTca(); + if (stringMatch.isFound()) { + prop.setCurrentModelElementId(stringMatch.getId()); + ObjectMapper objectMapper = new ObjectMapper(); + ObjectNode serviceConfigurations = objectMapper.createObjectNode(); + + StringMatchPolicyReq.appendServiceConfigurations(refProp, service, serviceConfigurations, stringMatch); + logger.info("Value of serviceConfigurations:" + serviceConfigurations); + ObjectNode servConfNode = (ObjectNode) serviceConfigurations.get("serviceConfigurations"); + + // get updated blueprint by attaching service Conf from + // globalProperties + updatedBlueprint = getUpdatedBlueprintWithServiceConf(refProp, prop, yamlvalue, servConfNode); + } else if (tca.isFound()) { + prop.setCurrentModelElementId(tca.getId()); + ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("tca.template", service); + ObjectNode content = rootNode.with("content"); + TcaMPolicyReq.appendSignatures(refProp, service, content, tca, prop); + logger.info("Value of content:" + content); + // ObjectNode servConfNode = + // (ObjectNode)signatures.get("signatures"); + + // get updated blueprint by attaching service Conf from + // globalProperties + updatedBlueprint = getUpdatedBlueprintWithConfiguration(refProp, prop, yamlvalue, content); + } + + logger.info("value of blueprint:" + updatedBlueprint); + return updatedBlueprint; + } + + private static String getUpdatedBlueprintWithServiceConf(RefProp refProp, ModelProperties prop, String yamlValue, + ObjectNode serviceConf) throws IOException { + Yaml yaml = new Yaml(); + + // Serialiaze Yaml file + Map loadedYaml = (Map) yaml.load(yamlValue); + // Get node templates information from Yaml + Map nodeTemplates = (Map) loadedYaml.get("node_templates"); + logger.info("value of NodeTemplates:" + nodeTemplates); + + // Get StringMatch Object information from node templates of Yaml + Map smObject = (Map) nodeTemplates.get("SM"); + logger.info("value of StringMatch:" + smObject); + + // Get Properties Object information from stringmatch of Yaml + Map propsObject = (Map) smObject.get("properties"); + logger.info("value of PropsObject:" + propsObject); + + String deploymentJsonObject = propsObject.get("deployment_JSON"); + logger.info("value of deploymentJson:" + deploymentJsonObject); + + ObjectMapper mapper = new ObjectMapper(); + ObjectNode deployJsonNode = (ObjectNode) mapper.readTree(deploymentJsonObject); + ObjectNode configurationObjectNode = (ObjectNode) deployJsonNode.get("configuration"); + + // "policyName":"example_model06.ClosedLoop_FRWL_SIG_0538e6f2_8c1b_4656_9999_3501b3c59ad7_StringMatch_", + String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); + String policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix); + configurationObjectNode.put("policyName", policyName); + + // "closedLoopControlName":"ClosedLoop-FRWL-SIG-0538e6f2-8c1b-4656-9999-3501b3c59ad7", + configurationObjectNode.put("closedLoopControlName", prop.getControlName()); + configurationObjectNode.set("serviceConfigurations", serviceConf); + propsObject.put("deployment_JSON", deployJsonNode.toString()); + String blueprint = yaml.dump(loadedYaml); + logger.info("value of updated Yaml File:" + blueprint); + + blueprint = yaml.dump(loadedYaml); + logger.info("value of updated Yaml File:" + blueprint); + + return blueprint; + } + + private static String getUpdatedBlueprintWithConfiguration(RefProp refProp, ModelProperties prop, String yamlValue, + ObjectNode serviceConf) throws JsonProcessingException, IOException { + String blueprint = ""; + Yaml yaml = new Yaml(); + // Serialiaze Yaml file + Map loadedYaml = (Map) yaml.load(yamlValue); + // Get node templates information from Yaml + Map nodeTemplates = (Map) loadedYaml.get("node_templates"); + logger.info("value of NodeTemplates:" + nodeTemplates); + // Get Tca Object information from node templates of Yaml + Map tcaObject = (Map) nodeTemplates.get("MTCA"); + logger.info("value of Tca:" + tcaObject); + // Get Properties Object information from tca of Yaml + Map propsObject = (Map) tcaObject.get("properties"); + logger.info("value of PropsObject:" + propsObject); + String deploymentJsonObject = (String) propsObject.get("deployment_JSON"); + logger.info("value of deploymentJson:" + deploymentJsonObject); + + ObjectMapper mapper = new ObjectMapper(); + + ObjectNode deployJsonNode = (ObjectNode) mapper.readTree(deploymentJsonObject); + + // "policyName":"example_model06.ClosedLoop_FRWL_SIG_0538e6f2_8c1b_4656_9999_3501b3c59ad7_Tca_", + String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); + String policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix); + serviceConf.put("policyName", policyName); + + deployJsonNode.set("configuration", serviceConf); + propsObject.put("deployment_JSON", deployJsonNode.toString()); + blueprint = yaml.dump(loadedYaml); + logger.info("value of updated Yaml File:" + blueprint); + + return blueprint; + } + + public static String formatAsdcLocationsReq(ModelProperties prop, String artifactName) { + ObjectMapper objectMapper = new ObjectMapper(); + Global global = prop.getGlobal(); + List locationsList = global.getLocation(); + ArrayNode locationsArrayNode = objectMapper.createArrayNode(); + ObjectNode locationObject = objectMapper.createObjectNode(); + for (String currLocation : locationsList) { + locationsArrayNode.add(currLocation); + } + locationObject.put("artifactName", artifactName); + locationObject.putPOJO("locations", locationsArrayNode); + String locationJsonFormat = locationObject.toString(); + logger.info("Value of locaation Json Artifact:" + locationsArrayNode); + return locationJsonFormat; + } + + public static String formatAsdcReq(String payloadData, String artifactName, String artifactLabel, + String artifactType) throws IOException { + logger.info("artifact=" + payloadData); + String base64Artifact = base64Encode(payloadData); + return "{ \n" + "\"payloadData\" : \"" + base64Artifact + "\",\n" + "\"artifactLabel\" : \"" + artifactLabel + + "\",\n" + "\"artifactName\" :\"" + artifactName + "\",\n" + "\"artifactType\" : \"" + artifactType + + "\",\n" + "\"artifactGroupType\" : \"DEPLOYMENT\",\n" + "\"description\" : \"from CLAMP Cockpit\"\n" + + "} \n"; + } + + public static String getAsdcReqUrl(ModelProperties prop, String url) { + Global globalProps = prop.getGlobal(); + String serviceUUID = ""; + String resourceInstanceName = ""; + if (globalProps != null) { + List resourceVf = globalProps.getResourceVf(); + if (resourceVf != null && resourceVf.size() > 0) { + resourceInstanceName = resourceVf.get(0); + } + if (globalProps.getService() != null) { + serviceUUID = globalProps.getService(); + } + } + String normalizedResourceInstanceName = normalizeResourceInstanceName(resourceInstanceName); + return url + "/" + serviceUUID + "/resourceInstances/" + normalizedResourceInstanceName + "/artifacts"; + } + + /** + * To get List of urls for all vfresources + * + * @param prop + * @param baseUrl + * @param sdcCatalogServices + * @return + * @throws Exception + */ + public static List getAsdcReqUrlsList(ModelProperties prop, String baseUrl, + SdcCatalogServices sdcCatalogServices, DelegateExecution execution) throws Exception { + // TODO : refact and regroup with very similar code + List urlList = new ArrayList<>(); + Global globalProps = prop.getGlobal(); + if (globalProps != null) { + if (globalProps.getService() != null) { + String serviceInvariantUUID = globalProps.getService(); + execution.setVariable("serviceInvariantUUID", serviceInvariantUUID); + List resourceVfList = globalProps.getResourceVf(); + String serviceUUID = sdcCatalogServices.getServiceUUIDFromServiceInvariantID(serviceInvariantUUID); + String asdcServicesInformation = sdcCatalogServices.getAsdcServicesInformation(serviceUUID); + CldsAsdcServiceDetail cldsAsdcServiceDetail = sdcCatalogServices.getCldsAsdcServiceDetailFromJson(asdcServicesInformation); + if (cldsAsdcServiceDetail != null && resourceVfList != null) { + List cldsAsdcResourcesList = cldsAsdcServiceDetail.getResources(); + if (cldsAsdcResourcesList != null && cldsAsdcResourcesList.size() > 0) { + for (CldsAsdcResource cldsAsdcResource : cldsAsdcResourcesList) { + if (cldsAsdcResource != null && cldsAsdcResource.getResoucreType() != null + && cldsAsdcResource.getResoucreType().equalsIgnoreCase("VF")) { + if (resourceVfList.contains(cldsAsdcResource.getResourceInvariantUUID())) { + String normalizedResourceInstanceName = normalizeResourceInstanceName(cldsAsdcResource.getResourceInstanceName()); + String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" + normalizedResourceInstanceName + "/artifacts"; + urlList.add(svcUrl); + } + } + } + } + } + } + } + return urlList; + } + + /** + * "Normalize" the resource instance name: - Remove spaces, underscores, + * dashes, and periods. - make lower case This is required by ASDC when + * using the resource instance name to upload an artifact. + * + * @param inText + * @return + */ + public static String normalizeResourceInstanceName(String inText) { + return inText.replace(" ", "").replace("-", "").replace(".", "").toLowerCase(); + } + + /** + * from michael + * + * @param data + * @return + */ + public static String calculateMD5ByString(String data) { + String calculatedMd5 = DigestUtils.md5Hex(data); + // encode base-64 result + return base64Encode(calculatedMd5.getBytes()); + } + + /** + * Base 64 encode a String. + * + * @param inText + * @return + */ + public static String base64Encode(String inText) { + return base64Encode(stringToByteArray(inText)); + } + + /** + * Convert String to byte array. + * + * @param inText + * @return + */ + public static byte[] stringToByteArray(String inText) { + return inText.getBytes(StandardCharsets.UTF_8); + } + + /** + * Base 64 encode a byte array. + * + * @param bytes + * @return + */ + public static String base64Encode(byte[] bytes) { + Base64.Encoder encoder = Base64.getEncoder(); + return encoder.encodeToString(bytes); + } + + /** + * Return ASDC id and pw as a HTTP Basic Auth string (for example: Basic + * dGVzdDoxMjM0NTY=). + * + * @return + */ + public static String getAsdcBasicAuth(RefProp refProp) { + String asdcId = refProp.getStringValue("asdc.serviceUsername"); + String asdcPw = refProp.getStringValue("asdc.servicePassword"); + String idPw = base64Encode(asdcId + ":" + asdcPw); + return "Basic " + idPw; + } + + private static String getYamlvalue(String docText) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + String yamlFileValue = ""; + ObjectNode root = objectMapper.readValue(docText, ObjectNode.class); + Iterator> entryItr = root.fields(); + while (entryItr.hasNext()) { + Entry entry = entryItr.next(); + String key = entry.getKey(); + if (key != null && key.equalsIgnoreCase("global")) { + ArrayNode arrayNode = (ArrayNode) entry.getValue(); + for (JsonNode anArrayNode : arrayNode) { + ObjectNode node = (ObjectNode) anArrayNode; + ArrayNode arrayValueNode = (ArrayNode) node.get("value"); + JsonNode jsonNode = arrayValueNode.get(0); + yamlFileValue = jsonNode.asText(); + logger.info("value:" + yamlFileValue); + } + break; + } + } + return yamlFileValue; + } +} diff --git a/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java new file mode 100644 index 000000000..0f66cd9ba --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java @@ -0,0 +1,138 @@ +/*- + * ============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.client.req; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.onap.clamp.clds.model.prop.Global; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.ServiceConfiguration; +import org.onap.clamp.clds.model.prop.StringMatch; +import org.onap.clamp.clds.model.refprop.RefProp; + +import java.io.IOException; +import java.util.Iterator; +import java.util.Map.Entry; +import java.util.logging.Logger; + + +/** + * Construct a Policy for String Match Micro Service request given CLDS objects. + */ +public class StringMatchPolicyReq { + // currently uses the java.util.logging.Logger like the Camunda engine + private static final Logger logger = Logger.getLogger(StringMatchPolicyReq.class.getName()); + + /** + * Format Policy String Match request. + * + * @param refProp + * @param prop + * @return + * @throws IOException + */ + public static String format(RefProp refProp, ModelProperties prop) throws IOException { + Global global = prop.getGlobal(); + String service = global.getService(); + + StringMatch sm = prop.getStringMatch(); + prop.setCurrentModelElementId(sm.getId()); + ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("sm.template", service); + + // "policyName": + rootNode.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); + + // "content":{ + ObjectNode content = rootNode.with("content"); + + // "closedLoopControlName": + content.put("closedLoopControlName", prop.getControlName()); + + // "serviceConfigurations":[ + appendServiceConfigurations(refProp, service, content, sm); + + String stringMatchPolicyReq = rootNode.toString(); + logger.info("stringMatchPolicyReq=" + stringMatchPolicyReq); + return stringMatchPolicyReq; + } + + /** + * Add serviceConfigurations to json + * + * @param appendToNode + * @param sm + * @throws IOException + */ + public static void appendServiceConfigurations(RefProp refProp, String service, ObjectNode appendToNode, StringMatch sm) throws IOException { + // "serviceConfigurations":{ + ObjectNode scNodes = appendToNode.with("serviceConfigurations"); + + Iterator scItr = sm.getServiceConfigurations().iterator(); + int index = 0; + while (scItr.hasNext()) { + ServiceConfiguration sc = scItr.next(); + + //"ItemX":{ + index++; + String keyValue = "Item" + index; + ObjectNode scNode = (ObjectNode) refProp.getJsonTemplate("sm.sc.template", service); + scNodes.set(keyValue, scNode); + + // "rulegroup":"abc", + String rulegroupInd = refProp.getStringValue("sm.rulegroup", service); + String groupNumber = sc.getGroupNumber(); + if (rulegroupInd != null && rulegroupInd.equalsIgnoreCase("true") && groupNumber != null && groupNumber.length() > 0) { + + //String rulegroup = (sc.getResourceVf() == null ? "" : String.join(" ", sc.getResourceVf())) + " - " + (sc.getResourceVfc() == null ? "" : String.join(" ", sc.getResourceVfc())); + scNode.put("rulegroup", groupNumber); + } + + // "aaiMatchingFields" : ["VM_NAME"], + JsonUtil.addArrayField(scNode, "aaiMatchingFields", sc.getaaiMatchingFields()); + // "aaiSendFields" : ["VMID", "TenantID"], + JsonUtil.addArrayField(scNode, "aaiSendFields", sc.getaaiSendFields()); + + // "stringSet": [ + ArrayNode ssNode = scNode.putArray("stringSet"); + // ObjectNode ssNode = scNode.with("stringSet"); + for (Entry entry : sc.getStringSet().entrySet()) { + // exclude eventSourceType + if (!entry.getKey().equals("eventSourceType")) { + ssNode.add(entry.getKey()); + ssNode.add(entry.getValue()); + } + } + + // timeWindow": "0", + scNode.put("timeWindow", sc.getTimeWindow()); + // "ageLimit": "3600", + scNode.put("ageLimit", sc.getAgeLimit()); + // "createClosedLoopEventId" : "Initial", + scNode.put("createClosedLoopEventId", sc.getCreateClosedLoopEventId()); + // "outputEventName": "OnSet" + scNode.put("outputEventName", sc.getOutputEventName()); + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java new file mode 100644 index 000000000..f8acb64f6 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java @@ -0,0 +1,93 @@ +package org.onap.clamp.clds.client.req; + +import java.io.IOException; +import java.util.Iterator; +import java.util.logging.Logger; + +import org.onap.clamp.clds.model.prop.Global; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.prop.TcaItem; +import org.onap.clamp.clds.model.prop.TcaThreshhold; +import org.onap.clamp.clds.model.refprop.RefProp; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Construct a Policy for Tca/MTca Service request given CLDS objects. + * + * + */ +public class TcaMPolicyReq { + private static final Logger logger = Logger.getLogger(StringMatchPolicyReq.class.getName()); + + /** + * Format Tca Policy request + * + * @param refProp + * @param prop + * @return + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public static String formatTca(RefProp refProp, ModelProperties prop) throws JsonParseException, JsonMappingException, IOException { + Global global = prop.getGlobal(); + String service = global.getService(); + + Tca tca = prop.getTca(); + prop.setCurrentModelElementId(tca.getId()); + ObjectNode rootNode = (ObjectNode)refProp.getJsonTemplate("tca.template", service); + rootNode.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); + ObjectNode content = rootNode.with("content"); + appendSignatures(refProp, service, content, tca, prop); + + String tcaPolicyReq = rootNode.toString(); + logger.info("tcaPolicyReq=" + tcaPolicyReq); + return tcaPolicyReq; + } + + /** + * Add appendSignatures to json + * + * @param refProp + * @param service + * @param appendToNode + * @param tca + * @param prop + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public static void appendSignatures(RefProp refProp, String service, ObjectNode appendToNode, Tca tca, ModelProperties prop) throws JsonParseException, JsonMappingException, IOException { + // "signatures":{ + ArrayNode tcaNodes = appendToNode.withArray("signatures"); + for(TcaItem tcaItem : tca.getTcaItems()){ + ObjectNode tcaNode = (ObjectNode)refProp.getJsonTemplate("tca.signature.template", service); + tcaNode.put("useCaseName", tcaItem.getTcaName()); + tcaNode.put("signatureName", tcaItem.getTcaName()+ "_" + tcaItem.getTcaUuId()); + tcaNode.put("signatureUuid", tcaItem.getTcaUuId()); + prop.setPolicyUniqueId(tcaItem.getPolicyId()); + tcaNode.put("closedLoopControlName", prop.getControlNameAndPolicyUniqueId()); + tcaNode.put("severity", tcaItem.getSeverity()); + tcaNode.put("maxInterval", tcaItem.getInterval()); + tcaNode.put("minMessageViolations", tcaItem.getViolations()); + + tcaNodes.add(tcaNode); + Iterator scItr = tcaItem.getTcaThreshholds().iterator(); + while(scItr.hasNext()) { + TcaThreshhold tcaThreshhold = scItr.next(); + // "thresholds": [ + ArrayNode thNodes = tcaNode.withArray("thresholds"); + ObjectNode thNode = thNodes.addObject(); + thNode.put("fieldPath", tcaThreshhold.getFieldPath()); + thNode.put("thresholdName", tcaThreshhold.getMetric()); + thNode.put("thresholdValue", tcaThreshhold.getThreshhold()); + thNode.put("direction", tcaThreshhold.getOperator()); + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/common/LogMessages.java b/src/main/java/org/onap/clamp/clds/common/LogMessages.java new file mode 100644 index 000000000..cdd479371 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/common/LogMessages.java @@ -0,0 +1,37 @@ +/*- + * ============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.common; + +import com.att.eelf.i18n.EELFResolvableErrorEnum; +import com.att.eelf.i18n.EELFResourceManager; + +public enum LogMessages implements EELFResolvableErrorEnum { + + LOGSERVICE_HELLO_MESSAGE, LOGSERVICE_EMAIL_ERROR, LOGSERVICE_EMAIL_CLASS, LOGSERVICE_EMAIL_CLASS_NULL, PROCESS_INSTANCE_ID; + + static { + EELFResourceManager.loadMessageBundle("logmessages"); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java b/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java new file mode 100644 index 000000000..244b40aa1 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java @@ -0,0 +1,87 @@ +/*- + * ============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 java.util.EnumSet; +import java.util.Map; +import java.util.logging.Logger; + +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 DISPATCHER_TYPES = EnumSet.of(DispatcherType.REQUEST); + + private static final String AJSC_CADI_PROPS_FILE = "cadi.properties"; + + private ServletContext servletContext; + + @Value("${com.att.ajsc.camunda.contextPath:/camunda}") + private String CAMUNDA_SUFFIX; + + private static final Logger log = Logger.getLogger(CamundaAuthFilterInitializer.class.getName()); + + @Override + public void onStartup(ServletContext servletContext) throws ServletException { + this.servletContext = servletContext; + + registerFilter("Authentication Filter", AuthenticationFilter.class, CAMUNDA_SUFFIX + "/*"); + } + + private FilterRegistration registerFilter(final String filterName, final Class filterClass, + final String... urlPatterns) { + return registerFilter(filterName, filterClass, null, urlPatterns); + } + + private FilterRegistration registerFilter(final String filterName, final Class filterClass, + final Map 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/CamundaEngineConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java new file mode 100644 index 000000000..949f4ea62 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java @@ -0,0 +1,49 @@ +/*- + * ============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.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import javax.sql.DataSource; + +@Configuration +public class CamundaEngineConfiguration { + + /** + * Camunda Identity databse DataSource configuration + */ + @Primary + @Bean(name = "camundaBpmDataSource") + @ConfigurationProperties(prefix = "spring.datasource") + public DataSource dataSource() { + return DataSourceBuilder + .create() + .build(); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java new file mode 100644 index 000000000..814d2c6ad --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java @@ -0,0 +1,142 @@ +/*- + * ============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.ajsc.common.AjscProvider; +import com.att.ajsc.common.AjscService; +import org.onap.clamp.clds.client.*; +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.boot.autoconfigure.jdbc.DataSourceBuilder; +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 javax.sql.DataSource; +import javax.xml.transform.TransformerConfigurationException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +@Configuration +@Profile("clamp-default") +public class CldsConfiguration { + + @Autowired + private ApplicationContext context; + + /** + * Clds Identity databse DataSource configuration + */ + @Bean(name = "cldsDataSource") + @ConfigurationProperties(prefix = "spring.cldsdatasource") + public DataSource cldsDataSource() { + return DataSourceBuilder + .create() + .build(); + } + + @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 = "cldsDao") + public CldsDao getCldsDao() { + CldsDao cldsDao = new CldsDao(); + cldsDao.setDataSource(cldsDataSource()); + return cldsDao; + } + + @Bean(name = "cldsBpmnTransformer") + public XslTransformer getCldsBpmnXslTransformer() throws TransformerConfigurationException { + XslTransformer xslTransformer = new XslTransformer(); + xslTransformer.setXslResourceName("xsl/clds-bpmn-transformer.xsl"); + return xslTransformer; + } + + @Bean + public RefProp getRefProp() throws IOException { + return new RefProp(); + } + + @Bean + public PolicyClient getPolicyClient() { + return new PolicyClient(); + } + + @Bean(name = "cldsEventDelegate") + public CldsEventDelegate getCldsEventDelegate() { + return new CldsEventDelegate(); + } + + @Bean(name = "dcaeReqDelegate") + public DcaeReqDelegate getDcaeReqDelegate() { + return new DcaeReqDelegate(); + } + + @Bean(name = "sdcSendReqDelegate") + public SdcSendReqDelegate getSdcSendReqDelegate() { + return new SdcSendReqDelegate(); + } + + @Bean(name = "dcaeReqDeleteDelegate") + public DcaeReqDeleteDelegate getDcaeReqDeleteDelegate() { + return new DcaeReqDeleteDelegate(); + } + + @Bean(name = "operationalPolicyDelegate") + public OperationalPolicyDelegate getOperationalPolicyDelegate() { + return new OperationalPolicyDelegate(); + } + + @Bean(name = "operationalPolicyDeleteDelegate") + public OperationalPolicyDeleteDelegate getOperationalPolicyDeleteDelegate() { + return new OperationalPolicyDeleteDelegate(); + } + + @Bean(name = "stringMatchPolicyDelegate") + public StringMatchPolicyDelegate getStringMatchPolicyDelegate() { + return new StringMatchPolicyDelegate(); + } + + @Bean(name = "stringMatchPolicyDeleteDelegate") + public StringMatchPolicyDeleteDelegate getStringMatchPolicyDeleteDelegate() { + return new StringMatchPolicyDeleteDelegate(); + } + + @Bean(name = "sdcCatalogServices") + public SdcCatalogServices getAsdcCatalogServices() { + return new SdcCatalogServices(); + } +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java new file mode 100644 index 000000000..571ad4b40 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java @@ -0,0 +1,117 @@ +/*- + * ============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.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.LinkedList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +@Configuration +@EnableWebSecurity +public class CldsSecurityConfig extends WebSecurityConfigurerAdapter { + + private static final Logger logger = Logger.getLogger(CldsSecurityConfig.class.getName()); + + @Autowired + private ApplicationContext appContext; + + @Value("${org.onap.clamp.config.files.cldsUsers:'classpath:etc/config/clds/clds-users.properties'}") + private String cldsUsers; + + private final static String ROLEPREFIX = "null|null|"; + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .csrf().disable() + .authorizeRequests() + .anyRequest().authenticated() + .and() + .formLogin() + .loginPage("/login.html") + .permitAll() + .and() + .logout() + .permitAll(); + } + + @Autowired + public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { + List userList = loadUsers(); + + // no users defined + if (null == userList || userList.isEmpty()) { + logger.log(Level.SEVERE, "No users defined. Users should be defined under clds/clds-users.properties."); + return; + } + + for (String user : userList) { + String[] userInfo = user.split("[|]"); + if (userInfo.length != 3) { + logger.log(Level.SEVERE, "Defined User(" + user + ") is not in good format. User format should be:||. Role should be eiother 'read' or 'all'."); + continue; + } + + auth + .inMemoryAuthentication() + .withUser(userInfo[0]).password(userInfo[1]).roles(ROLEPREFIX + ("all".equalsIgnoreCase(userInfo[2]) ? "*" : userInfo[2])); + + } + } + + private boolean validUser(String[] userInfo) { + return ((userInfo != null) && (userInfo.length == 3) && (("all".equals(userInfo[2])) || ("read".equals(userInfo[2])))); + } + + private List loadUsers() throws Exception { + logger.info("Load from clds-users.properties"); + + Resource resource = appContext.getResource(cldsUsers); + BufferedReader input = new BufferedReader(new InputStreamReader(resource.getInputStream())); + + List userList = new LinkedList<>(); + + String line; + while ((line = input.readLine()) != null) { + if (!line.contains("#")) { + userList.add(line); + } + logger.info("line read:" + line); + } + return userList; + } +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java new file mode 100644 index 000000000..5c5ba5742 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java @@ -0,0 +1,48 @@ +/*- + * ============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.ajsc.csilogging.common.AsyncSupport; +import com.att.ajsc.csilogging.interceptors.CsiLoggingCamelPostInterceptor; +import com.att.ajsc.csilogging.interceptors.CsiLoggingCamelPreInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@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/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java new file mode 100644 index 000000000..67e4d1b84 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -0,0 +1,485 @@ +/*- + * ============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.dao; + +import org.onap.clamp.clds.model.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.dao.EmptyResultDataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; +import org.springframework.jdbc.core.namedparam.SqlParameterSource; +import org.springframework.jdbc.core.simple.SimpleJdbcCall; +import org.springframework.stereotype.Repository; + +import javax.sql.DataSource; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.sql.Blob; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Data Access for CLDS Model tables. + */ +@Repository("cldsDao") +public class CldsDao { + + private static final Logger logger = LoggerFactory.getLogger(CldsDao.class); + + private JdbcTemplate jdbcTemplateObject; + private SimpleJdbcCall procGetModel; + private SimpleJdbcCall procGetModelTemplate; + private SimpleJdbcCall procSetModel; + private SimpleJdbcCall procInsEvent; + private SimpleJdbcCall procUpdEvent; + private SimpleJdbcCall procSetTemplate; + private SimpleJdbcCall procGetTemplate; + private SimpleJdbcCall procDelAllModelInstances; + private SimpleJdbcCall procInsModelInstance; + private SimpleJdbcCall procDelModelInstance; + + /** + * Log message when instantiating + */ + public CldsDao() { + logger.info("CldsDao instantiating..."); + } + + /** + * When dataSource is provided, instantiate spring jdbc objects. + * + * @param dataSource + */ + public void setDataSource(DataSource dataSource) { + this.jdbcTemplateObject = new JdbcTemplate(dataSource); + this.procGetModel = new SimpleJdbcCall(dataSource).withProcedureName("get_model"); + this.procGetModelTemplate = new SimpleJdbcCall(dataSource).withProcedureName("get_model_template"); + this.procSetModel = new SimpleJdbcCall(dataSource).withProcedureName("set_model"); + this.procInsEvent = new SimpleJdbcCall(dataSource).withProcedureName("ins_event"); + this.procUpdEvent = new SimpleJdbcCall(dataSource).withProcedureName("upd_event"); + this.procGetTemplate = new SimpleJdbcCall(dataSource).withProcedureName("get_template"); + this.procSetTemplate = new SimpleJdbcCall(dataSource).withProcedureName("set_template"); + this.procInsModelInstance = new SimpleJdbcCall(dataSource).withProcedureName("ins_model_instance"); + this.procDelModelInstance = new SimpleJdbcCall(dataSource).withProcedureName("del_model_instance"); + this.procDelAllModelInstances = new SimpleJdbcCall(dataSource).withProcedureName("del_all_model_instances"); + } + + /** + * Get a model from the database given the model name. + * + * @param modelName + * @return model + */ + public CldsModel getModel(String modelName) { + return getModel(modelName, null); + } + + /** + * Get a model from the database given the controlNameUuid. + * + * @param controlNameUuid + * @return model + */ + public CldsModel getModelByUuid(String controlNameUuid) { + return getModel(null, controlNameUuid); + } + + /** + * Get a model from the database given the model name or a controlNameUuid. + * + * @param modelName + * @return model + */ + private CldsModel getModel(String modelName, String controlNameUuid) { + CldsModel model = new CldsModel(); + model.setName(modelName); + SqlParameterSource in = new MapSqlParameterSource() + .addValue("v_model_name", modelName) + .addValue("v_control_name_uuid", controlNameUuid); + Map out = logSqlExecution(procGetModel, in); + model.setControlNamePrefix((String) out.get("v_control_name_prefix")); + model.setControlNameUuid((String) out.get("v_control_name_uuid")); + model.setId((String) (out.get("v_model_id"))); + model.setTemplateId((String) (out.get("v_template_id"))); + model.setTemplateName((String) (out.get("v_template_name"))); + model.setBpmnId((String) (out.get("v_template_bpmn_id"))); + model.setBpmnUserid((String) out.get("v_template_bpmn_userid")); + model.setBpmnText((String) out.get("v_template_bpmn_text")); + model.setPropId((String) (out.get("v_model_prop_id"))); + model.setPropUserid((String) out.get("v_model_prop_userid")); + model.setPropText((String) out.get("v_model_prop_text")); + model.setImageId((String) (out.get("v_template_image_id"))); + model.setImageUserid((String) out.get("v_template_image_userid")); + model.setImageText((String) out.get("v_template_image_text")); + model.setDocId((String) (out.get("v_template_doc_id"))); + model.setDocUserid((String) out.get("v_template_doc_userid")); + model.setDocText((String) out.get("v_template_doc_text")); + model.setBlueprintText((String) out.get("v_model_blueprint_text")); + model.getEvent().setId((String) (out.get("v_event_id"))); + model.getEvent().setActionCd((String) out.get("v_action_cd")); + model.getEvent().setActionStateCd((String) out.get("v_action_state_cd")); + model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id")); + model.getEvent().setUserid((String) out.get("v_event_userid")); + return model; + } + + /** + * Get a model and template information from the database given the model name. + * + * @param modelName + * @return model + */ + public CldsModel getModelTemplate(String modelName) { + CldsModel model = new CldsModel(); + model.setName(modelName); + SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName); + Map out = logSqlExecution(procGetModelTemplate, in); + // todo : rationalize + model.setControlNamePrefix((String) out.get("v_control_name_prefix")); + model.setControlNameUuid((String) out.get("v_control_name_uuid")); + model.setId((String) (out.get("v_model_id"))); + model.setTemplateId((String) (out.get("v_template_id"))); + model.setTemplateName((String) (out.get("v_template_name"))); + model.setBpmnId((String) (out.get("v_template_bpmn_id"))); + model.setBpmnUserid((String) out.get("v_template_bpmn_userid")); + model.setBpmnText((String) out.get("v_template_bpmn_text")); + model.setPropId((String) (out.get("v_model_prop_id"))); + model.setPropUserid((String) out.get("v_model_prop_userid")); + model.setPropText((String) out.get("v_model_prop_text")); + model.setImageId((String) (out.get("v_template_image_id"))); + model.setImageUserid((String) out.get("v_template_image_userid")); + model.setImageText((String) out.get("v_template_image_text")); + model.setDocId((String) (out.get("v_template_doc_id"))); + model.setDocUserid((String) out.get("v_template_doc_userid")); + model.setDocText((String) out.get("v_template_doc_text")); + model.setBlueprintText((String) out.get("v_model_blueprint_text")); + model.getEvent().setId((String) (out.get("v_event_id"))); + model.getEvent().setActionCd((String) out.get("v_action_cd")); + model.getEvent().setActionStateCd((String) out.get("v_action_state_cd")); + model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id")); + model.getEvent().setUserid((String) out.get("v_event_userid")); + + Map modelResults = logSqlExecution(procGetModel, in); + Object modelResultObject = modelResults.get("#result-set-1"); + if (modelResultObject != null && modelResultObject instanceof ArrayList) { + List modelInstanceRs = (List) modelResultObject; + for (Object currModelInstance : modelInstanceRs) { + if (currModelInstance != null && currModelInstance instanceof HashMap) { + HashMap modelInstanceMap = (HashMap) currModelInstance; + CldsModelInstance modelInstance = new CldsModelInstance(); + modelInstance.setModelInstanceId(modelInstanceMap.get("model_instance_id")); + modelInstance.setVmName(modelInstanceMap.get("vm_name")); + modelInstance.setLocation(modelInstanceMap.get("location")); + model.getCldsModelInstanceList().add(modelInstance); + logger.info("value of currModel: {}", currModelInstance); + } + } + } + return model; + } + + /** + * Update model in the database using parameter values and return updated model object. + * + * @param model + * @param userid + * @return + */ + public CldsModel setModel(CldsModel model, String userid) { + SqlParameterSource in = new MapSqlParameterSource() + .addValue("v_model_name", model.getName()) + .addValue("v_template_id", model.getTemplateId()) + .addValue("v_userid", userid) + .addValue("v_model_prop_text", model.getPropText()) + .addValue("v_model_blueprint_text", model.getBlueprintText()) + .addValue("v_control_name_prefix", model.getControlNamePrefix()) + .addValue("v_control_name_uuid", model.getControlNameUuid()); + Map out = logSqlExecution(procSetModel, in); + model.setControlNamePrefix((String) out.get("v_control_name_prefix")); + model.setControlNameUuid((String) out.get("v_control_name_uuid")); + model.setId((String) (out.get("v_model_id"))); + model.setPropId((String) (out.get("v_model_prop_id"))); + model.setPropUserid((String) (out.get("v_model_prop_userid"))); + model.setBlueprintId((String) (out.get("v_model_blueprint_id"))); + model.setBlueprintUserid((String) out.get("v_model_blueprint_userid")); + model.getEvent().setId((String) (out.get("v_event_id"))); + model.getEvent().setActionCd((String) out.get("v_action_cd")); + model.getEvent().setActionStateCd((String) out.get("v_action_state_cd")); + model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id")); + model.getEvent().setUserid((String) out.get("v_event_userid")); + return model; + } + + /** + * Inserts new modelInstance in the database using parameter values and return updated model object. + * + * @param model + * @param modelInstancesList + * @return + */ + public void insModelInstance(CldsModel model, List modelInstancesList) { + // Delete all existing model instances for given controlNameUUID + logger.debug("deleting instances for: {}", model.getControlNameUuid()); + delAllModelInstances(model.getControlNameUuid()); + + if (modelInstancesList == null) { + logger.debug("modelInstancesList == null"); + } else { + for (CldsModelInstance currModelInstance : modelInstancesList) { + logger.debug("v_control_name_uuid={}", model.getControlNameUuid()); + logger.debug("v_vm_name={}", currModelInstance.getVmName()); + logger.debug("v_location={}", currModelInstance.getLocation()); + SqlParameterSource in = new MapSqlParameterSource() + .addValue("v_control_name_uuid", model.getControlNameUuid()) + .addValue("v_vm_name", currModelInstance.getVmName()) + .addValue("v_location", currModelInstance.getLocation()); + Map out = logSqlExecution(procInsModelInstance, in); + model.setId((String) (out.get("v_model_id"))); + CldsModelInstance modelInstance = new CldsModelInstance(); + modelInstance.setLocation(currModelInstance.getLocation()); + modelInstance.setVmName(currModelInstance.getVmName()); + modelInstance.setModelInstanceId((String) (out.get("v_model_instance_id"))); + model.getCldsModelInstanceList().add(modelInstance); + } + } + } + + /** + * Delete a list of modelInstance from the database using parameter values and returns updated model object. + * This method is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of + * deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that + * are still deployed with any not on the list considered undeployed. + * + * @param controlNameUUid + * @param modelInstancesList + * @return + */ + private CldsModel delModelInstance(String controlNameUUid, List modelInstancesList) { + CldsModel model = new CldsModel(); + for (CldsModelInstance currModelInstance : modelInstancesList) { + SqlParameterSource in = new MapSqlParameterSource() + .addValue("v_control_name_uuid", controlNameUUid) + .addValue("v_vm_name", currModelInstance.getVmName()); + Map out = logSqlExecution(procDelModelInstance, in); + model.setId((String) (out.get("v_model_id"))); + } + return model; + } + + /** + * Insert an event in the database - require either modelName or controlNamePrefix/controlNameUuid. + * @param modelName + * @param controlNamePrefix + * @param controlNameUuid + * @param cldsEvent + * @return + */ + public CldsEvent insEvent(String modelName, String controlNamePrefix, String controlNameUuid, CldsEvent cldsEvent) { + CldsEvent event = new CldsEvent(); + SqlParameterSource in = new MapSqlParameterSource() + .addValue("v_model_name", modelName) + .addValue("v_control_name_prefix", controlNamePrefix) + .addValue("v_control_name_uuid", controlNameUuid) + .addValue("v_userid", cldsEvent.getUserid()) + .addValue("v_action_cd", cldsEvent.getActionCd()) + .addValue("v_action_state_cd", cldsEvent.getActionStateCd()) + .addValue("v_process_instance_id", cldsEvent.getProcessInstanceId()); + Map out = logSqlExecution(procInsEvent, in); + event.setId((String) (out.get("v_event_id"))); + return event; + } + + /** + * Method to delete all model instances based on controlNameUUID + * + * @param controlNameUUid + * @return + */ + private String delAllModelInstances(String controlNameUUid) { + SqlParameterSource in = new MapSqlParameterSource() + .addValue("v_control_name_uuid", controlNameUUid); + Map out = logSqlExecution(procDelAllModelInstances, in); + return (String) (out.get("v_model_id")); + } + + /** + * Update event with process instance id. + * + * @param eventId + * @param processInstanceId + */ + public void updEvent(String eventId, String processInstanceId) { + SqlParameterSource in = new MapSqlParameterSource() + .addValue("v_event_id", eventId) + .addValue("v_process_instance_id", processInstanceId); + logSqlExecution(procUpdEvent, in); + } + + /** + * Generic mapper for list of values + */ + private static final class ValueItemMapper implements RowMapper { + public ValueItem mapRow(ResultSet rs, int rowNum) throws SQLException { + ValueItem item = new ValueItem(); + item.setValue(rs.getString(1)); + return item; + } + } + + /** + * Generic mapper for CldsDBServiceCache + */ + private static final class CldsServiceDataMapper implements RowMapper { + public CldsServiceData mapRow(ResultSet rs, int rowNum) throws SQLException { + CldsServiceData cldsServiceData = new CldsServiceData(); + long age; + age = rs.getLong(5); + Blob blob = rs.getBlob(4); + InputStream is = blob.getBinaryStream(); + ObjectInputStream oip; + try { + oip = new ObjectInputStream(is); + cldsServiceData = (CldsServiceData) oip.readObject(); + cldsServiceData.setAgeOfRecord(age); + } catch (IOException | ClassNotFoundException e) { + logger.error("Error caught while retrieving cldsServiceData from database"); + } + return cldsServiceData; + } + } + + /** + * Return list of model names + * + * @return model names + */ + public List getBpmnNames() { + String SQL = "SELECT model_name FROM model ORDER BY 1;"; + return jdbcTemplateObject.query(SQL, new ValueItemMapper()); + } + + /** + * Update template in the database using parameter values and return updated template object. + * + * @param template + * @param userid + * @return + */ + public CldsTemplate setTemplate(CldsTemplate template, String userid) { + SqlParameterSource in = new MapSqlParameterSource() + .addValue("v_template_name", template.getName()) + .addValue("v_userid", userid) + .addValue("v_template_bpmn_text", template.getBpmnText()) + .addValue("v_template_image_text", template.getImageText()) + .addValue("v_template_doc_text", template.getPropText()); + Map out = logSqlExecution(procSetTemplate, in); + template.setId((String) (out.get("v_template_id"))); + template.setBpmnUserid((String) (out.get("v_template_bpmn_userid"))); + template.setBpmnId((String) (out.get("v_template_bpmn_id"))); + template.setBpmnText((String) (out.get("v_template_bpmn_text"))); + template.setImageId((String) (out.get("v_template_image_id"))); + template.setImageUserid((String) out.get("v_template_image_userid")); + template.setImageText((String) out.get("v_template_image_text")); + template.setPropId((String) (out.get("v_template_doc_id"))); + template.setPropUserid((String) out.get("v_template_doc_userid")); + template.setPropText((String) out.get("v_template_doc_text")); + return template; + } + + /** + * Return list of template names + * + * @return template names + */ + public List getTemplateNames() { + String SQL = "SELECT template_name FROM template ORDER BY 1;"; + return jdbcTemplateObject.query(SQL, new ValueItemMapper()); + } + + /** + * Get a template from the database given the model name. + * + * @param templateName + * @return model + */ + public CldsTemplate getTemplate(String templateName) { + CldsTemplate template = new CldsTemplate(); + template.setName(templateName); + SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", templateName); + Map out = logSqlExecution(procGetTemplate, in); + template.setId((String) (out.get("v_template_id"))); + template.setBpmnUserid((String) (out.get("v_template_bpmn_userid"))); + template.setBpmnId((String) (out.get("v_template_bpmn_id"))); + template.setBpmnText((String) (out.get("v_template_bpmn_text"))); + template.setImageId((String) (out.get("v_template_image_id"))); + template.setImageUserid((String) out.get("v_template_image_userid")); + template.setImageText((String) out.get("v_template_image_text")); + template.setPropId((String) (out.get("v_template_doc_id"))); + template.setPropUserid((String) out.get("v_template_doc_userid")); + template.setPropText((String) out.get("v_template_doc_text")); + return template; + } + + public CldsServiceData getCldsServiceCache(String invariantUUID) throws SQLException, IOException, ClassNotFoundException { + CldsServiceData cldsServiceData = null; + List cldsServiceDataList = new ArrayList<>(); + try { + String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? "; + cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[]{invariantUUID}, new CldsServiceDataMapper()); + logger.info("value of cldsServiceDataList: {}", cldsServiceDataList); + } catch (EmptyResultDataAccessException e) { + logger.info("cache row not found for invariantUUID: {}", invariantUUID); + } + return cldsServiceData; + } + + public void setCldsServiceCache(CldsDBServiceCache cldsDBServiceCache) throws SQLException, IOException { + if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null && cldsDBServiceCache.getServiceId() != null) { + String invariantUUID = cldsDBServiceCache.getInvariantId(); + String serviceUUID = cldsDBServiceCache.getServiceId(); + InputStream is = cldsDBServiceCache.getCldsDataInstream(); + String insertCldsServiceCacheSQL = "INSERT INTO clds_service_cache" + + "(invariant_service_id,service_id,timestamp,object_data) VALUES" + + "(?,?,CURRENT_TIMESTAMP,?) ON DUPLICATE KEY UPDATE invariant_service_id = VALUES(invariant_service_id) , timestamp = CURRENT_TIMESTAMP , object_data = VALUES(object_data) "; + jdbcTemplateObject.update(insertCldsServiceCacheSQL, invariantUUID, serviceUUID, is); + } + } + + private static Map logSqlExecution(SimpleJdbcCall call, SqlParameterSource source) { + try { + return call.execute(source); + } catch (Exception e) { + logger.error("Exception occured in " + source.getClass().getCanonicalName() + ": " + e); + throw e; + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java b/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java new file mode 100644 index 000000000..41023acec --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java @@ -0,0 +1,40 @@ +/*- + * ============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.exception; + +import com.att.ajsc.common.AjscProvider; +import com.att.ajsc.common.exception.ServerErrorException; +import com.att.ajsc.common.exception.ServiceException; + +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +@AjscProvider +public class AjscExceptionMapper implements ExceptionMapper { + + @Override + public Response toResponse(final Exception exception) { + return exception instanceof ServiceException ? ((ServiceException) exception).toResponse() : new ServerErrorException(exception.getMessage()).toResponse(); + } +} diff --git a/src/main/java/org/onap/clamp/clds/jsf/JsfExampleBean.java b/src/main/java/org/onap/clamp/clds/jsf/JsfExampleBean.java new file mode 100644 index 000000000..5fdcedd96 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/jsf/JsfExampleBean.java @@ -0,0 +1,61 @@ +/*- + * ============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.jsf; + +import javax.faces.bean.ManagedBean; +import javax.faces.bean.SessionScoped; +import java.io.Serializable; +import java.util.Date; + +@ManagedBean +@SessionScoped +public class JsfExampleBean implements Serializable { + + private static final long serialVersionUID = 1L; + + private String value; + private Date dateValue; + + private static final java.text.SimpleDateFormat timestampFormat = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"); + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public Date getDateValue() { + return dateValue; + } + + public void setDateValue(Date dateValue) { + this.dateValue = dateValue; + } + + public String getDateValueText() { + return timestampFormat.format(dateValue); + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java new file mode 100644 index 000000000..032547836 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java @@ -0,0 +1,59 @@ +/*- + * ============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.model; + +import java.io.Serializable; + +public class CldsAlarmCondition implements Serializable { + + private static final long serialVersionUID = 1L; + private String eventSourceType; + private String alarmConditionKey; + private String severity; + + public String getEventSourceType() { + return eventSourceType; + } + + public void setEventSourceType(String eventSourceType) { + this.eventSourceType = eventSourceType; + } + + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public String getAlarmConditionKey() { + return alarmConditionKey; + } + + public void setAlarmConditionKey(String alarmConditionKey) { + this.alarmConditionKey = alarmConditionKey; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcArtifact.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcArtifact.java new file mode 100644 index 000000000..43d5ab6ae --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsAsdcArtifact.java @@ -0,0 +1,112 @@ +/*- + * ============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.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CldsAsdcArtifact { + + private String artifactName; + private String artifactType; + private String artifactURL; + private String artifactDescription; + private String artifactTimeout; + private String artifactChecksum; + private String artifactUUID; + private String artifactVersion; + private String generatedFromUUID; + + public String getArtifactName() { + return artifactName; + } + + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public String getArtifactType() { + return artifactType; + } + + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + public String getArtifactURL() { + return artifactURL; + } + + public void setArtifactURL(String artifactURL) { + this.artifactURL = artifactURL; + } + + public String getArtifactDescription() { + return artifactDescription; + } + + public void setArtifactDescription(String artifactDescription) { + this.artifactDescription = artifactDescription; + } + + public String getArtifactTimeout() { + return artifactTimeout; + } + + public void setArtifactTimeout(String artifactTimeout) { + this.artifactTimeout = artifactTimeout; + } + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public String getArtifactUUID() { + return artifactUUID; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUUID = artifactUUID; + } + + public String getArtifactVersion() { + return artifactVersion; + } + + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } + + public String getGeneratedFromUUID() { + return generatedFromUUID; + } + + public void setGeneratedFromUUID(String generatedFromUUID) { + this.generatedFromUUID = generatedFromUUID; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcResource.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcResource.java new file mode 100644 index 000000000..3210b696b --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsAsdcResource.java @@ -0,0 +1,131 @@ +/*- + * ============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.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.math.BigDecimal; +import java.util.List; +import java.util.logging.Logger; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CldsAsdcResource implements Comparable { + private static final Logger logger = Logger.getLogger(CldsAsdcServiceInfo.class.getName()); + + private String resourceInstanceName; + private String resourceName; + private String resourceInvariantUUID; + private String resourceVersion; + private String resoucreType; + private String resourceUUID; + private List artifacts; + + public String getResourceInstanceName() { + return resourceInstanceName; + } + + public void setResourceInstanceName(String resourceInstanceName) { + this.resourceInstanceName = resourceInstanceName; + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public String getResourceInvariantUUID() { + return resourceInvariantUUID; + } + + public void setResourceInvariantUUID(String resourceInvariantUUID) { + this.resourceInvariantUUID = resourceInvariantUUID; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public String getResoucreType() { + return resoucreType; + } + + public void setResoucreType(String resoucreType) { + this.resoucreType = resoucreType; + } + + public String getResourceUUID() { + return resourceUUID; + } + + public void setResourceUUID(String resourceUUID) { + this.resourceUUID = resourceUUID; + } + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } + + @Override + public int compareTo(CldsAsdcResource in) { + // Compares this object with the specified object for order. + // Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. + + // first compare based on name + int rtn = resourceInstanceName.compareToIgnoreCase(in.resourceInstanceName); + + if (rtn == 0) { + BigDecimal myVersion = convertVersion(resourceVersion); + BigDecimal inVersion = convertVersion(in.resourceVersion); + rtn = myVersion.compareTo(inVersion); + } + return rtn; + } + + /** + * Convert version String into a BigDecimal + * + * @param versionText + * @return + */ + private BigDecimal convertVersion(String versionText) { + BigDecimal rtn = new BigDecimal(0.0); + try { + rtn = new BigDecimal(versionText); + } catch (NumberFormatException nfe) { + logger.warning("ASDC version=" + versionText + " is not decimal for name=" + resourceInstanceName); + } + return rtn; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcResourceBasicInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcResourceBasicInfo.java new file mode 100644 index 000000000..c66428a68 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsAsdcResourceBasicInfo.java @@ -0,0 +1,160 @@ +/*- + * ============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.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.math.BigDecimal; +import java.util.logging.Logger; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CldsAsdcResourceBasicInfo implements Comparable { + private static final Logger logger = Logger.getLogger(CldsAsdcServiceInfo.class.getName()); + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String subCategory; + private String resourceType; + private String lifecycleState; + private String lastUpdaterUserId; + + @Override + public int compareTo(CldsAsdcResourceBasicInfo in) { + // Compares this object with the specified object for order. + // Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. + // first compare based on name + int rtn = name.compareToIgnoreCase(in.name); + + if (rtn == 0) { + BigDecimal myVersion = convertVersion(version); + BigDecimal inVersion = convertVersion(in.version); + rtn = myVersion.compareTo(inVersion); + } + return rtn; + } + + /** + * Convert version String into a BigDecimal + * + * @param version + * @return + */ + private BigDecimal convertVersion(String version) { + BigDecimal rtn = new BigDecimal(0.0); + try { + rtn = new BigDecimal(version); + } catch (NumberFormatException nfe) { + logger.warning("ASDC version=" + version + " is not decimal for name=" + name); + } + return rtn; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public Logger getLOGGER() { + return logger; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceDetail.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceDetail.java new file mode 100644 index 000000000..f50e09d5f --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceDetail.java @@ -0,0 +1,142 @@ +/*- + * ============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.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CldsAsdcServiceDetail { + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String lifecycleState; + private String lastUpdaterUserId; + private String distributionStatus; + private String lastUpdaterFullName; + private List resources; + private List artifacts; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getDistributionStatus() { + return distributionStatus; + } + + public void setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public List getResources() { + return resources; + } + + public void setResources(List resources) { + this.resources = resources; + } + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceInfo.java new file mode 100644 index 000000000..3ed575345 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceInfo.java @@ -0,0 +1,148 @@ +/*- + * ============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.model; + +import java.math.BigDecimal; +import java.util.logging.Logger; + +public class CldsAsdcServiceInfo implements Comparable { + private static final Logger logger = Logger.getLogger(CldsAsdcServiceInfo.class.getName()); + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String lifecycleState; + private String lastUpdaterUserId; + private String distributionStatus; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getDistributionStatus() { + return distributionStatus; + } + + public void setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + } + + /** + * Compare using name and then version. Version is converted to a decimal. + */ + @Override + public int compareTo(CldsAsdcServiceInfo in) { + // Compares this object with the specified object for order. + // Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. + // first compare based on name + int rtn = name.compareToIgnoreCase(in.name); + + if (rtn == 0) { + BigDecimal myVersion = convertVersion(version); + BigDecimal inVersion = convertVersion(in.version); + rtn = myVersion.compareTo(inVersion); + } + + return rtn; + } + + /** + * Convert version String into a BigDecimal + * + * @param versionText + * @return + */ + private BigDecimal convertVersion(String versionText) { + try { + return new BigDecimal(versionText); + } catch (NumberFormatException nfe) { + logger.warning("ASDC version=" + versionText + " is not decimal for name=" + name); + } + return new BigDecimal(0.0); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java b/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java new file mode 100644 index 000000000..658e21f96 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java @@ -0,0 +1,66 @@ +/*- + * ============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.model; + +import java.io.*; + +public class CldsDBServiceCache { + + private String invariantId; + private String serviceId; + private InputStream cldsDataInstream; + + public String getInvariantId() { + return invariantId; + } + + public void setInvariantId(String invariantId) { + this.invariantId = invariantId; + } + + public String getServiceId() { + return serviceId; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + public InputStream getCldsDataInstream() throws IOException { + return cldsDataInstream; + } + + public void setCldsDataInstream(CldsServiceData cldsServiceData) throws IOException { + this.cldsDataInstream = getInstreamFromObject(cldsServiceData); + } + + private InputStream getInstreamFromObject(CldsServiceData cldsServiceData) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(cldsServiceData); + oos.flush(); + oos.close(); + return new ByteArrayInputStream(baos.toByteArray()); + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java new file mode 100644 index 000000000..8379e5024 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java @@ -0,0 +1,183 @@ +/*- + * ============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.model; + +import org.onap.clamp.clds.dao.CldsDao; + +/** + * Represent a CLDS Event. + */ +public class CldsEvent { + public static final String ACTION_CREATE = "CREATE"; + public static final String ACTION_SUBMIT = "SUBMIT"; + public static final String ACTION_RESUBMIT = "RESUBMIT"; // an update before model is active + public static final String ACTION_DISTRIBUTE = "DISTRIBUTE"; // only from dcae + public static final String ACTION_DEPLOY = "DEPLOY"; // only from dcae + public static final String ACTION_UNDEPLOY = "UNDEPLOY"; // only from dcae + public static final String ACTION_UPDATE = "UPDATE"; + public static final String ACTION_DELETE = "DELETE"; + public static final String ACTION_STOP = "STOP"; + public static final String ACTION_RESTART = "RESTART"; + + public static final String ACTION_STATE_INITIATED = "INITIATED"; + public static final String ACTION_STATE_SENT = "SENT"; + public static final String ACTION_STATE_COMPLETED = "COMPLETED"; + public static final String ACTION_STATE_RECEIVED = "RECEIVED"; + public static final String ACTION_STATE_ERROR = "ERROR"; + public static final String ACTION_STATE_ANY = null; + + private String id; + private String actionCd; + private String actionStateCd; + private String processInstanceId; + private String userid; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * @param cldsDao + * @param controlName + * @param userid + * @param actionCd + * @param actionStateCd + * @param processInstanceId + * @return + */ + public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd, String actionStateCd, String processInstanceId) { + CldsModel model = CldsModel.createUsingControlName(controlName); + return insEvent(cldsDao, model, actionCd, actionStateCd, processInstanceId); + } + + /** + * Insert event using controlNameUuid to find the model. + * This method meant for processing events from dcae. + * @param cldsDao + * @param model + * @param actionCd + * @param actionStateCd + * @param processInstanceId + * @return + */ + public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String actionCd, String actionStateCd, String processInstanceId) { + CldsEvent event = new CldsEvent(); + event.setActionCd(actionCd); + event.setActionStateCd(actionStateCd); + event.setProcessInstanceId(processInstanceId); + cldsDao.insEvent(null, model.getControlNamePrefix(), model.getControlNameUuid(), event); + return event; + } + + /** + * Check if actionCd and actionStateCd are equal to the supplied checkActionCd and checkActionStateCd. + * Treat checkActionStateCd == null as a wildcard + * checkActionCd should not be null. + * + * @param checkActionCd + * @param checkActionStateCd + * @return + */ + public boolean isActionAndStateCd(String checkActionCd, String checkActionStateCd) { + if (actionCd == null) { + return false; + } + // treat checkActionStateCd == null as a wildcard (same for actionStateCd, although it shouln't be null...) + if (checkActionStateCd == null || actionStateCd == null) { + return actionCd.equals(checkActionCd); + } + return actionCd.equals(checkActionCd) && actionStateCd.equals(checkActionStateCd); + } + + /** + * Check if actionStateCd is equal to the supplied checkActionStateCd. + * checkActionCd should not be null. + * + * @param checkActionStateCd + * @return + */ + public boolean isActionStateCd(String checkActionStateCd) { + return !(checkActionStateCd == null || actionStateCd == null) && actionStateCd.equals(checkActionStateCd); + } + + /** + * @return the actionCd + */ + public String getActionCd() { + return actionCd; + } + + /** + * @param actionCd the actionCd to set + */ + public void setActionCd(String actionCd) { + this.actionCd = actionCd; + } + + /** + * @return the actionStateCd + */ + public String getActionStateCd() { + return actionStateCd; + } + + /** + * @param actionStateCd the actionStateCd to set + */ + public void setActionStateCd(String actionStateCd) { + this.actionStateCd = actionStateCd; + } + + /** + * @return the processInstanceId + */ + public String getProcessInstanceId() { + return processInstanceId; + } + + /** + * @param processInstanceId the processInstanceId to set + */ + public void setProcessInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + } + + /** + * @return the userid + */ + public String getUserid() { + return userid; + } + + /** + * @param userid the userid to set + */ + public void setUserid(String userid) { + this.userid = userid; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java new file mode 100644 index 000000000..4d4f3aab3 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java @@ -0,0 +1,570 @@ +/*- + * ============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.model; + +import org.onap.clamp.clds.dao.CldsDao; +import org.jboss.resteasy.spi.BadRequestException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.NotFoundException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Represent a CLDS Model. + */ +public class CldsModel { + private static final Logger logger = LoggerFactory.getLogger(CldsModel.class); + + private static final int UUID_LENGTH = 36; + + public static final String STATUS_DESIGN = "DESIGN"; + public static final String STATUS_DISTRIBUTED = "DISTRIBUTED"; + public static final String STATUS_ACTIVE = "ACTIVE"; + public static final String STATUS_STOPPED = "STOPPED"; + public static final String STATUS_DELETING = "DELETING"; + public static final String STATUS_ERROR = "ERROR"; // manual intervention required + public static final String STATUS_UNKNOWN = "UNKNOWN"; + + private String id; + private String templateId; + private String templateName; + private String name; + private String controlNamePrefix; + private String controlNameUuid; + private String bpmnId; + private String bpmnUserid; + private String bpmnText; + private String propId; + private String propUserid; + private String propText; + private String imageId; + private String imageUserid; + private String imageText; + private String docId; + private String docUserid; + private String docText; + private String blueprintId; + private String blueprintUserid; + private String blueprintText; + private CldsEvent event; + private String status; + private List permittedActionCd; + private List cldsModelInstanceList; + + /** + * Construct empty model. + */ + public CldsModel() { + event = new CldsEvent(); + } + + /** + * Retrieve from DB. + * + * @param cldsDao + * @param name + * @return + */ + public static CldsModel retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) { + // get from db + CldsModel model = cldsDao.getModelTemplate(name); + if (model.getId() == null && !okIfNotFound) { + throw new NotFoundException(); + } + model.determineStatus(); + model.determinePermittedActionCd(); + return model; + } + + /** + * Save model to DB. + * + * @param cldsDao + * @param userid + */ + public void save(CldsDao cldsDao, String userid) { + cldsDao.setModel(this, userid); + determineStatus(); + determinePermittedActionCd(); + } + + /** + * Insert a new event for the new action. + * Throw IllegalArgumentException if requested actionCd is not permitted. + * + * @param cldsDao + * @param userid + * @param actionCd + * @param actionStateCd + */ + public void insEvent(CldsDao cldsDao, String userid, String actionCd, String actionStateCd) { + validateAction(actionCd); + event = CldsEvent.insEvent(cldsDao, this, actionCd, actionStateCd, null); + determineStatus(); + determinePermittedActionCd(); + } + + /** + * Update event with processInstanceId + * + * @param cldsDao + * @param processInstanceId + */ + public void updEvent(CldsDao cldsDao, String processInstanceId) { + cldsDao.updEvent(event.getId(), processInstanceId); + } + + /** + * set the status in the model + */ + private void determineStatus() { + + status = STATUS_UNKNOWN; + if (event == null || event.getActionCd() == null) { + status = STATUS_DESIGN; + } else if (event.isActionStateCd(CldsEvent.ACTION_STATE_ERROR)) { + status = STATUS_ERROR; + } else if (event.isActionAndStateCd(CldsEvent.ACTION_CREATE, CldsEvent.ACTION_STATE_ANY) || + event.isActionAndStateCd(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_STATE_ANY) || + event.isActionAndStateCd(CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_STATE_ANY) || + event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_RECEIVED)) { + status = STATUS_DESIGN; + } else if (event.isActionAndStateCd(CldsEvent.ACTION_DISTRIBUTE, CldsEvent.ACTION_STATE_RECEIVED) || + event.isActionAndStateCd(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_STATE_RECEIVED)) { + status = STATUS_DISTRIBUTED; + } else if (event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_SENT)) { + status = STATUS_DELETING; + } else if (event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_RECEIVED) || + event.isActionAndStateCd(CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_ANY) || + event.isActionAndStateCd(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STATE_ANY)) { + status = STATUS_ACTIVE; + } else if (event.isActionAndStateCd(CldsEvent.ACTION_STOP, CldsEvent.ACTION_STATE_ANY)) { + status = STATUS_STOPPED; + } + + } + + /** + * Get the actionCd from current event. If none, default value is CldsEvent.ACTION_CREATE + * + * @return + */ + private String getCurrentActionCd() { + // current default actionCd is CREATE + String actionCd = CldsEvent.ACTION_CREATE; + if (event != null && event.getActionCd() != null) { + actionCd = event.getActionCd(); + } + return actionCd; + } + + /** + * Get the actionStateCd from current event. If none, default value is CldsEvent.ACTION_STATE_COMPLETED + * + * @return + */ + private String getCurrentActionStateCd() { + // current default actionStateCd is CREATE + String actionStateCd = CldsEvent.ACTION_STATE_COMPLETED; + if (event != null && event.getActionStateCd() != null) { + actionStateCd = event.getActionStateCd(); + } + return actionStateCd; + } + + /** + * Determine permittedActionCd list using the actionCd from the current event. + */ + private void determinePermittedActionCd() { + String actionCd = getCurrentActionCd(); + switch (actionCd) { + case CldsEvent.ACTION_CREATE: + permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMIT); + break; + case CldsEvent.ACTION_SUBMIT: + case CldsEvent.ACTION_RESUBMIT: + // for 1702 delete is not currently implemented (and resubmit requires manually deleting artifact from asdc + permittedActionCd = Arrays.asList(CldsEvent.ACTION_RESUBMIT); + break; + case CldsEvent.ACTION_DISTRIBUTE: + case CldsEvent.ACTION_UNDEPLOY: + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE); + break; + case CldsEvent.ACTION_DEPLOY: + case CldsEvent.ACTION_RESTART: + case CldsEvent.ACTION_UPDATE: + // for 1702 delete is not currently implemented + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP); + break; + case CldsEvent.ACTION_DELETE: + if (getCurrentActionStateCd().equals(CldsEvent.ACTION_STATE_SENT)) { + permittedActionCd = Arrays.asList(); + } else { + permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMIT); + } + break; + case CldsEvent.ACTION_STOP: + // for 1702 delete is not currently implemented + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART); + break; + default: + logger.warn("Invalid current actionCd: " + actionCd); + } + } + + /** + * Validate requestedActionCd - determine permittedActionCd and then check if contained in permittedActionCd + * Throw IllegalArgumentException if requested actionCd is not permitted. + * + * @param requestedActionCd + */ + public void validateAction(String requestedActionCd) { + determinePermittedActionCd(); + if (!permittedActionCd.contains(requestedActionCd)) { + throw new IllegalArgumentException("Invalid requestedActionCd: " + requestedActionCd + ". Given current actionCd: " + getCurrentActionCd() + ", the permittedActionCd: " + permittedActionCd); + } + } + + /** + * Extract the UUID portion of a given full control name (controlNamePrefix + controlNameUuid). + * No fields are populated other than controlNamePrefix and controlNameUuid. + * Throws BadRequestException if length of given control name is less than UUID_LENGTH. + * + * @param fullControlName + * @return + */ + public static CldsModel createUsingControlName(String fullControlName) { + + int len = 0; + + if (fullControlName != null) { + len = fullControlName.length(); + } + if (len < UUID_LENGTH) { + throw new BadRequestException("closed loop id / control name length, " + len + ", less than the minimum of: " + UUID_LENGTH); + } + CldsModel model = new CldsModel(); + model.setControlNamePrefix(fullControlName.substring(0, len - UUID_LENGTH)); + model.setControlNameUuid(fullControlName.substring(len - UUID_LENGTH)); + return model; + } + + /** + * @return the controlName (controlNamePrefix + controlNameUuid) + */ + public String getControlName() { + return controlNamePrefix + controlNameUuid; + } + + /** + * To insert modelInstance to the database + * + * @param cldsDao + * @param dcaeEvent + */ + public static CldsModel insertModelInstance(CldsDao cldsDao, DcaeEvent dcaeEvent, String userid) { + String controlName = dcaeEvent.getControlName(); + CldsModel cldsModel = createUsingControlName(controlName); + cldsModel = cldsDao.getModelByUuid(cldsModel.getControlNameUuid()); + cldsModel.determineStatus(); + if (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_UNDEPLOY) || + (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_DEPLOY) && (cldsModel.getStatus().equals(STATUS_DISTRIBUTED) || cldsModel.getStatus().equals(STATUS_DESIGN)))) { + CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), CldsEvent.ACTION_STATE_RECEIVED, null); + } + cldsDao.insModelInstance(cldsModel, dcaeEvent.getInstances()); + return cldsModel; + } + + /** + * To remove modelInstance from the database + * This method is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of + * deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that + * are still deployed with any not on the list considered undeployed. + * + * @param cldsDao + * @param dcaeEvent + */ + @SuppressWarnings("unused") + private static CldsModel removeModelInstance(CldsDao cldsDao, DcaeEvent dcaeEvent) { + String controlName = dcaeEvent.getControlName(); + //cldsModel = cldsDao.delModelInstance(cldsModel.getControlNameUuid(), dcaeEvent.getInstances() ); + return createUsingControlName(controlName); + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + /** + * @return the controlNamePrefix + */ + public String getControlNamePrefix() { + return controlNamePrefix; + } + + /** + * @param controlNamePrefix the controlNamePrefix to set + */ + public void setControlNamePrefix(String controlNamePrefix) { + this.controlNamePrefix = controlNamePrefix; + } + + /** + * @return the controlNameUuid + */ + public String getControlNameUuid() { + return controlNameUuid; + } + + /** + * @param controlNameUuid the controlNameUuid to set + */ + public void setControlNameUuid(String controlNameUuid) { + this.controlNameUuid = controlNameUuid; + } + + + /** + * @return the propUserid + */ + public String getPropUserid() { + return propUserid; + } + + /** + * @param propUserid the propUserid to set + */ + public void setPropUserid(String propUserid) { + this.propUserid = propUserid; + } + + /** + * @return the propText + */ + public String getPropText() { + return propText; + } + + /** + * @param propText the propText to set + */ + public void setPropText(String propText) { + this.propText = propText; + } + + /** + * @return the event + */ + public CldsEvent getEvent() { + return event; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTemplateName() { + return templateName; + } + + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + public String getPropId() { + return propId; + } + + public void setPropId(String propId) { + this.propId = propId; + } + + /** + * @param event the event to set + */ + public void setEvent(CldsEvent event) { + this.event = event; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @param status the status to set + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * @return the permittedActionCd + */ + public List getPermittedActionCd() { + return permittedActionCd; + } + + /** + * @param permittedActionCd the permittedActionCd to set + */ + public void setPermittedActionCd(List permittedActionCd) { + this.permittedActionCd = permittedActionCd; + } + + public String getBlueprintId() { + return blueprintId; + } + + public void setBlueprintId(String blueprintId) { + this.blueprintId = blueprintId; + } + + public String getBlueprintUserid() { + return blueprintUserid; + } + + public void setBlueprintUserid(String blueprintUserid) { + this.blueprintUserid = blueprintUserid; + } + + public String getBlueprintText() { + return blueprintText; + } + + public void setBlueprintText(String blueprintText) { + this.blueprintText = blueprintText; + } + + public String getBpmnId() { + return bpmnId; + } + + public void setBpmnId(String bpmnId) { + this.bpmnId = bpmnId; + } + + public String getBpmnUserid() { + return bpmnUserid; + } + + public void setBpmnUserid(String bpmnUserid) { + this.bpmnUserid = bpmnUserid; + } + + public String getBpmnText() { + return bpmnText; + } + + public void setBpmnText(String bpmnText) { + this.bpmnText = bpmnText; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public String getImageUserid() { + return imageUserid; + } + + public void setImageUserid(String imageUserid) { + this.imageUserid = imageUserid; + } + + public String getImageText() { + return imageText; + } + + public void setImageText(String imageText) { + this.imageText = imageText; + } + + public String getDocId() { + return docId; + } + + public void setDocId(String docId) { + this.docId = docId; + } + + public String getDocUserid() { + return docUserid; + } + + public void setDocUserid(String docUserid) { + this.docUserid = docUserid; + } + + public String getDocText() { + return docText; + } + + public void setDocText(String docText) { + this.docText = docText; + } + + public List getCldsModelInstanceList() { + if (cldsModelInstanceList == null) { + cldsModelInstanceList = new ArrayList<>(); + } + return cldsModelInstanceList; + } + + public void setCldsModelInstanceList(List cldsModelInstanceList) { + this.cldsModelInstanceList = cldsModelInstanceList; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java b/src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java new file mode 100644 index 000000000..4c16aadef --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java @@ -0,0 +1,59 @@ +/*- + * ============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.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CldsModelInstance { + + private String modelInstanceId; + private String location; + private String vmName; + + public String getVmName() { + return vmName; + } + + public void setVmName(String vmName) { + this.vmName = vmName; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getModelInstanceId() { + return modelInstanceId; + } + + public void setModelInstanceId(String modelInstanceId) { + this.modelInstanceId = modelInstanceId; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java new file mode 100644 index 000000000..89108393f --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java @@ -0,0 +1,112 @@ +/*- + * ============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.model; + +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.service.CldsService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.NotAuthorizedException; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class CldsServiceData implements Serializable { + private static final Logger logger = LoggerFactory.getLogger(CldsServiceData.class); + + private static final long serialVersionUID = 1L; + + private String serviceInvariantUUID; + private String serviceUUID; + private Long ageOfRecord; + private List cldsVfs; + + public String getServiceInvariantUUID() { + return serviceInvariantUUID; + } + + public void setServiceInvariantUUID(String serviceInvariantUUID) { + this.serviceInvariantUUID = serviceInvariantUUID; + } + + public List getCldsVfs() { + return cldsVfs; + } + + public void setCldsVfs(List cldsVfs) { + this.cldsVfs = cldsVfs; + } + + public String getServiceUUID() { + return serviceUUID; + } + + public void setServiceUUID(String serviceUUID) { + this.serviceUUID = serviceUUID; + } + + public CldsServiceData getCldsServiceCache(CldsDao cldsDao, String invariantServiceUUID) throws Exception { + return cldsDao.getCldsServiceCache(invariantServiceUUID); + } + + public void setCldsServiceCache(CldsDao cldsDao, CldsDBServiceCache cldsDBServiceCache) throws Exception { + cldsDao.setCldsServiceCache(cldsDBServiceCache); + } + + public Long getAgeOfRecord() { + return ageOfRecord; + } + + public void setAgeOfRecord(Long ageOfRecord) { + this.ageOfRecord = ageOfRecord; + } + + /** + * Filter out any VFs that the user is not authorized for. + * Use the CldsService to determine if the user is authorized for a VF. + * + * @param svc + */ + public void filterVfs(CldsService svc) { + List filteredCldsVfs = new ArrayList<>(); + if (cldsVfs == null) { + logger.debug("cldsVfs == null"); + } else { + for (CldsVfData vf : cldsVfs) { + // if user is authorized for the VF then add it to the filtered list + try { + if (svc.isAuthorizedForVf(vf.getVfInvariantResourceUUID())) { + filteredCldsVfs.add(vf); + } + } catch (NotAuthorizedException e) { + logger.debug("user not authorized for {}", vf.getVfInvariantResourceUUID()); + // when not NotAuthorizedException - don't add to filteredCldsVfs list + } + } + } + // new filtered list replaces the list of VFs for the user + cldsVfs = filteredCldsVfs; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java new file mode 100644 index 000000000..6e2c8d70d --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java @@ -0,0 +1,186 @@ +/*- + * ============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.model; + +import org.onap.clamp.clds.dao.CldsDao; + +import javax.ws.rs.NotFoundException; + +/** + * Represent a CLDS Model. + */ +public class CldsTemplate { + + public static final String STATUS_DESIGN = "DESIGN"; + public static final String STATUS_ACTIVE = "ACTIVE"; + public static final String STATUS_STOPPED = "STOPPED"; + public static final String STATUS_DELETING = "DELETING"; + public static final String STATUS_ERROR = "ERROR"; // manual intervention required + public static final String STATUS_UNKNOWN = "UNKNOWN"; + + private String id; + private String name; + private String controlNamePrefix; + private String controlNameUuid; + private String bpmnId; + private String bpmnUserid; + private String bpmnText; + private String imageId; + private String imageUserid; + private String imageText; + private String propId; + private String propUserid; + private String propText; + + /** + * Save template to DB. + * + * @param cldsDao + * @param userid + */ + public void save(CldsDao cldsDao, String userid) { + cldsDao.setTemplate(this, userid); + } + + /** + * Retrieve from DB. + * + * @param cldsDao + * @param name + * @return + */ + public static CldsTemplate retrieve(CldsDao cldsDao, String name, boolean okIfNotFound) { + // get from db + CldsTemplate template = cldsDao.getTemplate(name); + if (template.getId() == null && !okIfNotFound) { + throw new NotFoundException(); + } + return template; + } + + public String getBpmnUserid() { + return bpmnUserid; + } + + public void setBpmnUserid(String bpmnUserid) { + this.bpmnUserid = bpmnUserid; + } + + public String getBpmnText() { + return bpmnText; + } + + public void setBpmnText(String bpmnText) { + this.bpmnText = bpmnText; + } + + public String getImageUserid() { + return imageUserid; + } + + public void setImageUserid(String imageUserid) { + this.imageUserid = imageUserid; + } + + public String getImageText() { + return imageText; + } + + public void setImageText(String imageText) { + this.imageText = imageText; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getControlNamePrefix() { + return controlNamePrefix; + } + + public void setControlNamePrefix(String controlNamePrefix) { + this.controlNamePrefix = controlNamePrefix; + } + + public String getControlNameUuid() { + return controlNameUuid; + } + + public void setControlNameUuid(String controlNameUuid) { + this.controlNameUuid = controlNameUuid; + } + + public String getPropId() { + return propId; + } + + public void setPropId(String propId) { + this.propId = propId; + } + + public String getPropUserid() { + return propUserid; + } + + public void setPropUserid(String propUserid) { + this.propUserid = propUserid; + } + + public String getPropText() { + return propText; + } + + public void setPropText(String propText) { + this.propText = propText; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getBpmnId() { + return bpmnId; + } + + public void setBpmnId(String bpmnId) { + this.bpmnId = bpmnId; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfData.java new file mode 100644 index 000000000..dbcfb3464 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsVfData.java @@ -0,0 +1,61 @@ +/*- + * ============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.model; + +import java.io.Serializable; +import java.util.List; + +public class CldsVfData implements Serializable { + + private static final long serialVersionUID = 1L; + + private String vfName; + private String vfInvariantResourceUUID; + private List cldsVfcs; + + public String getVfName() { + return vfName; + } + + public void setVfName(String vfName) { + this.vfName = vfName; + } + + public List getCldsVfcs() { + return cldsVfcs; + } + + public void setCldsVfcs(List cldsVfcs) { + this.cldsVfcs = cldsVfcs; + } + + public String getVfInvariantResourceUUID() { + return vfInvariantResourceUUID; + } + + public void setVfInvariantResourceUUID(String vfInvariantResourceUUID) { + this.vfInvariantResourceUUID = vfInvariantResourceUUID; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java new file mode 100644 index 000000000..2d56d01f0 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java @@ -0,0 +1,61 @@ +/*- + * ============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.model; + +import java.io.Serializable; +import java.util.List; + +public class CldsVfcData implements Serializable { + + private static final long serialVersionUID = 1L; + + private String vfcName; + private String vfcInvariantResourceUUID; + private List cldsAlarmConditions; + + public String getVfcName() { + return vfcName; + } + + public void setVfcName(String vfcName) { + this.vfcName = vfcName; + } + + public List getCldsAlarmConditions() { + return cldsAlarmConditions; + } + + public void setCldsAlarmConditions(List cldsAlarmConditions) { + this.cldsAlarmConditions = cldsAlarmConditions; + } + + public String getVfcInvariantResourceUUID() { + return vfcInvariantResourceUUID; + } + + public void setVfcInvariantResourceUUID(String vfcInvariantResourceUUID) { + this.vfcInvariantResourceUUID = vfcInvariantResourceUUID; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java new file mode 100644 index 000000000..e10971e7d --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java @@ -0,0 +1,149 @@ +/*- + * ============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.model; + +import org.jboss.resteasy.spi.BadRequestException; + +import java.util.List; + +/** + * Represent a DCAE Event. + */ +public class DcaeEvent { + public static final String EVENT_CREATED = "created"; // this is an event we (clds) sends to dcae + public static final String EVENT_DISTRIBUTION = "distribution"; + public static final String EVENT_DEPLOYMENT = "deployment"; + public static final String EVENT_UNDEPLOYMENT = "undeployment"; + public static final String ARTIFACT_NAME_SUFFIX = ".yml"; + + private String event; + private String serviceUUID; + private String resourceUUID; + private String artifactName; // controlName.yml + private List instances; + + /** + * Transform a DCAE Event Action to a CldsEvent.actionCd + * + * @return + */ + public String getCldsActionCd() { + if (event == null || event.length() == 0) { + throw new BadRequestException("action null or empty"); + } else if (event.equals(EVENT_CREATED)) { + return CldsEvent.ACTION_CREATE; + } else if (event.equals(EVENT_DISTRIBUTION)) { + return CldsEvent.ACTION_DISTRIBUTE; + } else if (event.equals(EVENT_DEPLOYMENT) && + (instances == null || instances.size() == 0)) { + return CldsEvent.ACTION_UNDEPLOY; + } else if (event.equals(EVENT_DEPLOYMENT)) { + return CldsEvent.ACTION_DEPLOY; + // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of + // deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that + // are still deployed with any not on the list considered undeployed. + //} else if ( event.equals(EVENT_UNDEPLOYMENT) ) { + // return CldsEvent.ACTION_UNDEPLOY; + } + throw new BadRequestException("event value not valid: " + event); + } + + /** + * Derive the controlName from the artifactName. + * + * @return the controlName + */ + public String getControlName() { + if (artifactName != null && artifactName.endsWith(ARTIFACT_NAME_SUFFIX)) { + return artifactName.substring(0, artifactName.length() - ARTIFACT_NAME_SUFFIX.length()); + } else { + throw new BadRequestException("artifactName value not valid (expecting it to end with " + ARTIFACT_NAME_SUFFIX + "): " + artifactName); + } + } + + /** + * @return the event + */ + public String getEvent() { + return event; + } + + /** + * @param event the event to set + */ + public void setEvent(String event) { + this.event = event; + } + + /** + * @return the serviceUUID + */ + public String getServiceUUID() { + return serviceUUID; + } + + /** + * @param serviceUUID the serviceUUID to set + */ + public void setServiceUUID(String serviceUUID) { + this.serviceUUID = serviceUUID; + } + + /** + * @return the resourceUUID + */ + public String getResourceUUID() { + return resourceUUID; + } + + /** + * @param resourceUUID the resourceUUID to set + */ + public void setResourceUUID(String resourceUUID) { + this.resourceUUID = resourceUUID; + } + + /** + * @return the artifactName + */ + public String getArtifactName() { + return artifactName; + } + + /** + * @param artifactName the artifactName to set + */ + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public List getInstances() { + return instances; + } + + public void setInstances(List instances) { + this.instances = instances; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/HelloWorld.java b/src/main/java/org/onap/clamp/clds/model/HelloWorld.java new file mode 100644 index 000000000..1165f5da4 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/HelloWorld.java @@ -0,0 +1,50 @@ +/*- + * ============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.model; + +public class HelloWorld { + + private String message; + + public HelloWorld() { + // needed for deserializer + } + + public HelloWorld(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return "message = " + getMessage(); + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/ValueItem.java b/src/main/java/org/onap/clamp/clds/model/ValueItem.java new file mode 100644 index 000000000..804d18546 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/ValueItem.java @@ -0,0 +1,58 @@ +/*- + * ============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.model; + +/** + * ValueItem used for value lists. + */ +public class ValueItem { + private String value; + + /** + * Instantiate using value. + * + * @param value + */ + public ValueItem(String value) { + this.value = value; + } + + public ValueItem() { + } + + /** + * @return the value + */ + public String getValue() { + return value; + } + + /** + * @param value the value to set + */ + public void setValue(String value) { + this.value = value; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Collector.java b/src/main/java/org/onap/clamp/clds/model/prop/Collector.java new file mode 100644 index 000000000..84bc38f0c --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/Collector.java @@ -0,0 +1,47 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.logging.Logger; + +/** + * Parse Collector json properties. + */ +public class Collector extends ModelElement { + private static final Logger logger = Logger.getLogger(Collector.class.getName()); + + /** + * Parse Collector given json node. + * + * @param modelBpmn + * @param modelJson + */ + public Collector(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(TYPE_COLLECTOR, modelProp, modelBpmn, modelJson); + topicPublishes = getValueByName("topicPublishes"); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Global.java b/src/main/java/org/onap/clamp/clds/model/prop/Global.java new file mode 100644 index 000000000..f8986b361 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/Global.java @@ -0,0 +1,113 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.List; +import java.util.logging.Logger; + +/** + * Parse global json properties. + *

+ * Example json: "global":[{"name":"service","value":["vUSP"]},{"name":"vnf","value":["vCTS","v3CDB"]},{"name":"location","value":["san_diego","san_antonio","kansas_city","kings_mountain","Secaucus","lisle","concord","houston","akron"]}] + */ +public class Global { + private static final Logger logger = Logger.getLogger(Global.class.getName()); + + private String service; + private List resourceVf; + private List resourceVfc; + private List location; + + /** + * Parse global given json node. + * + * @param modelJson + */ + public Global(JsonNode modelJson) { + JsonNode globalNode = modelJson.get("global"); + service = ModelElement.getValueByName(globalNode, "service"); + resourceVf = ModelElement.getValuesByName(globalNode, "vf"); + resourceVfc = ModelElement.getValuesByName(globalNode, "vfc"); + location = ModelElement.getValuesByName(globalNode, "location"); + } + + /** + * @return the service + */ + public String getService() { + return service; + } + + /** + * @param service the service to set + */ + public void setService(String service) { + this.service = service; + } + + /** + * @return the resourceVf + */ + public List getResourceVf() { + return resourceVf; + } + + /** + * @param resourceVf the resourceVf to set + */ + public void setResourceVf(List resourceVf) { + this.resourceVf = resourceVf; + } + + /** + * @return the resourceVfc + */ + public List getResourceVfc() { + return resourceVfc; + } + + /** + * @param resourceVfc the resourceVfc to set + */ + public void setResourceVfc(List resourceVfc) { + this.resourceVfc = resourceVfc; + } + + /** + * @return the location + */ + public List getLocation() { + return location; + } + + /** + * @param location the location to set + */ + public void setLocation(List location) { + this.location = location; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java new file mode 100644 index 000000000..b4cc11dc2 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java @@ -0,0 +1,153 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.io.IOException; +import java.util.*; +import java.util.Map.Entry; +import java.util.logging.Logger; + +/** + * Parse Model BPMN properties. + *

+ * Example json: {"collector":[{"id":"Collector_11r50j1", "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"}],"policy":[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} + */ +public class ModelBpmn { + private static final Logger logger = Logger.getLogger(ModelBpmn.class.getName()); + + // for each type, an array of entries + private final Map> entriesByType = new HashMap<>(); + + // for each id, an array of entries + private final Map> entriesById = new HashMap<>(); + + // List of all elementIds + private List bpmnElementIds; + + /** + * Create ModelBpmn and populate maps from json + * + * @param modelBpmnPropText + * @return + * @throws IOException + * @throws JsonMappingException + * @throws JsonParseException + */ + public static ModelBpmn create(String modelBpmnPropText) throws IOException { + ModelBpmn modelBpmn = new ModelBpmn(); + ObjectMapper objectMapper = new ObjectMapper(); + ObjectNode root = objectMapper.readValue(modelBpmnPropText, ObjectNode.class); + // iterate over each entry like: "collector":[{"id":"Collector_11r50j1","from":"StartEvent_1"}] + Iterator> entryItr = root.fields(); + List bpmnElementIdList = new ArrayList<>(); + while (entryItr.hasNext()) { + // process the entry + Entry entry = entryItr.next(); + String type = entry.getKey(); + ArrayNode arrayNode = (ArrayNode) entry.getValue(); + // process each id/from object, like: {"id":"Collector_11r50j1","from":"StartEvent_1"} + for (JsonNode anArrayNode : arrayNode) { + ObjectNode node = (ObjectNode) anArrayNode; + String id = node.get("id").asText(); + String fromId = node.get("from").asText(); + ModelBpmnEntry modelBpmnEntry = new ModelBpmnEntry(type, id, fromId); + modelBpmn.addEntry(modelBpmnEntry); + bpmnElementIdList.add(id); + } + modelBpmn.setBpmnElementIds(bpmnElementIdList); + } + return modelBpmn; + } + + /** + * Add entry to both maps. + * + * @param entry + */ + private void addEntry(ModelBpmnEntry entry) { + addEntry(entriesByType, entry, entry.getType()); + addEntry(entriesById, entry, entry.getId()); + } + + /** + * Add an entry to provided map with provided key. + * + * @param map + * @param entry + * @param key + */ + private static void addEntry(Map> map, ModelBpmnEntry entry, String key) { + List list = map.computeIfAbsent(key, k -> new ArrayList<>()); + list.add(entry); + } + + /** + * + * + * @param type + * @return true if the element is found or false otherwise + */ + public boolean getModelElementFound(String type) { + return entriesByType.get(type) != null; + } + + /** + * @return the id field given the ModelElement type + */ + public String getId(String type) { + return entriesByType.get(type).get(0).getId(); + } + + /** + * @return the fromId field given the ModelElement type + */ + public String getFromId(String type) { + return entriesByType.get(type).get(0).getFromId(); + } + + /** + * @return the ModelElement type given the ModelElement id + */ + public String getType(String id) { + return entriesById.get(id).get(0).getType(); + } + + /** + * @return list of elementIds from bpmn + */ + public List getBpmnElementIds() { + return bpmnElementIds; + } + + public void setBpmnElementIds(List bpmnElementIds) { + this.bpmnElementIds = bpmnElementIds; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java new file mode 100644 index 000000000..8002f447f --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java @@ -0,0 +1,95 @@ +/*- + * ============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.model.prop; + +import java.util.logging.Logger; + +/** + * Model BPMN property entry + *

+ * Example json: {"collector":[{"id":"Collector_11r50j1", "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"],"policy":[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} + */ +public class ModelBpmnEntry { + private static final Logger logger = Logger.getLogger(ModelBpmnEntry.class.getName()); + + private String type; + private String id; + private String fromId; + + /** + * Parse the json so that the "id" and "from" fields can be retrieved on demand. + * + * @param type + * @param id + * @param fromId + */ + public ModelBpmnEntry(String type, String id, String fromId) { + this.type = type; + this.id = id; + this.fromId = fromId; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(String type) { + this.type = type; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the fromId + */ + public String getFromId() { + return fromId; + } + + /** + * @param fromId the fromId to set + */ + public void setFromId(String fromId) { + this.fromId = fromId; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java new file mode 100644 index 000000000..d8e903060 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java @@ -0,0 +1,232 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +/** + * Provide base ModelElement functionality. + */ +public abstract class ModelElement { + private final static Logger sLOGGER = Logger.getLogger(ModelElement.class.getName()); + private static final Logger logger = Logger.getLogger(ModelElement.class.getName()); + + public static final String TYPE_COLLECTOR = "collector"; + public static final String TYPE_STRING_MATCH = "stringMatch"; + public static final String TYPE_POLICY = "policy"; + public static final String TYPE_TCA = "tca"; + + private final String type; + private final ModelBpmn modelBpmn; + private final String id; + protected String topicPublishes; + protected final JsonNode meNode; + private boolean isFound; + + private final ModelProperties modelProp; + + /** + * Perform base parsing of properties for a ModelElement (such as, + * Collector, StringMatch, Policy and Tca) + * + * @param type + * @param modelProp + * @param modelBpmn + * @param modelJson + */ + protected ModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + this.type = type; + this.modelProp = modelProp; + this.modelBpmn = modelBpmn; + this.id = modelBpmn.getId(type); + this.meNode = modelJson.get(id); + this.isFound = modelBpmn.getModelElementFound(type); + } + + /** + * topicSubscribes is the topicPublishes of the from Model Element + * + * @return the topicSubscribes + */ + public String getTopicSubscribes() { + // get fromId for this type + String fromId = modelBpmn.getFromId(type); + // find the type of the from model element + String fromType = modelBpmn.getType(fromId); + // get the model element for the type + ModelElement me = modelProp.getModelElementByType(fromType); + // get the topic publishes for the model element + return me.topicPublishes; + } + + /** + * @return the topicPublishes + */ + public String getTopicPublishes() { + return topicPublishes; + } + + /** + * Return the value field of the json node element that has a name field + * equals to the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static String getValueByName(JsonNode nodeIn, String name) { + String value = null; + if (nodeIn != null) { + for (JsonNode node : nodeIn) { + if (node.path("name").asText().equals(name)) { + JsonNode vnode = node.path("value"); + if (vnode.isArray()) { + // if array, assume value is in first element + value = vnode.path(0).asText(); + } else { + // otherwise, just return text + value = vnode.asText(); + } + } + } + } + if (value == null || value.length() == 0) { + sLOGGER.warning(name + "=" + value); + } else { + sLOGGER.fine(name + "=" + value); + } + return value; + } + + /** + * Return the int value field of the json node element that has a name field + * equals to the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static Integer getIntValueByName(JsonNode nodeIn, String name) { + String value = getValueByName(nodeIn, name); + return Integer.valueOf(value); + } + + /** + * Return an array of values for the field of the json node element that has + * a name field equals to the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static List getValuesByName(JsonNode nodeIn, String name) { + List values = null; + if (nodeIn != null) { + Iterator i = nodeIn.iterator(); + while (i.hasNext()) { + JsonNode node = i.next(); + if (node.path("name").asText().equals(name)) { + values = getValuesList(node); + } + } + } + if (values == null || values.size() == 0) { + sLOGGER.warning(name + "=" + values); + } else { + sLOGGER.fine(name + "=" + values); + } + return values; + } + + /** + * Return an array of String values. + * + * @param nodeIn + * @return + */ + public static List getValuesList(JsonNode nodeIn) { + ArrayList al = new ArrayList<>(); + if (nodeIn != null) { + Iterator itr = nodeIn.path("value").elements(); + while (itr.hasNext()) { + JsonNode node = itr.next(); + al.add(node.asText()); + } + } + return al; + } + + /** + * Return the value field of the json node element that has a name field + * equals to the given name. + * + * @param name + * @return + */ + public String getValueByName(String name) { + return getValueByName(meNode, name); + } + + /** + * Return the int value field of the json node element that has a name field + * equals to the given name. + * + * @param name + * @return + */ + public Integer getIntValueByName(String name) { + return getIntValueByName(meNode, name); + } + + /** + * Return an array of values for the field of the json node element that has + * a name field equals to the given name. + * + * @param name + * @return + */ + public List getValuesByName(String name) { + return getValuesByName(meNode, name); + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the isFound + */ + public boolean isFound() { + return isFound; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java new file mode 100644 index 000000000..014b8c77e --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java @@ -0,0 +1,320 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.clamp.clds.model.CldsEvent; +import org.onap.clamp.clds.model.CldsModel; +import org.camunda.bpm.engine.delegate.DelegateExecution; + +import java.io.IOException; +import java.util.List; +import java.util.logging.Logger; + +/** + * Parse model properties. + */ +public class ModelProperties { + private static final Logger logger = Logger.getLogger(ModelProperties.class.getName()); + + private ModelBpmn modelBpmn; + private JsonNode modelJson; + + private final String modelName; + private final String controlName; + private final String actionCd; + + private Global global; + private Collector collector; + private StringMatch stringMatch; + private Policy policy; + private Tca tca; + + private String currentModelElementId; + private String policyUniqueId; + + /** + * Retain data required to parse the ModelElement objects. (Rather than + * parse them all - parse them on demand if requested.) + * + * @param modelName + * @param controlName + * @param actionCd + * @param modelBpmnPropText + * @param modelPropText + * @throws JsonProcessingException + * @throws IOException + */ + public ModelProperties(String modelName, String controlName, String actionCd, String modelBpmnPropText, String modelPropText) throws IOException { + this.modelName = modelName; + this.controlName = controlName; + this.actionCd = actionCd; + modelBpmn = ModelBpmn.create(modelBpmnPropText); + ObjectMapper mapper = new ObjectMapper(); + modelJson = mapper.readTree(modelPropText); + } + + /** + * Get the VF for a model. If return null if there is no VF. + * + * @param model + * @return + */ + public static String getVf(CldsModel model) { + List vfs = null; + try { + ObjectMapper mapper = new ObjectMapper(); + JsonNode modelJson = mapper.readTree(model.getPropText()); + Global global = new Global(modelJson); + vfs = global.getResourceVf(); + } catch (IOException e) { + // VF is null + } + String vf = null; + if (vfs != null && !vfs.isEmpty()) { + vf = vfs.get(0); + } + return vf; + } + + /** + * Create ModelProperties for Camunda Delegate. + * + * @param execution + * @return + * @throws JsonProcessingException + * @throws IOException + */ + public static ModelProperties create(DelegateExecution execution) throws IOException { + String modelProp = (String) execution.getVariable("modelProp"); + String modelBpmnProp = (String) execution.getVariable("modelBpmnProp"); + String modelName = (String) execution.getVariable("modelName"); + String controlName = (String) execution.getVariable("controlName"); + String actionCd = (String) execution.getVariable("actionCd"); + + return new ModelProperties(modelName, controlName, actionCd, modelBpmnProp, modelProp); + } + + /** + * return appropriate model element given the type + * + * @param type + * @return + */ + public ModelElement getModelElementByType(String type) { + ModelElement me; + switch (type) { + case ModelElement.TYPE_COLLECTOR: + me = getCollector(); + break; + case ModelElement.TYPE_STRING_MATCH: + me = getStringMatch(); + break; + case ModelElement.TYPE_POLICY: + me = getPolicy(); + break; + case ModelElement.TYPE_TCA: + me = getTca(); + break; + default: + throw new IllegalArgumentException("Invalid ModelElement type: " + type); + } + return me; + } + + /** + * @return the modelName + */ + public String getModelName() { + return modelName; + } + + /** + * @return the controlName + */ + public String getControlName() { + return controlName; + } + + /** + * @return the controlNameAndPolicyUniqueId + */ + public String getControlNameAndPolicyUniqueId() { + return controlName + "_" + policyUniqueId; + } + + /** + * @return the currentPolicyName + */ + private String getCurrentPolicyName() { + return normalizePolicyScopeName(controlName + "_" + currentModelElementId); + } + + /** + * @return the currentPolicyScopeAndPolicyName + */ + public String getCurrentPolicyScopeAndPolicyName() { + return normalizePolicyScopeName(modelName + "." + getCurrentPolicyName()); + } + + /** + * @return the currentPolicyScopeAndFullPolicyName + */ + public String getCurrentPolicyScopeAndFullPolicyName(String policyNamePrefix) { + return normalizePolicyScopeName(modelName + "." + policyNamePrefix + getCurrentPolicyName()); + } + + /** + * @return the currentPolicyScopeAndFullPolicyNameWithVersion + */ + public String getCurrentPolicyScopeAndFullPolicyNameWithVersion(String policyNamePrefix, int version) { + return normalizePolicyScopeName( + modelName + "." + policyNamePrefix + getCurrentPolicyName() + "." + version + ".xml"); + } + + /** + * Replace all '-' with '_' within policy scope and name. + * + * @param inName + * @return + */ + private String normalizePolicyScopeName(String inName) { + return inName.replaceAll("-", "_"); + } + + /** + * @return the currentModelElementId + */ + public String getCurrentModelElementId() { + return currentModelElementId; + } + + /** + * When generating a policy request for a model element, must set the id of + * that model element using this method. Used to generate the policy name. + * + * @param currentModelElementId + * the currentModelElementId to set + */ + public void setCurrentModelElementId(String currentModelElementId) { + this.currentModelElementId = currentModelElementId; + } + + /** + * @return the policyUniqueId + */ + public String getPolicyUniqueId() { + return policyUniqueId; + } + + /** + * When generating a policy request for a model element, must set the unique + * id of that policy using this method. Used to generate the policy name. + * + * @param policyUniqueId + * the policyUniqueId to set + */ + public void setPolicyUniqueId(String policyUniqueId) { + this.policyUniqueId = policyUniqueId; + } + + /** + * @return the collector + */ + public Collector getCollector() { + if (collector == null) { + collector = new Collector(this, modelBpmn, modelJson); + } + return collector; + } + + /** + * @return the actionCd + */ + public String getActionCd() { + return actionCd; + } + + /** + * @return the isCreateRequest + */ + public boolean isCreateRequest() { + switch (actionCd) { + case CldsEvent.ACTION_SUBMIT: + case CldsEvent.ACTION_RESTART: + return true; + } + return false; + } + + public boolean isStopRequest() { + switch (actionCd) { + case CldsEvent.ACTION_STOP: + return true; + } + return false; + } + + /** + * @return the global + */ + public Global getGlobal() { + if (global == null) { + global = new Global(modelJson); + } + return global; + } + + /** + * @return the stringMatch + */ + public StringMatch getStringMatch() { + if (stringMatch == null) { + stringMatch = new StringMatch(this, modelBpmn, modelJson); + } + return stringMatch; + } + + /** + * @return the policy + */ + public Policy getPolicy() { + if (policy == null) { + policy = new Policy(this, modelBpmn, modelJson); + } + return policy; + } + + /** + * @return the tca + */ + public Tca getTca() { + if (tca == null) { + tca = new Tca(this, modelBpmn, modelJson); + } + return tca; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java new file mode 100644 index 000000000..729eb4381 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java @@ -0,0 +1,78 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +/** + * Parse Policy json properties. + *

+ * Example json: "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]}],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":["vf3RtPi"]}]]}] + */ +public class Policy extends ModelElement { + private static final Logger logger = Logger.getLogger(Policy.class.getName()); + + private final Integer timeout; + private final List policyItems; + + /** + * Parse Policy given json node. + * + * @param modelProp + * @param modelBpmn + * @param modelJson + */ + public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(TYPE_POLICY, modelProp, modelBpmn, modelJson); + timeout = getIntValueByName(meNode.get(0), "timeout"); + + // process policies + JsonNode policyNode = meNode.get(1).get("policyConfigurations"); + Iterator itr = policyNode.elements(); + policyItems = new ArrayList<>(); + while (itr.hasNext()) { + policyItems.add(new PolicyItem(itr.next())); + } + } + + /** + * @return the timeout + */ + public Integer getTimeout() { + return timeout; + } + + /** + * @return the policyItems + */ + public List getPolicyItems() { + return policyItems; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java new file mode 100644 index 000000000..a943f1840 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java @@ -0,0 +1,103 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.List; +import java.util.logging.Logger; + +/** + * Parse policyConfigurations from Policy json properties. + *

+ * Example json: "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]}],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":["vf3RtPi"]}]]}] + */ +public class PolicyItem { + private static final Logger logger = Logger.getLogger(Policy.class.getName()); + + private final String id; + private final String recipe; + private final int maxRetries; + private final int retryTimeLimit; + private final String parentPolicy; + private final List parentPolicyConditions; + + /** + * Parse Policy given json node. + * + * @param node + */ + public PolicyItem(JsonNode node) { + id = ModelElement.getValueByName(node, "_id"); + recipe = ModelElement.getValueByName(node, "recipe"); + maxRetries = ModelElement.getIntValueByName(node, "maxRetries"); + retryTimeLimit = ModelElement.getIntValueByName(node, "retryTimeLimit"); + parentPolicy = ModelElement.getValueByName(node, "parentPolicy"); + parentPolicyConditions = ModelElement.getValuesByName(node, "parentPolicyConditions"); + + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the recipe + */ + public String getRecipe() { + return recipe; + } + + /** + * @return the maxRetries + */ + public int getMaxRetries() { + return maxRetries; + } + + /** + * @return the retryTimeLimit + */ + public int getRetryTimeLimit() { + return retryTimeLimit; + } + + /** + * @return the parentPolicy + */ + public String getParentPolicy() { + return parentPolicy; + } + + /** + * @return the parentPolicyConditions + */ + public List getParentPolicyConditions() { + return parentPolicyConditions; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java b/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java new file mode 100644 index 000000000..498f852e9 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java @@ -0,0 +1,156 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +/** + * Parse serviceConfigurations from StringMatch json properties. + *

+ * Example json: "StringMatch_0c2cy0c":[[{"name":"topicPublishes","value":"DCAE-CL-EVENT"}],{"serviceConfigurations":[[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VNFNAME","LOCID"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Initial"]},{"name":"outputEventName","value":["OnSet"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}],[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VMID","Identiy","VNFNAME"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Close"]},{"name":"outputEventName","value":["Abatement"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}]]}] + */ +public class ServiceConfiguration { + + private static final Logger logger = Logger.getLogger(ServiceConfiguration.class.getName()); + + private final List aaiMatchingFields; + private final List aaiSendFields; + private final String groupNumber; + private final List resourceVf; + private final List resourceVfc; + private final String timeWindow; + private final String ageLimit; + private final String createClosedLoopEventId; + private final String outputEventName; + private final Map stringSet; + + /** + * Parse serviceConfigurations given json node. + * + * @param node + */ + public ServiceConfiguration(JsonNode node) { + aaiMatchingFields = ModelElement.getValuesByName(node, "aaiMatchingFields"); + aaiSendFields = ModelElement.getValuesByName(node, "aaiSendFields"); + groupNumber = ModelElement.getValueByName(node, "groupNumber"); + resourceVf = ModelElement.getValuesByName(node, "vf"); + resourceVfc = ModelElement.getValuesByName(node, "vfc"); + timeWindow = ModelElement.getValueByName(node, "timeWindow"); + ageLimit = ModelElement.getValueByName(node, "ageLimit"); + createClosedLoopEventId = ModelElement.getValueByName(node, "createClosedLoopEventId"); + outputEventName = ModelElement.getValueByName(node, "outputEventName"); + + // process the stringSet fields + JsonNode ssNodes = node.findPath("stringSet"); + Iterator itr = ssNodes.elements(); + stringSet = new HashMap<>(); + while (itr.hasNext()) { + JsonNode ssNode = itr.next(); + String key = ssNode.path("name").asText(); + String value = ssNode.path("value").path(0).asText(); + if (key.length() != 0 && value.length() != 0) { + // only add string set field if not null + logger.fine("stringSet: " + key + "=" + value); + stringSet.put(key, value); + } + } + } + + /** + * @return the aaiMatchingFields + */ + public List getaaiMatchingFields() { + return aaiMatchingFields; + } + + /** + * @return the aaiSendFields + */ + public List getaaiSendFields() { + return aaiSendFields; + } + + /** + * @return the groupNumber + */ + public String getGroupNumber() { + return groupNumber; + } + + /** + * @return the resourceVf + */ + public List getResourceVf() { + return resourceVf; + } + + /** + * @return the resourceVfc + */ + public List getResourceVfc() { + return resourceVfc; + } + + /** + * @return the timeWindow + */ + public String getTimeWindow() { + return timeWindow; + } + + /** + * @return the ageLimit + */ + public String getAgeLimit() { + return ageLimit; + } + + /** + * @return the createClosedLoopEventId + */ + public String getCreateClosedLoopEventId() { + return createClosedLoopEventId; + } + + /** + * @return the outputEventName + */ + public String getOutputEventName() { + return outputEventName; + } + + /** + * @return the stringSet + */ + public Map getStringSet() { + return stringSet; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java new file mode 100644 index 000000000..d7092c4e6 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java @@ -0,0 +1,70 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +/** + * Parse StringMatch json properties. + *

+ * Example json: "StringMatch_0c2cy0c":[[{"name":"topicPublishes","value":"DCAE-CL-EVENT"}],{"serviceConfigurations":[[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VNFNAME","LOCID"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Initial"]},{"name":"outputEventName","value":["OnSet"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}],[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VMID","Identiy","VNFNAME"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Close"]},{"name":"outputEventName","value":["Abatement"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}]]}] + */ +public class StringMatch extends ModelElement { + private static final Logger logger = Logger.getLogger(StringMatch.class.getName()); + + private final List serviceConfigurations; + + /** + * Parse StringMatch given json node. + * + * @param modelBpmn + * @param modelJson + */ + public StringMatch(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(ModelElement.TYPE_STRING_MATCH, modelProp, modelBpmn, modelJson); + + topicPublishes = getValueByName(meNode.get(0), "topicPublishes"); + + // process Server_Configurations + JsonNode serviceConfigurationsNode = meNode.get(1).get("serviceConfigurations"); + Iterator itr = serviceConfigurationsNode.elements(); + serviceConfigurations = new ArrayList<>(); + while (itr.hasNext()) { + serviceConfigurations.add(new ServiceConfiguration(itr.next())); + } + } + + /** + * @return the serviceConfigurations + */ + public List getServiceConfigurations() { + return serviceConfigurations; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java new file mode 100644 index 000000000..c7b23608a --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java @@ -0,0 +1,47 @@ +package org.onap.clamp.clds.model.prop; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse Tca json properties. + * + * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}} + * + * + */ +public class Tca extends ModelElement { + + private static final Logger logger = Logger.getLogger(StringMatch.class.getName()); + + private List tcaItems; + + /** + * Parse Tca given json node + * + * @param modelProp + * @param modelBpmn + * @param modelJson + */ + public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(ModelElement.TYPE_TCA, modelProp, modelBpmn, modelJson); + + // process Server_Configurations + if(meNode != null){ + Iterator itr = meNode.elements(); + tcaItems = new ArrayList(); + while(itr.hasNext()) { + tcaItems.add(new TcaItem(itr.next())); + } + } + } + + public List getTcaItems() { + return tcaItems; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java b/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java new file mode 100644 index 000000000..5792c0574 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java @@ -0,0 +1,128 @@ +package org.onap.clamp.clds.model.prop; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse Tca Item json properties. + * + * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}} + * + * + */ +public class TcaItem { + + private static final Logger logger = Logger.getLogger(TcaItem.class.getName()); + + private String tcaName; + private String tcaUuId; + private String nfNamingCode; + private String tcaEnable; + private String policyId; + private Integer interval; + private String severity; + private Integer violations; + private List tcaThreshholds; + + /** + * Parse Tca Item given json node + * + * @param node + */ + public TcaItem(JsonNode node) { + + tcaName = ModelElement.getValueByName(node, "tname"); + tcaUuId = ModelElement.getValueByName(node, "tuuid"); + nfNamingCode = ModelElement.getValueByName(node, "tnfc"); + tcaEnable = ModelElement.getValueByName(node, "tcaEnab"); + policyId = ModelElement.getValueByName(node, "tcaPolId"); + if(ModelElement.getValueByName(node, "tcaInt") != null){ + interval = Integer.valueOf(ModelElement.getValueByName(node, "tcaInt")); + } + severity = ModelElement.getValueByName(node, "tcaSev"); + if(ModelElement.getValueByName(node, "tcaVio") != null){ + violations = Integer.valueOf(ModelElement.getValueByName(node, "tcaVio")); + } + + // process service Configurations + JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); + Iterator itr = serviceConfigurationsNode.elements(); + tcaThreshholds = new ArrayList(); + while(itr.hasNext()) { + tcaThreshholds.add(new TcaThreshhold(itr.next())); + } + } + + public String getTcaName() { + return tcaName; + } + + public void setTcaName(String tcaName) { + this.tcaName = tcaName; + } + + public String getTcaUuId() { + return tcaUuId; + } + + public void setTcaUuId(String tcaUuId) { + this.tcaUuId = tcaUuId; + } + + public String getNfNamingCode() { + return nfNamingCode; + } + + public void setNfNamingCode(String nfNamingCode) { + this.nfNamingCode = nfNamingCode; + } + + public String getTcaEnable() { + return tcaEnable; + } + + public void setTcaEnable(String tcaEnable) { + this.tcaEnable = tcaEnable; + } + + public String getPolicyId() { + return policyId; + } + + public void setPolicyId(String policyId) { + this.policyId = policyId; + } + + public Integer getInterval() { + return interval; + } + + public void setInterval(Integer interval) { + this.interval = interval; + } + + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public Integer getViolations() { + return violations; + } + + public void setViolations(Integer violations) { + this.violations = violations; + } + + public List getTcaThreshholds() { + return tcaThreshholds; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java b/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java new file mode 100644 index 000000000..47f2c6fd5 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java @@ -0,0 +1,76 @@ +package org.onap.clamp.clds.model.prop; + +import java.util.logging.Logger; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse Tca Threshhold json properties. + * + * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}} + * + * + */ +public class TcaThreshhold { + + private static final Logger logger = Logger.getLogger(TcaThreshhold.class.getName()); + + private String metric; + private String fieldPath; + private String operator; + private Integer threshhold; + + /** + * Parse Tca Threshhold given json node + * + * @param node + */ + public TcaThreshhold(JsonNode node) { + + if(node.get(0) != null){ + metric = node.get(0).asText(); + } + if(node.get(1) != null){ + operator = node.get(1).asText(); + } + if(node.get(2) != null){ + threshhold = Integer.valueOf(node.get(2).asText()); + } + if(node.get(3) != null){ + fieldPath = node.get(3).asText(); + } + } + + public String getMetric() { + return metric; + } + + public void setMetric(String metric) { + this.metric = metric; + } + + public String getFieldPath() { + return fieldPath; + } + + public void setFieldPath(String fieldPath) { + this.fieldPath = fieldPath; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public Integer getThreshhold() { + return threshhold; + } + + public void setThreshhold(Integer threshhold) { + this.threshhold = threshhold; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java b/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java new file mode 100644 index 000000000..c81b6a770 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java @@ -0,0 +1,139 @@ +/*- + * ============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.model.refprop; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; +import org.springframework.core.io.Resource; + +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.logging.Logger; + +/** + * Holds reference properties. + */ +public class RefProp { + private static final Logger logger = Logger.getLogger(RefProp.class.getName()); + + @Autowired + private ApplicationContext appContext; + + private Properties prop; + + @Value("${org.onap.clamp.config.files.cldsReference:'classpath:/clds/clds-reference.properties'}") + private String cldsReferenceValuesFile; + + /** + * Load reference properties via null constructor + * + * @throws IOException + */ + public RefProp() throws IOException { + } + + @PostConstruct + public void loadConfig () throws IOException { + prop = new Properties(); + Resource resource = appContext.getResource(cldsReferenceValuesFile); + prop.load(resource.getInputStream()); + } + + /** + * get property value + * + * @param key + * @return + */ + public String getStringValue(String key) { + return prop.getProperty(key); + } + + /** + * get property value for a combo key (key1 + "." + key2). If not found just use key1. + * + * @param key1 + * @param key2 + * @return + */ + public String getStringValue(String key1, String key2) { + String value = getStringValue(key1 + "." + key2); + if (value == null || value.length() == 0) { + value = getStringValue(key1); + } + return value; + } + + /** + * Return json as objects that can be updated + * + * @param key + * @return + * @throws IOException + */ + public JsonNode getJsonTemplate(String key) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(getStringValue(key), JsonNode.class); + } + + /** + * Return json as objects that can be updated. First try with combo key (key1 + "." + key2), otherwise default to just key1. + * + * @param key1 + * @param key2 + * @return + * @throws IOException + */ + public JsonNode getJsonTemplate(String key1, String key2) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(getStringValue(key1, key2), JsonNode.class); + } + + /** + * Get list of values for a property field containing json and a field/keyword within that json. + * + * @param fieldName + * @param value + * @return + * @throws IOException + */ + public List decodeToList(String fieldName, String value) throws IOException { + JsonNode decode = getJsonTemplate(fieldName); + Iterator itr = decode.path(value).elements(); + ArrayList al = new ArrayList<>(); + while (itr.hasNext()) { + JsonNode node = itr.next(); + al.add(node.asText()); + } + return al; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java new file mode 100644 index 000000000..a0aadccb5 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -0,0 +1,646 @@ +/*- + * ============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.service; + +import com.att.ajsc.common.AjscService; +import com.att.ajsc.filemonitor.AJSCPropertiesMap; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.onap.clamp.clds.client.SdcCatalogServices; +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.transform.XslTransformer; +import org.apache.commons.lang3.StringUtils; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.jboss.resteasy.spi.BadRequestException; +import org.onap.clamp.clds.model.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; +import org.springframework.core.io.Resource; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * Service to save and retrieve the CLDS model attributes. + */ +@AjscService +@Path("/clds") +public class CldsService extends SecureServiceBase { + + @Autowired + private ApplicationContext appContext; + + private static final Logger logger = LoggerFactory.getLogger(CldsService.class); + + @Value("${CLDS_PERMISSION_TYPE_CL:org.onap.clamp.clds.cl}") + private static String CLDS_PERMISSION_TYPE_CL; + + @Value("${CLDS_PERMISSION_TYPE_CL_MANAGE:org.onap.clamp.clds.cl.manage}") + private static String CLDS_PERMISSION_TYPE_CL_MANAGE; + + @Value("${CLDS_PERMISSION_TYPE_CL_EVENT:/META-INF/securityFilterRules.json}") + private static String CLDS_PERMISSION_TYPE_CL_EVENT; + + @Value("${CLDS_PERMISSION_TYPE_FILTER_VF:/META-INF/securityFilterRules.json}") + private static String CLDS_PERMISSION_TYPE_FILTER_VF; + + @Value("${CLDS_PERMISSION_INSTANCE:/META-INF/securityFilterRules.json}") + private static String CLDS_PERMISSION_INSTANCE; + + private static final SecureServicePermission PERMISSION_READ_CL = SecureServicePermission.create(CLDS_PERMISSION_TYPE_CL, CLDS_PERMISSION_INSTANCE, "read"); + + private static final SecureServicePermission PERMISSION_UPDATE_CL = SecureServicePermission.create(CLDS_PERMISSION_TYPE_CL, CLDS_PERMISSION_INSTANCE, "update"); + + @Value("${org.onap.clamp.config.files.globalClds:classpath:/clds/globalClds.properties}") + private String globalClds; + private Properties globalCldsProperties; + + @Autowired + private CldsDao cldsDao; + @Autowired + private RuntimeService runtimeService; + @Autowired + private XslTransformer cldsBpmnTransformer; + + @Autowired + private RefProp refProp; + + @Autowired + private SdcCatalogServices asdcCatalogServices; + // + + public CldsService() { + } + + public CldsService(RefProp refProp) { + this.refProp = refProp; + } + + /** + * REST service that retrieves BPMN for a CLDS model name from the database. + * This is subset of the json getModel. + * This is only expected to be used for testing purposes, not by the UI. + * + * @param modelName + * @return bpmn xml text - content of bpmn given name + */ + @GET + @Path("/model/bpmn/{modelName}") + @Produces(MediaType.TEXT_XML) + public String getBpmnXml(@PathParam("modelName") String modelName) { + isAuthorized(PERMISSION_READ_CL); + logger.info("GET bpmnText for modelName={}", modelName); + CldsModel model = CldsModel.retrieve(cldsDao, modelName, false); + return model.getBpmnText(); + } + + /** + * REST service that saves BPMN for a CLDS model by name in the database. + * This is subset of the json putModel. + * This is only expected to be used for testing purposes, not by the UI. + * + * @param modelName + */ + @PUT + @Path("/model/bpmn/{modelName}") + @Consumes(MediaType.TEXT_XML) + public String putBpmnXml(@PathParam("modelName") String modelName, String bpmnText) { + isAuthorized(PERMISSION_UPDATE_CL); + logger.info("PUT bpmnText for modelName={}", modelName); + logger.info("PUT bpmnText={}", bpmnText); + CldsModel cldsModel = CldsModel.retrieve(cldsDao, modelName, true); + cldsModel.setBpmnText(bpmnText); + cldsModel.save(cldsDao, getUserid()); + return "wrote bpmnText for modelName=" + modelName; + } + + /** + * REST service that retrieves image for a CLDS model name from the database. + * This is subset of the json getModel. + * This is only expected to be used for testing purposes, not by the UI. + * + * @param modelName + * @return image xml text - content of image given name + */ + @GET + @Path("/model/image/{modelName}") + @Produces(MediaType.TEXT_XML) + public String getImageXml(@PathParam("modelName") String modelName) { + isAuthorized(PERMISSION_READ_CL); + logger.info("GET imageText for modelName={}", modelName); + CldsModel model = CldsModel.retrieve(cldsDao, modelName, false); + return model.getImageText(); + } + + /** + * REST service that saves image for a CLDS model by name in the database. + * This is subset of the json putModel. + * This is only expected to be used for testing purposes, not by the UI. + * + * @param modelName + */ + @PUT + @Path("/model/image/{modelName}") + @Consumes(MediaType.TEXT_XML) + public String putImageXml(@PathParam("modelName") String modelName, String imageText) { + isAuthorized(PERMISSION_UPDATE_CL); + logger.info("PUT iamgeText for modelName={}", modelName); + logger.info("PUT imageText={}", imageText); + CldsModel cldsModel = CldsModel.retrieve(cldsDao, modelName, true); + cldsModel.setImageText(imageText); + cldsModel.save(cldsDao, getUserid()); + return "wrote imageText for modelName=" + modelName; + } + + /** + * REST service that retrieves a CLDS model by name from the database. + * + * @param modelName + * @return clds model - clds model for the given model name + * @throws NotAuthorizedException + */ + @GET + @Path("/model/{modelName}") + @Produces(MediaType.APPLICATION_JSON) + public CldsModel getModel(@PathParam("modelName") String modelName) throws NotAuthorizedException { + isAuthorized(PERMISSION_READ_CL); + logger.debug("GET model for modelName={}", modelName); + CldsModel cldsModel = CldsModel.retrieve(cldsDao, modelName, false); + isAuthorizedForVf(cldsModel); + return cldsModel; + } + + /** + * REST service that saves a CLDS model by name in the database. + * + * @param modelName + * @throws TransformerException + * @throws TransformerConfigurationException + */ + @PUT + @Path("/model/{modelName}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public CldsModel putModel(@PathParam("modelName") String modelName, CldsModel cldsModel) throws TransformerException { + isAuthorized(PERMISSION_UPDATE_CL); + isAuthorizedForVf(cldsModel); + logger.info("PUT model for modelName={}", modelName); + logger.info("PUT bpmnText={}", cldsModel.getBpmnText()); + logger.info("PUT propText={}", cldsModel.getPropText()); + logger.info("PUT imageText={}", cldsModel.getImageText()); + cldsModel.setName(modelName); + + if (cldsModel.getTemplateName() != null) { + CldsTemplate template = cldsDao.getTemplate(cldsModel.getTemplateName()); + if (template != null) { + cldsModel.setTemplateId(template.getId()); + cldsModel.setDocText(template.getPropText()); + cldsModel.setDocId(template.getPropId()); + } + } + cldsModel.save(cldsDao, getUserid()); + return cldsModel; + } + + /** + * REST service that retrieves a list of CLDS model names. + * + * @return model names in JSON + */ + @GET + @Path("/model-names") + @Produces(MediaType.APPLICATION_JSON) + public List getModelNames() { +// isAuthorized(PERMISSION_READ_CL); + logger.info("GET list of model names"); + return cldsDao.getBpmnNames(); + } + + /** + * REST service that saves and processes an action for a CLDS model by name. + * + * @param action + * @param modelName + * @param test + * @param model + * @return + * @throws TransformerConfigurationException + * @throws TransformerException + * @throws IOException + * @throws JsonProcessingException + * @throws NotAuthorizedException + */ + @PUT + @Path("/action/{action}/{modelName}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public CldsModel putModelAndProcessAction(@PathParam("action") String action, @PathParam("modelName") String modelName, @QueryParam("test") String test, CldsModel model) throws TransformerException, NotAuthorizedException, IOException { + String actionCd = action.toUpperCase(); + SecureServicePermission permisionManage = SecureServicePermission.create(CLDS_PERMISSION_TYPE_CL_MANAGE, CLDS_PERMISSION_INSTANCE, actionCd); + isAuthorized(permisionManage); + isAuthorizedForVf(model); + String userid = getUserid(); + String actionStateCd = CldsEvent.ACTION_STATE_INITIATED; + String processDefinitionKey = "clds-process-action-wf"; + + logger.info("PUT actionCd={}", actionCd); + logger.info("PUT actionStateCd={}", actionStateCd); + logger.info("PUT processDefinitionKey={}", processDefinitionKey); + logger.info("PUT modelName={}", modelName); + logger.info("PUT test={}", test); + logger.info("PUT bpmnText={}", model.getBpmnText()); + logger.info("PUT propText={}", model.getPropText()); + logger.info("PUT userid={}", userid); + + if (model.getTemplateName() != null) { + CldsTemplate template = cldsDao.getTemplate(model.getTemplateName()); + if (template != null) { + model.setTemplateId(template.getId()); + model.setDocText(template.getPropText()); + model.setDocId(template.getPropId()); + } + } + // save model to db + model.setName(modelName); + model.save(cldsDao, getUserid()); + + // get vars and format if necessary + String prop = model.getPropText(); + String bpmn = model.getBpmnText(); + String docText = model.getDocText(); + String controlName = model.getControlName(); + + String bpmnJson = cldsBpmnTransformer.doXslTransformToString(bpmn); + logger.info("PUT bpmnJson={}", bpmnJson); + + boolean isTest = false; + if (test != null && test.equalsIgnoreCase("true")) { + isTest = true; + } else { + // if action.test.override is true, then any action will be marked as test=true (even if incoming action request had test=false); otherwise, test flag will be unchanged on the action request + String actionTestOverride = refProp.getStringValue("action.test.override"); + if (actionTestOverride != null && actionTestOverride.equalsIgnoreCase("true")) { + logger.info("PUT actionTestOverride={}", actionTestOverride); + logger.info("PUT override test indicator and setting it to true"); + isTest = true; + } + } + logger.info("PUT isTest={}", isTest); + + + boolean isInsertTestEvent = false; + String insertTestEvent = refProp.getStringValue("action.insert.test.event"); + if (insertTestEvent != null && insertTestEvent.equalsIgnoreCase("true")) { + isInsertTestEvent = true; + } + logger.info("PUT isInsertTestEvent={}", isInsertTestEvent); + + + // determine if requested action is permitted + model.validateAction(actionCd); + + // input variables to camunda process + Map variables = new HashMap<>(); + variables.put("actionCd", actionCd); + variables.put("modelProp", prop); + variables.put("modelBpmnProp", bpmnJson); + variables.put("modelName", modelName); + variables.put("controlName", controlName); + variables.put("docText", docText); + variables.put("isTest", isTest); + variables.put("userid", userid); + variables.put("isInsertTestEvent", isInsertTestEvent); + + // start camunda process + ProcessInstance pi = runtimeService.startProcessInstanceByKey(processDefinitionKey, variables); + + // log process info + logger.info("Started processDefinitionId={}, processInstanceId={}", pi.getProcessDefinitionId(), pi.getProcessInstanceId()); + + // refresh model info from db (get fresh event info) + return CldsModel.retrieve(cldsDao, modelName, false); + } + + /** + * REST service that accepts events for a model. + * + * @param test + * @param dcaeEvent + * @throws BadRequestException + */ + @POST + @Path("/dcae/event") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public String postDcaeEvent(@QueryParam("test") String test, DcaeEvent dcaeEvent) throws BadRequestException { + String userid = null; + // TODO: allow auth checking to be turned off by removing the permission type property + if (CLDS_PERMISSION_TYPE_CL_EVENT != null && CLDS_PERMISSION_TYPE_CL_EVENT.length() > 0) { + SecureServicePermission permissionEvent = SecureServicePermission.create(CLDS_PERMISSION_TYPE_CL_EVENT, CLDS_PERMISSION_INSTANCE, dcaeEvent.getEvent()); + isAuthorized(permissionEvent); + userid = getUserid(); + } + + boolean isTest = false; + if (test != null && test.equalsIgnoreCase("true")) { + isTest = true; + } + + int instanceCount = 0; + if (dcaeEvent.getInstances() != null) { + instanceCount = dcaeEvent.getInstances().size(); + } + String msgInfo = "event=" + dcaeEvent.getEvent() + " serviceUUID=" + dcaeEvent.getServiceUUID() + " resourceUUID=" + dcaeEvent.getResourceUUID() + " artifactName=" + dcaeEvent.getArtifactName() + " instance count=" + instanceCount + " isTest=" + isTest; + logger.info("POST dcae event {}", msgInfo); + + if (isTest) { + logger.warn("Ignorning test event from DCAE"); + } else { + if (DcaeEvent.EVENT_DEPLOYMENT.equalsIgnoreCase(dcaeEvent.getEvent())) { + CldsModel.insertModelInstance(cldsDao, dcaeEvent, userid); + } else { + CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), CldsEvent.ACTION_STATE_RECEIVED, null); + } + // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of + // deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that + // are still deployed with any not on the list considered undeployed. + //else if(DcaeEvent.EVENT_UNDEPLOYMENT.equalsIgnoreCase(dcaeEvent.getEvent())) + //{ + // CldsModel.removeModelInstance(cldsDao, dcaeEvent); + //} + } + + return msgInfo; + } + + /** + * REST service that retrieves asdc services + * + * @throws Exception + */ + @GET + @Path("/asdc/services") + @Produces(MediaType.APPLICATION_JSON) + public String getAsdcServices() throws Exception { + String retStr; + try { + String responseStr = asdcCatalogServices.getAsdcServicesInformation(null); + retStr = createUiServiceFormatJson(responseStr); + } catch (Exception e) { + logger.info("{} {}", e.getClass().getName(), e.getMessage()); + throw e; + } + logger.info("value of asdcServices : {}", retStr); + return retStr; + } + + /** + * REST service that retrieves total properties required by UI + * + * @throws Exception + */ + @GET + @Path("/properties") + @Produces(MediaType.APPLICATION_JSON) + public String getAsdcProperties() throws Exception { + return createPropertiesObjectByUUID(getGlobalCldsString(), "{}"); + } + + /** + * REST service that retrieves total properties by using invariantUUID based on refresh and non refresh + * + * @throws Exception + */ + @GET + @Path("/properties/{serviceInvariantUUID}") + @Produces(MediaType.APPLICATION_JSON) + public String getAsdcPropertiesByServiceUUIDForRefresh(@PathParam("serviceInvariantUUID") String serviceInvariantUUID, @DefaultValue("false") @QueryParam("refresh") String refresh) throws Exception { + CldsServiceData cldsServiceData = new CldsServiceData(); + cldsServiceData.setServiceInvariantUUID(serviceInvariantUUID); + + boolean isCldsAsdcDataExpired = true; + // To getcldsService information from database cache using invariantUUID only when refresh = false + if (refresh != null && refresh.equalsIgnoreCase("false")) { + cldsServiceData = cldsServiceData.getCldsServiceCache(cldsDao, serviceInvariantUUID); + // If cldsService is available in database Cache , verify is data expired or not + if (cldsServiceData != null) { + isCldsAsdcDataExpired = asdcCatalogServices.isCldsAsdcCacheDataExpired(cldsServiceData); + } + } + // If user Requested for refresh or database cache expired , get all data from asdc api. + if ((refresh != null && refresh.equalsIgnoreCase("true")) || isCldsAsdcDataExpired) { + cldsServiceData = asdcCatalogServices.getCldsServiceDataWithAlarmConditions(serviceInvariantUUID); + CldsDBServiceCache cldsDBServiceCache = asdcCatalogServices.getCldsDBServiceCacheUsingCldsServiceData(cldsServiceData); + if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null && cldsDBServiceCache.getServiceId() != null) { + cldsServiceData.setCldsServiceCache(cldsDao, cldsDBServiceCache); + } + } + + // filter out VFs the user is not authorized for + cldsServiceData.filterVfs(this); + + // format retrieved data into properties json + return asdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData); + } + + /** + * Determine if the user is authorized for a particular VF by its invariant UUID. + * + * @param vfInvariantUuid + * @throws NotAuthorizedException + * @return + */ + public boolean isAuthorizedForVf(String vfInvariantUuid) throws NotAuthorizedException { + if (CLDS_PERMISSION_TYPE_FILTER_VF != null && CLDS_PERMISSION_TYPE_FILTER_VF.length() > 0) { + SecureServicePermission permission = SecureServicePermission.create(CLDS_PERMISSION_TYPE_FILTER_VF, CLDS_PERMISSION_INSTANCE, vfInvariantUuid); + return isAuthorized(permission); + } else { + // if CLDS_PERMISSION_TYPE_FILTER_VF property is not provided, then VF filtering is turned off + logger.warn("VF filtering turned off"); + return true; + } + } + + /** + * Determine if the user is authorized for a particular VF by its invariant UUID. + * If not authorized, then NotAuthorizedException is thrown. + * + * @param model + * @return + */ + private boolean isAuthorizedForVf(CldsModel model) throws NotAuthorizedException { + String vf = ModelProperties.getVf(model); + if (vf == null || vf.length() == 0) { + logger.info("VF not found in model"); + return true; + } else { + return isAuthorizedForVf(vf); + } + } + + private String createUiServiceFormatJson(String responseStr) throws IOException { + if (StringUtils.isBlank(responseStr)) { + return ""; + } + ObjectMapper objectMapper = new ObjectMapper(); + List rawList = objectMapper.readValue(responseStr, objectMapper.getTypeFactory().constructCollectionType(List.class, CldsAsdcServiceInfo.class)); + ObjectNode invariantIdServiceNode = objectMapper.createObjectNode(); + ObjectNode serviceNode = objectMapper.createObjectNode(); + logger.info("value of cldsserviceiNfolist: {}", rawList); + if (rawList != null && rawList.size() > 0) { + List cldsAsdcServiceInfoList = asdcCatalogServices.removeDuplicateServices(rawList); + + for (CldsAsdcServiceInfo currCldsAsdcServiceInfo : cldsAsdcServiceInfoList) { + if (currCldsAsdcServiceInfo != null) { + invariantIdServiceNode.put(currCldsAsdcServiceInfo.getInvariantUUID(), currCldsAsdcServiceInfo.getName()); + } + } + serviceNode.putPOJO("service", invariantIdServiceNode); + } + return serviceNode.toString(); + } + + private String createPropertiesObjectByUUID(String globalProps, String cldsResponseStr) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + CldsAsdcServiceDetail cldsAsdcServiceDetail = mapper.readValue(cldsResponseStr, CldsAsdcServiceDetail.class); + ObjectNode globalPropsJson = null; + if (cldsAsdcServiceDetail != null && cldsAsdcServiceDetail.getUuid() != null) { + /** + * to create json with vf, alarm and locations + */ + ObjectNode serviceObjectNode = createEmptyVfAlarmObject(mapper); + ObjectNode vfObjectNode = mapper.createObjectNode(); + + /** + * to create json with vf and vfresourceId + */ + createVfObjectNode(vfObjectNode, mapper, cldsAsdcServiceDetail.getResources()); + serviceObjectNode.putPOJO(cldsAsdcServiceDetail.getInvariantUUID(), vfObjectNode); + ObjectNode byServiceBasicObjetNode = mapper.createObjectNode(); + byServiceBasicObjetNode.putPOJO("byService", serviceObjectNode); + + /** + * to create json with VFC Node + */ + ObjectNode emptyvfcobjectNode = createByVFCObjectNode(mapper, cldsAsdcServiceDetail.getResources()); + byServiceBasicObjetNode.putPOJO("byVf", emptyvfcobjectNode); + globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); + globalPropsJson.putPOJO("shared", byServiceBasicObjetNode); + logger.info("valuie of objNode: {}", globalPropsJson); + } else { + /** + * to create json with total properties when no serviceUUID passed + */ + globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); + } + return globalPropsJson.toString(); + } + + private ObjectNode createEmptyVfAlarmObject(ObjectMapper mapper) { + ObjectNode emptyObjectNode = mapper.createObjectNode(); + emptyObjectNode.put("", ""); + ObjectNode vfObjectNode = mapper.createObjectNode(); + vfObjectNode.putPOJO("vf", emptyObjectNode); + vfObjectNode.putPOJO("location", emptyObjectNode); + vfObjectNode.putPOJO("alarmCondition", emptyObjectNode); + ObjectNode emptyServiceObjectNode = mapper.createObjectNode(); + emptyServiceObjectNode.putPOJO("", vfObjectNode); + return emptyServiceObjectNode; + } + + private void createVfObjectNode(ObjectNode vfObjectNode2, ObjectMapper mapper, List rawCldsAsdcResourceList) throws IOException { + ObjectNode vfNode = mapper.createObjectNode(); + vfNode.put("", ""); + + // To remove repeated resource instance name from resourceInstanceList + List cldsAsdcResourceList = asdcCatalogServices.removeDuplicateAsdcResourceInstances(rawCldsAsdcResourceList); + /** + * Creating vf resource node using cldsAsdcResource Object + */ + if (cldsAsdcResourceList != null && cldsAsdcResourceList.size() > 0) { + for (CldsAsdcResource cldsAsdcResource : cldsAsdcResourceList) { + if (cldsAsdcResource != null && cldsAsdcResource.getResoucreType() != null && cldsAsdcResource.getResoucreType().equalsIgnoreCase("VF")) { + vfNode.put(cldsAsdcResource.getResourceUUID(), cldsAsdcResource.getResourceName()); + } + } + } + vfObjectNode2.putPOJO("vf", vfNode); + String locationStringValue = refProp.getStringValue("ui.location.default"); + String alarmStringValue = refProp.getStringValue("ui.alarm.default"); + + /** + * creating location json object using properties file value + */ + ObjectNode locationJsonNode = (ObjectNode) mapper.readValue(locationStringValue, JsonNode.class); + vfObjectNode2.putPOJO("location", locationJsonNode); + + /** + * creating alarm json object using properties file value + */ + logger.info("value of alarm: {}", alarmStringValue); + ObjectNode alarmStringJsonNode = (ObjectNode) mapper.readValue(alarmStringValue, JsonNode.class); + vfObjectNode2.putPOJO("alarmCondition", alarmStringJsonNode); + } + + private ObjectNode createByVFCObjectNode(ObjectMapper mapper, List cldsAsdcResourceList) { + ObjectNode emptyObjectNode = mapper.createObjectNode(); + ObjectNode emptyvfcobjectNode = mapper.createObjectNode(); + ObjectNode vfCObjectNode = mapper.createObjectNode(); + vfCObjectNode.putPOJO("vfC", emptyObjectNode); + ObjectNode subVfCObjectNode = mapper.createObjectNode(); + subVfCObjectNode.putPOJO("vfc", emptyObjectNode); + if (cldsAsdcResourceList != null && cldsAsdcResourceList.size() > 0) { + for (CldsAsdcResource cldsAsdcResource : cldsAsdcResourceList) { + if (cldsAsdcResource != null && cldsAsdcResource.getResoucreType() != null && cldsAsdcResource.getResoucreType().equalsIgnoreCase("VF")) { + vfCObjectNode.putPOJO(cldsAsdcResource.getResourceUUID(), subVfCObjectNode); + } + } + } + emptyvfcobjectNode.putPOJO("", vfCObjectNode); + return emptyvfcobjectNode; + } + + private String getGlobalCldsString() throws Exception { + if (null == globalCldsProperties) { + globalCldsProperties = new Properties(); + globalCldsProperties.load(appContext.getResource(globalClds).getInputStream()); + } + return (String) globalCldsProperties.get("globalCldsProps"); + } +} diff --git a/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java b/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java new file mode 100644 index 000000000..0ffa955c4 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java @@ -0,0 +1,275 @@ +/*- + * ============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.service; + +import com.att.ajsc.common.AjscService; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.model.CldsTemplate; +import org.onap.clamp.clds.model.ValueItem; +import org.onap.clamp.clds.model.prop.ModelBpmn; +import org.onap.clamp.clds.transform.XslTransformer; +import org.camunda.bpm.engine.RuntimeService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.xml.transform.TransformerException; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * Service to save and retrieve the CLDS model attributes. + */ +@AjscService +@Path("/cldsTempate") +public class CldsTemplateService extends SecureServiceBase { + + private static final Logger logger = LoggerFactory.getLogger(CldsTemplateService.class); + + private static final String collectorKey = "Collector"; + private static final String stringMatchKey = "StringMatch"; + private static final String policyKey = "Policy"; + + private static final String CLDS_PERMISSION_TYPE_TEMPLATE = System.getProperty("CLDS_PERMISSION_TYPE_TEMPLATE"); + private static final String CLDS_PERMISSION_INSTANCE = System.getProperty("CLDS_PERMISSION_INSTANCE"); + + private static final SecureServicePermission PERMISSION_READ_TEMPLATE = SecureServicePermission.create(CLDS_PERMISSION_TYPE_TEMPLATE, CLDS_PERMISSION_INSTANCE, "read"); + private static final SecureServicePermission PERMISSION_UPDATE_TEMPLATE = SecureServicePermission.create(CLDS_PERMISSION_TYPE_TEMPLATE, CLDS_PERMISSION_INSTANCE, "update"); + + @Autowired + private CldsDao cldsDao; + @Autowired + private RuntimeService runtimeService; + @Autowired + private XslTransformer cldsBpmnTransformer; + + private static String userid; + + /** + * REST service that retrieves BPMN for a CLDS template name from the database. + * This is subset of the json getModel. + * This is only expected to be used for testing purposes, not by the UI. + * + * @param templateName + * @return bpmn xml text - content of bpmn given name + */ + @GET + @Path("/template/bpmn/{templateName}") + @Produces(MediaType.TEXT_XML) + public String getBpmnTemplate(@PathParam("templateName") String templateName) { + isAuthorized(PERMISSION_READ_TEMPLATE); + logger.info("GET bpmnText for templateName=" + templateName); + CldsTemplate template = CldsTemplate.retrieve(cldsDao, templateName, false); + return template.getBpmnText(); + } + + /** + * REST service that saves BPMN for a CLDS template by name in the database. + * This is subset of the json putModel. + * This is only expected to be used for testing purposes, not by the UI. + * + * @param templateName + * @param bpmnText + */ + @PUT + @Path("/template/bpmn/{templateName}") + @Consumes(MediaType.TEXT_XML) + public String putBpmnTemplateXml(@PathParam("templateName") String templateName, String bpmnText) { + isAuthorized(PERMISSION_UPDATE_TEMPLATE); + logger.info("PUT bpmnText for templateName=" + templateName); + logger.info("PUT bpmnText=" + bpmnText); + CldsTemplate cldsTemplate = CldsTemplate.retrieve(cldsDao, templateName, true); + cldsTemplate.setBpmnText(bpmnText); + cldsTemplate.save(cldsDao, userid); + return "wrote bpmnText for templateName=" + templateName; + } + + /** + * REST service that retrieves image for a CLDS template name from the database. + * This is subset of the json getModel. + * This is only expected to be used for testing purposes, not by the UI. + * + * @param templateName + * @return image xml text - content of image given name + */ + @GET + @Path("/template/image/{templateName}") + @Produces(MediaType.TEXT_XML) + public String getImageXml(@PathParam("templateName") String templateName) { + isAuthorized(PERMISSION_READ_TEMPLATE); + logger.info("GET imageText for templateName=" + templateName); + CldsTemplate template = CldsTemplate.retrieve(cldsDao, templateName, false); + return template.getImageText(); + } + + /** + * REST service that saves image for a CLDS template by name in the database. + * This is subset of the json putModel. + * This is only expected to be used for testing purposes, not by the UI. + * + * @param templateName + * @param imageText + */ + @PUT + @Path("/template/image/{templateName}") + @Consumes(MediaType.TEXT_XML) + public String putImageXml(@PathParam("templateName") String templateName, String imageText) { + isAuthorized(PERMISSION_UPDATE_TEMPLATE); + logger.info("PUT iamgeText for modelName=" + templateName); + logger.info("PUT imageText=" + imageText); + CldsTemplate cldsTemplate = CldsTemplate.retrieve(cldsDao, templateName, true); + cldsTemplate.setImageText(imageText); + cldsTemplate.save(cldsDao, userid); + return "wrote imageText for modelName=" + templateName; + } + + /** + * REST service that retrieves a CLDS template by name from the database. + * + * @param templateName + * @return clds template - clds template for the given template name + */ + @GET + @Path("/template/{templateName}") + @Produces(MediaType.APPLICATION_JSON) + public CldsTemplate getTemplate(@PathParam("templateName") String templateName) { + isAuthorized(PERMISSION_READ_TEMPLATE); + logger.info("GET model for templateName=" + templateName); + return CldsTemplate.retrieve(cldsDao, templateName, false); + } + + /** + * REST service that saves a CLDS template by name in the database. + * + * @param templateName + * @throws IOException + * @throws JsonMappingException + * @throws JsonParseException + */ + @PUT + @Path("/template/{templateName}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public CldsTemplate putTemplate(@PathParam("templateName") String templateName, CldsTemplate cldsTemplate) throws TransformerException, IOException { + isAuthorized(PERMISSION_UPDATE_TEMPLATE); + logger.info("PUT Template for templateName=" + templateName); + logger.info("PUT bpmnText=" + cldsTemplate.getBpmnText()); + logger.info("PUT propText=" + cldsTemplate.getPropText()); + logger.info("PUT imageText=" + cldsTemplate.getImageText()); + cldsTemplate.setName(templateName); + String bpmnText = cldsTemplate.getBpmnText(); + String imageText = cldsTemplate.getImageText(); + String propText = cldsTemplate.getPropText(); + Map newBpmnIdsMap = getNewBpmnIdsMap(bpmnText, cldsTemplate.getPropText()); + for (String currBpmnId : newBpmnIdsMap.keySet()) { + if (currBpmnId != null && newBpmnIdsMap.get(currBpmnId) != null) { + bpmnText = bpmnText.replace(currBpmnId, newBpmnIdsMap.get(currBpmnId)); + imageText = imageText.replace(currBpmnId, newBpmnIdsMap.get(currBpmnId)); + propText = propText.replace(currBpmnId, newBpmnIdsMap.get(currBpmnId)); + } + } + cldsTemplate.setBpmnText(bpmnText); + cldsTemplate.setImageText(imageText); + cldsTemplate.setPropText(propText); + logger.info(" bpmnText : " + cldsTemplate.getBpmnText()); + logger.info(" Image Text : " + cldsTemplate.getImageText()); + logger.info(" Prop Text : " + cldsTemplate.getPropText()); + cldsTemplate.save(cldsDao, userid); + return cldsTemplate; + } + + /** + * REST service that retrieves a list of CLDS template names. + * + * @return template names in JSON + */ + @GET + @Path("/template-names") + @Produces(MediaType.APPLICATION_JSON) + public List getTemplateNames() { + isAuthorized(PERMISSION_READ_TEMPLATE); + logger.info("GET list of template names"); + return cldsDao.getTemplateNames(); + } + + + private Map getNewBpmnIdsMap(String bpmnText, String propText) throws TransformerException, IOException { + /** + * Test sample code start + */ + String bpmnJson = cldsBpmnTransformer.doXslTransformToString(bpmnText); + ModelBpmn templateBpmn = ModelBpmn.create(bpmnJson); + List bpmnElementIds = templateBpmn.getBpmnElementIds(); + logger.info("value of elementIds:" + bpmnElementIds); + logger.info("value of prop text:" + propText); + Map bpmnIoIdsMap = new HashMap<>(); + if (bpmnElementIds != null && bpmnElementIds.size() > 0) { + ObjectMapper objectMapper = new ObjectMapper(); + ObjectNode root = objectMapper.readValue(propText, ObjectNode.class); + Iterator> entryItr = root.fields(); + while (entryItr.hasNext()) { + // process the entry + Entry entry = entryItr.next(); + String keyPropName = entry.getKey(); + for (String currElementId : bpmnElementIds) { + if (keyPropName != null && keyPropName.equalsIgnoreCase(currElementId)) { + ArrayNode arrayNode = (ArrayNode) entry.getValue(); + // process each id/from object, like: {"id":"Collector_11r50j1", "from":"StartEvent_1"} + for (JsonNode anArrayNode : arrayNode) { + ObjectNode node = (ObjectNode) anArrayNode; + String valueNode = node.get("value").asText(); + logger.info("value of node:" + valueNode); + if (keyPropName.startsWith(collectorKey)) { + valueNode = collectorKey + "_" + valueNode; + } else if (keyPropName.startsWith(stringMatchKey)) { + valueNode = stringMatchKey + "_" + valueNode; + } else if (keyPropName.startsWith(policyKey)) { + valueNode = policyKey + "_" + valueNode; + } + bpmnIoIdsMap.put(keyPropName, valueNode); + } + break; + } + } + } + } + logger.info("value of hashmap:" + bpmnIoIdsMap); + /** + * Test sample code end + */ + return bpmnIoIdsMap; + } +} diff --git a/src/main/java/org/onap/clamp/clds/service/LogService.java b/src/main/java/org/onap/clamp/clds/service/LogService.java new file mode 100644 index 000000000..1c3d9dc67 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/LogService.java @@ -0,0 +1,38 @@ +/*- + * ============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.service; + +public interface LogService { + + String logMessage(String logMessageText, String javamail, String springmail, String commonsmail); + + String postLogMessage(String histEventList); + + String createLogMessage(String startTime, String endTime, String serviceName); + + String createLogMessageUsingHistory(String procInstId, String histEventList); + + String CreateHistLog(String procInstId); + +} diff --git a/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java b/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java new file mode 100644 index 000000000..e7ee93a40 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java @@ -0,0 +1,276 @@ +/*- + * ============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.service; + +import com.att.ajsc.camunda.core.AttCamundaHistoryEvent; +import com.att.ajsc.camunda.core.AttCamundaService; +import com.att.ajsc.logging.AjscEelfManager; +import com.att.eelf.configuration.EELFLogger; +import com.google.gson.Gson; +import org.onap.clamp.clds.common.LogMessages; +import org.apache.commons.mail.Email; +import org.apache.commons.mail.SimpleEmail; +import org.apache.cxf.jaxrs.ext.MessageContext; +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.history.HistoricActivityInstance; +import org.camunda.bpm.engine.impl.history.event.HistoricActivityInstanceEventEntity; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.mail.MailException; +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.stereotype.Service; + +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import javax.ws.rs.core.Context; +import java.util.*; + +@Service +public class LogServiceImpl implements LogService { + private static final EELFLogger logger = AjscEelfManager.getInstance().getLogger(LogServiceImpl.class); + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private HistoryService historyService; + + @Context + private MessageContext context; + + public void setRuntimeService(RuntimeService runtimeService) { + this.runtimeService = runtimeService; + } + + public LogServiceImpl() { + // needed for instantiation + } + + @Override + public String logMessage(String logMessageText, String javamail, String springmail, String commonsmail) { + logger.info("Value of contexxt : " + context); + String convId = null; + if (context != null) { + convId = context.getHttpServletRequest().getHeader("X-CSI-ConversationId"); + if (convId == null) { + convId = (String) context.getHttpServletRequest().getAttribute("X-CSI-ConversationId"); + } + context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing"); + AttCamundaService.setHttpRequest(context.getHttpServletRequest()); + } + // input variables to example camunda process + Map variables = new HashMap<>(); + variables.put("logMessageText", logMessageText); + if (convId != null) { + variables.put("conversationId", convId); + } + + // BEGIN - added for send mail testing + // also added the following to the method signature: , @QueryParam("javamail") String javamail, @QueryParam("springmail") String springmail, @QueryParam("commonsmail") String commonsmail + // if javamail parameter provided, assume it contains an email address. + // use Java Mail to send an email from that address, to that address + if (javamail != null && javamail.length() > 0) { + variables.put("javamail", javamail); + try { + Properties props = new Properties(); + props.put("mail.smtp.host", "smtp.sbc.com"); // eMail.setHostName + Session session = Session.getInstance(props); + MimeMessage msg = new MimeMessage(session); + + msg.setFrom(new InternetAddress(javamail)); //eMail.setFrom + + InternetAddress[] fromAddresses = {new InternetAddress(javamail)}; + msg.setReplyTo(fromAddresses); //eMail.addReplyTo + msg.setSubject("test message using javax.mail"); //eMail.setSubject + msg.setText(logMessageText); // eMail.setMsg + + msg.addRecipient(Message.RecipientType.TO, new InternetAddress(javamail)); // eMail.addTo + Transport.send(msg); + } catch (MessagingException e) { + logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e); + } + } + + // if springmail parameter provided, assume it contains an email address. + // use Spring Mail to send an email from that address, to that address + if (springmail != null && springmail.length() > 0) { + variables.put("springmail", springmail); + JavaMailSenderImpl sender = new JavaMailSenderImpl(); + SimpleMailMessage smsg = new SimpleMailMessage(); + + try { + sender.setHost("smtp.sbc.com"); // eMail.setHostName + smsg.setFrom(springmail); //eMail.setFrom + smsg.setReplyTo(springmail); //eMail.addReplyTo + smsg.setSubject("test message using spring mail"); //eMail.setSubject + smsg.setText(logMessageText); // eMail.setMsg + smsg.setTo(springmail); // eMail.addTo + sender.send(smsg); + } catch (MailException e) { + logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e); + } + } + + // if commonsmail parameter provided, assume it contains an email address. + // use Apache Commons Mail to send an email from that address, to that address + if (commonsmail != null && commonsmail.length() > 0) { + variables.put("commonsmail", commonsmail); + Email eMail = new SimpleEmail(); + try { + eMail.setHostName("smtp.sbc.com"); + eMail.setFrom(commonsmail); + eMail.addReplyTo(commonsmail); + eMail.setSubject("test message using commons mail"); + eMail.setMsg(logMessageText); + eMail.addTo(commonsmail); + java.net.URL classUrl = this.getClass().getResource("com.sun.mail.util.TraceInputStream"); + if (classUrl != null) { + logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS, classUrl.getFile()); + } else { + logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS, classUrl.getFile()); + logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS_NULL); + } + eMail.send(); + } catch (Exception e) { + logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e); + } + } + // END - added for send mail testing + + // execute example camunda process, log-message-wf + ProcessInstance pi = runtimeService.startProcessInstanceByKey("log-message-wf", variables); + AttCamundaService.setHttpRequest(null); + // return text message of what was done + return "Started processDefinitionId=" + pi.getProcessDefinitionId() + ", processInstanceId=" + pi.getProcessInstanceId() + ", to log message: " + logMessageText; + } + + @Override + public String postLogMessage(String histEventList) { + String message = "no logs Created"; + logger.info("value of history events:" + histEventList); + Gson gson = new Gson(); + AttCamundaHistoryEvent attCamundaHistoryEvent = gson.fromJson(histEventList, AttCamundaHistoryEvent.class); + if (attCamundaHistoryEvent != null && attCamundaHistoryEvent.getProcInstId() != null) { + logger.info(LogMessages.PROCESS_INSTANCE_ID, attCamundaHistoryEvent.getProcInstId()); + if (context != null && context.getHttpServletRequest() != null && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { + context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing"); + List histActInstList = historyService.createHistoricActivityInstanceQuery().processInstanceId(attCamundaHistoryEvent.getProcInstId()).list(); + + if (histActInstList != null && histActInstList.size() > 0) { + for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) { + if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null && currHistoricActivityInstance.getStartTime() != null + && currHistoricActivityInstance.getEndTime() != null) { + logger.info("value of serviceTrack:" + currHistoricActivityInstance); + message = "Log Entry Created"; + logger.info(message); + } + } + } + if (attCamundaHistoryEvent.getHistoryEventList() != null && attCamundaHistoryEvent.getHistoryEventList().size() > 0) { + List historyEventList = attCamundaHistoryEvent.getHistoryEventList(); + for (HistoricActivityInstanceEventEntity actiEvent : historyEventList) { + // resolve null pointer exception if actiEvent.getActivityName() + message = "Log Entry Created"; + } + } + } + } + return message; + } + + @Override + public String createLogMessage(String startTime, String endTime, String serviceName) { + String message = "no logs Created"; + + if (context != null && context.getHttpServletRequest() != null && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { + context.getHttpServletRequest().setAttribute("X-CSI-ClientApp", "AJSC-CSI~sdsds"); + /*PerformanceTrackingBean trackingBean =(PerformanceTrackingBean) context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN"); + PerformanceTracking.addInvokeServiceTrack(trackingBean, + serviceName, Long.valueOf(startTime), Long.valueOf(endTime), "Completed", + 500, 1000) ;*/ + message = "Log Entry Created"; + } + // return text message of what was done + return message; + } + + @Override + public String createLogMessageUsingHistory(String procInstId, String histEventList) { + String message = "no logs Created"; + logger.info("value of history events:" + histEventList); + logger.info("value of events:" + histEventList + ":" + histEventList); + if (context != null && context.getHttpServletRequest() != null && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { + context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing"); + List histActInstList = historyService.createHistoricActivityInstanceQuery().processInstanceId(procInstId).list(); + + if (histActInstList != null && histActInstList.size() > 0) { + for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) { + if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null && currHistoricActivityInstance.getStartTime() != null + && currHistoricActivityInstance.getEndTime() != null) { + logger.info("value of serviceTrack:" + currHistoricActivityInstance); + message = "Log Entry Created"; + logger.info(message); + } + } + } + } + return message; + } + + @Override + public String CreateHistLog(String procInstId) { + String message = "no logs Created"; + if (context != null && context.getHttpServletRequest() != null && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { + List histActInstList = historyService.createHistoricActivityInstanceQuery().processInstanceId(procInstId).list(); + + if (histActInstList != null && histActInstList.size() > 0) { + for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) { + if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null && currHistoricActivityInstance.getStartTime() != null + && currHistoricActivityInstance.getEndTime() != null) { + logger.info("value of serviceTrack:" + currHistoricActivityInstance); + context.getHttpServletRequest().setAttribute("X-CSI-ClientApp", "AJSC-CSI~sdsds"); + message = "Log Entry Created"; + } + } + } + } + return message; + } + + private String getActivityInstanceState(int activityInstanceState) { + String activityState = "Default"; + if (activityInstanceState == 1) { + activityState = "Complete"; + } else if (activityInstanceState == 2) { + activityState = "Cancelled"; + } + return activityState; + } +} diff --git a/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java new file mode 100644 index 000000000..c17af97fa --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java @@ -0,0 +1,105 @@ +/*- + * ============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.service; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.NotAuthorizedException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.SecurityContext; +import java.security.Principal; + +/** + * Base/abstract Service class. + * Implements shared security methods. + */ +public abstract class SecureServiceBase { + private static final Logger logger = LoggerFactory.getLogger(SecureServiceBase.class); + + @Context + private SecurityContext securityContext; + + /** + * Get the userid + * + * @return + */ + public String getUserid() { + return getPrincipalName(); + } + + /** + * Get the principal name. + * + * @return + */ + public String getPrincipalName() { + Principal p = securityContext.getUserPrincipal(); + String name = "Not found"; + if (p != null) { + name = p.getName(); + } + logger.debug("userPrincipal.getName()={}", name); + return name; + } + + /** + * Check if user is authorized for the given the permission. + * Allow matches if user has a permission with an "*" in permission instance + * or permission action even if the permission to check has a specific value + * in those fields. For example: + * if the user has this permission: app-perm-type|*|* + * it will be authorized if the inPermission to check is: app-perm-type|dev|read + * + * @param inPermission + * @return + * @throws NotAuthorizedException + */ + public boolean isAuthorized(SecureServicePermission inPermission) throws NotAuthorizedException { + boolean authorized = false; + logger.debug("checking if {} has permission: {}", getPrincipalName(), inPermission); + // check if the user has the permission key or the permission key with a combination of all instance and/or all action. + if (securityContext.isUserInRole(inPermission.getKey())) { + logger.info("{} authorized for permission: {}", getPrincipalName(), inPermission.getKey()); + authorized = true; + // the rest of these don't seem to be required - isUserInRole method appears to take * as a wildcard + } else if (securityContext.isUserInRole(inPermission.getKeyAllInstance())) { + logger.info("{} authorized because user has permission with * for instance: {}", getPrincipalName(), inPermission.getKey()); + authorized = true; + } else if (securityContext.isUserInRole(inPermission.getKeyAllInstanceAction())) { + logger.info("{} authorized because user has permission with * for instance and * for action: {}", getPrincipalName(), inPermission.getKey()); + authorized = true; + } else if (securityContext.isUserInRole(inPermission.getKeyAllAction())) { + logger.info("{} authorized because user has permission with * for action: {}", getPrincipalName(), inPermission.getKey()); + authorized = true; + } else { + String msg = getPrincipalName() + " does not have permission: " + inPermission; + logger.warn(msg); + throw new NotAuthorizedException(msg); + } + return authorized; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/service/SecureServicePermission.java b/src/main/java/org/onap/clamp/clds/service/SecureServicePermission.java new file mode 100644 index 000000000..a2213f91a --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/SecureServicePermission.java @@ -0,0 +1,190 @@ +/*- + * ============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.service; + +/** + * Permission class that can be instantiated easily using constructor or factory methods. + */ +public class SecureServicePermission { + public final static String ALL = "*"; + + private String type; + private String instance; + private String action; + + /** + * Factory method to create permission given type, instance, and action. + * + * @param type + * @param instance + * @param action + * @return + */ + public static SecureServicePermission create(String type, String instance, String action) { + return new SecureServicePermission(type, instance, action); + } + + /** + * Factory method to create permission given type and instance. Default action to ALL/*. + * + * @param type + * @param instance + * @return + */ + public static SecureServicePermission create(String type, String instance) { + return new SecureServicePermission(type, instance); + } + + /** + * Factory method to create permission given type. Default instance and action to ALL/*. + * + * @param type + * @return + */ + public static SecureServicePermission create(String type) { + return new SecureServicePermission(type); + } + + /** + * Instantiate permission given type, instance, and action. + * + * @param type + * @param instance + * @param action + */ + public SecureServicePermission(String type, String instance, String action) { + this.type = type; + this.instance = instance; + this.action = action; + } + + /** + * Instantiate permission given type and instance. Default action to ALL/*. + * + * @param type + * @param instance + */ + public SecureServicePermission(String type, String instance) { + this.type = type; + this.instance = instance; + this.action = ALL; + } + + /** + * Instantiate permission given type. Default instance and action to ALL/*. + * + * @param type + */ + public SecureServicePermission(String type) { + this.type = type; + this.instance = ALL; + this.action = ALL; + } + + /** + * Override toString - return permission in key format + */ + public String toString() { + return getKey(); + } + + /** + * Return Permission in Key format = type, instance, and action separate by pipe character. + * + * @return + */ + public String getKey() { + return type + "|" + instance + "|" + action; + } + + /** + * Return Permission in Key format = type, all instance, and action separate by pipe character. + * + * @return + */ + public String getKeyAllInstance() { + return type + "|" + ALL + "|" + action; + } + + /** + * Return Permission in Key format = type, all instance, and all action separate by pipe character. + * + * @return + */ + public String getKeyAllInstanceAction() { + return type + "|" + ALL + "|" + ALL; + } + + /** + * Return Permission in Key format = type, instance, and all action separate by pipe character. + * + * @return + */ + public String getKeyAllAction() { + return type + "|" + instance + "|" + ALL; + } + + /** + * @return the type + */ + public String getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(String type) { + this.type = type; + } + + /** + * @return the instance + */ + public String getInstance() { + return instance; + } + + /** + * @param instance the instance to set + */ + public void setInstance(String instance) { + this.instance = instance; + } + + /** + * @return the action + */ + public String getAction() { + return action; + } + + /** + * @param action the action to set + */ + public void setAction(String action) { + this.action = action; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogService.java b/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogService.java new file mode 100644 index 000000000..d0ef13595 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogService.java @@ -0,0 +1,101 @@ +/*- + * ============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.service.rs; + +import io.swagger.annotations.Api; + +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; + + +/** + * Service to invoke example Camunda process. + *

+ * Try testing by using: + * http://[hostname]:[serverPort]/jaxrsservices/log/log-message/your-message-here + */ +@Api(value = "/log") +@Path("/log") +@Produces({MediaType.TEXT_PLAIN}) +public interface JaxrsLogService { + + /** + * REST service that executes example camunda process to log input message. + * + * @param logMessageText + * @return output from service - comment on what was done + */ + @GET + @Path("/log-message/{logMessageText}") + @Produces(MediaType.TEXT_PLAIN) + String logMessage(@PathParam("logMessageText") String logMessageText, @QueryParam("javamail") String javamail, @QueryParam("springmail") String springmail, @QueryParam("commonsmail") String commonsmail); + + /** + * REST service that executes example camunda process to log input message. + * + * @return output from service - comment on what was done + */ + @POST + @Path("/postLogHist") + @Produces(MediaType.TEXT_PLAIN) + @Consumes(MediaType.APPLICATION_JSON) + String postLogMessage(String histEventList); + + /** + * REST service that executes example camunda process to log input message. + * + * @param startTime + * @param endTime + * @param serviceName + * @return output from service - comment on what was done + */ + @GET + @Path("/createLog/{startTime}/{endTime}/{serviceName}") + @Produces(MediaType.TEXT_PLAIN) + String createLogMessage(@PathParam("startTime") String startTime, @PathParam("endTime") String endTime, @PathParam("serviceName") String serviceName); + + /** + * REST service that executes example camunda process to log input message. + * + * @param procInstId + * @param histEventList + * @return output from service - comment on what was done + */ + @GET + @Path("/createLogHist/{procInstId}/{histEventList}") + @Produces(MediaType.TEXT_PLAIN) + String createLogMessageUsingHistory(@PathParam("procInstId") String procInstId, @PathParam("histEventList") String histEventList); + + /** + * REST service that executes example camunda process to log input message. + * + * @param procInstId + * @return output from service - comment on what was done + */ + @GET + @Path("/histLog/{procInstId}") + @Produces(MediaType.TEXT_PLAIN) + String CreateHistLog(@PathParam("procInstId") String procInstId); + +} diff --git a/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogServiceImpl.java b/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogServiceImpl.java new file mode 100644 index 000000000..4ef7d2e9e --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogServiceImpl.java @@ -0,0 +1,94 @@ +/*- + * ============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.service.rs; + +import com.att.ajsc.common.AjscService; +import org.onap.clamp.clds.service.LogService; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Service to invoke example Camunda process. + *

+ * Try testing by using: + * http://[hostname]:[serverPort]/services/log/log-message/your-message-here + */ +@AjscService +public class JaxrsLogServiceImpl implements JaxrsLogService { + + @Autowired + private LogService logService; + + /** + * REST service that executes example camunda process to log input message. + * + * @param logMessageText + * @return output from service - comment on what was done + */ + public String logMessage(String logMessageText, String javamail, String springmail, String commonsmail) { + return logService.logMessage(logMessageText, javamail, springmail, commonsmail); + } + + /** + * REST service that executes example camunda process to log input message. + * + * @return output from service - comment on what was done + */ + public String postLogMessage(String histEventList) { + return logService.postLogMessage(histEventList); + } + + /** + * REST service that executes example camunda process to log input message. + * + * @param startTime + * @param endTime + * @param serviceName + * @return output from service - comment on what was done + */ + public String createLogMessage(String startTime, String endTime, String serviceName) { + return logService.createLogMessage(startTime, endTime, serviceName); + } + + /** + * REST service that executes example camunda process to log input message. + * + * @param procInstId + * @param histEventList + * @return output from service - comment on what was done + */ + public String createLogMessageUsingHistory(String procInstId, String histEventList) { + return logService.createLogMessageUsingHistory(procInstId, histEventList); + } + + /** + * REST service that executes example camunda process to log input message. + * + * @param procInstId + * @return output from service - comment on what was done + */ + public String CreateHistLog(String procInstId) { + return logService.CreateHistLog(procInstId); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java b/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java new file mode 100644 index 000000000..2c666db06 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java @@ -0,0 +1,66 @@ +/*- + * ============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.transform; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Utility methods supporting transforms. + */ +public class TransformUtil { + + /** + * Return resource as a Stream. + * + * @param name + * @return resource - resource as stream + */ + public static InputStream getResourceAsStream(String name) { + InputStream is = Thread.currentThread().getContextClassLoader() + .getResourceAsStream(name); + if (is == null) { + throw new IllegalArgumentException("Unable to find resource: " + + name); + } + return is; + } + + /** + * Return resource as a Stream. + * + * @param name + * @throws IOException + */ + public static String getResourceAsString(String name) throws IOException { + InputStream is = getResourceAsStream(name); + java.util.Scanner scanner = new java.util.Scanner(is); + java.util.Scanner s = scanner.useDelimiter("\\A"); + String text = s.hasNext() ? s.next() : ""; + s.close(); + scanner.close(); + is.close(); + return text; + } +} diff --git a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java new file mode 100644 index 000000000..7d0031604 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java @@ -0,0 +1,59 @@ +/*- + * ============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.transform; + +import javax.xml.transform.*; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import java.io.StringReader; +import java.io.StringWriter; + +/** + * XSL Transformer. + */ +public class XslTransformer { + + private Templates templates; + + public void setXslResourceName(String xslResourceName) throws TransformerConfigurationException { + TransformerFactory tfactory = TransformerFactory.newInstance(); + templates = tfactory.newTemplates(new StreamSource(TransformUtil.getResourceAsStream(xslResourceName))); + } + + /** + * Given xml input, return the transformed result. + * + * @param xml + * @throws TransformerException + */ + public String doXslTransformToString(String xml) throws TransformerException { + StringWriter output = new StringWriter(4000); + + Transformer transformer = templates.newTransformer(); + transformer.transform(new StreamSource(new StringReader(xml)), + new StreamResult(output)); + return output.toString(); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/workflow/LogMessageDelegate.java b/src/main/java/org/onap/clamp/clds/workflow/LogMessageDelegate.java new file mode 100644 index 000000000..693b334ee --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/workflow/LogMessageDelegate.java @@ -0,0 +1,46 @@ +/*- + * ============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.workflow; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; + +/** + * Log message. + * Invoked by the log-message-wf example Camunda workflow/bpmn. + */ +public class LogMessageDelegate implements JavaDelegate { + + /** + * Perform activity. Log message from running process and set a variable in the running process. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + String logMessageText = (String) execution.getVariable("logMessageText"); + + System.out.println("Invoked from processDefinitionId=" + execution.getProcessDefinitionId() + ", processInstanceId=" + execution.getProcessInstanceId() + ", activityInstanceId=" + execution.getActivityInstanceId() + ": logMessageText=" + logMessageText); + execution.setVariable("isMessageLogComplete", true); + } +} diff --git a/src/main/java/org/onap/clamp/clds/workflow/ProcessRequestDelegate.java b/src/main/java/org/onap/clamp/clds/workflow/ProcessRequestDelegate.java new file mode 100644 index 000000000..324496422 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/workflow/ProcessRequestDelegate.java @@ -0,0 +1,57 @@ +/*- + * ============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. + */ + +/* 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. + */ +package org.onap.clamp.clds.workflow; + + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + + +@Component +public class ProcessRequestDelegate implements JavaDelegate { + + private static final Logger logger = LoggerFactory.getLogger(ProcessRequestDelegate.class); + + //@Override + public void execute(DelegateExecution execution) throws Exception { + logger.info("Processing request by '" + execution.getVariable("customerId") + "'..."); + logger.info("Processing request by '" + execution.getVariable("amount") + "'..."); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/workflow/RestMessageDelegate.java b/src/main/java/org/onap/clamp/clds/workflow/RestMessageDelegate.java new file mode 100644 index 000000000..0eda2decc --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/workflow/RestMessageDelegate.java @@ -0,0 +1,59 @@ +/*- + * ============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.workflow; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Logger; + +/** + * Log message. + * Invoked by the log-message-wf example Camunda workflow/bpmn. + */ +public class RestMessageDelegate implements JavaDelegate { + private static final Logger logger = Logger.getLogger(RestMessageDelegate.class.getName()); + + /** + * Perform activity. Log message from running process and set a variable in the running process. + * + * @param execution + */ + public void execute(DelegateExecution execution) throws Exception { + String logMessageText = (String) execution.getVariable("logMessageText"); + RestTemplate restTemplate = new RestTemplate(); + Map restValues = new HashMap<>(); + restValues.put("procInstId", execution.getProcessInstanceId()); + logger.info("Invoked from processDefinitionId=" + execution.getProcessDefinitionId() + ", processInstanceId=" + execution.getProcessInstanceId() + ", activityInstanceId=" + execution.getActivityInstanceId() + ": logMessageText=" + logMessageText); + // TODO: this should be fixed - put in temporary solution with existing sysprop and vars - why are we calling our own service? + String port = System.getProperty("server.port"); + ResponseEntity resp = restTemplate.getForEntity("http://localhost:" + port + "/services/CamundaExample/v1/jaxrsExample/log/histLog/{procInstId}", String.class, restValues); + logger.info("value of resp:" + resp); + execution.setVariable("isMessageLogComplete", true); + } +} -- cgit 1.2.3-korg From 1736336840125ff2c1aef00c7d55b1471e380cb7 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Tue, 1 Aug 2017 11:07:43 -0400 Subject: [CLAMP-26] upgrade org.onap.policy Change-Id: I893db1b973f09174adec85e452b1488e900bea00 Signed-off-by: Pamela Dragosh --- pom.xml | 8 +++--- .../clds/client/OperationalPolicyDelegate.java | 2 +- .../org/onap/clamp/clds/client/PolicyClient.java | 6 ++--- .../clds/client/req/OperationalPolicyReq.java | 30 +++++++++++----------- .../org/onap/clamp/clds/it/PolicyClientIT.java | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/main/java') diff --git a/pom.xml b/pom.xml index 801b2ee19..b853ccf30 100644 --- a/pom.xml +++ b/pom.xml @@ -316,7 +316,7 @@ - org.openecomp.policy.engine + org.onap.policy.engine PolicyEngineAPI 1.1.0-SNAPSHOT @@ -335,8 +335,8 @@ - org.openecomp.policy.common - ECOMP-Logging + org.onap.policy.common + ONAP-Logging 1.1.0-SNAPSHOT @@ -354,7 +354,7 @@ - org.openecomp.policy.engine + org.onap.policy.engine ControlloopPolicy 1.1.0-SNAPSHOT diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java index fc3ea2ab2..2b7b06697 100644 --- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java @@ -26,7 +26,7 @@ package org.onap.clamp.clds.client; import org.onap.clamp.clds.client.req.OperationalPolicyReq; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; -import org.openecomp.policy.api.AttributeType; +import org.onap.policy.api.AttributeType; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java index 95e60ea2e..d19c2167e 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java @@ -25,7 +25,7 @@ package org.onap.clamp.clds.client; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; -import org.openecomp.policy.api.*; +import org.onap.policy.api.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; @@ -106,7 +106,7 @@ public class PolicyClient { // Set Policy Type policyParameters.setPolicyConfigType(PolicyConfigType.MicroService); - policyParameters.setEcompName(refProp.getStringValue("policy.ecomp.name")); + policyParameters.setOnapName(refProp.getStringValue("policy.onap.name")); policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); policyParameters.setConfigBody(policyJson); @@ -339,4 +339,4 @@ public class PolicyClient { return responseMessage; } -} \ No newline at end of file +} diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java index 90b9ff8ad..17e606133 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -27,17 +27,17 @@ import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.prop.Policy; import org.onap.clamp.clds.model.prop.PolicyItem; -import org.openecomp.policy.controlloop.policy.TargetType; -import org.openecomp.policy.controlloop.policy.PolicyResult; -import org.openecomp.policy.controlloop.policy.Target; -import org.openecomp.policy.controlloop.policy.builder.BuilderException; -import org.openecomp.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; -import org.openecomp.policy.controlloop.policy.builder.Message; -import org.openecomp.policy.controlloop.policy.builder.Results; -import org.openecomp.policy.api.AttributeType; -import org.openecomp.policy.asdc.Resource; -import org.openecomp.policy.asdc.ResourceType; -import org.openecomp.policy.asdc.Service; +import org.onap.policy.controlloop.policy.TargetType; +import org.onap.policy.controlloop.policy.PolicyResult; +import org.onap.policy.controlloop.policy.Target; +import org.onap.policy.controlloop.policy.builder.BuilderException; +import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; +import org.onap.policy.controlloop.policy.builder.Message; +import org.onap.policy.controlloop.policy.builder.Results; +import org.onap.policy.api.AttributeType; +import org.onap.policy.asdc.Resource; +import org.onap.policy.asdc.ResourceType; +import org.onap.policy.asdc.Service; import org.onap.clamp.clds.model.refprop.RefProp; import org.jboss.resteasy.spi.BadRequestException; @@ -155,10 +155,10 @@ public class OperationalPolicyReq { builder.addResource(vfcResources); // process each policy - HashMap policyObjMap = new HashMap<>(); + HashMap policyObjMap = new HashMap<>(); List policyItemList = orderParentFirst(policy.getPolicyItems()); for (int i = 0; i < policyItemList.size(); i++) { - org.openecomp.policy.controlloop.policy.Policy policyObj; + org.onap.policy.controlloop.policy.Policy policyObj; PolicyItem policyItem = policyItemList.get(i); String policyName = policyItem.getRecipe() + " Policy"; if (i == 0) { @@ -173,7 +173,7 @@ public class OperationalPolicyReq { policyItem.getMaxRetries(), policyItem.getRetryTimeLimit()); } else { - org.openecomp.policy.controlloop.policy.Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy()); + org.onap.policy.controlloop.policy.Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy()); String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + parentPolicyObj.getName() + " - created by CLDS"; policyObj = builder.setPolicyForPolicyResult( policyName, @@ -296,4 +296,4 @@ public class OperationalPolicyReq { return prArray; } -} \ No newline at end of file +} diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java index 61ee1850d..d0fcf42e6 100644 --- a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java +++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java @@ -36,7 +36,7 @@ import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractIT; import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.prop.ModelProperties; -import org.openecomp.policy.api.AttributeType; +import org.onap.policy.api.AttributeType; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.junit4.SpringRunner; -- cgit 1.2.3-korg From 08673dc040d7483e159a6e705993690538d7b117 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 02:54:59 -0700 Subject: Rework SDC calls and model Rework the SDC model and queries + Add unit tests with JSON to validate the SDC model Change-Id: I93f08cdc883f5357e3a08e9c246ed30be50a3492 Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/client/SdcCatalogServices.java | 694 +++--- .../onap/clamp/clds/client/SdcSendReqDelegate.java | 135 +- .../org/onap/clamp/clds/client/req/SdcReq.java | 130 +- .../org/onap/clamp/clds/model/CldsSdcArtifact.java | 112 + .../org/onap/clamp/clds/model/CldsSdcResource.java | 135 ++ .../clamp/clds/model/CldsSdcResourceBasicInfo.java | 164 ++ .../clamp/clds/model/CldsSdcServiceDetail.java | 142 ++ .../onap/clamp/clds/model/CldsSdcServiceInfo.java | 153 ++ .../org/onap/clamp/clds/client/req/SdcReqTest.java | 41 +- .../onap/clamp/clds/it/SdcCatalogServicesIT.java | 289 +++ src/test/java/org/onap/clamp/clds/it/SdcIT.java | 87 + src/test/resources/example/sdc/sdcAlarmsList.csv | 13 + .../resources/example/sdc/sdcCinderVolume.json | 15 + .../resources/example/sdc/sdcMeasurementsList.csv | 17 + .../example/sdc/sdcResourceDetailsExample.json | 126 + .../resources/example/sdc/sdcSecurityRules.json | 15 + .../example/sdc/sdcServiceDetailsExample.json | 230 ++ .../example/sdc/sdcServicesListExample.json | 35 + .../example/sdc/sdcVFCGenericWithAlarms.json | 60 + .../resources/example/sdc/sdcVFCResources.json | 2445 ++++++++++++++++++++ src/test/resources/example/sdc/sdcVFResources.json | 1574 +++++++++++++ 21 files changed, 6202 insertions(+), 410 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcArtifact.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcServiceDetail.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsSdcServiceInfo.java create mode 100644 src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java create mode 100644 src/test/java/org/onap/clamp/clds/it/SdcIT.java create mode 100644 src/test/resources/example/sdc/sdcAlarmsList.csv create mode 100644 src/test/resources/example/sdc/sdcCinderVolume.json create mode 100644 src/test/resources/example/sdc/sdcMeasurementsList.csv create mode 100644 src/test/resources/example/sdc/sdcResourceDetailsExample.json create mode 100644 src/test/resources/example/sdc/sdcSecurityRules.json create mode 100644 src/test/resources/example/sdc/sdcServiceDetailsExample.json create mode 100644 src/test/resources/example/sdc/sdcServicesListExample.json create mode 100644 src/test/resources/example/sdc/sdcVFCGenericWithAlarms.json create mode 100644 src/test/resources/example/sdc/sdcVFCResources.json create mode 100644 src/test/resources/example/sdc/sdcVFResources.json (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java index 58bba3c9d..a009f06fd 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,41 +23,66 @@ package org.onap.clamp.clds.client; +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVRecord; +import org.apache.commons.lang3.StringUtils; +import org.onap.clamp.clds.client.req.SdcReq; +import org.onap.clamp.clds.model.CldsAlarmCondition; +import org.onap.clamp.clds.model.CldsDBServiceCache; +import org.onap.clamp.clds.model.CldsSdcArtifact; +import org.onap.clamp.clds.model.CldsSdcResource; +import org.onap.clamp.clds.model.CldsSdcResourceBasicInfo; +import org.onap.clamp.clds.model.CldsSdcServiceDetail; +import org.onap.clamp.clds.model.CldsSdcServiceInfo; +import org.onap.clamp.clds.model.CldsServiceData; +import org.onap.clamp.clds.model.CldsVfData; +import org.onap.clamp.clds.model.CldsVfKPIData; +import org.onap.clamp.clds.model.CldsVfcData; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.util.LoggingUtils; +import org.springframework.beans.factory.annotation.Autowired; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.TextNode; -import org.onap.clamp.clds.client.req.SdcReq; -import org.onap.clamp.clds.model.*; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVRecord; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; public class SdcCatalogServices { - private static final Logger logger = LoggerFactory.getLogger(SdcSendReqDelegate.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCatalogServices.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + private static final String RESOURCE_VF_TYPE = "VF"; + private static final String RESOURCE_VFC_TYPE = "VFC"; @Autowired - private RefProp refProp; + private RefProp refProp; - public String getAsdcServicesInformation(String uuid) throws Exception { - String baseUrl = refProp.getStringValue("asdc.serviceUrl"); - String basicAuth = SdcReq.getAsdcBasicAuth(refProp); + public String getSdcServicesInformation(String uuid) throws Exception { + Date startTime = new Date(); + String baseUrl = refProp.getStringValue("sdc.serviceUrl"); + String basicAuth = SdcReq.getSdcBasicAuth(refProp); try { String url = baseUrl; if (uuid != null) { @@ -67,7 +92,7 @@ public class SdcCatalogServices { HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); - conn.setRequestProperty("X-ONAP-InstanceID", "CLAMP-Tool"); + conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool"); conn.setRequestProperty("Authorization", basicAuth); conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); conn.setRequestMethod("GET"); @@ -77,113 +102,129 @@ public class SdcCatalogServices { logger.info(resp.toString()); return resp; } + // metrics log + LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName()); + } catch (Exception e) { - logger.error("not able to ger any service information from asdc for uuid:" + uuid); + LoggingUtils.setResponseContext("900", "Get sdc services failed", this.getClass().getName()); + LoggingUtils.setErrorContext("900", "Get sdc services error"); + logger.error("not able to get any service information from sdc for uuid:" + uuid); } + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setTargetContext("SDC", "Get Services"); + metricsLogger.info("Get sdc services information"); + return ""; } /** - * To remove duplicate serviceUUIDs from asdc services List + * To remove duplicate serviceUUIDs from sdc services List * - * @param rawCldsAsdcServiceList + * @param rawCldsSdcServiceList * @return */ - public List removeDuplicateServices(List rawCldsAsdcServiceList) { - List cldsAsdcServiceInfoList = null; - if (rawCldsAsdcServiceList != null && rawCldsAsdcServiceList.size() > 0) { + public List removeDuplicateServices(List rawCldsSdcServiceList) { + List cldsSdcServiceInfoList = null; + if (rawCldsSdcServiceList != null && rawCldsSdcServiceList.size() > 0) { // sort list - Collections.sort(rawCldsAsdcServiceList); - // and then take only the services with the max version (last in the list with the same name) - cldsAsdcServiceInfoList = new ArrayList<>(); - for (int i = 1; i < rawCldsAsdcServiceList.size(); i++) { - // compare name with previous - if not equal, then keep the previous (it's the last with that name) - CldsAsdcServiceInfo prev = rawCldsAsdcServiceList.get(i - 1); - if (!rawCldsAsdcServiceList.get(i).getName().equals(prev.getName())) { - cldsAsdcServiceInfoList.add(prev); + Collections.sort(rawCldsSdcServiceList); + // and then take only the services with the max version (last in the + // list with the same name) + cldsSdcServiceInfoList = new ArrayList<>(); + for (int i = 1; i < rawCldsSdcServiceList.size(); i++) { + // compare name with previous - if not equal, then keep the + // previous (it's the last with that name) + CldsSdcServiceInfo prev = rawCldsSdcServiceList.get(i - 1); + if (!rawCldsSdcServiceList.get(i).getName().equals(prev.getName())) { + cldsSdcServiceInfoList.add(prev); } } // add the last in the list - cldsAsdcServiceInfoList.add(rawCldsAsdcServiceList.get(rawCldsAsdcServiceList.size() - 1)); + cldsSdcServiceInfoList.add(rawCldsSdcServiceList.get(rawCldsSdcServiceList.size() - 1)); } - return cldsAsdcServiceInfoList; + return cldsSdcServiceInfoList; } /** - * To remove duplicate serviceUUIDs from asdc resources List + * To remove duplicate serviceUUIDs from sdc resources List * - * @param rawCldsAsdcResourceList + * @param rawCldsSdcResourceList * @return */ - public List removeDuplicateAsdcResourceInstances(List rawCldsAsdcResourceList) { - List cldsAsdcResourceList = null; - if (rawCldsAsdcResourceList != null && rawCldsAsdcResourceList.size() > 0) { + public List removeDuplicateSdcResourceInstances(List rawCldsSdcResourceList) { + List cldsSdcResourceList = null; + if (rawCldsSdcResourceList != null && rawCldsSdcResourceList.size() > 0) { // sort list - Collections.sort(rawCldsAsdcResourceList); - // and then take only the resources with the max version (last in the list with the same name) - cldsAsdcResourceList = new ArrayList<>(); - for (int i = 1; i < rawCldsAsdcResourceList.size(); i++) { - // compare name with previous - if not equal, then keep the previous (it's the last with that name) - CldsAsdcResource prev = rawCldsAsdcResourceList.get(i - 1); - if (!rawCldsAsdcResourceList.get(i).getResourceInstanceName().equals(prev.getResourceInstanceName())) { - cldsAsdcResourceList.add(prev); + Collections.sort(rawCldsSdcResourceList); + // and then take only the resources with the max version (last in + // the list with the same name) + cldsSdcResourceList = new ArrayList<>(); + for (int i = 1; i < rawCldsSdcResourceList.size(); i++) { + // compare name with previous - if not equal, then keep the + // previous (it's the last with that name) + CldsSdcResource prev = rawCldsSdcResourceList.get(i - 1); + if (!rawCldsSdcResourceList.get(i).getResourceInstanceName().equals(prev.getResourceInstanceName())) { + cldsSdcResourceList.add(prev); } } // add the last in the list - cldsAsdcResourceList.add(rawCldsAsdcResourceList.get(rawCldsAsdcResourceList.size() - 1)); + cldsSdcResourceList.add(rawCldsSdcResourceList.get(rawCldsSdcResourceList.size() - 1)); } - return cldsAsdcResourceList; + return cldsSdcResourceList; } - /** * To remove duplicate basic resources with same resourceUUIDs * - * @param rawCldsAsdcResourceListBasicList + * @param rawCldsSdcResourceListBasicList * @return */ - public List removeDuplicateAsdcResourceBasicInfo(List rawCldsAsdcResourceListBasicList) { - List cldsAsdcResourceBasicInfoList = null; - if (rawCldsAsdcResourceListBasicList != null && rawCldsAsdcResourceListBasicList.size() > 0) { + public List removeDuplicateSdcResourceBasicInfo( + List rawCldsSdcResourceListBasicList) { + List cldsSdcResourceBasicInfoList = null; + if (rawCldsSdcResourceListBasicList != null && rawCldsSdcResourceListBasicList.size() > 0) { // sort list - Collections.sort(rawCldsAsdcResourceListBasicList); - // and then take only the resources with the max version (last in the list with the same name) - cldsAsdcResourceBasicInfoList = new ArrayList<>(); - for (int i = 1; i < rawCldsAsdcResourceListBasicList.size(); i++) { - // compare name with previous - if not equal, then keep the previous (it's the last with that name) - CldsAsdcResourceBasicInfo prev = rawCldsAsdcResourceListBasicList.get(i - 1); - if (!rawCldsAsdcResourceListBasicList.get(i).getName().equals(prev.getName())) { - cldsAsdcResourceBasicInfoList.add(prev); + Collections.sort(rawCldsSdcResourceListBasicList); + // and then take only the resources with the max version (last in + // the list with the same name) + cldsSdcResourceBasicInfoList = new ArrayList<>(); + for (int i = 1; i < rawCldsSdcResourceListBasicList.size(); i++) { + // compare name with previous - if not equal, then keep the + // previous (it's the last with that name) + CldsSdcResourceBasicInfo prev = rawCldsSdcResourceListBasicList.get(i - 1); + if (!rawCldsSdcResourceListBasicList.get(i).getName().equals(prev.getName())) { + cldsSdcResourceBasicInfoList.add(prev); } } // add the last in the list - cldsAsdcResourceBasicInfoList.add(rawCldsAsdcResourceListBasicList.get(rawCldsAsdcResourceListBasicList.size() - 1)); + cldsSdcResourceBasicInfoList + .add(rawCldsSdcResourceListBasicList.get(rawCldsSdcResourceListBasicList.size() - 1)); } - return cldsAsdcResourceBasicInfoList; + return cldsSdcResourceBasicInfoList; } /** * To get ServiceUUID by using serviceInvariantUUID * - * @param invariantID + * @param invariantId * @return * @throws Exception */ - public String getServiceUUIDFromServiceInvariantID(String invariantID) throws Exception { - String serviceUUID = ""; - String responseStr = getAsdcServicesInformation(null); - List rawCldsAsdcServicesList = getCldsAsdcServicesListFromJson(responseStr); - List cldsAsdcServicesList = removeDuplicateServices(rawCldsAsdcServicesList); - if (cldsAsdcServicesList != null && cldsAsdcServicesList.size() > 0) { - for (CldsAsdcServiceInfo currCldsAsdcServiceInfo : cldsAsdcServicesList) { - if (currCldsAsdcServiceInfo != null && currCldsAsdcServiceInfo.getInvariantUUID() != null - && currCldsAsdcServiceInfo.getInvariantUUID().equalsIgnoreCase(invariantID)) { - serviceUUID = currCldsAsdcServiceInfo.getUuid(); + public String getServiceUuidFromServiceInvariantId(String invariantId) throws Exception { + String serviceUuid = ""; + String responseStr = getSdcServicesInformation(null); + List rawCldsSdcServicesList = getCldsSdcServicesListFromJson(responseStr); + List cldsSdcServicesList = removeDuplicateServices(rawCldsSdcServicesList); + if (cldsSdcServicesList != null && cldsSdcServicesList.size() > 0) { + for (CldsSdcServiceInfo currCldsSdcServiceInfo : cldsSdcServicesList) { + if (currCldsSdcServiceInfo != null && currCldsSdcServiceInfo.getInvariantUUID() != null + && currCldsSdcServiceInfo.getInvariantUUID().equalsIgnoreCase(invariantId)) { + serviceUuid = currCldsSdcServiceInfo.getUuid(); break; } } } - return serviceUUID; + return serviceUuid; } /** @@ -195,16 +236,17 @@ public class SdcCatalogServices { * @throws JsonMappingException * @throws IOException */ - public List getCldsAsdcServicesListFromJson(String jsonStr) throws IOException { + public List getCldsSdcServicesListFromJson(String jsonStr) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); if (StringUtils.isBlank(jsonStr)) { return null; } - return objectMapper.readValue(jsonStr, objectMapper.getTypeFactory().constructCollectionType(List.class, CldsAsdcServiceInfo.class)); + return objectMapper.readValue(jsonStr, + objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcServiceInfo.class)); } /** - * To get List class by parsing json string + * To get List class by parsing json string * * @param jsonStr * @return @@ -212,12 +254,13 @@ public class SdcCatalogServices { * @throws JsonMappingException * @throws IOException */ - public List getAllAsdcResourcesListFromJson(String jsonStr) throws IOException { + public List getAllSdcResourcesListFromJson(String jsonStr) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); if (StringUtils.isBlank(jsonStr)) { return null; } - return objectMapper.readValue(jsonStr, objectMapper.getTypeFactory().constructCollectionType(List.class, CldsAsdcResourceBasicInfo.class)); + return objectMapper.readValue(jsonStr, + objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcResourceBasicInfo.class)); } /** @@ -229,13 +272,13 @@ public class SdcCatalogServices { * @throws JsonMappingException * @throws IOException */ - public CldsAsdcResource getCldsAsdcResourceFromJson(String jsonStr) throws IOException { + public CldsSdcResource getCldsSdcResourceFromJson(String jsonStr) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.readValue(jsonStr, CldsAsdcResource.class); + return objectMapper.readValue(jsonStr, CldsSdcResource.class); } /** - * To get CldsAsdcServiceDetail by parsing json string + * To get CldsSdcServiceDetail by parsing json string * * @param jsonStr * @return @@ -243,26 +286,32 @@ public class SdcCatalogServices { * @throws JsonMappingException * @throws IOException */ - public CldsAsdcServiceDetail getCldsAsdcServiceDetailFromJson(String jsonStr) throws IOException { + public CldsSdcServiceDetail getCldsSdcServiceDetailFromJson(String jsonStr) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.readValue(jsonStr, CldsAsdcServiceDetail.class); + return objectMapper.readValue(jsonStr, CldsSdcServiceDetail.class); } /** - * To upload artifact to asdc based on serviceUUID and resourcename on url + * To upload artifact to sdc based on serviceUUID and resourcename on url + * * @param prop * @param userid * @param url - * @param formatttedAsdcReq + * @param formatttedSdcReq * @return * @throws Exception */ - public String uploadArtifactToAsdc(ModelProperties prop, String userid, String url, String formatttedAsdcReq) throws Exception { + public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formatttedSdcReq) + throws Exception { + // Verify whether it is triggered by Validation Test button from UI + if (prop.isTest()) { + return "sdc artifact upload not executed for test action"; + } logger.info("userid=" + userid); - String md5Text = SdcReq.calculateMD5ByString(formatttedAsdcReq); - byte[] postData = SdcReq.stringToByteArray(formatttedAsdcReq); + String md5Text = SdcReq.calculateMD5ByString(formatttedSdcReq); + byte[] postData = SdcReq.stringToByteArray(formatttedSdcReq); int postDataLength = postData.length; - HttpURLConnection conn = getAsdcHttpUrlConnection(userid, postDataLength, url, md5Text); + HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, md5Text); try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { wr.write(postData); } @@ -283,18 +332,19 @@ public class SdcCatalogServices { return responseStr; } - private HttpURLConnection getAsdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text) throws IOException { + private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text) + throws IOException { logger.info("userid=" + userid); - String basicAuth = SdcReq.getAsdcBasicAuth(refProp); - String asdcXONAPInstanceID = refProp.getStringValue("asdc.asdcX-ONAP-InstanceID"); + String basicAuth = SdcReq.getSdcBasicAuth(refProp); + String sdcXonapInstanceId = refProp.getStringValue("sdc.sdcX-InstanceID"); URL urlObj = new URL(url); HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); conn.setDoOutput(true); - conn.setRequestProperty("X-ONAP-InstanceID", asdcXONAPInstanceID); + conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), sdcXonapInstanceId); conn.setRequestProperty("Authorization", basicAuth); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Content-MD5", md5Text); - conn.setRequestProperty("HTTP_CSP_USERID", userid); + conn.setRequestProperty("USER_ID", userid); conn.setRequestMethod("POST"); conn.setRequestProperty("charset", "utf-8"); conn.setRequestProperty("Content-Length", Integer.toString(postDataLength)); @@ -326,8 +376,8 @@ public class SdcCatalogServices { return inStream; } - - public CldsDBServiceCache getCldsDBServiceCacheUsingCldsServiceData(CldsServiceData cldsServiceData) throws IOException { + public CldsDBServiceCache getCldsDbServiceCacheUsingCldsServiceData(CldsServiceData cldsServiceData) + throws IOException { CldsDBServiceCache cldsDbServiceCache = new CldsDBServiceCache(); cldsDbServiceCache.setCldsDataInstream(cldsServiceData); cldsDbServiceCache.setInvariantId(cldsServiceData.getServiceInvariantUUID()); @@ -335,14 +385,14 @@ public class SdcCatalogServices { return cldsDbServiceCache; } - public boolean isCldsAsdcCacheDataExpired(CldsServiceData cldsServiceData) throws Exception { + public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData) throws Exception { boolean expired = false; if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) { - String cachedServiceUUID = cldsServiceData.getServiceUUID(); - String latestServiceUUID = getServiceUUIDFromServiceInvariantID(cldsServiceData.getServiceInvariantUUID()); + String cachedServiceUuid = cldsServiceData.getServiceUUID(); + String latestServiceUuid = getServiceUuidFromServiceInvariantId(cldsServiceData.getServiceInvariantUUID()); String defaultRecordAge = refProp.getStringValue("CLDS_SERVICE_CACHE_MAX_SECONDS"); - if ((!cachedServiceUUID.equalsIgnoreCase(latestServiceUUID)) || - (cldsServiceData.getAgeOfRecord() != null && cldsServiceData.getAgeOfRecord() > Long.parseLong(defaultRecordAge))) { + if ((!cachedServiceUuid.equalsIgnoreCase(latestServiceUuid)) || (cldsServiceData.getAgeOfRecord() != null + && cldsServiceData.getAgeOfRecord() > Long.parseLong(defaultRecordAge))) { expired = true; } } else { @@ -351,29 +401,32 @@ public class SdcCatalogServices { return expired; } - public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUUID) throws Exception { - String url = refProp.getStringValue("asdc.serviceUrl"); - String catalogUrl = refProp.getStringValue("asdc.catalog.url"); - String serviceUUID = getServiceUUIDFromServiceInvariantID(invariantServiceUUID); - String serviceDetailUrl = url + "/" + serviceUUID + "/metadata"; + public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUuid) throws Exception { + String url = refProp.getStringValue("sdc.serviceUrl"); + String catalogUrl = refProp.getStringValue("sdc.catalog.url"); + String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid); + String serviceDetailUrl = url + "/" + serviceUuid + "/metadata"; String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl, false); ObjectMapper objectMapper = new ObjectMapper(); CldsServiceData cldsServiceData = new CldsServiceData(); if (responseStr != null) { - CldsAsdcServiceDetail cldsAsdcServiceDetail = objectMapper.readValue(responseStr, CldsAsdcServiceDetail.class); - cldsServiceData.setServiceUUID(cldsAsdcServiceDetail.getUuid()); - cldsServiceData.setServiceInvariantUUID(cldsAsdcServiceDetail.getInvariantUUID()); - - // To remove duplicate resources from serviceDetail and add valid vfs to service - if (cldsAsdcServiceDetail != null && cldsAsdcServiceDetail.getResources() != null) { - List cldsAsdcResourceList = removeDuplicateAsdcResourceInstances(cldsAsdcServiceDetail.getResources()); - if (cldsAsdcResourceList != null && cldsAsdcResourceList.size() > 0) { + CldsSdcServiceDetail cldsSdcServiceDetail = objectMapper.readValue(responseStr, CldsSdcServiceDetail.class); + cldsServiceData.setServiceUUID(cldsSdcServiceDetail.getUuid()); + cldsServiceData.setServiceInvariantUUID(cldsSdcServiceDetail.getInvariantUUID()); + + // To remove duplicate resources from serviceDetail and add valid + // vfs to service + if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null) { + List cldsSdcResourceList = removeDuplicateSdcResourceInstances( + cldsSdcServiceDetail.getResources()); + if (cldsSdcResourceList != null && cldsSdcResourceList.size() > 0) { List cldsVfDataList = new ArrayList<>(); - for (CldsAsdcResource currCldsAsdcResource : cldsAsdcResourceList) { - if (currCldsAsdcResource != null && currCldsAsdcResource.getResoucreType() != null && currCldsAsdcResource.getResoucreType().equalsIgnoreCase("VF")) { + for (CldsSdcResource currCldsSdcResource : cldsSdcResourceList) { + if (currCldsSdcResource != null && currCldsSdcResource.getResoucreType() != null + && currCldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { CldsVfData currCldsVfData = new CldsVfData(); - currCldsVfData.setVfName(currCldsAsdcResource.getResourceInstanceName()); - currCldsVfData.setVfInvariantResourceUUID(currCldsAsdcResource.getResourceInvariantUUID()); + currCldsVfData.setVfName(currCldsSdcResource.getResourceInstanceName()); + currCldsVfData.setVfInvariantResourceUUID(currCldsSdcResource.getResourceInvariantUUID()); cldsVfDataList.add(currCldsVfData); } } @@ -395,35 +448,47 @@ public class SdcCatalogServices { private void getAllVfcForVfList(List cldsVfDataList, String catalogUrl) throws IOException { // todo : refact this.. if (cldsVfDataList != null && cldsVfDataList.size() > 0) { - List allAsdcResources = getAllAsdcResources(); - String resourceVFType = "VF"; - List allVfResources = getAllAsdcVForVFCResourcesBasedOnResourceType(resourceVFType, allAsdcResources); - String resourceVFCType = "VFC"; - List allVfcResources = getAllAsdcVForVFCResourcesBasedOnResourceType(resourceVFCType, allAsdcResources); + List allVfResources = getAllSdcVForVFCResourcesBasedOnResourceType( + RESOURCE_VF_TYPE); + List allVfcResources = getAllSdcVForVFCResourcesBasedOnResourceType( + RESOURCE_VFC_TYPE); for (CldsVfData currCldsVfData : cldsVfDataList) { if (currCldsVfData != null && currCldsVfData.getVfInvariantResourceUUID() != null) { - String resourceUUID = getResourceUUIDFromResourceInvariantUUID(currCldsVfData.getVfInvariantResourceUUID(), allVfResources); - if (resourceUUID != null) { - String vfResourceUUIDUrl = catalogUrl + "resources" + "/" + resourceUUID + "/metadata"; - String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUUIDUrl, false); + String resourceUuid = getResourceUuidFromResourceInvariantUuid( + currCldsVfData.getVfInvariantResourceUUID(), allVfResources); + if (resourceUuid != null) { + String vfResourceUuidUrl = catalogUrl + "resources" + "/" + resourceUuid + "/metadata"; + String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl, false); if (vfResponse != null) { - List vfcDataListFromVfResponse = getVFCDataListFromVfResponse(vfResponse); + // Below 2 line are to get the KPI(field path) data + // associated with the VF's + List cldsVfKPIDataList = getFieldPathFromVF(vfResponse); + currCldsVfData.setCldsKPIList(cldsVfKPIDataList); + + List vfcDataListFromVfResponse = getVfcDataListFromVfResponse(vfResponse); if (vfcDataListFromVfResponse != null) { currCldsVfData.setCldsVfcs(vfcDataListFromVfResponse); if (vfcDataListFromVfResponse.size() > 0) { - // To get artifacts for every VFC and get alarm conditions from artifact + // To get artifacts for every VFC and get + // alarm conditions from artifact for (CldsVfcData currCldsVfcData : vfcDataListFromVfResponse) { - if (currCldsVfcData != null && currCldsVfcData.getVfcInvariantResourceUUID() != null) { - String resourceVFCUUID = getResourceUUIDFromResourceInvariantUUID(currCldsVfcData.getVfcInvariantResourceUUID(), allVfcResources); - if (resourceVFCUUID != null) { - String vfcResourceUUIDUrl = catalogUrl + "resources" + "/" + resourceVFCUUID + "/metadata"; - String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl, false); + if (currCldsVfcData != null + && currCldsVfcData.getVfcInvariantResourceUUID() != null) { + String resourceVfcUuid = getResourceUuidFromResourceInvariantUuid( + currCldsVfcData.getVfcInvariantResourceUUID(), allVfcResources); + if (resourceVfcUuid != null) { + String vfcResourceUuidUrl = catalogUrl + "resources" + "/" + + resourceVfcUuid + "/metadata"; + String vfcResponse = getCldsServicesOrResourcesBasedOnURL( + vfcResourceUuidUrl, false); if (vfcResponse != null) { - List alarmCondtionsFromVfc = getAlarmCondtionsFromVfc(vfcResponse); + List alarmCondtionsFromVfc = getAlarmCondtionsFromVfc( + vfcResponse); currCldsVfcData.setCldsAlarmConditions(alarmCondtionsFromVfc); } } else { - logger.info("No resourceVFC UUID found for given invariantID:" + currCldsVfcData.getVfcInvariantResourceUUID()); + logger.info("No resourceVFC UUID found for given invariantID:" + + currCldsVfcData.getVfcInvariantResourceUUID()); } } } @@ -431,14 +496,15 @@ public class SdcCatalogServices { } } } else { - logger.info("No resourceUUID found for given invariantREsourceUUID:" + currCldsVfData.getVfInvariantResourceUUID()); + logger.info("No resourceUUID found for given invariantREsourceUUID:" + + currCldsVfData.getVfInvariantResourceUUID()); } } } } } - private List getVFCDataListFromVfResponse(String vfResponse) throws IOException { + private List getVfcDataListFromVfResponse(String vfResponse) throws IOException { ObjectMapper mapper = new ObjectMapper(); ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources"); @@ -450,9 +516,9 @@ public class SdcCatalogServices { TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType"); if (resourceTypeNode != null && resourceTypeNode.textValue().equalsIgnoreCase("VFC")) { TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName"); - TextNode vfcInvariantResourceUUID = (TextNode) currVfcNode.get("resourceInvariantUUID"); + TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID"); currCldsVfcData.setVfcName(vfcResourceName.textValue()); - currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUUID.textValue()); + currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue()); cldsVfcDataList.add(currCldsVfcData); } } @@ -501,6 +567,75 @@ public class SdcCatalogServices { return cldsAlarmConditionList; } + // Method to get the artifact for any particular VF + private List getFieldPathFromVF(String vfResponse) throws JsonProcessingException, IOException { + List cldsVfKPIDataList = new ArrayList(); + ObjectMapper mapper = new ObjectMapper(); + ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); + ArrayNode artifactsArrayNode = (ArrayNode) vfResponseNode.get("artifacts"); + + if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) { + for (int index = 0; index < artifactsArrayNode.size(); index++) { + ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index); + TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL"); + TextNode artifactNameNode = (TextNode) currArtifactNode.get("artifactName"); + String artifactName = ""; + if (artifactNameNode != null) { + artifactName = artifactNameNode.textValue(); + artifactName = artifactName.substring(artifactName.lastIndexOf(".") + 1); + } + if (artifactUrlNode != null && artifactName != null && !artifactName.isEmpty() + && artifactName.equalsIgnoreCase("csv")) { + String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue()); + cldsVfKPIDataList.addAll(parseCsvToGetFieldPath(responsesFromArtifactUrl)); + logger.info(responsesFromArtifactUrl); + } + } + } + return cldsVfKPIDataList; + } + + private CldsVfKPIData convertCsvRecordToKpiData(CSVRecord record) { + if (record.size() < 6) { + logger.debug("invalid csv field path Record,total columns less than 6: " + record); + return null; + } + + if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3)) + || StringUtils.isBlank(record.get(5))) { + logger.debug("Invalid csv field path Record,one of column is having blank value : " + record); + return null; + } + + CldsVfKPIData cldsVfKPIData = new CldsVfKPIData(); + cldsVfKPIData.setNfNamingCode(record.get(0).trim()); + cldsVfKPIData.setNfNamingValue(record.get(1).trim()); + + cldsVfKPIData.setFieldPath(record.get(2).trim()); + cldsVfKPIData.setFieldPathValue(record.get(3).trim()); + + cldsVfKPIData.setThresholdName(record.get(4).trim()); + cldsVfKPIData.setThresholdValue(record.get(5).trim()); + return cldsVfKPIData; + + } + + // Method to get the artifactURL Data and set the CldsVfKPIData node + private List parseCsvToGetFieldPath(String allFieldPathValues) throws IOException { + List cldsVfKPIDataList = new ArrayList(); + Reader alarmReader = new StringReader(allFieldPathValues); + Iterable records = CSVFormat.RFC4180.parse(alarmReader); + if (records != null) { + for (CSVRecord record : records) { + CldsVfKPIData kpiData = this.convertCsvRecordToKpiData(record); + if (kpiData != null) { + cldsVfKPIDataList.add(kpiData); + } + } + } + return cldsVfKPIDataList; + } + private void processRecord(List cldsAlarmConditionList, CSVRecord record) { if (record == null) { return; @@ -509,7 +644,8 @@ public class SdcCatalogServices { logger.debug("invalid csv alarm Record,total columns less than 5: " + record); return; } - if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3)) || StringUtils.isBlank(record.get(4))) { + if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3)) + || StringUtils.isBlank(record.get(4))) { logger.debug("invalid csv alarm Record,one of column is having blank value : " + record); return; } @@ -520,8 +656,8 @@ public class SdcCatalogServices { cldsAlarmConditionList.add(cldsAlarmCondition); } - private String getResponsesFromArtifactUrl(String artifactsUrl) throws IOException { - String hostUrl = refProp.getStringValue("asdc.hostUrl"); + public String getResponsesFromArtifactUrl(String artifactsUrl) throws IOException { + String hostUrl = refProp.getStringValue("sdc.hostUrl"); artifactsUrl = artifactsUrl.replaceAll("\"", ""); String artifactUrl = hostUrl + artifactsUrl; logger.info("value of artifactURl:" + artifactUrl); @@ -531,22 +667,23 @@ public class SdcCatalogServices { } /** - * Service to services/resources/artifacts from asdc.Pass alarmConditions as true to get alarmconditons from artifact url and else it is false + * Service to services/resources/artifacts from sdc.Pass alarmConditions as + * true to get alarmconditons from artifact url and else it is false * * @param url * @param alarmConditions * @return * @throws IOException */ - private String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions) throws IOException { + public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions) { String responseStr; try { url = removeUnwantedBracesFromString(url); URL urlObj = new URL(url); HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); - String basicAuth = SdcReq.getAsdcBasicAuth(refProp); - conn.setRequestProperty("X-ONAP-InstanceID", "CLAMP-Tool"); + String basicAuth = SdcReq.getSdcBasicAuth(refProp); + conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool"); conn.setRequestProperty("Authorization", basicAuth); conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); conn.setRequestMethod("GET"); @@ -565,11 +702,12 @@ public class SdcCatalogServices { } responseStr = response.toString(); in.close(); + return responseStr; } catch (Exception e) { - logger.error("Exception occured :" + e.getMessage()); - throw e; + logger.error("Exception occurred :", e); + return ""; } - return responseStr; + } /** @@ -586,40 +724,42 @@ public class SdcCatalogServices { ObjectNode globalPropsJson; if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) { - /** - * Objectnode to save all byservice, byvf , byvfc and byalarm nodes - */ + // Objectnode to save all byservice, byvf , byvfc and byalarm nodes ObjectNode byIdObjectNode = mapper.createObjectNode(); - /** - * To create vf ResourceUUID node with serviceInvariantUUID - * - */ - ObjectNode invariantUUIDObjectNodeWithVF = createVFObjectNodeByServiceInvariantUUID(mapper, cldsServiceData); - byIdObjectNode.putPOJO("byService", invariantUUIDObjectNodeWithVF); - /** - * To create byVf and vfcResourceNode with vfResourceUUID - */ - ObjectNode vfcObjectNodeByVfUUID = createVFCObjectNodeByVfUUID(mapper, cldsServiceData.getCldsVfs()); - byIdObjectNode.putPOJO("byVf", vfcObjectNodeByVfUUID); + // To create vf ResourceUUID node with serviceInvariantUUID + ObjectNode invariantUuidObjectNodeWithVF = createVFObjectNodeByServiceInvariantUUID(mapper, + cldsServiceData); + byIdObjectNode.putPOJO("byService", invariantUuidObjectNodeWithVF); + // To create byVf and vfcResourceNode with vfResourceUUID + ObjectNode vfcObjectNodeByVfUuid = createVFCObjectNodeByVfUuid(mapper, cldsServiceData.getCldsVfs()); + byIdObjectNode.putPOJO("byVf", vfcObjectNodeByVfUuid); - /** - * To create byVfc and alarmCondition with vfcResourceUUID - */ - ObjectNode vfcResourceUUIDObjectNode = mapper.createObjectNode(); + // To create byKpi + ObjectNode kpiObjectNode = mapper.createObjectNode(); if (cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { if (currCldsVfData != null) { - createAlarmCondObjectNodeByVfcUUID(mapper, vfcResourceUUIDObjectNode, currCldsVfData.getCldsVfcs()); + createKPIObjectNodeByVfUUID(mapper, kpiObjectNode, currCldsVfData.getCldsKPIList()); } } } - byIdObjectNode.putPOJO("byVfc", vfcResourceUUIDObjectNode); + byIdObjectNode.putPOJO("byKpi", kpiObjectNode); - /** - * To create byAlarmCondition with alarmConditionKey - */ + // To create byVfc and alarmCondition with vfcResourceUUID + ObjectNode vfcResourceUuidObjectNode = mapper.createObjectNode(); + if (cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { + for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { + if (currCldsVfData != null) { + createAlarmCondObjectNodeByVfcUuid(mapper, vfcResourceUuidObjectNode, + currCldsVfData.getCldsVfcs()); + } + } + } + byIdObjectNode.putPOJO("byVfc", vfcResourceUuidObjectNode); + + // To create byAlarmCondition with alarmConditionKey List allAlarmConditions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData); ObjectNode alarmCondObjectNodeByAlarmKey = createAlarmCondObjectNodeByAlarmKey(mapper, allAlarmConditions); @@ -631,7 +771,7 @@ public class SdcCatalogServices { logger.info("valuie of objNode:" + globalPropsJson); } else { /** - * to create json with total properties when no serviceUUID passed + * to create json with total properties when no serviceUUID passed */ globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); } @@ -639,13 +779,16 @@ public class SdcCatalogServices { return totalPropsStr; } - private List getAllAlarmConditionsFromCldsServiceData(CldsServiceData cldsServiceData) { + public List getAllAlarmConditionsFromCldsServiceData(CldsServiceData cldsServiceData) { List alarmCondList = new ArrayList<>(); - if (cldsServiceData != null && cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { + if (cldsServiceData != null && cldsServiceData.getCldsVfs() != null + && cldsServiceData.getCldsVfs().size() > 0) { for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { - if (currCldsVfData != null && currCldsVfData.getCldsVfcs() != null && currCldsVfData.getCldsVfcs().size() > 0) { + if (currCldsVfData != null && currCldsVfData.getCldsVfcs() != null + && currCldsVfData.getCldsVfcs().size() > 0) { for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { - if (currCldsVfcData != null && currCldsVfcData.getCldsAlarmConditions() != null && currCldsVfcData.getCldsAlarmConditions().size() > 0) { + if (currCldsVfcData != null && currCldsVfcData.getCldsAlarmConditions() != null + && currCldsVfcData.getCldsAlarmConditions().size() > 0) { for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) { if (currCldsAlarmCondition != null) { alarmCondList.add(currCldsAlarmCondition); @@ -659,7 +802,8 @@ public class SdcCatalogServices { return alarmCondList; } - private ObjectNode createAlarmCondObjectNodeByAlarmKey(ObjectMapper mapper, List cldsAlarmCondList) { + private ObjectNode createAlarmCondObjectNodeByAlarmKey(ObjectMapper mapper, + List cldsAlarmCondList) { ObjectNode alarmCondKeyNode = mapper.createObjectNode(); if (cldsAlarmCondList != null && cldsAlarmCondList.size() > 0) { @@ -681,39 +825,66 @@ public class SdcCatalogServices { } private ObjectNode createVFObjectNodeByServiceInvariantUUID(ObjectMapper mapper, CldsServiceData cldsServiceData) { - ObjectNode invariantUUIDObjectNode = mapper.createObjectNode(); + ObjectNode invariantUuidObjectNode = mapper.createObjectNode(); ObjectNode vfObjectNode = mapper.createObjectNode(); - ObjectNode vfUUIDNode = mapper.createObjectNode(); + ObjectNode vfUuidNode = mapper.createObjectNode(); List cldsVfsList = cldsServiceData.getCldsVfs(); if (cldsVfsList != null && cldsVfsList.size() > 0) { for (CldsVfData currCldsVfData : cldsVfsList) { if (currCldsVfData != null) { - vfUUIDNode.put(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName()); + vfUuidNode.put(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName()); } } } else { - vfUUIDNode.put("", ""); + vfUuidNode.put("", ""); } - vfObjectNode.putPOJO("vf", vfUUIDNode); - invariantUUIDObjectNode.putPOJO(cldsServiceData.getServiceInvariantUUID(), vfObjectNode); - return invariantUUIDObjectNode; + vfObjectNode.putPOJO("vf", vfUuidNode); + invariantUuidObjectNode.putPOJO(cldsServiceData.getServiceInvariantUUID(), vfObjectNode); + return invariantUuidObjectNode; } - private void createAlarmCondObjectNodeByVfcUUID(ObjectMapper mapper, ObjectNode vfcResourceUUIDObjectNode, List cldsVfcDataList) { + private void createKPIObjectNodeByVfUUID(ObjectMapper mapper, ObjectNode vfResourceUUIDObjectNode, + List cldsVfKPIDataList) { + if (cldsVfKPIDataList != null && cldsVfKPIDataList.size() > 0) { + for (CldsVfKPIData currCldsVfKPIData : cldsVfKPIDataList) { + if (currCldsVfKPIData != null) { + ObjectNode thresholdNameObjectNode = mapper.createObjectNode(); + + ObjectNode fieldPathObjectNode = mapper.createObjectNode(); + ObjectNode nfNamingCodeNode = mapper.createObjectNode(); + + fieldPathObjectNode.put(currCldsVfKPIData.getFieldPathValue(), + currCldsVfKPIData.getFieldPathValue()); + nfNamingCodeNode.put(currCldsVfKPIData.getNfNamingValue(), currCldsVfKPIData.getNfNamingValue()); + + thresholdNameObjectNode.putPOJO("fieldPath", fieldPathObjectNode); + thresholdNameObjectNode.putPOJO("nfNamingCode", nfNamingCodeNode); + + vfResourceUUIDObjectNode.putPOJO(currCldsVfKPIData.getThresholdValue(), thresholdNameObjectNode); + } + } + } + } + + private void createAlarmCondObjectNodeByVfcUuid(ObjectMapper mapper, ObjectNode vfcResourceUUIDObjectNode, + List cldsVfcDataList) { ObjectNode alarmCondContsObjectNode = mapper.createObjectNode(); ObjectNode alarmCondNode = mapper.createObjectNode(); - // alarmCondNode.put("", ""); + // alarmCondNode.put("", ""); if (cldsVfcDataList != null && cldsVfcDataList.size() > 0) { for (CldsVfcData currCldsVfcData : cldsVfcDataList) { if (currCldsVfcData != null) { - if (currCldsVfcData.getCldsAlarmConditions() != null && currCldsVfcData.getCldsAlarmConditions().size() > 0) { + if (currCldsVfcData.getCldsAlarmConditions() != null + && currCldsVfcData.getCldsAlarmConditions().size() > 0) { for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) { - alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(), currCldsAlarmCondition.getAlarmConditionKey()); + alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(), + currCldsAlarmCondition.getAlarmConditionKey()); } alarmCondContsObjectNode.putPOJO("alarmCondition", alarmCondNode); } alarmCondContsObjectNode.putPOJO("alarmCondition", alarmCondNode); - vfcResourceUUIDObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), alarmCondContsObjectNode); + vfcResourceUUIDObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), + alarmCondContsObjectNode); } } } else { @@ -723,48 +894,51 @@ public class SdcCatalogServices { } } - private ObjectNode createVFCObjectNodeByVfUUID(ObjectMapper mapper, List cldsVfDataList) { + private ObjectNode createVFCObjectNodeByVfUuid(ObjectMapper mapper, List cldsVfDataList) { ObjectNode vfUUIDObjectNode = mapper.createObjectNode(); if (cldsVfDataList != null && cldsVfDataList.size() > 0) { for (CldsVfData currCldsVfData : cldsVfDataList) { if (currCldsVfData != null) { ObjectNode vfcObjectNode = mapper.createObjectNode(); - ObjectNode vfcUUIDNode = mapper.createObjectNode(); + ObjectNode vfcUuidNode = mapper.createObjectNode(); if (currCldsVfData.getCldsVfcs() != null && currCldsVfData.getCldsVfcs().size() > 0) { for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { - vfcUUIDNode.put(currCldsVfcData.getVfcInvariantResourceUUID(), currCldsVfcData.getVfcName()); + vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(), + currCldsVfcData.getVfcName()); } } else { - vfcUUIDNode.put("", ""); + vfcUuidNode.put("", ""); } - vfcObjectNode.putPOJO("vfc", vfcUUIDNode); + vfcObjectNode.putPOJO("vfc", vfcUuidNode); vfUUIDObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfcObjectNode); } } } else { - ObjectNode vfcUUIDNode = mapper.createObjectNode(); - vfcUUIDNode.put("", ""); + ObjectNode vfcUuidNode = mapper.createObjectNode(); + vfcUuidNode.put("", ""); ObjectNode vfcObjectNode = mapper.createObjectNode(); - vfcObjectNode.putPOJO("vfc", vfcUUIDNode); + vfcObjectNode.putPOJO("vfc", vfcUuidNode); vfUUIDObjectNode.putPOJO("", vfcObjectNode); } return vfUUIDObjectNode; } - public String getArtifactIdIfArtifactAlreadyExists(CldsAsdcServiceDetail cldsAsdcServiceDetail, String artifactName) { - String artifactUUId = null; + public String getArtifactIdIfArtifactAlreadyExists(CldsSdcServiceDetail CldsSdcServiceDetail, String artifactName) { + String artifactUuid = null; boolean artifactxists = false; - if (cldsAsdcServiceDetail != null && cldsAsdcServiceDetail.getResources() != null && cldsAsdcServiceDetail.getResources().size() > 0) { - for (CldsAsdcResource currCldsAsdcResource : cldsAsdcServiceDetail.getResources()) { + if (CldsSdcServiceDetail != null && CldsSdcServiceDetail.getResources() != null + && CldsSdcServiceDetail.getResources().size() > 0) { + for (CldsSdcResource currCldsSdcResource : CldsSdcServiceDetail.getResources()) { if (artifactxists) { break; } - if (currCldsAsdcResource != null && currCldsAsdcResource.getArtifacts() != null && currCldsAsdcResource.getArtifacts().size() > 0) { - for (CldsAsdcArtifact currCldsAsdcArtifact : currCldsAsdcResource.getArtifacts()) { - if (currCldsAsdcArtifact != null && currCldsAsdcArtifact.getArtifactName() != null) { - if (currCldsAsdcArtifact.getArtifactName().equalsIgnoreCase(artifactName)) { - artifactUUId = currCldsAsdcArtifact.getArtifactUUID(); + if (currCldsSdcResource != null && currCldsSdcResource.getArtifacts() != null + && currCldsSdcResource.getArtifacts().size() > 0) { + for (CldsSdcArtifact currCldsSdcArtifact : currCldsSdcResource.getArtifacts()) { + if (currCldsSdcArtifact != null && currCldsSdcArtifact.getArtifactName() != null) { + if (currCldsSdcArtifact.getArtifactName().equalsIgnoreCase(artifactName)) { + artifactUuid = currCldsSdcArtifact.getArtifactUUID(); artifactxists = true; break; } @@ -773,27 +947,25 @@ public class SdcCatalogServices { } } } - return artifactUUId; + return artifactUuid; } - public String updateControlLoopStatusToDCAE(String dcaeUrl, String invariantResourceUUID, String invariantServiceUUID, String artifactName) { - String baseUrl = refProp.getStringValue("asdc.serviceUrl"); - String basicAuth = SdcReq.getAsdcBasicAuth(refProp); - String postStatusData = "{ \n" + - "\"event\" : \"" + "Created" + "\",\n" + - "\"serviceUUID\" : \"" + invariantServiceUUID + "\",\n" + - "\"resourceUUID\" :\"" + invariantResourceUUID + "\",\n" + - "\"artifactName\" : \"" + artifactName + "\",\n" + - "} \n"; + public String updateControlLoopStatusToDcae(String dcaeUrl, String invariantResourceUuid, + String invariantServiceUuid, String artifactName) { + String baseUrl = refProp.getStringValue("sdc.serviceUrl"); + String basicAuth = SdcReq.getSdcBasicAuth(refProp); + String postStatusData = "{ \n" + "\"event\" : \"" + "Created" + "\",\n" + "\"serviceUUID\" : \"" + + invariantServiceUuid + "\",\n" + "\"resourceUUID\" :\"" + invariantResourceUuid + "\",\n" + + "\"artifactName\" : \"" + artifactName + "\",\n" + "} \n"; try { String url = baseUrl; - if (invariantServiceUUID != null) { + if (invariantServiceUuid != null) { url = dcaeUrl + "/closed-loops"; } URL urlObj = new URL(url); HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); - conn.setRequestProperty("X-ONAP-InstanceID", "CLAMP-Tool"); + conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool"); conn.setRequestProperty("Authorization", basicAuth); conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); conn.setRequestMethod("POST"); @@ -811,54 +983,40 @@ public class SdcCatalogServices { return resp; } } catch (Exception e) { - logger.error("not able to ger any service information from asdc for uuid:" + invariantServiceUUID); + logger.error("not able to ger any service information from sdc for uuid:" + invariantServiceUuid); } return ""; } /** - * To get all asdc VF/VFC Resources basic info + * To get all sdc VF/VFC Resources basic info * * @return * @throws IOException */ - private List getAllAsdcVForVFCResourcesBasedOnResourceType(String resourceType, List allAsdcResources) throws IOException { - List allAsdcVFResources = new ArrayList<>(); - if (allAsdcResources != null && allAsdcResources.size() > 0) { - for (CldsAsdcResourceBasicInfo currResource : allAsdcResources) { - if (currResource != null && currResource.getResourceType() != null && currResource.getResourceType().equalsIgnoreCase(resourceType)) { - allAsdcVFResources.add(currResource); - } - } - } - return allAsdcVFResources; + private List getAllSdcVForVFCResourcesBasedOnResourceType(String resourceType) + throws IOException { + List allSdcResourceVFCBasicInfo = new ArrayList(); + String catalogUrl = refProp.getStringValue("sdc.catalog.url"); + String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType; + String allSdcVFCResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false); + + allSdcResourceVFCBasicInfo = getAllSdcResourcesListFromJson(allSdcVFCResources); + return removeDuplicateSdcResourceBasicInfo(allSdcResourceVFCBasicInfo); } - private String getResourceUUIDFromResourceInvariantUUID(String resourceInvariantUUID, List resourceInfoList) throws IOException { - String resourceUUID = null; + private String getResourceUuidFromResourceInvariantUuid(String resourceInvariantUUID, + List resourceInfoList) throws IOException { + String resourceUuid = null; if (resourceInfoList != null && resourceInfoList.size() > 0) { - for (CldsAsdcResourceBasicInfo currResource : resourceInfoList) { + for (CldsSdcResourceBasicInfo currResource : resourceInfoList) { if (currResource != null && currResource.getInvariantUUID() != null && currResource.getUuid() != null && currResource.getInvariantUUID().equalsIgnoreCase(resourceInvariantUUID)) { - resourceUUID = currResource.getUuid(); + resourceUuid = currResource.getUuid(); break; } } } - return resourceUUID; - } - - /** - * To get all asdc Resources basic info - * - * @return - * @throws IOException - */ - private List getAllAsdcResources() throws IOException { - String catalogUrl = refProp.getStringValue("asdc.catalog.url"); - String resourceUrl = catalogUrl + "resources"; - String allAsdcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false); - List allAsdcResourceBasicInfo = getAllAsdcResourcesListFromJson(allAsdcResources); - return removeDuplicateAsdcResourceBasicInfo(allAsdcResourceBasicInfo); + return resourceUuid; } } diff --git a/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java index 93b6e954d..47a4ddc87 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,67 +23,71 @@ package org.onap.clamp.clds.client; +import java.util.List; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.clamp.clds.client.req.SdcReq; -import org.onap.clamp.clds.model.CldsAsdcServiceDetail; +import org.onap.clamp.clds.model.CldsSdcServiceDetail; import org.onap.clamp.clds.model.DcaeEvent; import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Send control loop model to dcae proxy. */ public class SdcSendReqDelegate implements JavaDelegate { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = LoggerFactory.getLogger(SdcSendReqDelegate.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcSendReqDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private RefProp refProp; + private RefProp refProp; @Autowired - private SdcCatalogServices asdcCatalogServices; + private SdcCatalogServices sdcCatalogServices; - private String baseUrl; - private String artifactType; - private String locationArtifactType; - private String artifactLabel; - private String locationArtifactLabel; + private String baseUrl; + private String artifactType; + private String locationArtifactType; + private String artifactLabel; + private String locationArtifactLabel; /** - * Perform activity. Send to asdc proxy. + * Perform activity. Send to sdc proxy. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { String userid = (String) execution.getVariable("userid"); logger.info("userid=" + userid); - String docText = (String) execution.getVariable("docText"); - String artifactName = execution.getVariable("controlName") + DcaeEvent.ARTIFACT_NAME_SUFFIX; + String docText = new String((byte[]) execution.getVariable("docText")); + String artifactName = (String) execution.getVariable("controlName") + DcaeEvent.ARTIFACT_NAME_SUFFIX; execution.setVariable("artifactName", artifactName); - getAsdcAttributes(); + getSdcAttributes((String) execution.getVariable("controlName")); ModelProperties prop = ModelProperties.create(execution); String bluprintPayload = SdcReq.formatBlueprint(refProp, prop, docText); - String formatttedAsdcReq = SdcReq.formatAsdcReq(bluprintPayload, artifactName, artifactLabel, artifactType); - if (formatttedAsdcReq != null) { - execution.setVariable("formattedArtifactReq", formatttedAsdcReq.getBytes()); + String formatttedSdcReq = SdcReq.formatSdcReq(bluprintPayload, artifactName, artifactLabel, artifactType); + if (formatttedSdcReq != null) { + execution.setVariable("formattedArtifactReq", formatttedSdcReq.getBytes()); } - List asdcReqUrlsList = SdcReq.getAsdcReqUrlsList(prop, baseUrl, asdcCatalogServices, execution); + List sdcReqUrlsList = SdcReq.getSdcReqUrlsList(prop, baseUrl, sdcCatalogServices, execution); - String asdcLocationsPayload = SdcReq.formatAsdcLocationsReq(prop, artifactName); - String locationArtifactName = execution.getVariable("controlName") + "-location.json"; - String formattedAsdcLocationReq = SdcReq.formatAsdcReq(asdcLocationsPayload, locationArtifactName, locationArtifactLabel, locationArtifactType); - if (formattedAsdcLocationReq != null) { - execution.setVariable("formattedLocationReq", formattedAsdcLocationReq.getBytes()); + String sdcLocationsPayload = SdcReq.formatSdcLocationsReq(prop, artifactName); + String locationArtifactName = (String) execution.getVariable("controlName") + "-location.json"; + String formattedSdcLocationReq = SdcReq.formatSdcReq(sdcLocationsPayload, locationArtifactName, + locationArtifactLabel, locationArtifactType); + if (formattedSdcLocationReq != null) { + execution.setVariable("formattedLocationReq", formattedSdcLocationReq.getBytes()); } String serviceInvariantUUID = getServiceInvariantUUIDFromProps(prop); - uploadToAsdc(prop, serviceInvariantUUID, userid, asdcReqUrlsList, formatttedAsdcReq, formattedAsdcLocationReq, artifactName, locationArtifactName); + uploadToSdc(prop, serviceInvariantUUID, userid, sdcReqUrlsList, formatttedSdcReq, formattedSdcLocationReq, + artifactName, locationArtifactName); } private String getServiceInvariantUUIDFromProps(ModelProperties props) { @@ -97,42 +101,53 @@ public class SdcSendReqDelegate implements JavaDelegate { return invariantUUID; } - private void uploadToAsdc(ModelProperties prop, String serviceInvariantUUID, String userid, List asdcReqUrlsList, String formatttedAsdcReq, String formattedAsdcLocationReq, String artifactName, String locationArtifactName) throws Exception { + private void uploadToSdc(ModelProperties prop, String serviceInvariantUUID, String userid, + List sdcReqUrlsList, String formatttedSdcReq, String formattedSdcLocationReq, String artifactName, + String locationArtifactName) throws Exception { logger.info("userid=" + userid); - if (asdcReqUrlsList != null && asdcReqUrlsList.size() > 0) { - for (String url : asdcReqUrlsList) { + if (sdcReqUrlsList != null && sdcReqUrlsList.size() > 0) { + for (String url : sdcReqUrlsList) { if (url != null) { - String originalServiceUUID = asdcCatalogServices.getServiceUUIDFromServiceInvariantID(serviceInvariantUUID); + String originalServiceUUID = sdcCatalogServices + .getServiceUuidFromServiceInvariantId(serviceInvariantUUID); logger.info("ServiceUUID used before upload in url:" + originalServiceUUID); - String asdcServicesInformation = asdcCatalogServices.getAsdcServicesInformation(originalServiceUUID); - CldsAsdcServiceDetail cldsAsdcServiceDetail = asdcCatalogServices.getCldsAsdcServiceDetailFromJson(asdcServicesInformation); - String uploadedArtifactUUID = asdcCatalogServices.getArtifactIdIfArtifactAlreadyExists(cldsAsdcServiceDetail, artifactName); - // Upload artifacts to asdc + String sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(originalServiceUUID); + CldsSdcServiceDetail CldsSdcServiceDetail = sdcCatalogServices + .getCldsSdcServiceDetailFromJson(sdcServicesInformation); + String uploadedArtifactUUID = sdcCatalogServices + .getArtifactIdIfArtifactAlreadyExists(CldsSdcServiceDetail, artifactName); + // Upload artifacts to sdc String updateUrl = uploadedArtifactUUID != null ? url + "/" + uploadedArtifactUUID : url; - String responseStr = asdcCatalogServices.uploadArtifactToAsdc(prop, userid, updateUrl, formatttedAsdcReq); - logger.info("value of asdc Response of uploading to asdc :" + responseStr); - String updatedServiceUUID = asdcCatalogServices.getServiceUUIDFromServiceInvariantID(serviceInvariantUUID); + String responseStr = sdcCatalogServices.uploadArtifactToSdc(prop, userid, updateUrl, + formatttedSdcReq); + logger.info("value of sdc Response of uploading to sdc :" + responseStr); + String updatedServiceUUID = sdcCatalogServices + .getServiceUuidFromServiceInvariantId(serviceInvariantUUID); if (!originalServiceUUID.equalsIgnoreCase(updatedServiceUUID)) { url = url.replace(originalServiceUUID, updatedServiceUUID); } logger.info("ServiceUUID used after upload in ulr:" + updatedServiceUUID); - asdcServicesInformation = asdcCatalogServices.getAsdcServicesInformation(updatedServiceUUID); - cldsAsdcServiceDetail = asdcCatalogServices.getCldsAsdcServiceDetailFromJson(asdcServicesInformation); - uploadedArtifactUUID = asdcCatalogServices.getArtifactIdIfArtifactAlreadyExists(cldsAsdcServiceDetail, locationArtifactName); - // To send location information also to asdc + sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(updatedServiceUUID); + CldsSdcServiceDetail = sdcCatalogServices.getCldsSdcServiceDetailFromJson(sdcServicesInformation); + uploadedArtifactUUID = sdcCatalogServices.getArtifactIdIfArtifactAlreadyExists(CldsSdcServiceDetail, + locationArtifactName); + // To send location information also to sdc updateUrl = uploadedArtifactUUID != null ? url + "/" + uploadedArtifactUUID : url; - responseStr = asdcCatalogServices.uploadArtifactToAsdc(prop, userid, updateUrl, formattedAsdcLocationReq); - logger.info("value of asdc Response of uploading location to asdc :" + responseStr); + responseStr = sdcCatalogServices.uploadArtifactToSdc(prop, userid, updateUrl, + formattedSdcLocationReq); + logger.info("value of sdc Response of uploading location to sdc :" + responseStr); } } } } - private void getAsdcAttributes() { - baseUrl = refProp.getStringValue("asdc.serviceUrl"); - artifactLabel = refProp.getStringValue("asdc.artifactLabel"); - locationArtifactLabel = refProp.getStringValue("asdc.locationArtifactLabel"); - artifactType = refProp.getStringValue("asdc.artifactType"); - locationArtifactType = refProp.getStringValue("asdc.locationArtifactType"); + private void getSdcAttributes(String controlName) { + baseUrl = refProp.getStringValue("sdc.serviceUrl"); + artifactLabel = SdcReq + .normalizeResourceInstanceName(refProp.getStringValue("sdc.artifactLabel") + "-" + controlName); + locationArtifactLabel = SdcReq + .normalizeResourceInstanceName(refProp.getStringValue("sdc.locationArtifactLabel") + "-" + controlName); + artifactType = refProp.getStringValue("sdc.artifactType"); + locationArtifactType = refProp.getStringValue("sdc.locationArtifactType"); } } diff --git a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java index 45f17164a..8a31a3b95 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,6 +23,28 @@ package org.onap.clamp.clds.client.req; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.codec.digest.DigestUtils; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.clamp.clds.client.SdcCatalogServices; +import org.onap.clamp.clds.model.CldsSdcResource; +import org.onap.clamp.clds.model.CldsSdcServiceDetail; +import org.onap.clamp.clds.model.prop.Global; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.StringMatch; +import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.refprop.RefProp; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -31,29 +53,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; -import org.onap.clamp.clds.client.SdcCatalogServices; -import org.onap.clamp.clds.model.CldsAsdcResource; -import org.onap.clamp.clds.model.CldsAsdcServiceDetail; -import org.onap.clamp.clds.model.prop.Global; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.StringMatch; -import org.onap.clamp.clds.model.prop.Tca; -import org.onap.clamp.clds.model.refprop.RefProp; -import org.apache.commons.codec.digest.DigestUtils; -import org.camunda.bpm.engine.delegate.DelegateExecution; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.*; -import java.util.Map.Entry; -import java.util.logging.Logger; /** - * Construct a Asdc request given CLDS objects. + * Construct a Sdc request given CLDS objects. */ public class SdcReq { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(SdcReq.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcReq.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); /** * @param refProp @@ -72,14 +78,15 @@ public class SdcReq { String yamlvalue = getYamlvalue(docText); String updatedBlueprint = ""; - StringMatch stringMatch = prop.getStringMatch(); - Tca tca = prop.getTca(); + StringMatch stringMatch = prop.getType(StringMatch.class); + Tca tca = prop.getType(Tca.class); if (stringMatch.isFound()) { prop.setCurrentModelElementId(stringMatch.getId()); ObjectMapper objectMapper = new ObjectMapper(); ObjectNode serviceConfigurations = objectMapper.createObjectNode(); - StringMatchPolicyReq.appendServiceConfigurations(refProp, service, serviceConfigurations, stringMatch); + StringMatchPolicyReq.appendServiceConfigurations(refProp, service, serviceConfigurations, stringMatch, + prop); logger.info("Value of serviceConfigurations:" + serviceConfigurations); ObjectNode servConfNode = (ObjectNode) serviceConfigurations.get("serviceConfigurations"); @@ -111,15 +118,15 @@ public class SdcReq { // Serialiaze Yaml file Map loadedYaml = (Map) yaml.load(yamlValue); // Get node templates information from Yaml - Map nodeTemplates = (Map) loadedYaml.get("node_templates"); + Map nodeTemplates = loadedYaml.get("node_templates"); logger.info("value of NodeTemplates:" + nodeTemplates); // Get StringMatch Object information from node templates of Yaml - Map smObject = (Map) nodeTemplates.get("SM"); + Map smObject = nodeTemplates.get("SM"); logger.info("value of StringMatch:" + smObject); // Get Properties Object information from stringmatch of Yaml - Map propsObject = (Map) smObject.get("properties"); + Map propsObject = smObject.get("properties"); logger.info("value of PropsObject:" + propsObject); String deploymentJsonObject = propsObject.get("deployment_JSON"); @@ -154,15 +161,15 @@ public class SdcReq { // Serialiaze Yaml file Map loadedYaml = (Map) yaml.load(yamlValue); // Get node templates information from Yaml - Map nodeTemplates = (Map) loadedYaml.get("node_templates"); + Map nodeTemplates = loadedYaml.get("node_templates"); logger.info("value of NodeTemplates:" + nodeTemplates); // Get Tca Object information from node templates of Yaml - Map tcaObject = (Map) nodeTemplates.get("MTCA"); + Map tcaObject = nodeTemplates.get("MTCA"); logger.info("value of Tca:" + tcaObject); // Get Properties Object information from tca of Yaml - Map propsObject = (Map) tcaObject.get("properties"); + Map propsObject = tcaObject.get("properties"); logger.info("value of PropsObject:" + propsObject); - String deploymentJsonObject = (String) propsObject.get("deployment_JSON"); + String deploymentJsonObject = propsObject.get("deployment_JSON"); logger.info("value of deploymentJson:" + deploymentJsonObject); ObjectMapper mapper = new ObjectMapper(); @@ -182,7 +189,7 @@ public class SdcReq { return blueprint; } - public static String formatAsdcLocationsReq(ModelProperties prop, String artifactName) { + public static String formatSdcLocationsReq(ModelProperties prop, String artifactName) { ObjectMapper objectMapper = new ObjectMapper(); Global global = prop.getGlobal(); List locationsList = global.getLocation(); @@ -198,7 +205,7 @@ public class SdcReq { return locationJsonFormat; } - public static String formatAsdcReq(String payloadData, String artifactName, String artifactLabel, + public static String formatSdcReq(String payloadData, String artifactName, String artifactLabel, String artifactType) throws IOException { logger.info("artifact=" + payloadData); String base64Artifact = base64Encode(payloadData); @@ -208,7 +215,7 @@ public class SdcReq { + "} \n"; } - public static String getAsdcReqUrl(ModelProperties prop, String url) { + public static String getSdcReqUrl(ModelProperties prop, String url) { Global globalProps = prop.getGlobal(); String serviceUUID = ""; String resourceInstanceName = ""; @@ -234,7 +241,7 @@ public class SdcReq { * @return * @throws Exception */ - public static List getAsdcReqUrlsList(ModelProperties prop, String baseUrl, + public static List getSdcReqUrlsList(ModelProperties prop, String baseUrl, SdcCatalogServices sdcCatalogServices, DelegateExecution execution) throws Exception { // TODO : refact and regroup with very similar code List urlList = new ArrayList<>(); @@ -244,18 +251,21 @@ public class SdcReq { String serviceInvariantUUID = globalProps.getService(); execution.setVariable("serviceInvariantUUID", serviceInvariantUUID); List resourceVfList = globalProps.getResourceVf(); - String serviceUUID = sdcCatalogServices.getServiceUUIDFromServiceInvariantID(serviceInvariantUUID); - String asdcServicesInformation = sdcCatalogServices.getAsdcServicesInformation(serviceUUID); - CldsAsdcServiceDetail cldsAsdcServiceDetail = sdcCatalogServices.getCldsAsdcServiceDetailFromJson(asdcServicesInformation); - if (cldsAsdcServiceDetail != null && resourceVfList != null) { - List cldsAsdcResourcesList = cldsAsdcServiceDetail.getResources(); - if (cldsAsdcResourcesList != null && cldsAsdcResourcesList.size() > 0) { - for (CldsAsdcResource cldsAsdcResource : cldsAsdcResourcesList) { - if (cldsAsdcResource != null && cldsAsdcResource.getResoucreType() != null - && cldsAsdcResource.getResoucreType().equalsIgnoreCase("VF")) { - if (resourceVfList.contains(cldsAsdcResource.getResourceInvariantUUID())) { - String normalizedResourceInstanceName = normalizeResourceInstanceName(cldsAsdcResource.getResourceInstanceName()); - String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" + normalizedResourceInstanceName + "/artifacts"; + String serviceUUID = sdcCatalogServices.getServiceUuidFromServiceInvariantId(serviceInvariantUUID); + String sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(serviceUUID); + CldsSdcServiceDetail CldsSdcServiceDetail = sdcCatalogServices + .getCldsSdcServiceDetailFromJson(sdcServicesInformation); + if (CldsSdcServiceDetail != null && resourceVfList != null) { + List CldsSdcResourcesList = CldsSdcServiceDetail.getResources(); + if (CldsSdcResourcesList != null && CldsSdcResourcesList.size() > 0) { + for (CldsSdcResource CldsSdcResource : CldsSdcResourcesList) { + if (CldsSdcResource != null && CldsSdcResource.getResoucreType() != null + && CldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { + if (resourceVfList.contains(CldsSdcResource.getResourceInvariantUUID())) { + String normalizedResourceInstanceName = normalizeResourceInstanceName( + CldsSdcResource.getResourceInstanceName()); + String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" + + normalizedResourceInstanceName + "/artifacts"; urlList.add(svcUrl); } } @@ -269,8 +279,8 @@ public class SdcReq { /** * "Normalize" the resource instance name: - Remove spaces, underscores, - * dashes, and periods. - make lower case This is required by ASDC when - * using the resource instance name to upload an artifact. + * dashes, and periods. - make lower case This is required by SDC when using + * the resource instance name to upload an artifact. * * @param inText * @return @@ -323,15 +333,15 @@ public class SdcReq { } /** - * Return ASDC id and pw as a HTTP Basic Auth string (for example: Basic + * Return SDC id and pw as a HTTP Basic Auth string (for example: Basic * dGVzdDoxMjM0NTY=). * * @return */ - public static String getAsdcBasicAuth(RefProp refProp) { - String asdcId = refProp.getStringValue("asdc.serviceUsername"); - String asdcPw = refProp.getStringValue("asdc.servicePassword"); - String idPw = base64Encode(asdcId + ":" + asdcPw); + public static String getSdcBasicAuth(RefProp refProp) { + String sdcId = refProp.getStringValue("sdc.serviceUsername"); + String sdcPw = refProp.getStringValue("sdc.servicePassword"); + String idPw = base64Encode(sdcId + ":" + sdcPw); return "Basic " + idPw; } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcArtifact.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcArtifact.java new file mode 100644 index 000000000..48f90170c --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsSdcArtifact.java @@ -0,0 +1,112 @@ +/*- + * ============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.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CldsSdcArtifact { + + private String artifactName; + private String artifactType; + private String artifactUrl; + private String artifactDescription; + private String artifactTimeout; + private String artifactChecksum; + private String artifactUuid; + private String artifactVersion; + private String generatedFromUuid; + + public String getArtifactName() { + return artifactName; + } + + public void setArtifactName(String artifactName) { + this.artifactName = artifactName; + } + + public String getArtifactType() { + return artifactType; + } + + public void setArtifactType(String artifactType) { + this.artifactType = artifactType; + } + + public String getArtifactURL() { + return artifactUrl; + } + + public void setArtifactURL(String artifactURL) { + this.artifactUrl = artifactURL; + } + + public String getArtifactDescription() { + return artifactDescription; + } + + public void setArtifactDescription(String artifactDescription) { + this.artifactDescription = artifactDescription; + } + + public String getArtifactTimeout() { + return artifactTimeout; + } + + public void setArtifactTimeout(String artifactTimeout) { + this.artifactTimeout = artifactTimeout; + } + + public String getArtifactChecksum() { + return artifactChecksum; + } + + public void setArtifactChecksum(String artifactChecksum) { + this.artifactChecksum = artifactChecksum; + } + + public String getArtifactUUID() { + return artifactUuid; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUuid = artifactUUID; + } + + public String getArtifactVersion() { + return artifactVersion; + } + + public void setArtifactVersion(String artifactVersion) { + this.artifactVersion = artifactVersion; + } + + public String getGeneratedFromUUID() { + return generatedFromUuid; + } + + public void setGeneratedFromUUID(String generatedFromUUID) { + this.generatedFromUuid = generatedFromUUID; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java new file mode 100644 index 000000000..7fa741c8b --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java @@ -0,0 +1,135 @@ +/*- + * ============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.model; + +import java.math.BigDecimal; +import java.util.List; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CldsSdcResource implements Comparable { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcResource.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + private String resourceInstanceName; + private String resourceName; + private String resourceInvariantUuid; + private String resourceVersion; + private String resoucreType; + private String resourceUuid; + private List artifacts; + + public String getResourceInstanceName() { + return resourceInstanceName; + } + + public void setResourceInstanceName(String resourceInstanceName) { + this.resourceInstanceName = resourceInstanceName; + } + + public String getResourceName() { + return resourceName; + } + + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + + public String getResourceInvariantUUID() { + return resourceInvariantUuid; + } + + public void setResourceInvariantUUID(String resourceInvariantUUID) { + this.resourceInvariantUuid = resourceInvariantUUID; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public String getResoucreType() { + return resoucreType; + } + + public void setResoucreType(String resoucreType) { + this.resoucreType = resoucreType; + } + + public String getResourceUUID() { + return resourceUuid; + } + + public void setResourceUUID(String resourceUUID) { + this.resourceUuid = resourceUUID; + } + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } + + @Override + public int compareTo(CldsSdcResource in) { + // Compares this object with the specified object for order. + // Returns a negative integer, zero, or a positive integer as this + // object is less than, equal to, or greater than the specified object. + + // first compare based on name + int rtn = resourceInstanceName.compareToIgnoreCase(in.resourceInstanceName); + + if (rtn == 0) { + BigDecimal myVersion = convertVersion(resourceVersion); + BigDecimal inVersion = convertVersion(in.resourceVersion); + rtn = myVersion.compareTo(inVersion); + } + return rtn; + } + + /** + * Convert version String into a BigDecimal + * + * @param versionText + * @return + */ + private BigDecimal convertVersion(String versionText) { + BigDecimal rtn = new BigDecimal(0.0); + try { + rtn = new BigDecimal(versionText); + } catch (NumberFormatException nfe) { + logger.warn("SDC version=" + versionText + " is not decimal for name=" + resourceInstanceName); + } + return rtn; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java new file mode 100644 index 000000000..80fa787ee --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java @@ -0,0 +1,164 @@ +/*- + * ============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.model; + +import java.math.BigDecimal; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CldsSdcResourceBasicInfo implements Comparable { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcResourceBasicInfo.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String subCategory; + private String resourceType; + private String lifecycleState; + private String lastUpdaterUserId; + + @Override + public int compareTo(CldsSdcResourceBasicInfo in) { + // Compares this object with the specified object for order. + // Returns a negative integer, zero, or a positive integer as this + // object is less than, equal to, or greater than the specified object. + // first compare based on name + int rtn = name.compareToIgnoreCase(in.name); + + if (rtn == 0) { + BigDecimal myVersion = convertVersion(version); + BigDecimal inVersion = convertVersion(in.version); + rtn = myVersion.compareTo(inVersion); + } + return rtn; + } + + /** + * Convert version String into a BigDecimal + * + * @param version + * @return + */ + private BigDecimal convertVersion(String version) { + BigDecimal rtn = new BigDecimal(0.0); + try { + rtn = new BigDecimal(version); + } catch (NumberFormatException nfe) { + logger.warn("SDC version=" + version + " is not decimal for name=" + name); + } + return rtn; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + public String getResourceType() { + return resourceType; + } + + public void setResourceType(String resourceType) { + this.resourceType = resourceType; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public EELFLogger getLOGGER() { + return logger; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceDetail.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceDetail.java new file mode 100644 index 000000000..551418b79 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceDetail.java @@ -0,0 +1,142 @@ +/*- + * ============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.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CldsSdcServiceDetail { + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String lifecycleState; + private String lastUpdaterUserId; + private String distributionStatus; + private String lastUpdaterFullName; + private List resources; + private List artifacts; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getDistributionStatus() { + return distributionStatus; + } + + public void setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + } + + public String getLastUpdaterFullName() { + return lastUpdaterFullName; + } + + public void setLastUpdaterFullName(String lastUpdaterFullName) { + this.lastUpdaterFullName = lastUpdaterFullName; + } + + public List getResources() { + return resources; + } + + public void setResources(List resources) { + this.resources = resources; + } + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceInfo.java new file mode 100644 index 000000000..175dc753c --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsSdcServiceInfo.java @@ -0,0 +1,153 @@ +/*- + * ============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.model; + +import java.math.BigDecimal; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class CldsSdcServiceInfo implements Comparable { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcServiceInfo.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String lifecycleState; + private String lastUpdaterUserId; + private String distributionStatus; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getInvariantUUID() { + return invariantUUID; + } + + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getToscaModelURL() { + return toscaModelURL; + } + + public void setToscaModelURL(String toscaModelURL) { + this.toscaModelURL = toscaModelURL; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(String lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public String getLastUpdaterUserId() { + return lastUpdaterUserId; + } + + public void setLastUpdaterUserId(String lastUpdaterUserId) { + this.lastUpdaterUserId = lastUpdaterUserId; + } + + public String getDistributionStatus() { + return distributionStatus; + } + + public void setDistributionStatus(String distributionStatus) { + this.distributionStatus = distributionStatus; + } + + /** + * Compare using name and then version. Version is converted to a decimal. + */ + @Override + public int compareTo(CldsSdcServiceInfo in) { + // Compares this object with the specified object for order. + // Returns a negative integer, zero, or a positive integer as this + // object is less than, equal to, or greater than the specified object. + // first compare based on name + int rtn = name.compareToIgnoreCase(in.name); + + if (rtn == 0) { + BigDecimal myVersion = convertVersion(version); + BigDecimal inVersion = convertVersion(in.version); + rtn = myVersion.compareTo(inVersion); + } + + return rtn; + } + + /** + * Convert version String into a BigDecimal + * + * @param versionText + * @return + */ + private BigDecimal convertVersion(String versionText) { + try { + return new BigDecimal(versionText); + } catch (NumberFormatException nfe) { + logger.warn("SDC version=" + versionText + " is not decimal for name=" + name); + } + return new BigDecimal(0.0); + } + +} diff --git a/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java b/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java index f4d693fe6..e7cb5c859 100644 --- a/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java +++ b/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java @@ -27,8 +27,8 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Assert; import org.junit.Test; import org.onap.clamp.clds.client.SdcCatalogServices; -import org.onap.clamp.clds.model.CldsAsdcResource; -import org.onap.clamp.clds.model.CldsAsdcServiceDetail; +import org.onap.clamp.clds.model.CldsSdcResource; +import org.onap.clamp.clds.model.CldsSdcServiceDetail; import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; @@ -38,50 +38,47 @@ import java.util.List; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -/** - * Created by Julien Bertozzi on 6/20/17. - */ public class SdcReqTest { String baseUrl = "AYBABTU"; String serviceInvariantUUID = "serviceInvariantUUID"; @Test - public void getAsdcReqUrlsListNoGlobalPropTest() throws Exception { + public void getSdcReqUrlsListNoGlobalPropTest() throws Exception { ModelProperties prop = mock(ModelProperties.class); SdcCatalogServices sdcCatalogServices = mock(SdcCatalogServices.class); DelegateExecution delegateExecution = mock(DelegateExecution.class); Global global = mock(Global.class); - CldsAsdcServiceDetail cldsAsdcServiceDetail = mock(CldsAsdcServiceDetail.class); - CldsAsdcResource cldsAsdcResource = mock(CldsAsdcResource.class); - List cldsAsdcResources = new ArrayList<>(); - cldsAsdcResources.add(cldsAsdcResource); + CldsSdcServiceDetail CldsSdcServiceDetail = mock(CldsSdcServiceDetail.class); + CldsSdcResource CldsSdcResource = mock(CldsSdcResource.class); + List CldsSdcResources = new ArrayList<>(); + CldsSdcResources.add(CldsSdcResource); List resourceVf = new ArrayList<>(); resourceVf.add(serviceInvariantUUID); - Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); + Assert.assertTrue(SdcReq.getSdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); when(prop.getGlobal()).thenReturn(global); - Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); + Assert.assertTrue(SdcReq.getSdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); when(global.getService()).thenReturn(serviceInvariantUUID); - Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); + Assert.assertTrue(SdcReq.getSdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); - when(sdcCatalogServices.getCldsAsdcServiceDetailFromJson(null)).thenReturn(cldsAsdcServiceDetail); + when(sdcCatalogServices.getCldsSdcServiceDetailFromJson(null)).thenReturn(CldsSdcServiceDetail); when(global.getResourceVf()).thenReturn(new ArrayList<>()); - Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); + Assert.assertTrue(SdcReq.getSdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); - when(cldsAsdcServiceDetail.getResources()).thenReturn(cldsAsdcResources); - Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); + when(CldsSdcServiceDetail.getResources()).thenReturn(CldsSdcResources); + Assert.assertTrue(SdcReq.getSdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); - when(cldsAsdcResource.getResoucreType()).thenReturn("VF"); - Assert.assertTrue(SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); + when(CldsSdcResource.getResoucreType()).thenReturn("VF"); + Assert.assertTrue(SdcReq.getSdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution).isEmpty()); when(global.getResourceVf()).thenReturn(resourceVf); - when(cldsAsdcResource.getResourceInvariantUUID()).thenReturn(serviceInvariantUUID); - when(cldsAsdcResource.getResourceInstanceName()).thenReturn("Resource instance name"); + when(CldsSdcResource.getResourceInvariantUUID()).thenReturn(serviceInvariantUUID); + when(CldsSdcResource.getResourceInstanceName()).thenReturn("Resource instance name"); List expected = new ArrayList<>(); expected.add("AYBABTU/null/resourceInstances/resourceinstancename/artifacts"); - Assert.assertEquals(expected, SdcReq.getAsdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution)); + Assert.assertEquals(expected, SdcReq.getSdcReqUrlsList(prop, baseUrl, sdcCatalogServices, delegateExecution)); } } diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java new file mode 100644 index 000000000..159e66ac5 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java @@ -0,0 +1,289 @@ +/*- + * ============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.it; + +import static org.junit.Assert.assertTrue; + +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.clamp.clds.AbstractIT; +import org.onap.clamp.clds.client.SdcCatalogServices; +import org.onap.clamp.clds.model.CldsAlarmCondition; +import org.onap.clamp.clds.model.CldsSdcResource; +import org.onap.clamp.clds.model.CldsSdcResourceBasicInfo; +import org.onap.clamp.clds.model.CldsSdcServiceInfo; +import org.onap.clamp.clds.model.CldsServiceData; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE + * Delegates in test. + */ +@RunWith(SpringRunner.class) +@SpringBootTest +public class SdcCatalogServicesIT extends AbstractIT { + @Autowired + private SdcCatalogServices sdcCatalogWired = new SdcCatalogServices(); + + @Test + public void removeDuplicateServicesTest() throws Exception { + SdcCatalogServices catalogServices = new SdcCatalogServices(); + List rawCldsSdcServiceList = new LinkedList(); + + CldsSdcServiceInfo service1a = new CldsSdcServiceInfo(); + service1a.setName("service1"); + service1a.setVersion("1.0"); + service1a.setInvariantUUID("invariantUUID1.0"); + rawCldsSdcServiceList.add(service1a); + rawCldsSdcServiceList.add(service1a); + + CldsSdcServiceInfo service1b = new CldsSdcServiceInfo(); + service1b.setName("service1"); + service1b.setVersion("1.1"); + service1b.setInvariantUUID("invariantUUID1.1"); + rawCldsSdcServiceList.add(service1b); + + CldsSdcServiceInfo service1c = new CldsSdcServiceInfo(); + service1c.setName("service1"); + service1c.setVersion("1.2"); + service1c.setInvariantUUID("invariantUUID1.2"); + rawCldsSdcServiceList.add(service1c); + + CldsSdcServiceInfo service2 = new CldsSdcServiceInfo(); + service2.setName("service2"); + service2.setVersion("1.0"); + service2.setInvariantUUID("invariantUUID2.0"); + rawCldsSdcServiceList.add(service2); + + List resultList = catalogServices.removeDuplicateServices(rawCldsSdcServiceList); + + assertTrue(resultList.size() == 2); + + CldsSdcServiceInfo res1, res2; + if ("service1".equals(resultList.get(0).getName())) { + res1 = resultList.get(0); + res2 = resultList.get(1); + } else { + res1 = resultList.get(1); + res2 = resultList.get(0); + } + + assertTrue("service1".equals(res1.getName())); + assertTrue("1.2".equals(res1.getVersion())); + + assertTrue("service2".equals(res2.getName())); + assertTrue("1.0".equals(res2.getVersion())); + + } + + @Test + public void removeDuplicateSdcResourceInstancesTest() { + SdcCatalogServices catalogServices = new SdcCatalogServices(); + List rawCldsSdcResourceList = new LinkedList(); + + CldsSdcResource sdcResource1a = new CldsSdcResource(); + sdcResource1a.setResourceInstanceName("resource1"); + sdcResource1a.setResourceVersion("1.0"); + rawCldsSdcResourceList.add(sdcResource1a); + + CldsSdcResource sdcResource1b = new CldsSdcResource(); + sdcResource1b.setResourceInstanceName("resource1"); + sdcResource1b.setResourceVersion("1.1"); + rawCldsSdcResourceList.add(sdcResource1b); + + CldsSdcResource sdcResource1c = new CldsSdcResource(); + sdcResource1c.setResourceInstanceName("resource1"); + sdcResource1c.setResourceVersion("1.2"); + rawCldsSdcResourceList.add(sdcResource1c); + + CldsSdcResource sdcResource2 = new CldsSdcResource(); + sdcResource2.setResourceInstanceName("resource2"); + sdcResource2.setResourceVersion("1.0"); + rawCldsSdcResourceList.add(sdcResource2); + + List resultList = catalogServices.removeDuplicateSdcResourceInstances(rawCldsSdcResourceList); + + CldsSdcResource res1, res2; + if ("resource1".equals(resultList.get(0).getResourceInstanceName())) { + res1 = resultList.get(0); + res2 = resultList.get(1); + } else { + res1 = resultList.get(1); + res2 = resultList.get(0); + } + + assertTrue("resource1".equals(res1.getResourceInstanceName())); + assertTrue("1.2".equals(res1.getResourceVersion())); + + assertTrue("resource2".equals(res2.getResourceInstanceName())); + assertTrue("1.0".equals(res2.getResourceVersion())); + + } + + @Test + public void removeDuplicateSdcResourceBasicInfoTest() { + + SdcCatalogServices catalogServices = new SdcCatalogServices(); + List rawCldsSdcResourceList = new LinkedList(); + + CldsSdcResourceBasicInfo sdcResource1a = new CldsSdcResourceBasicInfo(); + sdcResource1a.setName("resource1"); + sdcResource1a.setVersion("1.0"); + rawCldsSdcResourceList.add(sdcResource1a); + + CldsSdcResourceBasicInfo sdcResource1b = new CldsSdcResourceBasicInfo(); + sdcResource1b.setName("resource1"); + sdcResource1b.setVersion("1.1"); + rawCldsSdcResourceList.add(sdcResource1b); + + CldsSdcResourceBasicInfo sdcResource1c = new CldsSdcResourceBasicInfo(); + sdcResource1c.setName("resource1"); + sdcResource1c.setVersion("1.2"); + rawCldsSdcResourceList.add(sdcResource1c); + + CldsSdcResourceBasicInfo sdcResource2 = new CldsSdcResourceBasicInfo(); + sdcResource2.setName("resource2"); + sdcResource2.setVersion("1.0"); + rawCldsSdcResourceList.add(sdcResource2); + + List resultList = catalogServices + .removeDuplicateSdcResourceBasicInfo(rawCldsSdcResourceList); + + CldsSdcResourceBasicInfo res1, res2; + if ("resource1".equals(resultList.get(0).getName())) { + res1 = resultList.get(0); + res2 = resultList.get(1); + } else { + res1 = resultList.get(1); + res2 = resultList.get(0); + } + + assertTrue("resource1".equals(res1.getName())); + assertTrue("1.2".equals(res1.getVersion())); + + assertTrue("resource2".equals(res2.getName())); + assertTrue("1.0".equals(res2.getVersion())); + + } + + @Test + public void getServiceUuidFromServiceInvariantIdTest() throws Exception { + SdcCatalogServices aSpy = Mockito.spy(sdcCatalogWired); + Mockito.when(aSpy.getSdcServicesInformation(null)).thenReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")); + + // Try the vcts4 version 1.0, this one should be replaced by 1.1 so it + // should not exist, returning empty string + String resUuidVcts4Null = aSpy.getServiceUuidFromServiceInvariantId("a33ed748-3477-4434-b3f3-b5560f5e7d9b"); + assertTrue("".equals(resUuidVcts4Null)); + + // Try the vcts4 version 1.1, this one should be there as it replaces + // the vcts4 v1.0 + String resUuidVcts4Latest = aSpy.getServiceUuidFromServiceInvariantId("a33ed748-3477-4434-b3f3-b5560f5e7d9c"); + assertTrue("29018914-966c-442d-9d08-251b9dc45b8f".equals(resUuidVcts4Latest)); + + // Try the vcts5 version 1.0, this one should be there + String resUuidVcts5 = aSpy.getServiceUuidFromServiceInvariantId("a33ed748-3477-4434-b3f3-b5560f5e7d8c"); + assertTrue("29018914-966c-442d-9d08-251b9dc45b7f".equals(resUuidVcts5)); + + // try one that does not exist at all + String resUuidUnknown = aSpy.getServiceUuidFromServiceInvariantId("testuuid"); + assertTrue("".equals(resUuidUnknown)); + + } + + @Test + public void getCldsServiceDataWithAlarmConditionsTest() throws Exception { + SdcCatalogServices aSpy = Mockito.spy(sdcCatalogWired); + Mockito.when(aSpy.getSdcServicesInformation(null)).thenReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")); + + // This invariant uuid is the one from vcts4 v1.1 + String serviceResourceDetailUrl = refProp.getStringValue("sdc.serviceUrl") + + "/29018914-966c-442d-9d08-251b9dc45b8f/metadata"; + Mockito.when(aSpy.getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl, false)) + .thenReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServiceDetailsExample.json"), + "UTF-8")); + + String resourceDetailUrl = refProp.getStringValue("sdc.catalog.url") + + "resources/585822c7-4027-4f84-ba50-e9248606f136/metadata"; + Mockito.when(aSpy.getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl, false)) + .thenReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcResourceDetailsExample.json"), + "UTF-8")); + + String securityRulesDetailUrl = refProp.getStringValue("sdc.catalog.url") + + "resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/metadata"; + Mockito.when(aSpy.getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl, false)).thenReturn( + IOUtils.toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcSecurityRules.json"), + "UTF-8")); + + String cinderVolumeDetailUrl = refProp.getStringValue("sdc.catalog.url") + + "resources/b4288e07-597a-44a2-aa98-ad36e551a39d/metadata"; + Mockito.when(aSpy.getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl, false)).thenReturn( + IOUtils.toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcCinderVolume.json"), + "UTF-8")); + + String vfcGenericDetailUrl = refProp.getStringValue("sdc.catalog.url") + + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/metadata"; + Mockito.when(aSpy.getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl, false)).thenReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFCGenericWithAlarms.json"), "UTF-8")); + + String csvDetailUrl = "/sdc/v1/catalog/resources/84855843-5247-4e97-a2bd-5395a510253b/artifacts/d57ac7ec-f3c3-4793-983a-c75ac3a43153"; + Mockito.when(aSpy.getResponsesFromArtifactUrl(csvDetailUrl)).thenReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcMeasurementsList.csv"), "UTF-8")); + + String csvAlarmsDetailUrl = "/sdc/v1/catalog/resources/2c8f1219-8000-4001-aa13-496a0396d40f/resourceInstances/virc_fe_be/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392"; + Mockito.when(aSpy.getResponsesFromArtifactUrl(csvAlarmsDetailUrl)).thenReturn(IOUtils + .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8")); + + String allVfResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VF"; + Mockito.when(aSpy.getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl, false)).thenReturn(IOUtils + .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFResources.json"), "UTF-8")); + + String allVfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VFC"; + Mockito.when(aSpy.getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl, false)).thenReturn( + IOUtils.toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFCResources.json"), + "UTF-8")); + + CldsServiceData cldsServiceData = aSpy + .getCldsServiceDataWithAlarmConditions("a33ed748-3477-4434-b3f3-b5560f5e7d9c"); + assertTrue("a33ed748-3477-4434-b3f3-b5560f5e7d9c".equals(cldsServiceData.getServiceInvariantUUID())); + assertTrue("29018914-966c-442d-9d08-251b9dc45b8f".equals(cldsServiceData.getServiceUUID())); + assertTrue(cldsServiceData.getCldsVfs().size() == 1); + + List alarmsList = aSpy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData); + assertTrue(alarmsList.size() == 6); + + } + +} diff --git a/src/test/java/org/onap/clamp/clds/it/SdcIT.java b/src/test/java/org/onap/clamp/clds/it/SdcIT.java new file mode 100644 index 000000000..0d8acbff9 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/it/SdcIT.java @@ -0,0 +1,87 @@ +/*- + * ============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.it; + +import org.onap.clamp.clds.AbstractIT; +import org.onap.clamp.clds.client.req.SdcReq; +import org.onap.clamp.clds.model.CldsEvent; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.transform.TransformUtil; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.client.SdcCatalogServices; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.junit.BeforeClass; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE Delegates in test. + */ +@RunWith(SpringRunner.class) +@SpringBootTest +public class SdcIT extends AbstractIT { + @Autowired + private RefProp refProp; + + @Autowired + private SdcCatalogServices sdcCatalogServices; + + @BeforeClass + public static void oneTimeSetUp() { + System.setProperty("AJSC_CONF_HOME", System.getProperty("user.dir") + "/src/test/resources/"); + } + + @Test + public void testBlueprint() throws Exception { + String modelProp = TransformUtil.getResourceAsString("example/modelProp.json"); + String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnProp.json"); + String modelName = "example-model06"; + String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; + String docText = TransformUtil.getResourceAsString("example/templateProp.json"); + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, modelProp); + String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); + System.out.println("blueprint=" + blueprint); + //assertEquals(blueprint, ""); + } + + + @Test + public void testTcaBlueprint() throws Exception { + String modelProp = TransformUtil.getResourceAsString("example/modelPropForPolicy.json"); + String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnPropForPolicy.json"); + String modelName = "example-model06"; + String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; + + String docText = TransformUtil.getResourceAsString("example/templatePropForTca.json"); + + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, modelProp); + String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); + + System.out.println("blueprint=" + blueprint); + //assertEquals(blueprint, ""); + } +} diff --git a/src/test/resources/example/sdc/sdcAlarmsList.csv b/src/test/resources/example/sdc/sdcAlarmsList.csv new file mode 100644 index 000000000..247dcd9aa --- /dev/null +++ b/src/test/resources/example/sdc/sdcAlarmsList.csv @@ -0,0 +1,13 @@ +,EventSourceType,,AlarmCondition,Severity + +eventType,VPMS,alarmCondition,SwRestart,CRITICAL + +eventType,VPMS,alarmCondition,SwRestart,WARNING + +eventType,VPMS,alarmCondition,SwRestart,OK + +eventType,VPMS,alarmCondition,IsAlive,CRITICAL + +eventType,VPMS,alarmCondition,IsAlive,WARNING + +eventType,VPMS,alarmCondition,IsAlive,OK diff --git a/src/test/resources/example/sdc/sdcCinderVolume.json b/src/test/resources/example/sdc/sdcCinderVolume.json new file mode 100644 index 000000000..b5ffe6465 --- /dev/null +++ b/src/test/resources/example/sdc/sdcCinderVolume.json @@ -0,0 +1,15 @@ +{ + "uuid": "b4288e07-597a-44a2-aa98-ad36e551a39d", + "invariantUUID": "61dc85d2-5e17-480e-a71f-8f6d59a0ead2", + "name": "CinderVolume", + "version": "5.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b4288e07-597a-44a2-aa98-ad36e551a39d/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003", + "lastUpdaterFullName": "Jimmy Hendrix", + "toscaResourceName": "org.openecomp.resource.vfc.nodes.heat.cinder.Volume", + "description": "Represents a server-local block storage device that provides persistent storage to guest virtual machines. " +} \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcMeasurementsList.csv b/src/test/resources/example/sdc/sdcMeasurementsList.csv new file mode 100644 index 000000000..c04a3489e --- /dev/null +++ b/src/test/resources/example/sdc/sdcMeasurementsList.csv @@ -0,0 +1,17 @@ +fieldPath,$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMRAATTCBRA')].Value,thresholdName,PMRAATTCBRA ,nfNamingCode,ENBE + +fieldPath,$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMRASUCCCBRA')].Value,thresholdName,PMRASUCCCBRA ,nfNamingCode,ENBE + +fieldPath,$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMCELLDOWNTIMEAUTO')].Value,thresholdName,PMCELLDOWNTIMEAUTO ,nfNamingCode,ENBE + +fieldPath,$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMCELLDOWNTIMEMAN')].Value,thresholdName,PMCELLDOWNTIMEMAN ,nfNamingCode,ENBE + +fieldPath,$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMRRCCONNESTABATT')].Value,thresholdName,PMRRCCONNESTABATT ,nfNamingCode,ENBE + +fieldPath,$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMRRCCONNESTABSUCC')].Value,thresholdName,PMRRCCONNESTABSUCC ,nfNamingCode,ENBE + +fieldPath,$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMCELLDOWNTIMEAUTO')].Value,thresholdName,PMCELLDOWNTIMEAUTO ,nfNamingCode,ENBE + +fieldPath,$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMCELLDOWNTIMEMAN')].Value,thresholdName,PMCELLDOWNTIMEMAN ,nfNamingCode,ENBE + +fieldPath,$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMRRCCONNESTABFAILCELLLATENCY')].Value,thresholdName,PMRRCCONNESTABFAILCELLLATENCY,nfNamingCode,ENBE \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcResourceDetailsExample.json b/src/test/resources/example/sdc/sdcResourceDetailsExample.json new file mode 100644 index 000000000..6087d020f --- /dev/null +++ b/src/test/resources/example/sdc/sdcResourceDetailsExample.json @@ -0,0 +1,126 @@ +{ + "uuid": "585822c7-4027-4f84-ba50-e9248606f136", + "invariantUUID": "585822c7-4027-4f84-ba50-e9248606f134", + "name": "resourceName-1", + "version": "3.0", + "toscaModelURL": "/sdc/v1/catalog/resources/585822c7-4027-4f84-ba50-e9248606f136/toscaModel", + "category": "Network L2-3", + "subCategory": "Router", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743", + "lastUpdaterFullName": "Three ASDCMech", + "toscaResourceName": "org.openecomp.resource.vf.ClampDev", + "resources": + [ + { + "resourceInstanceName": "abstract_virc_fe_be_0", + "resourceName": "CLAMP-Dev-nodes.virc_fe_be_0", + "resourceInvariantUUID": "133dd665-fca8-4e8b-8126-9e74a8d23bf5", + "resourceVersion": "1.0", + "resoucreType": "CVFC", + "resourceUUID": "a0475018-1e7e-4ddd-8bee-33cbf958c2e6" + }, + + { + "resourceInstanceName": "virc_fe_be_RSG", + "resourceName": "SecurityRules", + "resourceInvariantUUID": "dd31d2de-0a7f-4198-8966-3a04100fbfe3", + "resourceVersion": "1.0", + "resoucreType": "VFC", + "resourceUUID": "d57e57d2-e3c6-470d-8d16-e6ea05f536c5" + }, + + { + "resourceInstanceName": "abstract_virc_fe_be_1", + "resourceName": "CLAMP-Dev-nodes.virc_fe_be_1", + "resourceInvariantUUID": "096ff622-d7ea-4482-b7fe-8c7d99e7d7c6", + "resourceVersion": "1.0", + "resoucreType": "VFC", + "resourceUUID": "2c8f1219-8000-4001-aa13-496a0396d40f" + }, + + { + "resourceInstanceName": "virc_fe_be_volume_1", + "resourceName": "CinderVolume", + "resourceInvariantUUID": "61dc85d2-5e17-480e-a71f-8f6d59a0ead2", + "resourceVersion": "5.0", + "resoucreType": "VFC", + "resourceUUID": "b4288e07-597a-44a2-aa98-ad36e551a39d" + }, + + { + "resourceInstanceName": "virc_fe_be_volume_0", + "resourceName": "CinderVolume", + "resourceInvariantUUID": "61dc85d2-5e17-480e-a71f-8f6d59a0ead2", + "resourceVersion": "5.0", + "resoucreType": "VFC", + "resourceUUID": "b4288e07-597a-44a2-aa98-ad36e551a39d" + } + ], + + "artifacts": + [ + { + "artifactName": "vf-license-model.xml", + "artifactType": "VF_LICENSE", + "artifactURL": "/sdc/v1/catalog/resources/91854bc8-534f-4249-899c-bbdc06f83436/artifacts/16ec4971-5f3d-4f29-b22e-4c9ede6fdd97", + "artifactDescription": "VF license file", + "artifactChecksum": "MGUwM2MzZmMyNTBhNzlmNjY2NjJmMTk1MjMwNjRlNzY=", + "artifactUUID": "16ec4971-5f3d-4f29-b22e-4c9ede6fdd97", + "artifactVersion": "1", + "artifactLabel": "vflicense", + "artifactGroupType": "DEPLOYMENT" + }, + + { + "artifactName": "base_fe_be.yaml", + "artifactType": "HEAT", + "artifactURL": "/sdc/v1/catalog/resources/91854bc8-534f-4249-899c-bbdc06f83436/artifacts/18fd7704-9fe7-40c6-bde2-a1753111a1af", + "artifactDescription": "created from csar", + "artifactTimeout": 60, + "artifactChecksum": "NTUyYjdlMDA1MGNmOGViZjA4OWQyOWEzNGU3NDM4OTk=", + "artifactUUID": "18fd7704-9fe7-40c6-bde2-a1753111a1af", + "artifactVersion": "2", + "artifactLabel": "heat1", + "artifactGroupType": "DEPLOYMENT" + }, + + { + "artifactName": "vendor-license-model.xml", + "artifactType": "VENDOR_LICENSE", + "artifactURL": "/sdc/v1/catalog/resources/91854bc8-534f-4249-899c-bbdc06f83436/artifacts/7ad72757-b35e-4084-954d-9f9d447f7a98", + "artifactDescription": " Vendor license file", + "artifactChecksum": "ZTFlYWYxYmEzY2ZiMmZmMDMyNWEyMmM2ZjI4ZjM1NTY=", + "artifactUUID": "7ad72757-b35e-4084-954d-9f9d447f7a98", + "artifactVersion": "1", + "artifactLabel": "vendorlicense", + "artifactGroupType": "DEPLOYMENT" + }, + + { + "artifactName": "user_data.sh", + "artifactType": "HEAT_ARTIFACT", + "artifactURL": "/sdc/v1/catalog/resources/91854bc8-534f-4249-899c-bbdc06f83436/artifacts/dff5a82d-5456-4653-87e5-4a8c52a9a67b", + "artifactDescription": "created from csar", + "artifactChecksum": "NmUyYjBmYzk5MDk3Mjc0NWNhZGU2ZGY1ZTE3YmU3ZjU=", + "artifactUUID": "dff5a82d-5456-4653-87e5-4a8c52a9a67b", + "artifactVersion": "1", + "artifactLabel": "heatartifact2", + "artifactGroupType": "DEPLOYMENT" + }, + { + "artifactName": "eNodeB_Thresholds.csv", + "artifactType": "OTHER", + "artifactURL": "/sdc/v1/catalog/resources/84855843-5247-4e97-a2bd-5395a510253b/artifacts/d57ac7ec-f3c3-4793-983a-c75ac3a43153", + "artifactDescription": "kpis with nfNamingCode", + "artifactChecksum": "YTc1MDU0ZDFhODUwMGM5YmIwM2FmMWUzMmRiY2NlMGI=", + "artifactUUID": "d57ac7ec-f3c3-4793-983a-c75ac3a43153", + "artifactVersion": "1", + "artifactLabel": "kpis", + "artifactGroupType": "DEPLOYMENT" + } + ], + + "description": "Description" +} \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcSecurityRules.json b/src/test/resources/example/sdc/sdcSecurityRules.json new file mode 100644 index 000000000..07930a288 --- /dev/null +++ b/src/test/resources/example/sdc/sdcSecurityRules.json @@ -0,0 +1,15 @@ +{ + "uuid": "d57e57d2-e3c6-470d-8d16-e6ea05f536c5", + "invariantUUID": "dd31d2de-0a7f-4198-8966-3a04100fbfe3", + "name": "SecurityRules", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/toscaModel", + "category": "Generic", + "subCategory": "Rules", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003", + "lastUpdaterFullName": "Jimmy Hendrix", + "toscaResourceName": "org.openecomp.resource.vfc.rules.nodes.heat.network.neutron.SecurityRules", + "description": "Configuration of policy rules to be applied on ports." +} \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcServiceDetailsExample.json b/src/test/resources/example/sdc/sdcServiceDetailsExample.json new file mode 100644 index 000000000..820c6ca55 --- /dev/null +++ b/src/test/resources/example/sdc/sdcServiceDetailsExample.json @@ -0,0 +1,230 @@ +{ + "uuid": "29018914-966c-442d-9d08-251b9dc45b8f", + "invariantUUID": "a33ed748-3477-4434-b3f3-b5560f5e7d9c", + "name": "vcts3", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8f/toscaModel", + "category": "Application L4+", + "subCategory": "Application Server", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535", + "lastUpdaterFullName": "MONICA LAZER", + "toscaResourceName": "org.openecomp.resource.vf.Vcts3", + "resources": + [ + { + "resourceInstanceName": "vCTS_port_0", + "resourceName": "NeutronPort", + "resourceInvariantUUID": "10428340-a673-4377-8696-af579a2e67a8", + "resourceVersion": "1.0", + "resoucreType": "CP", + "resourceUUID": "fdf0a74a-4942-4af0-9395-7bce23670662" + }, + + { + "resourceInstanceName": "vCTS", + "resourceName": "Vcts3.nodes.heat.vCTS_server", + "resourceInvariantUUID": "ef673ad3-2d81-47b7-99c2-bdc69ae79d80", + "resourceVersion": "1.0", + "resoucreType": "VFC", + "resourceUUID": "ab168037-e654-4990-a188-e5d2f25a8768", + "artifacts": + [ + { + "artifactName": "Fault-alarms-SDC-Albino-vCTS2.csv", + "artifactType": "SNMP_TRAP", + "artifactURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8f/resourceInstances/vcts/artifacts/b4f583b4-da0c-4bf8-81fb-415ebcd78cd4", + "artifactDescription": "Artifact created from csar", + "artifactChecksum": "NjI1ZTEyM2YxYWFhZThlMzZkNjAwZmNmMjEwNjZmMDQ=", + "artifactUUID": "b4f583b4-da0c-4bf8-81fb-415ebcd78cd4", + "artifactVersion": "1", + "artifactLabel": "faultalarmssdcalbinovcts2csv", + "artifactGroupType": "DEPLOYMENT" + }, + + { + "artifactName": "nagios2.csv", + "artifactType": "SNMP_TRAP", + "artifactURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8f/resourceInstances/vcts/artifacts/b1b86435-1de8-4d4a-8f69-f583a7417396", + "artifactDescription": "Artifact created from csar", + "artifactChecksum": "NzZlYTY1MmVjN2YyYWJlNWZkODIwYzBlNTFlYzg0NTA=", + "artifactUUID": "b1b86435-1de8-4d4a-8f69-f583a7417396", + "artifactVersion": "1", + "artifactLabel": "nagios2csv", + "artifactGroupType": "DEPLOYMENT" + } + ] + }, + + { + "resourceInstanceName": "resource-1", + "resourceInvariantUUID": "585822c7-4027-4f84-ba50-e9248606f134", + "resourceName": "resourceName-1", + "resoucreType": "VF", + "resourceUUID": "585822c7-4027-4f84-ba50-e9248606f136", + "resourceVersion": "3.0", + "category": "category", + "artifacts": + [ + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Meta data for VFModule", + "artifactName": "vnf-module-artifact.json", + "artifactType": "VF_MODULES_METADATA", + "artifactURL": "vnf-module-artifact.json", + "artifactUUID": "VfArtifact-UUID2", + "artifactVersion": "1.0" + }, + + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Nimbus Heat OAM", + "artifactName": "hot-nimbus-oam_v1.0.yaml", + "artifactTimeout": 100, + "artifactType": "HEAT", + "artifactURL": "hot-nimbus-oam_v1.0.yaml", + "artifactUUID": "Artifact-UUID1", + "artifactVersion": "1.0", + "generatedArtifact": "EnvArtifact-UUID2", + "relatedArtifact": + [ + "NestedArtifact-UUID3", + "ScriptArtifact-UUID1" + ] + }, + + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Nimbus Heat ENV OAM", + "artifactName": "hot-nimbus-oam_v1.0.env", + "artifactType": "HEAT_ENV", + "artifactURL": "hot-nimbus-oam_v1.0.env", + "artifactUUID": "EnvArtifact-UUID2", + "artifactVersion": "1.0" + }, + + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Nested OAM", + "artifactName": "nested-oam_v1.0.yaml", + "artifactTimeout": 10, + "artifactType": "HEAT_NESTED", + "artifactURL": "nested-oam_v1.0.yaml", + "artifactUUID": "NestedArtifact-UUID3", + "artifactVersion": "1.0" + }, + + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Nested PSM", + "artifactName": "nested-psm_v1.0.yaml", + "artifactTimeout": 10, + "artifactType": "HEAT_NESTED", + "artifactURL": "nested-psm_v1.0.yaml", + "artifactUUID": "NestedArtifact-UUID4", + "artifactVersion": "1.0" + }, + + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Script for Nimbus", + "artifactName": "cloud-nimbus.sh", + "artifactType": "HEAT_ARTIFACT", + "artifactURL": "cloud-nimbus.sh", + "artifactUUID": "ScriptNimbusArtifact-UUID1", + "artifactVersion": "1.0" + }, + + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Script for OAM", + "artifactName": "mount_iso_script.sh", + "artifactType": "HEAT_ARTIFACT", + "artifactURL": "mount_iso_script.sh", + "artifactUUID": "ScriptArtifact-UUID1", + "artifactVersion": "1.0" + }, + + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Heat Vol for OAM", + "artifactName": "hot-nimbus-oam-volumes_v1.0.yaml", + "artifactTimeout": 10, + "artifactType": "HEAT_VOL", + "artifactURL": "hot-nimbus-oam-volumes_v1.0.yaml", + "artifactUUID": "VolumeArtifact-UUID1", + "artifactVersion": "1.0", + "generatedArtifact": "VolumeEnvArtifact-UUID1", + "relatedArtifact": + [ + "NestedArtifact-UUID4" + ] + }, + + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Heat Env Vol for OAM", + "artifactName": "hot-nimbus-oam-volumes_v1.0.env", + "artifactType": "HEAT_ENV", + "artifactURL": "hot-nimbus-oam-volumes_v1.0.env", + "artifactUUID": "VolumeEnvArtifact-UUID1", + "artifactVersion": "1.0" + }, + + { + "artifactChecksum": "CheckSum", + "artifactDescription": "Meta data for VFModule", + "artifactName": "att_nimbus_vsaegw_ht_base_v13_0728v1.yaml", + "artifactTimeout": 100, + "artifactType": "HEAT", + "artifactURL": "att_nimbus_vsaegw_ht_base_v13_0728v1.yaml", + "artifactUUID": "HeatArtifactE2E-UUIDTest", + "artifactVersion": "1.0" + } + ] + } + ], + + "artifacts": + [ + { + "artifactName": "vf-license-model.xml", + "artifactType": "VF_LICENSE", + "artifactURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8f/artifacts/f8fb4591-5387-4424-8e7b-e31cb34a8cc1", + "artifactDescription": "VF license file", + "artifactChecksum": "NDkxZjBiYTA3YzE4YzQ2NzVjNjU4ZjE5YTI2YzY2YjM=", + "artifactUUID": "f8fb4591-5387-4424-8e7b-e31cb34a8cc1", + "artifactVersion": "1", + "artifactLabel": "vflicense", + "artifactGroupType": "DEPLOYMENT" + }, + + { + "artifactName": "base_TEST.yaml", + "artifactType": "HEAT", + "artifactURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8f/artifacts/ced9f553-a9bf-48e9-bd67-7f17162665ee", + "artifactDescription": "created from csar", + "artifactTimeout": 60, + "artifactChecksum": "NGVlN2MwZmE0MjU1MTZlNmRlOTMxZmM1NGZlMDk3ZDE=", + "artifactUUID": "ced9f553-a9bf-48e9-bd67-7f17162665ee", + "artifactVersion": "1", + "artifactLabel": "heat1", + "artifactGroupType": "DEPLOYMENT" + }, + + { + "artifactName": "vendor-license-model.xml", + "artifactType": "VENDOR_LICENSE", + "artifactURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8f/artifacts/a34232d1-60ee-4dda-add8-fbc14531ac24", + "artifactDescription": " Vendor license file", + "artifactChecksum": "OGEwYzI2Njk2YzI4YTVjMzdhMTI5ODNkNjQxMWIzZWU=", + "artifactUUID": "a34232d1-60ee-4dda-add8-fbc14531ac24", + "artifactVersion": "1", + "artifactLabel": "vendorlicense", + "artifactGroupType": "DEPLOYMENT" + } + ], + + "description": "for CLAMP" +} \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcServicesListExample.json b/src/test/resources/example/sdc/sdcServicesListExample.json new file mode 100644 index 000000000..3c1277a47 --- /dev/null +++ b/src/test/resources/example/sdc/sdcServicesListExample.json @@ -0,0 +1,35 @@ +[ + { + "uuid": "29018914-966c-442d-9d08-251b9dc45b8e", + "invariantUUID": "a33ed748-3477-4434-b3f3-b5560f5e7d9b", + "name": "vcts4", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8e/toscaModel", + "category": "Application L4+", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535", + "distributionStatus":"DISTRIBUTED" + }, + { + "uuid": "29018914-966c-442d-9d08-251b9dc45b8f", + "invariantUUID": "a33ed748-3477-4434-b3f3-b5560f5e7d9c", + "name": "vcts4", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8e/toscaModel", + "category": "Application L4+", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535", + "distributionStatus":"DISTRIBUTED" + }, + { + "uuid": "29018914-966c-442d-9d08-251b9dc45b7f", + "invariantUUID": "a33ed748-3477-4434-b3f3-b5560f5e7d8c", + "name": "vcts5", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8e/toscaModel", + "category": "Application L4+", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535", + "distributionStatus":"DISTRIBUTED" + } +] \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcVFCGenericWithAlarms.json b/src/test/resources/example/sdc/sdcVFCGenericWithAlarms.json new file mode 100644 index 000000000..0f9cf637b --- /dev/null +++ b/src/test/resources/example/sdc/sdcVFCGenericWithAlarms.json @@ -0,0 +1,60 @@ +{ + "uuid": "2c8f1219-8000-4001-aa13-496a0396d40f", + "invariantUUID": "096ff622-d7ea-4482-b7fe-8c7d99e7d7c6", + "name": "CLAMP-Dev-nodes.virc_fe_be_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2c8f1219-8000-4001-aa13-496a0396d40f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "CVFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740", + "lastUpdaterFullName": "Zero ASDCMech", + "toscaResourceName": "org.openecomp.resource.vfc.ClampDev.abstract.nodes.virc_fe_be_1", + "resources": + [ + { + "resourceInstanceName": "virc_fe_be_virc_fe_be_management_0_port", + "resourceName": "NeutronPort", + "resourceInvariantUUID": "10428340-a673-4377-8696-af579a2e67a8", + "resourceVersion": "5.0", + "resoucreType": "CP", + "resourceUUID": "045f3be0-7398-455b-8f0d-8eff2062a187" + }, + + { + "resourceInstanceName": "virc_fe_be_virc_fe_be_data_1_port", + "resourceName": "NeutronPort", + "resourceInvariantUUID": "10428340-a673-4377-8696-af579a2e67a8", + "resourceVersion": "5.0", + "resoucreType": "CP", + "resourceUUID": "045f3be0-7398-455b-8f0d-8eff2062a187" + }, + + { + "resourceInstanceName": "virc_fe_be", + "resourceName": "ClampDev.nodes.heat.virc_fe_be", + "resourceInvariantUUID": "e81d960d-794c-4d86-bbc4-31a2f86141ed", + "resourceVersion": "1.0", + "resoucreType": "VFC", + "resourceUUID": "d7646638-2572-4a94-b497-c028ac15f9ca" + } + ], + + "artifacts": + [ + { + "artifactName": "Fault-alarms-ASDC-vprobes-vLB.csv", + "artifactType": "SNMP_TRAP", + "artifactURL": "/sdc/v1/catalog/resources/2c8f1219-8000-4001-aa13-496a0396d40f/resourceInstances/virc_fe_be/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392", + "artifactDescription": "Artifact created from csar", + "artifactChecksum": "YWY2ZTY5NjhlOTU0YjQyZThhNTIyOGFmNzI1NTRiYzQ=", + "artifactUUID": "5138e316-0237-49aa-817a-b3d8eaf77392", + "artifactVersion": "1", + "artifactLabel": "faultalarmsasdcvprobesvlbcsv", + "artifactGroupType": "DEPLOYMENT" + } + ], + + "description": "Complex node type that is used as nested type in VF" +} \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcVFCResources.json b/src/test/resources/example/sdc/sdcVFCResources.json new file mode 100644 index 000000000..be2ee46d4 --- /dev/null +++ b/src/test/resources/example/sdc/sdcVFCResources.json @@ -0,0 +1,2445 @@ +[ + { + "uuid": "ab168037-e654-4990-a188-e5d2f25a8768", + "invariantUUID": "ef673ad3-2d81-47b7-99c2-bdc69ae79d80", + "name": "Vcts3.nodes.heat.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b3538c76-7d58-4e15-9a06-b51b32101965/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "da3c740a-e8af-4b85-a487-b4961b040fa3", + "invariantUUID": "2a477fa7-ac1b-4a62-baa1-e94c764d736b", + "name": "ScpTestVsp.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/da3c740a-e8af-4b85-a487-b4961b040fa3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "b31696d9-ad41-4cb5-bbdd-3e67845204f3", + "invariantUUID": "2b07e8fa-998d-4311-8ec0-61b86c798de9", + "name": "VpeBvRenana.nodes.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b31696d9-ad41-4cb5-bbdd-3e67845204f3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "25b74ab6-565b-424f-bb57-b434bb2944a0", + "invariantUUID": "ed69ed4f-80cd-48b5-86d5-4b5de21041be", + "name": "VpeBvRenana.nodes.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/25b74ab6-565b-424f-bb57-b434bb2944a0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "c13dc4c4-f4cb-4a54-9198-5bce42c5df02", + "invariantUUID": "6a828e59-cbee-4dc2-aa67-ee35a6eafd50", + "name": "Dev2devnfod.nodes.VF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c13dc4c4-f4cb-4a54-9198-5bce42c5df02/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + + { + "uuid": "08e94ce5-79e8-4873-9221-eb9e869ac679", + "invariantUUID": "da9ea806-971a-4338-bee7-6feeea270d8a", + "name": "Vprobe.nodes.vprobe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/08e94ce5-79e8-4873-9221-eb9e869ac679/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + + { + "uuid": "0d8f93f5-780e-47de-9b03-52ab31cb83d1", + "invariantUUID": "ce47044b-a00e-43d3-8aae-df047e6abe2e", + "name": "Vprobe.nodes.vLB", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0d8f93f5-780e-47de-9b03-52ab31cb83d1/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + + { + "uuid": "9140709a-d6a9-4690-b102-6fa96a696ce9", + "invariantUUID": "0c3d1be0-f4d8-4b0a-8cc8-05989de29dfc", + "name": "Dev2devnfod1207.nodes.VF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/9140709a-d6a9-4690-b102-6fa96a696ce9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + + { + "uuid": "6607c9fc-dc1d-4a89-ac57-b6b18fc79b69", + "invariantUUID": "7a17e445-0400-40bf-8bf6-91105996e19e", + "name": "Dev2devnfodvf.nodes.VF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/6607c9fc-dc1d-4a89-ac57-b6b18fc79b69/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + + { + "uuid": "3cb0c46c-af73-4420-ae5c-d4816b314980", + "invariantUUID": "0e332f76-d6f8-4e16-b2eb-bb1ccadec523", + "name": "volume", + "version": "4.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3cb0c46c-af73-4420-ae5c-d4816b314980/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "b4288e07-597a-44a2-aa98-ad36e551a39d", + "invariantUUID": "61dc85d2-5e17-480e-a71f-8f6d59a0ead2", + "name": "CinderVolume", + "version": "5.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b4288e07-597a-44a2-aa98-ad36e551a39d/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "156d628f-f515-4f58-bfb0-210632717ce3", + "invariantUUID": "cdafff07-0bbb-45f6-8a48-46ed2c98f29c", + "name": "VfDemor.nodes.heat.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/156d628f-f515-4f58-bfb0-210632717ce3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "28eeb6ce-2349-4c07-80ad-f0aacbf67028", + "invariantUUID": "ae71f982-2393-4fd7-8a69-c0050880e7c5", + "name": "Dev2devipassign2407.nodes.heat.pd_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/28eeb6ce-2349-4c07-80ad-f0aacbf67028/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + + { + "uuid": "f89e37a8-c5c0-4c0c-a034-f6c0ad8dd83f", + "invariantUUID": "59061740-4700-4800-83f1-0427f1ed1b8c", + "name": "Vmme1710.nodes.heat.ncb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f89e37a8-c5c0-4c0c-a034-f6c0ad8dd83f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "8263c4c5-555e-4b73-9210-ddc8dd7e42f8", + "invariantUUID": "a7b9db4c-685a-416c-a2ed-7711b1492cd3", + "name": "VnfcVspTest.nodes.heat.rdn", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8263c4c5-555e-4b73-9210-ddc8dd7e42f8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "dd7218d7-5760-4834-b78a-33edf5eb22e7", + "invariantUUID": "47be1ccb-856d-4d95-9722-f9d1913fe9df", + "name": "VnfcVspTest.nodes.heat.prx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/dd7218d7-5760-4834-b78a-33edf5eb22e7/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "10906cdf-dbec-405a-a513-7ed2090a5adb", + "invariantUUID": "746709d9-38fb-40af-88b0-856f6fadeb02", + "name": "VfExample.nodes.heat.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/10906cdf-dbec-405a-a513-7ed2090a5adb/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "e0ee89f0-175b-47d8-8258-1ac6ea6d52a8", + "invariantUUID": "a0d6e34d-c260-46ff-a55f-79fbce461ec2", + "name": "Vmme1710.nodes.heat.fsb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e0ee89f0-175b-47d8-8258-1ac6ea6d52a8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "e45c5438-0528-4a3d-bfa4-644b2343537c", + "invariantUUID": "cd1aa4fc-94bb-4e23-86b4-0e7b89c8cab8", + "name": "Vmme1710.nodes.heat.gpb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e45c5438-0528-4a3d-bfa4-644b2343537c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "76e5e6b8-baad-4e5e-b535-29a2ba4cb605", + "invariantUUID": "c76ccbe5-7087-4eb4-a0ff-2edd7d9a392c", + "name": "ContrailV2VirtualMachineInterface", + "version": "6.0", + "toscaModelURL": "/sdc/v1/catalog/resources/76e5e6b8-baad-4e5e-b535-29a2ba4cb605/toscaModel", + "category": "Generic", + "subCategory": "Network Elements", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "2b4c437e-9034-4ec3-b6f9-9309022673cf", + "invariantUUID": "39584568-5d64-4c63-9007-46b205ea4db8", + "name": "MadhuMdns.nodes.heat.dns", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2b4c437e-9034-4ec3-b6f9-9309022673cf/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "56cef7d0-af8c-4f18-80a2-e9aaf4366838", + "invariantUUID": "fab9a189-6bfa-4dfa-a4fe-2bfa4ff4e71b", + "name": "Alinavsp.nodes.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/56cef7d0-af8c-4f18-80a2-e9aaf4366838/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "d7646638-2572-4a94-b497-c028ac15f9ca", + "invariantUUID": "e81d960d-794c-4d86-bbc4-31a2f86141ed", + "name": "ClampDev.nodes.heat.virc_fe_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d7646638-2572-4a94-b497-c028ac15f9ca/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + + { + "uuid": "b58f9c1a-ad21-459d-9efa-a8924147cb90", + "invariantUUID": "a13cd6b9-c46e-4830-88ab-2b1c710a3b51", + "name": "sang_AR", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b58f9c1a-ad21-459d-9efa-a8924147cb90/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "27307a62-8512-4aeb-a0ad-e8e88643c2ba", + "invariantUUID": "91d1bde6-eb8e-4786-b7e6-193453662014", + "name": "SangVsp.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/27307a62-8512-4aeb-a0ad-e8e88643c2ba/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "b0322a5d-b664-4c47-9827-9d7c0ca2201b", + "invariantUUID": "745995d0-6bf0-49d4-895f-32d554a7c333", + "name": "vnfConfiguration", + "version": "3.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b0322a5d-b664-4c47-9827-9d7c0ca2201b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "fd0e3baa-fef7-4096-be2f-a73fea2f1360", + "invariantUUID": "4aca7e14-e2e4-4aeb-868e-aaaecea0cc5d", + "name": "SangVsp.nodes.heat.prx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fd0e3baa-fef7-4096-be2f-a73fea2f1360/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "a12dad87-6120-412f-8a53-c5bb88be89a3", + "invariantUUID": "84a7c06f-b3a7-448b-8777-626776b0b6bd", + "name": "Vmme1710.nodes.heat.vlc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a12dad87-6120-412f-8a53-c5bb88be89a3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "a14e3bbd-b04b-4924-817c-b4d13bfd8fe2", + "invariantUUID": "e205948e-5043-4cab-851d-e9e37f68736f", + "name": "VfExample.nodes.heat.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a14e3bbd-b04b-4924-817c-b4d13bfd8fe2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "a902ec74-9415-4d5c-a14e-f0861a272407", + "invariantUUID": "40894528-2703-4652-86d0-463ac2af8c80", + "name": "NewVendorMdns.nodes.heat.dns", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a902ec74-9415-4d5c-a14e-f0861a272407/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "82646e24-0e94-416a-aae2-9df4b2aa6217", + "invariantUUID": "a966f23a-ce65-4ef1-8d9f-718510852415", + "name": "SangVsp.nodes.heat.rdn", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/82646e24-0e94-416a-aae2-9df4b2aa6217/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "d87ce222-309b-46ab-9be9-c2d6ef7fe65e", + "invariantUUID": "37fcd63a-2d6e-4c42-8d63-183711976f9b", + "name": "multiFlavorVFC", + "version": "3.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d87ce222-309b-46ab-9be9-c2d6ef7fe65e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "c01c047d-395f-44fa-a34f-dc3f9c51c92c", + "invariantUUID": "23f8cb05-885d-4423-bae0-0d043f3c350c", + "name": "WebApplication", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c01c047d-395f-44fa-a34f-dc3f9c51c92c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "5fc1e5d4-1015-4614-b486-8727eb5e388b", + "invariantUUID": "19bf4492-3bdb-4d62-966d-2e2498e1891c", + "name": "Root", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5fc1e5d4-1015-4614-b486-8727eb5e388b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "61214be3-e560-44cc-877b-d484bcc2ee79", + "invariantUUID": "88a9f65b-94a0-4530-a17e-adaada70838d", + "name": "BlockStorage", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/61214be3-e560-44cc-877b-d484bcc2ee79/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "efb54bab-a842-48b3-842a-dffb000acf1f", + "invariantUUID": "cb2574f8-0b75-4ea1-8517-acba650ba72f", + "name": "Database", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/efb54bab-a842-48b3-842a-dffb000acf1f/toscaModel", + "category": "Generic", + "subCategory": "Database", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "4066e7da-0dba-4d0b-b74c-c30446ed277e", + "invariantUUID": "75c5fbc6-4366-4163-af9c-1a43bdb90425", + "name": "AbstractSubstitute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4066e7da-0dba-4d0b-b74c-c30446ed277e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "b39e436d-47b0-4509-95d6-8a63e2c722d1", + "invariantUUID": "0790aa94-5b47-4100-b26a-4cabd9639698", + "name": "ObjectStorage", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b39e436d-47b0-4509-95d6-8a63e2c722d1/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "94b8f588-624c-4e61-9ead-32aaadd8cf65", + "invariantUUID": "57eecece-2079-4a5d-9627-4fde30434552", + "name": "ContrailNetworkRules", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/94b8f588-624c-4e61-9ead-32aaadd8cf65/toscaModel", + "category": "Generic", + "subCategory": "Rules", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "fa17c264-7f19-4919-a1d4-aab5c53b9c32", + "invariantUUID": "b0a7ddd2-429e-493c-ba05-fe9440b49b54", + "name": "SoftwareComponent", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fa17c264-7f19-4919-a1d4-aab5c53b9c32/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "76ba485f-50a3-480d-895e-5c319191bc11", + "invariantUUID": "cf3ccc9c-b6ea-468e-8eef-f45479978fc1", + "name": "Allotedresource", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/76ba485f-50a3-480d-895e-5c319191bc11/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99124" + }, + + { + "uuid": "1909a305-e032-46ce-9278-c751659958cc", + "invariantUUID": "aa9abf65-5a91-4c6f-814e-47b5fa06ccbd", + "name": "Allotted resource 123456", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/1909a305-e032-46ce-9278-c751659958cc/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VFC", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "64fb42a4-7c3d-415b-afd0-1949abef550a", + "invariantUUID": "3bbcb293-24ff-4370-b46a-9233c92c1469", + "name": "ContrailAbstractSubstitute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/64fb42a4-7c3d-415b-afd0-1949abef550a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "c3ed93e4-4955-4100-8f4b-c9472cb3f28f", + "invariantUUID": "29e31a72-10c4-453d-99e6-76e0fe0f7a99", + "name": "Tuesdayvsp.nodes.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c3ed93e4-4955-4100-8f4b-c9472cb3f28f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "a71b3246-b54e-4646-bd6f-d5a11d4878df", + "invariantUUID": "b91e1d84-c9de-4a37-994a-b10949a14004", + "name": "Monitoringvsp.nodes.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a71b3246-b54e-4646-bd6f-d5a11d4878df/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "d36283cc-7d52-4893-8f72-fbffbbe17857", + "invariantUUID": "87802076-8649-4581-a540-b103ab15bd22", + "name": "Application", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d36283cc-7d52-4893-8f72-fbffbbe17857/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "2ef832aa-25f1-4f5a-b6d4-a6ee90011918", + "invariantUUID": "86ed816c-447f-477f-9810-4c07c7356c2e", + "name": "LoadBalancer", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2ef832aa-25f1-4f5a-b6d4-a6ee90011918/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "31060494-0c59-4c15-b4f4-34900d73b803", + "invariantUUID": "4950496e-6e75-47fb-8746-4895887a6d03", + "name": "Compute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/31060494-0c59-4c15-b4f4-34900d73b803/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "d57e57d2-e3c6-470d-8d16-e6ea05f536c5", + "invariantUUID": "dd31d2de-0a7f-4198-8966-3a04100fbfe3", + "name": "SecurityRules", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/toscaModel", + "category": "Generic", + "subCategory": "Rules", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "db9360b9-0edb-43e1-8cf0-00bb90b7c2be", + "invariantUUID": "651f273d-7e1d-410c-bd88-cf8c9f713454", + "name": "ContrailV2NetworkRules", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/db9360b9-0edb-43e1-8cf0-00bb90b7c2be/toscaModel", + "category": "Generic", + "subCategory": "Rules", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "503948a9-03bb-4738-8464-c6e21da10792", + "invariantUUID": "477a2abf-10b6-4777-bd50-afdcbbe59d54", + "name": "Vtsbc1.nodes.heat.module_2_perimeta_sw_b_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/503948a9-03bb-4738-8464-c6e21da10792/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "e4514d83-9708-427f-a62b-f996e426ba58", + "invariantUUID": "5886b184-53c2-475b-8e75-b38696c10b8a", + "name": "GlobalCompute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e4514d83-9708-427f-a62b-f996e426ba58/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "3ab24991-cf93-4d40-9468-52d233d36ad6", + "invariantUUID": "fb26e1e2-d7b0-4809-86e6-1ea31c5c6a4a", + "name": "FcgiOs.nodes.heat.modular_1_cgi_frwl_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3ab24991-cf93-4d40-9468-52d233d36ad6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "930aab76-fc52-43dd-8f19-e2ce11503bb5", + "invariantUUID": "f66c1a6b-2ad5-43dd-8cc9-1924f7eaad0f", + "name": "Vtsbc1.nodes.heat.vlan_subinterface_dual", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/930aab76-fc52-43dd-8f19-e2ce11503bb5/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "fca030db-0a4b-4873-94d2-20ea6b8f259f", + "invariantUUID": "124d05ac-8bbc-4510-94d7-c6418ee25864", + "name": "Vtsbc1.nodes.heat.module_2_perimeta_sw_a_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fca030db-0a4b-4873-94d2-20ea6b8f259f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "bc74b1ae-11f7-4550-8c25-e528e749d2ea", + "invariantUUID": "8c0c60ea-b468-4288-9aea-3232b5e7cce7", + "name": "Ronytestcsar.nodes.arb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bc74b1ae-11f7-4550-8c25-e528e749d2ea/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rb844h" + }, + + { + "uuid": "624a7da1-68ce-4b95-9d50-6a07d645e421", + "invariantUUID": "7ed55927-5274-461f-8ba5-76abdcf609a8", + "name": "Vftest54.nodes.heat.vdns", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/624a7da1-68ce-4b95-9d50-6a07d645e421/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rb844h" + }, + + { + "uuid": "0c19272a-b2a2-4ffe-a6e7-ce3a683f23fc", + "invariantUUID": "effff7eb-737b-496d-8e23-8e31efe67dc4", + "name": "VmmscEca.nodes.heat.arb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0c19272a-b2a2-4ffe-a6e7-ce3a683f23fc/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "az2497" + }, + + { + "uuid": "46887197-fec9-4cf5-9207-e6e7f4a6cf3a", + "invariantUUID": "1b8a54a2-b1ff-441c-9c6e-3aa83773e67c", + "name": "VfVolumeGroup.nodes.heat.sm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/46887197-fec9-4cf5-9207-e6e7f4a6cf3a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "563ca30e-8e6f-4456-b1c0-d1a5b6b052aa", + "invariantUUID": "876fe041-c25a-4e71-bbd3-ce18d1951974", + "name": "1607MogMultiMembersVolume.nodes.heat.sm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/563ca30e-8e6f-4456-b1c0-d1a5b6b052aa/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "2437819c-3f2e-4ae8-9427-b41463a63a21", + "invariantUUID": "6ec6862d-1e49-479b-b792-0b02a26cf9a6", + "name": "VfModule2.nodes.heat.eca_trx", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2437819c-3f2e-4ae8-9427-b41463a63a21/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "3c9b6ec9-2b6a-4c81-96cd-f3e5c0264ae6", + "invariantUUID": "cdc19c35-bcac-4f78-a7a6-c216b374f5a3", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3c9b6ec9-2b6a-4c81-96cd-f3e5c0264ae6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "612317df-67b5-487f-b592-44f5e682b0a9", + "invariantUUID": "3bae7612-b50d-48ed-8ae7-b6f17521395b", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/612317df-67b5-487f-b592-44f5e682b0a9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "77b6934c-353e-407e-aa1e-6f1288cb3969", + "invariantUUID": "adb87b9e-4bc2-4e96-8b1a-6176240f02a8", + "name": "VmogVnf1.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/77b6934c-353e-407e-aa1e-6f1288cb3969/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "48a5a370-d91d-4bdd-a1a0-8d82eedcced8", + "invariantUUID": "514ba932-1b32-447b-8655-f3a356047172", + "name": "VfModules.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/48a5a370-d91d-4bdd-a1a0-8d82eedcced8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "1450f9c2-b491-4ac6-a388-db4e0752a58f", + "invariantUUID": "5dc27c39-2540-4a2c-881c-5dab7859bbe8", + "name": "AppcTest.nodes.heat.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1450f9c2-b491-4ac6-a388-db4e0752a58f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "311a159d-ea0b-494c-97dd-52683df85faf", + "invariantUUID": "3c28e9d7-8ccf-4249-9eab-878d6cd84dfa", + "name": "Ixlt1Os.nodes.heat.its", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/311a159d-ea0b-494c-97dd-52683df85faf/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "4902fae4-7f42-43c5-9472-fe12eca3f510", + "invariantUUID": "60d87328-e9fd-474e-aa3e-791f23e7c0fa", + "name": "VfVolumeGroup.nodes.heat.cm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4902fae4-7f42-43c5-9472-fe12eca3f510/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "a82e5a26-463c-4b17-9d6e-16ea1f8c0dde", + "invariantUUID": "dfd14d20-8d28-4ad1-a824-dd75d282f97b", + "name": "VfVolumeGroup.nodes.heat.ps", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a82e5a26-463c-4b17-9d6e-16ea1f8c0dde/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "d852ce5c-c883-41a1-88f9-167b8b4ff197", + "invariantUUID": "18f3b7e1-3dfe-4299-982a-b510c64fbfba", + "name": "1607MogMultiMembersVolume.nodes.heat.ps", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d852ce5c-c883-41a1-88f9-167b8b4ff197/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "b299bd46-66c1-4954-af45-2fe3188f5c5e", + "invariantUUID": "41aa2e0e-f003-4a03-9e9b-5dbcc968b1df", + "name": "VfModulesVmmsc.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b299bd46-66c1-4954-af45-2fe3188f5c5e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "f80f5252-2ecb-41e3-84d5-936586ae0a3a", + "invariantUUID": "d90ae454-bc1c-44ef-a680-74b6a09d3123", + "name": "VfModules.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f80f5252-2ecb-41e3-84d5-936586ae0a3a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "9e4b96d7-5701-413e-8461-4cac258365ca", + "invariantUUID": "1a81fcd0-d62c-4ba3-b988-40a1a5986cb0", + "name": "TestPort.nodes.heat.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/9e4b96d7-5701-413e-8461-4cac258365ca/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "4d2bfb6f-9276-447b-b145-7f7856af9a6c", + "invariantUUID": "32a90486-5e0d-4977-b445-a9a165295841", + "name": "VmogVnf1.nodes.heat.pps", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4d2bfb6f-9276-447b-b145-7f7856af9a6c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "a614b20e-9c45-4163-b673-38f0068c5365", + "invariantUUID": "160c57a3-d87f-4f7f-a38a-7ecf6b48d42b", + "name": "Vmmsc.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a614b20e-9c45-4163-b673-38f0068c5365/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "fbad0868-45e9-433b-ada7-070e88c09672", + "invariantUUID": "8242ebe6-8333-4e4a-a997-31a391cbcc1f", + "name": "VmogVnf1.nodes.heat.mba", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fbad0868-45e9-433b-ada7-070e88c09672/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "e50cbfd4-a860-441b-b1ff-c654c3222ad6", + "invariantUUID": "03c1f631-d057-4246-b276-2a0e18119a21", + "name": "Pxtc.nodes.heat.mon", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e50cbfd4-a860-441b-b1ff-c654c3222ad6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "21aaf7bf-5af9-4b1a-9850-f4a5e95f185e", + "invariantUUID": "9bc1d654-b663-4170-89f2-e8dabb6d2342", + "name": "VmogVnf1.nodes.heat.ppd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/21aaf7bf-5af9-4b1a-9850-f4a5e95f185e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "9d4a37d7-3c9b-4dad-abb6-26b50b15da8b", + "invariantUUID": "419651d6-45e9-453a-95cd-4f9f0934fa9c", + "name": "Pxtc.nodes.heat.adm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/9d4a37d7-3c9b-4dad-abb6-26b50b15da8b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "bb8fddbf-e011-4fed-9f36-181478f4e56c", + "invariantUUID": "552c6aa1-0a27-45f7-a0e5-9a380a592ad4", + "name": "TestPort.nodes.heat.fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bb8fddbf-e011-4fed-9f36-181478f4e56c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "2bb496fb-6ede-42e0-957e-bd80fa2e8aa1", + "invariantUUID": "2a6f0a0e-2a76-43d1-9489-3ad4fdf82cdc", + "name": "Runtime", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2bb496fb-6ede-42e0-957e-bd80fa2e8aa1/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "a5226541-363b-4d78-8f52-06d421795457", + "invariantUUID": "3b05cf5e-5120-4aef-a213-f3d984c83efe", + "name": "TestPort.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a5226541-363b-4d78-8f52-06d421795457/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "f58b4bcf-baec-4c11-a6d0-0e92d4629fd2", + "invariantUUID": "603b02a9-afa2-487b-a8c1-90c84c21d4cf", + "name": "Vpe.nodes.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f58b4bcf-baec-4c11-a6d0-0e92d4629fd2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "30db70cc-17b8-4c39-a848-5f629e9a929e", + "invariantUUID": "2a3100da-581e-438a-915c-3c67ecbe8f9c", + "name": "AppcTest.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/30db70cc-17b8-4c39-a848-5f629e9a929e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "52398d14-90d0-4d3a-ac84-10b525e79e3c", + "invariantUUID": "8f061343-5507-4232-ba34-4933bb2b85d3", + "name": "Fdnt.nodes.heat.mod_vmsi_dnt_fw_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/52398d14-90d0-4d3a-ac84-10b525e79e3c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "d0deff85-ca52-4c86-8ca7-a02deddba983", + "invariantUUID": "c62a62a8-f021-4e22-85b9-45a19ddd8597", + "name": "Vtsbc1.nodes.heat.module_1_perimeta_sw_a_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d0deff85-ca52-4c86-8ca7-a02deddba983/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "25f77df9-f94a-4458-9699-5f483167f700", + "invariantUUID": "8d8675b4-88f8-43ad-aeed-3cb2e96d8f67", + "name": "DBMS", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/25f77df9-f94a-4458-9699-5f483167f700/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "1ce8b11c-589c-4359-9caa-590a43fb53ec", + "invariantUUID": "e4d4a041-38f9-416b-a97d-56eaca20cb88", + "name": "WebServer", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1ce8b11c-589c-4359-9caa-590a43fb53ec/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "f27b3a9c-b815-42fe-83c6-da86c18a63a6", + "invariantUUID": "0d4bec79-e600-4647-a9a6-35d1f1dd0802", + "name": "Fdnt1.nodes.heat.mod_vmsi_dnt_fw_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f27b3a9c-b815-42fe-83c6-da86c18a63a6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "c63814fe-9d50-4283-8229-ede6a5961de9", + "invariantUUID": "b9ffe743-22ae-4bdc-a36a-0fd7cdab97ff", + "name": "Mazav.nodes.heat.mod_vmsi_dnt_fw_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c63814fe-9d50-4283-8229-ede6a5961de9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "23f4bcc5-c6e1-4fdd-b45b-29eb3f82af2f", + "invariantUUID": "62545a84-126c-4563-b72b-7414cb2db617", + "name": "Fdnt1234.nodes.heat.mod_vmsi_dnt_fw_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/23f4bcc5-c6e1-4fdd-b45b-29eb3f82af2f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "e63ef8ed-d40d-4b5f-99da-898fbe4b051b", + "invariantUUID": "f747ebd4-8c02-4653-b919-7fd894450970", + "name": "Vtsbc1.nodes.heat.module_1_perimeta_sw_b_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e63ef8ed-d40d-4b5f-99da-898fbe4b051b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "292d2d83-c33b-4c22-8341-4401194a6499", + "invariantUUID": "b27f9b4b-2188-4edb-9e05-83680b5462b2", + "name": "VfModules1.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/292d2d83-c33b-4c22-8341-4401194a6499/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "af51c072-1754-4db3-97be-179ab7433295", + "invariantUUID": "b615bc4f-c4e3-4381-9467-f6674f4fe5ce", + "name": "VfModules1.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/af51c072-1754-4db3-97be-179ab7433295/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "5ec9fb9f-fa32-48e8-a317-8be839e15d30", + "invariantUUID": "ed2acd41-d9f5-475b-b696-9ff2ac93714e", + "name": "VmmscEca.nodes.arb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5ec9fb9f-fa32-48e8-a317-8be839e15d30/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "az2497" + }, + + { + "uuid": "3a8230f1-dd86-42f8-9d73-c239bc5c74e8", + "invariantUUID": "d7070c39-94e0-48f5-befc-c3b02a2dc1ec", + "name": "VfModulesVmmsc.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3a8230f1-dd86-42f8-9d73-c239bc5c74e8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "5658235d-6a1e-47fe-8e5f-9e081a11b713", + "invariantUUID": "7da4de5f-f610-4b0a-a57f-e76bf05e676e", + "name": "TestPort.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5658235d-6a1e-47fe-8e5f-9e081a11b713/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "d4979513-3719-4076-bbc1-5a4fe040ddc6", + "invariantUUID": "54f5d6e1-0290-473f-b7ef-ae5e31cd9985", + "name": "Vpe.nodes.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d4979513-3719-4076-bbc1-5a4fe040ddc6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "a450b1ba-2d69-44e7-8934-1d21952ba6c9", + "invariantUUID": "350c8017-ab5a-4633-bbe0-e7bbf71f0887", + "name": "TestConsol.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a450b1ba-2d69-44e7-8934-1d21952ba6c9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "c0bd2a8b-9dc3-4819-8ab1-11175ae06ef1", + "invariantUUID": "427b34d8-ca6d-4c94-8e4f-06d63a1e24eb", + "name": "NovaServer", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c0bd2a8b-9dc3-4819-8ab1-11175ae06ef1/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "5f6ccc29-6f6c-41cf-b995-73c58e7278d2", + "invariantUUID": "044d46c6-e6ae-4569-b7b4-3d0f626612de", + "name": "1607MogMultiMembersVolume.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5f6ccc29-6f6c-41cf-b995-73c58e7278d2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "5d6fdb58-1166-41b6-aab7-260e494ccc58", + "invariantUUID": "04c36447-22a8-4039-a7ae-fe134907061e", + "name": "ContrailCompute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5d6fdb58-1166-41b6-aab7-260e494ccc58/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + + { + "uuid": "57d4264b-3175-4a31-9515-f23c0318930f", + "invariantUUID": "8e3f2465-5f4f-4c9e-9b84-5db3d5d6a3f8", + "name": "VmogVnf1.nodes.heat.pcm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/57d4264b-3175-4a31-9515-f23c0318930f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "dcd62b53-a045-4864-9ed3-aaf722fec10a", + "invariantUUID": "046a066f-8398-4271-aa1a-4ccdd46c892f", + "name": "VfModuleLdsa.nodes.heat.ltm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/dcd62b53-a045-4864-9ed3-aaf722fec10a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "aa00977d-ff67-473a-acb8-bb24db037a0b", + "invariantUUID": "989ae5c8-e9b9-4e14-b609-1fde2ad4e165", + "name": "TestConsol.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/aa00977d-ff67-473a-acb8-bb24db037a0b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "cb08bf67-6fc9-44ae-ae31-ab619cfd94af", + "invariantUUID": "7555d6be-ef04-4812-b58c-b00eda9e1a1b", + "name": "AppcTest.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/cb08bf67-6fc9-44ae-ae31-ab619cfd94af/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "cc3a0064-e9d4-421e-ba14-ce340adb7ed9", + "invariantUUID": "341b0751-e9b7-4f80-935e-30aef979ea71", + "name": "VfModules.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/cc3a0064-e9d4-421e-ba14-ce340adb7ed9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "1f927980-bd8d-4a0c-8002-8f550e52efbe", + "invariantUUID": "d9f0237f-acaa-411f-843c-952d4d746d9f", + "name": "Vmmsc.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1f927980-bd8d-4a0c-8002-8f550e52efbe/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "6d1669d1-be78-47e7-aed4-d5a2267c81d4", + "invariantUUID": "b2a066b5-0062-482a-af23-9e1426f7d388", + "name": "VfVolumeGroup.nodes.heat.pd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/6d1669d1-be78-47e7-aed4-d5a2267c81d4/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "bd9e5061-40dc-42ca-8d77-c606a24c8bfd", + "invariantUUID": "a8cf5282-4c83-4540-8515-c315328af01d", + "name": "VfNoLicense.nodes.pcm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bd9e5061-40dc-42ca-8d77-c606a24c8bfd/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "68ea026e-c604-47b5-9cd1-524a58714a14", + "invariantUUID": "d0aa37ea-a1f8-41dc-9b5f-7e54f4d7a2f3", + "name": "VfNoLicense.nodes.pps", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/68ea026e-c604-47b5-9cd1-524a58714a14/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "bc3a8aae-7f94-4dac-b819-d37a077a08fc", + "invariantUUID": "0df5de75-3a9e-439a-8d03-e989ca7bfe16", + "name": "ScpTestVsp.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bc3a8aae-7f94-4dac-b819-d37a077a08fc/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "8ba3f710-58d4-4d60-9384-1dad449d381a", + "invariantUUID": "4a34455c-b9c0-48ca-90ac-debf986ac028", + "name": "VfDemor.nodes.vmx_vre", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8ba3f710-58d4-4d60-9384-1dad449d381a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "0a09e932-9fde-4e52-b7e3-2e542b61faa0", + "invariantUUID": "dd97be59-be12-4749-b8ca-1bf0d7336573", + "name": "ScpTestVsp.nodes.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0a09e932-9fde-4e52-b7e3-2e542b61faa0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "fa6ca25b-4578-4093-b8a2-031cb8f1f481", + "invariantUUID": "c88282f0-608d-4aef-b12f-dda9474f55f9", + "name": "VscpaasTest2.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fa6ca25b-4578-4093-b8a2-031cb8f1f481/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "f11a8681-ab58-4f0d-8387-76ecdfa31073", + "invariantUUID": "2a94a311-f6bb-48b6-a458-e4b1a724bfc7", + "name": "VscpaasTest2.nodes.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f11a8681-ab58-4f0d-8387-76ecdfa31073/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "4b1cca9b-23a0-4037-aaf3-ce5cd7c91851", + "invariantUUID": "98e3949f-1047-4cd8-9b8b-6b6c55d51f74", + "name": "Vprobe.nodes.vLBAgent", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4b1cca9b-23a0-4037-aaf3-ce5cd7c91851/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + + { + "uuid": "17ed7b78-1ffb-4864-a2ec-b6666a5fed16", + "invariantUUID": "2a6de403-c5b7-44ea-a398-ae78d53fb31a", + "name": "VpeAvRenana.nodes.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/17ed7b78-1ffb-4864-a2ec-b6666a5fed16/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "ab89b69b-b92b-4e34-b1db-a6378d709241", + "invariantUUID": "dbb9b18d-e3ea-48cf-bcbd-81d8d4b22d72", + "name": "Vmmsc.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ab89b69b-b92b-4e34-b1db-a6378d709241/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "d45694e4-ed86-4a44-a644-5a8a3ff89397", + "invariantUUID": "3eb4d8e0-2b85-4b74-bad3-2e4406f50d4d", + "name": "VfModules1.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d45694e4-ed86-4a44-a644-5a8a3ff89397/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "5c7fd7c0-fc79-4309-bb03-85388cae45a8", + "invariantUUID": "7ff3e308-cf42-47ae-afc3-ecd5ef9823c0", + "name": "VmmscEca.nodes.heat.eca", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5c7fd7c0-fc79-4309-bb03-85388cae45a8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "az2497" + }, + + { + "uuid": "f739ea35-7bd4-42ed-b9ee-1e0fd2017c72", + "invariantUUID": "ce4127ef-2564-40e6-b62e-6be7758f46a7", + "name": "Pxtc.nodes.heat.ddc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f739ea35-7bd4-42ed-b9ee-1e0fd2017c72/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "f2339431-f3ab-41c9-90c4-6c2c958e1b06", + "invariantUUID": "40ab991d-ad0c-4adb-9f2a-0f2eef8bb880", + "name": "VfModules1.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f2339431-f3ab-41c9-90c4-6c2c958e1b06/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "15728e01-7076-4765-8002-95154ad29d5f", + "invariantUUID": "9814209f-7b9d-4b21-8968-f6a3638b107c", + "name": "1607Mog.nodes.heat.cm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/15728e01-7076-4765-8002-95154ad29d5f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "ab168037-e654-4990-a188-e5d2f25a8768", + "invariantUUID": "ef673ad3-2d81-47b7-99c2-bdc69ae79d80", + "name": "Vcts3.nodes.heat.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ab168037-e654-4990-a188-e5d2f25a8768/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "e1d7eb6a-646d-4906-9981-44ed892dc01c", + "invariantUUID": "78245f38-b99a-49a8-ac5b-56737ad686db", + "name": "VfModulesVmmsc.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e1d7eb6a-646d-4906-9981-44ed892dc01c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "74c527c6-edb7-4bbe-a63c-d2daf5a12db0", + "invariantUUID": "18bc94d2-2be1-46e9-bd70-ded327b1324e", + "name": "VfModule2.nodes.heat.mmsc", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/74c527c6-edb7-4bbe-a63c-d2daf5a12db0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "345459d0-ba42-45ba-9eb0-cc56e4f35ea9", + "invariantUUID": "5362b258-b867-4e98-a3c4-138c6d444c69", + "name": "VfModule2.nodes.heat.nems_be", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/345459d0-ba42-45ba-9eb0-cc56e4f35ea9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "bc40b750-56ab-4c6b-8e15-412f9be0178f", + "invariantUUID": "ab769637-063f-41fd-927d-771a1913235b", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bc40b750-56ab-4c6b-8e15-412f9be0178f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "3ff3d87f-c55f-4b4c-a8ae-29931d910359", + "invariantUUID": "5af2c63a-1b3e-42a5-ab4b-07e97d1dcbd2", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3ff3d87f-c55f-4b4c-a8ae-29931d910359/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "2c8f1219-8000-4001-aa13-496a0396d40f", + "invariantUUID": "096ff622-d7ea-4482-b7fe-8c7d99e7d7c6", + "name": "CLAMP-Dev-nodes.virc_fe_be_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2c8f1219-8000-4001-aa13-496a0396d40f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + + { + "uuid": "d8a2de8a-27d8-491c-bbb9-da779a4da7c6", + "invariantUUID": "0b4d158e-c20e-4630-b515-3ecda2ad05a4", + "name": "VfModules.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d8a2de8a-27d8-491c-bbb9-da779a4da7c6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "d544d6a6-4fcc-42db-97f6-e8cccc69c5ee", + "invariantUUID": "cd4a433e-cf76-4652-a6b8-59e657e0c5a0", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d544d6a6-4fcc-42db-97f6-e8cccc69c5ee/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "5d6e7129-d7c8-41b8-ae2a-5f1688162c7c", + "invariantUUID": "350d9877-894a-4ce4-a899-48df9428ff88", + "name": "Vieccf.nodes.heat.iox", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5d6e7129-d7c8-41b8-ae2a-5f1688162c7c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "fcc6655e-7074-48de-89ef-ef6e4a5705e3", + "invariantUUID": "6dd080e4-372c-44cc-8c25-868d45f2e959", + "name": "VfModule2.nodes.heat.nems_fe", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fcc6655e-7074-48de-89ef-ef6e4a5705e3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "400cab12-2d1e-4a2c-a33a-d9d7b3262dd1", + "invariantUUID": "9ebca51b-16d0-423c-8e5f-4472c1888029", + "name": "VmogVnf1.nodes.heat.mbt", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/400cab12-2d1e-4a2c-a33a-d9d7b3262dd1/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "a068d0c0-06c6-4b58-bc99-6ac910700edb", + "invariantUUID": "f2e37302-fd97-48d7-bbdb-f0caaab5fe03", + "name": "1607Mog.nodes.heat.pd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a068d0c0-06c6-4b58-bc99-6ac910700edb/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "c2e88763-87a9-4d33-b598-7811ae3f87d2", + "invariantUUID": "9d16cf01-c244-42c8-bcfe-faf108069e84", + "name": "VfModulesVmmsc.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c2e88763-87a9-4d33-b598-7811ae3f87d2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "de861add-3f4a-4526-9754-8bcb69d0fd0e", + "invariantUUID": "67560771-ffcb-46fb-a40c-0e1dee74f43a", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/de861add-3f4a-4526-9754-8bcb69d0fd0e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "4514b4e5-f163-4011-87fd-445f4366e3c2", + "invariantUUID": "91c638ef-49f5-4366-8749-cda8a33ed41e", + "name": "VfModules.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4514b4e5-f163-4011-87fd-445f4366e3c2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "3679d10e-a1a2-46a4-97b3-4056a0920e7b", + "invariantUUID": "d272aa71-398a-4eff-ab00-6a4281b41c92", + "name": "Pxtc.nodes.heat.mda", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3679d10e-a1a2-46a4-97b3-4056a0920e7b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "f905ca32-dac5-4337-a1d7-cc2bca86b407", + "invariantUUID": "acbb7a13-7ae7-4ac7-b0e4-23314cbc65e2", + "name": "Vmmsc.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f905ca32-dac5-4337-a1d7-cc2bca86b407/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "ee10af8a-c8bf-4455-808e-5550050d4ea9", + "invariantUUID": "e74db59b-72fb-4734-9d48-40d8c47d292a", + "name": "VfModulesVmmsc.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ee10af8a-c8bf-4455-808e-5550050d4ea9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "771ca169-bfac-4306-9748-b2ae804852f9", + "invariantUUID": "ae627e8b-374b-41ac-9efb-25672099c7dd", + "name": "Vscp0502.nodes.heat.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/771ca169-bfac-4306-9748-b2ae804852f9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "72682bb7-94ca-47a7-9917-826f62e3d00d", + "invariantUUID": "7bb2f20e-10af-485b-9c7c-9fba2c016856", + "name": "1607Mog.nodes.heat.sm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/72682bb7-94ca-47a7-9917-826f62e3d00d/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "1fa641db-1d77-4242-8d0b-c0aa5f88fe2e", + "invariantUUID": "22464824-fcbe-4760-9aa7-f2d110e5c0f8", + "name": "1607MogMultiMembersVolume.nodes.heat.cm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1fa641db-1d77-4242-8d0b-c0aa5f88fe2e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "897dcb54-bb55-4311-8c0e-b663781d7e4f", + "invariantUUID": "c223adda-e48d-487d-98e8-654bbb8268af", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/897dcb54-bb55-4311-8c0e-b663781d7e4f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "a60c5230-8201-4b50-84a8-c905128c2bc2", + "invariantUUID": "59399b2e-66ed-4823-aa27-189fdb466045", + "name": "AppcTest.nodes.heat.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a60c5230-8201-4b50-84a8-c905128c2bc2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "173c32b5-44c8-4404-ba18-32d9de49afae", + "invariantUUID": "c247493b-15a4-47af-bb6b-c664cb5a4d37", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/173c32b5-44c8-4404-ba18-32d9de49afae/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "59aa2d42-db52-438c-a69c-0b97a193abcd", + "invariantUUID": "31fc926f-cfc5-42bd-8955-42e68c113902", + "name": "TestConsol.nodes.heat.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/59aa2d42-db52-438c-a69c-0b97a193abcd/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "0e6509c9-7d35-4daf-9086-9fe30fdd1275", + "invariantUUID": "9516ad03-b122-4738-ad6d-d9c2166cd75a", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0e6509c9-7d35-4daf-9086-9fe30fdd1275/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "e541a64c-9de7-4c71-b827-eb0f4d319e62", + "invariantUUID": "9952957d-d266-406e-ab7d-23a7fc154ea0", + "name": "1607MogMultiMembersVolume.nodes.heat.pd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e541a64c-9de7-4c71-b827-eb0f4d319e62/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "5e448cd9-6dbd-4c31-98f2-caeceaf5efa7", + "invariantUUID": "3a97ded5-e8fc-42fa-b244-a6f91b610e08", + "name": "VfModule2.nodes.heat.lb", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5e448cd9-6dbd-4c31-98f2-caeceaf5efa7/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "d5c6a462-9d9a-46d4-a0b2-485300f34f0c", + "invariantUUID": "635abeeb-d903-44a8-9135-5d26e1ee41a1", + "name": "VmogVnf1.nodes.heat.psm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d5c6a462-9d9a-46d4-a0b2-485300f34f0c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "8678abfe-8cbd-42f2-aa78-ca47a1beaa14", + "invariantUUID": "4d02c8a5-e141-4d01-94ec-7a3b94afda97", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8678abfe-8cbd-42f2-aa78-ca47a1beaa14/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "1c469da0-298f-41ea-94a2-aef82264e1e7", + "invariantUUID": "91530a04-e1f6-4242-abd2-f20630e1fa8f", + "name": "1607Mog.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1c469da0-298f-41ea-94a2-aef82264e1e7/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "c29e22e2-1a09-4164-a9a2-72d0e3f5df5b", + "invariantUUID": "a0e5c360-f0e7-4b8d-ac97-969b9dc5b187", + "name": "Vmmsc.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c29e22e2-1a09-4164-a9a2-72d0e3f5df5b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "986b76dc-aca7-45b1-919c-398b770d5504", + "invariantUUID": "cd2f22e1-e21e-474b-a506-1bb4365aa106", + "name": "AppcTest.nodes.heat.fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/986b76dc-aca7-45b1-919c-398b770d5504/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "606f6c2b-a411-4644-a183-5487e3aed612", + "invariantUUID": "d67b05d1-119c-47a3-8b20-2babb53b42b3", + "name": "Vpe.nodes.heat.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/606f6c2b-a411-4644-a183-5487e3aed612/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "00695bbf-fa3f-47e4-96d7-973700a66f4f", + "invariantUUID": "d26ce6ce-b1f8-4cdc-955d-e2272563cff6", + "name": "TestPort.nodes.heat.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/00695bbf-fa3f-47e4-96d7-973700a66f4f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "d94275b4-ccfa-4096-bd7b-dd45ff6e84f2", + "invariantUUID": "56a1b1c7-6a6f-402b-890f-8e3a1cc56feb", + "name": "Vieccf.nodes.heat.plt", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d94275b4-ccfa-4096-bd7b-dd45ff6e84f2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "8beb2fe4-672e-46c3-8650-e2065ea429ea", + "invariantUUID": "be756449-fd9d-4889-83ad-41ff26a82f09", + "name": "Pxtc.nodes.heat.mts", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8beb2fe4-672e-46c3-8650-e2065ea429ea/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "c4b4f162-a616-45c6-b229-9833a78a46fd", + "invariantUUID": "b502eeb1-091c-41cf-b4ba-52f9ab6ecfcc", + "name": "Vpe.nodes.heat.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c4b4f162-a616-45c6-b229-9833a78a46fd/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "95e982cd-551d-49b2-9600-04f1328b9ab5", + "invariantUUID": "26813b60-5437-4780-aaaa-9705b9d30357", + "name": "TestConsol.nodes.heat.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/95e982cd-551d-49b2-9600-04f1328b9ab5/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "8316c6e3-7791-42cb-80fb-e57ed0809be6", + "invariantUUID": "5ca065b5-c2e3-4561-9dc6-58fc84c8398c", + "name": "Vscp0502.nodes.heat.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8316c6e3-7791-42cb-80fb-e57ed0809be6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "49cc354b-ea2e-48a9-a6b8-d414e6991898", + "invariantUUID": "b94ec614-4972-4355-ab2f-3c7068714581", + "name": "Ronytestcsar.nodes.heat.arb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/49cc354b-ea2e-48a9-a6b8-d414e6991898/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rb844h" + }, + + { + "uuid": "cc0048fb-a464-4407-9907-5e760684bc7b", + "invariantUUID": "06aff944-cdab-42cd-a5a3-f2c2c65df4b2", + "name": "TestConsol.nodes.heat.fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/cc0048fb-a464-4407-9907-5e760684bc7b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "bc1dea1b-5753-4d17-af6f-ac6050b3e281", + "invariantUUID": "76d0ef26-6721-4f11-ba1a-04c93e7154c3", + "name": "Vieccf.nodes.heat.app", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bc1dea1b-5753-4d17-af6f-ac6050b3e281/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "0b894e43-6d45-4c3d-95dd-2e80228055f3", + "invariantUUID": "ca679ac7-9d4b-4da1-8912-a262c5599692", + "name": "VfVolumeGroup.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0b894e43-6d45-4c3d-95dd-2e80228055f3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "2bb1e047-fa3b-41f5-9d29-ebbdbf01857c", + "invariantUUID": "988032f2-873e-4273-9075-17ffd47f0a7f", + "name": "VfModules1.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2bb1e047-fa3b-41f5-9d29-ebbdbf01857c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "05c82d0d-826b-458c-8c81-9572298522a3", + "invariantUUID": "6e577da6-377d-46fb-84c0-3bfa4778062f", + "name": "Vscp0502.nodes.heat.fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/05c82d0d-826b-458c-8c81-9572298522a3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "c6809100-9349-4f98-a066-55b6f0cb8650", + "invariantUUID": "4d48d18e-baa3-41bb-8a07-3c553db1fbab", + "name": "Ronytestcsar.nodes.heat.eca", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c6809100-9349-4f98-a066-55b6f0cb8650/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rb844h" + }, + + { + "uuid": "abe50ede-b86c-415f-9f5f-235200433b51", + "invariantUUID": "c3cbaff7-a657-44d5-a0b3-cc65599b4fa8", + "name": "Csartest.nodes.heat.ltm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/abe50ede-b86c-415f-9f5f-235200433b51/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ss8214" + }, + + { + "uuid": "3ce1be04-57ad-4deb-bdba-b18447374a88", + "invariantUUID": "b08eef7d-1dd5-4996-9171-7822b48e9a9d", + "name": "Vprobe.nodes.qrouter", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3ce1be04-57ad-4deb-bdba-b18447374a88/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + + { + "uuid": "f6406bba-b64c-4211-aaee-773cde6e7d54", + "invariantUUID": "490345fc-f6fe-49a6-b18d-6dcacca02a7e", + "name": "VscpaasTest2.nodes.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f6406bba-b64c-4211-aaee-773cde6e7d54/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "d48751e4-07de-4208-9307-7ecb775fe7ca", + "invariantUUID": "ca0ae539-78d1-461a-a7ff-3dd663c85e2d", + "name": "pnf-test", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d48751e4-07de-4208-9307-7ecb775fe7ca/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "cdb99a41-e2ee-4b59-9107-13f0b2282ccc", + "invariantUUID": "6a828e59-cbee-4dc2-aa67-ee35a6eafd50", + "name": "Dev2devnfod.nodes.VF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/cdb99a41-e2ee-4b59-9107-13f0b2282ccc/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + + { + "uuid": "99b9dce6-ed85-4d76-aed9-40c020ba4607", + "invariantUUID": "c9e5dab6-eba5-4cc2-abff-305f8f508da1", + "name": "py-port-test", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/99b9dce6-ed85-4d76-aed9-40c020ba4607/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "acf4e0fa-17f9-4ac8-9fb2-2301cf942fcf", + "invariantUUID": "02cd4db0-a29b-4318-9b3b-a123b9103b85", + "name": "VfNoLicense.nodes.ppd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/acf4e0fa-17f9-4ac8-9fb2-2301cf942fcf/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "fb6a8f39-84be-49a2-b551-26ce99ee6853", + "invariantUUID": "501e3f78-ae62-4551-bc47-a9afa8f29034", + "name": "ScpTestVsp.nodes.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fb6a8f39-84be-49a2-b551-26ce99ee6853/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "b09ec9ff-af66-4bdc-82d4-01a918e8e3ca", + "invariantUUID": "02d284b6-feb3-4762-be9b-8f6955f6b0b9", + "name": "SdWanTestVsp.nodes.DUMMY_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b09ec9ff-af66-4bdc-82d4-01a918e8e3ca/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "83256b0a-cb38-45de-b5f0-d2d4390f543d", + "invariantUUID": "c291bec4-fe31-4e6d-9126-f5ce104b84d1", + "name": "Sangeetha.nodes.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/83256b0a-cb38-45de-b5f0-d2d4390f543d/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "16ba1289-5f91-4f07-914a-d2456d11c673", + "invariantUUID": "aafce2ad-8d15-4f53-88f5-9b3a1662f14e", + "name": "VpeAvRenana.nodes.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/16ba1289-5f91-4f07-914a-d2456d11c673/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "93fe78c8-1350-4b1f-ac5f-ede411b992a0", + "invariantUUID": "a11f76ed-0f0a-4093-9c94-5f5eb6c450b5", + "name": "VfNoLicense.nodes.psm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/93fe78c8-1350-4b1f-ac5f-ede411b992a0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "1e5eafc0-1888-4247-9762-9ebd1383d0ae", + "invariantUUID": "076ddfc3-8a9d-4289-b71e-a707d359b149", + "name": "VnfcVspTest.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1e5eafc0-1888-4247-9762-9ebd1383d0ae/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "01faf05a-70b9-442f-be62-9884ea4cdf33", + "invariantUUID": "cd5937cc-37ef-4a85-ba10-2568628d4c1b", + "name": "VfDemor.nodes.vmx_vpfe", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/01faf05a-70b9-442f-be62-9884ea4cdf33/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "4583652c-e066-4a5c-88b8-fbcdd8619d2c", + "invariantUUID": "216e59ce-6940-4085-949e-9b47d9756383", + "name": "VfDemor.nodes.heat.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4583652c-e066-4a5c-88b8-fbcdd8619d2c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "16f02038-00f6-4a11-ab98-2a2154e98924", + "invariantUUID": "479cf5fc-8df3-49ec-9e85-da7899420b61", + "name": "VscpaasTest2.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/16f02038-00f6-4a11-ab98-2a2154e98924/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + } +] \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcVFResources.json b/src/test/resources/example/sdc/sdcVFResources.json new file mode 100644 index 000000000..a8f32195d --- /dev/null +++ b/src/test/resources/example/sdc/sdcVFResources.json @@ -0,0 +1,1574 @@ +[ + { + "uuid": "585822c7-4027-4f84-ba50-e9248606f136", + "invariantUUID": "585822c7-4027-4f84-ba50-e9248606f134", + "name": "resourceName-1", + "version": "3.0", + "toscaModelURL": "/sdc/v1/catalog/resources/585822c7-4027-4f84-ba50-e9248606f136/toscaModel", + "category": "Network L2-3", + "subCategory": "Router", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743" + }, + + { + "uuid": "56389a7d-86db-49e1-aada-62aebf023f23", + "invariantUUID": "18a2c267-50a9-42ae-a3ec-4d55dd6df225", + "name": "shayVF", + "version": "0.2", + "toscaModelURL": "/sdc/v1/catalog/resources/56389a7d-86db-49e1-aada-62aebf023f23/toscaModel", + "category": "Application L4+", + "subCategory": "Load Balancer", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "ss8214" + }, + + { + "uuid": "2ce2fe72-7f8d-4184-87e6-5fd7aa650acd", + "invariantUUID": "9aa658ae-8f6d-49bc-810d-8a544d6b12f2", + "name": "Dev2DevNFODVf_17_July", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2ce2fe72-7f8d-4184-87e6-5fd7aa650acd/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sw594b" + }, + + { + "uuid": "ae841bc4-6534-4d12-b8a4-ddd07a062a7e", + "invariantUUID": "926f6d60-bf84-46c4-9ed7-f0bb774e5184", + "name": "Sangeetha", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/ae841bc4-6534-4d12-b8a4-ddd07a062a7e/toscaModel", + "category": "DCAE Component", + "subCategory": "Database", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "ss8214" + }, + + { + "uuid": "0c940638-618b-450e-aa99-b991a3200d1a", + "invariantUUID": "2d4d1e44-14f7-41e0-a37a-f8a6507c86f6", + "name": "Eli", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/0c940638-618b-450e-aa99-b991a3200d1a/toscaModel", + "category": "Allotted Resource", + "subCategory": "Contrail Route", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "el489u" + }, + + { + "uuid": "91854bc8-534f-4249-899c-bbdc06f83436", + "invariantUUID": "5e9c180a-44f1-45ce-a7bc-95b493ae9fd3", + "name": "CLAMP-Dev", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/91854bc8-534f-4249-899c-bbdc06f83436/toscaModel", + "category": "Generic", + "subCategory": "Network Elements", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743" + }, + + { + "uuid": "168b696d-8ed5-41ff-8158-b8adadfcedfa", + "invariantUUID": "9429f628-f58d-492e-aa97-de9bd9f98043", + "name": "ariel_test_vf001", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/168b696d-8ed5-41ff-8158-b8adadfcedfa/toscaModel", + "category": "Application L4+", + "subCategory": "Application Server", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743" + }, + + { + "uuid": "290603da-0c41-4120-b737-f800c6031a58", + "invariantUUID": "f22a9390-6d25-4fa7-a1dd-8d0121f6aacf", + "name": "VF-example", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/290603da-0c41-4120-b737-f800c6031a58/toscaModel", + "category": "Network L2-3", + "subCategory": "LAN Connectors", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "271b4961-e4dc-42d5-8c0c-4da8685973ac", + "invariantUUID": "822e9970-a3fd-4d62-8f00-5819323cb54d", + "name": "vf_AR", + "version": "3.0", + "toscaModelURL": "/sdc/v1/catalog/resources/271b4961-e4dc-42d5-8c0c-4da8685973ac/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "b109217b-c959-4228-b30d-8f376668174c", + "invariantUUID": "5d616289-3563-48d8-b41a-15a633d5f03c", + "name": "Map Microservice", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b109217b-c959-4228-b30d-8f376668174c/toscaModel", + "category": "DCAE Component", + "subCategory": "Microservice", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "44b0a91c-8d63-4304-a637-2eda78a86023", + "invariantUUID": "9b2e7539-b183-4a59-82ea-842494fe19e0", + "name": "enrich snmp", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/44b0a91c-8d63-4304-a637-2eda78a86023/toscaModel", + "category": "DCAE Component", + "subCategory": "Microservice", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743" + }, + + { + "uuid": "418a2ea5-6a8a-4498-9d0f-602a809552d6", + "invariantUUID": "58d0e85f-3161-47c9-981d-3cbcf1be56b6", + "name": "renana", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/418a2ea5-6a8a-4498-9d0f-602a809552d6/toscaModel", + "category": "Application L4+", + "subCategory": "Media Servers", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "13ae8064-344f-4d67-acd2-810516927f48", + "invariantUUID": "69b75e6e-a839-4a91-93d7-821610517cb5", + "name": "Dror1", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/13ae8064-344f-4d67-acd2-810516927f48/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m08740" + }, + + { + "uuid": "6510ee54-2ccb-406c-a006-8a67b589eecd", + "invariantUUID": "2ef1c565-6a85-424e-80ab-8efe14fefe9f", + "name": "SD-WAN-Test-VSP", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/6510ee54-2ccb-406c-a006-8a67b589eecd/toscaModel", + "category": "Network L2-3", + "subCategory": "WAN Connectors", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "c3c0a9e1-bcda-4b46-a7d6-3916ea3fc1ca", + "invariantUUID": "21052af3-0f73-4f82-af68-03123ed49d41", + "name": "rrrr", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/c3c0a9e1-bcda-4b46-a7d6-3916ea3fc1ca/toscaModel", + "category": "Allotted Resource", + "subCategory": "IP Mux Demux", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "ys278k" + }, + + { + "uuid": "10b535db-b01b-4a4b-aeef-97423d2d2093", + "invariantUUID": "761ed279-e5ff-43e2-8a05-b160224b7f54", + "name": "StringMatchingMS", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/10b535db-b01b-4a4b-aeef-97423d2d2093/toscaModel", + "category": "DCAE Component", + "subCategory": "Microservice", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "5ea777fc-a3fe-4688-aefd-b1297bd36381", + "invariantUUID": "6d1eb2c8-ae57-4d32-bd63-b47fd503aafb", + "name": "map snmp", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5ea777fc-a3fe-4688-aefd-b1297bd36381/toscaModel", + "category": "DCAE Component", + "subCategory": "Microservice", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743" + }, + + { + "uuid": "8d366342-8cfa-431b-82ca-013f7f06af50", + "invariantUUID": "822e9970-a3fd-4d62-8f00-5819323cb54d", + "name": "vf_AR", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/8d366342-8cfa-431b-82ca-013f7f06af50/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VF", + "lifecycleState": "CERTIFICATION_IN_PROGRESS", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "a804fb4e-33ce-4000-963f-d270a0593de2", + "invariantUUID": "6eb4b1ca-75ac-454b-a145-1ea27157bfac", + "name": "IP_Mux_Demux", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/a804fb4e-33ce-4000-963f-d270a0593de2/toscaModel", + "category": "Allotted Resource", + "subCategory": "IP Mux Demux", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "le056g" + }, + + { + "uuid": "9bed9e17-7bfa-4a92-9474-3bcf7187e206", + "invariantUUID": "853a6d9a-3004-462c-9142-631eb777a16c", + "name": "newShayVFMCT", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/9bed9e17-7bfa-4a92-9474-3bcf7187e206/toscaModel", + "category": "DCAE Component", + "subCategory": "Microservice", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "ss8214" + }, + + { + "uuid": "cae08b64-2784-4883-8dd0-747f6ebb94c4", + "invariantUUID": "3d51584c-aa2e-454a-a17a-970b51bbd668", + "name": "VES Collector Lisa", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/cae08b64-2784-4883-8dd0-747f6ebb94c4/toscaModel", + "category": "DCAE Component", + "subCategory": "Collector", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "lr0306" + }, + + { + "uuid": "d06b73ef-b908-44cd-8c17-11f1366c4f93", + "invariantUUID": "0ad06008-5ecc-4a24-a123-74fc23d7bf89", + "name": "shaytookmyvf", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/d06b73ef-b908-44cd-8c17-11f1366c4f93/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "11ff4510-008f-4818-87aa-d22e1b26d03e", + "invariantUUID": "5d138333-7a0f-432b-ad74-009a308c91c5", + "name": "VF- DemoR", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/11ff4510-008f-4818-87aa-d22e1b26d03e/toscaModel", + "category": "Network L2-3", + "subCategory": "Router", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "0ff82855-b0aa-4b0d-8451-82aa978ae4d5", + "invariantUUID": "9aa658ae-8f6d-49bc-810d-8a544d6b12f2", + "name": "Dev2DevNFODVf_17_July", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/0ff82855-b0aa-4b0d-8451-82aa978ae4d5/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "pa0916" + }, + + { + "uuid": "77d7e04f-89db-405f-ad53-8c2cc5bc721c", + "invariantUUID": "f632a0f0-d568-40aa-9342-341d603891e1", + "name": "vf_test", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/77d7e04f-89db-405f-ad53-8c2cc5bc721c/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "17dbd4a7-6c4d-4064-857e-8cbbc8303ed5", + "invariantUUID": "f632a0f0-d568-40aa-9342-341d603891e1", + "name": "vf_test", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/17dbd4a7-6c4d-4064-857e-8cbbc8303ed5/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "2c2fcf53-43af-41f4-8fec-0c729ca3cb4c", + "invariantUUID": "fc9af990-1ec6-4969-bd0d-973ae1ceba6f", + "name": "supplement snmp", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2c2fcf53-43af-41f4-8fec-0c729ca3cb4c/toscaModel", + "category": "DCAE Component", + "subCategory": "Microservice", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743" + }, + + { + "uuid": "57cc5cac-15a0-4c39-aff4-426930e55057", + "invariantUUID": "b0d77932-dadd-4bde-82c9-0bcc367cb81c", + "name": "Dev2DevIpAssign_24_07", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/57cc5cac-15a0-4c39-aff4-426930e55057/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "pa0916" + }, + + { + "uuid": "4859989b-5663-4ff5-ab2e-68b7bd1e43c2", + "invariantUUID": "489220ac-8a2f-44b8-97a3-12af3280aa0e", + "name": "Cognitor", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/4859989b-5663-4ff5-ab2e-68b7bd1e43c2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "sj2381" + }, + + { + "uuid": "5de1a119-461f-4ff4-8aa6-6f194e79e861", + "invariantUUID": "de9c75f4-7cc1-4a9c-8642-4fa9ee730bd2", + "name": "sang_vsp", + "version": "0.2", + "toscaModelURL": "/sdc/v1/catalog/resources/5de1a119-461f-4ff4-8aa6-6f194e79e861/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "af1041a9-0879-4fc1-9b62-42cf3eda5feb", + "invariantUUID": "4ed98cc2-22af-40c9-a031-86998cc12838", + "name": "FOI collector", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/af1041a9-0879-4fc1-9b62-42cf3eda5feb/toscaModel", + "category": "DCAE Component", + "subCategory": "Collector", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743" + }, + + { + "uuid": "271b4961-e4dc-42d5-8c0c-4da8685973ac", + "invariantUUID": "822e9970-a3fd-4d62-8f00-5819323cb54d", + "name": "vf_AR", + "version": "2.1", + "toscaModelURL": "/sdc/v1/catalog/resources/271b4961-e4dc-42d5-8c0c-4da8685973ac/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VF", + "lifecycleState": "CERTIFICATION_IN_PROGRESS", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "bdc9b09f-246e-407f-9ccd-313a240ced95", + "invariantUUID": "1b6e3f8e-c8e2-4e66-8d44-8c7186c6eb14", + "name": "VFTest5.4", + "version": "0.3", + "toscaModelURL": "/sdc/v1/catalog/resources/bdc9b09f-246e-407f-9ccd-313a240ced95/toscaModel", + "category": "Allotted Resource", + "subCategory": "Tunnel XConnect", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rb844h" + }, + + { + "uuid": "bbc70754-b046-4d8b-9ba5-1d4e96180788", + "invariantUUID": "c8e4743e-f7bd-4f04-8b7d-270f2de46c34", + "name": "VNFC_VSP_Test", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bbc70754-b046-4d8b-9ba5-1d4e96180788/toscaModel", + "category": "Network Connectivity", + "subCategory": "Virtual Links", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "7cb8a6c7-c4fb-4d46-9233-8b247bd70124", + "invariantUUID": "f607e055-7af8-470d-86d3-1e2236c1c5b9", + "name": "syslog", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/7cb8a6c7-c4fb-4d46-9233-8b247bd70124/toscaModel", + "category": "DCAE Component", + "subCategory": "Collector", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743" + }, + + { + "uuid": "ce7f92a3-d5a8-4830-b1f9-72d32ff0f2bc", + "invariantUUID": "b0d77932-dadd-4bde-82c9-0bcc367cb81c", + "name": "Dev2DevIpAssign_24_07", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ce7f92a3-d5a8-4830-b1f9-72d32ff0f2bc/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sw594b" + }, + + { + "uuid": "f721bc81-be73-4fe5-90ab-ac9544916b74", + "invariantUUID": "5ebab19c-76ab-4310-96c1-64ab03ae7f08", + "name": "New_vendor_mdns", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/f721bc81-be73-4fe5-90ab-ac9544916b74/toscaModel", + "category": "Generic", + "subCategory": "Database", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "6b934b9d-0785-4b46-8321-943a12b8031b", + "invariantUUID": "785012c2-fdd8-450d-8fa2-81ff60e25f1e", + "name": "vMMSC_AIC3.0__multi_members_multi_groups_volume.cs", + "version": "0.2", + "toscaModelURL": "/sdc/v1/catalog/resources/6b934b9d-0785-4b46-8321-943a12b8031b/toscaModel", + "category": "Application L4+", + "subCategory": "Media Servers", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "715426cc-acea-4dd9-9bbe-d338d40b0884", + "invariantUUID": "0879d8ba-7207-4ec4-9cc7-2eb695ef6876", + "name": "vmme_1710", + "version": "0.2", + "toscaModelURL": "/sdc/v1/catalog/resources/715426cc-acea-4dd9-9bbe-d338d40b0884/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "04addafc-2e5e-4381-8698-79a26acd5825", + "invariantUUID": "d348d94a-b49f-42ad-a5a2-6f94ebf58b75", + "name": "AVCXSADDAS", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/04addafc-2e5e-4381-8698-79a26acd5825/toscaModel", + "category": "Allotted Resource", + "subCategory": "IP Mux Demux", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "yy815m" + }, + + { + "uuid": "3962491f-c310-4a24-9f13-291d2acf2f08", + "invariantUUID": "5d138333-7a0f-432b-ad74-009a308c91c5", + "name": "VF- DemoR", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/3962491f-c310-4a24-9f13-291d2acf2f08/toscaModel", + "category": "Network L2-3", + "subCategory": "Router", + "resourceType": "VF", + "lifecycleState": "CERTIFICATION_IN_PROGRESS", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "191128bc-1756-469b-8973-fcc6236c72c1", + "invariantUUID": "c1fae22d-0fdb-42fe-96a7-822f19503f1b", + "name": "Scp-tempalte-test", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/191128bc-1756-469b-8973-fcc6236c72c1/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "READY_FOR_CERTIFICATION", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "9a4c7c75-b54b-4240-b3bf-2ead9b7427d1", + "invariantUUID": "b595ea39-21e7-4fee-aedb-ef68506d581d", + "name": "test-VF", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/9a4c7c75-b54b-4240-b3bf-2ead9b7427d1/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "c3d5e222-28b4-456f-8488-ff3b4846be60", + "invariantUUID": "92ff9c15-3b67-410a-b8ed-aed627656a35", + "name": "TEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEST", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/c3d5e222-28b4-456f-8488-ff3b4846be60/toscaModel", + "category": "Allotted Resource", + "subCategory": "Security Zone", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "nk909r" + }, + + { + "uuid": "c8663b6e-bbe2-401d-9500-ec5425463655", + "invariantUUID": "925243cf-e342-4d86-8558-63899fbe88da", + "name": "VF Module LDSA", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/c8663b6e-bbe2-401d-9500-ec5425463655/toscaModel", + "category": "Application L4+", + "subCategory": "Load Balancer", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "fda7c330-cb1e-4d43-9e97-87a5800b87c0", + "invariantUUID": "cc9b643b-8513-449b-a3f7-3c034b3f52a4", + "name": "composition", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fda7c330-cb1e-4d43-9e97-87a5800b87c0/toscaModel", + "category": "DCAE Component", + "subCategory": "Utility", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "27adaf15-a0c2-4889-bc10-b3fdb0bb038c", + "invariantUUID": "002b36df-41cd-4119-ab8d-0e9fae3cd3cb", + "name": "cdap_host", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/27adaf15-a0c2-4889-bc10-b3fdb0bb038c/toscaModel", + "category": "DCAE Component", + "subCategory": "Utility", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "84855843-5247-4e97-a2bd-5395a510253b", + "invariantUUID": "755deb72-d767-4656-98b0-9d8ed288e9e6", + "name": "TestClamp", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/84855843-5247-4e97-a2bd-5395a510253b/toscaModel", + "category": "Application L4+", + "subCategory": "Application Server", + "resourceType": "VF", + "lifecycleState": "READY_FOR_CERTIFICATION", + "lastUpdaterUserId": "rx827p" + }, + + { + "uuid": "e01dfc8f-2529-423b-9765-08b57df6ba51", + "invariantUUID": "6c7aaec2-59eb-41d9-8681-b7f976ab668d", + "name": "eNodeB-vf", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/e01dfc8f-2529-423b-9765-08b57df6ba51/toscaModel", + "category": "Application L4+", + "subCategory": "Application Server", + "resourceType": "VF", + "lifecycleState": "CERTIFICATION_IN_PROGRESS", + "lastUpdaterUserId": "rx827p" + }, + + { + "uuid": "d26e8473-b1c9-4751-bf7c-be0e10ba71ac", + "invariantUUID": "e06a2a94-5ff9-4ab7-879f-c2d5cfaef1ca", + "name": "tdy", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/d26e8473-b1c9-4751-bf7c-be0e10ba71ac/toscaModel", + "category": "Allotted Resource", + "subCategory": "Tunnel XConnect", + "resourceType": "VF", + "lifecycleState": "READY_FOR_CERTIFICATION", + "lastUpdaterUserId": "rb844h" + }, + + { + "uuid": "038601f9-f242-49ab-8c19-08b95f34f7bf", + "invariantUUID": "0f183d4f-875b-4e7b-a23d-b9d68d81e0db", + "name": "Highland Park", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/038601f9-f242-49ab-8c19-08b95f34f7bf/toscaModel", + "category": "DCAE Component", + "subCategory": "Microservice", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "25781e10-5fdd-499c-869d-0d70d61843df", + "invariantUUID": "f68b1982-a6ab-4849-b548-0d35655f4410", + "name": "Mikes VF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/25781e10-5fdd-499c-869d-0d70d61843df/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "mh677g" + }, + + { + "uuid": "c1c02cff-855f-438e-85f8-40c362874896", + "invariantUUID": "64cb5201-90d4-4cab-a6a9-f7416eeb307f", + "name": "PXTC", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/c1c02cff-855f-438e-85f8-40c362874896/toscaModel", + "category": "Application L4+", + "subCategory": "Web Server", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "837c2fee-c2b2-4e95-ad48-dd69772d99bd", + "invariantUUID": "e48b3ea8-39bc-41eb-84bf-f5ef267d31e4", + "name": "vMOG VNF 1", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/837c2fee-c2b2-4e95-ad48-dd69772d99bd/toscaModel", + "category": "Network L2-3", + "subCategory": "Gateway", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "29018914-966c-442d-9d08-251b9dc45b8e", + "invariantUUID": "a33ed748-3477-4434-b3f3-b5560f5e7d9b", + "name": "vcts3", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/29018914-966c-442d-9d08-251b9dc45b8e/toscaModel", + "category": "Application L4+", + "subCategory": "Application Server", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "6906502e-6c2c-4b6f-8a3e-a2283f13cd69", + "invariantUUID": "fae890f6-4cdc-4e89-9502-3b1491c90393", + "name": "Generic VNF Source", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/6906502e-6c2c-4b6f-8a3e-a2283f13cd69/toscaModel", + "category": "DCAE Component", + "subCategory": "Source", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "4168799c-a51f-4664-a5e9-f75bedda2a1c", + "invariantUUID": "55befb8d-81db-4ac0-8820-8ec582f8147b", + "name": "AppleVF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4168799c-a51f-4664-a5e9-f75bedda2a1c/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "nk909r" + }, + + { + "uuid": "28c11fbd-a859-4819-b8c7-555b4ed05a7f", + "invariantUUID": "ab6094d3-ffe3-4386-b1c2-d6e0dbf103f3", + "name": "VF", + "version": "0.2", + "toscaModelURL": "/sdc/v1/catalog/resources/28c11fbd-a859-4819-b8c7-555b4ed05a7f/toscaModel", + "category": "DCAE Component", + "subCategory": "Collector", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "ym903w" + }, + + { + "uuid": "dad125b7-cd8a-4fbe-a4ad-2b04944079da", + "invariantUUID": "dd3c68ac-5e6c-4b22-bea3-44fd7d6a6097", + "name": "Mazav", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/dad125b7-cd8a-4fbe-a4ad-2b04944079da/toscaModel", + "category": "Application L4+", + "subCategory": "Database", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "1e7f07c7-ff4c-40a6-95f6-a9b05f138027", + "invariantUUID": "cfff70d2-f942-4b25-b2ca-e64f64af511d", + "name": "vMMSC_AIC3.0__multi_members_multi_groups_volume", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1e7f07c7-ff4c-40a6-95f6-a9b05f138027/toscaModel", + "category": "Application L4+", + "subCategory": "Media Servers", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "yy815m" + }, + + { + "uuid": "2539b088-8e74-48d5-8401-77200be23f11", + "invariantUUID": "24ff5476-cabe-4cb5-99c8-e0f9ace75412", + "name": "AlinaVSP", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/2539b088-8e74-48d5-8401-77200be23f11/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "8bebc883-1961-4d2f-9c34-b8a9f56dd6bf", + "invariantUUID": "49241b40-9bd1-4d05-83a9-b097f40f4cc0", + "name": "MonitoringVSP", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/8bebc883-1961-4d2f-9c34-b8a9f56dd6bf/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "e0acc751-00cf-4f45-ac9d-23eb9cfc106d", + "invariantUUID": "1181d1c5-2524-40c2-bc81-e40dd813d70f", + "name": "Oren", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/e0acc751-00cf-4f45-ac9d-23eb9cfc106d/toscaModel", + "category": "Allotted Resource", + "subCategory": "Service Admin", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "ol664w" + }, + + { + "uuid": "2e42bac2-318a-410c-b8ff-3b3a31351be7", + "invariantUUID": "b2b88a73-5c55-4984-99dd-a35c55935d14", + "name": "SCP-Test-VSP", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2e42bac2-318a-410c-b8ff-3b3a31351be7/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "1a2bc1db-c4b3-4c26-837c-1f16b4e4eed0", + "invariantUUID": "869a4e40-2aac-42f6-9520-51d18a7bd5e0", + "name": "Vscpaas_Test2", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1a2bc1db-c4b3-4c26-837c-1f16b4e4eed0/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "52150d50-0b95-4056-b07a-abcf6414754e", + "invariantUUID": "cc4e47f7-360d-425b-a563-e870203d2d48", + "name": "SNMP Trap Collector", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/52150d50-0b95-4056-b07a-abcf6414754e/toscaModel", + "category": "DCAE Component", + "subCategory": "Collector", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "a36b04b6-6756-4860-9cbb-66a72d02361f", + "invariantUUID": "35841fd9-e768-466a-9a08-fd9f7dbef98d", + "name": "Vf-no-license", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/a36b04b6-6756-4860-9cbb-66a72d02361f/toscaModel", + "category": "Application L4+", + "subCategory": "Media Servers", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "8a1c4ce1-f132-4e05-92c1-91386689ddf5", + "invariantUUID": "4bd0b375-cec3-4da8-a6fb-028b523da60e", + "name": "vprobe", + "version": "0.2", + "toscaModelURL": "/sdc/v1/catalog/resources/8a1c4ce1-f132-4e05-92c1-91386689ddf5/toscaModel", + "category": "Application L4+", + "subCategory": "Application Server", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m08740" + }, + + { + "uuid": "4ae669b4-778a-4f13-bf42-99da0c805414", + "invariantUUID": "17ba1436-2800-4bcb-b066-0484d119ea8d", + "name": "oren2", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/4ae669b4-778a-4f13-bf42-99da0c805414/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "ol664w" + }, + + { + "uuid": "c68a5162-bebf-4675-9b83-1aec994abd35", + "invariantUUID": "219b289e-e94e-4c1b-8ca0-53a19f4cf140", + "name": "AlinaVF", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c68a5162-bebf-4675-9b83-1aec994abd35/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "d03c68fc-ed63-4fce-bf7f-ebe23993157d", + "invariantUUID": "94746803-5a82-4112-9719-7cb64a43ea99", + "name": "testfe", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/d03c68fc-ed63-4fce-bf7f-ebe23993157d/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VF", + "lifecycleState": "CERTIFICATION_IN_PROGRESS", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "ab88f446-f17f-4419-a4ce-84a24bc9a3c0", + "invariantUUID": "63aec7b3-8674-42ff-a9be-9d6c51544776", + "name": "Tunnel_XConnTest", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ab88f446-f17f-4419-a4ce-84a24bc9a3c0/toscaModel", + "category": "Allotted Resource", + "subCategory": "Tunnel XConnect", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "81d54f6d-ac2d-4282-ada9-48214e13dfd9", + "invariantUUID": "80d253d9-dca7-4d5e-96f2-e060deabf3bb", + "name": "Dev2DevNFOD_1207", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/81d54f6d-ac2d-4282-ada9-48214e13dfd9/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "pa0916" + }, + + { + "uuid": "c9ea2798-f3ba-4826-ae93-0786820cb890", + "invariantUUID": "5882c528-76fe-4884-90c7-71301ca52cf8", + "name": "vMMSC_ECA", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/c9ea2798-f3ba-4826-ae93-0786820cb890/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "az2497" + }, + + { + "uuid": "e795b7f2-09c3-40a8-bc38-64bdad5e9f68", + "invariantUUID": "96079a9a-dbe3-4492-ba85-95b1b49d0983", + "name": "APPleVFV10", + "version": "3.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e795b7f2-09c3-40a8-bc38-64bdad5e9f68/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "nk909r" + }, + + { + "uuid": "1b9546ab-d1cd-489b-b07b-13537418ad57", + "invariantUUID": "4612156f-0a8d-46c5-bfb1-86e80148d123", + "name": "BerryVFNamequaryV10", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/1b9546ab-d1cd-489b-b07b-13537418ad57/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "READY_FOR_CERTIFICATION", + "lastUpdaterUserId": "nk909r" + }, + + { + "uuid": "b71e8927-6567-4f14-a0ec-3bce871934c4", + "invariantUUID": "73bc5a4f-b902-43b2-83c2-915fa274960f", + "name": "vPE", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/b71e8927-6567-4f14-a0ec-3bce871934c4/toscaModel", + "category": "Application L4+", + "subCategory": "Border Element", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "31ad5aaa-8779-4384-819f-4a2ec217f608", + "invariantUUID": "f47b1fa4-574f-4c30-b0cf-af7919868eed", + "name": "BerryVFNamequery", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/31ad5aaa-8779-4384-819f-4a2ec217f608/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "nk909r" + }, + + { + "uuid": "10751313-0dd7-464a-92e3-ec77fcada2c8", + "invariantUUID": "229580a6-2d12-49b6-8c89-54d04f4569b4", + "name": "vIECCF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/10751313-0dd7-464a-92e3-ec77fcada2c8/toscaModel", + "category": "Application L4+", + "subCategory": "Database", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99124" + }, + + { + "uuid": "3951e021-7595-43b1-a6fd-de077c01af54", + "invariantUUID": "925243cf-e342-4d86-8558-63899fbe88da", + "name": "VF Module LDSA", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3951e021-7595-43b1-a6fd-de077c01af54/toscaModel", + "category": "Application L4+", + "subCategory": "Load Balancer", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99124" + }, + + { + "uuid": "3b30f9df-5cc6-4f1d-b8fc-bf034891539e", + "invariantUUID": "10a2a956-5190-4aa8-8d3d-dea5863ab40f", + "name": "blueberryvf", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3b30f9df-5cc6-4f1d-b8fc-bf034891539e/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "lm906x" + }, + + { + "uuid": "c4e944bd-aa6a-4bd0-85ac-5566c98d2adc", + "invariantUUID": "cc4e47f7-360d-425b-a563-e870203d2d48", + "name": "SNMP Trap Collector", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c4e944bd-aa6a-4bd0-85ac-5566c98d2adc/toscaModel", + "category": "DCAE Component", + "subCategory": "Collector", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "07116436-aab8-4a54-85be-6691e451e65b", + "invariantUUID": "b1133487-2512-4a6d-8b68-4f56b81fd6a2", + "name": "1607_MOG", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/07116436-aab8-4a54-85be-6691e451e65b/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "70974b30-6b89-41d2-8b5d-779279db3b96", + "invariantUUID": "725e5fd1-2520-4669-a5f2-23f9ad2fbec4", + "name": "vSCP0502", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/70974b30-6b89-41d2-8b5d-779279db3b96/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "c9e436c3-539f-45e2-90b4-b046af907877", + "invariantUUID": "bc7fe896-e286-41cb-a11f-7081fc92876b", + "name": "vMMSC", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/c9e436c3-539f-45e2-90b4-b046af907877/toscaModel", + "category": "Application L4+", + "subCategory": "Database", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "79a31423-43ae-4f00-9314-dbc6ed5dfcb7", + "invariantUUID": "6c1bcf11-ecdc-465d-83c7-4a1735ff8d00", + "name": "1607_MOG_multi_members_volume", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/79a31423-43ae-4f00-9314-dbc6ed5dfcb7/toscaModel", + "category": "Application L4+", + "subCategory": "Border Element", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99124" + }, + + { + "uuid": "ed9927dc-3c43-47bf-9c55-3aa3240749c4", + "invariantUUID": "d6ac75ef-0e55-41bb-9cac-bedd59c3b0b8", + "name": "SNMP Collector", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ed9927dc-3c43-47bf-9c55-3aa3240749c4/toscaModel", + "category": "DCAE Component", + "subCategory": "Collector", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "82460d6a-1cd7-4c57-bc89-625600555f80", + "invariantUUID": "c67108d4-a0b0-4eee-8fbc-c881d7bb21d3", + "name": "VF modules vMMSC", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/82460d6a-1cd7-4c57-bc89-625600555f80/toscaModel", + "category": "Application L4+", + "subCategory": "Web Server", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99124" + }, + + { + "uuid": "1d7a184b-3680-47e5-92de-6ac7207699a3", + "invariantUUID": "f7ba2bcd-747b-4ff6-994a-91be20fc726c", + "name": "VF modules", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/1d7a184b-3680-47e5-92de-6ac7207699a3/toscaModel", + "category": "Application L4+", + "subCategory": "Web Server", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "90043cc2-5150-4127-aabe-67ed5c8a603b", + "invariantUUID": "fc6589c4-f030-4d02-b516-b99f73bfdca8", + "name": "VF module_2", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/90043cc2-5150-4127-aabe-67ed5c8a603b/toscaModel", + "category": "Application L4+", + "subCategory": "Media Servers", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "4c81fa7a-9e59-498a-96ba-2fc16eba23a3", + "invariantUUID": "4612156f-0a8d-46c5-bfb1-86e80148d123", + "name": "BerryVFNamequaryV10", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4c81fa7a-9e59-498a-96ba-2fc16eba23a3/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "nk909r" + }, + + { + "uuid": "ac603264-cdf7-49ab-a9ae-92d341023218", + "invariantUUID": "379ab526-dc81-4b31-b60d-31c1805ddf5a", + "name": "FDNT1", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/ac603264-cdf7-49ab-a9ae-92d341023218/toscaModel", + "category": "Application L4+", + "subCategory": "Border Element", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "c8c959fb-c57e-4a10-9f7e-d5cc5bbd4301", + "invariantUUID": "1170b507-33f9-4a2e-a9af-e44744b6c10d", + "name": "contrail route", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/c8c959fb-c57e-4a10-9f7e-d5cc5bbd4301/toscaModel", + "category": "Allotted Resource", + "subCategory": "Contrail Route", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "e3edd7bb-9732-4915-b1b9-2b4af561d85c", + "invariantUUID": "7669a21f-e8bf-429d-8267-b9a9b1be0e16", + "name": "test-port", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/e3edd7bb-9732-4915-b1b9-2b4af561d85c/toscaModel", + "category": "Network L4+", + "subCategory": "Common Network Resources", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "8531f392-b695-49f4-98f8-cba632eb68fc", + "invariantUUID": "9dfe647e-7285-48dc-9e5d-f275f470e4ba", + "name": "security Zone", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/8531f392-b695-49f4-98f8-cba632eb68fc/toscaModel", + "category": "Allotted Resource", + "subCategory": "Security Zone", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "e4924deb-7355-4f1e-9f8f-bd4e3b609e98", + "invariantUUID": "6eb4b1ca-75ac-454b-a145-1ea27157bfac", + "name": "IP_Mux_Demux", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e4924deb-7355-4f1e-9f8f-bd4e3b609e98/toscaModel", + "category": "Allotted Resource", + "subCategory": "IP Mux Demux", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99124" + }, + + { + "uuid": "44ff8000-e703-4538-b26a-f2bc8205d7d4", + "invariantUUID": "26badc5a-d29e-4583-b773-0d42366a8bb1", + "name": "FDNT1234", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/44ff8000-e703-4538-b26a-f2bc8205d7d4/toscaModel", + "category": "Network L2-3", + "subCategory": "WAN Connectors", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99124" + }, + + { + "uuid": "5ce3812b-935b-4c17-a1a7-a79a5179772e", + "invariantUUID": "ad3e0a75-d124-418d-ad57-970a9668e4d8", + "name": "vTSBC1", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/5ce3812b-935b-4c17-a1a7-a79a5179772e/toscaModel", + "category": "Network L2-3", + "subCategory": "Gateway", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "e9fb3aa6-44f7-4154-9db6-1f60dac2d72f", + "invariantUUID": "ac661ee8-21b0-417f-98af-0b891c5f6c0d", + "name": "TuesdayVSP", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/e9fb3aa6-44f7-4154-9db6-1f60dac2d72f/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "75b67a7f-9e2e-4c7d-a926-331f05ce5ff1", + "invariantUUID": "32d62649-390c-4208-b5cd-c1dc7dddf3db", + "name": "VF modules_1", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/75b67a7f-9e2e-4c7d-a926-331f05ce5ff1/toscaModel", + "category": "Application L4+", + "subCategory": "Load Balancer", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "25b6b8dc-8f32-42ea-bcea-04369827ddbf", + "invariantUUID": "e5d959b4-f11e-42ac-aa26-26beb526faf1", + "name": "pnf-resource-test", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/25b6b8dc-8f32-42ea-bcea-04369827ddbf/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + + { + "uuid": "f4bed159-36a0-4ea4-b2d4-2ebea8c208b8", + "invariantUUID": "e6b04d60-4a33-4899-9185-082b9b170cb8", + "name": "Dev2DevNFOD", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f4bed159-36a0-4ea4-b2d4-2ebea8c208b8/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sw594b" + }, + + { + "uuid": "8dec3b8a-a0fa-4634-bbb4-d7bad5a912ab", + "invariantUUID": "eda652e4-6740-46bf-8d0f-92c4752070f6", + "name": "FCGI_OS", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/8dec3b8a-a0fa-4634-bbb4-d7bad5a912ab/toscaModel", + "category": "Application L4+", + "subCategory": "Database", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "691cbc68-61df-472d-ad2d-8791444d2e27", + "invariantUUID": "7daf1f14-2aa3-48d8-89e5-3383cf004b6a", + "name": "AAI broker", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/691cbc68-61df-472d-ad2d-8791444d2e27/toscaModel", + "category": "DCAE Component", + "subCategory": "Microservice", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "ccd6fa51-aafd-401f-96ce-3f0c94418865", + "invariantUUID": "fe5535d7-80e5-4278-bbdd-d2156b9a4d24", + "name": "test-consol", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/ccd6fa51-aafd-401f-96ce-3f0c94418865/toscaModel", + "category": "Network L2-3", + "subCategory": "Gateway", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "100be1c2-28d9-4d8c-8551-608f82b202f8", + "invariantUUID": "771cb756-d74d-416d-97cb-6c88f1915721", + "name": "Source Generic", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/100be1c2-28d9-4d8c-8551-608f82b202f8/toscaModel", + "category": "DCAE Component", + "subCategory": "Source", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + + { + "uuid": "e2555d36-4fec-476a-8504-6e111f5d5dfd", + "invariantUUID": "cca91831-e7c4-4761-86eb-200206af302d", + "name": "VF Volume group", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/e2555d36-4fec-476a-8504-6e111f5d5dfd/toscaModel", + "category": "Application L4+", + "subCategory": "Load Balancer", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "361f7f83-e4dd-4a27-ad4b-a7e1c7a52672", + "invariantUUID": "6598647d-b141-4c39-be82-91b536017bf2", + "name": "grapevnf", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/361f7f83-e4dd-4a27-ad4b-a7e1c7a52672/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "lm906x" + }, + + { + "uuid": "78160afe-b5e3-4978-8923-40d04671bd30", + "invariantUUID": "9b943920-4286-4f78-bc98-387d15812490", + "name": "APPC-test", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/78160afe-b5e3-4978-8923-40d04671bd30/toscaModel", + "category": "Network L4+", + "subCategory": "Common Network Resources", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "596c8b1d-3a1d-47fc-ace2-1fbebb94b1e5", + "invariantUUID": "b99889d1-bc9d-4a90-942c-88e21c358f75", + "name": "cherryvf", + "version": "3.0", + "toscaModelURL": "/sdc/v1/catalog/resources/596c8b1d-3a1d-47fc-ace2-1fbebb94b1e5/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "nk909r" + }, + + { + "uuid": "da3619c1-9b19-4edc-9853-a714c5034371", + "invariantUUID": "b90f7990-667a-4f63-9e7f-ee02f64766f1", + "name": "FDNT", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/da3619c1-9b19-4edc-9853-a714c5034371/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "m99121" + }, + + { + "uuid": "3c22db36-3461-4463-8b11-c8fbdb951c1e", + "invariantUUID": "42e3c73c-829f-464c-90fd-326ed7018d06", + "name": "RonyTestCSAR", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/3c22db36-3461-4463-8b11-c8fbdb951c1e/toscaModel", + "category": "Allotted Resource", + "subCategory": "Service Admin", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "rb844h" + }, + + { + "uuid": "d6c133c5-ab82-4c60-afe6-90556da55c7e", + "invariantUUID": "009e4104-2403-49c4-94ee-6dcb0547e44d", + "name": "VES Collector", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d6c133c5-ab82-4c60-afe6-90556da55c7e/toscaModel", + "category": "DCAE Component", + "subCategory": "Collector", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "43efef8f-204c-4a54-9121-ae19951063aa", + "invariantUUID": "926f6d60-bf84-46c4-9ed7-f0bb774e5184", + "name": "Sangeetha", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/43efef8f-204c-4a54-9121-ae19951063aa/toscaModel", + "category": "DCAE Component", + "subCategory": "Database", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "e01dfc8f-2529-423b-9765-08b57df6ba51", + "invariantUUID": "6c7aaec2-59eb-41d9-8681-b7f976ab668d", + "name": "eNodeB-vf", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e01dfc8f-2529-423b-9765-08b57df6ba51/toscaModel", + "category": "Application L4+", + "subCategory": "Application Server", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + + { + "uuid": "1cad2e90-0259-498f-884d-7bbe5a156fb2", + "invariantUUID": "76b01019-a533-4c31-871d-6275924c7543", + "name": "vPE-AV-renana", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1cad2e90-0259-498f-884d-7bbe5a156fb2/toscaModel", + "category": "Network L2-3", + "subCategory": "Router", + "resourceType": "VF", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08743" + }, + + { + "uuid": "747ccce2-7efb-403d-acd3-88bc9ffb43a2", + "invariantUUID": "76b01019-a533-4c31-871d-6275924c7543", + "name": "vPE-AV-renana", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/747ccce2-7efb-403d-acd3-88bc9ffb43a2/toscaModel", + "category": "Network L2-3", + "subCategory": "Router", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "2d0cb42c-398e-4c4c-959a-290459489cef", + "invariantUUID": "935689b9-80e2-4818-8c2d-fbbeaec9b56a", + "name": "csarTest", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/2d0cb42c-398e-4c4c-959a-290459489cef/toscaModel", + "category": "Application L4+", + "subCategory": "Load Balancer", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "ss8214" + }, + + { + "uuid": "62c5d4c8-1a5a-4081-bde7-8805821f41a0", + "invariantUUID": "5bf48fb1-a073-4ad5-84e0-387d9160713c", + "name": "madhu_mdns", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/62c5d4c8-1a5a-4081-bde7-8805821f41a0/toscaModel", + "category": "Application L4+", + "subCategory": "Firewall", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "sa997j" + }, + + { + "uuid": "8faf42f4-287a-430e-a761-9df0ce4075d1", + "invariantUUID": "6e2213a9-6ca2-4ab9-adfd-1af95c61f23d", + "name": "vPE-BV-Renana", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/8faf42f4-287a-430e-a761-9df0ce4075d1/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "rh176a" + }, + + { + "uuid": "541310cd-d7b4-48d1-969a-d81866277298", + "invariantUUID": "30df25ac-d6c9-4cec-8c56-b287cd462e30", + "name": "TCA", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/541310cd-d7b4-48d1-969a-d81866277298/toscaModel", + "category": "DCAE Component", + "subCategory": "Microservice", + "resourceType": "VF", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "ss7286" + } +] \ No newline at end of file -- cgit 1.2.3-korg From b3a21f74c5c31644eeef9634e33dde8a6972e3f8 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 02:58:27 -0700 Subject: Rework the Clamp db model Rework the DB model + new SQL associated to that Change-Id: Ibfa6e0bc9942f8b51a1681fab98502c462d34def Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- extra/sql/bulkload/clds-create-db-objects.sql | 55 ++-- extra/sql/bulkload/clds-stored-procedures.sql | 164 ++++++------ extra/sql/drop/clds-drop-db-objects.sql | 7 +- .../onap/clamp/clds/model/CldsAlarmCondition.java | 8 +- .../onap/clamp/clds/model/CldsDBServiceCache.java | 10 +- .../java/org/onap/clamp/clds/model/CldsEvent.java | 108 +++++--- .../java/org/onap/clamp/clds/model/CldsModel.java | 287 ++++++++++++++------- .../org/onap/clamp/clds/model/CldsServiceData.java | 54 ++-- .../org/onap/clamp/clds/model/CldsTemplate.java | 69 ++--- .../java/org/onap/clamp/clds/model/CldsVfData.java | 33 ++- .../org/onap/clamp/clds/model/CldsVfcData.java | 7 +- .../java/org/onap/clamp/clds/model/DcaeEvent.java | 81 +++--- .../java/org/onap/clamp/clds/model/ValueItem.java | 3 +- 13 files changed, 537 insertions(+), 349 deletions(-) (limited to 'src/main/java') diff --git a/extra/sql/bulkload/clds-create-db-objects.sql b/extra/sql/bulkload/clds-create-db-objects.sql index 5cbb7e017..3312daf56 100644 --- a/extra/sql/bulkload/clds-create-db-objects.sql +++ b/extra/sql/bulkload/clds-create-db-objects.sql @@ -1,18 +1,18 @@ -# +# # Create CLDS database objects (tables, etc.) # # CREATE DATABASE `camundabpm`; -USE `camundabpm`; -DROP USER 'camunda'; -CREATE USER 'camunda'; -GRANT ALL on camundabpm.* to 'camunda' identified by 'ndMSpw4CAM' with GRANT OPTION; -FLUSH PRIVILEGES; +USE `camundabpm`; +DROP USER 'camunda'; +CREATE USER 'camunda'; +GRANT ALL on camundabpm.* to 'camunda' identified by 'ndMSpw4CAM' with GRANT OPTION; +FLUSH PRIVILEGES; CREATE DATABASE `cldsdb4`; -USE `cldsdb4`; -DROP USER 'clds'; -CREATE USER 'clds'; +USE `cldsdb4`; +DROP USER 'clds'; +CREATE USER 'clds'; GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION; GRANT SELECT on mysql.proc TO 'clds'; FLUSH PRIVILEGES; @@ -32,7 +32,7 @@ CREATE TABLE template_bpmn ( template_bpmn_id VARCHAR(36) NOT NULL, template_id VARCHAR(36) NOT NULL, template_bpmn_text MEDIUMTEXT NOT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (template_bpmn_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -41,7 +41,7 @@ CREATE TABLE template_image ( template_image_id VARCHAR(36) NOT NULL, template_id VARCHAR(36) NOT NULL, template_image_text MEDIUMTEXT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (template_image_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -50,7 +50,7 @@ CREATE TABLE template_doc ( template_doc_id VARCHAR(36) NOT NULL, template_id VARCHAR(36) NOT NULL, template_doc_text MEDIUMTEXT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (template_doc_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -64,16 +64,20 @@ CREATE TABLE model ( event_id VARCHAR(36) NULL, control_name_prefix VARCHAR(80) NULL, control_name_uuid VARCHAR(36) NOT NULL, + service_type_id VARCHAR(80) NULL, + deployment_id VARCHAR(80) NULL, PRIMARY KEY (model_id), UNIQUE (model_name), - UNIQUE (control_name_uuid) + UNIQUE (control_name_uuid), + UNIQUE (service_type_id), + UNIQUE (deployment_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; CREATE TABLE model_properties ( model_prop_id VARCHAR(36) NOT NULL, model_id VARCHAR(36) NOT NULL, model_prop_text MEDIUMTEXT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (model_prop_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -82,7 +86,7 @@ CREATE TABLE model_blueprint ( model_blueprint_id VARCHAR(36) NOT NULL, model_id VARCHAR(36) NOT NULL, model_blueprint_text MEDIUMTEXT NULL, - userid VARCHAR(8), + user_id VARCHAR(80), timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (model_blueprint_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -104,7 +108,7 @@ CREATE TABLE event ( action_state_cd VARCHAR(80) NULL, prev_event_id VARCHAR(36) NULL, process_instance_id VARCHAR(80) NULL, - userid VARCHAR(8) NULL, + user_id VARCHAR(80) NULL, timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (event_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; @@ -131,7 +135,7 @@ ALTER TABLE template ADD CONSTRAINT template_doc_id_fkey01 FOREIGN KEY (template_doc_id) REFERENCES template_doc (template_doc_id); - + ALTER TABLE template_bpmn ADD CONSTRAINT template_id_fkey02 FOREIGN KEY (template_id) @@ -145,8 +149,8 @@ ALTER TABLE template_image ALTER TABLE template_doc ADD CONSTRAINT template_id_fkey04 FOREIGN KEY (template_id) - REFERENCES template (template_id); - + REFERENCES template (template_id); + ALTER TABLE model ADD CONSTRAINT template_id_fkey01 FOREIGN KEY (template_id) @@ -161,7 +165,7 @@ ALTER TABLE model ADD CONSTRAINT model_blueprint_id_fkey01 FOREIGN KEY (model_blueprint_id) REFERENCES model_blueprint (model_blueprint_id); - + ALTER TABLE model ADD CONSTRAINT event_id_fkey01 FOREIGN KEY (event_id) @@ -170,20 +174,19 @@ ALTER TABLE model ALTER TABLE model_properties ADD CONSTRAINT model_id_fkey01 FOREIGN KEY (model_id) - REFERENCES model (model_id); + REFERENCES model (model_id); ALTER TABLE model_blueprint ADD CONSTRAINT model_id_fkey02 FOREIGN KEY (model_id) - REFERENCES model (model_id); + REFERENCES model (model_id); ALTER TABLE model_instance ADD CONSTRAINT model_id_fkey04 FOREIGN KEY (model_id) - REFERENCES model (model_id); - + REFERENCES model (model_id); + ALTER TABLE event ADD CONSTRAINT model_id_fkey03 FOREIGN KEY (model_id) - REFERENCES model (model_id); - + REFERENCES model (model_id); diff --git a/extra/sql/bulkload/clds-stored-procedures.sql b/extra/sql/bulkload/clds-stored-procedures.sql index 41cc75e12..112cb2b55 100644 --- a/extra/sql/bulkload/clds-stored-procedures.sql +++ b/extra/sql/bulkload/clds-stored-procedures.sql @@ -1,7 +1,7 @@ -# -# CLDS stored procedures # +# CLDS stored procedures # + USE cldsdb4; DROP PROCEDURE IF EXISTS upd_event; @@ -10,43 +10,43 @@ DROP PROCEDURE IF EXISTS del_all_model_instances; DROP PROCEDURE IF EXISTS del_model_instance; DROP PROCEDURE IF EXISTS ins_model_instance; DROP PROCEDURE IF EXISTS set_model; -DROP PROCEDURE IF EXISTS get_model; -DROP PROCEDURE IF EXISTS get_model_template; +DROP PROCEDURE IF EXISTS get_model; +DROP PROCEDURE IF EXISTS get_model_template; DROP PROCEDURE IF EXISTS set_template; -DROP PROCEDURE IF EXISTS get_template; +DROP PROCEDURE IF EXISTS get_template; DELIMITER // CREATE PROCEDURE get_template (IN v_template_name VARCHAR(80), OUT v_template_id VARCHAR(36), OUT v_template_bpmn_id VARCHAR(36), - OUT v_template_bpmn_userid VARCHAR(8), + OUT v_template_bpmn_user_id VARCHAR(80), OUT v_template_bpmn_text MEDIUMTEXT, OUT v_template_image_id VARCHAR(36), - OUT v_template_image_userid VARCHAR(8), + OUT v_template_image_user_id VARCHAR(80), OUT v_template_image_text MEDIUMTEXT, OUT v_template_doc_id VARCHAR(36), - OUT v_template_doc_userid VARCHAR(8), + OUT v_template_doc_user_id VARCHAR(80), OUT v_template_doc_text MEDIUMTEXT) BEGIN SELECT t.template_id, tb.template_bpmn_id, - tb.userid, + tb.user_id, tb.template_bpmn_text, ti.template_image_id, - ti.userid, + ti.user_id, ti.template_image_text, td.template_doc_id, - td.userid, + td.user_id, td.template_doc_text INTO v_template_id, v_template_bpmn_id, - v_template_bpmn_userid, + v_template_bpmn_user_id, v_template_bpmn_text, v_template_image_id, - v_template_image_userid, + v_template_image_user_id, v_template_image_text, v_template_doc_id, - v_template_doc_userid, + v_template_doc_user_id, v_template_doc_text FROM template t, template_bpmn tb, @@ -59,17 +59,17 @@ BEGIN END; CREATE PROCEDURE set_template (IN v_template_name VARCHAR(80), - IN v_userid VARCHAR(8), + IN v_user_id VARCHAR(80), IN v_template_bpmn_text MEDIUMTEXT, IN v_template_image_text MEDIUMTEXT, IN v_template_doc_text MEDIUMTEXT, OUT v_template_id VARCHAR(36), OUT v_template_bpmn_id VARCHAR(36), - OUT v_template_bpmn_userid VARCHAR(8), + OUT v_template_bpmn_user_id VARCHAR(80), OUT v_template_image_id VARCHAR(36), - OUT v_template_image_userid VARCHAR(8), + OUT v_template_image_user_id VARCHAR(80), OUT v_template_doc_id VARCHAR(36), - OUT v_template_doc_userid VARCHAR(8)) + OUT v_template_doc_user_id VARCHAR(80)) BEGIN DECLARE v_old_template_bpmn_text MEDIUMTEXT; DECLARE v_old_template_image_text MEDIUMTEXT; @@ -79,13 +79,13 @@ BEGIN v_template_name, v_template_id, v_template_bpmn_id, - v_template_bpmn_userid, + v_template_bpmn_user_id, v_old_template_bpmn_text, v_template_image_id, - v_template_image_userid, + v_template_image_user_id, v_old_template_image_text, v_template_doc_id, - v_template_doc_userid, + v_template_doc_user_id, v_old_template_doc_text); IF v_template_id IS NULL THEN BEGIN @@ -98,23 +98,23 @@ BEGIN IF v_template_bpmn_id IS NULL OR v_template_bpmn_text <> v_old_template_bpmn_text THEN SET v_template_bpmn_id = UUID(); INSERT INTO template_bpmn - (template_bpmn_id, template_id, template_bpmn_text, userid) - VALUES (v_template_bpmn_id, v_template_id, v_template_bpmn_text, v_userid); - SET v_template_bpmn_userid = v_userid; + (template_bpmn_id, template_id, template_bpmn_text, user_id) + VALUES (v_template_bpmn_id, v_template_id, v_template_bpmn_text, v_user_id); + SET v_template_bpmn_user_id = v_user_id; END IF; IF v_template_image_id IS NULL OR v_template_image_text <> v_old_template_image_text THEN SET v_template_image_id = UUID(); INSERT INTO template_image - (template_image_id, template_id, template_image_text, userid) - VALUES (v_template_image_id, v_template_id, v_template_image_text, v_userid); - SET v_template_image_userid = v_userid; + (template_image_id, template_id, template_image_text, user_id) + VALUES (v_template_image_id, v_template_id, v_template_image_text, v_user_id); + SET v_template_image_user_id = v_user_id; END IF; IF v_template_doc_id IS NULL OR v_template_doc_text <> v_old_template_doc_text THEN SET v_template_doc_id = UUID(); INSERT INTO template_doc - (template_doc_id, template_id, template_doc_text, userid) - VALUES (v_template_doc_id, v_template_id, v_template_doc_text, v_userid); - SET v_template_doc_userid = v_userid; + (template_doc_id, template_id, template_doc_text, user_id) + VALUES (v_template_doc_id, v_template_id, v_template_doc_text, v_user_id); + SET v_template_doc_user_id = v_user_id; END IF; UPDATE template SET template_bpmn_id = v_template_bpmn_id, @@ -127,52 +127,58 @@ CREATE PROCEDURE get_model OUT v_control_name_prefix VARCHAR(80), INOUT v_control_name_uuid VARCHAR(36), OUT v_model_id VARCHAR(36), + OUT v_service_type_id VARCHAR(80), + OUT v_deployment_id VARCHAR(80), OUT v_template_name VARCHAR(80), OUT v_template_id VARCHAR(36), OUT v_model_prop_id VARCHAR(36), - OUT v_model_prop_userid VARCHAR(8), + OUT v_model_prop_user_id VARCHAR(80), OUT v_model_prop_text MEDIUMTEXT, OUT v_model_blueprint_id VARCHAR(36), - OUT v_model_blueprint_userid VARCHAR(8), + OUT v_model_blueprint_user_id VARCHAR(80), OUT v_model_blueprint_text MEDIUMTEXT, OUT v_event_id VARCHAR(36), OUT v_action_cd VARCHAR(80), OUT v_action_state_cd VARCHAR(80), OUT v_event_process_instance_id VARCHAR(80), - OUT v_event_userid VARCHAR(8)) + OUT v_event_user_id VARCHAR(80)) BEGIN SELECT m.control_name_prefix, m.control_name_uuid, m.model_id, + m.service_type_id, + m.deployment_id, t.template_name, m.template_id, mp.model_prop_id, - mp.userid, + mp.user_id, mp.model_prop_text, mb.model_blueprint_id, - mb.userid, + mb.user_id, mb.model_blueprint_text, e.event_id, e.action_cd, e.action_state_cd, e.process_instance_id, - e.userid + e.user_id INTO v_control_name_prefix, v_control_name_uuid, v_model_id, + v_service_type_id, + v_deployment_id, v_template_name, v_template_id, v_model_prop_id, - v_model_prop_userid, + v_model_prop_user_id, v_model_prop_text, v_model_blueprint_id, - v_model_blueprint_userid, + v_model_blueprint_user_id, v_model_blueprint_text, v_event_id, v_action_cd, v_action_state_cd, v_event_process_instance_id, - v_event_userid + v_event_user_id FROM model m, template t, model_properties mp, @@ -197,78 +203,84 @@ CREATE PROCEDURE get_model_template OUT v_control_name_prefix VARCHAR(80), INOUT v_control_name_uuid VARCHAR(36), OUT v_model_id VARCHAR(36), + OUT v_service_type_id VARCHAR(80), + OUT v_deployment_id VARCHAR(80), OUT v_template_name VARCHAR(80), OUT v_template_id VARCHAR(36), OUT v_model_prop_id VARCHAR(36), - OUT v_model_prop_userid VARCHAR(8), + OUT v_model_prop_user_id VARCHAR(80), OUT v_model_prop_text MEDIUMTEXT, OUT v_model_blueprint_id VARCHAR(36), - OUT v_model_blueprint_userid VARCHAR(8), + OUT v_model_blueprint_user_id VARCHAR(80), OUT v_model_blueprint_text MEDIUMTEXT, OUT v_template_bpmn_id VARCHAR(36), - OUT v_template_bpmn_userid VARCHAR(8), + OUT v_template_bpmn_user_id VARCHAR(80), OUT v_template_bpmn_text MEDIUMTEXT, OUT v_template_image_id VARCHAR(36), - OUT v_template_image_userid VARCHAR(8), + OUT v_template_image_user_id VARCHAR(80), OUT v_template_image_text MEDIUMTEXT, OUT v_template_doc_id VARCHAR(36), - OUT v_template_doc_userid VARCHAR(8), + OUT v_template_doc_user_id VARCHAR(80), OUT v_template_doc_text MEDIUMTEXT, OUT v_event_id VARCHAR(36), OUT v_action_cd VARCHAR(80), OUT v_action_state_cd VARCHAR(80), OUT v_event_process_instance_id VARCHAR(80), - OUT v_event_userid VARCHAR(8)) + OUT v_event_user_id VARCHAR(80)) BEGIN CALL get_model( v_model_name, v_control_name_prefix, v_control_name_uuid, v_model_id, + v_service_type_id, + v_deployment_id, v_template_name, v_template_id, v_model_prop_id, - v_model_prop_userid, + v_model_prop_user_id, v_model_prop_text, v_model_blueprint_id, - v_model_blueprint_userid, + v_model_blueprint_user_id, v_model_blueprint_text, v_event_id, v_action_cd, v_action_state_cd, v_event_process_instance_id, - v_event_userid); + v_event_user_id); CALL get_template( v_template_name, v_template_id, v_template_bpmn_id, - v_template_bpmn_userid, + v_template_bpmn_user_id, v_template_bpmn_text, v_template_image_id, - v_template_image_userid, + v_template_image_user_id, v_template_image_text, v_template_doc_id, - v_template_doc_userid, + v_template_doc_user_id, v_template_doc_text); END; CREATE PROCEDURE set_model (IN v_model_name VARCHAR(80), IN v_template_id VARCHAR(36), - IN v_userid VARCHAR(8), + IN v_user_id VARCHAR(80), IN v_model_prop_text MEDIUMTEXT, IN v_model_blueprint_text MEDIUMTEXT, + IN v_service_type_id VARCHAR(80), + IN v_deployment_id VARCHAR(80), INOUT v_control_name_prefix VARCHAR(80), INOUT v_control_name_uuid VARCHAR(36), OUT v_model_id VARCHAR(36), OUT v_model_prop_id VARCHAR(36), - OUT v_model_prop_userid VARCHAR(8), + OUT v_model_prop_user_id VARCHAR(80), OUT v_model_blueprint_id VARCHAR(36), - OUT v_model_blueprint_userid VARCHAR(8), + OUT v_model_blueprint_user_id VARCHAR(80), OUT v_event_id VARCHAR(36), OUT v_action_cd VARCHAR(80), OUT v_action_state_cd VARCHAR(80), OUT v_event_process_instance_id VARCHAR(80), - OUT v_event_userid VARCHAR(8)) + OUT v_event_user_id VARCHAR(80)) BEGIN DECLARE v_old_template_name VARCHAR(80); DECLARE v_old_template_id VARCHAR(36); @@ -276,25 +288,29 @@ BEGIN DECLARE v_old_control_name_uuid VARCHAR(36); DECLARE v_old_model_prop_text MEDIUMTEXT; DECLARE v_old_model_blueprint_text MEDIUMTEXT; + DECLARE v_old_service_type_id VARCHAR(80); + DECLARE v_old_deployment_id VARCHAR(80); SET v_model_id = NULL; CALL get_model( v_model_name, v_old_control_name_prefix, v_old_control_name_uuid, v_model_id, + v_old_service_type_id, + v_old_deployment_id, v_old_template_name, v_old_template_id, v_model_prop_id, - v_model_prop_userid, + v_model_prop_user_id, v_old_model_prop_text, v_model_blueprint_id, - v_model_blueprint_userid, + v_model_blueprint_user_id, v_old_model_blueprint_text, v_event_id, v_action_cd, v_action_state_cd, v_event_process_instance_id, - v_event_userid); + v_event_user_id); IF v_model_id IS NULL THEN BEGIN # UUID can be provided initially but cannot be updated @@ -304,16 +320,16 @@ BEGIN END IF; SET v_model_id = v_control_name_uuid; INSERT INTO model - (model_id, model_name, template_id, control_name_prefix, control_name_uuid) - VALUES (v_model_id, v_model_name, v_template_id, v_control_name_prefix, v_control_name_uuid); + (model_id, model_name, template_id, control_name_prefix, control_name_uuid, service_type_id, deployment_id) + VALUES (v_model_id, v_model_name, v_template_id, v_control_name_prefix, v_control_name_uuid, v_service_type_id, v_deployment_id); # since just created model, insert CREATED event as initial default event SET v_action_cd = 'CREATE'; SET v_action_state_cd = 'COMPLETED'; - SET v_event_userid = v_userid; + SET v_event_user_id = v_user_id; SET v_event_id = UUID(); INSERT INTO event - (event_id, model_id, action_cd, action_state_cd, userid) - VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_event_userid); + (event_id, model_id, action_cd, action_state_cd, user_id) + VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_event_user_id); UPDATE model SET event_id = v_event_id WHERE model_id = v_model_id; @@ -331,21 +347,23 @@ BEGIN IF v_model_prop_id IS NULL OR v_model_prop_text <> v_old_model_prop_text THEN SET v_model_prop_id = UUID(); INSERT INTO model_properties - (model_prop_id, model_id, model_prop_text, userid) - VALUES (v_model_prop_id, v_model_id, v_model_prop_text, v_userid); - SET v_model_prop_userid = v_userid; + (model_prop_id, model_id, model_prop_text, user_id) + VALUES (v_model_prop_id, v_model_id, v_model_prop_text, v_user_id); + SET v_model_prop_user_id = v_user_id; END IF; IF v_model_blueprint_id IS NULL OR v_model_blueprint_text <> v_old_model_blueprint_text THEN SET v_model_blueprint_id = UUID(); INSERT INTO model_blueprint - (model_blueprint_id, model_id, model_blueprint_text, userid) - VALUES (v_model_blueprint_id, v_model_id, v_model_blueprint_text, v_userid); - SET v_model_blueprint_userid = v_userid; + (model_blueprint_id, model_id, model_blueprint_text, user_id) + VALUES (v_model_blueprint_id, v_model_id, v_model_blueprint_text, v_user_id); + SET v_model_blueprint_user_id = v_user_id; END IF; UPDATE model SET control_name_prefix = v_control_name_prefix, model_prop_id = v_model_prop_id, - model_blueprint_id = v_model_blueprint_id + model_blueprint_id = v_model_blueprint_id, + service_type_id = v_service_type_id, + deployment_id = v_deployment_id WHERE model_id = v_model_id; END; CREATE PROCEDURE ins_model_instance @@ -396,7 +414,7 @@ CREATE PROCEDURE ins_event (IN v_model_name VARCHAR(80), IN v_control_name_prefix VARCHAR(80), IN v_control_name_uuid VARCHAR(36), - IN v_userid VARCHAR(8), + IN v_user_id VARCHAR(80), IN v_action_cd VARCHAR(80), IN v_action_state_cd VARCHAR(80), IN v_process_instance_id VARCHAR(80), @@ -413,8 +431,8 @@ BEGIN OR m.control_name_uuid = v_control_name_uuid; SET v_event_id = UUID(); INSERT INTO event - (event_id, model_id, action_cd, action_state_cd, prev_event_id, process_instance_id, userid) - VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_prev_event_id, v_process_instance_id, v_userid); + (event_id, model_id, action_cd, action_state_cd, prev_event_id, process_instance_id, user_id) + VALUES (v_event_id, v_model_id, v_action_cd, v_action_state_cd, v_prev_event_id, v_process_instance_id, v_user_id); UPDATE model SET event_id = v_event_id WHERE model_id = v_model_id; diff --git a/extra/sql/drop/clds-drop-db-objects.sql b/extra/sql/drop/clds-drop-db-objects.sql index 487aa49d0..478eaf0e0 100644 --- a/extra/sql/drop/clds-drop-db-objects.sql +++ b/extra/sql/drop/clds-drop-db-objects.sql @@ -1,6 +1,5 @@ -# -# Drop CLDS database objects (tables, etc.) # +# Drop CLDS database objects (tables, etc.) # @@ -10,7 +9,7 @@ ALTER TABLE template DROP FOREIGN KEY template_bpmn_id_fkey01; ALTER TABLE template DROP FOREIGN KEY template_doc_id_fkey01; - + ALTER TABLE model DROP FOREIGN KEY template_id_fkey01; ALTER TABLE model @@ -20,6 +19,8 @@ ALTER TABLE model ALTER TABLE model DROP FOREIGN KEY event_id_fkey01; +DROP TABLE clds_service_cache; + DROP TABLE model_instance; DROP TABLE model_blueprint; DROP TABLE model_properties; diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java index 032547836..e0d10097b 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java @@ -27,10 +27,10 @@ import java.io.Serializable; public class CldsAlarmCondition implements Serializable { - private static final long serialVersionUID = 1L; - private String eventSourceType; - private String alarmConditionKey; - private String severity; + private static final long serialVersionUID = 4271364536747705555L; + private String eventSourceType; + private String alarmConditionKey; + private String severity; public String getEventSourceType() { return eventSourceType; diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java b/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java index 658e21f96..4b2a2e30f 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java @@ -23,12 +23,16 @@ package org.onap.clamp.clds.model; -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectOutputStream; public class CldsDBServiceCache { - private String invariantId; - private String serviceId; + private String invariantId; + private String serviceId; private InputStream cldsDataInstream; public String getInvariantId() { diff --git a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java index 8379e5024..3b9c1d21b 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsEvent.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsEvent.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -29,29 +29,34 @@ import org.onap.clamp.clds.dao.CldsDao; * Represent a CLDS Event. */ public class CldsEvent { - public static final String ACTION_CREATE = "CREATE"; - public static final String ACTION_SUBMIT = "SUBMIT"; - public static final String ACTION_RESUBMIT = "RESUBMIT"; // an update before model is active - public static final String ACTION_DISTRIBUTE = "DISTRIBUTE"; // only from dcae - public static final String ACTION_DEPLOY = "DEPLOY"; // only from dcae - public static final String ACTION_UNDEPLOY = "UNDEPLOY"; // only from dcae - public static final String ACTION_UPDATE = "UPDATE"; - public static final String ACTION_DELETE = "DELETE"; - public static final String ACTION_STOP = "STOP"; - public static final String ACTION_RESTART = "RESTART"; + public static final String ACTION_TEST = "TEST"; + public static final String ACTION_CREATE = "CREATE"; + public static final String ACTION_SUBMIT = "SUBMIT"; + // an update before model is active + public static final String ACTION_RESUBMIT = "RESUBMIT"; + // only from dcae + public static final String ACTION_DISTRIBUTE = "DISTRIBUTE"; + // only from dcae + public static final String ACTION_DEPLOY = "DEPLOY"; + // only from dcae + public static final String ACTION_UNDEPLOY = "UNDEPLOY"; + public static final String ACTION_UPDATE = "UPDATE"; + public static final String ACTION_DELETE = "DELETE"; + public static final String ACTION_STOP = "STOP"; + public static final String ACTION_RESTART = "RESTART"; public static final String ACTION_STATE_INITIATED = "INITIATED"; - public static final String ACTION_STATE_SENT = "SENT"; + public static final String ACTION_STATE_SENT = "SENT"; public static final String ACTION_STATE_COMPLETED = "COMPLETED"; - public static final String ACTION_STATE_RECEIVED = "RECEIVED"; - public static final String ACTION_STATE_ERROR = "ERROR"; - public static final String ACTION_STATE_ANY = null; + public static final String ACTION_STATE_RECEIVED = "RECEIVED"; + public static final String ACTION_STATE_ERROR = "ERROR"; + public static final String ACTION_STATE_ANY = null; - private String id; - private String actionCd; - private String actionStateCd; - private String processInstanceId; - private String userid; + private String id; + private String actionCd; + private String actionStateCd; + private String processInstanceId; + private String userid; public String getId() { return id; @@ -70,14 +75,16 @@ public class CldsEvent { * @param processInstanceId * @return */ - public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd, String actionStateCd, String processInstanceId) { + public static CldsEvent insEvent(CldsDao cldsDao, String controlName, String userid, String actionCd, + String actionStateCd, String processInstanceId) { CldsModel model = CldsModel.createUsingControlName(controlName); - return insEvent(cldsDao, model, actionCd, actionStateCd, processInstanceId); + return insEvent(cldsDao, model, userid, actionCd, actionStateCd, processInstanceId); } /** - * Insert event using controlNameUuid to find the model. - * This method meant for processing events from dcae. + * Insert event using controlNameUuid to find the model. This method meant + * for processing events from dcae. + * * @param cldsDao * @param model * @param actionCd @@ -85,8 +92,10 @@ public class CldsEvent { * @param processInstanceId * @return */ - public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String actionCd, String actionStateCd, String processInstanceId) { + public static CldsEvent insEvent(CldsDao cldsDao, CldsModel model, String userId, String actionCd, String actionStateCd, + String processInstanceId) { CldsEvent event = new CldsEvent(); + event.setUserid(userId); event.setActionCd(actionCd); event.setActionStateCd(actionStateCd); event.setProcessInstanceId(processInstanceId); @@ -95,9 +104,23 @@ public class CldsEvent { } /** - * Check if actionCd and actionStateCd are equal to the supplied checkActionCd and checkActionStateCd. - * Treat checkActionStateCd == null as a wildcard - * checkActionCd should not be null. + * Check if actionCd is equal to the supplied checkActionCd checkActionCd + * should not be null. + * + * @param checkActionCd + * @return + */ + public boolean isActionCd(String checkActionCd) { + if (actionCd == null) { + return false; + } + return actionCd.equals(checkActionCd); + } + + /** + * Check if actionCd and actionStateCd are equal to the supplied + * checkActionCd and checkActionStateCd. Treat checkActionStateCd == null as + * a wildcard checkActionCd should not be null. * * @param checkActionCd * @param checkActionStateCd @@ -107,7 +130,8 @@ public class CldsEvent { if (actionCd == null) { return false; } - // treat checkActionStateCd == null as a wildcard (same for actionStateCd, although it shouln't be null...) + // treat checkActionStateCd == null as a wildcard (same for + // actionStateCd, although it shouln't be null...) if (checkActionStateCd == null || actionStateCd == null) { return actionCd.equals(checkActionCd); } @@ -133,7 +157,8 @@ public class CldsEvent { } /** - * @param actionCd the actionCd to set + * @param actionCd + * the actionCd to set */ public void setActionCd(String actionCd) { this.actionCd = actionCd; @@ -147,7 +172,8 @@ public class CldsEvent { } /** - * @param actionStateCd the actionStateCd to set + * @param actionStateCd + * the actionStateCd to set */ public void setActionStateCd(String actionStateCd) { this.actionStateCd = actionStateCd; @@ -161,7 +187,8 @@ public class CldsEvent { } /** - * @param processInstanceId the processInstanceId to set + * @param processInstanceId + * the processInstanceId to set */ public void setProcessInstanceId(String processInstanceId) { this.processInstanceId = processInstanceId; @@ -175,7 +202,8 @@ public class CldsEvent { } /** - * @param userid the userid to set + * @param userid + * the userid to set */ public void setUserid(String userid) { this.userid = userid; diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java index 4d4f3aab3..e34f47d98 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,58 +23,72 @@ package org.onap.clamp.clds.model; -import org.onap.clamp.clds.dao.CldsDao; -import org.jboss.resteasy.spi.BadRequestException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.ws.rs.NotFoundException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import javax.ws.rs.NotFoundException; + +import org.jboss.resteasy.spi.BadRequestException; +import org.onap.clamp.clds.dao.CldsDao; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + /** * Represent a CLDS Model. */ public class CldsModel { - private static final Logger logger = LoggerFactory.getLogger(CldsModel.class); - - private static final int UUID_LENGTH = 36; - - public static final String STATUS_DESIGN = "DESIGN"; - public static final String STATUS_DISTRIBUTED = "DISTRIBUTED"; - public static final String STATUS_ACTIVE = "ACTIVE"; - public static final String STATUS_STOPPED = "STOPPED"; - public static final String STATUS_DELETING = "DELETING"; - public static final String STATUS_ERROR = "ERROR"; // manual intervention required - public static final String STATUS_UNKNOWN = "UNKNOWN"; - - private String id; - private String templateId; - private String templateName; - private String name; - private String controlNamePrefix; - private String controlNameUuid; - private String bpmnId; - private String bpmnUserid; - private String bpmnText; - private String propId; - private String propUserid; - private String propText; - private String imageId; - private String imageUserid; - private String imageText; - private String docId; - private String docUserid; - private String docText; - private String blueprintId; - private String blueprintUserid; - private String blueprintText; - private CldsEvent event; - private String status; - private List permittedActionCd; + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsModel.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + private static final int UUID_LENGTH = 36; + + public static final String STATUS_DESIGN = "DESIGN"; + public static final String STATUS_DISTRIBUTED = "DISTRIBUTED"; + public static final String STATUS_ACTIVE = "ACTIVE"; + public static final String STATUS_STOPPED = "STOPPED"; + public static final String STATUS_DELETING = "DELETING"; + public static final String STATUS_ERROR = "ERROR"; // manual + // intervention + // required + public static final String STATUS_UNKNOWN = "UNKNOWN"; + + private String id; + private String templateId; + private String templateName; + private String name; + private String controlNamePrefix; + private String controlNameUuid; + private String bpmnId; + private String bpmnUserid; + private String bpmnText; + private String propId; + private String propUserid; + private String propText; + private String imageId; + private String imageUserid; + private String imageText; + private String docId; + private String docUserid; + private String docText; + private String blueprintId; + private String blueprintUserid; + private String blueprintText; + private CldsEvent event; + private String status; + private List permittedActionCd; private List cldsModelInstanceList; + private String typeId; + private String typeName; + + private String dispatcherResponse; + + private String deploymentId; + + private boolean userAuthorizedToUpdate; + /** * Construct empty model. */ @@ -100,6 +114,16 @@ public class CldsModel { return model; } + public boolean canInventoryCall() { + boolean canCall = false; + /* Below checks the clds ecent is submit/resubmit */ + + if ((event.isActionCd(CldsEvent.ACTION_SUBMIT) || event.isActionCd(CldsEvent.ACTION_RESUBMIT))) { + canCall = true; + } + return canCall; + } + /** * Save model to DB. * @@ -113,8 +137,8 @@ public class CldsModel { } /** - * Insert a new event for the new action. - * Throw IllegalArgumentException if requested actionCd is not permitted. + * Insert a new event for the new action. Throw IllegalArgumentException if + * requested actionCd is not permitted. * * @param cldsDao * @param userid @@ -123,7 +147,7 @@ public class CldsModel { */ public void insEvent(CldsDao cldsDao, String userid, String actionCd, String actionStateCd) { validateAction(actionCd); - event = CldsEvent.insEvent(cldsDao, this, actionCd, actionStateCd, null); + event = CldsEvent.insEvent(cldsDao, this, userid, actionCd, actionStateCd, null); determineStatus(); determinePermittedActionCd(); } @@ -148,19 +172,20 @@ public class CldsModel { status = STATUS_DESIGN; } else if (event.isActionStateCd(CldsEvent.ACTION_STATE_ERROR)) { status = STATUS_ERROR; - } else if (event.isActionAndStateCd(CldsEvent.ACTION_CREATE, CldsEvent.ACTION_STATE_ANY) || - event.isActionAndStateCd(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_STATE_ANY) || - event.isActionAndStateCd(CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_STATE_ANY) || - event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_RECEIVED)) { + } else if (event.isActionAndStateCd(CldsEvent.ACTION_CREATE, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_RESUBMIT, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_RECEIVED)) { status = STATUS_DESIGN; - } else if (event.isActionAndStateCd(CldsEvent.ACTION_DISTRIBUTE, CldsEvent.ACTION_STATE_RECEIVED) || - event.isActionAndStateCd(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_STATE_RECEIVED)) { + } else if (event.isActionAndStateCd(CldsEvent.ACTION_DISTRIBUTE, CldsEvent.ACTION_STATE_RECEIVED) + || event.isActionAndStateCd(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_STATE_RECEIVED)) { status = STATUS_DISTRIBUTED; } else if (event.isActionAndStateCd(CldsEvent.ACTION_DELETE, CldsEvent.ACTION_STATE_SENT)) { status = STATUS_DELETING; - } else if (event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_RECEIVED) || - event.isActionAndStateCd(CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_ANY) || - event.isActionAndStateCd(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STATE_ANY)) { + } else if (event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_RECEIVED) + || event.isActionAndStateCd(CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STATE_ANY) + || event.isActionAndStateCd(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_STATE_ANY)) { status = STATUS_ACTIVE; } else if (event.isActionAndStateCd(CldsEvent.ACTION_STOP, CldsEvent.ACTION_STATE_ANY)) { status = STATUS_STOPPED; @@ -169,7 +194,8 @@ public class CldsModel { } /** - * Get the actionCd from current event. If none, default value is CldsEvent.ACTION_CREATE + * Get the actionCd from current event. If none, default value is + * CldsEvent.ACTION_CREATE * * @return */ @@ -183,7 +209,8 @@ public class CldsModel { } /** - * Get the actionStateCd from current event. If none, default value is CldsEvent.ACTION_STATE_COMPLETED + * Get the actionStateCd from current event. If none, default value is + * CldsEvent.ACTION_STATE_COMPLETED * * @return */ @@ -197,28 +224,36 @@ public class CldsModel { } /** - * Determine permittedActionCd list using the actionCd from the current event. + * Determine permittedActionCd list using the actionCd from the current + * event. */ private void determinePermittedActionCd() { String actionCd = getCurrentActionCd(); switch (actionCd) { case CldsEvent.ACTION_CREATE: - permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMIT); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_SUBMIT, CldsEvent.ACTION_TEST); break; case CldsEvent.ACTION_SUBMIT: case CldsEvent.ACTION_RESUBMIT: - // for 1702 delete is not currently implemented (and resubmit requires manually deleting artifact from asdc + // for 1702 delete is not currently implemented (and resubmit + // requires manually deleting artifact from sdc permittedActionCd = Arrays.asList(CldsEvent.ACTION_RESUBMIT); break; case CldsEvent.ACTION_DISTRIBUTE: + permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT); + break; case CldsEvent.ACTION_UNDEPLOY: - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY); break; case CldsEvent.ACTION_DEPLOY: + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_UPDATE, + CldsEvent.ACTION_STOP); + break; case CldsEvent.ACTION_RESTART: case CldsEvent.ACTION_UPDATE: // for 1702 delete is not currently implemented - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP, + CldsEvent.ACTION_UNDEPLOY); break; case CldsEvent.ACTION_DELETE: if (getCurrentActionStateCd().equals(CldsEvent.ACTION_STATE_SENT)) { @@ -229,7 +264,8 @@ public class CldsModel { break; case CldsEvent.ACTION_STOP: // for 1702 delete is not currently implemented - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_RESTART, + CldsEvent.ACTION_UNDEPLOY); break; default: logger.warn("Invalid current actionCd: " + actionCd); @@ -237,22 +273,26 @@ public class CldsModel { } /** - * Validate requestedActionCd - determine permittedActionCd and then check if contained in permittedActionCd - * Throw IllegalArgumentException if requested actionCd is not permitted. + * Validate requestedActionCd - determine permittedActionCd and then check + * if contained in permittedActionCd Throw IllegalArgumentException if + * requested actionCd is not permitted. * * @param requestedActionCd */ public void validateAction(String requestedActionCd) { determinePermittedActionCd(); if (!permittedActionCd.contains(requestedActionCd)) { - throw new IllegalArgumentException("Invalid requestedActionCd: " + requestedActionCd + ". Given current actionCd: " + getCurrentActionCd() + ", the permittedActionCd: " + permittedActionCd); + throw new IllegalArgumentException( + "Invalid requestedActionCd: " + requestedActionCd + ". Given current actionCd: " + + getCurrentActionCd() + ", the permittedActionCd: " + permittedActionCd); } } /** - * Extract the UUID portion of a given full control name (controlNamePrefix + controlNameUuid). - * No fields are populated other than controlNamePrefix and controlNameUuid. - * Throws BadRequestException if length of given control name is less than UUID_LENGTH. + * Extract the UUID portion of a given full control name (controlNamePrefix + * + controlNameUuid). No fields are populated other than controlNamePrefix + * and controlNameUuid. Throws BadRequestException if length of given + * control name is less than UUID_LENGTH. * * @param fullControlName * @return @@ -265,7 +305,8 @@ public class CldsModel { len = fullControlName.length(); } if (len < UUID_LENGTH) { - throw new BadRequestException("closed loop id / control name length, " + len + ", less than the minimum of: " + UUID_LENGTH); + throw new BadRequestException( + "closed loop id / control name length, " + len + ", less than the minimum of: " + UUID_LENGTH); } CldsModel model = new CldsModel(); model.setControlNamePrefix(fullControlName.substring(0, len - UUID_LENGTH)); @@ -291,19 +332,22 @@ public class CldsModel { CldsModel cldsModel = createUsingControlName(controlName); cldsModel = cldsDao.getModelByUuid(cldsModel.getControlNameUuid()); cldsModel.determineStatus(); - if (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_UNDEPLOY) || - (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_DEPLOY) && (cldsModel.getStatus().equals(STATUS_DISTRIBUTED) || cldsModel.getStatus().equals(STATUS_DESIGN)))) { - CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), CldsEvent.ACTION_STATE_RECEIVED, null); + if (dcaeEvent.getCldsActionCd().equals(CldsEvent.ACTION_UNDEPLOY) || (dcaeEvent.getCldsActionCd() + .equals(CldsEvent.ACTION_DEPLOY) + && (cldsModel.getStatus().equals(STATUS_DISTRIBUTED) || cldsModel.getStatus().equals(STATUS_DESIGN)))) { + CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), + CldsEvent.ACTION_STATE_RECEIVED, null); } cldsDao.insModelInstance(cldsModel, dcaeEvent.getInstances()); return cldsModel; } /** - * To remove modelInstance from the database - * This method is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of - * deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that - * are still deployed with any not on the list considered undeployed. + * To remove modelInstance from the database This method is defunct - DCAE + * Proxy will not undeploy individual instances. It will send an empty list + * of deployed instances to indicate all have been removed. Or it will send + * an updated list to indicate those that are still deployed with any not on + * the list considered undeployed. * * @param cldsDao * @param dcaeEvent @@ -311,7 +355,8 @@ public class CldsModel { @SuppressWarnings("unused") private static CldsModel removeModelInstance(CldsDao cldsDao, DcaeEvent dcaeEvent) { String controlName = dcaeEvent.getControlName(); - //cldsModel = cldsDao.delModelInstance(cldsModel.getControlNameUuid(), dcaeEvent.getInstances() ); + // cldsModel = cldsDao.delModelInstance(cldsModel.getControlNameUuid(), + // dcaeEvent.getInstances() ); return createUsingControlName(controlName); } @@ -323,12 +368,28 @@ public class CldsModel { } /** - * @param name the name to set + * @param name + * the name to set */ public void setName(String name) { this.name = name; } + /** + * @return the typeName + */ + public String getTypeName() { + return typeName; + } + + /** + * @param name + * the typeName to set + */ + public void setTypeName(String typeName) { + this.typeName = typeName; + } + public String getTemplateId() { return templateId; } @@ -345,7 +406,8 @@ public class CldsModel { } /** - * @param controlNamePrefix the controlNamePrefix to set + * @param controlNamePrefix + * the controlNamePrefix to set */ public void setControlNamePrefix(String controlNamePrefix) { this.controlNamePrefix = controlNamePrefix; @@ -359,13 +421,13 @@ public class CldsModel { } /** - * @param controlNameUuid the controlNameUuid to set + * @param controlNameUuid + * the controlNameUuid to set */ public void setControlNameUuid(String controlNameUuid) { this.controlNameUuid = controlNameUuid; } - /** * @return the propUserid */ @@ -374,7 +436,8 @@ public class CldsModel { } /** - * @param propUserid the propUserid to set + * @param propUserid + * the propUserid to set */ public void setPropUserid(String propUserid) { this.propUserid = propUserid; @@ -388,7 +451,8 @@ public class CldsModel { } /** - * @param propText the propText to set + * @param propText + * the propText to set */ public void setPropText(String propText) { this.propText = propText; @@ -426,7 +490,8 @@ public class CldsModel { } /** - * @param event the event to set + * @param event + * the event to set */ public void setEvent(CldsEvent event) { this.event = event; @@ -440,7 +505,8 @@ public class CldsModel { } /** - * @param status the status to set + * @param status + * the status to set */ public void setStatus(String status) { this.status = status; @@ -454,7 +520,8 @@ public class CldsModel { } /** - * @param permittedActionCd the permittedActionCd to set + * @param permittedActionCd + * the permittedActionCd to set */ public void setPermittedActionCd(List permittedActionCd) { this.permittedActionCd = permittedActionCd; @@ -556,6 +623,14 @@ public class CldsModel { this.docText = docText; } + public String getTypeId() { + return typeId; + } + + public void setTypeId(String typeId) { + this.typeId = typeId; + } + public List getCldsModelInstanceList() { if (cldsModelInstanceList == null) { cldsModelInstanceList = new ArrayList<>(); @@ -567,4 +642,28 @@ public class CldsModel { this.cldsModelInstanceList = cldsModelInstanceList; } + public void setDispatcherResponse(String dispatcherResponse) { + this.dispatcherResponse = dispatcherResponse; + + } + + public String getDispatcherResponse() { + return this.dispatcherResponse; + } + + public String getDeploymentId() { + return deploymentId; + } + + public void setDeploymentId(String deploymentId) { + this.deploymentId = deploymentId; + } + + public boolean isUserAuthorizedToUpdate() { + return userAuthorizedToUpdate; + } + + public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) { + this.userAuthorizedToUpdate = userAuthorizedToUpdate; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java index 89108393f..dad7cb615 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,25 +23,29 @@ package org.onap.clamp.clds.model; -import org.onap.clamp.clds.dao.CldsDao; -import org.onap.clamp.clds.service.CldsService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.ws.rs.NotAuthorizedException; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import javax.ws.rs.NotAuthorizedException; + +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.service.CldsService; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + public class CldsServiceData implements Serializable { - private static final Logger logger = LoggerFactory.getLogger(CldsServiceData.class); - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -9153372664377279423L; + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsServiceData.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String serviceInvariantUUID; - private String serviceUUID; - private Long ageOfRecord; - private List cldsVfs; + private String serviceInvariantUUID; + private String serviceUUID; + private Long ageOfRecord; + private List cldsVfs; public String getServiceInvariantUUID() { return serviceInvariantUUID; @@ -84,8 +88,8 @@ public class CldsServiceData implements Serializable { } /** - * Filter out any VFs that the user is not authorized for. - * Use the CldsService to determine if the user is authorized for a VF. + * Filter out any VFs that the user is not authorized for. Use the + * CldsService to determine if the user is authorized for a VF. * * @param svc */ @@ -95,14 +99,16 @@ public class CldsServiceData implements Serializable { logger.debug("cldsVfs == null"); } else { for (CldsVfData vf : cldsVfs) { - // if user is authorized for the VF then add it to the filtered list + // if user is authorized for the VF then add it to the filtered + // list try { if (svc.isAuthorizedForVf(vf.getVfInvariantResourceUUID())) { filteredCldsVfs.add(vf); } } catch (NotAuthorizedException e) { logger.debug("user not authorized for {}", vf.getVfInvariantResourceUUID()); - // when not NotAuthorizedException - don't add to filteredCldsVfs list + // when not NotAuthorizedException - don't add to + // filteredCldsVfs list } } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java index 6e2c8d70d..a96ee381c 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsTemplate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,35 +23,39 @@ package org.onap.clamp.clds.model; -import org.onap.clamp.clds.dao.CldsDao; - import javax.ws.rs.NotFoundException; +import org.onap.clamp.clds.dao.CldsDao; + /** * Represent a CLDS Model. */ public class CldsTemplate { - public static final String STATUS_DESIGN = "DESIGN"; - public static final String STATUS_ACTIVE = "ACTIVE"; - public static final String STATUS_STOPPED = "STOPPED"; + public static final String STATUS_DESIGN = "DESIGN"; + public static final String STATUS_ACTIVE = "ACTIVE"; + public static final String STATUS_STOPPED = "STOPPED"; public static final String STATUS_DELETING = "DELETING"; - public static final String STATUS_ERROR = "ERROR"; // manual intervention required - public static final String STATUS_UNKNOWN = "UNKNOWN"; - - private String id; - private String name; - private String controlNamePrefix; - private String controlNameUuid; - private String bpmnId; - private String bpmnUserid; - private String bpmnText; - private String imageId; - private String imageUserid; - private String imageText; - private String propId; - private String propUserid; - private String propText; + public static final String STATUS_ERROR = "ERROR"; // manual + // intervention + // required + public static final String STATUS_UNKNOWN = "UNKNOWN"; + + private String id; + private String name; + private String controlNamePrefix; + private String controlNameUuid; + private String bpmnId; + private String bpmnUserid; + private String bpmnText; + private String imageId; + private String imageUserid; + private String imageText; + private String propId; + private String propUserid; + private String propText; + + private boolean userAuthorizedToUpdate; /** * Save template to DB. @@ -183,4 +187,11 @@ public class CldsTemplate { this.imageId = imageId; } + public boolean isUserAuthorizedToUpdate() { + return userAuthorizedToUpdate; + } + + public void setUserAuthorizedToUpdate(boolean userAuthorizedToUpdate) { + this.userAuthorizedToUpdate = userAuthorizedToUpdate; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfData.java index dbcfb3464..aa5712c58 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsVfData.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsVfData.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -28,11 +28,20 @@ import java.util.List; public class CldsVfData implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = -5069670140274203606L; + private String vfName; + private String vfInvariantResourceUUID; + private List cldsVfcs; - private String vfName; - private String vfInvariantResourceUUID; - private List cldsVfcs; + private List cldsKPIList; + + public List getCldsKPIList() { + return cldsKPIList; + } + + public void setCldsKPIList(List cldsKPIList) { + this.cldsKPIList = cldsKPIList; + } public String getVfName() { return vfName; diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java index 2d56d01f0..3828489cd 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsVfcData.java @@ -28,10 +28,9 @@ import java.util.List; public class CldsVfcData implements Serializable { - private static final long serialVersionUID = 1L; - - private String vfcName; - private String vfcInvariantResourceUUID; + private static final long serialVersionUID = 406993878174183557L; + private String vfcName; + private String vfcInvariantResourceUUID; private List cldsAlarmConditions; public String getVfcName() { diff --git a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java index e10971e7d..e144a0eb7 100644 --- a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java +++ b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,24 +23,25 @@ package org.onap.clamp.clds.model; -import org.jboss.resteasy.spi.BadRequestException; - import java.util.List; +import org.jboss.resteasy.spi.BadRequestException; + /** * Represent a DCAE Event. */ public class DcaeEvent { - public static final String EVENT_CREATED = "created"; // this is an event we (clds) sends to dcae - public static final String EVENT_DISTRIBUTION = "distribution"; - public static final String EVENT_DEPLOYMENT = "deployment"; - public static final String EVENT_UNDEPLOYMENT = "undeployment"; - public static final String ARTIFACT_NAME_SUFFIX = ".yml"; - - private String event; - private String serviceUUID; - private String resourceUUID; - private String artifactName; // controlName.yml + // this is an event we (clds) sends to dcae + public static final String EVENT_CREATED = "created"; + public static final String EVENT_DISTRIBUTION = "distribute"; + public static final String EVENT_DEPLOYMENT = "deployment"; + public static final String EVENT_UNDEPLOYMENT = "undeployment"; + public static final String ARTIFACT_NAME_SUFFIX = ".yml"; + + private String event; + private String serviceUUID; + private String resourceUUID; + private String artifactName; // controlName.yml private List instances; /** @@ -51,21 +52,24 @@ public class DcaeEvent { public String getCldsActionCd() { if (event == null || event.length() == 0) { throw new BadRequestException("action null or empty"); - } else if (event.equals(EVENT_CREATED)) { + } else if (event.equalsIgnoreCase(EVENT_CREATED)) { return CldsEvent.ACTION_CREATE; - } else if (event.equals(EVENT_DISTRIBUTION)) { + } else if (event.equalsIgnoreCase(EVENT_DISTRIBUTION)) { return CldsEvent.ACTION_DISTRIBUTE; - } else if (event.equals(EVENT_DEPLOYMENT) && - (instances == null || instances.size() == 0)) { - return CldsEvent.ACTION_UNDEPLOY; - } else if (event.equals(EVENT_DEPLOYMENT)) { + } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT) && (instances == null || instances.size() == 0)) { + return CldsEvent.ACTION_DEPLOY; + } else if (event.equalsIgnoreCase(EVENT_DEPLOYMENT)) { return CldsEvent.ACTION_DEPLOY; - // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of - // deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that - // are still deployed with any not on the list considered undeployed. - //} else if ( event.equals(EVENT_UNDEPLOYMENT) ) { - // return CldsEvent.ACTION_UNDEPLOY; + // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy + // individual instances. It will send an empty list of + // deployed instances to indicate all have been removed. Or it will + // send an updated list to indicate those that + // are still deployed with any not on the list considered + // undeployed. + } else if (event.equals(EVENT_UNDEPLOYMENT)) { + return CldsEvent.ACTION_UNDEPLOY; } + throw new BadRequestException("event value not valid: " + event); } @@ -78,7 +82,8 @@ public class DcaeEvent { if (artifactName != null && artifactName.endsWith(ARTIFACT_NAME_SUFFIX)) { return artifactName.substring(0, artifactName.length() - ARTIFACT_NAME_SUFFIX.length()); } else { - throw new BadRequestException("artifactName value not valid (expecting it to end with " + ARTIFACT_NAME_SUFFIX + "): " + artifactName); + throw new BadRequestException("artifactName value not valid (expecting it to end with " + + ARTIFACT_NAME_SUFFIX + "): " + artifactName); } } @@ -90,7 +95,8 @@ public class DcaeEvent { } /** - * @param event the event to set + * @param event + * the event to set */ public void setEvent(String event) { this.event = event; @@ -104,7 +110,8 @@ public class DcaeEvent { } /** - * @param serviceUUID the serviceUUID to set + * @param serviceUUID + * the serviceUUID to set */ public void setServiceUUID(String serviceUUID) { this.serviceUUID = serviceUUID; @@ -118,7 +125,8 @@ public class DcaeEvent { } /** - * @param resourceUUID the resourceUUID to set + * @param resourceUUID + * the resourceUUID to set */ public void setResourceUUID(String resourceUUID) { this.resourceUUID = resourceUUID; @@ -132,7 +140,8 @@ public class DcaeEvent { } /** - * @param artifactName the artifactName to set + * @param artifactName + * the artifactName to set */ public void setArtifactName(String artifactName) { this.artifactName = artifactName; diff --git a/src/main/java/org/onap/clamp/clds/model/ValueItem.java b/src/main/java/org/onap/clamp/clds/model/ValueItem.java index 804d18546..a3a81425e 100644 --- a/src/main/java/org/onap/clamp/clds/model/ValueItem.java +++ b/src/main/java/org/onap/clamp/clds/model/ValueItem.java @@ -49,7 +49,8 @@ public class ValueItem { } /** - * @param value the value to set + * @param value + * the value to set */ public void setValue(String value) { this.value = value; -- cgit 1.2.3-korg From 9a929da8221708f4d4b379af9e2be45a20a4dcd7 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 03:00:22 -0700 Subject: Rework all the clamp delegates Rework all the clamp delegates for Event, DCAE, Operational policy, stringmatch and TCA Change-Id: I8f3830cdf05b144dd5d039f833ef7e96c785df29 Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/Application.java | 20 +- src/main/java/org/onap/clamp/clds/Routes.java | 6 +- src/main/java/org/onap/clamp/clds/WebConfig.java | 1 - .../onap/clamp/clds/client/CldsEventDelegate.java | 32 +-- .../onap/clamp/clds/client/DcaeReqDelegate.java | 39 ++-- .../clamp/clds/client/DcaeReqDeleteDelegate.java | 33 +-- .../clds/client/OperationalPolicyDelegate.java | 61 ++--- .../client/OperationalPolicyDeleteDelegate.java | 43 ++-- .../org/onap/clamp/clds/client/PolicyClient.java | 249 +++++++++++++-------- .../clds/client/StringMatchPolicyDelegate.java | 53 +++-- .../client/StringMatchPolicyDeleteDelegate.java | 42 ++-- .../onap/clamp/clds/client/TcaPolicyDelegate.java | 94 +++++--- .../clamp/clds/client/TcaPolicyDeleteDelegate.java | 89 +++++--- 13 files changed, 450 insertions(+), 312 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index 8459027f3..037935175 100644 --- a/src/main/java/org/onap/clamp/clds/Application.java +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -23,7 +23,12 @@ package org.onap.clamp.clds; -import com.att.ajsc.common.utility.SystemPropertiesLoader; +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.camunda.bpm.spring.boot.starter.webapp.CamundaBpmWebappAutoConfiguration; import org.springframework.boot.SpringApplication; @@ -40,19 +45,18 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableAsync; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import java.util.ArrayList; -import java.util.Collection; +import com.att.ajsc.common.utility.SystemPropertiesLoader; @SpringBootApplication -@ComponentScan(basePackages = {"org.onap.clamp.clds","com.att.ajsc"}) -@EnableAutoConfiguration(exclude = {CamundaBpmWebappAutoConfiguration.class, HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class}) +@ComponentScan(basePackages = { "org.onap.clamp.clds", "com.att.ajsc" }) +@EnableAutoConfiguration(exclude = { CamundaBpmWebappAutoConfiguration.class, HibernateJpaAutoConfiguration.class, + JpaRepositoriesAutoConfiguration.class, SecurityAutoConfiguration.class, + ManagementWebSecurityAutoConfiguration.class }) @EnableAsync public class Application extends SpringBootServletInitializer { private static final String CAMEL_SERVLET_NAME = "CamelServlet"; - private static final String CAMEL_URL_MAPPING = "/restservices/clds/v1/*"; + private static final String CAMEL_URL_MAPPING = "/restservices/clds/v1/*"; @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { diff --git a/src/main/java/org/onap/clamp/clds/Routes.java b/src/main/java/org/onap/clamp/clds/Routes.java index 6fcb93078..cf6fc5ad9 100644 --- a/src/main/java/org/onap/clamp/clds/Routes.java +++ b/src/main/java/org/onap/clamp/clds/Routes.java @@ -23,11 +23,12 @@ package org.onap.clamp.clds; -import com.att.ajsc.common.camel.AjscRouteBuilder; import org.apache.camel.builder.RouteBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.att.ajsc.common.camel.AjscRouteBuilder; + @Component public class Routes extends RouteBuilder { @Autowired @@ -36,7 +37,8 @@ public class Routes extends RouteBuilder { @Override public void configure() throws Exception { ajscRoute.initialize(this); - ajscRoute.setRoute(from("servlet:/?matchOnUriPrefix=true").to("cxfbean:jaxrsServices?providers=jaxrsProviders")); + ajscRoute + .setRoute(from("servlet:/?matchOnUriPrefix=true").to("cxfbean:jaxrsServices?providers=jaxrsProviders")); } } diff --git a/src/main/java/org/onap/clamp/clds/WebConfig.java b/src/main/java/org/onap/clamp/clds/WebConfig.java index 38bd62e97..4de825fee 100644 --- a/src/main/java/org/onap/clamp/clds/WebConfig.java +++ b/src/main/java/org/onap/clamp/clds/WebConfig.java @@ -38,7 +38,6 @@ public class WebConfig { public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/swagger").setViewName("redirect:/icd/index.html"); registry.addViewController("/icd/").setViewName("redirect:/icd/index.html"); - registry.addViewController("/login").setViewName("login.html"); } }; } diff --git a/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java b/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java index 0f4d30d00..449e364ba 100644 --- a/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,31 +23,37 @@ package org.onap.clamp.clds.client; -import org.onap.clamp.clds.dao.CldsDao; -import org.onap.clamp.clds.model.CldsEvent; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.model.CldsEvent; import org.springframework.beans.factory.annotation.Autowired; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Create CLDS Event. */ public class CldsEventDelegate implements JavaDelegate { - private static final Logger logger = Logger.getLogger(CldsEventDelegate.class.getName()); + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsEventDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + @Autowired - private CldsDao cldsDao; + private CldsDao cldsDao; /** * Insert event using process variables. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { String controlName = (String) execution.getVariable("controlName"); String actionCd = (String) execution.getVariable("actionCd"); String actionStateCd = (String) execution.getVariable("actionStateCd"); + // Flag indicate whether it is triggered by Validation Test button from UI boolean isTest = (boolean) execution.getVariable("isTest"); boolean isInsertTestEvent = (boolean) execution.getVariable("isInsertTestEvent"); String userid = (String) execution.getVariable("userid"); diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java b/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java index 5583cf936..8abc395d1 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,37 +23,42 @@ package org.onap.clamp.clds.client; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.clamp.clds.client.req.DcaeReq; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Send control loop model to dcae proxy. */ public class DcaeReqDelegate implements JavaDelegate { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(DcaeReqDelegate.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReqDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private RefProp refProp; + private RefProp refProp; + + @Value("${org.onap.clamp.config.dcae.url:http://localhost:9000/closedloop-dcae-services}") + private String cldsDcaeUrl; /** - * Perform activity. Send to dcae proxy. + * Perform activity. Send to dcae proxy. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { ModelProperties prop = ModelProperties.create(execution); String dcaeReq = DcaeReq.format(refProp, prop); if (dcaeReq != null) { execution.setVariable("dcaeReq", dcaeReq.getBytes()); } - execution.setVariable("dcaeUrl", System.getProperty("CLDS_DCAE_URL") + "/" + prop.getControlName()); + execution.setVariable("dcaeUrl", cldsDcaeUrl + "/" + prop.getControlName()); } } diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java index 28dd6f1d6..29a906787 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,30 +23,31 @@ package org.onap.clamp.clds.client; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; import org.springframework.beans.factory.annotation.Autowired; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Send control loop model to dcae proxy. */ public class DcaeReqDeleteDelegate implements JavaDelegate { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(DcaeReqDeleteDelegate.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReqDeleteDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private RefProp refProp; + private RefProp refProp; /** - * Perform activity. Send to dcae proxy. + * Perform activity. Send to dcae proxy. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { ModelProperties prop = ModelProperties.create(execution); execution.setVariable("dcaeUrl", System.getProperty("CLDS_DCAE_URL") + "/" + prop.getControlName()); diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java index 2b7b06697..ed972d4bf 100644 --- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,44 +23,55 @@ package org.onap.clamp.clds.client; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.clamp.clds.client.req.OperationalPolicyReq; import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.Policy; +import org.onap.clamp.clds.model.prop.PolicyChain; import org.onap.clamp.clds.model.refprop.RefProp; import org.onap.policy.api.AttributeType; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Map; -import java.util.UUID; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Send Operational Policy info to policy api. */ public class OperationalPolicyDelegate implements JavaDelegate { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(OperationalPolicyDelegate.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(OperationalPolicyDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - @Autowired - private PolicyClient policyClient; - @Autowired - private RefProp refProp; + private PolicyClient policyClient; + + @Autowired + private RefProp refProp; /** - * Perform activity. Send Operational Policy info to policy api. + * Perform activity. Send Operational Policy info to policy api. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { - String operationalPolicyRequestUuid = UUID.randomUUID().toString(); - execution.setVariable("operationalPolicyRequestUuid", operationalPolicyRequestUuid); + // execution.setVariable("operationalPolicyRequestUuid", + // operationalPolicyRequestUuid); + String responseMessage = null; + String operationalPolicyRequestUuid = null; ModelProperties prop = ModelProperties.create(execution); - Map> attributes = OperationalPolicyReq.formatAttributes(refProp, prop); - String responseMessage = policyClient.sendBrms(attributes, prop, operationalPolicyRequestUuid); + for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) { + operationalPolicyRequestUuid = UUID.randomUUID().toString(); + Map> attributes = OperationalPolicyReq.formatAttributes(refProp, prop, + prop.getType(Policy.class).getId(), policyChain); + responseMessage = policyClient.sendBrms(attributes, prop, operationalPolicyRequestUuid); + } if (responseMessage != null) { execution.setVariable("operationalPolicyResponseMessage", responseMessage.getBytes()); } diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java index 816b2142a..e7b0be53d 100644 --- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,36 +23,43 @@ package org.onap.clamp.clds.client; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Policy; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.Policy; +import org.onap.clamp.clds.model.prop.PolicyChain; import org.springframework.beans.factory.annotation.Autowired; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Delete Operational Policy via policy api. */ public class OperationalPolicyDeleteDelegate implements JavaDelegate { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(OperationalPolicyDeleteDelegate.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(OperationalPolicyDeleteDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private PolicyClient policyClient; + private PolicyClient policyClient; /** - * Perform activity. Delete Operational Policy via policy api. + * Perform activity. Delete Operational Policy via policy api. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { ModelProperties prop = ModelProperties.create(execution); - Policy policy = prop.getPolicy(); + Policy policy = prop.getType(Policy.class); prop.setCurrentModelElementId(policy.getId()); - String responseMessage = policyClient.deleteBrms(prop); + String responseMessage = ""; + for (PolicyChain policyChain : policy.getPolicyChains()) { + prop.setPolicyUniqueId(policyChain.getPolicyId()); + responseMessage = policyClient.deleteBrms(prop); + } if (responseMessage != null) { execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes()); } diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java index d19c2167e..1a1d31443 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,35 +23,52 @@ package org.onap.clamp.clds.client; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; -import org.onap.policy.api.*; +import org.onap.policy.api.AttributeType; +import org.onap.policy.api.ConfigRequestParameters; +import org.onap.policy.api.DeletePolicyCondition; +import org.onap.policy.api.DeletePolicyParameters; +import org.onap.policy.api.PolicyChangeResponse; +import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigType; +import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyParameters; +import org.onap.policy.api.PolicyType; +import org.onap.policy.api.PushPolicyParameters; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; -import java.util.*; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Policy utility methods - specifically, send the policy. */ public class PolicyClient { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(PolicyClient.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:etc/clds/clds-policy-config.properties'}") - private String cldsPolicyConfigFile; + @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}") + protected String cldsPolicyConfigFile; @Autowired - private ApplicationContext appContext; - + protected ApplicationContext appContext; + @Autowired - private RefProp refProp; - + protected RefProp refProp; + public PolicyClient() { - + } /** @@ -63,7 +80,8 @@ public class PolicyClient { * @return * @throws Exception */ - public String sendBrms(Map> attributes, ModelProperties prop, String policyRequestUUID) throws Exception { + public String sendBrms(Map> attributes, ModelProperties prop, + String policyRequestUUID) throws Exception { PolicyParameters policyParameters = new PolicyParameters(); @@ -71,19 +89,19 @@ public class PolicyClient { policyParameters.setPolicyConfigType(PolicyConfigType.BRMS_PARAM); // Set Policy Name(Mandatory) - policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); - //Set Scope folder where the policy needs to be created(Mandatory) - //policyParameters.setPolicyScope(policyScope); + policyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueId()); - // documentation says this is options, but when tested, got the following failure: java.lang.Exception: Policy send failed: PE300 - Data Issue: No policyDescription given. + // documentation says this is options, but when tested, got the + // following failure: java.lang.Exception: Policy send failed: PE300 - + // Data Issue: No policyDescription given. policyParameters.setPolicyDescription(refProp.getStringValue("op.policyDescription")); policyParameters.setAttributes(attributes); - //Set a random UUID(Mandatory) + // Set a random UUID(Mandatory) policyParameters.setRequestID(UUID.fromString(policyRequestUUID)); - - String rtnMsg = send(policyParameters, prop); + String policyNamePrefix = refProp.getStringValue("policy.op.policyNamePrefix"); + String rtnMsg = send(policyParameters, prop, policyNamePrefix); String policyType = refProp.getStringValue("policy.op.type"); push(policyType, prop); @@ -106,18 +124,18 @@ public class PolicyClient { // Set Policy Type policyParameters.setPolicyConfigType(PolicyConfigType.MicroService); - policyParameters.setOnapName(refProp.getStringValue("policy.onap.name")); + policyParameters.setOnapName(refProp.getStringValue("policy.ecomp.name")); policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); policyParameters.setConfigBody(policyJson); policyParameters.setConfigBodyType(PolicyType.JSON); policyParameters.setRequestID(UUID.fromString(policyRequestUUID)); - - String rtnMsg = send(policyParameters, prop); - - String policyType = refProp.getStringValue("policy.ms.type"); - push(policyType, prop); + String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); + prop.setPolicyUniqueId("");//Adding this line to clear the policy id from policy name while pushing to policy engine + String rtnMsg = send(policyParameters, prop, policyNamePrefix); + String policyType = refProp.getStringValue("policy.ms.type"); + push(policyType, prop); return rtnMsg; } @@ -130,14 +148,21 @@ public class PolicyClient { * @return * @throws Exception */ - private String send(PolicyParameters policyParameters, ModelProperties prop) throws Exception { - PolicyEngine policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyNamePrefix) throws Exception { + // Verify whether it is triggered by Validation Test button from UI + if ( prop.isTest() ) { + return "send not executed for test action"; + } + + PolicyEngine policyEngine = new PolicyEngine( + appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); // API method to create or update Policy. PolicyChangeResponse response = null; String responseMessage; try { - if (prop.isCreateRequest()) { + List versions = getVersions(policyNamePrefix, prop); + if (versions.size() <= 0) { logger.info("Attempting to create policy for action=" + prop.getActionCd()); response = policyEngine.createPolicy(policyParameters); responseMessage = response.getResponseMessage(); @@ -154,7 +179,7 @@ public class PolicyClient { if (response != null && response.getResponseCode() == 200) { logger.info("Policy send successful"); } else { - logger.warning("Policy send failed: " + responseMessage); + logger.warn("Policy send failed: " + responseMessage); throw new Exception("Policy send failed: " + responseMessage); } @@ -169,17 +194,28 @@ public class PolicyClient { * @return * @throws Exception */ - private String push(String policyType, ModelProperties prop) throws Exception { - PushPolicyParameters pushPolicyParameters = new PushPolicyParameters(); + protected String push(String policyType, ModelProperties prop) throws Exception { + // Verify whether it is triggered by Validation Test button from UI + if ( prop.isTest() ) { + return "push not executed for test action"; + } + + PushPolicyParameters pushPolicyParameters = new PushPolicyParameters(); + + // Parameter arguments + if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) { + pushPolicyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueId()); + } else { + pushPolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); + } + logger.info("Policy Name in Push policy method - " + pushPolicyParameters.getPolicyName()); - //Parameter arguments - pushPolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); pushPolicyParameters.setPolicyType(policyType); - //pushPolicyParameters.setPolicyScope(policyScope); pushPolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group")); pushPolicyParameters.setRequestID(null); - PolicyEngine policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + PolicyEngine policyEngine = new PolicyEngine( + appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); // API method to create or update Policy. PolicyChangeResponse response = null; @@ -196,7 +232,7 @@ public class PolicyClient { if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) { logger.info("Policy push successful"); } else { - logger.warning("Policy push failed: " + responseMessage); + logger.warn("Policy push failed: " + responseMessage); throw new Exception("Policy push failed: " + responseMessage); } @@ -204,41 +240,53 @@ public class PolicyClient { } /** - * Use Get Config Policy API to retrieve the versions for a policy. - * Return versions in sorted order. - * Return empty list if none found. + * Use Get Config Policy API to retrieve the versions for a policy. Return + * versions in sorted order. Return empty list if none found. * * @param policyNamePrefix * @param prop * @return * @throws Exception */ - private List getVersions(String policyNamePrefix, ModelProperties prop) throws Exception { + protected List getVersions(String policyNamePrefix, ModelProperties prop) throws Exception { ArrayList versions = new ArrayList<>(); ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); - String policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix); - logger.info("policyName=" + policyName); - configRequestParameters.setPolicyName(policyName); - - PolicyEngine policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + String policyName = ""; - Collection response = policyEngine.getConfig(configRequestParameters); + if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) { + policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix) + "_" + prop.getPolicyUniqueId(); + } else { + policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix); + } - Iterator itrResp = response.iterator(); + logger.info("policyName=" + policyName); + configRequestParameters.setPolicyName(policyName); - while (itrResp.hasNext()) { - PolicyConfig policyConfig = itrResp.next(); - try { - Integer version = new Integer(policyConfig.getPolicyVersion()); - versions.add(version); - } catch (Exception e) { - // just print warning - if n;o policies, version may be null - logger.warning("warning: failed to parse policyConfig.getPolicyVersion()=" + policyConfig.getPolicyVersion()); - } - } - Collections.sort(versions); - logger.info("versions.size()=" + versions.size()); + PolicyEngine policyEngine = new PolicyEngine( + appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + + try { + Collection response = policyEngine.getConfig(configRequestParameters); + Iterator itrResp = response.iterator(); + + while (itrResp.hasNext()) { + PolicyConfig policyConfig = itrResp.next(); + try { + Integer version = new Integer(policyConfig.getPolicyVersion()); + versions.add(version); + } catch (Exception e) { + // just print warning - if n;o policies, version may be null + logger.warn( + "warning: failed to parse policyConfig.getPolicyVersion()=" + policyConfig.getPolicyVersion()); + } + } + Collections.sort(versions); + logger.info("Policy versions.size()=" + versions.size()); + } catch (Exception e) { + // just print warning - if no policy version found + logger.warn("warning: policy not found...policy name - " + policyName); + } return versions; } @@ -252,7 +300,8 @@ public class PolicyClient { */ public String deleteMicrosService(ModelProperties prop) throws Exception { String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); - return deletePolicy(policyNamePrefix, prop); + String policyType = refProp.getStringValue("policy.ms.type"); + return deletePolicy(policyNamePrefix, prop, policyType); } /** @@ -264,7 +313,8 @@ public class PolicyClient { */ public String deleteBrms(ModelProperties prop) throws Exception { String policyNamePrefix = refProp.getStringValue("policy.op.policyNamePrefix"); - return deletePolicy(policyNamePrefix, prop); + String policyType = refProp.getStringValue("policy.op.type"); + return deletePolicy(policyNamePrefix, prop, policyType); } /** @@ -275,34 +325,29 @@ public class PolicyClient { * @return * @throws Exception */ - private String deletePolicy(String policyNamePrefix, ModelProperties prop) throws Exception { - String responseMessage = null; - + protected String deletePolicy(String policyNamePrefix, ModelProperties prop, String policyType) throws Exception { DeletePolicyParameters deletePolicyParameters = new DeletePolicyParameters(); - List versions = getVersions(policyNamePrefix, prop); - if (versions.size() > 0) { - int maxVersion = Collections.max(versions); - - // format delete all PAP request - deletePolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndFullPolicyNameWithVersion(policyNamePrefix, maxVersion)); - deletePolicyParameters.setPolicyComponent("PAP"); - deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL); - String policyType = refProp.getStringValue("policy.ms.type"); - deletePolicyParameters.setPolicyType(policyType); - - //send delete request - responseMessage = sendDeletePolicy(deletePolicyParameters, prop); + if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) { + deletePolicyParameters.setPolicyName(prop.getPolicyScopeAndNameWithUniqueId()); + } else { + deletePolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); } + logger.info("Policy Name in delete policy method - " + deletePolicyParameters.getPolicyName()); + deletePolicyParameters.setPolicyComponent("PDP"); + deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL); + deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group")); + deletePolicyParameters.setPolicyType(policyType); + // send delete request + String responseMessage = null; + responseMessage = sendDeletePolicy(deletePolicyParameters, prop); - for (Integer version : versions) { - // format delete all PDP request - deletePolicyParameters.setPolicyName(prop.getCurrentPolicyScopeAndFullPolicyNameWithVersion(policyNamePrefix, version)); - deletePolicyParameters.setPolicyComponent("PDP"); - deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group")); - //send delete request - responseMessage = responseMessage + "; " + sendDeletePolicy(deletePolicyParameters, prop); - } + logger.info("Deleting policy from PAP..."); + deletePolicyParameters.setPolicyComponent("PAP"); + deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL); + + // send delete request + responseMessage = sendDeletePolicy(deletePolicyParameters, prop); return responseMessage; } @@ -315,8 +360,14 @@ public class PolicyClient { * @return * @throws Exception */ - private String sendDeletePolicy(DeletePolicyParameters deletePolicyParameters, ModelProperties prop) throws Exception { - PolicyEngine policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + protected String sendDeletePolicy(DeletePolicyParameters deletePolicyParameters, ModelProperties prop) + throws Exception { + // Verify whether it is triggered by Validation Test button from UI + if ( prop.isTest() ) { + return "delete not executed for test action"; + } + PolicyEngine policyEngine = new PolicyEngine( + appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); // API method to create or update Policy. PolicyChangeResponse response = null; @@ -333,10 +384,10 @@ public class PolicyClient { if (response != null && response.getResponseCode() == 200) { logger.info("Policy delete successful"); } else { - logger.warning("Policy delete failed: " + responseMessage); + logger.warn("Policy delete failed: " + responseMessage); throw new Exception("Policy delete failed: " + responseMessage); } return responseMessage; } -} +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java index 90e259f8c..50126d55e 100644 --- a/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,44 +23,51 @@ package org.onap.clamp.clds.client; +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.clamp.clds.client.req.StringMatchPolicyReq; import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.StringMatch; import org.onap.clamp.clds.model.refprop.RefProp; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; import org.springframework.beans.factory.annotation.Autowired; -import java.util.UUID; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Send String Match info to policy api. */ public class StringMatchPolicyDelegate implements JavaDelegate { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(StringMatchPolicyDelegate.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(StringMatchPolicyDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private PolicyClient policyClient; - + private PolicyClient policyClient; + @Autowired - private RefProp refProp; + private RefProp refProp; /** - * Perform activity. Send String Match info to policy api. + * Perform activity. Send String Match info to policy api. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { String stringMatchPolicyRequestUuid = UUID.randomUUID().toString(); execution.setVariable("stringMatchPolicyRequestUuid", stringMatchPolicyRequestUuid); ModelProperties prop = ModelProperties.create(execution); - String policyJson = StringMatchPolicyReq.format(refProp, prop); - String responseMessage = policyClient.sendMicroService(policyJson, prop, stringMatchPolicyRequestUuid); - if (responseMessage != null) { - execution.setVariable("stringMatchPolicyResponseMessage", responseMessage.getBytes()); + StringMatch stringMatch = prop.getType(StringMatch.class); + if (stringMatch.isFound()) { + String policyJson = StringMatchPolicyReq.format(refProp, prop); + String responseMessage = policyClient.sendMicroService(policyJson, prop, stringMatchPolicyRequestUuid); + if (responseMessage != null) { + execution.setVariable("stringMatchPolicyResponseMessage", responseMessage.getBytes()); + } } } diff --git a/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDeleteDelegate.java index 9efd358d7..5bda8d361 100644 --- a/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDeleteDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,36 +23,40 @@ package org.onap.clamp.clds.client; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.StringMatch; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.StringMatch; import org.springframework.beans.factory.annotation.Autowired; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Delete String Match Policy via policy api. */ public class StringMatchPolicyDeleteDelegate implements JavaDelegate { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(StringMatchPolicyDeleteDelegate.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(StringMatchPolicyDeleteDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private PolicyClient policyClient; + private PolicyClient policyClient; /** - * Perform activity. Delete String Match Policy via policy api. + * Perform activity. Delete String Match Policy via policy api. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { ModelProperties prop = ModelProperties.create(execution); - StringMatch stringMatch = prop.getStringMatch(); - prop.setCurrentModelElementId(stringMatch.getId()); + StringMatch stringMatch = prop.getType(StringMatch.class); + if (stringMatch.isFound()) { + prop.setCurrentModelElementId(stringMatch.getId()); - policyClient.deleteMicrosService(prop); + policyClient.deleteMicrosService(prop); + } } } diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java index 58843d9bf..e8b92a42b 100644 --- a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java @@ -1,53 +1,75 @@ +/*- + * ============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.client; import java.util.UUID; -import java.util.logging.Logger; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.springframework.beans.factory.annotation.Autowired; - import org.onap.clamp.clds.client.req.TcaMPolicyReq; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.prop.Tca; import org.onap.clamp.clds.model.refprop.RefProp; +import org.springframework.beans.factory.annotation.Autowired; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** - * Send Tca info to policy api. - * + * Send Tca info to policy api. + * * */ public class TcaPolicyDelegate implements JavaDelegate { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(TcaPolicyDelegate.class.getName()); - - @Autowired - private RefProp refProp; - - @Autowired PolicyClient policyClient; - - /** - * Perform activity. Send Tca info to policy api. - * - * @param execution - */ - public void execute(DelegateExecution execution) throws Exception { - String tcaPolicyRequestUuid = UUID.randomUUID().toString(); - execution.setVariable("tcaPolicyRequestUuid", tcaPolicyRequestUuid); - - ModelProperties prop = ModelProperties.create(execution); - Tca tca = prop.getTca(); - if(tca.isFound()){ - String policyJson = TcaMPolicyReq.formatTca(refProp, prop); - String responseMessage = policyClient.sendMicroService(policyJson, prop, tcaPolicyRequestUuid); - if(responseMessage != null) - { - execution.setVariable("tcaPolicyResponseMessage", responseMessage.getBytes()); - } - } - } - - - + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaPolicyDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + @Autowired + private RefProp refProp; + + @Autowired + PolicyClient policyClient; + + /** + * Perform activity. Send Tca info to policy api. + * + * @param execution + */ + @Override + public void execute(DelegateExecution execution) throws Exception { + String tcaPolicyRequestUuid = UUID.randomUUID().toString(); + execution.setVariable("tcaPolicyRequestUuid", tcaPolicyRequestUuid); + + ModelProperties prop = ModelProperties.create(execution); + Tca tca = prop.getType(Tca.class); + if (tca.isFound()) { + String policyJson = TcaMPolicyReq.formatTca(refProp, prop); + String responseMessage = policyClient.sendMicroService(policyJson, prop, tcaPolicyRequestUuid); + if (responseMessage != null) { + execution.setVariable("tcaPolicyResponseMessage", responseMessage.getBytes()); + } + } + } + } diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java index 31e05d7dd..d3fb3f73d 100644 --- a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java @@ -1,48 +1,67 @@ -package org.onap.clamp.clds.client; +/*- + * ============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. + */ -import java.util.logging.Logger; +package org.onap.clamp.clds.client; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.springframework.beans.factory.annotation.Autowired; - import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.prop.Tca; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.springframework.beans.factory.annotation.Autowired; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** - * Delete Tca Policy via policy api. - * + * Delete Tca Policy via policy api. + * * */ public class TcaPolicyDeleteDelegate implements JavaDelegate { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(TcaPolicyDeleteDelegate.class.getName()); - - @Autowired - private PolicyClient policyClient; - - /** - * Perform activity. Delete Tca Policy via policy api. - * - * @param execution - */ - public void execute(DelegateExecution execution) throws Exception { - - ModelProperties prop = ModelProperties.create(execution); - Tca tca = prop.getTca(); - if(tca.isFound()){ - prop.setCurrentModelElementId(tca.getId()); - - String responseMessage = policyClient.deleteMicrosService(prop); - if(responseMessage != null) - { - execution.setVariable("tcaPolicyDeleteResponseMessage", responseMessage.getBytes()); - } - } - } - - - + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaPolicyDeleteDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + @Autowired + private PolicyClient policyClient; + + /** + * Perform activity. Delete Tca Policy via policy api. + * + * @param execution + */ + @Override + public void execute(DelegateExecution execution) throws Exception { + + ModelProperties prop = ModelProperties.create(execution); + Tca tca = prop.getType(Tca.class); + if (tca.isFound()) { + prop.setCurrentModelElementId(tca.getId()); + + String responseMessage = policyClient.deleteMicrosService(prop); + if (responseMessage != null) { + execution.setVariable("tcaPolicyDeleteResponseMessage", responseMessage.getBytes()); + } + } + } + } -- cgit 1.2.3-korg From b436cd173daa367e15951f0c1f84f8b842a1e347 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 03:04:02 -0700 Subject: Rework the authentication Add more granularity in the default authentication mechanism + Add some unit tests with Json to validate the json decoder Change-Id: I89d0ef94e99fc8aa0c1e8c6432b5aa30a0a5ac88 Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/config/CldsConfiguration.java | 64 ++++++-- .../onap/clamp/clds/config/CldsSecurityConfig.java | 99 +++++------- .../clamp/clds/config/CldsUserJsonDecoder.java | 46 ++++++ .../java/org/onap/clamp/clds/service/CldsUser.java | 84 +++++++++++ .../clamp/clds/service/DefaultUserNameHandler.java | 47 ++++++ .../onap/clamp/clds/service/LogServiceImpl.java | 166 ++++++++++++--------- .../onap/clamp/clds/service/UserNameHandler.java | 31 ++++ .../org/onap/clamp/clds/service/UserService.java | 54 +++++++ .../onap/clamp/clds/service/UserServiceImpl.java | 46 ++++++ src/main/resources/clds/clds-users.json | 15 ++ src/main/resources/clds/clds-users.properties | 7 - .../clamp/clds/config/CldsUserJsonDecoderTest.java | 85 +++++++++++ .../clds/clds-users-incomplete-permissions.json | 14 ++ .../resources/clds/clds-users-no-permission.json | 9 ++ src/test/resources/clds/clds-users-two-users.json | 28 ++++ 15 files changed, 635 insertions(+), 160 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java create mode 100644 src/main/java/org/onap/clamp/clds/service/CldsUser.java create mode 100644 src/main/java/org/onap/clamp/clds/service/DefaultUserNameHandler.java create mode 100644 src/main/java/org/onap/clamp/clds/service/UserNameHandler.java create mode 100644 src/main/java/org/onap/clamp/clds/service/UserService.java create mode 100644 src/main/java/org/onap/clamp/clds/service/UserServiceImpl.java create mode 100644 src/main/resources/clds/clds-users.json delete mode 100644 src/main/resources/clds/clds-users.properties create mode 100644 src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java create mode 100644 src/test/resources/clds/clds-users-incomplete-permissions.json create mode 100644 src/test/resources/clds/clds-users-no-permission.json create mode 100644 src/test/resources/clds/clds-users-two-users.json (limited to 'src/main/java') 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 814d2c6ad..19c916435 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java @@ -23,9 +23,27 @@ package org.onap.clamp.clds.config; -import com.att.ajsc.common.AjscProvider; -import com.att.ajsc.common.AjscService; -import org.onap.clamp.clds.client.*; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.sql.DataSource; +import javax.xml.transform.TransformerConfigurationException; + +import org.onap.clamp.clds.client.CldsEventDelegate; +import org.onap.clamp.clds.client.DcaeDispatcherServices; +import org.onap.clamp.clds.client.DcaeInventoryServices; +import org.onap.clamp.clds.client.DcaeReqDelegate; +import org.onap.clamp.clds.client.DcaeReqDeleteDelegate; +import org.onap.clamp.clds.client.OperationalPolicyDelegate; +import org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate; +import org.onap.clamp.clds.client.PolicyClient; +import org.onap.clamp.clds.client.SdcCatalogServices; +import org.onap.clamp.clds.client.SdcSendReqDelegate; +import org.onap.clamp.clds.client.StringMatchPolicyDelegate; +import org.onap.clamp.clds.client.StringMatchPolicyDeleteDelegate; +import org.onap.clamp.clds.client.TcaPolicyDelegate; +import org.onap.clamp.clds.client.TcaPolicyDeleteDelegate; import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.model.refprop.RefProp; import org.onap.clamp.clds.transform.XslTransformer; @@ -37,11 +55,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import javax.sql.DataSource; -import javax.xml.transform.TransformerConfigurationException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import com.att.ajsc.common.AjscProvider; +import com.att.ajsc.common.AjscService; @Configuration @Profile("clamp-default") @@ -54,20 +69,18 @@ public class CldsConfiguration { * Clds Identity databse DataSource configuration */ @Bean(name = "cldsDataSource") - @ConfigurationProperties(prefix = "spring.cldsdatasource") + @ConfigurationProperties(prefix = "spring.datasource.cldsdb") public DataSource cldsDataSource() { - return DataSourceBuilder - .create() - .build(); + return DataSourceBuilder.create().build(); } @Bean(name = "jaxrsProviders") - public List jaxrsProviders() { + public List jaxrsProviders() { return new ArrayList(context.getBeansWithAnnotation(AjscProvider.class).values()); } @Bean(name = "jaxrsServices") - public List jaxrsServices() { + public List jaxrsServices() { return new ArrayList(context.getBeansWithAnnotation(AjscService.class).values()); } @@ -136,7 +149,28 @@ public class CldsConfiguration { } @Bean(name = "sdcCatalogServices") - public SdcCatalogServices getAsdcCatalogServices() { + public SdcCatalogServices getSdcCatalogServices() { return new SdcCatalogServices(); } + + @Bean(name = "dcaeDispatcherServices") + public DcaeDispatcherServices getDcaeDispatcherServices() { + return new DcaeDispatcherServices(); + } + + @Bean(name = "dcaeInventoryServices") + public DcaeInventoryServices getDcaeInventoryServices() { + return new DcaeInventoryServices(); + } + + @Bean(name = "tcaPolicyDelegate") + public TcaPolicyDelegate getTcaPolicyDelegate() { + return new TcaPolicyDelegate(); + } + + @Bean(name = "tcaPolicyDeleteDelegate") + public TcaPolicyDeleteDelegate getTcaPolicyDeleteDelegate() { + return new TcaPolicyDeleteDelegate(); + } + } \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java index 571ad4b40..7e6021c2b 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,95 +23,64 @@ package org.onap.clamp.clds.config; +import org.onap.clamp.clds.service.CldsUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.Resource; +import org.springframework.context.annotation.Profile; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.LinkedList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; @Configuration @EnableWebSecurity +@Profile("clamp-spring-authentication") public class CldsSecurityConfig extends WebSecurityConfigurerAdapter { - private static final Logger logger = Logger.getLogger(CldsSecurityConfig.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSecurityConfig.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private ApplicationContext appContext; + private ApplicationContext appContext; - @Value("${org.onap.clamp.config.files.cldsUsers:'classpath:etc/config/clds/clds-users.properties'}") - private String cldsUsers; + @Value("${org.onap.clamp.config.files.cldsUsers:'classpath:etc/config/clds/clds-users.json'}") + private String cldsUsersFile; - private final static String ROLEPREFIX = "null|null|"; + @Value("${CLDS_PERMISSION_TYPE_CL:permission-type-cl}") + private String cldsPersmissionTypeCl; + + @Value("${CLDS_PERMISSION_INSTANCE:dev}") + private String cldsPermissionInstance; @Override protected void configure(HttpSecurity http) throws Exception { - http - .csrf().disable() - .authorizeRequests() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login.html") - .permitAll() - .and() - .logout() - .permitAll(); + http.csrf().disable().httpBasic().and().authorizeRequests().antMatchers("/restservices/clds/v1/user/**") + .authenticated().anyRequest().permitAll().and().logout(); } @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - List userList = loadUsers(); + CldsUser[] usersList = loadUsers(); // no users defined - if (null == userList || userList.isEmpty()) { - logger.log(Level.SEVERE, "No users defined. Users should be defined under clds/clds-users.properties."); + if (null == usersList) { + logger.warn("No users defined. Users should be defined under " + cldsUsersFile); return; } - for (String user : userList) { - String[] userInfo = user.split("[|]"); - if (userInfo.length != 3) { - logger.log(Level.SEVERE, "Defined User(" + user + ") is not in good format. User format should be:||. Role should be eiother 'read' or 'all'."); - continue; - } - - auth - .inMemoryAuthentication() - .withUser(userInfo[0]).password(userInfo[1]).roles(ROLEPREFIX + ("all".equalsIgnoreCase(userInfo[2]) ? "*" : userInfo[2])); - + for (CldsUser user : usersList) { + auth.inMemoryAuthentication().withUser(user.getUser()).password(user.getPassword()) + .roles(user.getPermissionsString()); } } - private boolean validUser(String[] userInfo) { - return ((userInfo != null) && (userInfo.length == 3) && (("all".equals(userInfo[2])) || ("read".equals(userInfo[2])))); - } - - private List loadUsers() throws Exception { + private CldsUser[] loadUsers() throws Exception { logger.info("Load from clds-users.properties"); - - Resource resource = appContext.getResource(cldsUsers); - BufferedReader input = new BufferedReader(new InputStreamReader(resource.getInputStream())); - - List userList = new LinkedList<>(); - - String line; - while ((line = input.readLine()) != null) { - if (!line.contains("#")) { - userList.add(line); - } - logger.info("line read:" + line); - } - return userList; + return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream()); } -} \ No newline at end of file +} diff --git a/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java new file mode 100644 index 000000000..997a20f09 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java @@ -0,0 +1,46 @@ +/*- + * ============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 java.io.IOException; +import java.io.InputStream; + +import org.onap.clamp.clds.service.CldsUser; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class CldsUserJsonDecoder { + + /** + * This method decodes the JSON file provided to a CldsUser Array. The + * stream is closed after this call, this is not possible to reuse it. + * + * @return CldsUser[] Array containing a list of the user defined in the + * JSON file + */ + public static CldsUser[] decodeJson(InputStream cldsUsersFile) throws IOException { + // the ObjectMapper readValue method closes the stream no need to do it + return new ObjectMapper().readValue(cldsUsersFile, CldsUser[].class); + } +} diff --git a/src/main/java/org/onap/clamp/clds/service/CldsUser.java b/src/main/java/org/onap/clamp/clds/service/CldsUser.java new file mode 100644 index 000000000..9db1e6078 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/CldsUser.java @@ -0,0 +1,84 @@ +/*- + * ============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.service; + +import java.util.Arrays; + +public class CldsUser { + + private String user; + + private String password; + + private SecureServicePermission[] permissions; + + /** + * @return the user + */ + public String getUser() { + return user; + } + + /** + * @param user + * the user to set + */ + public void setUser(String user) { + this.user = user; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @param password + * the password to set + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * @return the permissions + */ + public SecureServicePermission[] getPermissions() { + return permissions; + } + + public String[] getPermissionsString() { + return Arrays.stream(getPermissions()).map(perm -> perm.getKey()).toArray(String[]::new); + } + + /** + * @param permissions + * the permissions to set + */ + public void setPermissions(SecureServicePermission[] permissions) { + this.permissions = permissions; + } +} diff --git a/src/main/java/org/onap/clamp/clds/service/DefaultUserNameHandler.java b/src/main/java/org/onap/clamp/clds/service/DefaultUserNameHandler.java new file mode 100644 index 000000000..511cafe1e --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/DefaultUserNameHandler.java @@ -0,0 +1,47 @@ +/*- + * ============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.service; + +import java.security.Principal; + +import javax.ws.rs.core.SecurityContext; + +public class DefaultUserNameHandler implements UserNameHandler { + + public DefaultUserNameHandler() { + } + + /* + * (non-Javadoc) + * + * @see + * org.onap.clamp.clds.service.PrincipalNameHandler#handleName(javax.ws.rs. + * core.SecurityContext) + */ + @Override + public String retrieveUserName(SecurityContext securityContext) { + Principal p = securityContext.getUserPrincipal(); + return (p == null ? "Not found" : p.getName()); + } +} diff --git a/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java b/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java index e7ee93a40..f38e129be 100644 --- a/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java +++ b/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,12 +23,19 @@ package org.onap.clamp.clds.service; -import com.att.ajsc.camunda.core.AttCamundaHistoryEvent; -import com.att.ajsc.camunda.core.AttCamundaService; -import com.att.ajsc.logging.AjscEelfManager; -import com.att.eelf.configuration.EELFLogger; -import com.google.gson.Gson; -import org.onap.clamp.clds.common.LogMessages; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.mail.Message; +import javax.mail.MessagingException; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; +import javax.ws.rs.core.Context; + import org.apache.commons.mail.Email; import org.apache.commons.mail.SimpleEmail; import org.apache.cxf.jaxrs.ext.MessageContext; @@ -37,33 +44,32 @@ import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.history.HistoricActivityInstance; import org.camunda.bpm.engine.impl.history.event.HistoricActivityInstanceEventEntity; import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.onap.clamp.clds.common.LogMessages; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mail.MailException; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.stereotype.Service; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; -import javax.ws.rs.core.Context; -import java.util.*; +import com.att.ajsc.camunda.core.AttCamundaHistoryEvent; +import com.att.ajsc.camunda.core.AttCamundaService; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.gson.Gson; @Service public class LogServiceImpl implements LogService { - private static final EELFLogger logger = AjscEelfManager.getInstance().getLogger(LogServiceImpl.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(LogServiceImpl.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); @Autowired - private RuntimeService runtimeService; + private RuntimeService runtimeService; @Autowired - private HistoryService historyService; + private HistoryService historyService; @Context - private MessageContext context; + private MessageContext context; public void setRuntimeService(RuntimeService runtimeService) { this.runtimeService = runtimeService; @@ -93,7 +99,9 @@ public class LogServiceImpl implements LogService { } // BEGIN - added for send mail testing - // also added the following to the method signature: , @QueryParam("javamail") String javamail, @QueryParam("springmail") String springmail, @QueryParam("commonsmail") String commonsmail + // also added the following to the method signature: , + // @QueryParam("javamail") String javamail, @QueryParam("springmail") + // String springmail, @QueryParam("commonsmail") String commonsmail // if javamail parameter provided, assume it contains an email address. // use Java Mail to send an email from that address, to that address if (javamail != null && javamail.length() > 0) { @@ -104,11 +112,11 @@ public class LogServiceImpl implements LogService { Session session = Session.getInstance(props); MimeMessage msg = new MimeMessage(session); - msg.setFrom(new InternetAddress(javamail)); //eMail.setFrom + msg.setFrom(new InternetAddress(javamail)); // eMail.setFrom - InternetAddress[] fromAddresses = {new InternetAddress(javamail)}; - msg.setReplyTo(fromAddresses); //eMail.addReplyTo - msg.setSubject("test message using javax.mail"); //eMail.setSubject + InternetAddress[] fromAddresses = { new InternetAddress(javamail) }; + msg.setReplyTo(fromAddresses); // eMail.addReplyTo + msg.setSubject("test message using javax.mail"); // eMail.setSubject msg.setText(logMessageText); // eMail.setMsg msg.addRecipient(Message.RecipientType.TO, new InternetAddress(javamail)); // eMail.addTo @@ -118,7 +126,8 @@ public class LogServiceImpl implements LogService { } } - // if springmail parameter provided, assume it contains an email address. + // if springmail parameter provided, assume it contains an email + // address. // use Spring Mail to send an email from that address, to that address if (springmail != null && springmail.length() > 0) { variables.put("springmail", springmail); @@ -127,9 +136,9 @@ public class LogServiceImpl implements LogService { try { sender.setHost("smtp.sbc.com"); // eMail.setHostName - smsg.setFrom(springmail); //eMail.setFrom - smsg.setReplyTo(springmail); //eMail.addReplyTo - smsg.setSubject("test message using spring mail"); //eMail.setSubject + smsg.setFrom(springmail); // eMail.setFrom + smsg.setReplyTo(springmail); // eMail.addReplyTo + smsg.setSubject("test message using spring mail"); // eMail.setSubject smsg.setText(logMessageText); // eMail.setMsg smsg.setTo(springmail); // eMail.addTo sender.send(smsg); @@ -138,18 +147,20 @@ public class LogServiceImpl implements LogService { } } - // if commonsmail parameter provided, assume it contains an email address. - // use Apache Commons Mail to send an email from that address, to that address + // if commonsmail parameter provided, assume it contains an email + // address. + // use Apache Commons Mail to send an email from that address, to that + // address if (commonsmail != null && commonsmail.length() > 0) { variables.put("commonsmail", commonsmail); - Email eMail = new SimpleEmail(); + Email email = new SimpleEmail(); try { - eMail.setHostName("smtp.sbc.com"); - eMail.setFrom(commonsmail); - eMail.addReplyTo(commonsmail); - eMail.setSubject("test message using commons mail"); - eMail.setMsg(logMessageText); - eMail.addTo(commonsmail); + email.setHostName("smtp.sbc.com"); + email.setFrom(commonsmail); + email.addReplyTo(commonsmail); + email.setSubject("test message using commons mail"); + email.setMsg(logMessageText); + email.addTo(commonsmail); java.net.URL classUrl = this.getClass().getResource("com.sun.mail.util.TraceInputStream"); if (classUrl != null) { logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS, classUrl.getFile()); @@ -157,7 +168,7 @@ public class LogServiceImpl implements LogService { logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS, classUrl.getFile()); logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS_NULL); } - eMail.send(); + email.send(); } catch (Exception e) { logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e); } @@ -168,7 +179,8 @@ public class LogServiceImpl implements LogService { ProcessInstance pi = runtimeService.startProcessInstanceByKey("log-message-wf", variables); AttCamundaService.setHttpRequest(null); // return text message of what was done - return "Started processDefinitionId=" + pi.getProcessDefinitionId() + ", processInstanceId=" + pi.getProcessInstanceId() + ", to log message: " + logMessageText; + return "Started processDefinitionId=" + pi.getProcessDefinitionId() + ", processInstanceId=" + + pi.getProcessInstanceId() + ", to log message: " + logMessageText; } @Override @@ -179,13 +191,17 @@ public class LogServiceImpl implements LogService { AttCamundaHistoryEvent attCamundaHistoryEvent = gson.fromJson(histEventList, AttCamundaHistoryEvent.class); if (attCamundaHistoryEvent != null && attCamundaHistoryEvent.getProcInstId() != null) { logger.info(LogMessages.PROCESS_INSTANCE_ID, attCamundaHistoryEvent.getProcInstId()); - if (context != null && context.getHttpServletRequest() != null && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { + if (context != null && context.getHttpServletRequest() != null + && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing"); - List histActInstList = historyService.createHistoricActivityInstanceQuery().processInstanceId(attCamundaHistoryEvent.getProcInstId()).list(); + List histActInstList = historyService.createHistoricActivityInstanceQuery() + .processInstanceId(attCamundaHistoryEvent.getProcInstId()).list(); if (histActInstList != null && histActInstList.size() > 0) { for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) { - if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null && currHistoricActivityInstance.getStartTime() != null + if (currHistoricActivityInstance != null + && currHistoricActivityInstance.getActivityName() != null + && currHistoricActivityInstance.getStartTime() != null && currHistoricActivityInstance.getEndTime() != null) { logger.info("value of serviceTrack:" + currHistoricActivityInstance); message = "Log Entry Created"; @@ -193,10 +209,13 @@ public class LogServiceImpl implements LogService { } } } - if (attCamundaHistoryEvent.getHistoryEventList() != null && attCamundaHistoryEvent.getHistoryEventList().size() > 0) { - List historyEventList = attCamundaHistoryEvent.getHistoryEventList(); + if (attCamundaHistoryEvent.getHistoryEventList() != null + && attCamundaHistoryEvent.getHistoryEventList().size() > 0) { + List historyEventList = attCamundaHistoryEvent + .getHistoryEventList(); for (HistoricActivityInstanceEventEntity actiEvent : historyEventList) { - // resolve null pointer exception if actiEvent.getActivityName() + // resolve null pointer exception if + // actiEvent.getActivityName() message = "Log Entry Created"; } } @@ -209,12 +228,17 @@ public class LogServiceImpl implements LogService { public String createLogMessage(String startTime, String endTime, String serviceName) { String message = "no logs Created"; - if (context != null && context.getHttpServletRequest() != null && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { + if (context != null && context.getHttpServletRequest() != null + && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { context.getHttpServletRequest().setAttribute("X-CSI-ClientApp", "AJSC-CSI~sdsds"); - /*PerformanceTrackingBean trackingBean =(PerformanceTrackingBean) context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN"); - PerformanceTracking.addInvokeServiceTrack(trackingBean, - serviceName, Long.valueOf(startTime), Long.valueOf(endTime), "Completed", - 500, 1000) ;*/ + /* + * PerformanceTrackingBean trackingBean =(PerformanceTrackingBean) + * context.getHttpServletRequest().getAttribute( + * "PERFORMANCE_TRACKER_BEAN"); + * PerformanceTracking.addInvokeServiceTrack(trackingBean, + * serviceName, Long.valueOf(startTime), Long.valueOf(endTime), + * "Completed", 500, 1000) ; + */ message = "Log Entry Created"; } // return text message of what was done @@ -226,13 +250,16 @@ public class LogServiceImpl implements LogService { String message = "no logs Created"; logger.info("value of history events:" + histEventList); logger.info("value of events:" + histEventList + ":" + histEventList); - if (context != null && context.getHttpServletRequest() != null && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { + if (context != null && context.getHttpServletRequest() != null + && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing"); - List histActInstList = historyService.createHistoricActivityInstanceQuery().processInstanceId(procInstId).list(); + List histActInstList = historyService.createHistoricActivityInstanceQuery() + .processInstanceId(procInstId).list(); if (histActInstList != null && histActInstList.size() > 0) { for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) { - if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null && currHistoricActivityInstance.getStartTime() != null + if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null + && currHistoricActivityInstance.getStartTime() != null && currHistoricActivityInstance.getEndTime() != null) { logger.info("value of serviceTrack:" + currHistoricActivityInstance); message = "Log Entry Created"; @@ -247,12 +274,15 @@ public class LogServiceImpl implements LogService { @Override public String CreateHistLog(String procInstId) { String message = "no logs Created"; - if (context != null && context.getHttpServletRequest() != null && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { - List histActInstList = historyService.createHistoricActivityInstanceQuery().processInstanceId(procInstId).list(); + if (context != null && context.getHttpServletRequest() != null + && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { + List histActInstList = historyService.createHistoricActivityInstanceQuery() + .processInstanceId(procInstId).list(); if (histActInstList != null && histActInstList.size() > 0) { for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) { - if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null && currHistoricActivityInstance.getStartTime() != null + if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null + && currHistoricActivityInstance.getStartTime() != null && currHistoricActivityInstance.getEndTime() != null) { logger.info("value of serviceTrack:" + currHistoricActivityInstance); context.getHttpServletRequest().setAttribute("X-CSI-ClientApp", "AJSC-CSI~sdsds"); @@ -263,14 +293,4 @@ public class LogServiceImpl implements LogService { } return message; } - - private String getActivityInstanceState(int activityInstanceState) { - String activityState = "Default"; - if (activityInstanceState == 1) { - activityState = "Complete"; - } else if (activityInstanceState == 2) { - activityState = "Cancelled"; - } - return activityState; - } } diff --git a/src/main/java/org/onap/clamp/clds/service/UserNameHandler.java b/src/main/java/org/onap/clamp/clds/service/UserNameHandler.java new file mode 100644 index 000000000..cadf334ea --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/UserNameHandler.java @@ -0,0 +1,31 @@ +/*- + * ============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.service; + +import javax.ws.rs.core.SecurityContext; + +public interface UserNameHandler { + + public String retrieveUserName(SecurityContext securityContext); +} diff --git a/src/main/java/org/onap/clamp/clds/service/UserService.java b/src/main/java/org/onap/clamp/clds/service/UserService.java new file mode 100644 index 000000000..6f3e480ad --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/UserService.java @@ -0,0 +1,54 @@ +/*- + * ============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.service; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import io.swagger.annotations.Api; + +/** + * User service used for authorization verification at the login page. Do not + * remove this class. + */ +@Api(value = "/user") +@Path("/user") +@Produces({ MediaType.TEXT_PLAIN }) +public interface UserService { + + /** + * REST service that returns the username. + * + * @param userName + * @return the user name + */ + @GET + @Path("/{userName}") + @Produces(MediaType.TEXT_PLAIN) + String getUser(@PathParam("userName") String userName); + +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/service/UserServiceImpl.java b/src/main/java/org/onap/clamp/clds/service/UserServiceImpl.java new file mode 100644 index 000000000..7d0fda0a1 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/service/UserServiceImpl.java @@ -0,0 +1,46 @@ +/*- + * ============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.service; + +import com.att.ajsc.common.AjscService; + +/** + * User service used for authorization verification at the login page. Do not + * remove this class. + */ +@AjscService +public class UserServiceImpl implements UserService { + + /** + * REST service that returns the username. + * + * @param userName + * @return the user name + */ + @Override + public String getUser(String userName) { + return userName; + } + +} \ No newline at end of file diff --git a/src/main/resources/clds/clds-users.json b/src/main/resources/clds/clds-users.json new file mode 100644 index 000000000..b569f9d3d --- /dev/null +++ b/src/main/resources/clds/clds-users.json @@ -0,0 +1,15 @@ + [{ + "user":"admin", + "password":"5f4dcc3b5aa765d61d8327deb882cf99", + "permissions": + [ + "permission-type-cl|dev|read", + "permission-type-cl|dev|update", + "permission-type-cl-manage|dev|*", + "permission-type-filter-vf|dev|*", + "permission-type-template|dev|read", + "permission-type-template|dev|update" + ] + } + +] \ No newline at end of file diff --git a/src/main/resources/clds/clds-users.properties b/src/main/resources/clds/clds-users.properties deleted file mode 100644 index f4b11e820..000000000 --- a/src/main/resources/clds/clds-users.properties +++ /dev/null @@ -1,7 +0,0 @@ -# Please define the CLDS users here -# The format is || -# Two types of roles are used:read, all -# - read: can only read template and closed loop design -# - all: can read and update template and closed loop related design -# -user|password|all \ No newline at end of file diff --git a/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java b/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java new file mode 100644 index 000000000..fa8adc761 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java @@ -0,0 +1,85 @@ +/*- + * ============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 static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.clamp.clds.service.CldsUser; + +public class CldsUserJsonDecoderTest { + + private String user1 = "admin1"; + private String user2 = "admin2"; + + private String password = "5f4dcc3b5aa765d61d8327deb882cf99"; + private String[] normalPermissionsArray = { "permission-type-cl|dev|read", "permission-type-cl|dev|update", + "permission-type-cl-manage|dev|*", "permission-type-filter-vf|dev|*", "permission-type-template|dev|read", + "permission-type-template|dev|update" }; + + private String[] incompletePermissionsArray = { "permission-type-cl|dev|*", "permission-type-cl|dev|*", + "permission-type-cl-manage|dev|*", "permission-type-filter-vf|dev|*", "permission-type-template|dev|read", + "permission-type-template|dev|update" }; + + @Test + public void testDecodingDoubleUsers() throws Exception { + CldsUser[] usersArray = CldsUserJsonDecoder + .decodeJson(CldsUserJsonDecoderTest.class.getResourceAsStream("/clds/clds-users-two-users.json")); + + assertEquals(usersArray.length, 2); + + assertEquals(usersArray[0].getUser(), user1); + assertEquals(usersArray[1].getUser(), user2); + + assertEquals(usersArray[0].getPassword(), password); + assertEquals(usersArray[1].getPassword(), password); + + assertArrayEquals(usersArray[0].getPermissionsString(), normalPermissionsArray); + assertArrayEquals(usersArray[1].getPermissionsString(), normalPermissionsArray); + } + + @Test + public void testDecodingNoPermission() throws Exception { + CldsUser[] usersArray = CldsUserJsonDecoder + .decodeJson(this.getClass().getResourceAsStream("/clds/clds-users-no-permission.json")); + + assertEquals(usersArray.length, 1); + assertEquals(usersArray[0].getUser(), user1); + assertEquals(usersArray[0].getPassword(), null); + assertArrayEquals(usersArray[0].getPermissionsString(), new String[0]); + } + + @Test + public void testDecodingIncompletePermissions() throws Exception { + CldsUser[] usersArray = CldsUserJsonDecoder + .decodeJson(this.getClass().getResourceAsStream("/clds/clds-users-incomplete-permissions.json")); + + assertEquals(usersArray.length, 1); + assertEquals(usersArray[0].getUser(), user1); + assertEquals(usersArray[0].getPassword(), password); + assertArrayEquals(usersArray[0].getPermissionsString(), incompletePermissionsArray); + } + +} diff --git a/src/test/resources/clds/clds-users-incomplete-permissions.json b/src/test/resources/clds/clds-users-incomplete-permissions.json new file mode 100644 index 000000000..a642511cd --- /dev/null +++ b/src/test/resources/clds/clds-users-incomplete-permissions.json @@ -0,0 +1,14 @@ + [{ + "user":"admin1", + "password":"5f4dcc3b5aa765d61d8327deb882cf99", + "permissions": + [ + "permission-type-cl|dev|", + "permission-type-cl|dev", + "permission-type-cl-manage|dev|*", + "permission-type-filter-vf|dev|*", + "permission-type-template|dev|read", + "permission-type-template|dev|update" + ] + } +] \ No newline at end of file diff --git a/src/test/resources/clds/clds-users-no-permission.json b/src/test/resources/clds/clds-users-no-permission.json new file mode 100644 index 000000000..77f16c38c --- /dev/null +++ b/src/test/resources/clds/clds-users-no-permission.json @@ -0,0 +1,9 @@ + [{ + "user":"admin1", + "permissions": + [ + + ] + } + +] \ No newline at end of file diff --git a/src/test/resources/clds/clds-users-two-users.json b/src/test/resources/clds/clds-users-two-users.json new file mode 100644 index 000000000..8c8d7278a --- /dev/null +++ b/src/test/resources/clds/clds-users-two-users.json @@ -0,0 +1,28 @@ + [{ + "user":"admin1", + "password":"5f4dcc3b5aa765d61d8327deb882cf99", + "permissions": + [ + "permission-type-cl|dev|read", + "permission-type-cl|dev|update", + "permission-type-cl-manage|dev|*", + "permission-type-filter-vf|dev|*", + "permission-type-template|dev|read", + "permission-type-template|dev|update" + ] + } + , + {"user":"admin2", + "password":"5f4dcc3b5aa765d61d8327deb882cf99", + "permissions": + [ + "permission-type-cl|dev|read", + "permission-type-cl|dev|update", + "permission-type-cl-manage|dev|*", + "permission-type-filter-vf|dev|*", + "permission-type-template|dev|read", + "permission-type-template|dev|update" + ] + + } +] \ No newline at end of file -- cgit 1.2.3-korg From 8727db8683fcd11fa3695b2cb4e9a7834a3280e1 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 03:06:03 -0700 Subject: Rework the Req classes for all Rework the req classes for TCA, Operational policy, StringMatch + Camunda config classes reworked Change-Id: I16a1e4b7485416c38ed50087c701aa2e305a768a Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- .../org/onap/clamp/clds/client/req/DcaeReq.java | 66 ++-- .../org/onap/clamp/clds/client/req/JsonUtil.java | 4 +- .../clds/client/req/OperationalPolicyReq.java | 343 +++++++++++++++------ .../clds/client/req/StringMatchPolicyReq.java | 145 ++++----- .../onap/clamp/clds/client/req/TcaMPolicyReq.java | 168 +++++----- .../clds/config/CamundaAuthFilterInitializer.java | 77 ++--- .../clds/config/CamundaEngineConfiguration.java | 10 +- 7 files changed, 503 insertions(+), 310 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java b/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java index 35d6c9f5f..a97e9d488 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,25 +23,26 @@ package org.onap.clamp.clds.client.req; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.node.ObjectNode; +import java.io.IOException; +import java.util.List; + import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.prop.StringMatch; import org.onap.clamp.clds.model.refprop.RefProp; -import java.io.IOException; -import java.util.List; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.node.ObjectNode; /** * Construct a DCAE request given CLDS objects. */ public class DcaeReq { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(DcaeReq.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReq.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); /** * Format DCAE request. @@ -55,39 +56,38 @@ public class DcaeReq { */ public static String format(RefProp refProp, ModelProperties prop) throws IOException { Global globalProp = prop.getGlobal(); - String service = globalProp.getService(); - StringMatch smProp = prop.getStringMatch(); + StringMatch smProp = prop.getType(StringMatch.class); prop.setCurrentModelElementId(smProp.getId()); ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.template"); - // "properties":{ + // "properties":{ ObjectNode properties = rootNode.with("properties"); - // "service_name": + // "service_name": properties.put("service_name", globalProp.getService()); - // "service_ids":[ - List service_ids = refProp.decodeToList("dcae.decode.service_ids", globalProp.getService()); - JsonUtil.addArrayField(properties, "service_ids", service_ids); - // "vnf_ids":[ + // "service_ids":[ + List serviceIds = refProp.decodeToList("dcae.decode.service_ids", globalProp.getService()); + JsonUtil.addArrayField(properties, "service_ids", serviceIds); + // "vnf_ids":[ JsonUtil.addArrayField(properties, "vnf_ids", globalProp.getResourceVf()); - // "location_ids":[ + // "location_ids":[ JsonUtil.addArrayField(properties, "location_ids", globalProp.getLocation()); - // "template":{ + // "template":{ ObjectNode template = rootNode.with("template"); - // "string_matching":{ - ObjectNode string_matching = template.with("string_matching"); - // "dcae":{ - ObjectNode dcae = string_matching.with("dcae"); + // "string_matching":{ + ObjectNode stringMatching = template.with("string_matching"); + // "dcae":{ + ObjectNode dcae = stringMatching.with("dcae"); dcae.put("inputTopic", smProp.getTopicSubscribes()); dcae.put("outputTopic", smProp.getTopicPublishes()); dcae.put("closedLoopControlName", prop.getControlName()); dcae.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); - // "serviceConfigurations":[ - StringMatchPolicyReq.appendServiceConfigurations(refProp, service, dcae, smProp); + // "serviceConfigurations":[ + StringMatchPolicyReq.appendServiceConfigurations(refProp, globalProp.getService(), dcae, smProp, prop); String dcaeReq = rootNode.toString(); logger.info("dcaeReq=" + dcaeReq); diff --git a/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java b/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java index 6aba683bc..31bd4ca49 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java +++ b/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java @@ -41,8 +41,8 @@ public class JsonUtil { * @param node */ public static void addListToArrayNode(List list, ArrayNode node) { - for (String aList : list) { - node.add(aList); + for (String aString : list) { + node.add(aString); } } diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java index 17e606133..41629cc11 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,37 +23,47 @@ package org.onap.clamp.clds.client.req; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.jboss.resteasy.spi.BadRequestException; import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Policy; +import org.onap.clamp.clds.model.prop.PolicyChain; import org.onap.clamp.clds.model.prop.PolicyItem; -import org.onap.policy.controlloop.policy.TargetType; +import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.policy.controlloop.policy.OperationsAccumulateParams; +import org.onap.policy.api.AttributeType; +import org.onap.policy.asdc.Resource; +import org.onap.policy.asdc.ResourceType; +import org.onap.policy.asdc.Service; +import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.controlloop.policy.Target; +import org.onap.policy.controlloop.policy.TargetType; import org.onap.policy.controlloop.policy.builder.BuilderException; import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; import org.onap.policy.controlloop.policy.builder.Message; import org.onap.policy.controlloop.policy.builder.Results; -import org.onap.policy.api.AttributeType; -import org.onap.policy.asdc.Resource; -import org.onap.policy.asdc.ResourceType; -import org.onap.policy.asdc.Service; -import org.onap.clamp.clds.model.refprop.RefProp; -import org.jboss.resteasy.spi.BadRequestException; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.*; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFLogger.Level; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; /** * Construct an Operational Policy request given CLDS objects. */ public class OperationalPolicyReq { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(OperationalPolicyReq.class.getName()); - + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyReq.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); /** * Format Operational Policy attributes. @@ -64,29 +74,52 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - public static Map> formatAttributes(RefProp refProp, ModelProperties prop) throws BuilderException, UnsupportedEncodingException { + public static Map> formatAttributes(RefProp refProp, ModelProperties prop, + String modelElementId, PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { Global global = prop.getGlobal(); - Policy policy = prop.getPolicy(); - prop.setCurrentModelElementId(policy.getId()); - - String templateName = refProp.getStringValue("op.templateName", global.getService()); + prop.setCurrentModelElementId(modelElementId); + prop.setPolicyUniqueId(policyChain.getPolicyId()); + + String templateName = ""; + String operationTopic = ""; + String notificationTopic = ""; + String controller = ""; + Tca tca = prop.getTca(); + if (tca.isFound()) { + if (!global.getActionSet().equalsIgnoreCase("enbRecipe")) { + throw new BadRequestException( + "Operation Policy validation problem: action set is not selected properly."); + } + templateName = refProp.getStringValue("op.eNodeB.templateName", global.getService()); + operationTopic = refProp.getStringValue("op.eNodeB.operationTopic", global.getService()); + notificationTopic = refProp.getStringValue("op.eNodeB.notificationTopic", global.getService()); + controller = refProp.getStringValue("op.eNodeB.controller", global.getService()); + } else { + if (!global.getActionSet().equalsIgnoreCase("vnfRecipe")) { + throw new BadRequestException( + "Operation Policy validation problem: Action set is not selected properly."); + } + templateName = refProp.getStringValue("op.templateName", global.getService()); + operationTopic = refProp.getStringValue("op.operationTopic", global.getService()); + notificationTopic = refProp.getStringValue("op.notificationTopic", global.getService()); + controller = refProp.getStringValue("op.controller", global.getService()); + } String recipeTopic = refProp.getStringValue("op.recipeTopic", global.getService()); - String operationTopic = refProp.getStringValue("op.operationTopic", global.getService()); - String notificationTopic = refProp.getStringValue("op.notificationTopic", global.getService()); // ruleAttributes - Map ruleAttributes = new HashMap<>(); + Map ruleAttributes = new HashMap(); if (operationTopic == null || operationTopic.length() == 0) { logger.info("templateName=" + templateName); logger.info("recipeTopic=" + recipeTopic); logger.info("notificationTopic=" + notificationTopic); - // if no operationTopic, then don't format yaml - use first policy from list - PolicyItem policyItem = policy.getPolicyItems().get(0); + // if no operationTopic, then don't format yaml - use first policy + // from list + PolicyItem policyItem = policyChain.getPolicyItems().get(0); ruleAttributes.put("templateName", templateName); - ruleAttributes.put("ClosedLoopControlName", prop.getControlName()); + ruleAttributes.put("ClosedLoopControlName", prop.getControlNameAndPolicyUniqueId()); ruleAttributes.put("RecipeTopic", recipeTopic); ruleAttributes.put("NotificationTopic", notificationTopic); @@ -105,10 +138,11 @@ public class OperationalPolicyReq { logger.info("notificationTopic=" + notificationTopic); // format yaml - String yaml = formatYaml(refProp, prop); + String yaml = tca.isFound() ? formateNodeBYaml(refProp, prop, modelElementId, policyChain) + : formatYaml(refProp, prop, modelElementId, policyChain); ruleAttributes.put("templateName", templateName); - ruleAttributes.put("ClosedLoopControlName", prop.getControlName()); + ruleAttributes.put("ClosedLoopControlName", prop.getControlNameAndPolicyUniqueId()); ruleAttributes.put("OperationTopic", operationTopic); ruleAttributes.put("NotificationTopic", notificationTopic); @@ -116,20 +150,16 @@ public class OperationalPolicyReq { } // matchingAttributes - String controller = refProp.getStringValue("op.controller", global.getService()); - - Map matchingAttributes = new HashMap<>(); + Map matchingAttributes = new HashMap(); matchingAttributes.put("controller", controller); - Map> attributes = new HashMap<>(); + Map> attributes = new HashMap>(); attributes.put(AttributeType.RULE, ruleAttributes); attributes.put(AttributeType.MATCHING, matchingAttributes); - return attributes; } - /** * Format Operational Policy yaml. * @@ -139,53 +169,50 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - private static String formatYaml(RefProp refProp, ModelProperties prop) throws BuilderException, UnsupportedEncodingException { + private static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId, + PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { + // get property objects Global global = prop.getGlobal(); - Policy policy = prop.getPolicy(); - prop.setCurrentModelElementId(policy.getId()); + prop.setCurrentModelElementId(modelElementId); + prop.setPolicyUniqueId(policyChain.getPolicyId()); - // convert values to ASDC objects + // convert values to SDC objects Service service = new Service(global.getService()); Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF); Resource[] vfcResources = convertToResource(global.getResourceVfc(), ResourceType.VFC); // create builder - ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(), policy.getTimeout(), service, vfResources); + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(), + policyChain.getTimeout(), service, vfResources); builder.addResource(vfcResources); // process each policy - HashMap policyObjMap = new HashMap<>(); - List policyItemList = orderParentFirst(policy.getPolicyItems()); + HashMap policyObjMap = new HashMap(); + List policyItemList = orderParentFirst(policyChain.getPolicyItems()); + Target target = new Target(); + target.setType(TargetType.VM); for (int i = 0; i < policyItemList.size(); i++) { + org.onap.policy.controlloop.policy.Policy policyObj; PolicyItem policyItem = policyItemList.get(i); String policyName = policyItem.getRecipe() + " Policy"; if (i == 0) { - String policyDescription = policyItem.getRecipe() + " Policy - the trigger (no parent) policy - created by CLDS"; - policyObj = builder.setTriggerPolicy( - policyName, - policyDescription, - "APPC", - new Target(TargetType.VM), - policyItem.getRecipe(), - new HashMap<>(), //TODO To verify ! - policyItem.getMaxRetries(), - policyItem.getRetryTimeLimit()); + String policyDescription = policyItem.getRecipe() + + " Policy - the trigger (no parent) policy - created by CLDS"; + policyObj = builder.setTriggerPolicy(policyName, policyDescription, + refProp.getStringValue("op.policy.appc"), target, policyItem.getRecipe(), null, + policyItem.getMaxRetries(), policyItem.getRetryTimeLimit()); } else { - org.onap.policy.controlloop.policy.Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy()); - String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + parentPolicyObj.getName() + " - created by CLDS"; - policyObj = builder.setPolicyForPolicyResult( - policyName, - policyDescription, - "APPC", - new Target(TargetType.VM), - policyItem.getRecipe(), - new HashMap<>(), //TODO To verify ! - policyItem.getMaxRetries(), - policyItem.getRetryTimeLimit(), - parentPolicyObj.getId(), + org.onap.policy.controlloop.policy.Policy parentPolicyObj = policyObjMap + .get(policyItem.getParentPolicy()); + String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + + parentPolicyObj.getName() + " - created by CLDS"; + policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, + refProp.getStringValue("op.policy.appc"), target, policyItem.getRecipe(), null, + policyItem.getMaxRetries(), policyItem.getRetryTimeLimit(), parentPolicyObj.getId(), convertToPolicyResult(policyItem.getParentPolicyConditions())); + logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId()); } policyObjMap.put(policyItem.getId(), policyObj); @@ -199,7 +226,7 @@ public class OperationalPolicyReq { logger.info("results.getSpecification()=" + results.getSpecification()); } else { // throw exception with error info - StringBuilder sb = new StringBuilder(); + StringBuffer sb = new StringBuffer(); sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: "); for (Message message : results.getMessages()) { sb.append(message.getMessage()); @@ -207,11 +234,143 @@ public class OperationalPolicyReq { } throw new BadRequestException(sb.toString()); } - return URLEncoder.encode(results.getSpecification(), "UTF-8"); + + String encodedYaml = URLEncoder.encode(results.getSpecification(), "UTF-8"); + + return encodedYaml; } /** - * Order list of PolicyItems so that parents come before any of their children + * Format Operational Policy yaml. + * + * @param refProp + * @param prop + * @return + * @throws BuilderException + * @throws UnsupportedEncodingException + */ + private static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId, + PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { + + // get property objects + Global global = prop.getGlobal(); + prop.setCurrentModelElementId(modelElementId); + prop.setPolicyUniqueId(policyChain.getPolicyId()); + + // convert values to SDC objects + Service service = new Service(global.getService()); + Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF); + Resource[] vfcResources = convertToResource(global.getResourceVfc(), ResourceType.VFC); + + // create builder + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(), + policyChain.getTimeout(), service, vfResources); + builder.addResource(vfcResources); + + // process each policy + HashMap policyObjMap = new HashMap(); + List policyItemList = addAOTSActorRecipe(refProp, global.getService(), + policyChain.getPolicyItems()); + Target target = new Target(); + target.setType(TargetType.VM); + Policy lastPolicyObj = new Policy(); + for (int i = 0; i < policyItemList.size(); i++) { + org.onap.policy.controlloop.policy.Policy policyObj; + PolicyItem policyItem = policyItemList.get(i); + String policyName = policyItem.getRecipe() + " Policy"; + if (i == 0) { + //To set up time window payload for trigger policy + Map payloadMap = new HashMap(); + payloadMap.put("timeWindow", refProp.getStringValue("op.eNodeB.timeWindow")); + String policyDescription = policyItem.getRecipe() + + " Policy - the trigger (no parent) policy - created by CLDS"; + policyObj = builder.setTriggerPolicy(policyName, policyDescription, policyItem.getActor(), target, + policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit()); + } else { + Policy parentPolicyObj = policyObjMap + .get(policyItem.getParentPolicy()); + String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + + parentPolicyObj.getName() + " - created by CLDS"; + policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, policyItem.getActor(), + target, policyItem.getRecipe(), null, policyItem.getMaxRetries(), + policyItem.getRetryTimeLimit(), parentPolicyObj.getId(), + convertToPolicyResult(policyItem.getParentPolicyConditions())); + lastPolicyObj = policyObj; + logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId()); + } + policyObjMap.put(policyItem.getId(), policyObj); + } + //To set up operations accumulate params + OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); + operationsAccumulateParams.setLimit(Integer.valueOf(refProp.getStringValue("op.eNodeB.limit"))); + operationsAccumulateParams.setPeriod(refProp.getStringValue("op.eNodeB.period")); + builder.addOperationsAccumulateParams(lastPolicyObj.getId(), operationsAccumulateParams); + + // + // Build the specification + // + Results results = builder.buildSpecification(); + if (results.isValid()) { + logger.info("results.getSpecification()=" + results.getSpecification()); + } else { + // throw exception with error info + StringBuffer sb = new StringBuffer(); + sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: "); + for (Message message : results.getMessages()) { + sb.append(message.getMessage()); + sb.append("; "); + } + throw new BadRequestException(sb.toString()); + } + + String encodedYaml = URLEncoder.encode(results.getSpecification(), "UTF-8"); + + return encodedYaml; + } + + /** + * Adding AOTS actor and other recipe for yaml + * + * @param inOrigList + * @return + */ + private static List addAOTSActorRecipe(RefProp refProp, String service, List inOrigList) { + List outList = new ArrayList(); + try { + PolicyItem policyItem = inOrigList.get(0); + ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("op.eNodeB.recipe", service); + Iterator itr = rootNode.get("eNodeBRecipes").elements(); + while (itr.hasNext()) { + PolicyItem policyItemObj = (PolicyItem) policyItem.clone(); + JsonNode recipeNode = itr.next(); + policyItemObj.setId(recipeNode.path("Recipe").asText()); + policyItemObj.setActor(recipeNode.path("Actor").asText()); + policyItemObj.setRecipe(recipeNode.path("Recipe").asText()); + policyItemObj.setParentPolicy(recipeNode.path("ParentPolicy").asText()); + if (!recipeNode.path("Retry").asText().isEmpty()) { + policyItemObj.setMaxRetries(Integer.parseInt(recipeNode.path("Retry").asText())); + } + if (!recipeNode.path("TimeLimit").asText().isEmpty()) { + policyItemObj.setRetryTimeLimit(Integer.parseInt(recipeNode.path("TimeLimit").asText())); + } + if (!recipeNode.path("PPConditions").asText().isEmpty()) { + List parentPolicyConditions = new ArrayList(); + for (String ppCondition : recipeNode.path("PPConditions").asText().split(",")) { + parentPolicyConditions.add(ppCondition); + } + policyItemObj.setParentPolicyConditions(parentPolicyConditions); + } + outList.add(policyItemObj); + } + } catch (Exception e) { + logger.log(Level.ERROR, "Error", e); + } + return outList; + } + + /** + * Order list of PolicyItems so that parents come before any of their + * children * * @param inOrigList * @return @@ -222,12 +381,14 @@ public class OperationalPolicyReq { List outList = new ArrayList<>(); int prevSize = 0; while (!inList.isEmpty()) { - // check if there's a loop in the policy chain (the inList should have been reduced by at least one) + // check if there's a loop in the policy chain (the inList should + // have been reduced by at least one) if (inList.size() == prevSize) { throw new BadRequestException("Operation Policy validation problem: loop in Operation Policy chain"); } prevSize = inList.size(); - // the following loop should remove at least one PolicyItem from the inList + // the following loop should remove at least one PolicyItem from the + // inList Iterator inListItr = inList.iterator(); while (inListItr.hasNext()) { PolicyItem inItem = inListItr.next(); @@ -235,7 +396,8 @@ public class OperationalPolicyReq { String parent = inItem.getParentPolicy(); if (parent == null || parent.length() == 0) { if (outList.size() > 0) { - throw new BadRequestException("Operation Policy validation problem: more than one trigger policy"); + throw new BadRequestException( + "Operation Policy validation problem: more than one trigger policy"); } else { outList.add(inItem); inListItr.remove(); @@ -244,7 +406,8 @@ public class OperationalPolicyReq { // check if this PolicyItem's parent has been processed for (PolicyItem outItem : outList) { if (outItem.getId().equals(parent)) { - // if the inItem parent is already in the outList, then add inItem to outList and remove from inList + // if the inItem parent is already in the outList, + // then add inItem to outList and remove from inList outList.add(inItem); inListItr.remove(); break; @@ -256,29 +419,29 @@ public class OperationalPolicyReq { return outList; } - /** * Convert a List of resource strings to an array of Resource objects. * - * @param rList + * @param stringList * @param resourceType * @return */ - private static Resource[] convertToResource(List rList, ResourceType resourceType) { + private static Resource[] convertToResource(List stringList, ResourceType resourceType) { int size = 0; - if (rList != null) { - size = rList.size(); + if (stringList != null) { + size = stringList.size(); } - Resource[] rArray = new Resource[size]; + Resource[] resourceArray = new Resource[size]; for (int i = 0; i < size; i++) { - String rString = rList.get(i); - rArray[i] = new Resource(rString, resourceType); + String rString = stringList.get(i); + resourceArray[i] = new Resource(rString, resourceType); } - return rArray; + return resourceArray; } /** - * Convert a List of policy result strings to an array of PolicyResult objects. + * Convert a List of policy result strings to an array of PolicyResult + * objects. * * @param prList * @return @@ -296,4 +459,4 @@ public class OperationalPolicyReq { return prArray; } -} +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java index 0f66cd9ba..5884c3dd2 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,26 +23,28 @@ package org.onap.clamp.clds.client.req; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import java.io.IOException; +import java.util.Iterator; +import java.util.Map.Entry; + import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.ResourceGroup; import org.onap.clamp.clds.model.prop.ServiceConfiguration; import org.onap.clamp.clds.model.prop.StringMatch; import org.onap.clamp.clds.model.refprop.RefProp; -import java.io.IOException; -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; /** * Construct a Policy for String Match Micro Service request given CLDS objects. */ public class StringMatchPolicyReq { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(StringMatchPolicyReq.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(StringMatchPolicyReq.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); /** * Format Policy String Match request. @@ -56,21 +58,12 @@ public class StringMatchPolicyReq { Global global = prop.getGlobal(); String service = global.getService(); - StringMatch sm = prop.getStringMatch(); + StringMatch sm = prop.getType(StringMatch.class); prop.setCurrentModelElementId(sm.getId()); ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("sm.template", service); - - // "policyName": rootNode.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); - - // "content":{ ObjectNode content = rootNode.with("content"); - - // "closedLoopControlName": - content.put("closedLoopControlName", prop.getControlName()); - - // "serviceConfigurations":[ - appendServiceConfigurations(refProp, service, content, sm); + appendServiceConfigurations(refProp, service, content, sm, prop); String stringMatchPolicyReq = rootNode.toString(); logger.info("stringMatchPolicyReq=" + stringMatchPolicyReq); @@ -84,55 +77,63 @@ public class StringMatchPolicyReq { * @param sm * @throws IOException */ - public static void appendServiceConfigurations(RefProp refProp, String service, ObjectNode appendToNode, StringMatch sm) throws IOException { - // "serviceConfigurations":{ + public static void appendServiceConfigurations(RefProp refProp, String service, ObjectNode appendToNode, + StringMatch sm, ModelProperties prop) throws IOException { + // "serviceConfigurations":{ ObjectNode scNodes = appendToNode.with("serviceConfigurations"); - Iterator scItr = sm.getServiceConfigurations().iterator(); int index = 0; - while (scItr.hasNext()) { - ServiceConfiguration sc = scItr.next(); - - //"ItemX":{ - index++; - String keyValue = "Item" + index; - ObjectNode scNode = (ObjectNode) refProp.getJsonTemplate("sm.sc.template", service); - scNodes.set(keyValue, scNode); - - // "rulegroup":"abc", - String rulegroupInd = refProp.getStringValue("sm.rulegroup", service); - String groupNumber = sc.getGroupNumber(); - if (rulegroupInd != null && rulegroupInd.equalsIgnoreCase("true") && groupNumber != null && groupNumber.length() > 0) { - - //String rulegroup = (sc.getResourceVf() == null ? "" : String.join(" ", sc.getResourceVf())) + " - " + (sc.getResourceVfc() == null ? "" : String.join(" ", sc.getResourceVfc())); - scNode.put("rulegroup", groupNumber); - } - - // "aaiMatchingFields" : ["VM_NAME"], - JsonUtil.addArrayField(scNode, "aaiMatchingFields", sc.getaaiMatchingFields()); - // "aaiSendFields" : ["VMID", "TenantID"], - JsonUtil.addArrayField(scNode, "aaiSendFields", sc.getaaiSendFields()); - - // "stringSet": [ - ArrayNode ssNode = scNode.putArray("stringSet"); - // ObjectNode ssNode = scNode.with("stringSet"); - for (Entry entry : sc.getStringSet().entrySet()) { - // exclude eventSourceType - if (!entry.getKey().equals("eventSourceType")) { - ssNode.add(entry.getKey()); - ssNode.add(entry.getValue()); + if (sm != null && sm.getResourceGroups() != null) { + for (ResourceGroup resourceGroup : sm.getResourceGroups()) { + Iterator scItr = resourceGroup.getServiceConfigurations().iterator(); + + while (scItr.hasNext()) { + ServiceConfiguration sc = scItr.next(); + + // "ItemX":{ + index++; + String keyValue = "Item" + index; + ObjectNode scNode = (ObjectNode) refProp.getJsonTemplate("sm.sc.template", service); + scNodes.set(keyValue, scNode); + + // "rulegroup":"abc", + String rulegroupInd = refProp.getStringValue("sm.rulegroup", service); + String groupNumber = resourceGroup.getGroupNumber(); + if (rulegroupInd != null && rulegroupInd.equalsIgnoreCase("true") && groupNumber != null + && groupNumber.length() > 0) { + scNode.put("rulegroup", groupNumber); + } + + // "closedLoopControlName": + prop.setPolicyUniqueId(resourceGroup.getPolicyId()); + scNode.put("closedLoopControlName", prop.getControlNameAndPolicyUniqueId()); + + // "aaiMatchingFields" : ["VM_NAME"], + JsonUtil.addArrayField(scNode, "aaiMatchingFields", sc.getaaiMatchingFields()); + // "aaiSendFields" : ["VMID", "TenantID"], + JsonUtil.addArrayField(scNode, "aaiSendFields", sc.getaaiSendFields()); + + // "stringSet": [ + ArrayNode ssNode = scNode.putArray("stringSet"); + + for (Entry entry : sc.getStringSet().entrySet()) { + // exclude eventSourceType + if (!entry.getKey().equals("eventSourceType")) { + ssNode.add(entry.getKey()); + ssNode.add(entry.getValue()); + } + } + + // timeWindow": "0", + scNode.put("timeWindow", sc.getTimeWindow()); + // "ageLimit": "3600", + scNode.put("ageLimit", sc.getAgeLimit()); + // "createClosedLoopEventId" : "Initial", + scNode.put("createClosedLoopEventId", sc.getCreateClosedLoopEventId()); + // "outputEventName": "OnSet" + scNode.put("outputEventName", sc.getOutputEventName()); } } - - // timeWindow": "0", - scNode.put("timeWindow", sc.getTimeWindow()); - // "ageLimit": "3600", - scNode.put("ageLimit", sc.getAgeLimit()); - // "createClosedLoopEventId" : "Initial", - scNode.put("createClosedLoopEventId", sc.getCreateClosedLoopEventId()); - // "outputEventName": "OnSet" - scNode.put("outputEventName", sc.getOutputEventName()); } } - } diff --git a/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java index f8acb64f6..f31062893 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java @@ -1,8 +1,30 @@ +/*- + * ============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.client.req; import java.io.IOException; import java.util.Iterator; -import java.util.logging.Logger; import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; @@ -10,84 +32,90 @@ import org.onap.clamp.clds.model.prop.Tca; import org.onap.clamp.clds.model.prop.TcaItem; import org.onap.clamp.clds.model.prop.TcaThreshhold; import org.onap.clamp.clds.model.refprop.RefProp; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; /** - * Construct a Policy for Tca/MTca Service request given CLDS objects. - * + * Construct a Policy for Tca/MTca Service request given CLDS objects. + * * */ public class TcaMPolicyReq { - private static final Logger logger = Logger.getLogger(StringMatchPolicyReq.class.getName()); - - /** - * Format Tca Policy request - * - * @param refProp - * @param prop - * @return - * @throws JsonParseException - * @throws JsonMappingException - * @throws IOException - */ - public static String formatTca(RefProp refProp, ModelProperties prop) throws JsonParseException, JsonMappingException, IOException { - Global global = prop.getGlobal(); - String service = global.getService(); - - Tca tca = prop.getTca(); - prop.setCurrentModelElementId(tca.getId()); - ObjectNode rootNode = (ObjectNode)refProp.getJsonTemplate("tca.template", service); - rootNode.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); - ObjectNode content = rootNode.with("content"); - appendSignatures(refProp, service, content, tca, prop); - - String tcaPolicyReq = rootNode.toString(); - logger.info("tcaPolicyReq=" + tcaPolicyReq); - return tcaPolicyReq; - } - - /** - * Add appendSignatures to json - * - * @param refProp - * @param service - * @param appendToNode - * @param tca - * @param prop - * @throws JsonParseException - * @throws JsonMappingException - * @throws IOException - */ - public static void appendSignatures(RefProp refProp, String service, ObjectNode appendToNode, Tca tca, ModelProperties prop) throws JsonParseException, JsonMappingException, IOException { - // "signatures":{ - ArrayNode tcaNodes = appendToNode.withArray("signatures"); - for(TcaItem tcaItem : tca.getTcaItems()){ - ObjectNode tcaNode = (ObjectNode)refProp.getJsonTemplate("tca.signature.template", service); - tcaNode.put("useCaseName", tcaItem.getTcaName()); - tcaNode.put("signatureName", tcaItem.getTcaName()+ "_" + tcaItem.getTcaUuId()); - tcaNode.put("signatureUuid", tcaItem.getTcaUuId()); - prop.setPolicyUniqueId(tcaItem.getPolicyId()); - tcaNode.put("closedLoopControlName", prop.getControlNameAndPolicyUniqueId()); - tcaNode.put("severity", tcaItem.getSeverity()); - tcaNode.put("maxInterval", tcaItem.getInterval()); - tcaNode.put("minMessageViolations", tcaItem.getViolations()); - - tcaNodes.add(tcaNode); - Iterator scItr = tcaItem.getTcaThreshholds().iterator(); - while(scItr.hasNext()) { - TcaThreshhold tcaThreshhold = scItr.next(); - // "thresholds": [ - ArrayNode thNodes = tcaNode.withArray("thresholds"); - ObjectNode thNode = thNodes.addObject(); - thNode.put("fieldPath", tcaThreshhold.getFieldPath()); - thNode.put("thresholdName", tcaThreshhold.getMetric()); - thNode.put("thresholdValue", tcaThreshhold.getThreshhold()); - thNode.put("direction", tcaThreshhold.getOperator()); - } - } + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaMPolicyReq.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + /** + * Format Tca Policy request + * + * @param refProp + * @param prop + * @return + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public static String formatTca(RefProp refProp, ModelProperties prop) + throws JsonParseException, JsonMappingException, IOException { + Global global = prop.getGlobal(); + String service = global.getService(); + + Tca tca = prop.getType(Tca.class); + prop.setCurrentModelElementId(tca.getId()); + ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("tca.template", service); + rootNode.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); + ObjectNode content = rootNode.with("content"); + appendSignatures(refProp, service, content, tca, prop); + + String tcaPolicyReq = rootNode.toString(); + logger.info("tcaPolicyReq=" + tcaPolicyReq); + return tcaPolicyReq; + } + + /** + * Add appendSignatures to json + * + * @param refProp + * @param service + * @param appendToNode + * @param tca + * @param prop + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public static void appendSignatures(RefProp refProp, String service, ObjectNode appendToNode, Tca tca, + ModelProperties prop) throws JsonParseException, JsonMappingException, IOException { + // "signatures":{ + ArrayNode tcaNodes = appendToNode.withArray("signatures"); + for (TcaItem tcaItem : tca.getTcaItems()) { + ObjectNode tcaNode = (ObjectNode) refProp.getJsonTemplate("tca.signature.template", service); + tcaNode.put("useCaseName", tcaItem.getTcaName()); + tcaNode.put("signatureName", tcaItem.getTcaName() + "_" + tcaItem.getTcaUuId()); + tcaNode.put("signatureUuid", tcaItem.getTcaUuId()); + prop.setPolicyUniqueId(tcaItem.getPolicyId()); + tcaNode.put("closedLoopControlName", prop.getControlNameAndPolicyUniqueId()); + tcaNode.put("severity", tcaItem.getSeverity()); + tcaNode.put("maxInterval", tcaItem.getInterval()); + tcaNode.put("minMessageViolations", tcaItem.getViolations()); + + tcaNodes.add(tcaNode); + Iterator scItr = tcaItem.getTcaThreshholds().iterator(); + while (scItr.hasNext()) { + TcaThreshhold tcaThreshhold = scItr.next(); + // "thresholds": [ + ArrayNode thNodes = tcaNode.withArray("thresholds"); + ObjectNode thNode = thNodes.addObject(); + thNode.put("fieldPath", tcaThreshhold.getFieldPath()); + thNode.put("thresholdName", tcaThreshhold.getMetric()); + thNode.put("thresholdValue", tcaThreshhold.getThreshhold()); + thNode.put("direction", tcaThreshhold.getOperator()); + } } + } } \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java b/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java index 244b40aa1..a411151a1 100644 --- a/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java +++ b/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -25,7 +25,6 @@ package org.onap.clamp.clds.config; import java.util.EnumSet; import java.util.Map; -import java.util.logging.Logger; import javax.servlet.DispatcherType; import javax.servlet.Filter; @@ -35,53 +34,57 @@ import javax.servlet.ServletException; import org.camunda.bpm.spring.boot.starter.CamundaBpmAutoConfiguration; import org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter; +import org.onap.clamp.clds.client.SdcCatalogServices; 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; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + @Configuration @ConditionalOnWebApplication @AutoConfigureAfter(CamundaBpmAutoConfiguration.class) public class CamundaAuthFilterInitializer implements ServletContextInitializer { - private static final EnumSet DISPATCHER_TYPES = EnumSet.of(DispatcherType.REQUEST); - - private static final String AJSC_CADI_PROPS_FILE = "cadi.properties"; + private static final EnumSet DISPATCHER_TYPES = EnumSet.of(DispatcherType.REQUEST); - private ServletContext servletContext; + private ServletContext servletContext; - @Value("${com.att.ajsc.camunda.contextPath:/camunda}") - private String CAMUNDA_SUFFIX; + @Value("${com.att.ajsc.camunda.contextPath:/camunda}") + private String camundaSuffix; - private static final Logger log = Logger.getLogger(CamundaAuthFilterInitializer.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(SdcCatalogServices.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - @Override - public void onStartup(ServletContext servletContext) throws ServletException { - this.servletContext = servletContext; + @Override + public void onStartup(ServletContext servletContext) throws ServletException { + this.servletContext = servletContext; - registerFilter("Authentication Filter", AuthenticationFilter.class, CAMUNDA_SUFFIX + "/*"); - } + registerFilter("Authentication Filter", AuthenticationFilter.class, camundaSuffix + "/*"); + } - private FilterRegistration registerFilter(final String filterName, final Class filterClass, - final String... urlPatterns) { - return registerFilter(filterName, filterClass, null, urlPatterns); - } + private FilterRegistration registerFilter(final String filterName, final Class filterClass, + final String... urlPatterns) { + return registerFilter(filterName, filterClass, null, urlPatterns); + } - private FilterRegistration registerFilter(final String filterName, final Class filterClass, - final Map initParameters, final String... urlPatterns) { - FilterRegistration filterRegistration = servletContext.getFilterRegistration(filterName); + private FilterRegistration registerFilter(final String filterName, final Class filterClass, + final Map initParameters, final String... urlPatterns) { + FilterRegistration filterRegistration = servletContext.getFilterRegistration(filterName); - if (filterRegistration == null) { - filterRegistration = servletContext.addFilter(filterName, filterClass); - filterRegistration.addMappingForUrlPatterns(DISPATCHER_TYPES, true, urlPatterns); + if (filterRegistration == null) { + filterRegistration = servletContext.addFilter(filterName, filterClass); + filterRegistration.addMappingForUrlPatterns(DISPATCHER_TYPES, true, urlPatterns); - if (initParameters != null) { - filterRegistration.setInitParameters(initParameters); - } - } + if (initParameters != null) { + filterRegistration.setInitParameters(initParameters); + } + } - return filterRegistration; - } + return filterRegistration; + } } diff --git a/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java index 949f4ea62..a27cc69ba 100644 --- a/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java @@ -23,14 +23,14 @@ package org.onap.clamp.clds.config; +import javax.sql.DataSource; + import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import javax.sql.DataSource; - @Configuration public class CamundaEngineConfiguration { @@ -39,11 +39,9 @@ public class CamundaEngineConfiguration { */ @Primary @Bean(name = "camundaBpmDataSource") - @ConfigurationProperties(prefix = "spring.datasource") + @ConfigurationProperties(prefix = "spring.datasource.camunda") public DataSource dataSource() { - return DataSourceBuilder - .create() - .build(); + return DataSourceBuilder.create().build(); } } -- cgit 1.2.3-korg From 5ff37e6b05bfd235ba782462e83355c5289018a1 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 03:08:14 -0700 Subject: Rework the Clds DAO and properties associated Rework the Clds DAO and Prop classes collector, modelBPMN, policy, service Config Change-Id: If64573d9d513b54f286f46db26ef57fcc7830617 Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/config/CsiLoggingConfiguration.java | 5 +- src/main/java/org/onap/clamp/clds/dao/CldsDao.java | 212 +++++++++-------- .../clamp/clds/exception/AjscExceptionMapper.java | 9 +- .../org/onap/clamp/clds/model/prop/Collector.java | 29 ++- .../org/onap/clamp/clds/model/prop/Global.java | 60 +++-- .../org/onap/clamp/clds/model/prop/ModelBpmn.java | 63 +++-- .../onap/clamp/clds/model/prop/ModelBpmnEntry.java | 44 ++-- .../onap/clamp/clds/model/prop/ModelElement.java | 58 +++-- .../clamp/clds/model/prop/ModelProperties.java | 197 ++++++++++------ .../org/onap/clamp/clds/model/prop/Policy.java | 72 +++--- .../org/onap/clamp/clds/model/prop/PolicyItem.java | 115 +++++++-- .../clds/model/prop/ServiceConfiguration.java | 85 ++++--- .../onap/clamp/clds/model/prop/StringMatch.java | 82 +++++-- .../java/org/onap/clamp/clds/model/prop/Tca.java | 105 ++++++--- .../org/onap/clamp/clds/model/prop/TcaItem.java | 261 ++++++++++++--------- .../onap/clamp/clds/model/prop/TcaThreshhold.java | 164 ++++++++----- 16 files changed, 968 insertions(+), 593 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java index 5c5ba5742..5b48e8d88 100644 --- a/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java @@ -23,11 +23,12 @@ 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; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; @Configuration public class CsiLoggingConfiguration { 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 67e4d1b84..d54976b84 100644 --- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,18 +23,6 @@ package org.onap.clamp.clds.dao; -import org.onap.clamp.clds.model.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.RowMapper; -import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; -import org.springframework.jdbc.core.namedparam.SqlParameterSource; -import org.springframework.jdbc.core.simple.SimpleJdbcCall; -import org.springframework.stereotype.Repository; - -import javax.sql.DataSource; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; @@ -46,25 +34,48 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.sql.DataSource; + +import org.onap.clamp.clds.model.CldsDBServiceCache; +import org.onap.clamp.clds.model.CldsEvent; +import org.onap.clamp.clds.model.CldsModel; +import org.onap.clamp.clds.model.CldsModelInstance; +import org.onap.clamp.clds.model.CldsServiceData; +import org.onap.clamp.clds.model.CldsTemplate; +import org.onap.clamp.clds.model.ValueItem; +import org.springframework.dao.EmptyResultDataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; +import org.springframework.jdbc.core.namedparam.SqlParameterSource; +import org.springframework.jdbc.core.simple.SimpleJdbcCall; +import org.springframework.stereotype.Repository; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + /** * Data Access for CLDS Model tables. */ @Repository("cldsDao") public class CldsDao { - private static final Logger logger = LoggerFactory.getLogger(CldsDao.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private JdbcTemplate jdbcTemplateObject; - private SimpleJdbcCall procGetModel; - private SimpleJdbcCall procGetModelTemplate; - private SimpleJdbcCall procSetModel; - private SimpleJdbcCall procInsEvent; - private SimpleJdbcCall procUpdEvent; - private SimpleJdbcCall procSetTemplate; - private SimpleJdbcCall procGetTemplate; - private SimpleJdbcCall procDelAllModelInstances; - private SimpleJdbcCall procInsModelInstance; - private SimpleJdbcCall procDelModelInstance; + private JdbcTemplate jdbcTemplateObject; + private SimpleJdbcCall procGetModel; + private SimpleJdbcCall procGetModelTemplate; + private SimpleJdbcCall procSetModel; + private SimpleJdbcCall procInsEvent; + private SimpleJdbcCall procUpdEvent; + private SimpleJdbcCall procSetTemplate; + private SimpleJdbcCall procGetTemplate; + private SimpleJdbcCall procDelAllModelInstances; + private SimpleJdbcCall procInsModelInstance; + private SimpleJdbcCall procDelModelInstance; + + private static final String healthcheck = "Select 1"; /** * Log message when instantiating @@ -121,8 +132,7 @@ public class CldsDao { private CldsModel getModel(String modelName, String controlNameUuid) { CldsModel model = new CldsModel(); model.setName(modelName); - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_model_name", modelName) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName) .addValue("v_control_name_uuid", controlNameUuid); Map out = logSqlExecution(procGetModel, in); model.setControlNamePrefix((String) out.get("v_control_name_prefix")); @@ -131,28 +141,31 @@ public class CldsDao { model.setTemplateId((String) (out.get("v_template_id"))); model.setTemplateName((String) (out.get("v_template_name"))); model.setBpmnId((String) (out.get("v_template_bpmn_id"))); - model.setBpmnUserid((String) out.get("v_template_bpmn_userid")); + model.setBpmnUserid((String) out.get("v_template_bpmn_user_id")); model.setBpmnText((String) out.get("v_template_bpmn_text")); model.setPropId((String) (out.get("v_model_prop_id"))); - model.setPropUserid((String) out.get("v_model_prop_userid")); + model.setPropUserid((String) out.get("v_model_prop_user_id")); model.setPropText((String) out.get("v_model_prop_text")); model.setImageId((String) (out.get("v_template_image_id"))); - model.setImageUserid((String) out.get("v_template_image_userid")); + model.setImageUserid((String) out.get("v_template_image_user_id")); model.setImageText((String) out.get("v_template_image_text")); model.setDocId((String) (out.get("v_template_doc_id"))); - model.setDocUserid((String) out.get("v_template_doc_userid")); + model.setDocUserid((String) out.get("v_template_doc_user_id")); model.setDocText((String) out.get("v_template_doc_text")); model.setBlueprintText((String) out.get("v_model_blueprint_text")); model.getEvent().setId((String) (out.get("v_event_id"))); model.getEvent().setActionCd((String) out.get("v_action_cd")); model.getEvent().setActionStateCd((String) out.get("v_action_state_cd")); model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id")); - model.getEvent().setUserid((String) out.get("v_event_userid")); + model.getEvent().setUserid((String) out.get("v_event_user_id")); + model.setTypeId((String) out.get("v_service_type_id")); + model.setDeploymentId((String) out.get("v_deployment_id")); return model; } /** - * Get a model and template information from the database given the model name. + * Get a model and template information from the database given the model + * name. * * @param modelName * @return model @@ -169,23 +182,25 @@ public class CldsDao { model.setTemplateId((String) (out.get("v_template_id"))); model.setTemplateName((String) (out.get("v_template_name"))); model.setBpmnId((String) (out.get("v_template_bpmn_id"))); - model.setBpmnUserid((String) out.get("v_template_bpmn_userid")); + model.setBpmnUserid((String) out.get("v_template_bpmn_user_id")); model.setBpmnText((String) out.get("v_template_bpmn_text")); model.setPropId((String) (out.get("v_model_prop_id"))); - model.setPropUserid((String) out.get("v_model_prop_userid")); + model.setPropUserid((String) out.get("v_model_prop_user_id")); model.setPropText((String) out.get("v_model_prop_text")); model.setImageId((String) (out.get("v_template_image_id"))); - model.setImageUserid((String) out.get("v_template_image_userid")); + model.setImageUserid((String) out.get("v_template_image_user_id")); model.setImageText((String) out.get("v_template_image_text")); model.setDocId((String) (out.get("v_template_doc_id"))); - model.setDocUserid((String) out.get("v_template_doc_userid")); + model.setDocUserid((String) out.get("v_template_doc_user_id")); model.setDocText((String) out.get("v_template_doc_text")); model.setBlueprintText((String) out.get("v_model_blueprint_text")); model.getEvent().setId((String) (out.get("v_event_id"))); model.getEvent().setActionCd((String) out.get("v_action_cd")); model.getEvent().setActionStateCd((String) out.get("v_action_state_cd")); model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id")); - model.getEvent().setUserid((String) out.get("v_event_userid")); + model.getEvent().setUserid((String) out.get("v_event_user_id")); + model.setTypeId((String) out.get("v_service_type_id")); + model.setDeploymentId((String) out.get("v_deployment_id")); Map modelResults = logSqlExecution(procGetModel, in); Object modelResultObject = modelResults.get("#result-set-1"); @@ -207,19 +222,19 @@ public class CldsDao { } /** - * Update model in the database using parameter values and return updated model object. + * Update model in the database using parameter values and return updated + * model object. * * @param model * @param userid * @return */ public CldsModel setModel(CldsModel model, String userid) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_model_name", model.getName()) - .addValue("v_template_id", model.getTemplateId()) - .addValue("v_userid", userid) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", model.getName()) + .addValue("v_template_id", model.getTemplateId()).addValue("v_user_id", userid) .addValue("v_model_prop_text", model.getPropText()) .addValue("v_model_blueprint_text", model.getBlueprintText()) + .addValue("v_service_type_id", model.getTypeId()).addValue("v_deployment_id", model.getDeploymentId()) .addValue("v_control_name_prefix", model.getControlNamePrefix()) .addValue("v_control_name_uuid", model.getControlNameUuid()); Map out = logSqlExecution(procSetModel, in); @@ -227,19 +242,20 @@ public class CldsDao { model.setControlNameUuid((String) out.get("v_control_name_uuid")); model.setId((String) (out.get("v_model_id"))); model.setPropId((String) (out.get("v_model_prop_id"))); - model.setPropUserid((String) (out.get("v_model_prop_userid"))); + model.setPropUserid((String) (out.get("v_model_prop_user_id"))); model.setBlueprintId((String) (out.get("v_model_blueprint_id"))); - model.setBlueprintUserid((String) out.get("v_model_blueprint_userid")); + model.setBlueprintUserid((String) out.get("v_model_blueprint_user_id")); model.getEvent().setId((String) (out.get("v_event_id"))); model.getEvent().setActionCd((String) out.get("v_action_cd")); model.getEvent().setActionStateCd((String) out.get("v_action_state_cd")); model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id")); - model.getEvent().setUserid((String) out.get("v_event_userid")); + model.getEvent().setUserid((String) out.get("v_event_user_id")); return model; } /** - * Inserts new modelInstance in the database using parameter values and return updated model object. + * Inserts new modelInstance in the database using parameter values and + * return updated model object. * * @param model * @param modelInstancesList @@ -273,10 +289,12 @@ public class CldsDao { } /** - * Delete a list of modelInstance from the database using parameter values and returns updated model object. - * This method is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of - * deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that - * are still deployed with any not on the list considered undeployed. + * Delete a list of modelInstance from the database using parameter values + * and returns updated model object. This method is defunct - DCAE Proxy + * will not undeploy individual instances. It will send an empty list of + * deployed instances to indicate all have been removed. Or it will send an + * updated list to indicate those that are still deployed with any not on + * the list considered undeployed. * * @param controlNameUUid * @param modelInstancesList @@ -285,8 +303,7 @@ public class CldsDao { private CldsModel delModelInstance(String controlNameUUid, List modelInstancesList) { CldsModel model = new CldsModel(); for (CldsModelInstance currModelInstance : modelInstancesList) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_control_name_uuid", controlNameUUid) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_control_name_uuid", controlNameUUid) .addValue("v_vm_name", currModelInstance.getVmName()); Map out = logSqlExecution(procDelModelInstance, in); model.setId((String) (out.get("v_model_id"))); @@ -295,7 +312,9 @@ public class CldsDao { } /** - * Insert an event in the database - require either modelName or controlNamePrefix/controlNameUuid. + * Insert an event in the database - require either modelName or + * controlNamePrefix/controlNameUuid. + * * @param modelName * @param controlNamePrefix * @param controlNameUuid @@ -304,12 +323,9 @@ public class CldsDao { */ public CldsEvent insEvent(String modelName, String controlNamePrefix, String controlNameUuid, CldsEvent cldsEvent) { CldsEvent event = new CldsEvent(); - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_model_name", modelName) - .addValue("v_control_name_prefix", controlNamePrefix) - .addValue("v_control_name_uuid", controlNameUuid) - .addValue("v_userid", cldsEvent.getUserid()) - .addValue("v_action_cd", cldsEvent.getActionCd()) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName) + .addValue("v_control_name_prefix", controlNamePrefix).addValue("v_control_name_uuid", controlNameUuid) + .addValue("v_user_id", cldsEvent.getUserid()).addValue("v_action_cd", cldsEvent.getActionCd()) .addValue("v_action_state_cd", cldsEvent.getActionStateCd()) .addValue("v_process_instance_id", cldsEvent.getProcessInstanceId()); Map out = logSqlExecution(procInsEvent, in); @@ -324,8 +340,7 @@ public class CldsDao { * @return */ private String delAllModelInstances(String controlNameUUid) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_control_name_uuid", controlNameUUid); + SqlParameterSource in = new MapSqlParameterSource().addValue("v_control_name_uuid", controlNameUUid); Map out = logSqlExecution(procDelAllModelInstances, in); return (String) (out.get("v_model_id")); } @@ -337,8 +352,7 @@ public class CldsDao { * @param processInstanceId */ public void updEvent(String eventId, String processInstanceId) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_event_id", eventId) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_event_id", eventId) .addValue("v_process_instance_id", processInstanceId); logSqlExecution(procUpdEvent, in); } @@ -347,6 +361,7 @@ public class CldsDao { * Generic mapper for list of values */ private static final class ValueItemMapper implements RowMapper { + @Override public ValueItem mapRow(ResultSet rs, int rowNum) throws SQLException { ValueItem item = new ValueItem(); item.setValue(rs.getString(1)); @@ -358,6 +373,7 @@ public class CldsDao { * Generic mapper for CldsDBServiceCache */ private static final class CldsServiceDataMapper implements RowMapper { + @Override public CldsServiceData mapRow(ResultSet rs, int rowNum) throws SQLException { CldsServiceData cldsServiceData = new CldsServiceData(); long age; @@ -387,29 +403,28 @@ public class CldsDao { } /** - * Update template in the database using parameter values and return updated template object. + * Update template in the database using parameter values and return updated + * template object. * * @param template * @param userid * @return */ public CldsTemplate setTemplate(CldsTemplate template, String userid) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_template_name", template.getName()) - .addValue("v_userid", userid) - .addValue("v_template_bpmn_text", template.getBpmnText()) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", template.getName()) + .addValue("v_user_id", userid).addValue("v_template_bpmn_text", template.getBpmnText()) .addValue("v_template_image_text", template.getImageText()) .addValue("v_template_doc_text", template.getPropText()); Map out = logSqlExecution(procSetTemplate, in); template.setId((String) (out.get("v_template_id"))); - template.setBpmnUserid((String) (out.get("v_template_bpmn_userid"))); + template.setBpmnUserid((String) (out.get("v_template_bpmn_user_id"))); template.setBpmnId((String) (out.get("v_template_bpmn_id"))); template.setBpmnText((String) (out.get("v_template_bpmn_text"))); template.setImageId((String) (out.get("v_template_image_id"))); - template.setImageUserid((String) out.get("v_template_image_userid")); + template.setImageUserid((String) out.get("v_template_image_user_id")); template.setImageText((String) out.get("v_template_image_text")); template.setPropId((String) (out.get("v_template_doc_id"))); - template.setPropUserid((String) out.get("v_template_doc_userid")); + template.setPropUserid((String) out.get("v_template_doc_user_id")); template.setPropText((String) out.get("v_template_doc_text")); return template; } @@ -436,24 +451,26 @@ public class CldsDao { SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", templateName); Map out = logSqlExecution(procGetTemplate, in); template.setId((String) (out.get("v_template_id"))); - template.setBpmnUserid((String) (out.get("v_template_bpmn_userid"))); + template.setBpmnUserid((String) (out.get("v_template_bpmn_user_id"))); template.setBpmnId((String) (out.get("v_template_bpmn_id"))); template.setBpmnText((String) (out.get("v_template_bpmn_text"))); template.setImageId((String) (out.get("v_template_image_id"))); - template.setImageUserid((String) out.get("v_template_image_userid")); + template.setImageUserid((String) out.get("v_template_image_user_id")); template.setImageText((String) out.get("v_template_image_text")); template.setPropId((String) (out.get("v_template_doc_id"))); - template.setPropUserid((String) out.get("v_template_doc_userid")); + template.setPropUserid((String) out.get("v_template_doc_user_id")); template.setPropText((String) out.get("v_template_doc_text")); return template; } - public CldsServiceData getCldsServiceCache(String invariantUUID) throws SQLException, IOException, ClassNotFoundException { + public CldsServiceData getCldsServiceCache(String invariantUUID) + throws SQLException, IOException, ClassNotFoundException { CldsServiceData cldsServiceData = null; List cldsServiceDataList = new ArrayList<>(); try { String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? "; - cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[]{invariantUUID}, new CldsServiceDataMapper()); + cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID }, + new CldsServiceDataMapper()); logger.info("value of cldsServiceDataList: {}", cldsServiceDataList); } catch (EmptyResultDataAccessException e) { logger.info("cache row not found for invariantUUID: {}", invariantUUID); @@ -462,24 +479,29 @@ public class CldsDao { } public void setCldsServiceCache(CldsDBServiceCache cldsDBServiceCache) throws SQLException, IOException { - if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null && cldsDBServiceCache.getServiceId() != null) { - String invariantUUID = cldsDBServiceCache.getInvariantId(); - String serviceUUID = cldsDBServiceCache.getServiceId(); + if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null + && cldsDBServiceCache.getServiceId() != null) { + String invariantUuid = cldsDBServiceCache.getInvariantId(); + String serviceUuid = cldsDBServiceCache.getServiceId(); InputStream is = cldsDBServiceCache.getCldsDataInstream(); - String insertCldsServiceCacheSQL = "INSERT INTO clds_service_cache" + String insertCldsServiceCacheSql = "INSERT INTO clds_service_cache" + "(invariant_service_id,service_id,timestamp,object_data) VALUES" + "(?,?,CURRENT_TIMESTAMP,?) ON DUPLICATE KEY UPDATE invariant_service_id = VALUES(invariant_service_id) , timestamp = CURRENT_TIMESTAMP , object_data = VALUES(object_data) "; - jdbcTemplateObject.update(insertCldsServiceCacheSQL, invariantUUID, serviceUUID, is); + jdbcTemplateObject.update(insertCldsServiceCacheSql, invariantUuid, serviceUuid, is); } } private static Map logSqlExecution(SimpleJdbcCall call, SqlParameterSource source) { - try { - return call.execute(source); - } catch (Exception e) { - logger.error("Exception occured in " + source.getClass().getCanonicalName() + ": " + e); - throw e; - } + try { + return call.execute(source); + } catch (Exception e) { + logger.error("Exception occured in " + source.getClass().getCanonicalName() + ": " + e); + throw e; + } + } + + public void doHealthCheck() throws SQLException, IOException { + jdbcTemplateObject.execute(healthcheck); } } diff --git a/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java b/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java index 41023acec..6aeadc546 100644 --- a/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java +++ b/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java @@ -23,18 +23,19 @@ package org.onap.clamp.clds.exception; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + import com.att.ajsc.common.AjscProvider; import com.att.ajsc.common.exception.ServerErrorException; import com.att.ajsc.common.exception.ServiceException; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; - @AjscProvider public class AjscExceptionMapper implements ExceptionMapper { @Override public Response toResponse(final Exception exception) { - return exception instanceof ServiceException ? ((ServiceException) exception).toResponse() : new ServerErrorException(exception.getMessage()).toResponse(); + return exception instanceof ServiceException ? ((ServiceException) exception).toResponse() + : new ServerErrorException(exception.getMessage()).toResponse(); } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Collector.java b/src/main/java/org/onap/clamp/clds/model/prop/Collector.java index 84bc38f0c..bcb9cf01d 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Collector.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Collector.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,15 +23,18 @@ package org.onap.clamp.clds.model.prop; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; -import java.util.logging.Logger; - /** * Parse Collector json properties. */ public class Collector extends ModelElement { - private static final Logger logger = Logger.getLogger(Collector.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Collector.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private static final String TYPE_COLLECTOR = "collector"; /** * Parse Collector given json node. @@ -44,4 +47,8 @@ public class Collector extends ModelElement { topicPublishes = getValueByName("topicPublishes"); } + public static final String getType() { + return TYPE_COLLECTOR; + } + } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Global.java b/src/main/java/org/onap/clamp/clds/model/prop/Global.java index f8986b361..2fb7d5040 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Global.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Global.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,23 +23,29 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse global json properties. *

- * Example json: "global":[{"name":"service","value":["vUSP"]},{"name":"vnf","value":["vCTS","v3CDB"]},{"name":"location","value":["san_diego","san_antonio","kansas_city","kings_mountain","Secaucus","lisle","concord","houston","akron"]}] + * Example json: + * "global":[{"name":"service","value":["vUSP"]},{"name":"vnf","value":["vCTS", + * "v3CDB"]},{"name":"location","value":["san_diego","san_antonio","kansas_city" + * ,"kings_mountain","Secaucus","lisle","concord","houston","akron"]}] */ public class Global { - private static final Logger logger = Logger.getLogger(Global.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Global.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String service; - private List resourceVf; - private List resourceVfc; - private List location; + private String service; + private String actionSet; + private List resourceVf; + private List resourceVfc; + private List location; /** * Parse global given json node. @@ -49,6 +55,7 @@ public class Global { public Global(JsonNode modelJson) { JsonNode globalNode = modelJson.get("global"); service = ModelElement.getValueByName(globalNode, "service"); + actionSet = ModelElement.getValueByName(globalNode, "actionSet"); resourceVf = ModelElement.getValuesByName(globalNode, "vf"); resourceVfc = ModelElement.getValuesByName(globalNode, "vfc"); location = ModelElement.getValuesByName(globalNode, "location"); @@ -62,12 +69,20 @@ public class Global { } /** - * @param service the service to set + * @param service + * the service to set */ public void setService(String service) { this.service = service; } + /** + * @return the actionSet + */ + public String getActionSet() { + return actionSet; + } + /** * @return the resourceVf */ @@ -76,7 +91,8 @@ public class Global { } /** - * @param resourceVf the resourceVf to set + * @param resourceVf + * the resourceVf to set */ public void setResourceVf(List resourceVf) { this.resourceVf = resourceVf; @@ -90,7 +106,8 @@ public class Global { } /** - * @param resourceVfc the resourceVfc to set + * @param resourceVfc + * the resourceVfc to set */ public void setResourceVfc(List resourceVfc) { this.resourceVfc = resourceVfc; @@ -104,7 +121,8 @@ public class Global { } /** - * @param location the location to set + * @param location + * the location to set */ public void setLocation(List location) { this.location = location; diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java index b4cc11dc2..63a03058d 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,6 +23,18 @@ package org.onap.clamp.clds.model.prop; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.onap.clamp.clds.service.CldsService; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; @@ -30,18 +42,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import java.io.IOException; -import java.util.*; -import java.util.Map.Entry; -import java.util.logging.Logger; - /** * Parse Model BPMN properties. *

- * Example json: {"collector":[{"id":"Collector_11r50j1", "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"}],"policy":[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} + * Example json: {"collector":[{"id":"Collector_11r50j1", + * "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"}],"policy" + * :[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} */ public class ModelBpmn { - private static final Logger logger = Logger.getLogger(ModelBpmn.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(CldsService.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); // for each type, an array of entries private final Map> entriesByType = new HashMap<>(); @@ -65,7 +76,8 @@ public class ModelBpmn { ModelBpmn modelBpmn = new ModelBpmn(); ObjectMapper objectMapper = new ObjectMapper(); ObjectNode root = objectMapper.readValue(modelBpmnPropText, ObjectNode.class); - // iterate over each entry like: "collector":[{"id":"Collector_11r50j1","from":"StartEvent_1"}] + // iterate over each entry like: + // "collector":[{"id":"Collector_11r50j1","from":"StartEvent_1"}] Iterator> entryItr = root.fields(); List bpmnElementIdList = new ArrayList<>(); while (entryItr.hasNext()) { @@ -73,7 +85,8 @@ public class ModelBpmn { Entry entry = entryItr.next(); String type = entry.getKey(); ArrayNode arrayNode = (ArrayNode) entry.getValue(); - // process each id/from object, like: {"id":"Collector_11r50j1","from":"StartEvent_1"} + // process each id/from object, like: + // {"id":"Collector_11r50j1","from":"StartEvent_1"} for (JsonNode anArrayNode : arrayNode) { ObjectNode node = (ObjectNode) anArrayNode; String id = node.get("id").asText(); @@ -110,8 +123,8 @@ public class ModelBpmn { } /** - * - * + * + * * @param type * @return true if the element is found or false otherwise */ @@ -123,14 +136,22 @@ public class ModelBpmn { * @return the id field given the ModelElement type */ public String getId(String type) { - return entriesByType.get(type).get(0).getId(); + String modelElementId = ""; + if (entriesByType.get(type) != null) { + modelElementId = entriesByType.get(type).get(0).getId(); + } + return modelElementId; } /** * @return the fromId field given the ModelElement type */ public String getFromId(String type) { - return entriesByType.get(type).get(0).getFromId(); + String modelElementFromIdId = ""; + if (entriesByType.get(type) != null) { + modelElementFromIdId = entriesByType.get(type).get(0).getFromId(); + } + return modelElementFromIdId; } /** diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java index 8002f447f..210795be4 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,22 +23,27 @@ package org.onap.clamp.clds.model.prop; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Model BPMN property entry *

- * Example json: {"collector":[{"id":"Collector_11r50j1", "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"],"policy":[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} + * Example json: {"collector":[{"id":"Collector_11r50j1", + * "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"],"policy": + * [{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} */ public class ModelBpmnEntry { - private static final Logger logger = Logger.getLogger(ModelBpmnEntry.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelBpmnEntry.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String type; - private String id; - private String fromId; + private String type; + private String id; + private String fromId; /** - * Parse the json so that the "id" and "from" fields can be retrieved on demand. + * Parse the json so that the "id" and "from" fields can be retrieved on + * demand. * * @param type * @param id @@ -58,7 +63,8 @@ public class ModelBpmnEntry { } /** - * @param type the type to set + * @param type + * the type to set */ public void setType(String type) { this.type = type; @@ -72,7 +78,8 @@ public class ModelBpmnEntry { } /** - * @param id the id to set + * @param id + * the id to set */ public void setId(String id) { this.id = id; @@ -86,7 +93,8 @@ public class ModelBpmnEntry { } /** - * @param fromId the fromId to set + * @param fromId + * the fromId to set */ public void setFromId(String fromId) { this.fromId = fromId; diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java index d8e903060..ed038db66 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,38 +23,37 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Provide base ModelElement functionality. */ public abstract class ModelElement { - private final static Logger sLOGGER = Logger.getLogger(ModelElement.class.getName()); - private static final Logger logger = Logger.getLogger(ModelElement.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelElement.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - public static final String TYPE_COLLECTOR = "collector"; - public static final String TYPE_STRING_MATCH = "stringMatch"; - public static final String TYPE_POLICY = "policy"; - public static final String TYPE_TCA = "tca"; + public static final String TYPE_POLICY = "policy"; + public static final String TYPE_TCA = "tca"; - private final String type; - private final ModelBpmn modelBpmn; - private final String id; - protected String topicPublishes; - protected final JsonNode meNode; - private boolean isFound; + private final String type; + private final ModelBpmn modelBpmn; + private final String id; + protected String topicPublishes; + protected final JsonNode meNode; + private boolean isFound; - private final ModelProperties modelProp; + private final ModelProperties modelProp; /** * Perform base parsing of properties for a ModelElement (such as, * Collector, StringMatch, Policy and Tca) - * + * * @param type * @param modelProp * @param modelBpmn @@ -117,9 +116,9 @@ public abstract class ModelElement { } } if (value == null || value.length() == 0) { - sLOGGER.warning(name + "=" + value); + logger.warn(name + "=" + value); } else { - sLOGGER.fine(name + "=" + value); + logger.debug(name + "=" + value); } return value; } @@ -157,9 +156,9 @@ public abstract class ModelElement { } } if (values == null || values.size() == 0) { - sLOGGER.warning(name + "=" + values); + logger.warn(name + "=" + values); } else { - sLOGGER.fine(name + "=" + values); + logger.debug(name + "=" + values); } return values; } @@ -228,5 +227,4 @@ public abstract class ModelElement { public boolean isFound() { return isFound; } - } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java index 014b8c77e..1cfd46165 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,38 +23,62 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.CldsModel; -import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.clamp.clds.service.CldsService; -import java.io.IOException; -import java.util.List; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; /** * Parse model properties. */ public class ModelProperties { - private static final Logger logger = Logger.getLogger(ModelProperties.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(CldsService.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance() + .getAuditLogger(); + + private ModelBpmn modelBpmn; + private JsonNode modelJson; + + private final String modelName; + private final String controlName; + private final String actionCd; + // Flag indicate whether it is triggered by Validation Test button from UI + private final boolean isTest; + + private Global global; + private Tca tca; - private ModelBpmn modelBpmn; - private JsonNode modelJson; + private final Map modelElements = new ConcurrentHashMap<>(); - private final String modelName; - private final String controlName; - private final String actionCd; + private String currentModelElementId; + private String policyUniqueId; - private Global global; - private Collector collector; - private StringMatch stringMatch; - private Policy policy; - private Tca tca; + private static final Object lock = new Object(); + private static Map, String> modelElementClasses = new ConcurrentHashMap<>(); - private String currentModelElementId; - private String policyUniqueId; + static { + synchronized (lock) { + modelElementClasses.put(Collector.class, Collector.getType()); + modelElementClasses.put(Policy.class, Policy.getType()); + modelElementClasses.put(StringMatch.class, StringMatch.getType()); + modelElementClasses.put(Tca.class, Tca.getType()); + } + } /** * Retain data required to parse the ModelElement objects. (Rather than @@ -63,18 +87,53 @@ public class ModelProperties { * @param modelName * @param controlName * @param actionCd + * @param isTest * @param modelBpmnPropText * @param modelPropText * @throws JsonProcessingException * @throws IOException */ - public ModelProperties(String modelName, String controlName, String actionCd, String modelBpmnPropText, String modelPropText) throws IOException { + public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, String modelBpmnPropText, + String modelPropText) throws IOException { this.modelName = modelName; this.controlName = controlName; this.actionCd = actionCd; + this.isTest = isTest; modelBpmn = ModelBpmn.create(modelBpmnPropText); - ObjectMapper mapper = new ObjectMapper(); - modelJson = mapper.readTree(modelPropText); + modelJson = new ObjectMapper().readTree(modelPropText); + + instantiateMissingModelElements(); + } + + /** + * This method is meant to ensure that one ModelElement instance exists for + * each ModelElement class. + * + * As new ModelElement classes could have been registered after + * instantiation of this ModelProperties, we need to build the missing + * ModelElement instances. + */ + private final void instantiateMissingModelElements() { + if (modelElementClasses.size() != modelElements.size()) { + Set missingTypes = new HashSet<>(modelElementClasses.values()); + missingTypes.removeAll(modelElements.keySet()); + // Parse the list of base Model Elements and build up the + // ModelElements + modelElementClasses.entrySet().stream().parallel() + .filter(entry -> (ModelElement.class.isAssignableFrom(entry.getKey()) + && missingTypes.contains(entry.getValue()))) + .forEach(entry -> { + try { + modelElements.put(entry.getValue(), + (entry.getKey() + .getConstructor(ModelProperties.class, ModelBpmn.class, JsonNode.class) + .newInstance(this, modelBpmn, modelJson))); + } catch (InstantiationException | NoSuchMethodException | IllegalAccessException + | InvocationTargetException e) { + logger.warn("Unable to instantiate a ModelElement, exception follows: " + e); + } + }); + } } /** @@ -109,13 +168,15 @@ public class ModelProperties { * @throws IOException */ public static ModelProperties create(DelegateExecution execution) throws IOException { - String modelProp = (String) execution.getVariable("modelProp"); + // String modelProp = (String) execution.getVariable("modelProp"); + String modelProp = new String((byte[]) execution.getVariable("modelProp")); String modelBpmnProp = (String) execution.getVariable("modelBpmnProp"); String modelName = (String) execution.getVariable("modelName"); String controlName = (String) execution.getVariable("controlName"); String actionCd = (String) execution.getVariable("actionCd"); + boolean isTest = (boolean)execution.getVariable("isTest"); - return new ModelProperties(modelName, controlName, actionCd, modelBpmnProp, modelProp); + return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp); } /** @@ -125,24 +186,11 @@ public class ModelProperties { * @return */ public ModelElement getModelElementByType(String type) { - ModelElement me; - switch (type) { - case ModelElement.TYPE_COLLECTOR: - me = getCollector(); - break; - case ModelElement.TYPE_STRING_MATCH: - me = getStringMatch(); - break; - case ModelElement.TYPE_POLICY: - me = getPolicy(); - break; - case ModelElement.TYPE_TCA: - me = getTca(); - break; - default: - throw new IllegalArgumentException("Invalid ModelElement type: " + type); + ModelElement modelElement = modelElements.get(type); + if (modelElement == null) { + throw new IllegalArgumentException("Invalid or not found ModelElement type: " + type); } - return me; + return modelElement; } /** @@ -180,6 +228,13 @@ public class ModelProperties { return normalizePolicyScopeName(modelName + "." + getCurrentPolicyName()); } + /** + * @return the policyScopeAndNameWithUniqueId + */ + public String getPolicyScopeAndNameWithUniqueId() { + return normalizePolicyScopeName(modelName + "." + getCurrentPolicyName() + "_" + policyUniqueId); + } + /** * @return the currentPolicyScopeAndFullPolicyName */ @@ -233,7 +288,7 @@ public class ModelProperties { /** * When generating a policy request for a model element, must set the unique * id of that policy using this method. Used to generate the policy name. - * + * * @param policyUniqueId * the policyUniqueId to set */ @@ -241,16 +296,6 @@ public class ModelProperties { this.policyUniqueId = policyUniqueId; } - /** - * @return the collector - */ - public Collector getCollector() { - if (collector == null) { - collector = new Collector(this, modelBpmn, modelJson); - } - return collector; - } - /** * @return the actionCd */ @@ -258,6 +303,13 @@ public class ModelProperties { return actionCd; } + /** + * @return the isTest + */ + public boolean isTest() { + return isTest; + } + /** * @return the isCreateRequest */ @@ -288,24 +340,17 @@ public class ModelProperties { return global; } - /** - * @return the stringMatch - */ - public StringMatch getStringMatch() { - if (stringMatch == null) { - stringMatch = new StringMatch(this, modelBpmn, modelJson); + public static final synchronized void registerModelElement(Class modelElementClass, + String type) { + if (!modelElementClasses.containsKey(modelElementClass.getClass())) { + modelElementClasses.put(modelElementClass, type); } - return stringMatch; } - /** - * @return the policy - */ - public Policy getPolicy() { - if (policy == null) { - policy = new Policy(this, modelBpmn, modelJson); - } - return policy; + public T getType(Class clazz) { + instantiateMissingModelElements(); + String type = modelElementClasses.get(clazz); + return (type != null ? (T) modelElements.get(type) : null); } /** diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java index 729eb4381..6673af213 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,23 +23,38 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse Policy json properties. *

- * Example json: "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]}],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":["vf3RtPi"]}]]}] + * Example json: + * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[ + * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{ + * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{ + * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]} + * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""] + * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""] + * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]} + * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]} + * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS" + * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[ + * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ + * "vf3RtPi"]}]]}] */ public class Policy extends ModelElement { - private static final Logger logger = Logger.getLogger(Policy.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private final Integer timeout; - private final List policyItems; + private List policyChains; + + private static final String TYPE_POLICY = "policy"; /** * Parse Policy given json node. @@ -49,30 +64,27 @@ public class Policy extends ModelElement { * @param modelJson */ public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(TYPE_POLICY, modelProp, modelBpmn, modelJson); - timeout = getIntValueByName(meNode.get(0), "timeout"); + super(ModelElement.TYPE_POLICY, modelProp, modelBpmn, modelJson); // process policies - JsonNode policyNode = meNode.get(1).get("policyConfigurations"); - Iterator itr = policyNode.elements(); - policyItems = new ArrayList<>(); - while (itr.hasNext()) { - policyItems.add(new PolicyItem(itr.next())); + if (meNode != null) { + Iterator itr = meNode.elements(); + policyChains = new ArrayList(); + while (itr.hasNext()) { + policyChains.add(new PolicyChain(itr.next())); + } } } /** - * @return the timeout + * @return the policyChains */ - public Integer getTimeout() { - return timeout; + public List getPolicyChains() { + return policyChains; } - /** - * @return the policyItems - */ - public List getPolicyItems() { - return policyItems; + public static final String getType() { + return TYPE_POLICY; } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java index a943f1840..d1729cda1 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,25 +23,40 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse policyConfigurations from Policy json properties. *

- * Example json: "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]}],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":["vf3RtPi"]}]]}] + * Example json: + * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[ + * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{ + * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{ + * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]} + * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""] + * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""] + * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]} + * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]} + * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS" + * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[ + * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ + * "vf3RtPi"]}]]}] */ -public class PolicyItem { - private static final Logger logger = Logger.getLogger(Policy.class.getName()); +public class PolicyItem implements Cloneable { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private final String id; - private final String recipe; - private final int maxRetries; - private final int retryTimeLimit; - private final String parentPolicy; - private final List parentPolicyConditions; + private String id; + private String recipe; + private int maxRetries; + private int retryTimeLimit; + private String parentPolicy; + private List parentPolicyConditions; + private String actor; /** * Parse Policy given json node. @@ -72,6 +87,48 @@ public class PolicyItem { return recipe; } + /** + * @set the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * @set the recipe + */ + public void setRecipe(String recipe) { + this.recipe = recipe; + } + + /** + * @set the parentPolicy + */ + public void setParentPolicy(String parentPolicy) { + this.parentPolicy = parentPolicy; + } + + /** + * @set the maxRetries + */ + public void setMaxRetries(int maxRetries) { + this.maxRetries = maxRetries; + } + + /** + * @set the retryTimeLimit + */ + public void setRetryTimeLimit(int retryTimeLimit) { + this.retryTimeLimit = retryTimeLimit; + } + + /** + * @set the parentPolicyConditions + */ + public void setParentPolicyConditions(List parentPolicyConditions) { + this.parentPolicyConditions = parentPolicyConditions; + } + /** * @return the maxRetries */ @@ -100,4 +157,22 @@ public class PolicyItem { return parentPolicyConditions; } + /** + * @return the actor + */ + public String getActor() { + return actor; + } + + /** + * @set the actor + */ + public void setActor(String actor) { + this.actor = actor; + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java b/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java index 498f852e9..186cc2192 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,32 +23,59 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse serviceConfigurations from StringMatch json properties. *

- * Example json: "StringMatch_0c2cy0c":[[{"name":"topicPublishes","value":"DCAE-CL-EVENT"}],{"serviceConfigurations":[[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VNFNAME","LOCID"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Initial"]},{"name":"outputEventName","value":["OnSet"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}],[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VMID","Identiy","VNFNAME"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Close"]},{"name":"outputEventName","value":["Abatement"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}]]}] + * Example json: + * {"StringMatch_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{ + * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value": + * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name" + * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name" + * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value": + * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name": + * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{ + * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[ + * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[ + * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]} + * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]}, + * {"name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ABATED"]}]]}]}} + * */ public class ServiceConfiguration { - private static final Logger logger = Logger.getLogger(ServiceConfiguration.class.getName()); - - private final List aaiMatchingFields; - private final List aaiSendFields; - private final String groupNumber; - private final List resourceVf; - private final List resourceVfc; - private final String timeWindow; - private final String ageLimit; - private final String createClosedLoopEventId; - private final String outputEventName; + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ServiceConfiguration.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private final List aaiMatchingFields; + private final List aaiSendFields; + // private final String groupNumber; + private final List resourceVf; + private final List resourceVfc; + private final String timeWindow; + private final String ageLimit; + private final String createClosedLoopEventId; + private final String outputEventName; private final Map stringSet; /** @@ -59,7 +86,7 @@ public class ServiceConfiguration { public ServiceConfiguration(JsonNode node) { aaiMatchingFields = ModelElement.getValuesByName(node, "aaiMatchingFields"); aaiSendFields = ModelElement.getValuesByName(node, "aaiSendFields"); - groupNumber = ModelElement.getValueByName(node, "groupNumber"); + // groupNumber = ModelElement.getValueByName(node, "groupNumber"); resourceVf = ModelElement.getValuesByName(node, "vf"); resourceVfc = ModelElement.getValuesByName(node, "vfc"); timeWindow = ModelElement.getValueByName(node, "timeWindow"); @@ -77,7 +104,7 @@ public class ServiceConfiguration { String value = ssNode.path("value").path(0).asText(); if (key.length() != 0 && value.length() != 0) { // only add string set field if not null - logger.fine("stringSet: " + key + "=" + value); + logger.debug("stringSet: " + key + "=" + value); stringSet.put(key, value); } } @@ -99,11 +126,9 @@ public class ServiceConfiguration { /** * @return the groupNumber - */ - public String getGroupNumber() { - return groupNumber; - } - + */ /* + * public String getGroupNumber() { return groupNumber; } + */ /** * @return the resourceVf */ diff --git a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java index d7092c4e6..b20db0aff 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,22 +23,51 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse StringMatch json properties. *

- * Example json: "StringMatch_0c2cy0c":[[{"name":"topicPublishes","value":"DCAE-CL-EVENT"}],{"serviceConfigurations":[[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VNFNAME","LOCID"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Initial"]},{"name":"outputEventName","value":["OnSet"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}],[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VMID","Identiy","VNFNAME"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Close"]},{"name":"outputEventName","value":["Abatement"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}]]}] + * Example json: + * {"StringMatch_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{ + * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value": + * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name" + * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name" + * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value": + * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name": + * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{ + * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[ + * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[ + * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]} + * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]}, + * {"name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ABATED"]}]]}]}} + * */ public class StringMatch extends ModelElement { - private static final Logger logger = Logger.getLogger(StringMatch.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(StringMatch.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private final List serviceConfigurations; + private List resourceGroups; + + private static final String TYPE_STRING_MATCH = "stringMatch"; /** * Parse StringMatch given json node. @@ -47,24 +76,27 @@ public class StringMatch extends ModelElement { * @param modelJson */ public StringMatch(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(ModelElement.TYPE_STRING_MATCH, modelProp, modelBpmn, modelJson); - - topicPublishes = getValueByName(meNode.get(0), "topicPublishes"); + super(TYPE_STRING_MATCH, modelProp, modelBpmn, modelJson); // process Server_Configurations - JsonNode serviceConfigurationsNode = meNode.get(1).get("serviceConfigurations"); - Iterator itr = serviceConfigurationsNode.elements(); - serviceConfigurations = new ArrayList<>(); - while (itr.hasNext()) { - serviceConfigurations.add(new ServiceConfiguration(itr.next())); + if (meNode != null) { + Iterator itr = meNode.elements(); + resourceGroups = new ArrayList(); + while (itr.hasNext()) { + resourceGroups.add(new ResourceGroup(itr.next())); + } } } /** - * @return the serviceConfigurations + * @return the resourceGroups */ - public List getServiceConfigurations() { - return serviceConfigurations; + public List getResourceGroups() { + return resourceGroups; + } + + public static final String getType() { + return TYPE_STRING_MATCH; } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java index c7b23608a..b94f52304 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java @@ -1,47 +1,88 @@ +/*- + * ============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.model.prop; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; /** * Parse Tca json properties. - * - * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}} - * + * + * Example json: + * {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab", + * "value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value" + * :"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{ + * "name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1", + * ">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value": + * "Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"}, + * {"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name": + * "tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{ + * "serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">" + * ,"2"]]}]}} + * * */ public class Tca extends ModelElement { - - private static final Logger logger = Logger.getLogger(StringMatch.class.getName()); - - private List tcaItems; - - /** - * Parse Tca given json node - * - * @param modelProp - * @param modelBpmn - * @param modelJson - */ - public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(ModelElement.TYPE_TCA, modelProp, modelBpmn, modelJson); - - // process Server_Configurations - if(meNode != null){ - Iterator itr = meNode.elements(); - tcaItems = new ArrayList(); - while(itr.hasNext()) { - tcaItems.add(new TcaItem(itr.next())); - } - } - } - - public List getTcaItems() { - return tcaItems; - } + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private List tcaItems; + + private static final String TYPE_TCA = "tca"; + + /** + * Parse Tca given json node + * + * @param modelProp + * @param modelBpmn + * @param modelJson + */ + public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(TYPE_TCA, modelProp, modelBpmn, modelJson); + + // process Server_Configurations + if (meNode != null) { + Iterator itr = meNode.elements(); + tcaItems = new ArrayList(); + while (itr.hasNext()) { + tcaItems.add(new TcaItem(itr.next())); + } + } + } + + public List getTcaItems() { + return tcaItems; + } + + public static final String getType() { + return TYPE_TCA; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java b/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java index 5792c0574..aa1abde17 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java @@ -1,128 +1,163 @@ +/*- + * ============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.model.prop; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; /** * Parse Tca Item json properties. - * - * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}} - * + * + * Example json: + * {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab", + * "value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value" + * :"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{ + * "name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1", + * ">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value": + * "Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"}, + * {"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name": + * "tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{ + * "serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">" + * ,"2"]]}]}} + * * */ public class TcaItem { - private static final Logger logger = Logger.getLogger(TcaItem.class.getName()); - - private String tcaName; - private String tcaUuId; - private String nfNamingCode; - private String tcaEnable; - private String policyId; - private Integer interval; - private String severity; - private Integer violations; - private List tcaThreshholds; - - /** - * Parse Tca Item given json node - * - * @param node - */ - public TcaItem(JsonNode node) { - - tcaName = ModelElement.getValueByName(node, "tname"); - tcaUuId = ModelElement.getValueByName(node, "tuuid"); - nfNamingCode = ModelElement.getValueByName(node, "tnfc"); - tcaEnable = ModelElement.getValueByName(node, "tcaEnab"); - policyId = ModelElement.getValueByName(node, "tcaPolId"); - if(ModelElement.getValueByName(node, "tcaInt") != null){ - interval = Integer.valueOf(ModelElement.getValueByName(node, "tcaInt")); - } - severity = ModelElement.getValueByName(node, "tcaSev"); - if(ModelElement.getValueByName(node, "tcaVio") != null){ - violations = Integer.valueOf(ModelElement.getValueByName(node, "tcaVio")); - } - - // process service Configurations - JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); - Iterator itr = serviceConfigurationsNode.elements(); - tcaThreshholds = new ArrayList(); - while(itr.hasNext()) { - tcaThreshholds.add(new TcaThreshhold(itr.next())); - } - } - - public String getTcaName() { - return tcaName; - } - - public void setTcaName(String tcaName) { - this.tcaName = tcaName; - } - - public String getTcaUuId() { - return tcaUuId; - } - - public void setTcaUuId(String tcaUuId) { - this.tcaUuId = tcaUuId; - } - - public String getNfNamingCode() { - return nfNamingCode; - } - - public void setNfNamingCode(String nfNamingCode) { - this.nfNamingCode = nfNamingCode; - } - - public String getTcaEnable() { - return tcaEnable; - } - - public void setTcaEnable(String tcaEnable) { - this.tcaEnable = tcaEnable; - } - - public String getPolicyId() { - return policyId; - } - - public void setPolicyId(String policyId) { - this.policyId = policyId; - } - - public Integer getInterval() { - return interval; - } - - public void setInterval(Integer interval) { - this.interval = interval; - } - - public String getSeverity() { - return severity; - } - - public void setSeverity(String severity) { - this.severity = severity; - } - - public Integer getViolations() { - return violations; - } - - public void setViolations(Integer violations) { - this.violations = violations; - } - - public List getTcaThreshholds() { - return tcaThreshholds; - } - + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaItem.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String tcaName; + private String tcaUuId; + private String nfNamingCode; + private String tcaEnable; + private String policyId; + private Integer interval; + private String severity; + private Integer violations; + private List tcaThreshholds; + + /** + * Parse Tca Item given json node + * + * @param node + */ + public TcaItem(JsonNode node) { + + tcaName = ModelElement.getValueByName(node, "tname"); + tcaUuId = ModelElement.getValueByName(node, "tuuid"); + nfNamingCode = ModelElement.getValueByName(node, "tnfc"); + tcaEnable = ModelElement.getValueByName(node, "tcaEnab"); + policyId = ModelElement.getValueByName(node, "tcaPolId"); + if (ModelElement.getValueByName(node, "tcaInt") != null) { + interval = Integer.valueOf(ModelElement.getValueByName(node, "tcaInt")); + } + severity = ModelElement.getValueByName(node, "tcaSev"); + if (ModelElement.getValueByName(node, "tcaVio") != null) { + violations = Integer.valueOf(ModelElement.getValueByName(node, "tcaVio")); + } + + // process service Configurations + JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); + Iterator itr = serviceConfigurationsNode.elements(); + tcaThreshholds = new ArrayList(); + while (itr.hasNext()) { + tcaThreshholds.add(new TcaThreshhold(itr.next())); + } + } + + public String getTcaName() { + return tcaName; + } + + public void setTcaName(String tcaName) { + this.tcaName = tcaName; + } + + public String getTcaUuId() { + return tcaUuId; + } + + public void setTcaUuId(String tcaUuId) { + this.tcaUuId = tcaUuId; + } + + public String getNfNamingCode() { + return nfNamingCode; + } + + public void setNfNamingCode(String nfNamingCode) { + this.nfNamingCode = nfNamingCode; + } + + public String getTcaEnable() { + return tcaEnable; + } + + public void setTcaEnable(String tcaEnable) { + this.tcaEnable = tcaEnable; + } + + public String getPolicyId() { + return policyId; + } + + public void setPolicyId(String policyId) { + this.policyId = policyId; + } + + public Integer getInterval() { + return interval; + } + + public void setInterval(Integer interval) { + this.interval = interval; + } + + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public Integer getViolations() { + return violations; + } + + public void setViolations(Integer violations) { + this.violations = violations; + } + + public List getTcaThreshholds() { + return tcaThreshholds; + } + } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java b/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java index 47f2c6fd5..39369f171 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java @@ -1,76 +1,110 @@ -package org.onap.clamp.clds.model.prop; +/*- + * ============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. + */ -import java.util.logging.Logger; +package org.onap.clamp.clds.model.prop; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; /** * Parse Tca Threshhold json properties. - * - * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}} - * + * + * Example json: + * {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab", + * "value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value" + * :"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{ + * "name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1", + * ">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value": + * "Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"}, + * {"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name": + * "tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{ + * "serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">" + * ,"2"]]}]}} + * * */ public class TcaThreshhold { - private static final Logger logger = Logger.getLogger(TcaThreshhold.class.getName()); - - private String metric; - private String fieldPath; - private String operator; - private Integer threshhold; - - /** - * Parse Tca Threshhold given json node - * - * @param node - */ - public TcaThreshhold(JsonNode node) { - - if(node.get(0) != null){ - metric = node.get(0).asText(); - } - if(node.get(1) != null){ - operator = node.get(1).asText(); - } - if(node.get(2) != null){ - threshhold = Integer.valueOf(node.get(2).asText()); - } - if(node.get(3) != null){ - fieldPath = node.get(3).asText(); - } - } - - public String getMetric() { - return metric; - } - - public void setMetric(String metric) { - this.metric = metric; - } - - public String getFieldPath() { - return fieldPath; - } - - public void setFieldPath(String fieldPath) { - this.fieldPath = fieldPath; - } - - public String getOperator() { - return operator; - } - - public void setOperator(String operator) { - this.operator = operator; - } - - public Integer getThreshhold() { - return threshhold; - } - - public void setThreshhold(Integer threshhold) { - this.threshhold = threshhold; - } - + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaThreshhold.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String metric; + private String fieldPath; + private String operator; + private Integer threshhold; + + /** + * Parse Tca Threshhold given json node + * + * @param node + */ + public TcaThreshhold(JsonNode node) { + + if (node.get(0) != null) { + metric = node.get(0).asText(); + } + if (node.get(1) != null) { + operator = node.get(1).asText(); + } + if (node.get(2) != null) { + threshhold = Integer.valueOf(node.get(2).asText()); + } + if (node.get(3) != null) { + fieldPath = node.get(3).asText(); + } + } + + public String getMetric() { + return metric; + } + + public void setMetric(String metric) { + this.metric = metric; + } + + public String getFieldPath() { + return fieldPath; + } + + public void setFieldPath(String fieldPath) { + this.fieldPath = fieldPath; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public Integer getThreshhold() { + return threshhold; + } + + public void setThreshhold(Integer threshhold) { + this.threshhold = threshhold; + } + } -- cgit 1.2.3-korg From 5a7bab3cf8dcc44ce306828619d09d43998174f0 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 03:09:34 -0700 Subject: Rework the CldsService (rest apis) Rework the Rest APis + Xsl transformer Change-Id: Icd9ae214c7c457b208235b4815729659ce8524a9 Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- .../org/onap/clamp/clds/model/refprop/RefProp.java | 61 +- .../org/onap/clamp/clds/service/CldsService.java | 661 ++++++++++++++++----- .../clamp/clds/service/CldsTemplateService.java | 200 +++++-- .../onap/clamp/clds/service/SecureServiceBase.java | 134 ++++- .../clds/service/SecureServicePermission.java | 70 ++- .../onap/clamp/clds/transform/TransformUtil.java | 12 +- .../onap/clamp/clds/transform/XslTransformer.java | 14 +- .../clamp/clds/workflow/LogMessageDelegate.java | 32 +- .../clds/workflow/ProcessRequestDelegate.java | 28 +- .../clamp/clds/workflow/RestMessageDelegate.java | 45 +- 10 files changed, 891 insertions(+), 366 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java b/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java index c81b6a770..3b1f9682f 100644 --- a/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java +++ b/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,34 +23,38 @@ package org.onap.clamp.clds.model.refprop; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationContext; -import org.springframework.core.io.Resource; - -import javax.annotation.PostConstruct; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Properties; -import java.util.logging.Logger; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; +import org.springframework.core.io.Resource; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; /** * Holds reference properties. */ public class RefProp { - private static final Logger logger = Logger.getLogger(RefProp.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(RefProp.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); @Autowired - private ApplicationContext appContext; - - private Properties prop; + private ApplicationContext appContext; + + private Properties prop; @Value("${org.onap.clamp.config.files.cldsReference:'classpath:/clds/clds-reference.properties'}") - private String cldsReferenceValuesFile; + private String cldsReferenceValuesFile; /** * Load reference properties via null constructor @@ -59,9 +63,9 @@ public class RefProp { */ public RefProp() throws IOException { } - + @PostConstruct - public void loadConfig () throws IOException { + public void loadConfig() throws IOException { prop = new Properties(); Resource resource = appContext.getResource(cldsReferenceValuesFile); prop.load(resource.getInputStream()); @@ -78,7 +82,8 @@ public class RefProp { } /** - * get property value for a combo key (key1 + "." + key2). If not found just use key1. + * get property value for a combo key (key1 + "." + key2). If not found just + * use key1. * * @param key1 * @param key2 @@ -105,7 +110,8 @@ public class RefProp { } /** - * Return json as objects that can be updated. First try with combo key (key1 + "." + key2), otherwise default to just key1. + * Return json as objects that can be updated. First try with combo key + * (key1 + "." + key2), otherwise default to just key1. * * @param key1 * @param key2 @@ -118,7 +124,8 @@ public class RefProp { } /** - * Get list of values for a property field containing json and a field/keyword within that json. + * Get list of values for a property field containing json and a + * field/keyword within that json. * * @param fieldName * @param value 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 a0aadccb5..aaeb03f60 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,87 +23,145 @@ package org.onap.clamp.clds.service; -import com.att.ajsc.common.AjscService; -import com.att.ajsc.filemonitor.AJSCPropertiesMap; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; +import java.io.IOException; +import java.io.InputStream; +import java.sql.SQLException; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import javax.annotation.PostConstruct; +import javax.ws.rs.Consumes; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.NotAuthorizedException; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; + +import org.apache.commons.lang3.StringUtils; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.jboss.resteasy.spi.BadRequestException; +import org.onap.clamp.clds.client.DcaeDispatcherServices; +import org.onap.clamp.clds.client.DcaeInventoryServices; import org.onap.clamp.clds.client.SdcCatalogServices; import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.model.CldsDBServiceCache; +import org.onap.clamp.clds.model.CldsEvent; +import org.onap.clamp.clds.model.CldsHealthCheck; +import org.onap.clamp.clds.model.CldsInfo; +import org.onap.clamp.clds.model.CldsModel; +import org.onap.clamp.clds.model.CldsSdcResource; +import org.onap.clamp.clds.model.CldsSdcServiceDetail; +import org.onap.clamp.clds.model.CldsSdcServiceInfo; +import org.onap.clamp.clds.model.CldsServiceData; +import org.onap.clamp.clds.model.CldsTemplate; +import org.onap.clamp.clds.model.DcaeEvent; +import org.onap.clamp.clds.model.ValueItem; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; import org.onap.clamp.clds.transform.XslTransformer; -import org.apache.commons.lang3.StringUtils; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.jboss.resteasy.spi.BadRequestException; -import org.onap.clamp.clds.model.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; -import org.springframework.core.io.Resource; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; +import com.att.ajsc.common.AjscService; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; /** * Service to save and retrieve the CLDS model attributes. */ @AjscService +@Api(value = "/clds", description = "Clds operations") @Path("/clds") public class CldsService extends SecureServiceBase { @Autowired - private ApplicationContext appContext; + private ApplicationContext appContext; + + private static final String RESOURCE_NAME = "clds-version.properties"; + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + @Value("${CLDS_PERMISSION_TYPE_CL:permission-type-cl}") + private String cldsPersmissionTypeCl; + + @Value("${CLDS_PERMISSION_TYPE_CL_MANAGE:permission-type-cl-manage}") + private String cldsPermissionTypeClManage; - private static final Logger logger = LoggerFactory.getLogger(CldsService.class); + @Value("${CLDS_PERMISSION_TYPE_CL_EVENT:permission-type-cl-event}") + private String cldsPermissionTypeClEvent; - @Value("${CLDS_PERMISSION_TYPE_CL:org.onap.clamp.clds.cl}") - private static String CLDS_PERMISSION_TYPE_CL; + @Value("${CLDS_PERMISSION_TYPE_FILTER_VF:permission-type-filter-vf}") + private String cldsPermissionTypeFilterVf; - @Value("${CLDS_PERMISSION_TYPE_CL_MANAGE:org.onap.clamp.clds.cl.manage}") - private static String CLDS_PERMISSION_TYPE_CL_MANAGE; + @Value("${CLDS_PERMISSION_TYPE_TEMPLATE:permission-type-template}") + private String cldsPermissionTypeTemplate; - @Value("${CLDS_PERMISSION_TYPE_CL_EVENT:/META-INF/securityFilterRules.json}") - private static String CLDS_PERMISSION_TYPE_CL_EVENT; + @Value("${CLDS_PERMISSION_INSTANCE:dev}") + private String cldsPermissionInstance; - @Value("${CLDS_PERMISSION_TYPE_FILTER_VF:/META-INF/securityFilterRules.json}") - private static String CLDS_PERMISSION_TYPE_FILTER_VF; + private SecureServicePermission permissionReadCl; - @Value("${CLDS_PERMISSION_INSTANCE:/META-INF/securityFilterRules.json}") - private static String CLDS_PERMISSION_INSTANCE; + private SecureServicePermission permissionUpdateCl; - private static final SecureServicePermission PERMISSION_READ_CL = SecureServicePermission.create(CLDS_PERMISSION_TYPE_CL, CLDS_PERMISSION_INSTANCE, "read"); + private SecureServicePermission permissionReadTemplate; - private static final SecureServicePermission PERMISSION_UPDATE_CL = SecureServicePermission.create(CLDS_PERMISSION_TYPE_CL, CLDS_PERMISSION_INSTANCE, "update"); + private SecureServicePermission permissionUpdateTemplate; - @Value("${org.onap.clamp.config.files.globalClds:classpath:/clds/globalClds.properties}") - private String globalClds; - private Properties globalCldsProperties; + @PostConstruct + private final void afterConstruction() { + permissionReadCl = SecureServicePermission.create(cldsPersmissionTypeCl, cldsPermissionInstance, "read"); + permissionUpdateCl = SecureServicePermission.create(cldsPersmissionTypeCl, cldsPermissionInstance, "update"); + permissionReadTemplate = SecureServicePermission.create(cldsPermissionTypeTemplate, cldsPermissionInstance, + "read"); + permissionUpdateTemplate = SecureServicePermission.create(cldsPermissionTypeTemplate, cldsPermissionInstance, + "update"); + } + + @Value("${org.onap.clamp.config.files.globalClds:'classpath:/clds/globalClds.properties'}") + private String globalClds; + private Properties globalCldsProperties; + + @Autowired + private CldsDao cldsDao; @Autowired - private CldsDao cldsDao; + private RuntimeService runtimeService; @Autowired - private RuntimeService runtimeService; + private XslTransformer cldsBpmnTransformer; + + @Autowired + private RefProp refProp; + @Autowired - private XslTransformer cldsBpmnTransformer; + private SdcCatalogServices sdcCatalogServices; @Autowired - private RefProp refProp; + private DcaeDispatcherServices dcaeDispatcherServices; @Autowired - private SdcCatalogServices asdcCatalogServices; - // + private DcaeInventoryServices dcaeInventoryServices; public CldsService() { } @@ -112,79 +170,186 @@ public class CldsService extends SecureServiceBase { this.refProp = refProp; } + /* + * + * 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") + @Produces(MediaType.APPLICATION_JSON) + public CldsInfo getCldsInfo() { + + CldsInfo cldsInfo = new CldsInfo(); + + // Get the user info + cldsInfo.setUserName(getUserName()); + + // Get CLDS application version + String cldsVersion = ""; + Properties props = new Properties(); + InputStream resourceStream = null; + + try { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + resourceStream = loader.getResourceAsStream(RESOURCE_NAME); + props.load(resourceStream); + cldsVersion = props.getProperty("clds.version"); + } catch (Exception ex) { + ex.printStackTrace(); + } finally { + if (resourceStream != null) { + try { + resourceStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + cldsInfo.setCldsVersion(cldsVersion); + + // Get the user list of permissions + cldsInfo.setPermissionReadCl(isAuthorized(permissionReadCl)); + cldsInfo.setPermissionUpdateCl(isAuthorized(permissionUpdateCl)); + cldsInfo.setPermissionReadTemplate(isAuthorized(permissionReadTemplate)); + cldsInfo.setPermissionUpdateTemplate(isAuthorized(permissionUpdateTemplate)); + return cldsInfo; + } + + @GET + @Path("/healthcheck") + @Produces(MediaType.APPLICATION_JSON) + public CldsHealthCheck gethealthcheck() { + + CldsHealthCheck cldsHealthCheck = new CldsHealthCheck(); + + try { + cldsDao.doHealthCheck(); + cldsHealthCheck.setHealthCheckComponent("CLDS-APP"); + cldsHealthCheck.setHealthCheckStatus("UP"); + cldsHealthCheck.setDescription("OK"); + } catch (SQLException e) { + logger.error("CLAMP application DB Error" + e); + cldsHealthCheck.setHealthCheckComponent("CLDS-APP"); + cldsHealthCheck.setHealthCheckStatus("DOWN"); + cldsHealthCheck.setDescription("NOT-OK"); + // return Response.status(500).entity("Database down for CLDS + // application").build(); + } catch (Exception e) { + logger.error("CLAMP application DB Error" + e); + cldsHealthCheck.setHealthCheckComponent("CLDS-APP"); + cldsHealthCheck.setHealthCheckStatus("DOWN"); + cldsHealthCheck.setDescription("NOT-OK"); + // return Response.status(500).entity("Database down for CLDS + // application").build(); + } + + return cldsHealthCheck; + + } + /** * REST service that retrieves BPMN for a CLDS model name from the database. - * This is subset of the json getModel. - * This is only expected to be used for testing purposes, not by the UI. + * This is subset of the json getModel. This is only expected to be used for + * testing purposes, not by the UI. * * @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) public String getBpmnXml(@PathParam("modelName") String modelName) { - isAuthorized(PERMISSION_READ_CL); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: GET model bpmn", getPrincipalName()); + isAuthorized(permissionReadCl); logger.info("GET bpmnText for modelName={}", modelName); CldsModel model = CldsModel.retrieve(cldsDao, modelName, false); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get model bpmn success", this.getClass().getName()); + auditLogger.info("GET model bpmn completed"); return model.getBpmnText(); } /** * REST service that saves BPMN for a CLDS model by name in the database. - * This is subset of the json putModel. - * This is only expected to be used for testing purposes, not by the UI. + * This is subset of the json putModel. This is only expected to be used for + * testing purposes, not by the UI. * * @param modelName */ + @ApiOperation(value = "Saves BPMN for a CLDS model by name in the database", notes = "This is only expected to be used for testing purposes, not by the UI", response = String.class) @PUT @Path("/model/bpmn/{modelName}") @Consumes(MediaType.TEXT_XML) public String putBpmnXml(@PathParam("modelName") String modelName, String bpmnText) { - isAuthorized(PERMISSION_UPDATE_CL); + LoggingUtils.setRequestContext("CldsService: PUT model bpmn", getPrincipalName()); + isAuthorized(permissionUpdateCl); logger.info("PUT bpmnText for modelName={}", modelName); logger.info("PUT bpmnText={}", bpmnText); CldsModel cldsModel = CldsModel.retrieve(cldsDao, modelName, true); cldsModel.setBpmnText(bpmnText); - cldsModel.save(cldsDao, getUserid()); + cldsModel.save(cldsDao, getUserId()); + // audit log + LoggingUtils.setTimeContext(new Date(), new Date()); + LoggingUtils.setResponseContext("0", "Put model bpmn success", this.getClass().getName()); + auditLogger.info("PUT model bpmn completed"); return "wrote bpmnText for modelName=" + modelName; } /** - * REST service that retrieves image for a CLDS model name from the database. - * This is subset of the json getModel. - * This is only expected to be used for testing purposes, not by the UI. + * REST service that retrieves image for a CLDS model name from the + * database. This is subset of the json getModel. This is only expected to + * be used for testing purposes, not by the UI. * * @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) public String getImageXml(@PathParam("modelName") String modelName) { - isAuthorized(PERMISSION_READ_CL); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: GET model image", getPrincipalName()); + isAuthorized(permissionReadCl); logger.info("GET imageText for modelName={}", modelName); CldsModel model = CldsModel.retrieve(cldsDao, modelName, false); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get model image success", this.getClass().getName()); + auditLogger.info("GET model image completed"); return model.getImageText(); } /** * REST service that saves image for a CLDS model by name in the database. - * This is subset of the json putModel. - * This is only expected to be used for testing purposes, not by the UI. + * This is subset of the json putModel. This is only expected to be used for + * testing purposes, not by the UI. * * @param modelName */ + @ApiOperation(value = "Saves image for a CLDS model by name in the database", notes = "This is only expected to be used for testing purposes, not by the UI", response = String.class) @PUT @Path("/model/image/{modelName}") @Consumes(MediaType.TEXT_XML) public String putImageXml(@PathParam("modelName") String modelName, String imageText) { - isAuthorized(PERMISSION_UPDATE_CL); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: PUT model image", getPrincipalName()); + isAuthorized(permissionUpdateCl); logger.info("PUT iamgeText for modelName={}", modelName); logger.info("PUT imageText={}", imageText); CldsModel cldsModel = CldsModel.retrieve(cldsDao, modelName, true); cldsModel.setImageText(imageText); - cldsModel.save(cldsDao, getUserid()); + cldsModel.save(cldsDao, getUserId()); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Put model image success", this.getClass().getName()); + auditLogger.info("PUT model image completed"); return "wrote imageText for modelName=" + modelName; } @@ -195,14 +360,38 @@ public class CldsService extends SecureServiceBase { * @return clds model - clds model for the given model name * @throws NotAuthorizedException */ + @ApiOperation(value = "Retrieves a CLDS model by name from the database", notes = "", response = String.class) @GET @Path("/model/{modelName}") @Produces(MediaType.APPLICATION_JSON) public CldsModel getModel(@PathParam("modelName") String modelName) throws NotAuthorizedException { - isAuthorized(PERMISSION_READ_CL); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: GET model", getPrincipalName()); + isAuthorized(permissionReadCl); logger.debug("GET model for modelName={}", modelName); CldsModel cldsModel = CldsModel.retrieve(cldsDao, modelName, false); isAuthorizedForVf(cldsModel); + cldsModel.setUserAuthorizedToUpdate(isAuthorizedNoException(permissionUpdateCl)); + + /** + * Checking condtion 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 + */ + dcaeInventoryServices.setEventInventory(cldsModel, getUserId()); + } catch (Exception e) { + LoggingUtils.setErrorContext("900", "Set event inventory error"); + logger.error("getModel set event Inventory error:" + e); + } + } + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get model success", this.getClass().getName()); + auditLogger.info("GET model completed"); return cldsModel; } @@ -213,12 +402,16 @@ public class CldsService extends SecureServiceBase { * @throws TransformerException * @throws TransformerConfigurationException */ + @ApiOperation(value = "Saves a CLDS model by name in the database", notes = "", response = String.class) @PUT @Path("/model/{modelName}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public CldsModel putModel(@PathParam("modelName") String modelName, CldsModel cldsModel) throws TransformerException { - isAuthorized(PERMISSION_UPDATE_CL); + public CldsModel putModel(@PathParam("modelName") String modelName, CldsModel cldsModel) + throws TransformerException { + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: PUT model", getPrincipalName()); + isAuthorized(permissionUpdateCl); isAuthorizedForVf(cldsModel); logger.info("PUT model for modelName={}", modelName); logger.info("PUT bpmnText={}", cldsModel.getBpmnText()); @@ -234,7 +427,12 @@ public class CldsService extends SecureServiceBase { cldsModel.setDocId(template.getPropId()); } } - cldsModel.save(cldsDao, getUserid()); + cldsModel.save(cldsDao, getUserId()); + cldsModel.save(cldsDao, getUserId()); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Put model success", this.getClass().getName()); + auditLogger.info("PUT model completed"); return cldsModel; } @@ -243,13 +441,21 @@ 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) public List getModelNames() { -// isAuthorized(PERMISSION_READ_CL); + // isAuthorized(permissionReadCl); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: GET model names", getPrincipalName()); logger.info("GET list of model names"); - return cldsDao.getBpmnNames(); + List names = cldsDao.getBpmnNames(); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get model names success", this.getClass().getName()); + auditLogger.info("GET model names completed"); + return names; } /** @@ -260,22 +466,26 @@ public class CldsService extends SecureServiceBase { * @param test * @param model * @return - * @throws TransformerConfigurationException - * @throws TransformerException - * @throws IOException + * @throws Exception * @throws JsonProcessingException * @throws NotAuthorizedException */ + @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) @Produces(MediaType.APPLICATION_JSON) - public CldsModel putModelAndProcessAction(@PathParam("action") String action, @PathParam("modelName") String modelName, @QueryParam("test") String test, CldsModel model) throws TransformerException, NotAuthorizedException, IOException { + public CldsModel putModelAndProcessAction(@PathParam("action") String action, + @PathParam("modelName") String modelName, @QueryParam("test") String test, CldsModel model) + throws Exception { + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: Process model action", getPrincipalName()); String actionCd = action.toUpperCase(); - SecureServicePermission permisionManage = SecureServicePermission.create(CLDS_PERMISSION_TYPE_CL_MANAGE, CLDS_PERMISSION_INSTANCE, actionCd); + SecureServicePermission permisionManage = SecureServicePermission.create(cldsPermissionTypeClManage, + cldsPermissionInstance, actionCd); isAuthorized(permisionManage); isAuthorizedForVf(model); - String userid = getUserid(); + String userid = getUserId(); String actionStateCd = CldsEvent.ACTION_STATE_INITIATED; String processDefinitionKey = "clds-process-action-wf"; @@ -287,6 +497,8 @@ public class CldsService extends SecureServiceBase { logger.info("PUT bpmnText={}", model.getBpmnText()); logger.info("PUT propText={}", model.getPropText()); logger.info("PUT userid={}", userid); + logger.info("PUT getTypeId={}", model.getTypeId()); + logger.info("PUT deploymentId={}", model.getDeploymentId()); if (model.getTemplateName() != null) { CldsTemplate template = cldsDao.getTemplate(model.getTemplateName()); @@ -298,7 +510,7 @@ public class CldsService extends SecureServiceBase { } // save model to db model.setName(modelName); - model.save(cldsDao, getUserid()); + model.save(cldsDao, getUserId()); // get vars and format if necessary String prop = model.getPropText(); @@ -309,11 +521,14 @@ public class CldsService extends SecureServiceBase { String bpmnJson = cldsBpmnTransformer.doXslTransformToString(bpmn); logger.info("PUT bpmnJson={}", bpmnJson); + // Flag indicates whether it is triggered by Validation Test button from UI boolean isTest = false; if (test != null && test.equalsIgnoreCase("true")) { - isTest = true; + isTest = true; } else { - // if action.test.override is true, then any action will be marked as test=true (even if incoming action request had test=false); otherwise, test flag will be unchanged on the action request + // if action.test.override is true, then any action will be marked + // as test=true (even if incoming action request had test=false); + // otherwise, test flag will be unchanged on the action request String actionTestOverride = refProp.getStringValue("action.test.override"); if (actionTestOverride != null && actionTestOverride.equalsIgnoreCase("true")) { logger.info("PUT actionTestOverride={}", actionTestOverride); @@ -323,7 +538,6 @@ public class CldsService extends SecureServiceBase { } logger.info("PUT isTest={}", isTest); - boolean isInsertTestEvent = false; String insertTestEvent = refProp.getStringValue("action.insert.test.event"); if (insertTestEvent != null && insertTestEvent.equalsIgnoreCase("true")) { @@ -331,30 +545,45 @@ public class CldsService extends SecureServiceBase { } logger.info("PUT isInsertTestEvent={}", isInsertTestEvent); - // determine if requested action is permitted model.validateAction(actionCd); // input variables to camunda process Map variables = new HashMap<>(); variables.put("actionCd", actionCd); - variables.put("modelProp", prop); + variables.put("modelProp", prop.getBytes()); variables.put("modelBpmnProp", bpmnJson); variables.put("modelName", modelName); variables.put("controlName", controlName); - variables.put("docText", docText); + variables.put("docText", docText.getBytes()); variables.put("isTest", isTest); variables.put("userid", userid); variables.put("isInsertTestEvent", isInsertTestEvent); + logger.info("modelProp - " + prop); + logger.info("docText - " + docText); // start camunda process ProcessInstance pi = runtimeService.startProcessInstanceByKey(processDefinitionKey, variables); // log process info - logger.info("Started processDefinitionId={}, processInstanceId={}", pi.getProcessDefinitionId(), pi.getProcessInstanceId()); + logger.info("Started processDefinitionId={}, processInstanceId={}", pi.getProcessDefinitionId(), + pi.getProcessInstanceId()); // refresh model info from db (get fresh event info) - return CldsModel.retrieve(cldsDao, modelName, false); + CldsModel retreivedModel = CldsModel.retrieve(cldsDao, modelName, false); + + if (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT) + || actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT)) { + // To verify inventory status and modify model status to distribute + dcaeInventoryServices.setEventInventory(retreivedModel, getUserId()); + retreivedModel.save(cldsDao, getUserId()); + } + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Process model action success", this.getClass().getName()); + auditLogger.info("Process model action completed"); + + return retreivedModel; } /** @@ -364,29 +593,37 @@ public class CldsService extends SecureServiceBase { * @param dcaeEvent * @throws BadRequestException */ + @ApiOperation(value = "Accepts events for a model", notes = "", response = String.class) @POST @Path("/dcae/event") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String postDcaeEvent(@QueryParam("test") String test, DcaeEvent dcaeEvent) throws BadRequestException { + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: Post dcae event", getPrincipalName()); String userid = null; - // TODO: allow auth checking to be turned off by removing the permission type property - if (CLDS_PERMISSION_TYPE_CL_EVENT != null && CLDS_PERMISSION_TYPE_CL_EVENT.length() > 0) { - SecureServicePermission permissionEvent = SecureServicePermission.create(CLDS_PERMISSION_TYPE_CL_EVENT, CLDS_PERMISSION_INSTANCE, dcaeEvent.getEvent()); + // TODO: allow auth checking to be turned off by removing the permission + // type property + if (cldsPermissionTypeClEvent != null && cldsPermissionTypeClEvent.length() > 0) { + SecureServicePermission permissionEvent = SecureServicePermission.create(cldsPermissionTypeClEvent, + cldsPermissionInstance, dcaeEvent.getEvent()); isAuthorized(permissionEvent); - userid = getUserid(); + userid = getUserId(); } + // Flag indicates whether it is triggered by Validation Test button from UI boolean isTest = false; if (test != null && test.equalsIgnoreCase("true")) { - isTest = true; + isTest = true; } int instanceCount = 0; if (dcaeEvent.getInstances() != null) { instanceCount = dcaeEvent.getInstances().size(); } - String msgInfo = "event=" + dcaeEvent.getEvent() + " serviceUUID=" + dcaeEvent.getServiceUUID() + " resourceUUID=" + dcaeEvent.getResourceUUID() + " artifactName=" + dcaeEvent.getArtifactName() + " instance count=" + instanceCount + " isTest=" + isTest; + String msgInfo = "event=" + dcaeEvent.getEvent() + " serviceUUID=" + dcaeEvent.getServiceUUID() + + " resourceUUID=" + dcaeEvent.getResourceUUID() + " artifactName=" + dcaeEvent.getArtifactName() + + " instance count=" + instanceCount + " isTest=" + isTest; logger.info("POST dcae event {}", msgInfo); if (isTest) { @@ -395,38 +632,43 @@ public class CldsService extends SecureServiceBase { if (DcaeEvent.EVENT_DEPLOYMENT.equalsIgnoreCase(dcaeEvent.getEvent())) { CldsModel.insertModelInstance(cldsDao, dcaeEvent, userid); } else { - CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), CldsEvent.ACTION_STATE_RECEIVED, null); + CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userid, dcaeEvent.getCldsActionCd(), + CldsEvent.ACTION_STATE_RECEIVED, null); } - // EVENT_UNDEPLOYMENT is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of - // deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that - // are still deployed with any not on the list considered undeployed. - //else if(DcaeEvent.EVENT_UNDEPLOYMENT.equalsIgnoreCase(dcaeEvent.getEvent())) - //{ - // CldsModel.removeModelInstance(cldsDao, dcaeEvent); - //} } + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Post dcae event success", this.getClass().getName()); + auditLogger.info("Post dcae event completed"); return msgInfo; } /** - * REST service that retrieves asdc services + * REST service that retrieves sdc services * * @throws Exception */ + @ApiOperation(value = "Retrieves sdc services", notes = "", response = String.class) @GET - @Path("/asdc/services") + @Path("/sdc/services") @Produces(MediaType.APPLICATION_JSON) - public String getAsdcServices() throws Exception { + public String getSdcServices() throws Exception { + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: GET sdc services", getPrincipalName()); String retStr; try { - String responseStr = asdcCatalogServices.getAsdcServicesInformation(null); + String responseStr = sdcCatalogServices.getSdcServicesInformation(null); retStr = createUiServiceFormatJson(responseStr); } catch (Exception e) { logger.info("{} {}", e.getClass().getName(), e.getMessage()); throw e; } - logger.info("value of asdcServices : {}", retStr); + logger.info("value of sdcServices : {}", retStr); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName()); + auditLogger.info("GET sdc services completed"); return retStr; } @@ -435,39 +677,51 @@ public class CldsService extends SecureServiceBase { * * @throws Exception */ + @ApiOperation(value = "Retrieves total properties required by UI", notes = "", response = String.class) @GET @Path("/properties") @Produces(MediaType.APPLICATION_JSON) - public String getAsdcProperties() throws Exception { + public String getSdcProperties() throws Exception { return createPropertiesObjectByUUID(getGlobalCldsString(), "{}"); } /** - * REST service that retrieves total properties by using invariantUUID based on refresh and non refresh + * REST service that retrieves total properties by using invariantUUID based + * on refresh and non refresh * * @throws Exception */ + @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) - public String getAsdcPropertiesByServiceUUIDForRefresh(@PathParam("serviceInvariantUUID") String serviceInvariantUUID, @DefaultValue("false") @QueryParam("refresh") String refresh) throws Exception { + public String getSdcPropertiesByServiceUUIDForRefresh( + @PathParam("serviceInvariantUUID") String serviceInvariantUUID, + @DefaultValue("false") @QueryParam("refresh") String refresh) throws Exception { + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: GET sdc properties by uuid", getPrincipalName()); CldsServiceData cldsServiceData = new CldsServiceData(); cldsServiceData.setServiceInvariantUUID(serviceInvariantUUID); - boolean isCldsAsdcDataExpired = true; - // To getcldsService information from database cache using invariantUUID only when refresh = false + boolean isCldsSdcDataExpired = true; + // To getcldsService information from database cache using invariantUUID + // only when refresh = false if (refresh != null && refresh.equalsIgnoreCase("false")) { cldsServiceData = cldsServiceData.getCldsServiceCache(cldsDao, serviceInvariantUUID); - // If cldsService is available in database Cache , verify is data expired or not + // If cldsService is available in database Cache , verify is data + // expired or not if (cldsServiceData != null) { - isCldsAsdcDataExpired = asdcCatalogServices.isCldsAsdcCacheDataExpired(cldsServiceData); + isCldsSdcDataExpired = sdcCatalogServices.isCldsSdcCacheDataExpired(cldsServiceData); } } - // If user Requested for refresh or database cache expired , get all data from asdc api. - if ((refresh != null && refresh.equalsIgnoreCase("true")) || isCldsAsdcDataExpired) { - cldsServiceData = asdcCatalogServices.getCldsServiceDataWithAlarmConditions(serviceInvariantUUID); - CldsDBServiceCache cldsDBServiceCache = asdcCatalogServices.getCldsDBServiceCacheUsingCldsServiceData(cldsServiceData); - if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null && cldsDBServiceCache.getServiceId() != null) { + // If user Requested for refresh or database cache expired , get all + // data from sdc api. + if ((refresh != null && refresh.equalsIgnoreCase("true")) || isCldsSdcDataExpired) { + cldsServiceData = sdcCatalogServices.getCldsServiceDataWithAlarmConditions(serviceInvariantUUID); + CldsDBServiceCache cldsDBServiceCache = sdcCatalogServices + .getCldsDbServiceCacheUsingCldsServiceData(cldsServiceData); + if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null + && cldsDBServiceCache.getServiceId() != null) { cldsServiceData.setCldsServiceCache(cldsDao, cldsDBServiceCache); } } @@ -475,31 +729,39 @@ public class CldsService extends SecureServiceBase { // filter out VFs the user is not authorized for cldsServiceData.filterVfs(this); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get sdc properties by uuid success", this.getClass().getName()); + auditLogger.info("GET sdc properties by uuid completed"); + // format retrieved data into properties json - return asdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData); + return sdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData); } /** - * Determine if the user is authorized for a particular VF by its invariant UUID. + * Determine if the user is authorized for a particular VF by its invariant + * UUID. * * @param vfInvariantUuid * @throws NotAuthorizedException * @return */ public boolean isAuthorizedForVf(String vfInvariantUuid) throws NotAuthorizedException { - if (CLDS_PERMISSION_TYPE_FILTER_VF != null && CLDS_PERMISSION_TYPE_FILTER_VF.length() > 0) { - SecureServicePermission permission = SecureServicePermission.create(CLDS_PERMISSION_TYPE_FILTER_VF, CLDS_PERMISSION_INSTANCE, vfInvariantUuid); + if (cldsPermissionTypeFilterVf != null && cldsPermissionTypeFilterVf.length() > 0) { + SecureServicePermission permission = SecureServicePermission.create(cldsPermissionTypeFilterVf, + cldsPermissionInstance, vfInvariantUuid); return isAuthorized(permission); } else { - // if CLDS_PERMISSION_TYPE_FILTER_VF property is not provided, then VF filtering is turned off + // if CLDS_PERMISSION_TYPE_FILTER_VF property is not provided, then + // VF filtering is turned off logger.warn("VF filtering turned off"); return true; } } /** - * Determine if the user is authorized for a particular VF by its invariant UUID. - * If not authorized, then NotAuthorizedException is thrown. + * Determine if the user is authorized for a particular VF by its invariant + * UUID. If not authorized, then NotAuthorizedException is thrown. * * @param model * @return @@ -519,16 +781,18 @@ public class CldsService extends SecureServiceBase { return ""; } ObjectMapper objectMapper = new ObjectMapper(); - List rawList = objectMapper.readValue(responseStr, objectMapper.getTypeFactory().constructCollectionType(List.class, CldsAsdcServiceInfo.class)); + List rawList = objectMapper.readValue(responseStr, + objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcServiceInfo.class)); ObjectNode invariantIdServiceNode = objectMapper.createObjectNode(); ObjectNode serviceNode = objectMapper.createObjectNode(); logger.info("value of cldsserviceiNfolist: {}", rawList); if (rawList != null && rawList.size() > 0) { - List cldsAsdcServiceInfoList = asdcCatalogServices.removeDuplicateServices(rawList); + List cldsSdcServiceInfoList = sdcCatalogServices.removeDuplicateServices(rawList); - for (CldsAsdcServiceInfo currCldsAsdcServiceInfo : cldsAsdcServiceInfoList) { - if (currCldsAsdcServiceInfo != null) { - invariantIdServiceNode.put(currCldsAsdcServiceInfo.getInvariantUUID(), currCldsAsdcServiceInfo.getName()); + for (CldsSdcServiceInfo currCldsSdcServiceInfo : cldsSdcServiceInfoList) { + if (currCldsSdcServiceInfo != null) { + invariantIdServiceNode.put(currCldsSdcServiceInfo.getInvariantUUID(), + currCldsSdcServiceInfo.getName()); } } serviceNode.putPOJO("service", invariantIdServiceNode); @@ -538,9 +802,9 @@ public class CldsService extends SecureServiceBase { private String createPropertiesObjectByUUID(String globalProps, String cldsResponseStr) throws IOException { ObjectMapper mapper = new ObjectMapper(); - CldsAsdcServiceDetail cldsAsdcServiceDetail = mapper.readValue(cldsResponseStr, CldsAsdcServiceDetail.class); + CldsSdcServiceDetail cldsSdcServiceDetail = mapper.readValue(cldsResponseStr, CldsSdcServiceDetail.class); ObjectNode globalPropsJson = null; - if (cldsAsdcServiceDetail != null && cldsAsdcServiceDetail.getUuid() != null) { + if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getUuid() != null) { /** * to create json with vf, alarm and locations */ @@ -550,22 +814,22 @@ public class CldsService extends SecureServiceBase { /** * to create json with vf and vfresourceId */ - createVfObjectNode(vfObjectNode, mapper, cldsAsdcServiceDetail.getResources()); - serviceObjectNode.putPOJO(cldsAsdcServiceDetail.getInvariantUUID(), vfObjectNode); + createVfObjectNode(vfObjectNode, mapper, cldsSdcServiceDetail.getResources()); + serviceObjectNode.putPOJO(cldsSdcServiceDetail.getInvariantUUID(), vfObjectNode); ObjectNode byServiceBasicObjetNode = mapper.createObjectNode(); byServiceBasicObjetNode.putPOJO("byService", serviceObjectNode); /** * to create json with VFC Node */ - ObjectNode emptyvfcobjectNode = createByVFCObjectNode(mapper, cldsAsdcServiceDetail.getResources()); + ObjectNode emptyvfcobjectNode = createByVFCObjectNode(mapper, cldsSdcServiceDetail.getResources()); byServiceBasicObjetNode.putPOJO("byVf", emptyvfcobjectNode); globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); globalPropsJson.putPOJO("shared", byServiceBasicObjetNode); logger.info("valuie of objNode: {}", globalPropsJson); } else { /** - * to create json with total properties when no serviceUUID passed + * to create json with total properties when no serviceUUID passed */ globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); } @@ -584,19 +848,22 @@ public class CldsService extends SecureServiceBase { return emptyServiceObjectNode; } - private void createVfObjectNode(ObjectNode vfObjectNode2, ObjectMapper mapper, List rawCldsAsdcResourceList) throws IOException { + private void createVfObjectNode(ObjectNode vfObjectNode2, ObjectMapper mapper, + List rawCldsSdcResourceList) throws IOException { ObjectNode vfNode = mapper.createObjectNode(); vfNode.put("", ""); // To remove repeated resource instance name from resourceInstanceList - List cldsAsdcResourceList = asdcCatalogServices.removeDuplicateAsdcResourceInstances(rawCldsAsdcResourceList); + List cldsSdcResourceList = sdcCatalogServices + .removeDuplicateSdcResourceInstances(rawCldsSdcResourceList); /** - * Creating vf resource node using cldsAsdcResource Object + * Creating vf resource node using cldsSdcResource Object */ - if (cldsAsdcResourceList != null && cldsAsdcResourceList.size() > 0) { - for (CldsAsdcResource cldsAsdcResource : cldsAsdcResourceList) { - if (cldsAsdcResource != null && cldsAsdcResource.getResoucreType() != null && cldsAsdcResource.getResoucreType().equalsIgnoreCase("VF")) { - vfNode.put(cldsAsdcResource.getResourceUUID(), cldsAsdcResource.getResourceName()); + if (cldsSdcResourceList != null && cldsSdcResourceList.size() > 0) { + for (CldsSdcResource cldsSdcResource : cldsSdcResourceList) { + if (cldsSdcResource != null && cldsSdcResource.getResoucreType() != null + && cldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { + vfNode.put(cldsSdcResource.getResourceUUID(), cldsSdcResource.getResourceName()); } } } @@ -605,7 +872,7 @@ public class CldsService extends SecureServiceBase { String alarmStringValue = refProp.getStringValue("ui.alarm.default"); /** - * creating location json object using properties file value + * creating location json object using properties file value */ ObjectNode locationJsonNode = (ObjectNode) mapper.readValue(locationStringValue, JsonNode.class); vfObjectNode2.putPOJO("location", locationJsonNode); @@ -618,29 +885,111 @@ public class CldsService extends SecureServiceBase { vfObjectNode2.putPOJO("alarmCondition", alarmStringJsonNode); } - private ObjectNode createByVFCObjectNode(ObjectMapper mapper, List cldsAsdcResourceList) { + private ObjectNode createByVFCObjectNode(ObjectMapper mapper, List cldsSdcResourceList) { ObjectNode emptyObjectNode = mapper.createObjectNode(); ObjectNode emptyvfcobjectNode = mapper.createObjectNode(); ObjectNode vfCObjectNode = mapper.createObjectNode(); vfCObjectNode.putPOJO("vfC", emptyObjectNode); ObjectNode subVfCObjectNode = mapper.createObjectNode(); subVfCObjectNode.putPOJO("vfc", emptyObjectNode); - if (cldsAsdcResourceList != null && cldsAsdcResourceList.size() > 0) { - for (CldsAsdcResource cldsAsdcResource : cldsAsdcResourceList) { - if (cldsAsdcResource != null && cldsAsdcResource.getResoucreType() != null && cldsAsdcResource.getResoucreType().equalsIgnoreCase("VF")) { - vfCObjectNode.putPOJO(cldsAsdcResource.getResourceUUID(), subVfCObjectNode); + if (cldsSdcResourceList != null && cldsSdcResourceList.size() > 0) { + for (CldsSdcResource cldsSdcResource : cldsSdcResourceList) { + if (cldsSdcResource != null && cldsSdcResource.getResoucreType() != null + && cldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { + vfCObjectNode.putPOJO(cldsSdcResource.getResourceUUID(), subVfCObjectNode); } } } emptyvfcobjectNode.putPOJO("", vfCObjectNode); return emptyvfcobjectNode; } - + + @PUT + @Path("/deploy/{modelName}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public CldsModel deployModel(@PathParam("action") String action, @PathParam("modelName") String modelName, + @QueryParam("test") String test, CldsModel model) throws Exception { + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: Deploy model", getPrincipalName()); + String deploymentId = "closedLoop_" + UUID.randomUUID() + "_deploymentId"; + String createNewDeploymentStatusUrl = dcaeDispatcherServices.createNewDeployment(deploymentId, + model.getTypeId()); + String operationStatus = "processing"; + while (operationStatus.equalsIgnoreCase("processing")) { + operationStatus = dcaeDispatcherServices.getOperationStatus(createNewDeploymentStatusUrl); + } + if (operationStatus != null && operationStatus.equalsIgnoreCase("succeeded")) { + String artifactName = model.getControlName(); + if (artifactName != null) { + artifactName = artifactName + ".yml"; + } + DcaeEvent dcaeEvent = new DcaeEvent(); + /* set dcae events */ + dcaeEvent.setArtifactName(artifactName); + dcaeEvent.setEvent(DcaeEvent.EVENT_DEPLOYMENT); + CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), getUserId(), dcaeEvent.getCldsActionCd(), + CldsEvent.ACTION_STATE_RECEIVED, null); + model.setDeploymentId(deploymentId); + model.save(cldsDao, getUserId()); + } + else{ + logger.info("Deploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); + throw new Exception("Deploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); + } + logger.info("Deploy model (" + modelName + ") succeeded...Deployment Id is - " + deploymentId); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Deploy model success", this.getClass().getName()); + auditLogger.info("Deploy model completed"); + return model; + } + + @PUT + @Path("/undeploy/{modelName}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public CldsModel unDeployModel(@PathParam("action") String action, @PathParam("modelName") String modelName, + @QueryParam("test") String test, CldsModel model) throws Exception { + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsService: Undeploy model", getPrincipalName()); + String operationStatusUndeployUrl = dcaeDispatcherServices.deleteExistingDeployment(model.getDeploymentId(), + model.getTypeId()); + String operationStatus = "processing"; + while (operationStatus.equalsIgnoreCase("processing")) { + operationStatus = dcaeDispatcherServices.getOperationStatus(operationStatusUndeployUrl); + } + if (operationStatus != null && operationStatus.equalsIgnoreCase("succeeded")) { + String artifactName = model.getControlName(); + if (artifactName != null) { + artifactName = artifactName + ".yml"; + } + DcaeEvent dcaeEvent = new DcaeEvent(); + // set dcae events + dcaeEvent.setArtifactName(artifactName); + dcaeEvent.setEvent(DcaeEvent.EVENT_UNDEPLOYMENT); + CldsEvent.insEvent(cldsDao, model.getControlName(), getUserId(), dcaeEvent.getCldsActionCd(), + CldsEvent.ACTION_STATE_RECEIVED, null); + model.setDeploymentId(null); + model.save(cldsDao, getUserId()); + } + else{ + logger.info("Undeploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); + throw new Exception("Undeploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); + } + logger.info("Undeploy model (" + modelName + ") succeeded."); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Undeploy model success", this.getClass().getName()); + auditLogger.info("Undeploy model completed"); + return model; + } + private String getGlobalCldsString() throws Exception { - if (null == globalCldsProperties) { + if (null == globalCldsProperties) { globalCldsProperties = new Properties(); globalCldsProperties.load(appContext.getResource(globalClds).getInputStream()); - } - return (String) globalCldsProperties.get("globalCldsProps"); + } + return (String) globalCldsProperties.get("globalCldsProps"); } } 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 0ffa955c4..07b9bb98f 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,32 +23,43 @@ package org.onap.clamp.clds.service; -import com.att.ajsc.common.AjscService; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import java.io.IOException; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.annotation.PostConstruct; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.xml.transform.TransformerException; + +import org.camunda.bpm.engine.RuntimeService; import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.model.CldsTemplate; import org.onap.clamp.clds.model.ValueItem; import org.onap.clamp.clds.model.prop.ModelBpmn; import org.onap.clamp.clds.transform.XslTransformer; -import org.camunda.bpm.engine.RuntimeService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.xml.transform.TransformerException; -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; +import com.att.ajsc.common.AjscService; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; /** * Service to save and retrieve the CLDS model attributes. @@ -57,31 +68,44 @@ import java.util.Map.Entry; @Path("/cldsTempate") public class CldsTemplateService extends SecureServiceBase { - private static final Logger logger = LoggerFactory.getLogger(CldsTemplateService.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsTemplateService.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private static final String collectorKey = "Collector"; + private static final String stringMatchKey = "StringMatch"; + private static final String policyKey = "Policy"; + + @Value("${CLDS_PERMISSION_TYPE_TEMPLATE:permission-type-template}") + private String cldsPermissionTypeTemplate; - private static final String collectorKey = "Collector"; - private static final String stringMatchKey = "StringMatch"; - private static final String policyKey = "Policy"; + @Value("${CLDS_PERMISSION_INSTANCE:dev}") + private String cldsPermissionInstance; - private static final String CLDS_PERMISSION_TYPE_TEMPLATE = System.getProperty("CLDS_PERMISSION_TYPE_TEMPLATE"); - private static final String CLDS_PERMISSION_INSTANCE = System.getProperty("CLDS_PERMISSION_INSTANCE"); + private SecureServicePermission permissionReadTemplate; - private static final SecureServicePermission PERMISSION_READ_TEMPLATE = SecureServicePermission.create(CLDS_PERMISSION_TYPE_TEMPLATE, CLDS_PERMISSION_INSTANCE, "read"); - private static final SecureServicePermission PERMISSION_UPDATE_TEMPLATE = SecureServicePermission.create(CLDS_PERMISSION_TYPE_TEMPLATE, CLDS_PERMISSION_INSTANCE, "update"); + private SecureServicePermission permissionUpdateTemplate; + + @PostConstruct + private final void afterConstruction() { + permissionReadTemplate = SecureServicePermission.create(cldsPermissionTypeTemplate, cldsPermissionInstance, + "read"); + permissionUpdateTemplate = SecureServicePermission.create(cldsPermissionTypeTemplate, cldsPermissionInstance, + "update"); + } @Autowired - private CldsDao cldsDao; + private CldsDao cldsDao; @Autowired private RuntimeService runtimeService; @Autowired private XslTransformer cldsBpmnTransformer; - private static String userid; + private static String userid; /** - * REST service that retrieves BPMN for a CLDS template name from the database. - * This is subset of the json getModel. - * This is only expected to be used for testing purposes, not by the UI. + * REST service that retrieves BPMN for a CLDS template name from the + * database. This is subset of the json getModel. This is only expected to + * be used for testing purposes, not by the UI. * * @param templateName * @return bpmn xml text - content of bpmn given name @@ -90,16 +114,22 @@ public class CldsTemplateService extends SecureServiceBase { @Path("/template/bpmn/{templateName}") @Produces(MediaType.TEXT_XML) public String getBpmnTemplate(@PathParam("templateName") String templateName) { - isAuthorized(PERMISSION_READ_TEMPLATE); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsTemplateService: GET template bpmn", getPrincipalName()); + isAuthorized(permissionReadTemplate); logger.info("GET bpmnText for templateName=" + templateName); CldsTemplate template = CldsTemplate.retrieve(cldsDao, templateName, false); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get template bpmn success", this.getClass().getName()); + auditLogger.info("GET template bpmn completed"); return template.getBpmnText(); } /** * REST service that saves BPMN for a CLDS template by name in the database. - * This is subset of the json putModel. - * This is only expected to be used for testing purposes, not by the UI. + * This is subset of the json putModel. This is only expected to be used for + * testing purposes, not by the UI. * * @param templateName * @param bpmnText @@ -108,19 +138,25 @@ public class CldsTemplateService extends SecureServiceBase { @Path("/template/bpmn/{templateName}") @Consumes(MediaType.TEXT_XML) public String putBpmnTemplateXml(@PathParam("templateName") String templateName, String bpmnText) { - isAuthorized(PERMISSION_UPDATE_TEMPLATE); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsTemplateService: PUT template bpmn", getPrincipalName()); + isAuthorized(permissionUpdateTemplate); logger.info("PUT bpmnText for templateName=" + templateName); logger.info("PUT bpmnText=" + bpmnText); CldsTemplate cldsTemplate = CldsTemplate.retrieve(cldsDao, templateName, true); cldsTemplate.setBpmnText(bpmnText); cldsTemplate.save(cldsDao, userid); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Put template bpmn success", this.getClass().getName()); + auditLogger.info("PUT template bpm completed"); return "wrote bpmnText for templateName=" + templateName; } /** - * REST service that retrieves image for a CLDS template name from the database. - * This is subset of the json getModel. - * This is only expected to be used for testing purposes, not by the UI. + * REST service that retrieves image for a CLDS template name from the + * database. This is subset of the json getModel. This is only expected to + * be used for testing purposes, not by the UI. * * @param templateName * @return image xml text - content of image given name @@ -129,16 +165,22 @@ public class CldsTemplateService extends SecureServiceBase { @Path("/template/image/{templateName}") @Produces(MediaType.TEXT_XML) public String getImageXml(@PathParam("templateName") String templateName) { - isAuthorized(PERMISSION_READ_TEMPLATE); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsTemplateService: GET template image", getPrincipalName()); + isAuthorized(permissionReadTemplate); logger.info("GET imageText for templateName=" + templateName); CldsTemplate template = CldsTemplate.retrieve(cldsDao, templateName, false); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get template image success", this.getClass().getName()); + auditLogger.info("GET template image completed"); return template.getImageText(); } /** - * REST service that saves image for a CLDS template by name in the database. - * This is subset of the json putModel. - * This is only expected to be used for testing purposes, not by the UI. + * REST service that saves image for a CLDS template by name in the + * database. This is subset of the json putModel. This is only expected to + * be used for testing purposes, not by the UI. * * @param templateName * @param imageText @@ -147,12 +189,18 @@ public class CldsTemplateService extends SecureServiceBase { @Path("/template/image/{templateName}") @Consumes(MediaType.TEXT_XML) public String putImageXml(@PathParam("templateName") String templateName, String imageText) { - isAuthorized(PERMISSION_UPDATE_TEMPLATE); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsTemplateService: PUT template image", getPrincipalName()); + isAuthorized(permissionUpdateTemplate); logger.info("PUT iamgeText for modelName=" + templateName); logger.info("PUT imageText=" + imageText); CldsTemplate cldsTemplate = CldsTemplate.retrieve(cldsDao, templateName, true); cldsTemplate.setImageText(imageText); cldsTemplate.save(cldsDao, userid); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Put template image success", this.getClass().getName()); + auditLogger.info("PUT template image completed"); return "wrote imageText for modelName=" + templateName; } @@ -166,9 +214,17 @@ public class CldsTemplateService extends SecureServiceBase { @Path("/template/{templateName}") @Produces(MediaType.APPLICATION_JSON) public CldsTemplate getTemplate(@PathParam("templateName") String templateName) { - isAuthorized(PERMISSION_READ_TEMPLATE); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsTemplateService: GET template", getPrincipalName()); + isAuthorized(permissionReadTemplate); logger.info("GET model for templateName=" + templateName); - return CldsTemplate.retrieve(cldsDao, templateName, false); + CldsTemplate template = CldsTemplate.retrieve(cldsDao, templateName, false); + template.setUserAuthorizedToUpdate(isAuthorizedNoException(permissionUpdateTemplate)); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get template success", this.getClass().getName()); + auditLogger.info("GET template completed"); + return template; } /** @@ -183,8 +239,12 @@ public class CldsTemplateService extends SecureServiceBase { @Path("/template/{templateName}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public CldsTemplate putTemplate(@PathParam("templateName") String templateName, CldsTemplate cldsTemplate) throws TransformerException, IOException { - isAuthorized(PERMISSION_UPDATE_TEMPLATE); + public CldsTemplate putTemplate(@PathParam("templateName") String templateName, CldsTemplate cldsTemplate) + throws TransformerException, IOException { + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsTemplateService: PUT template", getPrincipalName()); + isAuthorized(permissionUpdateTemplate); + logger.info("PUT Template for templateName=" + templateName); logger.info("PUT bpmnText=" + cldsTemplate.getBpmnText()); logger.info("PUT propText=" + cldsTemplate.getPropText()); @@ -208,6 +268,12 @@ public class CldsTemplateService extends SecureServiceBase { logger.info(" Image Text : " + cldsTemplate.getImageText()); logger.info(" Prop Text : " + cldsTemplate.getPropText()); cldsTemplate.save(cldsDao, userid); + + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Put template success", this.getClass().getName()); + auditLogger.info("PUT template completed"); + return cldsTemplate; } @@ -220,15 +286,22 @@ public class CldsTemplateService extends SecureServiceBase { @Path("/template-names") @Produces(MediaType.APPLICATION_JSON) public List getTemplateNames() { - isAuthorized(PERMISSION_READ_TEMPLATE); + Date startTime = new Date(); + LoggingUtils.setRequestContext("CldsTemplateService: GET template names", getPrincipalName()); + isAuthorized(permissionReadTemplate); logger.info("GET list of template names"); - return cldsDao.getTemplateNames(); + List names = cldsDao.getTemplateNames(); + // audit log + LoggingUtils.setTimeContext(startTime, new Date()); + LoggingUtils.setResponseContext("0", "Get template names success", this.getClass().getName()); + auditLogger.info("GET template names completed"); + return names; } - - private Map getNewBpmnIdsMap(String bpmnText, String propText) throws TransformerException, IOException { + private Map getNewBpmnIdsMap(String bpmnText, String propText) + throws TransformerException, IOException { /** - * Test sample code start + * Test sample code start */ String bpmnJson = cldsBpmnTransformer.doXslTransformToString(bpmnText); ModelBpmn templateBpmn = ModelBpmn.create(bpmnJson); @@ -247,7 +320,8 @@ public class CldsTemplateService extends SecureServiceBase { for (String currElementId : bpmnElementIds) { if (keyPropName != null && keyPropName.equalsIgnoreCase(currElementId)) { ArrayNode arrayNode = (ArrayNode) entry.getValue(); - // process each id/from object, like: {"id":"Collector_11r50j1", "from":"StartEvent_1"} + // process each id/from object, like: + // {"id":"Collector_11r50j1", "from":"StartEvent_1"} for (JsonNode anArrayNode : arrayNode) { ObjectNode node = (ObjectNode) anArrayNode; String valueNode = node.get("value").asText(); @@ -268,7 +342,7 @@ public class CldsTemplateService extends SecureServiceBase { } logger.info("value of hashmap:" + bpmnIoIdsMap); /** - * Test sample code end + * Test sample code end */ return bpmnIoIdsMap; } diff --git a/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java index c17af97fa..89e6c092a 100644 --- a/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java +++ b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,31 +23,48 @@ package org.onap.clamp.clds.service; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.security.Principal; import javax.ws.rs.NotAuthorizedException; import javax.ws.rs.core.Context; import javax.ws.rs.core.SecurityContext; -import java.security.Principal; + +import org.onap.clamp.clds.util.LoggingUtils; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** - * Base/abstract Service class. - * Implements shared security methods. + * Base/abstract Service class. Implements shared security methods. */ public abstract class SecureServiceBase { - private static final Logger logger = LoggerFactory.getLogger(SecureServiceBase.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SecureServiceBase.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + // By default we'll set it to a default handler + private static UserNameHandler userNameHandler = new DefaultUserNameHandler(); @Context - private SecurityContext securityContext; + private SecurityContext securityContext; /** - * Get the userid + * Get the userId from AAF/CSP. * * @return */ - public String getUserid() { - return getPrincipalName(); + public String getUserId() { + return getUserName(); + } + + /** + * Get the Full name. + * + * @return + */ + public String getUserName() { + String name = userNameHandler.retrieveUserName(securityContext); + logger.debug("userName={}", name); + return name; } /** @@ -56,22 +73,22 @@ public abstract class SecureServiceBase { * @return */ public String getPrincipalName() { - Principal p = securityContext.getUserPrincipal(); + Principal principal = securityContext.getUserPrincipal(); String name = "Not found"; - if (p != null) { - name = p.getName(); + if (principal != null) { + name = principal.getName(); } logger.debug("userPrincipal.getName()={}", name); return name; } /** - * Check if user is authorized for the given the permission. - * Allow matches if user has a permission with an "*" in permission instance - * or permission action even if the permission to check has a specific value - * in those fields. For example: - * if the user has this permission: app-perm-type|*|* - * it will be authorized if the inPermission to check is: app-perm-type|dev|read + * Check if user is authorized for the given the permission. Allow matches + * if user has a permission with an "*" in permission instance or permission + * action even if the permission to check has a specific value in those + * fields. For example: if the user has this permission: app-perm-type|*|* + * it will be authorized if the inPermission to check is: + * app-perm-type|dev|read * * @param inPermission * @return @@ -80,26 +97,79 @@ public abstract class SecureServiceBase { public boolean isAuthorized(SecureServicePermission inPermission) throws NotAuthorizedException { boolean authorized = false; logger.debug("checking if {} has permission: {}", getPrincipalName(), inPermission); - // check if the user has the permission key or the permission key with a combination of all instance and/or all action. + // check if the user has the permission key or the permission key with a + // combination of all instance and/or all action. if (securityContext.isUserInRole(inPermission.getKey())) { logger.info("{} authorized for permission: {}", getPrincipalName(), inPermission.getKey()); authorized = true; - // the rest of these don't seem to be required - isUserInRole method appears to take * as a wildcard + // the rest of these don't seem to be required - isUserInRole method + // appears to take * as a wildcard } else if (securityContext.isUserInRole(inPermission.getKeyAllInstance())) { - logger.info("{} authorized because user has permission with * for instance: {}", getPrincipalName(), inPermission.getKey()); + logger.info("{} authorized because user has permission with * for instance: {}", getPrincipalName(), + inPermission.getKey()); authorized = true; } else if (securityContext.isUserInRole(inPermission.getKeyAllInstanceAction())) { - logger.info("{} authorized because user has permission with * for instance and * for action: {}", getPrincipalName(), inPermission.getKey()); + logger.info("{} authorized because user has permission with * for instance and * for action: {}", + getPrincipalName(), inPermission.getKey()); authorized = true; } else if (securityContext.isUserInRole(inPermission.getKeyAllAction())) { - logger.info("{} authorized because user has permission with * for action: {}", getPrincipalName(), inPermission.getKey()); + logger.info("{} authorized because user has permission with * for action: {}", getPrincipalName(), + inPermission.getKey()); authorized = true; } else { String msg = getPrincipalName() + " does not have permission: " + inPermission; + LoggingUtils.setErrorContext("100", "Authorization Error"); logger.warn(msg); throw new NotAuthorizedException(msg); } return authorized; } + /** + * Check if user is authorized for the given aaf permission. Allow matches + * if user has a permission with an "*" in permission instance or permission + * action even if the permission to check has a specific value in those + * fields. For example: if the user has this permission: app-perm-type|*|* + * it will be authorized if the inPermission to check is: + * app-perm-type|dev|read + * + * @param aafPermission + * @return + * @throws NotAuthorizedException + */ + public boolean isAuthorizedNoException(SecureServicePermission inPermission) throws NotAuthorizedException { + boolean authorized = false; + logger.debug("checking if {} has permission: {}", getPrincipalName(), inPermission); + // check if the user has the permission key or the permission key with a + // combination of all instance and/or all action. + if (securityContext.isUserInRole(inPermission.getKey())) { + logger.info("{} authorized for permission: {}", getPrincipalName(), inPermission.getKey()); + authorized = true; + // the rest of these don't seem to be required - isUserInRole method + // appears to take * as a wildcard + } else if (securityContext.isUserInRole(inPermission.getKeyAllInstance())) { + logger.info("{} authorized because user has permission with * for instance: {}", getPrincipalName(), + inPermission.getKey()); + authorized = true; + } else if (securityContext.isUserInRole(inPermission.getKeyAllInstanceAction())) { + logger.info("{} authorized because user has permission with * for instance and * for action: {}", + getPrincipalName(), inPermission.getKey()); + authorized = true; + } else if (securityContext.isUserInRole(inPermission.getKeyAllAction())) { + logger.info("{} authorized because user has permission with * for action: {}", getPrincipalName(), + inPermission.getKey()); + authorized = true; + } else { + String msg = getPrincipalName() + " does not have permission: " + inPermission; + LoggingUtils.setErrorContext("100", "Authorization Error"); + logger.warn(msg); + } + return authorized; + } + + public static final void setUserNameHandler(UserNameHandler handler) { + if (handler != null) { + userNameHandler = handler; + } + } } diff --git a/src/main/java/org/onap/clamp/clds/service/SecureServicePermission.java b/src/main/java/org/onap/clamp/clds/service/SecureServicePermission.java index a2213f91a..fb8c6d2f7 100644 --- a/src/main/java/org/onap/clamp/clds/service/SecureServicePermission.java +++ b/src/main/java/org/onap/clamp/clds/service/SecureServicePermission.java @@ -24,14 +24,15 @@ package org.onap.clamp.clds.service; /** - * Permission class that can be instantiated easily using constructor or factory methods. + * Permission class that can be instantiated easily using constructor or factory + * methods. */ public class SecureServicePermission { public final static String ALL = "*"; - private String type; - private String instance; - private String action; + private String type; + private String instance; + private String action; /** * Factory method to create permission given type, instance, and action. @@ -46,24 +47,26 @@ public class SecureServicePermission { } /** - * Factory method to create permission given type and instance. Default action to ALL/*. + * Factory method to create permission given type and instance. Default + * action to ALL/*. * * @param type * @param instance * @return */ public static SecureServicePermission create(String type, String instance) { - return new SecureServicePermission(type, instance); + return new SecureServicePermission(type, instance, ALL); } /** - * Factory method to create permission given type. Default instance and action to ALL/*. + * Factory method to create permission given type. Default instance and + * action to ALL/*. * * @param type * @return */ public static SecureServicePermission create(String type) { - return new SecureServicePermission(type); + return new SecureServicePermission(type, ALL, ALL); } /** @@ -80,37 +83,32 @@ public class SecureServicePermission { } /** - * Instantiate permission given type and instance. Default action to ALL/*. + * Instantiate permission given type from concatenated string * - * @param type - * @param instance - */ - public SecureServicePermission(String type, String instance) { - this.type = type; - this.instance = instance; - this.action = ALL; - } - - /** - * Instantiate permission given type. Default instance and action to ALL/*. - * - * @param type + * @param concatenatedString + * the string type|instance|action, less than 3 params can be + * provided (e.g. "permission-type-cl", "permission-type-cl|dev", + * "permission-type-cl|dev|update" ) */ - public SecureServicePermission(String type) { - this.type = type; - this.instance = ALL; - this.action = ALL; + public SecureServicePermission(String concatenatedString) { + String[] userInfo = concatenatedString.split("[|]"); + // We should have at least 1 string + this.type = userInfo[0]; + this.instance = (userInfo.length > 1 ? userInfo[1] : ALL); + this.action = (userInfo.length > 2 ? userInfo[2] : ALL); } /** * Override toString - return permission in key format */ + @Override public String toString() { return getKey(); } /** - * Return Permission in Key format = type, instance, and action separate by pipe character. + * Return Permission in Key format = type, instance, and action separate by + * pipe character. * * @return */ @@ -119,7 +117,8 @@ public class SecureServicePermission { } /** - * Return Permission in Key format = type, all instance, and action separate by pipe character. + * Return Permission in Key format = type, all instance, and action separate + * by pipe character. * * @return */ @@ -128,7 +127,8 @@ public class SecureServicePermission { } /** - * Return Permission in Key format = type, all instance, and all action separate by pipe character. + * Return Permission in Key format = type, all instance, and all action + * separate by pipe character. * * @return */ @@ -137,7 +137,8 @@ public class SecureServicePermission { } /** - * Return Permission in Key format = type, instance, and all action separate by pipe character. + * Return Permission in Key format = type, instance, and all action separate + * by pipe character. * * @return */ @@ -153,7 +154,8 @@ public class SecureServicePermission { } /** - * @param type the type to set + * @param type + * the type to set */ public void setType(String type) { this.type = type; @@ -167,7 +169,8 @@ public class SecureServicePermission { } /** - * @param instance the instance to set + * @param instance + * the instance to set */ public void setInstance(String instance) { this.instance = instance; @@ -181,7 +184,8 @@ public class SecureServicePermission { } /** - * @param action the action to set + * @param action + * the action to set */ public void setAction(String action) { this.action = action; diff --git a/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java b/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java index 2c666db06..2c152c5a1 100644 --- a/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java +++ b/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java @@ -38,11 +38,9 @@ public class TransformUtil { * @return resource - resource as stream */ public static InputStream getResourceAsStream(String name) { - InputStream is = Thread.currentThread().getContextClassLoader() - .getResourceAsStream(name); + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); if (is == null) { - throw new IllegalArgumentException("Unable to find resource: " - + name); + throw new IllegalArgumentException("Unable to find resource: " + name); } return is; } @@ -56,9 +54,9 @@ public class TransformUtil { public static String getResourceAsString(String name) throws IOException { InputStream is = getResourceAsStream(name); java.util.Scanner scanner = new java.util.Scanner(is); - java.util.Scanner s = scanner.useDelimiter("\\A"); - String text = s.hasNext() ? s.next() : ""; - s.close(); + java.util.Scanner delimitedScanner = scanner.useDelimiter("\\A"); + String text = delimitedScanner.hasNext() ? delimitedScanner.next() : ""; + delimitedScanner.close(); scanner.close(); is.close(); return text; diff --git a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java index 7d0031604..d15f67c77 100644 --- a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java +++ b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java @@ -23,12 +23,17 @@ package org.onap.clamp.clds.transform; -import javax.xml.transform.*; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; import java.io.StringReader; import java.io.StringWriter; +import javax.xml.transform.Templates; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + /** * XSL Transformer. */ @@ -51,8 +56,7 @@ public class XslTransformer { StringWriter output = new StringWriter(4000); Transformer transformer = templates.newTransformer(); - transformer.transform(new StreamSource(new StringReader(xml)), - new StreamResult(output)); + transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(output)); return output.toString(); } diff --git a/src/main/java/org/onap/clamp/clds/workflow/LogMessageDelegate.java b/src/main/java/org/onap/clamp/clds/workflow/LogMessageDelegate.java index 693b334ee..3c5076327 100644 --- a/src/main/java/org/onap/clamp/clds/workflow/LogMessageDelegate.java +++ b/src/main/java/org/onap/clamp/clds/workflow/LogMessageDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -26,21 +26,29 @@ package org.onap.clamp.clds.workflow; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + /** - * Log message. - * Invoked by the log-message-wf example Camunda workflow/bpmn. + * Log message. Invoked by the log-message-wf example Camunda workflow/bpmn. */ public class LogMessageDelegate implements JavaDelegate { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(LogMessageDelegate.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); /** - * Perform activity. Log message from running process and set a variable in the running process. + * Perform activity. Log message from running process and set a variable in + * the running process. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { String logMessageText = (String) execution.getVariable("logMessageText"); - System.out.println("Invoked from processDefinitionId=" + execution.getProcessDefinitionId() + ", processInstanceId=" + execution.getProcessInstanceId() + ", activityInstanceId=" + execution.getActivityInstanceId() + ": logMessageText=" + logMessageText); + logger.info("Invoked from processDefinitionId=" + execution.getProcessDefinitionId() + ", processInstanceId=" + + execution.getProcessInstanceId() + ", activityInstanceId=" + execution.getActivityInstanceId() + + ": logMessageText=" + logMessageText); execution.setVariable("isMessageLogComplete", true); } } diff --git a/src/main/java/org/onap/clamp/clds/workflow/ProcessRequestDelegate.java b/src/main/java/org/onap/clamp/clds/workflow/ProcessRequestDelegate.java index 324496422..19bdcaf98 100644 --- a/src/main/java/org/onap/clamp/clds/workflow/ProcessRequestDelegate.java +++ b/src/main/java/org/onap/clamp/clds/workflow/ProcessRequestDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -33,22 +33,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onap.clamp.clds.workflow; +package org.onap.clamp.clds.workflow; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; @Component public class ProcessRequestDelegate implements JavaDelegate { - private static final Logger logger = LoggerFactory.getLogger(ProcessRequestDelegate.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ProcessRequestDelegate.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - //@Override + // @Override + @Override public void execute(DelegateExecution execution) throws Exception { logger.info("Processing request by '" + execution.getVariable("customerId") + "'..."); logger.info("Processing request by '" + execution.getVariable("amount") + "'..."); diff --git a/src/main/java/org/onap/clamp/clds/workflow/RestMessageDelegate.java b/src/main/java/org/onap/clamp/clds/workflow/RestMessageDelegate.java index 0eda2decc..e273b0e2c 100644 --- a/src/main/java/org/onap/clamp/clds/workflow/RestMessageDelegate.java +++ b/src/main/java/org/onap/clamp/clds/workflow/RestMessageDelegate.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -23,36 +23,45 @@ package org.onap.clamp.clds.workflow; +import java.util.HashMap; +import java.util.Map; + import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** - * Log message. - * Invoked by the log-message-wf example Camunda workflow/bpmn. + * Log message. Invoked by the log-message-wf example Camunda workflow/bpmn. */ public class RestMessageDelegate implements JavaDelegate { - private static final Logger logger = Logger.getLogger(RestMessageDelegate.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(RestMessageDelegate.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); /** - * Perform activity. Log message from running process and set a variable in the running process. + * Perform activity. Log message from running process and set a variable in + * the running process. * * @param execution */ + @Override public void execute(DelegateExecution execution) throws Exception { String logMessageText = (String) execution.getVariable("logMessageText"); RestTemplate restTemplate = new RestTemplate(); Map restValues = new HashMap<>(); restValues.put("procInstId", execution.getProcessInstanceId()); - logger.info("Invoked from processDefinitionId=" + execution.getProcessDefinitionId() + ", processInstanceId=" + execution.getProcessInstanceId() + ", activityInstanceId=" + execution.getActivityInstanceId() + ": logMessageText=" + logMessageText); - // TODO: this should be fixed - put in temporary solution with existing sysprop and vars - why are we calling our own service? + logger.info("Invoked from processDefinitionId=" + execution.getProcessDefinitionId() + ", processInstanceId=" + + execution.getProcessInstanceId() + ", activityInstanceId=" + execution.getActivityInstanceId() + + ": logMessageText=" + logMessageText); + // TODO: this should be fixed - put in temporary solution with existing + // sysprop and vars - why are we calling our own service? String port = System.getProperty("server.port"); - ResponseEntity resp = restTemplate.getForEntity("http://localhost:" + port + "/services/CamundaExample/v1/jaxrsExample/log/histLog/{procInstId}", String.class, restValues); + ResponseEntity resp = restTemplate.getForEntity( + "http://localhost:" + port + "/services/CamundaExample/v1/jaxrsExample/log/histLog/{procInstId}", + String.class, restValues); logger.info("value of resp:" + resp); execution.setVariable("isMessageLogComplete", true); } -- cgit 1.2.3-korg From 50d34dacd85c7fdaf73ab9e970587243d6e79ebf Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 03:15:42 -0700 Subject: Removal of useless files Removal of useless files like Helloworld or unused HTML files Change-Id: Id82af9bb27eb53a7564cd42ab25960eb34bbf102 Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- .../org/onap/clamp/clds/jsf/JsfExampleBean.java | 61 -------- .../onap/clamp/clds/model/CldsAsdcArtifact.java | 112 --------------- .../onap/clamp/clds/model/CldsAsdcResource.java | 131 ----------------- .../clds/model/CldsAsdcResourceBasicInfo.java | 160 --------------------- .../clamp/clds/model/CldsAsdcServiceDetail.java | 142 ------------------ .../onap/clamp/clds/model/CldsAsdcServiceInfo.java | 148 ------------------- .../java/org/onap/clamp/clds/model/HelloWorld.java | 50 ------- .../clamp/clds/service/rs/JaxrsLogService.java | 101 ------------- .../clamp/clds/service/rs/JaxrsLogServiceImpl.java | 94 ------------ .../resources/designer/partials/invalid_login.html | 27 ---- .../resources/designer/partials/please_wait.html | 28 ---- .../partials/portfolios/running_instances.html | 67 --------- src/main/resources/META-INF/resources/login.html | 39 ----- 13 files changed, 1160 deletions(-) delete mode 100644 src/main/java/org/onap/clamp/clds/jsf/JsfExampleBean.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcArtifact.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcResource.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcResourceBasicInfo.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceDetail.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceInfo.java delete mode 100644 src/main/java/org/onap/clamp/clds/model/HelloWorld.java delete mode 100644 src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogService.java delete mode 100644 src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogServiceImpl.java delete mode 100644 src/main/resources/META-INF/resources/designer/partials/invalid_login.html delete mode 100644 src/main/resources/META-INF/resources/designer/partials/please_wait.html delete mode 100644 src/main/resources/META-INF/resources/designer/partials/portfolios/running_instances.html delete mode 100644 src/main/resources/META-INF/resources/login.html (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/jsf/JsfExampleBean.java b/src/main/java/org/onap/clamp/clds/jsf/JsfExampleBean.java deleted file mode 100644 index 5fdcedd96..000000000 --- a/src/main/java/org/onap/clamp/clds/jsf/JsfExampleBean.java +++ /dev/null @@ -1,61 +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.jsf; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; -import java.io.Serializable; -import java.util.Date; - -@ManagedBean -@SessionScoped -public class JsfExampleBean implements Serializable { - - private static final long serialVersionUID = 1L; - - private String value; - private Date dateValue; - - private static final java.text.SimpleDateFormat timestampFormat = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"); - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public Date getDateValue() { - return dateValue; - } - - public void setDateValue(Date dateValue) { - this.dateValue = dateValue; - } - - public String getDateValueText() { - return timestampFormat.format(dateValue); - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcArtifact.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcArtifact.java deleted file mode 100644 index 43d5ab6ae..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsAsdcArtifact.java +++ /dev/null @@ -1,112 +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.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class CldsAsdcArtifact { - - private String artifactName; - private String artifactType; - private String artifactURL; - private String artifactDescription; - private String artifactTimeout; - private String artifactChecksum; - private String artifactUUID; - private String artifactVersion; - private String generatedFromUUID; - - public String getArtifactName() { - return artifactName; - } - - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - public String getArtifactType() { - return artifactType; - } - - public void setArtifactType(String artifactType) { - this.artifactType = artifactType; - } - - public String getArtifactURL() { - return artifactURL; - } - - public void setArtifactURL(String artifactURL) { - this.artifactURL = artifactURL; - } - - public String getArtifactDescription() { - return artifactDescription; - } - - public void setArtifactDescription(String artifactDescription) { - this.artifactDescription = artifactDescription; - } - - public String getArtifactTimeout() { - return artifactTimeout; - } - - public void setArtifactTimeout(String artifactTimeout) { - this.artifactTimeout = artifactTimeout; - } - - public String getArtifactChecksum() { - return artifactChecksum; - } - - public void setArtifactChecksum(String artifactChecksum) { - this.artifactChecksum = artifactChecksum; - } - - public String getArtifactUUID() { - return artifactUUID; - } - - public void setArtifactUUID(String artifactUUID) { - this.artifactUUID = artifactUUID; - } - - public String getArtifactVersion() { - return artifactVersion; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public String getGeneratedFromUUID() { - return generatedFromUUID; - } - - public void setGeneratedFromUUID(String generatedFromUUID) { - this.generatedFromUUID = generatedFromUUID; - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcResource.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcResource.java deleted file mode 100644 index 3210b696b..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsAsdcResource.java +++ /dev/null @@ -1,131 +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.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import java.math.BigDecimal; -import java.util.List; -import java.util.logging.Logger; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class CldsAsdcResource implements Comparable { - private static final Logger logger = Logger.getLogger(CldsAsdcServiceInfo.class.getName()); - - private String resourceInstanceName; - private String resourceName; - private String resourceInvariantUUID; - private String resourceVersion; - private String resoucreType; - private String resourceUUID; - private List artifacts; - - public String getResourceInstanceName() { - return resourceInstanceName; - } - - public void setResourceInstanceName(String resourceInstanceName) { - this.resourceInstanceName = resourceInstanceName; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public String getResourceInvariantUUID() { - return resourceInvariantUUID; - } - - public void setResourceInvariantUUID(String resourceInvariantUUID) { - this.resourceInvariantUUID = resourceInvariantUUID; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public String getResoucreType() { - return resoucreType; - } - - public void setResoucreType(String resoucreType) { - this.resoucreType = resoucreType; - } - - public String getResourceUUID() { - return resourceUUID; - } - - public void setResourceUUID(String resourceUUID) { - this.resourceUUID = resourceUUID; - } - - public List getArtifacts() { - return artifacts; - } - - public void setArtifacts(List artifacts) { - this.artifacts = artifacts; - } - - @Override - public int compareTo(CldsAsdcResource in) { - // Compares this object with the specified object for order. - // Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. - - // first compare based on name - int rtn = resourceInstanceName.compareToIgnoreCase(in.resourceInstanceName); - - if (rtn == 0) { - BigDecimal myVersion = convertVersion(resourceVersion); - BigDecimal inVersion = convertVersion(in.resourceVersion); - rtn = myVersion.compareTo(inVersion); - } - return rtn; - } - - /** - * Convert version String into a BigDecimal - * - * @param versionText - * @return - */ - private BigDecimal convertVersion(String versionText) { - BigDecimal rtn = new BigDecimal(0.0); - try { - rtn = new BigDecimal(versionText); - } catch (NumberFormatException nfe) { - logger.warning("ASDC version=" + versionText + " is not decimal for name=" + resourceInstanceName); - } - return rtn; - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcResourceBasicInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcResourceBasicInfo.java deleted file mode 100644 index c66428a68..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsAsdcResourceBasicInfo.java +++ /dev/null @@ -1,160 +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.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import java.math.BigDecimal; -import java.util.logging.Logger; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class CldsAsdcResourceBasicInfo implements Comparable { - private static final Logger logger = Logger.getLogger(CldsAsdcServiceInfo.class.getName()); - - private String uuid; - private String invariantUUID; - private String name; - private String version; - private String toscaModelURL; - private String category; - private String subCategory; - private String resourceType; - private String lifecycleState; - private String lastUpdaterUserId; - - @Override - public int compareTo(CldsAsdcResourceBasicInfo in) { - // Compares this object with the specified object for order. - // Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. - // first compare based on name - int rtn = name.compareToIgnoreCase(in.name); - - if (rtn == 0) { - BigDecimal myVersion = convertVersion(version); - BigDecimal inVersion = convertVersion(in.version); - rtn = myVersion.compareTo(inVersion); - } - return rtn; - } - - /** - * Convert version String into a BigDecimal - * - * @param version - * @return - */ - private BigDecimal convertVersion(String version) { - BigDecimal rtn = new BigDecimal(0.0); - try { - rtn = new BigDecimal(version); - } catch (NumberFormatException nfe) { - logger.warning("ASDC version=" + version + " is not decimal for name=" + name); - } - return rtn; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getInvariantUUID() { - return invariantUUID; - } - - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getToscaModelURL() { - return toscaModelURL; - } - - public void setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getSubCategory() { - return subCategory; - } - - public void setSubCategory(String subCategory) { - this.subCategory = subCategory; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getLifecycleState() { - return lifecycleState; - } - - public void setLifecycleState(String lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public void setLastUpdaterUserId(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; - } - - public Logger getLOGGER() { - return logger; - } -} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceDetail.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceDetail.java deleted file mode 100644 index f50e09d5f..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceDetail.java +++ /dev/null @@ -1,142 +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.model; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - -import java.util.List; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class CldsAsdcServiceDetail { - - private String uuid; - private String invariantUUID; - private String name; - private String version; - private String toscaModelURL; - private String category; - private String lifecycleState; - private String lastUpdaterUserId; - private String distributionStatus; - private String lastUpdaterFullName; - private List resources; - private List artifacts; - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getInvariantUUID() { - return invariantUUID; - } - - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getToscaModelURL() { - return toscaModelURL; - } - - public void setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getLifecycleState() { - return lifecycleState; - } - - public void setLifecycleState(String lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public void setLastUpdaterUserId(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; - } - - public String getDistributionStatus() { - return distributionStatus; - } - - public void setDistributionStatus(String distributionStatus) { - this.distributionStatus = distributionStatus; - } - - public String getLastUpdaterFullName() { - return lastUpdaterFullName; - } - - public void setLastUpdaterFullName(String lastUpdaterFullName) { - this.lastUpdaterFullName = lastUpdaterFullName; - } - - public List getResources() { - return resources; - } - - public void setResources(List resources) { - this.resources = resources; - } - - public List getArtifacts() { - return artifacts; - } - - public void setArtifacts(List artifacts) { - this.artifacts = artifacts; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceInfo.java deleted file mode 100644 index 3ed575345..000000000 --- a/src/main/java/org/onap/clamp/clds/model/CldsAsdcServiceInfo.java +++ /dev/null @@ -1,148 +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.model; - -import java.math.BigDecimal; -import java.util.logging.Logger; - -public class CldsAsdcServiceInfo implements Comparable { - private static final Logger logger = Logger.getLogger(CldsAsdcServiceInfo.class.getName()); - - private String uuid; - private String invariantUUID; - private String name; - private String version; - private String toscaModelURL; - private String category; - private String lifecycleState; - private String lastUpdaterUserId; - private String distributionStatus; - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public String getInvariantUUID() { - return invariantUUID; - } - - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getToscaModelURL() { - return toscaModelURL; - } - - public void setToscaModelURL(String toscaModelURL) { - this.toscaModelURL = toscaModelURL; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getLifecycleState() { - return lifecycleState; - } - - public void setLifecycleState(String lifecycleState) { - this.lifecycleState = lifecycleState; - } - - public String getLastUpdaterUserId() { - return lastUpdaterUserId; - } - - public void setLastUpdaterUserId(String lastUpdaterUserId) { - this.lastUpdaterUserId = lastUpdaterUserId; - } - - public String getDistributionStatus() { - return distributionStatus; - } - - public void setDistributionStatus(String distributionStatus) { - this.distributionStatus = distributionStatus; - } - - /** - * Compare using name and then version. Version is converted to a decimal. - */ - @Override - public int compareTo(CldsAsdcServiceInfo in) { - // Compares this object with the specified object for order. - // Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. - // first compare based on name - int rtn = name.compareToIgnoreCase(in.name); - - if (rtn == 0) { - BigDecimal myVersion = convertVersion(version); - BigDecimal inVersion = convertVersion(in.version); - rtn = myVersion.compareTo(inVersion); - } - - return rtn; - } - - /** - * Convert version String into a BigDecimal - * - * @param versionText - * @return - */ - private BigDecimal convertVersion(String versionText) { - try { - return new BigDecimal(versionText); - } catch (NumberFormatException nfe) { - logger.warning("ASDC version=" + versionText + " is not decimal for name=" + name); - } - return new BigDecimal(0.0); - } - -} diff --git a/src/main/java/org/onap/clamp/clds/model/HelloWorld.java b/src/main/java/org/onap/clamp/clds/model/HelloWorld.java deleted file mode 100644 index 1165f5da4..000000000 --- a/src/main/java/org/onap/clamp/clds/model/HelloWorld.java +++ /dev/null @@ -1,50 +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.model; - -public class HelloWorld { - - private String message; - - public HelloWorld() { - // needed for deserializer - } - - public HelloWorld(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return "message = " + getMessage(); - } -} diff --git a/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogService.java b/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogService.java deleted file mode 100644 index d0ef13595..000000000 --- a/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogService.java +++ /dev/null @@ -1,101 +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.service.rs; - -import io.swagger.annotations.Api; - -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; - - -/** - * Service to invoke example Camunda process. - *

- * Try testing by using: - * http://[hostname]:[serverPort]/jaxrsservices/log/log-message/your-message-here - */ -@Api(value = "/log") -@Path("/log") -@Produces({MediaType.TEXT_PLAIN}) -public interface JaxrsLogService { - - /** - * REST service that executes example camunda process to log input message. - * - * @param logMessageText - * @return output from service - comment on what was done - */ - @GET - @Path("/log-message/{logMessageText}") - @Produces(MediaType.TEXT_PLAIN) - String logMessage(@PathParam("logMessageText") String logMessageText, @QueryParam("javamail") String javamail, @QueryParam("springmail") String springmail, @QueryParam("commonsmail") String commonsmail); - - /** - * REST service that executes example camunda process to log input message. - * - * @return output from service - comment on what was done - */ - @POST - @Path("/postLogHist") - @Produces(MediaType.TEXT_PLAIN) - @Consumes(MediaType.APPLICATION_JSON) - String postLogMessage(String histEventList); - - /** - * REST service that executes example camunda process to log input message. - * - * @param startTime - * @param endTime - * @param serviceName - * @return output from service - comment on what was done - */ - @GET - @Path("/createLog/{startTime}/{endTime}/{serviceName}") - @Produces(MediaType.TEXT_PLAIN) - String createLogMessage(@PathParam("startTime") String startTime, @PathParam("endTime") String endTime, @PathParam("serviceName") String serviceName); - - /** - * REST service that executes example camunda process to log input message. - * - * @param procInstId - * @param histEventList - * @return output from service - comment on what was done - */ - @GET - @Path("/createLogHist/{procInstId}/{histEventList}") - @Produces(MediaType.TEXT_PLAIN) - String createLogMessageUsingHistory(@PathParam("procInstId") String procInstId, @PathParam("histEventList") String histEventList); - - /** - * REST service that executes example camunda process to log input message. - * - * @param procInstId - * @return output from service - comment on what was done - */ - @GET - @Path("/histLog/{procInstId}") - @Produces(MediaType.TEXT_PLAIN) - String CreateHistLog(@PathParam("procInstId") String procInstId); - -} diff --git a/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogServiceImpl.java b/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogServiceImpl.java deleted file mode 100644 index 4ef7d2e9e..000000000 --- a/src/main/java/org/onap/clamp/clds/service/rs/JaxrsLogServiceImpl.java +++ /dev/null @@ -1,94 +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.service.rs; - -import com.att.ajsc.common.AjscService; -import org.onap.clamp.clds.service.LogService; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * Service to invoke example Camunda process. - *

- * Try testing by using: - * http://[hostname]:[serverPort]/services/log/log-message/your-message-here - */ -@AjscService -public class JaxrsLogServiceImpl implements JaxrsLogService { - - @Autowired - private LogService logService; - - /** - * REST service that executes example camunda process to log input message. - * - * @param logMessageText - * @return output from service - comment on what was done - */ - public String logMessage(String logMessageText, String javamail, String springmail, String commonsmail) { - return logService.logMessage(logMessageText, javamail, springmail, commonsmail); - } - - /** - * REST service that executes example camunda process to log input message. - * - * @return output from service - comment on what was done - */ - public String postLogMessage(String histEventList) { - return logService.postLogMessage(histEventList); - } - - /** - * REST service that executes example camunda process to log input message. - * - * @param startTime - * @param endTime - * @param serviceName - * @return output from service - comment on what was done - */ - public String createLogMessage(String startTime, String endTime, String serviceName) { - return logService.createLogMessage(startTime, endTime, serviceName); - } - - /** - * REST service that executes example camunda process to log input message. - * - * @param procInstId - * @param histEventList - * @return output from service - comment on what was done - */ - public String createLogMessageUsingHistory(String procInstId, String histEventList) { - return logService.createLogMessageUsingHistory(procInstId, histEventList); - } - - /** - * REST service that executes example camunda process to log input message. - * - * @param procInstId - * @return output from service - comment on what was done - */ - public String CreateHistLog(String procInstId) { - return logService.CreateHistLog(procInstId); - } - -} diff --git a/src/main/resources/META-INF/resources/designer/partials/invalid_login.html b/src/main/resources/META-INF/resources/designer/partials/invalid_login.html deleted file mode 100644 index 7c279c0f6..000000000 --- a/src/main/resources/META-INF/resources/designer/partials/invalid_login.html +++ /dev/null @@ -1,27 +0,0 @@ - - - -

-

CSP Authentication not available for {{host}}.

-
diff --git a/src/main/resources/META-INF/resources/designer/partials/please_wait.html b/src/main/resources/META-INF/resources/designer/partials/please_wait.html deleted file mode 100644 index 8068e4cf5..000000000 --- a/src/main/resources/META-INF/resources/designer/partials/please_wait.html +++ /dev/null @@ -1,28 +0,0 @@ - - - -
-

Please Wait.....{{urlparam}}

- -
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/running_instances.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/running_instances.html deleted file mode 100644 index 1117c1601..000000000 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/running_instances.html +++ /dev/null @@ -1,67 +0,0 @@ - - - -
- - - - - -
- diff --git a/src/main/resources/META-INF/resources/login.html b/src/main/resources/META-INF/resources/login.html deleted file mode 100644 index 76cb7a6d7..000000000 --- a/src/main/resources/META-INF/resources/login.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - CLDS - - - -

Welcome to Clamp. Please login first.

- -
-
-
-
-
- - \ No newline at end of file -- cgit 1.2.3-korg From bb03393b823bc2b1ec43be654e13b83a5a74a566 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 8 Aug 2017 03:16:59 -0700 Subject: Rework of the DCAE client Rework of the DCAE client and javascripts/html pages of the designer (part5) Change-Id: I3e7b889e2112dc2745632a328a02c6c603ecc195 Issue-Id: CLAMP-1 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/client/DcaeDispatcherServices.java | 321 +++++++++++++++++++++ .../clamp/clds/client/DcaeInventoryServices.java | 181 ++++++++++++ .../org/onap/clamp/clds/model/CldsHealthCheck.java | 57 ++++ .../java/org/onap/clamp/clds/model/CldsInfo.java | 83 ++++++ .../org/onap/clamp/clds/model/CldsVfKPIData.java | 89 ++++++ .../onap/clamp/clds/model/prop/PolicyChain.java | 99 +++++++ .../onap/clamp/clds/model/prop/ResourceGroup.java | 114 ++++++++ .../org/onap/clamp/clds/util/LoggingUtils.java | 124 ++++++++ .../resources/designer/images/Collectors.png | Bin 0 -> 339 bytes .../META-INF/resources/designer/invalid_login.html | 45 +++ .../META-INF/resources/designer/lib/angular-md5.js | 208 +++++++++++++ .../META-INF/resources/designer/logout.html | 40 +++ .../resources/designer/menu_simplified.html | 54 ++++ .../partials/portfolios/extra_user_info.html | 49 ++++ .../META-INF/resources/designer/please_wait.html | 28 ++ .../designer/scripts/ExtraUserInfoCtrl.js | 37 +++ .../designer/scripts/ExtraUserInfoService.js | 41 +++ src/main/resources/policyLogger.properties | 47 +++ 18 files changed, 1617 insertions(+) create mode 100644 src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java create mode 100644 src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsInfo.java create mode 100644 src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java create mode 100644 src/main/java/org/onap/clamp/clds/util/LoggingUtils.java create mode 100644 src/main/resources/META-INF/resources/designer/images/Collectors.png create mode 100644 src/main/resources/META-INF/resources/designer/invalid_login.html create mode 100644 src/main/resources/META-INF/resources/designer/lib/angular-md5.js create mode 100644 src/main/resources/META-INF/resources/designer/logout.html create mode 100644 src/main/resources/META-INF/resources/designer/menu_simplified.html create mode 100644 src/main/resources/META-INF/resources/designer/partials/portfolios/extra_user_info.html create mode 100644 src/main/resources/META-INF/resources/designer/please_wait.html create mode 100644 src/main/resources/META-INF/resources/designer/scripts/ExtraUserInfoCtrl.js create mode 100644 src/main/resources/META-INF/resources/designer/scripts/ExtraUserInfoService.js create mode 100644 src/main/resources/policyLogger.properties (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java new file mode 100644 index 000000000..343391ebd --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java @@ -0,0 +1,321 @@ +/*- + * ============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.client; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.stream.Collectors; + +import javax.net.ssl.HttpsURLConnection; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.springframework.beans.factory.annotation.Autowired; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +/** + * + * + */ +public class DcaeDispatcherServices { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeDispatcherServices.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + @Autowired + private RefProp refProp; + + /** + * + * @param deploymentId + * @return + * @throws Exception + */ + public String deleteDeployment(String deploymentId) throws Exception { + + String statusUrl = null; + InputStream in = null; + try { + String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments/" + deploymentId; + logger.info("Dcae Dispatcher url - " + url); + URL obj = new URL(url); + HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); + conn.setRequestMethod("DELETE"); + int responseCode = conn.getResponseCode(); + + boolean requestFailed = true; + logger.info("responseCode=" + responseCode); + if (responseCode == 200 || responseCode == 202) { + requestFailed = false; + } + + InputStream inStream = conn.getErrorStream(); + if (inStream == null) { + inStream = conn.getInputStream(); + } + + String responseStr = null; + if (inStream != null) { + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inStream)); + String inputLine = null; + StringBuffer response = new StringBuffer(); + while ((inputLine = bufferedReader.readLine()) != null) { + response.append(inputLine); + } + responseStr = response.toString(); + } + + if (responseStr != null) { + if (requestFailed) { + logger.error("requestFailed - responseStr=" + responseStr); + throw new Exception(responseStr); + } + } + + logger.debug("response code " + responseCode); + in = conn.getInputStream(); + logger.debug("res:" + responseStr); + JSONParser parser = new JSONParser(); + Object obj0 = parser.parse(responseStr); + JSONObject jsonObj = (JSONObject) obj0; + JSONObject linksObj = (JSONObject) jsonObj.get("links"); + statusUrl = (String) linksObj.get("status"); + logger.debug("Status URL: " + statusUrl); + + } catch (Exception e) { + logger.error(e.getClass().getName() + " " + e.getMessage()); + throw e; + } finally { + if (in != null) { + in.close(); + } + } + + return statusUrl; + + } + + /** + * + * @param statusUrl + * @return + * @throws Exception + */ + public String getOperationStatus(String statusUrl) throws Exception { + + String opStatus = null; + InputStream in = null; + try { + URL obj = new URL(statusUrl); + HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); + conn.setRequestMethod("GET"); + int responseCode = conn.getResponseCode(); + logger.debug("response code " + responseCode); + in = conn.getInputStream(); + String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n")); + JSONParser parser = new JSONParser(); + Object obj0 = parser.parse(res); + JSONObject jsonObj = (JSONObject) obj0; + String operationType = (String) jsonObj.get("operationType"); + String status = (String) jsonObj.get("status"); + logger.debug("Operation Type " + operationType); + logger.debug("Status " + status); + opStatus = status; + + } catch (Exception e) { + logger.debug(e.getClass().getName() + " " + e.getMessage()); + logger.debug(e.getMessage() + + " : got exception while retrieving status, trying again until we get 200 response code"); + } finally { + if (in != null) { + in.close(); + } + } + + return opStatus; + } + + /** + * + * @throws Exception + */ + public void getDeployments() throws Exception { + InputStream in = null; + try { + String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments"; + logger.info("Dcae Dispatcher deployments url - " + url); + URL obj = new URL(url); + HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); + conn.setRequestMethod("GET"); + int responseCode = conn.getResponseCode(); + logger.debug("response code " + responseCode); + in = conn.getInputStream(); + String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n")); + logger.debug("res:" + res); + } catch (Exception e) { + logger.error("Exception occurred during DCAE communication", e); + throw e; + } finally { + if (in != null) { + in.close(); + } + } + } + + /** + * Returns status URL for deployment operation + * + * @param deploymentId + * @param serviceTypeId + * @return + * @throws Exception + */ + public String createNewDeployment(String deploymentId, String serviceTypeId) throws Exception { + + String statusUrl = null; + InputStream inStream = null; + BufferedReader in = null; + try { + String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}"; + logger.info("Dcae api Body String - " + apiBodyString); + String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments/" + deploymentId; + logger.info("Dcae Dispatcher Service url - " + url); + URL obj = new URL(url); + HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); + conn.setRequestMethod("PUT"); + conn.setRequestProperty("Content-Type", "application/json"); + conn.setDoOutput(true); + try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { + wr.writeBytes(apiBodyString); + wr.flush(); + } + + boolean requestFailed = true; + int responseCode = conn.getResponseCode(); + logger.info("responseCode=" + responseCode); + if (responseCode == 200 || responseCode == 202) { + requestFailed = false; + } + + inStream = conn.getErrorStream(); + if (inStream == null) { + inStream = conn.getInputStream(); + } + + String responseStr = null; + if (inStream != null) { + in = new BufferedReader(new InputStreamReader(inStream)); + + String inputLine = null; + + StringBuffer response = new StringBuffer(); + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + + responseStr = response.toString(); + } + + if (responseStr != null) { + if (requestFailed) { + logger.error("requestFailed - responseStr=" + responseStr); + throw new Exception(responseStr); + } + } + + logger.debug("response code " + responseCode); + JSONParser parser = new JSONParser(); + Object obj0 = parser.parse(responseStr); + JSONObject jsonObj = (JSONObject) obj0; + JSONObject linksObj = (JSONObject) jsonObj.get("links"); + statusUrl = (String) linksObj.get("status"); + logger.debug("Status URL: " + statusUrl); + } catch (Exception e) { + logger.error("Exception occurred during the DCAE communication", e); + throw e; + } finally { + if (inStream != null) { + inStream.close(); + } + if (in != null) { + in.close(); + } + } + return statusUrl; + } + + /** + * + * @param deploymentId + * @param serviceTypeId + * @return + * @throws Exception + */ + public String deleteExistingDeployment(String deploymentId, String serviceTypeId) throws Exception { + + String statusUrl = null; + InputStream in = null; + try { + String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}"; + logger.debug(apiBodyString); + String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments/" + deploymentId; + logger.info("Dcae Dispatcher deployments url - " + url); + URL obj = new URL(url); + HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); + conn.setRequestMethod("DELETE"); + conn.setRequestProperty("Content-Type", "application/json"); + conn.setDoOutput(true); + DataOutputStream wr = new DataOutputStream(conn.getOutputStream()); + wr.writeBytes(apiBodyString); + wr.flush(); + + int responseCode = conn.getResponseCode(); + logger.debug("response code " + responseCode); + in = conn.getInputStream(); + String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n")); + logger.debug("res:" + res); + JSONParser parser = new JSONParser(); + Object obj0 = parser.parse(res); + JSONObject jsonObj = (JSONObject) obj0; + JSONObject linksObj = (JSONObject) jsonObj.get("links"); + statusUrl = (String) linksObj.get("status"); + logger.debug("Status URL: " + statusUrl); + } catch (Exception e) { + logger.error("Exception occurred during DCAE communication", e); + throw e; + } finally { + if (in != null) { + in.close(); + } + } + return statusUrl; + } + +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java new file mode 100644 index 000000000..3dfe9fecb --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java @@ -0,0 +1,181 @@ +/*- + * ============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.client; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.List; + +import javax.ws.rs.BadRequestException; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.model.CldsEvent; +import org.onap.clamp.clds.model.CldsModel; +import org.onap.clamp.clds.model.DcaeEvent; +import org.onap.clamp.clds.model.prop.Global; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.springframework.beans.factory.annotation.Autowired; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; + +public class DcaeInventoryServices { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeInventoryServices.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + @Autowired + private RefProp refProp; + + @Autowired + private CldsDao cldsDao; + + @Autowired + private SdcCatalogServices sdcCatalogServices; + + public void setEventInventory(CldsModel cldsModel, String userId) throws Exception { + String artifactName = cldsModel.getControlName(); + DcaeEvent dcaeEvent = new DcaeEvent(); + String isDcaeInfoAvailable = null; + if (artifactName != null) { + artifactName = artifactName + ".yml"; + } + try { + /* + * Below are the properties required for calling the dcae inventory + * url call + */ + ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null, false, "{}", + cldsModel.getPropText()); + Global global = prop.getGlobal(); + String invariantServiceUuid = global.getService(); + List resourceUuidList = global.getResourceVf(); + String serviceUuid = sdcCatalogServices.getServiceUuidFromServiceInvariantId(invariantServiceUuid); + String resourceUuid = ""; + if (resourceUuidList != null && resourceUuidList.size() > 0) { + resourceUuid = resourceUuidList.get(0).toString(); + } + /* Invemtory service url is called in this method */ + isDcaeInfoAvailable = getDcaeInformation(artifactName, serviceUuid, resourceUuid); + + /* set dcae events */ + dcaeEvent.setArtifactName(artifactName); + dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION); + + } catch (JsonProcessingException e) { + // exception + logger.error("JsonProcessingException" + e); + } catch (IOException e) { + + // exception + logger.error("IOException :" + e); + } + /* Null whether the DCAE has items lenght or not */ + if (isDcaeInfoAvailable != null) { + /* Inserting Event in to DB */ + logger.info(isDcaeInfoAvailable); + JSONParser parser = new JSONParser(); + Object obj0 = parser.parse(isDcaeInfoAvailable); + JSONObject jsonObj = (JSONObject) obj0; + String oldTypeId = cldsModel.getTypeId(); + String newTypeId = ""; + if (jsonObj.get("typeId") != null) { + newTypeId = jsonObj.get("typeId").toString(); + cldsModel.setTypeId(jsonObj.get("typeId").toString()); + } + // cldsModel.setTypeName(cldsModel.getControlName().toString()+".yml"); + if (jsonObj.get("typeName") != null) { + cldsModel.setTypeName(jsonObj.get("typeName").toString()); + } + if(oldTypeId == null || !oldTypeId.equalsIgnoreCase(newTypeId)){ + CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(), + CldsEvent.ACTION_STATE_RECEIVED, null); + } + cldsModel.save(cldsDao, userId); + } else { + logger.info(cldsModel.getName() + " Model is not present in Dcae Inventory Service."); + } + } + + public String getDcaeInformation(String artifactName, String serviceUUID, String resourceUUID) + throws IOException, ParseException { + String queryString = "?sdcResourceId=" + resourceUUID + "&sdcServiceId=" + serviceUUID + "&typeName=" + + artifactName; + String fullUrl = refProp.getStringValue("DCAE_INVENTORY_URL") + "/dcae-service-types" + queryString; + logger.info("Dcae Inventory Service full url - " + fullUrl); + String daceInventoryResponse = null; + URL inventoryUrl = new URL(fullUrl); + + HttpURLConnection conn = (HttpURLConnection) inventoryUrl.openConnection(); + conn.setRequestMethod("GET"); + boolean requestFailed = true; + int responseCode = conn.getResponseCode(); + if (responseCode == 200) { + requestFailed = false; + } + + BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String inputLine = null; + StringBuffer response = new StringBuffer(); + String responseStr = null; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + in.close(); + responseStr = response.toString(); + if (responseStr != null) { + if (requestFailed) { + logger.error("requestFailed - responseStr=" + response); + throw new BadRequestException(responseStr); + } + } + String jsonResponseString = response.toString(); + JSONParser parser = new JSONParser(); + Object obj0 = parser.parse(jsonResponseString); + + JSONObject jsonObj = (JSONObject) obj0; + + Long totalCount = (Long) jsonObj.get("totalCount"); + + int numServices = totalCount.intValue(); + if (numServices == 0) { + daceInventoryResponse = null; + } else if (numServices > 0) { + JSONArray itemsArray = (JSONArray) jsonObj.get("items"); + JSONObject dcaeServiceType0 = (JSONObject) itemsArray.get(0); + daceInventoryResponse = dcaeServiceType0.toString(); + logger.info(daceInventoryResponse.toString()); + } + return daceInventoryResponse; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java b/src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java new file mode 100644 index 000000000..9a5e5a534 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsHealthCheck.java @@ -0,0 +1,57 @@ +/*- + * ============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.model; + +public class CldsHealthCheck { + + private String healthCheckComponent; + + public String getHealthCheckComponent() { + return healthCheckComponent; + } + + public void setHealthCheckComponent(String healthCheckComponent) { + this.healthCheckComponent = healthCheckComponent; + } + + private String healthCheckStatus; + private String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getHealthCheckStatus() { + return healthCheckStatus; + } + + public void setHealthCheckStatus(String healthCheckStatus) { + this.healthCheckStatus = healthCheckStatus; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsInfo.java new file mode 100644 index 000000000..9dc0f870d --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsInfo.java @@ -0,0 +1,83 @@ +/*- + * ============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.model; + +public class CldsInfo { + + private String userName; + private String cldsVersion; + private boolean permissionReadCl; + private boolean permissionUpdateCl; + private boolean permissionReadTemplate; + private boolean permissionUpdateTemplate; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getCldsVersion() { + return cldsVersion; + } + + public void setCldsVersion(String cldsVersion) { + this.cldsVersion = cldsVersion; + } + + public boolean isPermissionReadCl() { + return permissionReadCl; + } + + public void setPermissionReadCl(boolean permissionReadCl) { + this.permissionReadCl = permissionReadCl; + } + + public boolean isPermissionUpdateCl() { + return permissionUpdateCl; + } + + public void setPermissionUpdateCl(boolean permissionUpdateCl) { + this.permissionUpdateCl = permissionUpdateCl; + } + + public boolean isPermissionReadTemplate() { + return permissionReadTemplate; + } + + public void setPermissionReadTemplate(boolean permissionReadTemplate) { + this.permissionReadTemplate = permissionReadTemplate; + } + + public boolean isPermissionUpdateTemplate() { + return permissionUpdateTemplate; + } + + public void setPermissionUpdateTemplate(boolean permissionUpdateTemplate) { + this.permissionUpdateTemplate = permissionUpdateTemplate; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java b/src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java new file mode 100644 index 000000000..62e676f08 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/CldsVfKPIData.java @@ -0,0 +1,89 @@ +/*- + * ============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.model; + +import java.io.Serializable; + +public class CldsVfKPIData implements Serializable { + + private static final long serialVersionUID = 9067755871527776380L; + + private String nfNamingCode; + private String nfNamingValue; + + private String fieldPath; + private String fieldPathValue; + + private String thresholdName; + private String thresholdValue; + + public String getNfNamingCode() { + return nfNamingCode; + } + + public void setNfNamingCode(String nfNamingCode) { + this.nfNamingCode = nfNamingCode; + } + + public String getNfNamingValue() { + return nfNamingValue; + } + + public void setNfNamingValue(String nfNamingValue) { + this.nfNamingValue = nfNamingValue; + } + + public String getFieldPath() { + return fieldPath; + } + + public void setFieldPath(String fieldPath) { + this.fieldPath = fieldPath; + } + + public String getFieldPathValue() { + return fieldPathValue; + } + + public void setFieldPathValue(String fieldPathValue) { + this.fieldPathValue = fieldPathValue; + } + + public String getThresholdName() { + return thresholdName; + } + + public void setThresholdName(String thresholdName) { + this.thresholdName = thresholdName; + } + + public String getThresholdValue() { + return thresholdValue; + } + + public void setThresholdValue(String thresholdValue) { + this.thresholdValue = thresholdValue; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java new file mode 100644 index 000000000..6142e9e63 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java @@ -0,0 +1,99 @@ +/*- + * ============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.model.prop; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse Policy json properties. + * + * Example json: + * {"Policy_1e33tn8":{"PolicyTest1":[{"name":"pname","value":"PolicyTest1"},{ + * "name":"pid","value":"1"},{"name":"timeout","value":"345"},{ + * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name": + * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name" + * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name": + * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name": + * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name": + * "parentPolicy","value":[""]}]]}],"PolicyTest2":[{"name":"pname","value": + * "PolicyTest2"},{"name":"pid","value":"2"},{"name":"timeout","value":"345"},{ + * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name": + * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name" + * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name": + * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name": + * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name": + * "parentPolicy","value":[""]}]]}]}} f + * + */ +public class PolicyChain { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyChain.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String policyId; + private Integer timeout; + private List policyItems; + + public PolicyChain(JsonNode node) { + + policyId = ModelElement.getValueByName(node, "pid"); + timeout = ModelElement.getIntValueByName(node, "timeout"); + + // process policy configurations + JsonNode policyNode = node.get(node.size() - 1).get("policyConfigurations"); + Iterator itr = policyNode.elements(); + policyItems = new ArrayList(); + while (itr.hasNext()) { + policyItems.add(new PolicyItem(itr.next())); + } + } + + /** + * @return the policyId + */ + public String getPolicyId() { + return policyId; + } + + /** + * @return the timeout + */ + public Integer getTimeout() { + return timeout; + } + + /** + * @return the policyItems + */ + public List getPolicyItems() { + return policyItems; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java b/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java new file mode 100644 index 000000000..de98333a1 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java @@ -0,0 +1,114 @@ +/*- + * ============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.model.prop; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse Resource Group json properties. + * + * Example json: + * {"StringMatch_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{ + * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value": + * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name" + * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name" + * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value": + * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name": + * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{ + * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[ + * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[ + * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]} + * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]}, + * {"name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ABATED"]}]]}]}} + * + */ +public class ResourceGroup { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourceGroup.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String groupNumber; + private String policyId; + private List serviceConfigurations; + + /** + * Parse String Match Resource Group given json node. + * + * @param modelBpmn + * @param modelJson + */ + public ResourceGroup(JsonNode node) { + + groupNumber = ModelElement.getValueByName(node, "rgname"); + policyId = ModelElement.getValueByName(node, "policyId"); + + // process Server_Configurations + JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); + Iterator itr = serviceConfigurationsNode.elements(); + serviceConfigurations = new ArrayList(); + while (itr.hasNext()) { + serviceConfigurations.add(new ServiceConfiguration(itr.next())); + } + } + + /** + * @return the groupNumber + */ + public String getGroupNumber() { + return groupNumber; + } + + /** + * @return the policyId + */ + public String getPolicyId() { + return policyId; + } + + /** + * @return the serviceConfigurations + */ + public List getServiceConfigurations() { + return serviceConfigurations; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java new file mode 100644 index 000000000..c47400689 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java @@ -0,0 +1,124 @@ +/*- + * ============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.util; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; +import java.util.UUID; + +import org.jboss.logging.MDC; + +public class LoggingUtils { + + /** + * Set request related logging variables in thread local data via MDC + * + * @param service + * Service Name of API (ex. "PUT template") + * @param partner + * Partner name (client or user invoking API) + */ + public static void setRequestContext(String service, String partner) { + MDC.put("RequestId", "clds-" + UUID.randomUUID().toString()); + MDC.put("ServiceName", service); + MDC.put("PartnerName", partner); + } + + /** + * Set time related logging variables in thread local data via MDC + * + * @param beginTimeStamp + * Start time + * @param endTimeStamp + * End time + */ + public static void setTimeContext(Date beginTimeStamp, Date endTimeStamp) { + String beginTime = ""; + String endTime = ""; + String elapsedTime = ""; + + if (beginTimeStamp != null && endTimeStamp != null) { + elapsedTime = String.valueOf(endTimeStamp.getTime() - beginTimeStamp.getTime()); + beginTime = generateTimestampStr(beginTimeStamp); + endTime = generateTimestampStr(endTimeStamp); + } + + MDC.put("BeginTimestamp", beginTime); + MDC.put("EndTimestamp", endTime); + MDC.put("ElapsedTime", elapsedTime); + } + + /** + * Set response related logging variables in thread local data via MDC + * + * @param code + * Response code ("0" indicates success) + * @param description + * Response description + * @param className + * class name of invoking class + */ + public static void setResponseContext(String code, String description, String className) { + MDC.put("ResponseCode", code); + MDC.put("StatusCode", code.equals("0") ? "COMPLETE" : "ERROR"); + MDC.put("ResponseDescription", description != null ? description : ""); + MDC.put("ClassName", className != null ? className : ""); + } + + /** + * Set target related logging variables in thread local data via MDC + * + * @param targetEntity + * Target entity (an external/sub component, for ex. "sdc") + * @param targetServiceName + * Target service name (name of API invoked on target) + */ + public static void setTargetContext(String targetEntity, String targetServiceName) { + MDC.put("TargetEntity", targetEntity != null ? targetEntity : ""); + MDC.put("TargetServiceName", targetServiceName != null ? targetServiceName : ""); + } + + /** + * Set error related logging variables in thread local data via MDC + * + * @param code + * Error code + * @param description + * Error description + */ + public static void setErrorContext(String code, String description) { + MDC.put("ErrorCode", code); + MDC.put("ErrorDescription", description != null ? description : ""); + } + + private static String generateTimestampStr(Date timeStamp) { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); + TimeZone tz = TimeZone.getTimeZone("UTC"); + df.setTimeZone(tz); + return df.format(timeStamp); + } + +} diff --git a/src/main/resources/META-INF/resources/designer/images/Collectors.png b/src/main/resources/META-INF/resources/designer/images/Collectors.png new file mode 100644 index 000000000..8b3cc1eec Binary files /dev/null and b/src/main/resources/META-INF/resources/designer/images/Collectors.png differ diff --git a/src/main/resources/META-INF/resources/designer/invalid_login.html b/src/main/resources/META-INF/resources/designer/invalid_login.html new file mode 100644 index 000000000..067452e66 --- /dev/null +++ b/src/main/resources/META-INF/resources/designer/invalid_login.html @@ -0,0 +1,45 @@ + + + + + CLDS + +
+
Login Failed!
+
Please make sure your login and password are correct. + If you don't have the login credential, please contact CLAMP administrator.
+ +
To login again, please click Login
+
+ + + + diff --git a/src/main/resources/META-INF/resources/designer/lib/angular-md5.js b/src/main/resources/META-INF/resources/designer/lib/angular-md5.js new file mode 100644 index 000000000..7896bb429 --- /dev/null +++ b/src/main/resources/META-INF/resources/designer/lib/angular-md5.js @@ -0,0 +1,208 @@ +/* + angular-md5 - v0.1.8 + 2015-11-17 +*/ + +/* commonjs package manager support (eg componentjs) */ +if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports) { + module.exports = "angular-md5"; +} +(function(angular) { + angular.module("angular-md5", [ "gdi2290.md5" ]); + angular.module("ngMd5", [ "gdi2290.md5" ]); + angular.module("gdi2290.md5", [ "gdi2290.gravatar-filter", "gdi2290.md5-service", "gdi2290.md5-filter" ]); + "use strict"; + angular.module("gdi2290.gravatar-filter", []).filter("gravatar", [ "md5", function(md5) { + var cache = {}; + return function(text, defaultText) { + if (!cache[text]) { + defaultText = defaultText ? md5.createHash(defaultText.toString().toLowerCase()) : ""; + cache[text] = text ? md5.createHash(text.toString().toLowerCase()) : defaultText; + } + return cache[text]; + }; + } ]); + "use strict"; + angular.module("gdi2290.md5-filter", []).filter("md5", [ "md5", function(md5) { + return function(text) { + return text ? md5.createHash(text.toString().toLowerCase()) : text; + }; + } ]); + "use strict"; + angular.module("gdi2290.md5-service", []).factory("md5", [ function() { + var md5 = { + createHash: function(str) { + if (null === str) { + return null; + } + var xl; + var rotateLeft = function(lValue, iShiftBits) { + return lValue << iShiftBits | lValue >>> 32 - iShiftBits; + }; + var addUnsigned = function(lX, lY) { + var lX4, lY4, lX8, lY8, lResult; + lX8 = lX & 2147483648; + lY8 = lY & 2147483648; + lX4 = lX & 1073741824; + lY4 = lY & 1073741824; + lResult = (lX & 1073741823) + (lY & 1073741823); + if (lX4 & lY4) { + return lResult ^ 2147483648 ^ lX8 ^ lY8; + } + if (lX4 | lY4) { + if (lResult & 1073741824) { + return lResult ^ 3221225472 ^ lX8 ^ lY8; + } else { + return lResult ^ 1073741824 ^ lX8 ^ lY8; + } + } else { + return lResult ^ lX8 ^ lY8; + } + }; + var _F = function(x, y, z) { + return x & y | ~x & z; + }; + var _G = function(x, y, z) { + return x & z | y & ~z; + }; + var _H = function(x, y, z) { + return x ^ y ^ z; + }; + var _I = function(x, y, z) { + return y ^ (x | ~z); + }; + var _FF = function(a, b, c, d, x, s, ac) { + a = addUnsigned(a, addUnsigned(addUnsigned(_F(b, c, d), x), ac)); + return addUnsigned(rotateLeft(a, s), b); + }; + var _GG = function(a, b, c, d, x, s, ac) { + a = addUnsigned(a, addUnsigned(addUnsigned(_G(b, c, d), x), ac)); + return addUnsigned(rotateLeft(a, s), b); + }; + var _HH = function(a, b, c, d, x, s, ac) { + a = addUnsigned(a, addUnsigned(addUnsigned(_H(b, c, d), x), ac)); + return addUnsigned(rotateLeft(a, s), b); + }; + var _II = function(a, b, c, d, x, s, ac) { + a = addUnsigned(a, addUnsigned(addUnsigned(_I(b, c, d), x), ac)); + return addUnsigned(rotateLeft(a, s), b); + }; + var convertToWordArray = function(str) { + var lWordCount; + var lMessageLength = str.length; + var lNumberOfWords_temp1 = lMessageLength + 8; + var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - lNumberOfWords_temp1 % 64) / 64; + var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16; + var lWordArray = new Array(lNumberOfWords - 1); + var lBytePosition = 0; + var lByteCount = 0; + while (lByteCount < lMessageLength) { + lWordCount = (lByteCount - lByteCount % 4) / 4; + lBytePosition = lByteCount % 4 * 8; + lWordArray[lWordCount] = lWordArray[lWordCount] | str.charCodeAt(lByteCount) << lBytePosition; + lByteCount++; + } + lWordCount = (lByteCount - lByteCount % 4) / 4; + lBytePosition = lByteCount % 4 * 8; + lWordArray[lWordCount] = lWordArray[lWordCount] | 128 << lBytePosition; + lWordArray[lNumberOfWords - 2] = lMessageLength << 3; + lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29; + return lWordArray; + }; + var wordToHex = function(lValue) { + var wordToHexValue = "", wordToHexValue_temp = "", lByte, lCount; + for (lCount = 0; lCount <= 3; lCount++) { + lByte = lValue >>> lCount * 8 & 255; + wordToHexValue_temp = "0" + lByte.toString(16); + wordToHexValue = wordToHexValue + wordToHexValue_temp.substr(wordToHexValue_temp.length - 2, 2); + } + return wordToHexValue; + }; + var x = [], k, AA, BB, CC, DD, a, b, c, d, S11 = 7, S12 = 12, S13 = 17, S14 = 22, S21 = 5, S22 = 9, S23 = 14, S24 = 20, S31 = 4, S32 = 11, S33 = 16, S34 = 23, S41 = 6, S42 = 10, S43 = 15, S44 = 21; + x = convertToWordArray(str); + a = 1732584193; + b = 4023233417; + c = 2562383102; + d = 271733878; + xl = x.length; + for (k = 0; k < xl; k += 16) { + AA = a; + BB = b; + CC = c; + DD = d; + a = _FF(a, b, c, d, x[k + 0], S11, 3614090360); + d = _FF(d, a, b, c, x[k + 1], S12, 3905402710); + c = _FF(c, d, a, b, x[k + 2], S13, 606105819); + b = _FF(b, c, d, a, x[k + 3], S14, 3250441966); + a = _FF(a, b, c, d, x[k + 4], S11, 4118548399); + d = _FF(d, a, b, c, x[k + 5], S12, 1200080426); + c = _FF(c, d, a, b, x[k + 6], S13, 2821735955); + b = _FF(b, c, d, a, x[k + 7], S14, 4249261313); + a = _FF(a, b, c, d, x[k + 8], S11, 1770035416); + d = _FF(d, a, b, c, x[k + 9], S12, 2336552879); + c = _FF(c, d, a, b, x[k + 10], S13, 4294925233); + b = _FF(b, c, d, a, x[k + 11], S14, 2304563134); + a = _FF(a, b, c, d, x[k + 12], S11, 1804603682); + d = _FF(d, a, b, c, x[k + 13], S12, 4254626195); + c = _FF(c, d, a, b, x[k + 14], S13, 2792965006); + b = _FF(b, c, d, a, x[k + 15], S14, 1236535329); + a = _GG(a, b, c, d, x[k + 1], S21, 4129170786); + d = _GG(d, a, b, c, x[k + 6], S22, 3225465664); + c = _GG(c, d, a, b, x[k + 11], S23, 643717713); + b = _GG(b, c, d, a, x[k + 0], S24, 3921069994); + a = _GG(a, b, c, d, x[k + 5], S21, 3593408605); + d = _GG(d, a, b, c, x[k + 10], S22, 38016083); + c = _GG(c, d, a, b, x[k + 15], S23, 3634488961); + b = _GG(b, c, d, a, x[k + 4], S24, 3889429448); + a = _GG(a, b, c, d, x[k + 9], S21, 568446438); + d = _GG(d, a, b, c, x[k + 14], S22, 3275163606); + c = _GG(c, d, a, b, x[k + 3], S23, 4107603335); + b = _GG(b, c, d, a, x[k + 8], S24, 1163531501); + a = _GG(a, b, c, d, x[k + 13], S21, 2850285829); + d = _GG(d, a, b, c, x[k + 2], S22, 4243563512); + c = _GG(c, d, a, b, x[k + 7], S23, 1735328473); + b = _GG(b, c, d, a, x[k + 12], S24, 2368359562); + a = _HH(a, b, c, d, x[k + 5], S31, 4294588738); + d = _HH(d, a, b, c, x[k + 8], S32, 2272392833); + c = _HH(c, d, a, b, x[k + 11], S33, 1839030562); + b = _HH(b, c, d, a, x[k + 14], S34, 4259657740); + a = _HH(a, b, c, d, x[k + 1], S31, 2763975236); + d = _HH(d, a, b, c, x[k + 4], S32, 1272893353); + c = _HH(c, d, a, b, x[k + 7], S33, 4139469664); + b = _HH(b, c, d, a, x[k + 10], S34, 3200236656); + a = _HH(a, b, c, d, x[k + 13], S31, 681279174); + d = _HH(d, a, b, c, x[k + 0], S32, 3936430074); + c = _HH(c, d, a, b, x[k + 3], S33, 3572445317); + b = _HH(b, c, d, a, x[k + 6], S34, 76029189); + a = _HH(a, b, c, d, x[k + 9], S31, 3654602809); + d = _HH(d, a, b, c, x[k + 12], S32, 3873151461); + c = _HH(c, d, a, b, x[k + 15], S33, 530742520); + b = _HH(b, c, d, a, x[k + 2], S34, 3299628645); + a = _II(a, b, c, d, x[k + 0], S41, 4096336452); + d = _II(d, a, b, c, x[k + 7], S42, 1126891415); + c = _II(c, d, a, b, x[k + 14], S43, 2878612391); + b = _II(b, c, d, a, x[k + 5], S44, 4237533241); + a = _II(a, b, c, d, x[k + 12], S41, 1700485571); + d = _II(d, a, b, c, x[k + 3], S42, 2399980690); + c = _II(c, d, a, b, x[k + 10], S43, 4293915773); + b = _II(b, c, d, a, x[k + 1], S44, 2240044497); + a = _II(a, b, c, d, x[k + 8], S41, 1873313359); + d = _II(d, a, b, c, x[k + 15], S42, 4264355552); + c = _II(c, d, a, b, x[k + 6], S43, 2734768916); + b = _II(b, c, d, a, x[k + 13], S44, 1309151649); + a = _II(a, b, c, d, x[k + 4], S41, 4149444226); + d = _II(d, a, b, c, x[k + 11], S42, 3174756917); + c = _II(c, d, a, b, x[k + 2], S43, 718787259); + b = _II(b, c, d, a, x[k + 9], S44, 3951481745); + a = addUnsigned(a, AA); + b = addUnsigned(b, BB); + c = addUnsigned(c, CC); + d = addUnsigned(d, DD); + } + var temp = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d); + return temp.toLowerCase(); + } + }; + return md5; + } ]); +})(angular); \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/designer/logout.html b/src/main/resources/META-INF/resources/designer/logout.html new file mode 100644 index 000000000..fa1df329d --- /dev/null +++ b/src/main/resources/META-INF/resources/designer/logout.html @@ -0,0 +1,40 @@ + + + + + CLDS + +
+
+
You have been Logged Out successfully!
+
To login again, please click Login
+
+
diff --git a/src/main/resources/META-INF/resources/designer/menu_simplified.html b/src/main/resources/META-INF/resources/designer/menu_simplified.html new file mode 100644 index 000000000..0bee16015 --- /dev/null +++ b/src/main/resources/META-INF/resources/designer/menu_simplified.html @@ -0,0 +1,54 @@ + + + + + diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/extra_user_info.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/extra_user_info.html new file mode 100644 index 000000000..7fc043165 --- /dev/null +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/extra_user_info.html @@ -0,0 +1,49 @@ + + +
+ + + +
\ No newline at end of file diff --git a/src/main/resources/META-INF/resources/designer/please_wait.html b/src/main/resources/META-INF/resources/designer/please_wait.html new file mode 100644 index 000000000..8068e4cf5 --- /dev/null +++ b/src/main/resources/META-INF/resources/designer/please_wait.html @@ -0,0 +1,28 @@ + + + +
+

Please Wait.....{{urlparam}}

+ +
diff --git a/src/main/resources/META-INF/resources/designer/scripts/ExtraUserInfoCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/ExtraUserInfoCtrl.js new file mode 100644 index 000000000..f269b4134 --- /dev/null +++ b/src/main/resources/META-INF/resources/designer/scripts/ExtraUserInfoCtrl.js @@ -0,0 +1,37 @@ +/*- + * ============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. + */ + +app.controller('ExtraUserInfoCtrl', + ['$scope', '$rootScope', '$modalInstance','extraUserInfoService', '$location', 'dialogs', + function($scope, $rootScope, $modalInstance, extraUserInfoService, $location, dialogs) { + //console.log("///////////ExtraUserInfoCtrl"); + + extraUserInfoService.getUserInfo().then(function(pars){ + $scope.userInfo = pars; + }); + + $scope.close = function() { + $modalInstance.close("closed"); + }; + } +]); \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/designer/scripts/ExtraUserInfoService.js b/src/main/resources/META-INF/resources/designer/scripts/ExtraUserInfoService.js new file mode 100644 index 000000000..25dc37bd8 --- /dev/null +++ b/src/main/resources/META-INF/resources/designer/scripts/ExtraUserInfoService.js @@ -0,0 +1,41 @@ +/*- + * ============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. + */ +app.service('extraUserInfoService', ['$http', '$q', function($http, $q){ + //console.log("///////////extraUserInfoService"); + + this.getUserInfo = function(){ + var def = $q.defer(); + + var svcUrl = "/restservices/clds/v1/clds/cldsInfo"; + + $http.get(svcUrl) + .success(function(data){ + def.resolve(data); + }) + .error(function(data){ + def.reject("Retrieving User Info unsuccessful"); + }); + + return def.promise; + }; +}]); \ No newline at end of file diff --git a/src/main/resources/policyLogger.properties b/src/main/resources/policyLogger.properties new file mode 100644 index 000000000..2f1358bd3 --- /dev/null +++ b/src/main/resources/policyLogger.properties @@ -0,0 +1,47 @@ +### +# ============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. +### + +################################### Set concurrentHashMap and timer info ####################### +#Timer initial delay and the delay between in milliseconds before task is to be execute. +timer.delay.time=1000 +#Timer scheduleAtFixedRate period - time in milliseconds between successive task executions. +check.interval= 30000 +#Longest time an event info can be stored in the concurrentHashMap for logging - in seconds. +event.expired.time=86400 +#Size of the concurrentHashMap which stores the event starting time, etc - when its size reaches this limit, the Timer gets executed +#to remove all expired records from this concurrentHashMap. +concurrentHashMap.limit=5000 +#Size of the concurrentHashMap - when its size drops to this point, stop the Timer +stop.check.point=2500 +################################### Set logging format ############################################# +# set EELF for EELF logging format, set LOG4J for using log4j, set SYSTEMOUT for using system.out.println +logger.type=EELF +#################################### Set level for EELF or SYSTEMOUT logging ################################## +# Set level for debug file. Set DEBUG to enable .info, .warn and .debug; set INFO for enable .info and .warn; set OFF to disable all +debugLogger.level=INFO +# Set level for metrics file. Set OFF to disable; set ON to enable +metricsLogger.level=ON +# Set level for error file. Set OFF to disable; set ON to enable +error.level=ON +# Set level for audit file. Set OFF to disable; set ON to enable +audit.level=ON \ No newline at end of file -- cgit 1.2.3-korg From be0219b3b7f239bc5bba6d659c223a267ec4c0f5 Mon Sep 17 00:00:00 2001 From: xg353y Date: Thu, 17 Aug 2017 14:10:26 +0200 Subject: Code improvement Improve logging message; Introduce timeout for deploy/undeploy CL; Update allowed actions for deploy/undeploy/update action. Issue-id: CLAMP-43 Change-Id: Ic876e835447cc495d4ca42d9401ee4bd503d5db7 Signed-off-by: xg353y --- .../clamp/clds/client/DcaeDispatcherServices.java | 27 +++++++++++----------- .../onap/clamp/clds/client/SdcCatalogServices.java | 2 +- .../org/onap/clamp/clds/client/req/SdcReq.java | 1 + .../java/org/onap/clamp/clds/model/CldsModel.java | 8 +++---- .../org/onap/clamp/clds/service/CldsService.java | 10 ++++++++ .../org/onap/clamp/clds/util/LoggingUtils.java | 6 ++--- src/main/resources/META-INF/processes.xml | 8 +++++++ src/main/resources/clds/globalClds.properties | 2 +- 8 files changed, 41 insertions(+), 23 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java index 343391ebd..e5144bfe2 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java @@ -129,25 +129,26 @@ public class DcaeDispatcherServices { */ public String getOperationStatus(String statusUrl) throws Exception { - String opStatus = null; + //Assigning processing status to monitor operation status further + String opStatus = "processing"; InputStream in = null; try { URL obj = new URL(statusUrl); HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); conn.setRequestMethod("GET"); int responseCode = conn.getResponseCode(); - logger.debug("response code " + responseCode); - in = conn.getInputStream(); - String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n")); - JSONParser parser = new JSONParser(); - Object obj0 = parser.parse(res); - JSONObject jsonObj = (JSONObject) obj0; - String operationType = (String) jsonObj.get("operationType"); - String status = (String) jsonObj.get("status"); - logger.debug("Operation Type " + operationType); - logger.debug("Status " + status); - opStatus = status; - + logger.debug("Deployment operation status response code - " + responseCode); + if(responseCode == 200){ + in = conn.getInputStream(); + String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n")); + JSONParser parser = new JSONParser(); + Object obj0 = parser.parse(res); + JSONObject jsonObj = (JSONObject) obj0; + String operationType = (String) jsonObj.get("operationType"); + String status = (String) jsonObj.get("status"); + logger.debug("Operation Type - " + operationType + ", Status " + status); + opStatus = status; + } } catch (Exception e) { logger.debug(e.getClass().getName() + " " + e.getMessage()); logger.debug(e.getMessage() diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java index a009f06fd..df86977cd 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -108,7 +108,7 @@ public class SdcCatalogServices { } catch (Exception e) { LoggingUtils.setResponseContext("900", "Get sdc services failed", this.getClass().getName()); LoggingUtils.setErrorContext("900", "Get sdc services error"); - logger.error("not able to get any service information from sdc for uuid:" + uuid); + logger.error("not able to get any service information from sdc for uuid:" + uuid + " , exception is - " + e.getMessage()); } LoggingUtils.setTimeContext(startTime, new Date()); LoggingUtils.setTargetContext("SDC", "Get Services"); diff --git a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java index 8a31a3b95..08e196b7c 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java @@ -143,6 +143,7 @@ public class SdcReq { // "closedLoopControlName":"ClosedLoop-FRWL-SIG-0538e6f2-8c1b-4656-9999-3501b3c59ad7", configurationObjectNode.put("closedLoopControlName", prop.getControlName()); + configurationObjectNode.put("messageReaderConsumerGroup", prop.getModelName()); configurationObjectNode.set("serviceConfigurations", serviceConf); propsObject.put("deployment_JSON", deployJsonNode.toString()); String blueprint = yaml.dump(loadedYaml); diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java index e34f47d98..59db9b580 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java @@ -243,17 +243,15 @@ public class CldsModel { permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT); break; case CldsEvent.ACTION_UNDEPLOY: - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT); break; case CldsEvent.ACTION_DEPLOY: - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_UPDATE, - CldsEvent.ACTION_STOP); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP); break; case CldsEvent.ACTION_RESTART: case CldsEvent.ACTION_UPDATE: // for 1702 delete is not currently implemented - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP, - CldsEvent.ACTION_UNDEPLOY); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP, CldsEvent.ACTION_UNDEPLOY); break; case CldsEvent.ACTION_DELETE: if (getCurrentActionStateCd().equals(CldsEvent.ACTION_STATE_SENT)) { 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 aaeb03f60..509535c5b 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.UUID; +import java.util.concurrent.TimeUnit; import javax.annotation.PostConstruct; import javax.ws.rs.Consumes; @@ -916,7 +917,12 @@ public class CldsService extends SecureServiceBase { String createNewDeploymentStatusUrl = dcaeDispatcherServices.createNewDeployment(deploymentId, model.getTypeId()); String operationStatus = "processing"; + long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10); while (operationStatus.equalsIgnoreCase("processing")) { + //Break the loop if waiting for more than 10 mins + if(waitingTime < System.nanoTime()){ + break; + } operationStatus = dcaeDispatcherServices.getOperationStatus(createNewDeploymentStatusUrl); } if (operationStatus != null && operationStatus.equalsIgnoreCase("succeeded")) { @@ -956,7 +962,11 @@ public class CldsService extends SecureServiceBase { String operationStatusUndeployUrl = dcaeDispatcherServices.deleteExistingDeployment(model.getDeploymentId(), model.getTypeId()); String operationStatus = "processing"; + long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10); while (operationStatus.equalsIgnoreCase("processing")) { + if(waitingTime < System.nanoTime()){ + break; + } operationStatus = dcaeDispatcherServices.getOperationStatus(operationStatusUndeployUrl); } if (operationStatus != null && operationStatus.equalsIgnoreCase("succeeded")) { diff --git a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java index c47400689..8ceaa3d87 100644 --- a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java +++ b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java @@ -35,21 +35,21 @@ public class LoggingUtils { /** * Set request related logging variables in thread local data via MDC - * + * * @param service * Service Name of API (ex. "PUT template") * @param partner * Partner name (client or user invoking API) */ public static void setRequestContext(String service, String partner) { - MDC.put("RequestId", "clds-" + UUID.randomUUID().toString()); + MDC.put("RequestId", UUID.randomUUID().toString()); MDC.put("ServiceName", service); MDC.put("PartnerName", partner); } /** * Set time related logging variables in thread local data via MDC - * + * * @param beginTimeStamp * Start time * @param endTimeStamp diff --git a/src/main/resources/META-INF/processes.xml b/src/main/resources/META-INF/processes.xml index fddc60d1b..bd3547dfc 100644 --- a/src/main/resources/META-INF/processes.xml +++ b/src/main/resources/META-INF/processes.xml @@ -33,5 +33,13 @@ false + + default + bpmn/clds-process-action.bpmn + + true + false + + diff --git a/src/main/resources/clds/globalClds.properties b/src/main/resources/clds/globalClds.properties index 3402db324..f6607cb35 100644 --- a/src/main/resources/clds/globalClds.properties +++ b/src/main/resources/clds/globalClds.properties @@ -21,4 +21,4 @@ # ECOMP is a trademark and service mark of AT&T Intellectual Property. ### -globalCldsProps ={"collector":{"topicPublishes":{"DCAE-COLLECTOR-UCSNMP":"DCAE-COLLECTOR-UCSNMP"}},"string_match":{"topicPublishes":{"DCAE-CL-EVENT":"DCAE-CL-EVENT"},"aaiMatchingFields":{"cloud-region.identity-url":"cloud-region.identity-url","complex.city":"complex.city","complex.physical-location-id":"complex.physical-location-id","complex.state":"complex.state","generic-vnf.service-id":"generic-vnf.service-id","generic-vnf.vnf-name":"generic-vnf.vnf-name","generic-vnf.vnf-type":"generic-vnf.vnf-type","tenant.tenant-id":"tenant.tenant-id","vserver.in-maint":"vserver.in-maint","vserver.is-closed-loop-disabled":"vserver.is-closed-loop-disabled","vserver.l-interface.interface-name":"vserver.l-interface.interface-name","vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address":"vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address","vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address":"vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address","vserver.l-interface.network-name":"vserver.l-interface.network-name","vserver.prov-status":"vserver.prov-status","vserver.selflink":"vserver.selflink","vserver.vserver-id":"vserver.vserver-id","vserver.vserver-name":"vserver.vserver-name"},"aaiSendFields":{"cloud-region.identity-url":"cloud-region.identity-url","complex.city":"complex.city","complex.physical-location-id":"complex.physical-location-id","complex.state":"complex.state","generic-vnf.service-id":"generic-vnf.service-id","generic-vnf.vnf-name":"generic-vnf.vnf-name","generic-vnf.vnf-type":"generic-vnf.vnf-type","tenant.tenant-id":"tenant.tenant-id","vserver.in-maint":"vserver.in-maint","vserver.is-closed-loop-disabled":"vserver.is-closed-loop-disabled","vserver.l-interface.interface-name":"vserver.l-interface.interface-name","vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address":"vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address","vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address":"vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address","vserver.l-interface.network-name":"vserver.l-interface.network-name","vserver.prov-status":"vserver.prov-status","vserver.selflink":"vserver.selflink","vserver.vserver-id":"vserver.vserver-id","vserver.vserver-name":"vserver.vserver-name"},"eventSourceType":{"f5BigIP":"f5BigIP","vSBG_Alarms":"vSBG_Alarms","vCTS_Alarms":"vCTS_Alarms"},"eventSeverity":{"NORMAL":"NORMAL","not-NORMAL":"not-NORMAL","OK":"OK","WARNING":"WARNING","MINOR":"MINOR","MAJOR":"MAJOR","CRITICAL":"CRITICAL"},"timeWindow":0,"ageLimit":1600,"outputEventName":{"":"","ONSET":"ONSET","ABATED":"ABATED"},"createClosedLoopEventId":{"Initial":"Initial","Close":"Close"}},"tca":{"tname":"New_Set","tcaInt":"1","tcaVio":"1","tcaSev":{"Normal":"Normal","Critical":"Critical","Major":"Major","Minor":"Minor","Warning":"Warning"},"fieldPath":{"FIELDPATH_test_1":"FIELDPATH_test_1","FIELDPATH_test_2":"FIELDPATH_test_2"},"operator":{">":"GREATER","=":"EQUAL","<":"LESS"},"opsPolicy":{"POLICY_test_X":"POLICY_test_X","POLICY_test_Y":"POLICY_test_Y"}},"global":{"actionSet":{"vnfRecipe":"VNF", "enbRecipe":"eNodeB"},"location":{"SNDGCA64":"San Diego SAN3","ALPRGAED":"Alpharetta PDK1","LSLEILAA":"Lisle DPA3","MDTWNJC1":"FTL_C_location1","MDTWNJC2":"FTL_C_location2","MDTWNJ21":"FTL_L_location1","MDTWNJ22":"FTL_L_location2","RDM2WAGPLCP":"ISTFTL_location","RDM3":"RDM3WAGPLCP"}},"policy":{"pname":"0","timeout":345,"vnfRecipe":{"":"","restart":"Restart","rebuild":"Rebuild","migrate":"Migrate","healthCheck":"Health Check"},"enbRecipe":{"":"","reset":"Reset"},"maxRetries":"3","retryTimeLimit":180,"resource":{"vCTS":"vCTS","v3CDB":"v3CDB","vUDR":"vUDR","vCOM":"vCOM","vRAR":"vRAR","vLCS":"vLCS","vUDR-BE":"vUDR-BE","vDBE":"vDBE"},"parentPolicyConditions":{"Failure_Retries":"Failure: Max Retries Exceeded","Failure_Timeout":"Failure: Time Limit Exceeded","Failure_Guard":"Failure: Guard","Failure_Exception":"Failure: Exception","Failure":"Failure: Other","Success":"Success"}},"shared":{"byService":{"":{"vf":{"":""},"location":{"":""},"alarmCondition":{"":""}}},"byVf":{"":{"vfc":{"":""}}}}} \ No newline at end of file +globalCldsProps ={"collector":{"topicPublishes":{"DCAE-COLLECTOR-UCSNMP":"DCAE-COLLECTOR-UCSNMP"}},"string_match":{"topicPublishes":{"DCAE-CL-EVENT":"DCAE-CL-EVENT"},"aaiMatchingFields":{"cloud-region.identity-url":"cloud-region.identity-url","complex.city":"complex.city","complex.physical-location-id":"complex.physical-location-id","complex.state":"complex.state","generic-vnf.service-id":"generic-vnf.service-id","generic-vnf.vnf-name":"generic-vnf.vnf-name","generic-vnf.vnf-type":"generic-vnf.vnf-type","tenant.tenant-id":"tenant.tenant-id","vserver.in-maint":"vserver.in-maint","vserver.is-closed-loop-disabled":"vserver.is-closed-loop-disabled","vserver.l-interface.interface-name":"vserver.l-interface.interface-name","vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address":"vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address","vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address":"vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address","vserver.l-interface.network-name":"vserver.l-interface.network-name","vserver.prov-status":"vserver.prov-status","vserver.selflink":"vserver.selflink","vserver.vserver-id":"vserver.vserver-id","vserver.vserver-name":"vserver.vserver-name"},"aaiSendFields":{"cloud-region.identity-url":"cloud-region.identity-url","complex.city":"complex.city","complex.physical-location-id":"complex.physical-location-id","complex.state":"complex.state","generic-vnf.service-id":"generic-vnf.service-id","generic-vnf.vnf-name":"generic-vnf.vnf-name","generic-vnf.vnf-type":"generic-vnf.vnf-type","tenant.tenant-id":"tenant.tenant-id","vserver.in-maint":"vserver.in-maint","vserver.is-closed-loop-disabled":"vserver.is-closed-loop-disabled","vserver.l-interface.interface-name":"vserver.l-interface.interface-name","vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address":"vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address","vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address":"vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address","vserver.l-interface.network-name":"vserver.l-interface.network-name","vserver.prov-status":"vserver.prov-status","vserver.selflink":"vserver.selflink","vserver.vserver-id":"vserver.vserver-id","vserver.vserver-name":"vserver.vserver-name"},"eventSourceType":{"f5BigIP":"f5BigIP","vSBG_Alarms":"vSBG_Alarms","vCTS_Alarms":"vCTS_Alarms"},"eventSeverity":{"NORMAL":"NORMAL","not-NORMAL":"not-NORMAL","OK":"OK","WARNING":"WARNING","MINOR":"MINOR","MAJOR":"MAJOR","CRITICAL":"CRITICAL"},"timeWindow":0,"ageLimit":1600,"outputEventName":{"":"","ONSET":"ONSET","ABATED":"ABATED"},"createClosedLoopEventId":{"Initial":"Initial","Close":"Close"}},"tca":{"tname":"New_Set","tcaInt":"1","tcaVio":"1","tcaSev":{"NORMAL":"NORMAL","CRITICAL":"CRITICAL","MAJOR":"MAJOR","MINOR":"MINOR","WARNING":"WARNING"},"fieldPath":{"FIELDPATH_test_1":"FIELDPATH_test_1","FIELDPATH_test_2":"FIELDPATH_test_2"},"operator":{">":"GREATER","=":"EQUAL","<":"LESS"},"opsPolicy":{"POLICY_test_X":"POLICY_test_X","POLICY_test_Y":"POLICY_test_Y"}},"global":{"actionSet":{"vnfRecipe":"VNF", "enbRecipe":"eNodeB"},"location":{"SNDGCA64":"San Diego SAN3","ALPRGAED":"Alpharetta PDK1","LSLEILAA":"Lisle DPA3","MDTWNJC1":"FTL_C_location1","MDTWNJC2":"FTL_C_location2","MDTWNJ21":"FTL_L_location1","MDTWNJ22":"FTL_L_location2","RDM2WAGPLCP":"ISTFTL_location","RDM3":"RDM3WAGPLCP"}},"policy":{"pname":"0","timeout":345,"vnfRecipe":{"":"","restart":"Restart","rebuild":"Rebuild","migrate":"Migrate","healthCheck":"Health Check"},"enbRecipe":{"":"","reset":"Reset"},"maxRetries":"3","retryTimeLimit":180,"resource":{"vCTS":"vCTS","v3CDB":"v3CDB","vUDR":"vUDR","vCOM":"vCOM","vRAR":"vRAR","vLCS":"vLCS","vUDR-BE":"vUDR-BE","vDBE":"vDBE"},"parentPolicyConditions":{"Failure_Retries":"Failure: Max Retries Exceeded","Failure_Timeout":"Failure: Time Limit Exceeded","Failure_Guard":"Failure: Guard","Failure_Exception":"Failure: Exception","Failure":"Failure: Other","Success":"Success"}},"shared":{"byService":{"":{"vf":{"":""},"location":{"":""},"alarmCondition":{"":""}}},"byVf":{"":{"vfc":{"":""}}}}} \ No newline at end of file -- cgit 1.2.3-korg From 0627eb6d8ef545725c7828a0e11a85788495982a Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 03:54:36 -0700 Subject: Rename the CldsSecurityConfig This was unclear that this class was related to the Clds Users, so it has to be renamed Change-Id: Ia93bc24d4940a017274e55d06075f60954c75cc3 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/config/CldsSecurityConfig.java | 86 ---------------- .../clamp/clds/config/CldsSecurityConfigUsers.java | 111 +++++++++++++++++++++ 2 files changed, 111 insertions(+), 86 deletions(-) delete mode 100644 src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java create mode 100644 src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java deleted file mode 100644 index 7e6021c2b..000000000 --- a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfig.java +++ /dev/null @@ -1,86 +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.onap.clamp.clds.service.CldsUser; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@Configuration -@EnableWebSecurity -@Profile("clamp-spring-authentication") -public class CldsSecurityConfig extends WebSecurityConfigurerAdapter { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSecurityConfig.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - - @Autowired - private ApplicationContext appContext; - - @Value("${org.onap.clamp.config.files.cldsUsers:'classpath:etc/config/clds/clds-users.json'}") - private String cldsUsersFile; - - @Value("${CLDS_PERMISSION_TYPE_CL:permission-type-cl}") - private String cldsPersmissionTypeCl; - - @Value("${CLDS_PERMISSION_INSTANCE:dev}") - private String cldsPermissionInstance; - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().httpBasic().and().authorizeRequests().antMatchers("/restservices/clds/v1/user/**") - .authenticated().anyRequest().permitAll().and().logout(); - } - - @Autowired - public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - CldsUser[] usersList = loadUsers(); - - // no users defined - if (null == usersList) { - logger.warn("No users defined. Users should be defined under " + cldsUsersFile); - return; - } - - for (CldsUser user : usersList) { - auth.inMemoryAuthentication().withUser(user.getUser()).password(user.getPassword()) - .roles(user.getPermissionsString()); - } - } - - private CldsUser[] loadUsers() throws Exception { - logger.info("Load from clds-users.properties"); - return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream()); - } -} diff --git a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java new file mode 100644 index 000000000..a187ac556 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java @@ -0,0 +1,111 @@ +/*- + * ============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.onap.clamp.clds.service.CldsUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +/** + * This class is used to enable the HTTP authentication to login. It requires a + * specific JSON file containing the user definition + * (classpath:etc/config/clds/clds-users.json). + * + */ +@Configuration +@EnableWebSecurity +@Profile("clamp-spring-authentication") +public class CldsSecurityConfigUsers extends WebSecurityConfigurerAdapter { + + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(CldsSecurityConfigUsers.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + @Autowired + private ApplicationContext appContext; + + @Value("${org.onap.clamp.config.files.cldsUsers:'classpath:etc/config/clds/clds-users.json'}") + private String cldsUsersFile; + + @Value("${CLDS_PERMISSION_TYPE_CL:permission-type-cl}") + private String cldsPersmissionTypeCl; + + @Value("${CLDS_PERMISSION_INSTANCE:dev}") + private String cldsPermissionInstance; + + /** + * This method configures on which URL the authorization will be enabled. + */ + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable().httpBasic().and().authorizeRequests().antMatchers("/restservices/clds/v1/user/**") + .authenticated().anyRequest().permitAll().and().logout(); + } + + /** + * This method is called by the framework and is used to load all the users + * defined in cldsUsersFile variable (this file path can be configured in + * the application.properties). + * + * @param auth + * @throws Exception + */ + @Autowired + public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { + CldsUser[] usersList = loadUsers(); + + // no users defined + if (null == usersList) { + logger.warn("No users defined. Users should be defined under " + cldsUsersFile); + return; + } + + for (CldsUser user : usersList) { + auth.inMemoryAuthentication().withUser(user.getUser()).password(user.getPassword()) + .roles(user.getPermissionsString()); + } + } + + /** + * This method loads physically the JSON file and convert it to an Array of + * CldsUser. + * + * @return The array of CldsUser + * @throws Exception + */ + private CldsUser[] loadUsers() throws Exception { + logger.info("Load from clds-users.properties"); + return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream()); + } +} -- cgit 1.2.3-korg From f527ac93d843bd545bd6637cb012378c75a62e65 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 04:12:52 -0700 Subject: Add dynamic ports for HTTP/HTTPS The ports can now be configured in the application.properties and the both protocols can run at the same time (HTTP+HTTPS) Change-Id: I57d1b5643df33da45af2f6798923d94bff1d560d Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/Application.java | 68 +++++- ...EmbeddedServletContainerFactoryRedirection.java | 55 +++++ src/main/resources/application.properties | 269 ++++++++++++--------- src/test/java/org/onap/clamp/clds/it/HttpsIT.java | 143 +++++++++++ src/test/resources/https/https-test.properties | 152 ++++++++++++ src/test/resources/https/keystore-test.jks | Bin 0 -> 2244 bytes 6 files changed, 567 insertions(+), 120 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java create mode 100644 src/test/java/org/onap/clamp/clds/it/HttpsIT.java create mode 100644 src/test/resources/https/https-test.properties create mode 100644 src/test/resources/https/keystore-test.jks (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index 037935175..bebb07844 100644 --- a/src/main/java/org/onap/clamp/clds/Application.java +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -30,7 +30,10 @@ 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.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -39,13 +42,18 @@ import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfig import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; 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; import com.att.ajsc.common.utility.SystemPropertiesLoader; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; @SpringBootApplication @ComponentScan(basePackages = { "org.onap.clamp.clds", "com.att.ajsc" }) @@ -55,8 +63,29 @@ import com.att.ajsc.common.utility.SystemPropertiesLoader; @EnableAsync public class Application extends SpringBootServletInitializer { - private static final String CAMEL_SERVLET_NAME = "CamelServlet"; - private static final String CAMEL_URL_MAPPING = "/restservices/clds/v1/*"; + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Application.class); + + @Autowired + protected ApplicationContext appContext; + + private static final String CAMEL_SERVLET_NAME = "CamelServlet"; + private static final String CAMEL_URL_MAPPING = "/restservices/clds/v1/*"; + + // 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; + + /** + * 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; + + @Value("${server.ssl.key-store:none}") + private String sslKeystoreFile; @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { @@ -84,4 +113,39 @@ public class Application extends SpringBootServletInitializer { return ClientBuilder.newClient(); } + /** + * This method is used by Spring to create the servlet container factory. + * + * @return The TomcatEmbeddedServletContainerFactory just created + */ + @Bean + public EmbeddedServletContainerFactory getEmbeddedServletContainerFactory() { + TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(); + if (!"none".equals(httpRedirectedPort) && !"none".equals(sslKeystoreFile)) { + // Automatically redirect to HTTPS + tomcat = new TomcatEmbeddedServletContainerFactoryRedirection(); + Connector newConnector = createRedirectConnector(Integer.parseInt(springServerPort)); + if (newConnector != null) { + tomcat.addAdditionalTomcatConnectors(newConnector); + } + + } + return tomcat; + + } + + private Connector createRedirectConnector(int redirectSecuredPort) { + if (redirectSecuredPort <= 0) { + logger.warn( + "HTTP port redirection to HTTPS is disabled because the HTTPS port is 0 (random port) or -1 (Connector disabled)"); + return null; + } + Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); + connector.setScheme("http"); + connector.setSecure(false); + connector.setPort(Integer.parseInt(httpRedirectedPort)); + connector.setRedirectPort(redirectSecuredPort); + return connector; + } + } diff --git a/src/main/java/org/onap/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java b/src/main/java/org/onap/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java new file mode 100644 index 000000000..2878140f9 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java @@ -0,0 +1,55 @@ +/*- + * ============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; + +import org.apache.catalina.Context; +import org.apache.tomcat.util.descriptor.web.SecurityCollection; +import org.apache.tomcat.util.descriptor.web.SecurityConstraint; +import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; + +/** + * This class is a factory that redirects by default all HTTP to HTTPS + * connector. It is used by the Application.java class and defined in a Spring + * Bean. + * + * In order to do this, the method postProcessContext has been overridden to + * provide another behavior. + * + */ +public class TomcatEmbeddedServletContainerFactoryRedirection extends TomcatEmbeddedServletContainerFactory { + + /** + * This method is there to force the automatic redirection of all calls done + * on the tomcat server to a Secure connection. + */ + @Override + protected void postProcessContext(Context context) { + SecurityConstraint securityConstraint = new SecurityConstraint(); + securityConstraint.setUserConstraint("CONFIDENTIAL"); + SecurityCollection collection = new SecurityCollection(); + collection.addPattern("/*"); + securityConstraint.addCollection(collection); + context.addConstraint(securityConstraint); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ce4158bbd..9ed7c6ede 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,119 +1,152 @@ -### -# ============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. -### - -info.build.artifact=@project.artifactId@ -info.build.name=@project.name@ -info.build.description=@project.description@ -info.build.version=@project.version@ - - -server.contextPath=/ -#Modified engine-rest applicationpath -spring.jersey.application-path=/engine-rest -spring.profiles.active=clamp-default,clamp-spring-authentication -spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration - -#The max number of active threads in this pool -server.tomcat.max-threads=200 -#The minimum number of threads always kept alive -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. - -camel.springboot.consumer-template-cache-size=1000 -camel.springboot.producer-template-cache-size=1000 -camel.springboot.jmx-enabled=true -camel.defaultthreadpool.poolsize=10 -camel.defaultthreadpool.maxpoolsize=20 -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.url=jdbc:mysql://localhost:${docker.mariadb.port.host}/camundabpm?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 -spring.datasource.camunda.username=camunda -spring.datasource.camunda.password=ndMSpw4CAM -spring.datasource.camunda.driverClassName=com.mysql.jdbc.Driver -spring.datasource.camunda.validationQuery=SELECT 1 -spring.datasource.camunda.validationQueryTimeout=20000 -spring.datasource.camunda.validationInterval=60000 -spring.datasource.camunda.testWhileIdle = true -# Automatically test whether a connection provided is good or not -spring.datasource.camunda.testOnBorrow=true - -#Camunda application properties -#Camunda history level -camunda.bpm.history-level=auto - -#clds datasource connection details -spring.datasource.cldsdb.driver-class-name=com.mysql.jdbc.Driver -spring.datasource.cldsdb.url=jdbc:mysql://localhost:${docker.mariadb.port.host}/cldsdb4?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 -spring.datasource.cldsdb.username=clds -spring.datasource.cldsdb.password=sidnnd83K -spring.datasource.cldsdb.driverClassName=com.mysql.jdbc.Driver -spring.datasource.cldsdb.validationQuery=SELECT 1 -spring.datasource.cldsdb.validationQueryTimeout=20000 -spring.datasource.cldsdb.validationInterval=60000 -spring.datasource.cldsdb.testWhileIdle = true -# Automatically test whether a connection provided is good or not -spring.datasource.cldsdb.testOnBorrow=true - -#Async Executor default Parameters -async.core.pool.size=10 -async.max.pool.size=20 -async.queue.capacity=500 - -org.onap.clamp.config.dcae.url=http://localhost:9000/closedloop-dcae-services - -#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 -org.onap.clamp.config.files.globalClds=classpath:/clds/globalClds.properties - -#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! -CLDS_PERMISSION_TYPE_CL=permission-type-cl -CLDS_PERMISSION_TYPE_CL_MANAGE=permission-type-cl-manage -CLDS_PERMISSION_TYPE_CL_EVENT=permission-type-cl-event -CLDS_PERMISSION_TYPE_FILTER_VF=permission-type-filter-vf -CLDS_PERMISSION_TYPE_TEMPLATE=permission-type-template -#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties +### +# ============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. +### + +info.build.artifact=@project.artifactId@ +info.build.name=@project.name@ +info.build.description=@project.description@ +info.build.version=@project.version@ + +### Set the port for HTTP or HTTPS protocol (Controlled by Spring framework, only one at a time). +### (See below for the parameter 'server.http.port' if you want to have both enabled) +### To have only HTTP, keep the lines server.ssl.* commented +### To have only HTTPS enabled, uncomment the server.ssl.* lines and specify a right keystore location +server.port=8080 +### Settings for HTTPS (this automatically enables the HTTPS on the port 'server.port') +#server.ssl.key-store=file:/tmp/mykey.jks +#server.ssl.key-store-password=pass +#server.ssl.key-password=pass + +### 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 ...) +#server.http-to-https-redirection.port=8090 + +### HTTP Example: +###-------------- +### server.port=8080 + +### HTTPS Example: +### -------------- +### server.port=8443 +### server.ssl.key-store=file:/tmp/mykey.jks +### server.ssl.key-store-password=mypass +### server.ssl.key-password=mypass + +### HTTP (Redirected to HTTPS) and HTTPS Example: +### -------------------------------------------- +### server.port=8443 <-- The HTTPS port +### server.ssl.key-store=file:/tmp/mykey.jks +### server.ssl.key-store-password=mypass +### server.ssl.key-password=mypass +### server.http-to-https-redirection.port=8090 <-- The HTTP port + +server.contextPath=/ +#Modified engine-rest applicationpath +spring.jersey.application-path=/engine-rest +spring.profiles.active=clamp-default,clamp-spring-authentication +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration + +#The max number of active threads in this pool +server.tomcat.max-threads=200 +#The minimum number of threads always kept alive +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. + +camel.springboot.consumer-template-cache-size=1000 +camel.springboot.producer-template-cache-size=1000 +camel.springboot.jmx-enabled=true +camel.defaultthreadpool.poolsize=10 +camel.defaultthreadpool.maxpoolsize=20 +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.url=jdbc:mysql://localhost:${docker.mariadb.port.host}/camundabpm?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.camunda.username=camunda +spring.datasource.camunda.password=ndMSpw4CAM +spring.datasource.camunda.driverClassName=com.mysql.jdbc.Driver +spring.datasource.camunda.validationQuery=SELECT 1 +spring.datasource.camunda.validationQueryTimeout=20000 +spring.datasource.camunda.validationInterval=60000 +spring.datasource.camunda.testWhileIdle = true +# Automatically test whether a connection provided is good or not +spring.datasource.camunda.testOnBorrow=true + +#Camunda application properties +#Camunda history level +camunda.bpm.history-level=auto + +#clds datasource connection details +spring.datasource.cldsdb.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.cldsdb.url=jdbc:mysql://localhost:${docker.mariadb.port.host}/cldsdb4?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.cldsdb.username=clds +spring.datasource.cldsdb.password=sidnnd83K +spring.datasource.cldsdb.driverClassName=com.mysql.jdbc.Driver +spring.datasource.cldsdb.validationQuery=SELECT 1 +spring.datasource.cldsdb.validationQueryTimeout=20000 +spring.datasource.cldsdb.validationInterval=60000 +spring.datasource.cldsdb.testWhileIdle = true +# Automatically test whether a connection provided is good or not +spring.datasource.cldsdb.testOnBorrow=true + +#Async Executor default Parameters +async.core.pool.size=10 +async.max.pool.size=20 +async.queue.capacity=500 + +org.onap.clamp.config.dcae.url=http://localhost:9000/closedloop-dcae-services + +#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 +org.onap.clamp.config.files.globalClds=classpath:/clds/globalClds.properties + +#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! +CLDS_PERMISSION_TYPE_CL=permission-type-cl +CLDS_PERMISSION_TYPE_CL_MANAGE=permission-type-cl-manage +CLDS_PERMISSION_TYPE_CL_EVENT=permission-type-cl-event +CLDS_PERMISSION_TYPE_FILTER_VF=permission-type-filter-vf +CLDS_PERMISSION_TYPE_TEMPLATE=permission-type-template +#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties CLDS_PERMISSION_INSTANCE=dev \ No newline at end of file diff --git a/src/test/java/org/onap/clamp/clds/it/HttpsIT.java b/src/test/java/org/onap/clamp/clds/it/HttpsIT.java new file mode 100644 index 000000000..ff6303306 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/it/HttpsIT.java @@ -0,0 +1,143 @@ +/*- + * ============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.it; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; +import java.net.HttpURLConnection; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.clamp.clds.AbstractIT; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; + +/** + * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE + * Delegates in test. + */ +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) +@TestPropertySource(locations = "classpath:https/https-test.properties") +public class HttpsIT extends AbstractIT { + + @Value("${server.port}") + private String httpsPort; + + @Value("${server.http-to-https-redirection.port}") + private String httpPort; + + @BeforeClass + public static void setUp() { + + try { + // setup ssl context to ignore certificate errors + SSLContext ctx = SSLContext.getInstance("TLS"); + X509TrustManager tm = new X509TrustManager() { + + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) + throws java.security.cert.CertificateException { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) + throws java.security.cert.CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + }; + ctx.init(null, new TrustManager[] { tm }, null); + SSLContext.setDefault(ctx); + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + + @Test + public void testDesignerIndex() throws Exception { + RestTemplate template = new RestTemplate(); + final MySimpleClientHttpRequestFactory factory = new MySimpleClientHttpRequestFactory(new HostnameVerifier() { + + @Override + public boolean verify(final String hostname, final SSLSession session) { + return true; + } + }); + template.setRequestFactory(factory); + + ResponseEntity entity = template + .getForEntity("http://localhost:" + this.httpPort + "/designer/index.html", String.class); + assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND); + + ResponseEntity httpsEntity = template + .getForEntity("https://localhost:" + this.httpsPort + "/designer/index.html", String.class); + assertThat(httpsEntity.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat(httpsEntity.getBody()).contains("CLDS"); + + } + + /** + * Http Request Factory for ignoring SSL hostname errors. Not for production + * use! + */ + class MySimpleClientHttpRequestFactory extends SimpleClientHttpRequestFactory { + + private final HostnameVerifier verifier; + + public MySimpleClientHttpRequestFactory(final HostnameVerifier verifier) { + this.verifier = verifier; + } + + @Override + protected void prepareConnection(final HttpURLConnection connection, final String httpMethod) + throws IOException { + if (connection instanceof HttpsURLConnection) { + ((HttpsURLConnection) connection).setHostnameVerifier(this.verifier); + } + super.prepareConnection(connection, httpMethod); + } + } + +} diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties new file mode 100644 index 000000000..f38a46428 --- /dev/null +++ b/src/test/resources/https/https-test.properties @@ -0,0 +1,152 @@ +### +# ============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. +### + +info.build.artifact=@project.artifactId@ +info.build.name=@project.name@ +info.build.description=@project.description@ +info.build.version=@project.version@ + +### Set the port for HTTP or HTTPS protocol (Controlled by Spring framework, only one at a time). +### (See below for the parameter 'server.http.port' if you want to have both enabled) +### To have only HTTP, keep the lines server.ssl.* commented +### To have only HTTPS enabled, uncomment the server.ssl.* lines and specify a right keystore location +server.port=10443 +### Settings for HTTPS (this automatically enables the HTTPS on the port 'server.port') +server.ssl.key-store=classpath:https/keystore-test.jks +server.ssl.key-store-password=testpass +server.ssl.key-password=testpass + +### 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 ...) +server.http-to-https-redirection.port=10080 + +### HTTP Example: +###-------------- +### server.port=8080 + +### HTTPS Example: +### -------------- +### server.port=8443 +### server.ssl.key-store=file:/tmp/mykey.jks +### server.ssl.key-store-password=mypass +### server.ssl.key-password=mypass + +### HTTP (Redirected to HTTPS) and HTTPS Example: +### -------------------------------------------- +### server.port=8443 <-- The HTTPS port +### server.ssl.key-store=file:/tmp/mykey.jks +### server.ssl.key-store-password=mypass +### server.ssl.key-password=mypass +### server.http-to-https-redirection.port=8090 <-- The HTTP port + +server.contextPath=/ +#Modified engine-rest applicationpath +spring.jersey.application-path=/engine-rest +spring.profiles.active=clamp-default,clamp-spring-authentication +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration + +#The max number of active threads in this pool +server.tomcat.max-threads=200 +#The minimum number of threads always kept alive +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. + +camel.springboot.consumer-template-cache-size=1000 +camel.springboot.producer-template-cache-size=1000 +camel.springboot.jmx-enabled=true +camel.defaultthreadpool.poolsize=10 +camel.defaultthreadpool.maxpoolsize=20 +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.url=jdbc:mysql://localhost:${docker.mariadb.port.host}/camundabpm?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.camunda.username=camunda +spring.datasource.camunda.password=ndMSpw4CAM +spring.datasource.camunda.driverClassName=com.mysql.jdbc.Driver +spring.datasource.camunda.validationQuery=SELECT 1 +spring.datasource.camunda.validationQueryTimeout=20000 +spring.datasource.camunda.validationInterval=60000 +spring.datasource.camunda.testWhileIdle = true +# Automatically test whether a connection provided is good or not +spring.datasource.camunda.testOnBorrow=true + +#Camunda application properties +#Camunda history level +camunda.bpm.history-level=auto + +#clds datasource connection details +spring.datasource.cldsdb.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.cldsdb.url=jdbc:mysql://localhost:${docker.mariadb.port.host}/cldsdb4?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.cldsdb.username=clds +spring.datasource.cldsdb.password=sidnnd83K +spring.datasource.cldsdb.driverClassName=com.mysql.jdbc.Driver +spring.datasource.cldsdb.validationQuery=SELECT 1 +spring.datasource.cldsdb.validationQueryTimeout=20000 +spring.datasource.cldsdb.validationInterval=60000 +spring.datasource.cldsdb.testWhileIdle = true +# Automatically test whether a connection provided is good or not +spring.datasource.cldsdb.testOnBorrow=true + +#Async Executor default Parameters +async.core.pool.size=10 +async.max.pool.size=20 +async.queue.capacity=500 + +org.onap.clamp.config.dcae.url=http://localhost:9000/closedloop-dcae-services + +#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 +org.onap.clamp.config.files.globalClds=classpath:/clds/globalClds.properties + +#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! +CLDS_PERMISSION_TYPE_CL=permission-type-cl +CLDS_PERMISSION_TYPE_CL_MANAGE=permission-type-cl-manage +CLDS_PERMISSION_TYPE_CL_EVENT=permission-type-cl-event +CLDS_PERMISSION_TYPE_FILTER_VF=permission-type-filter-vf +CLDS_PERMISSION_TYPE_TEMPLATE=permission-type-template +#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties +CLDS_PERMISSION_INSTANCE=dev \ No newline at end of file diff --git a/src/test/resources/https/keystore-test.jks b/src/test/resources/https/keystore-test.jks new file mode 100644 index 000000000..04ad3b114 Binary files /dev/null and b/src/test/resources/https/keystore-test.jks differ -- cgit 1.2.3-korg From 180d25d8a83bd521f82441b5caa68e9153e86d98 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 04:25:26 -0700 Subject: Rework the format of this file The formatting was not correct and the imports were not sorted properly (according to Checkstyle) Change-Id: I4e0ddf8c2d493b41a335fd18070ccf285a43081d Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../clds/client/req/OperationalPolicyReq.java | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java index 41629cc11..950fcefe5 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -38,11 +38,11 @@ import org.onap.clamp.clds.model.prop.PolicyChain; import org.onap.clamp.clds.model.prop.PolicyItem; import org.onap.clamp.clds.model.prop.Tca; import org.onap.clamp.clds.model.refprop.RefProp; -import org.onap.policy.controlloop.policy.OperationsAccumulateParams; import org.onap.policy.api.AttributeType; import org.onap.policy.asdc.Resource; import org.onap.policy.asdc.ResourceType; import org.onap.policy.asdc.Service; +import org.onap.policy.controlloop.policy.OperationsAccumulateParams; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.controlloop.policy.Target; @@ -274,21 +274,20 @@ public class OperationalPolicyReq { Target target = new Target(); target.setType(TargetType.VM); Policy lastPolicyObj = new Policy(); - for (int i = 0; i < policyItemList.size(); i++) { + for (int i = 0; i < policyItemList.size(); i++) { org.onap.policy.controlloop.policy.Policy policyObj; PolicyItem policyItem = policyItemList.get(i); String policyName = policyItem.getRecipe() + " Policy"; if (i == 0) { - //To set up time window payload for trigger policy - Map payloadMap = new HashMap(); - payloadMap.put("timeWindow", refProp.getStringValue("op.eNodeB.timeWindow")); - String policyDescription = policyItem.getRecipe() + // To set up time window payload for trigger policy + Map payloadMap = new HashMap(); + payloadMap.put("timeWindow", refProp.getStringValue("op.eNodeB.timeWindow")); + String policyDescription = policyItem.getRecipe() + " Policy - the trigger (no parent) policy - created by CLDS"; policyObj = builder.setTriggerPolicy(policyName, policyDescription, policyItem.getActor(), target, policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit()); } else { - Policy parentPolicyObj = policyObjMap - .get(policyItem.getParentPolicy()); + Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy()); String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + parentPolicyObj.getName() + " - created by CLDS"; policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, policyItem.getActor(), @@ -300,12 +299,12 @@ public class OperationalPolicyReq { } policyObjMap.put(policyItem.getId(), policyObj); } - //To set up operations accumulate params - OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); - operationsAccumulateParams.setLimit(Integer.valueOf(refProp.getStringValue("op.eNodeB.limit"))); - operationsAccumulateParams.setPeriod(refProp.getStringValue("op.eNodeB.period")); - builder.addOperationsAccumulateParams(lastPolicyObj.getId(), operationsAccumulateParams); - + // To set up operations accumulate params + OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); + operationsAccumulateParams.setLimit(Integer.valueOf(refProp.getStringValue("op.eNodeB.limit"))); + operationsAccumulateParams.setPeriod(refProp.getStringValue("op.eNodeB.period")); + builder.addOperationsAccumulateParams(lastPolicyObj.getId(), operationsAccumulateParams); + // // Build the specification // -- cgit 1.2.3-korg From b339fbb09781e0761bec61ad37126d6241133d70 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 04:26:28 -0700 Subject: Rework the javadoc The javadoc was not correct for this file according to Checkstyle Change-Id: I608774f32816f48ec86143888cf7bd9368aad1df Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../java/org/onap/clamp/clds/client/req/SdcReq.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java index 08e196b7c..3c16ce60b 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java @@ -62,12 +62,22 @@ public class SdcReq { protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); /** + * Format the Blueprint from a Yaml + * * @param refProp + * The RefProp instance containing the Clds config * @param prop - * @return + * The ModelProperties describing the clds model + * @param docText + * The Yaml file that must be converted + * + * @return A String containing the BluePrint * @throws JsonParseException + * In case of issues * @throws JsonMappingException + * In case of issues * @throws IOException + * In case of issues */ public static String formatBlueprint(RefProp refProp, ModelProperties prop, String docText) throws JsonParseException, JsonMappingException, IOException { @@ -346,7 +356,14 @@ public class SdcReq { return "Basic " + idPw; } - private static String getYamlvalue(String docText) throws IOException { + /** + * Method to get yaml/template properties value from json + * + * @param docText + * @return + * @throws IOException + */ + public static String getYamlvalue(String docText) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); String yamlFileValue = ""; ObjectNode root = objectMapper.readValue(docText, ObjectNode.class); -- cgit 1.2.3-korg From c55a0d2b6c8bbbc789c687f503cf64322e897305 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 04:29:11 -0700 Subject: Add missing the eventName Add a new field for AlarmCondition (EventName) + getter and setter Change-Id: I825cc57ca65caa49de20cfcf4f8d6849f61de99e Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java index e0d10097b..7ec2f20a2 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsAlarmCondition.java @@ -31,6 +31,7 @@ public class CldsAlarmCondition implements Serializable { private String eventSourceType; private String alarmConditionKey; private String severity; + private String eventName; public String getEventSourceType() { return eventSourceType; @@ -56,4 +57,12 @@ public class CldsAlarmCondition implements Serializable { this.alarmConditionKey = alarmConditionKey; } + public String getEventName() { + return eventName; + } + + public void setEventName(String eventName) { + this.eventName = eventName; + } + } -- cgit 1.2.3-korg From af72cff2b9dfa1415e47dcd59e9a307913cab35d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 04:32:22 -0700 Subject: Add 2 new methods getNodeValueByName Add those new methods for new coming features Change-Id: I2dbdd8ea524b2eb93841642318a682950f5b7038 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/model/prop/ModelElement.java | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java index ed038db66..42333559e 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java @@ -122,6 +122,57 @@ public abstract class ModelElement { } return value; } + + /** + * Return the value field of the json node element that has a name field that equals the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static String getNodeValueByName(JsonNode nodeIn, String name) { + String value = null; + if ( nodeIn != null ) { + value = nodeIn.path(name).asText(); + } + if ( value == null || value.length() == 0 ) { + logger.warn(name + "=" + value); + } else { + logger.debug(name + "=" + value); + } + return value; + } + + + /** + * Return the value field of the json node element that has a name field that equals the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static List getNodeValuesByName(JsonNode nodeIn, String name) { + List values = new ArrayList(); + if ( nodeIn != null ) { + Iterator i = nodeIn.iterator(); + while (i.hasNext()) { + JsonNode node = i.next(); + if ( node.path("name").asText().equals(name) ) { + String value = ""; + JsonNode vnode = node.path("value"); + if ( vnode.isArray() ) { + // if array, assume value is in first element + value = vnode.path(0).asText(); + } else { + // otherwise, just return text + value = vnode.asText(); + } + values.add(value); + } + } + } + return values; + } /** * Return the int value field of the json node element that has a name field -- cgit 1.2.3-korg From e8bb2818b84918e5f1c985ae0f010e02bd3f1449 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 04:40:12 -0700 Subject: Add Request ID in Common Logging Add the requestId method + align the others classes using that + Rework the Exceptions thrown and the Javadocs Change-Id: I15bccf1d46ced15aa85d88287f05f1c14b6017fd Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/client/DcaeDispatcherServices.java | 123 +- .../clamp/clds/client/DcaeInventoryServices.java | 112 +- .../clds/client/OperationalPolicyDelegate.java | 53 +- .../onap/clamp/clds/client/SdcCatalogServices.java | 2235 +++++++++++--------- .../org/onap/clamp/clds/util/LoggingUtils.java | 37 +- 5 files changed, 1443 insertions(+), 1117 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java index e5144bfe2..3d8d5d53a 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java @@ -23,25 +23,31 @@ package org.onap.clamp.clds.client; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + import java.io.BufferedReader; import java.io.DataOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; +import java.util.Date; import java.util.stream.Collectors; import javax.net.ssl.HttpsURLConnection; +import javax.ws.rs.BadRequestException; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; +import org.onap.clamp.clds.exception.DcaeDeploymentException; import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - /** - * + * This class implements the communication with DCAE for the service + * deployments. * */ public class DcaeDispatcherServices { @@ -49,23 +55,29 @@ public class DcaeDispatcherServices { protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private RefProp refProp; + private RefProp refProp; /** - * + * Delete the deployment on DCAE. + * * @param deploymentId - * @return - * @throws Exception + * The deployment ID + * @return Return the URL Status + * @throws IOException + * In case of issues with the Stream */ - public String deleteDeployment(String deploymentId) throws Exception { + public String deleteDeployment(String deploymentId) throws IOException { String statusUrl = null; InputStream in = null; + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "deleteDeployment"); try { String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments/" + deploymentId; logger.info("Dcae Dispatcher url - " + url); URL obj = new URL(url); HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); conn.setRequestMethod("DELETE"); int responseCode = conn.getResponseCode(); @@ -94,7 +106,7 @@ public class DcaeDispatcherServices { if (responseStr != null) { if (requestFailed) { logger.error("requestFailed - responseStr=" + responseStr); - throw new Exception(responseStr); + throw new BadRequestException(responseStr); } } @@ -109,12 +121,14 @@ public class DcaeDispatcherServices { logger.debug("Status URL: " + statusUrl); } catch (Exception e) { - logger.error(e.getClass().getName() + " " + e.getMessage()); - throw e; + logger.error("Exception occurred during Delete Deployment Operation with DCAE", e); + throw new DcaeDeploymentException("Exception occurred during Delete Deployment Operation with DCAE", e); } finally { if (in != null) { in.close(); } + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("deleteDeployment complete"); } return statusUrl; @@ -122,23 +136,30 @@ public class DcaeDispatcherServices { } /** - * + * Get the Operation Status from a specified URL. + * * @param statusUrl - * @return - * @throws Exception + * The URL provided by a previous DCAE Query + * @return The status + * @throws IOException + * In case of issues with the Stream + * */ - public String getOperationStatus(String statusUrl) throws Exception { + public String getOperationStatus(String statusUrl) throws IOException { - //Assigning processing status to monitor operation status further + // Assigning processing status to monitor operation status further String opStatus = "processing"; InputStream in = null; + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "getOperationStatus"); try { URL obj = new URL(statusUrl); HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); conn.setRequestMethod("GET"); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); int responseCode = conn.getResponseCode(); logger.debug("Deployment operation status response code - " + responseCode); - if(responseCode == 200){ + if (responseCode == 200) { in = conn.getInputStream(); String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n")); JSONParser parser = new JSONParser(); @@ -150,58 +171,71 @@ public class DcaeDispatcherServices { opStatus = status; } } catch (Exception e) { - logger.debug(e.getClass().getName() + " " + e.getMessage()); + logger.error("Exception occurred during getOperationStatus Operation with DCAE", e); logger.debug(e.getMessage() + " : got exception while retrieving status, trying again until we get 200 response code"); } finally { if (in != null) { in.close(); } + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("getOperationStatus complete"); } - return opStatus; } /** - * - * @throws Exception + * This method send a getDeployments operation to DCAE. + * + * @throws IOException + * In case of issues with the Stream */ - public void getDeployments() throws Exception { + public void getDeployments() throws IOException { InputStream in = null; + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "getDeployments"); try { String url = refProp.getStringValue("DCAE_DISPATCHER_URL") + "/dcae-deployments"; logger.info("Dcae Dispatcher deployments url - " + url); URL obj = new URL(url); HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); conn.setRequestMethod("GET"); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); int responseCode = conn.getResponseCode(); logger.debug("response code " + responseCode); in = conn.getInputStream(); String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n")); logger.debug("res:" + res); } catch (Exception e) { - logger.error("Exception occurred during DCAE communication", e); - throw e; + logger.error("Exception occurred during getDeployments Operation with DCAE", e); + throw new DcaeDeploymentException("Exception occurred during getDeployments Operation with DCAE", e); } finally { if (in != null) { in.close(); } + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("getDeployments complete"); } } /** - * Returns status URL for deployment operation + * Returns status URL for createNewDeployment operation. * * @param deploymentId + * The deployment ID * @param serviceTypeId - * @return - * @throws Exception + * Service type ID + * @return The status URL + * @throws IOException + * In case of issues with the Stream */ - public String createNewDeployment(String deploymentId, String serviceTypeId) throws Exception { + public String createNewDeployment(String deploymentId, String serviceTypeId) throws IOException { String statusUrl = null; InputStream inStream = null; BufferedReader in = null; + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "createNewDeployment"); try { String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}"; logger.info("Dcae api Body String - " + apiBodyString); @@ -210,6 +244,7 @@ public class DcaeDispatcherServices { URL obj = new URL(url); HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); conn.setRequestMethod("PUT"); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); conn.setRequestProperty("Content-Type", "application/json"); conn.setDoOutput(true); try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { @@ -247,7 +282,7 @@ public class DcaeDispatcherServices { if (responseStr != null) { if (requestFailed) { logger.error("requestFailed - responseStr=" + responseStr); - throw new Exception(responseStr); + throw new BadRequestException(responseStr); } } @@ -259,8 +294,8 @@ public class DcaeDispatcherServices { statusUrl = (String) linksObj.get("status"); logger.debug("Status URL: " + statusUrl); } catch (Exception e) { - logger.error("Exception occurred during the DCAE communication", e); - throw e; + logger.error("Exception occurred during createNewDeployment Operation with DCAE", e); + throw new DcaeDeploymentException("Exception occurred during createNewDeployment Operation with DCAE", e); } finally { if (inStream != null) { inStream.close(); @@ -268,21 +303,29 @@ public class DcaeDispatcherServices { if (in != null) { in.close(); } + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("createNewDeployment complete"); } return statusUrl; } /** - * + * Returns status URL for deleteExistingDeployment operation. + * * @param deploymentId + * The deployment ID * @param serviceTypeId - * @return - * @throws Exception + * The service Type ID + * @return The status URL + * @throws IOException + * In case of issues with the Stream */ - public String deleteExistingDeployment(String deploymentId, String serviceTypeId) throws Exception { + public String deleteExistingDeployment(String deploymentId, String serviceTypeId) throws IOException { String statusUrl = null; InputStream in = null; + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "deleteExistingDeployment"); try { String apiBodyString = "{\"serviceTypeId\": \"" + serviceTypeId + "\"}"; logger.debug(apiBodyString); @@ -291,6 +334,7 @@ public class DcaeDispatcherServices { URL obj = new URL(url); HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection(); conn.setRequestMethod("DELETE"); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); conn.setRequestProperty("Content-Type", "application/json"); conn.setDoOutput(true); DataOutputStream wr = new DataOutputStream(conn.getOutputStream()); @@ -309,12 +353,15 @@ public class DcaeDispatcherServices { statusUrl = (String) linksObj.get("status"); logger.debug("Status URL: " + statusUrl); } catch (Exception e) { - logger.error("Exception occurred during DCAE communication", e); - throw e; + logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e); + throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE", + e); } finally { if (in != null) { in.close(); } + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("deleteExistingDeployment complete"); } return statusUrl; } diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java index 3dfe9fecb..c35eb0da4 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java @@ -23,11 +23,16 @@ package org.onap.clamp.clds.client; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; +import java.util.Date; import java.util.List; import javax.ws.rs.BadRequestException; @@ -43,29 +48,43 @@ import org.onap.clamp.clds.model.DcaeEvent; import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonProcessingException; - +/** + * This class implements the communication with DCAE for the service inventory. + * + */ public class DcaeInventoryServices { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeInventoryServices.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeInventoryServices.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Autowired - private RefProp refProp; + private RefProp refProp; @Autowired - private CldsDao cldsDao; + private CldsDao cldsDao; @Autowired - private SdcCatalogServices sdcCatalogServices; - - public void setEventInventory(CldsModel cldsModel, String userId) throws Exception { + private SdcCatalogServices sdcCatalogServices; + + /** + * Set the event inventory. + * + * @param cldsModel + * The CldsModel + * @param userId + * The user ID + * @throws ParseException + * In case of issues during the parsing of DCAE answer + */ + public void setEventInventory(CldsModel cldsModel, String userId) throws ParseException { String artifactName = cldsModel.getControlName(); DcaeEvent dcaeEvent = new DcaeEvent(); String isDcaeInfoAvailable = null; + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "setEventInventory"); if (artifactName != null) { artifactName = artifactName + ".yml"; } @@ -74,8 +93,8 @@ public class DcaeInventoryServices { * Below are the properties required for calling the dcae inventory * url call */ - ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null, false, "{}", - cldsModel.getPropText()); + ModelProperties prop = new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), null, false, + "{}", cldsModel.getPropText()); Global global = prop.getGlobal(); String invariantServiceUuid = global.getService(); List resourceUuidList = global.getResourceVf(); @@ -92,12 +111,12 @@ public class DcaeInventoryServices { dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION); } catch (JsonProcessingException e) { - // exception - logger.error("JsonProcessingException" + e); - } catch (IOException e) { - - // exception - logger.error("IOException :" + e); + logger.error("Error during JSON decoding", e); + } catch (IOException ex) { + logger.error("Error during JSON decoding", ex); + } finally { + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("setEventInventory complete"); } /* Null whether the DCAE has items lenght or not */ if (isDcaeInfoAvailable != null) { @@ -107,18 +126,18 @@ public class DcaeInventoryServices { Object obj0 = parser.parse(isDcaeInfoAvailable); JSONObject jsonObj = (JSONObject) obj0; String oldTypeId = cldsModel.getTypeId(); - String newTypeId = ""; + String newTypeId = ""; if (jsonObj.get("typeId") != null) { - newTypeId = jsonObj.get("typeId").toString(); + newTypeId = jsonObj.get("typeId").toString(); cldsModel.setTypeId(jsonObj.get("typeId").toString()); } // cldsModel.setTypeName(cldsModel.getControlName().toString()+".yml"); if (jsonObj.get("typeName") != null) { cldsModel.setTypeName(jsonObj.get("typeName").toString()); } - if(oldTypeId == null || !oldTypeId.equalsIgnoreCase(newTypeId)){ - CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(), - CldsEvent.ACTION_STATE_RECEIVED, null); + if (oldTypeId == null || !oldTypeId.equalsIgnoreCase(newTypeId)) { + CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(), + CldsEvent.ACTION_STATE_RECEIVED, null); } cldsModel.save(cldsDao, userId); } else { @@ -126,32 +145,55 @@ public class DcaeInventoryServices { } } - public String getDcaeInformation(String artifactName, String serviceUUID, String resourceUUID) + /** + * DO a query to DCAE to get some Information. + * + * @param artifactName + * The artifact Name + * @param serviceUuid + * The service UUID + * @param resourceUuid + * The resource UUID + * @return The DCAE inventory for the artifact + * @throws IOException + * In case of issues with the stream + * @throws ParseException + * In case of issues with the Json parsing + */ + public String getDcaeInformation(String artifactName, String serviceUuid, String resourceUuid) throws IOException, ParseException { - String queryString = "?sdcResourceId=" + resourceUUID + "&sdcServiceId=" + serviceUUID + "&typeName=" + Date startTime = new Date(); + LoggingUtils.setTargetContext("DCAE", "getDcaeInformation"); + String queryString = "?sdcResourceId=" + resourceUuid + "&sdcServiceId=" + serviceUuid + "&typeName=" + artifactName; String fullUrl = refProp.getStringValue("DCAE_INVENTORY_URL") + "/dcae-service-types" + queryString; + logger.info("Dcae Inventory Service full url - " + fullUrl); String daceInventoryResponse = null; URL inventoryUrl = new URL(fullUrl); HttpURLConnection conn = (HttpURLConnection) inventoryUrl.openConnection(); conn.setRequestMethod("GET"); + String reqid = LoggingUtils.getRequestId(); + logger.info("reqid set to " + reqid); + conn.setRequestProperty("X-ECOMP-RequestID", reqid); + boolean requestFailed = true; int responseCode = conn.getResponseCode(); if (responseCode == 200) { requestFailed = false; } - BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); - String inputLine = null; - StringBuffer response = new StringBuffer(); - String responseStr = null; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + StringBuilder response = new StringBuilder(); + + try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) { + String inputLine = null; + + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } } - in.close(); - responseStr = response.toString(); + String responseStr = response.toString(); if (responseStr != null) { if (requestFailed) { logger.error("requestFailed - responseStr=" + response); @@ -175,6 +217,8 @@ public class DcaeInventoryServices { daceInventoryResponse = dcaeServiceType0.toString(); logger.info(daceInventoryResponse.toString()); } + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("getDcaeInformation complete: number services returned=" + numServices); return daceInventoryResponse; } diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java index ed972d4bf..566d11a24 100644 --- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java @@ -23,8 +23,11 @@ package org.onap.clamp.clds.client; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.io.IOException; import java.util.Map; -import java.util.UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; @@ -33,47 +36,65 @@ import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.prop.Policy; import org.onap.clamp.clds.model.prop.PolicyChain; import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.util.LoggingUtils; import org.onap.policy.api.AttributeType; +import org.onap.policy.api.PolicyEngineException; +import org.onap.policy.controlloop.policy.builder.BuilderException; import org.springframework.beans.factory.annotation.Autowired; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - /** - * Send Operational Policy info to policy api. + * Send Operational Policy info to policy api. It uses the policy code to define + * the model and communicate with it. See also the PolicyClient class. + * */ public class OperationalPolicyDelegate implements JavaDelegate { protected static final EELFLogger logger = EELFManager.getInstance() .getLogger(OperationalPolicyDelegate.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + /** + * Automatically injected by Spring, define in CldsConfiguration as a bean. + */ @Autowired - private PolicyClient policyClient; + private PolicyClient policyClient; + /** + * Automatically injected by Spring, define in CldsConfiguration as a bean. + */ @Autowired - private RefProp refProp; + private RefProp refProp; /** * Perform activity. Send Operational Policy info to policy api. * * @param execution + * The DelegateExecution + * @throws BuilderException + * In case of issues with OperationalPolicyReq + * @throws IOException + * In case of issues with the stream + * @throws PolicyEngineException + * In case of issues with the PolicyEngine creation */ @Override - public void execute(DelegateExecution execution) throws Exception { + public void execute(DelegateExecution execution) throws IOException, BuilderException, PolicyEngineException { // execution.setVariable("operationalPolicyRequestUuid", // operationalPolicyRequestUuid); String responseMessage = null; String operationalPolicyRequestUuid = null; ModelProperties prop = ModelProperties.create(execution); - for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) { - operationalPolicyRequestUuid = UUID.randomUUID().toString(); - Map> attributes = OperationalPolicyReq.formatAttributes(refProp, prop, - prop.getType(Policy.class).getId(), policyChain); - responseMessage = policyClient.sendBrms(attributes, prop, operationalPolicyRequestUuid); - } - if (responseMessage != null) { - execution.setVariable("operationalPolicyResponseMessage", responseMessage.getBytes()); + Policy policy = prop.getType(Policy.class); + if (policy.isFound()) { + for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) { + operationalPolicyRequestUuid = LoggingUtils.getRequestId(); + Map> attributes = OperationalPolicyReq.formatAttributes(refProp, + prop, prop.getType(Policy.class).getId(), policyChain); + responseMessage = policyClient.sendBrms(attributes, prop, operationalPolicyRequestUuid); + } + if (responseMessage != null) { + execution.setVariable("operationalPolicyResponseMessage", responseMessage.getBytes()); + } } } diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java index df86977cd..a4e332a39 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -1,1022 +1,1213 @@ -/*- - * ============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.client; - -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.csv.CSVFormat; -import org.apache.commons.csv.CSVRecord; -import org.apache.commons.lang3.StringUtils; -import org.onap.clamp.clds.client.req.SdcReq; -import org.onap.clamp.clds.model.CldsAlarmCondition; -import org.onap.clamp.clds.model.CldsDBServiceCache; -import org.onap.clamp.clds.model.CldsSdcArtifact; -import org.onap.clamp.clds.model.CldsSdcResource; -import org.onap.clamp.clds.model.CldsSdcResourceBasicInfo; -import org.onap.clamp.clds.model.CldsSdcServiceDetail; -import org.onap.clamp.clds.model.CldsSdcServiceInfo; -import org.onap.clamp.clds.model.CldsServiceData; -import org.onap.clamp.clds.model.CldsVfData; -import org.onap.clamp.clds.model.CldsVfKPIData; -import org.onap.clamp.clds.model.CldsVfcData; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; -import org.onap.clamp.clds.util.LoggingUtils; -import org.springframework.beans.factory.annotation.Autowired; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.node.TextNode; - -public class SdcCatalogServices { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCatalogServices.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - - private static final String RESOURCE_VF_TYPE = "VF"; - private static final String RESOURCE_VFC_TYPE = "VFC"; - - @Autowired - private RefProp refProp; - - public String getSdcServicesInformation(String uuid) throws Exception { - Date startTime = new Date(); - String baseUrl = refProp.getStringValue("sdc.serviceUrl"); - String basicAuth = SdcReq.getSdcBasicAuth(refProp); - try { - String url = baseUrl; - if (uuid != null) { - url = baseUrl + "/" + uuid + "/metadata"; - } - URL urlObj = new URL(url); - - HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); - - conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool"); - conn.setRequestProperty("Authorization", basicAuth); - conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); - conn.setRequestMethod("GET"); - - String resp = getResponse(conn); - if (resp != null) { - logger.info(resp.toString()); - return resp; - } - // metrics log - LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName()); - - } catch (Exception e) { - LoggingUtils.setResponseContext("900", "Get sdc services failed", this.getClass().getName()); - LoggingUtils.setErrorContext("900", "Get sdc services error"); - logger.error("not able to get any service information from sdc for uuid:" + uuid + " , exception is - " + e.getMessage()); - } - LoggingUtils.setTimeContext(startTime, new Date()); - LoggingUtils.setTargetContext("SDC", "Get Services"); - metricsLogger.info("Get sdc services information"); - - return ""; - } - - /** - * To remove duplicate serviceUUIDs from sdc services List - * - * @param rawCldsSdcServiceList - * @return - */ - public List removeDuplicateServices(List rawCldsSdcServiceList) { - List cldsSdcServiceInfoList = null; - if (rawCldsSdcServiceList != null && rawCldsSdcServiceList.size() > 0) { - // sort list - Collections.sort(rawCldsSdcServiceList); - // and then take only the services with the max version (last in the - // list with the same name) - cldsSdcServiceInfoList = new ArrayList<>(); - for (int i = 1; i < rawCldsSdcServiceList.size(); i++) { - // compare name with previous - if not equal, then keep the - // previous (it's the last with that name) - CldsSdcServiceInfo prev = rawCldsSdcServiceList.get(i - 1); - if (!rawCldsSdcServiceList.get(i).getName().equals(prev.getName())) { - cldsSdcServiceInfoList.add(prev); - } - } - // add the last in the list - cldsSdcServiceInfoList.add(rawCldsSdcServiceList.get(rawCldsSdcServiceList.size() - 1)); - } - return cldsSdcServiceInfoList; - } - - /** - * To remove duplicate serviceUUIDs from sdc resources List - * - * @param rawCldsSdcResourceList - * @return - */ - public List removeDuplicateSdcResourceInstances(List rawCldsSdcResourceList) { - List cldsSdcResourceList = null; - if (rawCldsSdcResourceList != null && rawCldsSdcResourceList.size() > 0) { - // sort list - Collections.sort(rawCldsSdcResourceList); - // and then take only the resources with the max version (last in - // the list with the same name) - cldsSdcResourceList = new ArrayList<>(); - for (int i = 1; i < rawCldsSdcResourceList.size(); i++) { - // compare name with previous - if not equal, then keep the - // previous (it's the last with that name) - CldsSdcResource prev = rawCldsSdcResourceList.get(i - 1); - if (!rawCldsSdcResourceList.get(i).getResourceInstanceName().equals(prev.getResourceInstanceName())) { - cldsSdcResourceList.add(prev); - } - } - // add the last in the list - cldsSdcResourceList.add(rawCldsSdcResourceList.get(rawCldsSdcResourceList.size() - 1)); - } - return cldsSdcResourceList; - } - - /** - * To remove duplicate basic resources with same resourceUUIDs - * - * @param rawCldsSdcResourceListBasicList - * @return - */ - public List removeDuplicateSdcResourceBasicInfo( - List rawCldsSdcResourceListBasicList) { - List cldsSdcResourceBasicInfoList = null; - if (rawCldsSdcResourceListBasicList != null && rawCldsSdcResourceListBasicList.size() > 0) { - // sort list - Collections.sort(rawCldsSdcResourceListBasicList); - // and then take only the resources with the max version (last in - // the list with the same name) - cldsSdcResourceBasicInfoList = new ArrayList<>(); - for (int i = 1; i < rawCldsSdcResourceListBasicList.size(); i++) { - // compare name with previous - if not equal, then keep the - // previous (it's the last with that name) - CldsSdcResourceBasicInfo prev = rawCldsSdcResourceListBasicList.get(i - 1); - if (!rawCldsSdcResourceListBasicList.get(i).getName().equals(prev.getName())) { - cldsSdcResourceBasicInfoList.add(prev); - } - } - // add the last in the list - cldsSdcResourceBasicInfoList - .add(rawCldsSdcResourceListBasicList.get(rawCldsSdcResourceListBasicList.size() - 1)); - } - return cldsSdcResourceBasicInfoList; - } - - /** - * To get ServiceUUID by using serviceInvariantUUID - * - * @param invariantId - * @return - * @throws Exception - */ - public String getServiceUuidFromServiceInvariantId(String invariantId) throws Exception { - String serviceUuid = ""; - String responseStr = getSdcServicesInformation(null); - List rawCldsSdcServicesList = getCldsSdcServicesListFromJson(responseStr); - List cldsSdcServicesList = removeDuplicateServices(rawCldsSdcServicesList); - if (cldsSdcServicesList != null && cldsSdcServicesList.size() > 0) { - for (CldsSdcServiceInfo currCldsSdcServiceInfo : cldsSdcServicesList) { - if (currCldsSdcServiceInfo != null && currCldsSdcServiceInfo.getInvariantUUID() != null - && currCldsSdcServiceInfo.getInvariantUUID().equalsIgnoreCase(invariantId)) { - serviceUuid = currCldsSdcServiceInfo.getUuid(); - break; - } - } - } - return serviceUuid; - } - - /** - * To get CldsAsdsServiceInfo class by parsing json string - * - * @param jsonStr - * @return - * @throws JsonParseException - * @throws JsonMappingException - * @throws IOException - */ - public List getCldsSdcServicesListFromJson(String jsonStr) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - if (StringUtils.isBlank(jsonStr)) { - return null; - } - return objectMapper.readValue(jsonStr, - objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcServiceInfo.class)); - } - - /** - * To get List class by parsing json string - * - * @param jsonStr - * @return - * @throws JsonParseException - * @throws JsonMappingException - * @throws IOException - */ - public List getAllSdcResourcesListFromJson(String jsonStr) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - if (StringUtils.isBlank(jsonStr)) { - return null; - } - return objectMapper.readValue(jsonStr, - objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcResourceBasicInfo.class)); - } - - /** - * To get CldsAsdsResource class by parsing json string - * - * @param jsonStr - * @return - * @throws JsonParseException - * @throws JsonMappingException - * @throws IOException - */ - public CldsSdcResource getCldsSdcResourceFromJson(String jsonStr) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.readValue(jsonStr, CldsSdcResource.class); - } - - /** - * To get CldsSdcServiceDetail by parsing json string - * - * @param jsonStr - * @return - * @throws JsonParseException - * @throws JsonMappingException - * @throws IOException - */ - public CldsSdcServiceDetail getCldsSdcServiceDetailFromJson(String jsonStr) throws IOException { - ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.readValue(jsonStr, CldsSdcServiceDetail.class); - } - - /** - * To upload artifact to sdc based on serviceUUID and resourcename on url - * - * @param prop - * @param userid - * @param url - * @param formatttedSdcReq - * @return - * @throws Exception - */ - public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formatttedSdcReq) - throws Exception { - // Verify whether it is triggered by Validation Test button from UI - if (prop.isTest()) { - return "sdc artifact upload not executed for test action"; - } - logger.info("userid=" + userid); - String md5Text = SdcReq.calculateMD5ByString(formatttedSdcReq); - byte[] postData = SdcReq.stringToByteArray(formatttedSdcReq); - int postDataLength = postData.length; - HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, md5Text); - try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { - wr.write(postData); - } - boolean requestFailed = true; - int responseCode = conn.getResponseCode(); - logger.info("responseCode=" + responseCode); - if (responseCode == 200) { - requestFailed = false; - } - - String responseStr = getResponse(conn); - if (responseStr != null) { - if (requestFailed) { - logger.error("requestFailed - responseStr=" + responseStr); - throw new Exception(responseStr); - } - } - return responseStr; - } - - private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text) - throws IOException { - logger.info("userid=" + userid); - String basicAuth = SdcReq.getSdcBasicAuth(refProp); - String sdcXonapInstanceId = refProp.getStringValue("sdc.sdcX-InstanceID"); - URL urlObj = new URL(url); - HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); - conn.setDoOutput(true); - conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), sdcXonapInstanceId); - conn.setRequestProperty("Authorization", basicAuth); - conn.setRequestProperty("Content-Type", "application/json"); - conn.setRequestProperty("Content-MD5", md5Text); - conn.setRequestProperty("USER_ID", userid); - conn.setRequestMethod("POST"); - conn.setRequestProperty("charset", "utf-8"); - conn.setRequestProperty("Content-Length", Integer.toString(postDataLength)); - conn.setUseCaches(false); - return conn; - } - - private String getResponse(HttpURLConnection conn) throws IOException { - try (InputStream is = getInputStream(conn)) { - if (is != null) { - try (BufferedReader in = new BufferedReader(new InputStreamReader(is))) { - StringBuffer response = new StringBuffer(); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - } - return response.toString(); - } - } - } - return null; - } - - private InputStream getInputStream(HttpURLConnection conn) throws IOException { - InputStream inStream = conn.getErrorStream(); - if (inStream == null) { - inStream = conn.getInputStream(); - } - return inStream; - } - - public CldsDBServiceCache getCldsDbServiceCacheUsingCldsServiceData(CldsServiceData cldsServiceData) - throws IOException { - CldsDBServiceCache cldsDbServiceCache = new CldsDBServiceCache(); - cldsDbServiceCache.setCldsDataInstream(cldsServiceData); - cldsDbServiceCache.setInvariantId(cldsServiceData.getServiceInvariantUUID()); - cldsDbServiceCache.setServiceId(cldsServiceData.getServiceUUID()); - return cldsDbServiceCache; - } - - public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData) throws Exception { - boolean expired = false; - if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) { - String cachedServiceUuid = cldsServiceData.getServiceUUID(); - String latestServiceUuid = getServiceUuidFromServiceInvariantId(cldsServiceData.getServiceInvariantUUID()); - String defaultRecordAge = refProp.getStringValue("CLDS_SERVICE_CACHE_MAX_SECONDS"); - if ((!cachedServiceUuid.equalsIgnoreCase(latestServiceUuid)) || (cldsServiceData.getAgeOfRecord() != null - && cldsServiceData.getAgeOfRecord() > Long.parseLong(defaultRecordAge))) { - expired = true; - } - } else { - expired = true; - } - return expired; - } - - public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUuid) throws Exception { - String url = refProp.getStringValue("sdc.serviceUrl"); - String catalogUrl = refProp.getStringValue("sdc.catalog.url"); - String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid); - String serviceDetailUrl = url + "/" + serviceUuid + "/metadata"; - String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl, false); - ObjectMapper objectMapper = new ObjectMapper(); - CldsServiceData cldsServiceData = new CldsServiceData(); - if (responseStr != null) { - CldsSdcServiceDetail cldsSdcServiceDetail = objectMapper.readValue(responseStr, CldsSdcServiceDetail.class); - cldsServiceData.setServiceUUID(cldsSdcServiceDetail.getUuid()); - cldsServiceData.setServiceInvariantUUID(cldsSdcServiceDetail.getInvariantUUID()); - - // To remove duplicate resources from serviceDetail and add valid - // vfs to service - if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null) { - List cldsSdcResourceList = removeDuplicateSdcResourceInstances( - cldsSdcServiceDetail.getResources()); - if (cldsSdcResourceList != null && cldsSdcResourceList.size() > 0) { - List cldsVfDataList = new ArrayList<>(); - for (CldsSdcResource currCldsSdcResource : cldsSdcResourceList) { - if (currCldsSdcResource != null && currCldsSdcResource.getResoucreType() != null - && currCldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { - CldsVfData currCldsVfData = new CldsVfData(); - currCldsVfData.setVfName(currCldsSdcResource.getResourceInstanceName()); - currCldsVfData.setVfInvariantResourceUUID(currCldsSdcResource.getResourceInvariantUUID()); - cldsVfDataList.add(currCldsVfData); - } - } - cldsServiceData.setCldsVfs(cldsVfDataList); - // For each vf in the list , add all vfc's - getAllVfcForVfList(cldsVfDataList, catalogUrl); - logger.info("value of cldsServiceData:" + cldsServiceData); - logger.info("value of cldsServiceData:" + cldsServiceData.getServiceInvariantUUID()); - } - } - } - return cldsServiceData; - } - - /** - * @param cldsVfDataList - * @throws IOException - */ - private void getAllVfcForVfList(List cldsVfDataList, String catalogUrl) throws IOException { - // todo : refact this.. - if (cldsVfDataList != null && cldsVfDataList.size() > 0) { - List allVfResources = getAllSdcVForVFCResourcesBasedOnResourceType( - RESOURCE_VF_TYPE); - List allVfcResources = getAllSdcVForVFCResourcesBasedOnResourceType( - RESOURCE_VFC_TYPE); - for (CldsVfData currCldsVfData : cldsVfDataList) { - if (currCldsVfData != null && currCldsVfData.getVfInvariantResourceUUID() != null) { - String resourceUuid = getResourceUuidFromResourceInvariantUuid( - currCldsVfData.getVfInvariantResourceUUID(), allVfResources); - if (resourceUuid != null) { - String vfResourceUuidUrl = catalogUrl + "resources" + "/" + resourceUuid + "/metadata"; - String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl, false); - if (vfResponse != null) { - // Below 2 line are to get the KPI(field path) data - // associated with the VF's - List cldsVfKPIDataList = getFieldPathFromVF(vfResponse); - currCldsVfData.setCldsKPIList(cldsVfKPIDataList); - - List vfcDataListFromVfResponse = getVfcDataListFromVfResponse(vfResponse); - if (vfcDataListFromVfResponse != null) { - currCldsVfData.setCldsVfcs(vfcDataListFromVfResponse); - if (vfcDataListFromVfResponse.size() > 0) { - // To get artifacts for every VFC and get - // alarm conditions from artifact - for (CldsVfcData currCldsVfcData : vfcDataListFromVfResponse) { - if (currCldsVfcData != null - && currCldsVfcData.getVfcInvariantResourceUUID() != null) { - String resourceVfcUuid = getResourceUuidFromResourceInvariantUuid( - currCldsVfcData.getVfcInvariantResourceUUID(), allVfcResources); - if (resourceVfcUuid != null) { - String vfcResourceUuidUrl = catalogUrl + "resources" + "/" - + resourceVfcUuid + "/metadata"; - String vfcResponse = getCldsServicesOrResourcesBasedOnURL( - vfcResourceUuidUrl, false); - if (vfcResponse != null) { - List alarmCondtionsFromVfc = getAlarmCondtionsFromVfc( - vfcResponse); - currCldsVfcData.setCldsAlarmConditions(alarmCondtionsFromVfc); - } - } else { - logger.info("No resourceVFC UUID found for given invariantID:" - + currCldsVfcData.getVfcInvariantResourceUUID()); - } - } - } - } - } - } - } else { - logger.info("No resourceUUID found for given invariantREsourceUUID:" - + currCldsVfData.getVfInvariantResourceUUID()); - } - } - } - } - } - - private List getVfcDataListFromVfResponse(String vfResponse) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); - ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources"); - List cldsVfcDataList = new ArrayList<>(); - if (vfcArrayNode != null && vfcArrayNode.size() > 0) { - for (int index = 0; index < vfcArrayNode.size(); index++) { - CldsVfcData currCldsVfcData = new CldsVfcData(); - ObjectNode currVfcNode = (ObjectNode) vfcArrayNode.get(index); - TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType"); - if (resourceTypeNode != null && resourceTypeNode.textValue().equalsIgnoreCase("VFC")) { - TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName"); - TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID"); - currCldsVfcData.setVfcName(vfcResourceName.textValue()); - currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue()); - cldsVfcDataList.add(currCldsVfcData); - } - } - } - return cldsVfcDataList; - } - - private String removeUnwantedBracesFromString(String id) { - if (id != null && id.contains("\"")) { - id = id.replaceAll("\"", ""); - } - return id; - } - - private List getAlarmCondtionsFromVfc(String vfcResponse) throws IOException { - List cldsAlarmConditionList = new ArrayList<>(); - ObjectMapper mapper = new ObjectMapper(); - ObjectNode vfcResponseNode = (ObjectNode) mapper.readTree(vfcResponse); - ArrayNode artifactsArrayNode = (ArrayNode) vfcResponseNode.get("artifacts"); - - if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) { - for (int index = 0; index < artifactsArrayNode.size(); index++) { - ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index); - TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL"); - if (artifactUrlNode != null) { - String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue()); - cldsAlarmConditionList.addAll(parseCsvToGetAlarmConditions(responsesFromArtifactUrl)); - logger.info(responsesFromArtifactUrl); - } - } - } - return cldsAlarmConditionList; - } - - private List parseCsvToGetAlarmConditions(String allAlarmCondsValues) throws IOException { - List cldsAlarmConditionList = new ArrayList<>(); - Reader alarmReader = new StringReader(allAlarmCondsValues); - Iterable records = CSVFormat.RFC4180.parse(alarmReader); - if (records != null) { - Iterator it = records.iterator(); - if (it.hasNext()) { - it.next(); - } - it.forEachRemaining(record -> processRecord(cldsAlarmConditionList, record)); - } - return cldsAlarmConditionList; - } - - // Method to get the artifact for any particular VF - private List getFieldPathFromVF(String vfResponse) throws JsonProcessingException, IOException { - List cldsVfKPIDataList = new ArrayList(); - ObjectMapper mapper = new ObjectMapper(); - ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); - ArrayNode artifactsArrayNode = (ArrayNode) vfResponseNode.get("artifacts"); - - if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) { - for (int index = 0; index < artifactsArrayNode.size(); index++) { - ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index); - TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL"); - TextNode artifactNameNode = (TextNode) currArtifactNode.get("artifactName"); - String artifactName = ""; - if (artifactNameNode != null) { - artifactName = artifactNameNode.textValue(); - artifactName = artifactName.substring(artifactName.lastIndexOf(".") + 1); - } - if (artifactUrlNode != null && artifactName != null && !artifactName.isEmpty() - && artifactName.equalsIgnoreCase("csv")) { - String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue()); - cldsVfKPIDataList.addAll(parseCsvToGetFieldPath(responsesFromArtifactUrl)); - logger.info(responsesFromArtifactUrl); - } - } - } - return cldsVfKPIDataList; - } - - private CldsVfKPIData convertCsvRecordToKpiData(CSVRecord record) { - if (record.size() < 6) { - logger.debug("invalid csv field path Record,total columns less than 6: " + record); - return null; - } - - if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3)) - || StringUtils.isBlank(record.get(5))) { - logger.debug("Invalid csv field path Record,one of column is having blank value : " + record); - return null; - } - - CldsVfKPIData cldsVfKPIData = new CldsVfKPIData(); - cldsVfKPIData.setNfNamingCode(record.get(0).trim()); - cldsVfKPIData.setNfNamingValue(record.get(1).trim()); - - cldsVfKPIData.setFieldPath(record.get(2).trim()); - cldsVfKPIData.setFieldPathValue(record.get(3).trim()); - - cldsVfKPIData.setThresholdName(record.get(4).trim()); - cldsVfKPIData.setThresholdValue(record.get(5).trim()); - return cldsVfKPIData; - - } - - // Method to get the artifactURL Data and set the CldsVfKPIData node - private List parseCsvToGetFieldPath(String allFieldPathValues) throws IOException { - List cldsVfKPIDataList = new ArrayList(); - Reader alarmReader = new StringReader(allFieldPathValues); - Iterable records = CSVFormat.RFC4180.parse(alarmReader); - if (records != null) { - for (CSVRecord record : records) { - CldsVfKPIData kpiData = this.convertCsvRecordToKpiData(record); - if (kpiData != null) { - cldsVfKPIDataList.add(kpiData); - } - } - } - return cldsVfKPIDataList; - } - - private void processRecord(List cldsAlarmConditionList, CSVRecord record) { - if (record == null) { - return; - } - if (record.size() < 5) { - logger.debug("invalid csv alarm Record,total columns less than 5: " + record); - return; - } - if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3)) - || StringUtils.isBlank(record.get(4))) { - logger.debug("invalid csv alarm Record,one of column is having blank value : " + record); - return; - } - CldsAlarmCondition cldsAlarmCondition = new CldsAlarmCondition(); - cldsAlarmCondition.setEventSourceType(record.get(1)); - cldsAlarmCondition.setAlarmConditionKey(record.get(3)); - cldsAlarmCondition.setSeverity(record.get(4)); - cldsAlarmConditionList.add(cldsAlarmCondition); - } - - public String getResponsesFromArtifactUrl(String artifactsUrl) throws IOException { - String hostUrl = refProp.getStringValue("sdc.hostUrl"); - artifactsUrl = artifactsUrl.replaceAll("\"", ""); - String artifactUrl = hostUrl + artifactsUrl; - logger.info("value of artifactURl:" + artifactUrl); - String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl, true); - logger.info("value of artifactResponse:" + currArtifactResponse); - return currArtifactResponse; - } - - /** - * Service to services/resources/artifacts from sdc.Pass alarmConditions as - * true to get alarmconditons from artifact url and else it is false - * - * @param url - * @param alarmConditions - * @return - * @throws IOException - */ - public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions) { - String responseStr; - try { - url = removeUnwantedBracesFromString(url); - URL urlObj = new URL(url); - - HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); - String basicAuth = SdcReq.getSdcBasicAuth(refProp); - conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool"); - conn.setRequestProperty("Authorization", basicAuth); - conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); - conn.setRequestMethod("GET"); - - int responseCode = conn.getResponseCode(); - logger.info("responseCode=" + responseCode); - - BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); - StringBuffer response = new StringBuffer(); - String inputLine; - while ((inputLine = in.readLine()) != null) { - response.append(inputLine); - if (alarmConditions) { - response.append("\n"); - } - } - responseStr = response.toString(); - in.close(); - return responseStr; - } catch (Exception e) { - logger.error("Exception occurred :", e); - return ""; - } - - } - - /** - * To create properties object by using cldsServicedata - * - * @param globalProps - * @param cldsServiceData - * @return - * @throws IOException - */ - public String createPropertiesObjectByUUID(String globalProps, CldsServiceData cldsServiceData) throws IOException { - String totalPropsStr; - ObjectMapper mapper = new ObjectMapper(); - ObjectNode globalPropsJson; - if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) { - - // Objectnode to save all byservice, byvf , byvfc and byalarm nodes - ObjectNode byIdObjectNode = mapper.createObjectNode(); - - // To create vf ResourceUUID node with serviceInvariantUUID - ObjectNode invariantUuidObjectNodeWithVF = createVFObjectNodeByServiceInvariantUUID(mapper, - cldsServiceData); - byIdObjectNode.putPOJO("byService", invariantUuidObjectNodeWithVF); - - // To create byVf and vfcResourceNode with vfResourceUUID - ObjectNode vfcObjectNodeByVfUuid = createVFCObjectNodeByVfUuid(mapper, cldsServiceData.getCldsVfs()); - byIdObjectNode.putPOJO("byVf", vfcObjectNodeByVfUuid); - - // To create byKpi - ObjectNode kpiObjectNode = mapper.createObjectNode(); - if (cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { - for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { - if (currCldsVfData != null) { - createKPIObjectNodeByVfUUID(mapper, kpiObjectNode, currCldsVfData.getCldsKPIList()); - } - } - } - byIdObjectNode.putPOJO("byKpi", kpiObjectNode); - - // To create byVfc and alarmCondition with vfcResourceUUID - ObjectNode vfcResourceUuidObjectNode = mapper.createObjectNode(); - if (cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { - for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { - if (currCldsVfData != null) { - createAlarmCondObjectNodeByVfcUuid(mapper, vfcResourceUuidObjectNode, - currCldsVfData.getCldsVfcs()); - } - } - } - byIdObjectNode.putPOJO("byVfc", vfcResourceUuidObjectNode); - - // To create byAlarmCondition with alarmConditionKey - List allAlarmConditions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData); - ObjectNode alarmCondObjectNodeByAlarmKey = createAlarmCondObjectNodeByAlarmKey(mapper, allAlarmConditions); - - byIdObjectNode.putPOJO("byAlarmCondition", alarmCondObjectNodeByAlarmKey); - - globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); - - globalPropsJson.putPOJO("shared", byIdObjectNode); - logger.info("valuie of objNode:" + globalPropsJson); - } else { - /** - * to create json with total properties when no serviceUUID passed - */ - globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); - } - totalPropsStr = globalPropsJson.toString(); - return totalPropsStr; - } - - public List getAllAlarmConditionsFromCldsServiceData(CldsServiceData cldsServiceData) { - List alarmCondList = new ArrayList<>(); - if (cldsServiceData != null && cldsServiceData.getCldsVfs() != null - && cldsServiceData.getCldsVfs().size() > 0) { - for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { - if (currCldsVfData != null && currCldsVfData.getCldsVfcs() != null - && currCldsVfData.getCldsVfcs().size() > 0) { - for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { - if (currCldsVfcData != null && currCldsVfcData.getCldsAlarmConditions() != null - && currCldsVfcData.getCldsAlarmConditions().size() > 0) { - for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) { - if (currCldsAlarmCondition != null) { - alarmCondList.add(currCldsAlarmCondition); - } - } - } - } - } - } - } - return alarmCondList; - } - - private ObjectNode createAlarmCondObjectNodeByAlarmKey(ObjectMapper mapper, - List cldsAlarmCondList) { - ObjectNode alarmCondKeyNode = mapper.createObjectNode(); - - if (cldsAlarmCondList != null && cldsAlarmCondList.size() > 0) { - for (CldsAlarmCondition currCldsAlarmCondition : cldsAlarmCondList) { - if (currCldsAlarmCondition != null) { - ObjectNode alarmCondNode = mapper.createObjectNode(); - alarmCondNode.put("eventSourceType", currCldsAlarmCondition.getEventSourceType()); - alarmCondNode.put("eventSeverity", currCldsAlarmCondition.getSeverity()); - alarmCondKeyNode.putPOJO(currCldsAlarmCondition.getAlarmConditionKey(), alarmCondNode); - } - } - } else { - ObjectNode alarmCondNode = mapper.createObjectNode(); - alarmCondNode.put("eventSourceType", ""); - alarmCondNode.put("eventSeverity", ""); - alarmCondKeyNode.putPOJO("", alarmCondNode); - } - return alarmCondKeyNode; - } - - private ObjectNode createVFObjectNodeByServiceInvariantUUID(ObjectMapper mapper, CldsServiceData cldsServiceData) { - ObjectNode invariantUuidObjectNode = mapper.createObjectNode(); - ObjectNode vfObjectNode = mapper.createObjectNode(); - ObjectNode vfUuidNode = mapper.createObjectNode(); - List cldsVfsList = cldsServiceData.getCldsVfs(); - if (cldsVfsList != null && cldsVfsList.size() > 0) { - for (CldsVfData currCldsVfData : cldsVfsList) { - if (currCldsVfData != null) { - vfUuidNode.put(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName()); - } - } - } else { - vfUuidNode.put("", ""); - } - vfObjectNode.putPOJO("vf", vfUuidNode); - invariantUuidObjectNode.putPOJO(cldsServiceData.getServiceInvariantUUID(), vfObjectNode); - return invariantUuidObjectNode; - } - - private void createKPIObjectNodeByVfUUID(ObjectMapper mapper, ObjectNode vfResourceUUIDObjectNode, - List cldsVfKPIDataList) { - if (cldsVfKPIDataList != null && cldsVfKPIDataList.size() > 0) { - for (CldsVfKPIData currCldsVfKPIData : cldsVfKPIDataList) { - if (currCldsVfKPIData != null) { - ObjectNode thresholdNameObjectNode = mapper.createObjectNode(); - - ObjectNode fieldPathObjectNode = mapper.createObjectNode(); - ObjectNode nfNamingCodeNode = mapper.createObjectNode(); - - fieldPathObjectNode.put(currCldsVfKPIData.getFieldPathValue(), - currCldsVfKPIData.getFieldPathValue()); - nfNamingCodeNode.put(currCldsVfKPIData.getNfNamingValue(), currCldsVfKPIData.getNfNamingValue()); - - thresholdNameObjectNode.putPOJO("fieldPath", fieldPathObjectNode); - thresholdNameObjectNode.putPOJO("nfNamingCode", nfNamingCodeNode); - - vfResourceUUIDObjectNode.putPOJO(currCldsVfKPIData.getThresholdValue(), thresholdNameObjectNode); - } - } - } - } - - private void createAlarmCondObjectNodeByVfcUuid(ObjectMapper mapper, ObjectNode vfcResourceUUIDObjectNode, - List cldsVfcDataList) { - ObjectNode alarmCondContsObjectNode = mapper.createObjectNode(); - ObjectNode alarmCondNode = mapper.createObjectNode(); - // alarmCondNode.put("", ""); - if (cldsVfcDataList != null && cldsVfcDataList.size() > 0) { - for (CldsVfcData currCldsVfcData : cldsVfcDataList) { - if (currCldsVfcData != null) { - if (currCldsVfcData.getCldsAlarmConditions() != null - && currCldsVfcData.getCldsAlarmConditions().size() > 0) { - for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) { - alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(), - currCldsAlarmCondition.getAlarmConditionKey()); - } - alarmCondContsObjectNode.putPOJO("alarmCondition", alarmCondNode); - } - alarmCondContsObjectNode.putPOJO("alarmCondition", alarmCondNode); - vfcResourceUUIDObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), - alarmCondContsObjectNode); - } - } - } else { - alarmCondNode.put("", ""); - alarmCondContsObjectNode.putPOJO("alarmCondition", alarmCondNode); - vfcResourceUUIDObjectNode.putPOJO("", alarmCondContsObjectNode); - } - } - - private ObjectNode createVFCObjectNodeByVfUuid(ObjectMapper mapper, List cldsVfDataList) { - ObjectNode vfUUIDObjectNode = mapper.createObjectNode(); - - if (cldsVfDataList != null && cldsVfDataList.size() > 0) { - for (CldsVfData currCldsVfData : cldsVfDataList) { - if (currCldsVfData != null) { - ObjectNode vfcObjectNode = mapper.createObjectNode(); - ObjectNode vfcUuidNode = mapper.createObjectNode(); - if (currCldsVfData.getCldsVfcs() != null && currCldsVfData.getCldsVfcs().size() > 0) { - for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { - vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(), - currCldsVfcData.getVfcName()); - } - } else { - vfcUuidNode.put("", ""); - } - vfcObjectNode.putPOJO("vfc", vfcUuidNode); - vfUUIDObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfcObjectNode); - } - } - } else { - ObjectNode vfcUuidNode = mapper.createObjectNode(); - vfcUuidNode.put("", ""); - ObjectNode vfcObjectNode = mapper.createObjectNode(); - vfcObjectNode.putPOJO("vfc", vfcUuidNode); - vfUUIDObjectNode.putPOJO("", vfcObjectNode); - } - return vfUUIDObjectNode; - } - - public String getArtifactIdIfArtifactAlreadyExists(CldsSdcServiceDetail CldsSdcServiceDetail, String artifactName) { - String artifactUuid = null; - boolean artifactxists = false; - if (CldsSdcServiceDetail != null && CldsSdcServiceDetail.getResources() != null - && CldsSdcServiceDetail.getResources().size() > 0) { - for (CldsSdcResource currCldsSdcResource : CldsSdcServiceDetail.getResources()) { - if (artifactxists) { - break; - } - if (currCldsSdcResource != null && currCldsSdcResource.getArtifacts() != null - && currCldsSdcResource.getArtifacts().size() > 0) { - for (CldsSdcArtifact currCldsSdcArtifact : currCldsSdcResource.getArtifacts()) { - if (currCldsSdcArtifact != null && currCldsSdcArtifact.getArtifactName() != null) { - if (currCldsSdcArtifact.getArtifactName().equalsIgnoreCase(artifactName)) { - artifactUuid = currCldsSdcArtifact.getArtifactUUID(); - artifactxists = true; - break; - } - } - } - } - } - } - return artifactUuid; - } - - public String updateControlLoopStatusToDcae(String dcaeUrl, String invariantResourceUuid, - String invariantServiceUuid, String artifactName) { - String baseUrl = refProp.getStringValue("sdc.serviceUrl"); - String basicAuth = SdcReq.getSdcBasicAuth(refProp); - String postStatusData = "{ \n" + "\"event\" : \"" + "Created" + "\",\n" + "\"serviceUUID\" : \"" - + invariantServiceUuid + "\",\n" + "\"resourceUUID\" :\"" + invariantResourceUuid + "\",\n" - + "\"artifactName\" : \"" + artifactName + "\",\n" + "} \n"; - try { - String url = baseUrl; - if (invariantServiceUuid != null) { - url = dcaeUrl + "/closed-loops"; - } - URL urlObj = new URL(url); - - HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); - conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool"); - conn.setRequestProperty("Authorization", basicAuth); - conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); - conn.setRequestMethod("POST"); - - byte[] postData = SdcReq.stringToByteArray(postStatusData); - try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { - wr.write(postData); - } - - int responseCode = conn.getResponseCode(); - logger.info("responseCode=" + responseCode); - - String resp = getResponse(conn); - if (resp != null) { - return resp; - } - } catch (Exception e) { - logger.error("not able to ger any service information from sdc for uuid:" + invariantServiceUuid); - } - return ""; - } - - /** - * To get all sdc VF/VFC Resources basic info - * - * @return - * @throws IOException - */ - private List getAllSdcVForVFCResourcesBasedOnResourceType(String resourceType) - throws IOException { - List allSdcResourceVFCBasicInfo = new ArrayList(); - String catalogUrl = refProp.getStringValue("sdc.catalog.url"); - String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType; - String allSdcVFCResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false); - - allSdcResourceVFCBasicInfo = getAllSdcResourcesListFromJson(allSdcVFCResources); - return removeDuplicateSdcResourceBasicInfo(allSdcResourceVFCBasicInfo); - } - - private String getResourceUuidFromResourceInvariantUuid(String resourceInvariantUUID, - List resourceInfoList) throws IOException { - String resourceUuid = null; - if (resourceInfoList != null && resourceInfoList.size() > 0) { - for (CldsSdcResourceBasicInfo currResource : resourceInfoList) { - if (currResource != null && currResource.getInvariantUUID() != null && currResource.getUuid() != null - && currResource.getInvariantUUID().equalsIgnoreCase(resourceInvariantUUID)) { - resourceUuid = currResource.getUuid(); - break; - } - } - } - return resourceUuid; - } -} +/*- + * ============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.client; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fasterxml.jackson.databind.node.TextNode; + +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.List; + +import javax.ws.rs.BadRequestException; + +import org.apache.commons.csv.CSVFormat; +import org.apache.commons.csv.CSVRecord; +import org.apache.commons.lang3.StringUtils; +import org.onap.clamp.clds.client.req.SdcReq; +import org.onap.clamp.clds.model.CldsAlarmCondition; +import org.onap.clamp.clds.model.CldsDBServiceCache; +import org.onap.clamp.clds.model.CldsSdcArtifact; +import org.onap.clamp.clds.model.CldsSdcResource; +import org.onap.clamp.clds.model.CldsSdcResourceBasicInfo; +import org.onap.clamp.clds.model.CldsSdcServiceDetail; +import org.onap.clamp.clds.model.CldsSdcServiceInfo; +import org.onap.clamp.clds.model.CldsServiceData; +import org.onap.clamp.clds.model.CldsVfData; +import org.onap.clamp.clds.model.CldsVfKPIData; +import org.onap.clamp.clds.model.CldsVfcData; +import org.onap.clamp.clds.model.prop.Global; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.util.LoggingUtils; +import org.springframework.beans.factory.annotation.Autowired; + +public class SdcCatalogServices { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCatalogServices.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + private static final String RESOURCE_VF_TYPE = "VF"; + private static final String RESOURCE_VFC_TYPE = "VFC"; + + @Autowired + private RefProp refProp; + + /** + * This method get the SDC services Information with the corresponding + * Service UUID. + * + * @param uuid + * The service UUID + * @return A Json String with all the service list + */ + public String getSdcServicesInformation(String uuid) { + Date startTime = new Date(); + String baseUrl = refProp.getStringValue("sdc.serviceUrl"); + String basicAuth = SdcReq.getSdcBasicAuth(refProp); + LoggingUtils.setTargetContext("SDC", "getSdcServicesInformation"); + + try { + String url = baseUrl; + if (uuid != null) { + url = baseUrl + "/" + uuid + "/metadata"; + } + URL urlObj = new URL(url); + + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + + conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool"); + conn.setRequestProperty("Authorization", basicAuth); + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); + conn.setRequestMethod("GET"); + + String resp = getResponse(conn); + if (resp != null) { + logger.info(resp.toString()); + // metrics log + LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName()); + return resp; + } + } catch (IOException e) { + LoggingUtils.setResponseContext("900", "Get sdc services failed", this.getClass().getName()); + LoggingUtils.setErrorContext("900", "Get sdc services error"); + logger.error("not able to get any service information from sdc for uuid:" + uuid, e); + } finally { + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("getSdcServicesInformation complete"); + } + + return ""; + } + + /** + * To remove duplicate serviceUUIDs from sdc services List. + * + * @param rawCldsSdcServiceList + * A list of CldsSdcServiceInfo + * @return A list of CldsSdcServiceInfo without duplicate service UUID + */ + public List removeDuplicateServices(List rawCldsSdcServiceList) { + List cldsSdcServiceInfoList = null; + if (rawCldsSdcServiceList != null && rawCldsSdcServiceList.size() > 0) { + // sort list + Collections.sort(rawCldsSdcServiceList); + // and then take only the services with the max version (last in the + // list with the same name) + cldsSdcServiceInfoList = new ArrayList<>(); + for (int i = 1; i < rawCldsSdcServiceList.size(); i++) { + // compare name with previous - if not equal, then keep the + // previous (it's the last with that name) + CldsSdcServiceInfo prev = rawCldsSdcServiceList.get(i - 1); + if (!rawCldsSdcServiceList.get(i).getName().equals(prev.getName())) { + cldsSdcServiceInfoList.add(prev); + } + } + // add the last in the list + cldsSdcServiceInfoList.add(rawCldsSdcServiceList.get(rawCldsSdcServiceList.size() - 1)); + } + return cldsSdcServiceInfoList; + } + + /** + * To remove duplicate serviceUUIDs from sdc resources List. + * + * @param rawCldsSdcResourceList + * @return + */ + public List removeDuplicateSdcResourceInstances(List rawCldsSdcResourceList) { + List cldsSdcResourceList = null; + if (rawCldsSdcResourceList != null && rawCldsSdcResourceList.size() > 0) { + // sort list + Collections.sort(rawCldsSdcResourceList); + // and then take only the resources with the max version (last in + // the list with the same name) + cldsSdcResourceList = new ArrayList<>(); + for (int i = 1; i < rawCldsSdcResourceList.size(); i++) { + // compare name with previous - if not equal, then keep the + // previous (it's the last with that name) + CldsSdcResource prev = rawCldsSdcResourceList.get(i - 1); + if (!rawCldsSdcResourceList.get(i).getResourceInstanceName().equals(prev.getResourceInstanceName())) { + cldsSdcResourceList.add(prev); + } + } + // add the last in the list + cldsSdcResourceList.add(rawCldsSdcResourceList.get(rawCldsSdcResourceList.size() - 1)); + } + return cldsSdcResourceList; + } + + /** + * To remove duplicate basic resources with same resourceUUIDs. + * + * @param rawCldsSdcResourceListBasicList + * @return + */ + public List removeDuplicateSdcResourceBasicInfo( + List rawCldsSdcResourceListBasicList) { + List cldsSdcResourceBasicInfoList = null; + if (rawCldsSdcResourceListBasicList != null && rawCldsSdcResourceListBasicList.size() > 0) { + // sort list + Collections.sort(rawCldsSdcResourceListBasicList); + // and then take only the resources with the max version (last in + // the list with the same name) + cldsSdcResourceBasicInfoList = new ArrayList<>(); + for (int i = 1; i < rawCldsSdcResourceListBasicList.size(); i++) { + // compare name with previous - if not equal, then keep the + // previous (it's the last with that name) + CldsSdcResourceBasicInfo prev = rawCldsSdcResourceListBasicList.get(i - 1); + if (!rawCldsSdcResourceListBasicList.get(i).getName().equals(prev.getName())) { + cldsSdcResourceBasicInfoList.add(prev); + } + } + // add the last in the list + cldsSdcResourceBasicInfoList + .add(rawCldsSdcResourceListBasicList.get(rawCldsSdcResourceListBasicList.size() - 1)); + } + return cldsSdcResourceBasicInfoList; + } + + /** + * To get ServiceUUID by using serviceInvariantUUID. + * + * @param invariantId + * The invariant ID + * @return The service UUID + * @throws IOException + * In case of issues with the JSON decoder + */ + public String getServiceUuidFromServiceInvariantId(String invariantId) throws IOException { + String serviceUuid = ""; + String responseStr = getSdcServicesInformation(null); + List rawCldsSdcServicesList = getCldsSdcServicesListFromJson(responseStr); + List cldsSdcServicesList = removeDuplicateServices(rawCldsSdcServicesList); + if (cldsSdcServicesList != null && cldsSdcServicesList.size() > 0) { + for (CldsSdcServiceInfo currCldsSdcServiceInfo : cldsSdcServicesList) { + if (currCldsSdcServiceInfo != null && currCldsSdcServiceInfo.getInvariantUUID() != null + && currCldsSdcServiceInfo.getInvariantUUID().equalsIgnoreCase(invariantId)) { + serviceUuid = currCldsSdcServiceInfo.getUuid(); + break; + } + } + } + return serviceUuid; + } + + /** + * To get CldsAsdsServiceInfo class by parsing json string. + * + * @param jsonStr + * @return + * @throws IOException + */ + public List getCldsSdcServicesListFromJson(String jsonStr) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + if (StringUtils.isBlank(jsonStr)) { + return null; + } + return objectMapper.readValue(jsonStr, + objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcServiceInfo.class)); + } + + /** + * To get List of CldsSdcResourceBasicInfo class by parsing json string. + * + * @param jsonStr + * @return + * @throws IOException + */ + public List getAllSdcResourcesListFromJson(String jsonStr) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + if (StringUtils.isBlank(jsonStr)) { + return null; + } + return objectMapper.readValue(jsonStr, + objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcResourceBasicInfo.class)); + } + + /** + * To get CldsAsdsResource class by parsing json string. + * + * @param jsonStr + * @return + * @throws IOException + */ + public CldsSdcResource getCldsSdcResourceFromJson(String jsonStr) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(jsonStr, CldsSdcResource.class); + } + + /** + * To get CldsSdcServiceDetail by parsing json string. + * + * @param jsonStr + * @return + * @throws IOException + */ + public CldsSdcServiceDetail getCldsSdcServiceDetailFromJson(String jsonStr) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(jsonStr, CldsSdcServiceDetail.class); + } + + /** + * To upload artifact to sdc based on serviceUUID and resourcename on url. + * + * @param prop + * @param userid + * @param url + * @param formatttedSdcReq + * @return + * @throws IOException + */ + public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formatttedSdcReq) + throws IOException { + // Verify whether it is triggered by Validation Test button from UI + if (prop.isTest()) { + return "sdc artifact upload not executed for test action"; + } + logger.info("userid=" + userid); + String md5Text = SdcReq.calculateMD5ByString(formatttedSdcReq); + byte[] postData = SdcReq.stringToByteArray(formatttedSdcReq); + int postDataLength = postData.length; + HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, md5Text); + try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { + wr.write(postData); + } + boolean requestFailed = true; + int responseCode = conn.getResponseCode(); + logger.info("responseCode=" + responseCode); + if (responseCode == 200) { + requestFailed = false; + } + + String responseStr = getResponse(conn); + if (responseStr != null) { + if (requestFailed) { + logger.error("requestFailed - responseStr=" + responseStr); + throw new BadRequestException(responseStr); + } + } + return responseStr; + } + + private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text) + throws IOException { + logger.info("userid=" + userid); + String basicAuth = SdcReq.getSdcBasicAuth(refProp); + String sdcXonapInstanceId = refProp.getStringValue("sdc.sdcX-InstanceID"); + URL urlObj = new URL(url); + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + conn.setDoOutput(true); + conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), sdcXonapInstanceId); + conn.setRequestProperty("Authorization", basicAuth); + conn.setRequestProperty("Content-Type", "application/json"); + conn.setRequestProperty("Content-MD5", md5Text); + conn.setRequestProperty("USER_ID", userid); + conn.setRequestMethod("POST"); + conn.setRequestProperty("charset", "utf-8"); + conn.setRequestProperty("Content-Length", Integer.toString(postDataLength)); + conn.setUseCaches(false); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); + return conn; + } + + private String getResponse(HttpURLConnection conn) throws IOException { + try (InputStream is = getInputStream(conn)) { + if (is != null) { + try (BufferedReader in = new BufferedReader(new InputStreamReader(is))) { + StringBuilder response = new StringBuilder(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + } + return response.toString(); + } + } + } + return null; + } + + private InputStream getInputStream(HttpURLConnection conn) throws IOException { + InputStream inStream = conn.getErrorStream(); + if (inStream == null) { + inStream = conn.getInputStream(); + } + return inStream; + } + + public CldsDBServiceCache getCldsDbServiceCacheUsingCldsServiceData(CldsServiceData cldsServiceData) + throws IOException { + CldsDBServiceCache cldsDbServiceCache = new CldsDBServiceCache(); + cldsDbServiceCache.setCldsDataInstream(cldsServiceData); + cldsDbServiceCache.setInvariantId(cldsServiceData.getServiceInvariantUUID()); + cldsDbServiceCache.setServiceId(cldsServiceData.getServiceUUID()); + return cldsDbServiceCache; + } + + public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData) throws IOException { + boolean expired = false; + if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) { + String cachedServiceUuid = cldsServiceData.getServiceUUID(); + String latestServiceUuid = getServiceUuidFromServiceInvariantId(cldsServiceData.getServiceInvariantUUID()); + String defaultRecordAge = refProp.getStringValue("CLDS_SERVICE_CACHE_MAX_SECONDS"); + if ((!cachedServiceUuid.equalsIgnoreCase(latestServiceUuid)) || (cldsServiceData.getAgeOfRecord() != null + && cldsServiceData.getAgeOfRecord() > Long.parseLong(defaultRecordAge))) { + expired = true; + } + } else { + expired = true; + } + return expired; + } + + public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUuid) throws IOException { + String url = refProp.getStringValue("sdc.serviceUrl"); + String catalogUrl = refProp.getStringValue("sdc.catalog.url"); + String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid); + String serviceDetailUrl = url + "/" + serviceUuid + "/metadata"; + String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl, false); + ObjectMapper objectMapper = new ObjectMapper(); + CldsServiceData cldsServiceData = new CldsServiceData(); + if (responseStr != null) { + CldsSdcServiceDetail cldsSdcServiceDetail = objectMapper.readValue(responseStr, CldsSdcServiceDetail.class); + cldsServiceData.setServiceUUID(cldsSdcServiceDetail.getUuid()); + cldsServiceData.setServiceInvariantUUID(cldsSdcServiceDetail.getInvariantUUID()); + + // To remove duplicate resources from serviceDetail and add valid + // vfs to service + if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null) { + List cldsSdcResourceList = removeDuplicateSdcResourceInstances( + cldsSdcServiceDetail.getResources()); + if (cldsSdcResourceList != null && cldsSdcResourceList.size() > 0) { + List cldsVfDataList = new ArrayList<>(); + for (CldsSdcResource currCldsSdcResource : cldsSdcResourceList) { + if (currCldsSdcResource != null && currCldsSdcResource.getResoucreType() != null + && currCldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { + CldsVfData currCldsVfData = new CldsVfData(); + currCldsVfData.setVfName(currCldsSdcResource.getResourceInstanceName()); + currCldsVfData.setVfInvariantResourceUUID(currCldsSdcResource.getResourceInvariantUUID()); + cldsVfDataList.add(currCldsVfData); + } + } + cldsServiceData.setCldsVfs(cldsVfDataList); + // For each vf in the list , add all vfc's + getAllVfcForVfList(cldsVfDataList, catalogUrl); + logger.info("value of cldsServiceData:" + cldsServiceData); + logger.info("value of cldsServiceData:" + cldsServiceData.getServiceInvariantUUID()); + } + } + } + return cldsServiceData; + } + + /** + * @param cldsVfDataList + * @throws IOException + */ + private void getAllVfcForVfList(List cldsVfDataList, String catalogUrl) throws IOException { + // todo : refact this.. + if (cldsVfDataList != null && cldsVfDataList.size() > 0) { + List allVfResources = getAllSdcVForVfcResourcesBasedOnResourceType( + RESOURCE_VF_TYPE); + List allVfcResources = getAllSdcVForVfcResourcesBasedOnResourceType( + RESOURCE_VFC_TYPE); + for (CldsVfData currCldsVfData : cldsVfDataList) { + if (currCldsVfData != null && currCldsVfData.getVfInvariantResourceUUID() != null) { + String resourceUuid = getResourceUuidFromResourceInvariantUuid( + currCldsVfData.getVfInvariantResourceUUID(), allVfResources); + if (resourceUuid != null) { + String vfResourceUuidUrl = catalogUrl + "resources" + "/" + resourceUuid + "/metadata"; + String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl, false); + if (vfResponse != null) { + // Below 2 line are to get the KPI(field path) data + // associated with the VF's + List cldsVfKPIDataList = getFieldPathFromVF(vfResponse); + currCldsVfData.setCldsKPIList(cldsVfKPIDataList); + + List vfcDataListFromVfResponse = getVfcDataListFromVfResponse(vfResponse); + if (vfcDataListFromVfResponse != null) { + currCldsVfData.setCldsVfcs(vfcDataListFromVfResponse); + if (vfcDataListFromVfResponse.size() > 0) { + // To get artifacts for every VFC and get + // alarm conditions from artifact + for (CldsVfcData currCldsVfcData : vfcDataListFromVfResponse) { + if (currCldsVfcData != null + && currCldsVfcData.getVfcInvariantResourceUUID() != null) { + String resourceVfcUuid = getResourceUuidFromResourceInvariantUuid( + currCldsVfcData.getVfcInvariantResourceUUID(), allVfcResources); + if (resourceVfcUuid != null) { + String vfcResourceUuidUrl = catalogUrl + "resources" + "/" + + resourceVfcUuid + "/metadata"; + String vfcResponse = getCldsServicesOrResourcesBasedOnURL( + vfcResourceUuidUrl, false); + if (vfcResponse != null) { + List alarmCondtionsFromVfc = getAlarmCondtionsFromVfc( + vfcResponse); + currCldsVfcData.setCldsAlarmConditions(alarmCondtionsFromVfc); + } + } else { + logger.info("No resourceVFC UUID found for given invariantID:" + + currCldsVfcData.getVfcInvariantResourceUUID()); + } + } + } + } + } + } + } else { + logger.info("No resourceUUID found for given invariantREsourceUUID:" + + currCldsVfData.getVfInvariantResourceUUID()); + } + } + } + } + } + + private List getVfcDataListFromVfResponse(String vfResponse) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); + ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources"); + List cldsVfcDataList = new ArrayList<>(); + if (vfcArrayNode != null) { + for (JsonNode vfcjsonNode : vfcArrayNode) { + CldsVfcData currCldsVfcData = new CldsVfcData(); + ObjectNode currVfcNode = (ObjectNode) vfcjsonNode; + TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType"); + if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) { + TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName"); + TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID"); + currCldsVfcData.setVfcName(vfcResourceName.textValue()); + currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue()); + cldsVfcDataList.add(currCldsVfcData); + } else if (resourceTypeNode != null && "CVFC".equalsIgnoreCase(resourceTypeNode.textValue())) { + cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").textValue())); + } + } + } + return cldsVfcDataList; + } + + private List getVFCfromCVFC(String resourceUUID) { + String catalogUrl = refProp.getStringValue("sdc.catalog.url"); + List cldsVfcDataList = new ArrayList(); + + if (resourceUUID != null) { + String vfcResourceUUIDUrl = catalogUrl + "resources" + "/" + resourceUUID + "/metadata"; + try { + String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl, false); + ObjectMapper mapper = new ObjectMapper(); + ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfcResponse); + ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources"); + + if (vfcArrayNode != null) { + for (JsonNode vfcjsonNode : vfcArrayNode) { + CldsVfcData currCldsVfcData = new CldsVfcData(); + ObjectNode currVfcNode = (ObjectNode) vfcjsonNode; + TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType"); + if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) { + TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName"); + TextNode vfcInvariantResourceUUID = (TextNode) currVfcNode.get("resourceInvariantUUID"); + currCldsVfcData.setVfcName(vfcResourceName.textValue()); + currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUUID.textValue()); + cldsVfcDataList.add(currCldsVfcData); + } + } + } + } catch (IOException e) { + logger.error("Exception during JSON analyzis", e); + } + } + return cldsVfcDataList; + } + + private String removeUnwantedBracesFromString(String id) { + if (id != null && id.contains("\"")) { + id = id.replaceAll("\"", ""); + } + return id; + } + + private List getAlarmCondtionsFromVfc(String vfcResponse) throws IOException { + List cldsAlarmConditionList = new ArrayList<>(); + ObjectMapper mapper = new ObjectMapper(); + ObjectNode vfcResponseNode = (ObjectNode) mapper.readTree(vfcResponse); + ArrayNode artifactsArrayNode = (ArrayNode) vfcResponseNode.get("artifacts"); + + if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) { + for (int index = 0; index < artifactsArrayNode.size(); index++) { + ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index); + TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL"); + if (artifactUrlNode != null) { + String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue()); + cldsAlarmConditionList.addAll(parseCsvToGetAlarmConditions(responsesFromArtifactUrl)); + logger.info(responsesFromArtifactUrl); + } + } + } + return cldsAlarmConditionList; + } + + private List parseCsvToGetAlarmConditions(String allAlarmCondsValues) throws IOException { + List cldsAlarmConditionList = new ArrayList<>(); + Reader alarmReader = new StringReader(allAlarmCondsValues); + Iterable records = CSVFormat.RFC4180.parse(alarmReader); + if (records != null) { + Iterator it = records.iterator(); + if (it.hasNext()) { + it.next(); + } + it.forEachRemaining(record -> processRecord(cldsAlarmConditionList, record)); + } + return cldsAlarmConditionList; + } + + // Method to get the artifact for any particular VF + private List getFieldPathFromVF(String vfResponse) throws JsonProcessingException, IOException { + List cldsVfKPIDataList = new ArrayList(); + ObjectMapper mapper = new ObjectMapper(); + ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); + ArrayNode artifactsArrayNode = (ArrayNode) vfResponseNode.get("artifacts"); + + if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) { + for (int index = 0; index < artifactsArrayNode.size(); index++) { + ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index); + TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL"); + TextNode artifactNameNode = (TextNode) currArtifactNode.get("artifactName"); + String artifactName = ""; + if (artifactNameNode != null) { + artifactName = artifactNameNode.textValue(); + artifactName = artifactName.substring(artifactName.lastIndexOf(".") + 1); + } + if (artifactUrlNode != null && artifactName != null && !artifactName.isEmpty() + && artifactName.equalsIgnoreCase("csv")) { + String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue()); + cldsVfKPIDataList.addAll(parseCsvToGetFieldPath(responsesFromArtifactUrl)); + logger.info(responsesFromArtifactUrl); + } + } + } + return cldsVfKPIDataList; + } + + private CldsVfKPIData convertCsvRecordToKpiData(CSVRecord record) { + if (record.size() < 6) { + logger.debug("invalid csv field path Record,total columns less than 6: " + record); + return null; + } + + if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3)) + || StringUtils.isBlank(record.get(5))) { + logger.debug("Invalid csv field path Record,one of column is having blank value : " + record); + return null; + } + + CldsVfKPIData cldsVfKPIData = new CldsVfKPIData(); + cldsVfKPIData.setNfNamingCode(record.get(0).trim()); + cldsVfKPIData.setNfNamingValue(record.get(1).trim()); + + cldsVfKPIData.setFieldPath(record.get(2).trim()); + cldsVfKPIData.setFieldPathValue(record.get(3).trim()); + + cldsVfKPIData.setThresholdName(record.get(4).trim()); + cldsVfKPIData.setThresholdValue(record.get(5).trim()); + return cldsVfKPIData; + + } + + // Method to get the artifactURL Data and set the CldsVfKPIData node + private List parseCsvToGetFieldPath(String allFieldPathValues) throws IOException { + List cldsVfKPIDataList = new ArrayList(); + Reader alarmReader = new StringReader(allFieldPathValues); + Iterable records = CSVFormat.RFC4180.parse(alarmReader); + if (records != null) { + for (CSVRecord record : records) { + CldsVfKPIData kpiData = this.convertCsvRecordToKpiData(record); + if (kpiData != null) { + cldsVfKPIDataList.add(kpiData); + } + } + } + return cldsVfKPIDataList; + } + + private void processRecord(List cldsAlarmConditionList, CSVRecord record) { + if (record == null) { + return; + } + if (record.size() < 5) { + logger.debug("invalid csv alarm Record,total columns less than 5: " + record); + return; + } + if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3)) + || StringUtils.isBlank(record.get(4))) { + logger.debug("invalid csv alarm Record,one of column is having blank value : " + record); + return; + } + CldsAlarmCondition cldsAlarmCondition = new CldsAlarmCondition(); + cldsAlarmCondition.setEventSourceType(record.get(1)); + cldsAlarmCondition.setEventName(record.get(2)); + cldsAlarmCondition.setAlarmConditionKey(record.get(3)); + cldsAlarmCondition.setSeverity(record.get(4)); + cldsAlarmConditionList.add(cldsAlarmCondition); + } + + public String getResponsesFromArtifactUrl(String artifactsUrl) { + String hostUrl = refProp.getStringValue("sdc.hostUrl"); + artifactsUrl = artifactsUrl.replaceAll("\"", ""); + String artifactUrl = hostUrl + artifactsUrl; + logger.info("value of artifactURl:" + artifactUrl); + String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl, true); + logger.info("value of artifactResponse:" + currArtifactResponse); + return currArtifactResponse; + } + + /** + * Service to services/resources/artifacts from sdc.Pass alarmConditions as + * true to get alarmconditons from artifact url and else it is false + * + * @param url + * @param alarmConditions + * @return + * @throws IOException + */ + public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions) { + try { + url = removeUnwantedBracesFromString(url); + URL urlObj = new URL(url); + + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + String basicAuth = SdcReq.getSdcBasicAuth(refProp); + conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool"); + conn.setRequestProperty("Authorization", basicAuth); + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); + conn.setRequestMethod("GET"); + + int responseCode = conn.getResponseCode(); + logger.info("responseCode=" + responseCode); + StringBuilder response; + try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) { + response = new StringBuilder(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + response.append(inputLine); + if (alarmConditions) { + response.append("\n"); + } + } + } + return response.toString(); + } catch (IOException e) { + logger.error("Exception occurred during query to SDC", e); + return ""; + } + + } + + /** + * To create properties object by using cldsServicedata. + * + * @param globalProps + * @param cldsServiceData + * @return + * @throws IOException + */ + public String createPropertiesObjectByUUID(String globalProps, CldsServiceData cldsServiceData) throws IOException { + String totalPropsStr; + ObjectMapper mapper = new ObjectMapper(); + ObjectNode globalPropsJson; + if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) { + + // Objectnode to save all byservice, byvf , byvfc and byalarm nodes + ObjectNode byIdObjectNode = mapper.createObjectNode(); + + // To create vf ResourceUUID node with serviceInvariantUUID + ObjectNode invariantUuidObjectNodeWithVf = createVfObjectNodeByServiceInvariantUuid(mapper, + cldsServiceData); + byIdObjectNode.putPOJO("byService", invariantUuidObjectNodeWithVf); + + // To create byVf and vfcResourceNode with vfResourceUUID + ObjectNode vfcObjectNodeByVfUuid = createVfcObjectNodeByVfUuid(mapper, cldsServiceData.getCldsVfs()); + byIdObjectNode.putPOJO("byVf", vfcObjectNodeByVfUuid); + + // To create byKpi + ObjectNode kpiObjectNode = mapper.createObjectNode(); + if (cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { + for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { + if (currCldsVfData != null) { + createKpiObjectNodeByVfUuid(mapper, kpiObjectNode, currCldsVfData.getCldsKPIList()); + } + } + } + byIdObjectNode.putPOJO("byKpi", kpiObjectNode); + + // To create byVfc and alarmCondition with vfcResourceUUID + ObjectNode vfcResourceUuidObjectNode = mapper.createObjectNode(); + if (cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { + for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { + if (currCldsVfData != null) { + createAlarmCondObjectNodeByVfcUuid(mapper, vfcResourceUuidObjectNode, + currCldsVfData.getCldsVfcs()); + } + } + } + byIdObjectNode.putPOJO("byVfc", vfcResourceUuidObjectNode); + + // To create byAlarmCondition with alarmConditionKey + List allAlarmConditions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData, + "alarmCondition"); + ObjectNode alarmCondObjectNodeByAlarmKey = createAlarmCondObjectNodeByAlarmKey(mapper, allAlarmConditions); + + byIdObjectNode.putPOJO("byAlarmCondition", alarmCondObjectNodeByAlarmKey); + + // To create byAlertDescription with AlertDescription + List allAlertDescriptions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData, + "alertDescription"); + ObjectNode alertDescObjectNodeByAlert = createAlarmCondObjectNodeByAlarmKey(mapper, allAlertDescriptions); + + byIdObjectNode.putPOJO("byAlertDescription", alertDescObjectNodeByAlert); + + globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); + + globalPropsJson.putPOJO("shared", byIdObjectNode); + logger.info("valuie of objNode:" + globalPropsJson); + } else { + /** + * to create json with total properties when no serviceUUID passed + */ + globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); + } + totalPropsStr = globalPropsJson.toString(); + return totalPropsStr; + } + + /** + * Method to get alarm conditions/alert description from Service Data. + * + * @param cldsServiceData + * CldsServiceData the Service Data to analyze + * @param eventName + * The String event name that will be used to filter the alarm + * list + * @return The list of CldsAlarmCondition for the event name specified + */ + public List getAllAlarmConditionsFromCldsServiceData(CldsServiceData cldsServiceData, + String eventName) { + List alarmCondList = new ArrayList<>(); + if (cldsServiceData != null && cldsServiceData.getCldsVfs() != null + && !cldsServiceData.getCldsVfs().isEmpty()) { + for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { + alarmCondList.addAll(getAllAlarmConditionsFromCldsVfData(currCldsVfData, eventName)); + } + } + return alarmCondList; + } + + /** + * Method to get alarm conditions/alert description from VF Data. + * + * @param currCldsVfData + * The Vf Data to analyze + * @param eventName + * The String event name that will be used to filter the alarm + * list + * @return The list of CldsAlarmCondition for the event name specified + */ + private List getAllAlarmConditionsFromCldsVfData(CldsVfData currCldsVfData, String eventName) { + List alarmCondList = new ArrayList<>(); + + if (currCldsVfData != null && currCldsVfData.getCldsVfcs() != null && !currCldsVfData.getCldsVfcs().isEmpty()) { + for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { + alarmCondList.addAll(getAllAlarmConditionsFromCldsVfcData(currCldsVfcData, eventName)); + } + } + return alarmCondList; + } + + /** + * Method to get alarm conditions/alert description from VFC Data. + * + * @param currCldsVfcData + * The VfC Data to analyze + * @param eventName + * The String event name that will be used to filter the alarm + * list + * @return The list of CldsAlarmCondition for the event name specified + */ + private List getAllAlarmConditionsFromCldsVfcData(CldsVfcData currCldsVfcData, + String eventName) { + List alarmCondList = new ArrayList<>(); + + if (currCldsVfcData != null && currCldsVfcData.getCldsAlarmConditions() != null + && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) { + for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) { + if (currCldsAlarmCondition != null + && currCldsAlarmCondition.getEventName().equalsIgnoreCase(eventName)) { + alarmCondList.add(currCldsAlarmCondition); + } + } + } + return alarmCondList; + } + + private ObjectNode createAlarmCondObjectNodeByAlarmKey(ObjectMapper mapper, + List cldsAlarmCondList) { + ObjectNode alarmCondKeyNode = mapper.createObjectNode(); + + if (cldsAlarmCondList != null && cldsAlarmCondList.size() > 0) { + for (CldsAlarmCondition currCldsAlarmCondition : cldsAlarmCondList) { + if (currCldsAlarmCondition != null) { + ObjectNode alarmCondNode = mapper.createObjectNode(); + alarmCondNode.put("eventSourceType", currCldsAlarmCondition.getEventSourceType()); + alarmCondNode.put("eventSeverity", currCldsAlarmCondition.getSeverity()); + alarmCondKeyNode.putPOJO(currCldsAlarmCondition.getAlarmConditionKey(), alarmCondNode); + } + } + } else { + ObjectNode alarmCondNode = mapper.createObjectNode(); + alarmCondNode.put("eventSourceType", ""); + alarmCondNode.put("eventSeverity", ""); + alarmCondKeyNode.putPOJO("", alarmCondNode); + } + return alarmCondKeyNode; + } + + private ObjectNode createVfObjectNodeByServiceInvariantUuid(ObjectMapper mapper, CldsServiceData cldsServiceData) { + ObjectNode invariantUuidObjectNode = mapper.createObjectNode(); + ObjectNode vfObjectNode = mapper.createObjectNode(); + ObjectNode vfUuidNode = mapper.createObjectNode(); + List cldsVfsList = cldsServiceData.getCldsVfs(); + if (cldsVfsList != null && cldsVfsList.size() > 0) { + for (CldsVfData currCldsVfData : cldsVfsList) { + if (currCldsVfData != null) { + vfUuidNode.put(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName()); + } + } + } else { + vfUuidNode.put("", ""); + } + vfObjectNode.putPOJO("vf", vfUuidNode); + invariantUuidObjectNode.putPOJO(cldsServiceData.getServiceInvariantUUID(), vfObjectNode); + return invariantUuidObjectNode; + } + + private void createKpiObjectNodeByVfUuid(ObjectMapper mapper, ObjectNode vfResourceUuidObjectNode, + List cldsVfKpiDataList) { + if (cldsVfKpiDataList != null && cldsVfKpiDataList.size() > 0) { + for (CldsVfKPIData currCldsVfKpiData : cldsVfKpiDataList) { + if (currCldsVfKpiData != null) { + ObjectNode thresholdNameObjectNode = mapper.createObjectNode(); + + ObjectNode fieldPathObjectNode = mapper.createObjectNode(); + ObjectNode nfNamingCodeNode = mapper.createObjectNode(); + + fieldPathObjectNode.put(currCldsVfKpiData.getFieldPathValue(), + currCldsVfKpiData.getFieldPathValue()); + nfNamingCodeNode.put(currCldsVfKpiData.getNfNamingValue(), currCldsVfKpiData.getNfNamingValue()); + + thresholdNameObjectNode.putPOJO("fieldPath", fieldPathObjectNode); + thresholdNameObjectNode.putPOJO("nfNamingCode", nfNamingCodeNode); + + vfResourceUuidObjectNode.putPOJO(currCldsVfKpiData.getThresholdValue(), thresholdNameObjectNode); + } + } + } + } + + private void createAlarmCondObjectNodeByVfcUuid(ObjectMapper mapper, ObjectNode vfcResourceUuidObjectNode, + List cldsVfcDataList) { + ObjectNode vfcObjectNode = mapper.createObjectNode(); + ObjectNode alarmCondNode = mapper.createObjectNode(); + ObjectNode alertDescNode = mapper.createObjectNode(); + if (cldsVfcDataList != null && cldsVfcDataList.size() > 0) { + for (CldsVfcData currCldsVfcData : cldsVfcDataList) { + if (currCldsVfcData != null) { + if (currCldsVfcData.getCldsAlarmConditions() != null + && currCldsVfcData.getCldsAlarmConditions().size() > 0) { + for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) { + alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(), + currCldsAlarmCondition.getAlarmConditionKey()); + if (currCldsAlarmCondition.getEventName().equalsIgnoreCase("alarmCondition")) { + alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(), + currCldsAlarmCondition.getAlarmConditionKey()); + } else { + alertDescNode.put(currCldsAlarmCondition.getAlarmConditionKey(), + currCldsAlarmCondition.getAlarmConditionKey()); + } + } + } + vfcObjectNode.putPOJO("alarmCondition", alarmCondNode); + vfcObjectNode.putPOJO("alertDescription", alertDescNode); + vfcResourceUuidObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), vfcObjectNode); + } + } + } else { + alarmCondNode.put("", ""); + vfcObjectNode.putPOJO("alarmCondition", alarmCondNode); + alertDescNode.put("", ""); + vfcObjectNode.putPOJO("alertDescription", alarmCondNode); + vfcResourceUuidObjectNode.putPOJO("", vfcObjectNode); + } + } + + private ObjectNode createVfcObjectNodeByVfUuid(ObjectMapper mapper, List cldsVfDataList) { + ObjectNode vfUuidObjectNode = mapper.createObjectNode(); + + if (cldsVfDataList != null && cldsVfDataList.size() > 0) { + for (CldsVfData currCldsVfData : cldsVfDataList) { + if (currCldsVfData != null) { + ObjectNode vfcObjectNode = mapper.createObjectNode(); + ObjectNode vfcUuidNode = mapper.createObjectNode(); + if (currCldsVfData.getCldsVfcs() != null && currCldsVfData.getCldsVfcs().size() > 0) { + for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { + vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(), + currCldsVfcData.getVfcName()); + } + } else { + vfcUuidNode.put("", ""); + } + vfcObjectNode.putPOJO("vfc", vfcUuidNode); + vfUuidObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfcObjectNode); + } + } + } else { + ObjectNode vfcUuidNode = mapper.createObjectNode(); + vfcUuidNode.put("", ""); + ObjectNode vfcObjectNode = mapper.createObjectNode(); + vfcObjectNode.putPOJO("vfc", vfcUuidNode); + vfUuidObjectNode.putPOJO("", vfcObjectNode); + } + return vfUuidObjectNode; + } + + /** + * This method searches the equivalent artifact UUID for a specific + * artifactName in a SdcServiceDetail. + * + * @param cldsSdcServiceDetail + * The SdcServiceDetail that will be analyzed + * @param artifactName + * The artifact name that will be searched + * @return The artifact UUID found + */ + public String getArtifactIdIfArtifactAlreadyExists(CldsSdcServiceDetail cldsSdcServiceDetail, String artifactName) { + String artifactUuid = null; + boolean artifactExists = false; + if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null + && !cldsSdcServiceDetail.getResources().isEmpty()) { + for (CldsSdcResource currCldsSdcResource : cldsSdcServiceDetail.getResources()) { + if (artifactExists) { + break; + } + if (currCldsSdcResource != null && currCldsSdcResource.getArtifacts() != null + && !currCldsSdcResource.getArtifacts().isEmpty()) { + for (CldsSdcArtifact currCldsSdcArtifact : currCldsSdcResource.getArtifacts()) { + if (currCldsSdcArtifact != null && currCldsSdcArtifact.getArtifactName() != null) { + if (currCldsSdcArtifact.getArtifactName().equalsIgnoreCase(artifactName)) { + artifactUuid = currCldsSdcArtifact.getArtifactUUID(); + artifactExists = true; + break; + } + } + } + } + } + } + return artifactUuid; + } + + public String updateControlLoopStatusToDcae(String dcaeUrl, String invariantResourceUuid, + String invariantServiceUuid, String artifactName) { + String baseUrl = refProp.getStringValue("sdc.serviceUrl"); + String basicAuth = SdcReq.getSdcBasicAuth(refProp); + String postStatusData = "{ \n" + "\"event\" : \"" + "Created" + "\",\n" + "\"serviceUUID\" : \"" + + invariantServiceUuid + "\",\n" + "\"resourceUUID\" :\"" + invariantResourceUuid + "\",\n" + + "\"artifactName\" : \"" + artifactName + "\",\n" + "} \n"; + try { + String url = baseUrl; + if (invariantServiceUuid != null) { + url = dcaeUrl + "/closed-loops"; + } + URL urlObj = new URL(url); + + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool"); + conn.setRequestProperty("Authorization", basicAuth); + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); + conn.setRequestMethod("POST"); + + byte[] postData = SdcReq.stringToByteArray(postStatusData); + try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { + wr.write(postData); + } + + int responseCode = conn.getResponseCode(); + logger.info("responseCode=" + responseCode); + + String resp = getResponse(conn); + if (resp != null) { + return resp; + } + } catch (IOException e) { + logger.error("Not able to get any service information from sdc for uuid:" + invariantServiceUuid, e); + } + return ""; + } + + /** + * To get all sdc VF/VFC Resources basic info. + * + * @param resourceType + * The resourceType + * @return The list of CldsSdcResourceBasicInfo + * @throws IOException + * In case of issues with the Streams + */ + private List getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType) + throws IOException { + List allSdcResourceVfcBasicInfo = new ArrayList(); + String catalogUrl = refProp.getStringValue("sdc.catalog.url"); + String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType; + String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false); + + allSdcResourceVfcBasicInfo = getAllSdcResourcesListFromJson(allSdcVfcResources); + return removeDuplicateSdcResourceBasicInfo(allSdcResourceVfcBasicInfo); + } + + private String getResourceUuidFromResourceInvariantUuid(String resourceInvariantUuid, + List resourceInfoList) throws IOException { + String resourceUuid = null; + if (resourceInfoList != null && resourceInfoList.size() > 0) { + for (CldsSdcResourceBasicInfo currResource : resourceInfoList) { + if (currResource != null && currResource.getInvariantUUID() != null && currResource.getUuid() != null + && currResource.getInvariantUUID().equalsIgnoreCase(resourceInvariantUuid)) { + resourceUuid = currResource.getUuid(); + break; + } + } + } + return resourceUuid; + } + + /** + * Method to get service invariant uuid from model properties. + * + * @param props + * The Clds model properties + * @return The Service Id + */ + private String getServiceInvariantUuidFromProps(ModelProperties props) { + String invariantUuid = ""; + Global globalProps = props.getGlobal(); + if (globalProps != null && globalProps.getService() != null) { + invariantUuid = globalProps.getService(); + } + return invariantUuid; + } + + /** + * This method upload the BluePrint to SDC. + * + * @param prop + * The Clds model Properties + * @param userid + * The user id for SDC + * @param sdcReqUrlsList + * The list of SDC URL to try + * @param formattedSdcReq + * The blueprint to upload + * @param formattedSdcLocationReq + * THe location Blueprint to upload + * @param artifactName + * The artifact name from where we can get the Artifact UUID + * @param locationArtifactName + * The location artifact name from where we can get the Artifact + * UUID + * @throws IOException + * In case of issues with the streams + * + */ + public void uploadToSdc(ModelProperties prop, String userid, List sdcReqUrlsList, String formattedSdcReq, + String formattedSdcLocationReq, String artifactName, String locationArtifactName) throws IOException { + logger.info("userid=" + userid); + String serviceInvariantUuid = getServiceInvariantUuidFromProps(prop); + if (sdcReqUrlsList != null && !sdcReqUrlsList.isEmpty()) { + for (String url : sdcReqUrlsList) { + if (url != null) { + String originalServiceUuid = getServiceUuidFromServiceInvariantId(serviceInvariantUuid); + logger.info("ServiceUUID used before upload in url:" + originalServiceUuid); + String sdcServicesInformation = getSdcServicesInformation(originalServiceUuid); + CldsSdcServiceDetail cldsSdcServiceDetail = getCldsSdcServiceDetailFromJson(sdcServicesInformation); + String uploadedArtifactUuid = getArtifactIdIfArtifactAlreadyExists(cldsSdcServiceDetail, + artifactName); + // Upload artifacts to sdc + String updateUrl = uploadedArtifactUuid != null ? url + "/" + uploadedArtifactUuid : url; + String responseStr = uploadArtifactToSdc(prop, userid, updateUrl, formattedSdcReq); + logger.info("value of sdc Response of uploading to sdc :" + responseStr); + String updatedServiceUuid = getServiceUuidFromServiceInvariantId(serviceInvariantUuid); + if (!originalServiceUuid.equalsIgnoreCase(updatedServiceUuid)) { + url = url.replace(originalServiceUuid, updatedServiceUuid); + } + logger.info("ServiceUUID used after upload in ulr:" + updatedServiceUuid); + sdcServicesInformation = getSdcServicesInformation(updatedServiceUuid); + cldsSdcServiceDetail = getCldsSdcServiceDetailFromJson(sdcServicesInformation); + uploadedArtifactUuid = getArtifactIdIfArtifactAlreadyExists(cldsSdcServiceDetail, + locationArtifactName); + // To send location information also to sdc + updateUrl = uploadedArtifactUuid != null ? url + "/" + uploadedArtifactUuid : url; + responseStr = uploadArtifactToSdc(prop, userid, updateUrl, formattedSdcLocationReq); + logger.info("value of sdc Response of uploading location to sdc :" + responseStr); + } + } + } + } +} diff --git a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java index 8ceaa3d87..b501b2df0 100644 --- a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java +++ b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java @@ -29,27 +29,32 @@ import java.util.Date; import java.util.TimeZone; import java.util.UUID; -import org.jboss.logging.MDC; +import org.apache.log4j.MDC; +/** + * This class handles the special info that appear in the log, like RequestID, + * time context, ... + * + */ public class LoggingUtils { /** * Set request related logging variables in thread local data via MDC - * + * * @param service * Service Name of API (ex. "PUT template") * @param partner * Partner name (client or user invoking API) */ public static void setRequestContext(String service, String partner) { - MDC.put("RequestId", UUID.randomUUID().toString()); + MDC.put("RequestId", UUID.randomUUID().toString()); MDC.put("ServiceName", service); MDC.put("PartnerName", partner); } /** - * Set time related logging variables in thread local data via MDC - * + * Set time related logging variables in thread local data via MDC. + * * @param beginTimeStamp * Start time * @param endTimeStamp @@ -72,7 +77,7 @@ public class LoggingUtils { } /** - * Set response related logging variables in thread local data via MDC + * Set response related logging variables in thread local data via MDC. * * @param code * Response code ("0" indicates success) @@ -102,7 +107,7 @@ public class LoggingUtils { } /** - * Set error related logging variables in thread local data via MDC + * Set error related logging variables in thread local data via MDC. * * @param code * Error code @@ -121,4 +126,22 @@ public class LoggingUtils { return df.format(timeStamp); } + /** + * Get a previously stored RequestID for the thread local data via MDC. If + * one was not previously stored, generate one, store it, and return that + * one. + * + * @return A string with the request ID + */ + public static String getRequestId() { + String reqid; + + reqid = (String) MDC.get("RequestID"); + if (reqid == null || reqid.isEmpty()) { + reqid = UUID.randomUUID().toString(); + MDC.put("RequestId", reqid); + } + return reqid; + } + } -- cgit 1.2.3-korg From 84d012a83b2955f6a92cd79bbc1d5d6d5857ca8e Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 04:43:14 -0700 Subject: Fix a potential NPE The code must verify if the policy has been found or not Change-Id: I41343aec40643c29180c892996e4a65d0805193e Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../clds/client/OperationalPolicyDeleteDelegate.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java index e7b0be53d..2c60941c8 100644 --- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java @@ -56,13 +56,15 @@ public class OperationalPolicyDeleteDelegate implements JavaDelegate { prop.setCurrentModelElementId(policy.getId()); String responseMessage = ""; - for (PolicyChain policyChain : policy.getPolicyChains()) { - prop.setPolicyUniqueId(policyChain.getPolicyId()); - responseMessage = policyClient.deleteBrms(prop); - } - if (responseMessage != null) { - execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes()); - } + if(policy.isFound()){ + for (PolicyChain policyChain : policy.getPolicyChains()) { + prop.setPolicyUniqueId(policyChain.getPolicyId()); + responseMessage = policyClient.deleteBrms(prop); + } + if (responseMessage != null) { + execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes()); + } + } } } -- cgit 1.2.3-korg From 24a56d20da89c70134cf7434d8de185519a948f0 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 04:44:20 -0700 Subject: Rework the SONAR/Checkstyle report Add bad/missing javadocs + rework the exception thrown + logs + reorganize the import Change-Id: I37b5c8983785f00df28bcaee852dc54fd11e8001 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../org/onap/clamp/clds/client/PolicyClient.java | 245 +++++++++++++-------- 1 file changed, 156 insertions(+), 89 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java index 1a1d31443..e16f056ce 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java @@ -23,16 +23,24 @@ package org.onap.clamp.clds.client; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.UUID; +import javax.ws.rs.BadRequestException; + import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.util.LoggingUtils; import org.onap.policy.api.AttributeType; import org.onap.policy.api.ConfigRequestParameters; import org.onap.policy.api.DeletePolicyCondition; @@ -41,6 +49,7 @@ import org.onap.policy.api.PolicyChangeResponse; import org.onap.policy.api.PolicyConfig; import org.onap.policy.api.PolicyConfigType; import org.onap.policy.api.PolicyEngine; +import org.onap.policy.api.PolicyEngineException; import org.onap.policy.api.PolicyParameters; import org.onap.policy.api.PolicyType; import org.onap.policy.api.PushPolicyParameters; @@ -48,9 +57,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - /** * Policy utility methods - specifically, send the policy. */ @@ -59,29 +65,36 @@ public class PolicyClient { protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}") - protected String cldsPolicyConfigFile; + protected String cldsPolicyConfigFile; @Autowired - protected ApplicationContext appContext; + protected ApplicationContext appContext; @Autowired - protected RefProp refProp; + protected RefProp refProp; public PolicyClient() { } /** - * Perform send of microservice policy + * Perform send of microservice policy. * * @param attributes + * A map of attributes * @param prop - * @param policyRequestUUID - * @return - * @throws Exception + * The ModelProperties + * @param policyRequestUuid + * PolicyRequest UUID + * @return The response message of policy + * @throws IOException + * In case of issues with the Stream + * @throws PolicyEngineException + * In case of issues with the PolicyEngine class + * */ public String sendBrms(Map> attributes, ModelProperties prop, - String policyRequestUUID) throws Exception { + String policyRequestUuid) throws PolicyEngineException, IOException { PolicyParameters policyParameters = new PolicyParameters(); @@ -99,9 +112,9 @@ public class PolicyClient { policyParameters.setAttributes(attributes); // Set a random UUID(Mandatory) - policyParameters.setRequestID(UUID.fromString(policyRequestUUID)); + policyParameters.setRequestID(UUID.fromString(policyRequestUuid)); String policyNamePrefix = refProp.getStringValue("policy.op.policyNamePrefix"); - String rtnMsg = send(policyParameters, prop, policyNamePrefix); + String rtnMsg = send(policyParameters, prop, policyNamePrefix); String policyType = refProp.getStringValue("policy.op.type"); push(policyType, prop); @@ -110,32 +123,43 @@ public class PolicyClient { } /** - * Perform send of microservice policy + * Perform send of microservice policy. * * @param policyJson + * The policy JSON * @param prop - * @param policyRequestUUID - * @return - * @throws Exception + * The ModelProperties + * @param policyRequestUuid + * The policy Request UUID + * @return The response message of policy + * @throws PolicyEngineException + * In case of issues with the policy engine class creation + * @throws IOException + * In case of issue with the Stream */ - public String sendMicroService(String policyJson, ModelProperties prop, String policyRequestUUID) throws Exception { + public String sendMicroService(String policyJson, ModelProperties prop, String policyRequestUuid) + throws IOException, PolicyEngineException { PolicyParameters policyParameters = new PolicyParameters(); // Set Policy Type policyParameters.setPolicyConfigType(PolicyConfigType.MicroService); - policyParameters.setOnapName(refProp.getStringValue("policy.ecomp.name")); + policyParameters.setEcompName(refProp.getStringValue("policy.ecomp.name")); policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); policyParameters.setConfigBody(policyJson); policyParameters.setConfigBodyType(PolicyType.JSON); - policyParameters.setRequestID(UUID.fromString(policyRequestUUID)); + policyParameters.setRequestID(UUID.fromString(policyRequestUuid)); String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); - prop.setPolicyUniqueId("");//Adding this line to clear the policy id from policy name while pushing to policy engine - String rtnMsg = send(policyParameters, prop, policyNamePrefix); - String policyType = refProp.getStringValue("policy.ms.type"); - push(policyType, prop); + + // Adding this line to clear the policy id from policy name while + // pushing to policy engine + prop.setPolicyUniqueId(""); + + String rtnMsg = send(policyParameters, prop, policyNamePrefix); + String policyType = refProp.getStringValue("policy.ms.type"); + push(policyType, prop); return rtnMsg; } @@ -144,29 +168,38 @@ public class PolicyClient { * Perform send of policy. * * @param policyParameters + * The PolicyParameters * @param prop - * @return - * @throws Exception + * The ModelProperties + * @return THe response message of Policy + * @throws IOException + * In case of issues with the Stream + * @throws PolicyEngineException + * In case of issue when creating PolicyEngine class */ - protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyNamePrefix) throws Exception { - // Verify whether it is triggered by Validation Test button from UI - if ( prop.isTest() ) { - return "send not executed for test action"; - } + protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyNamePrefix) + throws IOException, PolicyEngineException { + // Verify whether it is triggered by Validation Test button from UI + if (prop.isTest()) { + return "send not executed for test action"; + } PolicyEngine policyEngine = new PolicyEngine( - appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); // API method to create or update Policy. PolicyChangeResponse response = null; String responseMessage; + Date startTime = new Date(); try { - List versions = getVersions(policyNamePrefix, prop); - if (versions.size() <= 0) { + List versions = getVersions(policyNamePrefix, prop); + if (versions.size() <= 0) { + LoggingUtils.setTargetContext("Policy", "createPolicy"); logger.info("Attempting to create policy for action=" + prop.getActionCd()); response = policyEngine.createPolicy(policyParameters); responseMessage = response.getResponseMessage(); } else { + LoggingUtils.setTargetContext("Policy", "updatePolicy"); logger.info("Attempting to update policy for action=" + prop.getActionCd()); response = policyEngine.updatePolicy(policyParameters); responseMessage = response.getResponseMessage(); @@ -176,11 +209,15 @@ public class PolicyClient { } logger.info("response is " + responseMessage); + LoggingUtils.setTimeContext(startTime, new Date()); + if (response != null && response.getResponseCode() == 200) { logger.info("Policy send successful"); + metricsLogger.info("Policy send success"); } else { logger.warn("Policy send failed: " + responseMessage); - throw new Exception("Policy send failed: " + responseMessage); + metricsLogger.info("Policy send failure"); + throw new BadRequestException("Policy send failed: " + responseMessage); } return responseMessage; @@ -190,17 +227,22 @@ public class PolicyClient { * Format and send push of policy. * * @param policyType + * The policy Type * @param prop - * @return - * @throws Exception + * The ModelProperties + * @return The response message of policy + * @throws IOException + * In case of issues with the stream + * @throws PolicyEngineException + * In case of issues with the PolicyEngine creation */ - protected String push(String policyType, ModelProperties prop) throws Exception { - // Verify whether it is triggered by Validation Test button from UI - if ( prop.isTest() ) { - return "push not executed for test action"; - } + protected String push(String policyType, ModelProperties prop) throws PolicyEngineException, IOException { + // Verify whether it is triggered by Validation Test button from UI + if (prop.isTest()) { + return "push not executed for test action"; + } - PushPolicyParameters pushPolicyParameters = new PushPolicyParameters(); + PushPolicyParameters pushPolicyParameters = new PushPolicyParameters(); // Parameter arguments if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) { @@ -233,7 +275,7 @@ public class PolicyClient { logger.info("Policy push successful"); } else { logger.warn("Policy push failed: " + responseMessage); - throw new Exception("Policy push failed: " + responseMessage); + throw new BadRequestException("Policy push failed: " + responseMessage); } return responseMessage; @@ -244,11 +286,17 @@ public class PolicyClient { * versions in sorted order. Return empty list if none found. * * @param policyNamePrefix + * The Policy Name Prefix * @param prop - * @return - * @throws Exception + * The ModelProperties + * @return The response message from policy + * @throws IOException + * In case of issues with the stream + * @throws PolicyEngineException + * In case of issues with the PolicyEngine creation */ - protected List getVersions(String policyNamePrefix, ModelProperties prop) throws Exception { + protected List getVersions(String policyNamePrefix, ModelProperties prop) + throws PolicyEngineException, IOException { ArrayList versions = new ArrayList<>(); ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); @@ -266,66 +314,80 @@ public class PolicyClient { PolicyEngine policyEngine = new PolicyEngine( appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); - try { - Collection response = policyEngine.getConfig(configRequestParameters); - Iterator itrResp = response.iterator(); - - while (itrResp.hasNext()) { - PolicyConfig policyConfig = itrResp.next(); - try { - Integer version = new Integer(policyConfig.getPolicyVersion()); - versions.add(version); - } catch (Exception e) { - // just print warning - if n;o policies, version may be null - logger.warn( - "warning: failed to parse policyConfig.getPolicyVersion()=" + policyConfig.getPolicyVersion()); - } - } - Collections.sort(versions); - logger.info("Policy versions.size()=" + versions.size()); - } catch (Exception e) { - // just print warning - if no policy version found - logger.warn("warning: policy not found...policy name - " + policyName); - } + try { + Collection response = policyEngine.getConfig(configRequestParameters); + Iterator itrResp = response.iterator(); + + while (itrResp.hasNext()) { + PolicyConfig policyConfig = itrResp.next(); + try { + Integer version = new Integer(policyConfig.getPolicyVersion()); + versions.add(version); + } catch (Exception e) { + // just print warning - if n;o policies, version may be null + logger.warn("warning: failed to parse policyConfig.getPolicyVersion()=" + + policyConfig.getPolicyVersion()); + } + } + Collections.sort(versions); + logger.info("Policy versions.size()=" + versions.size()); + } catch (Exception e) { + // just print warning - if no policy version found + logger.warn("warning: policy not found...policy name - " + policyName); + } return versions; } /** - * Format and send delete Micro Service requests to Policy + * Format and send delete Micro Service requests to Policy. * * @param prop - * @return - * @throws Exception + * The ModelProperties + * @return The response message from Policy + * @throws IOException + * In case of issues with the stream + * @throws PolicyEngineException + * In case of issues with the PolicyEngine creation */ - public String deleteMicrosService(ModelProperties prop) throws Exception { + public String deleteMicrosService(ModelProperties prop) throws PolicyEngineException, IOException { String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); String policyType = refProp.getStringValue("policy.ms.type"); return deletePolicy(policyNamePrefix, prop, policyType); } /** - * Format and send delete BRMS requests to Policy + * Format and send delete BRMS requests to Policy. * * @param prop - * @return - * @throws Exception + * The ModelProperties + * @return The response message from policy + * @throws IOException + * In case of issues with the stream + * @throws PolicyEngineException + * In case of issues with the PolicyEngine creation */ - public String deleteBrms(ModelProperties prop) throws Exception { + public String deleteBrms(ModelProperties prop) throws PolicyEngineException, IOException { String policyNamePrefix = refProp.getStringValue("policy.op.policyNamePrefix"); String policyType = refProp.getStringValue("policy.op.type"); return deletePolicy(policyNamePrefix, prop, policyType); } /** - * Format and send delete PAP and PDP requests to Policy + * Format and send delete PAP and PDP requests to Policy. * * @param policyNamePrefix + * The String policyNamePrefix * @param prop - * @return - * @throws Exception + * The ModelProperties + * @return The response message from policy + * @throws IOException + * in case of issues with the Stream + * @throws PolicyEngineException + * In case of issues with the PolicyEngine class creation */ - protected String deletePolicy(String policyNamePrefix, ModelProperties prop, String policyType) throws Exception { + protected String deletePolicy(String policyNamePrefix, ModelProperties prop, String policyType) + throws PolicyEngineException, IOException { DeletePolicyParameters deletePolicyParameters = new DeletePolicyParameters(); if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) { @@ -353,19 +415,24 @@ public class PolicyClient { } /** - * Send delete request to Policy + * Send delete request to Policy. * * @param deletePolicyParameters + * The DeletePolicyParameters * @param prop - * @return - * @throws Exception + * The ModelProperties + * @return The response message from policy + * @throws IOException + * In case of issues with the stream + * @throws PolicyEngineException + * In case of issues with PolicyEngine class creation */ protected String sendDeletePolicy(DeletePolicyParameters deletePolicyParameters, ModelProperties prop) - throws Exception { - // Verify whether it is triggered by Validation Test button from UI - if ( prop.isTest() ) { - return "delete not executed for test action"; - } + throws PolicyEngineException, IOException { + // Verify whether it is triggered by Validation Test button from UI + if (prop.isTest()) { + return "delete not executed for test action"; + } PolicyEngine policyEngine = new PolicyEngine( appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); @@ -385,7 +452,7 @@ public class PolicyClient { logger.info("Policy delete successful"); } else { logger.warn("Policy delete failed: " + responseMessage); - throw new Exception("Policy delete failed: " + responseMessage); + throw new BadRequestException("Policy delete failed: " + responseMessage); } return responseMessage; -- cgit 1.2.3-korg From 9bce8befd2f8627867a3c81b3830e584b58b527f Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 29 Aug 2017 04:47:45 -0700 Subject: Reorganize some code and fix checkstyle Two methods have been moved + rework javadocs + rework exception thrown (more specific exceptions) + rework the IT tests + Add a new exception for DCAE Change-Id: I3beb49bcbc5678f24c8be9e0340a936401c6cea9 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/client/SdcSendReqDelegate.java | 60 ++--------------- .../clds/exception/DcaeDeploymentException.java | 61 +++++++++++++++++ .../org/onap/clamp/clds/service/CldsService.java | 76 ++++++++++++---------- .../onap/clamp/clds/service/SecureServiceBase.java | 29 ++++++--- .../org/onap/clamp/clds/it/PolicyClientIT.java | 13 ++-- .../onap/clamp/clds/it/SdcCatalogServicesIT.java | 18 ++--- 6 files changed, 141 insertions(+), 116 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/exception/DcaeDeploymentException.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java index 47a4ddc87..ee233686b 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java @@ -28,9 +28,7 @@ import java.util.List; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.clamp.clds.client.req.SdcReq; -import org.onap.clamp.clds.model.CldsSdcServiceDetail; import org.onap.clamp.clds.model.DcaeEvent; -import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; import org.springframework.beans.factory.annotation.Autowired; @@ -85,62 +83,14 @@ public class SdcSendReqDelegate implements JavaDelegate { if (formattedSdcLocationReq != null) { execution.setVariable("formattedLocationReq", formattedSdcLocationReq.getBytes()); } - String serviceInvariantUUID = getServiceInvariantUUIDFromProps(prop); - uploadToSdc(prop, serviceInvariantUUID, userid, sdcReqUrlsList, formatttedSdcReq, formattedSdcLocationReq, + sdcCatalogServices.uploadToSdc(prop, userid, sdcReqUrlsList, formatttedSdcReq, formattedSdcLocationReq, artifactName, locationArtifactName); } - private String getServiceInvariantUUIDFromProps(ModelProperties props) { - String invariantUUID = ""; - Global globalProps = props.getGlobal(); - if (globalProps != null) { - if (globalProps.getService() != null) { - invariantUUID = globalProps.getService(); - } - } - return invariantUUID; - } - - private void uploadToSdc(ModelProperties prop, String serviceInvariantUUID, String userid, - List sdcReqUrlsList, String formatttedSdcReq, String formattedSdcLocationReq, String artifactName, - String locationArtifactName) throws Exception { - logger.info("userid=" + userid); - if (sdcReqUrlsList != null && sdcReqUrlsList.size() > 0) { - for (String url : sdcReqUrlsList) { - if (url != null) { - String originalServiceUUID = sdcCatalogServices - .getServiceUuidFromServiceInvariantId(serviceInvariantUUID); - logger.info("ServiceUUID used before upload in url:" + originalServiceUUID); - String sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(originalServiceUUID); - CldsSdcServiceDetail CldsSdcServiceDetail = sdcCatalogServices - .getCldsSdcServiceDetailFromJson(sdcServicesInformation); - String uploadedArtifactUUID = sdcCatalogServices - .getArtifactIdIfArtifactAlreadyExists(CldsSdcServiceDetail, artifactName); - // Upload artifacts to sdc - String updateUrl = uploadedArtifactUUID != null ? url + "/" + uploadedArtifactUUID : url; - String responseStr = sdcCatalogServices.uploadArtifactToSdc(prop, userid, updateUrl, - formatttedSdcReq); - logger.info("value of sdc Response of uploading to sdc :" + responseStr); - String updatedServiceUUID = sdcCatalogServices - .getServiceUuidFromServiceInvariantId(serviceInvariantUUID); - if (!originalServiceUUID.equalsIgnoreCase(updatedServiceUUID)) { - url = url.replace(originalServiceUUID, updatedServiceUUID); - } - logger.info("ServiceUUID used after upload in ulr:" + updatedServiceUUID); - sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(updatedServiceUUID); - CldsSdcServiceDetail = sdcCatalogServices.getCldsSdcServiceDetailFromJson(sdcServicesInformation); - uploadedArtifactUUID = sdcCatalogServices.getArtifactIdIfArtifactAlreadyExists(CldsSdcServiceDetail, - locationArtifactName); - // To send location information also to sdc - updateUrl = uploadedArtifactUUID != null ? url + "/" + uploadedArtifactUUID : url; - responseStr = sdcCatalogServices.uploadArtifactToSdc(prop, userid, updateUrl, - formattedSdcLocationReq); - logger.info("value of sdc Response of uploading location to sdc :" + responseStr); - } - } - } - } - + /** + * Method to get sdc service values from properties file. + * @param controlName + */ private void getSdcAttributes(String controlName) { baseUrl = refProp.getStringValue("sdc.serviceUrl"); artifactLabel = SdcReq diff --git a/src/main/java/org/onap/clamp/clds/exception/DcaeDeploymentException.java b/src/main/java/org/onap/clamp/clds/exception/DcaeDeploymentException.java new file mode 100644 index 000000000..6a60ac9d9 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/exception/DcaeDeploymentException.java @@ -0,0 +1,61 @@ +/*- + * ============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.exception; + +/** + * New exception to capture DCAE communication errors. + * + */ +public class DcaeDeploymentException extends RuntimeException { + + /** + * Generated ID + */ + private static final long serialVersionUID = 8452294782552680243L; + + /** + * This constructor can be used to create a new DcaeDeploymentException. + * + * @param message + * A string message detailing the problem + * @param e + * The exception sent by the code + */ + public DcaeDeploymentException(String message, Throwable e) { + super(message, e); + } + + /** + * This constructor can be used to create a new DcaeDeploymentException. Use + * this constructor only if you are creating a new exception stack, not if + * an exception was already raised by another code. + * + * @param message + * A string message detailing the problem + */ + public DcaeDeploymentException(String message) { + super(message); + } + +} 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 509535c5b..c0f711165 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -76,6 +76,8 @@ import org.onap.clamp.clds.util.LoggingUtils; 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.web.client.HttpClientErrorException; import com.att.ajsc.common.AjscService; import com.att.eelf.configuration.EELFLogger; @@ -97,38 +99,38 @@ import io.swagger.annotations.ApiOperation; public class CldsService extends SecureServiceBase { @Autowired - private ApplicationContext appContext; + private ApplicationContext appContext; - private static final String RESOURCE_NAME = "clds-version.properties"; + private static final String RESOURCE_NAME = "clds-version.properties"; - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); @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 String cldsPermissionInstance; - private SecureServicePermission permissionReadCl; + private SecureServicePermission permissionReadCl; - private SecureServicePermission permissionUpdateCl; + private SecureServicePermission permissionUpdateCl; - private SecureServicePermission permissionReadTemplate; + private SecureServicePermission permissionReadTemplate; - private SecureServicePermission permissionUpdateTemplate; + private SecureServicePermission permissionUpdateTemplate; @PostConstruct private final void afterConstruction() { @@ -212,10 +214,10 @@ public class CldsService extends SecureServiceBase { cldsInfo.setCldsVersion(cldsVersion); // Get the user list of permissions - cldsInfo.setPermissionReadCl(isAuthorized(permissionReadCl)); - cldsInfo.setPermissionUpdateCl(isAuthorized(permissionUpdateCl)); - cldsInfo.setPermissionReadTemplate(isAuthorized(permissionReadTemplate)); - cldsInfo.setPermissionUpdateTemplate(isAuthorized(permissionUpdateTemplate)); + cldsInfo.setPermissionReadCl(isAuthorizedNoException(permissionReadCl)); + cldsInfo.setPermissionUpdateCl(isAuthorizedNoException(permissionUpdateCl)); + cldsInfo.setPermissionReadTemplate(isAuthorizedNoException(permissionReadTemplate)); + cldsInfo.setPermissionUpdateTemplate(isAuthorizedNoException(permissionUpdateTemplate)); return cldsInfo; } @@ -447,9 +449,9 @@ public class CldsService extends SecureServiceBase { @Path("/model-names") @Produces(MediaType.APPLICATION_JSON) public List getModelNames() { - // isAuthorized(permissionReadCl); Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: GET model names", getPrincipalName()); + isAuthorized(permissionReadCl); logger.info("GET list of model names"); List names = cldsDao.getBpmnNames(); // audit log @@ -522,10 +524,11 @@ public class CldsService extends SecureServiceBase { String bpmnJson = cldsBpmnTransformer.doXslTransformToString(bpmn); logger.info("PUT bpmnJson={}", bpmnJson); - // Flag indicates whether it is triggered by Validation Test button from UI + // Flag indicates whether it is triggered by Validation Test button from + // UI boolean isTest = false; if (test != null && test.equalsIgnoreCase("true")) { - isTest = true; + isTest = true; } else { // if action.test.override is true, then any action will be marked // as test=true (even if incoming action request had test=false); @@ -612,10 +615,11 @@ public class CldsService extends SecureServiceBase { userid = getUserId(); } - // Flag indicates whether it is triggered by Validation Test button from UI + // Flag indicates whether it is triggered by Validation Test button from + // UI boolean isTest = false; if (test != null && test.equalsIgnoreCase("true")) { - isTest = true; + isTest = true; } int instanceCount = 0; @@ -919,8 +923,8 @@ public class CldsService extends SecureServiceBase { String operationStatus = "processing"; long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10); while (operationStatus.equalsIgnoreCase("processing")) { - //Break the loop if waiting for more than 10 mins - if(waitingTime < System.nanoTime()){ + // Break the loop if waiting for more than 10 mins + if (waitingTime < System.nanoTime()) { break; } operationStatus = dcaeDispatcherServices.getOperationStatus(createNewDeploymentStatusUrl); @@ -938,12 +942,12 @@ public class CldsService extends SecureServiceBase { CldsEvent.ACTION_STATE_RECEIVED, null); model.setDeploymentId(deploymentId); model.save(cldsDao, getUserId()); + } else { + logger.info("Deploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); + throw new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, + "Deploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); } - else{ - logger.info("Deploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); - throw new Exception("Deploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); - } - logger.info("Deploy model (" + modelName + ") succeeded...Deployment Id is - " + deploymentId); + logger.info("Deploy model (" + modelName + ") succeeded...Deployment Id is - " + deploymentId); // audit log LoggingUtils.setTimeContext(startTime, new Date()); LoggingUtils.setResponseContext("0", "Deploy model success", this.getClass().getName()); @@ -964,7 +968,7 @@ public class CldsService extends SecureServiceBase { String operationStatus = "processing"; long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10); while (operationStatus.equalsIgnoreCase("processing")) { - if(waitingTime < System.nanoTime()){ + if (waitingTime < System.nanoTime()) { break; } operationStatus = dcaeDispatcherServices.getOperationStatus(operationStatusUndeployUrl); @@ -982,13 +986,13 @@ public class CldsService extends SecureServiceBase { CldsEvent.ACTION_STATE_RECEIVED, null); model.setDeploymentId(null); model.save(cldsDao, getUserId()); + } else { + logger.info("Undeploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); + throw new HttpClientErrorException(HttpStatus.INTERNAL_SERVER_ERROR, + "Undeploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); } - else{ - logger.info("Undeploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); - throw new Exception("Undeploy model (" + modelName + ") failed...Operation Status is - " + operationStatus); - } - logger.info("Undeploy model (" + modelName + ") succeeded."); - // audit log + logger.info("Undeploy model (" + modelName + ") succeeded."); + // audit log LoggingUtils.setTimeContext(startTime, new Date()); LoggingUtils.setResponseContext("0", "Undeploy model success", this.getClass().getName()); auditLogger.info("Undeploy model completed"); diff --git a/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java index 89e6c092a..19813ebaf 100644 --- a/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java +++ b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java @@ -38,14 +38,14 @@ import com.att.eelf.configuration.EELFManager; * Base/abstract Service class. Implements shared security methods. */ public abstract class SecureServiceBase { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SecureServiceBase.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SecureServiceBase.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); // By default we'll set it to a default handler - private static UserNameHandler userNameHandler = new DefaultUserNameHandler(); + private static UserNameHandler userNameHandler = new DefaultUserNameHandler(); @Context - private SecurityContext securityContext; + private SecurityContext securityContext; /** * Get the userId from AAF/CSP. @@ -91,8 +91,12 @@ public abstract class SecureServiceBase { * app-perm-type|dev|read * * @param inPermission - * @return + * The permission to validate + * @return A boolean to indicate if the user has the permission to do + * execute the inPermission * @throws NotAuthorizedException + * In case of issues with the permission test, error is returned + * in this exception */ public boolean isAuthorized(SecureServicePermission inPermission) throws NotAuthorizedException { boolean authorized = false; @@ -133,11 +137,12 @@ public abstract class SecureServiceBase { * it will be authorized if the inPermission to check is: * app-perm-type|dev|read * - * @param aafPermission - * @return - * @throws NotAuthorizedException + * @param inPermission + * The permission to validate + * @return A boolean to indicate if the user has the permission to do + * execute the inPermission */ - public boolean isAuthorizedNoException(SecureServicePermission inPermission) throws NotAuthorizedException { + public boolean isAuthorizedNoException(SecureServicePermission inPermission) { boolean authorized = false; logger.debug("checking if {} has permission: {}", getPrincipalName(), inPermission); // check if the user has the permission key or the permission key with a @@ -167,6 +172,14 @@ public abstract class SecureServiceBase { return authorized; } + /** + * This method can be used by the Application.class to set the + * UserNameHandler that must be used in this class. The UserNameHandler + * where to get the User name + * + * @param handler + * The Handler impl to use + */ public static final void setUserNameHandler(UserNameHandler handler) { if (handler != null) { userNameHandler = handler; diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java index 543fba705..c0487e915 100644 --- a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java +++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java @@ -23,7 +23,6 @@ package org.onap.clamp.clds.it; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.IOException; @@ -34,25 +33,23 @@ import java.util.concurrent.TimeUnit; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; - import org.onap.clamp.clds.AbstractIT; import org.onap.clamp.clds.client.req.OperationalPolicyReq; import org.onap.clamp.clds.client.req.StringMatchPolicyReq; import org.onap.clamp.clds.client.req.TcaMPolicyReq; import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.*; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.Policy; +import org.onap.clamp.clds.model.prop.PolicyChain; +import org.onap.clamp.clds.model.prop.StringMatch; +import org.onap.clamp.clds.model.prop.Tca; import org.onap.clamp.clds.transform.TransformUtil; - import org.onap.policy.api.AttributeType; - import org.skyscreamer.jsonassert.JSONAssert; - import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.junit4.SpringRunner; - - /** * Test Policy API in org.onap.clamp.ClampDesigner.client package - replicate * Policy Delegates in tests. diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java index 46e45f35c..5d08e5ec0 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java @@ -5,16 +5,16 @@ * 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. + * 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============================================ * =================================================================== @@ -286,7 +286,7 @@ public class SdcCatalogServicesIT extends AbstractIT { assertTrue("29018914-966c-442d-9d08-251b9dc45b8f".equals(cldsServiceData.getServiceUUID())); assertTrue(cldsServiceData.getCldsVfs().size() == 1); - List alarmsList = spy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData); + List alarmsList = spy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData, "alarmCondition"); assertTrue(alarmsList.size() == 6); } -- cgit 1.2.3-korg From ef2025c00c146ecf2b8ddfbef3ec7f49b1726f49 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 05:48:15 -0700 Subject: Fix Sonar bugs In Application.class Blocker issues fixed Change-Id: I8e64a0caee24e23d52779d01cdffade61f7a6f53 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/Application.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index bebb07844..4fc68e1d0 100644 --- a/src/main/java/org/onap/clamp/clds/Application.java +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -23,6 +23,10 @@ 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; @@ -51,10 +55,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableAsync; -import com.att.ajsc.common.utility.SystemPropertiesLoader; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - @SpringBootApplication @ComponentScan(basePackages = { "org.onap.clamp.clds", "com.att.ajsc" }) @EnableAutoConfiguration(exclude = { CamundaBpmWebappAutoConfiguration.class, HibernateJpaAutoConfiguration.class, @@ -63,7 +63,7 @@ import com.att.eelf.configuration.EELFManager; @EnableAsync public class Application extends SpringBootServletInitializer { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Application.class); + protected static final EELFLogger eelfLogger = EELFManager.getInstance().getLogger(Application.class); @Autowired protected ApplicationContext appContext; @@ -94,7 +94,7 @@ public class Application extends SpringBootServletInitializer { public static void main(String[] args) throws Exception { SystemPropertiesLoader.addSystemProperties(); - SpringApplication.run(Application.class, args); + SpringApplication.run(Application.class, args); // NOSONAR } @Bean @@ -136,7 +136,7 @@ public class Application extends SpringBootServletInitializer { private Connector createRedirectConnector(int redirectSecuredPort) { if (redirectSecuredPort <= 0) { - logger.warn( + eelfLogger.warn( "HTTP port redirection to HTTPS is disabled because the HTTPS port is 0 (random port) or -1 (Connector disabled)"); return null; } -- cgit 1.2.3-korg From f13efdabda4ff77eedccf5595616c9423710f405 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 05:48:57 -0700 Subject: Fix Sonar bugs In OperationalPolicyReq.class Blocker issues fixed Change-Id: If35ab7674961c6d9c7558b1f81d7fd5fb22eae45 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../clds/client/req/OperationalPolicyReq.java | 39 ++++++++-------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java index 950fcefe5..e7f956d33 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -23,6 +23,12 @@ package org.onap.clamp.clds.client.req; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFLogger.Level; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; @@ -31,7 +37,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.jboss.resteasy.spi.BadRequestException; +import javax.ws.rs.BadRequestException; + import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.prop.PolicyChain; @@ -52,12 +59,6 @@ import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; import org.onap.policy.controlloop.policy.builder.Message; import org.onap.policy.controlloop.policy.builder.Results; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFLogger.Level; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - /** * Construct an Operational Policy request given CLDS objects. */ @@ -426,16 +427,10 @@ public class OperationalPolicyReq { * @return */ private static Resource[] convertToResource(List stringList, ResourceType resourceType) { - int size = 0; - if (stringList != null) { - size = stringList.size(); - } - Resource[] resourceArray = new Resource[size]; - for (int i = 0; i < size; i++) { - String rString = stringList.get(i); - resourceArray[i] = new Resource(rString, resourceType); + if (stringList == null || stringList.isEmpty()) { + return new Resource[0]; } - return resourceArray; + return stringList.stream().map(stringElem -> new Resource(stringElem, resourceType)).toArray(Resource[]::new); } /** @@ -446,16 +441,10 @@ public class OperationalPolicyReq { * @return */ private static PolicyResult[] convertToPolicyResult(List prList) { - int size = 0; - if (prList != null) { - size = prList.size(); - } - PolicyResult[] prArray = new PolicyResult[size]; - for (int i = 0; i < size; i++) { - String prString = prList.get(i); - prArray[i] = PolicyResult.toResult(prString); + if (prList == null || prList.isEmpty()) { + return new PolicyResult[0]; } - return prArray; + return prList.stream().map(stringElem -> PolicyResult.toResult(stringElem)).toArray(PolicyResult[]::new); } } \ No newline at end of file -- cgit 1.2.3-korg From 13966ab288578be392c5d2c64d5a9d7b6f600327 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 05:49:27 -0700 Subject: Fix Sonar bugs In client java packages Blocker issues fixed Change-Id: I7ea1fb546ad32422da7eef596a989e4696238651 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/client/DcaeDispatcherServices.java | 20 ++++---- .../org/onap/clamp/clds/client/PolicyClient.java | 36 +++++++-------- .../onap/clamp/clds/client/SdcCatalogServices.java | 53 ++++++++++++---------- 3 files changed, 53 insertions(+), 56 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java index 3d8d5d53a..718a2e997 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java @@ -96,18 +96,16 @@ public class DcaeDispatcherServices { if (inStream != null) { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inStream)); String inputLine = null; - StringBuffer response = new StringBuffer(); + StringBuilder response = new StringBuilder(); while ((inputLine = bufferedReader.readLine()) != null) { response.append(inputLine); } responseStr = response.toString(); } - if (responseStr != null) { - if (requestFailed) { - logger.error("requestFailed - responseStr=" + responseStr); - throw new BadRequestException(responseStr); - } + if (responseStr != null && requestFailed) { + logger.error("requestFailed - responseStr=" + responseStr); + throw new BadRequestException(responseStr); } logger.debug("response code " + responseCode); @@ -270,7 +268,7 @@ public class DcaeDispatcherServices { String inputLine = null; - StringBuffer response = new StringBuffer(); + StringBuilder response = new StringBuilder(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); @@ -279,11 +277,9 @@ public class DcaeDispatcherServices { responseStr = response.toString(); } - if (responseStr != null) { - if (requestFailed) { - logger.error("requestFailed - responseStr=" + responseStr); - throw new BadRequestException(responseStr); - } + if (responseStr != null && requestFailed) { + logger.error("requestFailed - responseStr=" + responseStr); + throw new BadRequestException(responseStr); } logger.debug("response code " + responseCode); diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java index e16f056ce..6095af155 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java @@ -61,8 +61,11 @@ import org.springframework.context.ApplicationContext; * Policy utility methods - specifically, send the policy. */ public class PolicyClient { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + protected static final String LOG_POLICY_PREFIX = "Response is "; + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}") protected String cldsPolicyConfigFile; @@ -73,10 +76,6 @@ public class PolicyClient { @Autowired protected RefProp refProp; - public PolicyClient() { - - } - /** * Perform send of microservice policy. * @@ -189,11 +188,11 @@ public class PolicyClient { // API method to create or update Policy. PolicyChangeResponse response = null; - String responseMessage; + String responseMessage = ""; Date startTime = new Date(); try { List versions = getVersions(policyNamePrefix, prop); - if (versions.size() <= 0) { + if (versions.isEmpty()) { LoggingUtils.setTargetContext("Policy", "createPolicy"); logger.info("Attempting to create policy for action=" + prop.getActionCd()); response = policyEngine.createPolicy(policyParameters); @@ -205,9 +204,9 @@ public class PolicyClient { responseMessage = response.getResponseMessage(); } } catch (Exception e) { - responseMessage = e.toString(); + logger.error("Exception occurred during policy communnication", e); } - logger.info("response is " + responseMessage); + logger.info(LOG_POLICY_PREFIX + responseMessage); LoggingUtils.setTimeContext(startTime, new Date()); @@ -261,15 +260,15 @@ public class PolicyClient { // API method to create or update Policy. PolicyChangeResponse response = null; - String responseMessage; + String responseMessage = ""; try { logger.info("Attempting to push policy..."); response = policyEngine.pushPolicy(pushPolicyParameters); responseMessage = response.getResponseMessage(); } catch (Exception e) { - responseMessage = e.toString(); + logger.error("Exception occurred during policy communnication", e); } - logger.info("response is " + responseMessage); + logger.info(LOG_POLICY_PREFIX + responseMessage); if (response != null && (response.getResponseCode() == 200 || response.getResponseCode() == 204)) { logger.info("Policy push successful"); @@ -333,7 +332,7 @@ public class PolicyClient { logger.info("Policy versions.size()=" + versions.size()); } catch (Exception e) { // just print warning - if no policy version found - logger.warn("warning: policy not found...policy name - " + policyName); + logger.warn("warning: policy not found...policy name - " + policyName, e); } return versions; @@ -401,8 +400,7 @@ public class PolicyClient { deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group")); deletePolicyParameters.setPolicyType(policyType); // send delete request - String responseMessage = null; - responseMessage = sendDeletePolicy(deletePolicyParameters, prop); + String responseMessage = sendDeletePolicy(deletePolicyParameters, prop); logger.info("Deleting policy from PAP..."); deletePolicyParameters.setPolicyComponent("PAP"); @@ -438,15 +436,15 @@ public class PolicyClient { // API method to create or update Policy. PolicyChangeResponse response = null; - String responseMessage; + String responseMessage = ""; try { logger.info("Attempting to delete policy..."); response = policyEngine.deletePolicy(deletePolicyParameters); responseMessage = response.getResponseMessage(); } catch (Exception e) { - responseMessage = e.toString(); + logger.error("Exception occurred during policy communnication", e); } - logger.info("response is " + responseMessage); + logger.info(LOG_POLICY_PREFIX + responseMessage); if (response != null && response.getResponseCode() == 200) { logger.info("Policy delete successful"); diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java index a4e332a39..24a3d3c41 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -423,14 +423,14 @@ public class SdcCatalogServices { // To remove duplicate resources from serviceDetail and add valid // vfs to service - if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null) { + if (cldsSdcServiceDetail.getResources() != null) { List cldsSdcResourceList = removeDuplicateSdcResourceInstances( cldsSdcServiceDetail.getResources()); - if (cldsSdcResourceList != null && cldsSdcResourceList.size() > 0) { + if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) { List cldsVfDataList = new ArrayList<>(); for (CldsSdcResource currCldsSdcResource : cldsSdcResourceList) { if (currCldsSdcResource != null && currCldsSdcResource.getResoucreType() != null - && currCldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { + && "VF".equalsIgnoreCase(currCldsSdcResource.getResoucreType())) { CldsVfData currCldsVfData = new CldsVfData(); currCldsVfData.setVfName(currCldsSdcResource.getResourceInstanceName()); currCldsVfData.setVfInvariantResourceUUID(currCldsSdcResource.getResourceInvariantUUID()); @@ -454,7 +454,7 @@ public class SdcCatalogServices { */ private void getAllVfcForVfList(List cldsVfDataList, String catalogUrl) throws IOException { // todo : refact this.. - if (cldsVfDataList != null && cldsVfDataList.size() > 0) { + if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) { List allVfResources = getAllSdcVForVfcResourcesBasedOnResourceType( RESOURCE_VF_TYPE); List allVfcResources = getAllSdcVForVfcResourcesBasedOnResourceType( @@ -475,7 +475,7 @@ public class SdcCatalogServices { List vfcDataListFromVfResponse = getVfcDataListFromVfResponse(vfResponse); if (vfcDataListFromVfResponse != null) { currCldsVfData.setCldsVfcs(vfcDataListFromVfResponse); - if (vfcDataListFromVfResponse.size() > 0) { + if (!vfcDataListFromVfResponse.isEmpty()) { // To get artifacts for every VFC and get // alarm conditions from artifact for (CldsVfcData currCldsVfcData : vfcDataListFromVfResponse) { @@ -537,7 +537,7 @@ public class SdcCatalogServices { private List getVFCfromCVFC(String resourceUUID) { String catalogUrl = refProp.getStringValue("sdc.catalog.url"); - List cldsVfcDataList = new ArrayList(); + List cldsVfcDataList = new ArrayList<>(); if (resourceUUID != null) { String vfcResourceUUIDUrl = catalogUrl + "resources" + "/" + resourceUUID + "/metadata"; @@ -569,10 +569,11 @@ public class SdcCatalogServices { } private String removeUnwantedBracesFromString(String id) { + String idReworked = ""; if (id != null && id.contains("\"")) { - id = id.replaceAll("\"", ""); + idReworked = id.replaceAll("\"", ""); } - return id; + return idReworked; } private List getAlarmCondtionsFromVfc(String vfcResponse) throws IOException { @@ -611,7 +612,7 @@ public class SdcCatalogServices { // Method to get the artifact for any particular VF private List getFieldPathFromVF(String vfResponse) throws JsonProcessingException, IOException { - List cldsVfKPIDataList = new ArrayList(); + List cldsVfKPIDataList = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); ArrayNode artifactsArrayNode = (ArrayNode) vfResponseNode.get("artifacts"); @@ -664,7 +665,7 @@ public class SdcCatalogServices { // Method to get the artifactURL Data and set the CldsVfKPIData node private List parseCsvToGetFieldPath(String allFieldPathValues) throws IOException { - List cldsVfKPIDataList = new ArrayList(); + List cldsVfKPIDataList = new ArrayList<>(); Reader alarmReader = new StringReader(allFieldPathValues); Iterable records = CSVFormat.RFC4180.parse(alarmReader); if (records != null) { @@ -701,8 +702,8 @@ public class SdcCatalogServices { public String getResponsesFromArtifactUrl(String artifactsUrl) { String hostUrl = refProp.getStringValue("sdc.hostUrl"); - artifactsUrl = artifactsUrl.replaceAll("\"", ""); - String artifactUrl = hostUrl + artifactsUrl; + String artifactsUrlReworked = artifactsUrl.replaceAll("\"", ""); + String artifactUrl = hostUrl + artifactsUrlReworked; logger.info("value of artifactURl:" + artifactUrl); String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl, true); logger.info("value of artifactResponse:" + currArtifactResponse); @@ -720,8 +721,8 @@ public class SdcCatalogServices { */ public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions) { try { - url = removeUnwantedBracesFromString(url); - URL urlObj = new URL(url); + String urlReworked = removeUnwantedBracesFromString(url); + URL urlObj = new URL(urlReworked); HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); String basicAuth = SdcReq.getSdcBasicAuth(refProp); @@ -738,7 +739,9 @@ public class SdcCatalogServices { response = new StringBuilder(); String inputLine; while ((inputLine = in.readLine()) != null) { - response.append(inputLine); + if (!inputLine.isEmpty()) { + response.append(inputLine); + } if (alarmConditions) { response.append("\n"); } @@ -780,7 +783,7 @@ public class SdcCatalogServices { // To create byKpi ObjectNode kpiObjectNode = mapper.createObjectNode(); - if (cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { + if (cldsServiceData.getCldsVfs() != null && !cldsServiceData.getCldsVfs().isEmpty()) { for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { if (currCldsVfData != null) { createKpiObjectNodeByVfUuid(mapper, kpiObjectNode, currCldsVfData.getCldsKPIList()); @@ -791,7 +794,7 @@ public class SdcCatalogServices { // To create byVfc and alarmCondition with vfcResourceUUID ObjectNode vfcResourceUuidObjectNode = mapper.createObjectNode(); - if (cldsServiceData.getCldsVfs() != null && cldsServiceData.getCldsVfs().size() > 0) { + if (cldsServiceData.getCldsVfs() != null && !cldsServiceData.getCldsVfs().isEmpty()) { for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) { if (currCldsVfData != null) { createAlarmCondObjectNodeByVfcUuid(mapper, vfcResourceUuidObjectNode, @@ -902,7 +905,7 @@ public class SdcCatalogServices { List cldsAlarmCondList) { ObjectNode alarmCondKeyNode = mapper.createObjectNode(); - if (cldsAlarmCondList != null && cldsAlarmCondList.size() > 0) { + if (cldsAlarmCondList != null && !cldsAlarmCondList.isEmpty()) { for (CldsAlarmCondition currCldsAlarmCondition : cldsAlarmCondList) { if (currCldsAlarmCondition != null) { ObjectNode alarmCondNode = mapper.createObjectNode(); @@ -925,7 +928,7 @@ public class SdcCatalogServices { ObjectNode vfObjectNode = mapper.createObjectNode(); ObjectNode vfUuidNode = mapper.createObjectNode(); List cldsVfsList = cldsServiceData.getCldsVfs(); - if (cldsVfsList != null && cldsVfsList.size() > 0) { + if (cldsVfsList != null && !cldsVfsList.isEmpty()) { for (CldsVfData currCldsVfData : cldsVfsList) { if (currCldsVfData != null) { vfUuidNode.put(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName()); @@ -941,7 +944,7 @@ public class SdcCatalogServices { private void createKpiObjectNodeByVfUuid(ObjectMapper mapper, ObjectNode vfResourceUuidObjectNode, List cldsVfKpiDataList) { - if (cldsVfKpiDataList != null && cldsVfKpiDataList.size() > 0) { + if (cldsVfKpiDataList != null && !cldsVfKpiDataList.isEmpty()) { for (CldsVfKPIData currCldsVfKpiData : cldsVfKpiDataList) { if (currCldsVfKpiData != null) { ObjectNode thresholdNameObjectNode = mapper.createObjectNode(); @@ -967,11 +970,11 @@ public class SdcCatalogServices { ObjectNode vfcObjectNode = mapper.createObjectNode(); ObjectNode alarmCondNode = mapper.createObjectNode(); ObjectNode alertDescNode = mapper.createObjectNode(); - if (cldsVfcDataList != null && cldsVfcDataList.size() > 0) { + if (cldsVfcDataList != null && !cldsVfcDataList.isEmpty()) { for (CldsVfcData currCldsVfcData : cldsVfcDataList) { if (currCldsVfcData != null) { if (currCldsVfcData.getCldsAlarmConditions() != null - && currCldsVfcData.getCldsAlarmConditions().size() > 0) { + && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) { for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) { alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(), currCldsAlarmCondition.getAlarmConditionKey()); @@ -1001,12 +1004,12 @@ public class SdcCatalogServices { private ObjectNode createVfcObjectNodeByVfUuid(ObjectMapper mapper, List cldsVfDataList) { ObjectNode vfUuidObjectNode = mapper.createObjectNode(); - if (cldsVfDataList != null && cldsVfDataList.size() > 0) { + if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) { for (CldsVfData currCldsVfData : cldsVfDataList) { if (currCldsVfData != null) { ObjectNode vfcObjectNode = mapper.createObjectNode(); ObjectNode vfcUuidNode = mapper.createObjectNode(); - if (currCldsVfData.getCldsVfcs() != null && currCldsVfData.getCldsVfcs().size() > 0) { + if (currCldsVfData.getCldsVfcs() != null && !currCldsVfData.getCldsVfcs().isEmpty()) { for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(), currCldsVfcData.getVfcName()); @@ -1126,7 +1129,7 @@ public class SdcCatalogServices { private String getResourceUuidFromResourceInvariantUuid(String resourceInvariantUuid, List resourceInfoList) throws IOException { String resourceUuid = null; - if (resourceInfoList != null && resourceInfoList.size() > 0) { + if (resourceInfoList != null && !resourceInfoList.isEmpty()) { for (CldsSdcResourceBasicInfo currResource : resourceInfoList) { if (currResource != null && currResource.getInvariantUUID() != null && currResource.getUuid() != null && currResource.getInvariantUUID().equalsIgnoreCase(resourceInvariantUuid)) { -- cgit 1.2.3-korg From f617d5ac8ec26e59fd0d66abc0081ff0a5e7cb14 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 05:53:07 -0700 Subject: Fix Sonar bugs In CldsSecurityConfigUsers.class Blocker issues fixed Change-Id: I3eb90ff986786ab76c767158e5aae3f1bbe0bdeb Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/config/CldsSecurityConfigUsers.java | 48 +++++++++++------ .../clamp/clds/exception/CldsUsersException.java | 61 ++++++++++++++++++++++ 2 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/exception/CldsUsersException.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java index a187ac556..09078f07d 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java @@ -23,6 +23,12 @@ package org.onap.clamp.clds.config; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.io.IOException; + +import org.onap.clamp.clds.exception.CldsUsersException; import org.onap.clamp.clds.service.CldsUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -34,9 +40,6 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - /** * This class is used to enable the HTTP authentication to login. It requires a * specific JSON file containing the user definition @@ -68,9 +71,14 @@ public class CldsSecurityConfigUsers extends WebSecurityConfigurerAdapter { * This method configures on which URL the authorization will be enabled. */ @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable().httpBasic().and().authorizeRequests().antMatchers("/restservices/clds/v1/user/**") - .authenticated().anyRequest().permitAll().and().logout(); + protected void configure(HttpSecurity http) { + try { + http.csrf().disable().httpBasic().and().authorizeRequests().antMatchers("/restservices/clds/v1/user/**") + .authenticated().anyRequest().permitAll().and().logout(); + } catch (Exception e) { + logger.error("Exception occurred during the setup of the Web users in memory", e); + throw new CldsUsersException("Exception occurred during the setup of the Web users in memory", e); + } } /** @@ -82,18 +90,23 @@ public class CldsSecurityConfigUsers extends WebSecurityConfigurerAdapter { * @throws Exception */ @Autowired - public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - CldsUser[] usersList = loadUsers(); + public void configureGlobal(AuthenticationManagerBuilder auth) { + try { + CldsUser[] usersList = loadUsers(); - // no users defined - if (null == usersList) { - logger.warn("No users defined. Users should be defined under " + cldsUsersFile); - return; - } + // no users defined + if (null == usersList) { + logger.warn("No users defined. Users should be defined under " + cldsUsersFile); + return; + } - for (CldsUser user : usersList) { - auth.inMemoryAuthentication().withUser(user.getUser()).password(user.getPassword()) - .roles(user.getPermissionsString()); + for (CldsUser user : usersList) { + auth.inMemoryAuthentication().withUser(user.getUser()).password(user.getPassword()) + .roles(user.getPermissionsString()); + } + } catch (Exception e) { + logger.error("Exception occurred during the setup of the Web users in memory", e); + throw new CldsUsersException("Exception occurred during the setup of the Web users in memory", e); } } @@ -102,9 +115,10 @@ public class CldsSecurityConfigUsers extends WebSecurityConfigurerAdapter { * CldsUser. * * @return The array of CldsUser + * @throws IOException * @throws Exception */ - private CldsUser[] loadUsers() throws Exception { + private CldsUser[] loadUsers() throws IOException { logger.info("Load from clds-users.properties"); return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream()); } diff --git a/src/main/java/org/onap/clamp/clds/exception/CldsUsersException.java b/src/main/java/org/onap/clamp/clds/exception/CldsUsersException.java new file mode 100644 index 000000000..27945bf18 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/exception/CldsUsersException.java @@ -0,0 +1,61 @@ +/*- + * ============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.exception; + +/** + * New exception to CldsUser errors. + * + */ +public class CldsUsersException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 933535057227505342L; + + /** + * This constructor can be used to create a new CldsUsersException. + * + * @param message + * A string message detailing the problem + * @param e + * The exception sent by the code + */ + public CldsUsersException(String message, Throwable e) { + super(message, e); + } + + /** + * This constructor can be used to create a new CldsUsersException. Use this + * constructor only if you are creating a new exception stack, not if an + * exception was already raised by another code. + * + * @param message + * A string message detailing the problem + */ + public CldsUsersException(String message) { + super(message); + } + +} -- cgit 1.2.3-korg From dba8d74ffafc51cdd496099d5ad0f391a234e402 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 05:54:45 -0700 Subject: Fix bad exception used Jboss exception used instead of javaws one Change-Id: If14eba2b529671b862bbdf8edb269eaae7dad77a Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/model/DcaeEvent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java index e144a0eb7..a9facc268 100644 --- a/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java +++ b/src/main/java/org/onap/clamp/clds/model/DcaeEvent.java @@ -25,7 +25,7 @@ package org.onap.clamp.clds.model; import java.util.List; -import org.jboss.resteasy.spi.BadRequestException; +import javax.ws.rs.BadRequestException; /** * Represent a DCAE Event. -- cgit 1.2.3-korg From 0b34dfecd6ee4e7f887fa47d2181edf097de788d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 05:56:17 -0700 Subject: Fix Sonar bugs In ModelElement.class Blocker issues fixed Change-Id: Ia03757ed3675d6af8a65b9ed862db25e703387d6 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/model/prop/ModelElement.java | 133 +++++++++++---------- 1 file changed, 67 insertions(+), 66 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java index 42333559e..42d11f4b5 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java @@ -23,32 +23,32 @@ package org.onap.clamp.clds.model.prop; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Provide base ModelElement functionality. */ public abstract class ModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelElement.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelElement.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - public static final String TYPE_POLICY = "policy"; - public static final String TYPE_TCA = "tca"; + public static final String TYPE_POLICY = "policy"; + public static final String TYPE_TCA = "tca"; - private final String type; - private final ModelBpmn modelBpmn; - private final String id; - protected String topicPublishes; - protected final JsonNode meNode; - private boolean isFound; + private final String type; + private final ModelBpmn modelBpmn; + private final String id; + protected String topicPublishes; + protected final JsonNode meNode; + private boolean isFound; - private final ModelProperties modelProp; + private final ModelProperties modelProp; /** * Perform base parsing of properties for a ModelElement (such as, @@ -122,57 +122,58 @@ public abstract class ModelElement { } return value; } - - /** - * Return the value field of the json node element that has a name field that equals the given name. - * - * @param nodeIn - * @param name - * @return - */ - public static String getNodeValueByName(JsonNode nodeIn, String name) { - String value = null; - if ( nodeIn != null ) { - value = nodeIn.path(name).asText(); - } - if ( value == null || value.length() == 0 ) { - logger.warn(name + "=" + value); - } else { - logger.debug(name + "=" + value); - } - return value; - } - - - /** - * Return the value field of the json node element that has a name field that equals the given name. - * - * @param nodeIn - * @param name - * @return - */ - public static List getNodeValuesByName(JsonNode nodeIn, String name) { - List values = new ArrayList(); - if ( nodeIn != null ) { - Iterator i = nodeIn.iterator(); - while (i.hasNext()) { - JsonNode node = i.next(); - if ( node.path("name").asText().equals(name) ) { - String value = ""; - JsonNode vnode = node.path("value"); - if ( vnode.isArray() ) { - // if array, assume value is in first element - value = vnode.path(0).asText(); - } else { - // otherwise, just return text - value = vnode.asText(); - } - values.add(value); - } - } - } - return values; - } + + /** + * Return the value field of the json node element that has a name field + * that equals the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static String getNodeValueByName(JsonNode nodeIn, String name) { + String value = null; + if (nodeIn != null) { + value = nodeIn.path(name).asText(); + } + if (value == null || value.length() == 0) { + logger.warn(name + "=" + value); + } else { + logger.debug(name + "=" + value); + } + return value; + } + + /** + * Return the value field of the json node element that has a name field + * that equals the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static List getNodeValuesByName(JsonNode nodeIn, String name) { + List values = new ArrayList<>(); + if (nodeIn != null) { + Iterator i = nodeIn.iterator(); + while (i.hasNext()) { + JsonNode node = i.next(); + if (node.path("name").asText().equals(name)) { + String value; + JsonNode vnode = node.path("value"); + if (vnode.isArray()) { + // if array, assume value is in first element + value = vnode.path(0).asText(); + } else { + // otherwise, just return text + value = vnode.asText(); + } + values.add(value); + } + } + } + return values; + } /** * Return the int value field of the json node element that has a name field @@ -206,7 +207,7 @@ public abstract class ModelElement { } } } - if (values == null || values.size() == 0) { + if (values == null || values.isEmpty()) { logger.warn(name + "=" + values); } else { logger.debug(name + "=" + values); -- cgit 1.2.3-korg From 5038c6dec6c51bdf7a5e4ff1d94ab5314c0eb3a3 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 05:57:52 -0700 Subject: Add a new test class Add a new test class for SdcPolicyReq class Change-Id: I8c3031a621a5fe1a2f6bc0d44988baae89a35545 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../java/org/onap/clamp/clds/model/CldsModel.java | 125 ++++++++++----------- .../clamp/clds/client/req/SdcPolicyReqTest.java | 82 ++++++++++++++ 2 files changed, 143 insertions(+), 64 deletions(-) create mode 100644 src/test/java/org/onap/clamp/clds/client/req/SdcPolicyReqTest.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java index 59db9b580..a830f9380 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java @@ -23,18 +23,18 @@ package org.onap.clamp.clds.model; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import javax.ws.rs.BadRequestException; import javax.ws.rs.NotFoundException; -import org.jboss.resteasy.spi.BadRequestException; import org.onap.clamp.clds.dao.CldsDao; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - /** * Represent a CLDS Model. */ @@ -42,52 +42,52 @@ public class CldsModel { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsModel.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private static final int UUID_LENGTH = 36; - - public static final String STATUS_DESIGN = "DESIGN"; - public static final String STATUS_DISTRIBUTED = "DISTRIBUTED"; - public static final String STATUS_ACTIVE = "ACTIVE"; - public static final String STATUS_STOPPED = "STOPPED"; - public static final String STATUS_DELETING = "DELETING"; - public static final String STATUS_ERROR = "ERROR"; // manual - // intervention - // required - public static final String STATUS_UNKNOWN = "UNKNOWN"; - - private String id; - private String templateId; - private String templateName; - private String name; - private String controlNamePrefix; - private String controlNameUuid; - private String bpmnId; - private String bpmnUserid; - private String bpmnText; - private String propId; - private String propUserid; - private String propText; - private String imageId; - private String imageUserid; - private String imageText; - private String docId; - private String docUserid; - private String docText; - private String blueprintId; - private String blueprintUserid; - private String blueprintText; - private CldsEvent event; - private String status; - private List permittedActionCd; - private List cldsModelInstanceList; - - private String typeId; - private String typeName; - - private String dispatcherResponse; - - private String deploymentId; - - private boolean userAuthorizedToUpdate; + private static final int UUID_LENGTH = 36; + + public static final String STATUS_DESIGN = "DESIGN"; + public static final String STATUS_DISTRIBUTED = "DISTRIBUTED"; + public static final String STATUS_ACTIVE = "ACTIVE"; + public static final String STATUS_STOPPED = "STOPPED"; + public static final String STATUS_DELETING = "DELETING"; + public static final String STATUS_ERROR = "ERROR"; // manual + // intervention + // required + public static final String STATUS_UNKNOWN = "UNKNOWN"; + + private String id; + private String templateId; + private String templateName; + private String name; + private String controlNamePrefix; + private String controlNameUuid; + private String bpmnId; + private String bpmnUserid; + private String bpmnText; + private String propId; + private String propUserid; + private String propText; + private String imageId; + private String imageUserid; + private String imageText; + private String docId; + private String docUserid; + private String docText; + private String blueprintId; + private String blueprintUserid; + private String blueprintText; + private CldsEvent event; + private String status; + private List permittedActionCd; + private List cldsModelInstanceList; + + private String typeId; + private String typeName; + + private String dispatcherResponse; + + private String deploymentId; + + private boolean userAuthorizedToUpdate; /** * Construct empty model. @@ -243,15 +243,18 @@ public class CldsModel { permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT); break; case CldsEvent.ACTION_UNDEPLOY: - permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY, + CldsEvent.ACTION_RESUBMIT); break; case CldsEvent.ACTION_DEPLOY: - permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UNDEPLOY, + CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP); break; case CldsEvent.ACTION_RESTART: case CldsEvent.ACTION_UPDATE: // for 1702 delete is not currently implemented - permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP, CldsEvent.ACTION_UNDEPLOY); + permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UPDATE, + CldsEvent.ACTION_STOP, CldsEvent.ACTION_UNDEPLOY); break; case CldsEvent.ACTION_DELETE: if (getCurrentActionStateCd().equals(CldsEvent.ACTION_STATE_SENT)) { @@ -296,19 +299,13 @@ public class CldsModel { * @return */ public static CldsModel createUsingControlName(String fullControlName) { - - int len = 0; - - if (fullControlName != null) { - len = fullControlName.length(); - } - if (len < UUID_LENGTH) { - throw new BadRequestException( - "closed loop id / control name length, " + len + ", less than the minimum of: " + UUID_LENGTH); + if (fullControlName == null || fullControlName.length() < UUID_LENGTH) { + throw new BadRequestException("closed loop id / control name length, " + fullControlName.length() + + ", less than the minimum of: " + UUID_LENGTH); } CldsModel model = new CldsModel(); - model.setControlNamePrefix(fullControlName.substring(0, len - UUID_LENGTH)); - model.setControlNameUuid(fullControlName.substring(len - UUID_LENGTH)); + model.setControlNamePrefix(fullControlName.substring(0, fullControlName.length() - UUID_LENGTH)); + model.setControlNameUuid(fullControlName.substring(fullControlName.length() - UUID_LENGTH)); return model; } diff --git a/src/test/java/org/onap/clamp/clds/client/req/SdcPolicyReqTest.java b/src/test/java/org/onap/clamp/clds/client/req/SdcPolicyReqTest.java new file mode 100644 index 000000000..c2d9ae466 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/client/req/SdcPolicyReqTest.java @@ -0,0 +1,82 @@ +/*- + * ============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.client.req; + +import static org.junit.Assert.assertTrue; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.onap.policy.asdc.Resource; +import org.onap.policy.asdc.ResourceType; +import org.onap.policy.controlloop.policy.PolicyResult; + +public class SdcPolicyReqTest { + + @Test + public void convertToResourceTest() throws NoSuchMethodException, SecurityException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException { + Method method = OperationalPolicyReq.class.getDeclaredMethod("convertToResource", List.class, + ResourceType.class); + method.setAccessible(true); + // return method.invoke(targetObject, argObjects); + OperationalPolicyReq policyReq = new OperationalPolicyReq(); + List stringList = new ArrayList<>(); + stringList.add("test1"); + stringList.add("test2"); + stringList.add("test3"); + stringList.add("test4"); + Resource resources[] = (Resource[]) method.invoke(policyReq, stringList, ResourceType.VF); + + assertTrue(resources.length == 4); + assertTrue("test1".equals(resources[0].getResourceName())); + assertTrue("test2".equals(resources[1].getResourceName())); + assertTrue("test3".equals(resources[2].getResourceName())); + assertTrue("test4".equals(resources[3].getResourceName())); + } + + @Test + public void convertToPolicyResultTest() throws NoSuchMethodException, SecurityException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException { + Method method = OperationalPolicyReq.class.getDeclaredMethod("convertToPolicyResult", List.class); + method.setAccessible(true); + // return method.invoke(targetObject, argObjects); + OperationalPolicyReq policyReq = new OperationalPolicyReq(); + List stringList = new ArrayList<>(); + stringList.add("FAILURE"); + stringList.add("SUCCESS"); + stringList.add("FAILURE_GUARD"); + stringList.add("FAILURE_TIMEOUT"); + PolicyResult policyResult[] = (PolicyResult[]) method.invoke(policyReq, stringList); + + assertTrue(policyResult.length == 4); + assertTrue(policyResult[0].equals(PolicyResult.FAILURE)); + assertTrue(policyResult[1].equals(PolicyResult.SUCCESS)); + assertTrue(policyResult[2].equals(PolicyResult.FAILURE_GUARD)); + assertTrue(policyResult[3].equals(PolicyResult.FAILURE_TIMEOUT)); + } +} -- cgit 1.2.3-korg From ac3c28f302fbad8af915e05a2c4d9157a15149ba Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 05:58:36 -0700 Subject: Fix Sonar bugs In service java package Blocker issues fixed Change-Id: I5c6ff6374c40d8e24c4fa920ca2af139761b9e4a Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../org/onap/clamp/clds/service/CldsService.java | 24 ++++++++++------------ .../onap/clamp/clds/service/LogServiceImpl.java | 21 +++++++++---------- 2 files changed, 21 insertions(+), 24 deletions(-) (limited to 'src/main/java') 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 c0f711165..3d6d54a11 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -23,6 +23,14 @@ 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.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + import java.io.IOException; import java.io.InputStream; import java.sql.SQLException; @@ -52,7 +60,6 @@ import javax.xml.transform.TransformerException; import org.apache.commons.lang3.StringUtils; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.jboss.resteasy.spi.BadRequestException; import org.onap.clamp.clds.client.DcaeDispatcherServices; import org.onap.clamp.clds.client.DcaeInventoryServices; import org.onap.clamp.clds.client.SdcCatalogServices; @@ -79,14 +86,6 @@ import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.web.client.HttpClientErrorException; -import com.att.ajsc.common.AjscService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -595,14 +594,13 @@ public class CldsService extends SecureServiceBase { * * @param test * @param dcaeEvent - * @throws BadRequestException */ @ApiOperation(value = "Accepts events for a model", notes = "", response = String.class) @POST @Path("/dcae/event") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public String postDcaeEvent(@QueryParam("test") String test, DcaeEvent dcaeEvent) throws BadRequestException { + public String postDcaeEvent(@QueryParam("test") String test, DcaeEvent dcaeEvent) { Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: Post dcae event", getPrincipalName()); String userid = null; @@ -929,7 +927,7 @@ public class CldsService extends SecureServiceBase { } operationStatus = dcaeDispatcherServices.getOperationStatus(createNewDeploymentStatusUrl); } - if (operationStatus != null && operationStatus.equalsIgnoreCase("succeeded")) { + if (operationStatus.equalsIgnoreCase("succeeded")) { String artifactName = model.getControlName(); if (artifactName != null) { artifactName = artifactName + ".yml"; @@ -973,7 +971,7 @@ public class CldsService extends SecureServiceBase { } operationStatus = dcaeDispatcherServices.getOperationStatus(operationStatusUndeployUrl); } - if (operationStatus != null && operationStatus.equalsIgnoreCase("succeeded")) { + if (operationStatus.equalsIgnoreCase("succeeded")) { String artifactName = model.getControlName(); if (artifactName != null) { artifactName = artifactName + ".yml"; diff --git a/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java b/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java index f38e129be..2f02aa6ab 100644 --- a/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java +++ b/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java @@ -23,6 +23,12 @@ package org.onap.clamp.clds.service; +import com.att.ajsc.camunda.core.AttCamundaHistoryEvent; +import com.att.ajsc.camunda.core.AttCamundaService; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.gson.Gson; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -51,25 +57,19 @@ import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.stereotype.Service; -import com.att.ajsc.camunda.core.AttCamundaHistoryEvent; -import com.att.ajsc.camunda.core.AttCamundaService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.google.gson.Gson; - @Service public class LogServiceImpl implements LogService { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(LogServiceImpl.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(LogServiceImpl.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); @Autowired - private RuntimeService runtimeService; + private RuntimeService runtimeService; @Autowired - private HistoryService historyService; + private HistoryService historyService; @Context - private MessageContext context; + private MessageContext context; public void setRuntimeService(RuntimeService runtimeService) { this.runtimeService = runtimeService; @@ -165,7 +165,6 @@ public class LogServiceImpl implements LogService { if (classUrl != null) { logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS, classUrl.getFile()); } else { - logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS, classUrl.getFile()); logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS_NULL); } email.send(); -- cgit 1.2.3-korg From 81bcf96396d1903e0b7f4a55b2e4a9ed86b0f5d2 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 07:31:31 -0700 Subject: Fix a blocker issue reported by SOnar Add a test to return a value that could potentially be null Change-Id: I092ba4f21775ae64aa86f8dbff8538e47ca16c43 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/model/CldsModel.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java index a830f9380..7eac3d92a 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java @@ -300,8 +300,9 @@ public class CldsModel { */ public static CldsModel createUsingControlName(String fullControlName) { if (fullControlName == null || fullControlName.length() < UUID_LENGTH) { - throw new BadRequestException("closed loop id / control name length, " + fullControlName.length() - + ", less than the minimum of: " + UUID_LENGTH); + throw new BadRequestException( + "closed loop id / control name length, " + (fullControlName != null ? fullControlName.length() : 0) + + ", less than the minimum of: " + UUID_LENGTH); } CldsModel model = new CldsModel(); model.setControlNamePrefix(fullControlName.substring(0, fullControlName.length() - UUID_LENGTH)); -- cgit 1.2.3-korg From 96302171677a66eb099426d60d9d3534b628f20e Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 08:02:25 -0700 Subject: Fix a Critical issue from SONAR Rework the log and include the Exception in it to help the debugging Change-Id: I8930a4bd65bf2cac48cb1fbf98fb17fe69b5d909 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/client/PolicyClient.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java index 6095af155..22f215ccf 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java @@ -324,8 +324,8 @@ public class PolicyClient { versions.add(version); } catch (Exception e) { // just print warning - if n;o policies, version may be null - logger.warn("warning: failed to parse policyConfig.getPolicyVersion()=" - + policyConfig.getPolicyVersion()); + logger.warn("Failed to parse due to an exception policyConfig.getPolicyVersion()=" + + policyConfig.getPolicyVersion(), e); } } Collections.sort(versions); -- cgit 1.2.3-korg From 88455c8883a33cb89a42aa2f4f9d43de7a13079f Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 30 Aug 2017 08:03:22 -0700 Subject: Fix critical SONAR issue Replace a default exception by a specific one Change-Id: I1eef698e994321e6dde70f723e4e3908c5a09118 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) Signed-off-by: ChrisC --- .../org/onap/clamp/clds/client/req/SdcReq.java | 79 ++++++++++++---------- .../clds/exception/SdcCommunicationException.java | 61 +++++++++++++++++ 2 files changed, 103 insertions(+), 37 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/exception/SdcCommunicationException.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java index 3c16ce60b..9c2ebcda1 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java @@ -23,6 +23,17 @@ package org.onap.clamp.clds.client.req; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +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.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -35,6 +46,7 @@ import java.util.Map.Entry; import org.apache.commons.codec.digest.DigestUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.clamp.clds.client.SdcCatalogServices; +import org.onap.clamp.clds.exception.SdcCommunicationException; import org.onap.clamp.clds.model.CldsSdcResource; import org.onap.clamp.clds.model.CldsSdcServiceDetail; import org.onap.clamp.clds.model.prop.Global; @@ -43,17 +55,6 @@ import org.onap.clamp.clds.model.prop.StringMatch; import org.onap.clamp.clds.model.prop.Tca; import org.onap.clamp.clds.model.refprop.RefProp; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.dataformat.yaml.snakeyaml.Yaml; - /** * Construct a Sdc request given CLDS objects. */ @@ -63,14 +64,14 @@ public class SdcReq { /** * Format the Blueprint from a Yaml - * + * * @param refProp * The RefProp instance containing the Clds config * @param prop * The ModelProperties describing the clds model * @param docText * The Yaml file that must be converted - * + * * @return A String containing the BluePrint * @throws JsonParseException * In case of issues @@ -253,37 +254,41 @@ public class SdcReq { * @throws Exception */ public static List getSdcReqUrlsList(ModelProperties prop, String baseUrl, - SdcCatalogServices sdcCatalogServices, DelegateExecution execution) throws Exception { + SdcCatalogServices sdcCatalogServices, DelegateExecution execution) { // TODO : refact and regroup with very similar code List urlList = new ArrayList<>(); - Global globalProps = prop.getGlobal(); - if (globalProps != null) { - if (globalProps.getService() != null) { - String serviceInvariantUUID = globalProps.getService(); - execution.setVariable("serviceInvariantUUID", serviceInvariantUUID); - List resourceVfList = globalProps.getResourceVf(); - String serviceUUID = sdcCatalogServices.getServiceUuidFromServiceInvariantId(serviceInvariantUUID); - String sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(serviceUUID); - CldsSdcServiceDetail CldsSdcServiceDetail = sdcCatalogServices - .getCldsSdcServiceDetailFromJson(sdcServicesInformation); - if (CldsSdcServiceDetail != null && resourceVfList != null) { - List CldsSdcResourcesList = CldsSdcServiceDetail.getResources(); - if (CldsSdcResourcesList != null && CldsSdcResourcesList.size() > 0) { - for (CldsSdcResource CldsSdcResource : CldsSdcResourcesList) { - if (CldsSdcResource != null && CldsSdcResource.getResoucreType() != null - && CldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { - if (resourceVfList.contains(CldsSdcResource.getResourceInvariantUUID())) { - String normalizedResourceInstanceName = normalizeResourceInstanceName( - CldsSdcResource.getResourceInstanceName()); - String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" - + normalizedResourceInstanceName + "/artifacts"; - urlList.add(svcUrl); + try { + Global globalProps = prop.getGlobal(); + if (globalProps != null) { + if (globalProps.getService() != null) { + String serviceInvariantUUID = globalProps.getService(); + execution.setVariable("serviceInvariantUUID", serviceInvariantUUID); + List resourceVfList = globalProps.getResourceVf(); + String serviceUUID = sdcCatalogServices.getServiceUuidFromServiceInvariantId(serviceInvariantUUID); + String sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(serviceUUID); + CldsSdcServiceDetail CldsSdcServiceDetail = sdcCatalogServices + .getCldsSdcServiceDetailFromJson(sdcServicesInformation); + if (CldsSdcServiceDetail != null && resourceVfList != null) { + List CldsSdcResourcesList = CldsSdcServiceDetail.getResources(); + if (CldsSdcResourcesList != null && CldsSdcResourcesList.size() > 0) { + for (CldsSdcResource CldsSdcResource : CldsSdcResourcesList) { + if (CldsSdcResource != null && CldsSdcResource.getResoucreType() != null + && CldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { + if (resourceVfList.contains(CldsSdcResource.getResourceInvariantUUID())) { + String normalizedResourceInstanceName = normalizeResourceInstanceName( + CldsSdcResource.getResourceInstanceName()); + String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" + + normalizedResourceInstanceName + "/artifacts"; + urlList.add(svcUrl); + } } } } } } } + } catch (IOException e) { + throw new SdcCommunicationException("Exception occurred during the SDC communication",e); } return urlList; } @@ -358,7 +363,7 @@ public class SdcReq { /** * Method to get yaml/template properties value from json - * + * * @param docText * @return * @throws IOException diff --git a/src/main/java/org/onap/clamp/clds/exception/SdcCommunicationException.java b/src/main/java/org/onap/clamp/clds/exception/SdcCommunicationException.java new file mode 100644 index 000000000..429ab8dff --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/exception/SdcCommunicationException.java @@ -0,0 +1,61 @@ +/*- + * ============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.exception; + +/** + * New exception to capture SDC communication errors. + * + */ +public class SdcCommunicationException extends RuntimeException { + + /** + * Generated ID + */ + private static final long serialVersionUID = 8452294782552680243L; + + /** + * This constructor can be used to create a new SdcCommunicationException. + * + * @param message + * A string message detailing the problem + * @param e + * The exception sent by the code + */ + public SdcCommunicationException(String message, Throwable e) { + super(message, e); + } + + /** + * This constructor can be used to create a new SdcCommunicationException. + * Use this constructor only if you are creating a new exception stack, not + * if an exception was already raised by another code. + * + * @param message + * A string message detailing the problem + */ + public SdcCommunicationException(String message) { + super(message); + } + +} -- cgit 1.2.3-korg From 4c14395a640b3f0f1d0422b5ff7f840ebee8e92d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 8 Sep 2017 12:14:08 +0200 Subject: Add Holmes to the Backend Add support for Holmes boxes defined in GUI, Holmes model has been added and also policy calls. Change-Id: I2bbef0030b5174075792b459b7ced74aa2e8aad2 Issue-Id: CLAMP-27 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/client/HolmesPolicyDelegate.java | 72 ++++++++ .../clds/client/HolmesPolicyDeleteDelegate.java | 62 +++++++ .../org/onap/clamp/clds/model/prop/Holmes.java | 71 ++++++++ .../org/onap/clamp/clds/model/prop/ModelBpmn.java | 28 +-- .../onap/clamp/clds/model/prop/ModelElement.java | 28 ++- .../clamp/clds/model/prop/ModelProperties.java | 50 ++---- .../org/onap/clamp/clds/model/prop/Policy.java | 22 +-- .../onap/clamp/clds/model/prop/ResourceGroup.java | 14 +- .../onap/clamp/clds/model/prop/StringMatch.java | 18 +- .../java/org/onap/clamp/clds/model/prop/Tca.java | 20 +-- .../onap/clamp/clds/transform/XslTransformer.java | 6 +- src/main/resources/bpmn/clds-process-action.bpmn | 199 +++++++++++---------- src/main/resources/xsl/clds-bpmn-transformer.xsl | 14 +- .../clamp/clds/transform/XslTransformerTest.java | 34 ++++ src/test/resources/example/modelBpmn.xml | 110 ------------ .../resources/example/xsl-validation/modelBpmn.xml | 156 ++++++++++++++++ .../example/xsl-validation/modelBpmnForVerif.json | 38 ++++ 17 files changed, 639 insertions(+), 303 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/Holmes.java create mode 100644 src/test/java/org/onap/clamp/clds/transform/XslTransformerTest.java delete mode 100644 src/test/resources/example/modelBpmn.xml create mode 100644 src/test/resources/example/xsl-validation/modelBpmn.xml create mode 100644 src/test/resources/example/xsl-validation/modelBpmnForVerif.json (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java new file mode 100644 index 000000000..db7b5241b --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java @@ -0,0 +1,72 @@ +/*- + * ============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.client; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.clamp.clds.model.prop.Holmes; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Send Holmes info to policy api. + */ +public class HolmesPolicyDelegate implements JavaDelegate { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(HolmesPolicyDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + @Autowired + private PolicyClient policyClient; + + @Autowired + private RefProp refProp; + + /** + * Perform activity. Send Holmes info to policy api. + * + * @param execution + */ + @Override + public void execute(DelegateExecution execution) throws Exception { + String holmesPolicyRequestUuid = UUID.randomUUID().toString(); + execution.setVariable("holmesPolicyRequestUuid", holmesPolicyRequestUuid); + + ModelProperties prop = ModelProperties.create(execution); + Holmes holmes = prop.getType(Holmes.class); + if (holmes.isFound()) { + String responseMessage = policyClient.sendMicroServiceInJson(holmes.getCorrelationLogic(), prop, + holmesPolicyRequestUuid); + if (responseMessage != null) { + execution.setVariable("holmesPolicyResponseMessage", responseMessage.getBytes()); + } + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java new file mode 100644 index 000000000..46b33ffea --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java @@ -0,0 +1,62 @@ +/*- + * ============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.client; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.onap.clamp.clds.model.prop.Holmes; +import org.onap.clamp.clds.model.prop.ModelProperties; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Delete Holmes Policy via policy api. + */ +public class HolmesPolicyDeleteDelegate implements JavaDelegate { + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(HolmesPolicyDeleteDelegate.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + @Autowired + private PolicyClient policyClient; + + /** + * Perform activity. Delete Holmes Policy via policy api. + * + * @param execution + */ + @Override + public void execute(DelegateExecution execution) throws Exception { + ModelProperties prop = ModelProperties.create(execution); + Holmes holmes = prop.getType(Holmes.class); + if (holmes.isFound()) { + prop.setCurrentModelElementId(holmes.getId()); + + policyClient.deleteMicrosService(prop); + } + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java b/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java new file mode 100644 index 000000000..233f656e1 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java @@ -0,0 +1,71 @@ +/*- + * ============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.model.prop; + +import com.fasterxml.jackson.databind.JsonNode; + +/** + * Parse Holmes bpmn parameters json properties. + *

+ * Example json: + * [{"name":"correlationalLogic","value":"vcwx"},{"name":"operationalPolicy","value":"cccc"}] + * + */ +public class Holmes extends ModelElement { + + private static final String TYPE_HOLMES = "holmes"; + + private String correlationLogic; + + private String operationalPolicy; + + /** + * Default constructor for Holmes Element + * + * @param modelProp + * The ModelProperties containing the all the info, like bpmn, + * bpmn params, etc ... + * @param modelBpmn + * @param modelJson + */ + public Holmes(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(TYPE_HOLMES, modelProp, modelBpmn, modelJson); + + correlationLogic = this.getValueByName("correlationalLogic"); + operationalPolicy = this.getValueByName("operationalPolicy"); + } + + public static final String getType() { + return TYPE_HOLMES; + } + + public String getCorrelationLogic() { + return correlationLogic; + } + + public String getOperationalPolicy() { + return operationalPolicy; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java index 63a03058d..ae7028dcd 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java @@ -23,6 +23,15 @@ package org.onap.clamp.clds.model.prop; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -33,15 +42,6 @@ import java.util.Map.Entry; import org.onap.clamp.clds.service.CldsService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - /** * Parse Model BPMN properties. *

@@ -50,9 +50,9 @@ import com.fasterxml.jackson.databind.node.ObjectNode; * :[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} */ public class ModelBpmn { - protected static final EELFLogger logger = EELFManager.getInstance() + protected static final EELFLogger logger = EELFManager.getInstance() .getLogger(CldsService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); // for each type, an array of entries private final Map> entriesByType = new HashMap<>(); @@ -123,12 +123,14 @@ public class ModelBpmn { } /** - * + * This method verifies if the ModelElement Type (collector, holmes, tca, + * ...) is in the list. * * @param type + * A model Element type (tca, collector, ...) * @return true if the element is found or false otherwise */ - public boolean getModelElementFound(String type) { + public boolean isModelElementTypeInList(String type) { return entriesByType.get(type) != null; } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java index 42d11f4b5..edf114261 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java @@ -32,20 +32,19 @@ import java.util.Iterator; import java.util.List; /** - * Provide base ModelElement functionality. + * Provide base ModelElement functionality. Perform base parsing of properties + * for a ModelElement (such as, Collector, StringMatch, Policy, Tca, Holmes, + * ...) */ public abstract class ModelElement { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelElement.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - public static final String TYPE_POLICY = "policy"; - public static final String TYPE_TCA = "tca"; - private final String type; private final ModelBpmn modelBpmn; private final String id; protected String topicPublishes; - protected final JsonNode meNode; + protected final JsonNode modelElementJsonNode; private boolean isFound; private final ModelProperties modelProp; @@ -64,12 +63,13 @@ public abstract class ModelElement { this.modelProp = modelProp; this.modelBpmn = modelBpmn; this.id = modelBpmn.getId(type); - this.meNode = modelJson.get(id); - this.isFound = modelBpmn.getModelElementFound(type); + this.modelElementJsonNode = modelJson.get(id); + this.isFound = modelBpmn.isModelElementTypeInList(type); } /** - * topicSubscribes is the topicPublishes of the from Model Element + * topicSubscribes is the topicPublishes of the from Model Element (the + * previous one in the chain). * * @return the topicSubscribes */ @@ -159,16 +159,14 @@ public abstract class ModelElement { while (i.hasNext()) { JsonNode node = i.next(); if (node.path("name").asText().equals(name)) { - String value; JsonNode vnode = node.path("value"); if (vnode.isArray()) { // if array, assume value is in first element - value = vnode.path(0).asText(); + values.add(vnode.path(0).asText()); } else { // otherwise, just return text - value = vnode.asText(); + values.add(vnode.asText()); } - values.add(value); } } } @@ -241,7 +239,7 @@ public abstract class ModelElement { * @return */ public String getValueByName(String name) { - return getValueByName(meNode, name); + return getValueByName(modelElementJsonNode, name); } /** @@ -252,7 +250,7 @@ public abstract class ModelElement { * @return */ public Integer getIntValueByName(String name) { - return getIntValueByName(meNode, name); + return getIntValueByName(modelElementJsonNode, name); } /** @@ -263,7 +261,7 @@ public abstract class ModelElement { * @return */ public List getValuesByName(String name) { - return getValuesByName(meNode, name); + return getValuesByName(modelElementJsonNode, name); } /** diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java index 1cfd46165..9684eea86 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java @@ -23,6 +23,12 @@ package org.onap.clamp.clds.model.prop; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.HashSet; @@ -36,19 +42,13 @@ import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.CldsModel; import org.onap.clamp.clds.service.CldsService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Parse model properties. */ public class ModelProperties { - protected static final EELFLogger logger = EELFManager.getInstance() + protected static final EELFLogger logger = EELFManager.getInstance() .getLogger(CldsService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance() + protected static final EELFLogger auditLogger = EELFManager.getInstance() .getAuditLogger(); private ModelBpmn modelBpmn; @@ -58,10 +58,9 @@ public class ModelProperties { private final String controlName; private final String actionCd; // Flag indicate whether it is triggered by Validation Test button from UI - private final boolean isTest; + private final boolean isTest; private Global global; - private Tca tca; private final Map modelElements = new ConcurrentHashMap<>(); @@ -93,8 +92,8 @@ public class ModelProperties { * @throws JsonProcessingException * @throws IOException */ - public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, String modelBpmnPropText, - String modelPropText) throws IOException { + public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, + String modelBpmnPropText, String modelPropText) throws IOException { this.modelName = modelName; this.controlName = controlName; this.actionCd = actionCd; @@ -150,7 +149,7 @@ public class ModelProperties { Global global = new Global(modelJson); vfs = global.getResourceVf(); } catch (IOException e) { - // VF is null + logger.warn("no VF found", e); } String vf = null; if (vfs != null && !vfs.isEmpty()) { @@ -168,13 +167,12 @@ public class ModelProperties { * @throws IOException */ public static ModelProperties create(DelegateExecution execution) throws IOException { - // String modelProp = (String) execution.getVariable("modelProp"); String modelProp = new String((byte[]) execution.getVariable("modelProp")); String modelBpmnProp = (String) execution.getVariable("modelBpmnProp"); String modelName = (String) execution.getVariable("modelName"); String controlName = (String) execution.getVariable("controlName"); String actionCd = (String) execution.getVariable("actionCd"); - boolean isTest = (boolean)execution.getVariable("isTest"); + boolean isTest = (boolean) execution.getVariable("isTest"); return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp); } @@ -303,12 +301,12 @@ public class ModelProperties { return actionCd; } - /** - * @return the isTest - */ - public boolean isTest() { - return isTest; - } + /** + * @return the isTest + */ + public boolean isTest() { + return isTest; + } /** * @return the isCreateRequest @@ -352,14 +350,4 @@ public class ModelProperties { String type = modelElementClasses.get(clazz); return (type != null ? (T) modelElements.get(type) : null); } - - /** - * @return the tca - */ - public Tca getTca() { - if (tca == null) { - tca = new Tca(this, modelBpmn, modelJson); - } - return tca; - } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java index 6673af213..452af20cd 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java @@ -23,14 +23,14 @@ package org.onap.clamp.clds.model.prop; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Parse Policy json properties. *

@@ -49,12 +49,12 @@ import com.fasterxml.jackson.databind.JsonNode; * "vf3RtPi"]}]]}] */ public class Policy extends ModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private List policyChains; + private List policyChains; - private static final String TYPE_POLICY = "policy"; + private static final String TYPE_POLICY = "policy"; /** * Parse Policy given json node. @@ -64,12 +64,12 @@ public class Policy extends ModelElement { * @param modelJson */ public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(ModelElement.TYPE_POLICY, modelProp, modelBpmn, modelJson); + super(TYPE_POLICY, modelProp, modelBpmn, modelJson); // process policies - if (meNode != null) { - Iterator itr = meNode.elements(); - policyChains = new ArrayList(); + if (modelElementJsonNode != null) { + Iterator itr = modelElementJsonNode.elements(); + policyChains = new ArrayList<>(); while (itr.hasNext()) { policyChains.add(new PolicyChain(itr.next())); } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java b/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java index de98333a1..6e986bb0e 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java @@ -23,14 +23,14 @@ package org.onap.clamp.clds.model.prop; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Parse Resource Group json properties. * @@ -63,8 +63,8 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class ResourceGroup { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourceGroup.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ResourceGroup.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); private String groupNumber; private String policyId; @@ -84,7 +84,7 @@ public class ResourceGroup { // process Server_Configurations JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); Iterator itr = serviceConfigurationsNode.elements(); - serviceConfigurations = new ArrayList(); + serviceConfigurations = new ArrayList<>(); while (itr.hasNext()) { serviceConfigurations.add(new ServiceConfiguration(itr.next())); } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java index b20db0aff..7fcc1b1b9 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java @@ -23,14 +23,12 @@ package org.onap.clamp.clds.model.prop; +import com.fasterxml.jackson.databind.JsonNode; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - /** * Parse StringMatch json properties. *

@@ -62,12 +60,10 @@ import com.fasterxml.jackson.databind.JsonNode; * */ public class StringMatch extends ModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(StringMatch.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private List resourceGroups; + private List resourceGroups; - private static final String TYPE_STRING_MATCH = "stringMatch"; + private static final String TYPE_STRING_MATCH = "stringMatch"; /** * Parse StringMatch given json node. @@ -79,9 +75,9 @@ public class StringMatch extends ModelElement { super(TYPE_STRING_MATCH, modelProp, modelBpmn, modelJson); // process Server_Configurations - if (meNode != null) { - Iterator itr = meNode.elements(); - resourceGroups = new ArrayList(); + if (modelElementJsonNode != null) { + Iterator itr = modelElementJsonNode.elements(); + resourceGroups = new ArrayList<>(); while (itr.hasNext()) { resourceGroups.add(new ResourceGroup(itr.next())); } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java index b94f52304..6bc68e23d 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java @@ -23,14 +23,14 @@ package org.onap.clamp.clds.model.prop; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Parse Tca json properties. * @@ -50,12 +50,12 @@ import com.fasterxml.jackson.databind.JsonNode; */ public class Tca extends ModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private List tcaItems; + private List tcaItems; - private static final String TYPE_TCA = "tca"; + private static final String TYPE_TCA = "tca"; /** * Parse Tca given json node @@ -68,9 +68,9 @@ public class Tca extends ModelElement { super(TYPE_TCA, modelProp, modelBpmn, modelJson); // process Server_Configurations - if (meNode != null) { - Iterator itr = meNode.elements(); - tcaItems = new ArrayList(); + if (modelElementJsonNode != null) { + Iterator itr = modelElementJsonNode.elements(); + tcaItems = new ArrayList<>(); while (itr.hasNext()) { tcaItems.add(new TcaItem(itr.next())); } diff --git a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java index d15f67c77..684bae3f6 100644 --- a/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java +++ b/src/main/java/org/onap/clamp/clds/transform/XslTransformer.java @@ -34,6 +34,8 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import org.onap.clamp.clds.util.ResourceFileUtil; + /** * XSL Transformer. */ @@ -43,7 +45,7 @@ public class XslTransformer { public void setXslResourceName(String xslResourceName) throws TransformerConfigurationException { TransformerFactory tfactory = TransformerFactory.newInstance(); - templates = tfactory.newTemplates(new StreamSource(TransformUtil.getResourceAsStream(xslResourceName))); + templates = tfactory.newTemplates(new StreamSource(ResourceFileUtil.getResourceAsStream(xslResourceName))); } /** @@ -53,7 +55,7 @@ public class XslTransformer { * @throws TransformerException */ public String doXslTransformToString(String xml) throws TransformerException { - StringWriter output = new StringWriter(4000); + StringWriter output = new StringWriter(4096); Transformer transformer = templates.newTransformer(); transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(output)); diff --git a/src/main/resources/bpmn/clds-process-action.bpmn b/src/main/resources/bpmn/clds-process-action.bpmn index d9f8619cc..780162403 100644 --- a/src/main/resources/bpmn/clds-process-action.bpmn +++ b/src/main/resources/bpmn/clds-process-action.bpmn @@ -1,5 +1,5 @@ - + @@ -13,26 +13,27 @@ sendOpPolicyReqDistribute StartEvent_1 ServiceTask_0x8ypxf - sendStringMatchingReqDistribute sendTcaReqDistribute + sendStringMatchingReqDistribute + sendHolmesReqDistribute sendStringMatchingReqDelete - sendOpPolicyReqDelete sendTcaReqDelete + sendOpPolicyReqDelete + sendHolmesReqDelete sendOpPolicyReqUpdate sendStringMatchingReqUpdate sendTcaReqUpdate + sendHolmesReqUpdate sendOpPolicyReqStop - ServiceTask_0d5zgbw sendOpPolicyReqRestart - ServiceTask_04d5jlr @@ -69,34 +70,32 @@ SequenceFlow_7 - - SequenceFlow_1rga27p + SequenceFlow_1tu9g11 SequenceFlow_10 - SequenceFlow_1kegg6u + SequenceFlow_0ejpmee SequenceFlow_28 - - SequenceFlow_17snsdc + SequenceFlow_29 SequenceFlow_30 - + - SequenceFlow_188n2z7 + SequenceFlow_31 SequenceFlow_32 - + @@ -122,43 +121,50 @@ SequenceFlow_1xlfq66 SequenceFlow_0w39hon - - - SequenceFlow_31 - SequenceFlow_188n2z7 + + + + SequenceFlow_23 + SequenceFlow_0tpegxf - - - SequenceFlow_29 - SequenceFlow_17snsdc + + + SequenceFlow_14 + SequenceFlow_1rga27p SequenceFlow_0w39hon SequenceFlow_14 - - - SequenceFlow_14 - SequenceFlow_1rga27p + + + + SequenceFlow_1rga27p + SequenceFlow_1tu9g11 - SequenceFlow_0tpegxf + SequenceFlow_1mtizad SequenceFlow_6 - - - SequenceFlow_23 - SequenceFlow_0tpegxf + + SequenceFlow_0tpegxf + SequenceFlow_1mtizad + SequenceFlow_27 SequenceFlow_26 - SequenceFlow_26 SequenceFlow_1kegg6u + + + SequenceFlow_1kegg6u + SequenceFlow_0ejpmee + + @@ -175,16 +181,16 @@ - + - - - + + + - + @@ -235,19 +241,19 @@ - - - - + + + + - + - + @@ -260,22 +266,22 @@ - + - - - + + + - + - + @@ -283,10 +289,10 @@ - - + + - + @@ -297,11 +303,10 @@ - - - + + - + @@ -310,7 +315,7 @@ - + @@ -322,18 +327,18 @@ - + - + - - + + - + @@ -349,9 +354,9 @@ - + - + @@ -362,56 +367,66 @@ - - - + + + - + - - + + - - - + + + - + - - + + - - + + + + + + + + + + + + + + + - + - - + + - - - + + + - + - - + + - - + + - + - - - diff --git a/src/main/resources/xsl/clds-bpmn-transformer.xsl b/src/main/resources/xsl/clds-bpmn-transformer.xsl index 94af952fc..8a39be55a 100644 --- a/src/main/resources/xsl/clds-bpmn-transformer.xsl +++ b/src/main/resources/xsl/clds-bpmn-transformer.xsl @@ -1,4 +1,4 @@ - + - - - - - SequenceFlow_0ex3w2w - - - SequenceFlow_0ex3w2w - SequenceFlow_185iyma - - - SequenceFlow_185iyma - SequenceFlow_092429t - - - SequenceFlow_092429t - SequenceFlow_0hghw7g - - - SequenceFlow_08j3fsl - SequenceFlow_0hghw7g - - - SequenceFlow_0hghw7g - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/resources/example/xsl-validation/modelBpmn.xml b/src/test/resources/example/xsl-validation/modelBpmn.xml new file mode 100644 index 000000000..3021902c7 --- /dev/null +++ b/src/test/resources/example/xsl-validation/modelBpmn.xml @@ -0,0 +1,156 @@ + + + + + SequenceFlow_1nvvr00 + + + SequenceFlow_0qf2552 + SequenceFlow_1a2oxpd + + + SequenceFlow_0jeu0gv + SequenceFlow_15gkgs5 + + + SequenceFlow_1nvvr00 + SequenceFlow_0qf2552 + + + SequenceFlow_15gkgs5 + SequenceFlow_0ev75ss + + + SequenceFlow_0ev75ss + SequenceFlow_103hvmr + + + SequenceFlow_103hvmr + + + SequenceFlow_1a2oxpd + SequenceFlow_0jeu0gv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/example/xsl-validation/modelBpmnForVerif.json b/src/test/resources/example/xsl-validation/modelBpmnForVerif.json new file mode 100644 index 000000000..1bef49a1a --- /dev/null +++ b/src/test/resources/example/xsl-validation/modelBpmnForVerif.json @@ -0,0 +1,38 @@ +{ + "collector": [ + { + "id": "Collector_", + "from": "StartEvent_1" + } + ], + "stringMatch": [ + { + "id": "StringMatch_0tw2y4f", + "from": "Collector_" + } + ], + "policy": [ + { + "id": "Policy_", + "from": "TCA_09hcdsx" + } + ], + "tca": [ + { + "id": "TCA_09hcdsx", + "from": "VesCollector_1kxjxy6" + } + ], + "vesCollector": [ + { + "id": "VesCollector_1kxjxy6", + "from": "Holmes_1fzdqp9" + } + ], + "holmes": [ + { + "id": "Holmes_1fzdqp9", + "from": "StringMatch_0tw2y4f" + } + ] +} \ No newline at end of file -- cgit 1.2.3-korg From 7104181e0ebd97bbd034b5c221561d42e4241fe5 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 8 Sep 2017 12:23:49 +0200 Subject: Sonar improvements and class renaming Some sonar improvements and class renaming in different files Change-Id: I8d8eff1e3fedee1d1c31e62edb80e1bb9ce75362 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/client/DcaeInventoryServices.java | 2 +- .../clds/client/OperationalPolicyDelegate.java | 5 +- .../org/onap/clamp/clds/client/PolicyClient.java | 86 +++++++++-- .../onap/clamp/clds/client/SdcCatalogServices.java | 13 +- .../onap/clamp/clds/client/SdcSendReqDelegate.java | 8 +- .../clds/client/StringMatchPolicyDelegate.java | 2 +- .../onap/clamp/clds/client/TcaPolicyDelegate.java | 2 +- .../clds/client/req/OperationalPolicyReq.java | 40 ++--- .../org/onap/clamp/clds/client/req/SdcReq.java | 48 +++--- src/main/java/org/onap/clamp/clds/dao/CldsDao.java | 39 +++-- .../clamp/clds/exception/CldsConfigException.java | 61 ++++++++ .../onap/clamp/clds/model/CldsDBServiceCache.java | 2 +- .../org/onap/clamp/clds/model/CldsSdcResource.java | 53 +++++-- .../clamp/clds/model/CldsSdcResourceBasicInfo.java | 60 +++++-- .../onap/clamp/clds/model/CldsSdcServiceInfo.java | 57 +++++-- .../org/onap/clamp/clds/model/CldsServiceData.java | 24 +-- .../org/onap/clamp/clds/model/refprop/RefProp.java | 26 ++-- .../org/onap/clamp/clds/service/CldsService.java | 172 ++++++++++----------- .../clamp/clds/service/CldsTemplateService.java | 41 +++-- .../onap/clamp/clds/transform/TransformUtil.java | 64 -------- .../org/onap/clamp/clds/util/ResourceFileUtil.java | 71 +++++++++ src/test/java/org/onap/clamp/clds/it/DcaeIT.java | 7 +- .../org/onap/clamp/clds/it/PolicyClientIT.java | 25 ++- src/test/java/org/onap/clamp/clds/it/SdcIT.java | 15 +- .../clds/model/prop/CustomModelElementTest.java | 6 +- .../clamp/clds/model/prop/ModelPropertiesTest.java | 11 +- 26 files changed, 560 insertions(+), 380 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/exception/CldsConfigException.java delete mode 100644 src/main/java/org/onap/clamp/clds/transform/TransformUtil.java create mode 100644 src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java index c35eb0da4..192dcdb91 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java @@ -100,7 +100,7 @@ public class DcaeInventoryServices { List resourceUuidList = global.getResourceVf(); String serviceUuid = sdcCatalogServices.getServiceUuidFromServiceInvariantId(invariantServiceUuid); String resourceUuid = ""; - if (resourceUuidList != null && resourceUuidList.size() > 0) { + if (resourceUuidList != null && !resourceUuidList.isEmpty()) { resourceUuid = resourceUuidList.get(0).toString(); } /* Invemtory service url is called in this method */ diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java index 566d11a24..493b3b3c7 100644 --- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java @@ -78,9 +78,6 @@ public class OperationalPolicyDelegate implements JavaDelegate { */ @Override public void execute(DelegateExecution execution) throws IOException, BuilderException, PolicyEngineException { - - // execution.setVariable("operationalPolicyRequestUuid", - // operationalPolicyRequestUuid); String responseMessage = null; String operationalPolicyRequestUuid = null; ModelProperties prop = ModelProperties.create(execution); @@ -90,7 +87,7 @@ public class OperationalPolicyDelegate implements JavaDelegate { operationalPolicyRequestUuid = LoggingUtils.getRequestId(); Map> attributes = OperationalPolicyReq.formatAttributes(refProp, prop, prop.getType(Policy.class).getId(), policyChain); - responseMessage = policyClient.sendBrms(attributes, prop, operationalPolicyRequestUuid); + responseMessage = policyClient.sendBrmsPolicy(attributes, prop, operationalPolicyRequestUuid); } if (responseMessage != null) { execution.setVariable("operationalPolicyResponseMessage", responseMessage.getBytes()); diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java index 22f215ccf..2b49a8ff5 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java @@ -62,10 +62,15 @@ import org.springframework.context.ApplicationContext; */ public class PolicyClient { + protected static final String POLICY_PREFIX_BASE = "Config_"; + protected static final String POLICY_PREFIX_BRMS_PARAM = "Config_BRMS_Param_"; + protected static final String POLICY_PREFIX_MICROSERVICE = "Config_MS_"; + protected static final String LOG_POLICY_PREFIX = "Response is "; - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(PolicyClient.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}") protected String cldsPolicyConfigFile; @@ -77,7 +82,7 @@ public class PolicyClient { protected RefProp refProp; /** - * Perform send of microservice policy. + * Perform BRMS policy type. * * @param attributes * A map of attributes @@ -92,7 +97,7 @@ public class PolicyClient { * In case of issues with the PolicyEngine class * */ - public String sendBrms(Map> attributes, ModelProperties prop, + public String sendBrmsPolicy(Map> attributes, ModelProperties prop, String policyRequestUuid) throws PolicyEngineException, IOException { PolicyParameters policyParameters = new PolicyParameters(); @@ -122,7 +127,7 @@ public class PolicyClient { } /** - * Perform send of microservice policy. + * Perform send of microservice policy in JSON. * * @param policyJson * The policy JSON @@ -136,7 +141,7 @@ public class PolicyClient { * @throws IOException * In case of issue with the Stream */ - public String sendMicroService(String policyJson, ModelProperties prop, String policyRequestUuid) + public String sendMicroServiceInJson(String policyJson, ModelProperties prop, String policyRequestUuid) throws IOException, PolicyEngineException { PolicyParameters policyParameters = new PolicyParameters(); @@ -163,6 +168,47 @@ public class PolicyClient { return rtnMsg; } + /** + * Perform send of base policy in OTHER type. + * + * @param configBody + * The config policy string body + * @param prop + * The ModelProperties + * @param policyRequestUuid + * The policy request UUID + * @return + * @throws IOException + * In case of issues with the policy engine class creation + * @throws PolicyEngineException + * In case of issue with the Stream + */ + public String sendBasePolicyInOther(String configBody, ModelProperties prop, String policyRequestUuid) + throws IOException, PolicyEngineException { + + PolicyParameters policyParameters = new PolicyParameters(); + + // Set Policy Type + policyParameters.setPolicyConfigType(PolicyConfigType.Base); + policyParameters.setEcompName(refProp.getStringValue("policy.ecomp.name")); + policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName()); + + policyParameters.setConfigBody(configBody); + policyParameters.setConfigBodyType(PolicyType.OTHER); + policyParameters.setConfigName("HolmesPolicy"); + + policyParameters.setRequestID(UUID.fromString(policyRequestUuid)); + + // Adding this line to clear the policy id from policy name while + // pushing to policy engine + prop.setPolicyUniqueId(""); + + String rtnMsg = send(policyParameters, prop, POLICY_PREFIX_BASE); + push(PolicyConfigType.Base.toString(), prop); + + return rtnMsg; + } + /** * Perform send of policy. * @@ -204,7 +250,7 @@ public class PolicyClient { responseMessage = response.getResponseMessage(); } } catch (Exception e) { - logger.error("Exception occurred during policy communnication", e); + logger.error("Exception occurred during policy communication", e); } logger.info(LOG_POLICY_PREFIX + responseMessage); @@ -266,7 +312,7 @@ public class PolicyClient { response = policyEngine.pushPolicy(pushPolicyParameters); responseMessage = response.getResponseMessage(); } catch (Exception e) { - logger.error("Exception occurred during policy communnication", e); + logger.error("Exception occurred during policy communication", e); } logger.info(LOG_POLICY_PREFIX + responseMessage); @@ -350,9 +396,20 @@ public class PolicyClient { * In case of issues with the PolicyEngine creation */ public String deleteMicrosService(ModelProperties prop) throws PolicyEngineException, IOException { - String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix"); String policyType = refProp.getStringValue("policy.ms.type"); - return deletePolicy(policyNamePrefix, prop, policyType); + return deletePolicy(prop, policyType); + } + + /** + * This method delete the Base policy. + * + * @param prop The model Properties + * @return A string with the answer from policy + * @throws PolicyEngineException In case of issues with the policy engine + * @throws IOException In case of issues with the stream + */ + public String deleteBasePolicy(ModelProperties prop) throws PolicyEngineException, IOException { + return deletePolicy(prop, PolicyConfigType.Base.toString()); } /** @@ -367,26 +424,23 @@ public class PolicyClient { * In case of issues with the PolicyEngine creation */ public String deleteBrms(ModelProperties prop) throws PolicyEngineException, IOException { - String policyNamePrefix = refProp.getStringValue("policy.op.policyNamePrefix"); String policyType = refProp.getStringValue("policy.op.type"); - return deletePolicy(policyNamePrefix, prop, policyType); + return deletePolicy(prop, policyType); } /** * Format and send delete PAP and PDP requests to Policy. * - * @param policyNamePrefix - * The String policyNamePrefix * @param prop * The ModelProperties + * * @return The response message from policy * @throws IOException * in case of issues with the Stream * @throws PolicyEngineException * In case of issues with the PolicyEngine class creation */ - protected String deletePolicy(String policyNamePrefix, ModelProperties prop, String policyType) - throws PolicyEngineException, IOException { + protected String deletePolicy(ModelProperties prop, String policyType) throws PolicyEngineException, IOException { DeletePolicyParameters deletePolicyParameters = new DeletePolicyParameters(); if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) { diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java index 24a3d3c41..d418ea55b 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -569,11 +569,7 @@ public class SdcCatalogServices { } private String removeUnwantedBracesFromString(String id) { - String idReworked = ""; - if (id != null && id.contains("\"")) { - idReworked = id.replaceAll("\"", ""); - } - return idReworked; + return (id != null) ? id.replaceAll("\"", "") : ""; } private List getAlarmCondtionsFromVfc(String vfcResponse) throws IOException { @@ -740,7 +736,7 @@ public class SdcCatalogServices { String inputLine; while ((inputLine = in.readLine()) != null) { if (!inputLine.isEmpty()) { - response.append(inputLine); + response.append(inputLine); } if (alarmConditions) { response.append("\n"); @@ -985,12 +981,13 @@ public class SdcCatalogServices { alertDescNode.put(currCldsAlarmCondition.getAlarmConditionKey(), currCldsAlarmCondition.getAlarmConditionKey()); } + } } - } + vfcObjectNode.putPOJO("alarmCondition", alarmCondNode); vfcObjectNode.putPOJO("alertDescription", alertDescNode); vfcResourceUuidObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), vfcObjectNode); - } + } } } else { alarmCondNode.put("", ""); diff --git a/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java index ee233686b..0ffde932e 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcSendReqDelegate.java @@ -70,9 +70,9 @@ public class SdcSendReqDelegate implements JavaDelegate { getSdcAttributes((String) execution.getVariable("controlName")); ModelProperties prop = ModelProperties.create(execution); String bluprintPayload = SdcReq.formatBlueprint(refProp, prop, docText); - String formatttedSdcReq = SdcReq.formatSdcReq(bluprintPayload, artifactName, artifactLabel, artifactType); - if (formatttedSdcReq != null) { - execution.setVariable("formattedArtifactReq", formatttedSdcReq.getBytes()); + String formattedSdcReq = SdcReq.formatSdcReq(bluprintPayload, artifactName, artifactLabel, artifactType); + if (formattedSdcReq != null) { + execution.setVariable("formattedArtifactReq", formattedSdcReq.getBytes()); } List sdcReqUrlsList = SdcReq.getSdcReqUrlsList(prop, baseUrl, sdcCatalogServices, execution); @@ -83,7 +83,7 @@ public class SdcSendReqDelegate implements JavaDelegate { if (formattedSdcLocationReq != null) { execution.setVariable("formattedLocationReq", formattedSdcLocationReq.getBytes()); } - sdcCatalogServices.uploadToSdc(prop, userid, sdcReqUrlsList, formatttedSdcReq, formattedSdcLocationReq, + sdcCatalogServices.uploadToSdc(prop, userid, sdcReqUrlsList, formattedSdcReq, formattedSdcLocationReq, artifactName, locationArtifactName); } diff --git a/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java index 50126d55e..d149137b6 100644 --- a/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java @@ -64,7 +64,7 @@ public class StringMatchPolicyDelegate implements JavaDelegate { StringMatch stringMatch = prop.getType(StringMatch.class); if (stringMatch.isFound()) { String policyJson = StringMatchPolicyReq.format(refProp, prop); - String responseMessage = policyClient.sendMicroService(policyJson, prop, stringMatchPolicyRequestUuid); + String responseMessage = policyClient.sendMicroServiceInJson(policyJson, prop, stringMatchPolicyRequestUuid); if (responseMessage != null) { execution.setVariable("stringMatchPolicyResponseMessage", responseMessage.getBytes()); } diff --git a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java index e8b92a42b..9debcc2a6 100644 --- a/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java @@ -65,7 +65,7 @@ public class TcaPolicyDelegate implements JavaDelegate { Tca tca = prop.getType(Tca.class); if (tca.isFound()) { String policyJson = TcaMPolicyReq.formatTca(refProp, prop); - String responseMessage = policyClient.sendMicroService(policyJson, prop, tcaPolicyRequestUuid); + String responseMessage = policyClient.sendMicroServiceInJson(policyJson, prop, tcaPolicyRequestUuid); if (responseMessage != null) { execution.setVariable("tcaPolicyResponseMessage", responseMessage.getBytes()); } diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java index e7f956d33..2b1762a24 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -85,8 +85,8 @@ public class OperationalPolicyReq { String operationTopic = ""; String notificationTopic = ""; String controller = ""; - Tca tca = prop.getTca(); - if (tca.isFound()) { + Tca tca = prop.getType(Tca.class); + if (tca != null && tca.isFound()) { if (!global.getActionSet().equalsIgnoreCase("enbRecipe")) { throw new BadRequestException( "Operation Policy validation problem: action set is not selected properly."); @@ -108,9 +108,9 @@ public class OperationalPolicyReq { String recipeTopic = refProp.getStringValue("op.recipeTopic", global.getService()); // ruleAttributes - Map ruleAttributes = new HashMap(); + Map ruleAttributes = new HashMap<>(); - if (operationTopic == null || operationTopic.length() == 0) { + if (operationTopic == null || operationTopic.isEmpty()) { logger.info("templateName=" + templateName); logger.info("recipeTopic=" + recipeTopic); logger.info("notificationTopic=" + notificationTopic); @@ -151,10 +151,10 @@ public class OperationalPolicyReq { } // matchingAttributes - Map matchingAttributes = new HashMap(); + Map matchingAttributes = new HashMap<>(); matchingAttributes.put("controller", controller); - Map> attributes = new HashMap>(); + Map> attributes = new HashMap<>(); attributes.put(AttributeType.RULE, ruleAttributes); attributes.put(AttributeType.MATCHING, matchingAttributes); @@ -189,7 +189,7 @@ public class OperationalPolicyReq { builder.addResource(vfcResources); // process each policy - HashMap policyObjMap = new HashMap(); + HashMap policyObjMap = new HashMap<>(); List policyItemList = orderParentFirst(policyChain.getPolicyItems()); Target target = new Target(); target.setType(TargetType.VM); @@ -227,7 +227,7 @@ public class OperationalPolicyReq { logger.info("results.getSpecification()=" + results.getSpecification()); } else { // throw exception with error info - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: "); for (Message message : results.getMessages()) { sb.append(message.getMessage()); @@ -235,10 +235,7 @@ public class OperationalPolicyReq { } throw new BadRequestException(sb.toString()); } - - String encodedYaml = URLEncoder.encode(results.getSpecification(), "UTF-8"); - - return encodedYaml; + return URLEncoder.encode(results.getSpecification(), "UTF-8"); } /** @@ -269,7 +266,7 @@ public class OperationalPolicyReq { builder.addResource(vfcResources); // process each policy - HashMap policyObjMap = new HashMap(); + HashMap policyObjMap = new HashMap<>(); List policyItemList = addAOTSActorRecipe(refProp, global.getService(), policyChain.getPolicyItems()); Target target = new Target(); @@ -281,7 +278,7 @@ public class OperationalPolicyReq { String policyName = policyItem.getRecipe() + " Policy"; if (i == 0) { // To set up time window payload for trigger policy - Map payloadMap = new HashMap(); + Map payloadMap = new HashMap<>(); payloadMap.put("timeWindow", refProp.getStringValue("op.eNodeB.timeWindow")); String policyDescription = policyItem.getRecipe() + " Policy - the trigger (no parent) policy - created by CLDS"; @@ -314,7 +311,7 @@ public class OperationalPolicyReq { logger.info("results.getSpecification()=" + results.getSpecification()); } else { // throw exception with error info - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: "); for (Message message : results.getMessages()) { sb.append(message.getMessage()); @@ -322,10 +319,7 @@ public class OperationalPolicyReq { } throw new BadRequestException(sb.toString()); } - - String encodedYaml = URLEncoder.encode(results.getSpecification(), "UTF-8"); - - return encodedYaml; + return URLEncoder.encode(results.getSpecification(), "UTF-8"); } /** @@ -335,7 +329,7 @@ public class OperationalPolicyReq { * @return */ private static List addAOTSActorRecipe(RefProp refProp, String service, List inOrigList) { - List outList = new ArrayList(); + List outList = new ArrayList<>(); try { PolicyItem policyItem = inOrigList.get(0); ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("op.eNodeB.recipe", service); @@ -354,7 +348,7 @@ public class OperationalPolicyReq { policyItemObj.setRetryTimeLimit(Integer.parseInt(recipeNode.path("TimeLimit").asText())); } if (!recipeNode.path("PPConditions").asText().isEmpty()) { - List parentPolicyConditions = new ArrayList(); + List parentPolicyConditions = new ArrayList<>(); for (String ppCondition : recipeNode.path("PPConditions").asText().split(",")) { parentPolicyConditions.add(ppCondition); } @@ -395,7 +389,7 @@ public class OperationalPolicyReq { // check for trigger policy (no parent) String parent = inItem.getParentPolicy(); if (parent == null || parent.length() == 0) { - if (outList.size() > 0) { + if (!outList.isEmpty()) { throw new BadRequestException( "Operation Policy validation problem: more than one trigger policy"); } else { @@ -431,7 +425,7 @@ public class OperationalPolicyReq { return new Resource[0]; } return stringList.stream().map(stringElem -> new Resource(stringElem, resourceType)).toArray(Resource[]::new); - } + } /** * Convert a List of policy result strings to an array of PolicyResult diff --git a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java index 9c2ebcda1..93c562601 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java @@ -233,7 +233,7 @@ public class SdcReq { String resourceInstanceName = ""; if (globalProps != null) { List resourceVf = globalProps.getResourceVf(); - if (resourceVf != null && resourceVf.size() > 0) { + if (resourceVf != null && !resourceVf.isEmpty()) { resourceInstanceName = resourceVf.get(0); } if (globalProps.getService() != null) { @@ -258,35 +258,35 @@ public class SdcReq { // TODO : refact and regroup with very similar code List urlList = new ArrayList<>(); try { - Global globalProps = prop.getGlobal(); - if (globalProps != null) { - if (globalProps.getService() != null) { - String serviceInvariantUUID = globalProps.getService(); - execution.setVariable("serviceInvariantUUID", serviceInvariantUUID); - List resourceVfList = globalProps.getResourceVf(); - String serviceUUID = sdcCatalogServices.getServiceUuidFromServiceInvariantId(serviceInvariantUUID); - String sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(serviceUUID); - CldsSdcServiceDetail CldsSdcServiceDetail = sdcCatalogServices - .getCldsSdcServiceDetailFromJson(sdcServicesInformation); - if (CldsSdcServiceDetail != null && resourceVfList != null) { - List CldsSdcResourcesList = CldsSdcServiceDetail.getResources(); - if (CldsSdcResourcesList != null && CldsSdcResourcesList.size() > 0) { - for (CldsSdcResource CldsSdcResource : CldsSdcResourcesList) { - if (CldsSdcResource != null && CldsSdcResource.getResoucreType() != null - && CldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { - if (resourceVfList.contains(CldsSdcResource.getResourceInvariantUUID())) { - String normalizedResourceInstanceName = normalizeResourceInstanceName( - CldsSdcResource.getResourceInstanceName()); - String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" - + normalizedResourceInstanceName + "/artifacts"; - urlList.add(svcUrl); - } + Global globalProps = prop.getGlobal(); + if (globalProps != null) { + if (globalProps.getService() != null) { + String serviceInvariantUUID = globalProps.getService(); + execution.setVariable("serviceInvariantUUID", serviceInvariantUUID); + List resourceVfList = globalProps.getResourceVf(); + String serviceUUID = sdcCatalogServices.getServiceUuidFromServiceInvariantId(serviceInvariantUUID); + String sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(serviceUUID); + CldsSdcServiceDetail CldsSdcServiceDetail = sdcCatalogServices + .getCldsSdcServiceDetailFromJson(sdcServicesInformation); + if (CldsSdcServiceDetail != null && resourceVfList != null) { + List CldsSdcResourcesList = CldsSdcServiceDetail.getResources(); + if (CldsSdcResourcesList != null && !CldsSdcResourcesList.isEmpty()) { + for (CldsSdcResource CldsSdcResource : CldsSdcResourcesList) { + if (CldsSdcResource != null && CldsSdcResource.getResoucreType() != null + && CldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { + if (resourceVfList.contains(CldsSdcResource.getResourceInvariantUUID())) { + String normalizedResourceInstanceName = normalizeResourceInstanceName( + CldsSdcResource.getResourceInstanceName()); + String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" + + normalizedResourceInstanceName + "/artifacts"; + urlList.add(svcUrl); } } } } } } + } } catch (IOException e) { throw new SdcCommunicationException("Exception occurred during the SDC communication",e); } 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 d54976b84..3b69502ae 100644 --- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -23,6 +23,9 @@ package org.onap.clamp.clds.dao; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; @@ -51,9 +54,6 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.jdbc.core.simple.SimpleJdbcCall; import org.springframework.stereotype.Repository; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - /** * Data Access for CLDS Model tables. */ @@ -63,19 +63,19 @@ public class CldsDao { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private JdbcTemplate jdbcTemplateObject; - private SimpleJdbcCall procGetModel; - private SimpleJdbcCall procGetModelTemplate; - private SimpleJdbcCall procSetModel; - private SimpleJdbcCall procInsEvent; - private SimpleJdbcCall procUpdEvent; - private SimpleJdbcCall procSetTemplate; - private SimpleJdbcCall procGetTemplate; - private SimpleJdbcCall procDelAllModelInstances; - private SimpleJdbcCall procInsModelInstance; - private SimpleJdbcCall procDelModelInstance; + private JdbcTemplate jdbcTemplateObject; + private SimpleJdbcCall procGetModel; + private SimpleJdbcCall procGetModelTemplate; + private SimpleJdbcCall procSetModel; + private SimpleJdbcCall procInsEvent; + private SimpleJdbcCall procUpdEvent; + private SimpleJdbcCall procSetTemplate; + private SimpleJdbcCall procGetTemplate; + private SimpleJdbcCall procDelAllModelInstances; + private SimpleJdbcCall procInsModelInstance; + private SimpleJdbcCall procDelModelInstance; - private static final String healthcheck = "Select 1"; + private static final String HEALTHCHECK = "Select 1"; /** * Log message when instantiating @@ -386,7 +386,7 @@ public class CldsDao { cldsServiceData = (CldsServiceData) oip.readObject(); cldsServiceData.setAgeOfRecord(age); } catch (IOException | ClassNotFoundException e) { - logger.error("Error caught while retrieving cldsServiceData from database"); + logger.error("Error caught while retrieving cldsServiceData from database", e); } return cldsServiceData; } @@ -463,8 +463,7 @@ public class CldsDao { return template; } - public CldsServiceData getCldsServiceCache(String invariantUUID) - throws SQLException, IOException, ClassNotFoundException { + public CldsServiceData getCldsServiceCache(String invariantUUID) { CldsServiceData cldsServiceData = null; List cldsServiceDataList = new ArrayList<>(); try { @@ -478,7 +477,7 @@ public class CldsDao { return cldsServiceData; } - public void setCldsServiceCache(CldsDBServiceCache cldsDBServiceCache) throws SQLException, IOException { + public void setCldsServiceCache(CldsDBServiceCache cldsDBServiceCache) { if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null && cldsDBServiceCache.getServiceId() != null) { String invariantUuid = cldsDBServiceCache.getInvariantId(); @@ -501,7 +500,7 @@ public class CldsDao { } public void doHealthCheck() throws SQLException, IOException { - jdbcTemplateObject.execute(healthcheck); + jdbcTemplateObject.execute(HEALTHCHECK); } } diff --git a/src/main/java/org/onap/clamp/clds/exception/CldsConfigException.java b/src/main/java/org/onap/clamp/clds/exception/CldsConfigException.java new file mode 100644 index 000000000..3122fbaa4 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/exception/CldsConfigException.java @@ -0,0 +1,61 @@ +/*- + * ============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.exception; + +/** + * New exception to CldsUser errors. + * + */ +public class CldsConfigException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 5958873136187918505L; + + /** + * This constructor can be used to create a new CldsConfigException. + * + * @param message + * A string message detailing the problem + * @param e + * The exception sent by the code + */ + public CldsConfigException(String message, Throwable e) { + super(message, e); + } + + /** + * This constructor can be used to create a new CldsConfigException. Use + * this constructor only if you are creating a new exception stack, not if + * an exception was already raised by another code. + * + * @param message + * A string message detailing the problem + */ + public CldsConfigException(String message) { + super(message); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java b/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java index 4b2a2e30f..f9a760b77 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsDBServiceCache.java @@ -51,7 +51,7 @@ public class CldsDBServiceCache { this.serviceId = serviceId; } - public InputStream getCldsDataInstream() throws IOException { + public InputStream getCldsDataInstream() { return cldsDataInstream; } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java index 7fa741c8b..9c47f450c 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsSdcResource.java @@ -23,26 +23,26 @@ package org.onap.clamp.clds.model; -import java.math.BigDecimal; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.math.BigDecimal; +import java.util.List; + @JsonIgnoreProperties(ignoreUnknown = true) public class CldsSdcResource implements Comparable { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcResource.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private String resourceInstanceName; - private String resourceName; - private String resourceInvariantUuid; - private String resourceVersion; - private String resoucreType; - private String resourceUuid; - private List artifacts; + private String resourceInstanceName; + private String resourceName; + private String resourceInvariantUuid; + private String resourceVersion; + private String resoucreType; + private String resourceUuid; + private List artifacts; public String getResourceInstanceName() { return resourceInstanceName; @@ -117,6 +117,37 @@ public class CldsSdcResource implements Comparable { return rtn; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode()); + result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CldsSdcResource other = (CldsSdcResource) obj; + if (resourceInstanceName == null) { + if (other.resourceInstanceName != null) + return false; + } else if (!resourceInstanceName.equals(other.resourceInstanceName)) + return false; + if (resourceVersion == null) { + if (other.resourceVersion != null) + return false; + } else if (!resourceVersion.equals(other.resourceVersion)) + return false; + return true; + } + /** * Convert version String into a BigDecimal * @@ -124,7 +155,7 @@ public class CldsSdcResource implements Comparable { * @return */ private BigDecimal convertVersion(String versionText) { - BigDecimal rtn = new BigDecimal(0.0); + BigDecimal rtn = BigDecimal.valueOf(0.0); try { rtn = new BigDecimal(versionText); } catch (NumberFormatException nfe) { diff --git a/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java b/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java index 80fa787ee..f91e36a81 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsSdcResourceBasicInfo.java @@ -23,28 +23,29 @@ package org.onap.clamp.clds.model; -import java.math.BigDecimal; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.math.BigDecimal; + @JsonIgnoreProperties(ignoreUnknown = true) public class CldsSdcResourceBasicInfo implements Comparable { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcResourceBasicInfo.class); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(CldsSdcResourceBasicInfo.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private String uuid; - private String invariantUUID; - private String name; - private String version; - private String toscaModelURL; - private String category; - private String subCategory; - private String resourceType; - private String lifecycleState; - private String lastUpdaterUserId; + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String subCategory; + private String resourceType; + private String lifecycleState; + private String lastUpdaterUserId; @Override public int compareTo(CldsSdcResourceBasicInfo in) { @@ -62,6 +63,37 @@ public class CldsSdcResourceBasicInfo implements Comparable { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcServiceInfo.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcServiceInfo.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String uuid; - private String invariantUUID; - private String name; - private String version; - private String toscaModelURL; - private String category; - private String lifecycleState; - private String lastUpdaterUserId; - private String distributionStatus; + private String uuid; + private String invariantUUID; + private String name; + private String version; + private String toscaModelURL; + private String category; + private String lifecycleState; + private String lastUpdaterUserId; + private String distributionStatus; public String getUuid() { return uuid; @@ -135,6 +135,37 @@ public class CldsSdcServiceInfo implements Comparable { return rtn; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((version == null) ? 0 : version.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CldsSdcServiceInfo other = (CldsSdcServiceInfo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (version == null) { + if (other.version != null) + return false; + } else if (!version.equals(other.version)) + return false; + return true; + } + /** * Convert version String into a BigDecimal * @@ -147,7 +178,7 @@ public class CldsSdcServiceInfo implements Comparable { } catch (NumberFormatException nfe) { logger.warn("SDC version=" + versionText + " is not decimal for name=" + name); } - return new BigDecimal(0.0); + return BigDecimal.valueOf(0.0); } } diff --git a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java index dad7cb615..943532f02 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsServiceData.java @@ -23,6 +23,9 @@ package org.onap.clamp.clds.model; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -32,20 +35,17 @@ import javax.ws.rs.NotAuthorizedException; import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.service.CldsService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - public class CldsServiceData implements Serializable { - private static final long serialVersionUID = -9153372664377279423L; + private static final long serialVersionUID = -9153372664377279423L; - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsServiceData.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsServiceData.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String serviceInvariantUUID; - private String serviceUUID; - private Long ageOfRecord; - private List cldsVfs; + private String serviceInvariantUUID; + private String serviceUUID; + private Long ageOfRecord; + private List cldsVfs; public String getServiceInvariantUUID() { return serviceInvariantUUID; @@ -71,11 +71,11 @@ public class CldsServiceData implements Serializable { this.serviceUUID = serviceUUID; } - public CldsServiceData getCldsServiceCache(CldsDao cldsDao, String invariantServiceUUID) throws Exception { + public CldsServiceData getCldsServiceCache(CldsDao cldsDao, String invariantServiceUUID) { return cldsDao.getCldsServiceCache(invariantServiceUUID); } - public void setCldsServiceCache(CldsDao cldsDao, CldsDBServiceCache cldsDBServiceCache) throws Exception { + public void setCldsServiceCache(CldsDao cldsDao, CldsDBServiceCache cldsDBServiceCache) { cldsDao.setCldsServiceCache(cldsDBServiceCache); } @@ -106,7 +106,7 @@ public class CldsServiceData implements Serializable { filteredCldsVfs.add(vf); } } catch (NotAuthorizedException e) { - logger.debug("user not authorized for {}", vf.getVfInvariantResourceUUID()); + logger.error("user not authorized for {}" + vf.getVfInvariantResourceUUID(), e); // when not NotAuthorizedException - don't add to // filteredCldsVfs list } diff --git a/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java b/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java index 3b1f9682f..4b26bc05d 100644 --- a/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java +++ b/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java @@ -23,6 +23,11 @@ package org.onap.clamp.clds.model.refprop; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; @@ -36,33 +41,20 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.core.io.Resource; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - /** * Holds reference properties. */ public class RefProp { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(RefProp.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(RefProp.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); @Autowired - private ApplicationContext appContext; + private ApplicationContext appContext; - private Properties prop; + private Properties prop; @Value("${org.onap.clamp.config.files.cldsReference:'classpath:/clds/clds-reference.properties'}") - private String cldsReferenceValuesFile; - - /** - * Load reference properties via null constructor - * - * @throws IOException - */ - public RefProp() throws IOException { - } + private String cldsReferenceValuesFile; @PostConstruct public void loadConfig() throws IOException { 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 3d6d54a11..ff4cfda17 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -24,16 +24,12 @@ 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.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import java.io.IOException; import java.io.InputStream; -import java.sql.SQLException; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -54,16 +50,18 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; -import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import org.apache.commons.lang3.StringUtils; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.json.simple.parser.ParseException; import org.onap.clamp.clds.client.DcaeDispatcherServices; import org.onap.clamp.clds.client.DcaeInventoryServices; import org.onap.clamp.clds.client.SdcCatalogServices; 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.model.CldsDBServiceCache; import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.CldsHealthCheck; @@ -93,43 +91,40 @@ import io.swagger.annotations.ApiOperation; * Service to save and retrieve the CLDS model attributes. */ @AjscService -@Api(value = "/clds", description = "Clds operations") +@Api(value = "/clds") @Path("/clds") public class CldsService extends SecureServiceBase { @Autowired - private ApplicationContext appContext; + private ApplicationContext appContext; - private static final String RESOURCE_NAME = "clds-version.properties"; - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + 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 String cldsPermissionInstance; - private SecureServicePermission permissionReadCl; + private SecureServicePermission permissionReadCl; - private SecureServicePermission permissionUpdateCl; + private SecureServicePermission permissionUpdateCl; - private SecureServicePermission permissionReadTemplate; + private SecureServicePermission permissionReadTemplate; - private SecureServicePermission permissionUpdateTemplate; + private SecureServicePermission permissionUpdateTemplate; @PostConstruct private final void afterConstruction() { @@ -192,23 +187,14 @@ public class CldsService extends SecureServiceBase { // Get CLDS application version String cldsVersion = ""; Properties props = new Properties(); - InputStream resourceStream = null; - try { - ClassLoader loader = Thread.currentThread().getContextClassLoader(); - resourceStream = loader.getResourceAsStream(RESOURCE_NAME); + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + + try (InputStream resourceStream = loader.getResourceAsStream(RESOURCE_NAME)) { props.load(resourceStream); cldsVersion = props.getProperty("clds.version"); } catch (Exception ex) { - ex.printStackTrace(); - } finally { - if (resourceStream != null) { - try { - resourceStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } + logger.error("Exception caught during the clds.version reading", ex); } cldsInfo.setCldsVersion(cldsVersion); @@ -232,22 +218,12 @@ public class CldsService extends SecureServiceBase { cldsHealthCheck.setHealthCheckComponent("CLDS-APP"); cldsHealthCheck.setHealthCheckStatus("UP"); cldsHealthCheck.setDescription("OK"); - } catch (SQLException e) { - logger.error("CLAMP application DB Error" + e); - cldsHealthCheck.setHealthCheckComponent("CLDS-APP"); - cldsHealthCheck.setHealthCheckStatus("DOWN"); - cldsHealthCheck.setDescription("NOT-OK"); - // return Response.status(500).entity("Database down for CLDS - // application").build(); } catch (Exception e) { - logger.error("CLAMP application DB Error" + e); + logger.error("CLAMP application DB Error", e); cldsHealthCheck.setHealthCheckComponent("CLDS-APP"); cldsHealthCheck.setHealthCheckStatus("DOWN"); cldsHealthCheck.setDescription("NOT-OK"); - // return Response.status(500).entity("Database down for CLDS - // application").build(); } - return cldsHealthCheck; } @@ -360,13 +336,12 @@ public class CldsService extends SecureServiceBase { * * @param modelName * @return clds model - clds model for the given model name - * @throws NotAuthorizedException */ @ApiOperation(value = "Retrieves a CLDS model by name from the database", notes = "", response = String.class) @GET @Path("/model/{modelName}") @Produces(MediaType.APPLICATION_JSON) - public CldsModel getModel(@PathParam("modelName") String modelName) throws NotAuthorizedException { + public CldsModel getModel(@PathParam("modelName") String modelName) { Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: GET model", getPrincipalName()); isAuthorized(permissionReadCl); @@ -376,7 +351,7 @@ public class CldsService extends SecureServiceBase { cldsModel.setUserAuthorizedToUpdate(isAuthorizedNoException(permissionUpdateCl)); /** - * Checking condtion whether our CLDS model can call INventory Method + * Checking condition whether our CLDS model can call INventory Method */ if (cldsModel.canInventoryCall()) { try { @@ -401,16 +376,13 @@ public class CldsService extends SecureServiceBase { * REST service that saves a CLDS model by name in the database. * * @param modelName - * @throws TransformerException - * @throws TransformerConfigurationException */ @ApiOperation(value = "Saves a CLDS model by name in the database", notes = "", response = String.class) @PUT @Path("/model/{modelName}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public CldsModel putModel(@PathParam("modelName") String modelName, CldsModel cldsModel) - throws TransformerException { + public CldsModel putModel(@PathParam("modelName") String modelName, CldsModel cldsModel) { Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: PUT model", getPrincipalName()); isAuthorized(permissionUpdateCl); @@ -468,9 +440,8 @@ public class CldsService extends SecureServiceBase { * @param test * @param model * @return - * @throws Exception - * @throws JsonProcessingException - * @throws NotAuthorizedException + * @throws TransformerException + * @throws ParseException */ @ApiOperation(value = "Saves and processes an action for a CLDS model by name", notes = "", response = String.class) @PUT @@ -479,7 +450,7 @@ public class CldsService extends SecureServiceBase { @Produces(MediaType.APPLICATION_JSON) public CldsModel putModelAndProcessAction(@PathParam("action") String action, @PathParam("modelName") String modelName, @QueryParam("test") String test, CldsModel model) - throws Exception { + throws TransformerException, ParseException { Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: Process model action", getPrincipalName()); String actionCd = action.toUpperCase(); @@ -656,17 +627,19 @@ public class CldsService extends SecureServiceBase { @GET @Path("/sdc/services") @Produces(MediaType.APPLICATION_JSON) - public String getSdcServices() throws Exception { + public String getSdcServices() { Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: GET sdc services", getPrincipalName()); String retStr; + + String responseStr = sdcCatalogServices.getSdcServicesInformation(null); try { - String responseStr = sdcCatalogServices.getSdcServicesInformation(null); retStr = createUiServiceFormatJson(responseStr); - } catch (Exception e) { - logger.info("{} {}", e.getClass().getName(), e.getMessage()); - throw e; + } catch (IOException e) { + logger.error("IOException during SDC communication", e); + throw new SdcCommunicationException("IOException during SDC communication", e); } + logger.info("value of sdcServices : {}", retStr); // audit log LoggingUtils.setTimeContext(startTime, new Date()); @@ -677,14 +650,16 @@ public class CldsService extends SecureServiceBase { /** * REST service that retrieves total properties required by UI + * + * @throws IOException + * In case of issues * - * @throws Exception */ @ApiOperation(value = "Retrieves total properties required by UI", notes = "", response = String.class) @GET @Path("/properties") @Produces(MediaType.APPLICATION_JSON) - public String getSdcProperties() throws Exception { + public String getSdcProperties() throws IOException { return createPropertiesObjectByUUID(getGlobalCldsString(), "{}"); } @@ -749,8 +724,8 @@ public class CldsService extends SecureServiceBase { * @throws NotAuthorizedException * @return */ - public boolean isAuthorizedForVf(String vfInvariantUuid) throws NotAuthorizedException { - if (cldsPermissionTypeFilterVf != null && cldsPermissionTypeFilterVf.length() > 0) { + public boolean isAuthorizedForVf(String vfInvariantUuid) { + if (cldsPermissionTypeFilterVf != null && !cldsPermissionTypeFilterVf.isEmpty()) { SecureServicePermission permission = SecureServicePermission.create(cldsPermissionTypeFilterVf, cldsPermissionInstance, vfInvariantUuid); return isAuthorized(permission); @@ -769,7 +744,7 @@ public class CldsService extends SecureServiceBase { * @param model * @return */ - private boolean isAuthorizedForVf(CldsModel model) throws NotAuthorizedException { + private boolean isAuthorizedForVf(CldsModel model) { String vf = ModelProperties.getVf(model); if (vf == null || vf.length() == 0) { logger.info("VF not found in model"); @@ -789,7 +764,7 @@ public class CldsService extends SecureServiceBase { ObjectNode invariantIdServiceNode = objectMapper.createObjectNode(); ObjectNode serviceNode = objectMapper.createObjectNode(); logger.info("value of cldsserviceiNfolist: {}", rawList); - if (rawList != null && rawList.size() > 0) { + if (rawList != null && !rawList.isEmpty()) { List cldsSdcServiceInfoList = sdcCatalogServices.removeDuplicateServices(rawList); for (CldsSdcServiceInfo currCldsSdcServiceInfo : cldsSdcServiceInfoList) { @@ -852,40 +827,55 @@ public class CldsService extends SecureServiceBase { } private void createVfObjectNode(ObjectNode vfObjectNode2, ObjectMapper mapper, - List rawCldsSdcResourceList) throws IOException { + List rawCldsSdcResourceList) { ObjectNode vfNode = mapper.createObjectNode(); vfNode.put("", ""); - // To remove repeated resource instance name from resourceInstanceList + // To remove repeated resource instance name from + // resourceInstanceList List cldsSdcResourceList = sdcCatalogServices .removeDuplicateSdcResourceInstances(rawCldsSdcResourceList); /** * Creating vf resource node using cldsSdcResource Object */ - if (cldsSdcResourceList != null && cldsSdcResourceList.size() > 0) { + if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) { for (CldsSdcResource cldsSdcResource : cldsSdcResourceList) { - if (cldsSdcResource != null && cldsSdcResource.getResoucreType() != null - && cldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { + if (cldsSdcResource != null && "VF".equalsIgnoreCase(cldsSdcResource.getResoucreType())) { vfNode.put(cldsSdcResource.getResourceUUID(), cldsSdcResource.getResourceName()); } } } vfObjectNode2.putPOJO("vf", vfNode); - String locationStringValue = refProp.getStringValue("ui.location.default"); - String alarmStringValue = refProp.getStringValue("ui.alarm.default"); /** * creating location json object using properties file value */ - ObjectNode locationJsonNode = (ObjectNode) mapper.readValue(locationStringValue, JsonNode.class); + ObjectNode locationJsonNode; + try { + locationJsonNode = (ObjectNode) mapper.readValue(refProp.getStringValue("ui.location.default"), + JsonNode.class); + } catch (IOException e) { + logger.error("Unable to load ui.location.default JSON in clds-references.properties properly", e); + throw new CldsConfigException( + "Unable to load ui.location.default JSON in clds-references.properties properly", e); + } vfObjectNode2.putPOJO("location", locationJsonNode); /** * creating alarm json object using properties file value */ + String alarmStringValue = refProp.getStringValue("ui.alarm.default"); logger.info("value of alarm: {}", alarmStringValue); - ObjectNode alarmStringJsonNode = (ObjectNode) mapper.readValue(alarmStringValue, JsonNode.class); + ObjectNode alarmStringJsonNode; + try { + alarmStringJsonNode = (ObjectNode) mapper.readValue(alarmStringValue, JsonNode.class); + } catch (IOException e) { + logger.error("Unable to ui.alarm.default JSON in clds-references.properties properly", e); + throw new CldsConfigException("Unable to load ui.alarm.default JSON in clds-references.properties properly", + e); + } vfObjectNode2.putPOJO("alarmCondition", alarmStringJsonNode); + } private ObjectNode createByVFCObjectNode(ObjectMapper mapper, List cldsSdcResourceList) { @@ -895,10 +885,9 @@ public class CldsService extends SecureServiceBase { vfCObjectNode.putPOJO("vfC", emptyObjectNode); ObjectNode subVfCObjectNode = mapper.createObjectNode(); subVfCObjectNode.putPOJO("vfc", emptyObjectNode); - if (cldsSdcResourceList != null && cldsSdcResourceList.size() > 0) { + if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) { for (CldsSdcResource cldsSdcResource : cldsSdcResourceList) { - if (cldsSdcResource != null && cldsSdcResource.getResoucreType() != null - && cldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { + if (cldsSdcResource != null && "VF".equalsIgnoreCase(cldsSdcResource.getResoucreType())) { vfCObjectNode.putPOJO(cldsSdcResource.getResourceUUID(), subVfCObjectNode); } } @@ -920,14 +909,14 @@ public class CldsService extends SecureServiceBase { model.getTypeId()); String operationStatus = "processing"; long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10); - while (operationStatus.equalsIgnoreCase("processing")) { + while ("processing".equalsIgnoreCase(operationStatus)) { // Break the loop if waiting for more than 10 mins if (waitingTime < System.nanoTime()) { break; } operationStatus = dcaeDispatcherServices.getOperationStatus(createNewDeploymentStatusUrl); } - if (operationStatus.equalsIgnoreCase("succeeded")) { + if ("succeeded".equalsIgnoreCase(operationStatus)) { String artifactName = model.getControlName(); if (artifactName != null) { artifactName = artifactName + ".yml"; @@ -958,20 +947,20 @@ public class CldsService extends SecureServiceBase { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public CldsModel unDeployModel(@PathParam("action") String action, @PathParam("modelName") String modelName, - @QueryParam("test") String test, CldsModel model) throws Exception { + @QueryParam("test") String test, CldsModel model) throws IOException { Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: Undeploy model", getPrincipalName()); String operationStatusUndeployUrl = dcaeDispatcherServices.deleteExistingDeployment(model.getDeploymentId(), model.getTypeId()); String operationStatus = "processing"; long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10); - while (operationStatus.equalsIgnoreCase("processing")) { + while ("processing".equalsIgnoreCase(operationStatus)) { if (waitingTime < System.nanoTime()) { break; } operationStatus = dcaeDispatcherServices.getOperationStatus(operationStatusUndeployUrl); } - if (operationStatus.equalsIgnoreCase("succeeded")) { + if ("succeeded".equalsIgnoreCase(operationStatus)) { String artifactName = model.getControlName(); if (artifactName != null) { artifactName = artifactName + ".yml"; @@ -997,11 +986,16 @@ public class CldsService extends SecureServiceBase { return model; } - private String getGlobalCldsString() throws Exception { - if (null == globalCldsProperties) { - globalCldsProperties = new Properties(); - globalCldsProperties.load(appContext.getResource(globalClds).getInputStream()); + private String getGlobalCldsString() { + try { + if (null == globalCldsProperties) { + globalCldsProperties = new Properties(); + globalCldsProperties.load(appContext.getResource(globalClds).getInputStream()); + } + return (String) globalCldsProperties.get("globalCldsProps"); + } catch (IOException e) { + logger.error("Unable to load the globalClds due to an exception", e); + throw new CldsConfigException("Unable to load the globalClds due to an exception", e); } - return (String) globalCldsProperties.get("globalCldsProps"); } } 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 07b9bb98f..87f9c0c4f 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java @@ -23,6 +23,14 @@ package org.onap.clamp.clds.service; +import com.att.ajsc.common.AjscService; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + import java.io.IOException; import java.util.Date; import java.util.HashMap; @@ -51,16 +59,6 @@ import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import com.att.ajsc.common.AjscService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - /** * Service to save and retrieve the CLDS model attributes. */ @@ -68,12 +66,9 @@ import com.fasterxml.jackson.databind.node.ObjectNode; @Path("/cldsTempate") public class CldsTemplateService extends SecureServiceBase { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsTemplateService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private static final String collectorKey = "Collector"; - private static final String stringMatchKey = "StringMatch"; - private static final String policyKey = "Policy"; + private static final String COLLECTOR_KEY = "Collector"; + private static final String STRING_MATCH_KEY = "StringMatch"; + private static final String POLICY_KEY = "Policy"; @Value("${CLDS_PERMISSION_TYPE_TEMPLATE:permission-type-template}") private String cldsPermissionTypeTemplate; @@ -309,7 +304,7 @@ public class CldsTemplateService extends SecureServiceBase { logger.info("value of elementIds:" + bpmnElementIds); logger.info("value of prop text:" + propText); Map bpmnIoIdsMap = new HashMap<>(); - if (bpmnElementIds != null && bpmnElementIds.size() > 0) { + if (bpmnElementIds != null && !bpmnElementIds.isEmpty()) { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode root = objectMapper.readValue(propText, ObjectNode.class); Iterator> entryItr = root.fields(); @@ -326,12 +321,12 @@ public class CldsTemplateService extends SecureServiceBase { ObjectNode node = (ObjectNode) anArrayNode; String valueNode = node.get("value").asText(); logger.info("value of node:" + valueNode); - if (keyPropName.startsWith(collectorKey)) { - valueNode = collectorKey + "_" + valueNode; - } else if (keyPropName.startsWith(stringMatchKey)) { - valueNode = stringMatchKey + "_" + valueNode; - } else if (keyPropName.startsWith(policyKey)) { - valueNode = policyKey + "_" + valueNode; + if (keyPropName.startsWith(COLLECTOR_KEY)) { + valueNode = COLLECTOR_KEY + "_" + valueNode; + } else if (keyPropName.startsWith(STRING_MATCH_KEY)) { + valueNode = STRING_MATCH_KEY + "_" + valueNode; + } else if (keyPropName.startsWith(POLICY_KEY)) { + valueNode = POLICY_KEY + "_" + valueNode; } bpmnIoIdsMap.put(keyPropName, valueNode); } diff --git a/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java b/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java deleted file mode 100644 index 2c152c5a1..000000000 --- a/src/main/java/org/onap/clamp/clds/transform/TransformUtil.java +++ /dev/null @@ -1,64 +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.transform; - -import java.io.IOException; -import java.io.InputStream; - -/** - * Utility methods supporting transforms. - */ -public class TransformUtil { - - /** - * Return resource as a Stream. - * - * @param name - * @return resource - resource as stream - */ - public static InputStream getResourceAsStream(String name) { - InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); - if (is == null) { - throw new IllegalArgumentException("Unable to find resource: " + name); - } - return is; - } - - /** - * Return resource as a Stream. - * - * @param name - * @throws IOException - */ - public static String getResourceAsString(String name) throws IOException { - InputStream is = getResourceAsStream(name); - java.util.Scanner scanner = new java.util.Scanner(is); - java.util.Scanner delimitedScanner = scanner.useDelimiter("\\A"); - String text = delimitedScanner.hasNext() ? delimitedScanner.next() : ""; - delimitedScanner.close(); - scanner.close(); - is.close(); - return text; - } -} diff --git a/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java b/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java new file mode 100644 index 000000000..0aaa09ac2 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java @@ -0,0 +1,71 @@ +/*- + * ============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.util; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Utility methods supporting transforms. + */ +public class ResourceFileUtil { + + /** + * Disable the ResourceFileUtil constructor. + */ + private ResourceFileUtil() { + + } + + /** + * Return resource as a Stream. + * + * @param name + * @return resource - resource as stream + */ + public static InputStream getResourceAsStream(String name) { + InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(name); + if (is == null) { + throw new IllegalArgumentException("Unable to find resource: " + name); + } + return is; + } + + /** + * Return resource as a Stream. + * + * @param name + * @throws IOException + */ + public static String getResourceAsString(String name) throws IOException { + InputStream is = getResourceAsStream(name); + java.util.Scanner scanner = new java.util.Scanner(is); + java.util.Scanner delimitedScanner = scanner.useDelimiter("\\A"); + String text = delimitedScanner.hasNext() ? delimitedScanner.next() : ""; + delimitedScanner.close(); + scanner.close(); + is.close(); + return text; + } +} diff --git a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java b/src/test/java/org/onap/clamp/clds/it/DcaeIT.java index 6cdcf98d6..fc13270c3 100644 --- a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java +++ b/src/test/java/org/onap/clamp/clds/it/DcaeIT.java @@ -30,8 +30,7 @@ import org.onap.clamp.clds.AbstractIT; import org.onap.clamp.clds.client.req.DcaeReq; import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.transform.TransformUtil; - +import org.onap.clamp.clds.util.ResourceFileUtil; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.junit4.SpringRunner; @@ -45,8 +44,8 @@ public class DcaeIT extends AbstractIT { @Test public void testDcaeReq() throws Exception { - String modelProp = TransformUtil.getResourceAsString("example/modelProp.json"); - String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnProp.json"); + String modelProp = ResourceFileUtil.getResourceAsString("example/modelProp.json"); + String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnProp.json"); String modelName = "example-model"; String controlName = "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756"; diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java index c0487e915..19fad4805 100644 --- a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java +++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java @@ -43,7 +43,7 @@ import org.onap.clamp.clds.model.prop.Policy; import org.onap.clamp.clds.model.prop.PolicyChain; import org.onap.clamp.clds.model.prop.StringMatch; import org.onap.clamp.clds.model.prop.Tca; -import org.onap.clamp.clds.transform.TransformUtil; +import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.policy.api.AttributeType; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.boot.test.context.SpringBootTest; @@ -62,14 +62,13 @@ public class PolicyClientIT extends AbstractIT { String modelName; String controlName; - /** - * Initialize Test. - */ + * Initialize Test. + */ @Before public void setUp() throws IOException { - modelProp = TransformUtil.getResourceAsString("example/modelProp.json"); - modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnProp.json"); + modelProp = ResourceFileUtil.getResourceAsString("example/modelProp.json"); + modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnProp.json"); modelName = "example-model06"; controlName = "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf"; } @@ -81,11 +80,11 @@ public class PolicyClientIT extends AbstractIT { String stringMatchPolicyRequestUuid = UUID.randomUUID().toString(); String policyJson = StringMatchPolicyReq.format(refProp, prop); - String correctValue = TransformUtil.getResourceAsString("expected/stringmatch.json"); + String correctValue = ResourceFileUtil.getResourceAsString("expected/stringmatch.json"); JSONAssert.assertEquals(policyJson, correctValue, true); String responseMessage = ""; try { - responseMessage = policyClient.sendMicroService(policyJson, prop, stringMatchPolicyRequestUuid); + responseMessage = policyClient.sendMicroServiceInJson(policyJson, prop, stringMatchPolicyRequestUuid); } catch (Exception e) { assertTrue(e.getMessage().contains("Policy send failed: PE500 ")); } @@ -102,7 +101,7 @@ public class PolicyClientIT extends AbstractIT { Map> attributes = OperationalPolicyReq.formatAttributes(refProp, prop, policy.getId(), policyChain); - String responseMessage = policyClient.sendBrms(attributes, prop, operationalPolicyRequestUuid); + String responseMessage = policyClient.sendBrmsPolicy(attributes, prop, operationalPolicyRequestUuid); System.out.println(responseMessage); } } @@ -110,15 +109,15 @@ public class PolicyClientIT extends AbstractIT { private void createUpdateTcaPolicy(String actionCd) throws Exception { ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp); - Tca tca = prop.getTca(); + Tca tca = prop.getType(Tca.class); if (tca.isFound()) { String tcaPolicyRequestUuid = UUID.randomUUID().toString(); String policyJson = TcaMPolicyReq.formatTca(refProp, prop); - String correctValue = TransformUtil.getResourceAsString("expected/tca.json"); + String correctValue = ResourceFileUtil.getResourceAsString("expected/tca.json"); JSONAssert.assertEquals(policyJson, correctValue, true); String responseMessage = ""; try { - responseMessage = policyClient.sendMicroService(policyJson, prop, tcaPolicyRequestUuid); + responseMessage = policyClient.sendMicroServiceInJson(policyJson, prop, tcaPolicyRequestUuid); } catch (Exception e) { assertTrue(e.getMessage().contains("Policy send failed: PE500 ")); } @@ -159,7 +158,7 @@ public class PolicyClientIT extends AbstractIT { private void deleteTcaPolicy(String actionCd) throws Exception { ModelProperties prop = new ModelProperties(modelName, controlName, actionCd, false, modelBpmnProp, modelProp); - Tca tca = prop.getTca(); + Tca tca = prop.getType(Tca.class); if (tca.isFound()) { prop.setCurrentModelElementId(tca.getId()); String responseMessage = ""; diff --git a/src/test/java/org/onap/clamp/clds/it/SdcIT.java b/src/test/java/org/onap/clamp/clds/it/SdcIT.java index 62932f82a..da9e5af76 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcIT.java @@ -33,8 +33,7 @@ import org.onap.clamp.clds.client.req.SdcReq; import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; -import org.onap.clamp.clds.transform.TransformUtil; - +import org.onap.clamp.clds.util.ResourceFileUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -58,11 +57,11 @@ public class SdcIT extends AbstractIT { @Test public void testBlueprint() throws Exception { - String modelProp = TransformUtil.getResourceAsString("example/modelProp.json"); - String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnProp.json"); + String modelProp = ResourceFileUtil.getResourceAsString("example/modelProp.json"); + String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnProp.json"); String modelName = "example-model06"; String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; - String docText = TransformUtil.getResourceAsString("example/templateProp.json"); + String docText = ResourceFileUtil.getResourceAsString("example/templateProp.json"); ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, modelProp); String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); @@ -73,11 +72,11 @@ public class SdcIT extends AbstractIT { @Test public void testTcaBlueprint() throws Exception { - String modelProp = TransformUtil.getResourceAsString("example/modelPropForPolicy.json"); - String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnPropForPolicy.json"); + String modelProp = ResourceFileUtil.getResourceAsString("example/modelPropForPolicy.json"); + String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnPropForPolicy.json"); String modelName = "example-model06"; String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; - String docText = TransformUtil.getResourceAsString("example/templatePropForTca.json"); + String docText = ResourceFileUtil.getResourceAsString("example/templatePropForTca.json"); ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, modelProp); String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java index 9c9cb4a73..89eaf51cd 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java @@ -27,7 +27,7 @@ import java.io.IOException; import org.junit.Assert; import org.junit.Test; -import org.onap.clamp.clds.transform.TransformUtil; +import org.onap.clamp.clds.util.ResourceFileUtil; public class CustomModelElementTest { @@ -38,8 +38,8 @@ public class CustomModelElementTest { public void testNewElement() { try { - String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnProp.json"); - String modelProp = TransformUtil.getResourceAsString("example/modelProp.json"); + String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnProp.json"); + String modelProp = ResourceFileUtil.getResourceAsString("example/modelProp.json"); String modName = "example-model-name"; String controlName = "example-control-name"; diff --git a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java index c1c4a8c39..22b3ba0cb 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java @@ -29,8 +29,7 @@ import java.io.IOException; import org.junit.Assert; import org.junit.Test; - -import org.onap.clamp.clds.transform.TransformUtil; +import org.onap.clamp.clds.util.ResourceFileUtil; /** @@ -40,8 +39,8 @@ public class ModelPropertiesTest { @Test public void testJsonParse() throws IOException { - String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnProp.json"); - String modelProp = TransformUtil.getResourceAsString("example/modelProp.json"); + String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnProp.json"); + String modelProp = ResourceFileUtil.getResourceAsString("example/modelProp.json"); String modName = "example-model-name"; String controlName = "example-control-name"; @@ -68,10 +67,10 @@ public class ModelPropertiesTest { @Test public void testPolicy() throws IOException { - String modelBpmnProp = TransformUtil.getResourceAsString("example/modelBpmnPropForPolicy.json"); + String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnPropForPolicy.json"); System.out.println(modelBpmnProp); - String modelProp = TransformUtil.getResourceAsString("example/modelPropForPolicy.json"); + String modelProp = ResourceFileUtil.getResourceAsString("example/modelPropForPolicy.json"); System.out.println(modelProp); ModelProperties prop = new ModelProperties("example-model-name", "example-control-name", null, true, modelBpmnProp, modelProp); -- cgit 1.2.3-korg From 02847bc3889fe3c3a419612ea7a94eca8794bdc6 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 8 Sep 2017 17:48:10 +0200 Subject: Rework some sonar critical and major bugs Class renamed to AbstractModelELement, exceptions reworked and IT tests as well Change-Id: Ief2b09b0e36776519338834e2af61aa6e638ee91 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/client/HolmesPolicyDelegate.java | 2 +- .../clds/client/HolmesPolicyDeleteDelegate.java | 2 +- .../org/onap/clamp/clds/client/PolicyClient.java | 157 ++++------ .../onap/clamp/clds/client/SdcCatalogServices.java | 344 ++++++++++++--------- .../clds/client/req/OperationalPolicyReq.java | 4 +- .../org/onap/clamp/clds/client/req/SdcReq.java | 34 +- .../onap/clamp/clds/config/CldsConfiguration.java | 9 +- .../clamp/clds/config/CldsUserJsonDecoder.java | 8 +- src/main/java/org/onap/clamp/clds/dao/CldsDao.java | 23 +- .../exception/policy/PolicyClientException.java | 61 ++++ .../clds/model/prop/AbstractModelElement.java | 280 +++++++++++++++++ .../org/onap/clamp/clds/model/prop/Collector.java | 2 +- .../org/onap/clamp/clds/model/prop/Global.java | 10 +- .../org/onap/clamp/clds/model/prop/Holmes.java | 2 +- .../clamp/clds/model/prop/ModelProperties.java | 14 +- .../org/onap/clamp/clds/model/prop/Policy.java | 2 +- .../onap/clamp/clds/model/prop/PolicyChain.java | 6 +- .../org/onap/clamp/clds/model/prop/PolicyItem.java | 12 +- .../onap/clamp/clds/model/prop/ResourceGroup.java | 4 +- .../clds/model/prop/ServiceConfiguration.java | 16 +- .../onap/clamp/clds/model/prop/StringMatch.java | 2 +- .../java/org/onap/clamp/clds/model/prop/Tca.java | 2 +- .../org/onap/clamp/clds/model/prop/TcaItem.java | 20 +- .../org/onap/clamp/clds/service/CldsService.java | 10 +- .../java/org/onap/clamp/clds/service/CldsUser.java | 2 +- .../org/onap/clamp/clds/client/req/SdcReqTest.java | 4 +- .../org/onap/clamp/clds/it/PolicyClientIT.java | 2 +- .../onap/clamp/clds/it/SdcCatalogServicesIT.java | 14 +- .../clamp/clds/model/prop/CustomModelElement.java | 2 +- 29 files changed, 699 insertions(+), 351 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/exception/policy/PolicyClientException.java create mode 100644 src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java index db7b5241b..c42a22c61 100644 --- a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDelegate.java @@ -61,7 +61,7 @@ public class HolmesPolicyDelegate implements JavaDelegate { ModelProperties prop = ModelProperties.create(execution); Holmes holmes = prop.getType(Holmes.class); if (holmes.isFound()) { - String responseMessage = policyClient.sendMicroServiceInJson(holmes.getCorrelationLogic(), prop, + String responseMessage = policyClient.sendBasePolicyInOther(holmes.getCorrelationLogic(), prop, holmesPolicyRequestUuid); if (responseMessage != null) { execution.setVariable("holmesPolicyResponseMessage", responseMessage.getBytes()); diff --git a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java index 46b33ffea..c3c91fa88 100644 --- a/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/HolmesPolicyDeleteDelegate.java @@ -55,7 +55,7 @@ public class HolmesPolicyDeleteDelegate implements JavaDelegate { if (holmes.isFound()) { prop.setCurrentModelElementId(holmes.getId()); - policyClient.deleteMicrosService(prop); + policyClient.deleteBasePolicy(prop); } } diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java index 2b49a8ff5..2bd680af2 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java @@ -31,13 +31,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.UUID; import javax.ws.rs.BadRequestException; +import org.onap.clamp.clds.exception.policy.PolicyClientException; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.refprop.RefProp; import org.onap.clamp.clds.util.LoggingUtils; @@ -47,6 +47,7 @@ import org.onap.policy.api.DeletePolicyCondition; import org.onap.policy.api.DeletePolicyParameters; import org.onap.policy.api.PolicyChangeResponse; import org.onap.policy.api.PolicyConfig; +import org.onap.policy.api.PolicyConfigException; import org.onap.policy.api.PolicyConfigType; import org.onap.policy.api.PolicyEngine; import org.onap.policy.api.PolicyEngineException; @@ -66,11 +67,11 @@ public class PolicyClient { protected static final String POLICY_PREFIX_BRMS_PARAM = "Config_BRMS_Param_"; protected static final String POLICY_PREFIX_MICROSERVICE = "Config_MS_"; - protected static final String LOG_POLICY_PREFIX = "Response is "; + protected static final String LOG_POLICY_PREFIX = "Response is "; protected static final EELFLogger logger = EELFManager.getInstance() .getLogger(PolicyClient.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}") protected String cldsPolicyConfigFile; @@ -91,14 +92,10 @@ public class PolicyClient { * @param policyRequestUuid * PolicyRequest UUID * @return The response message of policy - * @throws IOException - * In case of issues with the Stream - * @throws PolicyEngineException - * In case of issues with the PolicyEngine class * */ public String sendBrmsPolicy(Map> attributes, ModelProperties prop, - String policyRequestUuid) throws PolicyEngineException, IOException { + String policyRequestUuid) { PolicyParameters policyParameters = new PolicyParameters(); @@ -136,13 +133,8 @@ public class PolicyClient { * @param policyRequestUuid * The policy Request UUID * @return The response message of policy - * @throws PolicyEngineException - * In case of issues with the policy engine class creation - * @throws IOException - * In case of issue with the Stream */ - public String sendMicroServiceInJson(String policyJson, ModelProperties prop, String policyRequestUuid) - throws IOException, PolicyEngineException { + public String sendMicroServiceInJson(String policyJson, ModelProperties prop, String policyRequestUuid) { PolicyParameters policyParameters = new PolicyParameters(); @@ -177,14 +169,9 @@ public class PolicyClient { * The ModelProperties * @param policyRequestUuid * The policy request UUID - * @return - * @throws IOException - * In case of issues with the policy engine class creation - * @throws PolicyEngineException - * In case of issue with the Stream + * @return The answer from policy call */ - public String sendBasePolicyInOther(String configBody, ModelProperties prop, String policyRequestUuid) - throws IOException, PolicyEngineException { + public String sendBasePolicyInOther(String configBody, ModelProperties prop, String policyRequestUuid) { PolicyParameters policyParameters = new PolicyParameters(); @@ -216,22 +203,15 @@ public class PolicyClient { * The PolicyParameters * @param prop * The ModelProperties - * @return THe response message of Policy - * @throws IOException - * In case of issues with the Stream - * @throws PolicyEngineException - * In case of issue when creating PolicyEngine class + * @return The response message of Policy + * @throws Exception */ - protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyNamePrefix) - throws IOException, PolicyEngineException { + protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyNamePrefix) { // Verify whether it is triggered by Validation Test button from UI if (prop.isTest()) { return "send not executed for test action"; } - PolicyEngine policyEngine = new PolicyEngine( - appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); - // API method to create or update Policy. PolicyChangeResponse response = null; String responseMessage = ""; @@ -241,22 +221,23 @@ public class PolicyClient { if (versions.isEmpty()) { LoggingUtils.setTargetContext("Policy", "createPolicy"); logger.info("Attempting to create policy for action=" + prop.getActionCd()); - response = policyEngine.createPolicy(policyParameters); + response = getPolicyEngine().createPolicy(policyParameters); responseMessage = response.getResponseMessage(); } else { LoggingUtils.setTargetContext("Policy", "updatePolicy"); logger.info("Attempting to update policy for action=" + prop.getActionCd()); - response = policyEngine.updatePolicy(policyParameters); + response = getPolicyEngine().updatePolicy(policyParameters); responseMessage = response.getResponseMessage(); } } catch (Exception e) { logger.error("Exception occurred during policy communication", e); + throw new PolicyClientException("Exception while communicating with Policy", e); } logger.info(LOG_POLICY_PREFIX + responseMessage); LoggingUtils.setTimeContext(startTime, new Date()); - if (response != null && response.getResponseCode() == 200) { + if (response.getResponseCode() == 200) { logger.info("Policy send successful"); metricsLogger.info("Policy send success"); } else { @@ -276,12 +257,8 @@ public class PolicyClient { * @param prop * The ModelProperties * @return The response message of policy - * @throws IOException - * In case of issues with the stream - * @throws PolicyEngineException - * In case of issues with the PolicyEngine creation */ - protected String push(String policyType, ModelProperties prop) throws PolicyEngineException, IOException { + protected String push(String policyType, ModelProperties prop) { // Verify whether it is triggered by Validation Test button from UI if (prop.isTest()) { return "push not executed for test action"; @@ -301,15 +278,12 @@ public class PolicyClient { pushPolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group")); pushPolicyParameters.setRequestID(null); - PolicyEngine policyEngine = new PolicyEngine( - appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); - // API method to create or update Policy. PolicyChangeResponse response = null; String responseMessage = ""; try { logger.info("Attempting to push policy..."); - response = policyEngine.pushPolicy(pushPolicyParameters); + response = getPolicyEngine().pushPolicy(pushPolicyParameters); responseMessage = response.getResponseMessage(); } catch (Exception e) { logger.error("Exception occurred during policy communication", e); @@ -335,13 +309,10 @@ public class PolicyClient { * @param prop * The ModelProperties * @return The response message from policy - * @throws IOException - * In case of issues with the stream - * @throws PolicyEngineException - * In case of issues with the PolicyEngine creation + * @throws PolicyConfigException + * In case of issues with policy engine */ - protected List getVersions(String policyNamePrefix, ModelProperties prop) - throws PolicyEngineException, IOException { + protected List getVersions(String policyNamePrefix, ModelProperties prop) throws PolicyConfigException { ArrayList versions = new ArrayList<>(); ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); @@ -356,46 +327,42 @@ public class PolicyClient { logger.info("policyName=" + policyName); configRequestParameters.setPolicyName(policyName); - PolicyEngine policyEngine = new PolicyEngine( - appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); - - try { - Collection response = policyEngine.getConfig(configRequestParameters); - Iterator itrResp = response.iterator(); - - while (itrResp.hasNext()) { - PolicyConfig policyConfig = itrResp.next(); - try { - Integer version = new Integer(policyConfig.getPolicyVersion()); - versions.add(version); - } catch (Exception e) { - // just print warning - if n;o policies, version may be null - logger.warn("Failed to parse due to an exception policyConfig.getPolicyVersion()=" - + policyConfig.getPolicyVersion(), e); - } - } - Collections.sort(versions); - logger.info("Policy versions.size()=" + versions.size()); - } catch (Exception e) { - // just print warning - if no policy version found - logger.warn("warning: policy not found...policy name - " + policyName, e); + Collection response = getPolicyEngine().getConfig(configRequestParameters); + for (PolicyConfig policyConfig : response) { + Integer version = Integer.valueOf(policyConfig.getPolicyVersion()); + versions.add(version); } + Collections.sort(versions); + logger.info("Policy versions.size()=" + versions.size()); return versions; } + /** + * This method create a new policy engine. + * + * @return A new policy engine + */ + private PolicyEngine getPolicyEngine() { + PolicyEngine policyEngine; + try { + policyEngine = new PolicyEngine(appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); + } catch (IOException e1) { + throw new PolicyClientException("Exception when opening policy config file", e1); + } catch (PolicyEngineException e) { + throw new PolicyClientException("Exception when creating a new policy engine", e); + } + return policyEngine; + } + /** * Format and send delete Micro Service requests to Policy. * * @param prop * The ModelProperties * @return The response message from Policy - * @throws IOException - * In case of issues with the stream - * @throws PolicyEngineException - * In case of issues with the PolicyEngine creation */ - public String deleteMicrosService(ModelProperties prop) throws PolicyEngineException, IOException { + public String deleteMicrosService(ModelProperties prop) { String policyType = refProp.getStringValue("policy.ms.type"); return deletePolicy(prop, policyType); } @@ -403,12 +370,11 @@ public class PolicyClient { /** * This method delete the Base policy. * - * @param prop The model Properties + * @param prop + * The model Properties * @return A string with the answer from policy - * @throws PolicyEngineException In case of issues with the policy engine - * @throws IOException In case of issues with the stream */ - public String deleteBasePolicy(ModelProperties prop) throws PolicyEngineException, IOException { + public String deleteBasePolicy(ModelProperties prop) { return deletePolicy(prop, PolicyConfigType.Base.toString()); } @@ -418,12 +384,8 @@ public class PolicyClient { * @param prop * The ModelProperties * @return The response message from policy - * @throws IOException - * In case of issues with the stream - * @throws PolicyEngineException - * In case of issues with the PolicyEngine creation */ - public String deleteBrms(ModelProperties prop) throws PolicyEngineException, IOException { + public String deleteBrms(ModelProperties prop) { String policyType = refProp.getStringValue("policy.op.type"); return deletePolicy(prop, policyType); } @@ -435,12 +397,8 @@ public class PolicyClient { * The ModelProperties * * @return The response message from policy - * @throws IOException - * in case of issues with the Stream - * @throws PolicyEngineException - * In case of issues with the PolicyEngine class creation */ - protected String deletePolicy(ModelProperties prop, String policyType) throws PolicyEngineException, IOException { + protected String deletePolicy(ModelProperties prop, String policyType) { DeletePolicyParameters deletePolicyParameters = new DeletePolicyParameters(); if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) { @@ -454,16 +412,16 @@ public class PolicyClient { deletePolicyParameters.setPdpGroup(refProp.getStringValue("policy.pdp.group")); deletePolicyParameters.setPolicyType(policyType); // send delete request - String responseMessage = sendDeletePolicy(deletePolicyParameters, prop); + StringBuilder responseMessage = new StringBuilder(sendDeletePolicy(deletePolicyParameters, prop)); logger.info("Deleting policy from PAP..."); deletePolicyParameters.setPolicyComponent("PAP"); deletePolicyParameters.setDeleteCondition(DeletePolicyCondition.ALL); // send delete request - responseMessage = sendDeletePolicy(deletePolicyParameters, prop); + responseMessage.append(sendDeletePolicy(deletePolicyParameters, prop)); - return responseMessage; + return responseMessage.toString(); } /** @@ -474,26 +432,19 @@ public class PolicyClient { * @param prop * The ModelProperties * @return The response message from policy - * @throws IOException - * In case of issues with the stream - * @throws PolicyEngineException - * In case of issues with PolicyEngine class creation */ - protected String sendDeletePolicy(DeletePolicyParameters deletePolicyParameters, ModelProperties prop) - throws PolicyEngineException, IOException { + protected String sendDeletePolicy(DeletePolicyParameters deletePolicyParameters, ModelProperties prop) { // Verify whether it is triggered by Validation Test button from UI if (prop.isTest()) { return "delete not executed for test action"; } - PolicyEngine policyEngine = new PolicyEngine( - appContext.getResource(cldsPolicyConfigFile).getFile().getAbsolutePath()); // API method to create or update Policy. PolicyChangeResponse response = null; String responseMessage = ""; try { logger.info("Attempting to delete policy..."); - response = policyEngine.deletePolicy(deletePolicyParameters); + response = getPolicyEngine().deletePolicy(deletePolicyParameters); responseMessage = response.getResponseMessage(); } catch (Exception e) { logger.error("Exception occurred during policy communnication", e); diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java index d418ea55b..d31767150 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -25,7 +25,6 @@ package org.onap.clamp.clds.client; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; @@ -53,6 +52,7 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; import org.apache.commons.lang3.StringUtils; import org.onap.clamp.clds.client.req.SdcReq; +import org.onap.clamp.clds.exception.SdcCommunicationException; import org.onap.clamp.clds.model.CldsAlarmCondition; import org.onap.clamp.clds.model.CldsDBServiceCache; import org.onap.clamp.clds.model.CldsSdcArtifact; @@ -137,7 +137,7 @@ public class SdcCatalogServices { */ public List removeDuplicateServices(List rawCldsSdcServiceList) { List cldsSdcServiceInfoList = null; - if (rawCldsSdcServiceList != null && rawCldsSdcServiceList.size() > 0) { + if (rawCldsSdcServiceList != null && !rawCldsSdcServiceList.isEmpty()) { // sort list Collections.sort(rawCldsSdcServiceList); // and then take only the services with the max version (last in the @@ -165,7 +165,7 @@ public class SdcCatalogServices { */ public List removeDuplicateSdcResourceInstances(List rawCldsSdcResourceList) { List cldsSdcResourceList = null; - if (rawCldsSdcResourceList != null && rawCldsSdcResourceList.size() > 0) { + if (rawCldsSdcResourceList != null && !rawCldsSdcResourceList.isEmpty()) { // sort list Collections.sort(rawCldsSdcResourceList); // and then take only the resources with the max version (last in @@ -194,7 +194,7 @@ public class SdcCatalogServices { public List removeDuplicateSdcResourceBasicInfo( List rawCldsSdcResourceListBasicList) { List cldsSdcResourceBasicInfoList = null; - if (rawCldsSdcResourceListBasicList != null && rawCldsSdcResourceListBasicList.size() > 0) { + if (rawCldsSdcResourceListBasicList != null && !rawCldsSdcResourceListBasicList.isEmpty()) { // sort list Collections.sort(rawCldsSdcResourceListBasicList); // and then take only the resources with the max version (last in @@ -221,15 +221,13 @@ public class SdcCatalogServices { * @param invariantId * The invariant ID * @return The service UUID - * @throws IOException - * In case of issues with the JSON decoder */ - public String getServiceUuidFromServiceInvariantId(String invariantId) throws IOException { + public String getServiceUuidFromServiceInvariantId(String invariantId) { String serviceUuid = ""; String responseStr = getSdcServicesInformation(null); List rawCldsSdcServicesList = getCldsSdcServicesListFromJson(responseStr); List cldsSdcServicesList = removeDuplicateServices(rawCldsSdcServicesList); - if (cldsSdcServicesList != null && cldsSdcServicesList.size() > 0) { + if (cldsSdcServicesList != null && !cldsSdcServicesList.isEmpty()) { for (CldsSdcServiceInfo currCldsSdcServiceInfo : cldsSdcServicesList) { if (currCldsSdcServiceInfo != null && currCldsSdcServiceInfo.getInvariantUUID() != null && currCldsSdcServiceInfo.getInvariantUUID().equalsIgnoreCase(invariantId)) { @@ -245,32 +243,45 @@ public class SdcCatalogServices { * To get CldsAsdsServiceInfo class by parsing json string. * * @param jsonStr - * @return - * @throws IOException + * The Json string that must be decoded + * @return The list of CldsSdcServiceInfo, if there is a failure it return + * an empty list */ - public List getCldsSdcServicesListFromJson(String jsonStr) throws IOException { + public List getCldsSdcServicesListFromJson(String jsonStr) { ObjectMapper objectMapper = new ObjectMapper(); if (StringUtils.isBlank(jsonStr)) { - return null; + return new ArrayList<>(); + } + try { + return objectMapper.readValue(jsonStr, + objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcServiceInfo.class)); + } catch (IOException e) { + logger.error("Error when attempting to decode the JSON containing CldsSdcServiceInfo", e); + return new ArrayList<>(); } - return objectMapper.readValue(jsonStr, - objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcServiceInfo.class)); } /** * To get List of CldsSdcResourceBasicInfo class by parsing json string. * * @param jsonStr - * @return - * @throws IOException + * The JSOn string that must be decoded + * @return The list of CldsSdcResourceBasicInfo, an empty list in case of + * issues */ - public List getAllSdcResourcesListFromJson(String jsonStr) throws IOException { + public List getAllSdcResourcesListFromJson(String jsonStr) { ObjectMapper objectMapper = new ObjectMapper(); if (StringUtils.isBlank(jsonStr)) { - return null; + return new ArrayList<>(); + } + + try { + return objectMapper.readValue(jsonStr, + objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcResourceBasicInfo.class)); + } catch (IOException e) { + logger.error("Exception occurred when attempting to decode the list of CldsSdcResourceBasicInfo JSON", e); + return new ArrayList<>(); } - return objectMapper.readValue(jsonStr, - objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcResourceBasicInfo.class)); } /** @@ -290,76 +301,86 @@ public class SdcCatalogServices { * * @param jsonStr * @return - * @throws IOException */ - public CldsSdcServiceDetail getCldsSdcServiceDetailFromJson(String jsonStr) throws IOException { + public CldsSdcServiceDetail getCldsSdcServiceDetailFromJson(String jsonStr) { ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.readValue(jsonStr, CldsSdcServiceDetail.class); + try { + return objectMapper.readValue(jsonStr, CldsSdcServiceDetail.class); + } catch (IOException e) { + logger.error("Exception when attempting to decode the CldsSdcServiceDetail JSON", e); + return null; + } } /** - * To upload artifact to sdc based on serviceUUID and resourcename on url. + * To upload artifact to sdc based on serviceUUID and resource name on url. * * @param prop * @param userid * @param url - * @param formatttedSdcReq + * @param formattedSdcReq * @return - * @throws IOException */ - public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formatttedSdcReq) - throws IOException { + public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formatttedSdcReq) { // Verify whether it is triggered by Validation Test button from UI if (prop.isTest()) { return "sdc artifact upload not executed for test action"; } - logger.info("userid=" + userid); - String md5Text = SdcReq.calculateMD5ByString(formatttedSdcReq); - byte[] postData = SdcReq.stringToByteArray(formatttedSdcReq); - int postDataLength = postData.length; - HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, md5Text); - try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { - wr.write(postData); - } - boolean requestFailed = true; - int responseCode = conn.getResponseCode(); - logger.info("responseCode=" + responseCode); - if (responseCode == 200) { - requestFailed = false; - } + try { + logger.info("userid=" + userid); + String md5Text = SdcReq.calculateMD5ByString(formatttedSdcReq); + byte[] postData = SdcReq.stringToByteArray(formatttedSdcReq); + int postDataLength = postData.length; + HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, md5Text); + try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) { + wr.write(postData); + } + boolean requestFailed = true; + int responseCode = conn.getResponseCode(); + logger.info("responseCode=" + responseCode); + if (responseCode == 200) { + requestFailed = false; + } - String responseStr = getResponse(conn); - if (responseStr != null) { - if (requestFailed) { + String responseStr = getResponse(conn); + if (responseStr != null && requestFailed) { logger.error("requestFailed - responseStr=" + responseStr); throw new BadRequestException(responseStr); } + return responseStr; + } catch (IOException e) { + logger.error("Exception when attempting to communicate with SDC", e); + throw new SdcCommunicationException("Exception when attempting to communicate with SDC", e); } - return responseStr; + } - private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text) - throws IOException { - logger.info("userid=" + userid); - String basicAuth = SdcReq.getSdcBasicAuth(refProp); - String sdcXonapInstanceId = refProp.getStringValue("sdc.sdcX-InstanceID"); - URL urlObj = new URL(url); - HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); - conn.setDoOutput(true); - conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), sdcXonapInstanceId); - conn.setRequestProperty("Authorization", basicAuth); - conn.setRequestProperty("Content-Type", "application/json"); - conn.setRequestProperty("Content-MD5", md5Text); - conn.setRequestProperty("USER_ID", userid); - conn.setRequestMethod("POST"); - conn.setRequestProperty("charset", "utf-8"); - conn.setRequestProperty("Content-Length", Integer.toString(postDataLength)); - conn.setUseCaches(false); - conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); - return conn; + private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text) { + try { + logger.info("userid=" + userid); + String basicAuth = SdcReq.getSdcBasicAuth(refProp); + String sdcXonapInstanceId = refProp.getStringValue("sdc.sdcX-InstanceID"); + URL urlObj = new URL(url); + HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection(); + conn.setDoOutput(true); + conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), sdcXonapInstanceId); + conn.setRequestProperty("Authorization", basicAuth); + conn.setRequestProperty("Content-Type", "application/json"); + conn.setRequestProperty("Content-MD5", md5Text); + conn.setRequestProperty("USER_ID", userid); + conn.setRequestMethod("POST"); + conn.setRequestProperty("charset", "utf-8"); + conn.setRequestProperty("Content-Length", Integer.toString(postDataLength)); + conn.setUseCaches(false); + conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId()); + return conn; + } catch (IOException e) { + logger.error("Exception when attempting to open connection with SDC", e); + throw new SdcCommunicationException("Exception when attempting to open connection with SDC", e); + } } - private String getResponse(HttpURLConnection conn) throws IOException { + private String getResponse(HttpURLConnection conn) { try (InputStream is = getInputStream(conn)) { if (is != null) { try (BufferedReader in = new BufferedReader(new InputStreamReader(is))) { @@ -370,29 +391,42 @@ public class SdcCatalogServices { } return response.toString(); } + } else { + return null; } + } catch (IOException e) { + logger.error("Exception when attempting to open SDC response", e); + throw new SdcCommunicationException("Exception when attempting to open SDC response", e); } - return null; } - private InputStream getInputStream(HttpURLConnection conn) throws IOException { - InputStream inStream = conn.getErrorStream(); - if (inStream == null) { - inStream = conn.getInputStream(); + private InputStream getInputStream(HttpURLConnection conn) { + try { + InputStream inStream = conn.getErrorStream(); + if (inStream == null) { + inStream = conn.getInputStream(); + } + return inStream; + } catch (IOException e) { + logger.error("Exception when attempting to open SDC error stream", e); + throw new SdcCommunicationException("Exception when attempting to open SDC error stream", e); } - return inStream; } - public CldsDBServiceCache getCldsDbServiceCacheUsingCldsServiceData(CldsServiceData cldsServiceData) - throws IOException { - CldsDBServiceCache cldsDbServiceCache = new CldsDBServiceCache(); - cldsDbServiceCache.setCldsDataInstream(cldsServiceData); - cldsDbServiceCache.setInvariantId(cldsServiceData.getServiceInvariantUUID()); - cldsDbServiceCache.setServiceId(cldsServiceData.getServiceUUID()); - return cldsDbServiceCache; + public CldsDBServiceCache getCldsDbServiceCacheUsingCldsServiceData(CldsServiceData cldsServiceData) { + try { + CldsDBServiceCache cldsDbServiceCache = new CldsDBServiceCache(); + cldsDbServiceCache.setCldsDataInstream(cldsServiceData); + cldsDbServiceCache.setInvariantId(cldsServiceData.getServiceInvariantUUID()); + cldsDbServiceCache.setServiceId(cldsServiceData.getServiceUUID()); + return cldsDbServiceCache; + } catch (IOException e) { + logger.error("Exception when getting service in cache", e); + throw new SdcCommunicationException("Exception when getting service in cache", e); + } } - public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData) throws IOException { + public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData) { boolean expired = false; if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) { String cachedServiceUuid = cldsServiceData.getServiceUUID(); @@ -408,7 +442,7 @@ public class SdcCatalogServices { return expired; } - public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUuid) throws IOException { + public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUuid) { String url = refProp.getStringValue("sdc.serviceUrl"); String catalogUrl = refProp.getStringValue("sdc.catalog.url"); String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid); @@ -417,7 +451,13 @@ public class SdcCatalogServices { ObjectMapper objectMapper = new ObjectMapper(); CldsServiceData cldsServiceData = new CldsServiceData(); if (responseStr != null) { - CldsSdcServiceDetail cldsSdcServiceDetail = objectMapper.readValue(responseStr, CldsSdcServiceDetail.class); + CldsSdcServiceDetail cldsSdcServiceDetail; + try { + cldsSdcServiceDetail = objectMapper.readValue(responseStr, CldsSdcServiceDetail.class); + } catch (IOException e) { + logger.error("Exception when decoding the CldsServiceData JSON from SDC", e); + throw new SdcCommunicationException("Exception when decoding the CldsServiceData JSON from SDC", e); + } cldsServiceData.setServiceUUID(cldsSdcServiceDetail.getUuid()); cldsServiceData.setServiceInvariantUUID(cldsSdcServiceDetail.getInvariantUUID()); @@ -448,11 +488,7 @@ public class SdcCatalogServices { return cldsServiceData; } - /** - * @param cldsVfDataList - * @throws IOException - */ - private void getAllVfcForVfList(List cldsVfDataList, String catalogUrl) throws IOException { + private void getAllVfcForVfList(List cldsVfDataList, String catalogUrl) { // todo : refact this.. if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) { List allVfResources = getAllSdcVForVfcResourcesBasedOnResourceType( @@ -511,9 +547,15 @@ public class SdcCatalogServices { } } - private List getVfcDataListFromVfResponse(String vfResponse) throws IOException { + private List getVfcDataListFromVfResponse(String vfResponse) { ObjectMapper mapper = new ObjectMapper(); - ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); + ObjectNode vfResponseNode; + try { + vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); + } catch (IOException e) { + logger.error("Exception when decoding the JSON list of CldsVfcData", e); + return new ArrayList<>(); + } ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources"); List cldsVfcDataList = new ArrayList<>(); if (vfcArrayNode != null) { @@ -572,10 +614,16 @@ public class SdcCatalogServices { return (id != null) ? id.replaceAll("\"", "") : ""; } - private List getAlarmCondtionsFromVfc(String vfcResponse) throws IOException { + private List getAlarmCondtionsFromVfc(String vfcResponse) { List cldsAlarmConditionList = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); - ObjectNode vfcResponseNode = (ObjectNode) mapper.readTree(vfcResponse); + ObjectNode vfcResponseNode; + try { + vfcResponseNode = (ObjectNode) mapper.readTree(vfcResponse); + } catch (IOException e) { + logger.error("Exception when decoding the JSON list of CldsAlarmCondition", e); + return cldsAlarmConditionList; + } ArrayNode artifactsArrayNode = (ArrayNode) vfcResponseNode.get("artifacts"); if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) { @@ -592,25 +640,36 @@ public class SdcCatalogServices { return cldsAlarmConditionList; } - private List parseCsvToGetAlarmConditions(String allAlarmCondsValues) throws IOException { - List cldsAlarmConditionList = new ArrayList<>(); - Reader alarmReader = new StringReader(allAlarmCondsValues); - Iterable records = CSVFormat.RFC4180.parse(alarmReader); - if (records != null) { - Iterator it = records.iterator(); - if (it.hasNext()) { - it.next(); + private List parseCsvToGetAlarmConditions(String allAlarmCondsValues) { + try { + List cldsAlarmConditionList = new ArrayList<>(); + Reader alarmReader = new StringReader(allAlarmCondsValues); + Iterable records = CSVFormat.RFC4180.parse(alarmReader); + if (records != null) { + Iterator it = records.iterator(); + if (it.hasNext()) { + it.next(); + } + it.forEachRemaining(record -> processRecord(cldsAlarmConditionList, record)); } - it.forEachRemaining(record -> processRecord(cldsAlarmConditionList, record)); + return cldsAlarmConditionList; + } catch (IOException e) { + logger.error("Exception when attempting to parse the CSV containing the alarm", e); + return new ArrayList<>(); } - return cldsAlarmConditionList; } // Method to get the artifact for any particular VF - private List getFieldPathFromVF(String vfResponse) throws JsonProcessingException, IOException { + private List getFieldPathFromVF(String vfResponse) { List cldsVfKPIDataList = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); - ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); + ObjectNode vfResponseNode; + try { + vfResponseNode = (ObjectNode) mapper.readTree(vfResponse); + } catch (IOException e) { + logger.error("Exception when decoding the JSON list of CldsVfKPIData", e); + return cldsVfKPIDataList; + } ArrayNode artifactsArrayNode = (ArrayNode) vfResponseNode.get("artifacts"); if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) { @@ -621,7 +680,7 @@ public class SdcCatalogServices { String artifactName = ""; if (artifactNameNode != null) { artifactName = artifactNameNode.textValue(); - artifactName = artifactName.substring(artifactName.lastIndexOf(".") + 1); + artifactName = artifactName.substring(artifactName.lastIndexOf('.') + 1); } if (artifactUrlNode != null && artifactName != null && !artifactName.isEmpty() && artifactName.equalsIgnoreCase("csv")) { @@ -660,19 +719,24 @@ public class SdcCatalogServices { } // Method to get the artifactURL Data and set the CldsVfKPIData node - private List parseCsvToGetFieldPath(String allFieldPathValues) throws IOException { - List cldsVfKPIDataList = new ArrayList<>(); - Reader alarmReader = new StringReader(allFieldPathValues); - Iterable records = CSVFormat.RFC4180.parse(alarmReader); - if (records != null) { - for (CSVRecord record : records) { - CldsVfKPIData kpiData = this.convertCsvRecordToKpiData(record); - if (kpiData != null) { - cldsVfKPIDataList.add(kpiData); + private List parseCsvToGetFieldPath(String allFieldPathValues) { + try { + List cldsVfKPIDataList = new ArrayList<>(); + Reader alarmReader = new StringReader(allFieldPathValues); + Iterable records = CSVFormat.RFC4180.parse(alarmReader); + if (records != null) { + for (CSVRecord record : records) { + CldsVfKPIData kpiData = this.convertCsvRecordToKpiData(record); + if (kpiData != null) { + cldsVfKPIDataList.add(kpiData); + } } } + return cldsVfKPIDataList; + } catch (IOException e) { + logger.error("Exception when attempting to parse the CSV containing the alarm kpi data", e); + return new ArrayList<>(); } - return cldsVfKPIDataList; } private void processRecord(List cldsAlarmConditionList, CSVRecord record) { @@ -713,7 +777,6 @@ public class SdcCatalogServices { * @param url * @param alarmConditions * @return - * @throws IOException */ public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions) { try { @@ -736,7 +799,7 @@ public class SdcCatalogServices { String inputLine; while ((inputLine = in.readLine()) != null) { if (!inputLine.isEmpty()) { - response.append(inputLine); + response.append(inputLine); } if (alarmConditions) { response.append("\n"); @@ -757,9 +820,8 @@ public class SdcCatalogServices { * @param globalProps * @param cldsServiceData * @return - * @throws IOException */ - public String createPropertiesObjectByUUID(String globalProps, CldsServiceData cldsServiceData) throws IOException { + public String createPropertiesObjectByUUID(String globalProps, CldsServiceData cldsServiceData) { String totalPropsStr; ObjectMapper mapper = new ObjectMapper(); ObjectNode globalPropsJson; @@ -814,20 +876,29 @@ public class SdcCatalogServices { byIdObjectNode.putPOJO("byAlertDescription", alertDescObjectNodeByAlert); - globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); + globalPropsJson = decodeGlobalProp(globalProps, mapper); globalPropsJson.putPOJO("shared", byIdObjectNode); - logger.info("valuie of objNode:" + globalPropsJson); + logger.info("value of objNode:" + globalPropsJson); } else { /** * to create json with total properties when no serviceUUID passed */ - globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class); + globalPropsJson = decodeGlobalProp(globalProps, mapper); } totalPropsStr = globalPropsJson.toString(); return totalPropsStr; } + private ObjectNode decodeGlobalProp(String globalProps, ObjectMapper mapper) { + try { + return (ObjectNode) mapper.readValue(globalProps, JsonNode.class); + } catch (IOException e) { + logger.error("Exception occurred during decoding of the global props, returning an empty objectNode", e); + return mapper.createObjectNode(); + } + } + /** * Method to get alarm conditions/alert description from Service Data. * @@ -981,13 +1052,13 @@ public class SdcCatalogServices { alertDescNode.put(currCldsAlarmCondition.getAlarmConditionKey(), currCldsAlarmCondition.getAlarmConditionKey()); } - } } + } vfcObjectNode.putPOJO("alarmCondition", alarmCondNode); vfcObjectNode.putPOJO("alertDescription", alertDescNode); vfcResourceUuidObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), vfcObjectNode); - } + } } } else { alarmCondNode.put("", ""); @@ -1050,12 +1121,11 @@ public class SdcCatalogServices { if (currCldsSdcResource != null && currCldsSdcResource.getArtifacts() != null && !currCldsSdcResource.getArtifacts().isEmpty()) { for (CldsSdcArtifact currCldsSdcArtifact : currCldsSdcResource.getArtifacts()) { - if (currCldsSdcArtifact != null && currCldsSdcArtifact.getArtifactName() != null) { - if (currCldsSdcArtifact.getArtifactName().equalsIgnoreCase(artifactName)) { - artifactUuid = currCldsSdcArtifact.getArtifactUUID(); - artifactExists = true; - break; - } + if (currCldsSdcArtifact != null && currCldsSdcArtifact.getArtifactName() != null + && currCldsSdcArtifact.getArtifactName().equalsIgnoreCase(artifactName)) { + artifactUuid = currCldsSdcArtifact.getArtifactUUID(); + artifactExists = true; + break; } } } @@ -1109,22 +1179,16 @@ public class SdcCatalogServices { * @param resourceType * The resourceType * @return The list of CldsSdcResourceBasicInfo - * @throws IOException - * In case of issues with the Streams */ - private List getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType) - throws IOException { - List allSdcResourceVfcBasicInfo = new ArrayList(); + private List getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType) { String catalogUrl = refProp.getStringValue("sdc.catalog.url"); String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType; String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false); - - allSdcResourceVfcBasicInfo = getAllSdcResourcesListFromJson(allSdcVfcResources); - return removeDuplicateSdcResourceBasicInfo(allSdcResourceVfcBasicInfo); + return removeDuplicateSdcResourceBasicInfo(getAllSdcResourcesListFromJson(allSdcVfcResources)); } private String getResourceUuidFromResourceInvariantUuid(String resourceInvariantUuid, - List resourceInfoList) throws IOException { + List resourceInfoList) { String resourceUuid = null; if (resourceInfoList != null && !resourceInfoList.isEmpty()) { for (CldsSdcResourceBasicInfo currResource : resourceInfoList) { @@ -1172,12 +1236,10 @@ public class SdcCatalogServices { * @param locationArtifactName * The location artifact name from where we can get the Artifact * UUID - * @throws IOException - * In case of issues with the streams * */ public void uploadToSdc(ModelProperties prop, String userid, List sdcReqUrlsList, String formattedSdcReq, - String formattedSdcLocationReq, String artifactName, String locationArtifactName) throws IOException { + String formattedSdcLocationReq, String artifactName, String locationArtifactName) { logger.info("userid=" + userid); String serviceInvariantUuid = getServiceInvariantUuidFromProps(prop); if (sdcReqUrlsList != null && !sdcReqUrlsList.isEmpty()) { diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java index 2b1762a24..ad466ee7d 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -139,7 +139,7 @@ public class OperationalPolicyReq { logger.info("notificationTopic=" + notificationTopic); // format yaml - String yaml = tca.isFound() ? formateNodeBYaml(refProp, prop, modelElementId, policyChain) + String yaml = (tca != null && tca.isFound()) ? formateNodeBYaml(refProp, prop, modelElementId, policyChain) : formatYaml(refProp, prop, modelElementId, policyChain); ruleAttributes.put("templateName", templateName); @@ -425,7 +425,7 @@ public class OperationalPolicyReq { return new Resource[0]; } return stringList.stream().map(stringElem -> new Resource(stringElem, resourceType)).toArray(Resource[]::new); - } + } /** * Convert a List of policy result strings to an array of PolicyResult diff --git a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java index 93c562601..f8351ca5d 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java @@ -46,7 +46,6 @@ import java.util.Map.Entry; import org.apache.commons.codec.digest.DigestUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.clamp.clds.client.SdcCatalogServices; -import org.onap.clamp.clds.exception.SdcCommunicationException; import org.onap.clamp.clds.model.CldsSdcResource; import org.onap.clamp.clds.model.CldsSdcServiceDetail; import org.onap.clamp.clds.model.prop.Global; @@ -251,13 +250,12 @@ public class SdcReq { * @param baseUrl * @param sdcCatalogServices * @return - * @throws Exception */ public static List getSdcReqUrlsList(ModelProperties prop, String baseUrl, SdcCatalogServices sdcCatalogServices, DelegateExecution execution) { // TODO : refact and regroup with very similar code List urlList = new ArrayList<>(); - try { + Global globalProps = prop.getGlobal(); if (globalProps != null) { if (globalProps.getService() != null) { @@ -266,30 +264,28 @@ public class SdcReq { List resourceVfList = globalProps.getResourceVf(); String serviceUUID = sdcCatalogServices.getServiceUuidFromServiceInvariantId(serviceInvariantUUID); String sdcServicesInformation = sdcCatalogServices.getSdcServicesInformation(serviceUUID); - CldsSdcServiceDetail CldsSdcServiceDetail = sdcCatalogServices + CldsSdcServiceDetail cldsSdcServiceDetail = sdcCatalogServices .getCldsSdcServiceDetailFromJson(sdcServicesInformation); - if (CldsSdcServiceDetail != null && resourceVfList != null) { - List CldsSdcResourcesList = CldsSdcServiceDetail.getResources(); - if (CldsSdcResourcesList != null && !CldsSdcResourcesList.isEmpty()) { - for (CldsSdcResource CldsSdcResource : CldsSdcResourcesList) { + if (cldsSdcServiceDetail != null && resourceVfList != null) { + List cldsSdcResourcesList = cldsSdcServiceDetail.getResources(); + if (cldsSdcResourcesList != null && !cldsSdcResourcesList.isEmpty()) { + for (CldsSdcResource CldsSdcResource : cldsSdcResourcesList) { if (CldsSdcResource != null && CldsSdcResource.getResoucreType() != null - && CldsSdcResource.getResoucreType().equalsIgnoreCase("VF")) { - if (resourceVfList.contains(CldsSdcResource.getResourceInvariantUUID())) { - String normalizedResourceInstanceName = normalizeResourceInstanceName( - CldsSdcResource.getResourceInstanceName()); - String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" - + normalizedResourceInstanceName + "/artifacts"; - urlList.add(svcUrl); - } + && CldsSdcResource.getResoucreType().equalsIgnoreCase("VF") + && resourceVfList.contains(CldsSdcResource.getResourceInvariantUUID())) { + String normalizedResourceInstanceName = normalizeResourceInstanceName( + CldsSdcResource.getResourceInstanceName()); + String svcUrl = baseUrl + "/" + serviceUUID + "/resourceInstances/" + + normalizedResourceInstanceName + "/artifacts"; + urlList.add(svcUrl); + } } } } } } - } catch (IOException e) { - throw new SdcCommunicationException("Exception occurred during the SDC communication",e); - } + return urlList; } 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 19c916435..eee179111 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java @@ -23,7 +23,9 @@ package org.onap.clamp.clds.config; -import java.io.IOException; +import com.att.ajsc.common.AjscProvider; +import com.att.ajsc.common.AjscService; + import java.util.ArrayList; import java.util.List; @@ -55,9 +57,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import com.att.ajsc.common.AjscProvider; -import com.att.ajsc.common.AjscService; - @Configuration @Profile("clamp-default") public class CldsConfiguration { @@ -99,7 +98,7 @@ public class CldsConfiguration { } @Bean - public RefProp getRefProp() throws IOException { + public RefProp getRefProp() { return new RefProp(); } diff --git a/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java index 997a20f09..ecfb4aa11 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java @@ -23,13 +23,13 @@ package org.onap.clamp.clds.config; +import com.fasterxml.jackson.databind.ObjectMapper; + import java.io.IOException; import java.io.InputStream; import org.onap.clamp.clds.service.CldsUser; -import com.fasterxml.jackson.databind.ObjectMapper; - public class CldsUserJsonDecoder { /** @@ -43,4 +43,8 @@ public class CldsUserJsonDecoder { // the ObjectMapper readValue method closes the stream no need to do it return new ObjectMapper().readValue(cldsUsersFile, CldsUser[].class); } + + private CldsUserJsonDecoder() { + + } } 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 3b69502ae..3cc6a325a 100644 --- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -46,7 +46,6 @@ import org.onap.clamp.clds.model.CldsModelInstance; import org.onap.clamp.clds.model.CldsServiceData; import org.onap.clamp.clds.model.CldsTemplate; import org.onap.clamp.clds.model.ValueItem; -import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; @@ -398,8 +397,8 @@ public class CldsDao { * @return model names */ public List getBpmnNames() { - String SQL = "SELECT model_name FROM model ORDER BY 1;"; - return jdbcTemplateObject.query(SQL, new ValueItemMapper()); + String sql = "SELECT model_name FROM model ORDER BY 1;"; + return jdbcTemplateObject.query(sql, new ValueItemMapper()); } /** @@ -435,8 +434,8 @@ public class CldsDao { * @return template names */ public List getTemplateNames() { - String SQL = "SELECT template_name FROM template ORDER BY 1;"; - return jdbcTemplateObject.query(SQL, new ValueItemMapper()); + String sql = "SELECT template_name FROM template ORDER BY 1;"; + return jdbcTemplateObject.query(sql, new ValueItemMapper()); } /** @@ -466,14 +465,10 @@ public class CldsDao { public CldsServiceData getCldsServiceCache(String invariantUUID) { CldsServiceData cldsServiceData = null; List cldsServiceDataList = new ArrayList<>(); - try { - String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? "; - cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID }, - new CldsServiceDataMapper()); - logger.info("value of cldsServiceDataList: {}", cldsServiceDataList); - } catch (EmptyResultDataAccessException e) { - logger.info("cache row not found for invariantUUID: {}", invariantUUID); - } + String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? "; + cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID }, + new CldsServiceDataMapper()); + logger.info("value of cldsServiceDataList: {}", cldsServiceDataList); return cldsServiceData; } @@ -499,7 +494,7 @@ public class CldsDao { } } - public void doHealthCheck() throws SQLException, IOException { + public void doHealthCheck() { jdbcTemplateObject.execute(HEALTHCHECK); } diff --git a/src/main/java/org/onap/clamp/clds/exception/policy/PolicyClientException.java b/src/main/java/org/onap/clamp/clds/exception/policy/PolicyClientException.java new file mode 100644 index 000000000..eaeb0b8fe --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/exception/policy/PolicyClientException.java @@ -0,0 +1,61 @@ +/*- + * ============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.exception.policy; + +/** + * New exception to Policy Client errors. + * + */ +public class PolicyClientException extends RuntimeException { + + /** + * Serial ID. + */ + private static final long serialVersionUID = -8379167975420213634L; + + /** + * This constructor can be used to create a new PolicyClientException. + * + * @param message + * A string message detailing the problem + * @param e + * The exception sent by the code + */ + public PolicyClientException(String message, Throwable e) { + super(message, e); + } + + /** + * This constructor can be used to create a new PolicyClientException. Use + * this constructor only if you are creating a new exception stack, not if + * an exception was already raised by another code. + * + * @param message + * A string message detailing the problem + */ + public PolicyClientException(String message) { + super(message); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java new file mode 100644 index 000000000..a7dd5cbf0 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java @@ -0,0 +1,280 @@ +/*- + * ============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.model.prop; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Provide base ModelElement functionality. Perform base parsing of properties + * for a ModelElement (such as, Collector, StringMatch, Policy, Tca, Holmes, + * ...) + */ +public abstract class AbstractModelElement { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private final String type; + private final ModelBpmn modelBpmn; + private final String id; + protected String topicPublishes; + protected final JsonNode modelElementJsonNode; + private boolean isFound; + + private final ModelProperties modelProp; + + /** + * Perform base parsing of properties for a ModelElement (such as, + * Collector, StringMatch, Policy and Tca) + * + * @param type + * @param modelProp + * @param modelBpmn + * @param modelJson + */ + protected AbstractModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + this.type = type; + this.modelProp = modelProp; + this.modelBpmn = modelBpmn; + this.id = modelBpmn.getId(type); + this.modelElementJsonNode = modelJson.get(id); + this.isFound = modelBpmn.isModelElementTypeInList(type); + } + + /** + * topicSubscribes is the topicPublishes of the from Model Element (the + * previous one in the chain). + * + * @return the topicSubscribes + */ + public String getTopicSubscribes() { + // get fromId for this type + String fromId = modelBpmn.getFromId(type); + // find the type of the from model element + String fromType = modelBpmn.getType(fromId); + // get the model element for the type + AbstractModelElement me = modelProp.getModelElementByType(fromType); + // get the topic publishes for the model element + return me.topicPublishes; + } + + /** + * @return the topicPublishes + */ + public String getTopicPublishes() { + return topicPublishes; + } + + /** + * Return the value field of the json node element that has a name field + * equals to the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static String getValueByName(JsonNode nodeIn, String name) { + String value = null; + if (nodeIn != null) { + for (JsonNode node : nodeIn) { + if (node.path("name").asText().equals(name)) { + JsonNode vnode = node.path("value"); + if (vnode.isArray()) { + // if array, assume value is in first element + value = vnode.path(0).asText(); + } else { + // otherwise, just return text + value = vnode.asText(); + } + } + } + } + if (value == null || value.length() == 0) { + logger.warn(name + "=" + value); + } else { + logger.debug(name + "=" + value); + } + return value; + } + + /** + * Return the value field of the json node element that has a name field + * that equals the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static String getNodeValueByName(JsonNode nodeIn, String name) { + String value = null; + if (nodeIn != null) { + value = nodeIn.path(name).asText(); + } + if (value == null || value.length() == 0) { + logger.warn(name + "=" + value); + } else { + logger.debug(name + "=" + value); + } + return value; + } + + /** + * Return the value field of the json node element that has a name field + * that equals the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static List getNodeValuesByName(JsonNode nodeIn, String name) { + List values = new ArrayList<>(); + if (nodeIn != null) { + Iterator i = nodeIn.iterator(); + while (i.hasNext()) { + JsonNode node = i.next(); + if (node.path("name").asText().equals(name)) { + JsonNode vnode = node.path("value"); + if (vnode.isArray()) { + // if array, assume value is in first element + values.add(vnode.path(0).asText()); + } else { + // otherwise, just return text + values.add(vnode.asText()); + } + } + } + } + return values; + } + + /** + * Return the int value field of the json node element that has a name field + * equals to the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static Integer getIntValueByName(JsonNode nodeIn, String name) { + String value = getValueByName(nodeIn, name); + return Integer.valueOf(value); + } + + /** + * Return an array of values for the field of the json node element that has + * a name field equals to the given name. + * + * @param nodeIn + * @param name + * @return + */ + public static List getValuesByName(JsonNode nodeIn, String name) { + List values = null; + if (nodeIn != null) { + Iterator i = nodeIn.iterator(); + while (i.hasNext()) { + JsonNode node = i.next(); + if (node.path("name").asText().equals(name)) { + values = getValuesList(node); + } + } + } + if (values == null || values.isEmpty()) { + logger.warn(name + "=" + values); + } else { + logger.debug(name + "=" + values); + } + return values; + } + + /** + * Return an array of String values. + * + * @param nodeIn + * @return + */ + public static List getValuesList(JsonNode nodeIn) { + ArrayList al = new ArrayList<>(); + if (nodeIn != null) { + Iterator itr = nodeIn.path("value").elements(); + while (itr.hasNext()) { + JsonNode node = itr.next(); + al.add(node.asText()); + } + } + return al; + } + + /** + * Return the value field of the json node element that has a name field + * equals to the given name. + * + * @param name + * @return + */ + public String getValueByName(String name) { + return getValueByName(modelElementJsonNode, name); + } + + /** + * Return the int value field of the json node element that has a name field + * equals to the given name. + * + * @param name + * @return + */ + public Integer getIntValueByName(String name) { + return getIntValueByName(modelElementJsonNode, name); + } + + /** + * Return an array of values for the field of the json node element that has + * a name field equals to the given name. + * + * @param name + * @return + */ + public List getValuesByName(String name) { + return getValuesByName(modelElementJsonNode, name); + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the isFound + */ + public boolean isFound() { + return isFound; + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Collector.java b/src/main/java/org/onap/clamp/clds/model/prop/Collector.java index bcb9cf01d..be30f3ec2 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Collector.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Collector.java @@ -30,7 +30,7 @@ import com.fasterxml.jackson.databind.JsonNode; /** * Parse Collector json properties. */ -public class Collector extends ModelElement { +public class Collector extends AbstractModelElement { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Collector.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Global.java b/src/main/java/org/onap/clamp/clds/model/prop/Global.java index 2fb7d5040..48c2fd9fb 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Global.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Global.java @@ -54,11 +54,11 @@ public class Global { */ public Global(JsonNode modelJson) { JsonNode globalNode = modelJson.get("global"); - service = ModelElement.getValueByName(globalNode, "service"); - actionSet = ModelElement.getValueByName(globalNode, "actionSet"); - resourceVf = ModelElement.getValuesByName(globalNode, "vf"); - resourceVfc = ModelElement.getValuesByName(globalNode, "vfc"); - location = ModelElement.getValuesByName(globalNode, "location"); + service = AbstractModelElement.getValueByName(globalNode, "service"); + actionSet = AbstractModelElement.getValueByName(globalNode, "actionSet"); + resourceVf = AbstractModelElement.getValuesByName(globalNode, "vf"); + resourceVfc = AbstractModelElement.getValuesByName(globalNode, "vfc"); + location = AbstractModelElement.getValuesByName(globalNode, "location"); } /** diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java b/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java index 233f656e1..4fa040754 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Holmes.java @@ -32,7 +32,7 @@ import com.fasterxml.jackson.databind.JsonNode; * [{"name":"correlationalLogic","value":"vcwx"},{"name":"operationalPolicy","value":"cccc"}] * */ -public class Holmes extends ModelElement { +public class Holmes extends AbstractModelElement { private static final String TYPE_HOLMES = "holmes"; diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java index 9684eea86..ac25400db 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java @@ -62,13 +62,13 @@ public class ModelProperties { private Global global; - private final Map modelElements = new ConcurrentHashMap<>(); + private final Map modelElements = new ConcurrentHashMap<>(); private String currentModelElementId; private String policyUniqueId; private static final Object lock = new Object(); - private static Map, String> modelElementClasses = new ConcurrentHashMap<>(); + private static Map, String> modelElementClasses = new ConcurrentHashMap<>(); static { synchronized (lock) { @@ -119,7 +119,7 @@ public class ModelProperties { // Parse the list of base Model Elements and build up the // ModelElements modelElementClasses.entrySet().stream().parallel() - .filter(entry -> (ModelElement.class.isAssignableFrom(entry.getKey()) + .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey()) && missingTypes.contains(entry.getValue()))) .forEach(entry -> { try { @@ -183,8 +183,8 @@ public class ModelProperties { * @param type * @return */ - public ModelElement getModelElementByType(String type) { - ModelElement modelElement = modelElements.get(type); + public AbstractModelElement getModelElementByType(String type) { + AbstractModelElement modelElement = modelElements.get(type); if (modelElement == null) { throw new IllegalArgumentException("Invalid or not found ModelElement type: " + type); } @@ -338,14 +338,14 @@ public class ModelProperties { return global; } - public static final synchronized void registerModelElement(Class modelElementClass, + public static final synchronized void registerModelElement(Class modelElementClass, String type) { if (!modelElementClasses.containsKey(modelElementClass.getClass())) { modelElementClasses.put(modelElementClass, type); } } - public T getType(Class clazz) { + public T getType(Class clazz) { instantiateMissingModelElements(); String type = modelElementClasses.get(clazz); return (type != null ? (T) modelElements.get(type) : null); diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java index 452af20cd..80d12aaba 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java @@ -48,7 +48,7 @@ import java.util.List; * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ * "vf3RtPi"]}]]}] */ -public class Policy extends ModelElement { +public class Policy extends AbstractModelElement { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java index 6142e9e63..c8c2ef461 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java @@ -63,13 +63,13 @@ public class PolicyChain { public PolicyChain(JsonNode node) { - policyId = ModelElement.getValueByName(node, "pid"); - timeout = ModelElement.getIntValueByName(node, "timeout"); + policyId = AbstractModelElement.getValueByName(node, "pid"); + timeout = AbstractModelElement.getIntValueByName(node, "timeout"); // process policy configurations JsonNode policyNode = node.get(node.size() - 1).get("policyConfigurations"); Iterator itr = policyNode.elements(); - policyItems = new ArrayList(); + policyItems = new ArrayList<>(); while (itr.hasNext()) { policyItems.add(new PolicyItem(itr.next())); } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java index d1729cda1..c84affefe 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java @@ -64,12 +64,12 @@ public class PolicyItem implements Cloneable { * @param node */ public PolicyItem(JsonNode node) { - id = ModelElement.getValueByName(node, "_id"); - recipe = ModelElement.getValueByName(node, "recipe"); - maxRetries = ModelElement.getIntValueByName(node, "maxRetries"); - retryTimeLimit = ModelElement.getIntValueByName(node, "retryTimeLimit"); - parentPolicy = ModelElement.getValueByName(node, "parentPolicy"); - parentPolicyConditions = ModelElement.getValuesByName(node, "parentPolicyConditions"); + id = AbstractModelElement.getValueByName(node, "_id"); + recipe = AbstractModelElement.getValueByName(node, "recipe"); + maxRetries = AbstractModelElement.getIntValueByName(node, "maxRetries"); + retryTimeLimit = AbstractModelElement.getIntValueByName(node, "retryTimeLimit"); + parentPolicy = AbstractModelElement.getValueByName(node, "parentPolicy"); + parentPolicyConditions = AbstractModelElement.getValuesByName(node, "parentPolicyConditions"); } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java b/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java index 6e986bb0e..7395ced00 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ResourceGroup.java @@ -78,8 +78,8 @@ public class ResourceGroup { */ public ResourceGroup(JsonNode node) { - groupNumber = ModelElement.getValueByName(node, "rgname"); - policyId = ModelElement.getValueByName(node, "policyId"); + groupNumber = AbstractModelElement.getValueByName(node, "rgname"); + policyId = AbstractModelElement.getValueByName(node, "policyId"); // process Server_Configurations JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java b/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java index 186cc2192..f15d70196 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java @@ -84,15 +84,15 @@ public class ServiceConfiguration { * @param node */ public ServiceConfiguration(JsonNode node) { - aaiMatchingFields = ModelElement.getValuesByName(node, "aaiMatchingFields"); - aaiSendFields = ModelElement.getValuesByName(node, "aaiSendFields"); + aaiMatchingFields = AbstractModelElement.getValuesByName(node, "aaiMatchingFields"); + aaiSendFields = AbstractModelElement.getValuesByName(node, "aaiSendFields"); // groupNumber = ModelElement.getValueByName(node, "groupNumber"); - resourceVf = ModelElement.getValuesByName(node, "vf"); - resourceVfc = ModelElement.getValuesByName(node, "vfc"); - timeWindow = ModelElement.getValueByName(node, "timeWindow"); - ageLimit = ModelElement.getValueByName(node, "ageLimit"); - createClosedLoopEventId = ModelElement.getValueByName(node, "createClosedLoopEventId"); - outputEventName = ModelElement.getValueByName(node, "outputEventName"); + resourceVf = AbstractModelElement.getValuesByName(node, "vf"); + resourceVfc = AbstractModelElement.getValuesByName(node, "vfc"); + timeWindow = AbstractModelElement.getValueByName(node, "timeWindow"); + ageLimit = AbstractModelElement.getValueByName(node, "ageLimit"); + createClosedLoopEventId = AbstractModelElement.getValueByName(node, "createClosedLoopEventId"); + outputEventName = AbstractModelElement.getValueByName(node, "outputEventName"); // process the stringSet fields JsonNode ssNodes = node.findPath("stringSet"); diff --git a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java index 7fcc1b1b9..b74e7d134 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java @@ -59,7 +59,7 @@ import java.util.List; * "outputEventName","value":["ABATED"]}]]}]}} * */ -public class StringMatch extends ModelElement { +public class StringMatch extends AbstractModelElement { private List resourceGroups; diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java index 6bc68e23d..f7bbac0de 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java @@ -48,7 +48,7 @@ import java.util.List; * * */ -public class Tca extends ModelElement { +public class Tca extends AbstractModelElement { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); diff --git a/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java b/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java index aa1abde17..f104b0917 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java @@ -70,17 +70,17 @@ public class TcaItem { */ public TcaItem(JsonNode node) { - tcaName = ModelElement.getValueByName(node, "tname"); - tcaUuId = ModelElement.getValueByName(node, "tuuid"); - nfNamingCode = ModelElement.getValueByName(node, "tnfc"); - tcaEnable = ModelElement.getValueByName(node, "tcaEnab"); - policyId = ModelElement.getValueByName(node, "tcaPolId"); - if (ModelElement.getValueByName(node, "tcaInt") != null) { - interval = Integer.valueOf(ModelElement.getValueByName(node, "tcaInt")); + tcaName = AbstractModelElement.getValueByName(node, "tname"); + tcaUuId = AbstractModelElement.getValueByName(node, "tuuid"); + nfNamingCode = AbstractModelElement.getValueByName(node, "tnfc"); + tcaEnable = AbstractModelElement.getValueByName(node, "tcaEnab"); + policyId = AbstractModelElement.getValueByName(node, "tcaPolId"); + if (AbstractModelElement.getValueByName(node, "tcaInt") != null) { + interval = Integer.valueOf(AbstractModelElement.getValueByName(node, "tcaInt")); } - severity = ModelElement.getValueByName(node, "tcaSev"); - if (ModelElement.getValueByName(node, "tcaVio") != null) { - violations = Integer.valueOf(ModelElement.getValueByName(node, "tcaVio")); + severity = AbstractModelElement.getValueByName(node, "tcaSev"); + if (AbstractModelElement.getValueByName(node, "tcaVio") != null) { + violations = Integer.valueOf(AbstractModelElement.getValueByName(node, "tcaVio")); } // process service Configurations 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 ff4cfda17..920bce181 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -500,9 +500,6 @@ public class CldsService extends SecureServiceBase { if (test != null && test.equalsIgnoreCase("true")) { isTest = true; } else { - // if action.test.override is true, then any action will be marked - // as test=true (even if incoming action request had test=false); - // otherwise, test flag will be unchanged on the action request String actionTestOverride = refProp.getStringValue("action.test.override"); if (actionTestOverride != null && actionTestOverride.equalsIgnoreCase("true")) { logger.info("PUT actionTestOverride={}", actionTestOverride); @@ -666,8 +663,7 @@ public class CldsService extends SecureServiceBase { /** * REST service that retrieves total properties by using invariantUUID based * on refresh and non refresh - * - * @throws Exception + * */ @ApiOperation(value = "Retrieves total properties by using invariantUUID based on refresh and non refresh", notes = "", response = String.class) @GET @@ -675,7 +671,7 @@ public class CldsService extends SecureServiceBase { @Produces(MediaType.APPLICATION_JSON) public String getSdcPropertiesByServiceUUIDForRefresh( @PathParam("serviceInvariantUUID") String serviceInvariantUUID, - @DefaultValue("false") @QueryParam("refresh") String refresh) throws Exception { + @DefaultValue("false") @QueryParam("refresh") String refresh) { Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: GET sdc properties by uuid", getPrincipalName()); CldsServiceData cldsServiceData = new CldsServiceData(); @@ -901,7 +897,7 @@ public class CldsService extends SecureServiceBase { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public CldsModel deployModel(@PathParam("action") String action, @PathParam("modelName") String modelName, - @QueryParam("test") String test, CldsModel model) throws Exception { + @QueryParam("test") String test, CldsModel model) throws IOException { Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: Deploy model", getPrincipalName()); String deploymentId = "closedLoop_" + UUID.randomUUID() + "_deploymentId"; diff --git a/src/main/java/org/onap/clamp/clds/service/CldsUser.java b/src/main/java/org/onap/clamp/clds/service/CldsUser.java index 9db1e6078..34a3f8ea2 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsUser.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsUser.java @@ -71,7 +71,7 @@ public class CldsUser { } public String[] getPermissionsString() { - return Arrays.stream(getPermissions()).map(perm -> perm.getKey()).toArray(String[]::new); + return Arrays.stream(getPermissions()).map(SecureServicePermission::getKey).toArray(String[]::new); } /** diff --git a/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java b/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java index 20b85d6f6..a283f43d4 100644 --- a/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java +++ b/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java @@ -40,11 +40,11 @@ import org.onap.clamp.clds.model.prop.ModelProperties; public class SdcReqTest { - String baseUrl = "AYBABTU"; + String baseUrl = "AYBABTU"; String serviceInvariantUUID = "serviceInvariantUUID"; @Test - public void getSdcReqUrlsListNoGlobalPropTest() throws Exception { + public void getSdcReqUrlsListNoGlobalPropTest() { ModelProperties prop = mock(ModelProperties.class); SdcCatalogServices sdcCatalogServices = mock(SdcCatalogServices.class); DelegateExecution delegateExecution = mock(DelegateExecution.class); diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java index 19fad4805..69df97212 100644 --- a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java +++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java @@ -119,7 +119,7 @@ public class PolicyClientIT extends AbstractIT { try { responseMessage = policyClient.sendMicroServiceInJson(policyJson, prop, tcaPolicyRequestUuid); } catch (Exception e) { - assertTrue(e.getMessage().contains("Policy send failed: PE500 ")); + assertTrue(e.getMessage().contains("Exception while communicating with Policy")); } System.out.println(responseMessage); } diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java index 5d08e5ec0..a12d6b7d5 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java @@ -202,9 +202,10 @@ public class SdcCatalogServicesIT extends AbstractIT { @Test public void getServiceUuidFromServiceInvariantIdTest() throws Exception { SdcCatalogServices spy = Mockito.spy(sdcCatalogWired); - Mockito.when(spy.getSdcServicesInformation(null)).thenReturn(IOUtils.toString( - SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")); + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")) + .when(spy).getSdcServicesInformation(null); // Try the vcts4 version 1.0, this one should be replaced by 1.1 so it // should not exist, returning empty string String resUuidVcts4Null = spy.getServiceUuidFromServiceInvariantId("a33ed748-3477-4434-b3f3-b5560f5e7d9b"); @@ -228,8 +229,10 @@ public class SdcCatalogServicesIT extends AbstractIT { @Test public void getCldsServiceDataWithAlarmConditionsTest() throws Exception { SdcCatalogServices spy = Mockito.spy(sdcCatalogWired); - Mockito.when(spy.getSdcServicesInformation(null)).thenReturn(IOUtils.toString( - SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")); + + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")) + .when(spy).getSdcServicesInformation(null); // This invariant uuid is the one from vcts4 v1.1 String serviceResourceDetailUrl = refProp.getStringValue("sdc.serviceUrl") @@ -286,7 +289,8 @@ public class SdcCatalogServicesIT extends AbstractIT { assertTrue("29018914-966c-442d-9d08-251b9dc45b8f".equals(cldsServiceData.getServiceUUID())); assertTrue(cldsServiceData.getCldsVfs().size() == 1); - List alarmsList = spy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData, "alarmCondition"); + List alarmsList = spy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData, + "alarmCondition"); assertTrue(alarmsList.size() == 6); } diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java index c6b19d0f9..03d7d65da 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java @@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; /** * A CustomModelElement to test the capability to add new elements on the fly. */ -public class CustomModelElement extends ModelElement { +public class CustomModelElement extends AbstractModelElement { private static final String CUSTOM_TYPE = "customType"; -- cgit 1.2.3-korg From 97655250b373893157bfadd267ba21693b6fa905 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 8 Sep 2017 17:56:41 +0200 Subject: Remove class renamed as AbstractModelElement Remove a class that has been renamed to AbstractModelElement Change-Id: Ifbad3875da6265e3b092aceee0de801b19834d79 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/model/prop/ModelElement.java | 280 --------------------- 1 file changed, 280 deletions(-) delete mode 100644 src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java deleted file mode 100644 index edf114261..000000000 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java +++ /dev/null @@ -1,280 +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.model.prop; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Provide base ModelElement functionality. Perform base parsing of properties - * for a ModelElement (such as, Collector, StringMatch, Policy, Tca, Holmes, - * ...) - */ -public abstract class ModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelElement.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - private final String type; - private final ModelBpmn modelBpmn; - private final String id; - protected String topicPublishes; - protected final JsonNode modelElementJsonNode; - private boolean isFound; - - private final ModelProperties modelProp; - - /** - * Perform base parsing of properties for a ModelElement (such as, - * Collector, StringMatch, Policy and Tca) - * - * @param type - * @param modelProp - * @param modelBpmn - * @param modelJson - */ - protected ModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - this.type = type; - this.modelProp = modelProp; - this.modelBpmn = modelBpmn; - this.id = modelBpmn.getId(type); - this.modelElementJsonNode = modelJson.get(id); - this.isFound = modelBpmn.isModelElementTypeInList(type); - } - - /** - * topicSubscribes is the topicPublishes of the from Model Element (the - * previous one in the chain). - * - * @return the topicSubscribes - */ - public String getTopicSubscribes() { - // get fromId for this type - String fromId = modelBpmn.getFromId(type); - // find the type of the from model element - String fromType = modelBpmn.getType(fromId); - // get the model element for the type - ModelElement me = modelProp.getModelElementByType(fromType); - // get the topic publishes for the model element - return me.topicPublishes; - } - - /** - * @return the topicPublishes - */ - public String getTopicPublishes() { - return topicPublishes; - } - - /** - * Return the value field of the json node element that has a name field - * equals to the given name. - * - * @param nodeIn - * @param name - * @return - */ - public static String getValueByName(JsonNode nodeIn, String name) { - String value = null; - if (nodeIn != null) { - for (JsonNode node : nodeIn) { - if (node.path("name").asText().equals(name)) { - JsonNode vnode = node.path("value"); - if (vnode.isArray()) { - // if array, assume value is in first element - value = vnode.path(0).asText(); - } else { - // otherwise, just return text - value = vnode.asText(); - } - } - } - } - if (value == null || value.length() == 0) { - logger.warn(name + "=" + value); - } else { - logger.debug(name + "=" + value); - } - return value; - } - - /** - * Return the value field of the json node element that has a name field - * that equals the given name. - * - * @param nodeIn - * @param name - * @return - */ - public static String getNodeValueByName(JsonNode nodeIn, String name) { - String value = null; - if (nodeIn != null) { - value = nodeIn.path(name).asText(); - } - if (value == null || value.length() == 0) { - logger.warn(name + "=" + value); - } else { - logger.debug(name + "=" + value); - } - return value; - } - - /** - * Return the value field of the json node element that has a name field - * that equals the given name. - * - * @param nodeIn - * @param name - * @return - */ - public static List getNodeValuesByName(JsonNode nodeIn, String name) { - List values = new ArrayList<>(); - if (nodeIn != null) { - Iterator i = nodeIn.iterator(); - while (i.hasNext()) { - JsonNode node = i.next(); - if (node.path("name").asText().equals(name)) { - JsonNode vnode = node.path("value"); - if (vnode.isArray()) { - // if array, assume value is in first element - values.add(vnode.path(0).asText()); - } else { - // otherwise, just return text - values.add(vnode.asText()); - } - } - } - } - return values; - } - - /** - * Return the int value field of the json node element that has a name field - * equals to the given name. - * - * @param nodeIn - * @param name - * @return - */ - public static Integer getIntValueByName(JsonNode nodeIn, String name) { - String value = getValueByName(nodeIn, name); - return Integer.valueOf(value); - } - - /** - * Return an array of values for the field of the json node element that has - * a name field equals to the given name. - * - * @param nodeIn - * @param name - * @return - */ - public static List getValuesByName(JsonNode nodeIn, String name) { - List values = null; - if (nodeIn != null) { - Iterator i = nodeIn.iterator(); - while (i.hasNext()) { - JsonNode node = i.next(); - if (node.path("name").asText().equals(name)) { - values = getValuesList(node); - } - } - } - if (values == null || values.isEmpty()) { - logger.warn(name + "=" + values); - } else { - logger.debug(name + "=" + values); - } - return values; - } - - /** - * Return an array of String values. - * - * @param nodeIn - * @return - */ - public static List getValuesList(JsonNode nodeIn) { - ArrayList al = new ArrayList<>(); - if (nodeIn != null) { - Iterator itr = nodeIn.path("value").elements(); - while (itr.hasNext()) { - JsonNode node = itr.next(); - al.add(node.asText()); - } - } - return al; - } - - /** - * Return the value field of the json node element that has a name field - * equals to the given name. - * - * @param name - * @return - */ - public String getValueByName(String name) { - return getValueByName(modelElementJsonNode, name); - } - - /** - * Return the int value field of the json node element that has a name field - * equals to the given name. - * - * @param name - * @return - */ - public Integer getIntValueByName(String name) { - return getIntValueByName(modelElementJsonNode, name); - } - - /** - * Return an array of values for the field of the json node element that has - * a name field equals to the given name. - * - * @param name - * @return - */ - public List getValuesByName(String name) { - return getValuesByName(modelElementJsonNode, name); - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - /** - * @return the isFound - */ - public boolean isFound() { - return isFound; - } -} -- cgit 1.2.3-korg From 676a7325b3240d69270330928a00b7b2ec8e3861 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Mon, 11 Sep 2017 13:23:12 +0200 Subject: Fix Holmes delegates and sdc Fix holmes delegates not declared in the cldsconfiguration and SDC IT tests that reports some exceptions Change-Id: I19dae11ad994e78e1f71fc78a2ff4627d91e66c1 Issue-Id: CLAMP-27 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/config/CldsConfiguration.java | 12 + .../onap/clamp/clds/it/SdcCatalogServicesIT.java | 82 +- .../example/sdc/sdcCVFCResourceExample.json | 54 + .../example/sdc/sdcVFCResourceExample.json | 28 + .../resources/example/sdc/sdcVFCResourcesList.json | 2786 ++++++++++++++++++++ 5 files changed, 2934 insertions(+), 28 deletions(-) create mode 100644 src/test/resources/example/sdc/sdcCVFCResourceExample.json create mode 100644 src/test/resources/example/sdc/sdcVFCResourceExample.json create mode 100644 src/test/resources/example/sdc/sdcVFCResourcesList.json (limited to 'src/main/java') 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 eee179111..fa0ca9615 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java @@ -37,6 +37,8 @@ import org.onap.clamp.clds.client.DcaeDispatcherServices; import org.onap.clamp.clds.client.DcaeInventoryServices; import org.onap.clamp.clds.client.DcaeReqDelegate; import org.onap.clamp.clds.client.DcaeReqDeleteDelegate; +import org.onap.clamp.clds.client.HolmesPolicyDelegate; +import org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate; import org.onap.clamp.clds.client.OperationalPolicyDelegate; import org.onap.clamp.clds.client.OperationalPolicyDeleteDelegate; import org.onap.clamp.clds.client.PolicyClient; @@ -172,4 +174,14 @@ public class CldsConfiguration { return new TcaPolicyDeleteDelegate(); } + @Bean(name = "holmesPolicyDelegate") + public HolmesPolicyDelegate getHolmesPolicyDelegate() { + return new HolmesPolicyDelegate(); + } + + @Bean(name = "holmesPolicyDeleteDelegate") + public HolmesPolicyDeleteDelegate getHolmesPolicyDeleteDelegate() { + return new HolmesPolicyDeleteDelegate(); + } + } \ No newline at end of file diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java index a12d6b7d5..2995b6c8d 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java @@ -237,51 +237,77 @@ public class SdcCatalogServicesIT extends AbstractIT { // This invariant uuid is the one from vcts4 v1.1 String serviceResourceDetailUrl = refProp.getStringValue("sdc.serviceUrl") + "/29018914-966c-442d-9d08-251b9dc45b8f/metadata"; - Mockito.when(spy.getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl, false)) - .thenReturn(IOUtils.toString( - SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServiceDetailsExample.json"), - "UTF-8")); + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServiceDetailsExample.json"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl, false); String resourceDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources/585822c7-4027-4f84-ba50-e9248606f136/metadata"; - Mockito.when(spy.getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl, false)) - .thenReturn(IOUtils.toString( - SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcResourceDetailsExample.json"), - "UTF-8")); + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcResourceDetailsExample.json"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl, false); String securityRulesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/metadata"; - Mockito.when(spy.getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl, false)).thenReturn( - IOUtils.toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcSecurityRules.json"), - "UTF-8")); + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcSecurityRules.json"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl, false); String cinderVolumeDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources/b4288e07-597a-44a2-aa98-ad36e551a39d/metadata"; - Mockito.when(spy.getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl, false)).thenReturn( - IOUtils.toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcCinderVolume.json"), - "UTF-8")); + Mockito.doReturn(IOUtils + .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcCinderVolume.json"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl, false); String vfcGenericDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/metadata"; - Mockito.when(spy.getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl, false)).thenReturn(IOUtils.toString( - SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFCGenericWithAlarms.json"), "UTF-8")); + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFCGenericWithAlarms.json"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl, false); + + String csvAlarmsDetailUrl = refProp.getStringValue("sdc.catalog.url") + + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/resourceInstances/virc_fe_be/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392"; + Mockito.doReturn(IOUtils + .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl, false); - String csvDetailUrl = "/sdc/v1/catalog/resources/84855843-5247-4e97-a2bd-5395a510253b/artifacts/d57ac7ec-f3c3-4793-983a-c75ac3a43153"; - Mockito.when(spy.getResponsesFromArtifactUrl(csvDetailUrl)).thenReturn(IOUtils.toString( - SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcMeasurementsList.csv"), "UTF-8")); + Mockito.doReturn(IOUtils + .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl, true); - String csvAlarmsDetailUrl = "/sdc/v1/catalog/resources/2c8f1219-8000-4001-aa13-496a0396d40f/resourceInstances/virc_fe_be/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392"; - Mockito.when(spy.getResponsesFromArtifactUrl(csvAlarmsDetailUrl)).thenReturn(IOUtils - .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8")); + String csvAlarmsDetailUrl2 = refProp.getStringValue("sdc.catalog.url") + + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392"; + Mockito.doReturn(IOUtils + .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl2, true); String allVfResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VF"; - Mockito.when(spy.getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl, false)).thenReturn(IOUtils - .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFResources.json"), "UTF-8")); + Mockito.doReturn(IOUtils + .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFResources.json"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl, false); + + String cVfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + + "resources/a0475018-1e7e-4ddd-8bee-33cbf958c2e6/metadata"; + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcCVFCResourceExample.json"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(cVfcResourcesDetailUrl, false); String allVfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VFC"; - Mockito.when(spy.getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl, false)).thenReturn( - IOUtils.toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFCResources.json"), - "UTF-8")); + Mockito.doReturn(IOUtils + .toString(SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFCResources.json"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl, false); + + String allVfAlarms = refProp.getStringValue("sdc.catalog.url") + + "resources/84855843-5247-4e97-a2bd-5395a510253b/artifacts/d57ac7ec-f3c3-4793-983a-c75ac3a43153"; + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcMeasurementsList.csv"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfAlarms, true); + + String vfcResourceExample = refProp.getStringValue("sdc.catalog.url") + + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/metadata"; + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcVFCResourceExample.json"), "UTF-8")) + .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourceExample, false); CldsServiceData cldsServiceData = spy .getCldsServiceDataWithAlarmConditions("a33ed748-3477-4434-b3f3-b5560f5e7d9c"); @@ -291,7 +317,7 @@ public class SdcCatalogServicesIT extends AbstractIT { List alarmsList = spy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData, "alarmCondition"); - assertTrue(alarmsList.size() == 6); + assertTrue(alarmsList.size() == 12); } diff --git a/src/test/resources/example/sdc/sdcCVFCResourceExample.json b/src/test/resources/example/sdc/sdcCVFCResourceExample.json new file mode 100644 index 000000000..ffda413d3 --- /dev/null +++ b/src/test/resources/example/sdc/sdcCVFCResourceExample.json @@ -0,0 +1,54 @@ +{ + "uuid": "a0475018-1e7e-4ddd-8bee-33cbf958c2e6", + "invariantUUID": "133dd665-fca8-4e8b-8126-9e74a8d23bf5", + "name": "CLAMP-Dev-nodes.virc_fe_be_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a0475018-1e7e-4ddd-8bee-33cbf958c2e6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "CVFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740", + "lastUpdaterFullName": "Zero ASDCMech", + "toscaResourceName": "org.openecomp.resource.vfc.ClampDev.abstract.nodes.virc_fe_be_0", + "resources": [ + { + "resourceInstanceName": "virc_fe_be_virc_fe_be_management_0_port", + "resourceName": "NeutronPort", + "resourceInvariantUUID": "10428340-a673-4377-8696-af579a2e67a8", + "resourceVersion": "5.0", + "resoucreType": "CP", + "resourceUUID": "045f3be0-7398-455b-8f0d-8eff2062a187" + }, + { + "resourceInstanceName": "virc_fe_be", + "resourceName": "ClampDev.nodes.heat.virc_fe_be", + "resourceInvariantUUID": "e81d960d-794c-4d86-bbc4-31a2f86141ed", + "resourceVersion": "1.0", + "resoucreType": "VFC", + "resourceUUID": "d7646638-2572-4a94-b497-c028ac15f9ca", + "artifacts": [ + { + "artifactName": "Fault-alarms-ASDC-vprobes-vLB.csv", + "artifactType": "SNMP_TRAP", + "artifactURL": "/sdc/v1/catalog/resources/a0475018-1e7e-4ddd-8bee-33cbf958c2e6/resourceInstances/virc_fe_be/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392", + "artifactDescription": "Artifact created from csar", + "artifactChecksum": "YWY2ZTY5NjhlOTU0YjQyZThhNTIyOGFmNzI1NTRiYzQ=", + "artifactUUID": "5138e316-0237-49aa-817a-b3d8eaf77392", + "artifactVersion": "1", + "artifactLabel": "faultalarmsasdcvprobesvlbcsv", + "artifactGroupType": "DEPLOYMENT" + } + ] + }, + { + "resourceInstanceName": "virc_fe_be_virc_fe_be_data_1_port", + "resourceName": "NeutronPort", + "resourceInvariantUUID": "10428340-a673-4377-8696-af579a2e67a8", + "resourceVersion": "5.0", + "resoucreType": "CP", + "resourceUUID": "045f3be0-7398-455b-8f0d-8eff2062a187" + } + ], + "description": "Complex node type that is used as nested type in VF" +} \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcVFCResourceExample.json b/src/test/resources/example/sdc/sdcVFCResourceExample.json new file mode 100644 index 000000000..85b46c5ea --- /dev/null +++ b/src/test/resources/example/sdc/sdcVFCResourceExample.json @@ -0,0 +1,28 @@ +{ + "uuid": "d7646638-2572-4a94-b497-c028ac15f9ca", + "invariantUUID": "e81d960d-794c-4d86-bbc4-31a2f86141ed", + "name": "ClampDev.nodes.heat.virc_fe_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d7646638-2572-4a94-b497-c028ac15f9ca/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740", + "lastUpdaterFullName": "Zero ASDCMech", + "toscaResourceName": "org.openecomp.resource.vfc.Clampdev.abstract.nodes.heat.virc_fe_be", + "artifacts": [ + { + "artifactName": "Fault-alarms-ASDC-vprobes-vLB.csv", + "artifactType": "SNMP_TRAP", + "artifactURL": "/sdc/v1/catalog/resources/d7646638-2572-4a94-b497-c028ac15f9ca/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392", + "artifactDescription": "Artifact created from csar", + "artifactChecksum": "YWY2ZTY5NjhlOTU0YjQyZThhNTIyOGFmNzI1NTRiYzQ=", + "artifactUUID": "5138e316-0237-49aa-817a-b3d8eaf77392", + "artifactVersion": "1", + "artifactLabel": "faultalarmsasdcvprobesvlbcsv", + "artifactGroupType": "DEPLOYMENT" + } + ], + "description": "Not reusable inner VFC" +} \ No newline at end of file diff --git a/src/test/resources/example/sdc/sdcVFCResourcesList.json b/src/test/resources/example/sdc/sdcVFCResourcesList.json new file mode 100644 index 000000000..d99089cfd --- /dev/null +++ b/src/test/resources/example/sdc/sdcVFCResourcesList.json @@ -0,0 +1,2786 @@ +[ + { + "uuid": "b3538c76-7d58-4e15-9a06-b51b32101965", + "invariantUUID": "18a4a3c3-876f-4452-8cf0-fb3ebaf5344e", + "name": "VfNoLicense.nodes.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b3538c76-7d58-4e15-9a06-b51b32101965/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "da3c740a-e8af-4b85-a487-b4961b040fa3", + "invariantUUID": "2a477fa7-ac1b-4a62-baa1-e94c764d736b", + "name": "ScpTestVsp.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/da3c740a-e8af-4b85-a487-b4961b040fa3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "b31696d9-ad41-4cb5-bbdd-3e67845204f3", + "invariantUUID": "2b07e8fa-998d-4311-8ec0-61b86c798de9", + "name": "VpeBvRenana.nodes.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b31696d9-ad41-4cb5-bbdd-3e67845204f3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "25b74ab6-565b-424f-bb57-b434bb2944a0", + "invariantUUID": "ed69ed4f-80cd-48b5-86d5-4b5de21041be", + "name": "VpeBvRenana.nodes.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/25b74ab6-565b-424f-bb57-b434bb2944a0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "c13dc4c4-f4cb-4a54-9198-5bce42c5df02", + "invariantUUID": "6a828e59-cbee-4dc2-aa67-ee35a6eafd50", + "name": "Dev2devnfod.nodes.VF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c13dc4c4-f4cb-4a54-9198-5bce42c5df02/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + { + "uuid": "08e94ce5-79e8-4873-9221-eb9e869ac679", + "invariantUUID": "da9ea806-971a-4338-bee7-6feeea270d8a", + "name": "Vprobe.nodes.vprobe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/08e94ce5-79e8-4873-9221-eb9e869ac679/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "0d8f93f5-780e-47de-9b03-52ab31cb83d1", + "invariantUUID": "ce47044b-a00e-43d3-8aae-df047e6abe2e", + "name": "Vprobe.nodes.vLB", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0d8f93f5-780e-47de-9b03-52ab31cb83d1/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "9140709a-d6a9-4690-b102-6fa96a696ce9", + "invariantUUID": "0c3d1be0-f4d8-4b0a-8cc8-05989de29dfc", + "name": "Dev2devnfod1207.nodes.VF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/9140709a-d6a9-4690-b102-6fa96a696ce9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + { + "uuid": "6607c9fc-dc1d-4a89-ac57-b6b18fc79b69", + "invariantUUID": "7a17e445-0400-40bf-8bf6-91105996e19e", + "name": "Dev2devnfodvf.nodes.VF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/6607c9fc-dc1d-4a89-ac57-b6b18fc79b69/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + { + "uuid": "3cb0c46c-af73-4420-ae5c-d4816b314980", + "invariantUUID": "0e332f76-d6f8-4e16-b2eb-bb1ccadec523", + "name": "volume", + "version": "4.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3cb0c46c-af73-4420-ae5c-d4816b314980/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "b4288e07-597a-44a2-aa98-ad36e551a39d", + "invariantUUID": "61dc85d2-5e17-480e-a71f-8f6d59a0ead2", + "name": "CinderVolume", + "version": "5.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b4288e07-597a-44a2-aa98-ad36e551a39d/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "156d628f-f515-4f58-bfb0-210632717ce3", + "invariantUUID": "cdafff07-0bbb-45f6-8a48-46ed2c98f29c", + "name": "VfDemor.nodes.heat.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/156d628f-f515-4f58-bfb0-210632717ce3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "28eeb6ce-2349-4c07-80ad-f0aacbf67028", + "invariantUUID": "ae71f982-2393-4fd7-8a69-c0050880e7c5", + "name": "Dev2devipassign2407.nodes.heat.pd_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/28eeb6ce-2349-4c07-80ad-f0aacbf67028/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + { + "uuid": "f89e37a8-c5c0-4c0c-a034-f6c0ad8dd83f", + "invariantUUID": "59061740-4700-4800-83f1-0427f1ed1b8c", + "name": "Vmme1710.nodes.heat.ncb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f89e37a8-c5c0-4c0c-a034-f6c0ad8dd83f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "8263c4c5-555e-4b73-9210-ddc8dd7e42f8", + "invariantUUID": "a7b9db4c-685a-416c-a2ed-7711b1492cd3", + "name": "VnfcVspTest.nodes.heat.rdn", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8263c4c5-555e-4b73-9210-ddc8dd7e42f8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "dd7218d7-5760-4834-b78a-33edf5eb22e7", + "invariantUUID": "47be1ccb-856d-4d95-9722-f9d1913fe9df", + "name": "VnfcVspTest.nodes.heat.prx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/dd7218d7-5760-4834-b78a-33edf5eb22e7/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "10906cdf-dbec-405a-a513-7ed2090a5adb", + "invariantUUID": "746709d9-38fb-40af-88b0-856f6fadeb02", + "name": "VfExample.nodes.heat.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/10906cdf-dbec-405a-a513-7ed2090a5adb/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "e0ee89f0-175b-47d8-8258-1ac6ea6d52a8", + "invariantUUID": "a0d6e34d-c260-46ff-a55f-79fbce461ec2", + "name": "Vmme1710.nodes.heat.fsb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e0ee89f0-175b-47d8-8258-1ac6ea6d52a8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "e45c5438-0528-4a3d-bfa4-644b2343537c", + "invariantUUID": "cd1aa4fc-94bb-4e23-86b4-0e7b89c8cab8", + "name": "Vmme1710.nodes.heat.gpb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e45c5438-0528-4a3d-bfa4-644b2343537c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "ba541b5b-7d06-4198-adf9-c035b374cdb3", + "invariantUUID": "c2f34d4b-3c45-4367-a6f7-e9c06ad19607", + "name": "Newswproductnamefield.nodes.heat.ltm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ba541b5b-7d06-4198-adf9-c035b374cdb3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "e84b8370-ffb7-4f6c-a242-ab3f340617fa", + "invariantUUID": "c6808001-bc29-4896-a187-06c41a341a18", + "name": "Alaram.nodes.heat.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e84b8370-ffb7-4f6c-a242-ab3f340617fa/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "512ea41b-b9ac-412a-95ee-ac7410c2b6b2", + "invariantUUID": "9252564a-de36-4048-8a53-3923a6cb4b11", + "name": "Rony0620111.nodes.heat.rdn", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/512ea41b-b9ac-412a-95ee-ac7410c2b6b2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "el489u" + }, + { + "uuid": "b4897fd9-7a50-492a-9e0c-054d044c1dcf", + "invariantUUID": "544f39a2-1306-472a-978b-9323439a7953", + "name": "RenanaTest2.nodes.heat.vlc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b4897fd9-7a50-492a-9e0c-054d044c1dcf/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "24413de0-35fd-4e1b-8052-51a1c798b24d", + "invariantUUID": "ca0ae539-78d1-461a-a7ff-3dd663c85e2d", + "name": "pnf-test", + "version": "1.1", + "toscaModelURL": "/sdc/v1/catalog/resources/24413de0-35fd-4e1b-8052-51a1c798b24d/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VFC", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "d3543795-31cd-4bb9-acd7-09249fdf0c5b", + "invariantUUID": "f1703a65-8898-4dcc-8584-f15c0227d59b", + "name": "Ldsa1.nodes.heat.ltm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d3543795-31cd-4bb9-acd7-09249fdf0c5b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "2b4c437e-9034-4ec3-b6f9-9309022673cf", + "invariantUUID": "39584568-5d64-4c63-9007-46b205ea4db8", + "name": "MadhuMdns.nodes.heat.dns", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2b4c437e-9034-4ec3-b6f9-9309022673cf/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "56cef7d0-af8c-4f18-80a2-e9aaf4366838", + "invariantUUID": "fab9a189-6bfa-4dfa-a4fe-2bfa4ff4e71b", + "name": "Alinavsp.nodes.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/56cef7d0-af8c-4f18-80a2-e9aaf4366838/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + { + "uuid": "d7646638-2572-4a94-b497-c028ac15f9ca", + "invariantUUID": "e81d960d-794c-4d86-bbc4-31a2f86141ed", + "name": "ClampDev.nodes.heat.virc_fe_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d7646638-2572-4a94-b497-c028ac15f9ca/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "39300382-8d78-4598-afa0-042613d6d8f7", + "invariantUUID": "7f6da2dc-0172-4e79-b152-adcee2ffc02f", + "name": "MnsoamDemo.nodes.heat.mnsoamvfw", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/39300382-8d78-4598-afa0-042613d6d8f7/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "1d614214-2bc7-45bd-ab85-801ed72888c0", + "invariantUUID": "c9e19a34-5c50-463c-a409-2b2b0cfbaeac", + "name": "Rony0620.nodes.heat.rdn", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1d614214-2bc7-45bd-ab85-801ed72888c0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "el489u" + }, + { + "uuid": "880e5d06-8c62-43f2-ac4a-befff414e63c", + "invariantUUID": "dd47c5d0-3145-467b-abf1-d1ace19aed04", + "name": "Alinatest.nodes.heat.TEST_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/880e5d06-8c62-43f2-ac4a-befff414e63c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + { + "uuid": "b58f9c1a-ad21-459d-9efa-a8924147cb90", + "invariantUUID": "a13cd6b9-c46e-4830-88ab-2b1c710a3b51", + "name": "sang_AR", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b58f9c1a-ad21-459d-9efa-a8924147cb90/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "27307a62-8512-4aeb-a0ad-e8e88643c2ba", + "invariantUUID": "91d1bde6-eb8e-4786-b7e6-193453662014", + "name": "SangVsp.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/27307a62-8512-4aeb-a0ad-e8e88643c2ba/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "c0cfa0b8-1214-4abc-bf4b-f71aed72f03b", + "invariantUUID": "37fcd63a-2d6e-4c42-8d63-183711976f9b", + "name": "multiFlavorVFC", + "version": "4.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c0cfa0b8-1214-4abc-bf4b-f71aed72f03b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "fd0e3baa-fef7-4096-be2f-a73fea2f1360", + "invariantUUID": "4aca7e14-e2e4-4aeb-868e-aaaecea0cc5d", + "name": "SangVsp.nodes.heat.prx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fd0e3baa-fef7-4096-be2f-a73fea2f1360/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "efc0c5f9-b900-4d6e-a8d9-746bfb400c6d", + "invariantUUID": "3f6b3916-cc98-475b-86d6-c1e8c376a004", + "name": "Ldsa.nodes.heat.ltm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/efc0c5f9-b900-4d6e-a8d9-746bfb400c6d/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "c003a901-a27e-49a4-bf3f-d9d8ca838f0a", + "invariantUUID": "5e38e500-80a6-4d80-b6d8-43af998f4680", + "name": "ciRes259e8de19526", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/c003a901-a27e-49a4-bf3f-d9d8ca838f0a/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "NOT_CERTIFIED_CHECKOUT", + "lastUpdaterUserId": "cs0008" + }, + { + "uuid": "eb54de4c-e180-4a89-8025-1d58267049f8", + "invariantUUID": "c22782e4-18ed-4ac6-b636-2c6df20003d9", + "name": "Rony0620.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/eb54de4c-e180-4a89-8025-1d58267049f8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "el489u" + }, + { + "uuid": "d555e4fc-5c42-4990-9a53-3cc998496595", + "invariantUUID": "aa31721d-d880-4923-af59-7b136a6f1f4f", + "name": "Simonafirst0814.nodes.heat.TEST_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d555e4fc-5c42-4990-9a53-3cc998496595/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ss1245" + }, + { + "uuid": "73c3f25a-88a2-4ac3-89a4-9c0ecf5a9b31", + "invariantUUID": "62073892-e518-4cbf-9d67-207998273b9e", + "name": "Simona2test0814.nodes.heat.TEST_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/73c3f25a-88a2-4ac3-89a4-9c0ecf5a9b31/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ss1245" + }, + { + "uuid": "a12dad87-6120-412f-8a53-c5bb88be89a3", + "invariantUUID": "84a7c06f-b3a7-448b-8777-626776b0b6bd", + "name": "Vmme1710.nodes.heat.vlc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a12dad87-6120-412f-8a53-c5bb88be89a3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "eabf4617-19da-4df2-b195-579309638c51", + "invariantUUID": "cec737a5-ffdf-41a0-bc2c-1d5be9726589", + "name": "MnsdmzDemo.nodes.heat.mnsdmzvfw", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/eabf4617-19da-4df2-b195-579309638c51/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "a14e3bbd-b04b-4924-817c-b4d13bfd8fe2", + "invariantUUID": "e205948e-5043-4cab-851d-e9e37f68736f", + "name": "VfExample.nodes.heat.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a14e3bbd-b04b-4924-817c-b4d13bfd8fe2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "fa5a2fa8-ae63-49c0-9f6c-5e5e2b7f9faa", + "invariantUUID": "0be62615-f136-404e-a3f7-fe13b2507319", + "name": "Rony0620111.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fa5a2fa8-ae63-49c0-9f6c-5e5e2b7f9faa/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "el489u" + }, + { + "uuid": "41dea130-9195-4d0b-97ba-8d86c0b00684", + "invariantUUID": "249fe495-f72d-44f7-aebc-0128070f8467", + "name": "Shani148softwareProduct.nodes.heat.ltm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/41dea130-9195-4d0b-97ba-8d86c0b00684/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "b8334449-de6b-4133-9c5d-1eb6c2736614", + "invariantUUID": "41f48075-4619-43bb-9885-b4e42537c2fc", + "name": "AlinaTest2.nodes.heat.TEST_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b8334449-de6b-4133-9c5d-1eb6c2736614/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + { + "uuid": "97b6b724-1d91-406f-90c7-4d4643b34630", + "invariantUUID": "cda126b1-bfa5-4b29-aafa-c116e648a17a", + "name": "Ddd.nodes.heat.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/97b6b724-1d91-406f-90c7-4d4643b34630/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "a902ec74-9415-4d5c-a14e-f0861a272407", + "invariantUUID": "40894528-2703-4652-86d0-463ac2af8c80", + "name": "NewVendorMdns.nodes.heat.dns", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a902ec74-9415-4d5c-a14e-f0861a272407/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "3127c05d-fe28-4d7f-9866-33d87943e082", + "invariantUUID": "574a5ef9-530d-4b28-a7ab-1777547a8be2", + "name": "Vgmux.nodes.heat.vgmux", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3127c05d-fe28-4d7f-9866-33d87943e082/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml636r" + }, + { + "uuid": "c17fc945-c327-469b-9912-f6d628cd6e4e", + "invariantUUID": "706253ae-7a68-4519-83d7-8f8842499246", + "name": "Rony0620111.nodes.heat.prx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c17fc945-c327-469b-9912-f6d628cd6e4e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "el489u" + }, + { + "uuid": "82646e24-0e94-416a-aae2-9df4b2aa6217", + "invariantUUID": "a966f23a-ce65-4ef1-8d9f-718510852415", + "name": "SangVsp.nodes.heat.rdn", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/82646e24-0e94-416a-aae2-9df4b2aa6217/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "f059ce03-14f3-46c3-a9b3-246404b2f9d0", + "invariantUUID": "c787dc43-4580-42a5-88a7-70f5d56b8f9f", + "name": "NfodCheckpoint.nodes.NFOD_VFC", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f059ce03-14f3-46c3-a9b3-246404b2f9d0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "8dfca155-2ff7-49b3-b563-cc9c80bc951d", + "invariantUUID": "0b2b2953-bc5a-43e2-baf7-3f57b520e87b", + "name": "RenanaTest.nodes.heat.vlc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8dfca155-2ff7-49b3-b563-cc9c80bc951d/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "b36dd1f0-f6aa-464d-b579-b5b75585ed44", + "invariantUUID": "81944c97-5936-4aab-835f-be41f8d8f52f", + "name": "RenanaTest.nodes.heat.ncb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b36dd1f0-f6aa-464d-b579-b5b75585ed44/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "b425c959-77e2-49bd-8865-dbdb59348b1a", + "invariantUUID": "a19c7920-fa0f-4afe-9db7-504152ab0116", + "name": "Infra.nodes.heat.vdns", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b425c959-77e2-49bd-8865-dbdb59348b1a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml636r" + }, + { + "uuid": "3f631e5f-5a89-48e1-9a22-ef4bff70041e", + "invariantUUID": "3e77e831-0a4d-4970-a351-0dd04ab6cd9d", + "name": "RenanaTest.nodes.heat.fsb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3f631e5f-5a89-48e1-9a22-ef4bff70041e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "a6c14d60-4705-4c73-a5a6-0210c9f0d8b7", + "invariantUUID": "f97f4614-c0db-4967-9a7a-c3491831e888", + "name": "Vbrgemu.nodes.heat.vbrgemu", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a6c14d60-4705-4c73-a5a6-0210c9f0d8b7/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml636r" + }, + { + "uuid": "f6b85fc7-0be4-408a-8682-66227e9a9788", + "invariantUUID": "4b307d10-8da4-41f3-803a-49e908ea3f15", + "name": "Vgw.nodes.heat.vgw", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f6b85fc7-0be4-408a-8682-66227e9a9788/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml636r" + }, + { + "uuid": "35014ae6-b3dd-4a06-9046-df1b54354d40", + "invariantUUID": "372178ed-2849-4626-a87e-9b5fd319c0ee", + "name": "RenanaTest2.nodes.heat.gpb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/35014ae6-b3dd-4a06-9046-df1b54354d40/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "5fe71b5f-c733-4500-b129-a2f5822ba6f2", + "invariantUUID": "6943da4b-d378-4ae3-b1cf-50c011bdc420", + "name": "Alina0831vsp.nodes.heat.TEST_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5fe71b5f-c733-4500-b129-a2f5822ba6f2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + { + "uuid": "1b81e5d3-4a08-4db5-84a9-09096ff0f5ad", + "invariantUUID": "b3a8245a-9571-4e7c-bb76-7664ab035c41", + "name": "RenanaTest2.nodes.heat.ncb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1b81e5d3-4a08-4db5-84a9-09096ff0f5ad/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "65624d26-fca6-4af0-bbdb-f3cc33b81417", + "invariantUUID": "d6105f5d-a2c2-481a-929f-b9f2b5700fdf", + "name": "RenanaTest2.nodes.heat.fsb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/65624d26-fca6-4af0-bbdb-f3cc33b81417/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "3445e9cf-056a-4f0f-b0c3-a151cf9f3c5c", + "invariantUUID": "61017bfa-4ed3-4027-9942-5abbbce2d55a", + "name": "Demo1234.nodes.first", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3445e9cf-056a-4f0f-b0c3-a151cf9f3c5c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "78ff76c9-23d2-44c4-b0da-2492d93490b9", + "invariantUUID": "745995d0-6bf0-49d4-895f-32d554a7c333", + "name": "vnfConfiguration", + "version": "4.0", + "toscaModelURL": "/sdc/v1/catalog/resources/78ff76c9-23d2-44c4-b0da-2492d93490b9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "3ce98526-e5b6-4b40-99a1-916cca22b652", + "invariantUUID": "b5c65aea-949f-4fc9-928c-3a80619ffa8b", + "name": "Rony0620.nodes.heat.prx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3ce98526-e5b6-4b40-99a1-916cca22b652/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "el489u" + }, + { + "uuid": "aae2edf9-690a-4633-a6ff-d7556ab9ce58", + "invariantUUID": "c76ccbe5-7087-4eb4-a0ff-2edd7d9a392c", + "name": "ContrailV2VirtualMachineInterface", + "version": "7.0", + "toscaModelURL": "/sdc/v1/catalog/resources/aae2edf9-690a-4633-a6ff-d7556ab9ce58/toscaModel", + "category": "Generic", + "subCategory": "Network Elements", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "5a8831a3-d481-49ce-b029-754e37e4bc07", + "invariantUUID": "c319246f-3d23-4004-ac5b-ce65cb4135a0", + "name": "Infra.nodes.heat.vdhcp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5a8831a3-d481-49ce-b029-754e37e4bc07/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml636r" + }, + { + "uuid": "5c94528b-c068-4ece-9903-2a206e7b653b", + "invariantUUID": "cdc9d941-476d-4f55-a03d-215d8e9a5dca", + "name": "Infra.nodes.heat.vweb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5c94528b-c068-4ece-9903-2a206e7b653b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml636r" + }, + { + "uuid": "0b62cd13-b416-40fc-904b-b071f22134cd", + "invariantUUID": "d1a976cb-5d76-4206-a644-119c1bdf9d93", + "name": "Vbng.nodes.heat.vbng", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0b62cd13-b416-40fc-904b-b071f22134cd/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml636r" + }, + { + "uuid": "ee55b9c4-6ea2-4351-bf6e-f88f38130fd8", + "invariantUUID": "a059a8c6-f7c2-4048-84fc-ca6f5878f0ec", + "name": "VctsAlina.nodes.heat.TEST_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ee55b9c4-6ea2-4351-bf6e-f88f38130fd8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + { + "uuid": "c01c047d-395f-44fa-a34f-dc3f9c51c92c", + "invariantUUID": "23f8cb05-885d-4423-bae0-0d043f3c350c", + "name": "WebApplication", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c01c047d-395f-44fa-a34f-dc3f9c51c92c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "143166ba-bb54-4a38-b3c5-24850a16a283", + "invariantUUID": "b55f6660-646a-448a-91c2-a7d12bba8039", + "name": "Ddd.nodes.heat.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/143166ba-bb54-4a38-b3c5-24850a16a283/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "d6554a01-a3db-4dfe-8f41-af3866e18fa0", + "invariantUUID": "20e8590f-4134-4ee7-b908-a2c81a831128", + "name": "Alina0815vsp.nodes.heat.TEST_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d6554a01-a3db-4dfe-8f41-af3866e18fa0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + { + "uuid": "5fc1e5d4-1015-4614-b486-8727eb5e388b", + "invariantUUID": "19bf4492-3bdb-4d62-966d-2e2498e1891c", + "name": "Root", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5fc1e5d4-1015-4614-b486-8727eb5e388b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "90024548-1f2c-4267-b3f7-b64b2b7174d5", + "invariantUUID": "589dd9ec-222b-497b-aa50-b529fdece780", + "name": "Ddd.nodes.heat.fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/90024548-1f2c-4267-b3f7-b64b2b7174d5/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "592fb9b5-aace-4c14-8e10-f1214cc532f0", + "invariantUUID": "d81200b8-5427-4415-b5c3-d98963a48c43", + "name": "Infra.nodes.heat.vaaa", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/592fb9b5-aace-4c14-8e10-f1214cc532f0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml636r" + }, + { + "uuid": "73b40185-4478-402c-8951-2dd03b3e0e3c", + "invariantUUID": "fa7a3bb4-5892-4c19-a8c6-b0fa7b11102e", + "name": "NSD", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/73b40185-4478-402c-8951-2dd03b3e0e3c/toscaModel", + "category": "Allotted Resource", + "subCategory": "Contrail Route", + "resourceType": "VFC", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "ml636r" + }, + { + "uuid": "61214be3-e560-44cc-877b-d484bcc2ee79", + "invariantUUID": "88a9f65b-94a0-4530-a17e-adaada70838d", + "name": "BlockStorage", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/61214be3-e560-44cc-877b-d484bcc2ee79/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "efb54bab-a842-48b3-842a-dffb000acf1f", + "invariantUUID": "cb2574f8-0b75-4ea1-8517-acba650ba72f", + "name": "Database", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/efb54bab-a842-48b3-842a-dffb000acf1f/toscaModel", + "category": "Generic", + "subCategory": "Database", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "42315f4b-660e-44a5-b4bb-7fb80087de69", + "invariantUUID": "873af5a3-8f36-4199-b46a-9613f149de1e", + "name": "RenanaTest.nodes.heat.gpb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/42315f4b-660e-44a5-b4bb-7fb80087de69/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "4066e7da-0dba-4d0b-b74c-c30446ed277e", + "invariantUUID": "75c5fbc6-4366-4163-af9c-1a43bdb90425", + "name": "AbstractSubstitute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4066e7da-0dba-4d0b-b74c-c30446ed277e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "b39e436d-47b0-4509-95d6-8a63e2c722d1", + "invariantUUID": "0790aa94-5b47-4100-b26a-4cabd9639698", + "name": "ObjectStorage", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b39e436d-47b0-4509-95d6-8a63e2c722d1/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "94b8f588-624c-4e61-9ead-32aaadd8cf65", + "invariantUUID": "57eecece-2079-4a5d-9627-4fde30434552", + "name": "ContrailNetworkRules", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/94b8f588-624c-4e61-9ead-32aaadd8cf65/toscaModel", + "category": "Generic", + "subCategory": "Rules", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "fa17c264-7f19-4919-a1d4-aab5c53b9c32", + "invariantUUID": "b0a7ddd2-429e-493c-ba05-fe9440b49b54", + "name": "SoftwareComponent", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fa17c264-7f19-4919-a1d4-aab5c53b9c32/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "76ba485f-50a3-480d-895e-5c319191bc11", + "invariantUUID": "cf3ccc9c-b6ea-468e-8eef-f45479978fc1", + "name": "Allotedresource", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/76ba485f-50a3-480d-895e-5c319191bc11/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99124" + }, + { + "uuid": "1909a305-e032-46ce-9278-c751659958cc", + "invariantUUID": "aa9abf65-5a91-4c6f-814e-47b5fa06ccbd", + "name": "Allotted resource 123456", + "version": "0.1", + "toscaModelURL": "/sdc/v1/catalog/resources/1909a305-e032-46ce-9278-c751659958cc/toscaModel", + "category": "Allotted Resource", + "subCategory": "Allotted Resource", + "resourceType": "VFC", + "lifecycleState": "NOT_CERTIFIED_CHECKIN", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "64fb42a4-7c3d-415b-afd0-1949abef550a", + "invariantUUID": "3bbcb293-24ff-4370-b46a-9233c92c1469", + "name": "ContrailAbstractSubstitute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/64fb42a4-7c3d-415b-afd0-1949abef550a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "c3ed93e4-4955-4100-8f4b-c9472cb3f28f", + "invariantUUID": "29e31a72-10c4-453d-99e6-76e0fe0f7a99", + "name": "Tuesdayvsp.nodes.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c3ed93e4-4955-4100-8f4b-c9472cb3f28f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + { + "uuid": "a71b3246-b54e-4646-bd6f-d5a11d4878df", + "invariantUUID": "b91e1d84-c9de-4a37-994a-b10949a14004", + "name": "Monitoringvsp.nodes.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a71b3246-b54e-4646-bd6f-d5a11d4878df/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "af3193" + }, + { + "uuid": "d36283cc-7d52-4893-8f72-fbffbbe17857", + "invariantUUID": "87802076-8649-4581-a540-b103ab15bd22", + "name": "Application", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d36283cc-7d52-4893-8f72-fbffbbe17857/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "2ef832aa-25f1-4f5a-b6d4-a6ee90011918", + "invariantUUID": "86ed816c-447f-477f-9810-4c07c7356c2e", + "name": "LoadBalancer", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2ef832aa-25f1-4f5a-b6d4-a6ee90011918/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "31060494-0c59-4c15-b4f4-34900d73b803", + "invariantUUID": "4950496e-6e75-47fb-8746-4895887a6d03", + "name": "Compute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/31060494-0c59-4c15-b4f4-34900d73b803/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "d57e57d2-e3c6-470d-8d16-e6ea05f536c5", + "invariantUUID": "dd31d2de-0a7f-4198-8966-3a04100fbfe3", + "name": "SecurityRules", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/toscaModel", + "category": "Generic", + "subCategory": "Rules", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "db9360b9-0edb-43e1-8cf0-00bb90b7c2be", + "invariantUUID": "651f273d-7e1d-410c-bd88-cf8c9f713454", + "name": "ContrailV2NetworkRules", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/db9360b9-0edb-43e1-8cf0-00bb90b7c2be/toscaModel", + "category": "Generic", + "subCategory": "Rules", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "503948a9-03bb-4738-8464-c6e21da10792", + "invariantUUID": "477a2abf-10b6-4777-bd50-afdcbbe59d54", + "name": "Vtsbc1.nodes.heat.module_2_perimeta_sw_b_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/503948a9-03bb-4738-8464-c6e21da10792/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "e4514d83-9708-427f-a62b-f996e426ba58", + "invariantUUID": "5886b184-53c2-475b-8e75-b38696c10b8a", + "name": "GlobalCompute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e4514d83-9708-427f-a62b-f996e426ba58/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "3ab24991-cf93-4d40-9468-52d233d36ad6", + "invariantUUID": "fb26e1e2-d7b0-4809-86e6-1ea31c5c6a4a", + "name": "FcgiOs.nodes.heat.modular_1_cgi_frwl_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3ab24991-cf93-4d40-9468-52d233d36ad6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "930aab76-fc52-43dd-8f19-e2ce11503bb5", + "invariantUUID": "f66c1a6b-2ad5-43dd-8cc9-1924f7eaad0f", + "name": "Vtsbc1.nodes.heat.vlan_subinterface_dual", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/930aab76-fc52-43dd-8f19-e2ce11503bb5/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "fca030db-0a4b-4873-94d2-20ea6b8f259f", + "invariantUUID": "124d05ac-8bbc-4510-94d7-c6418ee25864", + "name": "Vtsbc1.nodes.heat.module_2_perimeta_sw_a_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fca030db-0a4b-4873-94d2-20ea6b8f259f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "bc74b1ae-11f7-4550-8c25-e528e749d2ea", + "invariantUUID": "8c0c60ea-b468-4288-9aea-3232b5e7cce7", + "name": "Ronytestcsar.nodes.arb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bc74b1ae-11f7-4550-8c25-e528e749d2ea/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rb844h" + }, + { + "uuid": "624a7da1-68ce-4b95-9d50-6a07d645e421", + "invariantUUID": "7ed55927-5274-461f-8ba5-76abdcf609a8", + "name": "Vftest54.nodes.heat.vdns", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/624a7da1-68ce-4b95-9d50-6a07d645e421/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rb844h" + }, + { + "uuid": "0c19272a-b2a2-4ffe-a6e7-ce3a683f23fc", + "invariantUUID": "effff7eb-737b-496d-8e23-8e31efe67dc4", + "name": "VmmscEca.nodes.heat.arb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0c19272a-b2a2-4ffe-a6e7-ce3a683f23fc/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "az2497" + }, + { + "uuid": "46887197-fec9-4cf5-9207-e6e7f4a6cf3a", + "invariantUUID": "1b8a54a2-b1ff-441c-9c6e-3aa83773e67c", + "name": "VfVolumeGroup.nodes.heat.sm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/46887197-fec9-4cf5-9207-e6e7f4a6cf3a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "563ca30e-8e6f-4456-b1c0-d1a5b6b052aa", + "invariantUUID": "876fe041-c25a-4e71-bbd3-ce18d1951974", + "name": "1607MogMultiMembersVolume.nodes.heat.sm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/563ca30e-8e6f-4456-b1c0-d1a5b6b052aa/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "2437819c-3f2e-4ae8-9427-b41463a63a21", + "invariantUUID": "6ec6862d-1e49-479b-b792-0b02a26cf9a6", + "name": "VfModule2.nodes.heat.eca_trx", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2437819c-3f2e-4ae8-9427-b41463a63a21/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "3c9b6ec9-2b6a-4c81-96cd-f3e5c0264ae6", + "invariantUUID": "cdc19c35-bcac-4f78-a7a6-c216b374f5a3", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3c9b6ec9-2b6a-4c81-96cd-f3e5c0264ae6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "612317df-67b5-487f-b592-44f5e682b0a9", + "invariantUUID": "3bae7612-b50d-48ed-8ae7-b6f17521395b", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/612317df-67b5-487f-b592-44f5e682b0a9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "77b6934c-353e-407e-aa1e-6f1288cb3969", + "invariantUUID": "adb87b9e-4bc2-4e96-8b1a-6176240f02a8", + "name": "VmogVnf1.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/77b6934c-353e-407e-aa1e-6f1288cb3969/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "48a5a370-d91d-4bdd-a1a0-8d82eedcced8", + "invariantUUID": "514ba932-1b32-447b-8655-f3a356047172", + "name": "VfModules.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/48a5a370-d91d-4bdd-a1a0-8d82eedcced8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "1450f9c2-b491-4ac6-a388-db4e0752a58f", + "invariantUUID": "5dc27c39-2540-4a2c-881c-5dab7859bbe8", + "name": "AppcTest.nodes.heat.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1450f9c2-b491-4ac6-a388-db4e0752a58f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "311a159d-ea0b-494c-97dd-52683df85faf", + "invariantUUID": "3c28e9d7-8ccf-4249-9eab-878d6cd84dfa", + "name": "Ixlt1Os.nodes.heat.its", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/311a159d-ea0b-494c-97dd-52683df85faf/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "4902fae4-7f42-43c5-9472-fe12eca3f510", + "invariantUUID": "60d87328-e9fd-474e-aa3e-791f23e7c0fa", + "name": "VfVolumeGroup.nodes.heat.cm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4902fae4-7f42-43c5-9472-fe12eca3f510/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "a82e5a26-463c-4b17-9d6e-16ea1f8c0dde", + "invariantUUID": "dfd14d20-8d28-4ad1-a824-dd75d282f97b", + "name": "VfVolumeGroup.nodes.heat.ps", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a82e5a26-463c-4b17-9d6e-16ea1f8c0dde/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "d852ce5c-c883-41a1-88f9-167b8b4ff197", + "invariantUUID": "18f3b7e1-3dfe-4299-982a-b510c64fbfba", + "name": "1607MogMultiMembersVolume.nodes.heat.ps", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d852ce5c-c883-41a1-88f9-167b8b4ff197/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "b299bd46-66c1-4954-af45-2fe3188f5c5e", + "invariantUUID": "41aa2e0e-f003-4a03-9e9b-5dbcc968b1df", + "name": "VfModulesVmmsc.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b299bd46-66c1-4954-af45-2fe3188f5c5e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "f80f5252-2ecb-41e3-84d5-936586ae0a3a", + "invariantUUID": "d90ae454-bc1c-44ef-a680-74b6a09d3123", + "name": "VfModules.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f80f5252-2ecb-41e3-84d5-936586ae0a3a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "9e4b96d7-5701-413e-8461-4cac258365ca", + "invariantUUID": "1a81fcd0-d62c-4ba3-b988-40a1a5986cb0", + "name": "TestPort.nodes.heat.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/9e4b96d7-5701-413e-8461-4cac258365ca/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "4d2bfb6f-9276-447b-b145-7f7856af9a6c", + "invariantUUID": "32a90486-5e0d-4977-b445-a9a165295841", + "name": "VmogVnf1.nodes.heat.pps", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4d2bfb6f-9276-447b-b145-7f7856af9a6c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "a614b20e-9c45-4163-b673-38f0068c5365", + "invariantUUID": "160c57a3-d87f-4f7f-a38a-7ecf6b48d42b", + "name": "Vmmsc.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a614b20e-9c45-4163-b673-38f0068c5365/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "fbad0868-45e9-433b-ada7-070e88c09672", + "invariantUUID": "8242ebe6-8333-4e4a-a997-31a391cbcc1f", + "name": "VmogVnf1.nodes.heat.mba", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fbad0868-45e9-433b-ada7-070e88c09672/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "e50cbfd4-a860-441b-b1ff-c654c3222ad6", + "invariantUUID": "03c1f631-d057-4246-b276-2a0e18119a21", + "name": "Pxtc.nodes.heat.mon", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e50cbfd4-a860-441b-b1ff-c654c3222ad6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "21aaf7bf-5af9-4b1a-9850-f4a5e95f185e", + "invariantUUID": "9bc1d654-b663-4170-89f2-e8dabb6d2342", + "name": "VmogVnf1.nodes.heat.ppd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/21aaf7bf-5af9-4b1a-9850-f4a5e95f185e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "9d4a37d7-3c9b-4dad-abb6-26b50b15da8b", + "invariantUUID": "419651d6-45e9-453a-95cd-4f9f0934fa9c", + "name": "Pxtc.nodes.heat.adm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/9d4a37d7-3c9b-4dad-abb6-26b50b15da8b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "bb8fddbf-e011-4fed-9f36-181478f4e56c", + "invariantUUID": "552c6aa1-0a27-45f7-a0e5-9a380a592ad4", + "name": "TestPort.nodes.heat.fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bb8fddbf-e011-4fed-9f36-181478f4e56c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "2bb496fb-6ede-42e0-957e-bd80fa2e8aa1", + "invariantUUID": "2a6f0a0e-2a76-43d1-9489-3ad4fdf82cdc", + "name": "Runtime", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2bb496fb-6ede-42e0-957e-bd80fa2e8aa1/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "a5226541-363b-4d78-8f52-06d421795457", + "invariantUUID": "3b05cf5e-5120-4aef-a213-f3d984c83efe", + "name": "TestPort.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a5226541-363b-4d78-8f52-06d421795457/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "f58b4bcf-baec-4c11-a6d0-0e92d4629fd2", + "invariantUUID": "603b02a9-afa2-487b-a8c1-90c84c21d4cf", + "name": "Vpe.nodes.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f58b4bcf-baec-4c11-a6d0-0e92d4629fd2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "30db70cc-17b8-4c39-a848-5f629e9a929e", + "invariantUUID": "2a3100da-581e-438a-915c-3c67ecbe8f9c", + "name": "AppcTest.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/30db70cc-17b8-4c39-a848-5f629e9a929e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "52398d14-90d0-4d3a-ac84-10b525e79e3c", + "invariantUUID": "8f061343-5507-4232-ba34-4933bb2b85d3", + "name": "Fdnt.nodes.heat.mod_vmsi_dnt_fw_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/52398d14-90d0-4d3a-ac84-10b525e79e3c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "d0deff85-ca52-4c86-8ca7-a02deddba983", + "invariantUUID": "c62a62a8-f021-4e22-85b9-45a19ddd8597", + "name": "Vtsbc1.nodes.heat.module_1_perimeta_sw_a_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d0deff85-ca52-4c86-8ca7-a02deddba983/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "25f77df9-f94a-4458-9699-5f483167f700", + "invariantUUID": "8d8675b4-88f8-43ad-aeed-3cb2e96d8f67", + "name": "DBMS", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/25f77df9-f94a-4458-9699-5f483167f700/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "1ce8b11c-589c-4359-9caa-590a43fb53ec", + "invariantUUID": "e4d4a041-38f9-416b-a97d-56eaca20cb88", + "name": "WebServer", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1ce8b11c-589c-4359-9caa-590a43fb53ec/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "f27b3a9c-b815-42fe-83c6-da86c18a63a6", + "invariantUUID": "0d4bec79-e600-4647-a9a6-35d1f1dd0802", + "name": "Fdnt1.nodes.heat.mod_vmsi_dnt_fw_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f27b3a9c-b815-42fe-83c6-da86c18a63a6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "c63814fe-9d50-4283-8229-ede6a5961de9", + "invariantUUID": "b9ffe743-22ae-4bdc-a36a-0fd7cdab97ff", + "name": "Mazav.nodes.heat.mod_vmsi_dnt_fw_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c63814fe-9d50-4283-8229-ede6a5961de9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "23f4bcc5-c6e1-4fdd-b45b-29eb3f82af2f", + "invariantUUID": "62545a84-126c-4563-b72b-7414cb2db617", + "name": "Fdnt1234.nodes.heat.mod_vmsi_dnt_fw_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/23f4bcc5-c6e1-4fdd-b45b-29eb3f82af2f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "e63ef8ed-d40d-4b5f-99da-898fbe4b051b", + "invariantUUID": "f747ebd4-8c02-4653-b919-7fd894450970", + "name": "Vtsbc1.nodes.heat.module_1_perimeta_sw_b_child", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e63ef8ed-d40d-4b5f-99da-898fbe4b051b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "292d2d83-c33b-4c22-8341-4401194a6499", + "invariantUUID": "b27f9b4b-2188-4edb-9e05-83680b5462b2", + "name": "VfModules1.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/292d2d83-c33b-4c22-8341-4401194a6499/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "af51c072-1754-4db3-97be-179ab7433295", + "invariantUUID": "b615bc4f-c4e3-4381-9467-f6674f4fe5ce", + "name": "VfModules1.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/af51c072-1754-4db3-97be-179ab7433295/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "5ec9fb9f-fa32-48e8-a317-8be839e15d30", + "invariantUUID": "ed2acd41-d9f5-475b-b696-9ff2ac93714e", + "name": "VmmscEca.nodes.arb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5ec9fb9f-fa32-48e8-a317-8be839e15d30/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "az2497" + }, + { + "uuid": "3a8230f1-dd86-42f8-9d73-c239bc5c74e8", + "invariantUUID": "d7070c39-94e0-48f5-befc-c3b02a2dc1ec", + "name": "VfModulesVmmsc.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3a8230f1-dd86-42f8-9d73-c239bc5c74e8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "5658235d-6a1e-47fe-8e5f-9e081a11b713", + "invariantUUID": "7da4de5f-f610-4b0a-a57f-e76bf05e676e", + "name": "TestPort.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5658235d-6a1e-47fe-8e5f-9e081a11b713/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "d4979513-3719-4076-bbc1-5a4fe040ddc6", + "invariantUUID": "54f5d6e1-0290-473f-b7ef-ae5e31cd9985", + "name": "Vpe.nodes.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d4979513-3719-4076-bbc1-5a4fe040ddc6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "a450b1ba-2d69-44e7-8934-1d21952ba6c9", + "invariantUUID": "350c8017-ab5a-4633-bbe0-e7bbf71f0887", + "name": "TestConsol.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a450b1ba-2d69-44e7-8934-1d21952ba6c9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "c0bd2a8b-9dc3-4819-8ab1-11175ae06ef1", + "invariantUUID": "427b34d8-ca6d-4c94-8e4f-06d63a1e24eb", + "name": "NovaServer", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c0bd2a8b-9dc3-4819-8ab1-11175ae06ef1/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "5f6ccc29-6f6c-41cf-b995-73c58e7278d2", + "invariantUUID": "044d46c6-e6ae-4569-b7b4-3d0f626612de", + "name": "1607MogMultiMembersVolume.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5f6ccc29-6f6c-41cf-b995-73c58e7278d2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "5d6fdb58-1166-41b6-aab7-260e494ccc58", + "invariantUUID": "04c36447-22a8-4039-a7ae-fe134907061e", + "name": "ContrailCompute", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5d6fdb58-1166-41b6-aab7-260e494ccc58/toscaModel", + "category": "Generic", + "subCategory": "Infrastructure", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "jh0003" + }, + { + "uuid": "57d4264b-3175-4a31-9515-f23c0318930f", + "invariantUUID": "8e3f2465-5f4f-4c9e-9b84-5db3d5d6a3f8", + "name": "VmogVnf1.nodes.heat.pcm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/57d4264b-3175-4a31-9515-f23c0318930f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "dcd62b53-a045-4864-9ed3-aaf722fec10a", + "invariantUUID": "046a066f-8398-4271-aa1a-4ccdd46c892f", + "name": "VfModuleLdsa.nodes.heat.ltm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/dcd62b53-a045-4864-9ed3-aaf722fec10a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "aa00977d-ff67-473a-acb8-bb24db037a0b", + "invariantUUID": "989ae5c8-e9b9-4e14-b609-1fde2ad4e165", + "name": "TestConsol.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/aa00977d-ff67-473a-acb8-bb24db037a0b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "cb08bf67-6fc9-44ae-ae31-ab619cfd94af", + "invariantUUID": "7555d6be-ef04-4812-b58c-b00eda9e1a1b", + "name": "AppcTest.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/cb08bf67-6fc9-44ae-ae31-ab619cfd94af/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "cc3a0064-e9d4-421e-ba14-ce340adb7ed9", + "invariantUUID": "341b0751-e9b7-4f80-935e-30aef979ea71", + "name": "VfModules.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/cc3a0064-e9d4-421e-ba14-ce340adb7ed9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "1f927980-bd8d-4a0c-8002-8f550e52efbe", + "invariantUUID": "d9f0237f-acaa-411f-843c-952d4d746d9f", + "name": "Vmmsc.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1f927980-bd8d-4a0c-8002-8f550e52efbe/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "6d1669d1-be78-47e7-aed4-d5a2267c81d4", + "invariantUUID": "b2a066b5-0062-482a-af23-9e1426f7d388", + "name": "VfVolumeGroup.nodes.heat.pd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/6d1669d1-be78-47e7-aed4-d5a2267c81d4/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "bd9e5061-40dc-42ca-8d77-c606a24c8bfd", + "invariantUUID": "a8cf5282-4c83-4540-8515-c315328af01d", + "name": "VfNoLicense.nodes.pcm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bd9e5061-40dc-42ca-8d77-c606a24c8bfd/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "68ea026e-c604-47b5-9cd1-524a58714a14", + "invariantUUID": "d0aa37ea-a1f8-41dc-9b5f-7e54f4d7a2f3", + "name": "VfNoLicense.nodes.pps", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/68ea026e-c604-47b5-9cd1-524a58714a14/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "bc3a8aae-7f94-4dac-b819-d37a077a08fc", + "invariantUUID": "0df5de75-3a9e-439a-8d03-e989ca7bfe16", + "name": "ScpTestVsp.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bc3a8aae-7f94-4dac-b819-d37a077a08fc/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "8ba3f710-58d4-4d60-9384-1dad449d381a", + "invariantUUID": "4a34455c-b9c0-48ca-90ac-debf986ac028", + "name": "VfDemor.nodes.vmx_vre", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8ba3f710-58d4-4d60-9384-1dad449d381a/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "0a09e932-9fde-4e52-b7e3-2e542b61faa0", + "invariantUUID": "dd97be59-be12-4749-b8ca-1bf0d7336573", + "name": "ScpTestVsp.nodes.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0a09e932-9fde-4e52-b7e3-2e542b61faa0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "fa6ca25b-4578-4093-b8a2-031cb8f1f481", + "invariantUUID": "c88282f0-608d-4aef-b12f-dda9474f55f9", + "name": "VscpaasTest2.nodes.fe_1", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fa6ca25b-4578-4093-b8a2-031cb8f1f481/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "f11a8681-ab58-4f0d-8387-76ecdfa31073", + "invariantUUID": "2a94a311-f6bb-48b6-a458-e4b1a724bfc7", + "name": "VscpaasTest2.nodes.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f11a8681-ab58-4f0d-8387-76ecdfa31073/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "4b1cca9b-23a0-4037-aaf3-ce5cd7c91851", + "invariantUUID": "98e3949f-1047-4cd8-9b8b-6b6c55d51f74", + "name": "Vprobe.nodes.vLBAgent", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4b1cca9b-23a0-4037-aaf3-ce5cd7c91851/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "17ed7b78-1ffb-4864-a2ec-b6666a5fed16", + "invariantUUID": "2a6de403-c5b7-44ea-a398-ae78d53fb31a", + "name": "VpeAvRenana.nodes.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/17ed7b78-1ffb-4864-a2ec-b6666a5fed16/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "ab89b69b-b92b-4e34-b1db-a6378d709241", + "invariantUUID": "dbb9b18d-e3ea-48cf-bcbd-81d8d4b22d72", + "name": "Vmmsc.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ab89b69b-b92b-4e34-b1db-a6378d709241/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "d45694e4-ed86-4a44-a644-5a8a3ff89397", + "invariantUUID": "3eb4d8e0-2b85-4b74-bad3-2e4406f50d4d", + "name": "VfModules1.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d45694e4-ed86-4a44-a644-5a8a3ff89397/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "5c7fd7c0-fc79-4309-bb03-85388cae45a8", + "invariantUUID": "7ff3e308-cf42-47ae-afc3-ecd5ef9823c0", + "name": "VmmscEca.nodes.heat.eca", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5c7fd7c0-fc79-4309-bb03-85388cae45a8/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "az2497" + }, + { + "uuid": "f739ea35-7bd4-42ed-b9ee-1e0fd2017c72", + "invariantUUID": "ce4127ef-2564-40e6-b62e-6be7758f46a7", + "name": "Pxtc.nodes.heat.ddc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f739ea35-7bd4-42ed-b9ee-1e0fd2017c72/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "f2339431-f3ab-41c9-90c4-6c2c958e1b06", + "invariantUUID": "40ab991d-ad0c-4adb-9f2a-0f2eef8bb880", + "name": "VfModules1.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f2339431-f3ab-41c9-90c4-6c2c958e1b06/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "15728e01-7076-4765-8002-95154ad29d5f", + "invariantUUID": "9814209f-7b9d-4b21-8968-f6a3638b107c", + "name": "1607Mog.nodes.heat.cm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/15728e01-7076-4765-8002-95154ad29d5f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "ab168037-e654-4990-a188-e5d2f25a8768", + "invariantUUID": "ef673ad3-2d81-47b7-99c2-bdc69ae79d80", + "name": "Vcts3.nodes.heat.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ab168037-e654-4990-a188-e5d2f25a8768/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + { + "uuid": "e1d7eb6a-646d-4906-9981-44ed892dc01c", + "invariantUUID": "78245f38-b99a-49a8-ac5b-56737ad686db", + "name": "VfModulesVmmsc.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e1d7eb6a-646d-4906-9981-44ed892dc01c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "74c527c6-edb7-4bbe-a63c-d2daf5a12db0", + "invariantUUID": "18bc94d2-2be1-46e9-bd70-ded327b1324e", + "name": "VfModule2.nodes.heat.mmsc", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/74c527c6-edb7-4bbe-a63c-d2daf5a12db0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "345459d0-ba42-45ba-9eb0-cc56e4f35ea9", + "invariantUUID": "5362b258-b867-4e98-a3c4-138c6d444c69", + "name": "VfModule2.nodes.heat.nems_be", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/345459d0-ba42-45ba-9eb0-cc56e4f35ea9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "bc40b750-56ab-4c6b-8e15-412f9be0178f", + "invariantUUID": "ab769637-063f-41fd-927d-771a1913235b", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bc40b750-56ab-4c6b-8e15-412f9be0178f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "3ff3d87f-c55f-4b4c-a8ae-29931d910359", + "invariantUUID": "5af2c63a-1b3e-42a5-ab4b-07e97d1dcbd2", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3ff3d87f-c55f-4b4c-a8ae-29931d910359/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "fda7cb95-cbd0-46cc-8311-87ae632f75d6", + "invariantUUID": "69c6a72d-5b61-4c66-955a-a70f547821f3", + "name": "1607Mog.nodes.heat.ps", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fda7cb95-cbd0-46cc-8311-87ae632f75d6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "d8a2de8a-27d8-491c-bbb9-da779a4da7c6", + "invariantUUID": "0b4d158e-c20e-4630-b515-3ecda2ad05a4", + "name": "VfModules.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d8a2de8a-27d8-491c-bbb9-da779a4da7c6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "d544d6a6-4fcc-42db-97f6-e8cccc69c5ee", + "invariantUUID": "cd4a433e-cf76-4652-a6b8-59e657e0c5a0", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d544d6a6-4fcc-42db-97f6-e8cccc69c5ee/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "5d6e7129-d7c8-41b8-ae2a-5f1688162c7c", + "invariantUUID": "350d9877-894a-4ce4-a899-48df9428ff88", + "name": "Vieccf.nodes.heat.iox", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5d6e7129-d7c8-41b8-ae2a-5f1688162c7c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "fcc6655e-7074-48de-89ef-ef6e4a5705e3", + "invariantUUID": "6dd080e4-372c-44cc-8c25-868d45f2e959", + "name": "VfModule2.nodes.heat.nems_fe", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fcc6655e-7074-48de-89ef-ef6e4a5705e3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "400cab12-2d1e-4a2c-a33a-d9d7b3262dd1", + "invariantUUID": "9ebca51b-16d0-423c-8e5f-4472c1888029", + "name": "VmogVnf1.nodes.heat.mbt", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/400cab12-2d1e-4a2c-a33a-d9d7b3262dd1/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "a068d0c0-06c6-4b58-bc99-6ac910700edb", + "invariantUUID": "f2e37302-fd97-48d7-bbdb-f0caaab5fe03", + "name": "1607Mog.nodes.heat.pd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a068d0c0-06c6-4b58-bc99-6ac910700edb/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "c2e88763-87a9-4d33-b598-7811ae3f87d2", + "invariantUUID": "9d16cf01-c244-42c8-bcfe-faf108069e84", + "name": "VfModulesVmmsc.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c2e88763-87a9-4d33-b598-7811ae3f87d2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "de861add-3f4a-4526-9754-8bcb69d0fd0e", + "invariantUUID": "67560771-ffcb-46fb-a40c-0e1dee74f43a", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/de861add-3f4a-4526-9754-8bcb69d0fd0e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "4514b4e5-f163-4011-87fd-445f4366e3c2", + "invariantUUID": "91c638ef-49f5-4366-8749-cda8a33ed41e", + "name": "VfModules.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4514b4e5-f163-4011-87fd-445f4366e3c2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "3679d10e-a1a2-46a4-97b3-4056a0920e7b", + "invariantUUID": "d272aa71-398a-4eff-ab00-6a4281b41c92", + "name": "Pxtc.nodes.heat.mda", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3679d10e-a1a2-46a4-97b3-4056a0920e7b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "f905ca32-dac5-4337-a1d7-cc2bca86b407", + "invariantUUID": "acbb7a13-7ae7-4ac7-b0e4-23314cbc65e2", + "name": "Vmmsc.nodes.heat.mmsc", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f905ca32-dac5-4337-a1d7-cc2bca86b407/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "ee10af8a-c8bf-4455-808e-5550050d4ea9", + "invariantUUID": "e74db59b-72fb-4734-9d48-40d8c47d292a", + "name": "VfModulesVmmsc.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/ee10af8a-c8bf-4455-808e-5550050d4ea9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "771ca169-bfac-4306-9748-b2ae804852f9", + "invariantUUID": "ae627e8b-374b-41ac-9efb-25672099c7dd", + "name": "Vscp0502.nodes.heat.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/771ca169-bfac-4306-9748-b2ae804852f9/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + { + "uuid": "72682bb7-94ca-47a7-9917-826f62e3d00d", + "invariantUUID": "7bb2f20e-10af-485b-9c7c-9fba2c016856", + "name": "1607Mog.nodes.heat.sm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/72682bb7-94ca-47a7-9917-826f62e3d00d/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "1fa641db-1d77-4242-8d0b-c0aa5f88fe2e", + "invariantUUID": "22464824-fcbe-4760-9aa7-f2d110e5c0f8", + "name": "1607MogMultiMembersVolume.nodes.heat.cm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1fa641db-1d77-4242-8d0b-c0aa5f88fe2e/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "897dcb54-bb55-4311-8c0e-b663781d7e4f", + "invariantUUID": "c223adda-e48d-487d-98e8-654bbb8268af", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.lb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/897dcb54-bb55-4311-8c0e-b663781d7e4f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "a60c5230-8201-4b50-84a8-c905128c2bc2", + "invariantUUID": "59399b2e-66ed-4823-aa27-189fdb466045", + "name": "AppcTest.nodes.heat.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/a60c5230-8201-4b50-84a8-c905128c2bc2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "173c32b5-44c8-4404-ba18-32d9de49afae", + "invariantUUID": "c247493b-15a4-47af-bb6b-c664cb5a4d37", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/173c32b5-44c8-4404-ba18-32d9de49afae/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "59aa2d42-db52-438c-a69c-0b97a193abcd", + "invariantUUID": "31fc926f-cfc5-42bd-8955-42e68c113902", + "name": "TestConsol.nodes.heat.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/59aa2d42-db52-438c-a69c-0b97a193abcd/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "0e6509c9-7d35-4daf-9086-9fe30fdd1275", + "invariantUUID": "9516ad03-b122-4738-ad6d-d9c2166cd75a", + "name": "VmmscAic30MultiMembersMultiGroupsVolume.nodes.heat.nems_fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0e6509c9-7d35-4daf-9086-9fe30fdd1275/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "e541a64c-9de7-4c71-b827-eb0f4d319e62", + "invariantUUID": "9952957d-d266-406e-ab7d-23a7fc154ea0", + "name": "1607MogMultiMembersVolume.nodes.heat.pd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/e541a64c-9de7-4c71-b827-eb0f4d319e62/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "5e448cd9-6dbd-4c31-98f2-caeceaf5efa7", + "invariantUUID": "3a97ded5-e8fc-42fa-b244-a6f91b610e08", + "name": "VfModule2.nodes.heat.lb", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/5e448cd9-6dbd-4c31-98f2-caeceaf5efa7/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "d5c6a462-9d9a-46d4-a0b2-485300f34f0c", + "invariantUUID": "635abeeb-d903-44a8-9135-5d26e1ee41a1", + "name": "VmogVnf1.nodes.heat.psm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d5c6a462-9d9a-46d4-a0b2-485300f34f0c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "8678abfe-8cbd-42f2-aa78-ca47a1beaa14", + "invariantUUID": "4d02c8a5-e141-4d01-94ec-7a3b94afda97", + "name": "VmmscAic30MultiMembersMultiGroupsVolumeCs.nodes.heat.eca_trx", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8678abfe-8cbd-42f2-aa78-ca47a1beaa14/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "1c469da0-298f-41ea-94a2-aef82264e1e7", + "invariantUUID": "91530a04-e1f6-4242-abd2-f20630e1fa8f", + "name": "1607Mog.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1c469da0-298f-41ea-94a2-aef82264e1e7/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "c29e22e2-1a09-4164-a9a2-72d0e3f5df5b", + "invariantUUID": "a0e5c360-f0e7-4b8d-ac97-969b9dc5b187", + "name": "Vmmsc.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c29e22e2-1a09-4164-a9a2-72d0e3f5df5b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "986b76dc-aca7-45b1-919c-398b770d5504", + "invariantUUID": "cd2f22e1-e21e-474b-a506-1bb4365aa106", + "name": "AppcTest.nodes.heat.fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/986b76dc-aca7-45b1-919c-398b770d5504/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "606f6c2b-a411-4644-a183-5487e3aed612", + "invariantUUID": "d67b05d1-119c-47a3-8b20-2babb53b42b3", + "name": "Vpe.nodes.heat.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/606f6c2b-a411-4644-a183-5487e3aed612/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "00695bbf-fa3f-47e4-96d7-973700a66f4f", + "invariantUUID": "d26ce6ce-b1f8-4cdc-955d-e2272563cff6", + "name": "TestPort.nodes.heat.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/00695bbf-fa3f-47e4-96d7-973700a66f4f/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "d94275b4-ccfa-4096-bd7b-dd45ff6e84f2", + "invariantUUID": "56a1b1c7-6a6f-402b-890f-8e3a1cc56feb", + "name": "Vieccf.nodes.heat.plt", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d94275b4-ccfa-4096-bd7b-dd45ff6e84f2/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "8beb2fe4-672e-46c3-8650-e2065ea429ea", + "invariantUUID": "be756449-fd9d-4889-83ad-41ff26a82f09", + "name": "Pxtc.nodes.heat.mts", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8beb2fe4-672e-46c3-8650-e2065ea429ea/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "c4b4f162-a616-45c6-b229-9833a78a46fd", + "invariantUUID": "b502eeb1-091c-41cf-b4ba-52f9ab6ecfcc", + "name": "Vpe.nodes.heat.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c4b4f162-a616-45c6-b229-9833a78a46fd/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "95e982cd-551d-49b2-9600-04f1328b9ab5", + "invariantUUID": "26813b60-5437-4780-aaaa-9705b9d30357", + "name": "TestConsol.nodes.heat.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/95e982cd-551d-49b2-9600-04f1328b9ab5/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "8316c6e3-7791-42cb-80fb-e57ed0809be6", + "invariantUUID": "5ca065b5-c2e3-4561-9dc6-58fc84c8398c", + "name": "Vscp0502.nodes.heat.smp", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/8316c6e3-7791-42cb-80fb-e57ed0809be6/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + { + "uuid": "49cc354b-ea2e-48a9-a6b8-d414e6991898", + "invariantUUID": "b94ec614-4972-4355-ab2f-3c7068714581", + "name": "Ronytestcsar.nodes.heat.arb", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/49cc354b-ea2e-48a9-a6b8-d414e6991898/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rb844h" + }, + { + "uuid": "cc0048fb-a464-4407-9907-5e760684bc7b", + "invariantUUID": "06aff944-cdab-42cd-a5a3-f2c2c65df4b2", + "name": "TestConsol.nodes.heat.fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/cc0048fb-a464-4407-9907-5e760684bc7b/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "bc1dea1b-5753-4d17-af6f-ac6050b3e281", + "invariantUUID": "76d0ef26-6721-4f11-ba1a-04c93e7154c3", + "name": "Vieccf.nodes.heat.app", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/bc1dea1b-5753-4d17-af6f-ac6050b3e281/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "0b894e43-6d45-4c3d-95dd-2e80228055f3", + "invariantUUID": "ca679ac7-9d4b-4da1-8912-a262c5599692", + "name": "VfVolumeGroup.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/0b894e43-6d45-4c3d-95dd-2e80228055f3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "2bb1e047-fa3b-41f5-9d29-ebbdbf01857c", + "invariantUUID": "988032f2-873e-4273-9075-17ffd47f0a7f", + "name": "VfModules1.nodes.heat.nems_be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/2bb1e047-fa3b-41f5-9d29-ebbdbf01857c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m99121" + }, + { + "uuid": "05c82d0d-826b-458c-8c81-9572298522a3", + "invariantUUID": "6e577da6-377d-46fb-84c0-3bfa4778062f", + "name": "Vscp0502.nodes.heat.fe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/05c82d0d-826b-458c-8c81-9572298522a3/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ml4535" + }, + { + "uuid": "c6809100-9349-4f98-a066-55b6f0cb8650", + "invariantUUID": "4d48d18e-baa3-41bb-8a07-3c553db1fbab", + "name": "Ronytestcsar.nodes.heat.eca", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/c6809100-9349-4f98-a066-55b6f0cb8650/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rb844h" + }, + { + "uuid": "abe50ede-b86c-415f-9f5f-235200433b51", + "invariantUUID": "c3cbaff7-a657-44d5-a0b3-cc65599b4fa8", + "name": "Csartest.nodes.heat.ltm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/abe50ede-b86c-415f-9f5f-235200433b51/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ss8214" + }, + { + "uuid": "3ce1be04-57ad-4deb-bdba-b18447374a88", + "invariantUUID": "b08eef7d-1dd5-4996-9171-7822b48e9a9d", + "name": "Vprobe.nodes.qrouter", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/3ce1be04-57ad-4deb-bdba-b18447374a88/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "m08740" + }, + { + "uuid": "f6406bba-b64c-4211-aaee-773cde6e7d54", + "invariantUUID": "490345fc-f6fe-49a6-b18d-6dcacca02a7e", + "name": "VscpaasTest2.nodes.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/f6406bba-b64c-4211-aaee-773cde6e7d54/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "d48751e4-07de-4208-9307-7ecb775fe7ca", + "invariantUUID": "ca0ae539-78d1-461a-a7ff-3dd663c85e2d", + "name": "pnf-test", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/d48751e4-07de-4208-9307-7ecb775fe7ca/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "cdb99a41-e2ee-4b59-9107-13f0b2282ccc", + "invariantUUID": "6a828e59-cbee-4dc2-aa67-ee35a6eafd50", + "name": "Dev2devnfod.nodes.VF", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/cdb99a41-e2ee-4b59-9107-13f0b2282ccc/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "pa0916" + }, + { + "uuid": "99b9dce6-ed85-4d76-aed9-40c020ba4607", + "invariantUUID": "c9e5dab6-eba5-4cc2-abff-305f8f508da1", + "name": "py-port-test", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/99b9dce6-ed85-4d76-aed9-40c020ba4607/toscaModel", + "category": "Application L4+", + "subCategory": "Call Control", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "acf4e0fa-17f9-4ac8-9fb2-2301cf942fcf", + "invariantUUID": "02cd4db0-a29b-4318-9b3b-a123b9103b85", + "name": "VfNoLicense.nodes.ppd", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/acf4e0fa-17f9-4ac8-9fb2-2301cf942fcf/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "fb6a8f39-84be-49a2-b551-26ce99ee6853", + "invariantUUID": "501e3f78-ae62-4551-bc47-a9afa8f29034", + "name": "ScpTestVsp.nodes.be", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/fb6a8f39-84be-49a2-b551-26ce99ee6853/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "b09ec9ff-af66-4bdc-82d4-01a918e8e3ca", + "invariantUUID": "02d284b6-feb3-4762-be9b-8f6955f6b0b9", + "name": "SdWanTestVsp.nodes.DUMMY_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/b09ec9ff-af66-4bdc-82d4-01a918e8e3ca/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "83256b0a-cb38-45de-b5f0-d2d4390f543d", + "invariantUUID": "c291bec4-fe31-4e6d-9126-f5ce104b84d1", + "name": "Sangeetha.nodes.vCTS_server", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/83256b0a-cb38-45de-b5f0-d2d4390f543d/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "sa997j" + }, + { + "uuid": "16ba1289-5f91-4f07-914a-d2456d11c673", + "invariantUUID": "aafce2ad-8d15-4f53-88f5-9b3a1662f14e", + "name": "VpeAvRenana.nodes.vmx_vpfe", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/16ba1289-5f91-4f07-914a-d2456d11c673/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "93fe78c8-1350-4b1f-ac5f-ede411b992a0", + "invariantUUID": "a11f76ed-0f0a-4093-9c94-5f5eb6c450b5", + "name": "VfNoLicense.nodes.psm", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/93fe78c8-1350-4b1f-ac5f-ede411b992a0/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "1e5eafc0-1888-4247-9762-9ebd1383d0ae", + "invariantUUID": "076ddfc3-8a9d-4289-b71e-a707d359b149", + "name": "VnfcVspTest.nodes.heat.oam", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/1e5eafc0-1888-4247-9762-9ebd1383d0ae/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + }, + { + "uuid": "01faf05a-70b9-442f-be62-9884ea4cdf33", + "invariantUUID": "cd5937cc-37ef-4a85-ba10-2568628d4c1b", + "name": "VfDemor.nodes.vmx_vpfe", + "version": "2.0", + "toscaModelURL": "/sdc/v1/catalog/resources/01faf05a-70b9-442f-be62-9884ea4cdf33/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "4583652c-e066-4a5c-88b8-fbcdd8619d2c", + "invariantUUID": "216e59ce-6940-4085-949e-9b47d9756383", + "name": "VfDemor.nodes.heat.vmx_vre", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/4583652c-e066-4a5c-88b8-fbcdd8619d2c/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "rh176a" + }, + { + "uuid": "16f02038-00f6-4a11-ab98-2a2154e98924", + "invariantUUID": "479cf5fc-8df3-49ec-9e85-da7899420b61", + "name": "VscpaasTest2.nodes.fe_0", + "version": "1.0", + "toscaModelURL": "/sdc/v1/catalog/resources/16f02038-00f6-4a11-ab98-2a2154e98924/toscaModel", + "category": "Generic", + "subCategory": "Abstract", + "resourceType": "VFC", + "lifecycleState": "CERTIFIED", + "lastUpdaterUserId": "ed852m" + } +] \ No newline at end of file -- cgit 1.2.3-korg From e206b8d9b1cb5a52668163f488bb744fc84d1e5c Mon Sep 17 00:00:00 2001 From: Anaël Closson Date: Mon, 11 Sep 2017 13:17:36 +0200 Subject: Fix: Policy GUI not responding on opening MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A call to the backend method getSdcPropertiesByServiceUUIDForRefresh is failing. This is due to invalid handling of Sdc messages introduced with revision 13966ab288578be392c5d2c64d5a9d7b6f600327. Change-Id: I1ade99f50a177d7db6042938c4f0734eba0071fd Issue-Id: CLAMP-51 Signed-off-by: Anaël Closson --- src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java index d31767150..5b9c5d36d 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -463,7 +463,7 @@ public class SdcCatalogServices { // To remove duplicate resources from serviceDetail and add valid // vfs to service - if (cldsSdcServiceDetail.getResources() != null) { + if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null) { List cldsSdcResourceList = removeDuplicateSdcResourceInstances( cldsSdcServiceDetail.getResources()); if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) { -- cgit 1.2.3-korg From 23717d3c29d319502914fcf8507089c360e178e1 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 13 Sep 2017 16:10:12 +0200 Subject: Rework the comment of the constructor Refactor the parameters name of the constructor Change-Id: Ie4314d0384a875da1e8bf3abc1092cd826347929 Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/model/prop/ModelProperties.java | 41 +++++++++++++--------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java index ac25400db..dc0de326b 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java @@ -46,28 +46,28 @@ import org.onap.clamp.clds.service.CldsService; * Parse model properties. */ public class ModelProperties { - protected static final EELFLogger logger = EELFManager.getInstance() + protected static final EELFLogger logger = EELFManager.getInstance() .getLogger(CldsService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance() + protected static final EELFLogger auditLogger = EELFManager.getInstance() .getAuditLogger(); - private ModelBpmn modelBpmn; - private JsonNode modelJson; + private ModelBpmn modelBpmn; + private JsonNode modelJson; - private final String modelName; - private final String controlName; - private final String actionCd; + private final String modelName; + private final String controlName; + private final String actionCd; // Flag indicate whether it is triggered by Validation Test button from UI - private final boolean isTest; + private final boolean isTest; - private Global global; + private Global global; private final Map modelElements = new ConcurrentHashMap<>(); - private String currentModelElementId; - private String policyUniqueId; + private String currentModelElementId; + private String policyUniqueId; - private static final Object lock = new Object(); + private static final Object lock = new Object(); private static Map, String> modelElementClasses = new ConcurrentHashMap<>(); static { @@ -84,21 +84,28 @@ public class ModelProperties { * parse them all - parse them on demand if requested.) * * @param modelName + * The model name coming form the UI * @param controlName + * The closed loop name coming from the UI * @param actionCd + * Type of operation PUT,UPDATE,DELETE * @param isTest - * @param modelBpmnPropText + * The test flag coming from the UI (for validation only, no + * query are physically executed) + * @param modelBpmnText + * The BPMN flow in JSON from the UI * @param modelPropText - * @throws JsonProcessingException + * The BPMN parameters for all boxes defined in modelBpmnTest * @throws IOException + * In case there is an issue with the JSON decoding */ - public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, - String modelBpmnPropText, String modelPropText) throws IOException { + public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, String modelBpmnText, + String modelPropText) throws IOException { this.modelName = modelName; this.controlName = controlName; this.actionCd = actionCd; this.isTest = isTest; - modelBpmn = ModelBpmn.create(modelBpmnPropText); + modelBpmn = ModelBpmn.create(modelBpmnText); modelJson = new ObjectMapper().readTree(modelPropText); instantiateMissingModelElements(); -- cgit 1.2.3-korg From 367b2a23d5149f26b51fedee04667f07ed7b6c97 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 13 Sep 2017 16:12:45 +0200 Subject: Rework the datasource access Make a call to Spring datasource instead calling the method directly Change-Id: If9464f8591cd140079d09dc33c83a8b4380bf5ae Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/java') 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 fa0ca9615..c00deea66 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java @@ -52,6 +52,7 @@ 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.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.ApplicationContext; @@ -67,7 +68,7 @@ public class CldsConfiguration { private ApplicationContext context; /** - * Clds Identity databse DataSource configuration + * Clds Identity database DataSource configuration */ @Bean(name = "cldsDataSource") @ConfigurationProperties(prefix = "spring.datasource.cldsdb") @@ -86,9 +87,9 @@ public class CldsConfiguration { } @Bean(name = "cldsDao") - public CldsDao getCldsDao() { + public CldsDao getCldsDao(@Qualifier("cldsDataSource") DataSource dataSource) { CldsDao cldsDao = new CldsDao(); - cldsDao.setDataSource(cldsDataSource()); + cldsDao.setDataSource(dataSource); return cldsDao; } -- cgit 1.2.3-korg From 9f6d3a45ca962a1ed5c64c84a01e398ec3b00874 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 13 Sep 2017 16:17:05 +0200 Subject: Clean unnecessary files using camunda The camunda examples have been removed as not used by anyone Change-Id: Ib659ea0d68aff613620fce6bf25d4d4a1e1acac4 Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- .../org/onap/clamp/clds/service/LogService.java | 38 --- .../onap/clamp/clds/service/LogServiceImpl.java | 295 --------------------- src/main/resources/META-INF/processes.xml | 8 - .../resources/bpmn/SampleTestProcessDelegate.bpmn | 79 ------ src/main/resources/bpmn/TestHumanTask.bpmn | 80 ------ src/main/resources/bpmn/TestHumanTask.png | Bin 3979 -> 0 bytes src/main/resources/bpmn/dish.dmn | 36 --- src/main/resources/bpmn/log-message.bpmn | 50 ---- src/main/resources/bpmn/log-message.png | Bin 3093 -> 0 bytes 9 files changed, 586 deletions(-) delete mode 100644 src/main/java/org/onap/clamp/clds/service/LogService.java delete mode 100644 src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java delete mode 100644 src/main/resources/bpmn/SampleTestProcessDelegate.bpmn delete mode 100644 src/main/resources/bpmn/TestHumanTask.bpmn delete mode 100644 src/main/resources/bpmn/TestHumanTask.png delete mode 100644 src/main/resources/bpmn/dish.dmn delete mode 100644 src/main/resources/bpmn/log-message.bpmn delete mode 100644 src/main/resources/bpmn/log-message.png (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/service/LogService.java b/src/main/java/org/onap/clamp/clds/service/LogService.java deleted file mode 100644 index 1c3d9dc67..000000000 --- a/src/main/java/org/onap/clamp/clds/service/LogService.java +++ /dev/null @@ -1,38 +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.service; - -public interface LogService { - - String logMessage(String logMessageText, String javamail, String springmail, String commonsmail); - - String postLogMessage(String histEventList); - - String createLogMessage(String startTime, String endTime, String serviceName); - - String createLogMessageUsingHistory(String procInstId, String histEventList); - - String CreateHistLog(String procInstId); - -} diff --git a/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java b/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java deleted file mode 100644 index 2f02aa6ab..000000000 --- a/src/main/java/org/onap/clamp/clds/service/LogServiceImpl.java +++ /dev/null @@ -1,295 +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.service; - -import com.att.ajsc.camunda.core.AttCamundaHistoryEvent; -import com.att.ajsc.camunda.core.AttCamundaService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.google.gson.Gson; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; -import javax.ws.rs.core.Context; - -import org.apache.commons.mail.Email; -import org.apache.commons.mail.SimpleEmail; -import org.apache.cxf.jaxrs.ext.MessageContext; -import org.camunda.bpm.engine.HistoryService; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.history.HistoricActivityInstance; -import org.camunda.bpm.engine.impl.history.event.HistoricActivityInstanceEventEntity; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.onap.clamp.clds.common.LogMessages; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.mail.MailException; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.mail.javamail.JavaMailSenderImpl; -import org.springframework.stereotype.Service; - -@Service -public class LogServiceImpl implements LogService { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(LogServiceImpl.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - - @Autowired - private RuntimeService runtimeService; - - @Autowired - private HistoryService historyService; - - @Context - private MessageContext context; - - public void setRuntimeService(RuntimeService runtimeService) { - this.runtimeService = runtimeService; - } - - public LogServiceImpl() { - // needed for instantiation - } - - @Override - public String logMessage(String logMessageText, String javamail, String springmail, String commonsmail) { - logger.info("Value of contexxt : " + context); - String convId = null; - if (context != null) { - convId = context.getHttpServletRequest().getHeader("X-CSI-ConversationId"); - if (convId == null) { - convId = (String) context.getHttpServletRequest().getAttribute("X-CSI-ConversationId"); - } - context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing"); - AttCamundaService.setHttpRequest(context.getHttpServletRequest()); - } - // input variables to example camunda process - Map variables = new HashMap<>(); - variables.put("logMessageText", logMessageText); - if (convId != null) { - variables.put("conversationId", convId); - } - - // BEGIN - added for send mail testing - // also added the following to the method signature: , - // @QueryParam("javamail") String javamail, @QueryParam("springmail") - // String springmail, @QueryParam("commonsmail") String commonsmail - // if javamail parameter provided, assume it contains an email address. - // use Java Mail to send an email from that address, to that address - if (javamail != null && javamail.length() > 0) { - variables.put("javamail", javamail); - try { - Properties props = new Properties(); - props.put("mail.smtp.host", "smtp.sbc.com"); // eMail.setHostName - Session session = Session.getInstance(props); - MimeMessage msg = new MimeMessage(session); - - msg.setFrom(new InternetAddress(javamail)); // eMail.setFrom - - InternetAddress[] fromAddresses = { new InternetAddress(javamail) }; - msg.setReplyTo(fromAddresses); // eMail.addReplyTo - msg.setSubject("test message using javax.mail"); // eMail.setSubject - msg.setText(logMessageText); // eMail.setMsg - - msg.addRecipient(Message.RecipientType.TO, new InternetAddress(javamail)); // eMail.addTo - Transport.send(msg); - } catch (MessagingException e) { - logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e); - } - } - - // if springmail parameter provided, assume it contains an email - // address. - // use Spring Mail to send an email from that address, to that address - if (springmail != null && springmail.length() > 0) { - variables.put("springmail", springmail); - JavaMailSenderImpl sender = new JavaMailSenderImpl(); - SimpleMailMessage smsg = new SimpleMailMessage(); - - try { - sender.setHost("smtp.sbc.com"); // eMail.setHostName - smsg.setFrom(springmail); // eMail.setFrom - smsg.setReplyTo(springmail); // eMail.addReplyTo - smsg.setSubject("test message using spring mail"); // eMail.setSubject - smsg.setText(logMessageText); // eMail.setMsg - smsg.setTo(springmail); // eMail.addTo - sender.send(smsg); - } catch (MailException e) { - logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e); - } - } - - // if commonsmail parameter provided, assume it contains an email - // address. - // use Apache Commons Mail to send an email from that address, to that - // address - if (commonsmail != null && commonsmail.length() > 0) { - variables.put("commonsmail", commonsmail); - Email email = new SimpleEmail(); - try { - email.setHostName("smtp.sbc.com"); - email.setFrom(commonsmail); - email.addReplyTo(commonsmail); - email.setSubject("test message using commons mail"); - email.setMsg(logMessageText); - email.addTo(commonsmail); - java.net.URL classUrl = this.getClass().getResource("com.sun.mail.util.TraceInputStream"); - if (classUrl != null) { - logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS, classUrl.getFile()); - } else { - logger.info(LogMessages.LOGSERVICE_EMAIL_CLASS_NULL); - } - email.send(); - } catch (Exception e) { - logger.error(LogMessages.LOGSERVICE_EMAIL_ERROR, e); - } - } - // END - added for send mail testing - - // execute example camunda process, log-message-wf - ProcessInstance pi = runtimeService.startProcessInstanceByKey("log-message-wf", variables); - AttCamundaService.setHttpRequest(null); - // return text message of what was done - return "Started processDefinitionId=" + pi.getProcessDefinitionId() + ", processInstanceId=" - + pi.getProcessInstanceId() + ", to log message: " + logMessageText; - } - - @Override - public String postLogMessage(String histEventList) { - String message = "no logs Created"; - logger.info("value of history events:" + histEventList); - Gson gson = new Gson(); - AttCamundaHistoryEvent attCamundaHistoryEvent = gson.fromJson(histEventList, AttCamundaHistoryEvent.class); - if (attCamundaHistoryEvent != null && attCamundaHistoryEvent.getProcInstId() != null) { - logger.info(LogMessages.PROCESS_INSTANCE_ID, attCamundaHistoryEvent.getProcInstId()); - if (context != null && context.getHttpServletRequest() != null - && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { - context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing"); - List histActInstList = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(attCamundaHistoryEvent.getProcInstId()).list(); - - if (histActInstList != null && histActInstList.size() > 0) { - for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) { - if (currHistoricActivityInstance != null - && currHistoricActivityInstance.getActivityName() != null - && currHistoricActivityInstance.getStartTime() != null - && currHistoricActivityInstance.getEndTime() != null) { - logger.info("value of serviceTrack:" + currHistoricActivityInstance); - message = "Log Entry Created"; - logger.info(message); - } - } - } - if (attCamundaHistoryEvent.getHistoryEventList() != null - && attCamundaHistoryEvent.getHistoryEventList().size() > 0) { - List historyEventList = attCamundaHistoryEvent - .getHistoryEventList(); - for (HistoricActivityInstanceEventEntity actiEvent : historyEventList) { - // resolve null pointer exception if - // actiEvent.getActivityName() - message = "Log Entry Created"; - } - } - } - } - return message; - } - - @Override - public String createLogMessage(String startTime, String endTime, String serviceName) { - String message = "no logs Created"; - - if (context != null && context.getHttpServletRequest() != null - && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { - context.getHttpServletRequest().setAttribute("X-CSI-ClientApp", "AJSC-CSI~sdsds"); - /* - * PerformanceTrackingBean trackingBean =(PerformanceTrackingBean) - * context.getHttpServletRequest().getAttribute( - * "PERFORMANCE_TRACKER_BEAN"); - * PerformanceTracking.addInvokeServiceTrack(trackingBean, - * serviceName, Long.valueOf(startTime), Long.valueOf(endTime), - * "Completed", 500, 1000) ; - */ - message = "Log Entry Created"; - } - // return text message of what was done - return message; - } - - @Override - public String createLogMessageUsingHistory(String procInstId, String histEventList) { - String message = "no logs Created"; - logger.info("value of history events:" + histEventList); - logger.info("value of events:" + histEventList + ":" + histEventList); - if (context != null && context.getHttpServletRequest() != null - && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { - context.getHttpServletRequest().setAttribute("CALL_TYPE", "Testing"); - List histActInstList = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(procInstId).list(); - - if (histActInstList != null && histActInstList.size() > 0) { - for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) { - if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null - && currHistoricActivityInstance.getStartTime() != null - && currHistoricActivityInstance.getEndTime() != null) { - logger.info("value of serviceTrack:" + currHistoricActivityInstance); - message = "Log Entry Created"; - logger.info(message); - } - } - } - } - return message; - } - - @Override - public String CreateHistLog(String procInstId) { - String message = "no logs Created"; - if (context != null && context.getHttpServletRequest() != null - && context.getHttpServletRequest().getAttribute("PERFORMANCE_TRACKER_BEAN") != null) { - List histActInstList = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(procInstId).list(); - - if (histActInstList != null && histActInstList.size() > 0) { - for (HistoricActivityInstance currHistoricActivityInstance : histActInstList) { - if (currHistoricActivityInstance != null && currHistoricActivityInstance.getActivityName() != null - && currHistoricActivityInstance.getStartTime() != null - && currHistoricActivityInstance.getEndTime() != null) { - logger.info("value of serviceTrack:" + currHistoricActivityInstance); - context.getHttpServletRequest().setAttribute("X-CSI-ClientApp", "AJSC-CSI~sdsds"); - message = "Log Entry Created"; - } - } - } - } - return message; - } -} diff --git a/src/main/resources/META-INF/processes.xml b/src/main/resources/META-INF/processes.xml index bd3547dfc..921a1029b 100644 --- a/src/main/resources/META-INF/processes.xml +++ b/src/main/resources/META-INF/processes.xml @@ -25,14 +25,6 @@ - - default - bpmn/log-message.bpmn - - true - false - - default bpmn/clds-process-action.bpmn diff --git a/src/main/resources/bpmn/SampleTestProcessDelegate.bpmn b/src/main/resources/bpmn/SampleTestProcessDelegate.bpmn deleted file mode 100644 index 41ffdb6dc..000000000 --- a/src/main/resources/bpmn/SampleTestProcessDelegate.bpmn +++ /dev/null @@ -1,79 +0,0 @@ - - - - - SequenceFlow_2 - - - SequenceFlow_2 - SequenceFlow_1 - - - - - SequenceFlow_1 - SequenceFlow_6 - - - - SequenceFlow_6 - SequenceFlow_5 - - - - SequenceFlow_5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/bpmn/TestHumanTask.bpmn b/src/main/resources/bpmn/TestHumanTask.bpmn deleted file mode 100644 index d456d65f1..000000000 --- a/src/main/resources/bpmn/TestHumanTask.bpmn +++ /dev/null @@ -1,80 +0,0 @@ - - - - - SequenceFlow_2 - - - SequenceFlow_2 - SequenceFlow_3 - - - - SequenceFlow_5 - - - SequenceFlow_6 - SequenceFlow_5 - - - - SequenceFlow_027hi4f - SequenceFlow_6 - - - - - SequenceFlow_3 - SequenceFlow_027hi4f - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/bpmn/TestHumanTask.png b/src/main/resources/bpmn/TestHumanTask.png deleted file mode 100644 index 7d8af39d4..000000000 Binary files a/src/main/resources/bpmn/TestHumanTask.png and /dev/null differ diff --git a/src/main/resources/bpmn/dish.dmn b/src/main/resources/bpmn/dish.dmn deleted file mode 100644 index 473a07ae5..000000000 --- a/src/main/resources/bpmn/dish.dmn +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - season - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/bpmn/log-message.bpmn b/src/main/resources/bpmn/log-message.bpmn deleted file mode 100644 index f38f254d8..000000000 --- a/src/main/resources/bpmn/log-message.bpmn +++ /dev/null @@ -1,50 +0,0 @@ - - - - - SequenceFlow_0k87nxp - - - SequenceFlow_0zjfjoh - - - - - SequenceFlow_0k87nxp - SequenceFlow_0zjfjoh - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/bpmn/log-message.png b/src/main/resources/bpmn/log-message.png deleted file mode 100644 index fa7c7565f..000000000 Binary files a/src/main/resources/bpmn/log-message.png and /dev/null differ -- cgit 1.2.3-korg From ff1b29770a38e58c7b8e59e567339c3f7921aa5c Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Wed, 13 Sep 2017 16:21:38 +0200 Subject: Add test to Holmes New test for holmes and refactor of the application.java class according to Sonar reports Change-Id: I2117b403c18e2cb2cd902018db951025a1db9bae Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/Application.java | 17 +- src/main/resources/application.properties | 22 ++- .../clamp/clds/model/prop/ModelPropertiesTest.java | 88 +++++----- .../example/model-properties/modelBpmn.json | 38 +++++ .../example/model-properties/modelBpmnProp.json | 188 +++++++++++++++++++++ src/test/resources/https/https-test.properties | 26 +-- 6 files changed, 312 insertions(+), 67 deletions(-) create mode 100644 src/test/resources/example/model-properties/modelBpmn.json create mode 100644 src/test/resources/example/model-properties/modelBpmnProp.json (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java index 4fc68e1d0..0304a6806 100644 --- a/src/main/java/org/onap/clamp/clds/Application.java +++ b/src/main/java/org/onap/clamp/clds/Application.java @@ -36,6 +36,8 @@ 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; @@ -43,6 +45,7 @@ import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoC import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -57,8 +60,8 @@ import org.springframework.scheduling.annotation.EnableAsync; @SpringBootApplication @ComponentScan(basePackages = { "org.onap.clamp.clds", "com.att.ajsc" }) -@EnableAutoConfiguration(exclude = { CamundaBpmWebappAutoConfiguration.class, HibernateJpaAutoConfiguration.class, - JpaRepositoriesAutoConfiguration.class, SecurityAutoConfiguration.class, +@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, CamundaBpmWebappAutoConfiguration.class, + HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class }) @EnableAsync public class Application extends SpringBootServletInitializer { @@ -92,11 +95,19 @@ public class Application extends SpringBootServletInitializer { return application.sources(Application.class); } - public static void main(String[] args) throws Exception { + 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 SpringApplication.run(Application.class, args); // NOSONAR } + private static void initializeComponents() { + ModelProperties.registerModelElement(Holmes.class, Holmes.getType()); + } + @Bean public ServletRegistrationBean servletRegistrationBean() { ServletRegistrationBean registration = new ServletRegistrationBean(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a66557835..854fe737d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -64,7 +64,6 @@ server.contextPath=/ #Modified engine-rest applicationpath spring.jersey.application-path=/engine-rest spring.profiles.active=clamp-default,clamp-spring-authentication -spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration #The max number of active threads in this pool server.tomcat.max-threads=200 @@ -93,34 +92,41 @@ 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 -spring.datasource.camunda.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/camundabpm?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.camunda.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/camundabpm?autoReconnect=true spring.datasource.camunda.username=camunda spring.datasource.camunda.password=ndMSpw4CAM spring.datasource.camunda.validationQuery=SELECT 1 spring.datasource.camunda.validationQueryTimeout=20000 -spring.datasource.camunda.validationInterval=60000 +spring.datasource.camunda.validationInterval=30000 spring.datasource.camunda.testWhileIdle = true +spring.datasource.camunda.minIdle = 0 +spring.datasource.camunda.initialSize=0 # Automatically test whether a connection provided is good or not spring.datasource.camunda.testOnBorrow=true +spring.datasource.camunda.ignoreExceptionOnPreLoad=true #Camunda application properties #Camunda history level -camunda.bpm.history-level=auto +camunda.bpm.history-level=none +camunda.bpm.database.type=mariadb +camunda.bpm.database.schema-update=false #clds datasource connection details -spring.datasource.camunda.driverClassName=org.mariadb.jdbc.Driver -spring.datasource.cldsdb.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/cldsdb4?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver +spring.datasource.cldsdb.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/cldsdb4?autoReconnect=true spring.datasource.cldsdb.username=clds spring.datasource.cldsdb.password=sidnnd83K spring.datasource.cldsdb.validationQuery=SELECT 1 spring.datasource.cldsdb.validationQueryTimeout=20000 -spring.datasource.cldsdb.validationInterval=60000 +spring.datasource.cldsdb.validationInterval=30000 spring.datasource.cldsdb.testWhileIdle = true +spring.datasource.cldsdb.minIdle = 0 +spring.datasource.cldsdb.initialSize=0 # Automatically test whether a connection provided is good or not spring.datasource.cldsdb.testOnBorrow=true +spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true #Async Executor default Parameters async.core.pool.size=10 diff --git a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java index 22b3ba0cb..02e27ea8f 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java @@ -24,69 +24,65 @@ package org.onap.clamp.clds.model.prop; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; -import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.onap.clamp.clds.util.ResourceFileUtil; - /** * Test org.onap.clamp.ClampDesigner.model.prop package using ModelProperties. */ public class ModelPropertiesTest { - @Test - public void testJsonParse() throws IOException { - String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnProp.json"); - String modelProp = ResourceFileUtil.getResourceAsString("example/modelProp.json"); - String modName = "example-model-name"; - String controlName = "example-control-name"; - - ModelProperties prop = new ModelProperties(modName, controlName, null, true, modelBpmnProp, modelProp); - Assert.assertEquals(modName, prop.getModelName()); - Assert.assertEquals(controlName, prop.getControlName()); - Assert.assertEquals(null, prop.getActionCd()); - Global global = prop.getGlobal(); - Assert.assertEquals("0f983e18-4603-4bb4-a98c-e29691fb16a1", global.getService()); - Assert.assertEquals("[SNDGCA64]", global.getLocation().toString()); - Assert.assertEquals("[6c7aaec2-59eb-41d9-8681-b7f976ab668d]", global.getResourceVf().toString()); - StringMatch sm = prop.getType(StringMatch.class); - Assert.assertEquals("StringMatch_", sm.getId()); - Policy policy = prop.getType(Policy.class); - Assert.assertEquals("Policy_", policy.getId()); - Assert.assertEquals(null, policy.getTopicPublishes()); - Assert.assertEquals(null, policy.getTopicSubscribes()); - - Tca tca = prop.getType(Tca.class); - Assert.assertEquals("Narra", tca.getTcaItems().get(0).getTcaName()); - Assert.assertEquals(Integer.valueOf(4), tca.getTcaItems().get(0).getTcaThreshholds().get(0).getThreshhold()); + @Before + public void registerNewClasses() { + ModelProperties.registerModelElement(Holmes.class, Holmes.getType()); } @Test - public void testPolicy() throws IOException { + public void testHolmes() throws IOException { - String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnPropForPolicy.json"); - System.out.println(modelBpmnProp); + String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/model-properties/modelBpmnProp.json"); + String modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/modelBpmn.json"); + + ModelProperties prop = new ModelProperties("example-model-name", "example-control-name", null, true, modelBpmn, + modelBpmnProp); - String modelProp = ResourceFileUtil.getResourceAsString("example/modelPropForPolicy.json"); - System.out.println(modelProp); - ModelProperties prop = new ModelProperties("example-model-name", "example-control-name", - null, true, modelBpmnProp, modelProp); - System.out.println("attempting prop.getGlobal()..."); - Global global = prop.getGlobal(); - System.out.println("attempting prop.getStringMatch()..."); StringMatch stringMatch = prop.getType(StringMatch.class); - if (stringMatch.isFound()) { - System.out.println("stringMatch json object is present..."); - assertEquals("1", stringMatch.getResourceGroups().get(0).getPolicyId()); - } - System.out.println("attempting prop.getPolicy()..."); + assertTrue(stringMatch.isFound()); + assertEquals("1505133578560", stringMatch.getResourceGroups().get(0).getGroupNumber()); + assertEquals("0", stringMatch.getResourceGroups().get(0).getPolicyId()); + assertEquals(1, stringMatch.getResourceGroups().get(0).getServiceConfigurations().size()); + List aaiMathcingFields = new ArrayList(); + aaiMathcingFields.add("complex.city"); + assertEquals(aaiMathcingFields, + stringMatch.getResourceGroups().get(0).getServiceConfigurations().get(0).getaaiMatchingFields()); + assertEquals("1600", stringMatch.getResourceGroups().get(0).getServiceConfigurations().get(0).getAgeLimit()); + assertEquals(1, stringMatch.getResourceGroups().get(0).getServiceConfigurations().get(0).getStringSet().size()); + + Collector collector = prop.getType(Collector.class); + assertTrue(collector.isFound()); + assertEquals("DCAE-COLLECTOR-UCSNMP", collector.getTopicPublishes()); + Policy policy = prop.getType(Policy.class); - if (policy.isFound()) { - System.out.println("policy json object is present..."); - assertEquals("1", policy.getPolicyChains().get(0).getPolicyId()); - } + assertTrue(policy.isFound()); + assertEquals(1, policy.getPolicyChains().size()); + assertEquals("0", policy.getPolicyChains().get(0).getPolicyId()); + assertEquals(1, policy.getPolicyChains().get(0).getPolicyItems().size()); + + Tca tca = prop.getType(Tca.class); + assertTrue(tca.isFound()); + assertEquals(1, tca.getTcaItems().size()); + assertEquals(0, tca.getTcaItems().get(0).getTcaThreshholds().size()); + + Holmes holmes = prop.getType(Holmes.class); + assertTrue(holmes.isFound()); + assertEquals("policy1", holmes.getOperationalPolicy()); + assertEquals("blabla", holmes.getCorrelationLogic()); } } \ No newline at end of file diff --git a/src/test/resources/example/model-properties/modelBpmn.json b/src/test/resources/example/model-properties/modelBpmn.json new file mode 100644 index 000000000..4737174c5 --- /dev/null +++ b/src/test/resources/example/model-properties/modelBpmn.json @@ -0,0 +1,38 @@ +{ + "collector": [ + { + "id": "Collector_1c72ct5", + "from": "StartEvent_1" + } + ], + "stringMatch": [ + { + "id": "StringMatch_05arstl", + "from": "Collector_1c72ct5" + } + ], + "policy": [ + { + "id": "Policy_0honxgv", + "from": "TCA_1jy9to4" + } + ], + "tca": [ + { + "id": "TCA_1jy9to4", + "from": "Holmes_0i4n2mm" + } + ], + "holmes": [ + { + "id": "Holmes_0i4n2mm", + "from": "VesCollector_0orydnh" + } + ], + "vesCollector": [ + { + "id": "VesCollector_0orydnh", + "from": "StringMatch_05arstl" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/example/model-properties/modelBpmnProp.json b/src/test/resources/example/model-properties/modelBpmnProp.json new file mode 100644 index 000000000..7e799aa8b --- /dev/null +++ b/src/test/resources/example/model-properties/modelBpmnProp.json @@ -0,0 +1,188 @@ +{ + "Collector_1c72ct5": [ + { + "name": "topicPublishes", + "value": "DCAE-COLLECTOR-UCSNMP" + } + ], + "StringMatch_05arstl": { + "group1": [ + { + "name": "rgname", + "value": "1505133578560" + }, + { + "name": "rgfriendlyname", + "value": "group1" + }, + { + "name": "policyName", + "value": "policy1" + }, + { + "name": "policyId", + "value": "0" + }, + { + "serviceConfigurations": [ + [ + { + "name": "aaiMatchingFields", + "value": [ + "complex.city" + ] + }, + { + "name": "aaiSendFields", + "value": [ + "cloud-region.identity-url" + ] + }, + { + "name": "timeWindow", + "value": [ + "0" + ] + }, + { + "name": "ageLimit", + "value": [ + "1600" + ] + }, + { + "name": "createClosedLoopEventId", + "value": [ + "Initial" + ] + }, + { + "name": "outputEventName", + "value": [ + "" + ] + }, + { + "stringSet": [ + { + + }, + { + "name": "eventSeverity", + "value": [ + "NORMAL" + ] + }, + { + "name": "eventSourceType", + "value": [ + "" + ] + } + ] + } + ] + ] + } + ] + }, + "Policy_0honxgv": { + "policy1": [ + { + "name": "pname", + "value": "policy1" + }, + { + "name": "pid", + "value": "0" + }, + { + "name": "timeout", + "value": "345" + }, + { + "policyConfigurations": [ + [ + { + "name": "maxRetries", + "value": [ + "3" + ] + }, + { + "name": "retryTimeLimit", + "value": [ + "180" + ] + }, + { + "name": "_id", + "value": [ + "dGLuNqg" + ] + }, + { + "name": "parentPolicy", + "value": [ + "" + ] + } + ] + ] + } + ] + }, + "TCA_1jy9to4": { + "tca1": [ + { + "name": "tname", + "value": "tca1" + }, + { + "name": "tuuid", + "value": "f43e3499-8c9c-teed-bb41-a0cb38ebf0d3" + }, + { + "name": "tnfc", + "value": "" + }, + { + "name": "tcaEnab", + "value": "on" + }, + { + "name": "tcaPol", + "value": "policy1" + }, + { + "name": "tcaPolId", + "value": "0" + }, + { + "name": "tcaInt", + "value": "1" + }, + { + "name": "tcaSev", + "value": "NORMAL" + }, + { + "name": "tcaVio", + "value": "1" + }, + { + "serviceConfigurations": [] + } + ] + }, + "Holmes_0i4n2mm": [ + { + "name": "correlationalLogic", + "value": "blabla" + }, + { + "name": "operationalPolicy", + "value": "policy1" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties index b30f6aaf9..d34f028a3 100644 --- a/src/test/resources/https/https-test.properties +++ b/src/test/resources/https/https-test.properties @@ -64,7 +64,6 @@ server.contextPath=/ #Modified engine-rest applicationpath spring.jersey.application-path=/engine-rest spring.profiles.active=clamp-default,clamp-spring-authentication -spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration #The max number of active threads in this pool server.tomcat.max-threads=200 @@ -93,35 +92,42 @@ camel.defaultthreadpool.rejectpolicy=CallerRuns kubernetes.namespace=com-att-ajsc #server.port=0 - #Camunda Process Engine DataSource connection Details -spring.datasource.camunda.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/camundabpm?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.camunda.driverClassName=org.mariadb.jdbc.Driver +spring.datasource.camunda.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/camundabpm?autoReconnect=true spring.datasource.camunda.username=camunda spring.datasource.camunda.password=ndMSpw4CAM -spring.datasource.camunda.driverClassName=org.mariadb.jdbc.Driver spring.datasource.camunda.validationQuery=SELECT 1 spring.datasource.camunda.validationQueryTimeout=20000 -spring.datasource.camunda.validationInterval=60000 +spring.datasource.camunda.validationInterval=30000 spring.datasource.camunda.testWhileIdle = true +spring.datasource.camunda.minIdle = 0 +spring.datasource.camunda.initialSize=0 # Automatically test whether a connection provided is good or not spring.datasource.camunda.testOnBorrow=true +spring.datasource.camunda.ignoreExceptionOnPreLoad=true + #Camunda application properties #Camunda history level -camunda.bpm.history-level=auto +camunda.bpm.history-level=none +camunda.bpm.database.type=mariadb +camunda.bpm.database.schema-update=false #clds datasource connection details -spring.datasource.cldsdb.driver-class-name=org.mariadb.jdbc.Driver -spring.datasource.cldsdb.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/cldsdb4?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver +spring.datasource.cldsdb.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/cldsdb4?autoReconnect=true spring.datasource.cldsdb.username=clds spring.datasource.cldsdb.password=sidnnd83K -spring.datasource.cldsdb.driverClassName=com.mysql.jdbc.Driver spring.datasource.cldsdb.validationQuery=SELECT 1 spring.datasource.cldsdb.validationQueryTimeout=20000 -spring.datasource.cldsdb.validationInterval=60000 +spring.datasource.cldsdb.validationInterval=30000 spring.datasource.cldsdb.testWhileIdle = true +spring.datasource.cldsdb.minIdle = 0 +spring.datasource.cldsdb.initialSize=0 # Automatically test whether a connection provided is good or not spring.datasource.cldsdb.testOnBorrow=true +spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true #Async Executor default Parameters async.core.pool.size=10 -- cgit 1.2.3-korg From 729ad06baa65151578399f13173cc5de35e1be8c Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Thu, 14 Sep 2017 16:08:55 +0200 Subject: Some rework around DAO classes Remove the useless return parameter in setModel, remove the runtimeService in cldsTemplateService Change-Id: Ia6d82cc3167f2e82b0da9cdb14d93c64ccee19c4 Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- src/main/java/org/onap/clamp/clds/dao/CldsDao.java | 4 +--- src/main/java/org/onap/clamp/clds/service/CldsService.java | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'src/main/java') 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 3cc6a325a..b64978346 100644 --- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -407,9 +407,8 @@ public class CldsDao { * * @param template * @param userid - * @return */ - public CldsTemplate setTemplate(CldsTemplate template, String userid) { + public void setTemplate(CldsTemplate template, String userid) { SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", template.getName()) .addValue("v_user_id", userid).addValue("v_template_bpmn_text", template.getBpmnText()) .addValue("v_template_image_text", template.getImageText()) @@ -425,7 +424,6 @@ public class CldsDao { template.setPropId((String) (out.get("v_template_doc_id"))); template.setPropUserid((String) out.get("v_template_doc_user_id")); template.setPropText((String) out.get("v_template_doc_text")); - return template; } /** 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 920bce181..0d62be55b 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -402,7 +402,6 @@ public class CldsService extends SecureServiceBase { } } cldsModel.save(cldsDao, getUserId()); - cldsModel.save(cldsDao, getUserId()); // audit log LoggingUtils.setTimeContext(startTime, new Date()); LoggingUtils.setResponseContext("0", "Put model success", this.getClass().getName()); -- cgit 1.2.3-korg From fbe35388ec1841b8a75fb054d2fc809b901c11aa Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Thu, 14 Sep 2017 16:11:00 +0200 Subject: Add new tests for DAO New test to validate some methods of the DAO and attempt to disable Camunda in IT when it was not required to have it Change-Id: I231230a7a4818f4bfd7887319a321625f66ffcae Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/service/CldsTemplateService.java | 4 +- .../java/org/onap/clamp/clds/it/CldsDaoIT.java | 149 +++++++ src/test/java/org/onap/clamp/clds/it/DcaeIT.java | 10 +- src/test/java/org/onap/clamp/clds/it/HttpsIT.java | 3 +- .../org/onap/clamp/clds/it/PolicyClientIT.java | 2 + .../org/onap/clamp/clds/it/PropJsonBuilderIT.java | 83 ++-- .../java/org/onap/clamp/clds/it/RefPropIT.java | 5 +- .../onap/clamp/clds/it/SdcCatalogServicesIT.java | 5 +- src/test/java/org/onap/clamp/clds/it/SdcIT.java | 20 +- .../resources/application-no-camunda.properties | 158 ++++++++ src/test/resources/example/dao/bpmn-prop.json | 54 +++ src/test/resources/example/dao/bpmn-template.xml | 126 ++++++ src/test/resources/example/dao/image-template.xml | 448 +++++++++++++++++++++ 13 files changed, 1000 insertions(+), 67 deletions(-) create mode 100644 src/test/java/org/onap/clamp/clds/it/CldsDaoIT.java create mode 100644 src/test/resources/application-no-camunda.properties create mode 100644 src/test/resources/example/dao/bpmn-prop.json create mode 100644 src/test/resources/example/dao/bpmn-template.xml create mode 100644 src/test/resources/example/dao/image-template.xml (limited to 'src/main/java') 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 87f9c0c4f..e6e7325a9 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsTemplateService.java @@ -49,7 +49,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.xml.transform.TransformerException; -import org.camunda.bpm.engine.RuntimeService; import org.onap.clamp.clds.dao.CldsDao; import org.onap.clamp.clds.model.CldsTemplate; import org.onap.clamp.clds.model.ValueItem; @@ -90,8 +89,7 @@ public class CldsTemplateService extends SecureServiceBase { @Autowired private CldsDao cldsDao; - @Autowired - private RuntimeService runtimeService; + @Autowired private XslTransformer cldsBpmnTransformer; diff --git a/src/test/java/org/onap/clamp/clds/it/CldsDaoIT.java b/src/test/java/org/onap/clamp/clds/it/CldsDaoIT.java new file mode 100644 index 000000000..bd419647d --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/it/CldsDaoIT.java @@ -0,0 +1,149 @@ +/*- + * ============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.it; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import javax.ws.rs.NotFoundException; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.clamp.clds.AbstractIT; +import org.onap.clamp.clds.dao.CldsDao; +import org.onap.clamp.clds.model.CldsEvent; +import org.onap.clamp.clds.model.CldsModel; +import org.onap.clamp.clds.model.CldsTemplate; +import org.onap.clamp.clds.util.ResourceFileUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * Test CldsDAO calls through CldsModel and CldsEvent. This really test the DB + * and stored procedures. + */ +@RunWith(SpringRunner.class) +@SpringBootTest +@TestPropertySource(locations = "classpath:application-no-camunda.properties") +public class CldsDaoIT extends AbstractIT { + + @Autowired + public CldsDao cldsDao; + + private String bpmnText; + private String imageText; + private String bpmnPropText; + + @Before + public void setupBefore() throws IOException { + bpmnText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-template.xml"); + imageText = ResourceFileUtil.getResourceAsString("example/dao/image-template.xml"); + bpmnPropText = ResourceFileUtil.getResourceAsString("example/dao/bpmn-prop.json"); + } + + @Test + public void testModelSave() throws IOException { + // Add the template first + CldsTemplate newTemplate = new CldsTemplate(); + newTemplate.setName("test-template"); + + newTemplate.setBpmnText(bpmnText); + newTemplate.setImageText(imageText); + + // Save the template in DB + cldsDao.setTemplate(newTemplate, "user"); + // Test if it's well there + CldsTemplate newTemplateRead = cldsDao.getTemplate("test-template"); + assertEquals(bpmnText, newTemplateRead.getBpmnText()); + assertEquals(imageText, newTemplateRead.getImageText()); + + // Save the model + CldsModel newModel = new CldsModel(); + newModel.setName("test-model"); + + newModel.setBpmnText(bpmnText); + newModel.setImageText(imageText); + newModel.setPropText(bpmnPropText); + newModel.setControlNamePrefix("ClosedLoop-"); + newModel.setTemplateName("test-template"); + newModel.setTemplateId(newTemplate.getId()); + newModel.setDocText(newTemplate.getPropText()); + newModel.setDocId(newTemplate.getPropId()); + // Save the model in DB + cldsDao.setModel(newModel, "user"); + // Test if the model can be retrieved + CldsModel newCldsModel = cldsDao.getModelTemplate("test-model"); + assertEquals(bpmnText, newCldsModel.getBpmnText()); + assertEquals(imageText, newCldsModel.getImageText()); + assertEquals(bpmnPropText, newCldsModel.getPropText()); + + } + + @Test(expected = NotFoundException.class) + public void testGetModelNotFound() { + CldsModel.retrieve(cldsDao, "test-model-not-found", false); + } + + @Test(expected = NotFoundException.class) + public void testGetTemplateNotFound() { + CldsTemplate.retrieve(cldsDao, "test-template-not-found", false); + } + + @Test + public void testInsEvent() { + // Add the template first + CldsTemplate newTemplate = new CldsTemplate(); + newTemplate.setName("test-template-for-event"); + + newTemplate.setBpmnText(bpmnText); + newTemplate.setImageText(imageText); + + newTemplate.save(cldsDao, "user"); + + // Test if it's well there + CldsTemplate newTemplateRead = CldsTemplate.retrieve(cldsDao, "test-template-for-event", false); + assertEquals(bpmnText, newTemplateRead.getBpmnText()); + assertEquals(imageText, newTemplateRead.getImageText()); + + // Save the model + CldsModel newModel = new CldsModel(); + newModel.setName("test-model-for-event"); + + newModel.setBpmnText(bpmnText); + newModel.setImageText(imageText); + newModel.setPropText(bpmnPropText); + newModel.setControlNamePrefix("ClosedLoop-"); + newModel.setTemplateName("test-template-for-event"); + newModel.setTemplateId(newTemplate.getId()); + newModel.setDocText(newTemplate.getPropText()); + newModel.setDocId(newTemplate.getPropId()); + + CldsEvent.insEvent(cldsDao, newModel, "user", CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_COMPLETED, + "process-instance-id"); + } +} diff --git a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java b/src/test/java/org/onap/clamp/clds/it/DcaeIT.java index fc13270c3..4f0ebb4e2 100644 --- a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java +++ b/src/test/java/org/onap/clamp/clds/it/DcaeIT.java @@ -25,7 +25,6 @@ package org.onap.clamp.clds.it; import org.junit.Test; import org.junit.runner.RunWith; - import org.onap.clamp.clds.AbstractIT; import org.onap.clamp.clds.client.req.DcaeReq; import org.onap.clamp.clds.model.CldsEvent; @@ -33,13 +32,16 @@ import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** - * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE Delegates in test. + * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE + * Delegates in test. */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class DcaeIT extends AbstractIT { @Test @@ -49,8 +51,8 @@ public class DcaeIT extends AbstractIT { String modelName = "example-model"; String controlName = "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756"; - ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, - true, modelBpmnProp, modelProp); + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, + modelProp); String dcaeReq = DcaeReq.format(refProp, prop); System.out.println("dcaeReq=" + dcaeReq); diff --git a/src/test/java/org/onap/clamp/clds/it/HttpsIT.java b/src/test/java/org/onap/clamp/clds/it/HttpsIT.java index ff6303306..98319b41a 100644 --- a/src/test/java/org/onap/clamp/clds/it/HttpsIT.java +++ b/src/test/java/org/onap/clamp/clds/it/HttpsIT.java @@ -50,8 +50,7 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate; /** - * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE - * Delegates in test. + * Test HTTP and HTTPS settings + redirection of HTTP to HTTPS. */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java index 69df97212..09f1efef3 100644 --- a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java +++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java @@ -48,6 +48,7 @@ import org.onap.policy.api.AttributeType; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** @@ -56,6 +57,7 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class PolicyClientIT extends AbstractIT { String modelProp; String modelBpmnProp; diff --git a/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java b/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java index c3b35eec9..525f9cb3c 100644 --- a/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java +++ b/src/test/java/org/onap/clamp/clds/it/PropJsonBuilderIT.java @@ -39,6 +39,7 @@ import org.onap.clamp.clds.client.req.SdcReq; import org.onap.clamp.clds.model.CldsSdcServiceDetail; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** @@ -49,9 +50,10 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class PropJsonBuilderIT extends AbstractIT { - private String globalPropsPartial; + private String globalPropsPartial; private ObjectMapper mapper; /** @@ -86,8 +88,8 @@ public class PropJsonBuilderIT extends AbstractIT { private void sampleJsonObject() throws JsonProcessingException { /** - * Create three JSON Objects objectNode1, objectNode2, objectNode3. - * Add all these three objects in the array + * Create three JSON Objects objectNode1, objectNode2, objectNode3. Add + * all these three objects in the array */ ObjectNode objectNode1 = mapper.createObjectNode(); objectNode1.put("bookName", "Java"); @@ -124,9 +126,8 @@ public class PropJsonBuilderIT extends AbstractIT { private String createEmptySharedObject() throws JsonProcessingException { /** - * Empty Object initialization. - * "": { "vf": { "": "" }, "location": { "": "" }, "alarmCondition": { - * "": "" } } + * Empty Object initialization. "": { "vf": { "": "" }, "location": { + * "": "" }, "alarmCondition": { "": "" } } */ ObjectNode emptyObjectNode = mapper.createObjectNode(); emptyObjectNode.put("", ""); @@ -144,8 +145,8 @@ public class PropJsonBuilderIT extends AbstractIT { emptyServiceObjectNode.putPOJO("", samArrayNode); /** - * Object initialization. - * "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3" } + * Object initialization. "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": + * "DCAE_CLAMP_DEMO3" } * */ ObjectNode dcaeClampDemo3Node = mapper.createObjectNode(); @@ -157,9 +158,8 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("vf", vfArrayNode); /** - * Object initialization. - * "location": { "SNDGCA64": "San Diego SAN3", "ALPRGAED": - * "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, + * Object initialization. "location": { "SNDGCA64": "San Diego SAN3", + * "ALPRGAED": "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, */ ObjectNode sandiegoLocationNode = mapper.createObjectNode(); sandiegoLocationNode.put("SNDGCA64", "San Diego SAN3"); @@ -173,10 +173,10 @@ public class PropJsonBuilderIT extends AbstractIT { locationObjectNode2.putPOJO("location", locationArrayNode); /** - * Object initialization. - * "alarmCondition": { "A+Fallback+Operation+will+soon+be+started": - * "A Fallback Operation will soon be started", - * "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed", + * Object initialization. "alarmCondition": { + * "A+Fallback+Operation+will+soon+be+started": "A Fallback Operation + * will soon be started", "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto + * Export Backup Failed", */ ObjectNode alamrCondition1 = mapper.createObjectNode(); alamrCondition1.put("A+Fallback+Operation+will+soon+be+started", "A Fallback Operation will soon be started"); @@ -206,8 +206,7 @@ public class PropJsonBuilderIT extends AbstractIT { byServiceBasicObjetNode.putPOJO("byService", byServiceBasicArrayNode); /** - * Object initialization. - * "byVf": { "": { "vfc": { "": "" }, + * Object initialization. "byVf": { "": { "vfc": { "": "" }, * "03596c12-c7e3-44b7-8994-5cdfeda8afdd": { "vfc": { " ": " " } } } } */ ObjectNode vfCObjectNode = mapper.createObjectNode(); @@ -240,9 +239,8 @@ public class PropJsonBuilderIT extends AbstractIT { private String createTestEmptySharedObject() throws IOException { /** - * Object initialization. - * "": { "vf": { "": "" }, "location": { "": "" }, "alarmCondition": { - * "": "" } } + * Object initialization. "": { "vf": { "": "" }, "location": { "": "" + * }, "alarmCondition": { "": "" } } */ ObjectNode emptyObjectNode = mapper.createObjectNode(); emptyObjectNode.put("", ""); @@ -254,8 +252,8 @@ public class PropJsonBuilderIT extends AbstractIT { emptyServiceObjectNode.putPOJO("", vfObjectNode); /** - * Object initialization. - * "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3" } + * Object initialization. "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": + * "DCAE_CLAMP_DEMO3" } * */ ObjectNode vfObjectNode2 = mapper.createObjectNode(); @@ -265,9 +263,8 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("vf", dcaeClampDemo3Node); /** - * Object initialization. - * "location": { "SNDGCA64": "San Diego SAN3", "ALPRGAED": - * "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, + * Object initialization. "location": { "SNDGCA64": "San Diego SAN3", + * "ALPRGAED": "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, */ // ObjectNode sandiegoLocationNode = mapper.createObjectNode(); // sandiegoLocationNode.put("SNDGCA64","San Diego SAN3"); @@ -277,10 +274,10 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("location", locationJsonNode); /** - * Object initialization. - * "alarmCondition": { "A+Fallback+Operation+will+soon+be+started": - * "A Fallback Operation will soon be started", - * "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed", + * Object initialization. "alarmCondition": { + * "A+Fallback+Operation+will+soon+be+started": "A Fallback Operation + * will soon be started", "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto + * Export Backup Failed", */ // ObjectNode alamrCondition1 = mapper.createObjectNode(); // alamrCondition1.put("A+Fallback+Operation+will+soon+be+started","A @@ -295,8 +292,7 @@ public class PropJsonBuilderIT extends AbstractIT { byServiceBasicObjetNode.putPOJO("byService", emptyServiceObjectNode); /** - * Object initialization. - * "byVf": { "": { "vfc": { "": "" }, + * Object initialization. "byVf": { "": { "vfc": { "": "" }, * "03596c12-c7e3-44b7-8994-5cdfeda8afdd": { "vfc": { " ": " " } } } } */ ObjectNode vfCObjectNode = mapper.createObjectNode(); @@ -316,9 +312,8 @@ public class PropJsonBuilderIT extends AbstractIT { private String createCldsSharedObject(CldsSdcServiceDetail CldsSdcServiceDetail) throws IOException { /** - * Object initialization. - * "": { "vf": { "": "" }, "location": { "": "" }, "alarmCondition": { - * "": "" } } + * Object initialization. "": { "vf": { "": "" }, "location": { "": "" + * }, "alarmCondition": { "": "" } } */ ObjectNode emptyObjectNode = mapper.createObjectNode(); emptyObjectNode.put("", ""); @@ -330,8 +325,8 @@ public class PropJsonBuilderIT extends AbstractIT { emptyServiceObjectNode.putPOJO("", vfObjectNode); /** - * Object initialization. - * "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": "DCAE_CLAMP_DEMO3" } + * Object initialization. "vf": { " ": " ", "DCAE_CLAMP_DEMO3 1": + * "DCAE_CLAMP_DEMO3" } * */ ObjectNode vfObjectNode2 = mapper.createObjectNode(); @@ -341,9 +336,8 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("vf", dcaeClampDemo3Node); /** - * Object initialization. - * "location": { "SNDGCA64": "San Diego SAN3", "ALPRGAED": - * "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, + * Object initialization. "location": { "SNDGCA64": "San Diego SAN3", + * "ALPRGAED": "Alpharetta PDK1", "LSLEILAA": "Lisle DPA3" }, */ ObjectNode sandiegoLocationNode = mapper.createObjectNode(); sandiegoLocationNode.put("SNDGCA64", "San Diego SAN3"); @@ -351,10 +345,10 @@ public class PropJsonBuilderIT extends AbstractIT { vfObjectNode2.putPOJO("location", sandiegoLocationNode); /** - * Object initialization. - * "alarmCondition": { "A+Fallback+Operation+will+soon+be+started": - * "A Fallback Operation will soon be started", - * "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto Export Backup Failed", + * Object initialization. "alarmCondition": { + * "A+Fallback+Operation+will+soon+be+started": "A Fallback Operation + * will soon be started", "BRM%2C+Auto+Export+Backup+Failed": "BRM, Auto + * Export Backup Failed", */ ObjectNode alamrCondition1 = mapper.createObjectNode(); alamrCondition1.put("A+Fallback+Operation+will+soon+be+started", "A Fallback Operation will soon be started"); @@ -365,8 +359,7 @@ public class PropJsonBuilderIT extends AbstractIT { byServiceBasicObjetNode.putPOJO("byService", emptyServiceObjectNode); /** - * Object initialization. - * "byVf": { "": { "vfc": { "": "" }, + * Object initialization. "byVf": { "": { "vfc": { "": "" }, * "03596c12-c7e3-44b7-8994-5cdfeda8afdd": { "vfc": { " ": " " } } } } */ diff --git a/src/test/java/org/onap/clamp/clds/it/RefPropIT.java b/src/test/java/org/onap/clamp/clds/it/RefPropIT.java index c6a5de29d..473ce4a27 100644 --- a/src/test/java/org/onap/clamp/clds/it/RefPropIT.java +++ b/src/test/java/org/onap/clamp/clds/it/RefPropIT.java @@ -32,6 +32,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractIT; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** @@ -39,12 +40,14 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @SpringBootTest +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class RefPropIT extends AbstractIT { /** * Test getting prop value as a JSON Node / template. * - * @throws IOException when JSON parsing fails + * @throws IOException + * when JSON parsing fails */ @Test public void testJsonTemplate() throws IOException { diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java index 2995b6c8d..dce6c901b 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java @@ -41,14 +41,15 @@ import org.onap.clamp.clds.model.CldsSdcServiceInfo; import org.onap.clamp.clds.model.CldsServiceData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** - * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE - * Delegates in test. + * Test SDC Catalog Service class by mocking the SDC answers. */ @RunWith(SpringRunner.class) @SpringBootTest +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class SdcCatalogServicesIT extends AbstractIT { @Autowired private SdcCatalogServices sdcCatalogWired = new SdcCatalogServices(); diff --git a/src/test/java/org/onap/clamp/clds/it/SdcIT.java b/src/test/java/org/onap/clamp/clds/it/SdcIT.java index da9e5af76..025420ff1 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcIT.java @@ -26,7 +26,6 @@ package org.onap.clamp.clds.it; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; - import org.onap.clamp.clds.AbstractIT; import org.onap.clamp.clds.client.SdcCatalogServices; import org.onap.clamp.clds.client.req.SdcReq; @@ -36,16 +35,18 @@ import org.onap.clamp.clds.model.refprop.RefProp; import org.onap.clamp.clds.util.ResourceFileUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; /** - * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE Delegates in test. + * Test SDC Blueprint formater. */ @RunWith(SpringRunner.class) @SpringBootTest +@TestPropertySource(locations = "classpath:application-no-camunda.properties") public class SdcIT extends AbstractIT { @Autowired - private RefProp refProp; + private RefProp refProp; @Autowired private SdcCatalogServices sdcCatalogServices; @@ -62,14 +63,13 @@ public class SdcIT extends AbstractIT { String modelName = "example-model06"; String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; String docText = ResourceFileUtil.getResourceAsString("example/templateProp.json"); - ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, - true, modelBpmnProp, modelProp); + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, + modelProp); String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); System.out.println("blueprint=" + blueprint); - //assertEquals(blueprint, ""); + // assertEquals(blueprint, ""); } - @Test public void testTcaBlueprint() throws Exception { String modelProp = ResourceFileUtil.getResourceAsString("example/modelPropForPolicy.json"); @@ -77,10 +77,10 @@ public class SdcIT extends AbstractIT { String modelName = "example-model06"; String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; String docText = ResourceFileUtil.getResourceAsString("example/templatePropForTca.json"); - ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, - true, modelBpmnProp, modelProp); + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, + modelProp); String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); System.out.println("blueprint=" + blueprint); - //assertEquals(blueprint, ""); + // assertEquals(blueprint, ""); } } diff --git a/src/test/resources/application-no-camunda.properties b/src/test/resources/application-no-camunda.properties new file mode 100644 index 000000000..dbf0e5bab --- /dev/null +++ b/src/test/resources/application-no-camunda.properties @@ -0,0 +1,158 @@ +### +# ============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. +### + +info.build.artifact=@project.artifactId@ +info.build.name=@project.name@ +info.build.description=@project.description@ +info.build.version=@project.version@ + +### Set the port for HTTP or HTTPS protocol (Controlled by Spring framework, only one at a time). +### (See below for the parameter 'server.http.port' if you want to have both enabled) +### To have only HTTP, keep the lines server.ssl.* commented +### To have only HTTPS enabled, uncomment the server.ssl.* lines and specify a right keystore location +server.port=10443 +### Settings for HTTPS (this automatically enables the HTTPS on the port 'server.port') +server.ssl.key-store=classpath:https/keystore-test.jks +server.ssl.key-store-password=testpass +server.ssl.key-password=testpass + +### 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 ...) +#server.http-to-https-redirection.port=10080 + +### HTTP Example: +###-------------- +### server.port=8080 + +### HTTPS Example: +### -------------- +### server.port=8443 +### server.ssl.key-store=file:/tmp/mykey.jks +### server.ssl.key-store-password=mypass +### server.ssl.key-password=mypass + +### HTTP (Redirected to HTTPS) and HTTPS Example: +### -------------------------------------------- +### server.port=8443 <-- The HTTPS port +### server.ssl.key-store=file:/tmp/mykey.jks +### server.ssl.key-store-password=mypass +### server.ssl.key-password=mypass +### server.http-to-https-redirection.port=8090 <-- The HTTP port + +server.contextPath=/ +#Modified engine-rest applicationpath +spring.jersey.application-path=/engine-rest +spring.profiles.active=clamp-default,clamp-spring-authentication +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration + +#The max number of active threads in this pool +server.tomcat.max-threads=200 +#The minimum number of threads always kept alive +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. + +camel.springboot.consumer-template-cache-size=1000 +camel.springboot.producer-template-cache-size=1000 +camel.springboot.jmx-enabled=true +camel.defaultthreadpool.poolsize=10 +camel.defaultthreadpool.maxpoolsize=20 +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.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/camundabpm?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.camunda.username=camunda +spring.datasource.camunda.password=ndMSpw4CAM +spring.datasource.camunda.driverClassName=org.mariadb.jdbc.Driver +spring.datasource.camunda.validationQuery=SELECT 1 +spring.datasource.camunda.validationQueryTimeout=20000 +spring.datasource.camunda.validationInterval=60000 +spring.datasource.camunda.testWhileIdle = true +# Automatically test whether a connection provided is good or not +spring.datasource.camunda.testOnBorrow=true + +#Camunda application properties +#Camunda history level +camunda.bpm.history-level=auto +camunda.bpm.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 + +#clds datasource connection details +spring.datasource.cldsdb.driver-class-name=org.mariadb.jdbc.Driver +spring.datasource.cldsdb.url=jdbc:mariadb://localhost:${docker.mariadb.port.host}/cldsdb4?verifyServerCertificate=false&useSSL=false&requireSSL=false&autoReconnect=true&maxReconnects=100 +spring.datasource.cldsdb.username=clds +spring.datasource.cldsdb.password=sidnnd83K +spring.datasource.cldsdb.driverClassName=com.mysql.jdbc.Driver +spring.datasource.cldsdb.validationQuery=SELECT 1 +spring.datasource.cldsdb.validationQueryTimeout=20000 +spring.datasource.cldsdb.validationInterval=60000 +spring.datasource.cldsdb.testWhileIdle = true +# Automatically test whether a connection provided is good or not +spring.datasource.cldsdb.testOnBorrow=true + +#Async Executor default Parameters +async.core.pool.size=10 +async.max.pool.size=20 +async.queue.capacity=500 + +org.onap.clamp.config.dcae.url=http://localhost:9000/closedloop-dcae-services + +#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 +org.onap.clamp.config.files.globalClds=classpath:/clds/globalClds.properties + +#Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! +CLDS_PERMISSION_TYPE_CL=permission-type-cl +CLDS_PERMISSION_TYPE_CL_MANAGE=permission-type-cl-manage +CLDS_PERMISSION_TYPE_CL_EVENT=permission-type-cl-event +CLDS_PERMISSION_TYPE_FILTER_VF=permission-type-filter-vf +CLDS_PERMISSION_TYPE_TEMPLATE=permission-type-template +#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties +CLDS_PERMISSION_INSTANCE=dev \ No newline at end of file diff --git a/src/test/resources/example/dao/bpmn-prop.json b/src/test/resources/example/dao/bpmn-prop.json new file mode 100644 index 000000000..f2bfc7de0 --- /dev/null +++ b/src/test/resources/example/dao/bpmn-prop.json @@ -0,0 +1,54 @@ +{ + "Holmes_1m8n1s9": [ + { + "name": "correlationalLogic", + "value": "uktukk" + } + ], + "Policy_19c1hms": { + "policy1": [ + { + "name": "pname", + "value": "policy1" + }, + { + "name": "pid", + "value": "0" + }, + { + "name": "timeout", + "value": "345" + }, + { + "policyConfigurations": [ + [ + { + "name": "maxRetries", + "value": [ + "3" + ] + }, + { + "name": "retryTimeLimit", + "value": [ + "180" + ] + }, + { + "name": "_id", + "value": [ + "JmAZRQx" + ] + }, + { + "name": "parentPolicy", + "value": [ + "" + ] + } + ] + ] + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/example/dao/bpmn-template.xml b/src/test/resources/example/dao/bpmn-template.xml new file mode 100644 index 000000000..5aa133acf --- /dev/null +++ b/src/test/resources/example/dao/bpmn-template.xml @@ -0,0 +1,126 @@ + + + + + SequenceFlow_0mshiwd + + + SequenceFlow_0mshiwd + SequenceFlow_0z37chw + + + SequenceFlow_0z37chw + SequenceFlow_1io8zzg + + + SequenceFlow_1io8zzg + SequenceFlow_0yenh9m + + + SequenceFlow_0yenh9m + SequenceFlow_1gq21be + + + SequenceFlow_1gq21be + SequenceFlow_14phr7v + + + SequenceFlow_14phr7v + SequenceFlow_1q2yngv + + + SequenceFlow_1q2yngv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/example/dao/image-template.xml b/src/test/resources/example/dao/image-template.xml new file mode 100644 index 000000000..d7af2aa67 --- /dev/null +++ b/src/test/resources/example/dao/image-template.xml @@ -0,0 +1,448 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Collector + + + + + + + + + + + + + StringMatch + + + + + + + + + + + + + + V + + + E + + + S + + + VesCollector + + + + + + + + + + + + + H + + + Holmes + + + + + + + + + + + + + TCA + + + + + + + + + + + + + Policy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit 1.2.3-korg From af0fbf9edb92544380d40ab2cffb87c89831944f Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Mon, 18 Sep 2017 11:10:02 +0200 Subject: Add new tests to CLAMP New tests added on ModelProperties, CldsModel and ITs (CldsService tests) Change-Id: I75a29c11ec66e0eef7c80f76cf90c30b2fc29972 Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- .../java/org/onap/clamp/clds/model/CldsModel.java | 6 +- .../clamp/clds/service/DefaultUserNameHandler.java | 3 - .../onap/clamp/clds/service/SecureServiceBase.java | 11 +- .../java/org/onap/clamp/clds/it/CldsServiceIT.java | 106 ++++++++++++ .../org/onap/clamp/clds/model/CldsModelTest.java | 170 +++++++++++++++++- .../clamp/clds/model/prop/ModelPropertiesTest.java | 9 + .../model-properties/modelBpmnPropWithGlobal.json | 192 +++++++++++++++++++++ 7 files changed, 488 insertions(+), 9 deletions(-) create mode 100644 src/test/java/org/onap/clamp/clds/it/CldsServiceIT.java create mode 100644 src/test/resources/example/model-properties/modelBpmnPropWithGlobal.json (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java index 7eac3d92a..62b10d44f 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java @@ -116,7 +116,7 @@ public class CldsModel { public boolean canInventoryCall() { boolean canCall = false; - /* Below checks the clds ecent is submit/resubmit */ + /* Below checks the clds event is submit/resubmit */ if ((event.isActionCd(CldsEvent.ACTION_SUBMIT) || event.isActionCd(CldsEvent.ACTION_RESUBMIT))) { canCall = true; @@ -225,7 +225,9 @@ public class CldsModel { /** * Determine permittedActionCd list using the actionCd from the current - * event. + * event. It's a states graph, given the next action that can be executed + * from the one that has been executed (described in the event object). + * ACTION_CREATE being the first one. */ private void determinePermittedActionCd() { String actionCd = getCurrentActionCd(); diff --git a/src/main/java/org/onap/clamp/clds/service/DefaultUserNameHandler.java b/src/main/java/org/onap/clamp/clds/service/DefaultUserNameHandler.java index 511cafe1e..574689e5b 100644 --- a/src/main/java/org/onap/clamp/clds/service/DefaultUserNameHandler.java +++ b/src/main/java/org/onap/clamp/clds/service/DefaultUserNameHandler.java @@ -29,9 +29,6 @@ import javax.ws.rs.core.SecurityContext; public class DefaultUserNameHandler implements UserNameHandler { - public DefaultUserNameHandler() { - } - /* * (non-Javadoc) * diff --git a/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java index 19813ebaf..acbd8bbd4 100644 --- a/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java +++ b/src/main/java/org/onap/clamp/clds/service/SecureServiceBase.java @@ -23,6 +23,9 @@ package org.onap.clamp.clds.service; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + import java.security.Principal; import javax.ws.rs.NotAuthorizedException; @@ -31,9 +34,6 @@ import javax.ws.rs.core.SecurityContext; import org.onap.clamp.clds.util.LoggingUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - /** * Base/abstract Service class. Implements shared security methods. */ @@ -185,4 +185,9 @@ public abstract class SecureServiceBase { userNameHandler = handler; } } + + public void setSecurityContext(SecurityContext securityContext) { + this.securityContext = securityContext; + } + } diff --git a/src/test/java/org/onap/clamp/clds/it/CldsServiceIT.java b/src/test/java/org/onap/clamp/clds/it/CldsServiceIT.java new file mode 100644 index 000000000..96131197b --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/it/CldsServiceIT.java @@ -0,0 +1,106 @@ +/*- + * ============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.it; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.InputStream; +import java.security.Principal; +import java.util.Properties; + +import javax.ws.rs.core.SecurityContext; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.clamp.clds.AbstractIT; +import org.onap.clamp.clds.model.CldsInfo; +import org.onap.clamp.clds.service.CldsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Test HTTP and HTTPS settings + redirection of HTTP to HTTPS. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource(locations = "classpath:application-no-camunda.properties") +public class CldsServiceIT extends AbstractIT { + + @Autowired + CldsService cldsService; + + @Test + public void testCldsInfoNotAuthorized() throws Exception { + SecurityContext securityContext = Mockito.mock(SecurityContext.class); + Principal p = Mockito.mock(Principal.class); + Mockito.when(p.getName()).thenReturn("admin"); + + Mockito.when(securityContext.getUserPrincipal()).thenReturn(p); + cldsService.setSecurityContext(securityContext); + + CldsInfo cldsInfo = cldsService.getCldsInfo(); + assertFalse(cldsInfo.isPermissionReadCl()); + assertFalse(cldsInfo.isPermissionReadTemplate()); + assertFalse(cldsInfo.isPermissionUpdateCl()); + assertFalse(cldsInfo.isPermissionUpdateTemplate()); + } + + @Test + public void testCldsInfoAuthorized() throws Exception { + + SecurityContext securityContext = Mockito.mock(SecurityContext.class); + Principal p = Mockito.mock(Principal.class); + Mockito.when(p.getName()).thenReturn("admin"); + + Mockito.when(securityContext.getUserPrincipal()).thenReturn(p); + Mockito.when(securityContext.isUserInRole("permission-type-cl|dev|read")).thenReturn(true); + Mockito.when(securityContext.isUserInRole("permission-type-cl|dev|update")).thenReturn(true); + Mockito.when(securityContext.isUserInRole("permission-type-template|dev|read")).thenReturn(true); + Mockito.when(securityContext.isUserInRole("permission-type-template|dev|update")).thenReturn(true); + + cldsService.setSecurityContext(securityContext); + + CldsInfo cldsInfo = cldsService.getCldsInfo(); + assertTrue(cldsInfo.isPermissionReadCl()); + assertTrue(cldsInfo.isPermissionReadTemplate()); + assertTrue(cldsInfo.isPermissionUpdateCl()); + assertTrue(cldsInfo.isPermissionUpdateTemplate()); + + Properties prop = new Properties(); + // InputStream in = + // CldsInfo.class.getResourceAsStream("clds-version.properties"); + InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("clds-version.properties"); + prop.load(in); + in.close(); + + assertEquals(cldsInfo.getCldsVersion(), prop.getProperty("clds.version")); + assertEquals(cldsInfo.getUserName(), "admin"); + } +} diff --git a/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java b/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java index 461b3ae41..0333bdb78 100644 --- a/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java +++ b/src/test/java/org/onap/clamp/clds/model/CldsModelTest.java @@ -24,6 +24,7 @@ package org.onap.clamp.clds.model; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import javax.ws.rs.BadRequestException; @@ -45,10 +46,177 @@ public class CldsModelTest { utilCreateUsingControlName("", "c42aceb-2350-11e6-8131-fa163ea8d2da"); } + @Test(expected = IllegalArgumentException.class) + public void testValidateActionEmptyEvent() { + CldsModel cldsModel = new CldsModel(); + cldsModel.validateAction(CldsEvent.ACTION_CREATE); + } + + @Test(expected = IllegalArgumentException.class) + public void testValidateActionNotExist() { + CldsModel cldsModel = new CldsModel(); + cldsModel.validateAction("unknown"); + } + + @Test + public void testValidateActionFromCreate() { + CldsModel cldsModel = new CldsModel(); + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_CREATE); + cldsModel.validateAction(CldsEvent.ACTION_SUBMIT); + cldsModel.validateAction(CldsEvent.ACTION_TEST); + + try { + cldsModel.validateAction(CldsEvent.ACTION_DEPLOY); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + } + + @Test + public void testValidateActionFromSubmitOrReSubmit() { + CldsModel cldsModel = new CldsModel(); + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_SUBMIT); + cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT); + try { + cldsModel.validateAction(CldsEvent.ACTION_DEPLOY); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_RESUBMIT); + cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT); + try { + cldsModel.validateAction(CldsEvent.ACTION_DEPLOY); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + } + + @Test + public void testValidateActionFromDistribute() { + CldsModel cldsModel = new CldsModel(); + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DISTRIBUTE); + cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT); + cldsModel.validateAction(CldsEvent.ACTION_DEPLOY); + + try { + cldsModel.validateAction(CldsEvent.ACTION_CREATE); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + } + + @Test + public void testValidateActionFromUndeploy() { + CldsModel cldsModel = new CldsModel(); + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_UNDEPLOY); + cldsModel.validateAction(CldsEvent.ACTION_UPDATE); + cldsModel.validateAction(CldsEvent.ACTION_DEPLOY); + cldsModel.validateAction(CldsEvent.ACTION_RESUBMIT); + + try { + cldsModel.validateAction(CldsEvent.ACTION_CREATE); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + } + + @Test + public void testValidateActionFromDeploy() { + CldsModel cldsModel = new CldsModel(); + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DEPLOY); + cldsModel.validateAction(CldsEvent.ACTION_DEPLOY); + cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY); + cldsModel.validateAction(CldsEvent.ACTION_UPDATE); + cldsModel.validateAction(CldsEvent.ACTION_STOP); + + try { + cldsModel.validateAction(CldsEvent.ACTION_CREATE); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + } + + @Test + public void testValidateActionFromRestartOrUpdate() { + CldsModel cldsModel = new CldsModel(); + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_RESTART); + cldsModel.validateAction(CldsEvent.ACTION_DEPLOY); + cldsModel.validateAction(CldsEvent.ACTION_UPDATE); + cldsModel.validateAction(CldsEvent.ACTION_STOP); + cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY); + + try { + cldsModel.validateAction(CldsEvent.ACTION_CREATE); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_UPDATE); + cldsModel.validateAction(CldsEvent.ACTION_DEPLOY); + cldsModel.validateAction(CldsEvent.ACTION_UPDATE); + cldsModel.validateAction(CldsEvent.ACTION_STOP); + cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY); + + try { + cldsModel.validateAction(CldsEvent.ACTION_CREATE); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + + } + + @Test + public void testValidateActionFromDelete() { + CldsModel cldsModel = new CldsModel(); + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DELETE); + cldsModel.validateAction(CldsEvent.ACTION_SUBMIT); + + try { + cldsModel.validateAction(CldsEvent.ACTION_CREATE); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_DELETE); + cldsModel.getEvent().setActionStateCd(CldsEvent.ACTION_STATE_SENT); + + try { + cldsModel.validateAction(CldsEvent.ACTION_SUBMIT); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + } + + @Test + public void testValidateActionFromStop() { + CldsModel cldsModel = new CldsModel(); + cldsModel.getEvent().setActionCd(CldsEvent.ACTION_STOP); + cldsModel.validateAction(CldsEvent.ACTION_UPDATE); + cldsModel.validateAction(CldsEvent.ACTION_RESTART); + cldsModel.validateAction(CldsEvent.ACTION_UNDEPLOY); + + try { + cldsModel.validateAction(CldsEvent.ACTION_CREATE); + fail("Exception should have been sent"); + } catch (IllegalArgumentException e) { + + } + } + /** * Utility Method to create model from controlname and uuid. */ - public void utilCreateUsingControlName(String controlNamePrefix, String controlNameUuid) { CldsModel model = CldsModel.createUsingControlName(controlNamePrefix + controlNameUuid); assertEquals(controlNamePrefix, model.getControlNamePrefix()); diff --git a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java index 02e27ea8f..efeae00d2 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java @@ -32,6 +32,7 @@ import java.util.List; import org.junit.Before; import org.junit.Test; +import org.onap.clamp.clds.model.CldsModel; import org.onap.clamp.clds.util.ResourceFileUtil; /** @@ -85,4 +86,12 @@ public class ModelPropertiesTest { assertEquals("policy1", holmes.getOperationalPolicy()); assertEquals("blabla", holmes.getCorrelationLogic()); } + + @Test + public void testGetVf() throws IOException { + CldsModel cldsModel = new CldsModel(); + cldsModel.setPropText( + ResourceFileUtil.getResourceAsString("example/model-properties/modelBpmnPropWithGlobal.json")); + assertEquals("f5213e3a-9191-4362-93b5-b67f8d770e44", ModelProperties.getVf(cldsModel)); + } } \ No newline at end of file diff --git a/src/test/resources/example/model-properties/modelBpmnPropWithGlobal.json b/src/test/resources/example/model-properties/modelBpmnPropWithGlobal.json new file mode 100644 index 000000000..5abb28a8c --- /dev/null +++ b/src/test/resources/example/model-properties/modelBpmnPropWithGlobal.json @@ -0,0 +1,192 @@ +{ + "collector": { + "topicPublishes": { + "DCAE-COLLECTOR-UCSNMP": "DCAE-COLLECTOR-UCSNMP", + "GFP-IP-AIC-SNMP-TRAPS": "GFP-IP-AIC-SNMP-TRAPS", + "AIC-SNMP-TRAPS": "AIC-SNMP-TRAPS" + } + }, + "string_match": { + "topicPublishes": { + "DCAE-CL-EVENT": "DCAE-CL-EVENT" + }, + "aaiMatchingFields": { + "cloud-region.identity-url": "cloud-region.identity-url", + "complex.city": "complex.city", + "complex.physical-location-id": "complex.physical-location-id", + "complex.state": "complex.state", + "generic-vnf.service-id": "generic-vnf.service-id", + "generic-vnf.vnf-name": "generic-vnf.vnf-name", + "generic-vnf.vnf-type": "generic-vnf.vnf-type", + "tenant.tenant-id": "tenant.tenant-id", + "vserver.in-maint": "vserver.in-maint", + "vserver.is-closed-loop-disabled": "vserver.is-closed-loop-disabled", + "vserver.l-interface.interface-name": "vserver.l-interface.interface-name", + "vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address": "vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address", + "vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address": "vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address", + "vserver.l-interface.network-name": "vserver.l-interface.network-name", + "vserver.prov-status": "vserver.prov-status", + "vserver.selflink": "vserver.selflink", + "vserver.vserver-id": "vserver.vserver-id", + "vserver.vserver-name": "vserver.vserver-name" + }, + "aaiSendFields": { + "cloud-region.identity-url": "cloud-region.identity-url", + "complex.city": "complex.city", + "complex.physical-location-id": "complex.physical-location-id", + "complex.state": "complex.state", + "generic-vnf.service-id": "generic-vnf.service-id", + "generic-vnf.vnf-name": "generic-vnf.vnf-name", + "generic-vnf.vnf-type": "generic-vnf.vnf-type", + "tenant.tenant-id": "tenant.tenant-id", + "vserver.in-maint": "vserver.in-maint", + "vserver.is-closed-loop-disabled": "vserver.is-closed-loop-disabled", + "vserver.l-interface.interface-name": "vserver.l-interface.interface-name", + "vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address": "vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address", + "vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address": "vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address", + "vserver.l-interface.network-name": "vserver.l-interface.network-name", + "vserver.prov-status": "vserver.prov-status", + "vserver.selflink": "vserver.selflink", + "vserver.vserver-id": "vserver.vserver-id", + "vserver.vserver-name": "vserver.vserver-name" + }, + "eventSourceType": { + "f5BigIP": "f5BigIP", + "vSBG_Alarms": "vSBG_Alarms", + "vCTS_Alarms": "vCTS_Alarms" + }, + "eventSeverity": { + "NORMAL": "NORMAL", + "not-NORMAL": "not-NORMAL", + "OK": "OK", + "WARNING": "WARNING", + "MINOR": "MINOR", + "MAJOR": "MAJOR", + "CRITICAL": "CRITICAL" + }, + "timeWindow": 0, + "ageLimit": 1600, + "outputEventName": { + "": "", + "ONSET": "ONSET", + "ABATED": "ABATED" + }, + "createClosedLoopEventId": { + "Initial": "Initial", + "Close": "Close" + } + }, + "tca": { + "tname": "New_Set", + "tcaInt": "1", + "tcaVio": "1", + "tcaSev": { + "NORMAL": "NORMAL", + "CRITICAL": "CRITICAL", + "MAJOR": "MAJOR", + "MINOR": "MINOR", + "WARNING": "WARNING" + }, + "fieldPath": { + "FIELDPATH_test_1": "FIELDPATH_test_1", + "FIELDPATH_test_2": "FIELDPATH_test_2" + }, + "operator": { + ">": "GREATER", + "=": "EQUAL", + "<": "LESS" + }, + "opsPolicy": { + "POLICY_test_X": "POLICY_test_X", + "POLICY_test_Y": "POLICY_test_Y" + } + }, + "global": [ + { + "name": "actionSet", + "value": [ + "vnfRecipe" + ] + }, + { + "name": "location", + "value": [ + "SNDGCA64", + "ALPRGAED" + ] + }, + { + "name": "vf", + "value": [ + "f5213e3a-9191-4362-93b5-b67f8d770e44" + ] + }, + { + "name": "location", + "value": [ + "SNDGCA64", + "ALPRGAED", + "LSLEILAA", + "MDTWNJC1" + ] + } + ], + "policy": { + "pname": "0", + "timeout": 345, + "vnfRecipe": { + "": "", + "restart": "Restart", + "rebuild": "Rebuild", + "migrate": "Migrate", + "healthCheck": "Health Check", + "evacuate": "Evacuate" + }, + "enbRecipe": { + "": "", + "reset": "Reset" + }, + "maxRetries": "3", + "retryTimeLimit": 180, + "resource": { + "vCTS": "vCTS", + "v3CDB": "v3CDB", + "vUDR": "vUDR", + "vCOM": "vCOM", + "vRAR": "vRAR", + "vLCS": "vLCS", + "vUDR-BE": "vUDR-BE", + "vDBE": "vDBE" + }, + "parentPolicyConditions": { + "Failure_Retries": "Failure: Max Retries Exceeded", + "Failure_Timeout": "Failure: Time Limit Exceeded", + "Failure_Guard": "Failure: Guard", + "Failure_Exception": "Failure: Exception", + "Failure": "Failure: Other", + "Success": "Success" + } + }, + "shared": { + "byService": { + "": { + "vf": { + "": "" + }, + "location": { + "": "" + }, + "alarmCondition": { + "": "" + } + } + }, + "byVf": { + "": { + "vfc": { + "": "" + } + } + } + } +} \ No newline at end of file -- cgit 1.2.3-korg From 2b15edd224cc6dcff90e170959102eb1a1bb1a50 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 19 Sep 2017 18:24:06 +0200 Subject: Removal of useless files & bugfix Removal of DCAE useless files, and bugfixes SDC calls(+CldsDAO bug), and insertion of the search engine for Model Properties window in UI Change-Id: Ia68117bb917807eaf8e8e317f391f90b6d948135 Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- .../onap/clamp/clds/client/DcaeReqDelegate.java | 64 ------ .../clamp/clds/client/DcaeReqDeleteDelegate.java | 55 ----- .../org/onap/clamp/clds/client/PolicyClient.java | 2 +- .../onap/clamp/clds/client/SdcCatalogServices.java | 33 ++- .../org/onap/clamp/clds/client/req/DcaeReq.java | 97 --------- .../onap/clamp/clds/config/CldsConfiguration.java | 12 -- .../clamp/clds/config/CldsSecurityConfigUsers.java | 14 +- src/main/java/org/onap/clamp/clds/dao/CldsDao.java | 13 +- .../org/onap/clamp/clds/service/CldsService.java | 6 +- .../META-INF/resources/designer/scripts/aOnBoot.js | 87 +++++--- src/main/resources/application.properties | 2 - src/main/resources/clds/clds-reference.properties | 224 ++++++++++----------- src/test/java/org/onap/clamp/clds/it/DcaeIT.java | 62 ------ src/test/java/org/onap/clamp/clds/it/SdcIT.java | 16 +- src/test/resources/https/https-test.properties | 2 - 15 files changed, 228 insertions(+), 461 deletions(-) delete mode 100644 src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java delete mode 100644 src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java delete mode 100644 src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java delete mode 100644 src/test/java/org/onap/clamp/clds/it/DcaeIT.java (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java b/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java deleted file mode 100644 index 8abc395d1..000000000 --- a/src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java +++ /dev/null @@ -1,64 +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.client; - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.clamp.clds.client.req.DcaeReq; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * Send control loop model to dcae proxy. - */ -public class DcaeReqDelegate implements JavaDelegate { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReqDelegate.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - - @Autowired - private RefProp refProp; - - @Value("${org.onap.clamp.config.dcae.url:http://localhost:9000/closedloop-dcae-services}") - private String cldsDcaeUrl; - - /** - * Perform activity. Send to dcae proxy. - * - * @param execution - */ - @Override - public void execute(DelegateExecution execution) throws Exception { - ModelProperties prop = ModelProperties.create(execution); - String dcaeReq = DcaeReq.format(refProp, prop); - if (dcaeReq != null) { - execution.setVariable("dcaeReq", dcaeReq.getBytes()); - } - execution.setVariable("dcaeUrl", cldsDcaeUrl + "/" + prop.getControlName()); - } -} diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java deleted file mode 100644 index 29a906787..000000000 --- a/src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java +++ /dev/null @@ -1,55 +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.client; - -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.camunda.bpm.engine.delegate.JavaDelegate; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.refprop.RefProp; -import org.springframework.beans.factory.annotation.Autowired; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * Send control loop model to dcae proxy. - */ -public class DcaeReqDeleteDelegate implements JavaDelegate { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReqDeleteDelegate.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - - @Autowired - private RefProp refProp; - - /** - * Perform activity. Send to dcae proxy. - * - * @param execution - */ - @Override - public void execute(DelegateExecution execution) throws Exception { - ModelProperties prop = ModelProperties.create(execution); - execution.setVariable("dcaeUrl", System.getProperty("CLDS_DCAE_URL") + "/" + prop.getControlName()); - } -} diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java index 2bd680af2..391e39556 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyClient.java @@ -204,7 +204,6 @@ public class PolicyClient { * @param prop * The ModelProperties * @return The response message of Policy - * @throws Exception */ protected String send(PolicyParameters policyParameters, ModelProperties prop, String policyNamePrefix) { // Verify whether it is triggered by Validation Test button from UI @@ -336,6 +335,7 @@ public class PolicyClient { logger.info("Policy versions.size()=" + versions.size()); return versions; + } /** diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java index 5b9c5d36d..e3d10c756 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -779,7 +779,9 @@ public class SdcCatalogServices { * @return */ public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions) { + Date startTime = new Date(); try { + LoggingUtils.setTargetContext("SDC", "getCldsServicesOrResourcesBasedOnURL"); String urlReworked = removeUnwantedBracesFromString(url); URL urlObj = new URL(urlReworked); @@ -792,7 +794,7 @@ public class SdcCatalogServices { conn.setRequestMethod("GET"); int responseCode = conn.getResponseCode(); - logger.info("responseCode=" + responseCode); + logger.info("Sdc resource url - " + urlReworked + " , responseCode=" + responseCode); StringBuilder response; try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) { response = new StringBuilder(); @@ -806,10 +808,16 @@ public class SdcCatalogServices { } } } + LoggingUtils.setResponseContext("0", "Get sdc resources success", this.getClass().getName()); return response.toString(); } catch (IOException e) { + LoggingUtils.setResponseContext("900", "Get sdc resources failed", this.getClass().getName()); + LoggingUtils.setErrorContext("900", "Get sdc resources error"); logger.error("Exception occurred during query to SDC", e); return ""; + } finally { + LoggingUtils.setTimeContext(startTime, new Date()); + metricsLogger.info("getCldsServicesOrResourcesBasedOnURL completed"); } } @@ -1069,14 +1077,22 @@ public class SdcCatalogServices { } } + /** + * Method to create vfc and kpi nodes inside vf node + * + * @param mapper + * @param cldsVfDataList + * @return + */ private ObjectNode createVfcObjectNodeByVfUuid(ObjectMapper mapper, List cldsVfDataList) { ObjectNode vfUuidObjectNode = mapper.createObjectNode(); if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) { for (CldsVfData currCldsVfData : cldsVfDataList) { if (currCldsVfData != null) { - ObjectNode vfcObjectNode = mapper.createObjectNode(); + ObjectNode vfObjectNode = mapper.createObjectNode(); ObjectNode vfcUuidNode = mapper.createObjectNode(); + ObjectNode kpiObjectNode = mapper.createObjectNode(); if (currCldsVfData.getCldsVfcs() != null && !currCldsVfData.getCldsVfcs().isEmpty()) { for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) { vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(), @@ -1085,8 +1101,17 @@ public class SdcCatalogServices { } else { vfcUuidNode.put("", ""); } - vfcObjectNode.putPOJO("vfc", vfcUuidNode); - vfUuidObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfcObjectNode); + if (currCldsVfData.getCldsKPIList() != null && !currCldsVfData.getCldsKPIList().isEmpty()) { + for (CldsVfKPIData currCldsVfKPIData : currCldsVfData.getCldsKPIList()) { + kpiObjectNode.put(currCldsVfKPIData.getThresholdValue(), + currCldsVfKPIData.getThresholdValue()); + } + } else { + kpiObjectNode.put("", ""); + } + vfObjectNode.putPOJO("vfc", vfcUuidNode); + vfObjectNode.putPOJO("kpi", kpiObjectNode); + vfUuidObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfObjectNode); } } } else { diff --git a/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java b/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java deleted file mode 100644 index a97e9d488..000000000 --- a/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java +++ /dev/null @@ -1,97 +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.client.req; - -import java.io.IOException; -import java.util.List; - -import org.onap.clamp.clds.model.prop.Global; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.StringMatch; -import org.onap.clamp.clds.model.refprop.RefProp; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Construct a DCAE request given CLDS objects. - */ -public class DcaeReq { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReq.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - - /** - * Format DCAE request. - * - * @param refProp - * @param prop - * @return - * @throws IOException - * @throws JsonMappingException - * @throws JsonParseException - */ - public static String format(RefProp refProp, ModelProperties prop) throws IOException { - Global globalProp = prop.getGlobal(); - - StringMatch smProp = prop.getType(StringMatch.class); - prop.setCurrentModelElementId(smProp.getId()); - - ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.template"); - - // "properties":{ - ObjectNode properties = rootNode.with("properties"); - // "service_name": - properties.put("service_name", globalProp.getService()); - // "service_ids":[ - List serviceIds = refProp.decodeToList("dcae.decode.service_ids", globalProp.getService()); - JsonUtil.addArrayField(properties, "service_ids", serviceIds); - // "vnf_ids":[ - JsonUtil.addArrayField(properties, "vnf_ids", globalProp.getResourceVf()); - // "location_ids":[ - JsonUtil.addArrayField(properties, "location_ids", globalProp.getLocation()); - - // "template":{ - ObjectNode template = rootNode.with("template"); - // "string_matching":{ - ObjectNode stringMatching = template.with("string_matching"); - // "dcae":{ - ObjectNode dcae = stringMatching.with("dcae"); - - dcae.put("inputTopic", smProp.getTopicSubscribes()); - dcae.put("outputTopic", smProp.getTopicPublishes()); - dcae.put("closedLoopControlName", prop.getControlName()); - dcae.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); - - // "serviceConfigurations":[ - StringMatchPolicyReq.appendServiceConfigurations(refProp, globalProp.getService(), dcae, smProp, prop); - - String dcaeReq = rootNode.toString(); - logger.info("dcaeReq=" + dcaeReq); - return dcaeReq; - } - -} 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 c00deea66..a6baa969e 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java @@ -35,8 +35,6 @@ import javax.xml.transform.TransformerConfigurationException; import org.onap.clamp.clds.client.CldsEventDelegate; import org.onap.clamp.clds.client.DcaeDispatcherServices; import org.onap.clamp.clds.client.DcaeInventoryServices; -import org.onap.clamp.clds.client.DcaeReqDelegate; -import org.onap.clamp.clds.client.DcaeReqDeleteDelegate; import org.onap.clamp.clds.client.HolmesPolicyDelegate; import org.onap.clamp.clds.client.HolmesPolicyDeleteDelegate; import org.onap.clamp.clds.client.OperationalPolicyDelegate; @@ -115,21 +113,11 @@ public class CldsConfiguration { return new CldsEventDelegate(); } - @Bean(name = "dcaeReqDelegate") - public DcaeReqDelegate getDcaeReqDelegate() { - return new DcaeReqDelegate(); - } - @Bean(name = "sdcSendReqDelegate") public SdcSendReqDelegate getSdcSendReqDelegate() { return new SdcSendReqDelegate(); } - @Bean(name = "dcaeReqDeleteDelegate") - public DcaeReqDeleteDelegate getDcaeReqDeleteDelegate() { - return new DcaeReqDeleteDelegate(); - } - @Bean(name = "operationalPolicyDelegate") public OperationalPolicyDelegate getOperationalPolicyDelegate() { return new OperationalPolicyDelegate(); diff --git a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java index 09078f07d..db99dbaf4 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsSecurityConfigUsers.java @@ -87,7 +87,6 @@ public class CldsSecurityConfigUsers extends WebSecurityConfigurerAdapter { * the application.properties). * * @param auth - * @throws Exception */ @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) { @@ -115,11 +114,14 @@ public class CldsSecurityConfigUsers extends WebSecurityConfigurerAdapter { * CldsUser. * * @return The array of CldsUser - * @throws IOException - * @throws Exception */ - private CldsUser[] loadUsers() throws IOException { - logger.info("Load from clds-users.properties"); - return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream()); + private CldsUser[] loadUsers() { + try { + logger.info("Load from clds-users.properties"); + return CldsUserJsonDecoder.decodeJson(appContext.getResource(cldsUsersFile).getInputStream()); + } catch (IOException e) { + logger.error("Unable to decode the User Json file", e); + throw new CldsUsersException("Load from clds-users.properties", e); + } } } 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 b64978346..6aa5f9127 100644 --- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -46,6 +46,7 @@ import org.onap.clamp.clds.model.CldsModelInstance; import org.onap.clamp.clds.model.CldsServiceData; import org.onap.clamp.clds.model.CldsTemplate; import org.onap.clamp.clds.model.ValueItem; +import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; @@ -463,10 +464,14 @@ public class CldsDao { public CldsServiceData getCldsServiceCache(String invariantUUID) { CldsServiceData cldsServiceData = null; List cldsServiceDataList = new ArrayList<>(); - String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? "; - cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID }, - new CldsServiceDataMapper()); - logger.info("value of cldsServiceDataList: {}", cldsServiceDataList); + try { + String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? "; + cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID }, + new CldsServiceDataMapper()); + logger.info("value of cldsServiceDataList: {}", cldsServiceDataList); + } catch (EmptyResultDataAccessException e) { + logger.info("cache row not found for invariantUUID: {}", invariantUUID); + } return cldsServiceData; } 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 0d62be55b..19e3caa39 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -702,13 +702,15 @@ public class CldsService extends SecureServiceBase { // filter out VFs the user is not authorized for cldsServiceData.filterVfs(this); + // format retrieved data into properties json + String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData); + // audit log LoggingUtils.setTimeContext(startTime, new Date()); LoggingUtils.setResponseContext("0", "Get sdc properties by uuid success", this.getClass().getName()); auditLogger.info("GET sdc properties by uuid completed"); - // format retrieved data into properties json - return sdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData); + return sdcProperties; } /** diff --git a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js index 01a39b62d..89807d627 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js +++ b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js @@ -112,37 +112,62 @@ function loadPropertyWindow(type) { } function setMultiSelect() { - $("select").each(function(index, mySelect) { - - var mySelectObj = $(mySelect); - if (! mySelectObj.parents(".multiselect-native-select")) { - // keep native for this one - return; - } - - if (mySelectObj.parents(".multiselect-native-select").length > 0) { - var selectDrop = mySelectObj.parent(".multiselect-native-select").find("select"); - mySelectObj.parent(".multiselect-native-select").parent().html(selectDrop); - } - - var options = { - numberDisplayed: 1, - maxHeight: 200 - }; - - if (mySelectObj.attr("multiple") - && mySelectObj.attr("multiple") != 'false') { - options.includeSelectAllOption = true; - } - - if (mySelectObj.attr("enableFilter") - && mySelectObj.attr("enableFilter") != 'false') { - options.enableCaseInsensitiveFiltering = true; - options.enableFiltering = true; - } - - mySelectObj.multiselect(options); - }); + $("select").each(function(index, mySelect) { + if ($(mySelect).parents(".multiselect-native-select") && + $(mySelect).parents(".multiselect-native-select").length < 1) { + if (!$(mySelect).attr("multiple")) { + if ($(mySelect).attr("enableFilter")) { + $(mySelect).multiselect({ + numberDisplayed: 1, + maxHeight: 200 + }); + } else { + $(mySelect).multiselect({ + numberDisplayed: 1, + enableFiltering: true, + maxHeight: 200 + }); + } + + } else { + $(mySelect).multiselect({ + numberDisplayed: 1, + includeSelectAllOption: true, + enableFiltering: true, + maxHeight: 200, + enableCaseInsensitiveFiltering: true + }); + } + + } else if ($(mySelect).parents(".multiselect-native-select") && + $(mySelect).parents(".multiselect-native-select").length > 0) { + var selectDrop = $(mySelect).parent(".multiselect-native-select").find("select"); + $(mySelect).parent(".multiselect-native-select").parent().html(selectDrop); + if (!$(mySelect).attr("multiple")) { + if ($(mySelect).attr("enableFilter")) { + $(mySelect).multiselect({ + numberDisplayed: 1, + maxHeight: 200 + }); + } else { + $(mySelect).multiselect({ + numberDisplayed: 1, + enableFiltering: true, + maxHeight: 200 + }); + } + } else { + $(mySelect).multiselect({ + numberDisplayed: 1, + includeSelectAllOption: true, + enableFiltering: true, + maxHeight: 200, + enableCaseInsensitiveFiltering: true + }); + } + } + }); + //refeshMultiSelect(); } function loadSharedPropertyByService(onChangeUUID, refresh, callBack) { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a7b16f250..ae5d31a98 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -133,8 +133,6 @@ async.core.pool.size=10 async.max.pool.size=20 async.queue.capacity=500 -org.onap.clamp.config.dcae.url=http://dcae.api.simpledemo.openecomp.org:9000/closedloop-dcae-services - #GRM Edge endpoint details service.name=ajsc6camundademo service.version=1.0.0.0 diff --git a/src/main/resources/clds/clds-reference.properties b/src/main/resources/clds/clds-reference.properties index df29279c9..abc25b179 100644 --- a/src/main/resources/clds/clds-reference.properties +++ b/src/main/resources/clds/clds-reference.properties @@ -1,117 +1,117 @@ -### -# ============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. -### - -# -# Poperties for CLDS -# -# -# DCAE request build properties -# -dcae.template={"properties":{"service_name":"","service_ids":[],"vnf_ids":[],"location_ids":[]},"template":{"string_matching":{"dcae":{"inputTopic":"","outputTopic":"","closedLoopControlName":"","closedLoopEventClient":"configuration.dcae.microservice.stringmatcher.xml","policyName":"","policyScope":"service=vSCP;resource=F5;type=configuration","policyVersion":"v0.0.1","serviceConfigurations":{}}}}} -dcae.decode.service_ids={"vUSP":["vUSP - vCTS"],"Trinity":["ASBGv TLS VNF","ASBGv No TLS","ASBGv (NO TLS) VNF","ASBGv TLS","NSBGv VNF","NSBGv"],"vSCP":["AKRON_vSCP_F5_FW-SVC/vSCP_F5_FW 1","ALLEN_vSCP_F5_FW-SVC/vSCP_F5_FW 1"],"vProbes":["vProbes - FW"]} -# -# SDC request blueprint properties -# -sdc.template={} -sdc.decode.service_ids={} -# -# -# General Policy request properties -# -policy.ecomp.name=DCAE -policy.pdp.group=default -policy.ms.type=MicroService -policy.ms.policyNamePrefix=Config_MS_ -policy.op.type=BRMS_Param -policy.op.policyNamePrefix=Config_BRMS_Param_ -# -# TCA MicroService Policy request build properties -# -tca.template={"service":"MThresholdCrossingConfiguration","location":"Edge","uuid":"TestUUID","policyName":"???","description":"from clds","configName":"MThresholdCrossingConfiguration","templateVersion":"5.2.0.1","priority":"4","version":"5.2.0.1","policyScope":"resource=F5,service=vSCP,type=configuration,closedLoopControlName=vSCP_F5_Firewall_d925ed73-8231-4d02-9545-db4e101f88f8","content":{"$class": "com.att.ecomp.dcae.clamp.common.MThresholdCrossingConfiguration","domain":"measurementsForVfScaling","policyScope":"pnf=eNodeB;type=configuration","policyName":"policy.dcae.configuration","policyVersion":"1.0.0","subscriberContentType": "application/json","subscriberConsumerId": "c13","subscriberConsumerGroup": "OpenDCAE-c13","subscriberTimeoutMS": "-1","subscriberMessageLimit": "-1","subscriberPollingInterval": "20000","publisherContentType": "application/json","publisherMaxBatchSize": "10","publisherMaxRecoveryQueueSize": "100000","publisherPollingInterval": "20000","publisherAlertWindowingTime": "86400","signatures":[]}} -tca.signature.template={"nfNamingCode":"ENBE","target":"common_id","targetType":"eNodeB","useCaseName":"???","signatureName":"???","signatureUuid":"???","closedLoopControlName":"???","severity":"???","version":"1.0.2","maxInterval":1200,"minMessageViolations":4,"thresholds":[]} -# -# String Match MicroService Policy request build properties -# -# default -sm.template={"service":"StringMatchingConfiguration","location":"Edge","uuid":"TestUUID","policyName":"???","description":"from clds","configName":"com.att.d2.policy.StringMatchingConfiguration","templateVersion":"1604","priority":"4","version":"1610","policyScope":"resource=F5,service=vSCP,type=configuration,closedLoopControlName=vSCP_F5_Firewall_d925ed73-8231-4d02-9545-db4e101f88f8","content":{"serviceConfigurations":{}}} -# by service: vSCP -sm.template.vSCP={"service":"StringMatchingConfiguration","location":"Edge","uuid":"TestUUID","policyName":"???","description":"from clds","configName":"com.att.d2.policy.StringMatchingConfiguration","templateVersion":"1604","priority":"4","version":"0.1.0-SNAPSHOT","policyScope":"resource=F5,service=vSCP,type=configuration,closedLoopControlName=vSCP_F5_Firewall_d925ed73-8231-4d02-9545-db4e101f88f8","content":{"serviceConfigurations":{}}} -sm.sc.template={} -# -# default -sm.rulegroup=true -# by service: vSCP -sm.rulegroup.vSCP=false -# -# -# Operational Policy request build properties -# -op.policyDescription=from clds -# default -op.templateName=ClosedLoopvUSP -op.operationTopic=APPC-CL -op.notificationTopic=POLICY-CL-MGT -op.controller=1610-vUSP -op.policy.appc=APPC -# by service: vSCP -op.templateName.vSCP=ClosedLoopTemplate -op.controller.vSCP=1607-f5fw -op.eNodeB.templateName=CLeNodeB -op.eNodeB.operationTopic=com.onap.sdnr.RanCLRequest-v00 -op.eNodeB.notificationTopic=com.onap-policy.IST-ENODEB-CL -op.eNodeB.controller=ClosedLoop-eNodeB -op.eNodeB.recipe={"eNodeBRecipes":[{"Actor":"AOTS","Recipe":"checkENodeBTicketHours","ParentPolicy":"","PPConditions":"","Retry":"0","TimeLimit":"120"},{"Actor":"AOTS","Recipe":"checkEquipmentStatus","ParentPolicy":"checkENodeBTicketHours","PPConditions":"Success","Retry":"0","TimeLimit":"120"},{"Actor":"AOTS","Recipe":"checkEimStatus","ParentPolicy":"checkEquipmentStatus","PPConditions":"Success","Retry":"0","TimeLimit":"120"},{"Actor":"AOTS","Recipe":"checkMaintenanceWindow","ParentPolicy":"checkEimStatus","PPConditions":"Success","Retry":"0","TimeLimit":"120"},{"Actor":"SDNR","Recipe":"Reset","ParentPolicy":"checkMaintenanceWindow","PPConditions":"Success","Retry":"","TimeLimit":""}]} -op.eNodeB.timeWindow=35 -op.eNodeB.limit=2 -op.eNodeB.period=10s -# -# Sdc service properties +### +# ============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. +### + +# +# Poperties for CLDS +# +# +# DCAE request build properties +# +dcae.template={"properties":{"service_name":"","service_ids":[],"vnf_ids":[],"location_ids":[]},"template":{"string_matching":{"dcae":{"inputTopic":"","outputTopic":"","closedLoopControlName":"","closedLoopEventClient":"configuration.dcae.microservice.stringmatcher.xml","policyName":"","policyScope":"service=vSCP;resource=F5;type=configuration","policyVersion":"v0.0.1","serviceConfigurations":{}}}}} +dcae.decode.service_ids={"vUSP":["vUSP - vCTS"],"Trinity":["ASBGv TLS VNF","ASBGv No TLS","ASBGv (NO TLS) VNF","ASBGv TLS","NSBGv VNF","NSBGv"],"vSCP":["AKRON_vSCP_F5_FW-SVC/vSCP_F5_FW 1","ALLEN_vSCP_F5_FW-SVC/vSCP_F5_FW 1"],"vProbes":["vProbes - FW"]} +# +# SDC request blueprint properties +# +sdc.template={} +sdc.decode.service_ids={} +# +# +# General Policy request properties +# +policy.ecomp.name=DCAE +policy.pdp.group=default +policy.ms.type=MicroService +policy.ms.policyNamePrefix=Config_MS_ +policy.op.type=BRMS_Param +policy.op.policyNamePrefix=Config_BRMS_Param_ +# +# TCA MicroService Policy request build properties +# +tca.template={"service":"MThresholdCrossingConfiguration","location":"Edge","uuid":"TestUUID","policyName":"???","description":"from clds","configName":"MThresholdCrossingConfiguration","templateVersion":"5.2.0.1","priority":"4","version":"5.2.0.1","policyScope":"resource=F5,service=vSCP,type=configuration,closedLoopControlName=vSCP_F5_Firewall_d925ed73-8231-4d02-9545-db4e101f88f8","content":{"$class": "com.att.ecomp.dcae.clamp.common.MThresholdCrossingConfiguration","domain":"measurementsForVfScaling","policyScope":"pnf=eNodeB;type=configuration","policyName":"policy.dcae.configuration","policyVersion":"1.0.0","subscriberContentType": "application/json","subscriberConsumerId": "c13","subscriberConsumerGroup": "OpenDCAE-c13","subscriberTimeoutMS": "-1","subscriberMessageLimit": "-1","subscriberPollingInterval": "20000","publisherContentType": "application/json","publisherMaxBatchSize": "10","publisherMaxRecoveryQueueSize": "100000","publisherPollingInterval": "20000","publisherAlertWindowingTime": "86400","signatures":[]}} +tca.signature.template={"nfNamingCode":"ENBE","target":"common_id","targetType":"eNodeB","useCaseName":"???","signatureName":"???","signatureUuid":"???","closedLoopControlName":"???","severity":"???","version":"1.0.2","maxInterval":1200,"minMessageViolations":4,"thresholds":[]} +# +# String Match MicroService Policy request build properties +# +# default +sm.template={"service":"StringMatchingConfiguration","location":"Edge","uuid":"TestUUID","policyName":"???","description":"from clds","configName":"com.att.d2.policy.StringMatchingConfiguration","templateVersion":"1604","priority":"4","version":"1610","policyScope":"resource=F5,service=vSCP,type=configuration,closedLoopControlName=vSCP_F5_Firewall_d925ed73-8231-4d02-9545-db4e101f88f8","content":{"serviceConfigurations":{}}} +# by service: vSCP +sm.template.vSCP={"service":"StringMatchingConfiguration","location":"Edge","uuid":"TestUUID","policyName":"???","description":"from clds","configName":"com.att.d2.policy.StringMatchingConfiguration","templateVersion":"1604","priority":"4","version":"0.1.0-SNAPSHOT","policyScope":"resource=F5,service=vSCP,type=configuration,closedLoopControlName=vSCP_F5_Firewall_d925ed73-8231-4d02-9545-db4e101f88f8","content":{"serviceConfigurations":{}}} +sm.sc.template={} +# +# default +sm.rulegroup=true +# by service: vSCP +sm.rulegroup.vSCP=false +# +# +# Operational Policy request build properties +# +op.policyDescription=from clds +# default +op.templateName=ClosedLoopvUSP +op.operationTopic=APPC-CL +op.notificationTopic=POLICY-CL-MGT +op.controller=1610-vUSP +op.policy.appc=APPC +# by service: vSCP +op.templateName.vSCP=ClosedLoopTemplate +op.controller.vSCP=1607-f5fw +op.eNodeB.templateName=CLeNodeB +op.eNodeB.operationTopic=com.onap.sdnr.RanCLRequest-v00 +op.eNodeB.notificationTopic=com.onap-policy.IST-ENODEB-CL +op.eNodeB.controller=ClosedLoop-eNodeB +op.eNodeB.recipe={"eNodeBRecipes":[{"Actor":"AOTS","Recipe":"checkENodeBTicketHours","ParentPolicy":"","PPConditions":"","Retry":"0","TimeLimit":"120"},{"Actor":"AOTS","Recipe":"checkEquipmentStatus","ParentPolicy":"checkENodeBTicketHours","PPConditions":"Success","Retry":"0","TimeLimit":"120"},{"Actor":"AOTS","Recipe":"checkEimStatus","ParentPolicy":"checkEquipmentStatus","PPConditions":"Success","Retry":"0","TimeLimit":"120"},{"Actor":"AOTS","Recipe":"checkMaintenanceWindow","ParentPolicy":"checkEimStatus","PPConditions":"Success","Retry":"0","TimeLimit":"120"},{"Actor":"SDNR","Recipe":"Reset","ParentPolicy":"checkMaintenanceWindow","PPConditions":"Success","Retry":"","TimeLimit":""}]} +op.eNodeB.timeWindow=35 +op.eNodeB.limit=2 +op.eNodeB.period=10s +# +# Sdc service properties sdc.catalog.url=http://sdc.api.simpledemo.openecomp.org:8080/sdc/v1/catalog/ sdc.hostUrl=http://sdc.api.simpledemo.openecomp.org:8080 sdc.serviceUrl=http://sdc.api.simpledemo.openecomp.org:8080/sdc/v1/catalog/services -sdc.serviceUsername=test -sdc.servicePassword=123456 -sdc.artifactLabel=blueprintclampcockpit -sdc.sdcX-InstanceID=CLAMP -sdc.artifactType=DCAE_INVENTORY_BLUEPRINT -sdc.locationArtifactLabel=locationclampcockpit -sdc.locationArtifactType=DCAE_INVENTORY_JSON -sdc.InstanceID=X-ONAP-InstanceID -# -# -# -ui.location.default={"SNDGCA64":"San Diego SAN3","ALPRGAED":"Alpharetta PDK1","LSLEILAA":"Lisle DPA3","MDTWNJC1":"FTL_C_location1","MDTWNJC2":"FTL_C_location2","MDTWNJ21":"FTL_L_location1","MDTWNJ22":"FTL_L_location2","RDM2WAGPLCP":"ISTFTL_location"} -ui.alarm.default={"Reports a transient alarm condition when an incoming CDR cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming CDR cannot be decoded successfully","Reports a transient alarm condition when an incoming ACR message cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming ACR message cannot be decoded successfully","Reports a transient alarm condition when a CDR validation fails":"vCCF: Reports a transient alarm condition when a CDR validation fails","Reports a transient alarm condition when an incoming GTP' message cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming GTP' message cannot be decoded successfully","Reports a transient alarm condition when an incoming CDR file cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming CDR file cannot be decoded successfully","Reports a transient alarm condition when an incoming Sh/Dh file cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming Sh/Dh file cannot be decoded successfully","Reports a transient alarm condition when an incoming ACR message is in conflict with former ACR in one diameter session":"vCCF: Reports a transient alarm condition when an incoming ACR message is in conflict with former ACR in one diameter session","Reports a transient alarm condition when an outgoing Ro message send fails":"vCCF: Reports a transient alarm condition when an outgoing Ro message send fails","Reports a transient alarm condition when an outgoing GTP' message send fails":"vCCF: Reports a transient alarm condition when an outgoing GTP' message send fails","Reports a transient alarm condition when an outgoing Sh/Dh message send fails":"vCCF: Reports a transient alarm condition when an outgoing Sh/Dh message send fails","Reports an alarm when build or send Rf message fail":"vCCF: Reports an alarm when build or send Rf message fail","Reports a transient alarm condition when an abnormal incoming CCA message":"vCCF: Reports a transient alarm condition when an abnormal incoming CCA message","Reports a transient alarm condition when there is an abnormal incoming Sh/Dh message":"vCCF: Reports a transient alarm condition when there is an abnormal incoming Sh/Dh message","For Rf interface, if IeCCF receives a message with incorrect value for session id.":"vCCF: For Rf interface, if IeCCF receives a message with incorrect value for session id.","Reports an alarm when CPU usage exceeds the major threshold, the local database exceeds the critical threshold, or the ACR partition exceeds the major threshold":"vCCF: Reports an alarm when CPU usage exceeds the major threshold, the local database exceeds the critical threshold, or the ACR partition exceeds the major threshold","Reports an alarm when CPU usage exceeds the minor threshold, the local database exceeds the major threshold, or the ACR partition exceeds the minor threshold":"vCCF: Reports an alarm when CPU usage exceeds the minor threshold, the local database exceeds the major threshold, or the ACR partition exceeds the minor threshold","Reports an alarm when CPU usage exceeds the critical threshold, the local database exceeds the major threshold, or the CDR partition exceeds the critical threshold":"vCCF: Reports an alarm when CPU usage exceeds the critical threshold, the local database exceeds the major threshold, or the CDR partition exceeds the critical threshold","Reports an alarm when CPU usage exceeds the major threshold or CDR partition exceeds the major threshold":"vCCF: Reports an alarm when CPU usage exceeds the major threshold or CDR partition exceeds the major threshold","Reports an alarm when external DB usage exceeds the major threshold":"vCCF: Reports an alarm when external DB usage exceeds the major threshold","If IeCCF comes to the status \\"Stop processing ACR records in ACRDB\\".":"vCCF: If IeCCF comes to the status \\"Stop processing ACR records in ACRDB\\".","If IeCCF comes to the status \\"Flush ACR is invoked\\".":"vCCF: If IeCCF comes to the status \\"Flush ACR is invoked\\".","Reports a transient alarm condition when the workflow definition table is provisioned wrongly":"vCCF: Reports a transient alarm condition when the workflow definition table is provisioned wrongly","Reports a transient alarm condition when the Action Definition table is provisioned wrongly":"vCCF: Reports a transient alarm condition when the Action Definition table is provisioned wrongly","Reports a transient alarm condition when the Ro Host Configuration is provisioned wrongly":"vCCF: Reports a transient alarm condition when the Ro Host Configuration is provisioned wrongly","Reports a transient alarm condition when the Sh Host Configuration is provisioned wrongly":"vCCF: Reports a transient alarm condition when the Sh Host Configuration is provisioned wrongly","Reports a transient alarm condition when a specific dictionary or rule does not exist":"vCCF: Reports a transient alarm condition when a specific dictionary or rule does not exist","Reports a transient alarm condition when failure occurs when mapping Rf message to XDR":"vCCF: Reports a transient alarm condition when failure occurs when mapping Rf message to XDR","Reports a transient alarm condition when failure occurs in aggregating process":"vCCF: Reports a transient alarm condition when failure occurs in aggregating process","Reports a transient alarm condition when failure happens in correlating process":"vCCF: Reports a transient alarm condition when failure happens in correlating process","Reports a transient alarm condition when failure occurs in generating CDR":"vCCF: Reports a transient alarm condition when failure occurs in generating CDR","Reports a transient alarm condition when failure occurs in constructing CCR message from XDR":"vCCF: Reports a transient alarm condition when failure occurs in constructing CCR message from XDR","Reports a transient alarm condition when an ACR/XER/BER/INC record write to bad file":"vCCF: Reports a transient alarm condition when an ACR/XER/BER/INC record write to bad file","Reports an alarm condition when aggregation or correlation central database connection is lost":"vCCF: Reports an alarm condition when aggregation or correlation central database connection is lost","Reports an alarm condition when a specific failure happens in database operations":"vCCF: Reports an alarm condition when a specific failure happens in database operations","Reports an alarm condition when DB capacity has been consumed to critical threshold":"vCCF: Reports an alarm condition when DB capacity has been consumed to critical threshold","Reports an alarm condition when DB capacity has been consumed to major threshold":"vCCF: Reports an alarm condition when DB capacity has been consumed to major threshold","Reports an alarm condition when DB capacity has been consumed to minor threshold.":"vCCF: Reports an alarm condition when DB capacity has been consumed to minor threshold.","Reports an alarm condition when application cannot deliver CDR to CDRSCH subsystem":"vCCF: Reports an alarm condition when application cannot deliver CDR to CDRSCH subsystem","Reports an alarm condition when some fields of ACR file header have error value and this ACR file cannot be processed further":"vCCF: Reports an alarm condition when some fields of ACR file header have error value and this ACR file cannot be processed further","Reports an alarm condition when some fields of ACR file header have invalid value and this ACR file can be processed further":"vCCF: Reports an alarm condition when some fields of ACR file header have invalid value and this ACR file can be processed further","Reports an alarm condition when the ACR file loses some ACR records":"vCCF: Reports an alarm condition when the ACR file loses some ACR records","Reports an alarm condition when some fields of ACR record header have error value and this ACR record and the following ACR records cannot be processed further":"vCCF: Reports an alarm condition when some fields of ACR record header have error value and this ACR record and the following ACR records cannot be processed further","Reports an alarm condition when error occurs in processing CDR/ACR files":"vCCF: Reports an alarm condition when error occurs in processing CDR/ACR files","Reports an alarm condition when CDR partition has been consumed to critical threshold":"vCCF: Reports an alarm condition when CDR partition has been consumed to critical threshold","Reports an alarm condition when CDR partition has been consumed to major threshold.":"vCCF: Reports an alarm condition when CDR partition has been consumed to major threshold.","Reports an alarm condition when CDR partition has been consumed to minor threshold":"vCCF: Reports an alarm condition when CDR partition has been consumed to minor threshold","Reports an alarm condition when ACR partition has been consumed to critical threshold":"vCCF: Reports an alarm condition when ACR partition has been consumed to critical threshold","Reports an alarm condition when ACR partition has been consumed to major threshold":"vCCF: Reports an alarm condition when ACR partition has been consumed to major threshold","Reports an alarm condition when ACR partition has been consumed to minor threshold":"vCCF: Reports an alarm condition when ACR partition has been consumed to minor threshold","Reports an alarm condition when CPU consumption reaches critical threshold":"vCCF: Reports an alarm condition when CPU consumption reaches critical threshold","Reports an alarm condition when CPU consumption reaches major threshold":"vCCF: Reports an alarm condition when CPU consumption reaches major threshold","Reports an alarm condition when CPU consumption reaches minor threshold":"vCCF: Reports an alarm condition when CPU consumption reaches minor threshold","Service shall monitor * number of partial CDR * number of incompleted CDR * number of unacceptable CDR If any one exceeds a configurable threshold in a configrable interval.":"vCCF: Service shall monitor * number of partial CDR * number of incompleted CDR * number of unacceptable CDR If any one exceeds a configurable threshold in a configrable interval.","CDR size exceed the platform capacity.":"vCCF: CDR size exceed the platform capacity.","Service shall monitor number of ACR without AII AVP, If it exceeds a configurable threshold in a configurable interval.":"vCCF: Service shall monitor number of ACR without AII AVP, If it exceeds a configurable threshold in a configurable interval.","Service shall monitor CDR cut due to ECCF_ACRNUMBER_IN_DB, If it exceeds a configurable threshold in a configurable interval.":"vCCF: Service shall monitor CDR cut due to ECCF_ACRNUMBER_IN_DB, If it exceeds a configurable threshold in a configurable interval.","External Node of this Cluster is overload":"vCCF: External Node of this Cluster is overload","bdb_high_latency":"vCCF-vDB: bdb_high_latency","bdb_high_throughput":"vCCF-vDB: bdb_high_throughput","bdb_size":"vCCF-vDB: bdb_size","cluster_inconsistent_rl_sw":"vCCF-vDB: cluster_inconsistent_rl_sw","cluster_node_remove_abort_failed":"vCCF-vDB: cluster_node_remove_abort_failed","cluster_node_remove_failed":"vCCF-vDB: cluster_node_remove_failed","cluster_ram_overcommit":"vCCF-vDB: cluster_ram_overcommit","cluster_rebalance_failed":"vCCF-vDB: cluster_rebalance_failed","cluster_too_few_nodes_for_replication":"vCCF-vDB: cluster_too_few_nodes_for_replication","node_cpu_utilization":"vCCF-vDB: node_cpu_utilization","node_ephemeral_storage":"vCCF-vDB: node_ephemeral_storage","node_failed":"vCCF-vDB: node_failed","node_memory":"vCCF-vDB: node_memory","node_net_throughput":"vCCF-vDB: node_net_throughput","node_offline_failed":"vCCF-vDB: node_offline_failed","node_offline_abort_failed":"vCCF-vDB: node_offline_abort_failed","node_online_failed":"vCCF-vDB: node_online_failed","OAM NODE- IS NOT ACTIVE ":"vCCF-vDB: OAM NODE- IS NOT ACTIVE ","LSS_asdaCommunicationFailure":"vCTS: LSS_asdaCommunicationFailure","LSS_ccdbCommunicationFailure":"vCTS: LSS_ccdbCommunicationFailure","LSS_cpiCTS3xxFailRate":"vCTS: LSS_cpiCTS3xxFailRate","LSS_cpiCTS4xxFailRate":"vCTS: LSS_cpiCTS4xxFailRate","LSS_cpiCTS5xxFailRate":"vCTS: LSS_cpiCTS5xxFailRate","LSS_cpiCTS6xxFailRate":"vCTS: LSS_cpiCTS6xxFailRate","LSS_cpiCTSSIPRetransmitInvite":"vCTS: LSS_cpiCTSSIPRetransmitInvite","LSS_cpiCTSSIPRetransmitNonInvite":"vCTS: LSS_cpiCTSSIPRetransmitNonInvite","LSS_glsInvalidCellId":"vCTS: LSS_glsInvalidCellId","LSS_glsServerUnavailable":"vCTS: LSS_glsServerUnavailable","LSS_hlrSyncConnection":"vCTS: LSS_hlrSyncConnection","LSS_hlrSyncQueue":"vCTS: LSS_hlrSyncQueue","LSS_lispBufferFullExternalLIG":"vCTS: LSS_lispBufferFullExternalLIG","LSS_prdbConnectWithAlternateFailure":"vCTS: LSS_prdbConnectWithAlternateFailure","LSS_prdbSyncDataToAlternateFailure":"vCTS: LSS_prdbSyncDataToAlternateFailure","LSS_preAllocatedResourceOverload":"vCTS: LSS_preAllocatedResourceOverload","LSS_prifSocketError":"vCTS: LSS_prifSocketError","LSS_prsCallInstanceExceeded":"vCTS: LSS_prsCallInstanceExceeded","LSS_prsCpuOverload":"vCTS: LSS_prsCpuOverload","LSS_prsDatabaseMigrationFailure":"vCTS: LSS_prsDatabaseMigrationFailure","LSS_prsFailureToConnectWithPRDB":"vCTS: LSS_prsFailureToConnectWithPRDB","LSS_prsQueueExceeded":"vCTS: LSS_prsQueueExceeded","LSS_smdiSocketError":"vCTS: LSS_smdiSocketError","LSS_socketError":"vCTS: LSS_socketError","LSS_softwareComponentDown":"vCTS: LSS_softwareComponentDown","LSS_tlsInitError":"vCTS: LSS_tlsInitError","LSS_usageOfSyncTable":"vCTS: LSS_usageOfSyncTable","LSS_utHttpProxyConnectionDown ":"vCTS: LSS_utHttpProxyConnectionDown ","LSS_wpifSocketError":"vCTS: LSS_wpifSocketError","LSS_acrTemporaryBufferOverload":"vCTS: LSS_acrTemporaryBufferOverload","LSS_adnsExtendedTTLcaching":"vCTS: LSS_adnsExtendedTTLcaching","LSS_adnsQueryFailureCaching":"vCTS: LSS_adnsQueryFailureCaching","LSS_adnsQueueCongestion":"vCTS: LSS_adnsQueueCongestion","LSS_asdaRequestQueue":"vCTS: LSS_asdaRequestQueue","LSS_capacityLicenseKeyExpiration":"vCTS: LSS_capacityLicenseKeyExpiration","LSS_capacityLicenseKeyNearExpiration":"vCTS: LSS_capacityLicenseKeyNearExpiration","LSS_capacityLicenseKeyValidationError":"vCTS: LSS_capacityLicenseKeyValidationError","LSS_cardConnectionLost":"vCTS: LSS_cardConnectionLost","LSS_cpiAlrmCritical":"vCTS: LSS_cpiAlrmCritical","LSS_cpiAlrmMajor":"vCTS: LSS_cpiAlrmMajor","LSS_cpiAlrmMinor":"vCTS: LSS_cpiAlrmMinor","LSS_cpiAlrmWarning":"vCTS: LSS_cpiAlrmWarning","LSS_cpiAsrtEsc":"vCTS: LSS_cpiAsrtEsc","LSS_cpiAsrtNonEsc":"vCTS: LSS_cpiAsrtNonEsc","LSS_cpiAsrtNonEscCritical":"vCTS: LSS_cpiAsrtNonEscCritical","LSS_cpiAsrtNonEscMajor":"vCTS: LSS_cpiAsrtNonEscMajor","LSS_cpiAsrtNonEscMinor":"vCTS: LSS_cpiAsrtNonEscMinor","LSS_cpiAudErrCount":"vCTS: LSS_cpiAudErrCount","LSS_cpiAudManAct":"vCTS: LSS_cpiAudManAct","LSS_cpiAudNewEvent":"vCTS: LSS_cpiAudNewEvent","LSS_cpiCompleteRateAlarm":"vCTS: LSS_cpiCompleteRateAlarm","LSS_cpiDropMGAllocConnReq":"vCTS: LSS_cpiDropMGAllocConnReq","LSS_cpiDropRateAlarm":"vCTS: LSS_cpiDropRateAlarm","LSS_cpiExceptionService":"vCTS: LSS_cpiExceptionService","LSS_cpiFailRateAlarm":"vCTS: LSS_cpiFailRateAlarm","LSS_cpiFailSCTPFastRetransIncr":"vCTS: LSS_cpiFailSCTPFastRetransIncr","LSS_cpiFailSCTPFastRetransRate":"vCTS: LSS_cpiFailSCTPFastRetransRate","LSS_cpiFailSCTPSRTT1Incr":"vCTS: LSS_cpiFailSCTPSRTT1Incr","LSS_cpiFailSCTPSRTT2Incr":"vCTS: LSS_cpiFailSCTPSRTT2Incr","LSS_cpiFailSCTPT3RetransIncr":"vCTS: LSS_cpiFailSCTPT3RetransIncr","LSS_cpiFailSCTPT3RetransRate":"vCTS: LSS_cpiFailSCTPT3RetransRate","LSS_cpiFileSysUsage":"vCTS: LSS_cpiFileSysUsage","LSS_cpiMemAllocFail":"vCTS: LSS_cpiMemAllocFail","LSS_cpiNumOfLICDRDel":"vCTS: LSS_cpiNumOfLICDRDel","LSS_cpiReinitServiceSelf":"vCTS: LSS_cpiReinitServiceSelf","LSS_cpiSIPRetransmitInvite":"vCTS: LSS_cpiSIPRetransmitInvite","LSS_cpiSIPRetransmitNonInvite":"vCTS: LSS_cpiSIPRetransmitNonInvite","LSS_cpiSS7DropSCTPPktsRcvd":"vCTS: LSS_cpiSS7DropSCTPPktsRcvd","LSS_cpiSS7FailSCTPFastRetransRate":"vCTS: LSS_cpiSS7FailSCTPFastRetransRate","LSS_cpiStabilityAlarm":"vCTS: LSS_cpiStabilityAlarm","LSS_cpuOverload":"vCTS: LSS_cpuOverload","LSS_databaseConnectionLost":"vCTS: LSS_databaseConnectionLost","LSS_databaseReplicationLinkDown":"vCTS: LSS_databaseReplicationLinkDown","LSS_databaseSizeExhausted":"vCTS: LSS_databaseSizeExhausted","LSS_dbHighCpuUtilization":"vCTS: LSS_dbHighCpuUtilization","LSS_dbOffline":"vCTS: LSS_dbOffline","LSS_dbStatusUnexpected":"vCTS: LSS_dbStatusUnexpected","LSS_degradedResource":"vCTS: LSS_degradedResource","LSS_degrow":"vCTS: LSS_degrow","LSS_deviceServerCxnLost":"vCTS: LSS_deviceServerCxnLost","LSS_diamLinkDown":"vCTS: LSS_diamLinkDown","LSS_diamMaxClientsExceeded":"vCTS: LSS_diamMaxClientsExceeded","LSS_dnsThreshold":"vCTS: LSS_dnsThreshold","LSS_ethernetError":"vCTS: LSS_ethernetError","LSS_ethernetLinkDown":"vCTS: LSS_ethernetLinkDown","LSS_externalConnectivity":"vCTS: LSS_externalConnectivity","LSS_featureLicenseExpiration":"vCTS: LSS_featureLicenseExpiration","LSS_featureLicenseKeyNearExpiration":"vCTS: LSS_featureLicenseKeyNearExpiration","LSS_featureLockValidationError":"vCTS: LSS_featureLockValidationError","LSS_fqdnError":"vCTS: LSS_fqdnError","LSS_fru":"vCTS: LSS_fru","LSS_gatewayCongestion":"vCTS: LSS_gatewayCongestion","LSS_gatewayForcedOOS":"vCTS: LSS_gatewayForcedOOS","LSS_gatewayProvisioningError":"vCTS: LSS_gatewayProvisioningError","LSS_gatewayUnreachable":"vCTS: LSS_gatewayUnreachable","LSS_gatewayUnregistered":"vCTS: LSS_gatewayUnregistered","LSS_globalParameterNotFound":"vCTS: LSS_globalParameterNotFound","LSS_grow":"vCTS: LSS_grow","LSS_h248MessageBufferDepletion":"vCTS: LSS_h248MessageBufferDepletion","LSS_hostDown":"vCTS: LSS_hostDown","LSS_hostReset":"vCTS: LSS_hostReset","LSS_invalidGateway":"vCTS: LSS_invalidGateway","LSS_iriLinkDown":"vCTS: LSS_iriLinkDown","LSS_ldapServerConnectionLost":"vCTS: LSS_ldapServerConnectionLost","LSS_llcDown":"vCTS: LSS_llcDown","LSS_logicalLinkDown":"vCTS: LSS_logicalLinkDown","LSS_logicalLinkNotFound":"vCTS: LSS_logicalLinkNotFound","LSS_logRotateThreshold":"vCTS: LSS_logRotateThreshold","LSS_memoryOverload":"vCTS: LSS_memoryOverload","LSS_nodeConfigFailure":"vCTS: LSS_nodeConfigFailure","LSS_nodeGroupOOS":"vCTS: LSS_nodeGroupOOS","LSS_nodeOOS":"vCTS: LSS_nodeOOS","LSS_nonCompliantFaultGroupMemberState":"vCTS: LSS_nonCompliantFaultGroupMemberState","LSS_nonCsAddrChannelDepletion":"vCTS: LSS_nonCsAddrChannelDepletion","LSS_numberOfTuplesInUse":"vCTS: LSS_numberOfTuplesInUse","LSS_osSecInfoModificationDetected":"vCTS: LSS_osSecInfoModificationDetected","LSS_osSecInformationMissing":"vCTS: LSS_osSecInformationMissing","LSS_osSecUnexpectedInformation":"vCTS: LSS_osSecUnexpectedInformation","LSS_pdnsMySqlReplication":"vCTS: LSS_pdnsMySqlReplication","LSS_pktCorruptionDetectedViaRCCLANCheck":"vCTS: LSS_pktCorruptionDetectedViaRCCLANCheck","LSS_platformCommandFailure":"vCTS: LSS_platformCommandFailure","LSS_pmDataNotCollected":"vCTS: LSS_pmDataNotCollected","LSS_processDown":"vCTS: LSS_processDown","LSS_processNotStarted":"vCTS: LSS_processNotStarted","LSS_provisioningInhibitedMode":"vCTS: LSS_provisioningInhibitedMode","LSS_rccInhibitedMode":"vCTS: LSS_rccInhibitedMode","LSS_remotedbLinkDown":"vCTS: LSS_remotedbLinkDown","LSS_remoteQueryServerFailure":"vCTS: LSS_remoteQueryServerFailure","LSS_restore":"vCTS: LSS_restore","LSS_serviceCFGDataTimestampError":"vCTS: LSS_serviceCFGDataTimestampError","LSS_serviceCommCxnLost":"vCTS: LSS_serviceCommCxnLost","LSS_serviceOnewayCommunication":"vCTS: LSS_serviceOnewayCommunication","LSS_sheddingOverload":"vCTS: LSS_sheddingOverload","LSS_simxml":"vCTS: LSS_simxml","LSS_sipLinkSetMaxQuarantineList":"vCTS: LSS_sipLinkSetMaxQuarantineList","LSS_sipLinkSetUnavailable":"vCTS: LSS_sipLinkSetUnavailable","LSS_sipLinkUnavailable":"vCTS: LSS_sipLinkUnavailable","LSS_softwareAllocatedResourceOverload":"vCTS: LSS_softwareAllocatedResourceOverload","LSS_softwareComponentStandbyNotReady":"vCTS: LSS_softwareComponentStandbyNotReady","LSS_softwareLicense":"vCTS: LSS_softwareLicense","LSS_svcdegrow":"vCTS: LSS_svcdegrow","LSS_svcgrow":"vCTS: LSS_svcgrow","LSS_swVersionMismatch":"vCTS: LSS_swVersionMismatch","LSS_tftpDownloadCorrupt":"vCTS: LSS_tftpDownloadCorrupt","LSS_timeStampValueOutOfSystemRange":"vCTS: LSS_timeStampValueOutOfSystemRange","LSS_transactionHandlerBlockDepletion":"vCTS: LSS_transactionHandlerBlockDepletion","LSS_upgrade":"vCTS: LSS_upgrade","SYS_BackupFailure":"vCTS: SYS_BackupFailure","SYS_Configuration":"vCTS: SYS_Configuration","SYS_COTRecordTransferFailure":"vCTS: SYS_COTRecordTransferFailure","SYS_CPM_USERDATA_INCONSITENCY":"vCTS: SYS_CPM_USERDATA_INCONSITENCY","SYS_CPM_USERDATA_RESTORED":"vCTS: SYS_CPM_USERDATA_RESTORED","SYS_EventQueueCapacity":"vCTS: SYS_EventQueueCapacity","SYS_ICMPFailure":"vCTS: SYS_ICMPFailure","SYS_IPsecConfig":"vCTS: SYS_IPsecConfig","SYS_LinkDown":"vCTS: SYS_LinkDown","SYS_NotifyDisabled":"vCTS: SYS_NotifyDisabled","SYS_NotifyLocked":"vCTS: SYS_NotifyLocked","SYS_NumTL1MeasThresh":"vCTS: SYS_NumTL1MeasThresh","SYS_RADIUS_TO_LDAP_FAILURE":"vCTS: SYS_RADIUS_TO_LDAP_FAILURE","SYS_ROOT_ACCESS_DENIED":"vCTS: SYS_ROOT_ACCESS_DENIED","SYS_ROOT_FTP_VIOLATION":"vCTS: SYS_ROOT_FTP_VIOLATION","SYS_ROOT_LOGIN_VIOLATION":"vCTS: SYS_ROOT_LOGIN_VIOLATION","SYS_ROOT_SSH_LOGIN_VIOLATION":"vCTS: SYS_ROOT_SSH_LOGIN_VIOLATION","SYS_SetupAAAFailure":"vCTS: SYS_SetupAAAFailure","SYS_SNETrapOverload":"vCTS: SYS_SNETrapOverload","SYS_SNMPAuthenticationFailure":"vCTS: SYS_SNMPAuthenticationFailure","SYS_SNMPFailure":"vCTS: SYS_SNMPFailure","SYS_SU_TO_ROOT_FAILURE":"vCTS: SYS_SU_TO_ROOT_FAILURE","SYS_SYSTEMTrapOverload":"vCTS: SYS_SYSTEMTrapOverload","SYS_ThresholdCrossed":"vCTS: SYS_ThresholdCrossed","SYS_UndiscoveredObject":"vCTS: SYS_UndiscoveredObject","SYS_WriteAAAFailure":"vCTS: SYS_WriteAAAFailure","jnxSpaceDiskUsageRising":"vDBE-EMS-Juniper: jnxSpaceDiskUsageRising","jnxSpaceDiskUsageRisingCleared":"vDBE-EMS-Juniper: jnxSpaceDiskUsageRisingCleared","jnxSpaceSwapUsageRising":"vDBE-EMS-Juniper: jnxSpaceSwapUsageRising","jnxSpaceSwapUsageRisingCleared":"vDBE-EMS-Juniper: jnxSpaceSwapUsageRisingCleared","jnxSpaceCPULARising":"vDBE-EMS-Juniper: jnxSpaceCPULARising","jnxSpaceCPULARisingCleared":"vDBE-EMS-Juniper: jnxSpaceCPULARisingCleared","jnxSpaceWebpProxyProcessDown":"vDBE-EMS-Juniper: jnxSpaceWebpProxyProcessDown","jnxSpaceWebpProxyProcessUp":"vDBE-EMS-Juniper: jnxSpaceWebpProxyProcessUp","jnxSpaceNMAProcessDown":"vDBE-EMS-Juniper: jnxSpaceNMAProcessDown","jnxSpaceNMAProcessUp":"vDBE-EMS-Juniper: jnxSpaceNMAProcessUp","jnxSpaceJbossProcessDown":"vDBE-EMS-Juniper: jnxSpaceJbossProcessDown","jnxSpaceJbossProcessUp":"vDBE-EMS-Juniper: jnxSpaceJbossProcessUp","jnxSpaceMysqlProcessDown":"vDBE-EMS-Juniper: jnxSpaceMysqlProcessDown","jnxSpaceMysqlProcessUp":"vDBE-EMS-Juniper: jnxSpaceMysqlProcessUp","jnxSpacePostgresqlProcessDown":"vDBE-EMS-Juniper: jnxSpacePostgresqlProcessDown","jnxSpacePostgresqlProcessUp":"vDBE-EMS-Juniper: jnxSpacePostgresqlProcessUp","jnxSpaceWatchdogStopped":"vDBE-EMS-Juniper: jnxSpaceWatchdogStopped","jnxSpaceWatchdogStarted":"vDBE-EMS-Juniper: jnxSpaceWatchdogStarted","jnxSpaceSNAProcessDown":"vDBE-EMS-Juniper: jnxSpaceSNAProcessDown","jnxSpaceSNAProcessUp":"vDBE-EMS-Juniper: jnxSpaceSNAProcessUp","jnxSpaceNodeDown":"vDBE-EMS-Juniper: jnxSpaceNodeDown","jnxSpaceNodeUp":"vDBE-EMS-Juniper: jnxSpaceNodeUp"," jnxSpaceNodeRemoval":"vDBE-EMS-Juniper: jnxSpaceNodeRemoval","jnxCmCfgChange":"vDBE-Juniper: jnxCmCfgChange","jnxCmRescueChange":"vDBE-Juniper: jnxCmRescueChange","jnxEventTrap":"vDBE-Juniper: jnxEventTrap","jnxJsFwAuthFailure":"vDBE-Juniper: jnxJsFwAuthFailure","jnxJsFwAuthServiceUp":"vDBE-Juniper: jnxJsFwAuthServiceUp","jnxJsFwAuthServiceDown":"vDBE-Juniper: jnxJsFwAuthServiceDown","jnxJsFwAuthCapacityExceeded":"vDBE-Juniper: jnxJsFwAuthCapacityExceeded","jnxJsIdpSignatureUpdate":"vDBE-Juniper: jnxJsIdpSignatureUpdate","jnxJsIdpAttackLog":"vDBE-Juniper: jnxJsIdpAttackLog","jnxJsSrcNatPoolThresholdStatus":"vDBE-Juniper: jnxJsSrcNatPoolThresholdStatus","jnxJsNatRuleThresholdStatus":"vDBE-Juniper: jnxJsNatRuleThresholdStatus","jnxJsScreenAttack":"vDBE-Juniper: jnxJsScreenAttack","jnxJsScreenCfgChange":"vDBE-Juniper: jnxJsScreenCfgChange","jnxJsAvPatternUpdateTrap":"vDBE-Juniper: jnxJsAvPatternUpdateTrap","jnxJsChassisClusterSwitchover":"vDBE-Juniper: jnxJsChassisClusterSwitchover","jnxJsChClusterIntfTrap":"vDBE-Juniper: jnxJsChClusterIntfTrap","jnxJsChClusterSpuMismatchTrap":"vDBE-Juniper: jnxJsChClusterSpuMismatchTrap","jnxJsChClusterWeightTrap":"vDBE-Juniper: jnxJsChClusterWeightTrap","jnxLicenseGraceExpired":"vDBE-Juniper: jnxLicenseGraceExpired","jnxLicenseGraceAboutToExpire":"vDBE-Juniper: jnxLicenseGraceAboutToExpire","jnxLicenseAboutToExpire":"vDBE-Juniper: jnxLicenseAboutToExpire","jnxLicenseInfringeCumulative":"vDBE-Juniper: jnxLicenseInfringeCumulative","jnxLicenseInfringeSingle":"vDBE-Juniper: jnxLicenseInfringeSingle","jnxNatAddrPoolThresholdStatus":"vDBE-Juniper: jnxNatAddrPoolThresholdStatus","jnxSyslogTrap":"vDBE-Juniper: jnxSyslogTrap","jnxAccessAuthServiceUp":"vDBE-Juniper: jnxAccessAuthServiceUp","jnxAccessAuthServiceDown":"vDBE-Juniper: jnxAccessAuthServiceDown","jnxAccessAuthServerDisabled":"vDBE-Juniper: jnxAccessAuthServerDisabled","jnxAccessAuthServerEnabled":"vDBE-Juniper: jnxAccessAuthServerEnabled","jnxAccessAuthAddressPoolHighThreshold":"vDBE-Juniper: jnxAccessAuthAddressPoolHighThreshold","jnxAccessAuthAddressPoolAbateThreshold":"vDBE-Juniper: jnxAccessAuthAddressPoolAbateThreshold","jnxAccessAuthAddressPoolOutOfAddresses":"vDBE-Juniper: jnxAccessAuthAddressPoolOutOfAddresses","jnxAccessAuthAddressPoolOutOfMemory":"vDBE-Juniper: jnxAccessAuthAddressPoolOutOfMemory","LEVEL_WARNING_CPU":"vMRF: LEVEL_WARNING_CPU","LEVEL_MAJOR_CPU":"vMRF: LEVEL_MAJOR_CPU","LEVEL_CRITICAL_CPU":"vMRF: LEVEL_CRITICAL_CPU","LEVEL_WARNING_MEM":"vMRF: LEVEL_WARNING_MEM","LEVEL_MAJOR_MEM":"vMRF: LEVEL_MAJOR_MEM","LEVEL_CRITICAL_MEM":"vMRF: LEVEL_CRITICAL_MEM","LEVEL_WARNING_DISK":"vMRF: LEVEL_WARNING_DISK","LEVEL_MAJOR_DISK":"vMRF: LEVEL_MAJOR_DISK","LEVEL_CRITICAL_DISK":"vMRF: LEVEL_CRITICAL_DISK","LEVEL_WARNING_RTPBANDWIDTH":"vMRF: LEVEL_WARNING_RTPBANDWIDTH","LEVEL_MAJOR_RTPBANDWIDTH":"vMRF: LEVEL_MAJOR_RTPBANDWIDTH","LEVEL_CRITICAL_RTPBANDWIDTH":"vMRF: LEVEL_CRITICAL_RTPBANDWIDTH","LEVEL_WARNING_RTPINPACKETLOSS":"vMRF: LEVEL_WARNING_RTPINPACKETLOSS","LEVEL_MAJOR_RTPINPACKETLOSS":"vMRF: LEVEL_MAJOR_RTPINPACKETLOSS","LEVEL_CRITICAL_RTPINPACKETLOSS":"vMRF: LEVEL_CRITICAL_RTPINPACKETLOSS","LEVEL_WARNING_RTPOUTPACKETLOSS":"vMRF: LEVEL_WARNING_RTPOUTPACKETLOSS","LEVEL_MAJOR_RTPOUTPACKETLOSS":"vMRF: LEVEL_MAJOR_RTPOUTPACKETLOSS","LEVEL_CRITICAL_RTPOUTPACKETLOSS":"vMRF: LEVEL_CRITICAL_RTPOUTPACKETLOSS","LEVEL_WARNING_TCPLOSTRETRANSMITRATE":"vMRF: LEVEL_WARNING_TCPLOSTRETRANSMITRATE","LEVEL_MAJOR_TCPLOSTRETRANSMITRATE":"vMRF: LEVEL_MAJOR_TCPLOSTRETRANSMITRATE","LEVEL_CRITICAL_TCPLOSTRETRANSMITRATE":"vMRF: LEVEL_CRITICAL_TCPLOSTRETRANSMITRATE","LEVEL_WARNING_TCPLOSSFAILURERATE":"vMRF: LEVEL_WARNING_TCPLOSSFAILURERATE","LEVEL_MAJOR_TCPLOSSFAILURERATE":"vMRF: LEVEL_MAJOR_TCPLOSSFAILURERATE","LEVEL_CRITICAL_TCPLOSSFAILURERATE":"vMRF: LEVEL_CRITICAL_TCPLOSSFAILURERATE","LEVEL_CRITICAL_RTPLINKDOWN":"vMRF: LEVEL_CRITICAL_RTPLINKDOWN","TARGET_REACHABLE":"vMRF: TARGET_REACHABLE","PUBLICATION_ERROR":"vMRF: PUBLICATION_ERROR","REMOTE_SERVER_SYNCHRONIZATION_ERROR":"vMRF: REMOTE_SERVER_SYNCHRONIZATION_ERROR","TRANSCODER_TOOL_EXEC_ERROR":"vMRF: TRANSCODER_TOOL_EXEC_ERROR","CLIENT_SYNCHRONIZATION_ERROR":"vMRF: CLIENT_SYNCHRONIZATION_ERROR","CLUSTER_UNREACHABLE":"vMRF: CLUSTER_UNREACHABLE","REMOTE_NODE_OFFLINE":"vMRF: REMOTE_NODE_OFFLINE","IPADDR_STOPPED":"vMRF: IPADDR_STOPPED","MRFC_STOPPED":"vMRF: MRFC_STOPPED","MNGT_STOPPED":"vMRF: MNGT_STOPPED","IPADDR_STARTED":"vMRF: IPADDR_STARTED","MRFC_STARTED":"vMRF: MRFC_STARTED","MNGT_STARTED":"vMRF: MNGT_STARTED","VOLATTACH_FAILED":"vMRF: VOLATTACH_FAILED","VOLDETACH_FAILED":"vMRF: VOLDETACH_FAILED","VOLDEL":"vMRF: VOLDEL","VOLCORRUPT":"vMRF: VOLCORRUPT","VOLFOREIGN":"vMRF: VOLFOREIGN","ACTIVE_ALARM_TABLE_PURGE":"vMRF: ACTIVE_ALARM_TABLE_PURGE","GENERIC_FORMER_STATELESS":"vMRF: GENERIC_FORMER_STATELESS","GENERIC_FORMER_STATEFUL":"vMRF: GENERIC_FORMER_STATEFUL","NO_MORE_ALARM_DESCRIPTION":"vMRF: NO_MORE_ALARM_DESCRIPTION","SERVICE_PROCESS_ENDS":"vMRF: SERVICE_PROCESS_ENDS","DEFENSE_STOPPED":"vMRF: DEFENSE_STOPPED","USER_ACCOUNT_LOCKED":"vMRF: USER_ACCOUNT_LOCKED","CONNECTION_SQL_NOT_ESTABLISHED":"vMRF: CONNECTION_SQL_NOT_ESTABLISHED","FALSE_ALARM":"vMRF: FALSE_ALARM","RADIUS SERVER HS":"vMRF: RADIUS SERVER HS","DRM_PACKAGER_IS_NOT_AVAILABLE":"vMRF: DRM_PACKAGER_IS_NOT_AVAILABLE","DRM_LICENSE_BUILDER_IS_NOT_AVAILABLE":"vMRF: DRM_LICENSE_BUILDER_IS_NOT_AVAILABLE","ERROR_WHILE_CREATING_PLAYLIST_MANAGER_FILE":"vMRF: ERROR_WHILE_CREATING_PLAYLIST_MANAGER_FILE","ERROR_WHILE_BUILDING_PLAYLIST_XML_REPRESENTATION":"vMRF: ERROR_WHILE_BUILDING_PLAYLIST_XML_REPRESENTATION","PLAYLIST_FILE_TO_PUBLISH_NOT_FOUND":"vMRF: PLAYLIST_FILE_TO_PUBLISH_NOT_FOUND","COULD_NOT_CONNECT_TO_PVNS_SERVER":"vMRF: COULD_NOT_CONNECT_TO_PVNS_SERVER","HTTP_OR_HTTPCLIENT_EXCEPTION_HAS_OCCURRED":"vMRF: HTTP_OR_HTTPCLIENT_EXCEPTION_HAS_OCCURRED","I/O_ERROR_WHILE_PUBLISHING_PLAYLIST_FILE":"vMRF: I/O_ERROR_WHILE_PUBLISHING_PLAYLIST_FILE","ERROR_WHILE_REQUESTING_SDP_FILE":"vMRF: ERROR_WHILE_REQUESTING_SDP_FILE","ERROR_WHILE_REQUESTING_SDP_FILE:_REMOTE_EXCEPTION":"vMRF: ERROR_WHILE_REQUESTING_SDP_FILE:_REMOTE_EXCEPTION","NO_STREAMING_RESOURCES":"vMRF: NO_STREAMING_RESOURCES","NO_STREAMING_MODULES_REGISTERED":"vMRF: NO_STREAMING_MODULES_REGISTERED","SM_FAILURE":"vMRF: SM_FAILURE","MISSING_FILE_OR_ENCODER":"vMRF: MISSING_FILE_OR_ENCODER","INVALID_RANGE":"vMRF: INVALID_RANGE","THRESHOLD_VALUE_EXCEEDED":"vMRF: THRESHOLD_VALUE_EXCEEDED","TICKET_QUEUE_FULL":"vMRF: TICKET_QUEUE_FULL","PARSING_INITIALIZATION_EXCEPTION":"vMRF: PARSING_INITIALIZATION_EXCEPTION","CUSTOMERCARE_INTERNAL_EXCEPTION":"vMRF: CUSTOMERCARE_INTERNAL_EXCEPTION","PARSING_EXCEPTION":"vMRF: PARSING_EXCEPTION","I/O_PROBLEM":"vMRF: I/O_PROBLEM","INEXISTENT_FILE_OR_FOLDER":"vMRF: INEXISTENT_FILE_OR_FOLDER","FILE_NOT_IN_XML_FORMAT":"vMRF: FILE_NOT_IN_XML_FORMAT","SERVICE_STATE_CHANGE":"vMRF: SERVICE_STATE_CHANGE","MONITORED_FILE_UPDATE_ERROR":"vMRF: MONITORED_FILE_UPDATE_ERROR","MONITORED_RPM_DELETED_ERROR":"vMRF: MONITORED_RPM_DELETED_ERROR","MONITORED_RPM_ADDED_ERROR":"vMRF: MONITORED_RPM_ADDED_ERROR","MONITORED_CHMOD_ERROR":"vMRF: MONITORED_CHMOD_ERROR","MONITORED_CHOWN_ERROR":"vMRF: MONITORED_CHOWN_ERROR","PASSWD_ROOT_ERROR":"vMRF: PASSWD_ROOT_ERROR","PASSWD_ERROR":"vMRF: PASSWD_ERROR","ROOTKIT_ERROR":"vMRF: ROOTKIT_ERROR","STARTUP_ERR_UNDEFINED_PORT":"vMRF: STARTUP_ERR_UNDEFINED_PORT","STARTUP_ERR_FAIL_FIND_HOSTNAME":"vMRF: STARTUP_ERR_FAIL_FIND_HOSTNAME","STARTUP_ERR_CF_MISSING":"vMRF: STARTUP_ERR_CF_MISSING","STARTUP_ERR_FAILED_TO_OPEN_CF":"vMRF: STARTUP_ERR_FAILED_TO_OPEN_CF","STARTUP_ERR_FAILED_TO_BIND_PORT":"vMRF: STARTUP_ERR_FAILED_TO_BIND_PORT","STARTUP_ERR_CFG_UNIT_MISSING":"vMRF: STARTUP_ERR_CFG_UNIT_MISSING","MCTR_INVALID_CODEC_NAME":"vMRF: MCTR_INVALID_CODEC_NAME","RTSP_SERVER_FAILURE":"vMRF: RTSP_SERVER_FAILURE","RTSP_SERVER_QUARANTINE":"vMRF: RTSP_SERVER_QUARANTINE","TRANSCODING_FAILURE":"vMRF: TRANSCODING_FAILURE","FILE_CACHE_FAILURE":"vMRF: FILE_CACHE_FAILURE","STARTUP_ERROR_INITIALIZATION_FAILED":"vMRF: STARTUP_ERROR_INITIALIZATION_FAILED","CONFERENCE_FAILURE":"vMRF: CONFERENCE_FAILURE","PLC_DEGRADATION_LOW":"vMRF: PLC_DEGRADATION_LOW","PLC_DEGRADATION_MEDIUM":"vMRF: PLC_DEGRADATION_MEDIUM","PLC_DEGRADATION_HIGH":"vMRF: PLC_DEGRADATION_HIGH","AUDIO_RESYNCH_LOW":"vMRF: AUDIO_RESYNCH_LOW","AUDIO_RESYNCH_MEDIUM":"vMRF: AUDIO_RESYNCH_MEDIUM","AUDIO_RESYNCH_HIGH":"vMRF: AUDIO_RESYNCH_HIGH","VIDEO_RESYNCH_LOW":"vMRF: VIDEO_RESYNCH_LOW","VIDEO_RESYNCH_MEDIUM":"vMRF: VIDEO_RESYNCH_MEDIUM","VIDEO_RESYNCH_HIGH":"vMRF: VIDEO_RESYNCH_HIGH","PLAY_FAILURES_LOW":"vMRF: PLAY_FAILURES_LOW","PLAY_FAILURES_MEDIUM":"vMRF: PLAY_FAILURES_MEDIUM","PLAY_FAILURES_HIGH":"vMRF: PLAY_FAILURES_HIGH","NOT_ENOUGH_FREE_CONFEREE":"vMRF: NOT_ENOUGH_FREE_CONFEREE","NO_LONGER_FREE_CONFERENCE_ROOM":"vMRF: NO_LONGER_FREE_CONFERENCE_ROOM","STARTUP_ERROR_FAIL_TO_READ_CF":"vMRF: STARTUP_ERROR_FAIL_TO_READ_CF","STARTUP_ERROR_SIP_ADAPTER_INIT":"vMRF: STARTUP_ERROR_SIP_ADAPTER_INIT","STARTUP_ERROR_MONITORING_INIT":"vMRF: STARTUP_ERROR_MONITORING_INIT","REGISTER_ERROR_FAILURE":"vMRF: REGISTER_ERROR_FAILURE","DRI_ERROR_FAILURE":"vMRF: DRI_ERROR_FAILURE","STARTUP_ERROR_STACK_CONFIGURATION":"vMRF: STARTUP_ERROR_STACK_CONFIGURATION","STARTUP_ERROR_CONF":"vMRF: STARTUP_ERROR_CONF","STARTUP_ERROR_UNDEFINED_PORT":"vMRF: STARTUP_ERROR_UNDEFINED_PORT","HOST_REMOVED":"vMRF: HOST_REMOVED","INTERCEPT_THRESHOLD_NB_DIALOG_ALLOCATED":"vMRF: INTERCEPT_THRESHOLD_NB_DIALOG_ALLOCATED","STARTUP_ERROR_STACK_CONF":"vMRF: STARTUP_ERROR_STACK_CONF","STARTUP_ERROR_CONFIGURATION":"vMRF: STARTUP_ERROR_CONFIGURATION","STARTUP_ERROR_FAILED_TO_RETRIEVE_HOSTNAME":"vMRF: STARTUP_ERROR_FAILED_TO_RETRIEVE_HOSTNAME","LEVEL_WARNING_CALL":"vMRF: LEVEL_WARNING_CALL","LEVEL_ALARM_MINOR_CALL":"vMRF: LEVEL_ALARM_MINOR_CALL","LEVEL_ALARM_MAJOR_CALL":"vMRF: LEVEL_ALARM_MAJOR_CALL","LEVEL_ALARM_MRFPoutOfService":"vMRF: LEVEL_ALARM_MRFPoutOfService","MRFP_CALL_REJECTED_Threshold #1":"vMRF: MRFP_CALL_REJECTED_Threshold #1","MRFP_CALL_REJECTED_Threshold #2":"vMRF: MRFP_CALL_REJECTED_Threshold #2","MRFP_CALL_REJECTED_Threshold #3":"vMRF: MRFP_CALL_REJECTED_Threshold #3","MRFP_CALL_RETRIED_Threshold #1":"vMRF: MRFP_CALL_RETRIED_Threshold #1","MRFP_CALL_RETRIED_Threshold #2":"vMRF: MRFP_CALL_RETRIED_Threshold #2","MRFP_CALL_RETRIED_Threshold #3":"vMRF: MRFP_CALL_RETRIED_Threshold #3","STARTUP_PUB_FILE_NOT_PRESENT":"vMRF: STARTUP_PUB_FILE_NOT_PRESENT","STARTUP_INF_FILE_NOT_PRESENT":"vMRF: STARTUP_INF_FILE_NOT_PRESENT","STARTUP_LIC_FILE_NOT_PRESENT":"vMRF: STARTUP_LIC_FILE_NOT_PRESENT","GENERIC_HARDWARE_PROBLEM":"vMRF: GENERIC_HARDWARE_PROBLEM","HARD_DRIVE_PROBLEM":"vMRF: HARD_DRIVE_PROBLEM","NETWORK_LINK_PROBLEM":"vMRF: NETWORK_LINK_PROBLEM","POWER_SUPPLY_PROBLEM":"vMRF: POWER_SUPPLY_PROBLEM","SMART_HARD_DRIVE_PROBLEM":"vMRF: SMART_HARD_DRIVE_PROBLEM","STARTUP_ERROR":"vMRF: STARTUP_ERROR","RESOURCE_NOT_ACCESSIBLE":"vMRF: RESOURCE_NOT_ACCESSIBLE","RESOURCE_ACCESSIBLE":"vMRF: RESOURCE_ACCESSIBLE","RESOURCE_FULL":"vMRF: RESOURCE_FULL","DRI_ALARM":"vMRF: DRI_ALARM","REGISTER_ERROR_CCF":"vMRF: REGISTER_ERROR_CCF","REGISTER_ERROR_EXTERNAL":"vMRF: REGISTER_ERROR_EXTERNAL","TIMEOUT_ERROR":"vMRF: TIMEOUT_ERROR","VXML_ERROR":"vMRF: VXML_ERROR","A Network Element is no longer available due to a connection failure":"vMVM: A Network Element is no longer available due to a connection failure","A MetaSphere server is reporting a fault with the configuration of its connection to MetaView":"vMVM: A MetaSphere server is reporting a fault with the configuration of its connection to MetaView","Configured OBS IPs don't match available OBS nodes. Configured but unavailable nodes include: []. Real nodes not configured include: []":"vMVM: Configured OBS IPs don't match available OBS nodes. Configured but unavailable nodes include: []. Real nodes not configured include: []","Service Assurance Server cannot be contacted":"vMVM: Service Assurance Server cannot be contacted","The primary MetaView Director has lost contact with the backup MetaView Director":"vMVM: The primary MetaView Director has lost contact with the backup MetaView Director","The active server has lost connection to the standby":"vMVM: The active server has lost connection to the standby","CrashCounter":"vprobes-vBE-Processing: CrashCounter","IsAlive":"vprobes-vBE-Processing: IsAlive","SwRestart":"vprobes-vLB: SwRestart","Repeated exceptions have occurred.":"vSBC-Metaswitch: Repeated exceptions have occurred.","A licensing limit is close to capacity.":"vSBC-Metaswitch: A licensing limit is close to capacity.","One or more feature packs have been breached.":"vSBC-Metaswitch: One or more feature packs have been breached.","The grace period on this Perimeta system will expire in less than 48 hours, after which calls will not be processed.":"vSBC-Metaswitch: The grace period on this Perimeta system will expire in less than 48 hours, after which calls will not be processed.","The grace period on this Perimeta system will expire in less than 7 days, after which calls will not be processed.":"vSBC-Metaswitch: The grace period on this Perimeta system will expire in less than 7 days, after which calls will not be processed.","The license on this Perimeta system will expire in less than 4 weeks.":"vSBC-Metaswitch: The license on this Perimeta system will expire in less than 4 weeks.","A Perimeta blade has become unlicensed.":"vSBC-Metaswitch: A Perimeta blade has become unlicensed.","Perimeta is licensed with a bypass certificate, which is valid until the time displayed.":"vSBC-Metaswitch: Perimeta is licensed with a bypass certificate, which is valid until the time displayed.","The number of licensed instances exceeded a threshold of the licensed limit.":"vSBC-Metaswitch: The number of licensed instances exceeded a threshold of the licensed limit.","The software token on the primary Distributed Capacity Manager will expire on the displayed date.":"vSBC-Metaswitch: The software token on the primary Distributed Capacity Manager will expire on the displayed date.","A capacity limit on the license installed on this Perimeta system does not match the largest limit across all systems in the deployment.":"vSBC-Metaswitch: A capacity limit on the license installed on this Perimeta system does not match the largest limit across all systems in the deployment.","An adjacency has voice quality alerts.":"vSBC-Metaswitch: An adjacency has voice quality alerts.","The number of calls being audited is congested.":"vSBC-Metaswitch: The number of calls being audited is congested.","Session Controller is rejecting calls because there is no valid active call policy set configured.":"vSBC-Metaswitch: Session Controller is rejecting calls because there is no valid active call policy set configured.","A call policy set is inactive because it has been misconfigured.":"vSBC-Metaswitch: A call policy set is inactive because it has been misconfigured.","Session Controller is inactive and rejecting calls.":"vSBC-Metaswitch: Session Controller is inactive and rejecting calls.","Sources have breached minor or major blacklist thresholds.":"vSBC-Metaswitch: Sources have breached minor or major blacklist thresholds.","Sources are blacklisted.":"vSBC-Metaswitch: Sources are blacklisted.","The blacklisting configuration will change as a result of upgrade and some configured blacklists or alerts will no longer be applied.":"vSBC-Metaswitch: The blacklisting configuration will change as a result of upgrade and some configured blacklists or alerts will no longer be applied.","A large number of downgrades and bans have been created as a result of blacklisting.":"vSBC-Metaswitch: A large number of downgrades and bans have been created as a result of blacklisting.","Session Controller is unable to track further sources for blacklisting.":"vSBC-Metaswitch: Session Controller is unable to track further sources for blacklisting.","A software protection switch was triggered.":"vSBC-Metaswitch: A software protection switch was triggered.","A disk area on a processor blade is nearly full.":"vSBC-Metaswitch: A disk area on a processor blade is nearly full.","Memory use is very high.":"vSBC-Metaswitch: Memory use is very high.","The primary processor-blade has lost contact with the backup.":"vSBC-Metaswitch: The primary processor-blade has lost contact with the backup.","An efix or patch has been applied to this system containing diagnostic versions of some software libraries.":"vSBC-Metaswitch: An efix or patch has been applied to this system containing diagnostic versions of some software libraries.","A software protection switch (SPS) was triggered. Call and registration state was lost.":"vSBC-Metaswitch: A software protection switch (SPS) was triggered. Call and registration state was lost.","The Ethernet Heartbeat between primary and backup processors has failed.":"vSBC-Metaswitch: The Ethernet Heartbeat between primary and backup processors has failed.","The Backplane Heartbeat between primary and backup processors has failed.":"vSBC-Metaswitch: The Backplane Heartbeat between primary and backup processors has failed.","A disk area on a processor blade reported an error.":"vSBC-Metaswitch: A disk area on a processor blade reported an error.","The system is upgrading.":"vSBC-Metaswitch: The system is upgrading.","An error with NTP functionality has been detected.":"vSBC-Metaswitch: An error with NTP functionality has been detected.","One or more users are locked out of the system.":"vSBC-Metaswitch: One or more users are locked out of the system.","The Craft Terminal user FTP directory on a processor blade is nearly full.":"vSBC-Metaswitch: The Craft Terminal user FTP directory on a processor blade is nearly full.","A scheduled configuration snapshot has failed.":"vSBC-Metaswitch: A scheduled configuration snapshot has failed.","The Session Controller is stopping as a result of administrator action.":"vSBC-Metaswitch: The Session Controller is stopping as a result of administrator action.","A Session Controller processor blade is stopping as a result of administrator action.":"vSBC-Metaswitch: A Session Controller processor blade is stopping as a result of administrator action.","An object could not be activated because its service address does not exist or is not fully specified.":"vSBC-Metaswitch: An object could not be activated because its service address does not exist or is not fully specified.","The hardware on a processor does not meet minimum requirements.":"vSBC-Metaswitch: The hardware on a processor does not meet minimum requirements.","The hardware expectations of the two processors are not the same.":"vSBC-Metaswitch: The hardware expectations of the two processors are not the same.","The read speed of the main hard disk on a processor blade is too slow.":"vSBC-Metaswitch: The read speed of the main hard disk on a processor blade is too slow.","An error has occurred reading from the hard disk on a processor blade.":"vSBC-Metaswitch: An error has occurred reading from the hard disk on a processor blade.","Backup and primary processor-blades have an inconsistent system role.":"vSBC-Metaswitch: Backup and primary processor-blades have an inconsistent system role.","Event: The system encountered a critical error and had to restart.":"vSBC-Metaswitch: Event: The system encountered a critical error and had to restart.","Event: A RADIUS server failed to respond to an authentication request.":"vSBC-Metaswitch: Event: A RADIUS server failed to respond to an authentication request.","Event: All configured RADIUS servers failed to respond to authentication requests.":"vSBC-Metaswitch: Event: All configured RADIUS servers failed to respond to authentication requests.","Event: The number of CPUs has changed.":"vSBC-Metaswitch: Event: The number of CPUs has changed.","Event: A user has been automatically deleted":"vSBC-Metaswitch: Event: A user has been automatically deleted","The primary processor blade has lost management connectivity":"vSBC-Metaswitch: The primary processor blade has lost management connectivity","Event: A processor blade is running with DPDK mode disabled when DPDK mode is,expected.":"vSBC-Metaswitch: Event: A processor blade is running with DPDK mode disabled when DPDK mode is,expected.","Event: Processor blade %1 is running with DPDK mode disabled when DPDK mode may be possible.":"vSBC-Metaswitch: Event: Processor blade %1 is running with DPDK mode disabled when DPDK mode may be possible.","Perimeta is attempting to resend cached billing records.":"vSBC-Metaswitch: Perimeta is attempting to resend cached billing records.","The Rf billing cache is full.":"vSBC-Metaswitch: The Rf billing cache is full.","The inbound call queue is congested.":"vSBC-Metaswitch: The inbound call queue is congested.","A configured realm group contains realms that are not available to the SBC.":"vSBC-Metaswitch: A configured realm group contains realms that are not available to the SBC.","An allowed MSC configuration is not connected to any physical MSCs.":"vSBC-Metaswitch: An allowed MSC configuration is not connected to any physical MSCs.","A SIP Peer has stopped responding to SIP OPTIONS pings. MSW: 20160303: Alarm text is changed in v3.9 software to read: \\"An adjacency has lost connectivity, according to SIP OPTIONS pings\\"":"vSBC-Metaswitch: A SIP Peer has stopped responding to SIP OPTIONS pings. MSW: 20160303: Alarm text is changed in v3.9 software to read: \\"An adjacency has lost connectivity, according to SIP OPTIONS pings\\"","An adjacency has failed as the listen socket could not be created. Check for configuration mismatches with the associated service interface.":"vSBC-Metaswitch: An adjacency has failed as the listen socket could not be created. Check for configuration mismatches with the associated service interface.","No suitable DNS records were found for a peer group's DNS hostname.":"vSBC-Metaswitch: No suitable DNS records were found for a peer group's DNS hostname.","One or more SIP peers from a peer group have stopped responding to SIP OPTIONS pings":"vSBC-Metaswitch: One or more SIP peers from a peer group have stopped responding to SIP OPTIONS pings","An adjacency has failed as its service network does not match the service network on its associated peer group.":"vSBC-Metaswitch: An adjacency has failed as its service network does not match the service network on its associated peer group.","An adjacency has failed as its configured TLS certificate could not be found.":"vSBC-Metaswitch: An adjacency has failed as its configured TLS certificate could not be found.","The caching function has not been initialized properly.":"vSBC-Metaswitch: The caching function has not been initialized properly.","An adjacency has failed as the listen socket could not be created.":"vSBC-Metaswitch: An adjacency has failed as the listen socket could not be created.","An adjacency is congested and may be rejecting calls.":"vSBC-Metaswitch: An adjacency is congested and may be rejecting calls.","There is an issue with a Diameter peer.":"vSBC-Metaswitch: There is an issue with a Diameter peer.","A realm is no longer reachable via any configured peers.":"vSBC-Metaswitch: A realm is no longer reachable via any configured peers.","An FQDN for a configured Diameter peer has failed to resolve to a valid IP address.":"vSBC-Metaswitch: An FQDN for a configured Diameter peer has failed to resolve to a valid IP address.","One or more peers resolved from a DNS lookup of a configured peer's address cannot be contacted":"vSBC-Metaswitch: One or more peers resolved from a DNS lookup of a configured peer's address cannot be contacted","An interface ARP or NDP probe has failed.":"vSBC-Metaswitch: An interface ARP or NDP probe has failed.","One or more IP address conflicts have been detected on service interfaces with zero criticality. If there are other probe failures, this alarm will remain raised until all conflicts are resolved.":"vSBC-Metaswitch: One or more IP address conflicts have been detected on service interfaces with zero criticality. If there are other probe failures, this alarm will remain raised until all conflicts are resolved.","One or more IP address conflicts have been detected on service interfaces with non-zero criticality. If there are other probe failures, this alarm will remain raised until all conflicts are resolved.":"vSBC-Metaswitch: One or more IP address conflicts have been detected on service interfaces with non-zero criticality. If there are other probe failures, this alarm will remain raised until all conflicts are resolved.","An interface device is running below the expected speed. This alarm was originally triggered by a probe failure on a service interface.":"vSBC-Metaswitch: An interface device is running below the expected speed. This alarm was originally triggered by a probe failure on a service interface.","An interface device is running above the expected speed.":"vSBC-Metaswitch: An interface device is running above the expected speed.","An IP address conflict has been detected on a management interface.":"vSBC-Metaswitch: An IP address conflict has been detected on a management interface.","An interface ICMP probe has failed.":"vSBC-Metaswitch: An interface ICMP probe has failed.","A High-Availability link has detected a connectivity issue.":"vSBC-Metaswitch: A High-Availability link has detected a connectivity issue.","An HA-link device is being reported as underspeed.":"vSBC-Metaswitch: An HA-link device is being reported as underspeed.","An IP address conflict has been detected on a replication interface.":"vSBC-Metaswitch: An IP address conflict has been detected on a replication interface.","The Session Controller has started.":"vSBC-Metaswitch: The Session Controller has started.","A statistic exceeded its configured thresholds.":"vSBC-Metaswitch: A statistic exceeded its configured thresholds.","One or more statistic has not been retrieved at least 3 times in a row.":"vSBC-Metaswitch: One or more statistic has not been retrieved at least 3 times in a row.","A Refresh Alarms request was triggered. Alarms not re-raised will be cleared in 5 minutes.":"vSBC-Metaswitch: A Refresh Alarms request was triggered. Alarms not re-raised will be cleared in 5 minutes.","A statistic has exceeded its configured thresholds.":"vSBC-Metaswitch: A statistic has exceeded its configured thresholds.","A Fallback Operation will soon be started":"vSBG: A Fallback Operation will soon be started","BRM, Auto Export Backup Failed":"vSBG: BRM, Auto Export Backup Failed","BRM, Scheduled Backup Failed":"vSBG: BRM, Scheduled Backup Failed","COM SA, AMF Component Cleanup Failed":"vSBG: COM SA, AMF Component Cleanup Failed","COM SA, AMF Component Instantiation Failed":"vSBG: COM SA, AMF Component Instantiation Failed","COM SA, AMF SI Unassigned":"vSBG: COM SA, AMF SI Unassigned","COM SA, CLM Cluster Node Unavailable":"vSBG: COM SA, CLM Cluster Node Unavailable","COM SA, MDF Detected Model Error":"vSBG: COM SA, MDF Detected Model Error","COM SA, Proxy Status of a Component Changed to Unproxied":"vSBG: COM SA, Proxy Status of a Component Changed to Unproxied","File Management, Number of Files in FileGroup Exceeded":"vSBG: File Management, Number of Files in FileGroup Exceeded","File Management, Max Size in FileGroup Exceeded":"vSBG: File Management, Max Size in FileGroup Exceeded","LOTC Disk Replication Communication":"vSBG: LOTC Disk Replication Communication","LOTC Disk Replication Consistency":"vSBG: LOTC Disk Replication Consistency","LOTC Disk Usage":"vSBG: LOTC Disk Usage","LOTC memory Usage":"vSBG: LOTC memory Usage","LOTC Time Synchronization":"vSBG: LOTC Time Synchronization","SBG, BGF Control Link Down":"vSBG: SBG, BGF Control Link Down","SBG, BGF Control Link Disabled":"vSBG: SBG, BGF Control Link Disabled","SBG, BGF Control Link Enabled":"vSBG: SBG, BGF Control Link Enabled","SBG, BGF Control Link Remote Locked":"vSBG: SBG, BGF Control Link Remote Locked","SBG, Charging Data Storage Maximum Records Reached":"vSBG: SBG, Charging Data Storage Maximum Records Reached","SBG, Charging Server Rejects Charging Data":"vSBG: SBG, Charging Server Rejects Charging Data","SBG, Excessive Packet Rate Detected ":"vSBG: SBG, Excessive Packet Rate Detected ","SBG, High Amount of Malformed Packets Received":"vSBG: SBG, High Amount of Malformed Packets Received","SBG, High Amount of STUN Packets Detected":"vSBG: SBG, High Amount of STUN Packets Detected","SBG, High Amount of TCP SYN Packets Received":"vSBG: SBG, High Amount of TCP SYN Packets Received","SBG, High Amount of UDP Packets Received ":"vSBG: SBG, High Amount of UDP Packets Received ","SBG, IP Address Blocked Due to Excessive Packet Rate":"vSBG: SBG, IP Address Blocked Due to Excessive Packet Rate","SBG, Lost Connectivity to Diameter Server":"vSBG: SBG, Lost Connectivity to Diameter Server","SBG, Mated Pair out of Service":"vSBG: SBG, Mated Pair out of Service","SBG, Network Unavailable for Media Handling":"vSBG: SBG, Network Unavailable for Media Handling","SBG, Non-emergency Call Released to Free Resources for Emergency Call":"vSBG: SBG, Non-emergency Call Released to Free Resources for Emergency Call","SBG, Not Enough Disk Space for Storing Charging Data":"vSBG: SBG, Not Enough Disk Space for Storing Charging Data","SBG, Payload Mated Pair Failure":"vSBG: SBG, Payload Mated Pair Failure","SBG, Payload Processor Failure":"vSBG: SBG, Payload Processor Failure","SBG, Processor Overloaded":"vSBG: SBG, Processor Overloaded","SBG, Registered User Set in Quarantine":"vSBG: SBG, Registered User Set in Quarantine","SBG, Registration Contacts Exceed Configured Threshold":"vSBG: SBG, Registration Contacts Exceed Configured Threshold","SBG, Sequential Restart Initiated":"vSBG: SBG, Sequential Restart Initiated","SBG, SIP Abuse Detected":"vSBG: SBG, SIP Abuse Detected","SBG, SIP Network Locked":"vSBG: SBG, SIP Network Locked","SBG, SIP Next Hop Reachable":"vSBG: SBG, SIP Next Hop Reachable","SBG, SIP Next Hop Unreachable":"vSBG: SBG, SIP Next Hop Unreachable","SBG, SIP Request Rejected by Network Throttling":"vSBG: SBG, SIP Request Rejected by Network Throttling","SBG, TLS Certificate Imported":"vSBG: SBG, TLS Certificate Imported","SBG, Trace Recording Session Number Limit Reached":"vSBG: SBG, Trace Recording Session Number Limit Reached","SBG, Trace Session Deactivated":"vSBG: SBG, Trace Session Deactivated","SBG, Trace Session Times Out":"vSBG: SBG, Trace Session Times Out","SBG, Unknown Media Type or Payload Type":"vSBG: SBG, Unknown Media Type or Payload Type"} -# -# if action.test.override is true, then any action will be marked as test=true (even if incoming action request had test=false); otherwise, test flag will be unchanged on the action request -action.test.override=false -# if action.insert.test.event is true, then insert event even if the action is set to test -action.insert.test.event=false -CLDS_SERVICE_CACHE_MAX_SECONDS=5 - -#DCAE Inventory Url Properties +sdc.serviceUsername=test +sdc.servicePassword=123456 +sdc.artifactLabel=blueprintclampcockpit +sdc.sdcX-InstanceID=CLAMP +sdc.artifactType=DCAE_INVENTORY_BLUEPRINT +sdc.locationArtifactLabel=locationclampcockpit +sdc.locationArtifactType=DCAE_INVENTORY_JSON +sdc.InstanceID=X-ECOMP-InstanceID +# +# +# +ui.location.default={"SNDGCA64":"San Diego SAN3","ALPRGAED":"Alpharetta PDK1","LSLEILAA":"Lisle DPA3","MDTWNJC1":"FTL_C_location1","MDTWNJC2":"FTL_C_location2","MDTWNJ21":"FTL_L_location1","MDTWNJ22":"FTL_L_location2","RDM2WAGPLCP":"ISTFTL_location"} +ui.alarm.default={"Reports a transient alarm condition when an incoming CDR cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming CDR cannot be decoded successfully","Reports a transient alarm condition when an incoming ACR message cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming ACR message cannot be decoded successfully","Reports a transient alarm condition when a CDR validation fails":"vCCF: Reports a transient alarm condition when a CDR validation fails","Reports a transient alarm condition when an incoming GTP' message cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming GTP' message cannot be decoded successfully","Reports a transient alarm condition when an incoming CDR file cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming CDR file cannot be decoded successfully","Reports a transient alarm condition when an incoming Sh/Dh file cannot be decoded successfully":"vCCF: Reports a transient alarm condition when an incoming Sh/Dh file cannot be decoded successfully","Reports a transient alarm condition when an incoming ACR message is in conflict with former ACR in one diameter session":"vCCF: Reports a transient alarm condition when an incoming ACR message is in conflict with former ACR in one diameter session","Reports a transient alarm condition when an outgoing Ro message send fails":"vCCF: Reports a transient alarm condition when an outgoing Ro message send fails","Reports a transient alarm condition when an outgoing GTP' message send fails":"vCCF: Reports a transient alarm condition when an outgoing GTP' message send fails","Reports a transient alarm condition when an outgoing Sh/Dh message send fails":"vCCF: Reports a transient alarm condition when an outgoing Sh/Dh message send fails","Reports an alarm when build or send Rf message fail":"vCCF: Reports an alarm when build or send Rf message fail","Reports a transient alarm condition when an abnormal incoming CCA message":"vCCF: Reports a transient alarm condition when an abnormal incoming CCA message","Reports a transient alarm condition when there is an abnormal incoming Sh/Dh message":"vCCF: Reports a transient alarm condition when there is an abnormal incoming Sh/Dh message","For Rf interface, if IeCCF receives a message with incorrect value for session id.":"vCCF: For Rf interface, if IeCCF receives a message with incorrect value for session id.","Reports an alarm when CPU usage exceeds the major threshold, the local database exceeds the critical threshold, or the ACR partition exceeds the major threshold":"vCCF: Reports an alarm when CPU usage exceeds the major threshold, the local database exceeds the critical threshold, or the ACR partition exceeds the major threshold","Reports an alarm when CPU usage exceeds the minor threshold, the local database exceeds the major threshold, or the ACR partition exceeds the minor threshold":"vCCF: Reports an alarm when CPU usage exceeds the minor threshold, the local database exceeds the major threshold, or the ACR partition exceeds the minor threshold","Reports an alarm when CPU usage exceeds the critical threshold, the local database exceeds the major threshold, or the CDR partition exceeds the critical threshold":"vCCF: Reports an alarm when CPU usage exceeds the critical threshold, the local database exceeds the major threshold, or the CDR partition exceeds the critical threshold","Reports an alarm when CPU usage exceeds the major threshold or CDR partition exceeds the major threshold":"vCCF: Reports an alarm when CPU usage exceeds the major threshold or CDR partition exceeds the major threshold","Reports an alarm when external DB usage exceeds the major threshold":"vCCF: Reports an alarm when external DB usage exceeds the major threshold","If IeCCF comes to the status \\"Stop processing ACR records in ACRDB\\".":"vCCF: If IeCCF comes to the status \\"Stop processing ACR records in ACRDB\\".","If IeCCF comes to the status \\"Flush ACR is invoked\\".":"vCCF: If IeCCF comes to the status \\"Flush ACR is invoked\\".","Reports a transient alarm condition when the workflow definition table is provisioned wrongly":"vCCF: Reports a transient alarm condition when the workflow definition table is provisioned wrongly","Reports a transient alarm condition when the Action Definition table is provisioned wrongly":"vCCF: Reports a transient alarm condition when the Action Definition table is provisioned wrongly","Reports a transient alarm condition when the Ro Host Configuration is provisioned wrongly":"vCCF: Reports a transient alarm condition when the Ro Host Configuration is provisioned wrongly","Reports a transient alarm condition when the Sh Host Configuration is provisioned wrongly":"vCCF: Reports a transient alarm condition when the Sh Host Configuration is provisioned wrongly","Reports a transient alarm condition when a specific dictionary or rule does not exist":"vCCF: Reports a transient alarm condition when a specific dictionary or rule does not exist","Reports a transient alarm condition when failure occurs when mapping Rf message to XDR":"vCCF: Reports a transient alarm condition when failure occurs when mapping Rf message to XDR","Reports a transient alarm condition when failure occurs in aggregating process":"vCCF: Reports a transient alarm condition when failure occurs in aggregating process","Reports a transient alarm condition when failure happens in correlating process":"vCCF: Reports a transient alarm condition when failure happens in correlating process","Reports a transient alarm condition when failure occurs in generating CDR":"vCCF: Reports a transient alarm condition when failure occurs in generating CDR","Reports a transient alarm condition when failure occurs in constructing CCR message from XDR":"vCCF: Reports a transient alarm condition when failure occurs in constructing CCR message from XDR","Reports a transient alarm condition when an ACR/XER/BER/INC record write to bad file":"vCCF: Reports a transient alarm condition when an ACR/XER/BER/INC record write to bad file","Reports an alarm condition when aggregation or correlation central database connection is lost":"vCCF: Reports an alarm condition when aggregation or correlation central database connection is lost","Reports an alarm condition when a specific failure happens in database operations":"vCCF: Reports an alarm condition when a specific failure happens in database operations","Reports an alarm condition when DB capacity has been consumed to critical threshold":"vCCF: Reports an alarm condition when DB capacity has been consumed to critical threshold","Reports an alarm condition when DB capacity has been consumed to major threshold":"vCCF: Reports an alarm condition when DB capacity has been consumed to major threshold","Reports an alarm condition when DB capacity has been consumed to minor threshold.":"vCCF: Reports an alarm condition when DB capacity has been consumed to minor threshold.","Reports an alarm condition when application cannot deliver CDR to CDRSCH subsystem":"vCCF: Reports an alarm condition when application cannot deliver CDR to CDRSCH subsystem","Reports an alarm condition when some fields of ACR file header have error value and this ACR file cannot be processed further":"vCCF: Reports an alarm condition when some fields of ACR file header have error value and this ACR file cannot be processed further","Reports an alarm condition when some fields of ACR file header have invalid value and this ACR file can be processed further":"vCCF: Reports an alarm condition when some fields of ACR file header have invalid value and this ACR file can be processed further","Reports an alarm condition when the ACR file loses some ACR records":"vCCF: Reports an alarm condition when the ACR file loses some ACR records","Reports an alarm condition when some fields of ACR record header have error value and this ACR record and the following ACR records cannot be processed further":"vCCF: Reports an alarm condition when some fields of ACR record header have error value and this ACR record and the following ACR records cannot be processed further","Reports an alarm condition when error occurs in processing CDR/ACR files":"vCCF: Reports an alarm condition when error occurs in processing CDR/ACR files","Reports an alarm condition when CDR partition has been consumed to critical threshold":"vCCF: Reports an alarm condition when CDR partition has been consumed to critical threshold","Reports an alarm condition when CDR partition has been consumed to major threshold.":"vCCF: Reports an alarm condition when CDR partition has been consumed to major threshold.","Reports an alarm condition when CDR partition has been consumed to minor threshold":"vCCF: Reports an alarm condition when CDR partition has been consumed to minor threshold","Reports an alarm condition when ACR partition has been consumed to critical threshold":"vCCF: Reports an alarm condition when ACR partition has been consumed to critical threshold","Reports an alarm condition when ACR partition has been consumed to major threshold":"vCCF: Reports an alarm condition when ACR partition has been consumed to major threshold","Reports an alarm condition when ACR partition has been consumed to minor threshold":"vCCF: Reports an alarm condition when ACR partition has been consumed to minor threshold","Reports an alarm condition when CPU consumption reaches critical threshold":"vCCF: Reports an alarm condition when CPU consumption reaches critical threshold","Reports an alarm condition when CPU consumption reaches major threshold":"vCCF: Reports an alarm condition when CPU consumption reaches major threshold","Reports an alarm condition when CPU consumption reaches minor threshold":"vCCF: Reports an alarm condition when CPU consumption reaches minor threshold","Service shall monitor * number of partial CDR * number of incompleted CDR * number of unacceptable CDR If any one exceeds a configurable threshold in a configrable interval.":"vCCF: Service shall monitor * number of partial CDR * number of incompleted CDR * number of unacceptable CDR If any one exceeds a configurable threshold in a configrable interval.","CDR size exceed the platform capacity.":"vCCF: CDR size exceed the platform capacity.","Service shall monitor number of ACR without AII AVP, If it exceeds a configurable threshold in a configurable interval.":"vCCF: Service shall monitor number of ACR without AII AVP, If it exceeds a configurable threshold in a configurable interval.","Service shall monitor CDR cut due to ECCF_ACRNUMBER_IN_DB, If it exceeds a configurable threshold in a configurable interval.":"vCCF: Service shall monitor CDR cut due to ECCF_ACRNUMBER_IN_DB, If it exceeds a configurable threshold in a configurable interval.","External Node of this Cluster is overload":"vCCF: External Node of this Cluster is overload","bdb_high_latency":"vCCF-vDB: bdb_high_latency","bdb_high_throughput":"vCCF-vDB: bdb_high_throughput","bdb_size":"vCCF-vDB: bdb_size","cluster_inconsistent_rl_sw":"vCCF-vDB: cluster_inconsistent_rl_sw","cluster_node_remove_abort_failed":"vCCF-vDB: cluster_node_remove_abort_failed","cluster_node_remove_failed":"vCCF-vDB: cluster_node_remove_failed","cluster_ram_overcommit":"vCCF-vDB: cluster_ram_overcommit","cluster_rebalance_failed":"vCCF-vDB: cluster_rebalance_failed","cluster_too_few_nodes_for_replication":"vCCF-vDB: cluster_too_few_nodes_for_replication","node_cpu_utilization":"vCCF-vDB: node_cpu_utilization","node_ephemeral_storage":"vCCF-vDB: node_ephemeral_storage","node_failed":"vCCF-vDB: node_failed","node_memory":"vCCF-vDB: node_memory","node_net_throughput":"vCCF-vDB: node_net_throughput","node_offline_failed":"vCCF-vDB: node_offline_failed","node_offline_abort_failed":"vCCF-vDB: node_offline_abort_failed","node_online_failed":"vCCF-vDB: node_online_failed","OAM NODE- IS NOT ACTIVE ":"vCCF-vDB: OAM NODE- IS NOT ACTIVE ","LSS_asdaCommunicationFailure":"vCTS: LSS_asdaCommunicationFailure","LSS_ccdbCommunicationFailure":"vCTS: LSS_ccdbCommunicationFailure","LSS_cpiCTS3xxFailRate":"vCTS: LSS_cpiCTS3xxFailRate","LSS_cpiCTS4xxFailRate":"vCTS: LSS_cpiCTS4xxFailRate","LSS_cpiCTS5xxFailRate":"vCTS: LSS_cpiCTS5xxFailRate","LSS_cpiCTS6xxFailRate":"vCTS: LSS_cpiCTS6xxFailRate","LSS_cpiCTSSIPRetransmitInvite":"vCTS: LSS_cpiCTSSIPRetransmitInvite","LSS_cpiCTSSIPRetransmitNonInvite":"vCTS: LSS_cpiCTSSIPRetransmitNonInvite","LSS_glsInvalidCellId":"vCTS: LSS_glsInvalidCellId","LSS_glsServerUnavailable":"vCTS: LSS_glsServerUnavailable","LSS_hlrSyncConnection":"vCTS: LSS_hlrSyncConnection","LSS_hlrSyncQueue":"vCTS: LSS_hlrSyncQueue","LSS_lispBufferFullExternalLIG":"vCTS: LSS_lispBufferFullExternalLIG","LSS_prdbConnectWithAlternateFailure":"vCTS: LSS_prdbConnectWithAlternateFailure","LSS_prdbSyncDataToAlternateFailure":"vCTS: LSS_prdbSyncDataToAlternateFailure","LSS_preAllocatedResourceOverload":"vCTS: LSS_preAllocatedResourceOverload","LSS_prifSocketError":"vCTS: LSS_prifSocketError","LSS_prsCallInstanceExceeded":"vCTS: LSS_prsCallInstanceExceeded","LSS_prsCpuOverload":"vCTS: LSS_prsCpuOverload","LSS_prsDatabaseMigrationFailure":"vCTS: LSS_prsDatabaseMigrationFailure","LSS_prsFailureToConnectWithPRDB":"vCTS: LSS_prsFailureToConnectWithPRDB","LSS_prsQueueExceeded":"vCTS: LSS_prsQueueExceeded","LSS_smdiSocketError":"vCTS: LSS_smdiSocketError","LSS_socketError":"vCTS: LSS_socketError","LSS_softwareComponentDown":"vCTS: LSS_softwareComponentDown","LSS_tlsInitError":"vCTS: LSS_tlsInitError","LSS_usageOfSyncTable":"vCTS: LSS_usageOfSyncTable","LSS_utHttpProxyConnectionDown ":"vCTS: LSS_utHttpProxyConnectionDown ","LSS_wpifSocketError":"vCTS: LSS_wpifSocketError","LSS_acrTemporaryBufferOverload":"vCTS: LSS_acrTemporaryBufferOverload","LSS_adnsExtendedTTLcaching":"vCTS: LSS_adnsExtendedTTLcaching","LSS_adnsQueryFailureCaching":"vCTS: LSS_adnsQueryFailureCaching","LSS_adnsQueueCongestion":"vCTS: LSS_adnsQueueCongestion","LSS_asdaRequestQueue":"vCTS: LSS_asdaRequestQueue","LSS_capacityLicenseKeyExpiration":"vCTS: LSS_capacityLicenseKeyExpiration","LSS_capacityLicenseKeyNearExpiration":"vCTS: LSS_capacityLicenseKeyNearExpiration","LSS_capacityLicenseKeyValidationError":"vCTS: LSS_capacityLicenseKeyValidationError","LSS_cardConnectionLost":"vCTS: LSS_cardConnectionLost","LSS_cpiAlrmCritical":"vCTS: LSS_cpiAlrmCritical","LSS_cpiAlrmMajor":"vCTS: LSS_cpiAlrmMajor","LSS_cpiAlrmMinor":"vCTS: LSS_cpiAlrmMinor","LSS_cpiAlrmWarning":"vCTS: LSS_cpiAlrmWarning","LSS_cpiAsrtEsc":"vCTS: LSS_cpiAsrtEsc","LSS_cpiAsrtNonEsc":"vCTS: LSS_cpiAsrtNonEsc","LSS_cpiAsrtNonEscCritical":"vCTS: LSS_cpiAsrtNonEscCritical","LSS_cpiAsrtNonEscMajor":"vCTS: LSS_cpiAsrtNonEscMajor","LSS_cpiAsrtNonEscMinor":"vCTS: LSS_cpiAsrtNonEscMinor","LSS_cpiAudErrCount":"vCTS: LSS_cpiAudErrCount","LSS_cpiAudManAct":"vCTS: LSS_cpiAudManAct","LSS_cpiAudNewEvent":"vCTS: LSS_cpiAudNewEvent","LSS_cpiCompleteRateAlarm":"vCTS: LSS_cpiCompleteRateAlarm","LSS_cpiDropMGAllocConnReq":"vCTS: LSS_cpiDropMGAllocConnReq","LSS_cpiDropRateAlarm":"vCTS: LSS_cpiDropRateAlarm","LSS_cpiExceptionService":"vCTS: LSS_cpiExceptionService","LSS_cpiFailRateAlarm":"vCTS: LSS_cpiFailRateAlarm","LSS_cpiFailSCTPFastRetransIncr":"vCTS: LSS_cpiFailSCTPFastRetransIncr","LSS_cpiFailSCTPFastRetransRate":"vCTS: LSS_cpiFailSCTPFastRetransRate","LSS_cpiFailSCTPSRTT1Incr":"vCTS: LSS_cpiFailSCTPSRTT1Incr","LSS_cpiFailSCTPSRTT2Incr":"vCTS: LSS_cpiFailSCTPSRTT2Incr","LSS_cpiFailSCTPT3RetransIncr":"vCTS: LSS_cpiFailSCTPT3RetransIncr","LSS_cpiFailSCTPT3RetransRate":"vCTS: LSS_cpiFailSCTPT3RetransRate","LSS_cpiFileSysUsage":"vCTS: LSS_cpiFileSysUsage","LSS_cpiMemAllocFail":"vCTS: LSS_cpiMemAllocFail","LSS_cpiNumOfLICDRDel":"vCTS: LSS_cpiNumOfLICDRDel","LSS_cpiReinitServiceSelf":"vCTS: LSS_cpiReinitServiceSelf","LSS_cpiSIPRetransmitInvite":"vCTS: LSS_cpiSIPRetransmitInvite","LSS_cpiSIPRetransmitNonInvite":"vCTS: LSS_cpiSIPRetransmitNonInvite","LSS_cpiSS7DropSCTPPktsRcvd":"vCTS: LSS_cpiSS7DropSCTPPktsRcvd","LSS_cpiSS7FailSCTPFastRetransRate":"vCTS: LSS_cpiSS7FailSCTPFastRetransRate","LSS_cpiStabilityAlarm":"vCTS: LSS_cpiStabilityAlarm","LSS_cpuOverload":"vCTS: LSS_cpuOverload","LSS_databaseConnectionLost":"vCTS: LSS_databaseConnectionLost","LSS_databaseReplicationLinkDown":"vCTS: LSS_databaseReplicationLinkDown","LSS_databaseSizeExhausted":"vCTS: LSS_databaseSizeExhausted","LSS_dbHighCpuUtilization":"vCTS: LSS_dbHighCpuUtilization","LSS_dbOffline":"vCTS: LSS_dbOffline","LSS_dbStatusUnexpected":"vCTS: LSS_dbStatusUnexpected","LSS_degradedResource":"vCTS: LSS_degradedResource","LSS_degrow":"vCTS: LSS_degrow","LSS_deviceServerCxnLost":"vCTS: LSS_deviceServerCxnLost","LSS_diamLinkDown":"vCTS: LSS_diamLinkDown","LSS_diamMaxClientsExceeded":"vCTS: LSS_diamMaxClientsExceeded","LSS_dnsThreshold":"vCTS: LSS_dnsThreshold","LSS_ethernetError":"vCTS: LSS_ethernetError","LSS_ethernetLinkDown":"vCTS: LSS_ethernetLinkDown","LSS_externalConnectivity":"vCTS: LSS_externalConnectivity","LSS_featureLicenseExpiration":"vCTS: LSS_featureLicenseExpiration","LSS_featureLicenseKeyNearExpiration":"vCTS: LSS_featureLicenseKeyNearExpiration","LSS_featureLockValidationError":"vCTS: LSS_featureLockValidationError","LSS_fqdnError":"vCTS: LSS_fqdnError","LSS_fru":"vCTS: LSS_fru","LSS_gatewayCongestion":"vCTS: LSS_gatewayCongestion","LSS_gatewayForcedOOS":"vCTS: LSS_gatewayForcedOOS","LSS_gatewayProvisioningError":"vCTS: LSS_gatewayProvisioningError","LSS_gatewayUnreachable":"vCTS: LSS_gatewayUnreachable","LSS_gatewayUnregistered":"vCTS: LSS_gatewayUnregistered","LSS_globalParameterNotFound":"vCTS: LSS_globalParameterNotFound","LSS_grow":"vCTS: LSS_grow","LSS_h248MessageBufferDepletion":"vCTS: LSS_h248MessageBufferDepletion","LSS_hostDown":"vCTS: LSS_hostDown","LSS_hostReset":"vCTS: LSS_hostReset","LSS_invalidGateway":"vCTS: LSS_invalidGateway","LSS_iriLinkDown":"vCTS: LSS_iriLinkDown","LSS_ldapServerConnectionLost":"vCTS: LSS_ldapServerConnectionLost","LSS_llcDown":"vCTS: LSS_llcDown","LSS_logicalLinkDown":"vCTS: LSS_logicalLinkDown","LSS_logicalLinkNotFound":"vCTS: LSS_logicalLinkNotFound","LSS_logRotateThreshold":"vCTS: LSS_logRotateThreshold","LSS_memoryOverload":"vCTS: LSS_memoryOverload","LSS_nodeConfigFailure":"vCTS: LSS_nodeConfigFailure","LSS_nodeGroupOOS":"vCTS: LSS_nodeGroupOOS","LSS_nodeOOS":"vCTS: LSS_nodeOOS","LSS_nonCompliantFaultGroupMemberState":"vCTS: LSS_nonCompliantFaultGroupMemberState","LSS_nonCsAddrChannelDepletion":"vCTS: LSS_nonCsAddrChannelDepletion","LSS_numberOfTuplesInUse":"vCTS: LSS_numberOfTuplesInUse","LSS_osSecInfoModificationDetected":"vCTS: LSS_osSecInfoModificationDetected","LSS_osSecInformationMissing":"vCTS: LSS_osSecInformationMissing","LSS_osSecUnexpectedInformation":"vCTS: LSS_osSecUnexpectedInformation","LSS_pdnsMySqlReplication":"vCTS: LSS_pdnsMySqlReplication","LSS_pktCorruptionDetectedViaRCCLANCheck":"vCTS: LSS_pktCorruptionDetectedViaRCCLANCheck","LSS_platformCommandFailure":"vCTS: LSS_platformCommandFailure","LSS_pmDataNotCollected":"vCTS: LSS_pmDataNotCollected","LSS_processDown":"vCTS: LSS_processDown","LSS_processNotStarted":"vCTS: LSS_processNotStarted","LSS_provisioningInhibitedMode":"vCTS: LSS_provisioningInhibitedMode","LSS_rccInhibitedMode":"vCTS: LSS_rccInhibitedMode","LSS_remotedbLinkDown":"vCTS: LSS_remotedbLinkDown","LSS_remoteQueryServerFailure":"vCTS: LSS_remoteQueryServerFailure","LSS_restore":"vCTS: LSS_restore","LSS_serviceCFGDataTimestampError":"vCTS: LSS_serviceCFGDataTimestampError","LSS_serviceCommCxnLost":"vCTS: LSS_serviceCommCxnLost","LSS_serviceOnewayCommunication":"vCTS: LSS_serviceOnewayCommunication","LSS_sheddingOverload":"vCTS: LSS_sheddingOverload","LSS_simxml":"vCTS: LSS_simxml","LSS_sipLinkSetMaxQuarantineList":"vCTS: LSS_sipLinkSetMaxQuarantineList","LSS_sipLinkSetUnavailable":"vCTS: LSS_sipLinkSetUnavailable","LSS_sipLinkUnavailable":"vCTS: LSS_sipLinkUnavailable","LSS_softwareAllocatedResourceOverload":"vCTS: LSS_softwareAllocatedResourceOverload","LSS_softwareComponentStandbyNotReady":"vCTS: LSS_softwareComponentStandbyNotReady","LSS_softwareLicense":"vCTS: LSS_softwareLicense","LSS_svcdegrow":"vCTS: LSS_svcdegrow","LSS_svcgrow":"vCTS: LSS_svcgrow","LSS_swVersionMismatch":"vCTS: LSS_swVersionMismatch","LSS_tftpDownloadCorrupt":"vCTS: LSS_tftpDownloadCorrupt","LSS_timeStampValueOutOfSystemRange":"vCTS: LSS_timeStampValueOutOfSystemRange","LSS_transactionHandlerBlockDepletion":"vCTS: LSS_transactionHandlerBlockDepletion","LSS_upgrade":"vCTS: LSS_upgrade","SYS_BackupFailure":"vCTS: SYS_BackupFailure","SYS_Configuration":"vCTS: SYS_Configuration","SYS_COTRecordTransferFailure":"vCTS: SYS_COTRecordTransferFailure","SYS_CPM_USERDATA_INCONSITENCY":"vCTS: SYS_CPM_USERDATA_INCONSITENCY","SYS_CPM_USERDATA_RESTORED":"vCTS: SYS_CPM_USERDATA_RESTORED","SYS_EventQueueCapacity":"vCTS: SYS_EventQueueCapacity","SYS_ICMPFailure":"vCTS: SYS_ICMPFailure","SYS_IPsecConfig":"vCTS: SYS_IPsecConfig","SYS_LinkDown":"vCTS: SYS_LinkDown","SYS_NotifyDisabled":"vCTS: SYS_NotifyDisabled","SYS_NotifyLocked":"vCTS: SYS_NotifyLocked","SYS_NumTL1MeasThresh":"vCTS: SYS_NumTL1MeasThresh","SYS_RADIUS_TO_LDAP_FAILURE":"vCTS: SYS_RADIUS_TO_LDAP_FAILURE","SYS_ROOT_ACCESS_DENIED":"vCTS: SYS_ROOT_ACCESS_DENIED","SYS_ROOT_FTP_VIOLATION":"vCTS: SYS_ROOT_FTP_VIOLATION","SYS_ROOT_LOGIN_VIOLATION":"vCTS: SYS_ROOT_LOGIN_VIOLATION","SYS_ROOT_SSH_LOGIN_VIOLATION":"vCTS: SYS_ROOT_SSH_LOGIN_VIOLATION","SYS_SetupAAAFailure":"vCTS: SYS_SetupAAAFailure","SYS_SNETrapOverload":"vCTS: SYS_SNETrapOverload","SYS_SNMPAuthenticationFailure":"vCTS: SYS_SNMPAuthenticationFailure","SYS_SNMPFailure":"vCTS: SYS_SNMPFailure","SYS_SU_TO_ROOT_FAILURE":"vCTS: SYS_SU_TO_ROOT_FAILURE","SYS_SYSTEMTrapOverload":"vCTS: SYS_SYSTEMTrapOverload","SYS_ThresholdCrossed":"vCTS: SYS_ThresholdCrossed","SYS_UndiscoveredObject":"vCTS: SYS_UndiscoveredObject","SYS_WriteAAAFailure":"vCTS: SYS_WriteAAAFailure","jnxSpaceDiskUsageRising":"vDBE-EMS-Juniper: jnxSpaceDiskUsageRising","jnxSpaceDiskUsageRisingCleared":"vDBE-EMS-Juniper: jnxSpaceDiskUsageRisingCleared","jnxSpaceSwapUsageRising":"vDBE-EMS-Juniper: jnxSpaceSwapUsageRising","jnxSpaceSwapUsageRisingCleared":"vDBE-EMS-Juniper: jnxSpaceSwapUsageRisingCleared","jnxSpaceCPULARising":"vDBE-EMS-Juniper: jnxSpaceCPULARising","jnxSpaceCPULARisingCleared":"vDBE-EMS-Juniper: jnxSpaceCPULARisingCleared","jnxSpaceWebpProxyProcessDown":"vDBE-EMS-Juniper: jnxSpaceWebpProxyProcessDown","jnxSpaceWebpProxyProcessUp":"vDBE-EMS-Juniper: jnxSpaceWebpProxyProcessUp","jnxSpaceNMAProcessDown":"vDBE-EMS-Juniper: jnxSpaceNMAProcessDown","jnxSpaceNMAProcessUp":"vDBE-EMS-Juniper: jnxSpaceNMAProcessUp","jnxSpaceJbossProcessDown":"vDBE-EMS-Juniper: jnxSpaceJbossProcessDown","jnxSpaceJbossProcessUp":"vDBE-EMS-Juniper: jnxSpaceJbossProcessUp","jnxSpaceMysqlProcessDown":"vDBE-EMS-Juniper: jnxSpaceMysqlProcessDown","jnxSpaceMysqlProcessUp":"vDBE-EMS-Juniper: jnxSpaceMysqlProcessUp","jnxSpacePostgresqlProcessDown":"vDBE-EMS-Juniper: jnxSpacePostgresqlProcessDown","jnxSpacePostgresqlProcessUp":"vDBE-EMS-Juniper: jnxSpacePostgresqlProcessUp","jnxSpaceWatchdogStopped":"vDBE-EMS-Juniper: jnxSpaceWatchdogStopped","jnxSpaceWatchdogStarted":"vDBE-EMS-Juniper: jnxSpaceWatchdogStarted","jnxSpaceSNAProcessDown":"vDBE-EMS-Juniper: jnxSpaceSNAProcessDown","jnxSpaceSNAProcessUp":"vDBE-EMS-Juniper: jnxSpaceSNAProcessUp","jnxSpaceNodeDown":"vDBE-EMS-Juniper: jnxSpaceNodeDown","jnxSpaceNodeUp":"vDBE-EMS-Juniper: jnxSpaceNodeUp"," jnxSpaceNodeRemoval":"vDBE-EMS-Juniper: jnxSpaceNodeRemoval","jnxCmCfgChange":"vDBE-Juniper: jnxCmCfgChange","jnxCmRescueChange":"vDBE-Juniper: jnxCmRescueChange","jnxEventTrap":"vDBE-Juniper: jnxEventTrap","jnxJsFwAuthFailure":"vDBE-Juniper: jnxJsFwAuthFailure","jnxJsFwAuthServiceUp":"vDBE-Juniper: jnxJsFwAuthServiceUp","jnxJsFwAuthServiceDown":"vDBE-Juniper: jnxJsFwAuthServiceDown","jnxJsFwAuthCapacityExceeded":"vDBE-Juniper: jnxJsFwAuthCapacityExceeded","jnxJsIdpSignatureUpdate":"vDBE-Juniper: jnxJsIdpSignatureUpdate","jnxJsIdpAttackLog":"vDBE-Juniper: jnxJsIdpAttackLog","jnxJsSrcNatPoolThresholdStatus":"vDBE-Juniper: jnxJsSrcNatPoolThresholdStatus","jnxJsNatRuleThresholdStatus":"vDBE-Juniper: jnxJsNatRuleThresholdStatus","jnxJsScreenAttack":"vDBE-Juniper: jnxJsScreenAttack","jnxJsScreenCfgChange":"vDBE-Juniper: jnxJsScreenCfgChange","jnxJsAvPatternUpdateTrap":"vDBE-Juniper: jnxJsAvPatternUpdateTrap","jnxJsChassisClusterSwitchover":"vDBE-Juniper: jnxJsChassisClusterSwitchover","jnxJsChClusterIntfTrap":"vDBE-Juniper: jnxJsChClusterIntfTrap","jnxJsChClusterSpuMismatchTrap":"vDBE-Juniper: jnxJsChClusterSpuMismatchTrap","jnxJsChClusterWeightTrap":"vDBE-Juniper: jnxJsChClusterWeightTrap","jnxLicenseGraceExpired":"vDBE-Juniper: jnxLicenseGraceExpired","jnxLicenseGraceAboutToExpire":"vDBE-Juniper: jnxLicenseGraceAboutToExpire","jnxLicenseAboutToExpire":"vDBE-Juniper: jnxLicenseAboutToExpire","jnxLicenseInfringeCumulative":"vDBE-Juniper: jnxLicenseInfringeCumulative","jnxLicenseInfringeSingle":"vDBE-Juniper: jnxLicenseInfringeSingle","jnxNatAddrPoolThresholdStatus":"vDBE-Juniper: jnxNatAddrPoolThresholdStatus","jnxSyslogTrap":"vDBE-Juniper: jnxSyslogTrap","jnxAccessAuthServiceUp":"vDBE-Juniper: jnxAccessAuthServiceUp","jnxAccessAuthServiceDown":"vDBE-Juniper: jnxAccessAuthServiceDown","jnxAccessAuthServerDisabled":"vDBE-Juniper: jnxAccessAuthServerDisabled","jnxAccessAuthServerEnabled":"vDBE-Juniper: jnxAccessAuthServerEnabled","jnxAccessAuthAddressPoolHighThreshold":"vDBE-Juniper: jnxAccessAuthAddressPoolHighThreshold","jnxAccessAuthAddressPoolAbateThreshold":"vDBE-Juniper: jnxAccessAuthAddressPoolAbateThreshold","jnxAccessAuthAddressPoolOutOfAddresses":"vDBE-Juniper: jnxAccessAuthAddressPoolOutOfAddresses","jnxAccessAuthAddressPoolOutOfMemory":"vDBE-Juniper: jnxAccessAuthAddressPoolOutOfMemory","LEVEL_WARNING_CPU":"vMRF: LEVEL_WARNING_CPU","LEVEL_MAJOR_CPU":"vMRF: LEVEL_MAJOR_CPU","LEVEL_CRITICAL_CPU":"vMRF: LEVEL_CRITICAL_CPU","LEVEL_WARNING_MEM":"vMRF: LEVEL_WARNING_MEM","LEVEL_MAJOR_MEM":"vMRF: LEVEL_MAJOR_MEM","LEVEL_CRITICAL_MEM":"vMRF: LEVEL_CRITICAL_MEM","LEVEL_WARNING_DISK":"vMRF: LEVEL_WARNING_DISK","LEVEL_MAJOR_DISK":"vMRF: LEVEL_MAJOR_DISK","LEVEL_CRITICAL_DISK":"vMRF: LEVEL_CRITICAL_DISK","LEVEL_WARNING_RTPBANDWIDTH":"vMRF: LEVEL_WARNING_RTPBANDWIDTH","LEVEL_MAJOR_RTPBANDWIDTH":"vMRF: LEVEL_MAJOR_RTPBANDWIDTH","LEVEL_CRITICAL_RTPBANDWIDTH":"vMRF: LEVEL_CRITICAL_RTPBANDWIDTH","LEVEL_WARNING_RTPINPACKETLOSS":"vMRF: LEVEL_WARNING_RTPINPACKETLOSS","LEVEL_MAJOR_RTPINPACKETLOSS":"vMRF: LEVEL_MAJOR_RTPINPACKETLOSS","LEVEL_CRITICAL_RTPINPACKETLOSS":"vMRF: LEVEL_CRITICAL_RTPINPACKETLOSS","LEVEL_WARNING_RTPOUTPACKETLOSS":"vMRF: LEVEL_WARNING_RTPOUTPACKETLOSS","LEVEL_MAJOR_RTPOUTPACKETLOSS":"vMRF: LEVEL_MAJOR_RTPOUTPACKETLOSS","LEVEL_CRITICAL_RTPOUTPACKETLOSS":"vMRF: LEVEL_CRITICAL_RTPOUTPACKETLOSS","LEVEL_WARNING_TCPLOSTRETRANSMITRATE":"vMRF: LEVEL_WARNING_TCPLOSTRETRANSMITRATE","LEVEL_MAJOR_TCPLOSTRETRANSMITRATE":"vMRF: LEVEL_MAJOR_TCPLOSTRETRANSMITRATE","LEVEL_CRITICAL_TCPLOSTRETRANSMITRATE":"vMRF: LEVEL_CRITICAL_TCPLOSTRETRANSMITRATE","LEVEL_WARNING_TCPLOSSFAILURERATE":"vMRF: LEVEL_WARNING_TCPLOSSFAILURERATE","LEVEL_MAJOR_TCPLOSSFAILURERATE":"vMRF: LEVEL_MAJOR_TCPLOSSFAILURERATE","LEVEL_CRITICAL_TCPLOSSFAILURERATE":"vMRF: LEVEL_CRITICAL_TCPLOSSFAILURERATE","LEVEL_CRITICAL_RTPLINKDOWN":"vMRF: LEVEL_CRITICAL_RTPLINKDOWN","TARGET_REACHABLE":"vMRF: TARGET_REACHABLE","PUBLICATION_ERROR":"vMRF: PUBLICATION_ERROR","REMOTE_SERVER_SYNCHRONIZATION_ERROR":"vMRF: REMOTE_SERVER_SYNCHRONIZATION_ERROR","TRANSCODER_TOOL_EXEC_ERROR":"vMRF: TRANSCODER_TOOL_EXEC_ERROR","CLIENT_SYNCHRONIZATION_ERROR":"vMRF: CLIENT_SYNCHRONIZATION_ERROR","CLUSTER_UNREACHABLE":"vMRF: CLUSTER_UNREACHABLE","REMOTE_NODE_OFFLINE":"vMRF: REMOTE_NODE_OFFLINE","IPADDR_STOPPED":"vMRF: IPADDR_STOPPED","MRFC_STOPPED":"vMRF: MRFC_STOPPED","MNGT_STOPPED":"vMRF: MNGT_STOPPED","IPADDR_STARTED":"vMRF: IPADDR_STARTED","MRFC_STARTED":"vMRF: MRFC_STARTED","MNGT_STARTED":"vMRF: MNGT_STARTED","VOLATTACH_FAILED":"vMRF: VOLATTACH_FAILED","VOLDETACH_FAILED":"vMRF: VOLDETACH_FAILED","VOLDEL":"vMRF: VOLDEL","VOLCORRUPT":"vMRF: VOLCORRUPT","VOLFOREIGN":"vMRF: VOLFOREIGN","ACTIVE_ALARM_TABLE_PURGE":"vMRF: ACTIVE_ALARM_TABLE_PURGE","GENERIC_FORMER_STATELESS":"vMRF: GENERIC_FORMER_STATELESS","GENERIC_FORMER_STATEFUL":"vMRF: GENERIC_FORMER_STATEFUL","NO_MORE_ALARM_DESCRIPTION":"vMRF: NO_MORE_ALARM_DESCRIPTION","SERVICE_PROCESS_ENDS":"vMRF: SERVICE_PROCESS_ENDS","DEFENSE_STOPPED":"vMRF: DEFENSE_STOPPED","USER_ACCOUNT_LOCKED":"vMRF: USER_ACCOUNT_LOCKED","CONNECTION_SQL_NOT_ESTABLISHED":"vMRF: CONNECTION_SQL_NOT_ESTABLISHED","FALSE_ALARM":"vMRF: FALSE_ALARM","RADIUS SERVER HS":"vMRF: RADIUS SERVER HS","DRM_PACKAGER_IS_NOT_AVAILABLE":"vMRF: DRM_PACKAGER_IS_NOT_AVAILABLE","DRM_LICENSE_BUILDER_IS_NOT_AVAILABLE":"vMRF: DRM_LICENSE_BUILDER_IS_NOT_AVAILABLE","ERROR_WHILE_CREATING_PLAYLIST_MANAGER_FILE":"vMRF: ERROR_WHILE_CREATING_PLAYLIST_MANAGER_FILE","ERROR_WHILE_BUILDING_PLAYLIST_XML_REPRESENTATION":"vMRF: ERROR_WHILE_BUILDING_PLAYLIST_XML_REPRESENTATION","PLAYLIST_FILE_TO_PUBLISH_NOT_FOUND":"vMRF: PLAYLIST_FILE_TO_PUBLISH_NOT_FOUND","COULD_NOT_CONNECT_TO_PVNS_SERVER":"vMRF: COULD_NOT_CONNECT_TO_PVNS_SERVER","HTTP_OR_HTTPCLIENT_EXCEPTION_HAS_OCCURRED":"vMRF: HTTP_OR_HTTPCLIENT_EXCEPTION_HAS_OCCURRED","I/O_ERROR_WHILE_PUBLISHING_PLAYLIST_FILE":"vMRF: I/O_ERROR_WHILE_PUBLISHING_PLAYLIST_FILE","ERROR_WHILE_REQUESTING_SDP_FILE":"vMRF: ERROR_WHILE_REQUESTING_SDP_FILE","ERROR_WHILE_REQUESTING_SDP_FILE:_REMOTE_EXCEPTION":"vMRF: ERROR_WHILE_REQUESTING_SDP_FILE:_REMOTE_EXCEPTION","NO_STREAMING_RESOURCES":"vMRF: NO_STREAMING_RESOURCES","NO_STREAMING_MODULES_REGISTERED":"vMRF: NO_STREAMING_MODULES_REGISTERED","SM_FAILURE":"vMRF: SM_FAILURE","MISSING_FILE_OR_ENCODER":"vMRF: MISSING_FILE_OR_ENCODER","INVALID_RANGE":"vMRF: INVALID_RANGE","THRESHOLD_VALUE_EXCEEDED":"vMRF: THRESHOLD_VALUE_EXCEEDED","TICKET_QUEUE_FULL":"vMRF: TICKET_QUEUE_FULL","PARSING_INITIALIZATION_EXCEPTION":"vMRF: PARSING_INITIALIZATION_EXCEPTION","CUSTOMERCARE_INTERNAL_EXCEPTION":"vMRF: CUSTOMERCARE_INTERNAL_EXCEPTION","PARSING_EXCEPTION":"vMRF: PARSING_EXCEPTION","I/O_PROBLEM":"vMRF: I/O_PROBLEM","INEXISTENT_FILE_OR_FOLDER":"vMRF: INEXISTENT_FILE_OR_FOLDER","FILE_NOT_IN_XML_FORMAT":"vMRF: FILE_NOT_IN_XML_FORMAT","SERVICE_STATE_CHANGE":"vMRF: SERVICE_STATE_CHANGE","MONITORED_FILE_UPDATE_ERROR":"vMRF: MONITORED_FILE_UPDATE_ERROR","MONITORED_RPM_DELETED_ERROR":"vMRF: MONITORED_RPM_DELETED_ERROR","MONITORED_RPM_ADDED_ERROR":"vMRF: MONITORED_RPM_ADDED_ERROR","MONITORED_CHMOD_ERROR":"vMRF: MONITORED_CHMOD_ERROR","MONITORED_CHOWN_ERROR":"vMRF: MONITORED_CHOWN_ERROR","PASSWD_ROOT_ERROR":"vMRF: PASSWD_ROOT_ERROR","PASSWD_ERROR":"vMRF: PASSWD_ERROR","ROOTKIT_ERROR":"vMRF: ROOTKIT_ERROR","STARTUP_ERR_UNDEFINED_PORT":"vMRF: STARTUP_ERR_UNDEFINED_PORT","STARTUP_ERR_FAIL_FIND_HOSTNAME":"vMRF: STARTUP_ERR_FAIL_FIND_HOSTNAME","STARTUP_ERR_CF_MISSING":"vMRF: STARTUP_ERR_CF_MISSING","STARTUP_ERR_FAILED_TO_OPEN_CF":"vMRF: STARTUP_ERR_FAILED_TO_OPEN_CF","STARTUP_ERR_FAILED_TO_BIND_PORT":"vMRF: STARTUP_ERR_FAILED_TO_BIND_PORT","STARTUP_ERR_CFG_UNIT_MISSING":"vMRF: STARTUP_ERR_CFG_UNIT_MISSING","MCTR_INVALID_CODEC_NAME":"vMRF: MCTR_INVALID_CODEC_NAME","RTSP_SERVER_FAILURE":"vMRF: RTSP_SERVER_FAILURE","RTSP_SERVER_QUARANTINE":"vMRF: RTSP_SERVER_QUARANTINE","TRANSCODING_FAILURE":"vMRF: TRANSCODING_FAILURE","FILE_CACHE_FAILURE":"vMRF: FILE_CACHE_FAILURE","STARTUP_ERROR_INITIALIZATION_FAILED":"vMRF: STARTUP_ERROR_INITIALIZATION_FAILED","CONFERENCE_FAILURE":"vMRF: CONFERENCE_FAILURE","PLC_DEGRADATION_LOW":"vMRF: PLC_DEGRADATION_LOW","PLC_DEGRADATION_MEDIUM":"vMRF: PLC_DEGRADATION_MEDIUM","PLC_DEGRADATION_HIGH":"vMRF: PLC_DEGRADATION_HIGH","AUDIO_RESYNCH_LOW":"vMRF: AUDIO_RESYNCH_LOW","AUDIO_RESYNCH_MEDIUM":"vMRF: AUDIO_RESYNCH_MEDIUM","AUDIO_RESYNCH_HIGH":"vMRF: AUDIO_RESYNCH_HIGH","VIDEO_RESYNCH_LOW":"vMRF: VIDEO_RESYNCH_LOW","VIDEO_RESYNCH_MEDIUM":"vMRF: VIDEO_RESYNCH_MEDIUM","VIDEO_RESYNCH_HIGH":"vMRF: VIDEO_RESYNCH_HIGH","PLAY_FAILURES_LOW":"vMRF: PLAY_FAILURES_LOW","PLAY_FAILURES_MEDIUM":"vMRF: PLAY_FAILURES_MEDIUM","PLAY_FAILURES_HIGH":"vMRF: PLAY_FAILURES_HIGH","NOT_ENOUGH_FREE_CONFEREE":"vMRF: NOT_ENOUGH_FREE_CONFEREE","NO_LONGER_FREE_CONFERENCE_ROOM":"vMRF: NO_LONGER_FREE_CONFERENCE_ROOM","STARTUP_ERROR_FAIL_TO_READ_CF":"vMRF: STARTUP_ERROR_FAIL_TO_READ_CF","STARTUP_ERROR_SIP_ADAPTER_INIT":"vMRF: STARTUP_ERROR_SIP_ADAPTER_INIT","STARTUP_ERROR_MONITORING_INIT":"vMRF: STARTUP_ERROR_MONITORING_INIT","REGISTER_ERROR_FAILURE":"vMRF: REGISTER_ERROR_FAILURE","DRI_ERROR_FAILURE":"vMRF: DRI_ERROR_FAILURE","STARTUP_ERROR_STACK_CONFIGURATION":"vMRF: STARTUP_ERROR_STACK_CONFIGURATION","STARTUP_ERROR_CONF":"vMRF: STARTUP_ERROR_CONF","STARTUP_ERROR_UNDEFINED_PORT":"vMRF: STARTUP_ERROR_UNDEFINED_PORT","HOST_REMOVED":"vMRF: HOST_REMOVED","INTERCEPT_THRESHOLD_NB_DIALOG_ALLOCATED":"vMRF: INTERCEPT_THRESHOLD_NB_DIALOG_ALLOCATED","STARTUP_ERROR_STACK_CONF":"vMRF: STARTUP_ERROR_STACK_CONF","STARTUP_ERROR_CONFIGURATION":"vMRF: STARTUP_ERROR_CONFIGURATION","STARTUP_ERROR_FAILED_TO_RETRIEVE_HOSTNAME":"vMRF: STARTUP_ERROR_FAILED_TO_RETRIEVE_HOSTNAME","LEVEL_WARNING_CALL":"vMRF: LEVEL_WARNING_CALL","LEVEL_ALARM_MINOR_CALL":"vMRF: LEVEL_ALARM_MINOR_CALL","LEVEL_ALARM_MAJOR_CALL":"vMRF: LEVEL_ALARM_MAJOR_CALL","LEVEL_ALARM_MRFPoutOfService":"vMRF: LEVEL_ALARM_MRFPoutOfService","MRFP_CALL_REJECTED_Threshold #1":"vMRF: MRFP_CALL_REJECTED_Threshold #1","MRFP_CALL_REJECTED_Threshold #2":"vMRF: MRFP_CALL_REJECTED_Threshold #2","MRFP_CALL_REJECTED_Threshold #3":"vMRF: MRFP_CALL_REJECTED_Threshold #3","MRFP_CALL_RETRIED_Threshold #1":"vMRF: MRFP_CALL_RETRIED_Threshold #1","MRFP_CALL_RETRIED_Threshold #2":"vMRF: MRFP_CALL_RETRIED_Threshold #2","MRFP_CALL_RETRIED_Threshold #3":"vMRF: MRFP_CALL_RETRIED_Threshold #3","STARTUP_PUB_FILE_NOT_PRESENT":"vMRF: STARTUP_PUB_FILE_NOT_PRESENT","STARTUP_INF_FILE_NOT_PRESENT":"vMRF: STARTUP_INF_FILE_NOT_PRESENT","STARTUP_LIC_FILE_NOT_PRESENT":"vMRF: STARTUP_LIC_FILE_NOT_PRESENT","GENERIC_HARDWARE_PROBLEM":"vMRF: GENERIC_HARDWARE_PROBLEM","HARD_DRIVE_PROBLEM":"vMRF: HARD_DRIVE_PROBLEM","NETWORK_LINK_PROBLEM":"vMRF: NETWORK_LINK_PROBLEM","POWER_SUPPLY_PROBLEM":"vMRF: POWER_SUPPLY_PROBLEM","SMART_HARD_DRIVE_PROBLEM":"vMRF: SMART_HARD_DRIVE_PROBLEM","STARTUP_ERROR":"vMRF: STARTUP_ERROR","RESOURCE_NOT_ACCESSIBLE":"vMRF: RESOURCE_NOT_ACCESSIBLE","RESOURCE_ACCESSIBLE":"vMRF: RESOURCE_ACCESSIBLE","RESOURCE_FULL":"vMRF: RESOURCE_FULL","DRI_ALARM":"vMRF: DRI_ALARM","REGISTER_ERROR_CCF":"vMRF: REGISTER_ERROR_CCF","REGISTER_ERROR_EXTERNAL":"vMRF: REGISTER_ERROR_EXTERNAL","TIMEOUT_ERROR":"vMRF: TIMEOUT_ERROR","VXML_ERROR":"vMRF: VXML_ERROR","A Network Element is no longer available due to a connection failure":"vMVM: A Network Element is no longer available due to a connection failure","A MetaSphere server is reporting a fault with the configuration of its connection to MetaView":"vMVM: A MetaSphere server is reporting a fault with the configuration of its connection to MetaView","Configured OBS IPs don't match available OBS nodes. Configured but unavailable nodes include: []. Real nodes not configured include: []":"vMVM: Configured OBS IPs don't match available OBS nodes. Configured but unavailable nodes include: []. Real nodes not configured include: []","Service Assurance Server cannot be contacted":"vMVM: Service Assurance Server cannot be contacted","The primary MetaView Director has lost contact with the backup MetaView Director":"vMVM: The primary MetaView Director has lost contact with the backup MetaView Director","The active server has lost connection to the standby":"vMVM: The active server has lost connection to the standby","CrashCounter":"vprobes-vBE-Processing: CrashCounter","IsAlive":"vprobes-vBE-Processing: IsAlive","SwRestart":"vprobes-vLB: SwRestart","Repeated exceptions have occurred.":"vSBC-Metaswitch: Repeated exceptions have occurred.","A licensing limit is close to capacity.":"vSBC-Metaswitch: A licensing limit is close to capacity.","One or more feature packs have been breached.":"vSBC-Metaswitch: One or more feature packs have been breached.","The grace period on this Perimeta system will expire in less than 48 hours, after which calls will not be processed.":"vSBC-Metaswitch: The grace period on this Perimeta system will expire in less than 48 hours, after which calls will not be processed.","The grace period on this Perimeta system will expire in less than 7 days, after which calls will not be processed.":"vSBC-Metaswitch: The grace period on this Perimeta system will expire in less than 7 days, after which calls will not be processed.","The license on this Perimeta system will expire in less than 4 weeks.":"vSBC-Metaswitch: The license on this Perimeta system will expire in less than 4 weeks.","A Perimeta blade has become unlicensed.":"vSBC-Metaswitch: A Perimeta blade has become unlicensed.","Perimeta is licensed with a bypass certificate, which is valid until the time displayed.":"vSBC-Metaswitch: Perimeta is licensed with a bypass certificate, which is valid until the time displayed.","The number of licensed instances exceeded a threshold of the licensed limit.":"vSBC-Metaswitch: The number of licensed instances exceeded a threshold of the licensed limit.","The software token on the primary Distributed Capacity Manager will expire on the displayed date.":"vSBC-Metaswitch: The software token on the primary Distributed Capacity Manager will expire on the displayed date.","A capacity limit on the license installed on this Perimeta system does not match the largest limit across all systems in the deployment.":"vSBC-Metaswitch: A capacity limit on the license installed on this Perimeta system does not match the largest limit across all systems in the deployment.","An adjacency has voice quality alerts.":"vSBC-Metaswitch: An adjacency has voice quality alerts.","The number of calls being audited is congested.":"vSBC-Metaswitch: The number of calls being audited is congested.","Session Controller is rejecting calls because there is no valid active call policy set configured.":"vSBC-Metaswitch: Session Controller is rejecting calls because there is no valid active call policy set configured.","A call policy set is inactive because it has been misconfigured.":"vSBC-Metaswitch: A call policy set is inactive because it has been misconfigured.","Session Controller is inactive and rejecting calls.":"vSBC-Metaswitch: Session Controller is inactive and rejecting calls.","Sources have breached minor or major blacklist thresholds.":"vSBC-Metaswitch: Sources have breached minor or major blacklist thresholds.","Sources are blacklisted.":"vSBC-Metaswitch: Sources are blacklisted.","The blacklisting configuration will change as a result of upgrade and some configured blacklists or alerts will no longer be applied.":"vSBC-Metaswitch: The blacklisting configuration will change as a result of upgrade and some configured blacklists or alerts will no longer be applied.","A large number of downgrades and bans have been created as a result of blacklisting.":"vSBC-Metaswitch: A large number of downgrades and bans have been created as a result of blacklisting.","Session Controller is unable to track further sources for blacklisting.":"vSBC-Metaswitch: Session Controller is unable to track further sources for blacklisting.","A software protection switch was triggered.":"vSBC-Metaswitch: A software protection switch was triggered.","A disk area on a processor blade is nearly full.":"vSBC-Metaswitch: A disk area on a processor blade is nearly full.","Memory use is very high.":"vSBC-Metaswitch: Memory use is very high.","The primary processor-blade has lost contact with the backup.":"vSBC-Metaswitch: The primary processor-blade has lost contact with the backup.","An efix or patch has been applied to this system containing diagnostic versions of some software libraries.":"vSBC-Metaswitch: An efix or patch has been applied to this system containing diagnostic versions of some software libraries.","A software protection switch (SPS) was triggered. Call and registration state was lost.":"vSBC-Metaswitch: A software protection switch (SPS) was triggered. Call and registration state was lost.","The Ethernet Heartbeat between primary and backup processors has failed.":"vSBC-Metaswitch: The Ethernet Heartbeat between primary and backup processors has failed.","The Backplane Heartbeat between primary and backup processors has failed.":"vSBC-Metaswitch: The Backplane Heartbeat between primary and backup processors has failed.","A disk area on a processor blade reported an error.":"vSBC-Metaswitch: A disk area on a processor blade reported an error.","The system is upgrading.":"vSBC-Metaswitch: The system is upgrading.","An error with NTP functionality has been detected.":"vSBC-Metaswitch: An error with NTP functionality has been detected.","One or more users are locked out of the system.":"vSBC-Metaswitch: One or more users are locked out of the system.","The Craft Terminal user FTP directory on a processor blade is nearly full.":"vSBC-Metaswitch: The Craft Terminal user FTP directory on a processor blade is nearly full.","A scheduled configuration snapshot has failed.":"vSBC-Metaswitch: A scheduled configuration snapshot has failed.","The Session Controller is stopping as a result of administrator action.":"vSBC-Metaswitch: The Session Controller is stopping as a result of administrator action.","A Session Controller processor blade is stopping as a result of administrator action.":"vSBC-Metaswitch: A Session Controller processor blade is stopping as a result of administrator action.","An object could not be activated because its service address does not exist or is not fully specified.":"vSBC-Metaswitch: An object could not be activated because its service address does not exist or is not fully specified.","The hardware on a processor does not meet minimum requirements.":"vSBC-Metaswitch: The hardware on a processor does not meet minimum requirements.","The hardware expectations of the two processors are not the same.":"vSBC-Metaswitch: The hardware expectations of the two processors are not the same.","The read speed of the main hard disk on a processor blade is too slow.":"vSBC-Metaswitch: The read speed of the main hard disk on a processor blade is too slow.","An error has occurred reading from the hard disk on a processor blade.":"vSBC-Metaswitch: An error has occurred reading from the hard disk on a processor blade.","Backup and primary processor-blades have an inconsistent system role.":"vSBC-Metaswitch: Backup and primary processor-blades have an inconsistent system role.","Event: The system encountered a critical error and had to restart.":"vSBC-Metaswitch: Event: The system encountered a critical error and had to restart.","Event: A RADIUS server failed to respond to an authentication request.":"vSBC-Metaswitch: Event: A RADIUS server failed to respond to an authentication request.","Event: All configured RADIUS servers failed to respond to authentication requests.":"vSBC-Metaswitch: Event: All configured RADIUS servers failed to respond to authentication requests.","Event: The number of CPUs has changed.":"vSBC-Metaswitch: Event: The number of CPUs has changed.","Event: A user has been automatically deleted":"vSBC-Metaswitch: Event: A user has been automatically deleted","The primary processor blade has lost management connectivity":"vSBC-Metaswitch: The primary processor blade has lost management connectivity","Event: A processor blade is running with DPDK mode disabled when DPDK mode is,expected.":"vSBC-Metaswitch: Event: A processor blade is running with DPDK mode disabled when DPDK mode is,expected.","Event: Processor blade %1 is running with DPDK mode disabled when DPDK mode may be possible.":"vSBC-Metaswitch: Event: Processor blade %1 is running with DPDK mode disabled when DPDK mode may be possible.","Perimeta is attempting to resend cached billing records.":"vSBC-Metaswitch: Perimeta is attempting to resend cached billing records.","The Rf billing cache is full.":"vSBC-Metaswitch: The Rf billing cache is full.","The inbound call queue is congested.":"vSBC-Metaswitch: The inbound call queue is congested.","A configured realm group contains realms that are not available to the SBC.":"vSBC-Metaswitch: A configured realm group contains realms that are not available to the SBC.","An allowed MSC configuration is not connected to any physical MSCs.":"vSBC-Metaswitch: An allowed MSC configuration is not connected to any physical MSCs.","A SIP Peer has stopped responding to SIP OPTIONS pings. MSW: 20160303: Alarm text is changed in v3.9 software to read: \\"An adjacency has lost connectivity, according to SIP OPTIONS pings\\"":"vSBC-Metaswitch: A SIP Peer has stopped responding to SIP OPTIONS pings. MSW: 20160303: Alarm text is changed in v3.9 software to read: \\"An adjacency has lost connectivity, according to SIP OPTIONS pings\\"","An adjacency has failed as the listen socket could not be created. Check for configuration mismatches with the associated service interface.":"vSBC-Metaswitch: An adjacency has failed as the listen socket could not be created. Check for configuration mismatches with the associated service interface.","No suitable DNS records were found for a peer group's DNS hostname.":"vSBC-Metaswitch: No suitable DNS records were found for a peer group's DNS hostname.","One or more SIP peers from a peer group have stopped responding to SIP OPTIONS pings":"vSBC-Metaswitch: One or more SIP peers from a peer group have stopped responding to SIP OPTIONS pings","An adjacency has failed as its service network does not match the service network on its associated peer group.":"vSBC-Metaswitch: An adjacency has failed as its service network does not match the service network on its associated peer group.","An adjacency has failed as its configured TLS certificate could not be found.":"vSBC-Metaswitch: An adjacency has failed as its configured TLS certificate could not be found.","The caching function has not been initialized properly.":"vSBC-Metaswitch: The caching function has not been initialized properly.","An adjacency has failed as the listen socket could not be created.":"vSBC-Metaswitch: An adjacency has failed as the listen socket could not be created.","An adjacency is congested and may be rejecting calls.":"vSBC-Metaswitch: An adjacency is congested and may be rejecting calls.","There is an issue with a Diameter peer.":"vSBC-Metaswitch: There is an issue with a Diameter peer.","A realm is no longer reachable via any configured peers.":"vSBC-Metaswitch: A realm is no longer reachable via any configured peers.","An FQDN for a configured Diameter peer has failed to resolve to a valid IP address.":"vSBC-Metaswitch: An FQDN for a configured Diameter peer has failed to resolve to a valid IP address.","One or more peers resolved from a DNS lookup of a configured peer's address cannot be contacted":"vSBC-Metaswitch: One or more peers resolved from a DNS lookup of a configured peer's address cannot be contacted","An interface ARP or NDP probe has failed.":"vSBC-Metaswitch: An interface ARP or NDP probe has failed.","One or more IP address conflicts have been detected on service interfaces with zero criticality. If there are other probe failures, this alarm will remain raised until all conflicts are resolved.":"vSBC-Metaswitch: One or more IP address conflicts have been detected on service interfaces with zero criticality. If there are other probe failures, this alarm will remain raised until all conflicts are resolved.","One or more IP address conflicts have been detected on service interfaces with non-zero criticality. If there are other probe failures, this alarm will remain raised until all conflicts are resolved.":"vSBC-Metaswitch: One or more IP address conflicts have been detected on service interfaces with non-zero criticality. If there are other probe failures, this alarm will remain raised until all conflicts are resolved.","An interface device is running below the expected speed. This alarm was originally triggered by a probe failure on a service interface.":"vSBC-Metaswitch: An interface device is running below the expected speed. This alarm was originally triggered by a probe failure on a service interface.","An interface device is running above the expected speed.":"vSBC-Metaswitch: An interface device is running above the expected speed.","An IP address conflict has been detected on a management interface.":"vSBC-Metaswitch: An IP address conflict has been detected on a management interface.","An interface ICMP probe has failed.":"vSBC-Metaswitch: An interface ICMP probe has failed.","A High-Availability link has detected a connectivity issue.":"vSBC-Metaswitch: A High-Availability link has detected a connectivity issue.","An HA-link device is being reported as underspeed.":"vSBC-Metaswitch: An HA-link device is being reported as underspeed.","An IP address conflict has been detected on a replication interface.":"vSBC-Metaswitch: An IP address conflict has been detected on a replication interface.","The Session Controller has started.":"vSBC-Metaswitch: The Session Controller has started.","A statistic exceeded its configured thresholds.":"vSBC-Metaswitch: A statistic exceeded its configured thresholds.","One or more statistic has not been retrieved at least 3 times in a row.":"vSBC-Metaswitch: One or more statistic has not been retrieved at least 3 times in a row.","A Refresh Alarms request was triggered. Alarms not re-raised will be cleared in 5 minutes.":"vSBC-Metaswitch: A Refresh Alarms request was triggered. Alarms not re-raised will be cleared in 5 minutes.","A statistic has exceeded its configured thresholds.":"vSBC-Metaswitch: A statistic has exceeded its configured thresholds.","A Fallback Operation will soon be started":"vSBG: A Fallback Operation will soon be started","BRM, Auto Export Backup Failed":"vSBG: BRM, Auto Export Backup Failed","BRM, Scheduled Backup Failed":"vSBG: BRM, Scheduled Backup Failed","COM SA, AMF Component Cleanup Failed":"vSBG: COM SA, AMF Component Cleanup Failed","COM SA, AMF Component Instantiation Failed":"vSBG: COM SA, AMF Component Instantiation Failed","COM SA, AMF SI Unassigned":"vSBG: COM SA, AMF SI Unassigned","COM SA, CLM Cluster Node Unavailable":"vSBG: COM SA, CLM Cluster Node Unavailable","COM SA, MDF Detected Model Error":"vSBG: COM SA, MDF Detected Model Error","COM SA, Proxy Status of a Component Changed to Unproxied":"vSBG: COM SA, Proxy Status of a Component Changed to Unproxied","File Management, Number of Files in FileGroup Exceeded":"vSBG: File Management, Number of Files in FileGroup Exceeded","File Management, Max Size in FileGroup Exceeded":"vSBG: File Management, Max Size in FileGroup Exceeded","LOTC Disk Replication Communication":"vSBG: LOTC Disk Replication Communication","LOTC Disk Replication Consistency":"vSBG: LOTC Disk Replication Consistency","LOTC Disk Usage":"vSBG: LOTC Disk Usage","LOTC memory Usage":"vSBG: LOTC memory Usage","LOTC Time Synchronization":"vSBG: LOTC Time Synchronization","SBG, BGF Control Link Down":"vSBG: SBG, BGF Control Link Down","SBG, BGF Control Link Disabled":"vSBG: SBG, BGF Control Link Disabled","SBG, BGF Control Link Enabled":"vSBG: SBG, BGF Control Link Enabled","SBG, BGF Control Link Remote Locked":"vSBG: SBG, BGF Control Link Remote Locked","SBG, Charging Data Storage Maximum Records Reached":"vSBG: SBG, Charging Data Storage Maximum Records Reached","SBG, Charging Server Rejects Charging Data":"vSBG: SBG, Charging Server Rejects Charging Data","SBG, Excessive Packet Rate Detected ":"vSBG: SBG, Excessive Packet Rate Detected ","SBG, High Amount of Malformed Packets Received":"vSBG: SBG, High Amount of Malformed Packets Received","SBG, High Amount of STUN Packets Detected":"vSBG: SBG, High Amount of STUN Packets Detected","SBG, High Amount of TCP SYN Packets Received":"vSBG: SBG, High Amount of TCP SYN Packets Received","SBG, High Amount of UDP Packets Received ":"vSBG: SBG, High Amount of UDP Packets Received ","SBG, IP Address Blocked Due to Excessive Packet Rate":"vSBG: SBG, IP Address Blocked Due to Excessive Packet Rate","SBG, Lost Connectivity to Diameter Server":"vSBG: SBG, Lost Connectivity to Diameter Server","SBG, Mated Pair out of Service":"vSBG: SBG, Mated Pair out of Service","SBG, Network Unavailable for Media Handling":"vSBG: SBG, Network Unavailable for Media Handling","SBG, Non-emergency Call Released to Free Resources for Emergency Call":"vSBG: SBG, Non-emergency Call Released to Free Resources for Emergency Call","SBG, Not Enough Disk Space for Storing Charging Data":"vSBG: SBG, Not Enough Disk Space for Storing Charging Data","SBG, Payload Mated Pair Failure":"vSBG: SBG, Payload Mated Pair Failure","SBG, Payload Processor Failure":"vSBG: SBG, Payload Processor Failure","SBG, Processor Overloaded":"vSBG: SBG, Processor Overloaded","SBG, Registered User Set in Quarantine":"vSBG: SBG, Registered User Set in Quarantine","SBG, Registration Contacts Exceed Configured Threshold":"vSBG: SBG, Registration Contacts Exceed Configured Threshold","SBG, Sequential Restart Initiated":"vSBG: SBG, Sequential Restart Initiated","SBG, SIP Abuse Detected":"vSBG: SBG, SIP Abuse Detected","SBG, SIP Network Locked":"vSBG: SBG, SIP Network Locked","SBG, SIP Next Hop Reachable":"vSBG: SBG, SIP Next Hop Reachable","SBG, SIP Next Hop Unreachable":"vSBG: SBG, SIP Next Hop Unreachable","SBG, SIP Request Rejected by Network Throttling":"vSBG: SBG, SIP Request Rejected by Network Throttling","SBG, TLS Certificate Imported":"vSBG: SBG, TLS Certificate Imported","SBG, Trace Recording Session Number Limit Reached":"vSBG: SBG, Trace Recording Session Number Limit Reached","SBG, Trace Session Deactivated":"vSBG: SBG, Trace Session Deactivated","SBG, Trace Session Times Out":"vSBG: SBG, Trace Session Times Out","SBG, Unknown Media Type or Payload Type":"vSBG: SBG, Unknown Media Type or Payload Type"} +# +# if action.test.override is true, then any action will be marked as test=true (even if incoming action request had test=false); otherwise, test flag will be unchanged on the action request +action.test.override=false +# if action.insert.test.event is true, then insert event even if the action is set to test +action.insert.test.event=false +CLDS_SERVICE_CACHE_MAX_SECONDS=5 + +#DCAE Inventory Url Properties DCAE_INVENTORY_URL = https://dcae.api.simpledemo.openecomp.org:8080 - -#DCAE Dispatcher Url Properties + +#DCAE Dispatcher Url Properties DCAE_DISPATCHER_URL = https://dcae.api.simpledemo.openecomp.org:8443 - + diff --git a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java b/src/test/java/org/onap/clamp/clds/it/DcaeIT.java deleted file mode 100644 index 4f0ebb4e2..000000000 --- a/src/test/java/org/onap/clamp/clds/it/DcaeIT.java +++ /dev/null @@ -1,62 +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.it; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.clamp.clds.AbstractIT; -import org.onap.clamp.clds.client.req.DcaeReq; -import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.util.ResourceFileUtil; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * Test DCAE API in org.onap.clamp.ClampDesigner.client package - replicate DCAE - * Delegates in test. - */ -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@TestPropertySource(locations = "classpath:application-no-camunda.properties") -public class DcaeIT extends AbstractIT { - - @Test - public void testDcaeReq() throws Exception { - String modelProp = ResourceFileUtil.getResourceAsString("example/modelProp.json"); - String modelBpmnProp = ResourceFileUtil.getResourceAsString("example/modelBpmnProp.json"); - String modelName = "example-model"; - String controlName = "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756"; - - ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, - modelProp); - String dcaeReq = DcaeReq.format(refProp, prop); - - System.out.println("dcaeReq=" + dcaeReq); - System.out.println("dcaeUrl=" + System.getProperty("CLDS_DCAE_URL") + "/" + controlName); - } - -} diff --git a/src/test/java/org/onap/clamp/clds/it/SdcIT.java b/src/test/java/org/onap/clamp/clds/it/SdcIT.java index 025420ff1..8883af254 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcIT.java @@ -26,6 +26,7 @@ package org.onap.clamp.clds.it; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; + import org.onap.clamp.clds.AbstractIT; import org.onap.clamp.clds.client.SdcCatalogServices; import org.onap.clamp.clds.client.req.SdcReq; @@ -46,7 +47,7 @@ import org.springframework.test.context.junit4.SpringRunner; @TestPropertySource(locations = "classpath:application-no-camunda.properties") public class SdcIT extends AbstractIT { @Autowired - private RefProp refProp; + private RefProp refProp; @Autowired private SdcCatalogServices sdcCatalogServices; @@ -63,13 +64,14 @@ public class SdcIT extends AbstractIT { String modelName = "example-model06"; String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; String docText = ResourceFileUtil.getResourceAsString("example/templateProp.json"); - ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, - modelProp); + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, + true, modelBpmnProp, modelProp); String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); System.out.println("blueprint=" + blueprint); - // assertEquals(blueprint, ""); + //assertEquals(blueprint, ""); } + @Test public void testTcaBlueprint() throws Exception { String modelProp = ResourceFileUtil.getResourceAsString("example/modelPropForPolicy.json"); @@ -77,10 +79,10 @@ public class SdcIT extends AbstractIT { String modelName = "example-model06"; String controlName = "ClosedLoop-FRWL-SIG04-1582f840-test-test-1234-005056a9d756"; String docText = ResourceFileUtil.getResourceAsString("example/templatePropForTca.json"); - ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, true, modelBpmnProp, - modelProp); + ModelProperties prop = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, + true, modelBpmnProp, modelProp); String blueprint = SdcReq.formatBlueprint(refProp, prop, docText); System.out.println("blueprint=" + blueprint); - // assertEquals(blueprint, ""); + //assertEquals(blueprint, ""); } } diff --git a/src/test/resources/https/https-test.properties b/src/test/resources/https/https-test.properties index eaccd4ac4..b0fd639c9 100644 --- a/src/test/resources/https/https-test.properties +++ b/src/test/resources/https/https-test.properties @@ -134,8 +134,6 @@ async.core.pool.size=10 async.max.pool.size=20 async.queue.capacity=500 -org.onap.clamp.config.dcae.url=http://localhost:9000/closedloop-dcae-services - #GRM Edge endpoint details service.name=ajsc6camundademo service.version=1.0.0.0 -- cgit 1.2.3-korg From 9f5ac4f9aacfe3066cceb3106e57cb52343ff0f8 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 22 Sep 2017 15:41:07 +0200 Subject: Add different log in AbstractModelElement Log changed when the Json attribute value is null or empty Change-Id: Ie0321efbbcc7f9c637f1bd8ea44001e5036987d3 Issue-ID: CLAMP-54 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/model/prop/AbstractModelElement.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java index a7dd5cbf0..7038dc6cf 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/AbstractModelElement.java @@ -37,8 +37,8 @@ import java.util.List; * ...) */ public abstract class AbstractModelElement { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); private final String type; private final ModelBpmn modelBpmn; @@ -49,6 +49,9 @@ public abstract class AbstractModelElement { private final ModelProperties modelProp; + private static final String LOG_ELEMENT = "Value '"; + private static final String LOG_NOT_FOUND = "' for key 'name' not found in JSON"; + /** * Perform base parsing of properties for a ModelElement (such as, * Collector, StringMatch, Policy and Tca) @@ -116,9 +119,9 @@ public abstract class AbstractModelElement { } } if (value == null || value.length() == 0) { - logger.warn(name + "=" + value); + logger.warn(LOG_ELEMENT + name + LOG_NOT_FOUND); } else { - logger.debug(name + "=" + value); + logger.debug(LOG_ELEMENT + name + LOG_NOT_FOUND + nodeIn.toString()); } return value; } @@ -137,9 +140,9 @@ public abstract class AbstractModelElement { value = nodeIn.path(name).asText(); } if (value == null || value.length() == 0) { - logger.warn(name + "=" + value); + logger.warn(LOG_ELEMENT + name + LOG_NOT_FOUND); } else { - logger.debug(name + "=" + value); + logger.debug(LOG_ELEMENT + name + LOG_NOT_FOUND + nodeIn.toString()); } return value; } @@ -206,9 +209,9 @@ public abstract class AbstractModelElement { } } if (values == null || values.isEmpty()) { - logger.warn(name + "=" + values); + logger.warn(LOG_ELEMENT + name + LOG_NOT_FOUND); } else { - logger.debug(name + "=" + values); + logger.debug(LOG_ELEMENT + name + LOG_NOT_FOUND + nodeIn.toString()); } return values; } -- cgit 1.2.3-korg From 8c5ffd0eb1269ceeb9b19a2c274577fae6240840 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 22 Sep 2017 15:52:45 +0200 Subject: Add the target resource ID Add target resource ID in operational policy code as requested. It changes the UI, the Policy code, the model and the tests. Change-Id: Ie72badde55e7f8b5c2e5234099a09b95958205cf Issue-ID: CLAMP-55 Signed-off-by: Determe, Sebastien (sd378r) --- .../clds/client/req/OperationalPolicyReq.java | 39 ++-- .../onap/clamp/clds/model/prop/PolicyChain.java | 23 +- .../org/onap/clamp/clds/model/prop/PolicyItem.java | 33 ++- .../portfolios/PolicyWindow_properties.html | 245 +++++++++++---------- .../onap/clamp/clds/it/OperationPolicyReqIT.java | 89 ++++++++ .../clamp/clds/model/prop/ModelPropertiesTest.java | 5 + .../example/model-properties/modelBpmnProp.json | 6 + .../model-properties/modelBpmnPropWithGlobal.json | 3 +- src/test/resources/example/modelProp.json | 95 +++----- src/test/resources/example/modelPropForPolicy.json | 28 +++ .../operational-policy/yaml-policy-chain-1.yaml | 112 ++++++++++ .../operational-policy/yaml-policy-chain-2.yaml | 112 ++++++++++ 12 files changed, 567 insertions(+), 223 deletions(-) create mode 100644 src/test/java/org/onap/clamp/clds/it/OperationPolicyReqIT.java create mode 100644 src/test/resources/example/operational-policy/yaml-policy-chain-1.yaml create mode 100644 src/test/resources/example/operational-policy/yaml-policy-chain-2.yaml (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java index ad466ee7d..a64bd7177 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -66,6 +66,10 @@ public class OperationalPolicyReq { protected static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyReq.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + private OperationalPolicyReq() { + + } + /** * Format Operational Policy attributes. * @@ -127,12 +131,16 @@ public class OperationalPolicyReq { String recipe = policyItem.getRecipe(); String maxRetries = String.valueOf(policyItem.getMaxRetries()); String retryTimeLimit = String.valueOf(policyItem.getRetryTimeLimit()); + String targetResourceId = String.valueOf(policyItem.getTargetResourceId()); logger.info("recipe=" + recipe); logger.info("maxRetries=" + maxRetries); logger.info("retryTimeLimit=" + retryTimeLimit); + logger.info("targetResourceId=" + targetResourceId); ruleAttributes.put("Recipe", recipe); ruleAttributes.put("MaxRetries", maxRetries); ruleAttributes.put("RetryTimeLimit", retryTimeLimit); + ruleAttributes.put("ResourceId", targetResourceId); + } else { logger.info("templateName=" + templateName); logger.info("operationTopic=" + operationTopic); @@ -189,24 +197,22 @@ public class OperationalPolicyReq { builder.addResource(vfcResources); // process each policy - HashMap policyObjMap = new HashMap<>(); + HashMap policyObjMap = new HashMap<>(); List policyItemList = orderParentFirst(policyChain.getPolicyItems()); - Target target = new Target(); - target.setType(TargetType.VM); - for (int i = 0; i < policyItemList.size(); i++) { - - org.onap.policy.controlloop.policy.Policy policyObj; - PolicyItem policyItem = policyItemList.get(i); + for (PolicyItem policyItem : policyItemList) { String policyName = policyItem.getRecipe() + " Policy"; - if (i == 0) { + Target target = new Target(); + target.setType(TargetType.VM); + target.setResourceID(policyItem.getTargetResourceId()); + Policy policyObj; + if (policyItemList.indexOf(policyItem) == 0) { String policyDescription = policyItem.getRecipe() + " Policy - the trigger (no parent) policy - created by CLDS"; policyObj = builder.setTriggerPolicy(policyName, policyDescription, refProp.getStringValue("op.policy.appc"), target, policyItem.getRecipe(), null, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit()); } else { - org.onap.policy.controlloop.policy.Policy parentPolicyObj = policyObjMap - .get(policyItem.getParentPolicy()); + Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy()); String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + parentPolicyObj.getName() + " - created by CLDS"; policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, @@ -269,14 +275,15 @@ public class OperationalPolicyReq { HashMap policyObjMap = new HashMap<>(); List policyItemList = addAOTSActorRecipe(refProp, global.getService(), policyChain.getPolicyItems()); - Target target = new Target(); - target.setType(TargetType.VM); + Policy lastPolicyObj = new Policy(); - for (int i = 0; i < policyItemList.size(); i++) { - org.onap.policy.controlloop.policy.Policy policyObj; - PolicyItem policyItem = policyItemList.get(i); + for (PolicyItem policyItem : policyItemList) { + Target target = new Target(); + target.setType(TargetType.VM); + target.setResourceID(policyItem.getTargetResourceId()); String policyName = policyItem.getRecipe() + " Policy"; - if (i == 0) { + Policy policyObj; + if (policyItemList.indexOf(policyItem) == 0) { // To set up time window payload for trigger policy Map payloadMap = new HashMap<>(); payloadMap.put("timeWindow", refProp.getStringValue("op.eNodeB.timeWindow")); diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java index c8c2ef461..5264629f2 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/PolicyChain.java @@ -23,14 +23,14 @@ package org.onap.clamp.clds.model.prop; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * Parse Policy json properties. * @@ -42,24 +42,27 @@ import com.fasterxml.jackson.databind.JsonNode; * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name": * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name": * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name": - * "parentPolicy","value":[""]}]]}],"PolicyTest2":[{"name":"pname","value": + * "parentPolicy","value":[""]},{"name": + * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}], + * "PolicyTest2":[{"name":"pname","value": * "PolicyTest2"},{"name":"pid","value":"2"},{"name":"timeout","value":"345"},{ * "policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name": * "maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name" * :"_id","value":["q2JmHD5"]},{"name":"parentPolicy","value":[""]}],[{"name": * "recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name": * "retryTimeLimit","value":["180"]},{"name":"_id","value":["0ZqHdrR"]},{"name": - * "parentPolicy","value":[""]}]]}]}} f + * "parentPolicy","value":[""]},{"name": + * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]}} f * */ public class PolicyChain { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyChain.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyChain.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String policyId; - private Integer timeout; - private List policyItems; + private String policyId; + private Integer timeout; + private List policyItems; public PolicyChain(JsonNode node) { diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java index c84affefe..5fc829835 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java @@ -23,12 +23,12 @@ package org.onap.clamp.clds.model.prop; -import java.util.List; - import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; +import java.util.List; + /** * Parse policyConfigurations from Policy json properties. *

@@ -44,19 +44,21 @@ import com.fasterxml.jackson.databind.JsonNode; * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS" * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[ * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ - * "vf3RtPi"]}]]}] + * "vf3RtPi"]},{"name": + * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}] */ public class PolicyItem implements Cloneable { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String id; - private String recipe; - private int maxRetries; - private int retryTimeLimit; - private String parentPolicy; - private List parentPolicyConditions; - private String actor; + private String id; + private String recipe; + private int maxRetries; + private int retryTimeLimit; + private String parentPolicy; + private List parentPolicyConditions; + private String actor; + private String targetResourceId; /** * Parse Policy given json node. @@ -70,6 +72,7 @@ public class PolicyItem implements Cloneable { retryTimeLimit = AbstractModelElement.getIntValueByName(node, "retryTimeLimit"); parentPolicy = AbstractModelElement.getValueByName(node, "parentPolicy"); parentPolicyConditions = AbstractModelElement.getValuesByName(node, "parentPolicyConditions"); + targetResourceId = AbstractModelElement.getValueByName(node, "targetResourceId"); } @@ -171,6 +174,14 @@ public class PolicyItem implements Cloneable { this.actor = actor; } + public String getTargetResourceId() { + return targetResourceId; + } + + public void setTargetResourceId(String targetResourceId) { + this.targetResourceId = targetResourceId; + } + @Override public Object clone() throws CloneNotSupportedException { return super.clone(); diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html index 4f7a77d4e..00e167516 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html @@ -23,14 +23,15 @@ -

+
- - +
+ +