use of org.apereo.portal.url.IPortletUrlBuilder in project uPortal by Jasig.
the class LayoutRESTController method setAltMaxURL.
private void setAltMaxURL(HttpServletRequest request, NamedNodeMap attributes, IPortletDefinition def, LayoutPortlet portlet) {
final String alternativeMaximizedLink = def.getAlternativeMaximizedLink();
if (alternativeMaximizedLink != null) {
portlet.setUrl(alternativeMaximizedLink);
portlet.setAltMaxUrl(true);
} else {
// get the maximized URL for this portlet
final IPortalUrlBuilder portalUrlBuilder = urlProvider.getPortalUrlBuilderByLayoutNode(request, attributes.getNamedItem("ID").getNodeValue(), UrlType.RENDER);
final IPortletWindowId targetPortletWindowId = portalUrlBuilder.getTargetPortletWindowId();
if (targetPortletWindowId != null) {
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(targetPortletWindowId);
portletUrlBuilder.setWindowState(WindowState.MAXIMIZED);
}
portlet.setUrl(portalUrlBuilder.getUrlString());
portlet.setAltMaxUrl(false);
}
}
use of org.apereo.portal.url.IPortletUrlBuilder in project uPortal by Jasig.
the class PortletAdministrationHelper method getFragmentAdminURL.
/**
* Get the link to the fragment admin portlet.
*
* @param request the current http request.
* @return the portlet link
*/
public String getFragmentAdminURL(HttpServletRequest request) {
IPortalUrlBuilder builder = urlProvider.getPortalUrlBuilderByPortletFName(request, PORTLET_FNAME_FRAGMENT_ADMIN_PORTLET, UrlType.RENDER);
IPortletUrlBuilder portletUrlBuilder = builder.getTargetedPortletUrlBuilder();
portletUrlBuilder.setPortletMode(PortletMode.VIEW);
portletUrlBuilder.setWindowState(WindowState.MAXIMIZED);
return builder.getUrlString();
}
use of org.apereo.portal.url.IPortletUrlBuilder in project uPortal by Jasig.
the class FailSafePortalUrlBuilder method getPortletUrlBuilder.
/* (non-Javadoc)
* @see org.apereo.portal.url.IPortalUrlBuilder#getPortletUrlBuilder(org.apereo.portal.portlet.om.IPortletWindowId)
*/
@Override
public IPortletUrlBuilder getPortletUrlBuilder(IPortletWindowId portletWindowId) {
IPortletUrlBuilder portletUrlBuilder;
synchronized (this.portletUrlBuilders) {
portletUrlBuilder = this.portletUrlBuilders.get(portletWindowId);
if (portletUrlBuilder == null) {
portletUrlBuilder = new FailSafePortletUrlBuilder(portletWindowId, this);
this.portletUrlBuilders.put(portletWindowId, portletUrlBuilder);
}
}
return portletUrlBuilder;
}
use of org.apereo.portal.url.IPortletUrlBuilder in project uPortal by Jasig.
the class XsltPortalUrlProvider method getPortletUrlBuilder.
/**
* Get the portlet URL builder for the specified fname or layoutId (fname takes precedence)
*
* @param request
* @param portalUrlBuilder
* @param fname - can be empty string
* @param layoutId - can by empty string
* @param state - can be empty string
* @param mode - can be empty string
* @param copyCurrentRenderParameters
* @param resourceId - can be empty string
* @return IPortletUrlBuilder
* @since 4.1
*/
public IPortletUrlBuilder getPortletUrlBuilder(HttpServletRequest request, IPortalUrlBuilder portalUrlBuilder, String fname, String layoutId, String state, String mode, String copyCurrentRenderParameters, String resourceId) {
final IPortletUrlBuilder portletUrlBuilder;
if (StringUtils.isNotEmpty(fname)) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, fname);
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
} else if (StringUtils.isNotEmpty(layoutId)) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByLayoutNodeId(request, layoutId);
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
} else {
final IPortletWindowId targetPortletWindowId = portalUrlBuilder.getTargetPortletWindowId();
if (targetPortletWindowId == null) {
if (this.logger.isDebugEnabled()) {
this.logger.warn("Can only target the default portlet if the root portal-url targets a portlet.", new Throwable());
} else {
this.logger.warn("Can only target the default portlet if the root portal-url targets a portlet. Enable debug for stack trace.");
}
return new FailSafePortletUrlBuilder(null, portalUrlBuilder);
}
portletUrlBuilder = portalUrlBuilder.getTargetedPortletUrlBuilder();
}
portletUrlBuilder.setCopyCurrentRenderParameters(Boolean.parseBoolean(copyCurrentRenderParameters));
if (StringUtils.isNotEmpty(state)) {
portletUrlBuilder.setWindowState(PortletUtils.getWindowState(state));
}
if (StringUtils.isNotEmpty(mode)) {
portletUrlBuilder.setPortletMode(PortletUtils.getPortletMode(mode));
}
if (StringUtils.isNotEmpty(resourceId) && portletUrlBuilder.getPortalUrlBuilder().getUrlType() == UrlType.RESOURCE) {
portletUrlBuilder.setResourceId(resourceId);
}
return portletUrlBuilder;
}
use of org.apereo.portal.url.IPortletUrlBuilder in project uPortal by Jasig.
the class PortletRedirectionController method getUrlString.
protected String getUrlString(IRedirectionUrl url, HttpServletRequest request, List<String> extraPath) {
if (url instanceof ExternalRedirectionUrl) {
ExternalRedirectionUrl externalUrl = (ExternalRedirectionUrl) url;
StringBuffer urlStr = new StringBuffer();
urlStr.append(externalUrl.getUrl());
try {
// add any additional parameters
String separator = "?";
for (Map.Entry<String, String[]> param : externalUrl.getAdditionalParameters().entrySet()) {
for (String value : param.getValue()) {
urlStr.append(separator);
urlStr.append(param.getKey());
urlStr.append("=");
urlStr.append(URLEncoder.encode(value, "UTF-8"));
separator = "&";
}
}
// add any dynamic parameters
for (Map.Entry<String, String> param : externalUrl.getDynamicParameters().entrySet()) {
String[] values = request.getParameterValues(param.getKey());
if (values != null) {
for (String value : values) {
urlStr.append(separator);
urlStr.append(param.getValue());
urlStr.append("=");
urlStr.append(URLEncoder.encode(value, "UTF-8"));
separator = "&";
}
}
}
if (!extraPath.isEmpty()) {
List<String> paramNames = externalUrl.getPathParameters();
ListIterator<String> itt = paramNames.listIterator();
while (itt.hasNext() && !extraPath.isEmpty()) {
String param = itt.next();
String value;
if (itt.hasNext()) {
value = extraPath.remove(0);
} else {
value = StringUtils.join(extraPath, "/");
}
urlStr.append(separator);
urlStr.append(param);
urlStr.append("=");
urlStr.append(URLEncoder.encode(value, "UTF-8"));
separator = "&";
}
}
return urlStr.toString();
} catch (UnsupportedEncodingException ex) {
log.error("Unable to encode URL parameter for external service redirect", ex);
return null;
}
} else {
PortletRedirectionUrl portletUrl = (PortletRedirectionUrl) url;
// create the base URL for the portlet
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, portletUrl.getFname());
final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(request, portletWindow.getPortletWindowId(), portletUrl.getType());
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getTargetedPortletUrlBuilder();
portletUrlBuilder.setPortletMode(portletUrl.getMode());
portletUrlBuilder.setWindowState(WindowState.MAXIMIZED);
// parameter to the portlet URL
for (Map.Entry<String, String[]> param : portletUrl.getAdditionalParameters().entrySet()) {
portletUrlBuilder.addParameter(param.getKey(), param.getValue());
}
// the value submitted to this service was non-null
for (Map.Entry<String, String> param : portletUrl.getDynamicParameters().entrySet()) {
String[] values = request.getParameterValues(param.getKey());
if (values != null) {
portletUrlBuilder.addParameter(param.getValue(), values);
}
}
if (!extraPath.isEmpty()) {
List<String> paramNames = portletUrl.getPathParameters();
ListIterator<String> itt = paramNames.listIterator();
while (itt.hasNext() && !extraPath.isEmpty()) {
String param = itt.next();
String value;
if (itt.hasNext()) {
value = extraPath.remove(0);
} else {
value = StringUtils.join(extraPath, "/");
}
if (StringUtils.isEmpty(value)) {
break;
} else
portletUrlBuilder.addParameter(param, value);
}
}
return portalUrlBuilder.getUrlString();
}
}
Aggregations