diff options
13 files changed, 70 insertions, 30 deletions
diff --git a/LICENSE.txt b/LICENSE.txt index 69d5fc1..9536f0b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,11 +1,11 @@ /* * ============LICENSE_START========================================== * =================================================================== -* Copyright © 2017 AT&T Intellectual Property. All rights reserved. +* Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. * =================================================================== * * Unless otherwise specified, all software contained herein is licensed -* under the Apache License, Version 2.0 (the “License”); +* under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -20,7 +20,7 @@ * * * Unless otherwise specified, all documentation contained herein is licensed -* under the Creative Commons License, Attribution 4.0 Intl. (the “License”); +* under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -1,3 +1,22 @@ +<!-- +================================================================================ +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. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END========================================================= + +ECOMP is a trademark and service mark of AT&T Intellectual Property. +--> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> diff --git a/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java index c3be670..fc6509a 100644 --- a/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java +++ b/src/main/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImpl.java @@ -112,7 +112,7 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService { } if (asdcServiceId != null) { - if ("NONE".equals(asdcServiceId.toUpperCase(Locale.ENGLISH))) { + if (asdcServiceId.equalsIgnoreCase("NONE")) { whereClauses.add("asdc_service_id is null"); } else { whereClauses.add(":asdcServiceId = asdc_service_id"); @@ -120,7 +120,7 @@ public class DcaeServiceTypesApiServiceImpl extends DcaeServiceTypesApiService { } if (asdcResourceId != null) { - if ("NONE".equals(asdcResourceId.toUpperCase(Locale.ENGLISH))) { + if (asdcResourceId.equalsIgnoreCase("NONE")) { whereClauses.add("asdc_resource_id is null"); } else { whereClauses.add(":asdcResourceId = asdc_resource_id"); diff --git a/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java index ae613da..f1219ac 100644 --- a/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java +++ b/src/main/java/io/swagger/api/impl/DcaeServicesApiServiceImpl.java @@ -76,7 +76,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { service.setVnfLocation(serviceObject.getVnfLocation()); service.setDeploymentRef(serviceObject.getDeploymentRef()); - List<DCAEServiceComponent> serviceComponents = new ArrayList<DCAEServiceComponent>(); + List<DCAEServiceComponent> serviceComponents = new ArrayList<>(); for (DCAEServiceComponentObject sco : componentObjects) { DCAEServiceComponent component = new DCAEServiceComponent(); @@ -136,7 +136,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { String componentType, Boolean shareable, DateTime created, Integer offset, UriInfo uriInfo, SecurityContext securityContext) { List<DCAEServiceObject> serviceObjects = new ArrayList<>(); - DateTime createdCutoff = (created == null ? DateTime.now(DateTimeZone.UTC) : created); + DateTime createdCutoff = created == null ? DateTime.now(DateTimeZone.UTC) : created; LOG.info(String.format("Create time upper bound cutoff: %s", createdCutoff.toString())); @@ -150,7 +150,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { sb.append(" join dcae_services_components_maps m on ds.service_id = m.service_id "); sb.append(" join dcae_service_components dsc on m.component_id = dsc.component_id"); - List<String> whereClauses = new ArrayList<String>(); + List<String> whereClauses = new ArrayList<>(); if (typeId != null) { whereClauses.add("ds.type_id = :typeId"); @@ -211,7 +211,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { if (shareable != null) { // NOTE: That the shareable field in the database is actually an integer. - query.bind("shareable", (shareable ? 1 : 0)); + query.bind("shareable", shareable ? 1 : 0); } query.bind("createdCutoff", createdCutoff); @@ -229,7 +229,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { List<DCAEServiceObject> serviceObjectsSliced = serviceObjects.subList(offset, endpoint); DCAEServiceComponentsDAO componentsDAO = InventoryDAOManager.getInstance().getDCAEServiceComponentsDAO(); - List<DCAEService> services = new ArrayList<DCAEService>(); + List<DCAEService> services = new ArrayList<>(); for (DCAEServiceObject so : serviceObjectsSliced) { List<DCAEServiceComponentObject> components = componentsDAO.getByServiceId(so.getServiceId()); @@ -302,7 +302,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { // Watch! We have to query for services regardless of status because we need to account for "removed" instances // that get resurrected. final DCAEServiceObject serviceObjectFromStore = servicesDAO.getByServiceId(serviceId); - final Map<String, DCAEServiceComponentObject> componentObjectsFromStore = new HashMap<String, DCAEServiceComponentObject>(); + final Map<String, DCAEServiceComponentObject> componentObjectsFromStore = new HashMap<>(); for (DCAEServiceComponentObject componentObject : componentsDAO.getByServiceId(serviceId)) { componentObjectsFromStore.put(componentObject.getComponentId(), componentObject); @@ -333,7 +333,7 @@ public class DcaeServicesApiServiceImpl extends DcaeServicesApiService { // 2) Insert/update DCAEServiceComponentObjects. Components exist independent of the associated DCAE service. - Map<String, DCAEServiceComponentObject> componentObjectsToSendBack = new HashMap<String, DCAEServiceComponentObject>(); + Map<String, DCAEServiceComponentObject> componentObjectsToSendBack = new HashMap<>(); for (DCAEServiceComponentRequest requestComponent : request.getComponents()) { // Have to query the database rather than checking the result of getting by service id because of the diff --git a/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java b/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java index 7c4e406..34fba7d 100644 --- a/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java +++ b/src/main/java/io/swagger/api/impl/DcaeServicesGroupbyApiServiceImpl.java @@ -39,7 +39,7 @@ public class DcaeServicesGroupbyApiServiceImpl extends DcaeServicesGroupbyApiSer @Override public Response dcaeServicesGroupbyPropertyNameGet(String propertyName, UriInfo uriInfo, SecurityContext securityContext) { - String columnName = ""; + String columnName; switch (propertyName) { case "type": diff --git a/src/main/java/org/onap/dcae/inventory/clients/DCAEControllerClient.java b/src/main/java/org/onap/dcae/inventory/clients/DCAEControllerClient.java index fed16b8..b309cfd 100644 --- a/src/main/java/org/onap/dcae/inventory/clients/DCAEControllerClient.java +++ b/src/main/java/org/onap/dcae/inventory/clients/DCAEControllerClient.java @@ -139,6 +139,11 @@ public class DCAEControllerClient { 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? @@ -213,10 +218,6 @@ public class DCAEControllerClient { } } - public DCAEControllerClient(Client client, - InventoryConfiguration.DCAEControllerConnectionConfiguration connectionConfiguration) { - this.client = client; - this.connectionConfiguration = connectionConfiguration; - } + } diff --git a/src/main/java/org/onap/dcae/inventory/clients/DatabusControllerClient.java b/src/main/java/org/onap/dcae/inventory/clients/DatabusControllerClient.java index 29330b0..b2429d9 100644 --- a/src/main/java/org/onap/dcae/inventory/clients/DatabusControllerClient.java +++ b/src/main/java/org/onap/dcae/inventory/clients/DatabusControllerClient.java @@ -48,7 +48,7 @@ public class DatabusControllerClient { resourcePath = (new StringBuilder("/")).append(resourcePath).toString(); } - return UriBuilder.fromPath(resourcePath.toString()).scheme("https").host(this.connectionConfiguration.getHost()) + return UriBuilder.fromPath(resourcePath).scheme("https").host(this.connectionConfiguration.getHost()) .port(this.connectionConfiguration.getPort()).build(); } diff --git a/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java index bdb6298..aa242a4 100644 --- a/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java +++ b/src/main/java/org/onap/dcae/inventory/daos/DCAEServiceTypesDAO.java @@ -40,6 +40,7 @@ import org.skife.jdbi.v2.sqlobject.customizers.Mapper; public interface DCAEServiceTypesDAO extends InventoryDAO { @SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_service_types\')") + @Override Boolean checkIfTableExists(); /** @@ -51,6 +52,7 @@ public interface DCAEServiceTypesDAO extends InventoryDAO { "vnf_types varchar[] not null, service_ids varchar[], service_locations varchar[], " + "asdc_service_id varchar, asdc_resource_id varchar, " + "created timestamp not null, deactivated timestamp, constraint pk_type_created primary key (type_id))") + @Override void createTable(); // REVIEW: asdcServiceId and asdcResourceId is implicitly part of the unique key and thus shouldn't be updated. diff --git a/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java b/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java index 68ed59c..270d638 100644 --- a/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java +++ b/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesComponentsMapsDAO.java @@ -34,8 +34,10 @@ import org.skife.jdbi.v2.sqlobject.SqlUpdate; public interface DCAEServicesComponentsMapsDAO extends InventoryDAO { @SqlQuery("select exists (select * from information_schema.tables where table_name = \'dcae_services_components_maps\')") + @Override Boolean checkIfTableExists(); + @Override @SqlUpdate("create table dcae_services_components_maps (service_id varchar not null references dcae_services (service_id), " + "component_id varchar not null references dcae_service_components (component_id), " + "created timestamp not null, primary key (service_id, component_id))") diff --git a/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesDAO.java b/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesDAO.java index c1ca46e..0595a9a 100644 --- a/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesDAO.java +++ b/src/main/java/org/onap/dcae/inventory/daos/DCAEServicesDAO.java @@ -42,7 +42,8 @@ public interface DCAEServicesDAO extends InventoryDAO { @SqlUpdate("create table dcae_services (service_id varchar not null primary key, type_id varchar not null, " + "vnf_id varchar not null, vnf_type varchar not null, vnf_location varchar not null, deployment_ref varchar, " + - "created timestamp not null, modified timestamp not null, status varchar not null)") + "created timestamp not null, modified timestamp not null, status varchar not null)") + @Override void createTable(); @SqlUpdate("insert into dcae_services(service_id, type_id, vnf_id, vnf_type, vnf_location, deployment_ref, " + diff --git a/src/main/java/org/onap/dcae/inventory/dbthings/StringListArgument.java b/src/main/java/org/onap/dcae/inventory/dbthings/StringListArgument.java index b08bec1..aa41ac6 100644 --- a/src/main/java/org/onap/dcae/inventory/dbthings/StringListArgument.java +++ b/src/main/java/org/onap/dcae/inventory/dbthings/StringListArgument.java @@ -44,14 +44,12 @@ public class StringListArgument implements ArgumentFactory<List<String>> { } @Override - public Argument build(Class<?> expectedType, List<String> value, StatementContext statementContext) { - return new Argument() { - @Override - public void apply(int position, PreparedStatement statement, StatementContext ctx) throws SQLException { - Array values = statement.getConnection().createArrayOf("varchar", value.toArray()); - statement.setArray(position, values); - } - }; - } + public Argument build(Class<?> expectedType, List<String> value, StatementContext statementContext) { + return (int position, PreparedStatement statement, StatementContext ctx) -> { + Array values = statement.getConnection().createArrayOf("varchar", value.toArray()); + statement.setArray(position, values); + }; + + } } diff --git a/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObject.java b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObject.java index 83e2bfe..232c18a 100644 --- a/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObject.java +++ b/src/main/java/org/onap/dcae/inventory/dbthings/models/DCAEServiceObject.java @@ -29,7 +29,7 @@ import org.joda.time.DateTimeZone; */ public class DCAEServiceObject { - public static enum DCAEServiceStatus { + public enum DCAEServiceStatus { RUNNING, REMOVED } diff --git a/swagger_inventory.yaml b/swagger_inventory.yaml index 11dbcbc..068f221 100644 --- a/swagger_inventory.yaml +++ b/swagger_inventory.yaml @@ -1,3 +1,20 @@ +# ================================================================================ +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# ECOMP is a trademark and service mark of AT&T Intellectual Property. swagger: '2.0' info: version: "2.1.0" |