use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataObjectModelController method getDictionary.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dictionary", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<IEntityModelDictionary>> getDictionary(@RequestParam(value = "typeCode", required = false) String typeCode) {
logger.debug("loading data model dictionary {}", typeCode);
IEntityModelDictionary dictionary = this.getDataObjectModelService().getDataModelDictionary(typeCode);
return new ResponseEntity<>(new SimpleRestResponse<>(dictionary), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataObjectModelController method deleteDataObjectModel.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataModelId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<Map>> deleteDataObjectModel(@PathVariable String dataModelId) throws ApsSystemException {
logger.info("deleting data object model -> {}", dataModelId);
MapBindingResult bindingResult = new MapBindingResult(new HashMap<>(), "dataModels");
Long dataId = this.getDataObjectModelValidator().checkValidModelId(dataModelId, bindingResult);
if (null == dataId) {
throw new ValidationGenericException(bindingResult);
}
this.getDataObjectModelService().removeDataObjectModel(Long.parseLong(dataModelId));
Map<String, String> payload = new HashMap<>();
payload.put("modelId", dataModelId);
return new ResponseEntity<>(new SimpleRestResponse<>(payload), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class GroupController method addGroup.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<GroupDto>> addGroup(@Valid @RequestBody GroupRequest groupRequest, BindingResult bindingResult) throws ApsSystemException {
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
getGroupValidator().validate(groupRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationConflictException(bindingResult);
}
GroupDto dto = this.getGroupService().addGroup(groupRequest);
return new ResponseEntity<>(new SimpleRestResponse<>(dto), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DatabaseController method getDumpReport.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/report/{reportCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<DumpReportDto>> getDumpReport(@PathVariable String reportCode) {
logger.debug("Required dump report -> code {}", reportCode);
DumpReportDto result = this.getDatabaseService().getDumpReportDto(reportCode);
logger.debug("Extracted dump report -> {}", result);
return new ResponseEntity<>(new SimpleRestResponse<>(result), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataTypeController method updateDataTypeAttribute.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes/{dataTypeCode}/attribute/{attributeCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<EntityTypeAttributeFullDto, Map<String, String>>> updateDataTypeAttribute(@PathVariable String dataTypeCode, @PathVariable String attributeCode, @Valid @RequestBody EntityTypeAttributeFullDto bodyRequest, BindingResult bindingResult) throws JsonProcessingException {
logger.debug("Data type {} - Updating attribute {}", dataTypeCode, bodyRequest);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
} else if (!StringUtils.equals(attributeCode, bodyRequest.getCode())) {
bindingResult.rejectValue("code", DataTypeValidator.ERRCODE_URINAME_MISMATCH, new String[] { attributeCode, bodyRequest.getCode() }, "entityType.attribute.code.mismatch");
throw new ValidationConflictException(bindingResult);
}
EntityTypeAttributeFullDto result = this.getDataObjectService().updateDataTypeAttribute(dataTypeCode, bodyRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
logger.debug("Main Response -> {}", result);
Map<String, String> metadata = new HashMap<>();
metadata.put("dataTypeCode", dataTypeCode);
return new ResponseEntity<>(new RestResponse<>(result, metadata), HttpStatus.OK);
}
Aggregations