use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.
the class SystemInfoWrapper method getActionPathUrl.
public String getActionPathUrl(String actionPath) {
String url = null;
RequestContext reqCtx = this.getReqCtx();
IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, reqCtx.getRequest());
try {
PageURL pageUrl = urlManager.createURL(reqCtx);
IPage currPage = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
pageUrl.setPage(currPage);
pageUrl.addParam(InternalServletTag.REQUEST_PARAM_ACTIONPATH, actionPath);
pageUrl.addParam(InternalServletTag.REQUEST_PARAM_FRAMEDEST, currentFrame.toString());
url = pageUrl.getURL();
} catch (Throwable t) {
_logger.error("Error getting path for action path: {}", actionPath, t);
return null;
}
return url;
}
use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.
the class LinkResolverManager method resolveLink.
@Override
public String resolveLink(SymbolicLink symbolicLink, String contentId, RequestContext reqCtx) {
if (null == symbolicLink) {
_logger.error("Null Symbolic Link");
return "";
}
String url = null;
try {
if (symbolicLink.getDestType() == SymbolicLink.URL_TYPE) {
url = symbolicLink.getUrlDest();
} else if (symbolicLink.getDestType() == SymbolicLink.PAGE_TYPE) {
PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
pageUrl.setPageCode(symbolicLink.getPageDest());
url = pageUrl.getURL();
} else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_ON_PAGE_TYPE) {
PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
pageUrl.setPageCode(symbolicLink.getPageDest());
pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, symbolicLink.getContentDest());
url = pageUrl.getURL();
} else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_TYPE) {
PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
String contentIdDest = symbolicLink.getContentDest();
String pageCode = this.getContentPageMapperManager().getPageCode(contentIdDest);
boolean forwardToDefaultPage = !this.isPageAllowed(reqCtx, pageCode);
if (forwardToDefaultPage) {
String viewPageCode = this.getContentManager().getViewPage(contentIdDest);
pageUrl.setPageCode(viewPageCode);
pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, contentIdDest);
} else {
pageUrl.setPageCode(pageCode);
}
url = pageUrl.getURL();
} else if (symbolicLink.getDestType() == SymbolicLink.RESOURCE_TYPE) {
ResourceInterface resource = this.getResourceManager().loadResource(symbolicLink.getResourceDest());
if (null != resource) {
url = resource.getDefaultUrlPath();
if (!resource.getMainGroup().equals(Group.FREE_GROUP_NAME)) {
if (!url.endsWith("/")) {
url += "/";
}
url += AbstractResourceAttribute.REFERENCED_RESOURCE_INDICATOR + "/" + contentId + "/";
}
}
}
} catch (Throwable t) {
_logger.error("Error resolve link from SymbolicLink", t);
throw new RuntimeException("Error resolve link from SymbolicLink", t);
}
return url;
}
use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.
the class PageInfoTag method extractPageUrl.
protected void extractPageUrl(IPage page, Lang currentLang, RequestContext reqCtx) {
IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.pageContext);
PageURL pageUrl = urlManager.createURL(reqCtx);
pageUrl.setPageCode(page.getCode());
if (this.getLangCode() != null) {
pageUrl.setLangCode(this.getLangCode());
} else {
pageUrl.setLangCode(currentLang.getCode());
}
if (null != this.getParameters()) {
Iterator<String> iter = this.getParameters().keySet().iterator();
while (iter.hasNext()) {
String name = (String) iter.next();
pageUrl.addParam(name, this.getParameters().get(name));
}
}
this.setValue(pageUrl.getURL());
}
use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.
the class AbstractControlService method redirect.
protected int redirect(String redirDestPage, Map<String, String> params, RequestContext reqCtx) {
int retStatus;
try {
String redirPar = this.getParameter(RequestContext.PAR_REDIRECT_FLAG, reqCtx);
if (redirPar == null || "".equals(redirPar)) {
PageURL url = this.getUrlManager().createURL(reqCtx);
url.setPageCode(redirDestPage);
if (null != params && !params.isEmpty()) {
Iterator<String> iter = params.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
url.addParam(key, params.get(key));
}
}
url.addParam(RequestContext.PAR_REDIRECT_FLAG, "1");
url.setEscapeAmp(false);
String redirUrl = url.getURL();
_logger.debug("Redirecting to {}", redirUrl);
return this.redirectUrl(redirUrl, reqCtx);
} else {
reqCtx.setHTTPError(HttpServletResponse.SC_BAD_REQUEST);
retStatus = ControllerManager.ERROR;
}
} catch (Throwable t) {
retStatus = ControllerManager.SYS_ERROR;
reqCtx.setHTTPError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
_logger.error("Error on creation redirect to page {}", redirDestPage, t);
}
return retStatus;
}
use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.
the class SystemInfoWrapper method getPageURLWithWidget.
public String getPageURLWithWidget(String widgetCode) {
String url = null;
try {
IPage page = this.getPageWithWidget(widgetCode);
if (null == page) {
return url;
}
IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.getReqCtx().getRequest());
PageURL pageUrl = urlManager.createURL(this.getReqCtx());
pageUrl.setPage(page);
url = pageUrl.getURL();
} catch (Throwable t) {
_logger.error("Error getting pageUrl with widget: {}", widgetCode, t);
return null;
}
return url;
}
Aggregations