summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/clamp/clds/Application.java20
-rw-r--r--src/main/java/org/onap/clamp/clds/Routes.java6
-rw-r--r--src/main/java/org/onap/clamp/clds/WebConfig.java1
-rw-r--r--src/main/java/org/onap/clamp/clds/client/CldsEventDelegate.java32
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeReqDelegate.java39
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeReqDeleteDelegate.java33
-rw-r--r--src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java61
-rw-r--r--src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java43
-rw-r--r--src/main/java/org/onap/clamp/clds/client/PolicyClient.java249
-rw-r--r--src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDelegate.java53
-rw-r--r--src/main/java/org/onap/clamp/clds/client/StringMatchPolicyDeleteDelegate.java42
-rw-r--r--src/main/java/org/onap/clamp/clds/client/TcaPolicyDelegate.java94
-rw-r--r--src/main/java/org/onap/clamp/clds/client/TcaPolicyDeleteDelegate.java89
13 files changed, 450 insertions, 312 deletions
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<AttributeType, Map<String, String>> 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<AttributeType, Map<String, String>> 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<AttributeType, Map<String, String>> attributes, ModelProperties prop, String policyRequestUUID) throws Exception {
+ public String sendBrms(Map<AttributeType, Map<String, String>> 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<Integer> 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<Integer> getVersions(String policyNamePrefix, ModelProperties prop) throws Exception {
+ protected List<Integer> getVersions(String policyNamePrefix, ModelProperties prop) throws Exception {
ArrayList<Integer> 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<PolicyConfig> response = policyEngine.getConfig(configRequestParameters);
+ if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {
+ policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix) + "_" + prop.getPolicyUniqueId();
+ } else {
+ policyName = prop.getCurrentPolicyScopeAndFullPolicyName(policyNamePrefix);
+ }
- Iterator<PolicyConfig> 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<PolicyConfig> response = policyEngine.getConfig(configRequestParameters);
+ Iterator<PolicyConfig> 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<Integer> 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());
+ }
+ }
+ }
+
}