Search in sources :

Example 66 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class DataObjectModelController method updateGroup.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataModelId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateGroup(@PathVariable String dataModelId, @Valid @RequestBody DataObjectModelRequest dataObjectModelRequest, BindingResult bindingResult) throws JsonProcessingException {
    logger.debug("Updating data object model -> {}", dataObjectModelRequest.getModelId());
    // field validations
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    this.getDataObjectModelValidator().validateBodyName(dataModelId, dataObjectModelRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    int result = this.getDataObjectModelValidator().validateBody(dataObjectModelRequest, true, bindingResult);
    if (bindingResult.hasErrors()) {
        if (404 == result) {
            if (1 == bindingResult.getFieldErrorCount("type")) {
                throw new RestRourceNotFoundException(DataObjectModelValidator.ERRCODE_PUT_DATAOBJECTTYPE_DOES_NOT_EXIST, "type", dataObjectModelRequest.getType());
            } else {
                throw new RestRourceNotFoundException(DataObjectModelValidator.ERRCODE_DATAOBJECTMODEL_ALREADY_EXISTS, "modelId", dataObjectModelRequest.getModelId());
            }
        } else {
            throw new ValidationGenericException(bindingResult);
        }
    }
    DataModelDto dataModelDto = this.getDataObjectModelService().updateDataObjectModel(dataObjectModelRequest);
    logger.debug("Main Response -> {}", dataModelDto);
    return new ResponseEntity<>(new RestResponse(dataModelDto), HttpStatus.OK);
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) DataModelDto(org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto) ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 67 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class DataObjectModelController method getDataObjectModels.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getDataObjectModels(RestListRequest requestList) {
    this.getDataObjectModelValidator().validateRestListRequest(requestList);
    PagedMetadata<DataModelDto> result = this.getDataObjectModelService().getDataObjectModels(requestList);
    this.getDataObjectModelValidator().validateRestListResult(requestList, result);
    logger.debug("Main Response -> {}", result);
    return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
Also used : DataModelDto(org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto) ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 68 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class EntityManagerController method getEntityManagers.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getEntityManagers(RestListRequest requestList) throws JsonProcessingException {
    PagedMetadata<String> result = this.getEntityManagerService().getEntityManagers(requestList);
    logger.debug("Main Response -> {}", result);
    return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 69 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class GroupController method getGroups.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getGroups(RestListRequest requestList) throws JsonProcessingException {
    this.getGroupValidator().validateRestListRequest(requestList);
    PagedMetadata<GroupDto> result = this.getGroupService().getGroups(requestList);
    this.getGroupValidator().validateRestListResult(requestList, result);
    logger.debug("Main Response -> {}", result);
    return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) GroupDto(org.entando.entando.aps.system.services.group.model.GroupDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 70 with ResponseEntity

use of org.springframework.http.ResponseEntity in project entando-core by entando.

the class GuiFragmentController method getGuiFragments.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getGuiFragments(RestListRequest requestList) throws JsonProcessingException {
    this.getGuiFragmentValidator().validateRestListRequest(requestList);
    PagedMetadata<GuiFragmentDtoSmall> result = this.getGuiFragmentService().getGuiFragments(requestList);
    this.getGuiFragmentValidator().validateRestListResult(requestList, result);
    logger.debug("Main Response -> {}", result);
    return new ResponseEntity<>(new RestResponse(result.getBody(), null, result), HttpStatus.OK);
}
Also used : GuiFragmentDtoSmall(org.entando.entando.aps.system.services.guifragment.model.GuiFragmentDtoSmall) ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ResponseEntity (org.springframework.http.ResponseEntity)1188 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)419 HttpHeaders (org.springframework.http.HttpHeaders)398 Test (org.junit.Test)120 ApiOperation (io.swagger.annotations.ApiOperation)116 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)108 HashMap (java.util.HashMap)104 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)103 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)98 HttpStatus (org.springframework.http.HttpStatus)88 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)85 ArrayList (java.util.ArrayList)80 GetMapping (org.springframework.web.bind.annotation.GetMapping)79 Timed (com.codahale.metrics.annotation.Timed)68 IOException (java.io.IOException)67 List (java.util.List)65 URI (java.net.URI)49 MediaType (org.springframework.http.MediaType)48 Test (org.junit.jupiter.api.Test)46 HttpEntity (org.springframework.http.HttpEntity)46