use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class PageDAO method createPageMetadata.
protected PageMetadata createPageMetadata(String code, ResultSet res, int startIndex) throws Throwable {
PageMetadata pageMetadata = new PageMetadata();
int index = startIndex;
String titleText = res.getString(index++);
ApsProperties titles = new ApsProperties();
try {
titles.loadFromXml(titleText);
} catch (Throwable t) {
_logger.error("IO error detected while parsing the titles of the page {}", code, t);
String msg = "IO error detected while parsing the titles of the page '" + code + "'";
throw new ApsSystemException(msg, t);
}
pageMetadata.setTitles(titles);
pageMetadata.setModel(this.getPageModelManager().getPageModel(res.getString(index++)));
Integer showable = res.getInt(index++);
pageMetadata.setShowable(showable == 1);
String extraConfig = res.getString(index++);
if (null != extraConfig && extraConfig.trim().length() > 0) {
try {
PageExtraConfigDOM configDom = new PageExtraConfigDOM();
configDom.addExtraConfig(pageMetadata, extraConfig);
} catch (Throwable t) {
_logger.error("IO error detected while parsing the extra config of the page {}", code, t);
String msg = "IO error detected while parsing the extra config of the page '" + code + "'";
throw new ApsSystemException(msg, t);
}
}
Timestamp date = res.getTimestamp(index++);
pageMetadata.setUpdatedAt(date != null ? new Date(date.getTime()) : null);
return pageMetadata;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class PageMetadata method clone.
@Override
public PageMetadata clone() throws CloneNotSupportedException {
PageMetadata copy = null;
try {
copy = this.getClass().newInstance();
ApsProperties titles = new ApsProperties();
titles.putAll(this.getTitles());
copy.setTitles(titles);
Set<String> extraGroups = this.getExtraGroups();
if (extraGroups != null) {
copy.setExtraGroups(new TreeSet<String>(extraGroups));
}
copy.setModel(this.getModel());
copy.setShowable(this.isShowable());
copy.setUseExtraTitles(this.isUseExtraTitles());
copy.setMimeType(this.getMimeType());
copy.setCharset(this.getCharset());
copy.setUpdatedAt(this.getUpdatedAt());
} catch (Throwable t) {
logger.error("Error cloning {}" + this.getClass(), t);
throw new RuntimeException("Error cloning " + this.getClass(), t);
}
return copy;
}
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.error("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);
}
// else {
// widget.setConfig(new ApsProperties());
// }
frame.setDefaultWidget(widget);
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class PageWithWidgetTag method filterByConfigParamValue.
protected List<IPage> filterByConfigParamValue(List<IPage> pages) {
List<IPage> filteredPages = new ArrayList<IPage>();
Iterator<IPage> it = pages.iterator();
while (it.hasNext()) {
IPage currentPage = it.next();
Widget[] widgets = currentPage.getWidgets();
if (widgets != null) {
for (Widget currentWidget : widgets) {
if (null != currentWidget && currentWidget.getType().getCode().equals(this.getWidgetTypeCode())) {
ApsProperties config = currentWidget.getConfig();
if (null != config) {
String value = config.getProperty(this.getFilterParamName());
if (StringUtils.isNotBlank(value) && value.equals(this.getFilterParamValue())) {
filteredPages.add(currentPage);
}
}
}
}
}
}
return filteredPages;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class ApiServiceAction method checkParameters.
private void checkParameters() {
try {
this.setApiParameterValues(new ApsProperties());
ApiMethod masterMethod = this.getMethod(this.getNamespace(), this.getResourceName());
List<ApiMethodParameter> apiParameters = masterMethod.getParameters();
if (null == apiParameters) {
return;
}
this.extractFreeParameters(apiParameters);
this.setApiParameters(apiParameters);
for (int i = 0; i < apiParameters.size(); i++) {
ApiMethodParameter apiParameter = apiParameters.get(i);
String fieldName = apiParameter.getKey() + "_apiParam";
String value = this.getRequest().getParameter(fieldName);
if (null != value && value.trim().length() > 0) {
this.getApiParameterValues().put(apiParameter.getKey(), value);
}
boolean isFreeParameter = (null != this.getFreeParameters()) ? this.getFreeParameters().contains(apiParameter.getKey()) : false;
if (apiParameter.isRequired() && (null == value || value.trim().length() == 0) && !isFreeParameter) {
this.addFieldError(fieldName, this.getText("error.service.parameter.invalidSetting", new String[] { apiParameter.getKey(), apiParameter.getDescription() }));
}
}
} catch (Throwable t) {
_logger.error("Error checking parameters", t);
throw new RuntimeException("Error checking parameters", t);
}
}
Aggregations