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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations