예제 #1
0
  @Override
  public void init(PortletConfig config) throws PortletException {
    CurrentInstance.clearAll();
    super.init(config);
    Properties initParameters = new Properties();

    // Read default parameters from the context
    final PortletContext context = config.getPortletContext();
    for (final Enumeration<String> e = context.getInitParameterNames(); e.hasMoreElements(); ) {
      final String name = e.nextElement();
      initParameters.setProperty(name, context.getInitParameter(name));
    }

    // Override with application settings from portlet.xml
    for (final Enumeration<String> e = config.getInitParameterNames(); e.hasMoreElements(); ) {
      final String name = e.nextElement();
      initParameters.setProperty(name, config.getInitParameter(name));
    }

    DeploymentConfiguration deploymentConfiguration = createDeploymentConfiguration(initParameters);
    try {
      vaadinService = createPortletService(deploymentConfiguration);
    } catch (ServiceException e) {
      throw new PortletException("Could not initialized VaadinPortlet", e);
    }
    // Sets current service even though there are no request and response
    vaadinService.setCurrentInstances(null, null);

    portletInitialized();

    CurrentInstance.clearAll();
  }
예제 #2
0
  @Override
  public void render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException, IOException {

    try {
      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);
      }

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

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

        PortletConfig portletConfig = getPortletConfig();

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

    super.render(renderRequest, renderResponse);
  }
예제 #3
0
  protected void updatePreferences(ActionRequest actionRequest, ActionResponse actionResponse)
      throws IOException, PortletException {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    if (!cmd.equals(Constants.UPDATE)) {
      return;
    }

    PortletPreferences preferences = actionRequest.getPreferences();

    String[] symbols =
        StringUtil.split(
            ParamUtil.getString(actionRequest, "symbols").toUpperCase(), StringPool.SPACE);

    Arrays.sort(symbols);

    preferences.setValues("symbols", symbols);

    try {
      preferences.store();
    } catch (ValidatorException ve) {
      SessionErrors.add(actionRequest, ValidatorException.class.getName(), ve);

      return;
    }

    PortletConfig portletConfig = getPortletConfig();

    SessionMessages.add(
        actionRequest,
        portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_UPDATED_PREFERENCES);
  }
  public BridgePhaseBaseImpl(PortletConfig portletConfig, BridgeConfig bridgeConfig) {

    this.portletConfig = portletConfig;
    this.bridgeConfig = bridgeConfig;
    this.portletName = portletConfig.getPortletName();
    this.bridgeRequestScopePreserved =
        PortletConfigParam.BridgeRequestScopePreserved.getBooleanValue(portletConfig);

    this.portletContext =
        BridgePortletContextFactory.getPortletContextInstance(portletConfig.getPortletContext());

    // Initialize the incongruity context implementation.
    this.incongruityContext = IncongruityContextFactory.getIncongruityContextInstance();

    // Get the bridge request scope cache from the factory.
    this.bridgeRequestScopeCache =
        BridgeRequestScopeCacheFactory.getBridgeRequestScopeCacheInstance(portletContext);

    // Get the default lifecycle instance from the factory.
    LifecycleFactory lifecycleFactory =
        (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    String lifecycleId = this.portletContext.getInitParameter(Bridge.LIFECYCLE_ID);

    if (lifecycleId == null) {
      lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
    }

    this.facesLifecycle = lifecycleFactory.getLifecycle(lifecycleId);
  }
  public void removeBridgeRequestScopesByPortlet(PortletConfig portletConfig) {
    String portletNameToRemove = portletConfig.getPortletName();
    PortletContext portletContext = portletConfig.getPortletContext();
    BridgeRequestScopeCache bridgeRequestScopeCache =
        BridgeRequestScopeCacheFactory.getBridgeRequestScopeCacheInstance(portletContext);
    Set<Map.Entry<String, BridgeRequestScope>> mapEntries = bridgeRequestScopeCache.entrySet();

    if (mapEntries != null) {

      List<String> keysToRemove = new ArrayList<String>();

      for (Map.Entry<String, BridgeRequestScope> mapEntry : mapEntries) {
        BridgeRequestScope bridgeRequestScope = mapEntry.getValue();
        String bridgeRequestScopeId = bridgeRequestScope.getId();
        String portletName = bridgeRequestScopeId.split("[:][:][:]")[0];

        if (portletNameToRemove.equals(portletName)) {
          keysToRemove.add(mapEntry.getKey());
        }
      }

      for (String key : keysToRemove) {
        bridgeRequestScopeCache.remove(key);
      }
    }
  }
  protected String getSaveAndContinueRedirect(
      ActionRequest actionRequest, BlogsEntry entry, String redirect) throws Exception {

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

    PortletConfig portletConfig =
        (PortletConfig) actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

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

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/blogs/edit_entry");

    portletURL.setParameter(Constants.CMD, Constants.UPDATE, false);
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("backURL", backURL, false);
    portletURL.setParameter("groupId", String.valueOf(entry.getGroupId()), false);
    portletURL.setParameter("entryId", String.valueOf(entry.getEntryId()), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
예제 #7
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());
  }
예제 #8
0
  public String getPortletName() {
    PortletConfig portletConfig =
        (PortletConfig) _request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    if (portletConfig == null) {
      return StringPool.BLANK;
    }

    return portletConfig.getPortletName();
  }
  /**
   * Register web-specific environment beans ("contextParameters", "contextAttributes") with the
   * given BeanFactory, as used by the Portlet ApplicationContext.
   *
   * @param bf the BeanFactory to configure
   * @param sc the ServletContext that we're running within
   * @param pc the PortletContext that we're running within
   * @param config the PortletConfig of the containing Portlet
   */
  static void registerEnvironmentBeans(
      ConfigurableListableBeanFactory bf,
      ServletContext sc,
      PortletContext pc,
      PortletConfig config) {

    if (sc != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
      bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, sc);
    }

    if (pc != null
        && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME)) {
      bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME, pc);
    }

    if (config != null
        && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME)) {
      bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME, config);
    }

    if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) {
      Map<String, String> parameterMap = new HashMap<String, String>();
      if (pc != null) {
        Enumeration paramNameEnum = pc.getInitParameterNames();
        while (paramNameEnum.hasMoreElements()) {
          String paramName = (String) paramNameEnum.nextElement();
          parameterMap.put(paramName, pc.getInitParameter(paramName));
        }
      }
      if (config != null) {
        Enumeration paramNameEnum = config.getInitParameterNames();
        while (paramNameEnum.hasMoreElements()) {
          String paramName = (String) paramNameEnum.nextElement();
          parameterMap.put(paramName, config.getInitParameter(paramName));
        }
      }
      bf.registerSingleton(
          WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME,
          Collections.unmodifiableMap(parameterMap));
    }

    if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) {
      Map<String, Object> attributeMap = new HashMap<String, Object>();
      if (pc != null) {
        Enumeration attrNameEnum = pc.getAttributeNames();
        while (attrNameEnum.hasMoreElements()) {
          String attrName = (String) attrNameEnum.nextElement();
          attributeMap.put(attrName, pc.getAttribute(attrName));
        }
      }
      bf.registerSingleton(
          WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME,
          Collections.unmodifiableMap(attributeMap));
    }
  }
  public void init(PortletConfig config) throws PortletException {

    long clock = System.currentTimeMillis();
    try {
      log.debug("Initializing InfoPortlet");
      super.init(config);

      normalView = config.getPortletContext().getRequestDispatcher(NORMAL_VIEW);
      maximizedView = config.getPortletContext().getRequestDispatcher(MAXIMIZED_VIEW);
    } finally {
      long duration = System.currentTimeMillis() - clock;
      log.debug(String.format("Initialization took %s ms.", duration));
    }
  }
  public void processAction(
      PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    if (!cmd.equals(Constants.UPDATE)) {
      return;
    }

    boolean allAssetVocabularies = ParamUtil.getBoolean(actionRequest, "allAssetVocabularies");
    long[] assetVocabularyIds =
        StringUtil.split(ParamUtil.getString(actionRequest, "assetVocabularyIds"), 0L);

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

    PortletPreferences preferences =
        PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);

    preferences.setValue("all-asset-vocabularies", String.valueOf(allAssetVocabularies));
    preferences.setValues("asset-vocabulary-ids", ArrayUtil.toStringArray(assetVocabularyIds));

    preferences.store();

    SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doConfigure");
  }
예제 #12
0
  public void processAction(PortletConfig config, ActionRequest req, ActionResponse res)
      throws Exception {

    try {
      String cmd = ParamUtil.getString(req, Constants.CMD);

      if (!cmd.equals(Constants.UPDATE)) {
        return;
      }

      String content = ParamUtil.getString(req, "content");

      if (Validator.isNull(content)) {
        throw new AnnouncementsContentException();
      }

      String portletResource = ParamUtil.getString(req, "portletResource");

      String languageId = LanguageUtil.getLanguageId(req);

      PortletPreferences prefs =
          PortletPreferencesFactoryUtil.getPortletSetup(req, portletResource, false, false);

      LocalizationUtil.setPrefsValue(prefs, "content", languageId, content);

      prefs.store();

      SessionMessages.add(req, config.getPortletName() + ".doConfigure");
    } catch (AnnouncementsContentException ace) {
      SessionErrors.add(req, ace.getClass().getName());
    }
  }
  protected void runScript(
      PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    String language = ParamUtil.getString(actionRequest, "language");
    String script = ParamUtil.getString(actionRequest, "script");

    PortletContext portletContext = portletConfig.getPortletContext();

    Map<String, Object> portletObjects =
        ScriptingUtil.getPortletObjects(
            portletConfig, portletContext, actionRequest, actionResponse);

    UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream();

    UnsyncPrintWriter unsyncPrintWriter = UnsyncPrintWriterPool.borrow(unsyncByteArrayOutputStream);

    portletObjects.put("out", unsyncPrintWriter);

    try {
      SessionMessages.add(actionRequest, "language", language);
      SessionMessages.add(actionRequest, "script", script);

      ScriptingUtil.exec(null, portletObjects, language, script);

      unsyncPrintWriter.flush();

      SessionMessages.add(actionRequest, "scriptOutput", unsyncByteArrayOutputStream.toString());
    } catch (ScriptingException se) {
      SessionErrors.add(actionRequest, ScriptingException.class.getName(), se);

      _log.error(se.getMessage());
    }
  }
  @Override
  public void processAction(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse)
      throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    if (!cmd.equals(Constants.UPDATE)) {
      return;
    }

    PortletPreferences preferences = actionRequest.getPreferences();

    String[] symbols =
        StringUtil.split(ParamUtil.getString(actionRequest, "symbols").toUpperCase());

    preferences.setValues("symbols", symbols);

    try {
      preferences.store();
    } catch (ValidatorException ve) {
      SessionErrors.add(actionRequest, ValidatorException.class.getName(), ve);

      return;
    }

    SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doEdit");
  }
  protected String getSaveAndContinueRedirect(
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      FileEntry fileEntry,
      String redirect)
      throws Exception {

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

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcRenderCommandName", "/document_library/edit_file_entry");
    portletURL.setParameter(Constants.CMD, Constants.UPDATE, false);
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("groupId", String.valueOf(fileEntry.getGroupId()), false);
    portletURL.setParameter("fileEntryId", String.valueOf(fileEntry.getFileEntryId()), false);
    portletURL.setParameter("version", String.valueOf(fileEntry.getVersion()), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
  protected String getSaveAndContinueRedirect(
      PortletConfig portletConfig, ActionRequest actionRequest, DDMStructure structure)
      throws Exception {

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

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setParameter("struts_action", "/dynamic_data_mapping/copy_structure");

    long classNameId = PortalUtil.getClassNameId(DDMStructure.class);

    portletURL.setParameter("classNameId", String.valueOf(classNameId), false);

    portletURL.setParameter("classPK", String.valueOf(structure.getStructureId()), false);
    portletURL.setParameter(
        "copyFormTemplates", ParamUtil.getString(actionRequest, "copyFormTemplates"), false);
    portletURL.setParameter(
        "copyDisplayTemplates", ParamUtil.getString(actionRequest, "copyDisplayTemplates"), false);
    portletURL.setWindowState(actionRequest.getWindowState());

    return portletURL.toString();
  }
예제 #17
0
  public void processAction(PortletConfig config, ActionRequest req, ActionResponse res)
      throws Exception {

    String cmd = ParamUtil.getString(req, Constants.CMD);

    String portletResource = ParamUtil.getString(req, "portletResource");

    PortletPreferences prefs =
        PortletPreferencesFactoryUtil.getPortletSetup(req, portletResource, true, true);

    if (cmd.equals("remove-footer-article")) {
      removeFooterArticle(req, prefs);
    } else if (cmd.equals("remove-header-article")) {
      removeHeaderArticle(req, prefs);
    } else if (cmd.equals("set-footer-article")) {
      setFooterArticle(req, prefs);
    } else if (cmd.equals("set-header-article")) {
      setHeaderArticle(req, prefs);
    } else if (cmd.equals(Constants.UPDATE)) {
      updateConfiguration(req, prefs);
    }

    if (SessionErrors.isEmpty(req)) {
      try {
        prefs.store();
      } catch (ValidatorException ve) {
        SessionErrors.add(req, ValidatorException.class.getName(), ve);

        return;
      }

      SessionMessages.add(req, config.getPortletName() + ".doConfigure");
    }
  }
  protected String[] getAllowedFileExtensions(
      PortletConfig portletConfig, PortletRequest portletRequest, PortletResponse portletResponse)
      throws PortalException {

    String portletName = portletConfig.getPortletName();

    if (!portletName.equals(DLPortletKeys.MEDIA_GALLERY_DISPLAY)) {
      return PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA);
    } else {
      ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      DLPortletInstanceSettings dlPortletInstanceSettings =
          DLPortletInstanceSettings.getInstance(themeDisplay.getLayout(), portletDisplay.getId());

      Set<String> extensions = new HashSet<>();

      String[] mimeTypes = dlPortletInstanceSettings.getMimeTypes();

      for (String mimeType : mimeTypes) {
        extensions.addAll(MimeTypesUtil.getExtensions(mimeType));
      }

      return extensions.toArray(new String[extensions.size()]);
    }
  }
예제 #19
0
  public void serveResource(
      ActionMapping actionMapping,
      ActionForm actionForm,
      PortletConfig portletConfig,
      ResourceRequest resourceRequest,
      ResourceResponse resourceResponse)
      throws Exception {

    String resourceID = resourceRequest.getResourceID();

    if (Validator.isNull(resourceID)) {
      return;
    }

    PortletContext portletContext = portletConfig.getPortletContext();

    PortletRequestDispatcher portletRequestDispatcher =
        portletContext.getRequestDispatcher(resourceID);

    if (portletRequestDispatcher == null) {
      return;
    }

    portletRequestDispatcher.forward(resourceRequest, resourceResponse);
  }
  public void processAction(
      PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    if (!cmd.equals(Constants.UPDATE)) {
      return;
    }

    String selectionMethod = ParamUtil.getString(actionRequest, "selectionMethod");
    String organizationId = ParamUtil.getString(actionRequest, "organizationId");
    String displayStyle = ParamUtil.getString(actionRequest, "displayStyle");
    int max = ParamUtil.getInteger(actionRequest, "max");

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

    PortletPreferences preferences =
        PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);

    preferences.setValue("selection-method", selectionMethod);
    preferences.setValue("organization-id", organizationId);
    preferences.setValue("display-style", displayStyle);
    preferences.setValue("max", String.valueOf(max));

    preferences.store();

    SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doConfigure");
  }
예제 #21
0
  protected void addSuccessMessage(ActionRequest actionRequest, ActionResponse actionResponse) {

    PortletConfig portletConfig =
        (PortletConfig) actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    boolean addProcessActionSuccessMessage =
        GetterUtil.getBoolean(
            portletConfig.getInitParameter("add-process-action-success-action"), true);

    if (!addProcessActionSuccessMessage) {
      return;
    }

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

    SessionMessages.add(actionRequest, "requestProcessed", successMessage);
  }
  public void init(PortletConfig config) throws PortletException {
    super.init(config);

    pContext = config.getPortletContext();
    try {
      vengine = vHelper.makeEngine(pContext);
    } catch (Exception e) {
      throw new PortletException("Cannot initialize Velocity ", e);
    }
    M_log.info("iFrame Portlet vengine=" + vengine + " rb=" + rb);
  }
예제 #23
0
  protected void initPortletApp(Portlet portlet, ServletContext servletContext)
      throws PortletException {

    PortletApp portletApp = portlet.getPortletApp();

    PortletConfig portletConfig = PortletConfigFactoryUtil.create(portlet, servletContext);

    PortletContext portletContext = portletConfig.getPortletContext();

    Set<PortletFilter> portletFilters = portletApp.getPortletFilters();

    for (PortletFilter portletFilter : portletFilters) {
      PortletFilterFactory.create(portletFilter, portletContext);
    }

    Set<PortletURLListener> portletURLListeners = portletApp.getPortletURLListeners();

    for (PortletURLListener portletURLListener : portletURLListeners) {
      PortletURLListenerFactory.create(portletURLListener);
    }
  }
예제 #24
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");
  }
예제 #25
0
  private void getPortletInfo(ActionRequest actionRequest) {
    log.info("getPortletInfo");
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PortletConfig portletConfig =
        (PortletConfig) actionRequest.getAttribute("javax.portlet.config");
    _portletName = portletConfig.getPortletName();
    PortletURL pURL =
        PortletURLFactoryUtil.create(
            actionRequest,
            _portletName + "_WAR_" + _portletName + "portlet",
            themeDisplay.getPlid(),
            PortletRequest.ACTION_PHASE);
    /*try {
    	pURL.setWindowState(WindowState.NORMAL );
    } catch (WindowStateException e1) {
    	// TODO Auto-generated catch block
    	e1.printStackTrace();
    }*/
    pURL.setParameter(ActionRequest.ACTION_NAME, ProxyConstant.ACTION_LINK);
    _portletURL = pURL.toString();

    // read portlet config;
    PortletPreferences preferences = actionRequest.getPreferences();
    String portletResource = ParamUtil.getString(actionRequest, "portletResource");

    if (Validator.isNotNull(portletResource)) {
      try {
        preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, 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", "");
  } /*
  public BridgeRequestScopeImpl(
      PortletConfig portletConfig,
      PortletContext portletContext,
      PortletRequest portletRequest,
      String idPrefix) {

    this.attributeMap = new HashMap<String, Object>();

    long timeInMillis = Calendar.getInstance().getTimeInMillis();
    this.idPrefix = idPrefix;
    this.idSuffix = Long.toString(timeInMillis);

    BridgeConfigFactory bridgeConfigFactory =
        (BridgeConfigFactory) BridgeFactoryFinder.getFactory(BridgeConfigFactory.class);
    BridgeConfig bridgeConfig = bridgeConfigFactory.getBridgeConfig();
    this.excludedAttributeNames = new ArrayList<String>();

    // Get the list of excluded BridgeRequestScope attributes from the faces-config.xml descriptors.
    Set<String> facesConfigExcludedAttributeNames = bridgeConfig.getExcludedRequestAttributes();

    // Get the list of excluded BridgeRequestScope attributes from the WEB-INF/portlet.xml
    // descriptor.
    @SuppressWarnings("unchecked")
    List<String> portletContextExcludedAttributeNames =
        (List<String>)
            portletContext.getAttribute(
                Bridge.BRIDGE_PACKAGE_PREFIX
                    + portletConfig.getPortletName()
                    + BridgeConstants.CHAR_PERIOD
                    + Bridge.EXCLUDED_REQUEST_ATTRIBUTES);

    // Combine the two lists into a single list of excluded BridgeRequestScope attributes.
    if (facesConfigExcludedAttributeNames != null) {
      this.excludedAttributeNames.addAll(facesConfigExcludedAttributeNames);
    }

    if (portletContextExcludedAttributeNames != null) {
      this.excludedAttributeNames.addAll(portletContextExcludedAttributeNames);
    }

    this.preExistingAttributeNames = getPreExistingRequestAttributeNames(portletRequest);

    Bridge.PortletPhase portletPhase =
        (Bridge.PortletPhase) portletRequest.getAttribute(Bridge.PORTLET_LIFECYCLE_PHASE);

    if ((portletPhase == Bridge.PortletPhase.ACTION_PHASE)
        || (portletPhase == Bridge.PortletPhase.EVENT_PHASE)) {
      beganInActionOrEventRequest = true;
    }
  }
예제 #27
0
  @Override
  public String get(HttpServletRequest request, String key, String defaultValue) {

    if ((request == null) || (key == null)) {
      return defaultValue;
    }

    PortletConfig portletConfig =
        (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    Locale locale = _getLocale(request);

    if (portletConfig == null) {
      return get(locale, key, defaultValue);
    }

    ResourceBundle resourceBundle = portletConfig.getResourceBundle(locale);

    if (resourceBundle.containsKey(key)) {
      return _get(resourceBundle, key);
    }

    return get(locale, key, defaultValue);
  }
예제 #28
0
  protected String getSaveAndContinueRedirect(
      PortletConfig portletConfig, ActionRequest actionRequest, BlogsEntry entry, String redirect)
      throws Exception {

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

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

    boolean preview = ParamUtil.getBoolean(actionRequest, "preview");

    PortletURLImpl portletURL =
        new PortletURLImpl(
            actionRequest,
            portletConfig.getPortletName(),
            themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    portletURL.setWindowState(actionRequest.getWindowState());

    String portletName = portletConfig.getPortletName();

    if (portletName.equals(PortletKeys.BLOGS_ADMIN)) {
      portletURL.setParameter("struts_action", "/blogs_admin/edit_entry");
    } else {
      portletURL.setParameter("struts_action", "/blogs/edit_entry");
    }

    portletURL.setParameter(Constants.CMD, Constants.UPDATE, false);
    portletURL.setParameter("redirect", redirect, false);
    portletURL.setParameter("backURL", backURL, false);
    portletURL.setParameter("groupId", String.valueOf(entry.getGroupId()), false);
    portletURL.setParameter("entryId", String.valueOf(entry.getEntryId()), false);
    portletURL.setParameter("preview", String.valueOf(preview), false);

    return portletURL.toString();
  }
    @Override
    public ResourceBundle getResourceBundle(Locale locale) {
      try {
        PortletRequest portletRequest = _portletRequestThreadLocal.get();

        long companyId = PortalUtil.getCompanyId(portletRequest);

        String portletResource = ParamUtil.getString(portletRequest, "portletResource");

        Portlet portlet = _portletLocalService.getPortletById(companyId, portletResource);

        HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest);

        PortletConfig portletConfig =
            PortletConfigFactoryUtil.create(portlet, httpServletRequest.getServletContext());

        return new AggregateResourceBundle(
            super.getResourceBundle(locale), portletConfig.getResourceBundle(locale));
      } catch (Exception e) {
        _log.error(e, e);
      }

      return super.getResourceBundle(locale);
    }
  public void processAction(
      PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {
      String portletResource = ParamUtil.getString(actionRequest, "portletResource");

      PortletPreferences preferences =
          PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);

      if (cmd.equals("add-selection")) {
        AssetPublisherUtil.addSelection(actionRequest, preferences);
      } else if (cmd.equals("move-selection-down")) {
        moveSelectionDown(actionRequest, preferences);
      } else if (cmd.equals("move-selection-up")) {
        moveSelectionUp(actionRequest, preferences);
      } else if (cmd.equals("remove-selection")) {
        removeSelection(actionRequest, preferences);
      } else if (cmd.equals("selection-style")) {
        setSelectionStyle(actionRequest, preferences);
      } else if (cmd.equals(Constants.UPDATE)) {
        String selectionStyle = preferences.getValue("selection-style", "dynamic");

        if (selectionStyle.equals("dynamic")) {
          updateDynamicSettings(actionRequest, preferences);
        } else if (selectionStyle.equals("manual")) {
          updateManualSettings(actionRequest, preferences);
        }
      }

      if (SessionErrors.isEmpty(actionRequest)) {
        preferences.store();

        SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doConfigure");
      }

      actionResponse.sendRedirect(ParamUtil.getString(actionRequest, "redirect"));
    } catch (Exception e) {
      if (e instanceof AssetTagException) {
        SessionErrors.add(actionRequest, e.getClass().getName(), e);
      } else {
        throw e;
      }
    }
  }