コード例 #1
0
    public void execute(Event<UIPortlet> event) throws Exception {
      UIPortlet uiPortlet = event.getSource();

      UIPortalApplication uiPortalApp = uiPortlet.getAncestorOfType(UIPortalApplication.class);
      UIWorkingWorkspace uiWorkingWS =
          uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
      PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
      pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
      pcontext.ignoreAJAXUpdateOnPortlets(true);

      String windowState = null;

      Object changeWindowStateAttribute =
          event.getRequestContext().getAttribute(CHANGE_WINDOW_STATE_EVENT);
      if (changeWindowStateAttribute != null && changeWindowStateAttribute instanceof String) {
        windowState = (String) changeWindowStateAttribute;
      }

      if (windowState == null) {
        windowState = event.getRequestContext().getRequestParameter(Constants.PORTAL_WINDOW_STATE);
      }
      if (windowState == null) {
        if (event.getRequestContext().getRequestParameter(UIComponent.OBJECTID) != null) {
          windowState = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID).trim();
        }
      }

      if (windowState == null) {
        windowState = uiPortlet.getCurrentWindowState().toString();
      }

      UIPage uiPage = uiPortlet.getAncestorOfType(UIPage.class);
      if (windowState.equals(WindowState.MAXIMIZED.toString())) {
        if (uiPage != null) {
          uiPage.normalizePortletWindowStates();
          uiPage.setMaximizedUIPortlet(uiPortlet);
        }
        uiPortlet.setCurrentWindowState(WindowState.MAXIMIZED);
        return;
      } else {
        if (windowState.equals(WindowState.MINIMIZED.toString())) {
          uiPortlet.setCurrentWindowState(WindowState.MINIMIZED);
        } else {
          uiPortlet.setCurrentWindowState(WindowState.NORMAL);
        }
        if (uiPage != null) {
          clearMaximizedUIComponent(uiPage, uiPortlet);
        }
      }
    }
コード例 #2
0
 /**
  * This method is used to set the next portlet window state if this one needs to be modified
  * because of the incoming request
  */
 public static void setNextState(UIPortlet uiPortlet, WindowState state) {
   if (state != null) {
     UIPage uiPage = uiPortlet.getAncestorOfType(UIPage.class);
     if (WindowState.MAXIMIZED.equals(state)) {
       uiPortlet.setCurrentWindowState(WindowState.MAXIMIZED);
       if (uiPage != null) {
         uiPage.setMaximizedUIPortlet(uiPortlet);
       }
     } else if (WindowState.MINIMIZED.equals(state)) {
       uiPortlet.setCurrentWindowState(WindowState.MINIMIZED);
       if (uiPage != null) {
         uiPage.setMaximizedUIPortlet(null);
       }
     } else {
       uiPortlet.setCurrentWindowState(WindowState.NORMAL);
       if (uiPage != null) {
         uiPage.setMaximizedUIPortlet(null);
       }
     }
   }
 }
コード例 #3
0
  @RequestMapping(
      value = {"VIEW"},
      params = {"action=browseMobile"})
  public ModelAndView browseMobile(
      RenderRequest request, RenderResponse response, @RequestParam String dir) {
    this.init(request);

    final PortletPreferences prefs = request.getPreferences();
    boolean forceMaximized4Mobile =
        "true".equals(prefs.getValue(PREF_FORCE_MAXIMIZED_4_MOBILE, "true"));
    String forceWindowState4Mobile =
        forceMaximized4Mobile
            ? WindowState.MAXIMIZED.toString()
            : request.getWindowState().toString();

    String decodedDir = pathEncodingUtils.decodeDir(dir);

    ModelMap model;
    if (!(dir == null || dir.length() == 0 || decodedDir.equals(JsTreeFile.ROOT_DRIVE))) {
      if (this.serverAccess.formAuthenticationRequired(decodedDir, userParameters)) {
        ListOrderedMap parentPathes = pathEncodingUtils.getParentsEncPathes(decodedDir, null, null);
        // we want to get the (last-1) key of sortedmap "parentPathes"
        String parentDir = (String) parentPathes.get(parentPathes.size() - 2);
        model = new ModelMap("currentDir", dir);
        model.put("parentDir", parentDir);
        model.put(
            "username",
            this.serverAccess.getUserPassword(decodedDir, userParameters).getUsername());
        model.put(
            "password",
            this.serverAccess.getUserPassword(decodedDir, userParameters).getPassword());
        model.put("forceWindowState4Mobile", forceWindowState4Mobile);
        return new ModelAndView("authenticationForm-portlet-mobile", model);
      }
    }
    model = browse(dir);
    model.put("forceWindowState4Mobile", forceWindowState4Mobile);
    return new ModelAndView("view-portlet-mobile", model);
  }
コード例 #4
0
  @RequestMapping(
      value = {"VIEW"},
      params = {"action=browseStandard"})
  public ModelAndView browseStandard(RenderRequest request, RenderResponse response, String dir) {
    this.init(request);
    final PortletPreferences prefs = request.getPreferences();
    boolean useDoubleClick = "true".equals(prefs.getValue(PREF_USE_DOUBLE_CLICK, "true"));
    boolean useCursorWaitDialog =
        "true".equals(prefs.getValue(PREF_USE_CURSOR_WAIT_DIALOG, "false"));

    ModelMap model = new ModelMap();
    model.put("useDoubleClick", useDoubleClick);
    model.put("useCursorWaitDialog", useCursorWaitDialog);
    if (dir == null) dir = "";
    model.put("defaultPath", dir);

    boolean fullViewOnlyMaximized =
        "true".equals(prefs.getValue(PREF_FULL_VIEW_ONLY_MAXIMIZED, "true"));
    boolean fullView =
        !fullViewOnlyMaximized || WindowState.MAXIMIZED.equals(request.getWindowState());
    model.put("fullView", fullView);

    return new ModelAndView("view-portlet", model);
  }
コード例 #5
0
    public void execute(Event<UIPortlet> event) throws Exception {
      UIPortlet uiPortlet = event.getSource();

      UIPortalApplication uiPortalApp = uiPortlet.getAncestorOfType(UIPortalApplication.class);
      UIWorkingWorkspace uiWorkingWS =
          uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
      PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
      pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
      pcontext.ignoreAJAXUpdateOnPortlets(true);

      String windowState = null;

      Object changeWindowStateAttribute =
          event.getRequestContext().getAttribute(CHANGE_WINDOW_STATE_EVENT);
      if (changeWindowStateAttribute != null && changeWindowStateAttribute instanceof String) {
        windowState = (String) changeWindowStateAttribute;
      }

      if (windowState == null) {
        windowState = event.getRequestContext().getRequestParameter(Constants.PORTAL_WINDOW_STATE);
      }
      if (windowState == null) {
        windowState = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID).trim();
      }

      if (windowState == null) {
        windowState = uiPortlet.getCurrentWindowState().toString();
      }

      UIPageBody uiPageBody = uiPortlet.getAncestorOfType(UIPageBody.class);
      UIPage uiPage = uiPortlet.getAncestorOfType(UIPage.class);
      if (windowState.equals(WindowState.MAXIMIZED.toString())) {
        if (uiPageBody != null) {
          uiPortlet.setCurrentWindowState(WindowState.MAXIMIZED);
          // TODO dang.tung: we have to set maximized portlet for page because in ShowMaxWindow case
          // the PageBody isn't rendered
          //                reference: UIPortalLifecycle, UIPageLifecycle, renderChildren() in
          // UIPageBody
          // ---------------------------------------------------------
          if (uiPage != null && uiPage.isShowMaxWindow()) {
            uiPage.setMaximizedUIPortlet(uiPortlet);
          }
          // ---------------------------------------------------------
          uiPageBody.setMaximizedUIComponent(uiPortlet);
        } else {
          uiPortlet.setCurrentWindowState(WindowState.NORMAL);
        }
        return;
      }
      if (uiPageBody != null) {
        UIPortlet maxPortlet = (UIPortlet) uiPageBody.getMaximizedUIComponent();
        if (maxPortlet == uiPortlet) {
          uiPageBody.setMaximizedUIComponent(null);
        }
      }
      // TODO dang.tung: for ShowMaxWindow situation
      // ----------------------------------------------------------------
      if (uiPage != null) {
        UIPortlet maxPortlet = (UIPortlet) uiPage.getMaximizedUIPortlet();
        if (maxPortlet == uiPortlet) {
          uiPage.setMaximizedUIPortlet(null);
        }
      }
      // -----------------------------------------------------------------
      if (windowState.equals(WindowState.MINIMIZED.toString())) {
        uiPortlet.setCurrentWindowState(WindowState.MINIMIZED);
        return;
      }
      uiPortlet.setCurrentWindowState(WindowState.NORMAL);
    }
コード例 #6
0
  @EventMapping(SearchConstants.SEARCH_REQUEST_QNAME_STRING)
  public void handleSearchEvents(EventRequest request, EventResponse response) {

    log.debug("Responding to Search Event");

    final Event event = request.getEvent();
    final SearchRequest searchQuery = (SearchRequest) event.getValue();

    final String searchTerms = searchQuery.getSearchTerms();

    final SearchResults searchResults = new SearchResults();

    searchResults.setQueryId(searchQuery.getQueryId());
    searchResults.setWindowId(request.getWindowID());

    for (ContactDomain domain : contactDomains) {

      if (domain.getHasSearch()) {

        ContactSet contacts = domain.search(searchTerms);

        for (Contact contact : contacts) {

          // Build the result object for the match
          final SearchResult searchResult = new SearchResult();
          String title =
              contact.getSurname().toUpperCase()
                  + ", "
                  + contact.getTitle()
                  + " "
                  + contact.getFirstname();
          if (contact.getPosition() != null && !contact.getPosition().equals(""))
            title += " (" + contact.getPosition() + ")";

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

          if (contact.getPrimaryEmailAddress() != null)
            summary.add("E:" + contact.getPrimaryEmailAddress().getEmailAddress());
          if (contact.getPrimaryPhoneNumber() != null)
            summary.add("T:" + contact.getPrimaryPhoneNumber().getPhoneNumber());

          String summaryText = StringUtils.collectionToDelimitedString(summary, " -- ");

          searchResult.setTitle(title);
          searchResult.setSummary(summaryText);

          /*
           * Portlet URL to be added when / if portlet support for
           * deep linking added.
           */
          PortletUrl url = new PortletUrl();
          url.setPortletMode("VIEW");
          url.setWindowState(WindowState.MAXIMIZED.toString());
          PortletUrlParameter domainParam = new PortletUrlParameter();
          domainParam.setName("domain");
          domainParam.getValue().add(domain.getId());
          url.getParam().add(domainParam);
          PortletUrlParameter urnParam = new PortletUrlParameter();
          urnParam.setName("urn");
          urnParam.getValue().add(contact.getURN());
          url.getParam().add(urnParam);

          searchResult.setPortletUrl(url);

          searchResult.getType().add("contact");
          // Add the result to the results and send the event
          searchResults.getSearchResult().add(searchResult);
        }
      }
    }

    response.setEvent(SearchConstants.SEARCH_RESULTS_QNAME, searchResults);

    log.debug(
        "Finished response -- " + searchResults.getSearchResult().size() + " -- results returned");
  }
コード例 #7
0
  public void processAction(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig config,
      ActionRequest req,
      ActionResponse res)
      throws Exception {

    String cmd = req.getParameter(Constants.CMD);
    String referer = req.getParameter("referer");

    if ((referer != null) && (referer.length() != 0)) {
      referer = URLDecoder.decode(referer, "UTF-8");
    }

    // Load the structure in the request
    try {
      Logger.debug(this, "Calling Retrieve method");
      _loadStructure(form, req, res);
    } catch (Exception ae) {
      _handleException(ae, req);
      return;
    }

    HibernateUtil.startTransaction();
    boolean returnToList = false;
    /*
     * If we are updating the workflow message, copy the information from
     * the struts bean to the hbm inode and run the update action and return
     * to the list
     */
    if ((cmd != null) && cmd.equals(Constants.ADD)) {
      try {
        Logger.debug(this, "Calling Add/Edit Method");
        if (Validator.validate(req, form, mapping)) {

          if (UtilMethods.isSet(((StructureForm) form).getInode())) {
            returnToList = true;
          }

          _saveStructure(form, req, res);
        }

      } catch (Exception ae) {
        _handleException(ae, req);
        return;
      }

    }
    /*
     * If we are deleteing the structure, run the delete action and return
     * to the list
     *
     */
    else if ((cmd != null) && cmd.equals(Constants.DELETE)) {
      try {
        Logger.debug(this, "Calling Delete Method");
        _deleteStructure(form, req, res);
      } catch (Exception ae) {
        _handleException(ae, req);
        return;
      }
      _sendToReferral(req, res, referer);
      return;
    } else if ((cmd != null) && cmd.equals(WebKeys.Structure.SET_DEFAULT)) {
      try {
        _defaultStructure(form, req, res);
      } catch (Exception ae) {
        _handleException(ae, req);
        return;
      }
      _sendToReferral(req, res, referer);
      return;
    } else if ((cmd != null) && cmd.equals(com.dotmarketing.util.Constants.RESET)) {
      try {
        _resetIntervals(form, req, res);
      } catch (Exception ae) {
        _handleException(ae, req);
        return;
      }
      _sendToReferral(req, res, referer);
      return;
    }

    HibernateUtil.commitTransaction();
    _loadForm(form, req, res);
    if (returnToList) {
      if (!UtilMethods.isSet(referer)) {
        java.util.Map<String, String[]> params = new java.util.HashMap<String, String[]>();

        if (((StructureForm) form).getStructureType() == Structure.STRUCTURE_TYPE_FORM) {
          params.put("struts_action", new String[] {"/ext/formhandler/view_form"});
        } else {
          params.put("struts_action", new String[] {"/ext/structure/view_structure"});
        }

        referer =
            com.dotmarketing.util.PortletURLUtil.getActionURL(
                req, WindowState.MAXIMIZED.toString(), params);
      }
      _sendToReferral(req, res, referer);
    } else {
      setForward(req, "portlet.ext.structure.edit_structure");
    }
  }
コード例 #8
0
  @Override
  public String getActualURL(
      long companyId,
      long groupId,
      boolean privateLayout,
      String mainPath,
      String friendlyURL,
      Map<String, String[]> params,
      Map<String, Object> requestContext)
      throws PortalException {

    String urlTitle =
        friendlyURL.substring(JournalArticleConstants.CANONICAL_URL_SEPARATOR.length());

    JournalArticle journalArticle =
        _journalArticleLocalService.getArticleByUrlTitle(groupId, urlTitle);

    Layout layout = getJournalArticleLayout(groupId, privateLayout, friendlyURL);

    String layoutActualURL = PortalUtil.getLayoutActualURL(layout, mainPath);

    InheritableMap<String, String[]> actualParams = new InheritableMap<>();

    if (params != null) {
      actualParams.setParentMap(params);
    }

    UnicodeProperties typeSettingsProperties = layout.getTypeSettingsProperties();

    String defaultAssetPublisherPortletId =
        typeSettingsProperties.get(LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID);

    String currentDefaultAssetPublisherPortletId = defaultAssetPublisherPortletId;

    if (Validator.isNull(defaultAssetPublisherPortletId)) {
      PortletInstance portletInstance =
          new PortletInstance(AssetPublisherPortletKeys.ASSET_PUBLISHER);

      defaultAssetPublisherPortletId = portletInstance.getPortletInstanceKey();
    }

    HttpServletRequest request = (HttpServletRequest) requestContext.get("request");

    if (Validator.isNull(currentDefaultAssetPublisherPortletId)) {
      String actualPortletAuthenticationToken =
          AuthTokenUtil.getToken(request, layout.getPlid(), defaultAssetPublisherPortletId);

      actualParams.put("p_p_auth", new String[] {actualPortletAuthenticationToken});
    }

    actualParams.put("p_p_id", new String[] {defaultAssetPublisherPortletId});
    actualParams.put("p_p_lifecycle", new String[] {"0"});

    if (Validator.isNull(currentDefaultAssetPublisherPortletId)) {
      actualParams.put("p_p_state", new String[] {WindowState.MAXIMIZED.toString()});
    }

    actualParams.put("p_p_mode", new String[] {"view"});
    actualParams.put("p_j_a_id", new String[] {String.valueOf(journalArticle.getId())});

    String namespace = PortalUtil.getPortletNamespace(defaultAssetPublisherPortletId);

    actualParams.put(namespace + "mvcPath", new String[] {"/view_content.jsp"});

    AssetRendererFactory<?> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
            JournalArticle.class.getName());

    actualParams.put(namespace + "type", new String[] {assetRendererFactory.getType()});

    actualParams.put(namespace + "urlTitle", new String[] {journalArticle.getUrlTitle()});

    String queryString = HttpUtil.parameterMapToString(actualParams, false);

    if (layoutActualURL.contains(StringPool.QUESTION)) {
      layoutActualURL = layoutActualURL + StringPool.AMPERSAND + queryString;
    } else {
      layoutActualURL = layoutActualURL + StringPool.QUESTION + queryString;
    }

    Locale locale = PortalUtil.getLocale(request);

    PortalUtil.addPageSubtitle(journalArticle.getTitle(locale), request);
    PortalUtil.addPageDescription(journalArticle.getDescription(locale), request);

    List<AssetTag> assetTags =
        _assetTagLocalService.getTags(
            JournalArticle.class.getName(), journalArticle.getPrimaryKey());

    if (!assetTags.isEmpty()) {
      PortalUtil.addPageKeywords(ListUtil.toString(assetTags, AssetTag.NAME_ACCESSOR), request);
    }

    return layoutActualURL;
  }