Search in sources :

Example 41 with RestAccessControl

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

the class UserSettingsController method getUserSettings.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getUserSettings() {
    logger.debug("loading user settings");
    UserSettingsDto userSettings = this.getUserSettingsService().getUserSettings();
    return new ResponseEntity<>(new RestResponse(userSettings), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) UserSettingsDto(org.entando.entando.aps.system.services.usersettings.model.UserSettingsDto) RestResponse(org.entando.entando.web.common.model.RestResponse) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with RestAccessControl

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

the class WidgetController method updateWidget.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/widgets/{widgetCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, name = "widget")
public ResponseEntity<RestResponse> updateWidget(@PathVariable String widgetCode, @Valid @RequestBody WidgetRequest widgetRequest, BindingResult bindingResult) {
    logger.trace("update widget. Code: {} and body {}: ", widgetCode, widgetRequest);
    // field validations
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    this.widgetValidator.validateWidgetCode(widgetCode, widgetRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    WidgetDto widgetDto = this.widgetService.updateWidget(widgetCode, widgetRequest);
    return new ResponseEntity<>(new RestResponse(widgetDto), 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) WidgetDto(org.entando.entando.aps.system.services.widgettype.model.WidgetDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 43 with RestAccessControl

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

the class WidgetController method getWidgets.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/widgets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getWidgets(RestListRequest requestList) {
    logger.trace("get widget list {}", requestList);
    this.getWidgetValidator().validateRestListRequest(requestList);
    PagedMetadata<WidgetDto> result = this.widgetService.getWidgets(requestList);
    this.getWidgetValidator().validateRestListResult(requestList, 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) WidgetDto(org.entando.entando.aps.system.services.widgettype.model.WidgetDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 44 with RestAccessControl

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

the class WidgetController method addWidget.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/widgets", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, name = "widget")
public ResponseEntity<RestResponse> addWidget(@Valid @RequestBody WidgetRequest widgetRequest, BindingResult bindingResult) throws ApsSystemException {
    logger.trace("add widget. body {}: ", widgetRequest);
    // field validations
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    // business validations
    this.widgetValidator.validate(widgetRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    WidgetDto widgetDto = this.widgetService.addWidget(widgetRequest);
    return new ResponseEntity<>(new RestResponse(widgetDto), 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) WidgetDto(org.entando.entando.aps.system.services.widgettype.model.WidgetDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 45 with RestAccessControl

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

the class DatabaseController method initBackup.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/initBackup", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> initBackup() {
    logger.debug("Required actual component configuration");
    List<ComponentDto> dtos = this.getDatabaseService().getCurrentComponents();
    logger.debug("Actual component configuration -> {}", dtos);
    return new ResponseEntity<>(new RestResponse(dtos), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) ComponentDto(org.entando.entando.aps.system.services.database.model.ComponentDto) 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