Search in sources :

Example 1 with LabelDto

use of org.entando.entando.aps.system.services.label.model.LabelDto in project entando-core by entando.

the class LabelController method geLabelGroup.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{labelCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> geLabelGroup(@PathVariable String labelCode) {
    logger.debug("loading label {}", labelCode);
    LabelDto label = this.getLabelService().getLabelGroup(labelCode);
    return new ResponseEntity<>(new RestResponse(label, null, new HashMap<>()), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) RestResponse(org.entando.entando.web.common.model.RestResponse) LabelDto(org.entando.entando.aps.system.services.label.model.LabelDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with LabelDto

use of org.entando.entando.aps.system.services.label.model.LabelDto in project entando-core by entando.

the class LabelController method addLabelGroup.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> addLabelGroup(@Valid @RequestBody LabelRequest labelRequest) throws ApsSystemException {
    logger.debug("adding label {}", labelRequest.getKey());
    LabelDto group = this.getLabelService().addLabelGroup(labelRequest);
    return new ResponseEntity<>(new RestResponse(group), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) LabelDto(org.entando.entando.aps.system.services.label.model.LabelDto) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with LabelDto

use of org.entando.entando.aps.system.services.label.model.LabelDto in project entando-core by entando.

the class LabelController method updateLabelGroup.

@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{labelCode}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> updateLabelGroup(@PathVariable String labelCode, @Valid @RequestBody LabelRequest labelRequest, BindingResult bindingResult) {
    logger.debug("updating label {}", labelRequest.getKey());
    this.getLabelValidator().validateBodyName(labelCode, labelRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }
    LabelDto group = this.getLabelService().updateLabelGroup(labelRequest);
    return new ResponseEntity<>(new RestResponse(group), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) RestResponse(org.entando.entando.web.common.model.RestResponse) LabelDto(org.entando.entando.aps.system.services.label.model.LabelDto) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) RestAccessControl(org.entando.entando.web.common.annotation.RestAccessControl) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with LabelDto

use of org.entando.entando.aps.system.services.label.model.LabelDto in project entando-core by entando.

the class LabelDtoBuilder method toDto.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected LabelDto toDto(String key, ApsProperties src) {
    LabelDto labelDto = new LabelDto();
    labelDto.setKey(key);
    Map<String, String> languages = (Map) src;
    labelDto.setTitles(languages);
    return labelDto;
}
Also used : LabelDto(org.entando.entando.aps.system.services.label.model.LabelDto) Map(java.util.Map)

Example 5 with LabelDto

use of org.entando.entando.aps.system.services.label.model.LabelDto in project entando-core by entando.

the class LabelService method validateUpdateLabelGroup.

protected BeanPropertyBindingResult validateUpdateLabelGroup(LabelDto labelDto) {
    BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(labelDto, "labelGroup");
    String defaultLang = this.getLangManager().getDefaultLang().getCode();
    boolean isDefaultLangValid = validateDefaultLang(labelDto, bindingResult, defaultLang);
    if (!isDefaultLangValid) {
        return bindingResult;
    }
    List<String> configuredLangs = this.getLangManager().getLangs().stream().map(i -> i.getCode()).collect(Collectors.toList());
    labelDto.getTitles().entrySet().forEach(i -> validateLangEntry(i, configuredLangs, defaultLang, bindingResult));
    return bindingResult;
}
Also used : Logger(org.slf4j.Logger) II18nManager(com.agiletec.aps.system.services.i18n.II18nManager) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) LoggerFactory(org.slf4j.LoggerFactory) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) ApsProperties(com.agiletec.aps.util.ApsProperties) LabelValidator(org.entando.entando.web.label.LabelValidator) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) List(java.util.List) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) RestListRequest(org.entando.entando.web.common.model.RestListRequest) RestServerError(org.entando.entando.aps.system.exception.RestServerError) Filter(org.entando.entando.web.common.model.Filter) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) Map(java.util.Map) Entry(java.util.Map.Entry) LabelDto(org.entando.entando.aps.system.services.label.model.LabelDto) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) Comparator(java.util.Comparator) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult)

Aggregations

LabelDto (org.entando.entando.aps.system.services.label.model.LabelDto)8 RestAccessControl (org.entando.entando.web.common.annotation.RestAccessControl)4 RestResponse (org.entando.entando.web.common.model.RestResponse)4 ResponseEntity (org.springframework.http.ResponseEntity)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)3 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)3 ApsProperties (com.agiletec.aps.util.ApsProperties)3 Map (java.util.Map)3 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)3 Filter (org.entando.entando.web.common.model.Filter)3 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)3 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)2 II18nManager (com.agiletec.aps.system.services.i18n.II18nManager)2 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)2 Comparator (java.util.Comparator)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 Collectors (java.util.stream.Collectors)2 StringUtils (org.apache.commons.lang3.StringUtils)2