Commit 80802802 authored by Ikram Haq's avatar Ikram Haq
Browse files

fix issue releated to the PATCH method in CAPIF-mgmt

parent 3c4d3918
Loading
Loading
Loading
Loading
+21 −28
Original line number Diff line number Diff line
@@ -547,6 +547,13 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) {
			errHandlerProblemDetails(w, err.Error(), retCode)
			return
		}
	} else {
		err, retCode := setService(appId, &_sInfo, ATTRIBUTES_CHANGED_ServiceAvailabilityNotificationChangeType)
		if err != nil {
			log.Error(err.Error())
			errHandlerProblemDetails(w, err.Error(), retCode)
			return
		}
	}

	// Compare LivenessInterval
@@ -632,22 +639,7 @@ func appServicesByIdPATCH(w http.ResponseWriter, r *http.Request) {
		return
	}

	// aefProfile := &AefProfile{
	// 	AefId:                 sInfo.AefProfiles[0].AefId,
	// 	Versions:              sInfo.AefProfiles[0].Versions,
	// 	InterfaceDescriptions: sInfo.AefProfiles[0].InterfaceDescriptions,
	// 	VendorSpecificUrnetsimeccapifexttransportInfo: &MecTransportInfoCapifExt{
	// 		Name:     sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Name,
	// 		Type_:    sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Type_,
	// 		Protocol: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Protocol,
	// 		Version:  sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Version,
	// 		Security: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Security,
	// 	},
	// }
	dsInfo := &ServiceApiDescriptionPatch{
		// ApiName:     sInfo.ApiName,
		// ApiId:       sInfo.ApiId,
		// AefProfiles: []AefProfile{*aefProfile},
		VendorSpecificUrnetsimeccapifextserviceInfo: &MecServiceInfoCapifExtPatch{
			Serializer:        sInfo.VendorSpecificUrnetsimeccapifextserviceInfo.Serializer,
			State:             sInfo.VendorSpecificUrnetsimeccapifextserviceInfo.State,
@@ -658,20 +650,14 @@ func appServicesByIdPATCH(w http.ResponseWriter, r *http.Request) {
		},
	}

	// transportInfo_ := TransportInfo{
	// 	Id:       sInfo.AefProfiles[0].AefId,
	// 	Name:     sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Name,
	// 	Type_:    sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Type_,
	// 	Protocol: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Protocol,
	// 	Version:  sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Version,
	// 	Endpoint: sInfo.AefProfiles[0].InterfaceDescriptions,
	// 	Security: sInfo.AefProfiles[0].VendorSpecificUrnetsimeccapifexttransportInfo.Security,
	// }

	// Create Service
	_sInfo := ServiceInfo{
		SerInstanceId:     sInfoPrev.SerInstanceId,
		SerName:           sInfoPrev.SerName,
		Version:           sInfoPrev.Version,
		SerCategory:       dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.Category,
		State:             dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.State,
		TransportInfo:     sInfoPrev.TransportInfo,
		Serializer:        dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.Serializer,
		ScopeOfLocality:   dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.ScopeOfLocality,
		ConsumedLocalOnly: dsInfo.VendorSpecificUrnetsimeccapifextserviceInfo.ConsumedLocalOnly,
@@ -681,8 +667,8 @@ func appServicesByIdPATCH(w http.ResponseWriter, r *http.Request) {

	// Current implementation only supports state parameter change;
	// Make sure none of the other service information fields have changed
	state := *_sInfo.State
	*_sInfo.State = *sInfoPrev.State
	// state := *_sInfo.State
	// *_sInfo.State = *sInfoPrev.State
	// isLocal is only set in responses, subscriptions and notifications;
	// Ignore this field while comparing the previous & new service info structs
	_sInfo.IsLocal = sInfoPrev.IsLocal
@@ -698,7 +684,7 @@ func appServicesByIdPATCH(w http.ResponseWriter, r *http.Request) {
	}*/

	// Compare service info states & update DB if necessary
	*_sInfo.State = state
	// *_sInfo.State = state
	if *_sInfo.State != *sInfoPrev.State {
		err, retCode := setService(appId, &_sInfo, STATE_CHANGED_ServiceAvailabilityNotificationChangeType)
		if err != nil {
@@ -706,6 +692,13 @@ func appServicesByIdPATCH(w http.ResponseWriter, r *http.Request) {
			errHandlerProblemDetails(w, err.Error(), retCode)
			return
		}
	} else {
		err, retCode := setService(appId, &_sInfo, ATTRIBUTES_CHANGED_ServiceAvailabilityNotificationChangeType)
		if err != nil {
			log.Error(err.Error())
			errHandlerProblemDetails(w, err.Error(), retCode)
			return
		}
	}

	// Compare LivenessInterval