예제 #1
0
  @Override
  public ActionForward render(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    try {
      renderRequest.setAttribute(
          WebKeys.SOCIAL_ACTIVITY_SETTINGS_MAP, getActivitySettingsMap(themeDisplay));
    } catch (Exception e) {
      if (e instanceof PrincipalException) {
        SessionErrors.add(renderRequest, e.getClass());

        return actionMapping.findForward("portlet.social_activity.error");
      } else {
        throw e;
      }
    }

    return actionMapping.findForward("portlet.social_activity.view");
  }
  @Override
  public void execute() throws BridgeException {

    logger.debug(Logger.SEPARATOR);
    logger.debug(
        "execute(RenderRequest, RenderResponse) portletName=[{0}] portletMode=[{1}]",
        portletName, renderRequest.getPortletMode());

    Object renderPartAttribute = renderRequest.getAttribute(RenderRequest.RENDER_PART);

    if ((renderPartAttribute != null) && renderPartAttribute.equals(RenderRequest.RENDER_HEADERS)) {
      doFacesHeaders(renderRequest, renderResponse);
    } else {

      try {
        execute(null);
      } catch (BridgeException e) {
        throw e;
      } catch (Throwable t) {
        throw new BridgeException(t);
      } finally {
        cleanup(renderRequest);
      }

      logger.debug(Logger.SEPARATOR);
    }
  }
예제 #3
0
  protected int getStatus(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!themeDisplay.isSignedIn()) {
      return WorkflowConstants.STATUS_APPROVED;
    }

    String value = renderRequest.getParameter("status");
    int status = GetterUtil.getInteger(value);

    if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) {
      return WorkflowConstants.STATUS_APPROVED;
    }

    long resourcePrimKey = getResourcePrimKey(renderRequest);

    if (resourcePrimKey == 0) {
      return WorkflowConstants.STATUS_APPROVED;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) {

      return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
    }

    return WorkflowConstants.STATUS_APPROVED;
  }
예제 #4
0
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getEntry(renderRequest);

      if (PropsValues.BLOGS_PINGBACK_ENABLED) {
        BlogsEntry entry = (BlogsEntry) renderRequest.getAttribute(WebKeys.BLOGS_ENTRY);

        if ((entry != null) && entry.isAllowPingbacks()) {
          HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse);

          response.addHeader(
              "X-Pingback", PortalUtil.getPortalURL(renderRequest) + "/xmlrpc/pingback");
        }
      }
    } catch (Exception e) {
      if (e instanceof NoSuchEntryException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass().getName());

        return mapping.findForward("portlet.blogs.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.blogs.edit_entry"));
  }
  @Override
  public int doEndTag() throws JspException {
    // From portlet:defineObjects
    final RenderRequest renderRequest =
        (RenderRequest) this.pageContext.getAttribute("renderRequest");
    final RenderResponse renderResponse =
        (RenderResponse) this.pageContext.getAttribute("renderResponse");

    final PortletDelegationLocator portletDelegationLocator =
        (PortletDelegationLocator)
            renderRequest.getAttribute(PortletDelegationLocator.PORTLET_DELECATION_LOCATOR_ATTR);

    final String sessionKey = this.sessionKeyPrefix + this.fname;

    final PortletSession portletSession = renderRequest.getPortletSession();
    IPortletWindowId portletWindowId = (IPortletWindowId) portletSession.getAttribute(sessionKey);

    final PortletDelegationDispatcher portletDelegationDispatcher;
    final DelegateState delegateState;
    // No id in session, create a new dispatcher
    if (portletWindowId == null) {
      portletDelegationDispatcher =
          portletDelegationLocator.createRequestDispatcher(renderRequest, this.fname);
      portletWindowId = portletDelegationDispatcher.getPortletWindowId();
      portletSession.setAttribute(sessionKey, portletWindowId);

      final PortletMode portletMode = PortletUtils.getPortletMode(this.portletMode);
      final WindowState windowState = PortletUtils.getWindowState(this.windowState);

      delegateState = new DelegateState(portletMode, windowState);
    }
    // id in session, get the old dispatcher
    else {
      portletDelegationDispatcher =
          portletDelegationLocator.getRequestDispatcher(renderRequest, portletWindowId);
      delegateState = null;
    }

    final DelegationRequest delegationRequest = new DelegationRequest();
    delegationRequest.setDelegateState(delegateState);

    // Setup base for portlet URLs
    delegationRequest.setParentPortletMode(this.parentUrlMode);
    delegationRequest.setParentWindowState(this.parentUrlState);
    delegationRequest.setParentParameters(this.parentUrlParameters);

    final JspWriter out = this.pageContext.getOut();
    try {
      portletDelegationDispatcher.doRender(
          renderRequest,
          renderResponse,
          delegationRequest,
          new JspWriterPortletOutputHandler(out, renderResponse));
    } catch (IOException e) {
      throw new JspException(
          "Failed to execute delegate render on portlet '" + this.fname + "'", e);
    }

    return Tag.EVAL_PAGE;
  }
예제 #6
0
  @Override
  public void render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("mvcPath", "hello_soy_description");

    template.put("descriptionURL", portletURL.toString());

    String path = getPath(renderRequest, renderResponse);

    if (Validator.equals(path, "hello_soy_edit")) {
      portletURL.setParameter("mvcPath", "hello_soy_view");
    } else {
      portletURL.setParameter("mvcPath", "hello_soy_edit");
    }

    template.put("portletURL", portletURL.toString());

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();

    template.put("userName", user.getFirstName());

    super.render(renderRequest, renderResponse);
  }
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Map<String, List<SocialEquityActionMapping>> equityActionMappingsMap =
        new LinkedHashMap<String, List<SocialEquityActionMapping>>();

    String[] classNames = ResourceActionsUtil.getSocialEquityClassNames();

    Comparator<String> comparator = new ModelResourceComparator(themeDisplay.getLocale());

    Arrays.sort(classNames, comparator);

    for (String className : classNames) {
      List<SocialEquityActionMapping> mergedEquityActionMappings =
          getMergedEquityActionMappings(themeDisplay.getScopeGroupIdOrLiveGroupId(), className);

      equityActionMappingsMap.put(className, mergedEquityActionMappings);
    }

    renderRequest.setAttribute(WebKeys.SOCIAL_EQUITY_ACTION_MAPPINGS_MAP, equityActionMappingsMap);

    return mapping.findForward("portlet.social_equity_admin.view");
  }
예제 #8
0
  protected long getResourcePrimKey(RenderRequest renderRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletPreferences preferences = renderRequest.getPreferences();

    long defaultValue = GetterUtil.getLong(preferences.getValue("resourcePrimKey", null));

    String mvcPath = ParamUtil.getString(renderRequest, "mvcPath");

    if (((defaultValue == 0) && mvcPath.equals(viewTemplate))
        || mvcPath.equals("/display/select_configuration_article.jsp")) {

      return 0;
    }

    long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey", defaultValue);

    if ((resourcePrimKey == 0) || (resourcePrimKey != defaultValue)) {
      return resourcePrimKey;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!KBArticlePermission.contains(permissionChecker, defaultValue, ActionKeys.VIEW)) {

      return 0;
    }

    return defaultValue;
  }
예제 #9
0
  @Override
  protected Gadget getGadget(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    PortletConfig portletConfig = getPortletConfig();

    return ShindigUtil.getGadget(portletConfig.getPortletName(), themeDisplay.getCompanyId());
  }
  public String renderDDMTemplate(
      PageContext pageContext,
      long ddmTemplateId,
      List<?> entries,
      Map<String, Object> contextObjects)
      throws Exception {

    contextObjects.put(PortletDisplayTemplateConstants.DDM_TEMPLATE_ID, ddmTemplateId);
    contextObjects.put(PortletDisplayTemplateConstants.ENTRIES, entries);

    if (entries.size() == 1) {
      contextObjects.put(PortletDisplayTemplateConstants.ENTRY, entries.get(0));
    }

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    contextObjects.put(PortletDisplayTemplateConstants.LOCALE, request.getLocale());

    contextObjects.put(PortletDisplayTemplateConstants.REQUEST, request);

    RenderRequest renderRequest =
        (RenderRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);

    contextObjects.put(PortletDisplayTemplateConstants.RENDER_REQUEST, renderRequest);

    RenderResponse renderResponse =
        (RenderResponse) request.getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE);

    contextObjects.put(PortletDisplayTemplateConstants.RENDER_RESPONSE, renderResponse);

    PortletURL currentURL = PortletURLUtil.getCurrent(renderRequest, renderResponse);

    contextObjects.put(PortletDisplayTemplateConstants.CURRENT_URL, currentURL.toString());

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    contextObjects.put(PortletDisplayTemplateConstants.THEME_DISPLAY, themeDisplay);

    // Taglibs

    DDMTemplate ddmTemplate = DDMTemplateLocalServiceUtil.getTemplate(ddmTemplateId);

    String language = ddmTemplate.getLanguage();

    if (language.equals(TemplateConstants.LANG_TYPE_FTL)) {
      _addTaglibSupportFTL(contextObjects, pageContext);
    } else if (language.equals(TemplateConstants.LANG_TYPE_VM)) {
      _addTaglibSupportVM(contextObjects, pageContext);
    }

    contextObjects.putAll(_getPortletPreferences(renderRequest));

    return _transformer.transform(themeDisplay, contextObjects, ddmTemplate.getScript(), language);
  }
예제 #11
0
  protected boolean doRequestedAuthentication(
      HttpClient client, HttpMethod method, RenderRequest request, RenderResponse response) {
    if (super.doRequestedAuthentication(client, method, request, response)) {
      // already handled
      return true;
    }

    // System.out.println("SSOWebContentPortlet.doRequestedAuthentication...");

    if (method.getHostAuthState().getAuthScheme().getSchemeName().equals(BASIC_AUTH_SCHEME_NAME)) {
      // Basic authentication being requested
      String userName = (String) request.getAttribute(SSO_REQUEST_ATTRIBUTE_USERNAME);
      if (userName == null) userName = "";
      String password = (String) request.getAttribute(SSO_REQUEST_ATTRIBUTE_PASSWORD);
      if (password == null) password = "";

      // System.out.println("...providing basic authentication with userName: "******", and
      // password: "******"SSOWebContentPortlent.doAuthenticate() - unexpected authentication scheme: "
              + method.getHostAuthState().getAuthScheme().getSchemeName());
    }

    // only know how to handle Basic authentication, in this context
    return false;
  }
  /**
   * @see
   *     org.apache.portals.bridges.velocity.GenericVelocityPortlet#doView(javax.portlet.RenderRequest,
   *     javax.portlet.RenderResponse)
   */
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    Context context = getContext(request);
    IngridResourceBundle messages =
        new IngridResourceBundle(
            getPortletConfig().getResourceBundle(request.getLocale()), request.getLocale());
    context.put("MESSAGES", messages);

    // check for just logged in users
    HttpSession session =
        ((RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV))
            .getRequest()
            .getSession(true);
    String loginStarted = (String) session.getAttribute(Settings.SESSION_LOGIN_STARTED);
    if (loginStarted != null && loginStarted.equals("1")) {
      session.removeAttribute(Settings.SESSION_LOGIN_STARTED);
      // do something "after login" stuff

      // initialize the session preference with persistent data from
      // personalization
      IngridSessionPreferences sessionPrefs =
          Utils.getSessionPreferences(
              request, IngridSessionPreferences.SESSION_KEY, IngridSessionPreferences.class);
      if (sessionPrefs != null) {
        Principal principal = request.getUserPrincipal();
        if (principal != null) {
          HashMap persistentSearchSettings =
              (HashMap)
                  IngridPersistencePrefs.getPref(
                      principal.getName(), IngridPersistencePrefs.SEARCH_SETTINGS);
          if (persistentSearchSettings != null) {
            sessionPrefs.putAll(persistentSearchSettings);
          }
        }
      }
    }

    String userName = request.getUserPrincipal().getName();
    User user = null;
    try {
      user = userManager.getUser(userName);
    } catch (SecurityException e) {
      e.printStackTrace();
    }

    if (user != null) {
      context.put("userAttributes", user.getInfoMap());
    }

    super.doView(request, response);
  }
  @Override
  protected void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    try {
      String mvcPath = renderRequest.getParameter("mvcPath");

      if (mvcPath.equals("/edit_permissions.jsp")) {
        checkEditPermissionsJSP(renderRequest);

        super.doDispatch(renderRequest, renderResponse);

        return;
      }

      Portlet portlet = ActionUtil.getPortlet(renderRequest);

      if (mvcPath.endsWith("edit_configuration.jsp")) {
        ThemeDisplay themeDisplay =
            (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

        String settingsScope = renderRequest.getParameter("settingsScope");

        PortletPreferences portletPreferences =
            getPortletPreferences(themeDisplay, portlet.getPortletId(), settingsScope);

        renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, portletPreferences);

        renderEditConfiguration(renderRequest, portlet);
      } else {
        PortletPreferences portletPreferences =
            ActionUtil.getLayoutPortletSetup(renderRequest, portlet);

        renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, portletPreferences);

        if (mvcPath.endsWith("edit_public_render_parameters.jsp")) {
          renderEditPublicParameters(renderRequest, portlet);
        }
      }

      renderResponse.setTitle(ActionUtil.getTitle(portlet, renderRequest));

      super.doDispatch(renderRequest, renderResponse);
    } catch (Exception e) {
      _log.error(e.getMessage());

      SessionErrors.add(renderRequest, e.getClass());

      include("/error.jsp", renderRequest, renderResponse);
    }
  }
예제 #14
0
  public void render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {
    if (!_processed) {
      ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
      PortletConfig portletConfig =
          (PortletConfig) renderRequest.getAttribute("javax.portlet.config");
      _portletName = portletConfig.getPortletName();
      PortletURL pURL =
          PortletURLFactoryUtil.create(
              renderRequest,
              _portletName + "_WAR_" + _portletName + "portlet",
              themeDisplay.getPlid(),
              PortletRequest.ACTION_PHASE);
      pURL.setParameter(ActionRequest.ACTION_NAME, ProxyConstant.ACTION_LINK);
      _portletURL = pURL.toString();
      // read portlet config;
      PortletPreferences preferences = renderRequest.getPreferences();
      String portletResource = ParamUtil.getString(renderRequest, "portletResource");

      if (Validator.isNotNull(portletResource)) {
        try {
          preferences =
              PortletPreferencesFactoryUtil.getPortletSetup(renderRequest, portletResource);
        } catch (PortalException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (SystemException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
      _proxyURL = preferences.getValue("url", "");
      log.info("proxyurl=" + _proxyURL);

      defaultProxyRequest();
      renderResponse.getWriter().print(_result);
    } else renderResponse.getWriter().print("processed");
  }
  protected void setWorkflowTaskRenderRequestAttribute(RenderRequest renderRequest)
      throws PortalException {

    long workflowTaskId = ParamUtil.getLong(renderRequest, "workflowTaskId");

    if (workflowTaskId > 0) {
      ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

      WorkflowTask workflowTask =
          WorkflowTaskManagerUtil.getWorkflowTask(themeDisplay.getCompanyId(), workflowTaskId);

      renderRequest.setAttribute(WebKeys.WORKFLOW_TASK, workflowTask);
    }
  }
예제 #16
0
  @Override
  public String render(
      PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!_openId.isEnabled(themeDisplay.getCompanyId())) {
      return _forwards.get("portlet.login.login");
    }

    renderResponse.setTitle(themeDisplay.translate("open-id"));

    return _forwards.get("portlet.login.open_id");
  }
 @Override
 public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
     throws IOException, PortletException {
   ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
   renderRequest.setAttribute(
       "portletList",
       LocationTrackerUtil.getPortletList(themeDisplay.getCompanyId(), themeDisplay.getLocale()));
   renderRequest.setAttribute(
       "searchContainer", LocationTrackerUtil.getSearchContainer(renderRequest, renderResponse));
   String portletId = ParamUtil.getString(renderRequest, "portletId");
   renderRequest.setAttribute("selectedPortletId", portletId);
   // renderRequest.setAttribute("portletDetailList",
   // LocationTrackerUtil.findPortlet(renderRequest));
   include(viewJSP, renderRequest, renderResponse);
 }
예제 #18
0
  protected void updateAccessToken(RenderRequest renderRequest, String oAuthVerifier)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Token requestToken = oAuthManager.getRequestToken(themeDisplay.getUser());

    OAuthService oAuthService = oAuthManager.getOAuthService();

    Token accessToken = oAuthService.getAccessToken(requestToken, new Verifier(oAuthVerifier));

    oAuthManager.updateAccessToken(themeDisplay.getUser(), accessToken);

    oAuthManager.deleteRequestToken(themeDisplay.getUser());
  }
예제 #19
0
  protected void remoteRender(RenderRequest renderRequest, RenderResponse renderResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    OAuthRequest oAuthRequest = new OAuthRequest(Verb.GET, getServerPortletURL());

    setRequestParameters(renderRequest, renderResponse, oAuthRequest);

    Response response = getResponse(themeDisplay.getUser(), oAuthRequest);

    renderResponse.setContentType(ContentTypes.TEXT_HTML);

    PrintWriter printWriter = renderResponse.getWriter();

    printWriter.write(response.getBody());
  }
  /* (non-Javadoc)
   * @see com.liferay.util.bridges.mvc.MVCPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
   */
  @Override
  public void doView(RenderRequest request, RenderResponse response)
      throws IOException, PortletException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    try {
      long[] categoryIds = new long[0];

      TipOfTheDayUtil.retrieveCategories(request, themeDisplay, categoryIds);

    } catch (Exception e) {
      logger.error("Error retrieving categories", e);
    }

    super.doView(request, response);
  }
  @Override
  public void doEdit(RenderRequest request, RenderResponse response)
      throws IOException, PortletException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long groupId = themeDisplay.getScopeGroupId();
    request.setAttribute(GROUP_ID, groupId);

    PortletPreferences preferences = request.getPreferences();
    String[] ids =
        preferences.getValue(ARTICLE_ID, LR_EMPTY_VALUE).split(ARTICLE_SELECTION_DELIMITER);
    String defaultArticle = preferences.getValue(DEFAULT_ARTICLE, LR_EMPTY_VALUE);
    request.setAttribute(DEFAULT_ARTICLE, defaultArticle);
    request.setAttribute(IDS, ids);

    super.doEdit(request, response);
  }
  protected int getStatus(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!themeDisplay.isSignedIn()) {
      return WorkflowConstants.STATUS_APPROVED;
    }

    String statusString = renderRequest.getParameter("status");

    int status = GetterUtil.getInteger(statusString);

    if ((statusString != null) && (status == WorkflowConstants.STATUS_APPROVED)) {

      return WorkflowConstants.STATUS_APPROVED;
    }

    Tuple resourceTuple = getResourceTuple(renderRequest);

    long resourcePrimKey = (Long) resourceTuple.getObject(1);

    if (resourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
      return WorkflowConstants.STATUS_APPROVED;
    }

    long resourceClassNameId = (Long) resourceTuple.getObject(0);

    long kbArticleClassNameId = PortalUtil.getClassNameId(KBArticleConstants.getClassName());

    if (resourceClassNameId == kbArticleClassNameId) {
      KBArticle kbArticle =
          KBArticleServiceUtil.fetchLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY);

      if (kbArticle == null) {
        return WorkflowConstants.STATUS_APPROVED;
      }

      if (KBArticlePermission.contains(
          themeDisplay.getPermissionChecker(), resourcePrimKey, ActionKeys.UPDATE)) {

        return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
      }
    }

    return WorkflowConstants.STATUS_APPROVED;
  }
  protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response)
      throws Exception {

    ModelAndView mav = null;
    BindException errors = null;
    if (getErrorsAttributeName() != null) {
      errors = (BindException) request.getAttribute(getErrorsAttributeName());
    }
    if (errors != null) {
      mav = new ModelAndView(getSuccessViewName(), errors.getModel());
    } else {
      mav = new ModelAndView(getSuccessViewName());
    }
    Object obj = getObject(request);
    mav.addObject(getObjectName(), obj);
    addData(request, mav);
    return mav;
  }
  public DDLRecordSet getRecordSet() {
    if (_recordSet != null) {
      return _recordSet;
    }

    RenderRequest renderRequest = _ddlRequestHelper.getRenderRequest();

    _recordSet =
        (DDLRecordSet) renderRequest.getAttribute(DDLWebKeys.DYNAMIC_DATA_LISTS_RECORD_SET);

    if (_recordSet != null) {
      return _recordSet;
    }

    _recordSet = _ddlRecordSetLocalService.fetchDDLRecordSet(getRecordSetId());

    return _recordSet;
  }
  @Override
  public ActionForward render(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, null);

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId =
        ParamUtil.getLong(renderRequest, "resourceGroupId", themeDisplay.getScopeGroupId());

    String portletResource = ParamUtil.getString(renderRequest, "portletResource");
    String modelResource = ParamUtil.getString(renderRequest, "modelResource");
    String resourcePrimKey = ParamUtil.getString(renderRequest, "resourcePrimKey");

    String selResource = portletResource;

    if (Validator.isNotNull(modelResource)) {
      selResource = modelResource;
    }

    try {
      PermissionServiceUtil.checkPermission(groupId, selResource, resourcePrimKey);
    } catch (PrincipalException pe) {
      SessionErrors.add(renderRequest, PrincipalException.class.getName());

      setForward(renderRequest, "portlet.portlet_configuration.error");
    }

    Portlet portlet =
        PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletResource);

    if (portlet != null) {
      renderResponse.setTitle(ActionUtil.getTitle(portlet, renderRequest));
    }

    return actionMapping.findForward(
        getForward(renderRequest, "portlet.portlet_configuration.edit_permissions"));
  }
예제 #26
0
  @Override
  public void render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    try {
      ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

      int status = getStatus(renderRequest);

      renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status);

      KBArticle kbArticle = null;

      long resourcePrimKey = getResourcePrimKey(renderRequest);

      if (resourcePrimKey > 0) {
        kbArticle = KBArticleServiceUtil.getLatestKBArticle(resourcePrimKey, status);
      } else {
        List<KBArticle> kbArticles =
            KBArticleLocalServiceUtil.getGroupKBArticles(
                themeDisplay.getScopeGroupId(), status, 0, 1, new KBArticlePriorityComparator());

        if (!kbArticles.isEmpty()) {
          kbArticle = kbArticles.get(0);
        }
      }

      renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle);
    } catch (Exception e) {
      if (e instanceof NoSuchArticleException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass());

        SessionMessages.add(
            renderRequest,
            PortalUtil.getPortletId(renderRequest)
                + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
      } else {
        throw new PortletException(e);
      }
    }

    super.render(renderRequest, renderResponse);
  }
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String portletName = portletConfig.getPortletName();

    if (!portletName.equals(PortletKeys.FAST_LOGIN)) {
      return mapping.findForward("portlet.login.login");
    }

    renderResponse.setTitle(themeDisplay.translate("anonymous-account"));

    return mapping.findForward("portlet.login.create_anonymous_account");
  }
  @Override
  protected void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    try {
      ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

      Token accessToken = oAuthManager.getAccessToken(themeDisplay.getUser());

      if (accessToken == null) {
        include("/login.jsp", renderRequest, renderResponse);

        return;
      }
    } catch (PortalException pe) {
      throw new PortletException(pe);
    }

    renderRequest.setAttribute(MarketplaceStoreWebKeys.OAUTH_AUTHORIZED, Boolean.TRUE);

    super.doDispatch(renderRequest, renderResponse);
  }
  @Override
  public String render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException {

    try {
      ActionUtil.getEntry(renderRequest);

      if (PropsValues.BLOGS_PINGBACK_ENABLED) {
        BlogsEntry entry = (BlogsEntry) renderRequest.getAttribute(WebKeys.BLOGS_ENTRY);

        if ((entry != null) && entry.isAllowPingbacks()) {
          HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse);

          response.addHeader(
              "X-Pingback", PortalUtil.getPortalURL(renderRequest) + "/xmlrpc/pingback");
        }
      }
    } catch (Exception e) {
      if (e instanceof NoSuchEntryException || e instanceof PrincipalException) {

        SessionErrors.add(renderRequest, e.getClass());

        return "/html/portlet/blogs/error.jsp";
      } else {
        throw new PortletException(e);
      }
    }

    long assetCategoryId = ParamUtil.getLong(renderRequest, "categoryId");
    String assetCategoryName = ParamUtil.getString(renderRequest, "tag");

    if ((assetCategoryId > 0) || Validator.isNotNull(assetCategoryName)) {
      return "/html/portlet/blogs/view.jsp";
    }

    return getPath();
  }
  @Override
  public void doView(RenderRequest request, RenderResponse response)
      throws IOException, PortletException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    long groupId = themeDisplay.getScopeGroupId();

    PortletPreferences preferences = request.getPreferences();
    boolean showAnnouncer = false;
    if (themeDisplay.isSignedIn()) {
      String articleVersionId = preferences.getValue(ARTICLE_ID_CONSECUTIVE, LR_EMPTY_VALUE);
      String articleIds = preferences.getValue(ARTICLE_ID, LR_EMPTY_VALUE);
      if (!articleIds.equals(LR_EMPTY_VALUE)) {
        for (String articleId : articleIds.split(ARTICLE_SELECTION_DELIMITER)) {
          if (!AnnouncerTools.isArticle(groupId, articleId)) {
            AnnouncerTools.removeArticle(preferences, themeDisplay, articleId);
          }
          try {
            String layoutPK = String.valueOf(themeDisplay.getLayout().getPrimaryKey());
            showAnnouncer =
                AnnouncerTools.showAnnouncer(
                    themeDisplay.getRealUser().getUuid(), layoutPK, articleVersionId);
            request.setAttribute(ARTICLE_VERSION_ID, articleVersionId);
          } catch (SystemException e) {
            LOG.error(e);
          }
        }
      }
    }
    request.setAttribute(GROUP_ID, groupId);
    request.setAttribute(SHOW_ANNOUNCER, showAnnouncer);
    request.setAttribute(SIGNED_IN, themeDisplay.isSignedIn());
    String defaultArticle = preferences.getValue(DEFAULT_ARTICLE, LR_EMPTY_VALUE);
    request.setAttribute(DEFAULT_ARTICLE, defaultArticle);

    super.doView(request, response);
  }