Search in sources :

Example 86 with RestAccessControl

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

the class DataTypeController method getDataType.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes/{dataTypeCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<DataTypeDto>> getDataType(@PathVariable String dataTypeCode) throws JsonProcessingException {
    logger.debug("Requested data type -> {}", dataTypeCode);
    if (!this.getDataTypeValidator().existType(dataTypeCode)) {
        throw new ResourceNotFoundException(DataTypeValidator.ERRCODE_ENTITY_TYPE_DOES_NOT_EXIST, "Data Type", dataTypeCode);
    }
    DataTypeDto dto = this.getDataObjectService().getDataType(dataTypeCode);
    logger.debug("Main Response -> {}", dto);
    return new ResponseEntity<>(new SimpleRestResponse<>(dto), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) DataTypeDto(org.entando.entando.aps.system.services.dataobject.model.DataTypeDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

Example 87 with RestAccessControl

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

the class DataTypeController method extractStatus.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypesStatus", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<EntityTypesStatusDto>> extractStatus() throws Throwable {
    logger.debug("Extract data types status");
    EntityTypesStatusDto status = this.getDataObjectService().getDataTypesRefreshStatus();
    logger.debug("Extracted data types status {}", status);
    return new ResponseEntity<>(new SimpleRestResponse<>(status), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) EntityTypesStatusDto(org.entando.entando.aps.system.services.entity.model.EntityTypesStatusDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

Example 88 with RestAccessControl

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

the class DataTypeController method addDataTypes.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<DataTypeDto>> addDataTypes(@Valid @RequestBody DataTypeDtoRequest bodyRequest, BindingResult bindingResult) throws JsonProcessingException {
    // field validations
    this.getDataTypeValidator().validate(bodyRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    // business validations
    if (this.getDataTypeValidator().existType(bodyRequest.getCode())) {
        bindingResult.reject(DataTypeValidator.ERRCODE_ENTITY_TYPE_ALREADY_EXISTS, new String[] { bodyRequest.getCode() }, "entityType.exists");
    }
    if (bindingResult.hasErrors()) {
        throw new ValidationConflictException(bindingResult);
    }
    DataTypeDto result = this.getDataObjectService().addDataType(bodyRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    logger.debug("Main Response -> {}", result);
    return new ResponseEntity<>(new SimpleRestResponse<>(result), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) DataTypeDto(org.entando.entando.aps.system.services.dataobject.model.DataTypeDto) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

Example 89 with RestAccessControl

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

the class DataTypeController method getDataTypeAttributeType.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypeAttributes/{attributeTypeCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SimpleRestResponse<AttributeTypeDto>> getDataTypeAttributeType(@PathVariable String attributeTypeCode) throws JsonProcessingException {
    logger.debug("Extracting attribute type -> {}", attributeTypeCode);
    AttributeTypeDto attribute = this.getDataObjectService().getAttributeType(attributeTypeCode);
    logger.debug("Main Response -> {}", attribute);
    return new ResponseEntity<>(new SimpleRestResponse<>(attribute), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) AttributeTypeDto(org.entando.entando.aps.system.services.entity.model.AttributeTypeDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl)

Example 90 with RestAccessControl

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

the class DataTypeController method addDataTypeAttribute.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/dataTypes/{dataTypeCode}/attribute", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse<EntityTypeAttributeFullDto, Map<String, String>>> addDataTypeAttribute(@PathVariable String dataTypeCode, @Valid @RequestBody EntityTypeAttributeFullDto bodyRequest, BindingResult bindingResult) throws JsonProcessingException {
    logger.debug("Data type {} - Adding attribute {}", dataTypeCode, bodyRequest);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    EntityTypeAttributeFullDto result = this.getDataObjectService().addDataTypeAttribute(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) 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