[RICPLT-2157] Restructure handlers and converters.......
[ric-plt/e2mgr.git] / E2Manager / controllers / nodeb_controller.go
index a3136f0..802537d 100644 (file)
@@ -72,8 +72,7 @@ type NodebController struct {
        rnibWriterProvider func() rNibWriter.RNibWriter
 }
 
-func NewNodebController(logger *logger.Logger, rmrService *services.RmrService, rnibReaderProvider func() reader.RNibReader,
-       rnibWriterProvider func() rNibWriter.RNibWriter) *NodebController {
+func NewNodebController(logger *logger.Logger, rmrService *services.RmrService, rnibReaderProvider func() reader.RNibReader, rnibWriterProvider func() rNibWriter.RNibWriter) *NodebController {
        messageChannel = make(chan *models.E2RequestMessage)
        errorChannel = make(chan error)
        return &NodebController{
@@ -158,7 +157,7 @@ func (rc NodebController) GetNodebIdList (writer http.ResponseWriter, request *h
                return;
        }
 
-       pmList := utils.ConvertNodebIdListToProtoMessageList(*nodebIdList)
+       pmList := utils.ConvertNodebIdListToProtoMessageList(nodebIdList)
        result, err := utils.MarshalProtoMessageListToJsonArray(pmList)
 
        if err != nil {
@@ -250,13 +249,13 @@ func printHandlingRequestElapsedTimeInMs(logger *logger.Logger, startTime time.T
                float64(time.Since(startTime))/float64(time.Millisecond))
 }
 
-func rnibErrorToHttpError(rnibError common.IRNibError) (int, int, string) {
-       switch rnibError.GetCode() {
-       case common.RESOURCE_NOT_FOUND:
+func rnibErrorToHttpError(rnibError error) (int, int, string) {
+       switch rnibError.(type) {
+       case *common.ResourceNotFoundError:
                return http.StatusNotFound, notFoundErrorCode, notFoundErrorMessage
-       case common.INTERNAL_ERROR:
+       case *common.InternalError:
                return http.StatusInternalServerError, internalErrorCode, internalErrorMessage
-       case common.VALIDATION_ERROR:
+       case *common.ValidationError:
                return http.StatusBadRequest, validationErrorCode, validationFailedMessage
        default:
                return http.StatusInternalServerError, internalErrorCode, internalErrorMessage