Search in sources :

Example 61 with ResponseEntity

use of org.springframework.http.ResponseEntity 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 62 with ResponseEntity

use of org.springframework.http.ResponseEntity 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 63 with ResponseEntity

use of org.springframework.http.ResponseEntity 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 64 with ResponseEntity

use of org.springframework.http.ResponseEntity 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 65 with ResponseEntity

use of org.springframework.http.ResponseEntity 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)

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