Commit de23e83e authored by Konstantinos Poulakakis's avatar Konstantinos Poulakakis
Browse files

Add TMF 673 Geographic Address Validation endpoints

parent a61c2ffa
Loading
Loading
Loading
Loading
+42 −40
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.etsi.osl.tmf.gam673.model.GeographicAddress;
import org.etsi.osl.tmf.gam673.model.GeographicSubAddress;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.Set;

@Generated
public interface GeographicAddressManagementApi {
@@ -51,14 +53,7 @@ public interface GeographicAddressManagementApi {
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.POST)
    default ResponseEntity<GeographicAddress> createGeographicAddress(@Parameter(description = "The geographic address to be created", required = true) @Valid @RequestBody GeographicAddress geographicAddress) {
            try {
                return new ResponseEntity<>(getObjectMapper().get().readValue("{  \"@baseType\" : \"@baseType\",  \"validFor\" : {    \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",    \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"  },  \"@type\" : \"@type\",  \"name\" : \"name\",  \"description\" : \"description\",  \"href\" : \"href\",  \"id\" : \"id\",  \"@schemaLocation\" : \"@schemaLocation\",  \"objective\" : [ {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  }, {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  } ]}", GeographicAddress.class), HttpStatus.NOT_IMPLEMENTED);
            } catch (IOException e) {
                log.error("Couldn't serialize response for content type application/json", e);
                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
            }
    }
    ResponseEntity<GeographicAddress> createGeographicAddress(@Parameter(description = "The geographic address to be created", required = true) @Valid @RequestBody GeographicAddress geographicAddress);

    @Operation(summary = "Deletes a 'GeographicAddress' by Id", operationId = "deleteGeographicAddress", description = "", tags={ "GeographicAddress", })
    @ApiResponses(value = {
@@ -74,13 +69,7 @@ public interface GeographicAddressManagementApi {
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.DELETE)
    default ResponseEntity<Void> deleteGeographicAddress(@Parameter(description = "Identifier of the Geographic address", required = true) @PathVariable("id") String id) {
        if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
        } else {
            log.warn("ObjectMapper or HttpServletRequest not configured in default GeographicAddressManagementApi interface so no example is generated");
        }
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
    }
    ResponseEntity<Void> deleteGeographicAddress(@Parameter(description = "Identifier of the Geographic address", required = true) @PathVariable("id") String id);


    @Operation(summary = "List or find 'GeographicAddress' objects", operationId = "listGeographicAddress", description = "" , tags={ "GeographicAddress", })
@@ -97,15 +86,7 @@ public interface GeographicAddressManagementApi {
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.GET)
    default ResponseEntity<List<GeographicAddress>> listGeographicAddress() {
            try {
                return new ResponseEntity<>(getObjectMapper().get().readValue("[ {  \"@baseType\" : \"@baseType\",  \"validFor\" : {    \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",    \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"  },  \"@type\" : \"@type\",  \"name\" : \"name\",  \"description\" : \"description\",  \"href\" : \"href\",  \"id\" : \"id\",  \"@schemaLocation\" : \"@schemaLocation\",  \"objective\" : [ {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  }, {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  } ]}, {  \"@baseType\" : \"@baseType\",  \"validFor\" : {    \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",    \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"  },  \"@type\" : \"@type\",  \"name\" : \"name\",  \"description\" : \"description\",  \"href\" : \"href\",  \"id\" : \"id\",  \"@schemaLocation\" : \"@schemaLocation\",  \"objective\" : [ {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  }, {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  } ]} ]", List.class), HttpStatus.NOT_IMPLEMENTED);
            } catch (IOException e) {
                log.error("Couldn't serialize response for content type application/json", e);
                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
            }

    }
    ResponseEntity<List<GeographicAddress>> listGeographicAddress();


    @Operation(summary = "Updates partially a 'GeographicAddress' by Id", operationId = "patchGeographicAddress", description = "", tags={ "GeographicAddress", })
@@ -122,14 +103,7 @@ public interface GeographicAddressManagementApi {
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.PATCH)
    default ResponseEntity<GeographicAddress> patchGeographicAddress(@Parameter(description = "Identifier of the Geographic address", required = true) @PathVariable("id") String id, @Parameter(description = "The Service Level Specification to be updated", required = true) @Valid @RequestBody GeographicAddress geographicAddress) {
            try {
                return new ResponseEntity<>(getObjectMapper().get().readValue("{  \"@baseType\" : \"@baseType\",  \"validFor\" : {    \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",    \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"  },  \"@type\" : \"@type\",  \"name\" : \"name\",  \"description\" : \"description\",  \"href\" : \"href\",  \"id\" : \"id\",  \"@schemaLocation\" : \"@schemaLocation\",  \"objective\" : [ {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  }, {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  } ]}", GeographicAddress.class), HttpStatus.NOT_IMPLEMENTED);
            } catch (IOException e) {
                log.error("Couldn't serialize response for content type application/json", e);
                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
            }
    }
    ResponseEntity<GeographicAddress> patchGeographicAddress(@Parameter(description = "Identifier of the Geographic address", required = true) @PathVariable("id") String id, @Parameter(description = "The Service Level Specification to be updated", required = true) @Valid @RequestBody GeographicAddress geographicAddress);


    @Operation(summary = "Retrieves a 'GeographicAddress' by Id", operationId = "retrieveGeographicAddress", description = "" , tags={ "GeographicAddress", })
@@ -146,13 +120,41 @@ public interface GeographicAddressManagementApi {
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.GET)
    default ResponseEntity<GeographicAddress> retrieveGeographicAddress() {
            try {
                return new ResponseEntity<>(getObjectMapper().get().readValue("[ {  \"@baseType\" : \"@baseType\",  \"validFor\" : {    \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",    \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"  },  \"@type\" : \"@type\",  \"name\" : \"name\",  \"description\" : \"description\",  \"href\" : \"href\",  \"id\" : \"id\",  \"@schemaLocation\" : \"@schemaLocation\",  \"objective\" : [ {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  }, {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  } ]}, {  \"@baseType\" : \"@baseType\",  \"validFor\" : {    \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\",    \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\"  },  \"@type\" : \"@type\",  \"name\" : \"name\",  \"description\" : \"description\",  \"href\" : \"href\",  \"id\" : \"id\",  \"@schemaLocation\" : \"@schemaLocation\",  \"objective\" : [ {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  }, {    \"@referredType\" : \"@referredType\",    \"href\" : \"href\",    \"id\" : \"id\"  } ]} ]", GeographicAddress.class), HttpStatus.NOT_IMPLEMENTED);
            } catch (IOException e) {
                log.error("Couldn't serialize response for content type application/json", e);
                return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
            }
    }
    ResponseEntity<GeographicAddress> retrieveGeographicAddress(@Parameter(description = "Identifier of the geographic address", required = true) @PathVariable("id") String id);

    @Operation(summary = "Retrieves a 'GeographicSubAddress' by Id", operationId = "retrieveGeographicSubAddress", description = "" , tags={ "GeographicSubAddress", })
    @ApiResponses(value = {
            @ApiResponse(responseCode ="200", description = "Ok" ),
            @ApiResponse(responseCode = "400", description = "Bad Request" ),
            @ApiResponse(responseCode = "401", description = "Unauthorized" ),
            @ApiResponse(responseCode = "403", description = "Forbidden" ),
            @ApiResponse(responseCode = "404", description = "Not Found" ),
            @ApiResponse(responseCode = "405", description = "Method Not allowed" ),
            @ApiResponse(responseCode = "409", description = "Conflict" ),
            @ApiResponse(responseCode = "500", description = "Internal Server Error" ) })
    @RequestMapping(value = "/geographicAddress/{id}/geographicSubAddress",
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.GET)
    ResponseEntity<Set<GeographicSubAddress>> retrieveGeographicSubAddress(
            @Parameter(description = "Identifier of the geographic address", required = true) @PathVariable("id") String id);

    @Operation(summary = "Retrieves a 'GeographicSubAddress' by Id", operationId = "retrieveGeographicSubAddress", description = "" , tags={ "GeographicSubAddress", })
    @ApiResponses(value = {
            @ApiResponse(responseCode ="200", description = "Ok" ),
            @ApiResponse(responseCode = "400", description = "Bad Request" ),
            @ApiResponse(responseCode = "401", description = "Unauthorized" ),
            @ApiResponse(responseCode = "403", description = "Forbidden" ),
            @ApiResponse(responseCode = "404", description = "Not Found" ),
            @ApiResponse(responseCode = "405", description = "Method Not allowed" ),
            @ApiResponse(responseCode = "409", description = "Conflict" ),
            @ApiResponse(responseCode = "500", description = "Internal Server Error" ) })
    @RequestMapping(value = "/geographicAddress/{id}/geographicSubAddress/{id}",
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.GET)
    ResponseEntity<GeographicSubAddress> retrieveGeographicSubAddress(
            @Parameter(description = "Identifier of the geographic address", required = true) @PathVariable("id") String geoAddressId,
            @Parameter(description = "Identifier of the geographic sub address", required = true) @PathVariable("id") String geoSubAddressId);

}
+48 −8
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ package org.etsi.osl.tmf.gam673.api;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.Valid;
import org.etsi.osl.tmf.gam673.model.GeographicAddress;
import org.etsi.osl.tmf.gam673.model.GeographicSubAddress;
import org.etsi.osl.tmf.gam673.reposervices.GeographicAddressManagementService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Set;

@Controller
@RequestMapping("/geographicAddressManagement/v4/")
@@ -48,14 +50,9 @@ public class GeographicAddressManagementApiController implements GeographicAddre
    public ResponseEntity<GeographicAddress> createGeographicAddress(
            @Parameter(description = "The geographic address to be created", required = true) @Valid @RequestBody GeographicAddress geographicAddress
    ) {

        try{

            GeographicAddress c = geographicAddressManagementService.createGeographicAddress(geographicAddress);

            return new ResponseEntity<>(c, HttpStatus.OK);


        } catch (Exception e) {
            log.error(COULD_NOT_SERIALIZE, e);
            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
@@ -76,12 +73,40 @@ public class GeographicAddressManagementApiController implements GeographicAddre

    }

    @PreAuthorize("hasAnyAuthority('ROLE_USER')" )
    @Override
    public ResponseEntity<GeographicAddress> retrieveGeographicAddress(
            @Parameter(description = "Identifier of the geographic address", required = true) @PathVariable("id") String id) {
        try{
            GeographicAddress c = geographicAddressManagementService.findGeographicAddressByUUID(id);

            return new ResponseEntity<>(c, HttpStatus.OK);
        }catch (Exception e){
            log.error(COULD_NOT_SERIALIZE, e);
            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

    @PreAuthorize("hasAnyAuthority('ROLE_USER')" )
    @Override
    public ResponseEntity<Set<GeographicSubAddress>> retrieveGeographicSubAddress(
            @Parameter(description = "Identifier of the geographic address", required = true) @PathVariable("id") String id) {
        try{
            Set<GeographicSubAddress> c = geographicAddressManagementService.findAllGeographicSubAddresses(id);

            return new ResponseEntity<>(c, HttpStatus.OK);
        }catch (Exception e){
            log.error(COULD_NOT_SERIALIZE, e);
            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }


    @PreAuthorize("hasAnyAuthority('ROLE_USER')" )
    @Override
    public ResponseEntity<GeographicAddress> patchGeographicAddress(
            @Parameter(description = "Identifier of the ServiceOrder", required = true) @PathVariable("id") String id,
            @Parameter(description = "The ServiceOrder to be updated", required = true) @Valid @RequestBody GeographicAddress geographicAddress) {
            @Parameter(description = "Identifier of the geographic address", required = true) @PathVariable("id") String id,
            @Parameter(description = "The Geographic Address to be updated", required = true) @Valid @RequestBody GeographicAddress geographicAddress) {
        try{
            GeographicAddress c = geographicAddressManagementService.updateGeographicAddress(id, geographicAddress);

@@ -92,4 +117,19 @@ public class GeographicAddressManagementApiController implements GeographicAddre
        }
    }

    @PreAuthorize("hasAnyAuthority('ROLE_USER')" )
    @Override
    public ResponseEntity<GeographicSubAddress> retrieveGeographicSubAddress(
            @Parameter(description = "Identifier of the geographic address", required = true) @PathVariable("id") String geoAddressId,
            @Parameter(description = "Identifier of the geographic sub address", required = true) @PathVariable("id") String geoSubAddressId){
        try{
            GeographicSubAddress c = geographicAddressManagementService.findGeographicSubAddressByUUID(geoAddressId,geoSubAddressId);

            return new ResponseEntity<>(c, HttpStatus.OK);
        }catch (Exception e){
            log.error(COULD_NOT_SERIALIZE, e);
            return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

}
+121 −0
Original line number Diff line number Diff line
package org.etsi.osl.tmf.gam673.api;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.org.slf4j.internal.Logger;
import com.sun.org.slf4j.internal.LoggerFactory;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.etsi.osl.tmf.gam673.model.GeographicAddressValidation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
import java.util.Optional;

@Generated
public interface GeographicAddressValidationManagementApi {
    Logger log = LoggerFactory.getLogger(GeographicAddressValidationManagementApi.class);

    default Optional<ObjectMapper> getObjectMapper() {
        return Optional.empty();
    }

    default Optional<HttpServletRequest> getRequest() {
        return Optional.empty();
    }

    default Optional<String> getAcceptHeader() {
        return getRequest().map(r -> r.getHeader("Accept"));
    }

    @Operation(summary = "Creates a 'GeographicAddressValidation'", operationId = "createGeographicAddressValidation", description = "", tags={ "geographicAddress", })
    @ApiResponses(value = {
            @ApiResponse(responseCode = "400", description = "Created" ),
            @ApiResponse(responseCode = "400", description = "Bad Request" ),
            @ApiResponse(responseCode = "401", description = "Unauthorized" ),
            @ApiResponse(responseCode = "403", description = "Forbidden" ),
            @ApiResponse(responseCode = "404", description = "Not Found" ),
            @ApiResponse(responseCode = "405", description = "Method Not allowed" ),
            @ApiResponse(responseCode = "409", description = "Conflict" ),
            @ApiResponse(responseCode = "500", description = "Internal Server Error" ) })
    @RequestMapping(value = "/geographicAddressValidation",
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.POST)
    ResponseEntity<GeographicAddressValidation> createGeographicAddressValidation(@Parameter(description = "The geographic address to be created", required = true) @Valid @RequestBody GeographicAddressValidation geographicAddressValidation);

    @Operation(summary = "Deletes a 'GeographicAddressValidation' by Id", operationId = "deleteGeographicAddressValidation", description = "", tags={ "GeographicAddressValidation", })
    @ApiResponses(value = {
            @ApiResponse(responseCode = "204", description = "Deleted" ),
            @ApiResponse(responseCode = "400", description = "Bad Request" ),
            @ApiResponse(responseCode = "401", description = "Unauthorized" ),
            @ApiResponse(responseCode = "403", description = "Forbidden" ),
            @ApiResponse(responseCode = "404", description = "Not Found" ),
            @ApiResponse(responseCode = "405", description = "Method Not allowed" ),
            @ApiResponse(responseCode = "409", description = "Conflict" ),
            @ApiResponse(responseCode = "500", description = "Internal Server Error" ) })
    @RequestMapping(value = "/geographicAddressValidation/{id}",
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.DELETE)
    ResponseEntity<Void> deleteGeographicAddressValidation(@Parameter(description = "Identifier of the Geographic address", required = true) @PathVariable("id") String id);


    @Operation(summary = "List or find 'GeographicAddressValidation' objects", operationId = "listGeographicAddressValidation", description = "" , tags={ "GeographicAddressValidation", })
    @ApiResponses(value = {
            @ApiResponse(responseCode ="200", description = "Ok" ),
            @ApiResponse(responseCode = "400", description = "Bad Request" ),
            @ApiResponse(responseCode = "401", description = "Unauthorized" ),
            @ApiResponse(responseCode = "403", description = "Forbidden" ),
            @ApiResponse(responseCode = "404", description = "Not Found" ),
            @ApiResponse(responseCode = "405", description = "Method Not allowed" ),
            @ApiResponse(responseCode = "409", description = "Conflict" ),
            @ApiResponse(responseCode = "500", description = "Internal Server Error" ) })
    @RequestMapping(value = "/geographicAddressValidation",
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.GET)
    ResponseEntity<List<GeographicAddressValidation>> listGeographicAddressValidation();


    @Operation(summary = "Updates partially a 'GeographicAddressValidation' by Id", operationId = "patchGeographicAddressValidation", description = "", tags={ "GeographicAddressValidation", })
    @ApiResponses(value = {
            @ApiResponse(responseCode ="200", description = "Updated" ),
            @ApiResponse(responseCode = "400", description = "Bad Request" ),
            @ApiResponse(responseCode = "401", description = "Unauthorized" ),
            @ApiResponse(responseCode = "403", description = "Forbidden" ),
            @ApiResponse(responseCode = "404", description = "Not Found" ),
            @ApiResponse(responseCode = "405", description = "Method Not allowed" ),
            @ApiResponse(responseCode = "409", description = "Conflict" ),
            @ApiResponse(responseCode = "500", description = "Internal Server Error" ) })
    @RequestMapping(value = "/geographicAddressValidation/{id}",
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.PATCH)
    ResponseEntity<GeographicAddressValidation> patchGeographicAddressValidation(@Parameter(description = "Identifier of the Geographic address", required = true) @PathVariable("id") String id, @Parameter(description = "The Service Level Specification to be updated", required = true) @Valid @RequestBody GeographicAddressValidation geographicAddressValidation);


    @Operation(summary = "Retrieves a 'GeographicAddressValidation' by Id", operationId = "retrieveGeographicAddressValidation", description = "" , tags={ "GeographicAddressValidation", })
    @ApiResponses(value = {
            @ApiResponse(responseCode ="200", description = "Ok" ),
            @ApiResponse(responseCode = "400", description = "Bad Request" ),
            @ApiResponse(responseCode = "401", description = "Unauthorized" ),
            @ApiResponse(responseCode = "403", description = "Forbidden" ),
            @ApiResponse(responseCode = "404", description = "Not Found" ),
            @ApiResponse(responseCode = "405", description = "Method Not allowed" ),
            @ApiResponse(responseCode = "409", description = "Conflict" ),
            @ApiResponse(responseCode = "500", description = "Internal Server Error" ) })
    @RequestMapping(value = "/geographicAddressValidation/{id}",
            produces = { "application/json" },
            consumes = { "application/json" },
            method = RequestMethod.GET)
    ResponseEntity<GeographicAddressValidation> retrieveGeographicAddressValidation(@Parameter(description = "Identifier of the geographic address", required = true) @PathVariable("id") String id);

}
+109 −0

File added.

Preview size limit exceeded, changes collapsed.

+15 −0
Original line number Diff line number Diff line
package org.etsi.osl.tmf.gam673.repo;

import org.etsi.osl.tmf.gam673.model.GeographicAddressValidation;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

@Repository
public interface GeographicAddressValidationManagementRepository extends CrudRepository<GeographicAddressValidation, Long>, PagingAndSortingRepository<GeographicAddressValidation, Long> {

    Optional<GeographicAddressValidation> findByUuid(String id);

}
Loading