use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletWindowRegistryImpl method getPortletWindow.
@Override
public Tuple<IPortletWindow, StartElement> getPortletWindow(HttpServletRequest request, StartElement element) {
// Check if the layout node explicitly specifies the window id
final Attribute windowIdAttribute = element.getAttributeByName(PORTLET_WINDOW_ID_ATTR_NAME);
if (windowIdAttribute != null) {
final String windowIdStr = windowIdAttribute.getValue();
final IPortletWindowId portletWindowId = this.getPortletWindowId(request, windowIdStr);
final IPortletWindow portletWindow = this.getPortletWindow(request, portletWindowId);
return new Tuple<IPortletWindow, StartElement>(portletWindow, element);
}
// No explicit window id, look it up based on the layout node id
final Attribute nodeIdAttribute = element.getAttributeByName(IUserLayoutManager.ID_ATTR_NAME);
final String layoutNodeId = nodeIdAttribute.getValue();
IPortletWindow portletWindow = this.getOrCreateDefaultPortletWindowByLayoutNodeId(request, layoutNodeId);
if (portletWindow == null) {
// No window for the layout node, return null
return null;
}
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
if (portalRequestInfo.getUrlState() == UrlState.DETACHED) {
/*
* We want to handle DETACHED portlet windows differently/explicitly,
* but we need to be aware there may be other portlets on the page
* besides the targeted one. These would be portlets in regions
* (Respondr theme) -- such as DynamicRespondrSkin.
*
* We need to confirm, therefore, that this is actually the portlet
* in DETACHED. If it is, we'll send back a 'stateless' PortletWindow.
*/
if (portalRequestInfo.getTargetedPortletWindowId().toString().contains("_" + layoutNodeId + "_")) {
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
portletWindow = this.getOrCreateStatelessPortletWindow(request, portletWindowId);
}
}
element = this.addPortletWindowId(element, portletWindow.getPortletWindowId());
return new Tuple<IPortletWindow, StartElement>(portletWindow, element);
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortalController method actionRequest.
@RequestMapping(headers = { "org.apereo.portal.url.UrlType=ACTION" })
public void actionRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
final IPortletRequestInfo portletRequestInfo = portalRequestInfo.getTargetedPortletRequestInfo();
final IPortalUrlBuilder actionRedirectUrl;
if (portletRequestInfo != null) {
final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
actionRedirectUrl = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(request, targetWindowId, UrlType.RENDER);
} else {
final String targetedLayoutNodeId = portalRequestInfo.getTargetedLayoutNodeId();
if (targetedLayoutNodeId != null) {
actionRedirectUrl = this.portalUrlProvider.getPortalUrlBuilderByLayoutNode(request, targetedLayoutNodeId, UrlType.RENDER);
} else {
actionRedirectUrl = this.portalUrlProvider.getDefaultUrl(request);
}
}
// Stuff the action-redirect URL builder into the request so other code can use it during
// request processing
this.portalUrlProvider.convertToPortalActionUrlBuilder(request, actionRedirectUrl);
if (portletRequestInfo != null) {
final IPortletWindowId targetWindowId = portletRequestInfo.getPortletWindowId();
try {
this.portletExecutionManager.doPortletAction(targetWindowId, request, response);
} catch (RuntimeException e) {
this.logger.error("Exception thrown while executing portlet action for: " + portletRequestInfo, e);
// TODO this should be a constant right?
actionRedirectUrl.setParameter("portletActionError", targetWindowId.toString());
}
}
sendRedirect(actionRedirectUrl, response);
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletRenderingInitiationCharacterComponent method getEventReader.
/* (non-Javadoc)
* @see org.apereo.portal.rendering.PipelineComponent#getEventReader(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public PipelineEventReader<CharacterEventReader, CharacterEvent> getEventReader(HttpServletRequest request, HttpServletResponse response) {
final PipelineEventReader<CharacterEventReader, CharacterEvent> pipelineEventReader = this.wrappedComponent.getEventReader(request, response);
final CharacterEventReader eventReader = pipelineEventReader.getEventReader();
final List<CharacterEvent> eventBuffer = new LinkedList<CharacterEvent>();
while (eventReader.hasNext()) {
final CharacterEvent event = eventReader.next();
switch(event.getEventType()) {
case PORTLET_HEADER:
{
final PortletHeaderPlaceholderEvent headerEvent = (PortletHeaderPlaceholderEvent) event;
final IPortletWindowId portletWindowId = headerEvent.getPortletWindowId();
if (!this.portletExecutionManager.isPortletRenderHeaderRequested(portletWindowId, request, response)) {
this.portletExecutionManager.startPortletHeaderRender(portletWindowId, request, response);
}
break;
}
case PORTLET_CONTENT:
{
final PortletContentPlaceholderEvent headerEvent = (PortletContentPlaceholderEvent) event;
final IPortletWindowId portletWindowId = headerEvent.getPortletWindowId();
if (!this.portletExecutionManager.isPortletRenderRequested(portletWindowId, request, response)) {
this.portletExecutionManager.startPortletRender(portletWindowId, request, response);
}
break;
}
default:
}
eventBuffer.add(event);
}
final Map<String, String> outputProperties = pipelineEventReader.getOutputProperties();
final CharacterEventBufferReader bufferEventReader = new CharacterEventBufferReader(eventBuffer.listIterator());
return new PipelineEventReaderImpl<CharacterEventReader, CharacterEvent>(bufferEventReader, outputProperties);
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImpl method parsePortletParameterName.
/**
* Parse the parameter name and the optional portlet window id from a fully qualified query
* parameter.
*/
protected Tuple<String, IPortletWindowId> parsePortletParameterName(HttpServletRequest request, String name, Set<String> additionalPortletIds) {
// Look for a 2nd separator which might indicate a portlet window id
for (final String additionalPortletId : additionalPortletIds) {
final int windowIdIdx = name.indexOf(additionalPortletId);
if (windowIdIdx == -1) {
continue;
}
final String paramName = name.substring(PORTLET_PARAM_PREFIX.length() + additionalPortletId.length() + SEPARATOR.length());
final IPortletWindowId portletWindowId = this.portletWindowRegistry.getPortletWindowId(request, additionalPortletId);
return new Tuple<String, IPortletWindowId>(paramName, portletWindowId);
}
final String paramName = this.safeSubstringAfter(PORTLET_PARAM_PREFIX, name);
return new Tuple<String, IPortletWindowId>(paramName, null);
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class UrlSyntaxProviderImpl method getCanonicalUrl.
@Override
public String getCanonicalUrl(HttpServletRequest request) {
boolean isRedirectionToDefaultUrl = false;
request = this.portalRequestUtils.getOriginalPortalRequest(request);
final String cachedCanonicalUrl = (String) request.getAttribute(PORTAL_CANONICAL_URL);
if (cachedCanonicalUrl != null) {
if (logger.isDebugEnabled()) {
logger.debug("short-circuit: found canonicalUrl within request attributes");
}
return cachedCanonicalUrl;
}
final IPortalRequestInfo portalRequestInfo = this.getPortalRequestInfo(request);
final UrlType urlType = portalRequestInfo.getUrlType();
final IPortletWindowId targetedPortletWindowId = portalRequestInfo.getTargetedPortletWindowId();
final String targetedLayoutNodeId = portalRequestInfo.getTargetedLayoutNodeId();
// Create a portal url builder with the appropriate target
final IPortalUrlBuilder portalUrlBuilder;
if (targetedPortletWindowId != null) {
portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(request, targetedPortletWindowId, urlType);
} else if (targetedLayoutNodeId != null) {
portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByLayoutNode(request, targetedLayoutNodeId, urlType);
} else {
portalUrlBuilder = this.portalUrlProvider.getDefaultUrl(request);
isRedirectionToDefaultUrl = request.getPathInfo() != null;
}
// Copy over portal parameters
Map<String, List<String>> portalParameters = portalRequestInfo.getPortalParameters();
if (isRedirectionToDefaultUrl) {
// add in redirect parameter so we know that we were
// redirected
Map<String, List<String>> portalParamsWithRedirect = new HashMap<String, List<String>>(portalParameters);
portalParamsWithRedirect.put("redirectToDefault", Collections.singletonList("true"));
portalUrlBuilder.setParameters(portalParamsWithRedirect);
} else {
portalUrlBuilder.setParameters(portalParameters);
}
// Copy data for each portlet
for (final IPortletRequestInfo portletRequestInfo : portalRequestInfo.getPortletRequestInfoMap().values()) {
final IPortletWindowId portletWindowId = portletRequestInfo.getPortletWindowId();
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
// Parameters
final Map<String, List<String>> portletParameters = portletRequestInfo.getPortletParameters();
portletUrlBuilder.setParameters(portletParameters);
switch(urlType) {
case RESOURCE:
{
// cacheability and resourceId for resource requests
portletUrlBuilder.setCacheability(portletRequestInfo.getCacheability());
portletUrlBuilder.setResourceId(portletRequestInfo.getResourceId());
}
// fall through
case RENDER:
case ACTION:
{
// state & mode for all requests
portletUrlBuilder.setWindowState(portletRequestInfo.getWindowState());
portletUrlBuilder.setPortletMode(portletRequestInfo.getPortletMode());
break;
}
}
}
return portalUrlBuilder.getUrlString();
}
Aggregations