diff options
Diffstat (limited to 'src/main')
13 files changed, 7 insertions, 572 deletions
diff --git a/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java b/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java index 2fda7e7..ba27ada 100644 --- a/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java +++ b/src/main/java/io/swagger/api/factories/DcaeServicesApiServiceFactory.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * dcae-inventory * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ package io.swagger.api.factories; -import org.onap.dcae.inventory.clients.DCAEControllerClient; import org.onap.dcae.inventory.clients.DatabusControllerClient; import io.swagger.api.DcaeServicesApiService; import io.swagger.api.impl.DcaeServicesApiServiceImpl; @@ -29,23 +28,18 @@ import io.swagger.api.impl.DcaeServicesApiServiceImpl; public final class DcaeServicesApiServiceFactory { // Yes I agree this code is not great and I blame for Swagger for putting me in this spot. - private static DCAEControllerClient dcaeControllerClient; private static DatabusControllerClient databusControllerClient; //Utility classes, which are a collection of static members, are not meant to be instantiated. private DcaeServicesApiServiceFactory(){ } - public static void setDcaeControllerClient(DCAEControllerClient dcaeControllerClient) { - DcaeServicesApiServiceFactory.dcaeControllerClient = dcaeControllerClient; - } - public static void setDatabusControllerClient(DatabusControllerClient databusControllerClient) { DcaeServicesApiServiceFactory.databusControllerClient = databusControllerClient; } public static DcaeServicesApiService getDcaeServicesApi() { - return new DcaeServicesApiServiceImpl(dcaeControllerClient, databusControllerClient); + return new DcaeServicesApiServiceImpl(databusControllerClient); } } diff --git a/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java index f1219ac..26949af 100644 --- a/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java +++ b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * dcae-inventory * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ package io.swagger.api.impl; -import org.onap.dcae.inventory.clients.DCAEControllerClient; import org.onap.dcae.inventory.clients.DatabusControllerClient; import org.onap.dcae.inventory.daos.DCAEServiceComponentsDAO; import org.onap.dcae.inventory.daos.DCAEServiceTransactionDAO; @@ -29,7 +28,6 @@ import org.onap.dcae.inventory.daos.InventoryDAOManager; import org.onap.dcae.inventory.dbthings.mappers.DCAEServiceObjectMapper; import org.onap.dcae.inventory.dbthings.models.DCAEServiceComponentObject; import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject; -import org.onap.dcae.inventory.exceptions.DCAEControllerClientException; import org.onap.dcae.inventory.exceptions.DatabusControllerClientException; import io.swagger.api.*; import io.swagger.model.*; @@ -51,14 +49,11 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { private static final Logger LOG = LoggerFactory.getLogger(DcaeServicesApiServiceImpl.class); private static final int PAGINATION_PAGE_SIZE = 25; - private static final String COMPONENT_SOURCE_DCAE_CONTROLLER = "DCAECONTROLLER"; private static final String COMPONENT_SOURCE_DATA_BUS_CONTROLLER = "DMAAPCONTROLLER"; - private final DCAEControllerClient dcaeControllerClient; private final DatabusControllerClient databusControllerClient; - public DcaeServicesApiServiceImpl(DCAEControllerClient dcaeControllerClient, DatabusControllerClient databusControllerClient) { - this.dcaeControllerClient = dcaeControllerClient; + public DcaeServicesApiServiceImpl(DatabusControllerClient databusControllerClient) { this.databusControllerClient = databusControllerClient; } @@ -90,22 +85,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { // TODO: When putting together the components fail. Should this be a 500 case? // For now, this is just logged as a warning. - if (COMPONENT_SOURCE_DCAE_CONTROLLER.equalsIgnoreCase(sco.getComponentSource())) { - if (this.dcaeControllerClient != null) { - try { - DCAEControllerClient.ServiceInstance serviceInstance - = this.dcaeControllerClient.getServiceInstance(component.getComponentId()); - component.setStatus(serviceInstance.getStatus()); - // There's no specific location rather its inferred from the AIC tenant - component.setLocation(this.dcaeControllerClient.getLocation(serviceInstance)); - Link componentLink = Link.fromUri(this.dcaeControllerClient.constructResourceURI(sco.getComponentId())) - .rel("component").title(component.getComponentId()).build(); - component.setComponentLink(componentLink); - } catch (DCAEControllerClientException e) { - LOG.warn(String.format("%s, %s", e.getMessage(), sco.toString()), e); - } - } - } else if (COMPONENT_SOURCE_DATA_BUS_CONTROLLER.equalsIgnoreCase(sco.getComponentSource())) { + if (COMPONENT_SOURCE_DATA_BUS_CONTROLLER.equalsIgnoreCase(sco.getComponentSource())) { if (this.databusControllerClient != null) { try { if (this.databusControllerClient.isExists(sco.getComponentId())) { diff --git a/src/main/java/org/onap/dcae/inventory/InventoryApplication.java b/src/main/java/org/onap/dcae/inventory/InventoryApplication.java index 939cfdd..09ee260 100644 --- a/src/main/java/org/onap/dcae/inventory/InventoryApplication.java +++ b/src/main/java/org/onap/dcae/inventory/InventoryApplication.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * dcae-inventory * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,11 +25,8 @@ import io.dropwizard.configuration.ConfigurationFactory; import io.dropwizard.configuration.ConfigurationFactoryFactory; import io.dropwizard.configuration.JsonConfigurationFactory; import io.dropwizard.configuration.UrlConfigurationSourceProvider; -import org.onap.dcae.inventory.clients.DCAEControllerClient; import org.onap.dcae.inventory.clients.DatabusControllerClient; import org.onap.dcae.inventory.exceptions.mappers.DBIExceptionMapper; -import org.onap.dcae.inventory.exceptions.mappers.DCAEControllerConnectionExceptionMapper; -import org.onap.dcae.inventory.exceptions.mappers.DCAEControllerTimeoutExceptionMapper; import org.onap.dcae.inventory.providers.NotFoundExceptionMapper; import org.onap.dcae.inventory.daos.InventoryDAOManager; import com.fasterxml.jackson.databind.module.SimpleModule; @@ -144,21 +141,6 @@ public class InventoryApplication extends Application<InventoryConfiguration> { simpleModule.addSerializer(Link.class, new LinkSerializer()); environment.getObjectMapper().registerModule(simpleModule); - // Setup DCAE controller client - // Used by the dcae-services API - if (configuration.getDcaeControllerConnection().getRequired()) { - final Client clientDCAEController = new JerseyClientBuilder(environment).using(configuration.getJerseyClientConfiguration()) - .build("DCAEControllerClient"); - HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder().build(); - clientDCAEController.register(feature); - final DCAEControllerClient dcaeControllerClient = new DCAEControllerClient(clientDCAEController, configuration.getDcaeControllerConnection()); - DcaeServicesApiServiceFactory.setDcaeControllerClient(dcaeControllerClient); - - LOG.info("Use of DCAE controller client is required. Turned on."); - } else { - LOG.warn("Use of DCAE controller client is *not* required. Turned off."); - } - // Setup Databus controller client // Used by the dcae-services API if (configuration.getDatabusControllerConnection().getRequired()) { @@ -177,8 +159,6 @@ public class InventoryApplication extends Application<InventoryConfiguration> { } environment.jersey().register(NotFoundExceptionMapper.class); - environment.jersey().register(DCAEControllerConnectionExceptionMapper.class); - environment.jersey().register(DCAEControllerTimeoutExceptionMapper.class); environment.jersey().register(DBIExceptionMapper.UnableToObtainConnectionExceptionMapper.class); environment.jersey().register(DBIExceptionMapper.UnableToExecuteStatementExceptionMapper.class); environment.jersey().register(DBIExceptionMapper.UnableToCreateStatementExceptionMapper.class); diff --git a/src/main/java/org/onap/dcae/inventory/InventoryConfiguration.java b/src/main/java/org/onap/dcae/inventory/InventoryConfiguration.java index 0dacb26..76a525a 100644 --- a/src/main/java/org/onap/dcae/inventory/InventoryConfiguration.java +++ b/src/main/java/org/onap/dcae/inventory/InventoryConfiguration.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * dcae-inventory * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,55 +34,6 @@ import javax.validation.constraints.NotNull; */ public class InventoryConfiguration extends Configuration { - public static class DCAEControllerConnectionConfiguration { - @NotEmpty - @JsonProperty - private String host; - - @NotNull - @JsonProperty - private Integer port; - - @NotEmpty - @JsonProperty - private String basePath; - - @NotEmpty - @JsonProperty - private String user; - - @NotEmpty - @JsonProperty - private String password; - - @JsonProperty - private Boolean required = true; - - public String getHost() { - return this.host; - } - - public Integer getPort() { - return this.port; - } - - public String getBasePath() { - return this.basePath; - } - - public String getUser() { - return this.user; - } - - public String getPassword() { - return this.password; - } - - public Boolean getRequired() { - return this.required; - } - } - public static class DatabusControllerConnectionConfiguration { @NotEmpty @JsonProperty @@ -134,10 +85,6 @@ public class InventoryConfiguration extends Configuration { @NotNull @JsonProperty - private DCAEControllerConnectionConfiguration dcaeControllerConnection = new DCAEControllerConnectionConfiguration(); - - @NotNull - @JsonProperty private DatabusControllerConnectionConfiguration databusControllerConnection = new DatabusControllerConnectionConfiguration(); @NotNull @@ -158,10 +105,6 @@ public class InventoryConfiguration extends Configuration { return this.database; } - public DCAEControllerConnectionConfiguration getDcaeControllerConnection() { - return this.dcaeControllerConnection; - } - public DatabusControllerConnectionConfiguration getDatabusControllerConnection() { return databusControllerConnection; } diff --git a/src/main/java/org/onap/dcae/inventory/clients/DCAEControllerClient.java b/src/main/java/org/onap/dcae/inventory/clients/DCAEControllerClient.java deleted file mode 100644 index b309cfd..0000000 --- a/src/main/java/org/onap/dcae/inventory/clients/DCAEControllerClient.java +++ /dev/null @@ -1,223 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * dcae-inventory - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcae.inventory.clients; - -import org.onap.dcae.inventory.InventoryConfiguration; -import org.onap.dcae.inventory.exceptions.DCAEControllerClientException; -import org.onap.dcae.inventory.exceptions.DCAEControllerConnectionException; -import org.onap.dcae.inventory.exceptions.DCAEControllerTimeoutException; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.ws.rs.ProcessingException; -import javax.ws.rs.client.Client; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; - -import static org.glassfish.jersey.client.authentication.HttpAuthenticationFeature.*; - -/** - * Created by mhwang on 5/12/16. - */ -public class DCAEControllerClient { - - /** - * Used for JSON objects of the form: - * "hostService": {"$ref": "/services/vm-docker-host-2/instances/mtl2"} - */ - public static class Reference { - - @JsonProperty("$ref") - private String ref; - - public String getRef() { - return ref; - } - - public void setRef(String ref) { - this.ref = ref; - } - - } - - /** - * Used for the JSON objects returned from /services/{service id}/instances/{instance id} - * calls. - */ - @JsonIgnoreProperties(ignoreUnknown = true) - public static class ServiceInstance { - - @JsonProperty("status") - private String status; - - /** - * Property points to the Docker host this Docker container runs on. - * This service instance is an application to be run as a Docker container if this value is not null. - */ - @JsonProperty("hostService") - @JsonInclude(JsonInclude.Include.NON_ABSENT) - private Reference hostService; - - /** - * Property points to the CDAP cluster this CDAP application is deployed on. - * This service instance is a CDAP application if this value is not null. - */ - @JsonProperty("clusterService") - @JsonInclude(JsonInclude.Include.NON_ABSENT) - private Reference clusterService; - - /** - * Property points to the location resource that this instance is associated with. - * This property is not null when the service instance is a "pure" VM. - */ - @JsonProperty("location") - @JsonInclude(JsonInclude.Include.NON_ABSENT) - private Reference location; - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Reference getHostService() { - return hostService; - } - - public void setHostService(Reference hostService) { - this.hostService = hostService; - } - - public Reference getClusterService() { - return clusterService; - } - - public void setClusterService(Reference clusterService) { - this.clusterService = clusterService; - } - - public Reference getLocation() { - return location; - } - - public void setLocation(Reference location) { - this.location = location; - } - - } - - private static final Logger LOG = LoggerFactory.getLogger(DCAEControllerClient.class); - - private final Client client; - private final InventoryConfiguration.DCAEControllerConnectionConfiguration connectionConfiguration; - - public DCAEControllerClient(Client client, - InventoryConfiguration.DCAEControllerConnectionConfiguration connectionConfiguration) { - this.client = client; - this.connectionConfiguration = connectionConfiguration; - } - public URI constructResourceURI(String resourcePath) { - // TODO: Better way to construct this? - - // Make sure that the resource path has a "/" because the UriBuilder sucks and doesn't do it for us. - if (resourcePath.charAt(0) != '/') { - resourcePath = (new StringBuilder("/")).append(resourcePath).toString(); - } - - StringBuilder actualPath = new StringBuilder("/"); - actualPath.append(this.connectionConfiguration.getBasePath()); - actualPath.append(resourcePath); - - return UriBuilder.fromPath(actualPath.toString()).scheme("http").host(this.connectionConfiguration.getHost()) - .port(this.connectionConfiguration.getPort()).build(); - } - - public ServiceInstance getServiceInstance(String componentId) throws DCAEControllerClientException { - URI uri = constructResourceURI(componentId); - Response response = null; - - try { - response = client.target(uri).request(MediaType.APPLICATION_JSON_TYPE) - .header("Content-Type", "application/json") - .property(HTTP_AUTHENTICATION_BASIC_USERNAME, connectionConfiguration.getUser()) - .property(HTTP_AUTHENTICATION_BASIC_PASSWORD, connectionConfiguration.getPassword()).get(); - } catch (ProcessingException e) { - // Apparently the exceptions are wrapped which is not ideal because many different types of errors are embedded - // in single exception. TODO: May want to come back to split up the errors. - // Example: - // javax.ws.rs.ProcessingException: org.apache.http.conn.ConnectTimeoutException: Connect to <dcae controller domain name>:9998 - String message = "Connecting with DCAE controller probably timed out"; - LOG.error(message, e); - String exceptionMessage = String.format("%s: %s", message, e.getMessage()); - throw new DCAEControllerTimeoutException(exceptionMessage); - } catch (Exception e) { - String message = "Unexpected connection issue with DCAE controller"; - LOG.error(message, e); - String exceptionMessage = String.format("%s: %s", message, e.getMessage()); - throw new DCAEControllerConnectionException(exceptionMessage); - } - - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Received response from DCAE controller: %d", response.getStatus())); - } - - if (response.getStatus() == 200) { - ObjectMapper om = new ObjectMapper(); - - try { - return om.readValue((InputStream) response.getEntity(), ServiceInstance.class); - } catch (IOException e) { - throw new DCAEControllerClientException(e); - } - } - - throw new DCAEControllerClientException(String.format("Unexpected error from DCAE controller: %d", response.getStatus())); - } - - public String getLocation(ServiceInstance serviceInstance) { - if (serviceInstance.getLocation() != null) { - return serviceInstance.getLocation().getRef(); - } else if (serviceInstance.getClusterService() != null) { - // Drill down: Location is on the underlying CDAP cluster service instance - String cdapClusterRef = serviceInstance.getClusterService().getRef(); - return getLocation(getServiceInstance(cdapClusterRef)); - } else if (serviceInstance.getHostService() != null) { - // Drill down: Location is on the underlying Docker host service instance - String dockerHostRef = serviceInstance.getHostService().getRef(); - return getLocation(getServiceInstance(dockerHostRef)); - } else { - throw new DCAEControllerClientException("No valid location for service instance"); - } - } - - - -} diff --git a/src/main/java/org/onap/dcae/inventory/exceptions/DCAEControllerClientException.java b/src/main/java/org/onap/dcae/inventory/exceptions/DCAEControllerClientException.java deleted file mode 100644 index b549ee1..0000000 --- a/src/main/java/org/onap/dcae/inventory/exceptions/DCAEControllerClientException.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * dcae-inventory - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcae.inventory.exceptions; - -/** - * Created by mhwang on 5/13/16. - */ -public class DCAEControllerClientException extends RuntimeException { - - public DCAEControllerClientException(String message) { - super(message); - } - - public DCAEControllerClientException(Throwable e) { - super(e); - } - -} diff --git a/src/main/java/org/onap/dcae/inventory/exceptions/DCAEControllerConnectionException.java b/src/main/java/org/onap/dcae/inventory/exceptions/DCAEControllerConnectionException.java deleted file mode 100644 index f96ffbe..0000000 --- a/src/main/java/org/onap/dcae/inventory/exceptions/DCAEControllerConnectionException.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * dcae-inventory - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcae.inventory.exceptions; - -/** - * Created by mhwang on 8/23/16. - */ -public class DCAEControllerConnectionException extends RuntimeException { - - public DCAEControllerConnectionException(String message) { - super(message); - } - - public DCAEControllerConnectionException(Throwable e) { - super(e); - } - -} diff --git a/src/main/java/org/onap/dcae/inventory/exceptions/DCAEControllerTimeoutException.java b/src/main/java/org/onap/dcae/inventory/exceptions/DCAEControllerTimeoutException.java deleted file mode 100644 index 48f5044..0000000 --- a/src/main/java/org/onap/dcae/inventory/exceptions/DCAEControllerTimeoutException.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * dcae-inventory - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcae.inventory.exceptions; - -/** - * Created by mhwang on 8/23/16. - */ -public class DCAEControllerTimeoutException extends RuntimeException { - - public DCAEControllerTimeoutException(String message) { - super(message); - } - - public DCAEControllerTimeoutException(Throwable e) { - super(e); - } - -} diff --git a/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java b/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java deleted file mode 100644 index e345c6e..0000000 --- a/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DCAEControllerConnectionExceptionMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * dcae-inventory - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcae.inventory.exceptions.mappers; - -import org.onap.dcae.inventory.exceptions.DCAEControllerConnectionException; - -import javax.ws.rs.core.Response; - -/** - * Created by mhwang on 8/23/16. - */ -public class DCAEControllerConnectionExceptionMapper extends DCAEControllerExceptionMapper<DCAEControllerConnectionException> { - - @Override - protected Response.Status getStatus() { - return Response.Status.BAD_GATEWAY; - } - -} diff --git a/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java b/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java deleted file mode 100644 index 8e4eb3b..0000000 --- a/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DCAEControllerExceptionMapper.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * dcae-inventory - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcae.inventory.exceptions.mappers; - -import io.swagger.api.ApiResponseMessage; - -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; - -/** - * Created by mhwang on 8/23/16. - */ -public abstract class DCAEControllerExceptionMapper<T extends RuntimeException> implements ExceptionMapper<T> { - - abstract protected Response.Status getStatus(); - - @Override - public Response toResponse(T e) { - ApiResponseMessage response = new ApiResponseMessage(ApiResponseMessage.ERROR, e.getMessage()); - return Response.status(this.getStatus()).entity(response).build(); - } - -} diff --git a/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java b/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java deleted file mode 100644 index 67eb6ca..0000000 --- a/src/main/java/org/onap/dcae/inventory/exceptions/mappers/DCAEControllerTimeoutExceptionMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * dcae-inventory - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcae.inventory.exceptions.mappers; - -import org.onap.dcae.inventory.exceptions.DCAEControllerTimeoutException; - -import javax.ws.rs.core.Response; - -/** - * Created by mhwang on 8/23/16. - */ -public class DCAEControllerTimeoutExceptionMapper extends DCAEControllerExceptionMapper<DCAEControllerTimeoutException> { - - @Override - protected Response.Status getStatus() { - return Response.Status.GATEWAY_TIMEOUT; - } - -} diff --git a/src/main/resources/config.json b/src/main/resources/config.json index 436a181..89d887a 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -16,14 +16,6 @@ "evictionInterval": "10s", "minIdleTime": "1 minute" }, - "dcaeControllerConnection": { - "host": "dcae-controller-hostname", - "port": 9998, - "basePath": "resources", - "user": null, - "password": null, - "required": false - }, "databusControllerConnection": { "host": "databus-controller-hostname", "port": 8443, diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 505eea5..e882be0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,14 +40,6 @@ database: # the minimum amount of time an connection must sit idle in the pool before it is eligible for eviction minIdleTime: 1 minute -dcaeControllerConnection: - host: dcae-controller-hostname - port: 9998 - # Apparently this is variable parameter amongst DCAE controller instances - basePath: resources - user: - password: - databusControllerConnection: host: databus-controller-hostname port: 8443 |