Loading pom.xml +1 −1 Changes for pom.xml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ <dependency> <groupId>org.etsi.osl.hypo.api</groupId> <artifactId>tmf.schema</artifactId> <version>2.7.2</version> <version>2.8.0</version> </dependency> <dependency> Loading src/main/java/org/etsi/osl/hypo/api/tmf/common/api/constants/AlarmLogsConstants.java +4 −0 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/common/api/constants/AlarmLogsConstants.java: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,10 @@ public final class AlarmLogsConstants { "POST Service Request failed. Rules Execution Error"; public static final String PATCH_SERVICE_REQUEST_ALARM_LOG = "PATCH Service Request failed."; public static final String POST_SERVICE_ORDER_FAILED = "POST Service Order Request Failed."; public static final String POST_REQUEST_FAILED = "POST Request Failed."; public static final String GET_REQUEST_FAILED = "GET Request Failed."; public static final String PATCH_REQUEST_FAILED = "GET Request Failed."; public static final String DELETE_REQUEST_FAILED = "GET Request Failed."; public static final String KAFKA_SERVICE_UPDATE_MESSAGE_ALARM_LOG = "KAFKA Service Update Message Failure for service id"; Loading src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/rest/ServiceSpecificationResource.java +6 −8 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/rest/ServiceSpecificationResource.java: 6 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ public class ServiceSpecificationResource { @Valid ServiceSpecificationCreateRequest serviceSpecificationCreateRequest) { logger.debug("Request : " + serviceSpecificationCreateRequest.toString()); ServiceSpecification serviceSpecification = serviceSpecificationService.getResponseFromCreateRequest(serviceSpecificationCreateRequest); serviceSpecificationService.responseFromCreateRequest(serviceSpecificationCreateRequest); return Response.ok(serviceSpecification).status(Response.Status.CREATED).build(); } Loading @@ -106,8 +106,7 @@ public class ServiceSpecificationResource { @Schema(implementation = ServiceSpecification.class, type = SchemaType.ARRAY))) public Response getAll(@RestQuery String fields, @Context UriInfo uriInfo) { Map<String, String> criteriaParams = UtilService.getRequestedCriteriaForFiltering(uriInfo); return Response.ok( serviceSpecificationService.getResponseForGetAllRequest(fields, criteriaParams)) return Response.ok(serviceSpecificationService.responseForGetAllRequest(fields, criteriaParams)) .build(); } Loading @@ -128,8 +127,7 @@ public class ServiceSpecificationResource { public Response getAllWithPeeredData(@RestQuery String fields, @Context UriInfo uriInfo) { Map<String, String> criteriaParams = UtilService.getRequestedCriteriaForFiltering(uriInfo); Set<ServiceSpecificationWithPeeredInfo> responseForGetAllRequestWithPeeringInfo = serviceSpecificationService.getResponseForGetAllRequestWithPeeringInfo( fields, criteriaParams); serviceSpecificationService.responseForGetAllRequestWithPeeringInfo(fields, criteriaParams); return Response.ok(responseForGetAllRequestWithPeeringInfo).build(); } Loading Loading @@ -158,7 +156,7 @@ public class ServiceSpecificationResource { logger.info("Get service specification with id : " + id); Map<String, String> criteriaParams = UtilService.getRequestedCriteriaForFiltering(uriInfo); ServiceSpecification serviceSpecification = serviceSpecificationService.getResponseFromGetRequest(id, fields, criteriaParams); serviceSpecificationService.responseFromGetRequest(id, fields, criteriaParams); return Response.ok(serviceSpecification).build(); } Loading Loading @@ -197,7 +195,7 @@ public class ServiceSpecificationResource { logger.info("Update service specification with id : " + id); logger.debugf("Request : " + specs.toString()); ServiceSpecification serviceSpecification = serviceSpecificationService.getResponseFromUpdateRequest(specs, id); serviceSpecificationService.responseFromUpdateRequest(specs, id); return Response.ok(serviceSpecification).build(); } Loading Loading @@ -228,7 +226,7 @@ public class ServiceSpecificationResource { mediaType = APPLICATION_JSON, schema = @Schema(implementation = ErrorMessage.class))) public Response delete(@RestPath String id) { serviceSpecificationService.getResponseFromDeleteRequest(id); serviceSpecificationService.responseFromDeleteRequest(id); logger.info("Successful delete service specification with id : " + id); return Response.noContent().build(); } Loading src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/services/ServiceCatalogService.java +85 −16 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/services/ServiceCatalogService.java: 85 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ package org.etsi.osl.hypo.api.tmf.services.catalog.api.services; import static org.etsi.osl.hypo.api.tmf.ServiceCategoriesConstants.FIVE_G_SERVICES; import static org.etsi.osl.hypo.api.tmf.ServiceCategoriesConstants.K8S_SERVICES; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.DELETE_REQUEST_FAILED; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.GET_REQUEST_FAILED; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.PATCH_REQUEST_FAILED; import jakarta.enterprise.context.ApplicationScoped; import jakarta.transaction.Transactional; Loading @@ -13,10 +16,14 @@ import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants; import org.etsi.osl.hypo.api.tmf.common.api.model.RelatedPartyDTO; import org.etsi.osl.hypo.api.tmf.common.api.repository.RelatedPartyRepository; import org.etsi.osl.hypo.api.tmf.common.api.services.UtilService; import org.etsi.osl.hypo.api.tmf.common.exception.DuplicateKeyException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotFoundException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotPersistedException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotUpdatedException; import org.etsi.osl.hypo.api.tmf.common.exception.ServiceNotFoundException; import org.etsi.osl.hypo.api.tmf.common.model.BaseEntity; import org.etsi.osl.hypo.api.tmf.common.schema.RelatedPartyEntity; Loading Loading @@ -47,7 +54,7 @@ public class ServiceCatalogService { private static final Logger logger = Logger.getLogger(ServiceCatalogService.class); private static final String ALREADY_EXISTS = "' already exists"; private static final String ALREADY_EXISTS = " already exists"; public ServiceCatalogService( ServiceCatalogApiEntityToResponseMapper serviceCatalogApiEntityToResponseMapper, Loading @@ -68,6 +75,7 @@ public class ServiceCatalogService { @Transactional public ServiceCatalog responseFromCreateRequest(ServiceCatalogCreateRequest request) { try { ServiceCatalogEntity serviceCatalogEntity = serviceCatalogApiRequestToEntityMapper.serviceCatalogueDtoToEntity(request); Set<String> categoryIds = Loading @@ -81,7 +89,18 @@ public class ServiceCatalogService { ServiceCatalogEntity createdEntity = createServiceCatalogEntity(serviceCatalogEntity, categoryIds, partyIds); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO(createdEntity); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO( createdEntity); } catch (DuplicateKeyException e) { logger.errorf(e, String.join(" ", AlarmLogsConstants.POST_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String error = String.format("Service Catalog Persistence with name %s failed", request.getName()); logger.errorf(e, error); logger.error(String.join(" ", AlarmLogsConstants.POST_REQUEST_FAILED, error)); throw new EntityNotPersistedException(error); } } public ServiceCatalog findOrCreateCatalog(ServiceCatalogCreateRequest request) { Loading @@ -103,6 +122,7 @@ public class ServiceCatalogService { @Transactional public List<ServiceCatalog> responseFromGetAllRequest(String fields, Map<String, String> params) { try { return findAllCatalogs(params).stream() .map( serviceCatalogEntity -> Loading @@ -111,33 +131,70 @@ public class ServiceCatalogService { serviceCatalogEntity), fields)) .toList(); } catch (Exception e) { logger.errorf(e, "responseForGetAllRequest failed with query params %s", params); String message = String.join("", GET_REQUEST_FAILED, " Failed to fetch Service Catalogs"); logger.error(message); throw new EntityNotFoundException(message); } } @Transactional public ServiceCatalog responseFromGetRequest( String serviceCatalogueId, String fields, Map<String, String> params) { try { ServiceCatalogEntity serviceCatalogEntity = getByIdAndCriteria(serviceCatalogueId, fields, params); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO( serviceCatalogEntity); } catch (EntityNotFoundException e) { logger.error(String.join(" ", GET_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { logger.errorf(e, GET_REQUEST_FAILED); throw new EntityNotFoundException( String.join( " ", GET_REQUEST_FAILED, " exception class type: ", e.getClass().getSimpleName())); } } public ServiceCatalog responseFromUpdateRequest( ServiceCatalogUpdateRequest newCatalogue, String serviceCatalogueId) { ServiceCatalogUpdateRequest newCatalogue, String serviceCatalogId) { try { ServiceCatalogEntity serviceCatalogEntity = serviceCatalogApiRequestToEntityMapper.serviceCatalogueDtoToEntity(newCatalogue); Set<String> serviceCategoryIds = newCatalogue.getServiceCategories().stream() .map(ServiceCategoryRef::getId) .collect(Collectors.toSet()); ServiceCatalogEntity updatedEntity = updateServiceCatalog(serviceCatalogueId, serviceCatalogEntity, serviceCategoryIds); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO(updatedEntity); updateServiceCatalog(serviceCatalogId, serviceCatalogEntity, serviceCategoryIds); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO( updatedEntity); } catch (ServiceNotFoundException e) { logger.errorf(String.join(" ", PATCH_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to update Service Catalog with id: %s", serviceCatalogId); logger.errorf(e, notUpdatedMessage); logger.error(String.join(" ", PATCH_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } public void responseFromDeleteRequest(String serviceCatalogueId) { deleteServiceCatalog(serviceCatalogueId); public void responseFromDeleteRequest(String id) { try { this.deleteServiceCatalog(id); } catch (EntityNotFoundException e) { logger.errorf(String.join(" ", DELETE_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to DELETE Catalog with id: %s", id); logger.errorf(e, notUpdatedMessage); logger.error(String.join("", DELETE_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } @Transactional Loading Loading @@ -177,7 +234,7 @@ public class ServiceCatalogService { if (serviceCatalogue.isPresent()) { return serviceCatalogue.get(); } throw new ServiceNotFoundException("Service Catalogue with id " + id + " not found"); throw new EntityNotFoundException("Service Catalogue with id " + id + " not found"); } @Transactional Loading Loading @@ -296,7 +353,7 @@ public class ServiceCatalogService { @Transactional public void removeServiceCatalogsByPartyId(String relatedPartyId) { // find serviceCatalogs by party Id // find serviceCatalogs by party id List<ServiceCatalogEntity> serviceCatalogsByPartyId = serviceCatalogRepository.findCatalogsByRelatedPartyId(relatedPartyId); Loading @@ -314,7 +371,7 @@ public class ServiceCatalogService { * @param relatedPartyId: the organization/individual/party id related to the catalogs */ public void cleanUpServiceCatalogsByPartyID(String relatedPartyId) { // find serviceCatalogs by party Id // find serviceCatalogs by party id CatalogAndCategoryDeletionIds catalogAndCategoryDeletionIds = extractCatalogsAndCategoryIdsForDeletions(relatedPartyId); // remove catalogs Loading Loading @@ -371,15 +428,15 @@ public class ServiceCatalogService { } @Transactional public ServiceCatalogEntity deleteServiceCatalog(String id) { public void deleteServiceCatalog(String id) { ServiceCatalogEntity serviceCatalogEntity = this.getServiceCatalogEntity(id); serviceCatalogRepository.delete(serviceCatalogEntity); return serviceCatalogEntity; } @Transactional public ServiceCatalogEntity updateServiceCatalog( String id, ServiceCatalogEntity newServiceCatalogue, Set<String> serviceCategoryIds) { try { ServiceCatalogEntity serviceCatalog = checkIfNameAndIdAlreadyExists(id, newServiceCatalogue); serviceCatalogUpdateEntityMapper.serviceCatalogEntityUpdate( newServiceCatalogue, serviceCatalog); Loading @@ -393,15 +450,26 @@ public class ServiceCatalogService { serviceCatalog.getServiceCategories().addAll(serviceCategories); return serviceCatalog; } catch (DuplicateKeyException | EntityNotFoundException | ServiceNotFoundException e) { String notFoundMessage = String.format("Failed to get Specification with id: %s", id); logger.errorf(e, notFoundMessage); logger.errorf(String.join(" ", PATCH_REQUEST_FAILED, notFoundMessage), id); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to update Specification with id: %s", id); logger.errorf(e, notUpdatedMessage); logger.error(String.join(" ", PATCH_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } private void checkIfServiceCatalogueExists(ServiceCatalogEntity serviceCatalogue) { if (serviceCatalogExistsById(serviceCatalogue.getId())) { throw new DuplicateKeyException( "Service Catalogue with id '" + serviceCatalogue.getId() + ALREADY_EXISTS); "Service Catalogue with id: " + serviceCatalogue.getId() + ALREADY_EXISTS); } else if (serviceCatalogExistsByName(serviceCatalogue.getName())) { throw new DuplicateKeyException( "Service Catalogue with name '" + serviceCatalogue.getName() + ALREADY_EXISTS); "Service Catalogue with name:" + serviceCatalogue.getName() + ALREADY_EXISTS); } } Loading @@ -416,7 +484,8 @@ public class ServiceCatalogService { } return serviceCatalogue.get(); } throw new ServiceNotFoundException("Service Catalogue with id '" + id + "' not found"); throw new EntityNotFoundException( String.format("Service Catalogue with id :%s was not found", id)); } private boolean serviceCatalogExistsById(String id) { Loading src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/services/ServiceCategoryService.java +62 −6 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/services/ServiceCategoryService.java: 62 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ package org.etsi.osl.hypo.api.tmf.services.catalog.api.services; import static org.etsi.osl.hypo.api.tmf.ServiceCategoriesConstants.FIVE_G_SERVICES; import static org.etsi.osl.hypo.api.tmf.ServiceCategoriesConstants.K8S_SERVICES; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.DELETE_REQUEST_FAILED; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.GET_REQUEST_FAILED; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.PATCH_REQUEST_FAILED; import jakarta.enterprise.context.ApplicationScoped; import jakarta.transaction.Transactional; Loading @@ -11,8 +14,12 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants; import org.etsi.osl.hypo.api.tmf.common.api.services.UtilService; import org.etsi.osl.hypo.api.tmf.common.exception.DuplicateKeyException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotFoundException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotPersistedException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotUpdatedException; import org.etsi.osl.hypo.api.tmf.common.exception.ServiceNotFoundException; import org.etsi.osl.hypo.api.tmf.common.model.BaseEntity; import org.etsi.osl.hypo.api.tmf.services.catalog.api.mapper.ServiceCatalogApiEntityToResponseMapper; Loading Loading @@ -41,7 +48,7 @@ public class ServiceCategoryService { private static final Logger logger = Logger.getLogger(ServiceCategoryService.class); private static final String ALREADY_EXISTS = "' already exists"; private static final String ALREADY_EXISTS = " already exists"; public ServiceCategoryService( ServiceCatalogApiEntityToResponseMapper serviceCatalogueApiEntityToResponseMapper, Loading @@ -59,6 +66,7 @@ public class ServiceCategoryService { } public ServiceCategory responseFromCreateRequest(ServiceCategoryCreateRequest request) { try { ServiceCategoryEntity serviceCategoryEntity = serviceCatalogueApiRequestToEntityMapper.serviceCategoryDtoToEntity(request); Set<String> candidateIds = Loading @@ -70,6 +78,16 @@ public class ServiceCategoryService { createServiceCategory(serviceCategoryEntity, candidateIds); return serviceCatalogueApiEntityToResponseMapper.serviceCategoryEntityToResponseDTO( createdCategoryEntity); } catch (DuplicateKeyException e) { logger.error(String.join(" ", AlarmLogsConstants.POST_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String error = String.format("Service Category Persistence with name %s failed", request.getName()); logger.errorf(e, error); logger.error(String.join(" ", AlarmLogsConstants.POST_REQUEST_FAILED, error)); throw new EntityNotPersistedException(error); } } public ServiceCategory findOrCreateCategory(ServiceCategoryCreateRequest request) { Loading @@ -88,14 +106,25 @@ public class ServiceCategoryService { public ServiceCategory responseFromGetRequest( String serviceCategoryId, String fields, Map<String, String> params) { try { ServiceCategoryEntity createdCategoryEntity = getByIdAndCriteria(serviceCategoryId, fields, params); this.getByIdAndCriteria(serviceCategoryId, fields, params); return serviceCatalogueApiEntityToResponseMapper.serviceCategoryEntityToResponseDTO( createdCategoryEntity); } catch (EntityNotFoundException e) { logger.error(String.join(" ", GET_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { logger.errorf(e, GET_REQUEST_FAILED); throw new EntityNotFoundException( String.join( " ", GET_REQUEST_FAILED, " exception class type: ", e.getClass().getSimpleName())); } } public ServiceCategory responseFromUpdateRequest( ServiceCategoryUpdateRequest serviceCategoryUpdateRequest, String id) { try { ServiceCategoryEntity newServiceCategory = serviceCatalogueApiRequestToEntityMapper.serviceCategoryDtoToEntity( serviceCategoryUpdateRequest); Loading @@ -109,14 +138,35 @@ public class ServiceCategoryService { updateServiceCategory(id, newServiceCategory, serviceCandidateIds); return serviceCatalogueApiEntityToResponseMapper.serviceCategoryEntityToResponseDTO( updatedCategoryEntity); } catch (ServiceNotFoundException e) { logger.errorf(String.join(" ", PATCH_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to update Service Category with id: %s", id); logger.errorf(e, notUpdatedMessage); logger.error(String.join(" ", PATCH_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } public void responseFromDeleteRequest(String serviceCategoryId) { deleteServiceCategory(serviceCategoryId); try { this.deleteServiceCategory(serviceCategoryId); } catch (ServiceNotFoundException e) { logger.errorf(String.join(" ", DELETE_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to DELETE Service Category with id: %s", serviceCategoryId); logger.errorf(e, notUpdatedMessage); logger.error(String.join("", DELETE_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } public List<ServiceCategory> responseFromGetAllRequest( String fields, Map<String, String> params) { try { return findAllCategories(params).stream() .map( serviceCategoryEntity -> Loading @@ -125,6 +175,12 @@ public class ServiceCategoryService { serviceCategoryEntity), fields)) .toList(); } catch (Exception e) { logger.errorf(e, "responseForGetAllRequest failed with query params %s", params); String message = String.join("", GET_REQUEST_FAILED, " Failed to fetch Service Categories"); logger.error(message); throw new EntityNotFoundException(message); } } @Transactional Loading @@ -145,7 +201,7 @@ public class ServiceCategoryService { if (serviceCategories.isEmpty()) { String notFoundMessage = String.format("Service Category with id %s and the above criteria not found", id); throw new ServiceNotFoundException(notFoundMessage); throw new EntityNotFoundException(notFoundMessage); } ServiceCategoryEntity serviceCategory = serviceCategories.get(0); Loading Loading @@ -341,10 +397,10 @@ public class ServiceCategoryService { private void checkIfServiceCategoryExists(ServiceCategoryEntity serviceCategory) { if (checkServiceCategoryExistenceById(serviceCategory.getId())) { throw new DuplicateKeyException( "Service Category with id '" + serviceCategory.getId() + ALREADY_EXISTS); "Service Category with id:" + serviceCategory.getId() + ALREADY_EXISTS); } else if (checkServiceCategoryExistenceByName(serviceCategory.getName())) { throw new DuplicateKeyException( "Service Category with name '" + serviceCategory.getName() + ALREADY_EXISTS); "Service Category with name:" + serviceCategory.getName() + ALREADY_EXISTS); } } Loading Loading
pom.xml +1 −1 Changes for pom.xml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ <dependency> <groupId>org.etsi.osl.hypo.api</groupId> <artifactId>tmf.schema</artifactId> <version>2.7.2</version> <version>2.8.0</version> </dependency> <dependency> Loading
src/main/java/org/etsi/osl/hypo/api/tmf/common/api/constants/AlarmLogsConstants.java +4 −0 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/common/api/constants/AlarmLogsConstants.java: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,10 @@ public final class AlarmLogsConstants { "POST Service Request failed. Rules Execution Error"; public static final String PATCH_SERVICE_REQUEST_ALARM_LOG = "PATCH Service Request failed."; public static final String POST_SERVICE_ORDER_FAILED = "POST Service Order Request Failed."; public static final String POST_REQUEST_FAILED = "POST Request Failed."; public static final String GET_REQUEST_FAILED = "GET Request Failed."; public static final String PATCH_REQUEST_FAILED = "GET Request Failed."; public static final String DELETE_REQUEST_FAILED = "GET Request Failed."; public static final String KAFKA_SERVICE_UPDATE_MESSAGE_ALARM_LOG = "KAFKA Service Update Message Failure for service id"; Loading
src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/rest/ServiceSpecificationResource.java +6 −8 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/rest/ServiceSpecificationResource.java: 6 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ public class ServiceSpecificationResource { @Valid ServiceSpecificationCreateRequest serviceSpecificationCreateRequest) { logger.debug("Request : " + serviceSpecificationCreateRequest.toString()); ServiceSpecification serviceSpecification = serviceSpecificationService.getResponseFromCreateRequest(serviceSpecificationCreateRequest); serviceSpecificationService.responseFromCreateRequest(serviceSpecificationCreateRequest); return Response.ok(serviceSpecification).status(Response.Status.CREATED).build(); } Loading @@ -106,8 +106,7 @@ public class ServiceSpecificationResource { @Schema(implementation = ServiceSpecification.class, type = SchemaType.ARRAY))) public Response getAll(@RestQuery String fields, @Context UriInfo uriInfo) { Map<String, String> criteriaParams = UtilService.getRequestedCriteriaForFiltering(uriInfo); return Response.ok( serviceSpecificationService.getResponseForGetAllRequest(fields, criteriaParams)) return Response.ok(serviceSpecificationService.responseForGetAllRequest(fields, criteriaParams)) .build(); } Loading @@ -128,8 +127,7 @@ public class ServiceSpecificationResource { public Response getAllWithPeeredData(@RestQuery String fields, @Context UriInfo uriInfo) { Map<String, String> criteriaParams = UtilService.getRequestedCriteriaForFiltering(uriInfo); Set<ServiceSpecificationWithPeeredInfo> responseForGetAllRequestWithPeeringInfo = serviceSpecificationService.getResponseForGetAllRequestWithPeeringInfo( fields, criteriaParams); serviceSpecificationService.responseForGetAllRequestWithPeeringInfo(fields, criteriaParams); return Response.ok(responseForGetAllRequestWithPeeringInfo).build(); } Loading Loading @@ -158,7 +156,7 @@ public class ServiceSpecificationResource { logger.info("Get service specification with id : " + id); Map<String, String> criteriaParams = UtilService.getRequestedCriteriaForFiltering(uriInfo); ServiceSpecification serviceSpecification = serviceSpecificationService.getResponseFromGetRequest(id, fields, criteriaParams); serviceSpecificationService.responseFromGetRequest(id, fields, criteriaParams); return Response.ok(serviceSpecification).build(); } Loading Loading @@ -197,7 +195,7 @@ public class ServiceSpecificationResource { logger.info("Update service specification with id : " + id); logger.debugf("Request : " + specs.toString()); ServiceSpecification serviceSpecification = serviceSpecificationService.getResponseFromUpdateRequest(specs, id); serviceSpecificationService.responseFromUpdateRequest(specs, id); return Response.ok(serviceSpecification).build(); } Loading Loading @@ -228,7 +226,7 @@ public class ServiceSpecificationResource { mediaType = APPLICATION_JSON, schema = @Schema(implementation = ErrorMessage.class))) public Response delete(@RestPath String id) { serviceSpecificationService.getResponseFromDeleteRequest(id); serviceSpecificationService.responseFromDeleteRequest(id); logger.info("Successful delete service specification with id : " + id); return Response.noContent().build(); } Loading
src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/services/ServiceCatalogService.java +85 −16 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/services/ServiceCatalogService.java: 85 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ package org.etsi.osl.hypo.api.tmf.services.catalog.api.services; import static org.etsi.osl.hypo.api.tmf.ServiceCategoriesConstants.FIVE_G_SERVICES; import static org.etsi.osl.hypo.api.tmf.ServiceCategoriesConstants.K8S_SERVICES; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.DELETE_REQUEST_FAILED; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.GET_REQUEST_FAILED; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.PATCH_REQUEST_FAILED; import jakarta.enterprise.context.ApplicationScoped; import jakarta.transaction.Transactional; Loading @@ -13,10 +16,14 @@ import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants; import org.etsi.osl.hypo.api.tmf.common.api.model.RelatedPartyDTO; import org.etsi.osl.hypo.api.tmf.common.api.repository.RelatedPartyRepository; import org.etsi.osl.hypo.api.tmf.common.api.services.UtilService; import org.etsi.osl.hypo.api.tmf.common.exception.DuplicateKeyException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotFoundException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotPersistedException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotUpdatedException; import org.etsi.osl.hypo.api.tmf.common.exception.ServiceNotFoundException; import org.etsi.osl.hypo.api.tmf.common.model.BaseEntity; import org.etsi.osl.hypo.api.tmf.common.schema.RelatedPartyEntity; Loading Loading @@ -47,7 +54,7 @@ public class ServiceCatalogService { private static final Logger logger = Logger.getLogger(ServiceCatalogService.class); private static final String ALREADY_EXISTS = "' already exists"; private static final String ALREADY_EXISTS = " already exists"; public ServiceCatalogService( ServiceCatalogApiEntityToResponseMapper serviceCatalogApiEntityToResponseMapper, Loading @@ -68,6 +75,7 @@ public class ServiceCatalogService { @Transactional public ServiceCatalog responseFromCreateRequest(ServiceCatalogCreateRequest request) { try { ServiceCatalogEntity serviceCatalogEntity = serviceCatalogApiRequestToEntityMapper.serviceCatalogueDtoToEntity(request); Set<String> categoryIds = Loading @@ -81,7 +89,18 @@ public class ServiceCatalogService { ServiceCatalogEntity createdEntity = createServiceCatalogEntity(serviceCatalogEntity, categoryIds, partyIds); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO(createdEntity); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO( createdEntity); } catch (DuplicateKeyException e) { logger.errorf(e, String.join(" ", AlarmLogsConstants.POST_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String error = String.format("Service Catalog Persistence with name %s failed", request.getName()); logger.errorf(e, error); logger.error(String.join(" ", AlarmLogsConstants.POST_REQUEST_FAILED, error)); throw new EntityNotPersistedException(error); } } public ServiceCatalog findOrCreateCatalog(ServiceCatalogCreateRequest request) { Loading @@ -103,6 +122,7 @@ public class ServiceCatalogService { @Transactional public List<ServiceCatalog> responseFromGetAllRequest(String fields, Map<String, String> params) { try { return findAllCatalogs(params).stream() .map( serviceCatalogEntity -> Loading @@ -111,33 +131,70 @@ public class ServiceCatalogService { serviceCatalogEntity), fields)) .toList(); } catch (Exception e) { logger.errorf(e, "responseForGetAllRequest failed with query params %s", params); String message = String.join("", GET_REQUEST_FAILED, " Failed to fetch Service Catalogs"); logger.error(message); throw new EntityNotFoundException(message); } } @Transactional public ServiceCatalog responseFromGetRequest( String serviceCatalogueId, String fields, Map<String, String> params) { try { ServiceCatalogEntity serviceCatalogEntity = getByIdAndCriteria(serviceCatalogueId, fields, params); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO( serviceCatalogEntity); } catch (EntityNotFoundException e) { logger.error(String.join(" ", GET_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { logger.errorf(e, GET_REQUEST_FAILED); throw new EntityNotFoundException( String.join( " ", GET_REQUEST_FAILED, " exception class type: ", e.getClass().getSimpleName())); } } public ServiceCatalog responseFromUpdateRequest( ServiceCatalogUpdateRequest newCatalogue, String serviceCatalogueId) { ServiceCatalogUpdateRequest newCatalogue, String serviceCatalogId) { try { ServiceCatalogEntity serviceCatalogEntity = serviceCatalogApiRequestToEntityMapper.serviceCatalogueDtoToEntity(newCatalogue); Set<String> serviceCategoryIds = newCatalogue.getServiceCategories().stream() .map(ServiceCategoryRef::getId) .collect(Collectors.toSet()); ServiceCatalogEntity updatedEntity = updateServiceCatalog(serviceCatalogueId, serviceCatalogEntity, serviceCategoryIds); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO(updatedEntity); updateServiceCatalog(serviceCatalogId, serviceCatalogEntity, serviceCategoryIds); return serviceCatalogApiEntityToResponseMapper.serviceCatalogEntityToResponseDTO( updatedEntity); } catch (ServiceNotFoundException e) { logger.errorf(String.join(" ", PATCH_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to update Service Catalog with id: %s", serviceCatalogId); logger.errorf(e, notUpdatedMessage); logger.error(String.join(" ", PATCH_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } public void responseFromDeleteRequest(String serviceCatalogueId) { deleteServiceCatalog(serviceCatalogueId); public void responseFromDeleteRequest(String id) { try { this.deleteServiceCatalog(id); } catch (EntityNotFoundException e) { logger.errorf(String.join(" ", DELETE_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to DELETE Catalog with id: %s", id); logger.errorf(e, notUpdatedMessage); logger.error(String.join("", DELETE_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } @Transactional Loading Loading @@ -177,7 +234,7 @@ public class ServiceCatalogService { if (serviceCatalogue.isPresent()) { return serviceCatalogue.get(); } throw new ServiceNotFoundException("Service Catalogue with id " + id + " not found"); throw new EntityNotFoundException("Service Catalogue with id " + id + " not found"); } @Transactional Loading Loading @@ -296,7 +353,7 @@ public class ServiceCatalogService { @Transactional public void removeServiceCatalogsByPartyId(String relatedPartyId) { // find serviceCatalogs by party Id // find serviceCatalogs by party id List<ServiceCatalogEntity> serviceCatalogsByPartyId = serviceCatalogRepository.findCatalogsByRelatedPartyId(relatedPartyId); Loading @@ -314,7 +371,7 @@ public class ServiceCatalogService { * @param relatedPartyId: the organization/individual/party id related to the catalogs */ public void cleanUpServiceCatalogsByPartyID(String relatedPartyId) { // find serviceCatalogs by party Id // find serviceCatalogs by party id CatalogAndCategoryDeletionIds catalogAndCategoryDeletionIds = extractCatalogsAndCategoryIdsForDeletions(relatedPartyId); // remove catalogs Loading Loading @@ -371,15 +428,15 @@ public class ServiceCatalogService { } @Transactional public ServiceCatalogEntity deleteServiceCatalog(String id) { public void deleteServiceCatalog(String id) { ServiceCatalogEntity serviceCatalogEntity = this.getServiceCatalogEntity(id); serviceCatalogRepository.delete(serviceCatalogEntity); return serviceCatalogEntity; } @Transactional public ServiceCatalogEntity updateServiceCatalog( String id, ServiceCatalogEntity newServiceCatalogue, Set<String> serviceCategoryIds) { try { ServiceCatalogEntity serviceCatalog = checkIfNameAndIdAlreadyExists(id, newServiceCatalogue); serviceCatalogUpdateEntityMapper.serviceCatalogEntityUpdate( newServiceCatalogue, serviceCatalog); Loading @@ -393,15 +450,26 @@ public class ServiceCatalogService { serviceCatalog.getServiceCategories().addAll(serviceCategories); return serviceCatalog; } catch (DuplicateKeyException | EntityNotFoundException | ServiceNotFoundException e) { String notFoundMessage = String.format("Failed to get Specification with id: %s", id); logger.errorf(e, notFoundMessage); logger.errorf(String.join(" ", PATCH_REQUEST_FAILED, notFoundMessage), id); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to update Specification with id: %s", id); logger.errorf(e, notUpdatedMessage); logger.error(String.join(" ", PATCH_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } private void checkIfServiceCatalogueExists(ServiceCatalogEntity serviceCatalogue) { if (serviceCatalogExistsById(serviceCatalogue.getId())) { throw new DuplicateKeyException( "Service Catalogue with id '" + serviceCatalogue.getId() + ALREADY_EXISTS); "Service Catalogue with id: " + serviceCatalogue.getId() + ALREADY_EXISTS); } else if (serviceCatalogExistsByName(serviceCatalogue.getName())) { throw new DuplicateKeyException( "Service Catalogue with name '" + serviceCatalogue.getName() + ALREADY_EXISTS); "Service Catalogue with name:" + serviceCatalogue.getName() + ALREADY_EXISTS); } } Loading @@ -416,7 +484,8 @@ public class ServiceCatalogService { } return serviceCatalogue.get(); } throw new ServiceNotFoundException("Service Catalogue with id '" + id + "' not found"); throw new EntityNotFoundException( String.format("Service Catalogue with id :%s was not found", id)); } private boolean serviceCatalogExistsById(String id) { Loading
src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/services/ServiceCategoryService.java +62 −6 Changes for src/main/java/org/etsi/osl/hypo/api/tmf/services/catalog/api/services/ServiceCategoryService.java: 62 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ package org.etsi.osl.hypo.api.tmf.services.catalog.api.services; import static org.etsi.osl.hypo.api.tmf.ServiceCategoriesConstants.FIVE_G_SERVICES; import static org.etsi.osl.hypo.api.tmf.ServiceCategoriesConstants.K8S_SERVICES; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.DELETE_REQUEST_FAILED; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.GET_REQUEST_FAILED; import static org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants.PATCH_REQUEST_FAILED; import jakarta.enterprise.context.ApplicationScoped; import jakarta.transaction.Transactional; Loading @@ -11,8 +14,12 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.etsi.osl.hypo.api.tmf.common.api.constants.AlarmLogsConstants; import org.etsi.osl.hypo.api.tmf.common.api.services.UtilService; import org.etsi.osl.hypo.api.tmf.common.exception.DuplicateKeyException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotFoundException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotPersistedException; import org.etsi.osl.hypo.api.tmf.common.exception.EntityNotUpdatedException; import org.etsi.osl.hypo.api.tmf.common.exception.ServiceNotFoundException; import org.etsi.osl.hypo.api.tmf.common.model.BaseEntity; import org.etsi.osl.hypo.api.tmf.services.catalog.api.mapper.ServiceCatalogApiEntityToResponseMapper; Loading Loading @@ -41,7 +48,7 @@ public class ServiceCategoryService { private static final Logger logger = Logger.getLogger(ServiceCategoryService.class); private static final String ALREADY_EXISTS = "' already exists"; private static final String ALREADY_EXISTS = " already exists"; public ServiceCategoryService( ServiceCatalogApiEntityToResponseMapper serviceCatalogueApiEntityToResponseMapper, Loading @@ -59,6 +66,7 @@ public class ServiceCategoryService { } public ServiceCategory responseFromCreateRequest(ServiceCategoryCreateRequest request) { try { ServiceCategoryEntity serviceCategoryEntity = serviceCatalogueApiRequestToEntityMapper.serviceCategoryDtoToEntity(request); Set<String> candidateIds = Loading @@ -70,6 +78,16 @@ public class ServiceCategoryService { createServiceCategory(serviceCategoryEntity, candidateIds); return serviceCatalogueApiEntityToResponseMapper.serviceCategoryEntityToResponseDTO( createdCategoryEntity); } catch (DuplicateKeyException e) { logger.error(String.join(" ", AlarmLogsConstants.POST_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String error = String.format("Service Category Persistence with name %s failed", request.getName()); logger.errorf(e, error); logger.error(String.join(" ", AlarmLogsConstants.POST_REQUEST_FAILED, error)); throw new EntityNotPersistedException(error); } } public ServiceCategory findOrCreateCategory(ServiceCategoryCreateRequest request) { Loading @@ -88,14 +106,25 @@ public class ServiceCategoryService { public ServiceCategory responseFromGetRequest( String serviceCategoryId, String fields, Map<String, String> params) { try { ServiceCategoryEntity createdCategoryEntity = getByIdAndCriteria(serviceCategoryId, fields, params); this.getByIdAndCriteria(serviceCategoryId, fields, params); return serviceCatalogueApiEntityToResponseMapper.serviceCategoryEntityToResponseDTO( createdCategoryEntity); } catch (EntityNotFoundException e) { logger.error(String.join(" ", GET_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { logger.errorf(e, GET_REQUEST_FAILED); throw new EntityNotFoundException( String.join( " ", GET_REQUEST_FAILED, " exception class type: ", e.getClass().getSimpleName())); } } public ServiceCategory responseFromUpdateRequest( ServiceCategoryUpdateRequest serviceCategoryUpdateRequest, String id) { try { ServiceCategoryEntity newServiceCategory = serviceCatalogueApiRequestToEntityMapper.serviceCategoryDtoToEntity( serviceCategoryUpdateRequest); Loading @@ -109,14 +138,35 @@ public class ServiceCategoryService { updateServiceCategory(id, newServiceCategory, serviceCandidateIds); return serviceCatalogueApiEntityToResponseMapper.serviceCategoryEntityToResponseDTO( updatedCategoryEntity); } catch (ServiceNotFoundException e) { logger.errorf(String.join(" ", PATCH_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to update Service Category with id: %s", id); logger.errorf(e, notUpdatedMessage); logger.error(String.join(" ", PATCH_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } public void responseFromDeleteRequest(String serviceCategoryId) { deleteServiceCategory(serviceCategoryId); try { this.deleteServiceCategory(serviceCategoryId); } catch (ServiceNotFoundException e) { logger.errorf(String.join(" ", DELETE_REQUEST_FAILED, e.getMessage())); throw e; } catch (Exception e) { String notUpdatedMessage = String.format("Failed to DELETE Service Category with id: %s", serviceCategoryId); logger.errorf(e, notUpdatedMessage); logger.error(String.join("", DELETE_REQUEST_FAILED, notUpdatedMessage)); throw new EntityNotUpdatedException(notUpdatedMessage); } } public List<ServiceCategory> responseFromGetAllRequest( String fields, Map<String, String> params) { try { return findAllCategories(params).stream() .map( serviceCategoryEntity -> Loading @@ -125,6 +175,12 @@ public class ServiceCategoryService { serviceCategoryEntity), fields)) .toList(); } catch (Exception e) { logger.errorf(e, "responseForGetAllRequest failed with query params %s", params); String message = String.join("", GET_REQUEST_FAILED, " Failed to fetch Service Categories"); logger.error(message); throw new EntityNotFoundException(message); } } @Transactional Loading @@ -145,7 +201,7 @@ public class ServiceCategoryService { if (serviceCategories.isEmpty()) { String notFoundMessage = String.format("Service Category with id %s and the above criteria not found", id); throw new ServiceNotFoundException(notFoundMessage); throw new EntityNotFoundException(notFoundMessage); } ServiceCategoryEntity serviceCategory = serviceCategories.get(0); Loading Loading @@ -341,10 +397,10 @@ public class ServiceCategoryService { private void checkIfServiceCategoryExists(ServiceCategoryEntity serviceCategory) { if (checkServiceCategoryExistenceById(serviceCategory.getId())) { throw new DuplicateKeyException( "Service Category with id '" + serviceCategory.getId() + ALREADY_EXISTS); "Service Category with id:" + serviceCategory.getId() + ALREADY_EXISTS); } else if (checkServiceCategoryExistenceByName(serviceCategory.getName())) { throw new DuplicateKeyException( "Service Category with name '" + serviceCategory.getName() + ALREADY_EXISTS); "Service Category with name:" + serviceCategory.getName() + ALREADY_EXISTS); } } Loading