Commit 09544bf4 authored by Christos Tranoris's avatar Christos Tranoris
Browse files

fix for #60

parent e31e8499
Loading
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public class ResourceApiRouteBuilder extends RouteBuilder {
	public void configure() throws Exception {
		
		from( CATALOG_ADD_RESOURCE )
		.log(LoggingLevel.INFO, log, CATALOG_ADD_RESOURCE + " message received!")
		.log(LoggingLevel.DEBUG, log, CATALOG_ADD_RESOURCE + " message received!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.unmarshal().json( JsonLibrary.Jackson, ResourceCreate.class, true)
		.bean( resourceRepoService, "addResource(${body})")
@@ -83,13 +83,13 @@ public class ResourceApiRouteBuilder extends RouteBuilder {
		.convertBodyTo( String.class );
		
		from( CATALOG_GET_RESOURCE_BY_ID )
		.log(LoggingLevel.INFO, log, CATALOG_GET_RESOURCE_BY_ID + " message received!")
		.log(LoggingLevel.DEBUG, log, CATALOG_GET_RESOURCE_BY_ID + " message received!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.bean( resourceRepoService, "getResourceEagerAsString")
		.convertBodyTo( String.class );	
				
		from( CATALOG_UPD_RESOURCE )
		.log(LoggingLevel.INFO, log, CATALOG_UPD_RESOURCE + " message received!")
		.log(LoggingLevel.DEBUG, log, CATALOG_UPD_RESOURCE + " message received!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.unmarshal().json( JsonLibrary.Jackson, ResourceUpdate.class, true)
		.bean( resourceRepoService, "updateResource(${header.resourceId}, ${body}, ${header.triggerServiceActionQueue} )")
@@ -97,14 +97,14 @@ public class ResourceApiRouteBuilder extends RouteBuilder {
		.convertBodyTo( String.class );		

		from( CATALOG_RESOURCES_OF_PARTNERS )
		.log(LoggingLevel.INFO, log, CATALOG_RESOURCES_OF_PARTNERS + " message received!")
		.log(LoggingLevel.DEBUG, log, CATALOG_RESOURCES_OF_PARTNERS + " message received!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.bean( resourceRepoService, "findAllActiveAndReservedResourcesOfPartners")
		.marshal().json( JsonLibrary.Jackson)
		.convertBodyTo( String.class );
		
		from( CATALOG_UPDADD_RESOURCE )
		.log(LoggingLevel.INFO, log, CATALOG_UPDADD_RESOURCE + " message received!")
		.log(LoggingLevel.DEBUG, log, CATALOG_UPDADD_RESOURCE + " message received!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.unmarshal().json( JsonLibrary.Jackson, ResourceCreate.class, true)
		.bean( resourceRepoService, "addOrUpdateResourceByNameCategoryVersion(${header.aname},${header.acategory}, ${header.aversion}, ${body})")
+12 −12
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder {
      
      
		from( CATALOG_ADD_SERVICE )
		.log(LoggingLevel.INFO, log, CATALOG_ADD_SERVICE + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, CATALOG_ADD_SERVICE + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.unmarshal().json( JsonLibrary.Jackson, ServiceCreate.class, true)
		.bean( serviceRepoService, "addService(${body})")
@@ -131,7 +131,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder {
		.convertBodyTo( String.class );
		
		from( CATALOG_GET_SERVICE_BY_ID )
		.log(LoggingLevel.INFO, log, CATALOG_GET_SERVICE_BY_ID + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, CATALOG_GET_SERVICE_BY_ID + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.bean( serviceRepoService, "getServiceEagerAsString")
		.convertBodyTo( String.class );
@@ -139,7 +139,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder {
		
		
		from( CATALOG_UPD_SERVICE )
		.log(LoggingLevel.INFO, log, CATALOG_UPD_SERVICE + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, CATALOG_UPD_SERVICE + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.unmarshal().json( JsonLibrary.Jackson, ServiceUpdate.class, true)
		.bean( serviceRepoService, "updateService(${header.serviceid}, ${body}, ${header.triggerServiceActionQueue} )")
@@ -148,14 +148,14 @@ public class ServiceApiRouteBuilder extends RouteBuilder {
		
		
		from( CATALOG_SERVICE_QUEUE_ITEMS_GET )
		.log(LoggingLevel.INFO, log, CATALOG_SERVICE_QUEUE_ITEMS_GET + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, CATALOG_SERVICE_QUEUE_ITEMS_GET + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.bean( serviceRepoService, "findAllServiceActionQueueItems")
		.marshal().json( JsonLibrary.Jackson)
		.convertBodyTo( String.class );
		
		from( CATALOG_SERVICE_QUEUE_ITEM_UPD )
		.log(LoggingLevel.INFO, log, CATALOG_SERVICE_QUEUE_ITEM_UPD + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, CATALOG_SERVICE_QUEUE_ITEM_UPD + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.unmarshal().json( JsonLibrary.Jackson, ServiceActionQueueItem.class, true)
		.bean( serviceRepoService, "updateServiceActionQueueItem(${body})")
@@ -163,7 +163,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder {
		.convertBodyTo( String.class );
		
		from( CATALOG_SERVICE_QUEUE_ITEM_DELETE )
		.log(LoggingLevel.INFO, log, CATALOG_SERVICE_QUEUE_ITEM_DELETE + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, CATALOG_SERVICE_QUEUE_ITEM_DELETE + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.unmarshal().json( JsonLibrary.Jackson, ServiceActionQueueItem.class, true)
		.bean( serviceRepoService, "deleteServiceActionQueueItemByUuid(${header.itemid})");
@@ -171,7 +171,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder {
		
		
		from( CATALOG_SERVICES_TO_TERMINATE )
		.log(LoggingLevel.INFO, log, CATALOG_SERVICES_TO_TERMINATE + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, CATALOG_SERVICES_TO_TERMINATE + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.bean( serviceRepoService, "findAllActiveServicesToTerminate")
		.marshal().json( JsonLibrary.Jackson)
@@ -179,7 +179,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder {
		

		from( CATALOG_SERVICES_OF_PARTNERS )
		.log(LoggingLevel.INFO, log, CATALOG_SERVICES_OF_PARTNERS + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, CATALOG_SERVICES_OF_PARTNERS + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.bean( serviceRepoService, "findAllActiveAndReservedServicesOfPartners")
		.marshal().json( JsonLibrary.Jackson)
@@ -187,14 +187,14 @@ public class ServiceApiRouteBuilder extends RouteBuilder {
		

		from( CATALOG_GET_SERVICE_BY_ORDERID )
		.log(LoggingLevel.INFO, log, CATALOG_GET_SERVICE_BY_ORDERID + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, CATALOG_GET_SERVICE_BY_ORDERID + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.bean( serviceRepoService, "getServicesFromOrderID")
		.marshal().json( JsonLibrary.Jackson)
		.convertBodyTo( String.class );
		
		from( NFV_CATALOG_NS_LCMCHANGED )
		.log(LoggingLevel.INFO, log, NFV_CATALOG_NS_LCMCHANGED + " message received and will be processed for service inventory!")
		.log(LoggingLevel.DEBUG, log, NFV_CATALOG_NS_LCMCHANGED + " message received and will be processed for service inventory!")
		.to("log:DEBUG?showBody=true&showHeaders=true")
		.unmarshal().json( JsonLibrary.Jackson, DeploymentDescriptor.class, true)
		.bean( serviceRepoService, "nfvCatalogNSResourceChanged(${body})");
@@ -202,7 +202,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder {


        from( EVENT_RESOURCE_STATE_CHANGED )
        .log(LoggingLevel.INFO, log, EVENT_RESOURCE_STATE_CHANGED + " message received and will be processed for service inventory!")
        .log(LoggingLevel.DEBUG, log, EVENT_RESOURCE_STATE_CHANGED + " message received and will be processed for service inventory!")
        .to("log:DEBUG?showBody=true&showHeaders=true")
        .unmarshal().json( JsonLibrary.Jackson, ResourceStateChangeNotification.class, true)
        .bean( serviceRepoService, "resourceStateChangedEvent(${body})");
@@ -216,7 +216,7 @@ public class ServiceApiRouteBuilder extends RouteBuilder {
            .logHandled(true)
            .retriesExhaustedLogLevel(LoggingLevel.ERROR)
            .retryAttemptedLogLevel(LoggingLevel.ERROR))     
        .log(LoggingLevel.INFO, log, EVENT_RESOURCE_CREATE + " message received and will be processed for service inventory!")
        .log(LoggingLevel.DEBUG, log, EVENT_RESOURCE_CREATE + " message received and will be processed for service inventory!")
        .to("log:DEBUG?showBody=true&showHeaders=true")
        .unmarshal().json( JsonLibrary.Jackson, ResourceCreateNotification.class, true)
        .bean( serviceRepoService, "resourceCreatedEvent(${body})");
+117 −27
Original line number Diff line number Diff line
@@ -341,6 +341,23 @@ public class ServiceRepoService {
		s.addNoteItem(noteItem);		
		
        
        int cnt = 0;
        if ( service.getServiceCharacteristic()!=null)
          for (Characteristic ch : service.getServiceCharacteristic()) {
            if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) {
              cnt++; 
            }
            if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) {
              logger.debug("=============================================>  FOUND CHARACTERISTIC addService AdditionPropertiesAsJson IN addService" );
              logger.debug("=============================================>  AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() );
            }
        } 

        if ( cnt>1) {
          logger.debug("=============================================>  FOUND CHARACTERISTIC TWICE AFTER service  addService" );
          
        }
		
		s = this.serviceRepo.save( s );

		raiseServiceCreateNotification(s);
@@ -394,6 +411,40 @@ public class ServiceRepoService {
		}
		
		
        int cnt = 0;
        if ( servUpd.getServiceCharacteristic() != null ) {
          for (Characteristic ch1 : servUpd.getServiceCharacteristic()) {
              if ( ch1.getName().equals( "org.etsi.osl.prefixName" ) ) {
                cnt++; 
              }
              if ( ch1.getName().equals( "AdditionPropertiesAsJson" ) ) {
                logger.debug("=============================================>  FOUND CHARACTERISTIC AdditionPropertiesAsJson IN servUpd" );
                logger.debug("=============================================>  AdditionPropertiesAsJson charlength=" + ch1.getValue().getValue().length() );
              }
              
          } 

          if ( cnt>1) {
            logger.debug("=============================================>  FOUND CHARACTERISTIC TWICE servUpd updateService servUpd" );
            
          }            
        }
        cnt = 0;
          for (Characteristic ch : service.getServiceCharacteristic()) {
              if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) {
                cnt++; 
              }
              if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) {
                logger.debug("=============================================>  FOUND CHARACTERISTIC AdditionPropertiesAsJson IN service" );
                logger.debug("=============================================>  AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() );
              }
          } 

          if ( cnt>1) {
            logger.debug("=============================================>  FOUND CHARACTERISTIC TWICE service updateService service" );
            
          }
		
				
		if (servUpd.getType()!=null) {
			service.setType(servUpd.getType());			
@@ -536,7 +587,16 @@ public class ServiceRepoService {
					} else {
						service.addServiceCharacteristicItem(n);

			              if ( n.getName().equals( "AdditionPropertiesAsJson" ) ) {
			                logger.debug("=============================================>  ADDING AdditionPropertiesAsJson to service" );
			                if ( n.getValue()!=null ) {
		                        logger.debug("=============================================>  ADDING AdditionPropertiesAsJson charlength=" + n.getValue().getValue().length() );                        
		                      } else {

		                        logger.debug("=============================================>  ADDING AdditionPropertiesAsJson charlength=NULL" );
		                      }
		                      
			              }
						if ( !n.getName().contains("::") ) { //it is not a child characteristic
	                        serviceCharacteristicChanged = true;    
	                        charChangedForNotes += n.getName() + ", "; 						  
@@ -613,6 +673,7 @@ public class ServiceRepoService {
		
        if (charChangedForNotes.contains( "reconciledAt") ) { //this is just a sync message, so we need to igore such changes
          serviceCharacteristicChanged = false;
          logger.debug("=============================================>  Just reconciledAt changed" );
        }
		
		if (serviceCharacteristicChanged) {
@@ -634,6 +695,21 @@ public class ServiceRepoService {
		
		service = this.serviceRepo.save( service );
		
        cnt = 0;
        for (Characteristic ch : service.getServiceCharacteristic()) {
            if ( ch.getName().equals( "org.etsi.osl.prefixName" ) ) {
              cnt++; 
            }
            if ( ch.getName().equals( "AdditionPropertiesAsJson" ) ) {
              logger.debug("=============================================>  FOUND CHARACTERISTIC AFTER AdditionPropertiesAsJson IN service" );
              logger.debug("=============================================>  AdditionPropertiesAsJson charlength=" + ch.getValue().getValue().length() );
            }
        } 

        if ( cnt>1) {
          logger.debug("=============================================>  FOUND CHARACTERISTIC TWICE AFTER service updateService service" );
          
        }
		
	    String requestedServiceAsJson = null;
	    try {
@@ -779,6 +855,7 @@ public class ServiceRepoService {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
			logger.info("======================================================================================================");			
		}
		
		return service;
@@ -894,10 +971,10 @@ public class ServiceRepoService {

		if ( schart!= null ) {
			String teest = schart.getValue().getValue();
			logger.debug("schart size = " + teest.length() );
			logger.info("schart size = " + teest.length() );
			
			logger.debug("schart " + teest );
			logger.debug("======================================================================================================");			
			logger.info("schart " + teest );
			logger.info("======================================================================================================");			
		}
		
		return res;
@@ -1207,16 +1284,17 @@ public class ServiceRepoService {
              }
              
              
              
              Boolean stateChaged = false;
              ServiceUpdate supd = new ServiceUpdate();
              nextState = aService.findNextStateBasedOnResourceList(rlist);
              supd.setState(nextState);
              String stateText="";
              if ( !aService.getState().equals(nextState)) {
                stateChaged = true;
                stateText = "State changed from " + aService.getState() + " to " + nextState + ".";
                logger.debug("====================>  stateText = " + stateText);
                for (Resource r : rlist) {
                  logger.debug("==================>  s:"+  r.getResourceStatus().name()+ ", name:"+ r.getName() );
                  logger.debug("==================>  r:{}, state:{} ="+  r.getName() + ", "+  r.getResourceStatus().name());
                  
                }
              }
@@ -1224,9 +1302,11 @@ public class ServiceRepoService {
              //adding all characteristics from service
              for (Characteristic ch : aService.getServiceCharacteristic()) {
                supd.addServiceCharacteristicItem(ch);
              }
                
                
              }
              
              Boolean characteristicFoundDifferent =false;
              String dontCopyChars = "clusterMasterURL,currentContextCluster,fullResourceName,Kind,apiGroup,UID,metadata";
              String[] arrayDontCopyChars = dontCopyChars.split(",");
              Set<String> setB = new HashSet<>(Arrays.asList(arrayDontCopyChars));
@@ -1235,14 +1315,21 @@ public class ServiceRepoService {
                  if  ( rChar.getValue() != null ) {

                    String characteristicname = kind + resourcename + rChar.getName();
                    if ( supd.getServiceCharacteristicByName( characteristicname ) != null ) {
                    Characteristic servChar = supd.getServiceCharacteristicByName( characteristicname );
                    if ( servChar != null && servChar.getValue() != null) {                      
                      if (! servChar.getValue().getValue().equals( rChar.getValue().getValue() ) ) {
                        characteristicFoundDifferent = true;
                        supd.getServiceCharacteristicByName( characteristicname ) .value(new Any( rChar.getValue() ));  
                        logger.debug("====================>  add characteristic: " + characteristicname +", value: "+ rChar.getValue().getValue());                      
                      }
                      
                    } else {
                      Characteristic cNew = new Characteristic();
                      cNew.setName( characteristicname  );     
                      cNew.value( new Any( rChar.getValue() ));
                      supd.addServiceCharacteristicItem( cNew );
                      
                      characteristicFoundDifferent = true;
                      logger.debug("====================>  add New characteristic: " + characteristicname +", value: "+ rChar.getValue().getValue());
                    }
                    
                    
@@ -1252,6 +1339,7 @@ public class ServiceRepoService {
              }

                
              if ( stateChaged || characteristicFoundDifferent) {
                Characteristic noteCheck = as.getServiceCharacteristicByName("_DETAILED_NOTES_");
                if ( noteCheck!= null 
                    && noteCheck.getValue() != null
@@ -1268,6 +1356,8 @@ public class ServiceRepoService {
                
              }

        }
      

      }catch (Exception e) {
        e.printStackTrace();