From f5f13c4f6b6fe3b4d98e349dfd7db59339803436 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 19 Feb 2017 12:35:04 +0200 Subject: push addional code Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando --- .../application-config-rest-services/pom.xml | 62 +++++++++++++++ .../rest/ApplicationConfiguration.java | 69 +++++++++++++++++ ...licationConfigEntityToApplicationConfigDto.java | 34 +++++++++ ...MapConfigurationDataToConfigurationDataDto.java | 34 +++++++++ .../services/ApplicationConfigurationImpl.java | 87 ++++++++++++++++++++++ .../application-config-rest-types/pom.xml | 17 +++++ .../types/ApplicationConfigDto.java | 43 +++++++++++ .../types/ConfigurationDataDto.java | 50 +++++++++++++ .../application-config-rest/pom.xml | 23 ++++++ 9 files changed, 419 insertions(+) create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml new file mode 100644 index 0000000000..a5979798d2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + + org.openecomp.sdc + application-config-rest + 1.0.0-SNAPSHOT + + + application-config-rest-services + + + + + + io.swagger + swagger-annotations + 1.5.3 + + + javax.ws.rs + javax.ws.rs-api + ${ws.rs.version} + + + org.springframework + spring-context + ${spring.framework.version} + + + javax.inject + javax.inject + 1 + + + org.openecomp.sdc + openecomp-sdc-application-config-manager + ${project.version} + + + org.openecomp.sdc + application-config-rest-types + ${project.version} + + + org.openecomp.sdc + openecomp-sdc-common-rest + ${project.version} + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + ${cxf.version} + + + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java new file mode 100644 index 0000000000..df743a6a93 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdcrests.applicationconfig.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; +import org.springframework.validation.annotation.Validated; + +import java.io.InputStream; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("/v1.0/application-configuration") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Application Configuration") +@Validated +public interface ApplicationConfiguration { + + @POST + @Path("/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Insert JSON schema into application config table") + Response insertToTable(@QueryParam("namespace") String namespace, @QueryParam("key") String key, + @Multipart("value") InputStream fileContainingSchema); + + + @GET + @Path("/{namespace}/{key}") + @ApiOperation(value = "Get JSON schema by namespace and key", + response = ConfigurationDataDto.class) + Response getFromTable(@PathParam("namespace") String namespace, @PathParam("key") String key); + + + @GET + @Path("/{namespace}") + @ApiOperation(value = "Get List of keys and values by namespace", + responseContainer = "List") + Response getListOfConfigurationByNamespaceFromTable(@PathParam("namespace") String namespace); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java new file mode 100644 index 0000000000..4d43e37769 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdcrests.applicationconfig.rest.mapping; + +import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity; +import org.openecomp.sdcrests.applicationconfiguration.types.ApplicationConfigDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapApplicationConfigEntityToApplicationConfigDto + extends MappingBase { + @Override + public void doMapping(ApplicationConfigEntity source, ApplicationConfigDto target) { + target.setKey(source.getKey()); + target.setValue(source.getValue()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java new file mode 100644 index 0000000000..6865c676ec --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdcrests.applicationconfig.rest.mapping; + +import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; +import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapConfigurationDataToConfigurationDataDto + extends MappingBase { + @Override + public void doMapping(ConfigurationData source, ConfigurationDataDto target) { + target.setValue(source.getValue()); + target.setTimeStamp(source.getTimeStamp()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java new file mode 100644 index 0000000000..81f7251fdc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdcrests.applicationconfig.rest.services; + +import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity; +import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.sdc.applicationconfig.ApplicationConfigManager; +import org.openecomp.sdcrests.applicationconfig.rest.ApplicationConfiguration; +import org.openecomp.sdcrests.applicationconfig.rest.mapping.MapApplicationConfigEntityToApplicationConfigDto; +import org.openecomp.sdcrests.applicationconfig.rest.mapping.MapConfigurationDataToConfigurationDataDto; +import org.openecomp.sdcrests.applicationconfiguration.types.ApplicationConfigDto; +import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.io.InputStream; +import java.util.Collection; +import javax.inject.Named; + +import javax.ws.rs.core.Response; + +@Named +@Service("applicationConfiguration") +@Scope(value = "prototype") +public class ApplicationConfigurationImpl implements ApplicationConfiguration { + + @Autowired + private ApplicationConfigManager applicationConfigManager; + + + @Override + public Response insertToTable(String namespace, String key, InputStream fileContainingSchema) { + String value = new String(FileUtils.toByteArray(fileContainingSchema)); + + applicationConfigManager.insertIntoTable(namespace, key, value); + + return Response.ok().build(); + } + + @Override + public Response getFromTable(String namespace, String key) { + ConfigurationData value = applicationConfigManager.getFromTable(namespace, key); + ConfigurationDataDto valueDto = new MapConfigurationDataToConfigurationDataDto() + .applyMapping(value, ConfigurationDataDto.class); + + return Response.ok(valueDto).build(); + } + + @Override + public Response getListOfConfigurationByNamespaceFromTable(String namespace) { + Collection applicationConfigEntities = + applicationConfigManager.getListOfConfigurationByNamespace(namespace); + GenericCollectionWrapper applicationConfigWrapper = + new GenericCollectionWrapper<>(); + MapApplicationConfigEntityToApplicationConfigDto mapper = + new MapApplicationConfigEntityToApplicationConfigDto(); + + for (ApplicationConfigEntity applicationConfigEntity : applicationConfigEntities) { + applicationConfigWrapper + .add(mapper.applyMapping(applicationConfigEntity, ApplicationConfigDto.class)); + } + + return Response.ok(applicationConfigWrapper).build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml new file mode 100644 index 0000000000..52d592d4bf --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + + org.openecomp.sdc + application-config-rest + 1.0.0-SNAPSHOT + + + org.openecomp.sdc + application-config-rest-types + + + \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java new file mode 100644 index 0000000000..4d2f160d51 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdcrests.applicationconfiguration.types; + +public class ApplicationConfigDto { + + private String key; + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java new file mode 100644 index 0000000000..fcabcf5e89 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * 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.openecomp.sdcrests.applicationconfiguration.types; + +public class ConfigurationDataDto { + private String value; + private long timeStamp; + + public ConfigurationDataDto(String value, long timeStamp) { + this.value = value; + this.timeStamp = timeStamp; + } + + public ConfigurationDataDto() { + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public long getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(long timeStamp) { + this.timeStamp = timeStamp; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml new file mode 100644 index 0000000000..cc1fbbbe6b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + + org.openecomp.sdc + openecomp-sdc-rest-webapp + 1.0.0-SNAPSHOT + + + org.openecomp.sdc + application-config-rest + pom + + + + application-config-rest-services + application-config-rest-types + + + \ No newline at end of file -- cgit 1.2.3-korg