Search in sources :

Example 6 with RestAccessControl

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

the class DatabaseController method getStatus.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/status", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getStatus() {
    Integer status = this.getDatabaseService().getStatus();
    Map<String, String> response = new HashMap<>();
    response.put("status", String.valueOf(status));
    logger.debug("Required database status -> {}", status);
    return new ResponseEntity<>(new RestResponse(response), 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)

Example 7 with RestAccessControl

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

the class DatabaseController method getDumpReports.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getDumpReports(@Valid RestListRequest requestList) {
    this.getDatabaseValidator().validateRestListRequest(requestList);
    PagedMetadata<ShortDumpReportDto> result = this.getDatabaseService().getShortDumpReportDtos(requestList);
    this.getDatabaseValidator().validateRestListResult(requestList, result);
    return new ResponseEntity<>(new RestResponse(result.getBody(), new ArrayList<>(), result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) ArrayList(java.util.ArrayList) ShortDumpReportDto(org.entando.entando.aps.system.services.database.model.ShortDumpReportDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with RestAccessControl

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

the class DatabaseController method startBackup.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/startBackup", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> startBackup() throws Throwable {
    logger.debug("Starting database backup");
    this.getDatabaseService().startDatabaseBackup();
    Map<String, String> response = new HashMap<>();
    response.put("status", String.valueOf(this.getDatabaseService().getStatus()));
    logger.debug("Database backup started");
    return new ResponseEntity<>(new RestResponse(response), 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)

Example 9 with RestAccessControl

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

the class DataTypeController method deleteDataType.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataTypeCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteDataType(@PathVariable String dataTypeCode) throws ApsSystemException {
    logger.debug("Deleting data type -> {}", dataTypeCode);
    this.getDataObjectService().deleteDataType(dataTypeCode);
    Map<String, String> payload = new HashMap<>();
    payload.put("code", dataTypeCode);
    return new ResponseEntity<>(new RestResponse(payload), 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)

Example 10 with RestAccessControl

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

the class DataTypeController method updateDataType.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataTypeCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateDataType(@PathVariable String dataTypeCode, @Valid @RequestBody DataTypeDtoRequest request, BindingResult bindingResult) throws JsonProcessingException {
    int result = this.getDataTypeValidator().validateBodyName(dataTypeCode, request, bindingResult);
    if (bindingResult.hasErrors()) {
        if (result == 404) {
            throw new RestRourceNotFoundException(DataTypeValidator.ERRCODE_ENTITY_TYPE_DOES_NOT_EXIST, "data type", dataTypeCode);
        } else {
            throw new ValidationGenericException(bindingResult);
        }
    }
    DataTypeDto dto = this.getDataObjectService().updateDataType(request, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    logger.debug("Main Response -> {}", dto);
    return new ResponseEntity<>(new RestResponse(dto), HttpStatus.OK);
}
Also used : RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) DataTypeDto(org.entando.entando.aps.system.services.dataobject.model.DataTypeDto) 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