diff options
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services')
33 files changed, 1007 insertions, 1327 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java index 7caa639bac..7225a36f55 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java @@ -7,9 +7,9 @@ * 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. @@ -17,102 +17,83 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; -import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +import org.springframework.validation.annotation.Validated; -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - -@Path( - "/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/entitlement-pools/{entitlementPoolId}/limits") +@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/entitlement-pools/{entitlementPoolId}/limits") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - Entitlement Pool Limits")}) @Validated public interface EntitlementPoolLimits { - @POST - @Path("/") - @Operation(description = "Create vendor entitlement pool limits") - Response createLimit(@Valid LimitRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") - String versionId, - @Parameter(description = "Vendor license model Entitlement Pool Id") - @PathParam("entitlementPoolId") - String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - - @GET - @Path("/") - @Operation(description = "List vendor entitlement pool limits", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = LimitRequestDto.class))))) - Response listLimits( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") - String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create vendor entitlement pool limits") + Response createLimit(@Valid LimitRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{limitId}") - @Operation(description = "Update vendor entitlement pool limit") - Response updateLimit(@Valid LimitRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") - String versionId, - @Parameter(description = "Vendor license model Entitlement Pool Id") - @PathParam("entitlementPoolId") - String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @PathParam("limitId") String limitId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor entitlement pool limits", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = LimitRequestDto.class))))) + Response listLimits(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{limitId}") - @Operation(description = "Get vendor entitlement pool limit", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LimitEntityDto.class)))) - Response getLimit( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam - ("entitlementPoolId") String entitlementPoolId, - @Parameter(description = "Vendor license model Entitlement Pool Limit Id") @PathParam("limitId") - String limitId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{limitId}") + @Operation(description = "Update vendor entitlement pool limit") + Response updateLimit(@Valid LimitRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @PathParam("limitId") String limitId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{limitId}") - @Operation(description = "Delete vendor entitlement pool limit") - Response deleteLimit( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model Entitlement pool Id") @PathParam("entitlementPoolId") - String entitlementPoolId, - @PathParam("limitId") String limitId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{limitId}") + @Operation(description = "Get vendor entitlement pool limit", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LimitEntityDto.class)))) + Response getLimit(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @Parameter(description = "Vendor license model Entitlement Pool Limit Id") @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{limitId}") + @Operation(description = "Delete vendor entitlement pool limit") + Response deleteLimit(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java index 89b632f2e5..b2d320023e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java @@ -17,30 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; -import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/entitlement-pools") @Produces(MediaType.APPLICATION_JSON) @@ -48,52 +53,44 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - Entitlement Pools")}) @Validated public interface EntitlementPools { + @GET @Path("/") - @Operation(description = "List vendor entitlement pools", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = EntitlementPoolEntityDto.class))))) - Response listEntitlementPools( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @Operation(description = "List vendor entitlement pools", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = EntitlementPoolEntityDto.class))))) + Response listEntitlementPools(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @Operation(description = "Create vendor entitlement pool") Response createEntitlementPool(@Valid EntitlementPoolRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam ("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{entitlementPoolId}") @Operation(description = "Update vendor entitlement pool") Response updateEntitlementPool(@Valid EntitlementPoolRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @PathParam("entitlementPoolId") String entitlementPoolId, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @PathParam("entitlementPoolId") String entitlementPoolId, @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @Path("/{entitlementPoolId}") @Operation(description = "Get vendor entitlement pool", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = EntitlementPoolEntityDto.class)))) - Response getEntitlementPool( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("entitlementPoolId") String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + Response getEntitlementPool(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{entitlementPoolId}") @Operation(description = "Delete vendor entitlement pool") - Response deleteEntitlementPool( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("entitlementPoolId") String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - + Response deleteEntitlementPool(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java index 80403f59e1..efb6479b0f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java @@ -7,9 +7,9 @@ * 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. @@ -17,34 +17,38 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupEntityDto; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupModelDto; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupRequestDto; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupUpdateRequestDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - - @Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/feature-groups") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -52,51 +56,43 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface FeatureGroups { - @GET - @Path("/") - @Operation(description = "List vendor feature groups",responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =FeatureGroupEntityDto.class))))) - Response listFeatureGroups( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @POST - @Path("/") - @Operation(description = "Create vendor feature group") - Response createFeatureGroup(@Valid FeatureGroupRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor feature groups", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = FeatureGroupEntityDto.class))))) + Response listFeatureGroups(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{featureGroupId}") - @Operation(description = "Update vendor feature group") - Response updateFeatureGroup(@Valid FeatureGroupUpdateRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("featureGroupId") String featureGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create vendor feature group") + Response createFeatureGroup(@Valid FeatureGroupRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{featureGroupId}") - @Operation(description = "Get vendor feature group", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =FeatureGroupModelDto.class)))) - Response getFeatureGroup( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("featureGroupId") String featureGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{featureGroupId}") + @Operation(description = "Update vendor feature group") + Response updateFeatureGroup(@Valid FeatureGroupUpdateRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("featureGroupId") String featureGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{featureGroupId}") - @Operation(description = "Delete vendor feature group") - Response deleteFeatureGroup( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("featureGroupId") String featureGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{featureGroupId}") + @Operation(description = "Get vendor feature group", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = FeatureGroupModelDto.class)))) + Response getFeatureGroup(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("featureGroupId") String featureGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{featureGroupId}") + @Operation(description = "Delete vendor feature group") + Response deleteFeatureGroup(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("featureGroupId") String featureGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java index 0d384ed7bb..d74ddaa8fe 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java @@ -7,9 +7,9 @@ * 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. @@ -17,89 +17,82 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementEntityDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementModelDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementRequestDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementUpdateRequestDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - - @Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-agreements") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - License Agreements")}) @Validated - public interface LicenseAgreements { - @GET - @Path("/") - @Operation(description = "List vendor license agreements", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =LicenseAgreementEntityDto.class))))) - Response listLicenseAgreements( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @POST - @Path("/") - @Operation(description = "Create vendor license agreement") - Response createLicenseAgreement(@Valid LicenseAgreementRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor license agreements", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = LicenseAgreementEntityDto.class))))) + Response listLicenseAgreements(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{licenseAgreementId}") - @Operation(description = "Update vendor license agreement") - Response updateLicenseAgreement(@Valid LicenseAgreementUpdateRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @PathParam("licenseAgreementId") String licenseAgreementId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create vendor license agreement") + Response createLicenseAgreement(@Valid LicenseAgreementRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{licenseAgreementId}") - @Operation(description = "Get vendor license agreement", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LicenseAgreementModelDto.class)))) - Response getLicenseAgreement( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("licenseAgreementId") String licenseAgreementId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{licenseAgreementId}") + @Operation(description = "Update vendor license agreement") + Response updateLicenseAgreement(@Valid LicenseAgreementUpdateRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseAgreementId") String licenseAgreementId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{licenseAgreementId}") - @Operation(description = "Delete vendor license agreement") - Response deleteLicenseAgreement( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("licenseAgreementId") String licenseAgreementId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{licenseAgreementId}") + @Operation(description = "Get vendor license agreement", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LicenseAgreementModelDto.class)))) + Response getLicenseAgreement(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseAgreementId") String licenseAgreementId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{licenseAgreementId}") + @Operation(description = "Delete vendor license agreement") + Response deleteLicenseAgreement(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseAgreementId") String licenseAgreementId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java index afa9663b10..898f084d5f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java @@ -7,9 +7,9 @@ * 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. @@ -17,100 +17,83 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; -import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +import org.springframework.validation.annotation.Validated; -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - -@Path( - "/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups/{licenseKeyGroupId}/limits") +@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups/{licenseKeyGroupId}/limits") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - License Key Group Limits")}) @Validated public interface LicenseKeyGroupLimits { - @POST - @Path("/") - @Operation(description = "Create vendor license key group limit") - Response createLimit(@Valid LimitRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") - String versionId, - @Parameter(description = "Vendor license model License Key Group Id") - @PathParam("licenseKeyGroupId") - String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create vendor license key group limit") + Response createLimit(@Valid LimitRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/") - @Operation(description = "List vendor license key group limits", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = LimitEntityDto.class))))) - Response listLimits( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId") - String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor license key group limits", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = LimitEntityDto.class))))) + Response listLimits(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{limitId}") - @Operation(description = "Update vendor license key group limit") - Response updateLimit(@Valid LimitRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") - String versionId, - @Parameter(description = "Vendor license model License Key Group Id") - @PathParam("licenseKeyGroupId") - String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @PathParam("limitId") String limitId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{limitId}") + @Operation(description = "Update vendor license key group limit") + Response updateLimit(@Valid LimitRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @PathParam("limitId") String limitId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{limitId}") - @Operation(description = "Get vendor entitlement pool limit", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LimitEntityDto.class)))) - Response getLimit( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model License Key Group") @PathParam - ("licenseKeyGroupId") String entitlementPoolId, - @Parameter(description = "Vendor license model License Key Group Limit Id") @PathParam("limitId") - String limitId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{limitId}") + @Operation(description = "Get vendor entitlement pool limit", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LimitEntityDto.class)))) + Response getLimit(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model License Key Group") @PathParam("licenseKeyGroupId") String entitlementPoolId, + @Parameter(description = "Vendor license model License Key Group Limit Id") @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{limitId}") - @Operation(description = "Delete vendor license key group limit") - Response deleteLimit( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model license key group Id") @PathParam("licenseKeyGroupId") - String licenseKeyGroupId, - @PathParam("limitId") String limitId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{limitId}") + @Operation(description = "Delete vendor license key group limit") + Response deleteLimit(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model license key group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java index 50dc3c82a1..2bb565b124 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java @@ -7,9 +7,9 @@ * 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. @@ -17,31 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; -import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups") @Produces(MediaType.APPLICATION_JSON) @@ -49,52 +53,44 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - License Key Groups")}) @Validated public interface LicenseKeyGroups { - @GET - @Path("/") - @Operation(description = "List vendor license key groups", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =LicenseKeyGroupEntityDto.class))))) - Response listLicenseKeyGroups( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create vendor license key group") - Response createLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor license key groups", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = LicenseKeyGroupEntityDto.class))))) + Response listLicenseKeyGroups(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @POST + @Path("/") + @Operation(description = "Create vendor license key group") + Response createLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{licenseKeyGroupId}") - @Operation(description = "Update vendor license key group") - Response updateLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @PathParam("licenseKeyGroupId") String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{licenseKeyGroupId}") + @Operation(description = "Update vendor license key group") + Response updateLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{licenseKeyGroupId}") - @Operation(description = "Get vendor license key group",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LicenseKeyGroupEntityDto.class)))) - Response getLicenseKeyGroup( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("licenseKeyGroupId") String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{licenseKeyGroupId}") + @Operation(description = "Get vendor license key group", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LicenseKeyGroupEntityDto.class)))) + Response getLicenseKeyGroup(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{licenseKeyGroupId}") - @Operation(description = "Delete vendor license key group") - Response deleteLicenseKeyGroup( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("licenseKeyGroupId") String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{licenseKeyGroupId}") + @Operation(description = "Delete vendor license key group") + Response deleteLicenseKeyGroup(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java index 3778129f7f..0636b6e599 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java @@ -13,19 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +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; import org.openecomp.sdcrests.common.RestConstants; import org.openecomp.sdcrests.item.types.ItemDto; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto; @@ -33,15 +46,6 @@ import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - - @Path("/v1.0/vendor-license-models") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -49,64 +53,48 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface VendorLicenseModels { - @GET - @Path("/") - @Operation(description = "List vendor license models", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation=ItemDto.class))))) - Response listLicenseModels(@Parameter(description = "Filter to return only Vendor License Models with at" + - " least one version at this status. Currently supported values: 'Certified' , 'Draft'") - @QueryParam("versionFilter") String versionStatus, - @Parameter(description = "Filter to only return Vendor License Models at this status." + - "Currently supported values: 'ACTIVE' , 'ARCHIVED'." + - "Default value = 'ACTIVE'.") - @QueryParam("Status") String itemStatus, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - - @POST - @Path("/") - @Operation(description = "Create vendor license model") - Response createLicenseModel(@Valid VendorLicenseModelRequestDto request, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor license models", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ItemDto.class))))) + Response listLicenseModels(@Parameter(description = "Filter to return only Vendor License Models with at" + + " least one version at this status. Currently supported values: 'Certified' , 'Draft'") @QueryParam("versionFilter") String versionStatus, + @Parameter(description = "Filter to only return Vendor License Models at this status." + + "Currently supported values: 'ACTIVE' , 'ARCHIVED'." + + "Default value = 'ACTIVE'.") @QueryParam("Status") String itemStatus, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{vlmId}") - @Operation(description = "Delete vendor license model") - Response deleteLicenseModel( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create vendor license model") + Response createLicenseModel(@Valid VendorLicenseModelRequestDto request, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{vlmId}/versions/{versionId}") - @Operation(description = "Update vendor license model") - Response updateLicenseModel(@Valid VendorLicenseModelRequestDto request, - @Parameter(description = "Vendor license model Id") - @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{vlmId}") + @Operation(description = "Delete vendor license model") + Response deleteLicenseModel(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{vlmId}/versions/{versionId}") - @Operation(description = "Get vendor license model", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=VendorLicenseModelEntityDto.class)))) - Response getLicenseModel( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{vlmId}/versions/{versionId}") + @Operation(description = "Update vendor license model") + Response updateLicenseModel(@Valid VendorLicenseModelRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{vlmId}/versions/{versionId}") + @Operation(description = "Get vendor license model", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = VendorLicenseModelEntityDto.class)))) + Response getLicenseModel(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{vlmId}/versions/{versionId}/actions") - @Operation(description = "Update vendor license model") - Response actOnLicenseModel(@Valid VendorLicenseModelActionRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{vlmId}/versions/{versionId}/actions") + @Operation(description = "Update vendor license model") + Response actOnLicenseModel(@Valid VendorLicenseModelActionRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java index 35833e9621..05d2d1ac77 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java @@ -7,9 +7,9 @@ * 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. @@ -17,17 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; public class LimitCreationDto { - private String limitId; - public String getLimitId() { - return limitId; - } + private String limitId; + + public String getLimitId() { + return limitId; + } - public void setLimitId(String limitId) { - this.limitId = limitId; - } + public void setLimitId(String limitId) { + this.limitId = limitId; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java index 28eeb29018..f4b6119056 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java @@ -7,9 +7,9 @@ * 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. @@ -17,20 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; -public class MapChoiceOrOtherDtoToChoiceOrOther - extends MappingBase<ChoiceOrOtherDto, ChoiceOrOther> { +public class MapChoiceOrOtherDtoToChoiceOrOther extends MappingBase<ChoiceOrOtherDto, ChoiceOrOther> { - @Override - public void doMapping(ChoiceOrOtherDto source, ChoiceOrOther target) { - target.setChoice(source.getChoice()); - target.setOther(source.getOther()); - target.setResult(null); - } + @Override + public void doMapping(ChoiceOrOtherDto source, ChoiceOrOther target) { + target.setChoice(source.getChoice()); + target.setOther(source.getOther()); + target.setResult(null); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java index 2d686110d5..aad72491ac 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java @@ -7,9 +7,9 @@ * 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. @@ -17,19 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; -public class MapChoiceOrOtherToChoiceOrOtherDto - extends MappingBase<ChoiceOrOther, ChoiceOrOtherDto> { +public class MapChoiceOrOtherToChoiceOrOtherDto extends MappingBase<ChoiceOrOther, ChoiceOrOtherDto> { - @Override - public void doMapping(ChoiceOrOther source, ChoiceOrOtherDto target) { - target.setChoice(source.getChoice()); - target.setOther(source.getOther()); - } + @Override + public void doMapping(ChoiceOrOther source, ChoiceOrOtherDto target) { + target.setChoice(source.getChoice()); + target.setOther(source.getOther()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java index 2510bd0634..6dc6e6af92 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; @@ -25,26 +24,23 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; -public class MapEntitlementPoolEntityToEntitlementPoolEntityDto - extends MappingBase<EntitlementPoolEntity, EntitlementPoolEntityDto> { - @Override - public void doMapping(EntitlementPoolEntity source, EntitlementPoolEntityDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setThresholdValue(source.getThresholdValue()); - target.setThresholdUnits(source.getThresholdUnit()); - target.setIncrements(source.getIncrements()); - - target.setOperationalScope(new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto() - .applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); - - target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); +public class MapEntitlementPoolEntityToEntitlementPoolEntityDto extends MappingBase<EntitlementPoolEntity, EntitlementPoolEntityDto> { - target.setStartDate(source.getStartDate()); - target.setExpiryDate(source.getExpiryDate()); - target.setVersionUUID(source.getVersionUuId()); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } + @Override + public void doMapping(EntitlementPoolEntity source, EntitlementPoolEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setThresholdValue(source.getThresholdValue()); + target.setThresholdUnits(source.getThresholdUnit()); + target.setIncrements(source.getIncrements()); + target.setOperationalScope( + new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto().applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); + target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); + target.setVersionUUID(source.getVersionUuId()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java index 5c45ed652a..1058a869aa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; @@ -25,21 +24,20 @@ import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; -public class MapEntitlementPoolRequestDtoToEntitlementPoolEntity - extends MappingBase<EntitlementPoolRequestDto, EntitlementPoolEntity> { - @Override - public void doMapping(EntitlementPoolRequestDto source, EntitlementPoolEntity target) { - target.setName(source.getName()); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setThresholdValue(source.getThresholdValue()); - target.setThresholdUnit(source.getThresholdUnits()); - target.setIncrements(source.getIncrements()); - target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther() - .applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); +public class MapEntitlementPoolRequestDtoToEntitlementPoolEntity extends MappingBase<EntitlementPoolRequestDto, EntitlementPoolEntity> { - target.setStartDate(source.getStartDate()); - target.setExpiryDate(source.getExpiryDate()); - } + @Override + public void doMapping(EntitlementPoolRequestDto source, EntitlementPoolEntity target) { + target.setName(source.getName()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setThresholdValue(source.getThresholdValue()); + target.setThresholdUnit(source.getThresholdUnits()); + target.setIncrements(source.getIncrements()); + target.setOperationalScope( + new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther().applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java index 5dbf087e45..e362c92196 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; -public class MapFeatureGroupDescriptorDtoToFeatureGroupEntity - extends MappingBase<FeatureGroupDescriptorDto, FeatureGroupEntity> { - @Override - public void doMapping(FeatureGroupDescriptorDto source, FeatureGroupEntity target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setPartNumber(source.getPartNumber()); - } -}
\ No newline at end of file +public class MapFeatureGroupDescriptorDtoToFeatureGroupEntity extends MappingBase<FeatureGroupDescriptorDto, FeatureGroupEntity> { + + @Override + public void doMapping(FeatureGroupDescriptorDto source, FeatureGroupEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setPartNumber(source.getPartNumber()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java index 70f5666bcb..ee8626abaa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java @@ -7,9 +7,9 @@ * 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. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; -public class MapFeatureGroupEntityToFeatureGroupDescriptorDto - extends MappingBase<FeatureGroupEntity, FeatureGroupDescriptorDto> { - @Override - public void doMapping(FeatureGroupEntity source, FeatureGroupDescriptorDto target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setPartNumber(source.getPartNumber()); - } +public class MapFeatureGroupEntityToFeatureGroupDescriptorDto extends MappingBase<FeatureGroupEntity, FeatureGroupDescriptorDto> { + + @Override + public void doMapping(FeatureGroupEntity source, FeatureGroupDescriptorDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setPartNumber(source.getPartNumber()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java index f5ea8414d5..98d703299b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; @@ -25,14 +24,13 @@ import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto; -public class MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity - extends MappingBase<LicenseAgreementDescriptorDto, LicenseAgreementEntity> { - @Override - public void doMapping(LicenseAgreementDescriptorDto source, LicenseAgreementEntity target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setLicenseTerm(new MapChoiceOrOtherDtoToChoiceOrOther() - .applyMapping(source.getLicenseTerm(), ChoiceOrOther.class)); - target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); - } +public class MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity extends MappingBase<LicenseAgreementDescriptorDto, LicenseAgreementEntity> { + + @Override + public void doMapping(LicenseAgreementDescriptorDto source, LicenseAgreementEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setLicenseTerm(new MapChoiceOrOtherDtoToChoiceOrOther().applyMapping(source.getLicenseTerm(), ChoiceOrOther.class)); + target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java index 2fd4f669cf..46de11f021 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; @@ -25,14 +24,13 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto; -public class MapLicenseAgreementEntityToLicenseAgreementDescriptorDto - extends MappingBase<LicenseAgreementEntity, LicenseAgreementDescriptorDto> { - @Override - public void doMapping(LicenseAgreementEntity source, LicenseAgreementDescriptorDto target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setLicenseTerm(new MapChoiceOrOtherToChoiceOrOtherDto() - .applyMapping(source.getLicenseTerm(), ChoiceOrOtherDto.class)); - target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); - } +public class MapLicenseAgreementEntityToLicenseAgreementDescriptorDto extends MappingBase<LicenseAgreementEntity, LicenseAgreementDescriptorDto> { + + @Override + public void doMapping(LicenseAgreementEntity source, LicenseAgreementDescriptorDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setLicenseTerm(new MapChoiceOrOtherToChoiceOrOtherDto().applyMapping(source.getLicenseTerm(), ChoiceOrOtherDto.class)); + target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java index c543cf402e..3690a7c5d3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; @@ -25,23 +24,23 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; -public class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto - extends MappingBase<LicenseKeyGroupEntity, LicenseKeyGroupEntityDto> { - @Override - public void doMapping(LicenseKeyGroupEntity source, LicenseKeyGroupEntityDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setOperationalScope(new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto() - .applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); - target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); - target.setStartDate(source.getStartDate()); - target.setExpiryDate(source.getExpiryDate()); - target.setThresholdUnits(source.getThresholdUnits()); - target.setThresholdValue(source.getThresholdValue()); - target.setIncrements(source.getIncrements()); - target.setVersionUUID(source.getVersionUuId()); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } +public class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto extends MappingBase<LicenseKeyGroupEntity, LicenseKeyGroupEntityDto> { + + @Override + public void doMapping(LicenseKeyGroupEntity source, LicenseKeyGroupEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setOperationalScope( + new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto().applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); + target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); + target.setThresholdUnits(source.getThresholdUnits()); + target.setThresholdValue(source.getThresholdValue()); + target.setIncrements(source.getIncrements()); + target.setVersionUUID(source.getVersionUuId()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java index 87eea4ba1e..ed0e79d0a5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; @@ -25,20 +24,20 @@ import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; -public class MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity - extends MappingBase<LicenseKeyGroupRequestDto, LicenseKeyGroupEntity> { - @Override - public void doMapping(LicenseKeyGroupRequestDto source, LicenseKeyGroupEntity target) { - target.setName(source.getName()); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther() - .applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); - target.setStartDate(source.getStartDate()); - target.setExpiryDate(source.getExpiryDate()); - target.setThresholdUnits(source.getThresholdUnits()); - target.setThresholdValue(source.getThresholdValue()); - target.setIncrements(source.getIncrements()); - } +public class MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity extends MappingBase<LicenseKeyGroupRequestDto, LicenseKeyGroupEntity> { + + @Override + public void doMapping(LicenseKeyGroupRequestDto source, LicenseKeyGroupEntity target) { + target.setName(source.getName()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setOperationalScope( + new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther().applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); + target.setThresholdUnits(source.getThresholdUnits()); + target.setThresholdValue(source.getThresholdValue()); + target.setIncrements(source.getIncrements()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java index ef4ae1ccdc..eb1a8a2def 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java @@ -7,9 +7,9 @@ * 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. @@ -17,16 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; import org.openecomp.sdcrests.mapping.MappingBase; -public class MapLimitEntityToLimitCreationDto extends - MappingBase<LimitEntity, LimitCreationDto> { - @Override - public void doMapping(LimitEntity source, LimitCreationDto target) { - target.setLimitId(source.getId()); - } +public class MapLimitEntityToLimitCreationDto extends MappingBase<LimitEntity, LimitCreationDto> { + + @Override + public void doMapping(LimitEntity source, LimitCreationDto target) { + target.setLimitId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java index b17a0e08d4..030fcc1c91 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; @@ -26,17 +25,16 @@ import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; public class MapLimitEntityToLimitDto extends MappingBase<LimitEntity, LimitEntityDto> { - @Override - public void doMapping(LimitEntity source, LimitEntityDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setMetric(source.getMetric()); - target.setAggregationFunction(source.getAggregationFunction() != null ? source - .getAggregationFunction().name() : null); - target.setTime(source.getTime()); - target.setType(source.getType() != null ? source.getType().name() : null); - target.setUnit(source.getUnit()); - target.setValue(source.getValue()); - } + @Override + public void doMapping(LimitEntity source, LimitEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setMetric(source.getMetric()); + target.setAggregationFunction(source.getAggregationFunction() != null ? source.getAggregationFunction().name() : null); + target.setTime(source.getTime()); + target.setType(source.getType() != null ? source.getType().name() : null); + target.setUnit(source.getUnit()); + target.setValue(source.getValue()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java index 99f45bfc18..2de29c6e0c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.common.errors.CoreException; @@ -32,11 +31,9 @@ import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; - public class MapLimitRequestDtoToLimitEntity extends MappingBase<LimitRequestDto, LimitEntity> { - private static final Logger logger = - LoggerFactory.getLogger(MapLimitRequestDtoToLimitEntity.class); + private static final Logger logger = LoggerFactory.getLogger(MapLimitRequestDtoToLimitEntity.class); @Override public void doMapping(LimitRequestDto source, LimitEntity target) { @@ -49,27 +46,22 @@ public class MapLimitRequestDtoToLimitEntity extends MappingBase<LimitRequestDto logger.error(exception.getMessage(), exception); throwInvalidValueError("type", VendorLicenseErrorCodes.LIMIT_INVALID_TYPE); } - try { - AggregationFunction function = source.getAggregationFunction() != null ? - AggregationFunction.valueOf(source.getAggregationFunction()) : null; + AggregationFunction function = + source.getAggregationFunction() != null ? AggregationFunction.valueOf(source.getAggregationFunction()) : null; target.setAggregationFunction(function); } catch (IllegalArgumentException exception) { logger.error(exception.getMessage(), exception); - throwInvalidValueError("aggregationFunction", - VendorLicenseErrorCodes.LIMIT_INVALID_AGGREGATIONFUNCTION); + throwInvalidValueError("aggregationFunction", VendorLicenseErrorCodes.LIMIT_INVALID_AGGREGATIONFUNCTION); } - target.setTime(source.getTime()); target.setMetric(source.getMetric()); target.setValue(source.getValue()); target.setUnit(source.getUnit()); - } private void throwInvalidValueError(String attribute, String vendorLicenseErrorCode) { - ErrorCode errorCode = LimitErrorBuilder.getInvalidValueErrorBuilder(attribute, - vendorLicenseErrorCode); + ErrorCode errorCode = LimitErrorBuilder.getInvalidValueErrorBuilder(attribute, vendorLicenseErrorCode); throw new CoreException(errorCode); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java index 320bf67bdf..ad0aab26d1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java @@ -7,9 +7,9 @@ * 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. @@ -17,20 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; -public class MapMultiChoiceOrOtherDtoToMultiChoiceOrOther - extends MappingBase<MultiChoiceOrOtherDto, MultiChoiceOrOther> { +public class MapMultiChoiceOrOtherDtoToMultiChoiceOrOther extends MappingBase<MultiChoiceOrOtherDto, MultiChoiceOrOther> { - @Override - public void doMapping(MultiChoiceOrOtherDto source, MultiChoiceOrOther target) { - target.setChoices(source.getChoices()); - target.setOther(source.getOther()); - target.setResults(null); - } + @Override + public void doMapping(MultiChoiceOrOtherDto source, MultiChoiceOrOther target) { + target.setChoices(source.getChoices()); + target.setOther(source.getOther()); + target.setResults(null); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java index 9649053fb4..93a2007897 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java @@ -7,9 +7,9 @@ * 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. @@ -17,19 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; -public class MapMultiChoiceOrOtherToMultiChoiceOrOtherDto - extends MappingBase<MultiChoiceOrOther, MultiChoiceOrOtherDto> { +public class MapMultiChoiceOrOtherToMultiChoiceOrOtherDto extends MappingBase<MultiChoiceOrOther, MultiChoiceOrOtherDto> { - @Override - public void doMapping(MultiChoiceOrOther source, MultiChoiceOrOtherDto target) { - target.setChoices(source.getChoices()); - target.setOther(source.getOther()); - } + @Override + public void doMapping(MultiChoiceOrOther source, MultiChoiceOrOtherDto target) { + target.setChoices(source.getChoices()); + target.setOther(source.getOther()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java index 7bdde1d592..5b0bfb7d73 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java @@ -17,20 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; -public class MapVendorLicenseModelEntityToDto - extends MappingBase<VendorLicenseModelEntity, VendorLicenseModelEntityDto> { - @Override - public void doMapping(VendorLicenseModelEntity source, VendorLicenseModelEntityDto target) { - target.setId(source.getId()); - target.setVendorName(source.getVendorName()); - target.setDescription(source.getDescription()); - target.setIconRef(source.getIconRef()); - } +public class MapVendorLicenseModelEntityToDto extends MappingBase<VendorLicenseModelEntity, VendorLicenseModelEntityDto> { + + @Override + public void doMapping(VendorLicenseModelEntity source, VendorLicenseModelEntityDto target) { + target.setId(source.getId()); + target.setVendorName(source.getVendorName()); + target.setDescription(source.getDescription()); + target.setIconRef(source.getIconRef()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java index 593a4a37b0..2cbc81980a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto; -public class MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity - extends MappingBase<VendorLicenseModelRequestDto, VendorLicenseModelEntity> { - @Override - public void doMapping(VendorLicenseModelRequestDto source, VendorLicenseModelEntity target) { - target.setVendorName(source.getVendorName()); - target.setDescription(source.getDescription()); - target.setIconRef(source.getIconRef()); - } +public class MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity extends MappingBase<VendorLicenseModelRequestDto, VendorLicenseModelEntity> { + + @Override + public void doMapping(VendorLicenseModelRequestDto source, VendorLicenseModelEntity target) { + target.setVendorName(source.getVendorName()); + target.setDescription(source.getDescription()); + target.setIconRef(source.getIconRef()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java index 544c1d7331..38e0a78154 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; - +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; @@ -37,126 +38,89 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("entitlementPoolLimits") @Scope(value = "prototype") public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); - - private static final String PARENT = "EntitlementPool"; - - @Override - public Response createLimit(LimitRequestDto request, - String vlmId, - String versionId, - String entitlementPoolId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); - - LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); - limitEntity.setVendorLicenseModelId(vlmId); - limitEntity.setVersion(version); - limitEntity.setEpLkgId(entitlementPoolId); - limitEntity.setParent(PARENT); - LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity); - MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); - LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class); - - return Response.ok(createdLimitDto != null ? createdLimitDto : null).build(); - } - - @Override - public Response listLimits(String vlmId, String versionId, String entitlementPoolId, String - user) { - Version version = new Version(versionId); - vendorLicenseManager - .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); - - Collection<LimitEntity> limits = - vendorLicenseManager.listLimits(vlmId, version, entitlementPoolId); - - GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); - MapLimitEntityToLimitDto outputMapper = - new MapLimitEntityToLimitDto(); - for (LimitEntity limit : limits) { - result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + private static final String PARENT = "EntitlementPool"; + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); + + @Override + public Response createLimit(LimitRequestDto request, String vlmId, String versionId, String entitlementPoolId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + LimitEntity limitEntity = new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setVersion(version); + limitEntity.setEpLkgId(entitlementPoolId); + limitEntity.setParent(PARENT); + LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity); + MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); + LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class); + return Response.ok(createdLimitDto != null ? createdLimitDto : null).build(); } - return Response.ok(result).build(); - } - - @Override - public Response getLimit(String vlmId, String versionId, String entitlementPoolId, - String limitId, String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); - LimitEntity limitInput = new LimitEntity(); - limitInput.setVendorLicenseModelId(vlmId); - limitInput.setVersion(version); - limitInput.setEpLkgId(entitlementPoolId); - limitInput.setId(limitId); - LimitEntity limit = vendorLicenseManager.getLimit(limitInput); - - LimitEntityDto entitlementPoolEntityDto = limit == null ? null : - new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class); - return Response.ok(entitlementPoolEntityDto).build(); - } - @Override - public Response updateLimit(LimitRequestDto request, - String vlmId, - String versionId, - String entitlementPoolId, - String limitId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); - - LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); - limitEntity.setVendorLicenseModelId(vlmId); - limitEntity.setVersion(version); - limitEntity.setEpLkgId(entitlementPoolId); - limitEntity.setId(limitId); - limitEntity.setParent(PARENT); - - vendorLicenseManager.updateLimit(limitEntity); - return Response.ok().build(); - } + @Override + public Response listLimits(String vlmId, String versionId, String entitlementPoolId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + Collection<LimitEntity> limits = vendorLicenseManager.listLimits(vlmId, version, entitlementPoolId); + GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); + MapLimitEntityToLimitDto outputMapper = new MapLimitEntityToLimitDto(); + for (LimitEntity limit : limits) { + result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + } + return Response.ok(result).build(); + } - /** - * Delete entitlement pool. - * - * @param vlmId the vlm id - * @param entitlementPoolId the entitlement pool id - * @param limitId the limitId - * @param user the user - * @return the response - */ - public Response deleteLimit(String vlmId, String versionId, String entitlementPoolId, - String limitId, String user) { - Version version = new Version(versionId); - vendorLicenseManager.getEntitlementPool( - new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + @Override + public Response getLimit(String vlmId, String versionId, String entitlementPoolId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setVersion(version); + limitInput.setEpLkgId(entitlementPoolId); + limitInput.setId(limitId); + LimitEntity limit = vendorLicenseManager.getLimit(limitInput); + LimitEntityDto entitlementPoolEntityDto = limit == null ? null : new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class); + return Response.ok(entitlementPoolEntityDto).build(); + } - LimitEntity limitInput = new LimitEntity(); - limitInput.setVendorLicenseModelId(vlmId); - limitInput.setVersion(version); - limitInput.setEpLkgId(entitlementPoolId); - limitInput.setId(limitId); - limitInput.setParent(PARENT); + @Override + public Response updateLimit(LimitRequestDto request, String vlmId, String versionId, String entitlementPoolId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + LimitEntity limitEntity = new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setVersion(version); + limitEntity.setEpLkgId(entitlementPoolId); + limitEntity.setId(limitId); + limitEntity.setParent(PARENT); + vendorLicenseManager.updateLimit(limitEntity); + return Response.ok().build(); + } - vendorLicenseManager.deleteLimit(limitInput); - return Response.ok().build(); - } + /** + * Delete entitlement pool. + * + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param limitId the limitId + * @param user the user + * @return the response + */ + public Response deleteLimit(String vlmId, String versionId, String entitlementPoolId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setVersion(version); + limitInput.setEpLkgId(entitlementPoolId); + limitInput.setId(limitId); + limitInput.setParent(PARENT); + vendorLicenseManager.deleteLimit(limitInput); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java index 83519198b7..bff8c7a449 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; import java.util.Comparator; @@ -42,115 +41,97 @@ import org.springframework.stereotype.Service; @Service("entitlementPools") @Scope(value = "prototype") public class EntitlementPoolsImpl implements EntitlementPools { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); - - /** - * List entitlement pools response. - * - * @param vlmId the vlm id - * @param versionId the version - * @param user the user - * @return the response - */ - public Response listEntitlementPools(String vlmId, String versionId, String user) { - MapEntitlementPoolEntityToEntitlementPoolEntityDto outputMapper = - new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); + /** + * List entitlement pools response. + * + * @param vlmId the vlm id + * @param versionId the version + * @param user the user + * @return the response + */ + public Response listEntitlementPools(String vlmId, String versionId, String user) { + MapEntitlementPoolEntityToEntitlementPoolEntityDto outputMapper = new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); GenericCollectionWrapper<EntitlementPoolEntityDto> result = new GenericCollectionWrapper<>( - vendorLicenseManager.listEntitlementPools(vlmId, new Version(versionId)).stream() - .sorted(Comparator.comparing(EntitlementPoolEntity::getName)) - .map(item -> outputMapper.applyMapping(item, EntitlementPoolEntityDto.class)) - .collect(Collectors.toList())); - + vendorLicenseManager.listEntitlementPools(vlmId, new Version(versionId)).stream() + .sorted(Comparator.comparing(EntitlementPoolEntity::getName)) + .map(item -> outputMapper.applyMapping(item, EntitlementPoolEntityDto.class)).collect(Collectors.toList())); return Response.ok(result).build(); } - /** - * Create entitlement pool response. - * - * @param request the request - * @param vlmId the vlm id - * @param user the user - * @return the response - */ - public Response createEntitlementPool(EntitlementPoolRequestDto request, String vlmId, - String versionId, String user) { - EntitlementPoolEntity entitlementPoolEntity = - new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() + /** + * Create entitlement pool response. + * + * @param request the request + * @param vlmId the vlm id + * @param user the user + * @return the response + */ + public Response createEntitlementPool(EntitlementPoolRequestDto request, String vlmId, String versionId, String user) { + EntitlementPoolEntity entitlementPoolEntity = new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() .applyMapping(request, EntitlementPoolEntity.class); - entitlementPoolEntity.setVendorLicenseModelId(vlmId); - entitlementPoolEntity.setVersion(new Version(versionId)); - - EntitlementPoolEntity createdEntitlementPool = - vendorLicenseManager.createEntitlementPool(entitlementPoolEntity); - StringWrapperResponse result = - createdEntitlementPool != null ? new StringWrapperResponse(createdEntitlementPool.getId()) - : null; - return Response.ok(result).build(); - } + entitlementPoolEntity.setVendorLicenseModelId(vlmId); + entitlementPoolEntity.setVersion(new Version(versionId)); + EntitlementPoolEntity createdEntitlementPool = vendorLicenseManager.createEntitlementPool(entitlementPoolEntity); + StringWrapperResponse result = createdEntitlementPool != null ? new StringWrapperResponse(createdEntitlementPool.getId()) : null; + return Response.ok(result).build(); + } - /** - * Update entitlement pool response. - * - * @param request the request - * @param vlmId the vlm id - * @param entitlementPoolId the entitlement pool id - * @param user the user - * @return the response - */ - public Response updateEntitlementPool(EntitlementPoolRequestDto request, String vlmId, - String versionId, String entitlementPoolId, String user) { - EntitlementPoolEntity entitlementPoolEntity = - new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() + /** + * Update entitlement pool response. + * + * @param request the request + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param user the user + * @return the response + */ + public Response updateEntitlementPool(EntitlementPoolRequestDto request, String vlmId, String versionId, String entitlementPoolId, String user) { + EntitlementPoolEntity entitlementPoolEntity = new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() .applyMapping(request, EntitlementPoolEntity.class); - entitlementPoolEntity.setVendorLicenseModelId(vlmId); - entitlementPoolEntity.setVersion(new Version(versionId)); - entitlementPoolEntity.setId(entitlementPoolId); - - vendorLicenseManager.updateEntitlementPool(entitlementPoolEntity); - return Response.ok().build(); - } - - /** - * Gets entitlement pool. - * - * @param vlmId the vlm id - * @param versionId the version id - * @param entitlementPoolId the entitlement pool id - * @param user the user - * @return the entitlement pool - */ - public Response getEntitlementPool(String vlmId, String versionId, String entitlementPoolId, - String user) { - EntitlementPoolEntity epInput = new EntitlementPoolEntity(); - epInput.setVendorLicenseModelId(vlmId); - epInput.setVersion(new Version(versionId)); - epInput.setId(entitlementPoolId); - EntitlementPoolEntity entitlementPool = vendorLicenseManager.getEntitlementPool(epInput); + entitlementPoolEntity.setVendorLicenseModelId(vlmId); + entitlementPoolEntity.setVersion(new Version(versionId)); + entitlementPoolEntity.setId(entitlementPoolId); + vendorLicenseManager.updateEntitlementPool(entitlementPoolEntity); + return Response.ok().build(); + } - EntitlementPoolEntityDto entitlementPoolEntityDto = entitlementPool == null ? null : - new MapEntitlementPoolEntityToEntitlementPoolEntityDto() - .applyMapping(entitlementPool, EntitlementPoolEntityDto.class); - return Response.ok(entitlementPoolEntityDto).build(); - } + /** + * Gets entitlement pool. + * + * @param vlmId the vlm id + * @param versionId the version id + * @param entitlementPoolId the entitlement pool id + * @param user the user + * @return the entitlement pool + */ + public Response getEntitlementPool(String vlmId, String versionId, String entitlementPoolId, String user) { + EntitlementPoolEntity epInput = new EntitlementPoolEntity(); + epInput.setVendorLicenseModelId(vlmId); + epInput.setVersion(new Version(versionId)); + epInput.setId(entitlementPoolId); + EntitlementPoolEntity entitlementPool = vendorLicenseManager.getEntitlementPool(epInput); + EntitlementPoolEntityDto entitlementPoolEntityDto = entitlementPool == null ? null + : new MapEntitlementPoolEntityToEntitlementPoolEntityDto().applyMapping(entitlementPool, EntitlementPoolEntityDto.class); + return Response.ok(entitlementPoolEntityDto).build(); + } - /** - * Delete entitlement pool response. - * - * @param vlmId the vlm id - * @param entitlementPoolId the entitlement pool id - * @param user the user - * @return the response - */ - public Response deleteEntitlementPool(String vlmId, String versionId, String entitlementPoolId, - String user) { - EntitlementPoolEntity epInput = new EntitlementPoolEntity(); - epInput.setVendorLicenseModelId(vlmId); - epInput.setId(entitlementPoolId); - epInput.setVersion(new Version(versionId)); - vendorLicenseManager.deleteEntitlementPool(epInput); - return Response.ok().build(); - } + /** + * Delete entitlement pool response. + * + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param user the user + * @return the response + */ + public Response deleteEntitlementPool(String vlmId, String versionId, String entitlementPoolId, String user) { + EntitlementPoolEntity epInput = new EntitlementPoolEntity(); + epInput.setVendorLicenseModelId(vlmId); + epInput.setId(entitlementPoolId); + epInput.setVersion(new Version(versionId)); + vendorLicenseManager.deleteEntitlementPool(epInput); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java index 4ea35d321d..a945784213 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; import java.util.Comparator; @@ -54,104 +53,75 @@ import org.springframework.stereotype.Service; @Scope(value = "prototype") public class FeatureGroupsImpl implements FeatureGroups { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); @Override public Response listFeatureGroups(String vlmId, String versionId, String user) { - - MapFeatureGroupEntityToFeatureGroupDescriptorDto outputMapper = - new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); - + MapFeatureGroupEntityToFeatureGroupDescriptorDto outputMapper = new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); GenericCollectionWrapper<FeatureGroupEntityDto> results = new GenericCollectionWrapper<>( - vendorLicenseManager.listFeatureGroups(vlmId, new Version(versionId)).stream() - .sorted(Comparator.comparing(FeatureGroupEntity::getName)) - .map(fg -> getFeatureGroupEntityDto(outputMapper,fg)).collect(Collectors.toList())); - + vendorLicenseManager.listFeatureGroups(vlmId, new Version(versionId)).stream().sorted(Comparator.comparing(FeatureGroupEntity::getName)) + .map(fg -> getFeatureGroupEntityDto(outputMapper, fg)).collect(Collectors.toList())); return Response.ok(results).build(); } @Override - public Response createFeatureGroup(FeatureGroupRequestDto request, String vlmId, String versionId, - String user) { + public Response createFeatureGroup(FeatureGroupRequestDto request, String vlmId, String versionId, String user) { FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity() - .applyMapping(request, FeatureGroupEntity.class); + .applyMapping(request, FeatureGroupEntity.class); featureGroupEntity.setVendorLicenseModelId(vlmId); featureGroupEntity.setVersion(new Version(versionId)); featureGroupEntity.setLicenseKeyGroupIds(request.getAddedLicenseKeyGroupsIds()); featureGroupEntity.setEntitlementPoolIds(request.getAddedEntitlementPoolsIds()); - - FeatureGroupEntity createdFeatureGroup = - vendorLicenseManager.createFeatureGroup(featureGroupEntity); - - StringWrapperResponse result = - createdFeatureGroup != null ? new StringWrapperResponse(createdFeatureGroup.getId()) : null; + FeatureGroupEntity createdFeatureGroup = vendorLicenseManager.createFeatureGroup(featureGroupEntity); + StringWrapperResponse result = createdFeatureGroup != null ? new StringWrapperResponse(createdFeatureGroup.getId()) : null; return Response.ok(result).build(); } @Override - public Response updateFeatureGroup(FeatureGroupUpdateRequestDto request, String vlmId, - String versionId, String featureGroupId, String user) { + public Response updateFeatureGroup(FeatureGroupUpdateRequestDto request, String vlmId, String versionId, String featureGroupId, String user) { FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity() - .applyMapping(request, FeatureGroupEntity.class); + .applyMapping(request, FeatureGroupEntity.class); featureGroupEntity.setVendorLicenseModelId(vlmId); featureGroupEntity.setVersion(new Version(versionId)); featureGroupEntity.setId(featureGroupId); - - vendorLicenseManager - .updateFeatureGroup(featureGroupEntity, request.getAddedLicenseKeyGroupsIds(), - request.getRemovedLicenseKeyGroupsIds(), request.getAddedEntitlementPoolsIds(), - request.getRemovedEntitlementPoolsIds()); + vendorLicenseManager.updateFeatureGroup(featureGroupEntity, request.getAddedLicenseKeyGroupsIds(), request.getRemovedLicenseKeyGroupsIds(), + request.getAddedEntitlementPoolsIds(), request.getRemovedEntitlementPoolsIds()); return Response.ok().build(); } @Override - public Response getFeatureGroup(String vlmId, String versionId, String featureGroupId, - String user) { + public Response getFeatureGroup(String vlmId, String versionId, String featureGroupId, String user) { FeatureGroupEntity fgInput = new FeatureGroupEntity(); fgInput.setVendorLicenseModelId(vlmId); fgInput.setVersion(new Version(versionId)); fgInput.setId(featureGroupId); FeatureGroupModel featureGroupModel = vendorLicenseManager.getFeatureGroupModel(fgInput); - if (featureGroupModel == null) { return Response.ok().build(); } - FeatureGroupModelDto fgmDto = new FeatureGroupModelDto(); fgmDto.setId(featureGroupModel.getFeatureGroup().getId()); - fgmDto.setReferencingLicenseAgreements( - featureGroupModel.getFeatureGroup().getReferencingLicenseAgreements()); - new MapFeatureGroupEntityToFeatureGroupDescriptorDto() - .doMapping(featureGroupModel.getFeatureGroup(), fgmDto); - + fgmDto.setReferencingLicenseAgreements(featureGroupModel.getFeatureGroup().getReferencingLicenseAgreements()); + new MapFeatureGroupEntityToFeatureGroupDescriptorDto().doMapping(featureGroupModel.getFeatureGroup(), fgmDto); if (!CollectionUtils.isEmpty(featureGroupModel.getLicenseKeyGroups())) { fgmDto.setLicenseKeyGroups(new HashSet<>()); - - MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto lkgMapper = - new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); + MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto lkgMapper = new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); for (LicenseKeyGroupEntity lkg : featureGroupModel.getLicenseKeyGroups()) { - fgmDto.getLicenseKeyGroups() - .add(lkgMapper.applyMapping(lkg, LicenseKeyGroupEntityDto.class)); + fgmDto.getLicenseKeyGroups().add(lkgMapper.applyMapping(lkg, LicenseKeyGroupEntityDto.class)); } } - if (!CollectionUtils.isEmpty(featureGroupModel.getEntitlementPools())) { fgmDto.setEntitlementPools(new HashSet<>()); - - MapEntitlementPoolEntityToEntitlementPoolEntityDto epMapper = - new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); + MapEntitlementPoolEntityToEntitlementPoolEntityDto epMapper = new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); for (EntitlementPoolEntity ep : featureGroupModel.getEntitlementPools()) { fgmDto.getEntitlementPools().add(epMapper.applyMapping(ep, EntitlementPoolEntityDto.class)); - } } return Response.ok(fgmDto).build(); } @Override - public Response deleteFeatureGroup(String vlmId, String versionId, String featureGroupId, - String user) { + public Response deleteFeatureGroup(String vlmId, String versionId, String featureGroupId, String user) { FeatureGroupEntity fgInput = new FeatureGroupEntity(); fgInput.setVendorLicenseModelId(vlmId); fgInput.setVersion(new Version(versionId)); @@ -160,7 +130,7 @@ public class FeatureGroupsImpl implements FeatureGroups { return Response.ok().build(); } - private FeatureGroupEntityDto getFeatureGroupEntityDto(MapFeatureGroupEntityToFeatureGroupDescriptorDto mapper,FeatureGroupEntity fg) { + private FeatureGroupEntityDto getFeatureGroupEntityDto(MapFeatureGroupEntityToFeatureGroupDescriptorDto mapper, FeatureGroupEntity fg) { FeatureGroupEntityDto fgDto = new FeatureGroupEntityDto(); fgDto.setId(fg.getId()); fgDto.setLicenseKeyGroupsIds(fg.getLicenseKeyGroupIds()); @@ -169,5 +139,4 @@ public class FeatureGroupsImpl implements FeatureGroups { mapper.doMapping(fg, fgDto); return fgDto; } - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java index 7c0539931b..fb67b237f0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; import java.util.Comparator; @@ -51,8 +50,7 @@ import org.springframework.stereotype.Service; @Scope(value = "prototype") public class LicenseAgreementsImpl implements LicenseAgreements { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); /** * List license agreements response. @@ -63,20 +61,14 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @return the response */ public Response listLicenseAgreements(String vlmId, String versionId, String user) { - - MapLicenseAgreementEntityToLicenseAgreementDescriptorDto outputMapper = - new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(); - + MapLicenseAgreementEntityToLicenseAgreementDescriptorDto outputMapper = new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(); GenericCollectionWrapper<LicenseAgreementEntityDto> results = new GenericCollectionWrapper<>( - vendorLicenseManager.listLicenseAgreements(vlmId, new Version(versionId)).stream() - .sorted(Comparator.comparing(LicenseAgreementEntity::getName)) - .map(lae -> getLicenseAgreementEntityDto(outputMapper, lae)) - .collect(Collectors.toList())); - + vendorLicenseManager.listLicenseAgreements(vlmId, new Version(versionId)).stream() + .sorted(Comparator.comparing(LicenseAgreementEntity::getName)).map(lae -> getLicenseAgreementEntityDto(outputMapper, lae)) + .collect(Collectors.toList())); return Response.ok(results).build(); } - /** * Create license agreement response. * @@ -85,20 +77,14 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @param user the user * @return the response */ - public Response createLicenseAgreement(LicenseAgreementRequestDto request, String vlmId, - String versionId, String user) { - LicenseAgreementEntity licenseAgreementEntity = - new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() - .applyMapping(request, LicenseAgreementEntity.class); + public Response createLicenseAgreement(LicenseAgreementRequestDto request, String vlmId, String versionId, String user) { + LicenseAgreementEntity licenseAgreementEntity = new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() + .applyMapping(request, LicenseAgreementEntity.class); licenseAgreementEntity.setVendorLicenseModelId(vlmId); licenseAgreementEntity.setVersion(new Version(versionId)); licenseAgreementEntity.setFeatureGroupIds(request.getAddedFeatureGroupsIds()); - - LicenseAgreementEntity createdLicenseAgreement = - vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity); - StringWrapperResponse result = - createdLicenseAgreement != null ? new StringWrapperResponse(createdLicenseAgreement.getId()) - : null; + LicenseAgreementEntity createdLicenseAgreement = vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity); + StringWrapperResponse result = createdLicenseAgreement != null ? new StringWrapperResponse(createdLicenseAgreement.getId()) : null; return Response.ok(result).build(); } @@ -111,18 +97,14 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @param user the user * @return the response */ - public Response updateLicenseAgreement(LicenseAgreementUpdateRequestDto request, String vlmId, - String versionId, String licenseAgreementId, String user) { - LicenseAgreementEntity licenseAgreementEntity = - new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() - .applyMapping(request, LicenseAgreementEntity.class); + public Response updateLicenseAgreement(LicenseAgreementUpdateRequestDto request, String vlmId, String versionId, String licenseAgreementId, + String user) { + LicenseAgreementEntity licenseAgreementEntity = new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() + .applyMapping(request, LicenseAgreementEntity.class); licenseAgreementEntity.setVendorLicenseModelId(vlmId); licenseAgreementEntity.setVersion(new Version(versionId)); licenseAgreementEntity.setId(licenseAgreementId); - - vendorLicenseManager - .updateLicenseAgreement(licenseAgreementEntity, request.getAddedFeatureGroupsIds(), - request.getRemovedFeatureGroupsIds()); + vendorLicenseManager.updateLicenseAgreement(licenseAgreementEntity, request.getAddedFeatureGroupsIds(), request.getRemovedFeatureGroupsIds()); return Response.ok().build(); } @@ -135,32 +117,24 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @param user the user * @return the license agreement */ - public Response getLicenseAgreement(String vlmId, String versionId, String licenseAgreementId, - String user) { + public Response getLicenseAgreement(String vlmId, String versionId, String licenseAgreementId, String user) { LicenseAgreementModel licenseAgreementModel = vendorLicenseManager - .getLicenseAgreementModel(vlmId, new Version(versionId), licenseAgreementId); - + .getLicenseAgreementModel(vlmId, new Version(versionId), licenseAgreementId); if (licenseAgreementModel == null) { return Response.ok().build(); } - LicenseAgreementModelDto lamDto = new LicenseAgreementModelDto(); lamDto.setId(licenseAgreementModel.getLicenseAgreement().getId()); - new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto() - .doMapping(licenseAgreementModel.getLicenseAgreement(), lamDto); - + new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto().doMapping(licenseAgreementModel.getLicenseAgreement(), lamDto); if (!CollectionUtils.isEmpty(licenseAgreementModel.getFeatureGroups())) { lamDto.setFeatureGroups(new HashSet<>()); - - MapFeatureGroupEntityToFeatureGroupDescriptorDto fgMapper = - new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); + MapFeatureGroupEntityToFeatureGroupDescriptorDto fgMapper = new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); for (FeatureGroupEntity fg : licenseAgreementModel.getFeatureGroups()) { FeatureGroupEntityDto fgeDto = new FeatureGroupEntityDto(); fgeDto.setId(fg.getId()); fgeDto.setEntitlementPoolsIds(fg.getEntitlementPoolIds()); fgeDto.setLicenseKeyGroupsIds(fg.getLicenseKeyGroupIds()); fgMapper.doMapping(fg, fgeDto); - lamDto.getFeatureGroups().add(fgeDto); } } @@ -176,14 +150,13 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @param user the user * @return the response */ - public Response deleteLicenseAgreement(String vlmId, String versionId, String licenseAgreementId, - String user) { + public Response deleteLicenseAgreement(String vlmId, String versionId, String licenseAgreementId, String user) { vendorLicenseManager.deleteLicenseAgreement(vlmId, new Version(versionId), licenseAgreementId); return Response.ok().build(); } - private LicenseAgreementEntityDto getLicenseAgreementEntityDto( - MapLicenseAgreementEntityToLicenseAgreementDescriptorDto mapper, LicenseAgreementEntity lae) { + private LicenseAgreementEntityDto getLicenseAgreementEntityDto(MapLicenseAgreementEntityToLicenseAgreementDescriptorDto mapper, + LicenseAgreementEntity lae) { LicenseAgreementEntityDto laeDto = new LicenseAgreementEntityDto(); laeDto.setId(lae.getId()); laeDto.setFeatureGroupsIds(lae.getFeatureGroupIds()); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java index 14491b0e6a..7d4f1f7679 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; @@ -36,126 +38,89 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("licenseKeyGroupLimits") @Scope(value = "prototype") public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); - - private static final String PARENT = "LicenseKeyGroup"; - - - @Override - public Response createLimit(LimitRequestDto request, - String vlmId, - String versionId, - String licenseKeyGroupId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager.getLicenseKeyGroup( - new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - - LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); - limitEntity.setVendorLicenseModelId(vlmId); - limitEntity.setVersion(version); - limitEntity.setEpLkgId(licenseKeyGroupId); - limitEntity.setParent(PARENT); - LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity); - MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); - LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class); - return Response.ok(createdLimitDto != null ? createdLimitDto : null).build(); - } - - @Override - public Response listLimits(String vlmId, String versionId, String licenseKeyGroupId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - - Collection<LimitEntity> limits = - vendorLicenseManager.listLimits(vlmId, version, licenseKeyGroupId); - - GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); - MapLimitEntityToLimitDto outputMapper = - new MapLimitEntityToLimitDto(); - for (LimitEntity limit : limits) { - result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + private static final String PARENT = "LicenseKeyGroup"; + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); + + @Override + public Response createLimit(LimitRequestDto request, String vlmId, String versionId, String licenseKeyGroupId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + LimitEntity limitEntity = new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setVersion(version); + limitEntity.setEpLkgId(licenseKeyGroupId); + limitEntity.setParent(PARENT); + LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity); + MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); + LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class); + return Response.ok(createdLimitDto != null ? createdLimitDto : null).build(); } - return Response.ok(result).build(); - } - - @Override - public Response updateLimit(LimitRequestDto request, - String vlmId, - String versionId, - String licenseKeyGroupId, - String limitId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - - LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); - limitEntity.setVendorLicenseModelId(vlmId); - limitEntity.setVersion(version); - limitEntity.setEpLkgId(licenseKeyGroupId); - limitEntity.setId(limitId); - limitEntity.setParent(PARENT); - - vendorLicenseManager.updateLimit(limitEntity); - return Response.ok().build(); - } - /** - * Delete License Key Group. - * - * @param vlmId the vlm id - * @param licenseKeyGroupId the license Key Group id - * @param limitId the limitId - * @param user the user - * @return the response - */ - public Response deleteLimit(String vlmId, String versionId, String licenseKeyGroupId, - String limitId, String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - - LimitEntity limitInput = new LimitEntity(); - limitInput.setVendorLicenseModelId(vlmId); - limitInput.setVersion(version); - limitInput.setEpLkgId(licenseKeyGroupId); - limitInput.setId(limitId); - limitInput.setParent(PARENT); + @Override + public Response listLimits(String vlmId, String versionId, String licenseKeyGroupId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + Collection<LimitEntity> limits = vendorLicenseManager.listLimits(vlmId, version, licenseKeyGroupId); + GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); + MapLimitEntityToLimitDto outputMapper = new MapLimitEntityToLimitDto(); + for (LimitEntity limit : limits) { + result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + } + return Response.ok(result).build(); + } - vendorLicenseManager.deleteLimit(limitInput); - return Response.ok().build(); - } + @Override + public Response updateLimit(LimitRequestDto request, String vlmId, String versionId, String licenseKeyGroupId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + LimitEntity limitEntity = new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setVersion(version); + limitEntity.setEpLkgId(licenseKeyGroupId); + limitEntity.setId(limitId); + limitEntity.setParent(PARENT); + vendorLicenseManager.updateLimit(limitEntity); + return Response.ok().build(); + } - @Override - public Response getLimit(String vlmId, String versionId, String licenseKeyGroupId, - String limitId, String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - LimitEntity limitInput = new LimitEntity(); - limitInput.setVendorLicenseModelId(vlmId); - limitInput.setVersion(version); - limitInput.setEpLkgId(licenseKeyGroupId); - limitInput.setId(limitId); - LimitEntity limit = vendorLicenseManager.getLimit(limitInput); + /** + * Delete License Key Group. + * + * @param vlmId the vlm id + * @param licenseKeyGroupId the license Key Group id + * @param limitId the limitId + * @param user the user + * @return the response + */ + public Response deleteLimit(String vlmId, String versionId, String licenseKeyGroupId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setVersion(version); + limitInput.setEpLkgId(licenseKeyGroupId); + limitInput.setId(limitId); + limitInput.setParent(PARENT); + vendorLicenseManager.deleteLimit(limitInput); + return Response.ok().build(); + } - LimitEntityDto entitlementPoolEntityDto = limit == null ? null - : new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class); - return Response.ok(entitlementPoolEntityDto).build(); - } + @Override + public Response getLimit(String vlmId, String versionId, String licenseKeyGroupId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setVersion(version); + limitInput.setEpLkgId(licenseKeyGroupId); + limitInput.setId(limitId); + LimitEntity limit = vendorLicenseManager.getLimit(limitInput); + LimitEntityDto entitlementPoolEntityDto = limit == null ? null : new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class); + return Response.ok(entitlementPoolEntityDto).build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java index 3edee02080..f7ddc25eba 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java @@ -7,9 +7,9 @@ * 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. @@ -17,12 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; import java.util.Comparator; import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.inject.Named; import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; @@ -45,116 +43,97 @@ import org.springframework.validation.annotation.Validated; @Scope(value = "prototype") @Validated public class LicenseKeyGroupsImpl implements LicenseKeyGroups { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); - - /** - * List license key groups response. - * - * @param vlmId the vlm id - * @param versionId the version - * @param user the user - * @return the response - */ - public Response listLicenseKeyGroups(String vlmId, String versionId, String user) { - MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto outputMapper = - new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); - GenericCollectionWrapper<LicenseKeyGroupEntityDto> result = new GenericCollectionWrapper<>( + /** + * List license key groups response. + * + * @param vlmId the vlm id + * @param versionId the version + * @param user the user + * @return the response + */ + public Response listLicenseKeyGroups(String vlmId, String versionId, String user) { + MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto outputMapper = new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); + GenericCollectionWrapper<LicenseKeyGroupEntityDto> result = new GenericCollectionWrapper<>( vendorLicenseManager.listLicenseKeyGroups(vlmId, new Version(versionId)).stream() - .sorted(Comparator.comparing(LicenseKeyGroupEntity::getName)) - .map(item -> outputMapper.applyMapping(item, LicenseKeyGroupEntityDto.class)) - .collect(Collectors.toList())); - - return Response.ok(result).build(); - } + .sorted(Comparator.comparing(LicenseKeyGroupEntity::getName)) + .map(item -> outputMapper.applyMapping(item, LicenseKeyGroupEntityDto.class)).collect(Collectors.toList())); + return Response.ok(result).build(); + } - /** - * Create license key group response. - * - * @param request the request - * @param vlmId the vlm id - * @param user the user - * @return the response - */ - public Response createLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, - String versionId, String user) { - LicenseKeyGroupEntity licenseKeyGroupEntity = - new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() + /** + * Create license key group response. + * + * @param request the request + * @param vlmId the vlm id + * @param user the user + * @return the response + */ + public Response createLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, String versionId, String user) { + LicenseKeyGroupEntity licenseKeyGroupEntity = new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() .applyMapping(request, LicenseKeyGroupEntity.class); - licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); - licenseKeyGroupEntity.setVersion(new Version(versionId)); + licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); + licenseKeyGroupEntity.setVersion(new Version(versionId)); + LicenseKeyGroupEntity createdLicenseKeyGroup = vendorLicenseManager.createLicenseKeyGroup(licenseKeyGroupEntity); + StringWrapperResponse result = createdLicenseKeyGroup != null ? new StringWrapperResponse(createdLicenseKeyGroup.getId()) : null; + return Response.ok(result).build(); + } - LicenseKeyGroupEntity createdLicenseKeyGroup = - vendorLicenseManager.createLicenseKeyGroup(licenseKeyGroupEntity); - StringWrapperResponse result = - createdLicenseKeyGroup != null ? new StringWrapperResponse(createdLicenseKeyGroup.getId()) - : null; - return Response.ok(result).build(); - } - - /** - * Update license key group response. - * - * @param request the request - * @param vlmId the vlm id - * @param licenseKeyGroupId the license key group id - * @param user the user - * @return the response - */ - public Response updateLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, - String versionId, - String licenseKeyGroupId, String user) { - LicenseKeyGroupEntity licenseKeyGroupEntity = - new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() + /** + * Update license key group response. + * + * @param request the request + * @param vlmId the vlm id + * @param licenseKeyGroupId the license key group id + * @param user the user + * @return the response + */ + public Response updateLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, String versionId, String licenseKeyGroupId, String user) { + LicenseKeyGroupEntity licenseKeyGroupEntity = new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() .applyMapping(request, LicenseKeyGroupEntity.class); - licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); - licenseKeyGroupEntity.setVersion(new Version(versionId)); - licenseKeyGroupEntity.setId(licenseKeyGroupId); - - vendorLicenseManager.updateLicenseKeyGroup(licenseKeyGroupEntity); - return Response.ok().build(); - } - - /** - * Gets license key group. - * - * @param vlmId the vlm id - * @param versionId the version - * @param licenseKeyGroupId the license key group id - * @param user the user - * @return the license key group - */ - public Response getLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, - String user) { - LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); - lkgInput.setVendorLicenseModelId(vlmId); - lkgInput.setVersion(new Version(versionId)); - lkgInput.setId(licenseKeyGroupId); - LicenseKeyGroupEntity licenseKeyGroup = vendorLicenseManager.getLicenseKeyGroup(lkgInput); + licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); + licenseKeyGroupEntity.setVersion(new Version(versionId)); + licenseKeyGroupEntity.setId(licenseKeyGroupId); + vendorLicenseManager.updateLicenseKeyGroup(licenseKeyGroupEntity); + return Response.ok().build(); + } - LicenseKeyGroupEntityDto licenseKeyGroupEntityDto = licenseKeyGroup == null ? null : - new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto() - .applyMapping(licenseKeyGroup, LicenseKeyGroupEntityDto.class); - return Response.ok(licenseKeyGroupEntityDto).build(); - } + /** + * Gets license key group. + * + * @param vlmId the vlm id + * @param versionId the version + * @param licenseKeyGroupId the license key group id + * @param user the user + * @return the license key group + */ + public Response getLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, String user) { + LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); + lkgInput.setVendorLicenseModelId(vlmId); + lkgInput.setVersion(new Version(versionId)); + lkgInput.setId(licenseKeyGroupId); + LicenseKeyGroupEntity licenseKeyGroup = vendorLicenseManager.getLicenseKeyGroup(lkgInput); + LicenseKeyGroupEntityDto licenseKeyGroupEntityDto = licenseKeyGroup == null ? null + : new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto().applyMapping(licenseKeyGroup, LicenseKeyGroupEntityDto.class); + return Response.ok(licenseKeyGroupEntityDto).build(); + } - /** - * Delete license key group response. - * - * @param vlmId the vlm id - * @param licenseKeyGroupId the license key group id - * @param user the user - * @return the response - */ - public Response deleteLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, - String user) { - LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); - lkgInput.setVendorLicenseModelId(vlmId); - lkgInput.setVersion(new Version(versionId)); - lkgInput.setId(licenseKeyGroupId); - vendorLicenseManager.deleteLicenseKeyGroup(lkgInput); - return Response.ok().build(); - } + /** + * Delete license key group response. + * + * @param vlmId the vlm id + * @param licenseKeyGroupId the license key group id + * @param user the user + * @return the response + */ + public Response deleteLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, String user) { + LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); + lkgInput.setVendorLicenseModelId(vlmId); + lkgInput.setVersion(new Version(versionId)); + lkgInput.setId(licenseKeyGroupId); + vendorLicenseManager.deleteLicenseKeyGroup(lkgInput); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java index df6363c883..0255b14753 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java @@ -13,10 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.openecomp.sdcrests.vendorlicense.rest.services; +import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME; +import static org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto.VendorLicenseModelAction.Submit; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Predicate; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.util.UniqueValueUtil; import org.openecomp.sdc.activitylog.ActivityLogManager; @@ -65,17 +77,6 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.function.Predicate; - -import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.*; -import static org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto.VendorLicenseModelAction.Submit; - @Named @Service("vendorLicenseModels") @Scope(value = "prototype") @@ -83,75 +84,57 @@ import static org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActio public class VendorLicenseModelsImpl implements VendorLicenseModels { private static final String SUBMIT_ITEM_ACTION = "Submit_Item"; - private static final String SUBMIT_HEALED_VERSION_ERROR = - "VLM Id %s: Error while submitting version %s created based on Certified version %s for healing purpose."; + private static final String SUBMIT_HEALED_VERSION_ERROR = "VLM Id %s: Error while submitting version %s created based on Certified version %s for healing purpose."; private static final Logger LOGGER = LoggerFactory.getLogger(VendorLicenseModelsImpl.class); private PermissionsManager permissionsManager = PermissionsManagerFactory.getInstance().createInterface(); - private NotificationPropagationManager notifier = - NotificationPropagationManagerFactory.getInstance().createInterface(); - + private NotificationPropagationManager notifier = NotificationPropagationManagerFactory.getInstance().createInterface(); private AsdcItemManager asdcItemManager = AsdcItemManagerFactory.getInstance().createInterface(); private VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); private ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); - private UniqueValueUtil uniqueValueUtil = - new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); + private UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); @Override public Response listLicenseModels(String versionStatus, String itemStatus, String user) { Predicate<Item> itemPredicate = createItemPredicate(versionStatus, itemStatus, user); - GenericCollectionWrapper<ItemDto> results = new GenericCollectionWrapper<>(); MapItemToDto mapper = new MapItemToDto(); - asdcItemManager.list(itemPredicate).stream() - .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) - .forEach(item -> results.add(mapper.applyMapping(item, ItemDto.class))); - + asdcItemManager.list(itemPredicate).stream().sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) + .forEach(item -> results.add(mapper.applyMapping(item, ItemDto.class))); return Response.ok(results).build(); } @Override public Response createLicenseModel(VendorLicenseModelRequestDto request, String user) { - Item item = new Item(); item.setType(ItemType.vlm.name()); item.setOwner(user); item.setStatus(ItemStatus.ACTIVE); item.setName(request.getVendorName()); item.setDescription(request.getDescription()); - uniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, item.getName()); item = asdcItemManager.create(item); uniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, item.getName()); - Version version = versioningManager.create(item.getId(), new Version(), null); - VendorLicenseModelEntity vlm = new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity() - .applyMapping(request, VendorLicenseModelEntity.class); + .applyMapping(request, VendorLicenseModelEntity.class); vlm.setId(item.getId()); vlm.setVersion(version); - vendorLicenseManager.createVendorLicenseModel(vlm); versioningManager.publish(item.getId(), version, "Initial vlm:" + vlm.getVendorName()); - ItemCreationDto itemCreationDto = new ItemCreationDto(); itemCreationDto.setItemId(item.getId()); itemCreationDto.setVersion(new MapVersionToDto().applyMapping(version, VersionDto.class)); - - activityLogManager - .logActivity(new ActivityLogEntity(vlm.getId(), version, ActivityType.Create, user, true, "", "")); - + activityLogManager.logActivity(new ActivityLogEntity(vlm.getId(), version, ActivityType.Create, user, true, "", "")); return Response.ok(itemCreationDto).build(); } @Override - public Response updateLicenseModel(VendorLicenseModelRequestDto request, String vlmId, String versionId, - String user) { + public Response updateLicenseModel(VendorLicenseModelRequestDto request, String vlmId, String versionId, String user) { VendorLicenseModelEntity vlm = new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity() - .applyMapping(request, VendorLicenseModelEntity.class); + .applyMapping(request, VendorLicenseModelEntity.class); vlm.setId(vlmId); vlm.setVersion(new Version(versionId)); - vendorLicenseManager.updateVendorLicenseModel(vlm); return Response.ok().build(); } @@ -160,74 +143,56 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { public Response getLicenseModel(String vlmId, String versionId, String user) { Version version = versioningManager.get(vlmId, new Version(versionId)); VendorLicenseModelEntity vlm = vendorLicenseManager.getVendorLicenseModel(vlmId, version); - try { - HealingManagerFactory.getInstance().createInterface() - .healItemVersion(vlmId, version, ItemType.vlm, false) - .ifPresent(healedVersion -> { - vlm.setVersion(healedVersion); - if (version.getStatus() == VersionStatus.Certified) { - submitHealedVersion(vlmId, healedVersion, versionId, user); - } - }); + HealingManagerFactory.getInstance().createInterface().healItemVersion(vlmId, version, ItemType.vlm, false).ifPresent(healedVersion -> { + vlm.setVersion(healedVersion); + if (version.getStatus() == VersionStatus.Certified) { + submitHealedVersion(vlmId, healedVersion, versionId, user); + } + }); } catch (Exception e) { LOGGER.error(String.format("Error while auto healing VLM with Id %s and version %s", vlmId, versionId), e); } - - VendorLicenseModelEntityDto vlmDto = - new MapVendorLicenseModelEntityToDto().applyMapping(vlm, VendorLicenseModelEntityDto.class); + VendorLicenseModelEntityDto vlmDto = new MapVendorLicenseModelEntityToDto().applyMapping(vlm, VendorLicenseModelEntityDto.class); return Response.ok(vlmDto).build(); } @Override public Response deleteLicenseModel(String vlmId, String user) { Item vlm = asdcItemManager.get(vlmId); - if (!vlm.getType().equals(ItemType.vlm.name())) { - throw new CoreException((new ErrorCode.ErrorCodeBuilder() - .withMessage(String.format("Vlm with id %s does not exist.", vlmId)) - .build())); + throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage(String.format("Vlm with id %s does not exist.", vlmId)).build())); } - Integer certifiedVersionsCounter = vlm.getVersionStatusCounters().get(VersionStatus.Certified); if (Objects.isNull(certifiedVersionsCounter) || certifiedVersionsCounter == 0) { asdcItemManager.delete(vlm); permissionsManager.deleteItemPermissions(vlmId); uniqueValueUtil.deleteUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, vlm.getName()); notifyUsers(vlmId, vlm.getName(), null, null, user, NotificationEventTypes.DELETE); - return Response.ok().build(); } else { - return Response.status(Response.Status.FORBIDDEN) - .entity(new Exception(Messages.DELETE_VLM_ERROR.getErrorMessage())).build(); + return Response.status(Response.Status.FORBIDDEN).entity(new Exception(Messages.DELETE_VLM_ERROR.getErrorMessage())).build(); } } @Override - public Response actOnLicenseModel(VendorLicenseModelActionRequestDto request, String vlmId, String versionId, - String user) { + public Response actOnLicenseModel(VendorLicenseModelActionRequestDto request, String vlmId, String versionId, String user) { Version version = new Version(versionId); - if (request.getAction() == Submit) { if (!permissionsManager.isAllowed(vlmId, user, SUBMIT_ITEM_ACTION)) { - return Response.status(Response.Status.FORBIDDEN) - .entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); + return Response.status(Response.Status.FORBIDDEN).entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); } String message = request.getSubmitRequest() == null ? "Submit" : request.getSubmitRequest().getMessage(); submit(vlmId, version, message, user); - notifyUsers(vlmId, null, version, message, user, NotificationEventTypes.SUBMIT); - } return Response.ok().build(); } private void submit(String vlmId, Version version, String message, String user) { - vendorLicenseManager.validate(vlmId, version); versioningManager.submit(vlmId, version, message); - activityLogManager - .logActivity(new ActivityLogEntity(vlmId, version, ActivityType.Submit, user, true, "", message)); + activityLogManager.logActivity(new ActivityLogEntity(vlmId, version, ActivityType.Submit, user, true, "", message)); } private void submitHealedVersion(String vlmId, Version healedVersion, String baseVersionId, String user) { @@ -238,21 +203,16 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { } } - private void notifyUsers(String itemId, String itemName, Version version, String message, String userName, - NotificationEventTypes eventType) { + private void notifyUsers(String itemId, String itemName, Version version, String message, String userName, NotificationEventTypes eventType) { Map<String, Object> eventProperties = new HashMap<>(); eventProperties.put(ITEM_NAME, itemName == null ? asdcItemManager.get(itemId).getName() : itemName); eventProperties.put(ITEM_ID, itemId); - if (version != null) { - eventProperties.put(VERSION_NAME, - version.getName() == null ? versioningManager.get(itemId, version).getName() : version.getName()); + eventProperties.put(VERSION_NAME, version.getName() == null ? versioningManager.get(itemId, version).getName() : version.getName()); eventProperties.put(VERSION_ID, version.getId()); } - eventProperties.put(SUBMIT_DESCRIPTION, message); eventProperties.put(PERMISSION_USER, userName); - Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId); try { notifier.notifySubscribers(syncEvent, userName); @@ -261,6 +221,27 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { } } + private boolean userHasPermission(String itemId, String userId) { + return permissionsManager.getUserItemPermission(itemId, userId) + .map(permission -> permission.matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name())).orElse(false); + } + + private Predicate<Item> createItemPredicate(String versionStatus, String itemStatus, String user) { + Predicate<Item> itemPredicate = item -> ItemType.vlm.name().equals(item.getType()); + if (ItemStatus.ARCHIVED.name().equals(itemStatus)) { + itemPredicate = itemPredicate.and(item -> ItemStatus.ARCHIVED.equals(item.getStatus())); + } else { + itemPredicate = itemPredicate.and(item -> ItemStatus.ACTIVE.equals(item.getStatus())); + if (VersionStatus.Certified.name().equals(versionStatus)) { + itemPredicate = itemPredicate.and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Certified)); + } else if (VersionStatus.Draft.name().equals(versionStatus)) { + itemPredicate = itemPredicate + .and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Draft) && userHasPermission(item.getId(), user)); + } + } + return itemPredicate; + } + private class SyncEvent implements Event { private String eventType; @@ -295,33 +276,4 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { return entityId; } } - - private boolean userHasPermission(String itemId, String userId) { - return permissionsManager.getUserItemPermission(itemId, userId) - .map(permission -> permission - .matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name())) - .orElse(false); - } - - private Predicate<Item> createItemPredicate(String versionStatus, String itemStatus, String user) { - Predicate<Item> itemPredicate = item -> ItemType.vlm.name().equals(item.getType()); - - if (ItemStatus.ARCHIVED.name().equals(itemStatus)) { - itemPredicate = itemPredicate.and(item -> ItemStatus.ARCHIVED.equals(item.getStatus())); - } else { - itemPredicate = itemPredicate.and(item -> ItemStatus.ACTIVE.equals(item.getStatus())); - - if (VersionStatus.Certified.name().equals(versionStatus)) { - itemPredicate = - itemPredicate.and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Certified)); - - } else if (VersionStatus.Draft.name().equals(versionStatus)) { - itemPredicate = itemPredicate - .and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Draft) - && userHasPermission(item.getId(), user)); - } - } - return itemPredicate; - } - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VlmUniqueTypeProvider.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VlmUniqueTypeProvider.java index 5beeec242f..91e1ac5593 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VlmUniqueTypeProvider.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VlmUniqueTypeProvider.java @@ -15,20 +15,18 @@ */ package org.openecomp.sdcrests.vendorlicense.rest.services; -import org.openecomp.sdcrests.uniquevalue.types.UniqueTypesProvider; +import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.UniqueValues.VENDOR_NAME; import java.util.Collections; import java.util.Map; - -import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.UniqueValues.VENDOR_NAME; +import org.openecomp.sdcrests.uniquevalue.types.UniqueTypesProvider; public class VlmUniqueTypeProvider implements UniqueTypesProvider { - private static final Map<String, String> uniqueTypes = - Collections.singletonMap("VlmName", VENDOR_NAME); + private static final Map<String, String> uniqueTypes = Collections.singletonMap("VlmName", VENDOR_NAME); - @Override - public Map<String, String> listUniqueTypes() { - return uniqueTypes; - } + @Override + public Map<String, String> listUniqueTypes() { + return uniqueTypes; + } } |