use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletAdministrationHelper method getDelegateWindowId.
public IPortletWindowId getDelegateWindowId(ExternalContext externalContext, String fname) {
final PortletRequest nativeRequest = (PortletRequest) externalContext.getNativeRequest();
final PortletSession portletSession = nativeRequest.getPortletSession();
return (IPortletWindowId) portletSession.getAttribute(RenderPortletTag.DEFAULT_SESSION_KEY_PREFIX + fname);
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class DefinitionHeaderProvider method createHeader.
@Override
public Header createHeader(RenderRequest renderRequest, RenderResponse renderResponse) {
// Username
final String username = getUsername(renderRequest);
// Obtain the MarketplacePortletDefinition for this soffit
final HttpServletRequest httpr = portalRequestUtils.getCurrentPortalRequest();
final IPortletWindowId portletWindowId = portletWindowRegistry.getPortletWindowId(httpr, renderRequest.getWindowID());
final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpr, portletWindowId);
final IPortletDefinition pdef = portletWindow.getPortletEntity().getPortletDefinition();
final MarketplacePortletDefinition mpdef = this.marketplaceService.getOrCreateMarketplacePortletDefinition(pdef);
final IPerson user = personManager.getPerson(httpr);
final Locale locale = getUserLocale(user);
// Title
final String title = mpdef.getTitle(locale.toString());
// FName
final String fname = mpdef.getFName();
// Description
final String description = mpdef.getDescription(locale.toString());
// Categories
List<String> categories = new ArrayList<>();
for (PortletCategory pc : mpdef.getCategories()) {
categories.add(pc.getName());
}
// Parameters
Map<String, List<String>> parameters = new HashMap<>();
for (IPortletDefinitionParameter param : mpdef.getParameters()) {
parameters.put(param.getName(), Collections.singletonList(param.getValue()));
}
final Definition definition = definitionService.createDefinition(title, fname, description, categories, parameters, username, getExpiration(renderRequest));
final Header rslt = new BasicHeader(Headers.DEFINITION.getName(), definition.getEncryptedToken());
logger.debug("Produced the following {} header for username='{}': {}", Headers.DEFINITION.getName(), username, rslt);
return rslt;
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletDelegationView method render.
/* (non-Javadoc)
* @see org.springframework.web.servlet.View#render(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
final IPortletWindowId portletWindowId = (IPortletWindowId) model.get(DELEGATE_PORTLET_WINDOW_ID);
final DelegationRequest delegationRequest = (DelegationRequest) model.get(DELEGATE_REQUEST);
final PortletRequest portletRequest = (PortletRequest) request.getAttribute(Constants.PORTLET_REQUEST);
final PortletResponse portletResponse = (PortletResponse) request.getAttribute(Constants.PORTLET_RESPONSE);
final PortletDelegationDispatcher requestDispatcher = portletDelegationLocator.getRequestDispatcher(portletRequest, portletWindowId);
if (requestDispatcher == null) {
throw new IllegalArgumentException("No PortletDelegationDispatcher exists for portlet window id: " + portletWindowId);
}
this.logger.debug("Found delegation dispatcher for portlet window id {} - {}", portletWindowId, requestDispatcher);
final DelegationResponse delegationResponse;
final String phase = (String) request.getAttribute(PortletRequest.LIFECYCLE_PHASE);
if (PortletRequest.RENDER_PHASE.equals(phase)) {
final PortletOutputHandler portletOutputHandler = (PortletOutputHandler) model.get(DELEGATE_RENDER_OUTPUT_HANDLER);
if (portletOutputHandler != null) {
this.logger.debug("Delegating RenderRequest with custom Writer and {}", delegationRequest);
delegationResponse = requestDispatcher.doRender((RenderRequest) portletRequest, (RenderResponse) portletResponse, delegationRequest, portletOutputHandler);
} else {
this.logger.debug("Delegating RenderRequest with default Writer and {}", delegationRequest);
delegationResponse = requestDispatcher.doRender((RenderRequest) portletRequest, (RenderResponse) portletResponse, delegationRequest);
}
} else if (PortletRequest.RESOURCE_PHASE.equals(phase)) {
this.logger.debug("Delegating ResourceRequest and {}", delegationRequest);
delegationResponse = requestDispatcher.doServeResource((ResourceRequest) portletRequest, (ResourceResponse) portletResponse, delegationRequest);
} else {
throw new UnsupportedOperationException("Portlet lifecycle phase " + phase + " is not supported by the delegation view");
}
this.logger.debug("{}", delegationResponse);
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletDelegationLocatorImpl method getRequestDispatcher.
/* (non-Javadoc)
* @see org.apereo.portal.api.portlet.PortletDelegationLocator#getRequestDispatcher(org.apereo.portal.portlet.om.IPortletWindowId)
*/
@Override
public PortletDelegationDispatcher getRequestDispatcher(PortletRequest portletRequest, IPortletWindowId portletWindowId) {
final HttpServletRequest request = this.portalRequestUtils.getPortletHttpRequest(portletRequest);
final IPerson person = this.personManager.getPerson(request);
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
final IPortletWindowId delegationParentId = portletWindow.getDelegationParentId();
if (delegationParentId == null) {
throw new IllegalArgumentException("Portlet window '" + portletWindow + "' is not a delegate window and cannot be delgated to.");
}
return new PortletDelegationDispatcherImpl(portletWindow, person.getID(), this.portalRequestUtils, this.personManager, this.portletRenderer, this.portalUrlProvider, this.portletDelegationManager);
}
use of org.apereo.portal.portlet.om.IPortletWindowId in project uPortal by Jasig.
the class PortletRegistryUtil method buildPortletUrl.
/**
* Builds a portal URL to the specific portlet definition {@link IPortletDefinition}, if the
* remote user in the request has browse permissions to the portlet.
*
* @param httpServletRequest Web request with requester as remote user
* @param portlet Definition of portlet to build a maximized portal URL
* @return URL string if user has access; otherwise, return null
*/
public String buildPortletUrl(HttpServletRequest httpServletRequest, IPortletDefinition portlet) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(httpServletRequest, portlet.getFName());
// portletWindow is null if user does not have access to portlet.
if (portletWindow == null) {
return null;
}
// If user does not have browse permission, exclude the portlet.
if (!this.authorizationService.canPrincipalBrowse(this.authorizationService.newPrincipal(httpServletRequest.getRemoteUser(), EntityEnum.PERSON.getClazz()), portlet)) {
return null;
}
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
final IPortalUrlBuilder portalUrlBuilder = this.portalUrlProvider.getPortalUrlBuilderByPortletFName(httpServletRequest, portlet.getFName(), UrlType.RENDER);
final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
portletUrlBuilder.setWindowState(PortletUtils.getWindowState("maximized"));
return portalUrlBuilder.getUrlString();
}
Aggregations