@Override
  public String render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException {

    Portlet portlet = null;

    try {
      portlet = ActionUtil.getPortlet(renderRequest);
    } catch (PrincipalException pe) {
      SessionErrors.add(renderRequest, pe.getClass());

      return "/error.jsp";
    } catch (Exception e) {
      throw new PortletException(e);
    }

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

      renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, null);

      return "/publish_portlet.jsp";
    } catch (Exception e) {
      SessionErrors.add(renderRequest, e.getClass());

      return "/error.jsp";
    }
  }
Ejemplo n.º 2
0
 public void doEdit(RenderRequest request, RenderResponse response)
     throws IOException, PortletException {
   setRenderAttributes(request);
   response.setContentType("text/html");
   response.setTitle("Edit");
   PortletRequestDispatcher prd =
       getPortletContext().getRequestDispatcher("/WEB-INF/jsp/Browser/edit.jsp");
   prd.include(request, response);
 }
  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);
  }
  @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);
    }
  }
  /**
   * @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);

    PortletPreferences prefs = request.getPreferences();
    String titleKey = prefs.getValue("titleKey", "searchSettings.title.rankingAndGrouping");
    response.setTitle(messages.getString(titleKey));

    UtilsSearch.doViewForPartnerPortlet(request, context);

    Principal principal = request.getUserPrincipal();
    String partnerStr =
        (String)
            IngridPersistencePrefs.getPref(
                principal.getName(), IngridPersistencePrefs.SEARCH_PARTNER);

    if (partnerStr != null) {

      PortletSession session = request.getPortletSession();
      DisplayTreeNode partnerRoot = (DisplayTreeNode) session.getAttribute("partnerRoot");
      Iterator it = partnerRoot.getChildren().iterator();
      while (it.hasNext()) {
        DisplayTreeNode partnerNode = (DisplayTreeNode) it.next();
        if (partnerStr.indexOf(Settings.QFIELD_PARTNER.concat(":").concat(partnerNode.getId()))
                != -1
            || partnerNode.get("checked") != null) {
          partnerNode.put("checked", "true");
        } else {
          partnerNode.remove("checked");
        }
        Iterator it2 = partnerNode.getChildren().iterator();
        while (it2.hasNext()) {
          DisplayTreeNode providerNode = (DisplayTreeNode) it2.next();
          if (partnerStr.indexOf(Settings.QFIELD_PROVIDER.concat(":").concat(providerNode.getId()))
              != -1) {
            providerNode.put("checked", "true");
            partnerNode.setOpen(true);
          } else {
            providerNode.remove("checked");
          }
        }
      }
    }
    super.doView(request, response);
  }
Ejemplo n.º 6
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");
  }
  /**
   * @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);

    // set localized title for this page
    response.setTitle(messages.getString("admin.statistics.headline"));

    context.put(
        "apacheStatisticsURL",
        PortalConfig.getInstance().getString(PortalConfig.APACHE_STATISTICS_URL, ""));

    super.doView(request, response);
  }
  @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"));
  }
  @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");
  }
Ejemplo n.º 10
0
  // Render the portlet - this is not supposed to change the state of the portlet
  // Render may be called many times so if it changes the state - that is tacky
  // Render will be called when someone presses "refresh" or when another portlet
  // onthe same page is handed an Action.
  public void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
    response.setContentType("text/html");

    // System.out.println("==== doView called ====");

    // Grab that underlying request to get a GET parameter
    ServletRequest req = (ServletRequest) ThreadLocalManager.get(CURRENT_HTTP_REQUEST);
    String popupDone = req.getParameter("sakai.popup");

    PrintWriter out = response.getWriter();
    Placement placement = ToolManager.getCurrentPlacement();
    response.setTitle(placement.getTitle());
    String source = placement.getPlacementConfig().getProperty(SOURCE);
    if (source == null) source = "";
    String height = placement.getPlacementConfig().getProperty(HEIGHT);
    if (height == null) height = "1200px";
    boolean maximize = "true".equals(placement.getPlacementConfig().getProperty(MAXIMIZE));

    boolean popup = false; // Comes from content item
    boolean oldPopup = "true".equals(placement.getPlacementConfig().getProperty(POPUP));

    // Retrieve the corresponding content item and tool to check the launch
    Map<String, Object> content = null;
    Map<String, Object> tool = null;
    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;
    }
    try {
      content = m_ltiService.getContent(key);
      // If we are supposed to popup (per the content), do so and optionally
      // copy the calue into the placement to communicate with the portal
      popup = getLongNull(content.get("newpage")) == 1;
      if (oldPopup != popup) {
        placement.getPlacementConfig().setProperty(POPUP, popup ? "true" : "false");
        placement.save();
      }
      String launch = (String) content.get("launch");
      Long tool_id = getLongNull(content.get("tool_id"));
      if (launch == null && tool_id != null) {
        tool = m_ltiService.getTool(tool_id);
        launch = (String) tool.get("launch");
      }

      // Force http:// to pop-up if we are https://
      String serverUrl = ServerConfigurationService.getServerUrl();
      if (request.isSecure() || (serverUrl != null && serverUrl.startsWith("https://"))) {
        if (launch != null && launch.startsWith("http://")) popup = true;
      }
    } catch (Exception e) {
      out.println(rb.getString("get.info.notconfig"));
      e.printStackTrace();
      return;
    }

    if (source != null && source.trim().length() > 0) {

      Context context = new VelocityContext();
      context.put("tlang", rb);
      context.put("validator", validator);
      context.put("source", source);
      context.put("height", height);
      sendAlert(request, context);
      context.put("popupdone", Boolean.valueOf(popupDone != null));
      context.put("popup", Boolean.valueOf(popup));
      context.put("maximize", Boolean.valueOf(maximize));

      vHelper.doTemplate(vengine, "/vm/main.vm", context, out);
    } else {
      out.println(rb.getString("get.info.notconfig"));
    }

    // System.out.println("==== doView complete ====");
  }
 public void setTitle(String title) {
   response.setTitle(title);
 }
  @SuppressWarnings("unchecked")
  @RenderMode(name = "VIEW")
  public void showBooks(RenderRequest request, RenderResponse response)
      throws IOException, PortletException {
    logger.info("Entering showBooks method");
    PortalContext context = request.getPortalContext();
    printSupportedPortletModes(context);
    printSupportedWindowStates(context);

    // --get user attributes user.name.given and user.name.family
    Map<String, Object> userAttributeMap =
        (Map<String, Object>) request.getAttribute(PortletRequest.USER_INFO);
    String firstName = "";
    String lastName = "";
    if (userAttributeMap != null) {
      firstName = (String) userAttributeMap.get("user.name.given");
      lastName = (String) userAttributeMap.get("user.name.family");
      request.setAttribute("firstName", firstName);
      request.setAttribute("lastName", lastName);
    }

    String portalInfo = context.getPortalInfo();
    request.setAttribute("portalInfo", portalInfo);

    // --generate all the URLs that will be used by the portlet
    generateUrls(request, response);

    String myaction = request.getParameter("myaction");
    if (myaction != null) {
      logger.info("myaction parameter is not null. Value is " + myaction);
      request.getPortletSession().setAttribute("myaction", myaction, PortletSession.PORTLET_SCOPE);
    } else {
      // -- if myaction is NULL then show the home page of Book
      // catalog
      // page
      request
          .getPortletSession()
          .setAttribute("myaction", "showCatalog", PortletSession.PORTLET_SCOPE);
    }

    // -- send myaction as a request attribute to the BookServlet.
    request.setAttribute("myaction", request.getPortletSession().getAttribute("myaction"));

    // --dynamically obtain the title for the portlet, based on myaction
    String titleKey =
        "portlet.title." + (String) request.getPortletSession().getAttribute("myaction");
    response.setTitle(getResourceBundle(request.getLocale()).getString(titleKey));

    // --if the action is uploadTocForm then store the ISBN number of
    // the
    // --book for which the TOC is being uploaded. The upload action
    // will use the ISBN number to create file name -- refer home.jsp
    // page
    if (((String) request.getAttribute("myaction")).equalsIgnoreCase("uploadTocForm")) {
      request.getPortletSession().setAttribute("isbnNumber", request.getParameter("isbnNumber"));
    }

    if (((String) request.getPortletSession().getAttribute("myaction"))
        .equalsIgnoreCase("showSearchResults")) {
      request.setAttribute(
          "matchingBooks", request.getPortletSession().getAttribute("matchingBooks"));
    }

    // its important to encode URLs
    PortletRequestDispatcher dispatcher =
        request
            .getPortletSession()
            .getPortletContext()
            .getRequestDispatcher(response.encodeURL("/myservlet/bookServlet"));
    dispatcher.include(request, response);
  }