Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions adminapi/dcm/dcmformula_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ func UpdateDcmFormulaHandler(w http.ResponseWriter, r *http.Request) {
// r.Body is already drained in the middleware
xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("failed to cast response writer to XResponseWriter in UpdateDcmFormulaHandler")
xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, "unable to cast XResponseWriter object")
return
}
Expand Down Expand Up @@ -353,6 +354,7 @@ func DcmFormulaSettingsAvailabilitygHandler(w http.ResponseWriter, r *http.Reque
// r.Body is already drained in the middleware
xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("failed to cast response writer to XResponseWriter in DcmFormulaSettingsAvailabilitygHandler")
xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, "responsewriter cast error")
return
}
Expand Down Expand Up @@ -394,6 +396,7 @@ func DcmFormulasAvailabilitygHandler(w http.ResponseWriter, r *http.Request) {
// r.Body is already drained in the middleware
xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("failed to cast response writer to XResponseWriter in DcmFormulasAvailabilitygHandler")
xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, "responsewriter cast error")
return
}
Expand Down Expand Up @@ -425,6 +428,7 @@ func PostDcmFormulaFilteredWithParamsHandler(w http.ResponseWriter, r *http.Requ

xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("failed to cast response writer to XResponseWriter in PostDcmFormulaFilteredWithParamsHandler")
xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, "responsewriter cast error")
return
}
Expand Down Expand Up @@ -518,6 +522,7 @@ func DcmFormulaChangePriorityHandler(w http.ResponseWriter, r *http.Request) {

for _, entry := range reorganizedFormulas {
if err = db.GetCachedSimpleDao().SetOne(db.TABLE_DCM_RULE, entry.GetID(), entry); err != nil {
log.WithFields(log.Fields{"entity_id": entry.GetID(), "error": err}).Error("failed to update dcm formula priority")
xhttp.WriteAdminErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("unable to update dcm rule: %s", err))
return
}
Expand Down
5 changes: 5 additions & 0 deletions adminapi/dcm/dcmformula_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/rdkcentral/xconfwebconfig/rulesengine"
re "github.com/rdkcentral/xconfwebconfig/rulesengine"
"github.com/rdkcentral/xconfwebconfig/shared/logupload"
log "github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -79,6 +80,7 @@ func DeleteDcmFormulabyId(id string, appType string) *xcommon.ResponseEntity {

err = DeleteOneDcmFormula(id, appType)
if err != nil {
log.WithFields(log.Fields{"entity_id": id, "error": err}).Error("failed to delete dcm formula")
return xcommon.NewResponseEntityWithStatus(http.StatusInternalServerError, err, nil)
}

Expand Down Expand Up @@ -231,6 +233,7 @@ func CreateDcmRule(dfrule *logupload.DCMGenericRule, appType string) *xwhttp.Res
for _, entry := range changedDcmRules {
entry.(*logupload.DCMGenericRule).Updated = util.GetTimestamp()
if err := db.GetCachedSimpleDao().SetOne(db.TABLE_DCM_RULE, entry.GetID(), entry); err != nil {
log.WithFields(log.Fields{"entity_id": entry.GetID(), "error": err}).Error("failed to create dcm formula")
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log message is misleading: the failing SetOne call is persisting a mix of new and re-prioritized existing rules after reorganization, not strictly "create". Consider using wording like "failed to persist dcm rule changes" (and/or include operation context) so logs are accurate during priority rebalancing failures.

Suggested change
log.WithFields(log.Fields{"entity_id": entry.GetID(), "error": err}).Error("failed to create dcm formula")
log.WithFields(log.Fields{"entity_id": entry.GetID(), "error": err}).Error("failed to persist dcm rule changes")

Copilot uses AI. Check for mistakes.
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}
}
Expand Down Expand Up @@ -271,6 +274,7 @@ func UpdateDcmRule(incomingFormula *logupload.DCMGenericRule, appType string) *x
if incomingFormula.Priority == existingFormula.Priority {
incomingFormula.Updated = util.GetTimestamp()
if err := db.GetCachedSimpleDao().SetOne(db.TABLE_DCM_RULE, incomingFormula.ID, incomingFormula); err != nil {
log.WithFields(log.Fields{"entity_id": incomingFormula.ID, "error": err}).Error("failed to update dcm formula")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}
} else {
Expand All @@ -279,6 +283,7 @@ func UpdateDcmRule(incomingFormula *logupload.DCMGenericRule, appType string) *x
for _, entry := range changedFormulae {
entry.(*logupload.DCMGenericRule).Updated = util.GetTimestamp()
if err := db.GetCachedSimpleDao().SetOne(db.TABLE_DCM_RULE, entry.GetID(), entry); err != nil {
log.WithFields(log.Fields{"entity_id": entry.GetID(), "error": err}).Error("failed to update dcm formula priority")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}
}
Expand Down
3 changes: 3 additions & 0 deletions adminapi/dcm/device_settings_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func DeleteDeviceSettingsbyId(id string, app string) *xwhttp.ResponseEntity {

err = DeleteOneDeviceSettings(id)
if err != nil {
log.WithFields(log.Fields{"entity_id": id, "error": err}).Error("failed to delete device settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand Down Expand Up @@ -181,6 +182,7 @@ func CreateDeviceSettings(dset *logupload.DeviceSettings, app string) *xwhttp.Re

dset.Updated = util.GetTimestamp()
if err := db.GetCachedSimpleDao().SetOne(db.TABLE_DEVICE_SETTINGS, dset.ID, dset); err != nil {
log.WithFields(log.Fields{"entity_id": dset.ID, "error": err}).Error("failed to create device settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand All @@ -207,6 +209,7 @@ func UpdateDeviceSettings(dset *logupload.DeviceSettings, app string) *xwhttp.Re

dset.Updated = util.GetTimestamp()
if err := db.GetCachedSimpleDao().SetOne(db.TABLE_DEVICE_SETTINGS, dset.ID, dset); err != nil {
log.WithFields(log.Fields{"entity_id": dset.ID, "error": err}).Error("failed to update device settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}
return xwhttp.NewResponseEntity(http.StatusOK, nil, dset)
Expand Down
3 changes: 3 additions & 0 deletions adminapi/dcm/logrepo_settings_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func DeleteLogRepoSettingsbyId(id string, app string) *xwhttp.ResponseEntity {

err = DeleteOneLogRepoSettings(id)
if err != nil {
log.WithFields(log.Fields{"entity_id": id, "error": err}).Error("failed to delete log repo settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand Down Expand Up @@ -200,6 +201,7 @@ func CreateLogRepoSettings(lr *logupload.UploadRepository, app string) *xwhttp.R
}
lr.Updated = util.GetTimestamp()
if err = db.GetCachedSimpleDao().SetOne(db.TABLE_UPLOAD_REPOSITORY, lr.ID, lr); err != nil {
log.WithFields(log.Fields{"entity_id": lr.ID, "error": err}).Error("failed to create log repo settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}
return xwhttp.NewResponseEntity(http.StatusCreated, nil, lr)
Expand Down Expand Up @@ -227,6 +229,7 @@ func UpdateLogRepoSettings(lr *logupload.UploadRepository, app string) *xwhttp.R

lr.Updated = util.GetTimestamp()
if err = db.GetCachedSimpleDao().SetOne(db.TABLE_UPLOAD_REPOSITORY, lr.ID, lr); err != nil {
log.WithFields(log.Fields{"entity_id": lr.ID, "error": err}).Error("failed to update log repo settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand Down
3 changes: 3 additions & 0 deletions adminapi/dcm/logupload_settings_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func DeleteLogUploadSettingsbyId(id string, app string) *xwhttp.ResponseEntity {
}
err := DeleteOneLogUploadSettings(id)
if err != nil {
log.WithFields(log.Fields{"entity_id": id, "error": err}).Error("failed to delete log upload settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand Down Expand Up @@ -169,6 +170,7 @@ func CreateLogUploadSettings(lu *logupload.LogUploadSettings, app string) *xwhtt

lu.Updated = util.GetTimestamp()
if err := ds.GetCachedSimpleDao().SetOne(ds.TABLE_LOG_UPLOAD_SETTINGS, lu.ID, lu); err != nil {
log.WithFields(log.Fields{"entity_id": lu.ID, "error": err}).Error("failed to create log upload settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand All @@ -195,6 +197,7 @@ func UpdateLogUploadSettings(lu *logupload.LogUploadSettings, app string) *xwhtt

lu.Updated = util.GetTimestamp()
if err := ds.GetCachedSimpleDao().SetOne(ds.TABLE_LOG_UPLOAD_SETTINGS, lu.ID, lu); err != nil {
log.WithFields(log.Fields{"entity_id": lu.ID, "error": err}).Error("failed to update log upload settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand Down
1 change: 1 addition & 0 deletions adminapi/dcm/test_page_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func DcmTestPageHandler(w http.ResponseWriter, r *http.Request) {

xw, ok := w.(*xwhttp.XResponseWriter)
if !ok {
log.Error("unable to cast response writer to XResponseWriter in DcmTestPageHandler")
xhttp.AdminError(w, xwcommon.NewRemoteErrorAS(http.StatusInternalServerError, "responsewriter cast error"))
return
}
Expand Down
3 changes: 3 additions & 0 deletions adminapi/dcm/vod_settings_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func DeleteVodSettingsbyId(id string, app string) *xwhttp.ResponseEntity {

err = DeleteOneVodSettings(id)
if err != nil {
log.WithFields(log.Fields{"entity_id": id, "error": err}).Error("failed to delete vod settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand Down Expand Up @@ -180,6 +181,7 @@ func CreateVodSettings(vs *logupload.VodSettings, app string) *xwhttp.ResponseEn

vs.Updated = xutil.GetTimestamp()
if err := db.GetCachedSimpleDao().SetOne(db.TABLE_VOD_SETTINGS, vs.ID, vs); err != nil {
log.WithFields(log.Fields{"entity_id": vs.ID, "error": err}).Error("failed to create vod settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand All @@ -203,6 +205,7 @@ func UpdateVodSettings(vs *logupload.VodSettings, app string) *xwhttp.ResponseEn

vs.Updated = xwutil.GetTimestamp()
if err := db.GetCachedSimpleDao().SetOne(db.TABLE_VOD_SETTINGS, vs.ID, vs); err != nil {
log.WithFields(log.Fields{"entity_id": vs.ID, "error": err}).Error("failed to update vod settings")
return xwhttp.NewResponseEntity(http.StatusInternalServerError, err, nil)
}

Expand Down
Loading