diff options
Diffstat (limited to 'src/main/java/org/onap')
10 files changed, 155 insertions, 129 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"); |