diff options
author | sebdet <sebastien.determe@intl.att.com> | 2021-04-07 10:10:45 +0200 |
---|---|---|
committer | sebdet <sebastien.determe@intl.att.com> | 2021-04-15 17:49:58 +0200 |
commit | 1f2d62dd48694fa78041572a200b3e5d04bd268e (patch) | |
tree | 58989ac6875277998b07d97be9883a039ee970b4 /src | |
parent | 58e7987439bca70cdd2715863a020b76baa8ac1c (diff) |
Update dependencies
Update dependencies to remove some issues reported by Nexus-IQ.
Issue-ID: POLICY-3169
Issue-ID: POLICY-3120
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Change-Id: Ia8939f0c85ac4087c3fc2c71b66914d6c7178347
Diffstat (limited to 'src')
27 files changed, 618 insertions, 506 deletions
diff --git a/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java b/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java index f703e3363..89be4fc28 100644 --- a/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java +++ b/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * ONAP CLAMP + * ONAP POLICY-CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Modifications Copyright (c) 2019 Samsung @@ -48,17 +48,14 @@ import org.springframework.stereotype.Component; public class AuthorizationController { protected static final EELFLogger logger = - EELFManager.getInstance().getLogger(AuthorizationController.class); + EELFManager.getInstance().getLogger(AuthorizationController.class); protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - protected static final EELFLogger securityLogger = - EELFManager.getInstance().getSecurityLogger(); + protected static final EELFLogger securityLogger = EELFManager.getInstance().getSecurityLogger(); // By default we'll set it to a default handler @Autowired private ClampProperties refProp; - private SecurityContext securityContext = SecurityContextHolder.getContext(); - public static final String PERM_PREFIX = "security.permission.type."; private static final String PERM_INSTANCE = "security.permission.instance"; @@ -81,23 +78,19 @@ public class AuthorizationController { */ public static String getPrincipalName(SecurityContext securityContext) { String principal = AuthorizationController.retrieveUserName(securityContext); - String name = "Not found"; - if (principal != null) { - name = principal; - } - return name; + return principal != null ? principal : "Not found"; } /** * Insert authorize the api based on the permission. * * @param camelExchange The Camel Exchange object containing the properties - * @param typeVar The type of the permissions - * @param instanceVar The instance of the permissions. e.g. dev - * @param action The action of the permissions. e.g. read + * @param typeVar The type of the permissions + * @param instanceVar The instance of the permissions. e.g. dev + * @param action The action of the permissions. e.g. read */ public void authorize(Exchange camelExchange, String typeVar, String instanceVar, - String action) { + String action) { String type = refProp.getStringValue(PERM_PREFIX + typeVar); String instance = refProp.getStringValue(PERM_INSTANCE); @@ -108,7 +101,7 @@ public class AuthorizationController { if (null != instanceVar && !instanceVar.isEmpty()) { instance = instanceVar; } - String principalName = AuthorizationController.getPrincipalName(this.securityContext); + String principalName = AuthorizationController.getPrincipalName(SecurityContextHolder.getContext()); SecureServicePermission perm = SecureServicePermission.create(type, instance, action); Date startTime = new Date(); LoggingUtils.setTargetContext("Clamp", "authorize"); @@ -131,23 +124,23 @@ public class AuthorizationController { */ public boolean isUserPermitted(SecureServicePermission inPermission) { - String principalName = AuthorizationController.getPrincipalName(this.securityContext); + String principalName = AuthorizationController.getPrincipalName(SecurityContextHolder.getContext()); // check if the user has the permission key or the permission key with a // combination of all instance and/or all action. if (hasRole(inPermission.getKey()) || hasRole(inPermission.getKeyAllInstance())) { auditLogger.info("{} authorized because user has permission with * for instance: {}", - principalName, inPermission.getKey().replace("|", ":")); + principalName, inPermission.getKey().replace("|", ":")); return true; // the rest of these don't seem to be required - isUserInRole method // appears to take * as a wildcard } else if (hasRole(inPermission.getKeyAllInstanceAction())) { auditLogger.info( - "{} authorized because user has permission with * for instance and * for action: {}", - principalName, inPermission.getKey().replace("|", ":")); + "{} authorized because user has permission with * for instance and * for action: {}", + principalName, inPermission.getKey().replace("|", ":")); return true; } else if (hasRole(inPermission.getKeyAllAction())) { auditLogger.info("{} authorized because user has permission with * for action: {}", - principalName, inPermission.getKey().replace("|", ":")); + principalName, inPermission.getKey().replace("|", ":")); return true; } else { return false; @@ -155,7 +148,7 @@ public class AuthorizationController { } protected boolean hasRole(String role) { - Authentication authentication = securityContext.getAuthentication(); + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return false; } @@ -176,11 +169,11 @@ public class AuthorizationController { */ public ClampInformation getClampInformation() { ClampInformation clampInfo = new ClampInformation(); - Authentication authentication = securityContext.getAuthentication(); + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return new ClampInformation(); } - clampInfo.setUserName(AuthorizationController.getPrincipalName(this.securityContext)); + clampInfo.setUserName(AuthorizationController.getPrincipalName(SecurityContextHolder.getContext())); for (GrantedAuthority auth : authentication.getAuthorities()) { clampInfo.getAllPermissions().add(auth.getAuthority()); } diff --git a/src/main/java/org/onap/policy/clamp/authorization/UserService.java b/src/main/java/org/onap/policy/clamp/authorization/UserService.java index c748a5a54..96347f82f 100644 --- a/src/main/java/org/onap/policy/clamp/authorization/UserService.java +++ b/src/main/java/org/onap/policy/clamp/authorization/UserService.java @@ -22,8 +22,6 @@ package org.onap.policy.clamp.authorization; - -import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Controller; @@ -34,14 +32,12 @@ import org.springframework.stereotype.Controller; @Controller public class UserService { - private SecurityContext securityContext = SecurityContextHolder.getContext(); - /** * REST service that returns the username. * * @return the user name */ public String getUser() { - return AuthorizationController.getPrincipalName(securityContext); + return AuthorizationController.getPrincipalName(SecurityContextHolder.getContext()); } }
\ No newline at end of file diff --git a/src/main/java/org/onap/policy/clamp/clds/Application.java b/src/main/java/org/onap/policy/clamp/clds/Application.java index 79247ca63..17f08c973 100644 --- a/src/main/java/org/onap/policy/clamp/clds/Application.java +++ b/src/main/java/org/onap/policy/clamp/clds/Application.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * ONAP CLAMP + * ONAP POLICY-CLAMP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Modifications Copyright (c) 2019 Samsung @@ -35,6 +35,7 @@ import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Enumeration; +import org.apache.camel.component.servlet.springboot.ServletMappingAutoConfiguration; import org.apache.catalina.connector.Connector; import org.onap.policy.clamp.clds.util.ClampVersioning; import org.onap.policy.clamp.clds.util.ResourceFileUtils; @@ -61,10 +62,11 @@ import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.transaction.annotation.EnableTransactionManagement; -@ComponentScan(basePackages = { "org.onap.policy.clamp" }) -@SpringBootApplication(exclude = { SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class }) -@EnableJpaRepositories(basePackages = { "org.onap.policy.clamp" }) -@EntityScan(basePackages = { "org.onap.policy.clamp" }) +@ComponentScan(basePackages = {"org.onap.policy.clamp"}) +@SpringBootApplication(exclude = {SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class, + ServletMappingAutoConfiguration.class}) +@EnableJpaRepositories(basePackages = {"org.onap.policy.clamp"}) +@EntityScan(basePackages = {"org.onap.policy.clamp"}) @EnableTransactionManagement @EnableConfigurationProperties @EnableAsync @@ -95,6 +97,10 @@ public class Application extends SpringBootServletInitializer { return application.sources(Application.class); } + /** + * Main method that starts the Clamp backend. + * @param args app params + */ public static void main(String[] args) { // Start the Spring application SpringApplication.run(Application.class, args); diff --git a/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java b/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java index ff79ef413..085e905e9 100644 --- a/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java +++ b/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java @@ -74,12 +74,10 @@ public class CdsServices { public CdsBpWorkFlowListResponse getBlueprintWorkflowList(String blueprintName, String blueprintVersion) {
LoggingUtils.setTargetContext("CDS", "getBlueprintWorkflowList");
- Exchange myCamelExchange = ExchangeBuilder.anExchange(camelContext)
- .withProperty("blueprintName", blueprintName).withProperty("blueprintVersion", blueprintVersion)
- .build();
-
Exchange exchangeResponse = camelContext.createProducerTemplate()
- .send("direct:get-blueprint-workflow-list", myCamelExchange);
+ .send("direct:get-blueprint-workflow-list", ExchangeBuilder.anExchange(camelContext)
+ .withProperty("blueprintName", blueprintName).withProperty("blueprintVersion", blueprintVersion)
+ .withProperty("raiseHttpExceptionFlag", true).build());
if (Integer.valueOf(200).equals(exchangeResponse.getIn().getHeader("CamelHttpResponseCode"))) {
String cdsResponse = (String) exchangeResponse.getIn().getBody();
@@ -107,12 +105,10 @@ public class CdsServices { String workflow) {
LoggingUtils.setTargetContext("CDS", "getWorkflowInputProperties");
- Exchange myCamelExchange = ExchangeBuilder.anExchange(camelContext)
- .withBody(getCdsPayloadForWorkFlow(blueprintName, blueprintVersion, workflow))
- .build();
-
Exchange exchangeResponse = camelContext.createProducerTemplate()
- .send("direct:get-blueprint-workflow-input-properties", myCamelExchange);
+ .send("direct:get-blueprint-workflow-input-properties", ExchangeBuilder.anExchange(camelContext)
+ .withBody(getCdsPayloadForWorkFlow(blueprintName, blueprintVersion, workflow))
+ .withProperty("raiseHttpExceptionFlag", true).build());
if (Integer.valueOf(200).equals(exchangeResponse.getIn().getHeader("CamelHttpResponseCode"))) {
String cdsResponse = (String) exchangeResponse.getIn().getBody();
@@ -159,9 +155,9 @@ public class CdsServices { }
private void handleListType(String propertyName,
- JsonObject inputProperty,
- JsonObject dataTypes,
- JsonObject inputObject) {
+ JsonObject inputProperty,
+ JsonObject dataTypes,
+ JsonObject inputObject) {
if (inputProperty.get("entry_schema") == null) {
throw new CdsParametersException("Entry schema is null for " + propertyName);
}
diff --git a/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java b/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java index fed061e7d..1956a962f 100644 --- a/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java +++ b/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java @@ -109,7 +109,7 @@ public class DcaeInventoryServices { for (int i = 0; i < retryLimit; i++) {
Exchange myCamelExchange = ExchangeBuilder.anExchange(camelContext)
.withProperty("blueprintResourceId", resourceUuid).withProperty("blueprintServiceId", serviceUuid)
- .withProperty("blueprintName", artifactName).build();
+ .withProperty("blueprintName", artifactName).withProperty("raiseHttpExceptionFlag", true).build();
metricsLogger.info("Attempt n°" + i + " to contact DCAE inventory");
Exchange exchangeResponse = camelContext.createProducerTemplate()
diff --git a/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java b/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java index 9431f40e8..5f10c0afb 100644 --- a/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java +++ b/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * ONAP CLAMP + * ONAP POLICY-CLAMP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights + * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,112 +23,144 @@ package org.onap.policy.clamp.clds.config; import java.io.IOException; -import java.net.URL; import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; +import java.util.Objects; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManagerFactory; import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.http4.HttpClientConfigurer; -import org.apache.camel.component.http4.HttpComponent; +import org.apache.camel.component.http.HttpComponent; import org.apache.camel.model.rest.RestBindingMode; +import org.apache.http.client.config.RequestConfig; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.PlainConnectionSocketFactory; import org.apache.http.conn.ssl.SSLSocketFactory; -import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.BasicHttpClientConnectionManager; import org.onap.policy.clamp.clds.util.ClampVersioning; import org.onap.policy.clamp.clds.util.ResourceFileUtils; import org.onap.policy.clamp.util.PassDecoder; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class CamelConfiguration extends RouteBuilder { + private static final String HTTP = "http"; + private static final String HTTPS = "https"; + @Autowired CamelContext camelContext; + @Value("${server.ssl.key-store:#{null}}") + private String keyStore; + + @Value("${server.ssl.key-store-type:JKS}") + private String keyStoreType; + + @Value("${server.ssl.key-store-password:#{null}}") + private String keyStorePass; + + @Value("${server.ssl.trust-store:#{null}}") + private String trustStore; + + @Value("${server.ssl.trust-store-password:#{null}}") + private String trustStorePass; + + @Value("${server.ssl.trust-store-type:JKS}") + private String trustStoreType; + + @Value("${server.ssl.trust-store-algorithm:PKIX}") + private String trustStoreAlgorithm; + + @Value("${clamp.config.httpclient.connectTimeout:-1}") + private int connectTimeout; + + @Value("${clamp.config.httpclient.connectRequestTimeout:-1}") + private int connectRequestTimeout; + + @Value("${clamp.config.httpclient.socketTimeout:-1}") + private int socketTimeout; + + @Value("${clamp.config.keyFile:#{null}}") + private String keyFile; + + @Autowired - private Environment env; - - private void configureDefaultSslProperties() throws IOException { - if (env.getProperty("server.ssl.trust-store") != null) { - URL storeResource = Thread.currentThread().getContextClassLoader() - .getResource(env.getProperty("server.ssl.trust-store").replaceFirst("classpath:", "")); - System.setProperty("javax.net.ssl.trustStore", storeResource.getPath()); - String keyFile = env.getProperty("clamp.config.keyFile"); - String trustStorePass = PassDecoder.decode(env.getProperty("server.ssl.trust-store-password"), - keyFile); - System.setProperty("javax.net.ssl.trustStorePassword", trustStorePass); - System.setProperty("javax.net.ssl.trustStoreType", "jks"); - System.setProperty("ssl.TrustManagerFactory.algorithm", "PKIX"); - storeResource = Thread.currentThread().getContextClassLoader() - .getResource(env.getProperty("server.ssl.key-store").replaceFirst("classpath:", "")); - System.setProperty("javax.net.ssl.keyStore", storeResource.getPath()); - - String keyStorePass = PassDecoder.decode(env.getProperty("server.ssl.key-store-password"), - keyFile); - System.setProperty("javax.net.ssl.keyStorePassword", keyStorePass); - System.setProperty("javax.net.ssl.keyStoreType", env.getProperty("server.ssl.key-store-type")); + private ClampProperties clampProperties; + + private void configureDefaultSslProperties() { + if (trustStore != null) { + System.setProperty("javax.net.ssl.trustStore", Thread.currentThread().getContextClassLoader() + .getResource(trustStore.replaceFirst("classpath:", "")).getPath()); + System.setProperty("javax.net.ssl.trustStorePassword", Objects.requireNonNull( + PassDecoder.decode(trustStorePass, keyFile))); + System.setProperty("javax.net.ssl.trustStoreType", trustStoreType); + System.setProperty("ssl.TrustManagerFactory.algorithm", trustStoreAlgorithm); + } + if (keyStore != null) { + System.setProperty("javax.net.ssl.keyStore", Thread.currentThread().getContextClassLoader() + .getResource(keyStore.replaceFirst("classpath:", "")).getPath()); + System.setProperty("javax.net.ssl.keyStorePassword", Objects.requireNonNull( + PassDecoder.decode(keyStorePass, keyFile))); + System.setProperty("javax.net.ssl.keyStoreType", keyStoreType); } + } - private void registerTrustStore() - throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException, CertificateException, IOException { - if (env.getProperty("server.ssl.trust-store") != null) { - KeyStore truststore = KeyStore.getInstance("JKS"); - String keyFile = env.getProperty("clamp.config.keyFile"); - String password = PassDecoder.decode(env.getProperty("server.ssl.trust-store-password"), keyFile); - truststore.load( - ResourceFileUtils.getResourceAsStream(env.getProperty("server.ssl.trust-store")), - password.toCharArray()); + private void configureCamelHttpComponent() + throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException, CertificateException, + IOException { + RequestConfig requestConfig = RequestConfig.custom() + .setConnectTimeout(connectTimeout) + .setConnectionRequestTimeout(connectRequestTimeout) + .setSocketTimeout(socketTimeout).build(); - TrustManagerFactory trustFactory = TrustManagerFactory.getInstance("PKIX"); + if (trustStore != null) { + KeyStore truststore = KeyStore.getInstance(trustStoreType); + truststore.load( + ResourceFileUtils.getResourceAsStream(trustStore), + Objects.requireNonNull(PassDecoder.decode(trustStorePass, keyFile)).toCharArray()); + TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(trustStoreAlgorithm); trustFactory.init(truststore); SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, trustFactory.getTrustManagers(), null); - SSLSocketFactory factory = new SSLSocketFactory(sslcontext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - SchemeRegistry registry = new SchemeRegistry(); - final Scheme scheme = new Scheme("https4", 443, factory); - registry.register(scheme); - ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory(); - HttpComponent http4 = camelContext.getComponent("https4", HttpComponent.class); - http4.setHttpClientConfigurer(new HttpClientConfigurer() { - - @Override - public void configureHttpClient(HttpClientBuilder builder) { - builder.setSSLSocketFactory(factory); - Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() - .register("https", factory).register("http", plainsf).build(); - builder.setConnectionManager(new BasicHttpClientConnectionManager(registry)); - } + camelContext.getComponent(HTTPS, HttpComponent.class).setHttpClientConfigurer(builder -> { + SSLSocketFactory factory = new SSLSocketFactory(sslcontext, + SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + builder.setSSLSocketFactory(factory); + builder.setConnectionManager(new BasicHttpClientConnectionManager( + RegistryBuilder.<ConnectionSocketFactory>create().register(HTTPS, factory).build())) + .setDefaultRequestConfig(requestConfig); }); } + camelContext.getComponent(HTTP, HttpComponent.class).setHttpClientConfigurer(builder -> { + Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() + .register(HTTP, PlainConnectionSocketFactory.getSocketFactory()).build(); + builder.setConnectionManager(new BasicHttpClientConnectionManager(registry)) + .setDefaultRequestConfig(requestConfig); + }); } @Override public void configure() - throws KeyManagementException, KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { + throws KeyManagementException, KeyStoreException, NoSuchAlgorithmException, CertificateException, + IOException { restConfiguration().component("servlet").bindingMode(RestBindingMode.json).jsonDataFormat("clamp-gson") - .dataFormatProperty("prettyPrint", "true")// .enableCORS(true) - // turn on swagger api-doc - .apiContextPath("api-doc").apiVendorExtension(true).apiProperty("api.title", "Clamp Rest API") - .apiProperty("api.version", ClampVersioning.getCldsVersionFromProps()) - .apiProperty("base.path", "/restservices/clds/"); - - // camelContext.setTracing(true); + .dataFormatProperty("prettyPrint", "true")// .enableCORS(true) + // turn on swagger api-doc + .apiContextPath("api-doc").apiVendorExtension(true).apiProperty("api.title", "Clamp Rest API") + .apiProperty("api.version", ClampVersioning.getCldsVersionFromProps()) + .apiProperty("base.path", "/restservices/clds/"); + // Configure httpClient properties for Camel HTTP/HTTPS calls configureDefaultSslProperties(); - registerTrustStore(); + configureCamelHttpComponent(); } } diff --git a/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java b/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java index d7a158e73..b5f9837b0 100644 --- a/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java +++ b/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * ONAP CLAMP + * ONAP POLICY-CLAMP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -62,10 +62,10 @@ public class LoggingUtils { private static final String EMPTY_MESSAGE = ""; /** Logger delegate. */ - private Logger mlogger; + private final Logger mlogger; /** Automatic UUID, overrideable per adapter or per invocation. */ - private static UUID sInstanceUUID = UUID.randomUUID(); + private static final UUID sInstanceUUID = UUID.randomUUID(); /** * Constructor. diff --git a/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java b/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java index e5f12163e..95d1fe182 100644 --- a/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java +++ b/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,7 +34,7 @@ import java.nio.charset.StandardCharsets; import org.apache.camel.Exchange; import org.apache.camel.spi.DataFormat; import org.apache.camel.spi.DataFormatName; -import org.apache.camel.support.ServiceSupport; +import org.apache.camel.support.service.ServiceSupport; import org.apache.camel.util.IOHelper; import org.onap.policy.clamp.clds.util.JsonUtils; diff --git a/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java b/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java index 1b36aab55..6a935d011 100644 --- a/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java +++ b/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * ONAP CLAMP + * ONAP POLICY-CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -125,7 +125,7 @@ public class DcaeComponent extends ExternalComponent { * @return the Right Url modified if needed */ public static String getStatusUrl(DcaeOperationStatusResponse dcaeResponse) { - return dcaeResponse.getLinks().getStatus().replaceAll("http:", "http4:").replaceAll("https:", "https4:"); + return dcaeResponse.getLinks().getStatus(); } /** diff --git a/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java b/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java index bdd77cb41..1a936bbca 100644 --- a/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java +++ b/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * ONAP CLAMP + * ONAP POLICY-CLAMP * ================================================================================ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. @@ -145,8 +145,9 @@ public class PolicyEngineServices { * @return A yaml containing all policy Types and all data types */ public String downloadAllPolicyModels() { - return callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-policy-models", - "Get all policies models"); + return callCamelRoute( + ExchangeBuilder.anExchange(camelContext).withProperty("raiseHttpExceptionFlag", true).build(), + "direct:get-all-policy-models", "Get all policies models"); } /** @@ -166,7 +167,8 @@ public class PolicyEngineServices { Yaml yamlParser = new Yaml(options); String responseBody = callCamelRoute( ExchangeBuilder.anExchange(camelContext).withProperty("policyModelType", policyType) - .withProperty("policyModelVersion", policyVersion).build(), "direct:get-policy-tosca-model", + .withProperty("policyModelVersion", policyVersion).withProperty("raiseHttpExceptionFlag", true) + .build(), "direct:get-policy-tosca-model", "Get one policy"); if (responseBody == null || responseBody.isEmpty()) { @@ -182,8 +184,9 @@ public class PolicyEngineServices { */ public void downloadPdpGroups() { String responseBody = - callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-pdp-groups", - "Get Pdp Groups"); + callCamelRoute( + ExchangeBuilder.anExchange(camelContext).withProperty("raiseHttpExceptionFlag", true).build(), + "direct:get-all-pdp-groups", "Get Pdp Groups"); if (responseBody == null || responseBody.isEmpty()) { logger.warn("getPdpGroups returned by policy engine could not be decoded, as it's null or empty"); diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties index f398f8d98..f7f9229f6 100644 --- a/src/main/resources/application-noaaf.properties +++ b/src/main/resources/application-noaaf.properties @@ -1,8 +1,8 @@ ### # ============LICENSE_START======================================================= -# ONAP CLAMP +# ONAP POLICY-CLAMP # ================================================================================ -# Copyright (C) 2017-2019,2021 AT&T Intellectual Property. All rights +# Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights # reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); @@ -90,10 +90,10 @@ camel.defaultthreadpool.maxpoolsize=20 camel.defaultthreadpool.maxqueuesize=1000 camel.defaultthreadpool.keepaliveTime=60 camel.defaultthreadpool.rejectpolicy=CallerRuns -#camel.springboot.xmlRoutes = false -camel.springboot.xmlRoutes=classpath:/clds/camel/routes/*.xml -camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml -#camel.springboot.typeConversion = false +camel.springboot.xml-routes=classpath:/clds/camel/routes/*.xml +camel.springboot.xml-rests=classpath:/clds/camel/rest/*.xml +camel.springboot.backlog-tracing=true +camel.springboot.tracing=true #clds datasource connection details spring.datasource.driverClassName=org.mariadb.jdbc.Driver @@ -141,12 +141,15 @@ clamp.config.files.cldsUsers=classpath:/clds/clds-users.json clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json +clamp.config.httpclient.socketTimeout=20000 +clamp.config.httpclient.connectTimeout=10000 + # # Configuration Settings for Policy Engine Components -clamp.config.policy.api.url=http4://localhost:8085 +clamp.config.policy.api.url=http://localhost:8085 clamp.config.policy.api.userName=healthcheck clamp.config.policy.api.password=zb!XztG34 -clamp.config.policy.pap.url=http4://localhost:8085 +clamp.config.policy.pap.url=http://localhost:8085 clamp.config.policy.pap.userName=healthcheck clamp.config.policy.pap.password=zb!XztG34 @@ -155,12 +158,12 @@ clamp.config.policy.pap.password=zb!XztG34 clamp.config.sdc.csarFolder = /tmp/sdc-controllers #DCAE Inventory Url Properties -clamp.config.dcae.inventory.url=http4://localhost:8085 +clamp.config.dcae.inventory.url=http://localhost:8085 clamp.config.dcae.intentory.retry.interval=10000 clamp.config.dcae.intentory.retry.limit=5 #DCAE Deployment Url Properties -clamp.config.dcae.deployment.url=http4://localhost:8085 +clamp.config.dcae.deployment.url=http://localhost:8085 clamp.config.dcae.deployment.userName=test clamp.config.dcae.deployment.password=test @@ -182,6 +185,6 @@ clamp.config.tosca.converter.default.datatypes=classpath:/clds/tosca-converter/d clamp.config.tosca.converter.dictionary.support.enabled=true # Configuration settings for CDS -clamp.config.cds.url=http4://cds-blueprints-processor-http:8080 +clamp.config.cds.url=http://cds-blueprints-processor-http:8080 clamp.config.cds.userName=ccsdkapps clamp.config.cds.password=ccsdkapps
\ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 97870d2b6..a4a51091f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ ### # ============LICENSE_START======================================================= -# ONAP CLAMP +# ONAP POLICY-CLAMP # ================================================================================ # Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights # reserved. @@ -95,10 +95,10 @@ camel.defaultthreadpool.maxpoolsize=20 camel.defaultthreadpool.maxqueuesize=1000 camel.defaultthreadpool.keepaliveTime=60 camel.defaultthreadpool.rejectpolicy=CallerRuns -#camel.springboot.xmlRoutes = false -camel.springboot.xmlRoutes=classpath:/clds/camel/routes/*.xml -camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml -#camel.springboot.typeConversion = false +camel.springboot.xml-routes=classpath:/clds/camel/routes/*.xml +camel.springboot.xml-rests=classpath:/clds/camel/rest/*.xml +camel.springboot.backlog-tracing=true +camel.springboot.tracing=true #clds datasource connection details spring.datasource.driverClassName=org.mariadb.jdbc.Driver @@ -144,12 +144,14 @@ clamp.config.files.cldsUsers=classpath:/clds/clds-users.json clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json +clamp.config.httpclient.socketTimeout=20000 +clamp.config.httpclient.connectTimeout=10000 # # Configuration Settings for Policy Engine Components -clamp.config.policy.api.url=http4://policy.api.simpledemo.onap.org:6969 +clamp.config.policy.api.url=http://policy.api.simpledemo.onap.org:6969 clamp.config.policy.api.userName=healthcheck clamp.config.policy.api.password=zb!XztG34 -clamp.config.policy.pap.url=http4://policy.api.simpledemo.onap.org:6969 +clamp.config.policy.pap.url=http://policy.api.simpledemo.onap.org:6969 clamp.config.policy.pap.userName=healthcheck clamp.config.policy.pap.password=zb!XztG34 @@ -158,12 +160,12 @@ clamp.config.policy.pap.password=zb!XztG34 clamp.config.sdc.csarFolder=/tmp/sdc-controllers #DCAE Inventory Url Properties -clamp.config.dcae.inventory.url=http4://dcae.api.simpledemo.onap.org:8080 +clamp.config.dcae.inventory.url=http://dcae.api.simpledemo.onap.org:8080 clamp.config.dcae.intentory.retry.interval=10000 clamp.config.dcae.intentory.retry.limit=5 #DCAE Deployment Url Properties -clamp.config.dcae.deployment.url=http4://dcae.api.simpledemo.onap.org:8188 +clamp.config.dcae.deployment.url=http://dcae.api.simpledemo.onap.org:8188 clamp.config.dcae.deployment.userName=test clamp.config.dcae.deployment.password=test @@ -196,6 +198,6 @@ clamp.config.tosca.converter.default.datatypes=classpath:/clds/tosca-converter/d clamp.config.tosca.converter.dictionary.support.enabled=true # Configuration settings for CDS -clamp.config.cds.url=http4://cds-blueprints-processor-http:8080 +clamp.config.cds.url=http://cds-blueprints-processor-http:8080 clamp.config.cds.userName=ccsdkapps clamp.config.cds.password=ccsdkapps
\ No newline at end of file diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 7129c2828..fe94460c4 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -23,7 +23,7 @@ <log loggingLevel="ERROR" message="GET All Loop names FAILED: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -56,7 +56,7 @@ <log loggingLevel="ERROR" message="GET Loop request failed for loop: ${header.loopName}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -77,7 +77,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Update the global properties')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')"/> - <setHeader headerName="GlobalPropertiesJson"> + <setHeader name="GlobalPropertiesJson"> <simple>${body}</simple> </setHeader> <to uri="direct:load-loop"/> @@ -97,7 +97,7 @@ <log loggingLevel="ERROR" message="UPDATE Global properties FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -117,7 +117,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Update operational policies')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')"/> - <setHeader headerName="OperationalPoliciesArray"> + <setHeader name="OperationalPoliciesArray"> <simple>${body}</simple> </setHeader> <to uri="direct:load-loop"/> @@ -139,7 +139,7 @@ <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('UPDATE Operational policies request FAILED, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -161,7 +161,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Update Microservice policies')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')"/> - <setProperty propertyName="MicroServicePolicyObject"> + <setProperty name="MicroServicePolicyObject"> <simple>${body}</simple> </setProperty> @@ -183,7 +183,7 @@ message="UPDATE MicroService policy FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('UPDATE MicroService policy request FAILED, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -200,9 +200,6 @@ <doTry> <log loggingLevel="INFO" message="DCAE DEPLOY request for loop: ${header.loopName}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> - <simple resultType="java.lang.Boolean">true</simple> - </setProperty> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'DCAE DEPLOY request')"/> <to @@ -210,7 +207,6 @@ <to uri="direct:load-loop"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('DCAE DEPLOY request','INFO',${exchangeProperty[loopObject]})"/> - <to uri="direct:deploy-loop"/> <log loggingLevel="INFO" @@ -230,7 +226,7 @@ message="DEPLOY request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('DEPLOY request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -273,7 +269,7 @@ message="REFRESH json schema request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('REFRESH Json schema request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -316,7 +312,7 @@ message="REFRESH json schema request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('REFRESH Json schema request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -333,9 +329,6 @@ <doTry> <log loggingLevel="INFO" message="DCAE UNDEPLOY request for loop: ${header.loopName}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> - <simple resultType="java.lang.Boolean">true</simple> - </setProperty> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'DCAE UNDEPLOY request')"/> <to @@ -362,7 +355,7 @@ message="UNDEPLOY request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('UNDEPLOY request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -379,7 +372,7 @@ <doTry> <log loggingLevel="INFO" message="STOP request for loop: ${header.loopName}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">true</simple> </setProperty> <to @@ -408,7 +401,7 @@ message="STOP request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('STOP request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -425,9 +418,6 @@ <doTry> <log loggingLevel="INFO" message="RESTART request for loop: ${header.loopName}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> - <simple resultType="java.lang.Boolean">true</simple> - </setProperty> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*,'RESTART request')"/> <to @@ -455,7 +445,7 @@ message="RESTART request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('RESTART request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -472,7 +462,7 @@ <doTry> <log loggingLevel="INFO" message="POLICY SUBMIT request for loop: ${header.loopName}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">true</simple> </setProperty> <to @@ -482,7 +472,7 @@ <to uri="direct:load-loop"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('POLICY SUBMIT request','INFO',${exchangeProperty[loopObject]})"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:remove-all-policy-from-active-pdp-group"/> @@ -491,12 +481,12 @@ <split> <simple>${exchangeProperty[loopObject].getMicroServicePolicies()} </simple> - <setProperty propertyName="policy"> + <setProperty name="policy"> <simple>${body}</simple> </setProperty> <log loggingLevel="INFO" message="Processing Micro Service Policy: ${exchangeProperty[policy].getName()}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:delete-policy-from-loop-object"/> @@ -507,12 +497,12 @@ <split> <simple>${exchangeProperty[loopObject].getOperationalPolicies()} </simple> - <setProperty propertyName="policy"> + <setProperty name="policy"> <simple>${body}</simple> </setProperty> <log loggingLevel="INFO" message="Processing Operational Policy: ${exchangeProperty[policy].getName()}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> @@ -543,7 +533,7 @@ message="SUBMIT request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('SUBMIT request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -559,7 +549,7 @@ <doTry> <log loggingLevel="INFO" message="DELETE request for loop: ${header.loopName}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">true</simple> </setProperty> <to @@ -576,12 +566,12 @@ <split> <simple>${exchangeProperty[loopObject].getMicroServicePolicies()} </simple> - <setProperty propertyName="policy"> + <setProperty name="policy"> <simple>${body}</simple> </setProperty> <log loggingLevel="INFO" message="Deleting Micro Service Policy: ${exchangeProperty[policy].getName()}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:delete-policy-from-loop-object"/> @@ -591,12 +581,12 @@ <split> <simple>${exchangeProperty[loopObject].getOperationalPolicies()} </simple> - <setProperty propertyName="policy"> + <setProperty name="policy"> <simple>${body}</simple> </setProperty> <log loggingLevel="INFO" message="Deleting Operational Policy: ${exchangeProperty[policy].getName()}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:delete-policy-from-loop-object"/> @@ -618,7 +608,7 @@ message="DELETE request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('DELETE request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -666,7 +656,7 @@ <setBody> <simple>${exchangeProperty[loopObject]}</simple> </setBody> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>200</constant> </setHeader> </doFinally> @@ -701,7 +691,7 @@ message="ADD operational policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('ADD OperationalPolicy request failed','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -724,17 +714,17 @@ <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')"/> <to uri="direct:load-loop"/> - <setProperty propertyName="policyName"> + <setProperty name="policyName"> <simple>${header.policyName}</simple> </setProperty> - <setProperty propertyName="policy"> + <setProperty name="policy"> <simple>${exchangeProperty[loopObject].getOperationalPolicy(header.policyName)}</simple> </setProperty> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:remove-one-policy-from-active-pdp-group"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:delete-policy-from-loop-object"/> @@ -755,7 +745,7 @@ message="REMOVE operational policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('REMOVE OperationalPolicy request failed','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -793,7 +783,7 @@ message="CREATE Loop from Template request failed for loop: ${header.loopName}, ${exception.stacktrace}"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('CREATE Loop from template request failed','ERROR',${exchangeProperty[loopObject]})"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -826,7 +816,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET ALL templates request failed: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -860,7 +850,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET Template request failed for template: ${header.templateName}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -892,7 +882,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET All Template names request failed for template: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -926,7 +916,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET Dictionary request failed: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -959,7 +949,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET Dictionary request failed: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -992,7 +982,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET Dictionary request failed for: ${header.dictionaryName}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1011,7 +1001,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Add New or Update Dictionary')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'tosca','','update')"/> - <setProperty propertyName="DictionaryObject"> + <setProperty name="DictionaryObject"> <simple>${body}</simple> </setProperty> <to @@ -1027,7 +1017,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="PUT Dictionary request failed for: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1049,7 +1039,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Add New or Update Dictionary Element')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'tosca','','update')"/> - <setProperty propertyName="DictionaryObject"> + <setProperty name="DictionaryObject"> <simple>${body}</simple> </setProperty> <to @@ -1065,7 +1055,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="PUT Dictionary request failed for: ${header.name}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1097,7 +1087,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="DELETE Dictionary request failed for: ${header.name}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1131,7 +1121,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="DELETE Dictionary element request failed for: ${header.name}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1165,7 +1155,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET Policy Models request failed for: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1198,7 +1188,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET Policy Model request failed for type: ${header.policyModelType}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1231,7 +1221,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET Policy Model YAML request failed for type: ${header.policyModelType}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1253,7 +1243,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Upload New or Update Tosca Policy Model')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'tosca','','update')"/> - <setProperty propertyName="PolicyModelTosca"> + <setProperty name="PolicyModelTosca"> <simple>${body}</simple> </setProperty> <to @@ -1269,7 +1259,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="POST Policy Model YAML request failed: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1291,7 +1281,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Upload New or Update Tosca Policy Model')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'tosca','','update')"/> - <setProperty propertyName="PolicyModelTosca"> + <setProperty name="PolicyModelTosca"> <simple>${body}</simple> </setProperty> <to @@ -1307,7 +1297,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="MODIFY Policy Model YAML request failed: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1327,13 +1317,15 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'GET Policies List ')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'policies','','read')"/> - + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> <to uri="direct:get-all-policies"/> - <setProperty propertyName="policiesListResponse"> + <setProperty name="policiesListResponse"> <simple>${body}</simple> </setProperty> <to uri="direct:get-all-pdp-groups"/> - <setProperty propertyName="pdpGroupInfoResponse"> + <setProperty name="pdpGroupInfoResponse"> <simple>${body}</simple> </setProperty> <setBody> @@ -1351,7 +1343,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="GET Policies list JSON request failed: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1376,13 +1368,16 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'CREATE a new Policy ')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'policies','','update')"/> - <setProperty propertyName="policyModelType"> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> + <setProperty name="policyModelType"> <simple>${header.policyModelType}</simple> </setProperty> - <setProperty propertyName="policyModelVersion"> + <setProperty name="policyModelVersion"> <simple>${header.policyModelVersion}</simple> </setProperty> - <setProperty propertyName="policyProperties"> + <setProperty name="policyProperties"> <simple>${body}</simple> </setProperty> <to @@ -1404,7 +1399,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="CREATE Policy request failed for type: ${header.policyModelType}/${header.policyModelVersion}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1424,19 +1419,22 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'DELETE a Policy ')"/> <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'policies','','update')"/> - <setProperty propertyName="policyModelType"> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> + <setProperty name="policyModelType"> <simple>${header.policyModelType}</simple> </setProperty> - <setProperty propertyName="policyModelVersion"> + <setProperty name="policyModelVersion"> <simple>${header.policyModelVersion}</simple> </setProperty> - <setProperty propertyName="policyName"> + <setProperty name="policyName"> <simple>${header.policyName}</simple> </setProperty> - <setProperty propertyName="policyVersion"> + <setProperty name="policyVersion"> <simple>${header.policyVersion}</simple> </setProperty> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:undeploy-one-policy-from-pap"/> @@ -1452,7 +1450,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="DELETE Policy request failed for policy: ${header.policyName}/${header.policyVersion}, ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> @@ -1478,6 +1476,9 @@ </setBody> <log loggingLevel="INFO" message="PDP Group DEPLOY request payload: ${body}"/> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> <to uri="direct:add-multiple-policies-to-pdp-group"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=endLog()"/> @@ -1490,7 +1491,7 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/> <log loggingLevel="ERROR" message="PDP Group deployment request failed: ${exception.stacktrace}"/> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>500</constant> </setHeader> <setBody> diff --git a/src/main/resources/clds/camel/rest/clds-services.xml b/src/main/resources/clds/camel/rest/clds-services.xml index 61e1efbdc..aa4c3cbee 100644 --- a/src/main/resources/clds/camel/rest/clds-services.xml +++ b/src/main/resources/clds/camel/rest/clds-services.xml @@ -9,7 +9,7 @@ </setBody> <when> <simple> ${body} == 'NOT-OK'</simple> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>404</constant> </setHeader> <log loggingLevel="ERROR" message="HealthCheck failed" /> diff --git a/src/main/resources/clds/camel/routes/cds-flows.xml b/src/main/resources/clds/camel/routes/cds-flows.xml index 73f8cb849..10fcb091e 100644 --- a/src/main/resources/clds/camel/routes/cds-flows.xml +++ b/src/main/resources/clds/camel/routes/cds-flows.xml @@ -5,15 +5,15 @@ message="Getting blueprint workflow list from CDS"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('CDS', 'Getting workflow list from CDS')"/> <doTry> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="Content-Type"> + <setHeader name="Content-Type"> <constant>application/json</constant> </setHeader> <log loggingLevel="INFO" message="Endpoint to query workflows from CDS : {{clamp.config.cds.url}}/api/v1/blueprint-model/workflows/blueprint-name/${exchangeProperty[blueprintName]}/version/${exchangeProperty[blueprintVersion]}"></log> - <toD uri="{{clamp.config.cds.url}}/api/v1/blueprint-model/workflows/blueprint-name/${exchangeProperty[blueprintName]}/version/${exchangeProperty[blueprintVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.cds.userName}}&authPassword={{clamp.config.cds.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=30000&authenticationPreemptive=true&connectionClose=true"/> + <toD uri="{{clamp.config.cds.url}}/api/v1/blueprint-model/workflows/blueprint-name/${exchangeProperty[blueprintName]}/version/${exchangeProperty[blueprintVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.cds.userName}}&authPassword={{clamp.config.cds.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> <doCatch> <exception>java.lang.Exception</exception> @@ -36,15 +36,15 @@ message="Getting blueprint input properties for workflow"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('CDS', 'Getting input properties for workflow')"/> <doTry> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>POST</constant> </setHeader> - <setHeader headerName="Content-Type"> + <setHeader name="Content-Type"> <constant>application/json</constant> </setHeader> <log loggingLevel="INFO" message="Endpoint to query input properties for workflow from CDS : {{clamp.config.cds.url}}/api/v1/blueprint-model/workflow-spec"></log> - <toD uri="{{clamp.config.cds.url}}/api/v1/blueprint-model/workflow-spec?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.cds.userName}}&authPassword={{clamp.config.cds.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=30000&authenticationPreemptive=true&connectionClose=true"/> + <toD uri="{{clamp.config.cds.url}}/api/v1/blueprint-model/workflow-spec?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.cds.userName}}&authPassword={{clamp.config.cds.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> <doCatch> <exception>java.lang.Exception</exception> diff --git a/src/main/resources/clds/camel/routes/dcae-flows.xml b/src/main/resources/clds/camel/routes/dcae-flows.xml index 1a0eb7b9a..d74bd91bf 100644 --- a/src/main/resources/clds/camel/routes/dcae-flows.xml +++ b/src/main/resources/clds/camel/routes/dcae-flows.xml @@ -5,11 +5,17 @@ <when> <simple>${exchangeProperty['loopObject'].getLoopTemplate().getUniqueBlueprint()} == true </simple> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> <to uri="direct:deploy-loop-single-blueprint"/> </when> <when> <simple>${exchangeProperty['loopObject'].getLoopTemplate().getUniqueBlueprint()} == false </simple> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> <to uri="direct:deploy-loop-multi-blueprint"/> </when> </choice> @@ -24,51 +30,51 @@ <split> <simple>${exchangeProperty[loopObject].getMicroServicePolicies()} </simple> - <setProperty propertyName="microServicePolicy"> + <setProperty name="microServicePolicy"> <simple>${body}</simple> </setProperty> <log loggingLevel="INFO" message="Processing Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <setBody> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="getDeployPayload(${exchangeProperty[loopObject]},${exchangeProperty[microServicePolicy]})"/> </setBody> - <setProperty propertyName="dcaeDeploymentId"> + <setProperty name="dcaeDeploymentId"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="generateDeploymentId()"/> </setProperty> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>PUT</constant> </setHeader> - <setHeader headerName="Content-Type"> + <setHeader name="Content-Type"> <constant>application/json</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to deploy loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}"></log> <toD - uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=300000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> - <setProperty propertyName="dcaeResponse"> + <setProperty name="dcaeResponse"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="convertDcaeResponse(${body})"/> </setProperty> - <setProperty propertyName="dcaeStatusUrl"> + <setProperty name="dcaeStatusUrl"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="getStatusUrl(${exchangeProperty[dcaeResponse]})"/> </setProperty> @@ -82,14 +88,14 @@ <handled> <constant>false</constant> </handled> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>DEPLOY micro service failed (MicroService name:${exchangeProperty[microServicePolicy].getName()}), Dep-id:${exchangeProperty[dcaeDeploymentId]}, StatusUrl:${exchangeProperty[dcaeStatusUrl]}) </simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>DCAE</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -112,40 +118,40 @@ <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="getDeployPayload(${exchangeProperty[loopObject]})"/> </setBody> - <setProperty propertyName="dcaeDeploymentId"> + <setProperty name="dcaeDeploymentId"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="generateDeploymentId()"/> </setProperty> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>PUT</constant> </setHeader> - <setHeader headerName="Content-Type"> + <setHeader name="Content-Type"> <constant>application/json</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to deploy loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}"></log> <toD - uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=300000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> - <setProperty propertyName="dcaeResponse"> + <setProperty name="dcaeResponse"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="convertDcaeResponse(${body})"/> </setProperty> - <setProperty propertyName="dcaeStatusUrl"> + <setProperty name="dcaeStatusUrl"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="getStatusUrl(${exchangeProperty[dcaeResponse]})"/> </setProperty> @@ -155,13 +161,13 @@ <to uri="direct:reset-raise-http-exception-flag"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>DEPLOY loop status (Dep-id:${exchangeProperty[dcaeDeploymentId]}, StatusUrl:${exchangeProperty[dcaeStatusUrl]}) </simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>DCAE</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -174,11 +180,17 @@ <when> <simple>${exchangeProperty['loopObject'].getLoopTemplate().getUniqueBlueprint()} == true </simple> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> <to uri="direct:undeploy-loop-single-blueprint"/> </when> <when> <simple>${exchangeProperty['loopObject'].getLoopTemplate().getUniqueBlueprint()} == false </simple> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> <to uri="direct:undeploy-loop-multi-blueprint"/> </when> </choice> @@ -193,7 +205,7 @@ <split> <simple>${exchangeProperty[loopObject].getMicroServicePolicies()} </simple> - <setProperty propertyName="microServicePolicy"> + <setProperty name="microServicePolicy"> <simple>${body}</simple> </setProperty> <log @@ -207,34 +219,34 @@ <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="getUndeployPayload(${exchangeProperty[microServicePolicy]})"/> </setBody> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>DELETE</constant> </setHeader> - <setHeader headerName="Content-Type"> + <setHeader name="Content-Type"> <constant>application/json</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to undeploy loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[microServicePolicy].getDcaeDeploymentId()}"></log> <toD - uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[microServicePolicy].getDcaeDeploymentId()}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=300000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[microServicePolicy].getDcaeDeploymentId()}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> - <setProperty propertyName="dcaeResponse"> + <setProperty name="dcaeResponse"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="convertDcaeResponse(${body})"/> </setProperty> - <setProperty propertyName="dcaeStatusUrl"> + <setProperty name="dcaeStatusUrl"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="getStatusUrl(${exchangeProperty[dcaeResponse]})"/> </setProperty> @@ -244,7 +256,7 @@ uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLogForComponent('Undeploy for the micro service: ${exchangeProperty[microServicePolicy].getName()} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText}','INFO','DCAE',${exchangeProperty[loopObject]})"/> </when> <otherwise> - <log loggingLevel="WARNING" + <log loggingLevel="WARN" message="Cannot Undeploy for the micro service: ${exchangeProperty[microServicePolicy].getName()}, the Deployment ID does not exist !"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLogForComponent('Cannot Undeploy for the micro service: ${exchangeProperty[microServicePolicy].getName()}, the Deployment ID does not exist !','WARNING','DCAE',${exchangeProperty[loopObject]})"/> @@ -256,12 +268,12 @@ <handled> <constant>false</constant> </handled> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>UNDEPLOY micro service failed (MicroService name:${exchangeProperty[microServicePolicy].getName()}) </simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>DCAE</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -281,43 +293,41 @@ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Undeploying the loop')"/> <choice> <when> - <simple>${exchangeProperty[loopObject].getDcaeDeploymentId()} - != null - </simple> + <simple>${exchangeProperty[loopObject].getDcaeDeploymentId()} != null</simple> <doTry> <setBody> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="getUndeployPayload(${exchangeProperty[loopObject]})"/> </setBody> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>DELETE</constant> </setHeader> - <setHeader headerName="Content-Type"> + <setHeader name="Content-Type"> <constant>application/json</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to undeploy loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[loopObject].getDcaeDeploymentId()}"></log> <toD - uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[loopObject].getDcaeDeploymentId()}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=300000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[loopObject].getDcaeDeploymentId()}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> - <setProperty propertyName="dcaeResponse"> + <setProperty name="dcaeResponse"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="convertDcaeResponse(${body})"/> </setProperty> - <setProperty propertyName="dcaeStatusUrl"> + <setProperty name="dcaeStatusUrl"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="getStatusUrl(${exchangeProperty[dcaeResponse]})"/> </setProperty> @@ -327,10 +337,10 @@ <to uri="direct:reset-raise-http-exception-flag"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>UNDEPLOY loop status</simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>DCAE</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -338,7 +348,7 @@ </doTry> </when> <otherwise> - <log loggingLevel="WARNING" + <log loggingLevel="WARN" message="Cannot Undeploy for the loop: ${exchangeProperty[loopObject].getName()}, the Deployment ID does not exist !"/> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLog('Cannot Undeploy for the loop: ${exchangeProperty[loopObject].getName()}, the Deployment ID does not exist !','WARNING',${exchangeProperty[loopObject]})"/> @@ -352,18 +362,18 @@ <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Getting Deployment status')"/> <doTry> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> @@ -373,18 +383,18 @@ <when> <simple>${exchangeProperty[getStatusUrl].contains("?")} == true </simple> - <setProperty propertyName="uriSeparator"> + <setProperty name="uriSeparator"> <simple>&</simple> </setProperty> </when> <otherwise> - <setProperty propertyName="uriSeparator"> + <setProperty name="uriSeparator"> <simple>?</simple> </setProperty> </otherwise> </choice> <toD - uri="${exchangeProperty[getStatusUrl]}${exchangeProperty[uriSeparator]}bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=30000&authenticationPreemptive=true&connectionClose=true"/> + uri="${exchangeProperty[getStatusUrl]}${exchangeProperty[uriSeparator]}bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&authenticationPreemptive=true&connectionClose=true"/> <doCatch> <exception>java.lang.Exception</exception> <handled> @@ -400,10 +410,10 @@ <to uri="direct:reset-raise-http-exception-flag"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>DCAE deployment status</simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>DCAE</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -417,25 +427,25 @@ <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Getting blueprint id in inventory')"/> <doTry> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to query Dcae inventory Loop status: {{clamp.config.dcae.inventory.url}}/dcae-service-types?${header[CamelHttpQuery]}"></log> <toD - uri="{{clamp.config.dcae.inventory.url}}/dcae-service-types?asdcResourceId=${exchangeProperty[blueprintResourceId]}&asdcServiceId=${exchangeProperty[blueprintServiceId]}&typeName=${exchangeProperty[blueprintName]}&bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=30000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.dcae.inventory.url}}/dcae-service-types?asdcResourceId=${exchangeProperty[blueprintResourceId]}&asdcServiceId=${exchangeProperty[blueprintServiceId]}&typeName=${exchangeProperty[blueprintName]}&bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> @@ -451,33 +461,33 @@ message="Getting all DCAE blueprint from inventory"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Getting all blueprint from inventory')"/> <doTry> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to query Blueprints from DCAE inventory: {{clamp.config.dcae.inventory.url}}/dcae-service-types?${header[CamelHttpQuery]}"></log> - <toD uri="{{clamp.config.dcae.inventory.url}}/dcae-service-types;bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=30000&authenticationPreemptive=true&connectionClose=true"/> + <toD uri="{{clamp.config.dcae.inventory.url}}/dcae-service-types;bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> - <setProperty propertyName="dcaeResponseList"> + <setProperty name="dcaeResponseList"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="convertToDcaeInventoryResponse(${body})"/> </setProperty> <split> <simple>${exchangeProperty[dcaeResponseList]}</simple> <convertBodyTo type="org.onap.policy.clamp.clds.model.dcae.DcaeInventoryResponse"/> - <setProperty propertyName="dcaeResponse"> + <setProperty name="dcaeResponse"> <simple>${body}</simple> </setProperty> <to uri="bean:org.onap.policy.clamp.clds.model.dcae.DcaeInventoryCache?method=addDcaeInventoryResponse(${exchangeProperty[dcaeResponse]})"/> diff --git a/src/main/resources/clds/camel/routes/loop-flows.xml b/src/main/resources/clds/camel/routes/loop-flows.xml index f6a838ef0..4a3cc84b2 100644 --- a/src/main/resources/clds/camel/routes/loop-flows.xml +++ b/src/main/resources/clds/camel/routes/loop-flows.xml @@ -4,13 +4,13 @@ <setBody> <simple>${header.loopName}</simple> </setBody> - <setProperty propertyName="loopObject"> + <setProperty name="loopObject"> <method ref="org.onap.policy.clamp.loop.LoopService" method="getLoop" /> </setProperty> <when> <simple>${exchangeProperty[loopObject]} == null</simple> - <setHeader headerName="CamelHttpResponseCode"> + <setHeader name="CamelHttpResponseCode"> <constant>404</constant> </setHeader> <log loggingLevel="WARN" message="Loop not found in database: ${body}" /> @@ -19,14 +19,14 @@ </route> <route id="update-policy-status-for-loop"> <from uri="direct:update-policy-status-for-loop" /> - <setProperty propertyName="policyComponent"> + <setProperty name="policyComponent"> <simple>${exchangeProperty[loopObject].getComponent('POLICY')} </simple> </setProperty> - <setProperty propertyName="policyFound"> + <setProperty name="policyFound"> <simple resultType="java.lang.Boolean">true</simple> </setProperty> - <setProperty propertyName="policyDeployed"> + <setProperty name="policyDeployed"> <simple resultType="java.lang.Boolean">true</simple> </setProperty> <log loggingLevel="INFO" @@ -34,19 +34,19 @@ <split> <simple>${exchangeProperty[loopObject].getMicroServicePolicies()} </simple> - <setProperty propertyName="policyName"> + <setProperty name="policyName"> <simple>${body.getName()}</simple> </setProperty> - <setProperty propertyName="policyType"> + <setProperty name="policyType"> <simple>${body.getPolicyModel().getPolicyModelType()}</simple> </setProperty> - <setProperty propertyName="policyTypeVersion"> + <setProperty name="policyTypeVersion"> <simple>${body.getPolicyModel().getVersion()}</simple> </setProperty> - <setProperty propertyName="policyPdpGroup"> + <setProperty name="policyPdpGroup"> <simple>${body.getPdpGroup()}</simple> </setProperty> - <setProperty propertyName="policyVersion"> + <setProperty name="policyVersion"> <simple>1.0.0</simple> </setProperty> <setBody> @@ -61,19 +61,19 @@ <split> <simple>${exchangeProperty[loopObject].getOperationalPolicies()} </simple> - <setProperty propertyName="policyName"> + <setProperty name="policyName"> <simple>${body.getName()}</simple> </setProperty> - <setProperty propertyName="policyType"> + <setProperty name="policyType"> <simple>${body.getPolicyModel().getPolicyModelType()}</simple> </setProperty> - <setProperty propertyName="policyTypeVersion"> + <setProperty name="policyTypeVersion"> <simple>${body.getPolicyModel().getVersion()}</simple> </setProperty> - <setProperty propertyName="policyVersion"> + <setProperty name="policyVersion"> <simple>1.0.0</simple> </setProperty> - <setProperty propertyName="policyPdpGroup"> + <setProperty name="policyPdpGroup"> <simple>${body.getPdpGroup()}</simple> </setProperty> <setBody> @@ -83,7 +83,7 @@ message="Processing Operational Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" /> <to uri="direct:verify-one-policy" /> </split> - <setProperty propertyName="policyState"> + <setProperty name="policyState"> <simple> ${exchangeProperty[policyComponent].getState()} </simple> </setProperty> @@ -100,29 +100,29 @@ <when> <simple>${exchangeProperty['loopObject'].getLoopTemplate().getUniqueBlueprint()} == true </simple> - <setProperty propertyName="dcaeComponent"> + <setProperty name="dcaeComponent"> <simple>${exchangeProperty[loopObject].getComponent('DCAE')}</simple> </setProperty> <when> <simple>${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()} != null </simple> - <setProperty propertyName="getStatusUrl"> + <setProperty name="getStatusUrl"> <simple>${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()}</simple> </setProperty> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:get-dcae-deployment-status" /> <when> <simple> ${header.CamelHttpResponseCode} == 200 </simple> <convertBodyTo type="java.lang.String" /> - <setProperty propertyName="dcaeResponse"> + <setProperty name="dcaeResponse"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="convertDcaeResponse(${body})" /> </setProperty> </when> </when> - <setProperty propertyName="dcaeState"> + <setProperty name="dcaeState"> <simple> ${exchangeProperty[dcaeComponent].computeState(*)} </simple> </setProperty> @@ -137,32 +137,32 @@ <split> <simple>${exchangeProperty[loopObject].getMicroServicePolicies()} </simple> - <setProperty propertyName="microServicePolicy"> + <setProperty name="microServicePolicy"> <simple>${body}</simple> </setProperty> - <setProperty propertyName="dcaeComponent"> + <setProperty name="dcaeComponent"> <simple>${exchangeProperty[loopObject].getComponent('DCAE_' + ${exchangeProperty[microServicePolicy].getName()})}</simple> </setProperty> <when> <simple>${exchangeProperty[microServicePolicy].getDcaeDeploymentStatusUrl()} != null </simple> - <setProperty propertyName="getStatusUrl"> + <setProperty name="getStatusUrl"> <simple>${exchangeProperty[microServicePolicy].getDcaeDeploymentStatusUrl()}</simple> </setProperty> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:get-dcae-deployment-status" /> <when> <simple> ${header.CamelHttpResponseCode} == 200 </simple> <convertBodyTo type="java.lang.String" /> - <setProperty propertyName="dcaeResponse"> + <setProperty name="dcaeResponse"> <method ref="org.onap.policy.clamp.loop.components.external.DcaeComponent" method="convertDcaeResponse(${body})" /> </setProperty> </when> </when> - <setProperty propertyName="dcaeState"> + <setProperty name="dcaeState"> <simple> ${exchangeProperty[dcaeComponent].computeState(*)} </simple> </setProperty> @@ -181,14 +181,14 @@ <choice> <when> <simple>${exchangeProperty['dcaeState'].getStateName()} == - 'BLUEPRINT_DEPLOYED' and ${exchangeProperty['policyState'].getStateName()} + 'BLUEPRINT_DEPLOYED' && ${exchangeProperty['policyState'].getStateName()} == 'NOT_SENT' </simple> <to uri="bean:org.onap.policy.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'DESIGN')" /> </when> <when> - <simple>${exchangeProperty['dcaeState'].getStateName()} == 'IN_ERROR' or + <simple>${exchangeProperty['dcaeState'].getStateName()} == 'IN_ERROR' || ${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLATION_FAILED' </simple> @@ -197,7 +197,7 @@ </when> <when> <simple>${exchangeProperty['dcaeState'].getStateName()} == - 'MICROSERVICE_UNINSTALLATION_FAILED' or + 'MICROSERVICE_UNINSTALLATION_FAILED' || ${exchangeProperty['policyState'].getStateName()} == 'IN_ERROR' </simple> <to @@ -205,7 +205,7 @@ </when> <when> <simple>${exchangeProperty['dcaeState'].getStateName()} == - 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and + 'MICROSERVICE_INSTALLED_SUCCESSFULLY' && ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED' </simple> <to @@ -213,7 +213,7 @@ </when> <when> <simple>${exchangeProperty['dcaeState'].getStateName()} == - 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and + 'MICROSERVICE_INSTALLED_SUCCESSFULLY' && ${exchangeProperty['policyState'].getStateName()} == 'SENT' </simple> <to @@ -221,8 +221,8 @@ </when> <when> <simple>${exchangeProperty['dcaeState'].getStateName()} == - 'BLUEPRINT_DEPLOYED' or ${exchangeProperty['dcaeState'].getStateName()} == - 'MICROSERVICE_UNINSTALLED_SUCCESSFULLY' and + 'BLUEPRINT_DEPLOYED' || ${exchangeProperty['dcaeState'].getStateName()} == + 'MICROSERVICE_UNINSTALLED_SUCCESSFULLY' && ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED' </simple> <to @@ -230,9 +230,9 @@ </when> <when> <simple>${exchangeProperty['dcaeState'].getStateName()} == - 'PROCESSING_MICROSERVICE_INSTALLATION' or + 'PROCESSING_MICROSERVICE_INSTALLATION' || ${exchangeProperty['dcaeState'].getStateName()} == - 'PROCESSING_MICROSERVICE_UNINSTALLATION' and + 'PROCESSING_MICROSERVICE_UNINSTALLATION' && ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED' </simple> <to @@ -240,7 +240,7 @@ </when> <when> <simple>${exchangeProperty['dcaeState'].getStateName()} == - 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and + 'MICROSERVICE_INSTALLED_SUCCESSFULLY' && ${exchangeProperty['policyState'].getStateName()} != 'NOT_SENT' </simple> <to diff --git a/src/main/resources/clds/camel/routes/policy-flows.xml b/src/main/resources/clds/camel/routes/policy-flows.xml index cc51a086e..f86ade5ef 100644 --- a/src/main/resources/clds/camel/routes/policy-flows.xml +++ b/src/main/resources/clds/camel/routes/policy-flows.xml @@ -1,31 +1,31 @@ <routes xmlns="http://camel.apache.org/schema/spring"> <route id="verify-one-policy"> <from uri="direct:verify-one-policy"/> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:get-policy"/> <when> <simple>${header.CamelHttpResponseCode} != 200</simple> - <setProperty propertyName="policyFound"> + <setProperty name="policyFound"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <log loggingLevel="WARN" message="At least one policy has not been found on policy engine: ${exchangeProperty[policyName]}"/> </when> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <to uri="direct:get-deployment-policy"/> <when> <simple>${header.CamelHttpResponseCode} != 200</simple> - <setProperty propertyName="policyDeployed"> + <setProperty name="policyDeployed"> <simple resultType="java.lang.Boolean">false</simple> </setProperty> <log loggingLevel="WARN" message="At least one policy has not been deployed on policy engine: ${exchangeProperty[policyName]}"/> </when> - <setProperty propertyName="newPolicyState"> + <setProperty name="newPolicyState"> <simple>${exchangeProperty[policyComponent].computeState(*)}</simple> </setProperty> </route> @@ -37,25 +37,25 @@ message="Getting Policy: ${exchangeProperty[policyName]}"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Get Policy')"/> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to get policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/${exchangeProperty[policyTypeVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/${exchangeProperty[policyTypeVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/${exchangeProperty[policyTypeVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&authenticationPreemptive=true&connectionClose=true"/> <doCatch> <exception>java.lang.Exception</exception> <handled> @@ -71,12 +71,12 @@ <to uri="direct:reset-raise-http-exception-flag"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>${exchangeProperty[policyName]} GET Policy status </simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>POLICY</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -91,25 +91,25 @@ message="Getting the policy deployment in PDP: ${exchangeProperty[policyName]}"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy deployment in PDP')"/> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to get policy deployment status: {{clamp.config.policy.pap.url}}/policy/pap/v1/policies/status/${exchangeProperty[policyPdpGroup]}/${exchangeProperty[policyName]}/1.0.0"></log> <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/policies/status/${exchangeProperty[policyPdpGroup]}/${exchangeProperty[policyName]}/1.0.0?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/policies/status/${exchangeProperty[policyPdpGroup]}/${exchangeProperty[policyName]}/1.0.0?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&authenticationPreemptive=true&connectionClose=true"/> <doCatch> <exception>java.lang.Exception</exception> <handled> @@ -125,12 +125,12 @@ <to uri="direct:reset-raise-http-exception-flag"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>${exchangeProperty[policyName]} GET Policy deployment status </simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>POLICY</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -149,22 +149,22 @@ <simple>${exchangeProperty[policy].createPolicyPayload()} </simple> </setBody> - <setProperty propertyName="policyModelType"> + <setProperty name="policyModelType"> <simple>${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}</simple> </setProperty> - <setProperty propertyName="policyModelVersion"> + <setProperty name="policyModelVersion"> <simple>${exchangeProperty[policy].getPolicyModel().getVersion()}</simple> </setProperty> <to uri="direct:create-policy"/> <doFinally> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>${exchangeProperty[policy].getName()} creation status </simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>POLICY</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -179,28 +179,28 @@ message="Deleting Policy in a loop: ${exchangeProperty[policy].getName()}"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Policy in a loop')"/> - <setProperty propertyName="policyModelType"> + <setProperty name="policyModelType"> <simple>${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}</simple> </setProperty> - <setProperty propertyName="policyModelVersion"> + <setProperty name="policyModelVersion"> <simple>${exchangeProperty[policy].getPolicyModel().getVersion()}</simple> </setProperty> - <setProperty propertyName="policyName"> + <setProperty name="policyName"> <simple>${exchangeProperty[policy].getName()}</simple> </setProperty> - <setProperty propertyName="policyVersion"> + <setProperty name="policyVersion"> <simple>1.0.0</simple> </setProperty> <to uri="direct:delete-policy"/> <doFinally> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>${exchangeProperty[policy].getName()} removal status </simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>POLICY</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -220,14 +220,17 @@ ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"POST")} </simple> </setBody> + <setProperty name="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">true</simple> + </setProperty> <to uri="direct:add-multiple-policies-to-pdp-group"/> <doFinally> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>PDP Group push ALL status</simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>POLICY</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -247,37 +250,37 @@ ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"DELETE")} </simple> </setBody> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>POST</constant> </setHeader> - <setHeader headerName="Content-Type"> + <setHeader name="Content-Type"> <constant>application/json</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to remove policies from PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log> <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&useSystemProperties=true&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&useSystemProperties=true&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&authenticationPreemptive=true&connectionClose=true"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>PDP Group remove ALL status</simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>POLICY</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -292,15 +295,15 @@ message="Removing policy from active PDP group for loop: ${exchangeProperty[loopObject].getName()}"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Removing one policy PDP group')"/> - <setProperty propertyName="policyVersion"> + <setProperty name="policyVersion"> <simple>1.0.0</simple> </setProperty> <to uri="direct:undeploy-one-policy-from-pap"/> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>${exchangeProperty[policyName]} PDP Group removal status </simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>POLICY</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -309,10 +312,10 @@ <handled> <constant>false</constant> </handled> - <setProperty propertyName="logMessage"> + <setProperty name="logMessage"> <simple>PDP Group removal, Error reported: ${exception}</simple> </setProperty> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <simple>POLICY</simple> </setProperty> <to uri="direct:dump-loop-log-http-response"/> @@ -331,25 +334,25 @@ <log loggingLevel="INFO" message="Getting all the policy models"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting all the policy models')"/> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to get all policy models: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> @@ -366,25 +369,25 @@ message="Getting the policy tosca model: ${exchangeProperty[policyModelType]}/${exchangeProperty[policyModelVersion]}"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy model')"/> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to get policy model: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> @@ -401,25 +404,25 @@ message="Getting the list of PDP Groups"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the PDP Group list')"/> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to get policy model: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps"></log> <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> @@ -436,25 +439,25 @@ message="Getting the policies list"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policies list')"/> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>GET</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to get policies list: {{clamp.config.policy.api.url}}/policy/api/v1/policies"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policies?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policies?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&authenticationPreemptive=true&connectionClose=true"/> <convertBodyTo type="java.lang.String"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> @@ -471,28 +474,28 @@ message="Add policies to PDP group"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Add policies to PDP group')"/> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>POST</constant> </setHeader> - <setHeader headerName="Content-Type"> + <setHeader name="Content-Type"> <constant>application/json</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to add policies to PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log> <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&useSystemProperties=true&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&useSystemProperties=true&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&authenticationPreemptive=true&connectionClose=true"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> <to @@ -510,25 +513,25 @@ <setBody> <constant>null</constant> </setBody> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>DELETE</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to delete policy from PDP Group: {{clamp.config.policy.pap.url}}/pdps/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log> <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&authenticationPreemptive=true&connectionClose=true"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> <to @@ -545,28 +548,28 @@ message="Create Policy from model ${exchangeProperty[policyModelType]}/${exchangeProperty[policyModelVersion]}"/> <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Policy')"/> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>POST</constant> </setHeader> - <setHeader headerName="Content-Type"> + <setHeader name="Content-Type"> <constant>application/json</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to create policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&authenticationPreemptive=true&connectionClose=true"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> <to @@ -584,25 +587,25 @@ <setBody> <constant>null</constant> </setBody> - <setHeader headerName="CamelHttpMethod"> + <setHeader name="CamelHttpMethod"> <constant>DELETE</constant> </setHeader> - <setHeader headerName="X-ONAP-RequestID"> + <setHeader name="X-ONAP-RequestID"> <simple>${exchangeProperty[X-ONAP-RequestID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> + <setHeader name="X-ONAP-InvocationID"> <simple>${exchangeProperty[X-ONAP-InvocationID]} </simple> </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> + <setHeader name="X-ONAP-PartnerName"> <simple>${exchangeProperty[X-ONAP-PartnerName]} </simple> </setHeader> <log loggingLevel="INFO" message="Endpoint to delete policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log> <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelType]}/versions/${exchangeProperty[policyModelVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&authenticationPreemptive=true&connectionClose=true"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> diff --git a/src/main/resources/clds/camel/routes/utils-flows.xml b/src/main/resources/clds/camel/routes/utils-flows.xml index d5da4faee..90900f842 100644 --- a/src/main/resources/clds/camel/routes/utils-flows.xml +++ b/src/main/resources/clds/camel/routes/utils-flows.xml @@ -1,7 +1,7 @@ <routes xmlns="http://camel.apache.org/schema/spring"> <route id="reset-raise-http-exception-flag"> <from uri="direct:reset-raise-http-exception-flag" /> - <setProperty propertyName="raiseHttpExceptionFlag"> + <setProperty name="raiseHttpExceptionFlag"> <simple resultType="java.lang.Boolean">true</simple> </setProperty> </route> @@ -19,7 +19,7 @@ <otherwise> <to uri="bean:org.onap.policy.clamp.loop.log.LoopLogService?method=addLogForComponent('${exchangeProperty[logMessage]} - ${header.CamelHttpResponseCode} : ${header.CamelHttpResponseText}','INFO','${exchangeProperty[logComponent]}',${exchangeProperty[loopObject]})" /> - <setProperty propertyName="logComponent"> + <setProperty name="logComponent"> <constant>null</constant> </setProperty> </otherwise> diff --git a/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java b/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java index 51c4c078a..622fd5999 100644 --- a/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java +++ b/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java @@ -1,9 +1,11 @@ /*- * ============LICENSE_START======================================================= - * ONAP CLAMP + * ONAP POLICY-CLAMP * ================================================================================ * Copyright (C) 2019 Samsung. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2021 AT&T + * ================================================================================ * 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 @@ -28,7 +30,7 @@ import static org.mockito.Mockito.mock; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; -import org.apache.camel.impl.DefaultExchange; +import org.apache.camel.support.DefaultExchange; import org.junit.Test; import org.mockito.Mockito; import org.onap.policy.clamp.clds.util.LoggingUtils; @@ -43,7 +45,7 @@ public class FlowLogOperationTest { private FlowLogOperation flowLogOperation = new FlowLogOperation(); @Test - public void testStratLog() { + public void testStartLog() { // given LoggingUtils loggingUtils = mock(LoggingUtils.class); ReflectionTestUtils.setField(flowLogOperation, "util", loggingUtils); @@ -65,7 +67,7 @@ public class FlowLogOperationTest { public void testInvokeLog() { // given final String mockEntity = "mockEntity"; - final String mockServiceName = "mockSerivceName"; + final String mockServiceName = "mockServiceName"; MDCAdapter mdcAdapter = MDC.getMDCAdapter(); // when flowLogOperation.invokeLog(mockEntity, mockServiceName); diff --git a/src/test/java/org/onap/policy/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/policy/clamp/loop/CsarInstallerItCase.java index 5b67f1f3a..b0abf832b 100644 --- a/src/test/java/org/onap/policy/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/policy/clamp/loop/CsarInstallerItCase.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * ONAP CLAMP + * ONAP POLICY-CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Modifications copyright (c) 2019 Nokia @@ -98,9 +98,9 @@ public class CsarInstallerItCase { @Qualifier("csarInstaller") private CsarInstaller csarInstaller; - private BlueprintArtifact buildFakeBuildprintArtifact(String instanceName, String invariantResourceUuid, - String blueprintFilePath, String artifactName, - String invariantServiceUuid) throws IOException { + private BlueprintArtifact buildFakeBlueprintArtifact(String instanceName, String invariantResourceUuid, + String blueprintFilePath, String artifactName, + String invariantServiceUuid) throws IOException { IResourceInstance resource = Mockito.mock(IResourceInstance.class); Mockito.when(resource.getResourceInstanceName()).thenReturn(instanceName); Mockito.when(resource.getResourceInvariantUUID()).thenReturn(invariantResourceUuid); @@ -127,7 +127,7 @@ public class CsarInstallerItCase { Map<String, BlueprintArtifact> blueprintMap = new HashMap<>(); Mockito.when(csarHandler.getMapOfBlueprints()).thenReturn(blueprintMap); // Create fake blueprint artifact 1 on resource1 - BlueprintArtifact blueprintArtifact = buildFakeBuildprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, + BlueprintArtifact blueprintArtifact = buildFakeBlueprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, INVARIANT_RESOURCE1_UUID, "example/sdc/blueprint-dcae/tca-bad-policy.yaml", "tca-bad-policy.yaml", INVARIANT_SERVICE_UUID); listResources.add(blueprintArtifact.getResourceAttached()); @@ -167,25 +167,25 @@ public class CsarInstallerItCase { Map<String, BlueprintArtifact> blueprintMap = new HashMap<>(); Mockito.when(csarHandler.getMapOfBlueprints()).thenReturn(blueprintMap); // Create fake blueprint artifact 1 on resource1 - BlueprintArtifact blueprintArtifact = buildFakeBuildprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, + BlueprintArtifact blueprintArtifact = buildFakeBlueprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, INVARIANT_RESOURCE1_UUID, "example/sdc/blueprint-dcae/tca.yaml", "tca.yaml", INVARIANT_SERVICE_UUID); listResources.add(blueprintArtifact.getResourceAttached()); blueprintMap.put(blueprintArtifact.getBlueprintArtifactName(), blueprintArtifact); // Create fake blueprint artifact 2 on resource2 - blueprintArtifact = buildFakeBuildprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE2, INVARIANT_RESOURCE2_UUID, + blueprintArtifact = buildFakeBlueprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE2, INVARIANT_RESOURCE2_UUID, "example/sdc/blueprint-dcae/tca_2.yaml", "tca_2.yaml", INVARIANT_SERVICE_UUID); listResources.add(blueprintArtifact.getResourceAttached()); blueprintMap.put(blueprintArtifact.getBlueprintArtifactName(), blueprintArtifact); // Create fake blueprint artifact 3 on resource 1 so that it's possible to // test multiple CL deployment per Service/vnf - blueprintArtifact = buildFakeBuildprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, INVARIANT_RESOURCE1_UUID, + blueprintArtifact = buildFakeBlueprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, INVARIANT_RESOURCE1_UUID, "example/sdc/blueprint-dcae/tca_3.yaml", "tca_3.yaml", INVARIANT_SERVICE_UUID); blueprintMap.put(blueprintArtifact.getBlueprintArtifactName(), blueprintArtifact); // Create fake blueprint artifact 3 on resource 1 so that it's possible to // test multiple CL deployment per Service/vnf - blueprintArtifact = buildFakeBuildprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, INVARIANT_RESOURCE1_UUID, + blueprintArtifact = buildFakeBlueprintArtifact(RESOURCE_INSTANCE_NAME_RESOURCE1, INVARIANT_RESOURCE1_UUID, "example/sdc/blueprint-dcae/tca-guilin.yaml", "tca-guilin.yaml", INVARIANT_SERVICE_UUID); blueprintMap.put(blueprintArtifact.getBlueprintArtifactName(), blueprintArtifact); diff --git a/src/test/java/org/onap/policy/clamp/loop/DcaeComponentTest.java b/src/test/java/org/onap/policy/clamp/loop/DcaeComponentTest.java index c94937031..c95725457 100644 --- a/src/test/java/org/onap/policy/clamp/loop/DcaeComponentTest.java +++ b/src/test/java/org/onap/policy/clamp/loop/DcaeComponentTest.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * ONAP CLAMP + * ONAP POLICY-CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,6 +36,7 @@ import org.junit.Test; import org.mockito.Mockito; import org.onap.policy.clamp.clds.model.dcae.DcaeInventoryResponse; import org.onap.policy.clamp.clds.model.dcae.DcaeOperationStatusResponse; +import org.onap.policy.clamp.clds.util.ResourceFileUtils; import org.onap.policy.clamp.loop.components.external.DcaeComponent; import org.onap.policy.clamp.loop.components.external.ExternalComponentState; import org.onap.policy.clamp.loop.template.LoopTemplate; @@ -52,7 +53,7 @@ public class DcaeComponentTest { JsonObject.class)); loopTest.setLastComputedState(LoopState.DESIGN); loopTest.setDcaeDeploymentId("123456789"); - loopTest.setDcaeDeploymentStatusUrl("http4://localhost:8085"); + loopTest.setDcaeDeploymentStatusUrl("http://localhost:8085"); MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", new PolicyModel("policy1", "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0"), true, @@ -175,36 +176,10 @@ public class DcaeComponentTest { */ @Test public void convertToDcaeInventoryResponseTest() throws IOException, ParseException { - String dcaeFakeResponse = "{\n" + " \"links\": {\n" + " \"previousLink\": {\n" - + " \"title\": \"string\",\n" + " \"rel\": \"string\",\n" + " \"uri\": \"string\",\n" - + " \"uriBuilder\": {},\n" + " \"rels\": [\n" + " \"string\"\n" + " ],\n" - + " \"params\": {\n" + " \"additionalProp1\": \"string\",\n" - + " \"additionalProp2\": \"string\",\n" + " \"additionalProp3\": \"string\"\n" - + " },\n" + " \"type\": \"string\"\n" + " },\n" + " \"nextLink\": {\n" - + " \"title\": \"string\",\n" + " \"rel\": \"string\",\n" + " \"uri\": \"string\",\n" - + " \"uriBuilder\": {},\n" + " \"rels\": [\n" + " \"string\"\n" + " ],\n" - + " \"params\": {\n" + " \"additionalProp1\": \"string\",\n" - + " \"additionalProp2\": \"string\",\n" + " \"additionalProp3\": \"string\"\n" - + " },\n" + " \"type\": \"string\"\n" + " }\n" + " },\n" + " \"totalCount\": 0,\n" - + " \"items\": [\n" + " {\n" + " \"owner\": \"testOwner\",\n" - + " \"application\": \"testApplication\",\n" + " \"component\": \"testComponent\",\n" - + " \"typeName\": \"testTypeName\",\n" + " \"typeVersion\": 0,\n" - + " \"blueprintTemplate\": \"testBlueprintTemplate\",\n" + " \"serviceIds\": [\n" - + " \"serviceId1\", \"serviceId2\"\n" + " ],\n" + " \"vnfTypes\": [\n" - + " \"vnfType1\", \"vnfType2\"\n" + " ],\n" + " \"serviceLocations\": [\n" - + " \"serviceLocation1\", \"serviceLocation2\"\n" + " ],\n" - + " \"asdcServiceId\": \"testAsdcServiceId\",\n" - + " \"asdcResourceId\": \"testAsdcResourceId\",\n" - + " \"asdcServiceURL\": \"testAsdcServiceURL\",\n" + " \"typeId\": \"testTypeId\",\n" - + " \"selfLink\": {\n" + " \"title\": \"selfLinkTitle\",\n" - + " \"rel\": \"selfLinkRel\",\n" + " \"uri\": \"selfLinkUri\",\n" - + " \"uriBuilder\": {},\n" + " \"rels\": [\n" + " \"string\"\n" + " ],\n" - + " \"params\": {\n" + " \"additionalProp1\": \"string\",\n" - + " \"additionalProp2\": \"string\",\n" + " \"additionalProp3\": \"string\"\n" - + " },\n" + " \"type\": \"string\"\n" + " },\n" - + " \"created\": \"2020-01-22T09:38:15.436Z\",\n" - + " \"deactivated\": \"2020-01-22T09:38:15.437Z\"\n" + " }\n" + " ]\n" + "}"; - List<DcaeInventoryResponse> responseObject = DcaeComponent.convertToDcaeInventoryResponse(dcaeFakeResponse); + + List<DcaeInventoryResponse> responseObject = DcaeComponent + .convertToDcaeInventoryResponse( + ResourceFileUtils.getResourceAsString("example/dcae/inventory-response.json")); assertThat(responseObject.get(0).getAsdcResourceId()).isEqualTo("testAsdcResourceId"); assertThat(responseObject.get(0).getAsdcServiceId()).isEqualTo("testAsdcServiceId"); assertThat(responseObject.get(0).getTypeName()).isEqualTo("testTypeName"); diff --git a/src/test/java/org/onap/policy/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/policy/clamp/loop/LoopServiceTestItCase.java index 010c4978a..74092727c 100644 --- a/src/test/java/org/onap/policy/clamp/loop/LoopServiceTestItCase.java +++ b/src/test/java/org/onap/policy/clamp/loop/LoopServiceTestItCase.java @@ -355,10 +355,10 @@ public class LoopServiceTestItCase { saveTestLoopToDb(); Loop loop = loopService.getLoop(EXAMPLE_LOOP_NAME); loopService.updateDcaeDeploymentFields(loop, "CLAMP_c5ce429a-f570-48c5-a7ea-53bed8f86f85", - "https4://deployment-handler.onap:8443"); + "https://deployment-handler.onap:8443"); loop = loopService.getLoop(EXAMPLE_LOOP_NAME); assertThat(loop.getDcaeDeploymentId()).isEqualTo("CLAMP_c5ce429a-f570-48c5-a7ea-53bed8f86f85"); - assertThat(loop.getDcaeDeploymentStatusUrl()).isEqualTo("https4://deployment-handler.onap:8443"); + assertThat(loop.getDcaeDeploymentStatusUrl()).isEqualTo("https://deployment-handler.onap:8443"); } @Test diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 2a4caee98..d67fe74a3 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -1,6 +1,6 @@ ### # ============LICENSE_START======================================================= -# ONAP CLAMP +# ONAP POLICY-CLAMP # ================================================================================ # Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights # reserved. @@ -79,10 +79,11 @@ camel.defaultthreadpool.maxpoolsize=20 camel.defaultthreadpool.maxqueuesize=1000 camel.defaultthreadpool.keepaliveTime=60 camel.defaultthreadpool.rejectpolicy=CallerRuns -#camel.springboot.xmlRoutes = false -camel.springboot.xmlRoutes=classpath:/clds/camel/routes/*.xml -camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml -#camel.springboot.typeConversion = false +camel.springboot.xml-routes=classpath:/clds/camel/routes/*.xml +camel.springboot.xml-rests=classpath:/clds/camel/rest/*.xml +camel.springboot.backlog-tracing=true +camel.springboot.tracing=true +camel.springboot.message-history=true #clds datasource connection details spring.datasource.driverClassName=org.mariadb.jdbc.Driver @@ -128,12 +129,15 @@ clamp.config.files.cldsUsers=classpath:/clds/clds-users.json clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json +clamp.config.httpclient.socketTimeout=20000 +clamp.config.httpclient.connectTimeout=10000 + # # Configuration Settings for Policy Engine Components -clamp.config.policy.api.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.policy.api.url=http://localhost:${docker.http-cache.port.host} clamp.config.policy.api.userName=healthcheck clamp.config.policy.api.password=zb!XztG34 -clamp.config.policy.pap.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.policy.pap.url=http://localhost:${docker.http-cache.port.host} clamp.config.policy.pap.userName=healthcheck clamp.config.policy.pap.password=zb!XztG34 @@ -142,12 +146,12 @@ clamp.config.policy.pap.password=zb!XztG34 clamp.config.sdc.csarFolder = ${project.build.directory}/sdc-tests #DCAE Inventory Url Properties -clamp.config.dcae.inventory.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.dcae.inventory.url=http://localhost:${docker.http-cache.port.host} clamp.config.dcae.intentory.retry.interval=100 clamp.config.dcae.intentory.retry.limit=1 #DCAE Deployment Url Properties -clamp.config.dcae.deployment.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.dcae.deployment.url=http://localhost:${docker.http-cache.port.host} clamp.config.dcae.deployment.userName=test clamp.config.dcae.deployment.password=test @@ -164,7 +168,7 @@ clamp.config.security.permission.instance=dev clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal # Configuration settings for CDS -clamp.config.cds.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.cds.url=http://localhost:${docker.http-cache.port.host} clamp.config.cds.userName=ccsdkapps clamp.config.cds.password=ccsdkapps diff --git a/src/test/resources/example/dcae/inventory-response.json b/src/test/resources/example/dcae/inventory-response.json new file mode 100644 index 000000000..1ebf068b8 --- /dev/null +++ b/src/test/resources/example/dcae/inventory-response.json @@ -0,0 +1,78 @@ +{ + "links": { + "previousLink": { + "title": "string", + "rel": "string", + "uri": "string", + "uriBuilder": {}, + "rels": [ + "string" + ], + "params": { + "additionalProp1": "string", + "additionalProp2": "string", + "additionalProp3": "string" + }, + "type": "string" + }, + "nextLink": { + "title": "string", + "rel": "string", + "uri": "string", + "uriBuilder": {}, + "rels": [ + "string" + ], + "params": { + "additionalProp1": "string", + "additionalProp2": "string", + "additionalProp3": "string" + }, + "type": "string" + } + }, + "totalCount": 0, + "items": [ + { + "owner": "testOwner", + "application": "testApplication", + "component": "testComponent", + "typeName": "testTypeName", + "typeVersion": 0, + "blueprintTemplate": "testBlueprintTemplate", + "serviceIds": [ + "serviceId1", + "serviceId2" + ], + "vnfTypes": [ + "vnfType1", + "vnfType2" + ], + "serviceLocations": [ + "serviceLocation1", + "serviceLocation2" + ], + "asdcServiceId": "testAsdcServiceId", + "asdcResourceId": "testAsdcResourceId", + "asdcServiceURL": "testAsdcServiceURL", + "typeId": "testTypeId", + "selfLink": { + "title": "selfLinkTitle", + "rel": "selfLinkRel", + "uri": "selfLinkUri", + "uriBuilder": {}, + "rels": [ + "string" + ], + "params": { + "additionalProp1": "string", + "additionalProp2": "string", + "additionalProp3": "string" + }, + "type": "string" + }, + "created": "2020-01-22T09:38:15.436Z", + "deactivated": "2020-01-22T09:38:15.437Z" + } + ] +}
\ 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 b52b16db4..14079a78e 100644 --- a/src/test/resources/https/https-test.properties +++ b/src/test/resources/https/https-test.properties @@ -96,10 +96,11 @@ camel.defaultthreadpool.maxpoolsize=20 camel.defaultthreadpool.maxqueuesize=1000 camel.defaultthreadpool.keepaliveTime=60 camel.defaultthreadpool.rejectpolicy=CallerRuns -#camel.springboot.xmlRoutes = false -camel.springboot.xmlRoutes=classpath:/clds/camel/routes/*.xml -camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml -#camel.springboot.typeConversion = false +camel.springboot.xml-routes=classpath:/clds/camel/routes/*.xml +camel.springboot.xml-rests=classpath:/clds/camel/rest/*.xml +camel.springboot.backlog-tracing=true +camel.springboot.tracing=true +camel.springboot.message-history=true #For EELF logback file #com.att.eelf.logging.path= @@ -107,6 +108,9 @@ com.att.eelf.logging.file=logback-default.xml #The log folder that will be used in logback.xml file clamp.config.log.path=log +clamp.config.httpclient.socketTimeout=20000 +clamp.config.httpclient.connectTimeout=10000 + #Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case ! clamp.config.security.permission.type.cl=org.onap.clamp.clds.cl clamp.config.security.permission.type.cl.manage=org.onap.clamp.clds.cl.manage diff --git a/src/test/resources/robotframework/robotframework-test.properties b/src/test/resources/robotframework/robotframework-test.properties index 1e173f961..a12f052ad 100644 --- a/src/test/resources/robotframework/robotframework-test.properties +++ b/src/test/resources/robotframework/robotframework-test.properties @@ -1,6 +1,6 @@ ### # ============LICENSE_START======================================================= -# ONAP CLAMP +# ONAP POLICY-CLAMP # ================================================================================ # Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights # reserved. @@ -79,10 +79,11 @@ camel.defaultthreadpool.maxpoolsize=20 camel.defaultthreadpool.maxqueuesize=1000 camel.defaultthreadpool.keepaliveTime=60 camel.defaultthreadpool.rejectpolicy=CallerRuns -#camel.springboot.xmlRoutes = false -camel.springboot.xmlRoutes=classpath:/clds/camel/routes/*.xml -camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml -#camel.springboot.typeConversion = false +camel.springboot.xml-routes=classpath:/clds/camel/routes/*.xml +camel.springboot.xml-rests=classpath:/clds/camel/rest/*.xml +camel.springboot.backlog-tracing=true +camel.springboot.tracing=true +camel.springboot.message-history=true #clds datasource connection details spring.datasource.driverClassName=org.mariadb.jdbc.Driver @@ -128,12 +129,15 @@ clamp.config.files.cldsUsers=classpath:/clds/clds-users.json clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json +clamp.config.httpclient.socketTimeout=20000 +clamp.config.httpclient.connectTimeout=10000 + # # Configuration Settings for Policy Engine Components -clamp.config.policy.api.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.policy.api.url=http://localhost:${docker.http-cache.port.host} clamp.config.policy.api.userName=healthcheck clamp.config.policy.api.password=zb!XztG34 -clamp.config.policy.pap.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.policy.pap.url=http://localhost:${docker.http-cache.port.host} clamp.config.policy.pap.userName=healthcheck clamp.config.policy.pap.password=zb!XztG34 @@ -142,12 +146,12 @@ clamp.config.policy.pap.password=zb!XztG34 clamp.config.sdc.csarFolder = ${project.build.directory}/sdc-tests #DCAE Inventory Url Properties -clamp.config.dcae.inventory.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.dcae.inventory.url=http://localhost:${docker.http-cache.port.host} clamp.config.dcae.intentory.retry.interval=100 clamp.config.dcae.intentory.retry.limit=1 #DCAE Deployment Url Properties -clamp.config.dcae.deployment.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.dcae.deployment.url=http://localhost:${docker.http-cache.port.host} clamp.config.dcae.deployment.userName=test clamp.config.dcae.deployment.password=test @@ -164,7 +168,7 @@ clamp.config.security.permission.instance=dev clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal, org.onap.aaf.cadi.principal.CachedBasicPrincipal # Configuration settings for CDS -clamp.config.cds.url=http4://localhost:${docker.http-cache.port.host} +clamp.config.cds.url=http://localhost:${docker.http-cache.port.host} clamp.config.cds.userName=ccsdkapps clamp.config.cds.password=ccsdkapps |