예제 #1
0
  public static String getResourceProxyURL(Map params) {
    FastStringBuffer url = new FastStringBuffer();

    url.append("/wsrp/resource_proxy/get");

    if (params != null) {

      String paramValue = GetterUtil.getString((String) params.get(Constants.URL));

      url.append(Constants.PARAMS_START);
      url.append("url");
      url.append(Constants.EQUALS);
      try {
        paramValue = Base64.encode(ObjectSerializer.serialize(paramValue));
        url.append(paramValue);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    String cookie = SimpleHTTPSender.getCurrentCookie();
    try {
      cookie = Base64.encode(ObjectSerializer.serialize(cookie));
    } catch (Exception e) {
      e.printStackTrace();
    }

    url.append(Constants.NEXT_PARAM);
    url.append("cookie");
    url.append(Constants.EQUALS);
    url.append(cookie);

    return url.toString();
  }
예제 #2
0
  private Map _getParameters(String paramString) {
    Map navParams = new HashMap();

    if (paramString != null) {
      byte[] desMap = Base64.decode(paramString);

      Map naviState = null;

      try {
        naviState = ObjectDeserializer.deserializeMap(desMap);
      } catch (IOException iox) {
      } catch (ClassNotFoundException classNotFoundEx) {
      }

      if (naviState != null) {
        navParams.putAll(naviState);
      }
    }

    return navParams;
  }
예제 #3
0
  public BlockingInteractionResponse invokePerformBlockingInteraction(
      PerformBlockingInteraction pbo) throws WSRPException {
    String portletHandle = pbo.getPortletContext().getPortletHandle();

    BlockingInteractionResponse bir = new BlockingInteractionResponse();
    UpdateResponse updateRes = new UpdateResponse();
    bir.setUpdateResponse(updateRes);

    try {
      MarkupParams markupParams = pbo.getMarkupParams();

      // window state
      String wsrpWindowState = markupParams.getWindowState();
      WindowState windowState = WSRPUtil.fromWsrpWindowState(wsrpWindowState);

      // portlet mode
      String wsrpMode = markupParams.getMode();
      PortletMode mode = WSRPUtil.fromWsrpMode(wsrpMode);

      ServletContext ctx = WSRPUtil.getServletContext();
      long companyId = WSRPUtil.getCompanyId();

      Portlet portlet = PortletLocalServiceUtil.getPortletById(companyId, portletHandle);
      CachePortlet cachePortlet = PortletInstanceFactory.create(portlet, ctx);
      PortletConfig portletConfig = PortletConfigFactory.create(portlet, ctx);
      PortletContext portletCtx = portletConfig.getPortletContext();

      Locale reqLocale = LocaleHelper.getLocale(markupParams.getLocales()[0]);
      String reqMimeType = markupParams.getMimeTypes()[0];
      InteractionParams interactionParams = pbo.getInteractionParams();
      Map actionParameters = _getActionParameters(interactionParams);
      HttpServletRequest httpReq =
          new WSRPServletRequest(
              WSRPUtil.getHttpServletRequest(), reqLocale, reqMimeType, actionParameters);
      PortletPreferencesIds portletPreferencesIds =
          PortletPreferencesFactoryUtil.getPortletPreferencesIds(httpReq, portlet.getPortletId());
      PortletPreferences portletPreferences =
          PortletPreferencesLocalServiceUtil.getPreferences(portletPreferencesIds);

      // this gets the default layout of the general guest
      User user = UserLocalServiceUtil.getDefaultUser(companyId);
      Layout layout = _getDefaultUserLayout(user.getCompanyId());

      ActionRequestImpl actionRequest =
          ActionRequestFactory.create(
              httpReq,
              portlet,
              cachePortlet,
              portletCtx,
              windowState,
              mode,
              portletPreferences,
              layout.getPlid());
      WSRPServletResponse res = new WSRPServletResponse();

      ActionResponseImpl actionResponse =
          new WSRPActionResponseImpl(
              pbo,
              _provider,
              actionRequest,
              res,
              portlet.getPortletId(),
              user,
              layout,
              windowState,
              mode);

      cachePortlet.processAction(actionRequest, actionResponse);
      String newNavState = null;

      Map renderParams = _getRenderParameters(httpReq, actionResponse);
      newNavState = Base64.encode(ObjectSerializer.serialize(renderParams));

      updateRes.setNavigationalState(newNavState);

      ActionRequestFactory.recycle(actionRequest);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return bir;
  }