use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataObjectModelController method addDataObjectModel.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<DataModelDto>> addDataObjectModel(@Valid @RequestBody DataObjectModelRequest dataObjectModelRequest, BindingResult bindingResult) throws JsonProcessingException {
logger.debug("Adding data object model -> {}", dataObjectModelRequest.getModelId());
// field validations
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
this.getDataObjectModelValidator().validate(dataObjectModelRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
int result = this.getDataObjectModelValidator().validateBody(dataObjectModelRequest, false, bindingResult);
if (bindingResult.hasErrors()) {
if (404 == result) {
throw new ResourceNotFoundException(DataObjectModelValidator.ERRCODE_POST_DATAOBJECTTYPE_DOES_NOT_EXIST, "type", dataObjectModelRequest.getType());
} else {
throw new ValidationGenericException(bindingResult);
}
}
DataModelDto dataModelDto = this.getDataObjectModelService().addDataObjectModel(dataObjectModelRequest);
logger.debug("Main Response -> {}", dataModelDto);
return new ResponseEntity<>(new SimpleRestResponse<>(dataModelDto), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class ActivityStreamController method addLike.
@RestAccessControl(permission = Permission.ENTER_BACKEND)
@RequestMapping(value = "/{recordId}/like", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<ActionLogRecordDto>> addLike(@PathVariable int recordId, HttpServletRequest request) throws JsonProcessingException {
ActionLogRecordDto result = this.getActivityStreamService().addLike(recordId, (UserDetails) request.getSession().getAttribute("user"));
logger.debug("adding like to activity stream record", 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 CategoryController method getCategory.
@RestAccessControl(permission = { Permission.MANAGE_CATEGORIES, Permission.CONTENT_EDITOR })
@RequestMapping(value = "/{categoryCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<CategoryDto>> getCategory(@PathVariable String categoryCode) {
logger.debug("getting category {}", categoryCode);
CategoryDto category = this.getCategoryService().getCategory(categoryCode);
return new ResponseEntity<>(new SimpleRestResponse<>(category), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class CategoryController method addCategory.
@RestAccessControl(permission = Permission.MANAGE_CATEGORIES)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<CategoryDto>> addCategory(@Valid @RequestBody CategoryDto categoryRequest, BindingResult bindingResult) throws ApsSystemException {
// field validations
this.getCategoryValidator().validate(categoryRequest, bindingResult);
if (bindingResult.hasErrors()) {
throw new ValidationGenericException(bindingResult);
}
// business validations
this.getCategoryValidator().validatePostReferences(categoryRequest, bindingResult);
CategoryDto category = this.getCategoryService().addCategory(categoryRequest);
return new ResponseEntity<>(new SimpleRestResponse<>(category), HttpStatus.OK);
}
use of org.entando.entando.web.common.annotation.RestAccessControl in project entando-core by entando.
the class DataTypeController method getDataTypeAttribute.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes/{dataTypeCode}/attribute/{attributeCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<EntityTypeAttributeFullDto, Map<String, String>>> getDataTypeAttribute(@PathVariable String dataTypeCode, @PathVariable String attributeCode) throws JsonProcessingException {
logger.debug("Requested data type {} - attribute {}", dataTypeCode, attributeCode);
EntityTypeAttributeFullDto dto = this.getDataObjectService().getDataTypeAttribute(dataTypeCode, attributeCode);
logger.debug("Main Response -> {}", dto);
Map<String, String> metadata = new HashMap<>();
metadata.put("dataTypeCode", dataTypeCode);
return new ResponseEntity<>(new RestResponse<>(dto, metadata), HttpStatus.OK);
}
Aggregations