Search in sources :

Example 16 with RestAccessControl

use of org.entando.entando.web.common.annotation.RestAccessControl 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 17 with RestAccessControl

use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.

the class GroupController method updateGroup.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{groupCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateGroup(@PathVariable String groupCode, @Valid @RequestBody GroupRequest groupRequest, BindingResult bindingResult) {
    // field validations
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    this.getGroupValidator().validateBodyName(groupCode, groupRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    GroupDto group = this.getGroupService().updateGroup(groupCode, groupRequest.getName());
    return new ResponseEntity<>(new RestResponse(group), 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) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with RestAccessControl

use of org.entando.entando.web.common.annotation.RestAccessControl 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)

Example 19 with RestAccessControl

use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.

the class GuiFragmentController method addGuiFragment.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> addGuiFragment(@Valid @RequestBody GuiFragmentRequestBody guiFragmentRequest, BindingResult bindingResult) throws ApsSystemException {
    // field validations
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    // business validations
    this.getGuiFragmentValidator().validate(guiFragmentRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    GuiFragmentDto fragment = this.getGuiFragmentService().addGuiFragment(guiFragmentRequest);
    return new ResponseEntity<>(new RestResponse(fragment), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) GuiFragmentDto(org.entando.entando.aps.system.services.guifragment.model.GuiFragmentDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with RestAccessControl

use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.

the class GuiFragmentController method deleteGuiFragment.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{fragmentCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteGuiFragment(@PathVariable String fragmentCode) throws ApsSystemException {
    logger.info("deleting {}", fragmentCode);
    this.getGuiFragmentService().removeGuiFragment(fragmentCode);
    Map<String, String> result = new HashMap<>();
    result.put("code", fragmentCode);
    return new ResponseEntity<>(new RestResponse(result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)87 RestResponse (org.entando.entando.web.common.model.RestResponse)86 ResponseEntity (org.springframework.http.ResponseEntity)86 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)86 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)34 HashMap (java.util.HashMap)33 ArrayList (java.util.ArrayList)14 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)8 PageDto (org.entando.entando.aps.system.services.page.model.PageDto)7 UserDto (org.entando.entando.aps.system.services.user.model.UserDto)6 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)5 CategoryDto (org.entando.entando.aps.system.services.category.model.CategoryDto)4 DataModelDto (org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto)4 LabelDto (org.entando.entando.aps.system.services.label.model.LabelDto)4 RoleDto (org.entando.entando.aps.system.services.role.model.RoleDto)4 WidgetDto (org.entando.entando.aps.system.services.widgettype.model.WidgetDto)4 DataTypeDto (org.entando.entando.aps.system.services.dataobject.model.DataTypeDto)3 GroupDto (org.entando.entando.aps.system.services.group.model.GroupDto)3 LanguageDto (org.entando.entando.aps.system.services.language.LanguageDto)3 PageModelDto (org.entando.entando.aps.system.services.pagemodel.model.PageModelDto)3