Search in sources :

Example 16 with PortletException

use of javax.portlet.PortletException in project liferay-ide by liferay.

the class SearchPortlet method render.

@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
    try {
        int status = getStatus(renderRequest);
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);
        KBArticle kbArticle = null;
        long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey");
        if (resourcePrimKey > 0) {
            kbArticle = KBArticleServiceUtil.getLatestKBArticle(resourcePrimKey, status);
        }
        renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle);
    } catch (Exception e) {
        if (e instanceof NoSuchArticleException || e instanceof PrincipalException) {
            SessionErrors.add(renderRequest, e.getClass());
        } else {
            throw new PortletException(e);
        }
    }
    super.render(renderRequest, renderResponse);
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) PortletException(javax.portlet.PortletException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) NoSuchArticleException(com.liferay.knowledgebase.NoSuchArticleException) IOException(java.io.IOException) NoSuchSubscriptionException(com.liferay.portal.NoSuchSubscriptionException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) NoSuchCommentException(com.liferay.knowledgebase.NoSuchCommentException) PortletException(javax.portlet.PortletException)

Example 17 with PortletException

use of javax.portlet.PortletException in project liferay-ide by liferay.

the class EditorPortlet method serveResource.

@Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException {
    try {
        AuthTokenUtil.checkCSRFToken(PortalUtil.getHttpServletRequest(resourceRequest), this.getClass().getName());
        String resourceID = resourceRequest.getResourceID();
        if (resourceID.equals("addFileEntry")) {
            serveAddFileEntry(resourceRequest, resourceResponse);
        } else if (resourceID.equals("addFolder")) {
            serveAddFolder(resourceRequest, resourceResponse);
        } else if (resourceID.equals("deleteFileEntry")) {
            serveDeleteFileEntry(resourceRequest, resourceResponse);
        } else if (resourceID.equals("deleteFolder")) {
            serveDeleteFolder(resourceRequest, resourceResponse);
        } else if (resourceID.equals("getFileEntryContent")) {
            serveGetFileEntryContent(resourceRequest, resourceResponse);
        } else if (resourceID.equals("getFolderChildren")) {
            serveGetFolderChildren(resourceRequest, resourceResponse);
        } else if (resourceID.equals("getRenderParameters")) {
            serveGetRenderParameters(resourceRequest, resourceResponse);
        } else if (resourceID.equals("updateFileEntryContent")) {
            serveUpdateFileEntryContent(resourceRequest, resourceResponse);
        } else if (resourceID.equals("updateFileEntryTitle")) {
            serveUpdateFileEntryTitle(resourceRequest, resourceResponse);
        } else if (resourceID.equals("updateFolderName")) {
            serveUpdateFolderName(resourceRequest, resourceResponse);
        }
    } catch (IOException ioe) {
        serveException(ioe, resourceRequest, resourceResponse);
        throw ioe;
    } catch (PortletException pe) {
        serveException(pe, resourceRequest, resourceResponse);
        throw pe;
    } catch (Exception e) {
        serveException(e, resourceRequest, resourceResponse);
        throw new PortletException(e);
    }
}
Also used : PortletException(javax.portlet.PortletException) IOException(java.io.IOException) IOException(java.io.IOException) PortletException(javax.portlet.PortletException)

Example 18 with PortletException

use of javax.portlet.PortletException in project liferay-ide by liferay.

the class BaseGadgetPortlet method render.

@Override
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
    try {
        doRender(renderRequest, renderResponse);
        super.render(renderRequest, renderResponse);
    } catch (IOException ioe) {
        throw ioe;
    } catch (PortletException pe) {
        throw pe;
    } catch (Exception e) {
        throw new PortletException(e);
    }
}
Also used : PortletException(javax.portlet.PortletException) IOException(java.io.IOException) IOException(java.io.IOException) PortletException(javax.portlet.PortletException)

Example 19 with PortletException

use of javax.portlet.PortletException in project sw360portal by sw360.

the class LinkedReleasesAndProjectsAwarePortlet method serveLoadLinkedReleasesRows.

protected void serveLoadLinkedReleasesRows(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
    final User user = UserCacheHolder.getUserFromRequest(request);
    String branchId = request.getParameter(PARENT_BRANCH_ID);
    request.setAttribute(PARENT_BRANCH_ID, branchId);
    if (branchId != null) {
        String id = branchId.split("_")[0];
        try {
            ComponentService.Iface client = thriftClients.makeComponentClient();
            Release release = client.getReleaseById(id, user);
            putDirectlyLinkedReleaseRelationsInRequest(request, release);
        } catch (TException e) {
            log.error("Error getting projects!", e);
            throw new PortletException("cannot get projects", e);
        }
    } else {
        putDirectlyLinkedReleaseRelationsInRequest(request, new Release());
    }
    request.setAttribute(PortalConstants.PARENT_SCOPE_GROUP_ID, request.getParameter(PortalConstants.PARENT_SCOPE_GROUP_ID));
    include("/html/utils/ajax/linkedReleasesRows.jsp", request, response, PortletRequest.RESOURCE_PHASE);
}
Also used : TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) PortletException(javax.portlet.PortletException) ComponentService(org.eclipse.sw360.datahandler.thrift.components.ComponentService) Release(org.eclipse.sw360.datahandler.thrift.components.Release)

Example 20 with PortletException

use of javax.portlet.PortletException in project uPortal by Jasig.

the class PortletRendererImpl method doRender.

protected PortletRenderResult doRender(IPortletWindowId portletWindowId, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, PortletOutputHandler portletOutputHandler, RenderPart renderPart) throws IOException {
    final CacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult> cacheState = renderPart.getCacheState(this.portletCacheControlService, httpServletRequest, portletWindowId);
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(httpServletRequest, portletWindowId);
    enforceConfigPermission(httpServletRequest, portletWindow);
    /*
         * If the portlet is rendering in EXCLUSIVE WindowState ignore the provided PortletOutputHandler and
         * write directly to the response.
         *
         * THIS IS VERY BAD AND SHOULD BE DEPRECATED ALONG WITH EXCLUSIVE WINDOW STATE
         */
    if (IPortletRenderer.EXCLUSIVE.equals(portletWindow.getWindowState())) {
        portletOutputHandler = new ResourcePortletOutputHandler(httpServletResponse);
    }
    if (cacheState.isUseCachedData()) {
        return doRenderReplayCachedContent(portletWindow, httpServletRequest, cacheState, portletOutputHandler, renderPart, 0);
    }
    final int cacheSizeThreshold = this.portletCacheControlService.getCacheSizeThreshold();
    final CachingPortletOutputHandler cachingPortletOutputHandler = new CachingPortletOutputHandler(portletOutputHandler, cacheSizeThreshold);
    final CacheControl cacheControl = cacheState.getCacheControl();
    // Setup the request and response
    httpServletRequest = this.setupPortletRequest(httpServletRequest);
    httpServletResponse = new PortletMimeHttpServletResponseWrapper(httpServletResponse, portletWindow, portletOutputHandler, cacheControl);
    httpServletRequest.setAttribute(IPortletRenderer.ATTRIBUTE__PORTLET_CACHE_CONTROL, cacheControl);
    httpServletRequest.setAttribute(IPortletRenderer.ATTRIBUTE__PORTLET_OUTPUT_HANDLER, cachingPortletOutputHandler);
    logger.debug("Rendering portlet {} for window {}", renderPart.name(), portletWindow);
    final long renderStartTime = System.nanoTime();
    try {
        httpServletRequest.setAttribute(PortletRequest.RENDER_PART, renderPart.getRenderPart());
        this.portletContainer.doRender(portletWindow.getPlutoPortletWindow(), httpServletRequest, httpServletResponse);
    } catch (PortletException pe) {
        throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing renderMarkup.", portletWindow, pe);
    } catch (PortletContainerException pce) {
        throw new PortletDispatchException("The portlet container threw an exception while executing renderMarkup on portlet window '" + portletWindow + "'.", portletWindow, pce);
    } catch (IOException ioe) {
        throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing renderMarkup.", portletWindow, ioe);
    }
    final long executionTime = System.nanoTime() - renderStartTime;
    // See if the portlet signaled to use the cached content
    final boolean useCachedContent = cacheControl.useCachedContent();
    if (useCachedContent) {
        final CachedPortletData<PortletRenderResult> cachedPortletData = cacheState.getCachedPortletData();
        if (cachedPortletData == null) {
            throw new PortletDispatchException("The portlet window '" + portletWindow + "' indicated via CacheControl#useCachedContent " + "that the portal should render cached content, however there is no cached content to return. " + "This is a portlet bug.", portletWindow);
        }
        // Update the expiration time and re-store in the cache
        cachedPortletData.updateExpirationTime(cacheControl.getExpirationTime());
        renderPart.cachePortletOutput(portletCacheControlService, portletWindowId, httpServletRequest, cacheState, cachedPortletData);
        return doRenderReplayCachedContent(portletWindow, httpServletRequest, cacheState, portletOutputHandler, renderPart, executionTime);
    }
    publishRenderEvent(portletWindow, httpServletRequest, renderPart, executionTime, false);
    // Build the render result
    final PortletRenderResult portletRenderResult = constructPortletRenderResult(httpServletRequest, executionTime);
    // Check if the portlet's output should be cached
    if (cacheState != null) {
        boolean shouldCache = this.portletCacheControlService.shouldOutputBeCached(cacheControl);
        if (shouldCache) {
            final CachedPortletData<PortletRenderResult> cachedPortletData = cachingPortletOutputHandler.getCachedPortletData(portletRenderResult, cacheControl);
            if (cachedPortletData != null) {
                renderPart.cachePortletOutput(portletCacheControlService, portletWindowId, httpServletRequest, cacheState, cachedPortletData);
            }
        }
    }
    return portletRenderResult;
}
Also used : CachingPortletOutputHandler(org.apereo.portal.portlet.container.cache.CachingPortletOutputHandler) PortletException(javax.portlet.PortletException) IOException(java.io.IOException) PortletContainerException(org.apache.pluto.container.PortletContainerException) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) CachedPortletData(org.apereo.portal.portlet.container.cache.CachedPortletData) PortletDispatchException(org.apereo.portal.portlet.PortletDispatchException) PortletMimeHttpServletResponseWrapper(org.apereo.portal.utils.web.PortletMimeHttpServletResponseWrapper) HeaderSettingCacheControl(org.apereo.portal.portlet.container.cache.HeaderSettingCacheControl) CacheControl(javax.portlet.CacheControl)

Aggregations

PortletException (javax.portlet.PortletException)21 IOException (java.io.IOException)17 NoSuchArticleException (com.liferay.knowledgebase.NoSuchArticleException)5 NoSuchCommentException (com.liferay.knowledgebase.NoSuchCommentException)5 KBArticle (com.liferay.knowledgebase.model.KBArticle)5 NoSuchSubscriptionException (com.liferay.portal.NoSuchSubscriptionException)5 PortalException (com.liferay.portal.kernel.exception.PortalException)5 PrincipalException (com.liferay.portal.security.auth.PrincipalException)5 PortletContainerException (org.apache.pluto.container.PortletContainerException)5 PortletDispatchException (org.apereo.portal.portlet.PortletDispatchException)5 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)5 SystemException (com.liferay.portal.kernel.exception.SystemException)3 TException (org.apache.thrift.TException)3 PortletHttpServletResponseWrapper (org.apereo.portal.utils.web.PortletHttpServletResponseWrapper)3 User (org.eclipse.sw360.datahandler.thrift.users.User)3 CacheControl (javax.portlet.CacheControl)2 PortletSession (javax.portlet.PortletSession)2 SessionUser (org.alfresco.repo.SessionUser)2 AuthenticationException (org.alfresco.repo.security.authentication.AuthenticationException)2 AuthenticationService (org.alfresco.service.cmr.security.AuthenticationService)2