use of org.apereo.portal.url.IPortalUrlBuilder in project uPortal by Jasig.
the class LayoutRESTController method getRESTController.
/**
* A REST call to get a json feed of the current users layout. Intent was to provide a layout
* document without per-tab information for mobile device rendering.
*
* @param request The servlet request. Utilized to get the users instance and eventually there
* layout
* @param tab The tab name of which you would like to filter; optional; if not provided, will
* return entire layout.
* @return json feed of the layout
* @deprecated Use /api/v4-3/dlm/layout.json. It has much more information about portlets and
* includes regions and breakout per tab
*/
@Deprecated
@RequestMapping(value = "/layoutDoc", method = RequestMethod.GET)
public ModelAndView getRESTController(HttpServletRequest request, @RequestParam(value = "tab", required = false) String tab) {
final IPerson person = personManager.getPerson(request);
List<LayoutPortlet> portlets = new ArrayList<LayoutPortlet>();
try {
final IUserInstance ui = userInstanceManager.getUserInstance(request);
final IUserPreferencesManager upm = ui.getPreferencesManager();
final IUserProfile profile = upm.getUserProfile();
final DistributedUserLayout userLayout = userLayoutStore.getUserLayout(person, profile);
Document document = userLayout.getLayout();
NodeList portletNodes = null;
if (tab != null) {
NodeList folders = document.getElementsByTagName("folder");
for (int i = 0; i < folders.getLength(); i++) {
Node node = folders.item(i);
if (tab.equalsIgnoreCase(node.getAttributes().getNamedItem("name").getNodeValue())) {
TabListOfNodes tabNodes = new TabListOfNodes();
tabNodes.addAllChannels(node.getChildNodes());
portletNodes = tabNodes;
break;
}
}
} else {
portletNodes = document.getElementsByTagName("channel");
}
for (int i = 0; i < portletNodes.getLength(); i++) {
try {
NamedNodeMap attributes = portletNodes.item(i).getAttributes();
IPortletDefinition def = portletDao.getPortletDefinitionByFname(attributes.getNamedItem("fname").getNodeValue());
LayoutPortlet portlet = new LayoutPortlet(def);
portlet.setNodeId(attributes.getNamedItem("ID").getNodeValue());
//get alt max URL
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);
}
portlets.add(portlet);
} catch (Exception e) {
log.warn("Exception construction JSON representation of mobile portlet", e);
}
}
ModelAndView mv = new ModelAndView();
mv.addObject("layout", portlets);
mv.setViewName("json");
return mv;
} catch (Exception e) {
log.error("Error retrieving user layout document", e);
}
return null;
}
use of org.apereo.portal.url.IPortalUrlBuilder in project uPortal by Jasig.
the class PortletURLProviderImpl method getType.
/* (non-Javadoc)
* @see org.apache.pluto.container.PortletURLProvider#getType()
*/
@Override
public TYPE getType() {
final IPortalUrlBuilder portalUrlBuilder = this.portletUrlBuilder.getPortalUrlBuilder();
final UrlType urlType = portalUrlBuilder.getUrlType();
return urlType.getPortletUrlType();
}
use of org.apereo.portal.url.IPortalUrlBuilder 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.url.IPortalUrlBuilder in project uPortal by Jasig.
the class PortletErrorController method executeReset.
/**
* @param request
* @param response
* @throws Exception
*/
@RequestMapping("VIEW")
public void executeReset(ActionRequest request, ActionResponse response) throws Exception {
final String windowId = request.getParameter("failedPortletWindowId");
if (StringUtils.isNotBlank(windowId)) {
HttpServletRequest httpRequest = this.portalRequestUtils.getPortletHttpRequest(request);
IPortletWindowId portletWindowId = this.portletWindowRegistry.getPortletWindowId(httpRequest, windowId);
HttpServletResponse httpResponse = this.portalRequestUtils.getOriginalPortalResponse(request);
this.portletRenderer.doReset(portletWindowId, httpRequest, httpResponse);
IPortalUrlBuilder builder = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(httpRequest, portletWindowId, UrlType.RENDER);
response.sendRedirect(builder.getUrlString());
}
}
use of org.apereo.portal.url.IPortalUrlBuilder in project uPortal by Jasig.
the class PortletErrorController method renderError.
/**
* Render the error portlet view.
*
* @param request
* @param response
* @param model
* @return the name of the view to display
* @throws Exception
*/
@RequestMapping("VIEW")
public String renderError(RenderRequest request, RenderResponse response, ModelMap model) throws Exception {
HttpServletRequest httpRequest = this.portalRequestUtils.getPortletHttpRequest(request);
IPortletWindowId currentFailedPortletWindowId = (IPortletWindowId) request.getAttribute(REQUEST_ATTRIBUTE__CURRENT_FAILED_PORTLET_WINDOW_ID);
model.addAttribute("portletWindowId", currentFailedPortletWindowId);
Exception cause = (Exception) request.getAttribute(REQUEST_ATTRIBUTE__CURRENT_EXCEPTION_CAUSE);
model.addAttribute("exception", cause);
final String rootCauseMessage = ExceptionUtils.getRootCauseMessage(cause);
model.addAttribute("rootCauseMessage", rootCauseMessage);
// Maintenance Mode?
if (cause != null && cause instanceof MaintenanceModeException) {
return "/jsp/PortletError/maintenance";
}
IUserInstance userInstance = this.userInstanceManager.getUserInstance(httpRequest);
if (hasAdminPrivileges(userInstance)) {
IPortletWindow window = this.portletWindowRegistry.getPortletWindow(httpRequest, currentFailedPortletWindowId);
window.setRenderParameters(new ParameterMap());
IPortalUrlBuilder adminRetryUrl = this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(httpRequest, currentFailedPortletWindowId, UrlType.RENDER);
model.addAttribute("adminRetryUrl", adminRetryUrl.getUrlString());
final IPortletWindow portletWindow = portletWindowRegistry.getPortletWindow(httpRequest, currentFailedPortletWindowId);
final IPortletEntity parentPortletEntity = portletWindow.getPortletEntity();
final IPortletDefinition parentPortletDefinition = parentPortletEntity.getPortletDefinition();
model.addAttribute("channelDefinition", parentPortletDefinition);
StringWriter stackTraceWriter = new StringWriter();
cause.printStackTrace(new PrintWriter(stackTraceWriter));
model.addAttribute("stackTrace", stackTraceWriter.toString());
return "/jsp/PortletError/detailed";
}
// no admin privileges, return generic view
return "/jsp/PortletError/generic";
}
Aggregations