Search in sources :

Example 81 with RestAccessControl

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) IEntityModelDictionary(org.entando.entando.aps.system.services.dataobjectmodel.model.IEntityModelDictionary) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 82 with RestAccessControl

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) MapBindingResult(org.springframework.validation.MapBindingResult) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 83 with RestAccessControl

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) GroupDto(org.entando.entando.aps.system.services.group.model.GroupDto) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

Example 84 with RestAccessControl

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) DumpReportDto(org.entando.entando.aps.system.services.database.model.DumpReportDto) 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 85 with RestAccessControl

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) EntityTypeAttributeFullDto(org.entando.entando.aps.system.services.entity.model.EntityTypeAttributeFullDto) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

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