Loading go-apps/meep-app-enablement/api/service-mgmt/swagger.yaml +3 −0 Original line number Diff line number Diff line Loading @@ -412,6 +412,9 @@ components: type: string format: uri description: A URI reference that identifies the specific occurrence of the problem required: - status - detail GrantType: description: OAuth 2.0 grant type type: string Loading go-apps/meep-app-enablement/server/service-mgmt/convert.go +9 −0 Original line number Diff line number Diff line Loading @@ -86,3 +86,12 @@ func convertSubscriptionLinkListToJson(obj *SubscriptionLinkList) string { } return string(jsonInfo) } func convertProblemDetailstoJson(probdetails *ProblemDetails) string { jsonInfo, err := json.Marshal(*probdetails) if err != nil { log.Error(err.Error()) return "" } return string(jsonInfo) } go-apps/meep-app-enablement/server/service-mgmt/model_problem_details.go +2 −2 Original line number Diff line number Diff line Loading @@ -29,9 +29,9 @@ type ProblemDetails struct { // A short, human-readable summary of the problem type Title string `json:"title,omitempty"` // The HTTP status code for this occurrence of the problem Status int32 `json:"status,omitempty"` Status int32 `json:"status"` // A human-readable explanation specific to this occurrence of the problem Detail string `json:"detail,omitempty"` Detail string `json:"detail"` // A URI reference that identifies the specific occurrence of the problem Instance string `json:"instance,omitempty"` } go-apps/meep-app-enablement/server/service-mgmt/service-mgmt.go +62 −51 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -198,7 +198,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -215,7 +215,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { err = decoder.Decode(&sInfoPost) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -223,38 +223,38 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { if sInfoPost.SerInstanceId != "" { errStr := "Service instance ID must not be present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.SerName == "" { errStr := "Mandatory Service Name parameter not present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.Version == "" { errStr := "Mandatory Service Version parameter not present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.State == nil { errStr := "Mandatory Service State parameter not present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.Serializer == nil { errStr := "Mandatory Serializer parameter not present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.SerCategory != nil { errStr := validateCategoryRef(sInfoPost.SerCategory) if errStr != "" { log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } } Loading @@ -262,7 +262,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { (sInfoPost.TransportId == "" && sInfoPost.TransportInfo == nil) { errStr := "Either transportId or transportInfo but not both shall be present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.TransportInfo != nil { Loading @@ -274,7 +274,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { sInfoPost.TransportInfo.Endpoint == nil { errStr := "Id, Name, Type, Protocol, Version, Endpoint are all mandatory parameters of TransportInfo" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } } Loading @@ -296,7 +296,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { err, retCode := setService(appId, sInfo, ServiceAvailabilityNotificationChangeType_ADDED) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), retCode) errHandlerProblemDetails(w, err.Error(), retCode) return } Loading @@ -319,7 +319,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -331,7 +331,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -357,7 +357,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { err = decoder.Decode(&sInfo) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -374,7 +374,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { if sInfoJson != sInfoPrevJson { errStr := "Only the ServiceInfo state property may be changed" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } Loading @@ -384,7 +384,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { err, retCode := setService(appId, &sInfo, ServiceAvailabilityNotificationChangeType_STATE_CHANGED) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), retCode) errHandlerProblemDetails(w, err.Error(), retCode) return } } Loading @@ -407,7 +407,7 @@ func appServicesByIdDELETE(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -419,7 +419,7 @@ func appServicesByIdDELETE(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -436,7 +436,7 @@ func appServicesByIdDELETE(w http.ResponseWriter, r *http.Request) { // Delete service err = delServiceById(appId, svcId) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading Loading @@ -464,7 +464,7 @@ func appServicesGET(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfoAnyMep(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -476,7 +476,7 @@ func appServicesGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -497,7 +497,7 @@ func appServicesByIdGET(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfoAnyMep(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -509,7 +509,7 @@ func appServicesByIdGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading Loading @@ -550,7 +550,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -562,7 +562,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -573,19 +573,19 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { err = decoder.Decode(&serAvailNotifSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } // Validate mandatory properties if serAvailNotifSub.CallbackReference == "" { log.Error("Mandatory CallbackReference parameter not present") http.Error(w, "Mandatory CallbackReference parameter not present", http.StatusBadRequest) errHandlerProblemDetails(w, "Mandatory CallbackReference parameter not present", http.StatusBadRequest) return } if serAvailNotifSub.SubscriptionType != SER_AVAILABILITY_NOTIF_SUB_TYPE { log.Error("SubscriptionType shall be SerAvailabilityNotificationSubscription") http.Error(w, "SubscriptionType shall be SerAvailabilityNotificationSubscription", http.StatusBadRequest) errHandlerProblemDetails(w, "SubscriptionType shall be SerAvailabilityNotificationSubscription", http.StatusBadRequest) return } Loading @@ -607,7 +607,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { errStr := validateCategoryRef(&categoryRef) if errStr != "" { log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } } Loading @@ -619,7 +619,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { if nbMutuallyExclusiveParams > 1 { errStr := "FilteringCriteria attributes serInstanceIds, serNames, serCategories are mutually-exclusive" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } } Loading @@ -640,7 +640,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { _, err = subMgr.CreateSubscription(subCfg, jsonSub) if err != nil { log.Error("Failed to create subscription") http.Error(w, "Failed to create subscription", http.StatusInternalServerError) errHandlerProblemDetails(w, "Failed to create subscription", http.StatusInternalServerError) return } Loading @@ -662,7 +662,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { // Get App instance info appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -674,7 +674,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -683,7 +683,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { sub, err := subMgr.GetSubscription(subId) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -691,7 +691,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { if sub.Cfg.AppId != appId || sub.Cfg.Type != SER_AVAILABILITY_NOTIF_SUB_TYPE { err = errors.New("Subscription not found") log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -712,7 +712,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { // Get App instance info appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -724,7 +724,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -733,7 +733,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { sub, err := subMgr.GetSubscription(subId) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -741,7 +741,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { if sub.Cfg.AppId != appId || sub.Cfg.Type != SER_AVAILABILITY_NOTIF_SUB_TYPE { err = errors.New("Subscription not found") log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -749,7 +749,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { err = subMgr.DeleteSubscription(sub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -768,7 +768,7 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) { // Get App instance info appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -780,7 +780,7 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading Loading @@ -839,7 +839,7 @@ func transportsGET(w http.ResponseWriter, r *http.Request) { jsonResponse, err := json.Marshal(transportInfoResp) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) Loading Loading @@ -978,7 +978,7 @@ func getServices(w http.ResponseWriter, r *http.Request, appId string) { validParams := []string{"ser_instance_id", "ser_name", "ser_category_id", "consumed_local_only", "is_local", "scope_of_locality"} err := validateQueryParams(q, validParams) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) errHandlerProblemDetails(w, err.Error(), http.StatusBadRequest) return } Loading @@ -1002,7 +1002,7 @@ func getServices(w http.ResponseWriter, r *http.Request, appId string) { // Make sure only 1 or none of the following are present: ser_instance_id, ser_name, ser_category_id err = validateServiceQueryParams(serInstanceId, serName, serCategoryId) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) errHandlerProblemDetails(w, err.Error(), http.StatusBadRequest) return } Loading Loading @@ -1031,7 +1031,7 @@ func getServices(w http.ResponseWriter, r *http.Request, appId string) { err = rc.ForEachJSONEntry(key, populateServiceInfoList, sInfoList) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -1039,7 +1039,7 @@ func getServices(w http.ResponseWriter, r *http.Request, appId string) { jsonResponse, err := json.Marshal(sInfoList.Services) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) Loading @@ -1051,7 +1051,7 @@ func getService(w http.ResponseWriter, r *http.Request, appId string, serviceId if serviceId == "" { errStr := "Invalid Service ID" log.Error(errStr) http.Error(w, errStr, http.StatusInternalServerError) errHandlerProblemDetails(w, errStr, http.StatusInternalServerError) return } Loading @@ -1068,7 +1068,7 @@ func getService(w http.ResponseWriter, r *http.Request, appId string, serviceId err := rc.ForEachJSONEntry(key, populateServiceInfoList, &sInfoList) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -1082,7 +1082,7 @@ func getService(w http.ResponseWriter, r *http.Request, appId string, serviceId jsonResponse, err := json.Marshal(sInfoList.Services[0]) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) Loading Loading @@ -1485,3 +1485,14 @@ func newSerAvailabilityNotifSubCfg(sub *SerAvailabilityNotificationSubscription, } return subCfg } func errHandlerProblemDetails(w http.ResponseWriter, error string, code int) { var pd ProblemDetails pd.Detail = error pd.Status = int32(code) jsonResponse := convertProblemDetailstoJson(&pd) w.WriteHeader(code) fmt.Fprint(w, jsonResponse) } Loading
go-apps/meep-app-enablement/api/service-mgmt/swagger.yaml +3 −0 Original line number Diff line number Diff line Loading @@ -412,6 +412,9 @@ components: type: string format: uri description: A URI reference that identifies the specific occurrence of the problem required: - status - detail GrantType: description: OAuth 2.0 grant type type: string Loading
go-apps/meep-app-enablement/server/service-mgmt/convert.go +9 −0 Original line number Diff line number Diff line Loading @@ -86,3 +86,12 @@ func convertSubscriptionLinkListToJson(obj *SubscriptionLinkList) string { } return string(jsonInfo) } func convertProblemDetailstoJson(probdetails *ProblemDetails) string { jsonInfo, err := json.Marshal(*probdetails) if err != nil { log.Error(err.Error()) return "" } return string(jsonInfo) }
go-apps/meep-app-enablement/server/service-mgmt/model_problem_details.go +2 −2 Original line number Diff line number Diff line Loading @@ -29,9 +29,9 @@ type ProblemDetails struct { // A short, human-readable summary of the problem type Title string `json:"title,omitempty"` // The HTTP status code for this occurrence of the problem Status int32 `json:"status,omitempty"` Status int32 `json:"status"` // A human-readable explanation specific to this occurrence of the problem Detail string `json:"detail,omitempty"` Detail string `json:"detail"` // A URI reference that identifies the specific occurrence of the problem Instance string `json:"instance,omitempty"` }
go-apps/meep-app-enablement/server/service-mgmt/service-mgmt.go +62 −51 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -198,7 +198,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -215,7 +215,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { err = decoder.Decode(&sInfoPost) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -223,38 +223,38 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { if sInfoPost.SerInstanceId != "" { errStr := "Service instance ID must not be present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.SerName == "" { errStr := "Mandatory Service Name parameter not present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.Version == "" { errStr := "Mandatory Service Version parameter not present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.State == nil { errStr := "Mandatory Service State parameter not present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.Serializer == nil { errStr := "Mandatory Serializer parameter not present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.SerCategory != nil { errStr := validateCategoryRef(sInfoPost.SerCategory) if errStr != "" { log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } } Loading @@ -262,7 +262,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { (sInfoPost.TransportId == "" && sInfoPost.TransportInfo == nil) { errStr := "Either transportId or transportInfo but not both shall be present" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } if sInfoPost.TransportInfo != nil { Loading @@ -274,7 +274,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { sInfoPost.TransportInfo.Endpoint == nil { errStr := "Id, Name, Type, Protocol, Version, Endpoint are all mandatory parameters of TransportInfo" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } } Loading @@ -296,7 +296,7 @@ func appServicesPOST(w http.ResponseWriter, r *http.Request) { err, retCode := setService(appId, sInfo, ServiceAvailabilityNotificationChangeType_ADDED) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), retCode) errHandlerProblemDetails(w, err.Error(), retCode) return } Loading @@ -319,7 +319,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -331,7 +331,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -357,7 +357,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { err = decoder.Decode(&sInfo) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -374,7 +374,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { if sInfoJson != sInfoPrevJson { errStr := "Only the ServiceInfo state property may be changed" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } Loading @@ -384,7 +384,7 @@ func appServicesByIdPUT(w http.ResponseWriter, r *http.Request) { err, retCode := setService(appId, &sInfo, ServiceAvailabilityNotificationChangeType_STATE_CHANGED) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), retCode) errHandlerProblemDetails(w, err.Error(), retCode) return } } Loading @@ -407,7 +407,7 @@ func appServicesByIdDELETE(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -419,7 +419,7 @@ func appServicesByIdDELETE(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -436,7 +436,7 @@ func appServicesByIdDELETE(w http.ResponseWriter, r *http.Request) { // Delete service err = delServiceById(appId, svcId) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading Loading @@ -464,7 +464,7 @@ func appServicesGET(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfoAnyMep(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -476,7 +476,7 @@ func appServicesGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -497,7 +497,7 @@ func appServicesByIdGET(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfoAnyMep(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -509,7 +509,7 @@ func appServicesByIdGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading Loading @@ -550,7 +550,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { // Get App instance appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -562,7 +562,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -573,19 +573,19 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { err = decoder.Decode(&serAvailNotifSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } // Validate mandatory properties if serAvailNotifSub.CallbackReference == "" { log.Error("Mandatory CallbackReference parameter not present") http.Error(w, "Mandatory CallbackReference parameter not present", http.StatusBadRequest) errHandlerProblemDetails(w, "Mandatory CallbackReference parameter not present", http.StatusBadRequest) return } if serAvailNotifSub.SubscriptionType != SER_AVAILABILITY_NOTIF_SUB_TYPE { log.Error("SubscriptionType shall be SerAvailabilityNotificationSubscription") http.Error(w, "SubscriptionType shall be SerAvailabilityNotificationSubscription", http.StatusBadRequest) errHandlerProblemDetails(w, "SubscriptionType shall be SerAvailabilityNotificationSubscription", http.StatusBadRequest) return } Loading @@ -607,7 +607,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { errStr := validateCategoryRef(&categoryRef) if errStr != "" { log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } } Loading @@ -619,7 +619,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { if nbMutuallyExclusiveParams > 1 { errStr := "FilteringCriteria attributes serInstanceIds, serNames, serCategories are mutually-exclusive" log.Error(errStr) http.Error(w, errStr, http.StatusBadRequest) errHandlerProblemDetails(w, errStr, http.StatusBadRequest) return } } Loading @@ -640,7 +640,7 @@ func applicationsSubscriptionsPOST(w http.ResponseWriter, r *http.Request) { _, err = subMgr.CreateSubscription(subCfg, jsonSub) if err != nil { log.Error("Failed to create subscription") http.Error(w, "Failed to create subscription", http.StatusInternalServerError) errHandlerProblemDetails(w, "Failed to create subscription", http.StatusInternalServerError) return } Loading @@ -662,7 +662,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { // Get App instance info appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -674,7 +674,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -683,7 +683,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { sub, err := subMgr.GetSubscription(subId) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -691,7 +691,7 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) { if sub.Cfg.AppId != appId || sub.Cfg.Type != SER_AVAILABILITY_NOTIF_SUB_TYPE { err = errors.New("Subscription not found") log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -712,7 +712,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { // Get App instance info appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -724,7 +724,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading @@ -733,7 +733,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { sub, err := subMgr.GetSubscription(subId) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -741,7 +741,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { if sub.Cfg.AppId != appId || sub.Cfg.Type != SER_AVAILABILITY_NOTIF_SUB_TYPE { err = errors.New("Subscription not found") log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -749,7 +749,7 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) { err = subMgr.DeleteSubscription(sub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -768,7 +768,7 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) { // Get App instance info appInfo, err := getAppInfo(appId) if err != nil { http.Error(w, err.Error(), http.StatusNotFound) errHandlerProblemDetails(w, err.Error(), http.StatusNotFound) return } Loading @@ -780,7 +780,7 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) { w.WriteHeader(code) fmt.Fprintf(w, problemDetails) } else { http.Error(w, err.Error(), code) errHandlerProblemDetails(w, err.Error(), code) } return } Loading Loading @@ -839,7 +839,7 @@ func transportsGET(w http.ResponseWriter, r *http.Request) { jsonResponse, err := json.Marshal(transportInfoResp) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) Loading Loading @@ -978,7 +978,7 @@ func getServices(w http.ResponseWriter, r *http.Request, appId string) { validParams := []string{"ser_instance_id", "ser_name", "ser_category_id", "consumed_local_only", "is_local", "scope_of_locality"} err := validateQueryParams(q, validParams) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) errHandlerProblemDetails(w, err.Error(), http.StatusBadRequest) return } Loading @@ -1002,7 +1002,7 @@ func getServices(w http.ResponseWriter, r *http.Request, appId string) { // Make sure only 1 or none of the following are present: ser_instance_id, ser_name, ser_category_id err = validateServiceQueryParams(serInstanceId, serName, serCategoryId) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) errHandlerProblemDetails(w, err.Error(), http.StatusBadRequest) return } Loading Loading @@ -1031,7 +1031,7 @@ func getServices(w http.ResponseWriter, r *http.Request, appId string) { err = rc.ForEachJSONEntry(key, populateServiceInfoList, sInfoList) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -1039,7 +1039,7 @@ func getServices(w http.ResponseWriter, r *http.Request, appId string) { jsonResponse, err := json.Marshal(sInfoList.Services) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) Loading @@ -1051,7 +1051,7 @@ func getService(w http.ResponseWriter, r *http.Request, appId string, serviceId if serviceId == "" { errStr := "Invalid Service ID" log.Error(errStr) http.Error(w, errStr, http.StatusInternalServerError) errHandlerProblemDetails(w, errStr, http.StatusInternalServerError) return } Loading @@ -1068,7 +1068,7 @@ func getService(w http.ResponseWriter, r *http.Request, appId string, serviceId err := rc.ForEachJSONEntry(key, populateServiceInfoList, &sInfoList) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } Loading @@ -1082,7 +1082,7 @@ func getService(w http.ResponseWriter, r *http.Request, appId string, serviceId jsonResponse, err := json.Marshal(sInfoList.Services[0]) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) errHandlerProblemDetails(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) Loading Loading @@ -1485,3 +1485,14 @@ func newSerAvailabilityNotifSubCfg(sub *SerAvailabilityNotificationSubscription, } return subCfg } func errHandlerProblemDetails(w http.ResponseWriter, error string, code int) { var pd ProblemDetails pd.Detail = error pd.Status = int32(code) jsonResponse := convertProblemDetailstoJson(&pd) w.WriteHeader(code) fmt.Fprint(w, jsonResponse) }