diff options
author | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-08-17 19:45:00 +0000 |
---|---|---|
committer | Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com> | 2018-08-20 01:18:24 +0000 |
commit | a3c9519d6aa7eb8e1f450a7d041047f2c0a5cc07 (patch) | |
tree | 8681e2b23e7eabfd2c0034c6b74b48ac17631d65 /ms/controllerblueprints/modules/service/src | |
parent | c9cb1ad84cc84566f85eef8f8c6351a94b2d7340 (diff) |
Controller Blueprints Microservice
Restcontroller Swagger Implementation with Embeded jar for Controller Bluprints MS
Change-Id: I0c0a33f0e29dad0d4aa703e3e381068b510e57d4
Issue-ID: CCSDK-468
Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/controllerblueprints/modules/service/src')
16 files changed, 288 insertions, 975 deletions
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java deleted file mode 100644 index f223dccb2..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.common;
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-import javax.ws.rs.ext.Provider;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-@Provider
-public class ServiceExceptionMapper implements ExceptionMapper<BluePrintException> {
-
- @Override
- public Response toResponse(BluePrintException ex) {
- ErrorMessage errorMessage = new ErrorMessage();
- errorMessage.setCode(ex.getCode());
- errorMessage.setMessage(ex.getMessage());
- StringWriter errorStackTrace = new StringWriter();
- ex.printStackTrace(new PrintWriter(errorStackTrace));
- errorMessage.setDeveloperMessage(ex.toString());
- return Response.status(500).entity(errorMessage).type(MediaType.APPLICATION_JSON).build();
- }
-
-}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java index e90807633..81f7d7018 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java @@ -1,17 +1,17 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Copyright © 2017-2018 AT&T Intellectual Property.
*
- * 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
+ * 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
+ * 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.
+ * 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.
*/
package org.onap.ccsdk.apps.controllerblueprints.service.common;
@@ -20,7 +20,6 @@ import io.swagger.models.*; import io.swagger.models.parameters.BodyParameter;
import io.swagger.models.parameters.Parameter;
import io.swagger.models.properties.*;
-import io.swagger.util.Json;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
@@ -63,8 +62,7 @@ public class SwaggerGenerator { swagger.setDefinitions(getDefinition());
- swaggerContent = Json.pretty(swagger);
- return swaggerContent;
+ return swagger.toString();
}
private Info getInfo() {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java index 86c89bf90..94324a808 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java @@ -16,164 +16,112 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-import io.swagger.annotations.*;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
+import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.*;
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
import java.util.List;
/**
- * ConfigModelRest.java Purpose: Rest service controller for ConfigModelRest Management
- *
- * @author Brinda Santh
- * @version 1.0
+ * {@inheritDoc}
*/
-@Api
-@Path("/service")
-@Produces({MediaType.APPLICATION_JSON})
-public interface ConfigModelRest {
+@RestController
+@RequestMapping("/api/v1/config-model")
+public class ConfigModelRest {
- /**
- * This is a getConfigModel rest service
- *
- * @param id
- * @return ConfigModel
- * @throws BluePrintException
- */
- @GET
- @Path("/configmodel/{id}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- @RequestMapping(value = "/configmodel/{id}", method = RequestMethod.GET)
- @ResponseBody ConfigModel getConfigModel(@ApiParam(required = true) @PathParam("id") Long id)
- throws BluePrintException;
-
+ private ConfigModelService configModelService;
/**
- * This is a saveConfigModel rest service
- *
- * @param configModel
- * @return ConfigModel
- * @throws BluePrintException
+ * This is a ConfigModelRest constructor.
+ *
+ * @param configModelService Config Model Service
*/
- @POST
- @Path("/configmodel")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ServiceTemplate.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ConfigModel saveConfigModel(@ApiParam(required = true) ConfigModel configModel)
- throws BluePrintException;
+ public ConfigModelRest(ConfigModelService configModelService) {
+ this.configModelService = configModelService;
- /**
- * This is a deleteConfigModel rest service
- *
- * @param id
- * @throws BluePrintException
- */
- @DELETE
- @Path("/configmodel/{id}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to delete ConfigModel.")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- void deleteConfigModel(@ApiParam(required = true) @PathParam("id") Long id) throws BluePrintException;
+ }
- /**
- * This is a getInitialConfigModel rest service
- *
- * @param name
- * @return ConfigModel
- * @throws BluePrintException
- */
- @GET
- @Path("/configmodelinitial/{name}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ConfigModel getInitialConfigModel(@ApiParam(required = true) @PathParam("name") String name)
- throws BluePrintException;
+ @GetMapping(path = "/initial/{name}")
+ public @ResponseBody
+ ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException {
+ try {
+ return this.configModelService.getInitialConfigModel(name);
+ } catch (Exception e) {
+ throw new BluePrintException(2000, e.getMessage(), e);
+ }
+ }
- /**
- * This is a getCloneConfigModel rest service
- *
- * @param id
- * @return ConfigModel
- * @throws BluePrintException
- */
- @GET
- @Path("/configmodelclone/{id}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ConfigModel getCloneConfigModel(@ApiParam(required = true) @PathParam("id") Long id)
- throws BluePrintException;
+ @PostMapping(path = "/")
+ public @ResponseBody
+ ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException {
+ try {
+ return this.configModelService.saveConfigModel(configModel);
+ } catch (Exception e) {
+ throw new BluePrintException(2200, e.getMessage(), e);
+ }
+ }
- /**
- * This is a publishConfigModel rest service
- *
- * @param id
- * @return ServiceTemplate
- * @throws BluePrintException
- */
- @GET
- @Path("/configmodelpublish/{id}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ConfigModel.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ConfigModel publishConfigModel(@ApiParam(required = true) @PathParam("id") Long id)
- throws BluePrintException;
+ @DeleteMapping(path = "/{id}")
+ public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
+ try {
+ this.configModelService.deleteConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(4000, e.getMessage(), e);
+ }
+ }
- /**
- * This is a getConfigModelByNameAndVersion rest service
- *
- * @param name
- * @param version
- * @return ConfigModel
- * @throws BluePrintException
- */
- @GET
- @Path("/configmodelbyname/{name}/version/{version}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ConfigModel getConfigModelByNameAndVersion(@ApiParam(required = true) @PathParam("name") String name,
- @ApiParam(required = true) @PathParam("version") String version) throws BluePrintException;
+ @GetMapping(path = "/publish/{id}")
+ public @ResponseBody
+ ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
+ try {
+ return this.configModelService.publishConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(2500, e.getMessage(), e);
+ }
+ }
- /**
- * This is a searchServiceModels rest service
- *
- * @param tags
- * @return List<ConfigModel>
- * @throws BluePrintException
- */
- @GET
- @Path("/configmodelsearch/{tags}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- List<ConfigModel> searchConfigModels(@ApiParam(required = true) @PathParam("tags") String tags)
- throws BluePrintException;
+ @GetMapping(path = "/{id}")
+ public @ResponseBody
+ ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
+ try {
+ return this.configModelService.getConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(2001, e.getMessage(), e);
+ }
+ }
+
+ @GetMapping(path = "/by-name/{name}/version/{version}")
+ public @ResponseBody
+ ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name,
+ @PathVariable(value = "version") String version) throws BluePrintException {
+ try {
+ return this.configModelService.getConfigModelByNameAndVersion(name, version);
+ } catch (Exception e) {
+ throw new BluePrintException(2002, e.getMessage(), e);
+ }
+ }
+
+ @GetMapping(path = "/search/{tags}")
+ public @ResponseBody
+ List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException {
+ try {
+ return this.configModelService.searchConfigModels(tags);
+ } catch (Exception e) {
+ throw new BluePrintException(2003, e.getMessage(), e);
+ }
+ }
+
+ @GetMapping(path = "/clone/{id}")
+ public @ResponseBody
+ ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
+ try {
+ return this.configModelService.getCloneConfigModel(id);
+ } catch (Exception e) {
+ throw new BluePrintException(2004, e.getMessage(), e);
+ }
+ }
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java deleted file mode 100644 index a9abcd5ff..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * {@inheritDoc}
- */
-@Service
-public class ConfigModelRestImpl implements ConfigModelRest {
-
- private ConfigModelService configModelService;
-
- /**
- * This is a ConfigModelRestImpl constructor.
- *
- * @param configModelService Config Model Service
- */
- public ConfigModelRestImpl(ConfigModelService configModelService) {
- this.configModelService = configModelService;
-
- }
-
- @Override
- public ConfigModel getInitialConfigModel(String name) throws BluePrintException {
- try {
- return this.configModelService.getInitialConfigModel(name);
- } catch (Exception e) {
- throw new BluePrintException(2000, e.getMessage(), e);
- }
- }
-
- @Override
- public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {
- try {
- return this.configModelService.saveConfigModel(configModel);
- } catch (Exception e) {
- throw new BluePrintException(2200, e.getMessage(), e);
- }
- }
-
- @Override
- public void deleteConfigModel(Long id) throws BluePrintException {
- try {
- this.configModelService.deleteConfigModel(id);
- } catch (Exception e) {
- throw new BluePrintException(4000, e.getMessage(), e);
- }
- }
-
- @Override
- public ConfigModel publishConfigModel(Long id) throws BluePrintException {
- try {
- return this.configModelService.publishConfigModel(id);
- } catch (Exception e) {
- throw new BluePrintException(2500, e.getMessage(), e);
- }
- }
-
- @Override
- public ConfigModel getConfigModel(Long id) throws BluePrintException {
- try {
- return this.configModelService.getConfigModel(id);
- } catch (Exception e) {
- throw new BluePrintException(2001, e.getMessage(), e);
- }
- }
-
- @Override
- public ConfigModel getConfigModelByNameAndVersion(String name, String version) throws BluePrintException {
- try {
- return this.configModelService.getConfigModelByNameAndVersion(name, version);
- } catch (Exception e) {
- throw new BluePrintException(2002, e.getMessage(), e);
- }
- }
-
- @Override
- public List<ConfigModel> searchConfigModels(String tags) throws BluePrintException {
- try {
- return this.configModelService.searchConfigModels(tags);
- } catch (Exception e) {
- throw new BluePrintException(2003, e.getMessage(), e);
- }
- }
-
- @Override
- public ConfigModel getCloneConfigModel(Long id) throws BluePrintException {
- try {
- return this.configModelService.getCloneConfigModel(id);
- } catch (Exception e) {
- throw new BluePrintException(2004, e.getMessage(), e);
- }
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java index 59b730309..2fa64316f 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java @@ -16,110 +16,77 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-import io.swagger.annotations.*;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.*;
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
import java.util.List;
/**
- * ModelTypeRest.java Purpose: Rest service controller for Artifact Handling
- *
- * @author Brinda Santh
- * @version 1.0
+ * {@inheritDoc}
*/
-@Api
-@Path("/service")
-@Produces({MediaType.APPLICATION_JSON})
-public interface ModelTypeRest {
+@RestController
+@RequestMapping("/api/v1/model-type")
+public class ModelTypeRest {
- /**
- * This is a getModelTypeByName rest service
- *
- * @param name
- * @return ModelType
- * @throws BluePrintException
- */
- @GET
- @Path("/modeltype/{name}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to get Model Type by id", response = ModelType.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ModelType getModelTypeByName(@ApiParam(required = true) @PathParam("name") String name)
- throws BluePrintException;
+ private ModelTypeService modelTypeService;
/**
- * This is a saveModelType rest service
- *
- * @param modelType
- * @return ModelType
- * @throws BluePrintException
+ * This is a ModelTypeResourceImpl, used to save and get the model types stored in database
+ *
+ * @param modelTypeService Model Type Service
*/
+ public ModelTypeRest(ModelTypeService modelTypeService) {
+ this.modelTypeService = modelTypeService;
+ }
- @POST
- @Path("/modeltype")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to Save Model Type", response = ModelType.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ModelType saveModelType(@ApiParam(required = true) ModelType modelType) throws BluePrintException;
+ @GetMapping(path = "/{name}")
+ public ModelType getModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {
+ try {
+ return modelTypeService.getModelTypeByName(name);
+ } catch (Exception e) {
+ throw new BluePrintException(1000, e.getMessage(), e);
+ }
+ }
- /**
- * This is a deleteModelType rest service
- *
- * @param name
- * @throws BluePrintException
- */
- @DELETE
- @Path("/modeltype/{name}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to delete Model Type")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- void deleteModelTypeByName(@ApiParam(required = true) @PathParam("name") String name)
- throws BluePrintException;
+ @GetMapping(path = "/search/{tags}")
+ public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) throws BluePrintException {
+ try {
+ return modelTypeService.searchModelTypes(tags);
+ } catch (Exception e) {
+ throw new BluePrintException(1001, e.getMessage(), e);
+ }
+ }
- /**
- * This is a searchModelType rest service
- *
- * @param tags
- * @return List<ModelType>
- * @throws BluePrintException
- */
- @GET
- @Path("/modeltypesearch/{tags}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class,
- responseContainer = "List")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- List<ModelType> searchModelTypes(@ApiParam(required = true) @PathParam("tags") String tags)
- throws BluePrintException;
+ @GetMapping(path = "/by-definition/{definitionType}")
+ public @ResponseBody
+ List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) throws BluePrintException {
+ try {
+ return modelTypeService.getModelTypeByDefinitionType(definitionType);
+ } catch (Exception e) {
+ throw new BluePrintException(1002, e.getMessage(), e);
+ }
+ }
- /**
- * This is a getModelTypeByDefinitionType rest service
- *
- * @param definitionType
- * @return List<ModelType>
- * @throws BluePrintException
- */
- @GET
- @Path("/modeltypebydefinition/{definitionType}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class,
- responseContainer = "List")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- List<ModelType> getModelTypeByDefinitionType(
- @ApiParam(required = true) @PathParam("definitionType") String definitionType)
- throws BluePrintException;
+ @PostMapping(path = "/")
+ public @ResponseBody
+ ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException {
+ try {
+ return modelTypeService.saveModel(modelType);
+ } catch (Exception e) {
+ throw new BluePrintException(1100, e.getMessage(), e);
+ }
+ }
+ @DeleteMapping(path = "/{name}")
+ public void deleteModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {
+ try {
+ modelTypeService.deleteByModelName(name);
+ } catch (Exception e) {
+ throw new BluePrintException(1400, e.getMessage(), e);
+ }
+ }
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java deleted file mode 100644 index 6fbc69699..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * {@inheritDoc}
- */
-@Service
-public class ModelTypeRestImpl implements ModelTypeRest {
-
- private ModelTypeService modelTypeService;
-
- /**
- * This is a ModelTypeResourceImpl, used to save and get the model types stored in database
- *
- * @param modelTypeService Model Type Service
- */
- public ModelTypeRestImpl(ModelTypeService modelTypeService) {
- this.modelTypeService = modelTypeService;
- }
-
- @Override
- public ModelType getModelTypeByName(String modelName) throws BluePrintException {
- try {
- return modelTypeService.getModelTypeByName(modelName);
- } catch (Exception e) {
- throw new BluePrintException(1000, e.getMessage(), e);
- }
- }
-
- @Override
- public List<ModelType> searchModelTypes(String tags) throws BluePrintException {
- try {
- return modelTypeService.searchModelTypes(tags);
- } catch (Exception e) {
- throw new BluePrintException(1001, e.getMessage(), e);
- }
- }
-
- @Override
- public List<ModelType> getModelTypeByDefinitionType(String definitionType) throws BluePrintException {
- try {
- return modelTypeService.getModelTypeByDefinitionType(definitionType);
- } catch (Exception e) {
- throw new BluePrintException(1002, e.getMessage(), e);
- }
- }
-
- @Override
- public ModelType saveModelType(ModelType modelType) throws BluePrintException {
- try {
- return modelTypeService.saveModel(modelType);
- } catch (Exception e) {
- throw new BluePrintException(1100, e.getMessage(), e);
- }
- }
-
- @Override
- public void deleteModelTypeByName(String name) throws BluePrintException {
- try {
- modelTypeService.deleteByModelName(name);
- } catch (Exception e) {
- throw new BluePrintException(1400, e.getMessage(), e);
- }
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index 5bc983363..dfb06bba5 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -16,111 +16,83 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-import io.swagger.annotations.*;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.*;
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
import java.util.List;
/**
- * ResourceDictionaryRest.java Purpose: Rest service controller for Artifact Handling
- *
- * @author Brinda Santh
- * @version 1.0
+ * {@inheritDoc}
*/
-@Api
-@Path("/service")
-@Produces({MediaType.APPLICATION_JSON})
+@RestController
+@RequestMapping(value = "/api/v1/dictionary")
+public class ResourceDictionaryRest {
-public interface ResourceDictionaryRest {
- /**
- * This is a getDataDictionaryByPath rest service
- *
- * @param name
- * @return ResourceDictionary
- * @throws BluePrintException
- */
- @GET
- @Path("/dictionary/{name}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to get Resource dictionary", response = ResourceDictionary.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ResourceDictionary getResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name)
- throws BluePrintException;
+ private ResourceDictionaryService resourceDictionaryService;
/**
- * This is a saveDataDictionary rest service
- *
- * @param resourceMapping
- * @return ResourceDictionary
- * @throws BluePrintException
+ * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database
+ *
+ * @param dataDictionaryService Data Dictionary Service
*/
+ public ResourceDictionaryRest(ResourceDictionaryService dataDictionaryService) {
+ this.resourceDictionaryService = dataDictionaryService;
+ }
- @POST
- @Path("/dictionary")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to Save Resource dictionary Type", response = ResourceDictionary.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ResourceDictionary saveResourceDictionary(@ApiParam(required = true) ResourceDictionary resourceMapping)
- throws BluePrintException;
+ @PostMapping(path = "/")
+ public @ResponseBody
+ ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary)
+ throws BluePrintException {
+ try {
+ return resourceDictionaryService.saveResourceDictionary(dataDictionary);
+ } catch (Exception e) {
+ throw new BluePrintException(4100, e.getMessage(), e);
+ }
+ }
- /**
- * This is a deleteDataDictionaryByName rest service
- *
- * @param name
- * @throws BluePrintException
- */
- @DELETE
- @Path("/dictionary/{name}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to delete ResourceDictionary Type")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- void deleteResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name)
- throws BluePrintException;
+ @DeleteMapping(path = "/{name}")
+ public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
+ try {
+ resourceDictionaryService.deleteResourceDictionary(name);
+ } catch (Exception e) {
+ throw new BluePrintException(4400, e.getMessage(), e);
+ }
+ }
- /**
- * This is a searchResourceDictionaryByTags rest service
- *
- * @param tags
- * @return ResourceDictionary
- * @throws BluePrintException
- */
- @GET
- @Path("/dictionarysearch/{tags}")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to search Resource dictionary by tags",
- response = ResourceDictionary.class, responseContainer = "List")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- List<ResourceDictionary> searchResourceDictionaryByTags(
- @ApiParam(required = true) @PathParam("tags") String tags) throws BluePrintException;
+ @GetMapping(path = "/{name}")
+ public @ResponseBody
+ ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
+ try {
+ return resourceDictionaryService.getResourceDictionaryByName(name);
+ } catch (Exception e) {
+ throw new BluePrintException(4001, e.getMessage(), e);
+ }
+ }
- /**
- * This is a searchResourceDictionaryByNames rest service
- *
- * @param names
- * @return List<ResourceDictionary>
- * @throws BluePrintException
- */
- @POST
- @Path("/dictionarybynames")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to get ResourceDictionary Type by names",
- response = ResourceDictionary.class, responseContainer = "List")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- List<ResourceDictionary> searchResourceDictionaryByNames(@ApiParam(required = true) List<String> names)
- throws BluePrintException;
+ @PostMapping(path = "/by-names")
+ public @ResponseBody
+ List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names)
+ throws BluePrintException {
+ try {
+ return resourceDictionaryService.searchResourceDictionaryByNames(names);
+ } catch (Exception e) {
+ throw new BluePrintException(4002, e.getMessage(), e);
+ }
+ }
+
+ @GetMapping(path = "/search/{tags}")
+ public @ResponseBody
+ List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException {
+ try {
+ return resourceDictionaryService.searchResourceDictionaryByTags(tags);
+ } catch (Exception e) {
+ throw new BluePrintException(4003, e.getMessage(), e);
+ }
+ }
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java deleted file mode 100644 index e3448424d..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * {@inheritDoc}
- */
-@Service
-public class ResourceDictionaryRestImpl implements ResourceDictionaryRest {
-
-
- private ResourceDictionaryService resourceDictionaryService;
-
- /**
- * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database
- *
- * @param dataDictionaryService Data Dictionary Service
- */
- public ResourceDictionaryRestImpl(ResourceDictionaryService dataDictionaryService) {
- this.resourceDictionaryService = dataDictionaryService;
- }
-
- @Override
- public ResourceDictionary saveResourceDictionary(ResourceDictionary dataDictionary)
- throws BluePrintException {
- try {
- return resourceDictionaryService.saveResourceDictionary(dataDictionary);
- } catch (Exception e) {
- throw new BluePrintException(4100, e.getMessage(), e);
- }
- }
-
- @Override
- public void deleteResourceDictionaryByName(String name) throws BluePrintException {
- try {
- resourceDictionaryService.deleteResourceDictionary(name);
- } catch (Exception e) {
- throw new BluePrintException(4400, e.getMessage(), e);
- }
- }
-
- @Override
- public ResourceDictionary getResourceDictionaryByName(String resourcePath) throws BluePrintException {
- try {
- return resourceDictionaryService.getResourceDictionaryByName(resourcePath);
- } catch (Exception e) {
- throw new BluePrintException(4001, e.getMessage(), e);
- }
- }
-
- @Override
- public List<ResourceDictionary> searchResourceDictionaryByNames(List<String> names)
- throws BluePrintException {
- try {
- return resourceDictionaryService.searchResourceDictionaryByNames(names);
- } catch (Exception e) {
- throw new BluePrintException(4002, e.getMessage(), e);
- }
- }
-
- @Override
- public List<ResourceDictionary> searchResourceDictionaryByTags(String tags) throws BluePrintException {
- try {
- return resourceDictionaryService.searchResourceDictionaryByTags(tags);
- } catch (Exception e) {
- throw new BluePrintException(4003, e.getMessage(), e);
- }
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java index fcb8f3119..d8ea1941b 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java @@ -16,119 +16,87 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-import io.swagger.annotations.*;
+
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
+import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.*;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
import java.util.List;
-
/**
- * ServiceTemplateRest.java Purpose: ServiceTemplateRest interface
- *
- * @author Brinda Santh
- * @version 1.0
+ * {@inheritDoc}
*/
+@RestController
+@RequestMapping(value = "/api/v1/service-template")
+public class ServiceTemplateRest {
-@Api
-@Path("/service")
-@Produces({MediaType.APPLICATION_JSON})
-public interface ServiceTemplateRest {
+ private ServiceTemplateService serviceTemplateService;
/**
- * This is a enrichServiceTemplate rest service
- *
- * @param serviceTemplate
- * @return ServiceTemplate
- * @throws BluePrintException
+ * This is a ServiceTemplateRest constructor
+ *
+ * @param serviceTemplateService Service Template Service
*/
- @POST
- @Path("/servicetemplate/enrich")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to enrich service template", response = ServiceTemplate.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ServiceTemplate enrichServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate)
- throws BluePrintException;
+ public ServiceTemplateRest(ServiceTemplateService serviceTemplateService) {
+ this.serviceTemplateService = serviceTemplateService;
+ }
- /**
- * This is a validateServiceTemplate rest service
- *
- * @param serviceTemplate
- * @return ServiceTemplate
- * @throws BluePrintException
- */
- @POST
- @Path("/servicetemplate/validate")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to validate service template", response = ServiceTemplate.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- ServiceTemplate validateServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate)
- throws BluePrintException;
+ @PostMapping(path = "/enrich")
+ public @ResponseBody
+ ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {
+ try {
+ return serviceTemplateService.enrichServiceTemplate(serviceTemplate);
+ } catch (Exception e) {
+ throw new BluePrintException(3500, e.getMessage(), e);
+ }
+ }
- /**
- * This is a generateResourceAssignments rest service
- *
- * @param templateContent
- * @return List<ResourceAssignment>
- * @throws BluePrintException
- */
- @POST
- @Path("/resourceassignment/generate")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to auto map for the Resource Mapping",
- response = ResourceAssignment.class, responseContainer = "List")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- List<ResourceAssignment> generateResourceAssignments(
- @ApiParam(required = true) ConfigModelContent templateContent) throws BluePrintException;
+ @PostMapping(path = "/validate")
+ public @ResponseBody
+ ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {
+ try {
+ return serviceTemplateService.validateServiceTemplate(serviceTemplate);
+ } catch (Exception e) {
+ throw new BluePrintException(3501, e.getMessage(), e);
+ }
+ }
- /**
- * This is a autoMap rest service
- *
- * @param resourceAssignments
- * @return AutoMapResponse
- * @throws BluePrintException
- */
- @POST
- @Path("/resourceassignment/automap")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to auto map for the Resource assignments",
- response = AutoMapResponse.class)
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- AutoMapResponse autoMap(@ApiParam(required = true) List<ResourceAssignment> resourceAssignments)
- throws BluePrintException;
+ @PostMapping(path = "/resource-assignment/auto-map")
+ public @ResponseBody
+ AutoMapResponse autoMap(@RequestBody List<ResourceAssignment> resourceAssignments) throws BluePrintException {
+ try {
+ return serviceTemplateService.autoMap(resourceAssignments);
+ } catch (Exception e) {
+ throw new BluePrintException(3502, e.getMessage(), e);
+ }
+ }
- /**
- * This is a validateResourceAssignments rest service
- *
- * @param resourceAssignments
- * @return List<ResourceAssignment>
- * @throws BluePrintException
- */
- @POST
- @Path("/resourceassignment/validate")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- @ApiOperation(value = "Provides Rest service to validate Resource assignments", response = ResourceAssignment.class,
- responseContainer = "List")
- @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"),
- @ApiResponse(code = 500, message = "Unexpected Runtime error")})
- List<ResourceAssignment> validateResourceAssignments(
- @ApiParam(required = true) List<ResourceAssignment> resourceAssignments) throws BluePrintException;
+ @PostMapping(path = "/resource-assignment/validate")
+ public @ResponseBody
+ List<ResourceAssignment> validateResourceAssignments(@RequestBody List<ResourceAssignment> resourceAssignments)
+ throws BluePrintException {
+ try {
+ return serviceTemplateService.validateResourceAssignments(resourceAssignments);
+ } catch (Exception e) {
+ throw new BluePrintException(3503, e.getMessage(), e);
+ }
+ }
+
+ @PostMapping(path = "/resource-assignment/generate")
+ public @ResponseBody
+ List<ResourceAssignment> generateResourceAssignments(@RequestBody ConfigModelContent templateContent)
+ throws BluePrintException {
+ try {
+ return serviceTemplateService.generateResourceAssignments(templateContent);
+ } catch (Exception e) {
+ throw new BluePrintException(3504, e.getMessage(), e);
+ }
+ }
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java deleted file mode 100644 index 6c49d5c65..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.rs;
-
-
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
-import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
-import org.springframework.stereotype.Service;
-
-import java.util.List;
-
-/**
- * {@inheritDoc}
- */
-@Service
-public class ServiceTemplateRestImpl implements ServiceTemplateRest {
-
- private ServiceTemplateService serviceTemplateService;
-
- /**
- * This is a ServiceTemplateRestImpl constructor
- *
- * @param serviceTemplateService Service Template Service
- */
- public ServiceTemplateRestImpl(ServiceTemplateService serviceTemplateService) {
- this.serviceTemplateService = serviceTemplateService;
- }
-
- @Override
- public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
- try {
- return serviceTemplateService.enrichServiceTemplate(serviceTemplate);
- } catch (Exception e) {
- throw new BluePrintException(3500, e.getMessage(), e);
- }
- }
-
- @Override
- public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
- try {
- return serviceTemplateService.validateServiceTemplate(serviceTemplate);
- } catch (Exception e) {
- throw new BluePrintException(3501, e.getMessage(), e);
- }
- }
-
- @Override
- public AutoMapResponse autoMap(List<ResourceAssignment> resourceAssignments) throws BluePrintException {
- try {
- return serviceTemplateService.autoMap(resourceAssignments);
- } catch (Exception e) {
- throw new BluePrintException(3502, e.getMessage(), e);
- }
- }
-
- @Override
- public List<ResourceAssignment> validateResourceAssignments(List<ResourceAssignment> resourceAssignments)
- throws BluePrintException {
- try {
- return serviceTemplateService.validateResourceAssignments(resourceAssignments);
- } catch (Exception e) {
- throw new BluePrintException(3503, e.getMessage(), e);
- }
- }
-
- @Override
- public List<ResourceAssignment> generateResourceAssignments(ConfigModelContent templateContent)
- throws BluePrintException {
- try {
- return serviceTemplateService.generateResourceAssignments(templateContent);
- } catch (Exception e) {
- throw new BluePrintException(3504, e.getMessage(), e);
- }
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java deleted file mode 100644 index f5535eb12..000000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.glassfish.jersey.logging.LoggingFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.servlet.ServletProperties; -import org.onap.ccsdk.apps.controllerblueprints.service.common.ServiceExceptionMapper; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ConfigModelRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ResourceDictionaryRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ServiceTemplateRestImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - -import java.util.logging.Logger; - - -@Component -public class JerseyConfiguration extends ResourceConfig { - private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName()); - - @Bean - @Primary - public ObjectMapper objectMapper() { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); - objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); - objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); - return objectMapper; - } - - @Autowired - public JerseyConfiguration() { - register(ConfigModelRestImpl.class); - register(ModelTypeRestImpl.class); - register(ResourceDictionaryRestImpl.class); - register(ServiceTemplateRestImpl.class); - // Exception Mapping - register(ServiceExceptionMapper.class); - property(ServletProperties.FILTER_FORWARD_ON_404, true); - register(new LoggingFeature(log)); - } - - -}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java deleted file mode 100644 index ea259c9c9..000000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java +++ /dev/null @@ -1,36 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * 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.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints;
-
-import org.springframework.context.annotation.Bean;
-
-import java.util.ArrayList;
-
-//@Configuration
-public class TestConfiguration {
-
- @Bean("jaxrsProviders")
- public ArrayList<Object> provider() {
- return new ArrayList<Object>();
- }
-
- @Bean("jaxrsServices")
- public ArrayList<Object> service() {
- return new ArrayList<Object>();
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java index 5b10a7e86..a4a787b08 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java @@ -20,7 +20,6 @@ import org.junit.*; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
-import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
import org.slf4j.Logger;
@@ -35,7 +34,7 @@ import java.util.List; @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class})
+@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ConfigModelRestTest {
@@ -68,7 +67,6 @@ public class ConfigModelRestTest { ConfigModel configModel = configModelRest.getInitialConfigModel(name);
Assert.assertNotNull("Failed to get Initial Config Model , Return object is Null", configModel);
Assert.assertNotNull("Failed to get Service Template Content ", configModel.getConfigModelContents());
-
}
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java index d33349c53..d328b3eac 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java @@ -21,7 +21,6 @@ import org.junit.*; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
-import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
import org.slf4j.Logger;
@@ -38,7 +37,7 @@ import java.util.List; @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class})
+@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ModelTypeRestTest {
private static Logger log = LoggerFactory.getLogger(ModelTypeRestTest.class);
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java index 71dff338b..afe9b426f 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
-import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration;
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,7 +40,7 @@ import java.util.List; @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class})
+@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ResourceDictionaryRestTest {
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java index f81dd4165..fdc68e4e5 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
-import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration;
import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
@@ -46,7 +45,7 @@ import java.util.List; @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class})
+@ContextConfiguration(classes = {TestApplication.class})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ServiceTemplateRestTest {
|