use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class ApiI18nLabelInterface method updateInlineLabel.
public void updateInlineLabel(JAXBI18nLabel jaxbI18nLabel) throws ApiException {
try {
this.checkLabels(jaxbI18nLabel);
String key = jaxbI18nLabel.getKey();
ApsProperties labelGroups = this.getI18nManager().getLabelGroup(key);
_logger.info("KEY -> {} ", key);
boolean isEdit = (null != labelGroups);
if (!isEdit) {
labelGroups = new ApsProperties();
} else {
//
}
ApsProperties labels = jaxbI18nLabel.extractLabels();
Iterator<Object> iterator = labels.keySet().iterator();
while (iterator.hasNext()) {
Object langKey = iterator.next();
labelGroups.put(langKey, labels.get(langKey));
}
if (isEdit) {
this.getI18nManager().updateLabelGroup(key, labelGroups);
_logger.info("*** EDIT DONE *** -> {}", labelGroups);
} else {
this.getI18nManager().addLabelGroup(key, labelGroups);
_logger.info("*** ADD DONE *** -> {}", labelGroups);
}
} catch (ApiException | ApsSystemException t) {
_logger.error("Error updating label {} ", t);
throw new ApiException("Error updating labels", t);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class ApiI18nLabelInterface method checkLabels.
protected void checkLabels(JAXBI18nLabel jaxbI18nLabel) throws ApiException {
try {
String key = jaxbI18nLabel.getKey();
if (null == key || key.trim().length() == 0) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Label key required", Response.Status.CONFLICT);
}
ApsProperties labels = jaxbI18nLabel.extractLabels();
if (null == labels || labels.isEmpty()) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Label list can't be empty", Response.Status.CONFLICT);
}
Iterator<Object> labelCodeIter = labels.keySet().iterator();
while (labelCodeIter.hasNext()) {
Object langCode = labelCodeIter.next();
Object value = labels.get(langCode);
if (null == value || value.toString().trim().length() == 0) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Label for the language '" + langCode + "' is empty", Response.Status.CONFLICT);
}
}
} catch (ApiException ae) {
_logger.error("Error method checkLabels ", ae);
throw new ApiException("Error method checkLabels", ae);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class PageModelDOM method buildDefaultWidget.
private void buildDefaultWidget(Frame frame, Element defaultWidgetElement, int pos, IWidgetTypeManager widgetTypeManager) {
Widget widget = new Widget();
String widgetCode = defaultWidgetElement.getAttributeValue(ATTRIBUTE_CODE);
WidgetType type = widgetTypeManager.getWidgetType(widgetCode);
if (null == type) {
_logger.warn("Unknown code of the default widget - '{}'", widgetCode);
return;
}
widget.setType(type);
Element propertiesElement = defaultWidgetElement.getChild(TAB_PROPERTIES);
if (null != propertiesElement) {
ApsProperties prop = this.buildProperties(propertiesElement);
widget.setConfig(prop);
}
frame.setDefaultWidget(widget);
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class DataObjectViewerHelper method getRenderizationInfo.
@Override
public DataObjectRenderizationInfo getRenderizationInfo(String dataobjectId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
DataObjectRenderizationInfo renderizationInfo = null;
try {
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String langCode = currentLang.getCode();
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties widgetConfig = widget.getConfig();
dataobjectId = this.extractDataId(dataobjectId, widgetConfig, reqCtx);
modelId = this.extractModelId(dataobjectId, modelId, widgetConfig, reqCtx);
if (dataobjectId != null && modelId != null) {
long longModelId = new Long(modelId).longValue();
this.setStylesheet(longModelId, reqCtx);
renderizationInfo = this.getDataObjectDispenser().getRenderizationInfo(dataobjectId, longModelId, langCode, reqCtx, true);
if (null == renderizationInfo) {
_logger.info("Null Renderization informations: dataobject={}", dataobjectId);
return null;
}
this.manageAttributeValues(renderizationInfo, publishExtraTitle, reqCtx);
} else {
_logger.warn("Parametri visualizzazione dataobject incompleti: dataobject={} modello={}", dataobjectId, modelId);
}
} catch (Throwable t) {
_logger.error("Error extracting renderization info", t);
throw new ApsSystemException("Error extracting renderization info", t);
}
return renderizationInfo;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class DataObjectListHelper method getConfiguredUserFilters.
@Override
public List<UserFilterOptionBean> getConfiguredUserFilters(IDataObjectListTagBean bean, RequestContext reqCtx) throws ApsSystemException {
List<UserFilterOptionBean> userEntityFilters = null;
try {
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties config = (null != widget) ? widget.getConfig() : null;
if (null == config || null == config.getProperty(WIDGET_PARAM_CONTENT_TYPE)) {
return null;
}
String dataObjectTypeCode = config.getProperty(WIDGET_PARAM_CONTENT_TYPE);
IApsEntity prototype = this.getDataObjectManager().getEntityPrototype(dataObjectTypeCode);
if (null == prototype) {
_logger.error("Null dataObject type by code '{}'", dataObjectTypeCode);
return null;
}
Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String userFilters = config.getProperty(WIDGET_PARAM_USER_FILTERS);
if (null != userFilters && userFilters.length() > 0) {
userEntityFilters = FilterUtils.getUserFilters(userFilters, currentFrame, currentLang, prototype, this.getUserFilterDateFormat(), reqCtx.getRequest());
}
} catch (Throwable t) {
_logger.error("Error extracting user filters", t);
throw new ApsSystemException("Error extracting user filters", t);
}
return userEntityFilters;
}
Aggregations