use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class CurrentUserProfileAction method addLabelGroups.
protected void addLabelGroups(String key, String defaultValue) throws ApsSystemException {
try {
ApsProperties properties = new ApsProperties();
Lang defaultLang = super.getLangManager().getDefaultLang();
properties.put(defaultLang.getCode(), defaultValue);
this.getI18nManager().addLabelGroup(key, properties);
} catch (Throwable t) {
_logger.error("Error adding label groups - key '{}'", key, t);
// ApsSystemUtils.logThrowable(t, this, "addLabelGroups");
throw new RuntimeException("Error adding label groups - key '" + key + "'", t);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class PageService method updatePage.
private IPage updatePage(IPage oldPage, PageRequest pageRequest) {
Page page = new Page();
PageMetadata metadata = oldPage.getMetadata();
if (metadata == null) {
metadata = new PageMetadata();
}
this.valueMetadataFromRequest(metadata, pageRequest);
page.setMetadata(metadata);
page.setCode(pageRequest.getCode());
page.setShowable(pageRequest.isDisplayedInMenu());
if (!oldPage.getModel().getCode().equals(pageRequest.getPageModel())) {
PageModel model = this.getPageModelManager().getPageModel(pageRequest.getPageModel());
model.setCode(pageRequest.getPageModel());
page.setModel(model);
page.setWidgets(new Widget[model.getFrames().length]);
} else {
page.setWidgets(oldPage.getWidgets());
}
page.setCharset(pageRequest.getCharset());
page.setMimeType(pageRequest.getContentType());
page.setParentCode(pageRequest.getParentCode());
page.setUseExtraTitles(pageRequest.isSeo());
Optional<Map<String, String>> titles = Optional.ofNullable(pageRequest.getTitles());
ApsProperties apsTitles = new ApsProperties();
titles.ifPresent(values -> values.keySet().forEach((lang) -> {
apsTitles.put(lang, values.get(lang));
}));
page.setTitles(apsTitles);
page.setGroup(pageRequest.getOwnerGroup());
if (page.getExtraGroups() != null) {
List<String> oldGroups = new ArrayList<>(page.getExtraGroups());
oldGroups.forEach(page::removeExtraGroup);
}
if (pageRequest.getJoinGroups() != null) {
pageRequest.getJoinGroups().forEach(page::addExtraGroup);
}
page.setParentCode(pageRequest.getParentCode());
page.setPosition(oldPage.getPosition());
page.setChildrenCodes(oldPage.getChildrenCodes());
return page;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class LabelService method addLabelGroup.
@Override
public LabelDto addLabelGroup(LabelDto labelRequest) {
try {
BeanPropertyBindingResult validationResult = this.validateAddLabelGroup(labelRequest);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
String code = labelRequest.getKey();
ApsProperties languages = new ApsProperties();
languages.putAll(labelRequest.getTitles());
this.getI18nManager().addLabelGroup(code, languages);
return labelRequest;
} catch (ApsSystemException t) {
logger.error("error in add label group with code {}", labelRequest.getKey(), t);
throw new RestServerError("error in add label group", t);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class LabelService method updateLabelGroup.
@Override
public LabelDto updateLabelGroup(LabelDto labelRequest) {
try {
String code = labelRequest.getKey();
ApsProperties labelGroup = this.getI18nManager().getLabelGroup(code);
if (null == labelGroup) {
logger.warn("no label found with key {}", code);
throw new ResourceNotFoundException(LabelValidator.ERRCODE_LABELGROUP_NOT_FOUND, "label", code);
}
BeanPropertyBindingResult validationResult = this.validateUpdateLabelGroup(labelRequest);
if (validationResult.hasErrors()) {
throw new ValidationGenericException(validationResult);
}
ApsProperties languages = new ApsProperties();
languages.putAll(labelRequest.getTitles());
this.getI18nManager().updateLabelGroup(code, languages);
return labelRequest;
} catch (ApsSystemException t) {
logger.error("error in update label group with code {}", labelRequest.getKey(), t);
throw new RestServerError("error in update label group", t);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class ApiI18nLabelInterface method getLabel.
public JAXBI18nLabel getLabel(Properties properties) throws ApiException, ApsSystemException {
JAXBI18nLabel jaxbI18nLabel = null;
try {
String key = properties.getProperty("key");
ApsProperties labelGroups = this.getI18nManager().getLabelGroup(key);
if (null == labelGroups) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Label with key '" + key + "' does not exist", Response.Status.CONFLICT);
}
jaxbI18nLabel = new JAXBI18nLabel(key, labelGroups);
} catch (ApiException ae) {
throw ae;
} catch (ApsSystemException t) {
_logger.error("error loading labels", t);
throw new ApsSystemException("Error loading labels", t);
}
return jaxbI18nLabel;
}
Aggregations