Commit 9a01865b authored by Kostis Trantzas's avatar Kostis Trantzas
Browse files

Merge branch 'productorderdev' into 'develop'

Productorderdev

See merge request !47
parents 30e9832b ed313f01
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -9,10 +9,10 @@
		<relativePath>../org.etsi.osl.main</relativePath>
	</parent>

	<version>${org.etsi.osl.tmf.api.version>}</version>

	<artifactId>org.etsi.osl.tmf.api</artifactId>
	<name>org.etsi.osl.tmf.api</name>
	<version>${org.etsi.osl.tmf.api.version}</version>

	<organization>
		<name>OpenSlice by ETSI</name>
@@ -20,6 +20,7 @@
	</organization>



	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+38 −2
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ public class SwaggerDocumentationConfig {
  
  
	@Bean
	public OpenApiCustomizer scm622OpenAPI() {
	public OpenApiCustomizer po622OpenAPI() {
		return openApi -> openApi
				.specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) 
				.info(new Info().title("TMF 622 Product Ordering")
@@ -161,13 +161,49 @@ public class SwaggerDocumentationConfig {
	  	SpringDocUtils.getConfig().replaceWithClass(java.time.OffsetDateTime.class, java.util.Date.class);
      return GroupedOpenApi.builder()
      		.group("tmf-api-622-ProductOrderingManagement-v4.0.0")
      		.addOpenApiCustomizer( this.scm622OpenAPI() )
      		.addOpenApiCustomizer( this.po622OpenAPI() )
      		.packagesToScan("org.etsi.osl.tmf.po622.api")
      		.build();

  }
	
  
  /**
   * TMF 637 Product Inventory Management 
   * @return
   */
  @Bean
  public OpenApiCustomizer pim637penAPI() {
      
      
      return openApi -> openApi
              .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) 
                .info(new Info().title("TMF 637 Product Inventory Management")
                    .description("**TMF API Reference : TMF 637 - Product Inventory Management**  Release : 19.0 - June 2019\n\nThe Product Inventory Management API provides standardized mechanism for product inventory management such as creation, update and retrieval of the representation of a product in the inventory. It also allows the notification of events related to product lifecycle  **Product resource** A product offering procured by a customer or other interested party playing a party role. A product is realized as one or more service(s) and / or resource(s).  Product Inventory API performs the following operations on product : - Retrieval of a product or a collection of products depending on filter criteria - Partial update of a product (including updating rules and for administration purpose) - Creation of a product (including default values and creation rules and for administration purpose) - Deletion of a product (for administration purposes) - Notification of events on product.  Copyright © TM Forum 2019. All Rights Reserved   ")
                    
                    .version("4.0.0")
                    .license(new License().name("Apache 2.0").url("https://osl.etsi.org")))
                  .externalDocs(new ExternalDocumentation()
                          .description("TMF API Tables")
                          .url("https://www.tmforum.org/oda/open-apis/table"));        
                       
    }
  
  
@Bean
public GroupedOpenApi pim637() {

      SpringDocUtils.getConfig().replaceWithClass(java.time.LocalDate.class, java.sql.Date.class);
      SpringDocUtils.getConfig().replaceWithClass(java.time.OffsetDateTime.class, java.util.Date.class);
    return GroupedOpenApi.builder()
          .group("tmf-api-637-ProductInventoryManagement-v4.0.0")
          .addOpenApiCustomizer( this.pim637penAPI() )
          .packagesToScan("org.etsi.osl.tmf.pim637.api")
          .build();

}

	  
  /**
	 * TMF 634 Resource Catalog Management
	 * @return
+20 −0
Original line number Diff line number Diff line
@@ -224,4 +224,24 @@ public interface ProductOfferingApi {
		return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
	}
	
	   @Operation(summary = "Creates and Retrieves a ProductOffering by ID", operationId = "retrieveProductOffering", description = "This operation retrieves a ProductOffering entity. Attribute selection is enabled for all first level attributes." , tags = {
           "productOffering", })
   @ApiResponses(value = { @ApiResponse(responseCode ="200", description = "Success" ),
           @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 = "/productOffering/fromServiceSpecId/{id}", produces = {
           "application/json;charset=utf-8" }, method = RequestMethod.POST)
   default ResponseEntity<ProductOffering> createRetrieveProductOfferingBasedOnServiceSpec(
           @Parameter(description = "Identifier of the ProductOffering", required = true) @PathVariable("id") String id) {
       
       
       return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
   }


}
+16 −0
Original line number Diff line number Diff line
@@ -167,5 +167,21 @@ public class ProductOfferingApiController implements ProductOfferingApi {
		}
	}
	
	@Override
    @PreAuthorize("hasAnyAuthority('ROLE_ADMIN')" )
	public ResponseEntity<ProductOffering> createRetrieveProductOfferingBasedOnServiceSpec(
	  String id) {
	  try {

        
        return new ResponseEntity<ProductOffering>(productOfferingRepoService.createRetrieveProductOfferingBasedOnServiceSpec(id),
                HttpStatus.OK);
    } catch (Exception e) {
        log.error("Couldn't serialize response for content type application/json", e);
        return new ResponseEntity<ProductOffering>(HttpStatus.INTERNAL_SERVER_ERROR);
    }

	}

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

import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.dataformat.JsonLibrary;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.etsi.osl.tmf.pcm620.model.ProductSpecificationCreate;
import org.etsi.osl.tmf.pcm620.model.ProductSpecificationUpdate;
import org.etsi.osl.tmf.pcm620.reposervices.ProductOfferingRepoService;
import org.etsi.osl.tmf.pcm620.reposervices.ProductSpecificationRepoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Configuration
//@RefreshScope
@Component
public class ProductSpecificationApiRouteBuilder extends RouteBuilder {

  private static final transient Log logger = LogFactory.getLog(ProductSpecificationApiRouteBuilder.class.getName());

  @Value("${CATALOG_GET_PRODUCTSPEC_BY_ID}")
  private String CATALOG_GET_PRODUCTSPEC_BY_ID = "";
  

  @Value("${CATALOG_ADD_PRODUCTSPEC}")
  private String CATALOG_ADD_PRODUCTSPEC = "";
  

  @Value("${CATALOG_UPD_PRODUCTSPEC}")
  private String CATALOG_UPD_PRODUCTSPEC = "";
  
  @Value("${CATALOG_UPDADD_PRODUCTSPEC}")
  private String CATALOG_UPDADD_PRODUCTSPEC = "";
  

  @Value("${CATALOG_GET_PRODUCTOFFERING_BY_ID}")
  private String CATALOG_GET_PRODUCTOFFERING_BY_ID = "";
  
  
  
  @Autowired
  ProductSpecificationRepoService productSpecificationRepoService;

  @Autowired
  ProductOfferingRepoService productOfferingRepoService;
  

  @Override
  public void configure() throws Exception {
    from( CATALOG_GET_PRODUCTSPEC_BY_ID )
    .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTSPEC_BY_ID + " message received!")
    .to("log:DEBUG?showBody=true&showHeaders=true")
    .bean( productSpecificationRepoService, "findByUuidEager")
    .marshal().json( JsonLibrary.Jackson, String.class)
    .convertBodyTo( String.class );

    
    from( CATALOG_ADD_PRODUCTSPEC )
    .log(LoggingLevel.INFO, log, CATALOG_ADD_PRODUCTSPEC + " message received!")
    .to("log:DEBUG?showBody=true&showHeaders=true")
    .unmarshal().json( JsonLibrary.Jackson, ProductSpecificationCreate .class, true)
    .bean( productSpecificationRepoService, "addProductSpecification(${body})")
    .marshal().json( JsonLibrary.Jackson)
    .convertBodyTo( String.class );
            
    from( CATALOG_UPD_PRODUCTSPEC )
    .log(LoggingLevel.INFO, log, CATALOG_UPD_PRODUCTSPEC + " message received!")
    .to("log:DEBUG?showBody=true&showHeaders=true")
    .unmarshal().json( JsonLibrary.Jackson, ProductSpecificationUpdate.class, true)
    .bean( productSpecificationRepoService, "updateProductSpecification(${header.serviceSpecId},  ${body} )")
    .marshal().json( JsonLibrary.Jackson)
    .convertBodyTo( String.class );

    from( CATALOG_UPDADD_PRODUCTSPEC )
    .log(LoggingLevel.INFO, log, CATALOG_UPD_PRODUCTSPEC + " message received!")
    .to("log:DEBUG?showBody=true&showHeaders=true")
    .unmarshal().json( JsonLibrary.Jackson, ProductSpecificationUpdate.class, true)
    .bean( productSpecificationRepoService, "updateOrAddProductSpecification(${header.serviceSpecId}, ${header.forceId}, ${body} )")
    .marshal().json( JsonLibrary.Jackson)
    .convertBodyTo( String.class );
    

    from( CATALOG_GET_PRODUCTOFFERING_BY_ID )
    .log(LoggingLevel.INFO, log, CATALOG_GET_PRODUCTOFFERING_BY_ID + " message received!")
    .to("log:DEBUG?showBody=true&showHeaders=true")
    .bean( productOfferingRepoService, "findByUuidEager")
    .marshal().json( JsonLibrary.Jackson, String.class)
    .convertBodyTo( String.class );
    
    
  }
}
Loading