aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java103
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java101
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java13
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java4
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java3
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java3
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java1
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java12
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java23
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java75
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java178
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java179
12 files changed, 692 insertions, 3 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
new file mode 100644
index 0000000000..3e7adc845d
--- /dev/null
+++ 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
@@ -0,0 +1,103 @@
+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.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+
+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.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+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;
+
+@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/entitlement-pools" +
+ "/{entitlementPoolId}/limits")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Vendor License Model - Entitlement Pool Limits")
+@Validated
+public interface EntitlementPoolLimits {
+
+ @POST
+ @Path("/")
+ @ApiOperation(value = "Create vendor entitlement pool limits")
+ Response createLimit(@Valid LimitRequestDto request,
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId")
+ String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam
+ ("versionId")
+ String versionId,
+ @ApiParam(value = "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("/")
+ @ApiOperation(value = "List vendor entitlement pool limits",
+ response = LimitRequestDto.class,
+ responseContainer = "List")
+ Response listLimits(
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
+ @ApiParam(value = "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}")
+ @ApiOperation(value = "Update vendor entitlement pool limit")
+ Response updateLimit(@Valid LimitRequestDto request,
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId")
+ String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam
+ ("versionId")
+ String versionId,
+ @ApiParam(value = "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("/{limitId}")
+ @ApiOperation(value = "Get vendor entitlement pool limit",
+ response = LimitEntityDto.class)
+ Response getLimit(
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
+ @ApiParam(value = "Vendor license model Entitlement Pool Id") @PathParam
+ ("entitlementPoolId") String entitlementPoolId,
+ @ApiParam(value = "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}")
+ @ApiOperation(value = "Delete vendor entitlement pool limit")
+ Response deleteLimit(
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
+ @ApiParam(value = "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/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
new file mode 100644
index 0000000000..bfb2d51af0
--- /dev/null
+++ 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
@@ -0,0 +1,101 @@
+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.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto;
+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.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;
+
+@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups" +
+ "/{licenseKeyGroupId}/limits")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+@Api(value = "Vendor License Model - License Key Group Limits")
+@Validated
+public interface LicenseKeyGroupLimits {
+
+ @POST
+ @Path("/")
+ @ApiOperation(value = "Create vendor license key group limit")
+ Response createLimit(@Valid LimitRequestDto request,
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId")
+ String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam
+ ("versionId")
+ String versionId,
+ @ApiParam(value = "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("/")
+ @ApiOperation(value = "List vendor license key group limits",
+ response = LimitEntityDto.class,
+ responseContainer = "List")
+ Response listLimits(
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
+ @ApiParam(value = "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}")
+ @ApiOperation(value = "Update vendor license key group limit")
+ Response updateLimit(@Valid LimitRequestDto request,
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId")
+ String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam
+ ("versionId")
+ String versionId,
+ @ApiParam(value = "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}")
+ @ApiOperation(value = "Get vendor entitlement pool limit",
+ response = LimitEntityDto.class)
+ Response getLimit(
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
+ @ApiParam(value = "Vendor license model License Key Group") @PathParam
+ ("licenseKeyGroupId") String entitlementPoolId,
+ @ApiParam(value = "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}")
+ @ApiOperation(value = "Delete vendor license key group limit")
+ Response deleteLimit(
+ @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId,
+ @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId,
+ @ApiParam(value = "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/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
new file mode 100644
index 0000000000..da7852da2c
--- /dev/null
+++ 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
@@ -0,0 +1,13 @@
+package org.openecomp.sdcrests.vendorlicense.rest.mapping;
+
+public class LimitCreationDto {
+ private String limitId;
+
+ public String getLimitId() {
+ return 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/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 c9f4ab894b..d35c06c30d 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
@@ -47,7 +47,9 @@ public class MapEntitlementPoolEntityToEntitlementPoolEntityDto
.applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class));
target.setTime(choiceOrOtherMapper.applyMapping(source.getTime(), ChoiceOrOtherDto.class));
target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
-
target.setReferencingFeatureGroups(source.getReferencingFeatureGroups());
+
+ 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/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 fe626e374c..5442e1af61 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
@@ -45,7 +45,8 @@ public class MapEntitlementPoolRequestDtoToEntitlementPoolEntity
target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther()
.applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class));
target.setTime(choiceOrOtherMapper.applyMapping(source.getTime(), ChoiceOrOther.class));
-
target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
+ 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 9875a332bd..dedc2a01f0 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
@@ -31,5 +31,6 @@ public class MapFeatureGroupDescriptorDtoToFeatureGroupEntity
target.setName(source.getName());
target.setDescription(source.getDescription());
target.setPartNumber(source.getPartNumber());
+ target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
}
-}
+} \ No newline at end of file
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..ce69384f41 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
@@ -31,5 +31,6 @@ public class MapFeatureGroupEntityToFeatureGroupDescriptorDto
target.setName(source.getName());
target.setDescription(source.getDescription());
target.setPartNumber(source.getPartNumber());
+ 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/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
new file mode 100644
index 0000000000..6883f3e48c
--- /dev/null
+++ 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
@@ -0,0 +1,12 @@
+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());
+ }
+}
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
new file mode 100644
index 0000000000..9678f927b0
--- /dev/null
+++ 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
@@ -0,0 +1,23 @@
+package org.openecomp.sdcrests.vendorlicense.rest.mapping;
+
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto;
+import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto;
+
+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() != null ? source.getMetric().name() : null);
+ target.setAggregationFunction(source.getAggregationFunction() != null ? source
+ .getAggregationFunction().name() : null);
+ target.setTime(source.getTime() != null ? source.getTime().name() : null);
+ 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
new file mode 100644
index 0000000000..7f48ece1cf
--- /dev/null
+++ 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
@@ -0,0 +1,75 @@
+package org.openecomp.sdcrests.vendorlicense.rest.mapping;
+
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerServiceName;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
+import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder;
+import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.ImageErrorBuilder;
+import org.openecomp.sdcrests.mapping.MappingBase;
+import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitType;
+
+
+public class MapLimitRequestDtoToLimitEntity extends MappingBase<LimitRequestDto, LimitEntity> {
+ @Override
+ public void doMapping(LimitRequestDto source, LimitEntity target) {
+ target.setName(source.getName());
+ target.setDescription(source.getDescription());
+ try {
+ LimitType type = LimitType.valueOf(source.getType());
+ target.setType(type);
+ }
+ catch (IllegalArgumentException exception) {
+ throwInvalidValueError("type", VendorLicenseErrorCodes.LIMIT_INVALID_TYPE);
+ }
+
+ try {
+ EntitlementMetric metric = EntitlementMetric.valueOf(source.getMetric());
+ target.setMetric(metric);
+ }
+ catch (IllegalArgumentException exception) {
+ throwInvalidValueError("metric", VendorLicenseErrorCodes.LIMIT_INVALID_METRIC);
+ }
+
+ try {
+ AggregationFunction function = source.getAggregationFunction() != null ?
+ AggregationFunction.valueOf(source.getAggregationFunction()) : null;
+ target.setAggregationFunction(function);
+ }
+ catch (IllegalArgumentException exception) {
+ throwInvalidValueError("aggregationFunction",
+ VendorLicenseErrorCodes.LIMIT_INVALID_AGGREGATIONFUNCTION);
+ }
+
+ try {
+ EntitlementTime time = source.getTime() != null ?
+ EntitlementTime.valueOf(source.getTime()) : null;
+ target.setTime(time);
+ }
+ catch (IllegalArgumentException exception) {
+ throwInvalidValueError("time", VendorLicenseErrorCodes.LIMIT_INVALID_TIME);
+ }
+
+ target.setValue(source.getValue());
+ target.setUnit(source.getUnit());
+
+ }
+
+ private void throwInvalidValueError(String attribute, String vendorLicenseErrorCode) {
+ ErrorCode errorCode = LimitErrorBuilder.getInvalidValueErrorBuilder(attribute,
+ vendorLicenseErrorCode);
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message() );
+ 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/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
new file mode 100644
index 0000000000..3a08822048
--- /dev/null
+++ 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
@@ -0,0 +1,178 @@
+package org.openecomp.sdcrests.vendorlicense.rest.services;
+
+
+import org.openecomp.sdc.logging.context.MdcUtil;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.types.LoggerServiceName;
+import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.vendorlicense.rest.EntitlementPoolLimits;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.LimitCreationDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitCreationDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitRequestDtoToLimitEntity;
+import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto;
+import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto;
+import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
+import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+
+@Named
+@Service("entitlementPoolLimits")
+@Scope(value = "prototype")
+public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ @Autowired
+ private VendorLicenseManager vendorLicenseManager;
+
+ @Override
+ public Response createLimit(LimitRequestDto request,
+ String vlmId,
+ String versionId,
+ String entitlementPoolId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId);
+
+ MdcUtil.initMdc(LoggerServiceName.Create_LIMIT.toString());
+ vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
+ (versionId), entitlementPoolId), user);
+
+ LimitEntity limitEntity =
+ new MapLimitRequestDtoToLimitEntity()
+ .applyMapping(request, LimitEntity.class);
+ limitEntity.setEpLkgId(entitlementPoolId);
+ limitEntity.setVendorLicenseModelId(vlmId);
+
+ LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity, user);
+ MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto();
+ LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto
+ .class);
+
+ /*StringWrapperResponse result =
+ createdLimit != null ? new StringWrapperResponse(createdLimit.getId())
+ : null;*/
+
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId);
+
+ //return Response.ok(result).build();
+ return Response.ok(createdLimitDto != null ? createdLimitDto : null)
+ .build();
+ }
+
+ @Override
+ public Response listLimits(String vlmId, String versionId, String entitlementPoolId, String
+ user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId);
+
+ MdcUtil.initMdc(LoggerServiceName.List_EP.toString());
+ vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
+ (versionId), entitlementPoolId), user);
+
+ Collection<LimitEntity> limits =
+ vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), entitlementPoolId, user);
+
+ GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>();
+ MapLimitEntityToLimitDto outputMapper =
+ new MapLimitEntityToLimitDto();
+ for (LimitEntity limit : limits) {
+ result.add(outputMapper.applyMapping(limit, LimitEntityDto.class));
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId);
+
+ return Response.ok(result).build();
+ }
+
+ @Override
+ public Response getLimit( String vlmId, String versionId, String entitlementPoolId,
+ String limitId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId,
+ limitId);
+
+ MdcUtil.initMdc(LoggerServiceName.Get_LIMIT.toString());
+
+ vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
+ (versionId), entitlementPoolId), user);
+ LimitEntity epInput = new LimitEntity();
+ epInput.setVendorLicenseModelId(vlmId);
+ epInput.setVersion(Version.valueOf(versionId));
+ epInput.setEpLkgId(entitlementPoolId);
+ epInput.setId(limitId);
+ LimitEntity limit = vendorLicenseManager.getLimit(epInput, user);
+
+ LimitEntityDto entitlementPoolEntityDto = limit == null ? null :
+ new MapLimitEntityToLimitDto()
+ .applyMapping(limit, LimitEntityDto.class);
+
+ mdcDataDebugMessage.debugExitMessage("VLM id, EP id, Limit Id", vlmId, entitlementPoolId,
+ limitId);
+
+ return Response.ok(entitlementPoolEntityDto).build();
+ }
+
+ @Override
+ public Response updateLimit(LimitRequestDto request,
+ String vlmId,
+ String versionId,
+ String entitlementPoolId,
+ String limitId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id",
+ limitId);
+
+ MdcUtil.initMdc(LoggerServiceName.Update_LIMIT.toString());
+
+ vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
+ (versionId), entitlementPoolId), user);
+
+ LimitEntity limitEntity =
+ new MapLimitRequestDtoToLimitEntity()
+ .applyMapping(request, LimitEntity.class);
+ limitEntity.setEpLkgId(entitlementPoolId);
+ limitEntity.setVendorLicenseModelId(vlmId);
+ limitEntity.setId(limitId);
+
+ vendorLicenseManager.updateLimit(limitEntity, user);
+
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP id", entitlementPoolId, "limit Id",
+ limitId);
+
+ 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) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId, entitlementPoolId, limitId);
+
+ MdcUtil.initMdc(LoggerServiceName.Delete_LIMIT.toString());
+ vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, Version.valueOf
+ (versionId), entitlementPoolId), user);
+
+ LimitEntity limitInput = new LimitEntity();
+ limitInput.setVendorLicenseModelId(vlmId);
+ limitInput.setEpLkgId(entitlementPoolId);
+ limitInput.setId(limitId);
+ vendorLicenseManager.deleteLimit(limitInput, user);
+
+ mdcDataDebugMessage.debugExitMessage("VLM id, Verison Id, EP id, Limit Id", vlmId, versionId, entitlementPoolId, limitId);
+
+ 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/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
new file mode 100644
index 0000000000..aabba71a5c
--- /dev/null
+++ 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
@@ -0,0 +1,179 @@
+package org.openecomp.sdcrests.vendorlicense.rest.services;
+
+import org.openecomp.sdc.logging.context.MdcUtil;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.types.LoggerServiceName;
+import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.vendorlicense.rest.LicenseKeyGroupLimits;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.LimitCreationDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitCreationDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitDto;
+import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitRequestDtoToLimitEntity;
+import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto;
+import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto;
+import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
+import org.openecomp.sdcrests.wrappers.StringWrapperResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
+
+@Named
+@Service("licenseKeyGroupLimits")
+@Scope(value = "prototype")
+public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ @Autowired
+ private VendorLicenseManager vendorLicenseManager;
+
+ @Override
+ public Response createLimit(LimitRequestDto request,
+ String vlmId,
+ String versionId,
+ String licenseKeyGroupId,
+ String user) {
+
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId);
+
+ MdcUtil.initMdc(LoggerServiceName.Create_LIMIT.toString());
+ vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
+ (versionId), licenseKeyGroupId), user);
+
+ LimitEntity limitEntity =
+ new MapLimitRequestDtoToLimitEntity()
+ .applyMapping(request, LimitEntity.class);
+ limitEntity.setEpLkgId(licenseKeyGroupId);
+ limitEntity.setVendorLicenseModelId(vlmId);
+
+ LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity, user);
+ MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto();
+ LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto
+ .class);
+ /*StringWrapperResponse result =
+ createdLimit != null ? new StringWrapperResponse(createdLimit.getId())
+ : null;*/
+
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId);
+
+ //return Response.ok(result).build();
+ return Response.ok(createdLimitDto != null ? createdLimitDto : null)
+ .build();
+ }
+
+ @Override
+ public Response listLimits(String vlmId, String versionId, String licenseKeyGroupId, String
+ user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId);
+
+ MdcUtil.initMdc(LoggerServiceName.List_EP.toString());
+ vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
+ (versionId), licenseKeyGroupId), user);
+
+ Collection<LimitEntity> limits =
+ vendorLicenseManager.listLimits(vlmId, Version.valueOf(versionId), licenseKeyGroupId, user);
+
+ GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>();
+ MapLimitEntityToLimitDto outputMapper =
+ new MapLimitEntityToLimitDto();
+ for (LimitEntity limit : limits) {
+ result.add(outputMapper.applyMapping(limit, LimitEntityDto.class));
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId);
+
+ return Response.ok(result).build();
+ }
+
+ @Override
+ public Response updateLimit(LimitRequestDto request,
+ String vlmId,
+ String versionId,
+ String licenseKeyGroupId,
+ String limitId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId, "limit Id",
+ limitId);
+
+ MdcUtil.initMdc(LoggerServiceName.Update_LIMIT.toString());
+
+ vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
+ (versionId), licenseKeyGroupId), user);
+
+ LimitEntity limitEntity =
+ new MapLimitRequestDtoToLimitEntity()
+ .applyMapping(request, LimitEntity.class);
+ limitEntity.setEpLkgId(licenseKeyGroupId);
+ limitEntity.setVendorLicenseModelId(vlmId);
+ limitEntity.setId(limitId);
+
+ vendorLicenseManager.updateLimit(limitEntity, user);
+
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "LKG id", licenseKeyGroupId, "limit Id",
+ limitId);
+
+ 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) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id, Verison Id, LKG id, Limit Id", vlmId, versionId,
+ licenseKeyGroupId, limitId);
+
+ MdcUtil.initMdc(LoggerServiceName.Delete_LIMIT.toString());
+ vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
+ (versionId), licenseKeyGroupId), user);
+
+ LimitEntity limitInput = new LimitEntity();
+ limitInput.setVendorLicenseModelId(vlmId);
+ limitInput.setEpLkgId(licenseKeyGroupId);
+ limitInput.setId(limitId);
+ vendorLicenseManager.deleteLimit(limitInput, user);
+
+ mdcDataDebugMessage.debugExitMessage("VLM id, Verison Id, LKG id, Limit Id", vlmId, versionId,
+ licenseKeyGroupId, limitId);
+
+ return Response.ok().build();
+ }
+
+ @Override
+ public Response getLimit( String vlmId, String versionId, String licenseKeyGroupId,
+ String limitId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id, Limit Id", vlmId, licenseKeyGroupId,
+ limitId);
+
+ MdcUtil.initMdc(LoggerServiceName.Get_LIMIT.toString());
+ vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, Version.valueOf
+ (versionId), licenseKeyGroupId), user);
+ LimitEntity epInput = new LimitEntity();
+ epInput.setVendorLicenseModelId(vlmId);
+ epInput.setVersion(Version.valueOf(versionId));
+ epInput.setEpLkgId(licenseKeyGroupId);
+ epInput.setId(limitId);
+ LimitEntity limit = vendorLicenseManager.getLimit(epInput, user);
+
+ LimitEntityDto entitlementPoolEntityDto = limit == null ? null :
+ new MapLimitEntityToLimitDto()
+ .applyMapping(limit, LimitEntityDto.class);
+
+ mdcDataDebugMessage.debugExitMessage("VLM id, LKG id, Limit Id", vlmId, licenseKeyGroupId,
+ limitId);
+
+ return Response.ok(entitlementPoolEntityDto).build();
+ }
+}