Search in sources :

Example 1 with RestAccessControl

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

the class CategoryController method getCategories.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getCategories(@RequestParam(value = "parentCode", required = false, defaultValue = "home") String parentCode) {
    logger.debug("getting category tree for parent {}", parentCode);
    List<CategoryDto> result = this.getCategoryService().getTree(parentCode);
    Map<String, String> metadata = new HashMap<>();
    metadata.put("parentCode", parentCode);
    return new ResponseEntity<>(new RestResponse(result, new ArrayList<>(), metadata), HttpStatus.OK);
}
Also used : CategoryDto(org.entando.entando.aps.system.services.category.model.CategoryDto) ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) ArrayList(java.util.ArrayList) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with RestAccessControl

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

the class DatabaseController method deleteDumpReport.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/report/{reportCode}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> deleteDumpReport(@PathVariable String reportCode) {
    logger.debug("Deleting dump report -> code {}", reportCode);
    this.getDatabaseService().deleteDumpReport(reportCode);
    logger.debug("Deleted dump report -> {}", reportCode);
    Map<String, String> response = new HashMap<>();
    response.put("code", reportCode);
    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 3 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 4 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 5 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)

Aggregations

RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)118 ResponseEntity (org.springframework.http.ResponseEntity)108 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)84 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)45 RestResponse (org.entando.entando.web.common.model.RestResponse)42 HashMap (java.util.HashMap)36 ResourceNotFoundException (org.entando.entando.aps.system.exception.ResourceNotFoundException)9 ActivityStreamAuditable (org.entando.entando.web.common.annotation.ActivityStreamAuditable)9 PageDto (org.entando.entando.aps.system.services.page.model.PageDto)8 UserDto (org.entando.entando.aps.system.services.user.model.UserDto)7 ArrayList (java.util.ArrayList)6 DataModelDto (org.entando.entando.aps.system.services.dataobjectmodel.model.DataModelDto)6 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)5 RoleDto (org.entando.entando.aps.system.services.role.model.RoleDto)5 ActionLogRecordDto (org.entando.entando.aps.system.services.actionlog.model.ActionLogRecordDto)4 CategoryDto (org.entando.entando.aps.system.services.category.model.CategoryDto)4 LabelDto (org.entando.entando.aps.system.services.label.model.LabelDto)4 PageConfigurationDto (org.entando.entando.aps.system.services.page.model.PageConfigurationDto)4 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)4 DataTypeDto (org.entando.entando.aps.system.services.dataobject.model.DataTypeDto)3