コード例 #1
0
  // Read access token from DB and display error message if it's not available
  protected AccessToken loadAccessTokenOrRedirectToObtainIt(
      String username, OAuthProvider oauthProvider, RenderRequest request, RenderResponse response)
      throws IOException, PortletException {
    // Try requestContext first. Otherwise obtain OAuthProvider via API
    AccessToken accessToken = requestContext.getAccessToken(oauthProviderKey);
    if (accessToken == null) {
      accessToken = oauthProvider.loadAccessToken(username);
    }

    if (accessToken == null) {
      // Will be processed by method AbstractSocialPortlet.actionRedirectToOAuthFlow
      PortletURL actionURL = response.createActionURL();
      actionURL.setParameter(
          ActionRequest.ACTION_NAME, AbstractSocialPortlet.ACTION_OAUTH_REDIRECT);

      request.setAttribute(
          ATTRIBUTE_ERROR_MESSAGE,
          oauthProvider.getFriendlyName() + " access token not available for you.");
      request.setAttribute(ATTRIBUTE_OAUTH_PROVIDER, oauthProvider);
      PortletRequestDispatcher prd =
          filterConfig.getPortletContext().getRequestDispatcher("/jsp/error/token.jsp");
      prd.include(request, response);
    }

    return accessToken;
  }
コード例 #2
0
ファイル: PortletURLUtil.java プロジェクト: nykma/ykt4sungard
  public static PortletURL clone(
      LiferayPortletURL liferayPortletURL, boolean action, RenderResponse res)
      throws PortletException {

    LiferayPortletURL newURLImpl = null;

    if (action) {
      newURLImpl = (LiferayPortletURL) res.createActionURL();
    } else {
      newURLImpl = (LiferayPortletURL) res.createRenderURL();
    }

    newURLImpl.setPortletId(liferayPortletURL.getPortletId());

    WindowState windowState = liferayPortletURL.getWindowState();

    if (windowState != null) {
      newURLImpl.setWindowState(windowState);
    }

    PortletMode portletMode = liferayPortletURL.getPortletMode();

    if (portletMode != null) {
      newURLImpl.setPortletMode(portletMode);
    }

    newURLImpl.setParameters(liferayPortletURL.getParameterMap());

    return newURLImpl;
  }
コード例 #3
0
  public void doEdit(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = getTitleString(request);
    if (title != null) response.setTitle(title);

    Context context = new VelocityContext();
    context.put("tlang", rb);
    context.put("validator", validator);
    sendAlert(request, context);

    PortletURL url = response.createActionURL();
    context.put("actionUrl", url.toString());
    context.put("doCancel", "sakai.cancel");
    context.put("doUpdate", "sakai.update");

    // get current site
    Placement placement = ToolManager.getCurrentPlacement();
    String siteId = "";

    // find the right LTIContent object for this page
    String source = placement.getPlacementConfig().getProperty(SOURCE);
    Long key = getContentIdFromSource(source);
    if (key == null) {
      out.println(rb.getString("get.info.notconfig"));
      M_log.warn("Cannot find content id placement=" + placement.getId() + " source=" + source);
      return;
    }

    Map<String, Object> content = m_ltiService.getContent(key);
    if (content == null) {
      out.println(rb.getString("get.info.notconfig"));
      M_log.warn("Cannot find content item placement=" + placement.getId() + " key=" + key);
      return;
    }

    // attach the ltiToolId to each model attribute, so that we could have the tool configuration
    // page for multiple tools
    String foundLtiToolId = content.get(m_ltiService.LTI_TOOL_ID).toString();
    Map<String, Object> tool = m_ltiService.getTool(Long.valueOf(foundLtiToolId));
    if (tool == null) {
      out.println(rb.getString("get.info.notconfig"));
      M_log.warn("Cannot find tool placement=" + placement.getId() + " key=" + foundLtiToolId);
      return;
    }

    String[] contentToolModel = m_ltiService.getContentModel(Long.valueOf(foundLtiToolId));
    String formInput = m_ltiService.formInput(content, contentToolModel);
    context.put("formInput", formInput);

    vHelper.doTemplate(vengine, "/vm/edit.vm", context, out);
  }
  /* set the Portlet's default Edit: it's a simple <form> */
  public void doEdit(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    renderResponse.setContentType("text/html");
    PortletURL saveSettingsStatisticsURL = renderResponse.createActionURL();
    saveSettingsStatisticsURL.setParameter(
        "saveSettingsGoogleMapsUtility", "saveSettingsGoogleMapsUtility");
    renderRequest.setAttribute(
        "saveSettingsGoogleMapsUtilityURL", saveSettingsStatisticsURL.toString());

    include(editJSP, renderRequest, renderResponse);
  }
コード例 #5
0
  @Override
  public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException {

    renderResponse.setContentType(ContentTypes.TEXT_HTML);

    PrintWriter printWriter = renderResponse.getWriter();

    printWriter.write("<a href=\"");
    printWriter.write(String.valueOf(renderResponse.createActionURL()));
    printWriter.write("\">Send Event</a>");

    printWriter.close();
  }
コード例 #6
0
 /**
  * From the parameter HashMap at input, creates the reference navigation url.
  *
  * @param paramsMap The parameter HashMap
  * @return A <code>portletURL</code> object representing the navigation URL
  */
 protected PortletURL createUrl(HashMap paramsMap) {
   PortletURL url = renderResponse.createActionURL();
   Set paramsKeys = paramsMap.keySet();
   Iterator iter = paramsKeys.iterator();
   while (iter.hasNext()) {
     String paramKey = (String) iter.next();
     String paramValue = (String) paramsMap.get(paramKey);
     //			paramKey = JavaScript.escape(paramKey.toUpperCase());
     //			paramValue = JavaScript.escape(paramValue.toUpperCase());
     // paramKey = JavaScript.escape(paramKey);
     // paramValue = JavaScript.escape(paramValue);
     url.setParameter(paramKey, paramValue);
   }
   return url;
 }
コード例 #7
0
 public PortletURL createActionURL() {
   return response.createActionURL();
 }
コード例 #8
0
  private void generateUrls(RenderRequest request, RenderResponse response)
      throws PortletModeException, WindowStateException {
    // Render URL for Print hyperlink
    PortletURL printModeUrl = response.createRenderURL();
    if (request.isPortletModeAllowed(new PortletMode("print"))) {
      printModeUrl.setPortletMode(new PortletMode("print"));
    }
    if (request.isWindowStateAllowed(new WindowState("pop_up"))) {
      printModeUrl.setWindowState(new WindowState("pop_up"));
    }
    request.setAttribute("printModeUrl", printModeUrl);

    // Action URL for upload Toc action
    PortletURL uploadTocActionUrl = response.createActionURL();
    uploadTocActionUrl.setParameter("myaction", "uploadTocAction");
    uploadTocActionUrl.setParameter(ActionRequest.ACTION_NAME, "uploadTocAction");
    request.setAttribute("uploadTocActionUrl", uploadTocActionUrl);

    // Render URL for Full Screen hyperlink
    PortletURL fullScreenUrl = response.createRenderURL();
    fullScreenUrl.setWindowState(WindowState.MAXIMIZED);
    request.setAttribute("fullScreenUrl", fullScreenUrl);

    // Render URL for Help hyperlink
    PortletURL helpUrl = response.createRenderURL();
    helpUrl.setPortletMode(PortletMode.HELP);
    request.setAttribute("helpUrl", helpUrl);

    // Render URL for Home hyperlink
    PortletURL homeUrl = response.createRenderURL();
    homeUrl.setPortletMode(PortletMode.VIEW);
    request.setAttribute("homeUrl", homeUrl);

    // Render URL for Preferences hyperlink
    PortletURL prefUrl = response.createRenderURL();
    prefUrl.setPortletMode(PortletMode.EDIT);
    request.setAttribute("prefUrl", prefUrl);

    // Render URL for form submission for Adding book
    PortletURL addBookFormUrl = response.createRenderURL();
    addBookFormUrl.setParameter("myaction", "addBookForm");
    request.setAttribute("addBookFormUrl", addBookFormUrl);

    // Action URL for Add Book Action
    PortletURL addBookActionUrl = response.createActionURL();
    addBookActionUrl.setParameter(ActionRequest.ACTION_NAME, "addBookAction");
    request.setAttribute("addBookActionUrl", addBookActionUrl);

    // Action URL for resetting search
    PortletURL resetActionUrl = response.createActionURL();
    resetActionUrl.setParameter(ActionRequest.ACTION_NAME, "resetAction");
    request.setAttribute("resetActionUrl", resetActionUrl);

    // Action URL for searching books
    PortletURL searchBookActionUrl = response.createActionURL();
    searchBookActionUrl.setParameter(ActionRequest.ACTION_NAME, "searchBookAction");
    request.setAttribute("searchBookActionUrl", searchBookActionUrl);

    // Render URL for Refresh Search Results link
    PortletURL refreshResultsUrl = response.createRenderURL();
    refreshResultsUrl.setParameter("myaction", "refreshResults");
    request.setAttribute("refreshResultsUrl", refreshResultsUrl);
  }
  @Override
  public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {
    LOGGER.entering(LOG_CLASS, "main portlet render entry");

    long tid = Thread.currentThread().getId();
    portletReq.setAttribute(THREADID_ATTR, tid);

    PrintWriter writer = portletResp.getWriter();

    PortletSession ps = portletReq.getPortletSession();
    String msg =
        (String)
            ps.getAttribute(
                RESULT_ATTR_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse",
                APPLICATION_SCOPE);
    if (msg != null) {
      writer.write("<p>" + msg + "</p><br/>\n");
      ps.removeAttribute(
          RESULT_ATTR_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse",
          APPLICATION_SCOPE);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_containsHeader */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.containsHeader must return false"         */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_containsHeader", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectURL1 */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeRedirectURL must return null"       */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectURL1",
              aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectUrl */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeRedirectUrl must return null"       */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeRedirectUrl",
              aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeURL1 */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeURL must provide the same           */
    /* functionality as ActionResponse.encodeURL"                           */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeURL1", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeUrl */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.encodeUrl must provide the same           */
    /* functionality as ActionResponse.encodeURL"                           */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_encodeUrl", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getBufferSize */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getBufferSize must return 0"              */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getBufferSize", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getCharacterEncoding */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getCharacterEncoding must return null"    */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getCharacterEncoding",
              aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getContentType */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getContentType must return null"          */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getContentType", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getLocale */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.getLocale must return null"               */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_getLocale", aurl);
      tb.writeTo(writer);
    }

    /* TestCase: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_isCommitted */
    /* Details: "In a target jsp of a include in the Action phase, the      */
    /* method HttpServletResponse.isCommitted must return true"             */
    {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb =
          new TestButton(
              "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse_isCommitted", aurl);
      tb.writeTo(writer);
    }
  }
コード例 #10
0
  /**
   * Do start tag.
   *
   * @return the int
   * @throws JspException the jsp exception
   * @see it.eng.spagobi.commons.presentation.tags.CheckListTag#doStartTag()
   */
  public int doStartTag() throws JspException {
    SpagoBITracer.info("Admintools", "ListTag", "doStartTag", " method invoked");
    httpRequest = (HttpServletRequest) pageContext.getRequest();
    renderResponse = (RenderResponse) httpRequest.getAttribute("javax.portlet.response");
    renderRequest = (RenderRequest) httpRequest.getAttribute("javax.portlet.request");

    _requestContainer = RequestContainerPortletAccess.getRequestContainer(httpRequest);
    portReq = PortletUtilities.getPortletRequest();
    _serviceRequest = _requestContainer.getServiceRequest();
    _responseContainer = ResponseContainerPortletAccess.getResponseContainer(httpRequest);

    msgBuilder = MessageBuilderFactory.getMessageBuilder();
    if (_bundle == null) _bundle = "messages";

    _session = _requestContainer.getSessionContainer();

    _serviceResponse = _responseContainer.getServiceResponse();
    ConfigSingleton configure = ConfigSingleton.getInstance();
    if (_actionName != null) {
      _serviceName = _actionName;
      _content = _serviceResponse;
      SourceBean actionBean =
          (SourceBean)
              configure.getFilteredSourceBeanAttribute("ACTIONS.ACTION", "NAME", _actionName);
      _layout = (SourceBean) actionBean.getAttribute("CONFIG");
      if (_layout == null) {
        // if the layout is dinamically created it is an attribute of the response
        _layout = (SourceBean) _serviceResponse.getAttribute("CONFIG");
      }
      _providerURL = "ACTION_NAME=" + _actionName + "&";
      _providerUrlMap.put("ACTION_NAME", _actionName);
      HashMap params = (HashMap) _serviceResponse.getAttribute("PARAMETERS_MAP");
      if (params != null) {
        _paramsMap = params;
        _providerUrlMap.putAll(_paramsMap);
      }
    } // if (_actionName != null)
    else if (_moduleName != null) {
      _serviceName = _moduleName;
      SpagoBITracer.debug("Admintools", "ListTag", "doStartTag", " Module Name: " + _moduleName);
      _content = (SourceBean) _serviceResponse.getAttribute(_moduleName);
      SourceBean moduleBean =
          (SourceBean)
              configure.getFilteredSourceBeanAttribute("MODULES.MODULE", "NAME", _moduleName);

      if (moduleBean != null)
        SpagoBITracer.debug(
            "Admintools", "ListTag", "doStartTag", _moduleName + " configuration loaded");
      _layout = (SourceBean) moduleBean.getAttribute("CONFIG");
      if (_layout == null) {
        // if the layout is dinamically created it is an attribute of the response
        _layout = (SourceBean) _serviceResponse.getAttribute(_moduleName + ".CONFIG");
      }
      String pageName = (String) _serviceRequest.getAttribute("PAGE");
      SpagoBITracer.debug("Admintools", "ListTag", "doStartTag", " PAGE: " + pageName);
      _providerURL = "PAGE=" + pageName + "&MODULE=" + _moduleName + "&";
      _providerUrlMap.put("PAGE", pageName);
      _providerUrlMap.put("MODULE", _moduleName);
      HashMap params = (HashMap) _serviceResponse.getAttribute(_moduleName + ".PARAMETERS_MAP");
      if (params != null) {
        _paramsMap = params;
        _providerUrlMap.putAll(_paramsMap);
      }
    } // if (_moduleName != null)
    else {
      SpagoBITracer.critical("Admintools", "ListTag", "doStartTag", "service name not specified");
      throw new JspException("Business name not specified !");
    } // if (_content == null)
    if (_content == null) {
      SpagoBITracer.warning("Admintools", "ListTag", "doStartTag", "list content null");
      return SKIP_BODY;
    } // if (_content == null)
    if (_layout == null) {
      SpagoBITracer.warning(
          "Admintools", "ListTag", "doStartTag", "list module configuration null");
      return SKIP_BODY;
    } // if (_layout == null)
    // if the LightNavigator is disabled entering the list, it is kept disabled untill exiting the
    // list
    Object lightNavigatorDisabledObj =
        _serviceRequest.getAttribute(LightNavigationManager.LIGHT_NAVIGATOR_DISABLED);
    if (lightNavigatorDisabledObj != null) {
      String lightNavigatorDisabled = (String) lightNavigatorDisabledObj;
      _providerUrlMap.put(LightNavigationManager.LIGHT_NAVIGATOR_DISABLED, lightNavigatorDisabled);
    }
    _htmlStream = new StringBuffer();

    PortletURL url = renderResponse.createActionURL();
    url.setParameter("PAGE", "DetailBIObjectPage");
    url.setParameter("MESSAGEDET", "RETURN_FROM_SUBREPORTS_LOOKUP");
    url.setParameter("LIGHT_NAVIGATOR_DISABLED", "true");

    _htmlStream.append(" <form method='POST' action='" + url.toString() + "'>\n");
    makeForm();
    _htmlStream.append(" </form>\n");
    try {
      pageContext.getOut().print(_htmlStream);
    } // try
    catch (Exception ex) {
      SpagoBITracer.critical(
          "Admintools", "ListTag", "doStartTag", "Impossible to send the stream");
      throw new JspException("Impossible to send the stream");
    } // catch (Exception ex)
    return SKIP_BODY;
  } // public int doStartTag() throws JspException