@Override
  public void processAction(ActionRequest portletReq, ActionResponse portletResp)
      throws PortletException, IOException {
    LOGGER.entering(LOG_CLASS, "main portlet processAction entry");

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

    StringWriter writer = new StringWriter();
  }
示例#2
0
 protected void processParameters(ActionRequest request, Properties args, List<Result> results) {
   final String METHOD_NAME = "processParameters";
   boolean isTraceEnabled = LOGGER.isLoggable(Level.FINER);
   boolean isDebugEnabled = LOGGER.isLoggable(Level.FINEST);
   boolean isErrorEnabled = LOGGER.isLoggable(Level.SEVERE);
   if (isTraceEnabled) {
     LOGGER.entering(
         CLASS_NAME, METHOD_NAME, new Object[] {request.getParameterMap(), args, results});
   }
   String title = Utils.param(request, this.templateId + "_title");
   if (isDebugEnabled) {
     LOGGER.finest(METHOD_NAME + " Checking for widget title...");
   }
   if (!Utils.empty(title)) {
     if (isDebugEnabled) {
       LOGGER.finest(METHOD_NAME + " Found widget title " + title + "...");
     }
     args.setProperty("title", title);
   } else {
     results.add(new PortletResult(Result.WARNING, Results.MISSING_TITLE));
   }
   if (requiresSubtitle()) {
     String subTitle = Utils.param(request, this.templateId + "_subTitle");
     if (isDebugEnabled) {
       LOGGER.finest(METHOD_NAME + " Checking for widget subTitle...");
     }
     if (!Utils.empty(subTitle)) {
       if (isDebugEnabled) {
         LOGGER.finest(METHOD_NAME + " Found widget subTitle " + subTitle + "...");
       }
       args.setProperty("subTitle", subTitle);
     } else {
       results.add(new PortletResult(Result.WARNING, Results.MISSING_SUBTITLE));
     }
   }
   if (hasStyles()) {
     String style = Utils.param(request, getTemplateId() + "_style");
     if (isDebugEnabled) {
       LOGGER.finest(METHOD_NAME + " Checking for template style...");
     }
     if (!Utils.empty(style)) {
       if (isDebugEnabled) {
         LOGGER.finest(METHOD_NAME + " Found template style " + style + "...");
       }
       args.setProperty("style", style);
     } else {
       results.add(new PortletResult(Result.WARNING, Results.MISSING_STYLE));
     }
   }
   if (isTraceEnabled) {
     LOGGER.exiting(CLASS_NAME, METHOD_NAME);
   }
 }
  @Override
  public void processAction(ActionRequest portletReq, ActionResponse portletResp)
      throws PortletException, IOException {
    LOGGER.entering(LOG_CLASS, "main portlet processAction entry");

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

    StringWriter writer = new StringWriter();

    // Now do the actual dispatch
    String target =
        JSP_PREFIX
            + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPActionResponse"
            + JSP_SUFFIX
            + "?"
            + QUERY_STRING;
    PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
    rd.include(portletReq, portletResp);
  }
示例#4
0
  public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException {

    log.info("processaction");
    // read the config
    getPortletInfo(actionRequest);

    String method = actionRequest.getMethod();

    // get posted/getted params
    Map<String, String[]> paramMap = actionRequest.getParameterMap(); // .getRequestParameterMap();

    // build our proxy request to target server
    HttpProxyImpl proxy = new HttpProxyImpl();

    ProxyResponse pResponse = null;

    XslContentTransformer xform =
        new XslContentTransformer("/com/plexobject/transform/xhtmlTransform.xslt", true);
    Map<String, String> props = new HashMap<String, String>();
    props.put("callbackHandler", "www.portlet.com");
    props.put("portletURL", _portletURL);
    // props.put("portletURL",portletURL);

    String origActionURL = "", rootURL = _proxyURL;

    Map<String, String[]> params = new HashMap<String, String[]>();
    Iterator i = paramMap.keySet().iterator();
    while (i.hasNext()) {
      String key = (String) i.next();
      String value = ((String[]) paramMap.get(key))[0];

      if (key.equalsIgnoreCase("origUrl")) // test for regular link e.g. a href
      origActionURL = value;
      else if (key.equalsIgnoreCase("_originalActionUrl")) // test for form link
      origActionURL = value;
      else if (key.equalsIgnoreCase("rootURL")) rootURL = value;
      else params.put(key, paramMap.get(key));
      // log.info("Key="+ key + " value=" + value);

    }

    String url = origActionURL == "" ? _proxyURL : origActionURL;
    // set relative URL

    if (Validator.isNotNull(_state)) rootURL = _state.getUri();
    url = buildProxyURL(url, rootURL);

    log.info("url=" + url + " method=" + method + " rooturl=" + rootURL);

    if (_state == null) _state = new ProxyState(url, method);
    else _state.setUri(url, method);
    pResponse = proxy.request(_state, params);

    String response = xform.transform(pResponse.getContents(), props);
    // System.out.print(response);
    // log.info(response);
    actionRequest.setAttribute("result", response);
    actionRequest.setAttribute("url", url);
    log.info("endAction");
    /*
    //show the result
    String portletName = (String)actionRequest.getAttribute(WebKeys.PORTLET_ID);
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PortletURL redirectURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest),portletName,
                   themeDisplay.getLayout().getPlid(), PortletRequest.RENDER_PHASE);
    redirectURL.setParameter("jspPage", ProxyConstant.RENDER_RESPONSE); // set required parameter that you need in doView or render Method
    //redirectURL.setParameter("content", response);
    actionResponse.sendRedirect(redirectURL.toString());

           */
  }
  @Override
  public void processAction(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse)
      throws Exception {

    File file = null;

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

      long groupId = ParamUtil.getLong(actionRequest, "groupId");
      boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");
      long[] layoutIds = ParamUtil.getLongValues(actionRequest, "layoutIds");
      String fileName = ParamUtil.getString(actionRequest, "exportFileName");
      String range = ParamUtil.getString(actionRequest, "range");

      Date startDate = null;
      Date endDate = null;

      if (range.equals("dateRange")) {
        int startDateMonth = ParamUtil.getInteger(actionRequest, "startDateMonth");
        int startDateDay = ParamUtil.getInteger(actionRequest, "startDateDay");
        int startDateYear = ParamUtil.getInteger(actionRequest, "startDateYear");
        int startDateHour = ParamUtil.getInteger(actionRequest, "startDateHour");
        int startDateMinute = ParamUtil.getInteger(actionRequest, "startDateMinute");
        int startDateAmPm = ParamUtil.getInteger(actionRequest, "startDateAmPm");

        if (startDateAmPm == Calendar.PM) {
          startDateHour += 12;
        }

        startDate =
            PortalUtil.getDate(
                startDateMonth,
                startDateDay,
                startDateYear,
                startDateHour,
                startDateMinute,
                themeDisplay.getTimeZone(),
                new PortalException());

        int endDateMonth = ParamUtil.getInteger(actionRequest, "endDateMonth");
        int endDateDay = ParamUtil.getInteger(actionRequest, "endDateDay");
        int endDateYear = ParamUtil.getInteger(actionRequest, "endDateYear");
        int endDateHour = ParamUtil.getInteger(actionRequest, "endDateHour");
        int endDateMinute = ParamUtil.getInteger(actionRequest, "endDateMinute");
        int endDateAmPm = ParamUtil.getInteger(actionRequest, "endDateAmPm");

        if (endDateAmPm == Calendar.PM) {
          endDateHour += 12;
        }

        endDate =
            PortalUtil.getDate(
                endDateMonth,
                endDateDay,
                endDateYear,
                endDateHour,
                endDateMinute,
                themeDisplay.getTimeZone(),
                new PortalException());
      } else if (range.equals("fromLastPublishDate")) {
        LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, privateLayout);

        UnicodeProperties settingsProperties = layoutSet.getSettingsProperties();

        long lastPublishDate =
            GetterUtil.getLong(settingsProperties.getProperty("last-publish-date"));

        if (lastPublishDate > 0) {
          Calendar cal = Calendar.getInstance(themeDisplay.getTimeZone(), themeDisplay.getLocale());

          endDate = cal.getTime();

          cal.setTimeInMillis(lastPublishDate);

          startDate = cal.getTime();
        }
      } else if (range.equals("last")) {
        int rangeLast = ParamUtil.getInteger(actionRequest, "last");

        Date now = new Date();

        startDate = new Date(now.getTime() - (rangeLast * Time.HOUR));

        endDate = now;
      }

      file =
          LayoutServiceUtil.exportLayoutsAsFile(
              groupId,
              privateLayout,
              layoutIds,
              actionRequest.getParameterMap(),
              startDate,
              endDate);

      HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
      HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);

      ServletResponseUtil.sendFile(
          request, response, fileName, new FileInputStream(file), ContentTypes.APPLICATION_ZIP);

      setForward(actionRequest, ActionConstants.COMMON_NULL);
    } catch (Exception e) {
      _log.error(e, e);

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

      String pagesRedirect = ParamUtil.getString(actionRequest, "pagesRedirect");

      sendRedirect(actionRequest, actionResponse, pagesRedirect);
    } finally {
      FileUtil.delete(file);
    }
  }
示例#6
0
 public void buildPortletConfiguration(
     ActionRequest request,
     ActionResponse response,
     Map<String, Object> adminPrefs,
     Map<String, Object> sharedPrefs)
     throws DesignerException {
   final String METHOD_NAME = "buildPortletConfiguration";
   boolean isTraceEnabled = LOGGER.isLoggable(Level.FINER);
   boolean isDebugEnabled = LOGGER.isLoggable(Level.FINEST);
   boolean isErrorEnabled = LOGGER.isLoggable(Level.SEVERE);
   if (isTraceEnabled) {
     LOGGER.entering(CLASS_NAME, METHOD_NAME, new Object[] {request.getParameterMap()});
   }
   Properties args = new Properties();
   List<Result> results = new ArrayList<Result>();
   processParameters(request, args, results);
   if (results.size() == 0) {
     WidgetFactory f = WidgetFactory.createWidgetFactory(request, response);
     LrpConfig lrpConfig = createWidget(f, args, results);
     if (lrpConfig != null) {
       if (isDebugEnabled) {
         LOGGER.finest(METHOD_NAME + " Widget creation successful! LRP config is " + lrpConfig);
       }
       sharedPrefs.put(Constants.WCM_CONTENT_TYPE_PREF, lrpConfig.getContentType());
       sharedPrefs.put(Constants.WCM_CONTENT_CONTEXT_TYPE_PREF, lrpConfig.getContentContextType());
       sharedPrefs.put(Constants.WCM_CONTENT_CONTEXT_IDR_PREF, lrpConfig.getContentIdr());
       String componentIdr = lrpConfig.getComponentIdr();
       String broadcastsTo = lrpConfig.getBroadcastsTo();
       String listensTo = lrpConfig.getListensTo();
       String categories = lrpConfig.getCategories();
       String siteAreas = lrpConfig.getSiteAreas();
       String title = lrpConfig.getPortletTitle();
       if (componentIdr != null) {
         sharedPrefs.put(Constants.WCM_COMPONENT_IDR_PREF, componentIdr);
       }
       if (broadcastsTo != null) {
         sharedPrefs.put(Constants.WCM_BROADCASTS_TO_PREF, broadcastsTo);
       }
       if (listensTo != null) {
         sharedPrefs.put(Constants.WCM_LISTENS_TO_PREF, listensTo);
       }
       if (categories != null) {
         sharedPrefs.put(Constants.WCM_CATEGORY_OVERRIDE_PREF, categories);
       }
       if (siteAreas != null) {
         sharedPrefs.put(Constants.WCM_SITEAREA_OVERRIDE_PREF, siteAreas);
       }
       if (title != null) {
         sharedPrefs.put(Constants.WCM_PORTLET_TITLE_PREF, title);
         sharedPrefs.put(
             Constants.WCM_PORTLET_TITLE_TYPE_PREF, Constants.WCM_PORTLET_TITLE_TYPE_GENERAL);
       }
       if (isDebugEnabled) {
         LOGGER.finest(METHOD_NAME + " Configured shared prefs: " + sharedPrefs);
       }
     } else {
       if (isDebugEnabled) {
         LOGGER.finest(METHOD_NAME + " Widget creation failed!");
       }
       DesignerException e = new DesignerException();
       for (Result r : results) {
         e.addResult(r);
       }
       throw e;
     }
   } else {
     DesignerException e = new DesignerException();
     for (Result r : results) {
       e.addResult(r);
     }
     throw e;
   }
   if (isTraceEnabled) {
     LOGGER.exiting(CLASS_NAME, METHOD_NAME);
   }
 }