Commit 3827f47f authored by Kostis Trantzas's avatar Kostis Trantzas
Browse files

Merge remote-tracking branch 'origin/develop' into...

Merge remote-tracking branch 'origin/develop' into 106-update-the-api-to-address-the-new-resource-state-model

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parents 9f821018 b5b0d74c
Loading
Loading
Loading
Loading
Loading
+2 −2
Changes for Dockerfile: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
FROM ibm-semeru-runtimes:open-17.0.7_7-jdk
# RUN mkdir /opt/shareclasses
RUN mkdir -p /opt/openslice/lib/
COPY target/org.etsi.osl.tmf.api-1.4.0-SNAPSHOT-exec.jar /opt/openslice/lib/
CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/org.etsi.osl.tmf.api-1.4.0-SNAPSHOT-exec.jar"]
COPY target/org.etsi.osl.tmf.api-2.0.0-SNAPSHOT-exec.jar /opt/openslice/lib/
CMD ["java", "-Xshareclasses:cacheDir=/opt/shareclasses", "-jar", "/opt/openslice/lib/org.etsi.osl.tmf.api-2.0.0-SNAPSHOT-exec.jar"]
EXPOSE 13082
 No newline at end of file
+1 −1
Changes for pom.xml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
	<parent>
		<groupId>org.etsi.osl</groupId>
		<artifactId>org.etsi.osl.main</artifactId>
		<version>2026Q2-SNAPSHOT</version>
		<version>2026Q4-SNAPSHOT</version>
		<relativePath>../org.etsi.osl.main</relativePath>
	</parent>

+15 −4
Changes for src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java: 15 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -1235,6 +1235,10 @@ public class ServiceRepoService {
    }
    
    
    private String normalizeValueType(String valueType) {
  	  return (valueType == null || valueType.isBlank()) ? "" : valueType.trim();
	}

    private CharCopyResult copyCharacteristicsFromResource( @Valid Service aService, @Valid ServiceUpdate supd, @Valid Resource res) {

      Boolean characteristicFoundDifferent = false;
@@ -1277,20 +1281,27 @@ public class ServiceRepoService {

            String characteristicname = kind + resourcename + rChar.getName();
            Characteristic servChar = supd.getServiceCharacteristicByName( characteristicname );
           
		    if ( servChar != null && servChar.getValue() != null) {  
              if (! servChar.getValue().getValue().equals( rChar.getValue().getValue() ) ) {
			  boolean valueChanged = ! servChar.getValue().getValue().equals( rChar.getValue().getValue() );
			  boolean typeChanged = ! normalizeValueType( servChar.getValueType() ).equals( normalizeValueType( rChar.getValueType() ) );
			
              if ( valueChanged || typeChanged ) {
                characteristicFoundDifferent = true;
                supd.getServiceCharacteristicByName( characteristicname ) .value(new Any( rChar.getValue() ));  
                logger.debug("====================>  update characteristic: " + characteristicname +", value: "+ rChar.getValue().getValue());                      
				servChar.value( new Any( rChar.getValue() ) );
				servChar.setValueType( rChar.getValueType() );

                logger.debug("====================>  update characteristic: " + characteristicname + ", value: " + rChar.getValue().getValue() + ", valueType: " + rChar.getValueType());                      
              }
              
            } else {
              Characteristic cNew = new Characteristic();
              cNew.setName( characteristicname );     
              cNew.value( new Any( rChar.getValue() ));
			  cNew.setValueType( rChar.getValueType());
              supd.addServiceCharacteristicItem( cNew );
              characteristicFoundDifferent = true;
              logger.debug("====================>  add New characteristic: " + characteristicname +", value: "+ rChar.getValue().getValue());
              logger.debug("====================>  add New characteristic: " + characteristicname +", value: " + rChar.getValue().getValue() + ", valueType: " + rChar.getValueType()); 
            }
            
            
+5
Changes for src/main/java/org/etsi/osl/tmf/so641/api/ServiceOrderApiController.java: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -218,9 +218,14 @@ public class ServiceOrderApiController implements ServiceOrderApi {
			Principal principal,			
			@Parameter(description = "Identifier of the ServiceOrder", required = true) @PathVariable("id") String id,
			@Parameter(description = "The ServiceOrder to be updated", required = true) @Valid @RequestBody ServiceOrderUpdate serviceOrder) {
		try {
			ServiceOrder c = serviceOrderRepoService.updateServiceOrder(id, serviceOrder);

			return new ResponseEntity<ServiceOrder>(c, HttpStatus.OK);
		} catch (NotFoundException e) {
			log.error("Couldn't update Service Order. ", e);
			return new ResponseEntity<ServiceOrder>(HttpStatus.BAD_REQUEST);
		}
	}

	@PreAuthorize("hasAnyAuthority('ROLE_USER')" )
+46 −17
Changes for src/main/java/org/etsi/osl/tmf/so641/reposervices/ServiceOrderRepoService.java: 46 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -462,14 +462,7 @@ public class ServiceOrderRepoService {
		// Ensure that all Services Specifications exist
		List <ServiceOrderItem> serviceOrderItemList = serviceOrderCreate.getOrderItem();
		for (ServiceOrderItem serviceOrderItem: serviceOrderItemList) {
			ServiceRestriction serviceRestriction = serviceOrderItem.getService();
			ServiceSpecificationRef serviceSpecificationRef = serviceRestriction.getServiceSpecification();
			String serviceSpecificationId = serviceSpecificationRef.getId();

			ServiceSpecification serviceSpecification = serviceSpecRepoService.findByUuid(serviceSpecificationId);

			if (serviceSpecification == null)
				throw new NotFoundException(400, "There is no Service Specification with Id: " + serviceSpecificationId);
			checkServiceSpecificationExists(serviceOrderItem);
		}

		ServiceOrder so = new ServiceOrder();
@@ -701,12 +694,41 @@ public class ServiceOrderRepoService {
		
	}

	/**
	 * Ensures that the order item references an existing Service Specification
	 *
	 * @param soi
	 * @throws NotFoundException (400) if the item has no service specification or it does not exist
	 */
	private void checkServiceSpecificationExists(ServiceOrderItem soi) throws NotFoundException {
		ServiceSpecificationRef serviceSpecificationRef = ( soi.getService() != null ) ? soi.getService().getServiceSpecification() : null;
		String serviceSpecificationId = ( serviceSpecificationRef != null ) ? serviceSpecificationRef.getId() : null;

		if ( ( serviceSpecificationId == null ) || ( serviceSpecRepoService.findByUuid(serviceSpecificationId) == null ) ) {
			throw new NotFoundException(400, "There is no Service Specification with Id: " + serviceSpecificationId);
		}
	}

	@Transactional
	public ServiceOrder updateServiceOrder(String id, @Valid ServiceOrderUpdate serviceOrderUpd) {
	public ServiceOrder updateServiceOrder(String id, @Valid ServiceOrderUpdate serviceOrderUpd) throws NotFoundException {

		logger.info("Will updateServiceOrder:" + id);

		ServiceOrder so = this.findByUuid(id);

		/**
		 * Order items to be appended are validated before anything is changed: the order is managed,
		 * and a checked exception does not roll the transaction back, so a later throw would still
		 * commit the part of the update applied until then
		 */
		if ( serviceOrderUpd.getOrderItem() != null ) {
			for (ServiceOrderItem soiUpd :  serviceOrderUpd.getOrderItem()) {
				if ( so.findOrderItemById( soiUpd.getId() ) == null ) {
					checkServiceSpecificationExists( soiUpd );
				}
			}
		}

		boolean stateChanged = false;
		boolean expectedCompletionDateChanged = false;

@@ -765,17 +787,22 @@ public class ServiceOrderRepoService {
			for (ServiceOrderItem soiUpd :  serviceOrderUpd.getOrderItem()) {
				ServiceOrderItem soiOrigin = so.findOrderItemById( soiUpd.getId() );
				if (soiOrigin!=null) {
					updateOrderItem(soiOrigin, soiUpd);
					/**
					 * When we patch the order and see a MODIFY or DELETE action, we set the state to ACKNOWLEDGED
					 * An existing order item can only be modified or deleted, it cannot be added again.
					 * An ADD action is dropped, so that the item keeps its current action.
					 */
					if ( soiOrigin.getAction().equals( ServiceOrderActionType.MODIFY ) ||
							soiOrigin.getAction().equals( ServiceOrderActionType.DELETE )) {
						soiOrigin.setState( ServiceOrderStateType.ACKNOWLEDGED  );
						so.setState( ServiceOrderStateType.ACKNOWLEDGED );
						

					if ( ServiceOrderActionType.ADD.equals( soiUpd.getAction() ) ) {
						soiUpd.setAction( null );
					}
					updateOrderItem(soiOrigin, soiUpd);
					/**
					 * 2026-09-24: removed the automatic ACKNOWLEDGED of the order item and of the order, which
					 * was applied when the patch carried a MODIFY or DELETE action.
					 * An order may still be in planning: e.g. it starts next week and is kept in INITIAL while
					 * its items are added or modified. Acknowledging it on the first such change would start
					 * its processing too early. The order is moved to ACKNOWLEDGED explicitly, by setting its
					 * state, once its items are final.
					 */

				} else {
					/**
@@ -784,8 +811,10 @@ public class ServiceOrderRepoService {
					 * the uuid2 generator assigns it a fresh identifier. ServiceOrder.orderItem cascades
					 * PERSIST/MERGE and ServiceOrderItem.service cascades ALL, so the item's
					 * ServiceRestriction and its characteristics are persisted along with it.
					 * A new order item is always an ADD, whatever action it arrives with.
					 */
					soiUpd.setUuid( null );
					soiUpd.setAction( ServiceOrderActionType.ADD );
					so.addOrderItemItem( soiUpd );
					logger.info("Order item appended to service order " + id
							+ " (action=" + soiUpd.getAction() + ", state=" + soiUpd.getState() + ")");
Loading