use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class LangAction method add.
public String add() {
try {
Lang langToAdd = this.getLangManager().getLang(this.getLangCode());
if (null != langToAdd) {
String[] args = { this.getLangCode() };
this.addActionError(this.getText("error.lang.alreadyPresent", args));
return INPUT;
}
this.getLangManager().addLang(this.getLangCode());
} catch (Throwable t) {
_logger.error("error in add", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class LocaleStringAction method checkLabels.
private void checkLabels() {
Iterator<Lang> langsIter = this.getLangManager().getLangs().iterator();
while (langsIter.hasNext()) {
Lang lang = langsIter.next();
String code = lang.getCode();
String label = this.getRequest().getParameter(code);
if (null != label && label.trim().length() > 0) {
this.addLabel(code, label);
} else {
this.getLabels().remove(code);
if (lang.isDefault()) {
String[] args = { lang.getDescr() };
this.addFieldError(code, this.getText("error.label.valueMandatory", args));
}
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class RequestValidator method isRightPath.
private boolean isRightPath(RequestContext reqCtx) {
boolean ok = false;
String resourcePath;
Matcher matcher;
Lang lang = null;
IPage page = null;
if (this.getResourcePath(reqCtx).equals("/pages")) {
resourcePath = getFullResourcePath(reqCtx);
matcher = this._patternFullPath.matcher(resourcePath);
if (matcher.lookingAt()) {
ok = true;
String sect1 = matcher.group(1);
lang = getLangManager().getLang(sect1);
page = this.getPage(matcher);
}
} else {
resourcePath = getResourcePath(reqCtx);
matcher = this._pattern.matcher(resourcePath);
if (matcher.lookingAt()) {
ok = true;
String sect1 = matcher.group(1);
String sect2 = matcher.group(2);
lang = getLangManager().getLang(sect1);
page = this.getPageManager().getOnlinePage(sect2);
} else {
// to preserve url with ".wp" suffix
matcher = this._oldPattern.matcher(resourcePath);
if (matcher.lookingAt()) {
ok = true;
String sect1 = matcher.group(1);
String sect2 = matcher.group(2);
lang = getLangManager().getLang(sect1);
page = this.getPageManager().getOnlinePage(sect2);
}
}
}
if (!ok)
return false;
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, page);
return true;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class PreviewRequestValidator method isRightPath.
private boolean isRightPath(RequestContext reqCtx) {
boolean ok = false;
String resourcePath;
Matcher matcher;
Lang lang = null;
IPage page = null;
if (this.getResourcePath(reqCtx).equals("/preview")) {
resourcePath = getFullResourcePath(reqCtx);
matcher = this._pattern.matcher(resourcePath);
if (matcher.lookingAt()) {
ok = true;
String sect1 = matcher.group(1);
String sect2 = matcher.group(2);
lang = getLangManager().getLang(sect1);
page = this.getDesiredPage(sect2);
}
}
if (!ok) {
return false;
}
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, page);
return true;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ContentPreviewViewerHelper method getRenderedContent.
@Override
public String getRenderedContent(String contentId, String modelId, RequestContext reqCtx) throws ApsSystemException {
String renderedContent = "";
HttpServletRequest request = reqCtx.getRequest();
try {
String contentOnSessionMarker = (String) request.getAttribute("contentOnSessionMarker");
if (null == contentOnSessionMarker || contentOnSessionMarker.trim().length() == 0) {
contentOnSessionMarker = request.getParameter("contentOnSessionMarker");
}
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String langCode = currentLang.getCode();
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
Content contentOnSession = (Content) request.getSession().getAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker);
contentId = (contentOnSession.getId() == null ? contentOnSession.getTypeCode() + "123" : contentOnSession.getId());
ApsProperties widgetConfig = widget.getConfig();
modelId = this.extractModelId(contentId, modelId, widgetConfig);
if (null != contentId && null != modelId) {
long longModelId = new Long(modelId).longValue();
this.setStylesheet(longModelId, reqCtx);
ContentRenderizationInfo renderizationInfo = this.getContentDispenser().getRenderizationInfo(contentId, longModelId, langCode, reqCtx);
if (null == renderizationInfo) {
_logger.warn("Null Renderization informations: content={}", contentId);
} else {
this.getContentDispenser().resolveLinks(renderizationInfo, reqCtx);
renderedContent = renderizationInfo.getRenderedContent();
}
} else {
_logger.warn("Parametri visualizzazione contenuto incompleti: contenuto={} modello={}", contentId, modelId);
}
} catch (Throwable t) {
_logger.error("error loading rendered content for preview", t);
// ApsSystemUtils.logThrowable(t, this, "getRenderedContent");
throw new ApsSystemException("error loading rendered content for preview", t);
}
return renderedContent;
}
Aggregations