Merging "develop" to "main" branch

Merge request reports

Loading
+27 −7
Changes for src/main/java/org/etsi/osl/osom/lcm/LcmBaseExecutor.java: 27 added lines, 7 removed lines.
Original line number Diff line number Diff line
package org.etsi.osl.osom.lcm;

import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
@@ -11,15 +14,20 @@ import java.util.function.Consumer;
import javax.net.ssl.SSLException;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.exc.StreamWriteException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.DatabindException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Option;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.text.StringEscapeUtils;
import org.etsi.osl.osom.partnerservices.GenericClient;
import org.etsi.osl.tmf.common.model.Any;
import org.etsi.osl.tmf.common.model.EValueType;
@@ -126,7 +134,7 @@ public abstract class LcmBaseExecutor {

	}

	private Optional<Characteristic> getCharacteristicByName(String charName) {
	protected Optional<Characteristic> getCharacteristicByName(String charName) {

		List<Characteristic> serviceCharacteristic;
		if (lcmspec.getLcmrulephase().equals("PRE_PROVISION") || this.vars.getService() == null) {
@@ -225,20 +233,32 @@ public abstract class LcmBaseExecutor {
		return -1;
	}


	public String getCharValAsString(String charName) {
		logger.debug("getCharValAsString " + charName);
		Optional<Characteristic> c = getCharacteristicByName(charName);
		Optional<Characteristic> characteristic = getCharacteristicByName(charName);

		if (c.isPresent()) {
			logger.debug("getCharValAsString " + c.get().getValue().getValue());
			return c.get().getValue().getValue();
		logger.info("Getting characteristic value as a string...");
	
		if (characteristic.isPresent()) {
			return characteristic.get().getValue().getValue();
		}
	
		return null;
	}

		logger.debug("getCharValAsString NULL ");

	public String escapeText(String s) {
		if (s == null || s.isEmpty()) {
			logger.debug("escapeText NULL ");
			return null;
		}

		logger.info("Escaping string...");

		return "\"" + StringEscapeUtils.escapeJava(s) + "\"";
	}
	

	public Boolean getCharValFromBooleanType(String charName) {
		logger.debug("getCharValFromBooleanType " + charName);
		Optional<Characteristic> c = getCharacteristicByName(charName);
+15 −16
Changes for src/main/java/org/etsi/osl/osom/management/MetricoOrchestrationService.java: 15 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -81,25 +81,16 @@ public class MetricoOrchestrationService implements JavaDelegate {
			String cfs_id = String.valueOf(serviceCharacteristic.getValue().getValue());
			mcjFVO.setConsumingApplicationId(cfs_id);

			serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_END_TIME");
			String endTimeString = 	String.valueOf(serviceCharacteristic.getValue().getValue());
			ScheduleDefinitionFVO scheduleDefinition = new ScheduleDefinitionFVO();
			if (endTimeString != null && !endTimeString.equals("")) {
				OffsetDateTime endTime = convertStringToOffsetDateTime(endTimeString, DateTimeFormat.ISO.DATE_TIME );
				scheduleDefinition.setScheduleDefinitionEndTime(endTime);
			if(aService.getStartDate() != null) {
				scheduleDefinition.setScheduleDefinitionStartTime(aService.getStartDate());
			} else {
				OffsetDateTime endTime = OffsetDateTime.now().plusHours(1);
				scheduleDefinition.setScheduleDefinitionEndTime(endTime);
				scheduleDefinition.setScheduleDefinitionStartTime(OffsetDateTime.now(ZoneOffset.UTC));
			}

			serviceCharacteristic = aService.getServiceCharacteristicByName("_MT_START_TIME");
			String startTimeString = String.valueOf(serviceCharacteristic.getValue().getValue());
			if (startTimeString != null&& !startTimeString.equals("")) {
				OffsetDateTime startTime = convertStringToOffsetDateTime(startTimeString, DateTimeFormat.ISO.DATE_TIME );
				scheduleDefinition.setScheduleDefinitionStartTime(startTime);
			if(aService.getEndDate() != null) {
				scheduleDefinition.setScheduleDefinitionEndTime(aService.getEndDate());
			} else {
				OffsetDateTime startTime = OffsetDateTime.now();
				scheduleDefinition.setScheduleDefinitionStartTime(startTime);
				scheduleDefinition.setScheduleDefinitionEndTime(OffsetDateTime.now(ZoneOffset.UTC).plusHours(1));
			}
			List<ScheduleDefinitionFVO> scheduleDefinitions = new ArrayList<>();
			scheduleDefinitions.add(scheduleDefinition);
@@ -161,7 +152,7 @@ public class MetricoOrchestrationService implements JavaDelegate {
            su = new ServiceUpdate();// the object to update the service
            MeasurementCollectionJob mcj = serviceOrderManager.addMeasurementCollectionJob(mcjFVO);
            if  (mcj != null){
              logger.info("Measurement Collection Job was not created.");
              logger.info("Measurement Collection Job was created.");

              serviceCharacteristic = new Characteristic();              
              serviceCharacteristic.setName( "_MT_MCJ_REFID" );
@@ -172,6 +163,14 @@ public class MetricoOrchestrationService implements JavaDelegate {
              serviceCharacteristic.setValue(val);
              su.addServiceCharacteristicItem(serviceCharacteristic);

			  MeasurementCollectionJobMVO mcjMVO = new MeasurementCollectionJobMVO();
			  mcjMVO.setExecutionState(ExecutionStateType.ACKNOWLEDGED);
			  try {
				  serviceOrderManager.updateMeasurementCollectionJobById(mcj.getUuid(), mcjMVO);
			  } catch (IOException e) {
				  throw new RuntimeException(e);
			  }

            } else {
              logger.error("Measurement Collection Job was not created.");
              su.setState(ServiceStateType.TERMINATED);
+37
Changes for src/main/java/org/etsi/osl/osom/management/ServiceOrderManager.java: 37 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import org.etsi.osl.model.nfv.ScaleDescriptor;
import org.etsi.osl.osom.serviceactions.NSActionRequestPayload;
import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJob;
import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobFVO;
import org.etsi.osl.tmf.pm628.model.MeasurementCollectionJobMVO;
import org.etsi.osl.tmf.pm632.model.Organization;
import org.etsi.osl.tmf.rcm634.model.LogicalResourceSpecification;
import org.etsi.osl.tmf.rcm634.model.ResourceSpecification;
@@ -200,6 +201,9 @@ public class ServiceOrderManager {
    @Value("${PM_MEASUREMENT_COLLECTION_JOB_ADD}")
    private String PM_MEASUREMENT_COLLECTION_JOB_ADD = "";

	@Value("${PM_MEASUREMENT_COLLECTION_JOB_UPDATE}")
	private String PM_MEASUREMENT_COLLECTION_JOB_UPDATE;

    
	@Transactional
	public void processOrder(ServiceOrder serviceOrder) {
@@ -1167,6 +1171,39 @@ public class ServiceOrderManager {
    return null;
}

	/**
	 * Updates a Measurement Collection Job in the database using the given Measurement Collection Job ID and update information.
	 *
	 * @param mcjId  the ID of the Measurement Collection Job to update
	 * @param mcjMVO the update information for the Measurement Collection Job
	 * @return the updated Measurement Collection Job, or null if the job could not be updated
	 */
	public MeasurementCollectionJob updateMeasurementCollectionJobById(String mcjId, MeasurementCollectionJobMVO mcjMVO) throws IOException {

		MeasurementCollectionJob measurementCollectionJob;
		logger.debug("will update MeasurementCollectionJob with id "+ mcjId+" and \nMeasurementCollectionJob.toString():\n"+ toJsonString(mcjMVO));


        try {
			Map<String, Object> map = new HashMap<>();
			map.put("mcjid", mcjId);

			Object response = template.requestBodyAndHeaders(PM_MEASUREMENT_COLLECTION_JOB_UPDATE, toJsonString(mcjMVO), map);
			logger.info("JsonUtil.toJsonString(mcjMVO): \n" + toJsonString(mcjMVO));
			if (!(response instanceof String)) {
				logger.error("MeasurementCollectionJob object is wrong.");
				return null;
			}
			measurementCollectionJob = toJsonObj((String) response, MeasurementCollectionJob.class);
			logger.info("response from PM_MEASUREMENT_COLLECTION_JOB_UPDATE: " + response);
			return measurementCollectionJob;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("Cannot update MeasurementCollectionJob with id " + mcjId + ":\n" + e.toString());
		}
		return null;
	}

  


+4 −4
Changes for src/main/resources/processes/ServiceActionProcess.bpmn: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -44,11 +44,11 @@
    </sequenceFlow>
    <sequenceFlow id="flow22" sourceRef="stServiceActivationAction" targetRef="stServiceActionComplete"></sequenceFlow>
    <sequenceFlow id="flow23" sourceRef="stInactiveAction" targetRef="stServiceActionComplete"></sequenceFlow>
    <serviceTask id="stServiceEvaluateΑction" name="Service Evaluate Αction" activiti:delegateExpression="${ServiceEvaluateAction}"></serviceTask>
    <sequenceFlow id="flow24" name="saction HandleEvaluateService" sourceRef="exclusivegateway1" targetRef="stServiceEvaluateΑction">
    <serviceTask id="stServiceEvaluateAction" name="Service Evaluate Action" activiti:delegateExpression="${ServiceEvaluateAction}"></serviceTask>
    <sequenceFlow id="flow24" name="saction HandleEvaluateService" sourceRef="exclusivegateway1" targetRef="stServiceEvaluateAction">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${saction=='HandleEvaluateService'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow25" sourceRef="stServiceEvaluateΑction" targetRef="stServiceActionComplete"></sequenceFlow>
    <sequenceFlow id="flow25" sourceRef="stServiceEvaluateAction" targetRef="stServiceActionComplete"></sequenceFlow>
    <serviceTask id="stCRTerminate" name="CR Terminate Task" activiti:delegateExpression="${CRTerminateTask}"></serviceTask>
    <sequenceFlow id="flow26" name="saction CRTerminate" sourceRef="exclusivegateway1" targetRef="stCRTerminate">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${saction=='CRTerminate'}]]></conditionExpression>
@@ -98,7 +98,7 @@
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="1170.0" y="218.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="stServiceEvaluateΑction" id="BPMNShape_stServiceEvaluateΑction">
      <bpmndi:BPMNShape bpmnElement="stServiceEvaluateAction" id="BPMNShape_stServiceEvaluateAction">
        <omgdc:Bounds height="65.0" width="105.0" x="709.0" y="571.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="stCRTerminate" id="BPMNShape_stCRTerminate">
+1
Changes for src/main/resources/application.yml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -128,3 +128,4 @@ CRD_PATCH_CR_REQ: "jms:queue:CRD.PATCH.CR_REQ"

#TMF628 ACTIONS
PM_MEASUREMENT_COLLECTION_JOB_ADD:         "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.ADD"
PM_MEASUREMENT_COLLECTION_JOB_UPDATE:      "jms:queue:PM.MEASUREMENTCOLLECTIONJOB.UPDATE"
 No newline at end of file
Loading
Loading