コード例 #1
0
  @Override
  public String getRestoreLink(PortletRequest portletRequest, long classPK)
      throws PortalException, SystemException {

    String portletId = PortletKeys.WIKI;

    WikiPage page = WikiPageLocalServiceUtil.getPage(classPK);

    long plid = PortalUtil.getPlidFromPortletId(page.getGroupId(), PortletKeys.WIKI);

    if (plid == LayoutConstants.DEFAULT_PLID) {
      plid = PortalUtil.getControlPanelPlid(portletRequest);

      portletId = PortletKeys.WIKI_ADMIN;
    }

    PortletURL portletURL =
        PortletURLFactoryUtil.create(portletRequest, portletId, plid, PortletRequest.RENDER_PHASE);

    WikiNode node = page.getNode();

    portletURL.setParameter("struts_action", "/wiki/view");
    portletURL.setParameter("nodeName", node.getName());
    portletURL.setParameter("title", HtmlUtil.unescape(page.getTitle()));

    return portletURL.toString();
  }
コード例 #2
0
  private static User _getUser(HttpServletRequest request) throws Exception {
    HttpSession session = request.getSession();

    if (PortalSessionThreadLocal.getHttpSession() == null) {
      PortalSessionThreadLocal.setHttpSession(session);
    }

    User user = PortalUtil.getUser(request);

    if (user != null) {
      return user;
    }

    String userIdString = (String) session.getAttribute("j_username");
    String password = (String) session.getAttribute("j_password");

    if ((userIdString != null) && (password != null)) {
      long userId = GetterUtil.getLong(userIdString);

      user = UserLocalServiceUtil.getUser(userId);
    } else {
      long companyId = PortalUtil.getCompanyId(request);

      Company company = CompanyLocalServiceUtil.getCompany(companyId);

      user = company.getDefaultUser();
    }

    return user;
  }
コード例 #3
0
  protected PortletURL getRestoreURL(
      PortletRequest portletRequest, long classPK, boolean isContainerModel)
      throws PortalException, SystemException {

    String portletId = PortletKeys.MESSAGE_BOARDS;

    MBThread thread = MBThreadLocalServiceUtil.getThread(classPK);

    long plid = PortalUtil.getPlidFromPortletId(thread.getGroupId(), PortletKeys.MESSAGE_BOARDS);

    if (plid == LayoutConstants.DEFAULT_PLID) {
      portletId = PortletKeys.MESSAGE_BOARDS_ADMIN;

      plid = PortalUtil.getControlPanelPlid(portletRequest);
    }

    PortletURL portletURL =
        PortletURLFactoryUtil.create(portletRequest, portletId, plid, PortletRequest.RENDER_PHASE);

    if (isContainerModel) {
      if (portletId.equals(PortletKeys.MESSAGE_BOARDS)) {
        portletURL.setParameter("struts_action", "/message_boards/view");
      } else {
        portletURL.setParameter("struts_action", "/message_boards_admin/view");
      }
    } else {
      if (portletId.equals(PortletKeys.MESSAGE_BOARDS)) {
        portletURL.setParameter("struts_action", "/message_boards/view_message");
      } else {
        portletURL.setParameter("struts_action", "/message_boards_admin/view_message");
      }
    }

    return portletURL;
  }
コード例 #4
0
  @Override
  public String getURLViewInContext(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      String noSuchEntryRedirect)
      throws Exception {

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

    Layout layout = themeDisplay.getLayout();

    if (Validator.isNotNull(_article.getLayoutUuid())) {
      layout =
          LayoutLocalServiceUtil.getLayoutByUuidAndCompanyId(
              _article.getLayoutUuid(), _article.getCompanyId());
    }

    String portletId = (String) liferayPortletRequest.getAttribute(WebKeys.PORTLET_ID);

    PortletPreferences portletSetup =
        PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout, portletId);

    String linkToLayoutUuid =
        GetterUtil.getString(portletSetup.getValue("portletSetupLinkToLayoutUuid", null));

    if (Validator.isNotNull(_article.getLayoutUuid()) && Validator.isNull(linkToLayoutUuid)) {

      Group group = themeDisplay.getScopeGroup();

      if (group.getGroupId() != _article.getGroupId()) {
        group = GroupLocalServiceUtil.getGroup(_article.getGroupId());
      }

      String groupFriendlyURL =
          PortalUtil.getGroupFriendlyURL(group, layout.isPrivateLayout(), themeDisplay);

      return PortalUtil.addPreservedParameters(
          themeDisplay,
          groupFriendlyURL
              .concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR)
              .concat(_article.getUrlTitle()));
    }

    List<Long> hitLayoutIds =
        JournalContentSearchLocalServiceUtil.getLayoutIds(
            _article.getGroupId(), layout.isPrivateLayout(), _article.getArticleId());

    if (!hitLayoutIds.isEmpty()) {
      Long hitLayoutId = hitLayoutIds.get(0);

      Layout hitLayout =
          LayoutLocalServiceUtil.getLayout(
              _article.getGroupId(), layout.isPrivateLayout(), hitLayoutId.longValue());

      return PortalUtil.getLayoutURL(hitLayout, themeDisplay);
    }

    return noSuchEntryRedirect;
  }
コード例 #5
0
  @Override
  public String getDisplayURL(ThemeDisplay themeDisplay, boolean privateLayout) {

    if (!privateLayout && (getPublicLayoutsPageCount() > 0)) {
      try {
        String groupFriendlyURL =
            PortalUtil.getGroupFriendlyURL(getPublicLayoutSet(), themeDisplay);

        return PortalUtil.addPreservedParameters(themeDisplay, groupFriendlyURL);
      } catch (PortalException pe) {
        _log.error(pe, pe);
      }
    } else if (privateLayout && (getPrivateLayoutsPageCount() > 0)) {
      try {
        String groupFriendlyURL =
            PortalUtil.getGroupFriendlyURL(getPrivateLayoutSet(), themeDisplay);

        return PortalUtil.addPreservedParameters(themeDisplay, groupFriendlyURL);
      } catch (PortalException pe) {
        _log.error(pe);
      }
    }

    return StringPool.BLANK;
  }
コード例 #6
0
  @Override
  public String getPortalURL(long groupId) throws PortalException, SystemException {

    String portalURL = PortalUtil.getPortalURL(getVirtualHostname(), Http.HTTP_PORT, false);

    if (groupId <= 0) {
      return portalURL;
    }

    Group group = GroupLocalServiceUtil.getGroup(groupId);

    if (group.hasPublicLayouts()) {
      LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, false);

      if (Validator.isNotNull(layoutSet.getVirtualHostname())) {
        portalURL = PortalUtil.getPortalURL(layoutSet.getVirtualHostname(), Http.HTTP_PORT, false);
      }
    } else if (group.hasPrivateLayouts()) {
      LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, true);

      if (Validator.isNotNull(layoutSet.getVirtualHostname())) {
        portalURL = PortalUtil.getPortalURL(layoutSet.getVirtualHostname(), Http.HTTP_PORT, false);
      }
    }

    return portalURL;
  }
コード例 #7
0
  @Override
  public String render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortletException {

    HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(renderRequest);

    HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(renderResponse);

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

    if (!_openId.isEnabled(themeDisplay.getCompanyId()) || themeDisplay.isSignedIn()) {

      return "/login.jsp";
    }

    RequestDispatcher requestDispatcher = _servletContext.getRequestDispatcher(_JSP_PATH);

    try {
      requestDispatcher.include(httpServletRequest, httpServletResponse);
    } catch (Exception e) {
      _log.error("Unable to include JSP " + _JSP_PATH, e);

      throw new PortletException("Unable to include JSP " + _JSP_PATH, e);
    }

    return "/navigation.jsp";
  }
コード例 #8
0
  @Override
  public ActionForward render(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      RenderRequest renderRequest,
      RenderResponse renderResponse)
      throws Exception {

    try {
      ActionUtil.getEntry(renderRequest);

      if (PropsValues.BLOGS_PINGBACK_ENABLED) {
        BlogsEntry entry = (BlogsEntry) renderRequest.getAttribute(WebKeys.BLOGS_ENTRY);

        if ((entry != null) && entry.isAllowPingbacks()) {
          HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse);

          response.addHeader(
              "X-Pingback", PortalUtil.getPortalURL(renderRequest) + "/xmlrpc/pingback");
        }
      }
    } catch (Exception e) {
      if (e instanceof NoSuchEntryException || e instanceof PrincipalException) {

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

        return mapping.findForward("portlet.blogs.error");
      } else {
        throw e;
      }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.blogs.edit_entry"));
  }
コード例 #9
0
  protected void login(
      ThemeDisplay themeDisplay, ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    String login = ParamUtil.getString(actionRequest, "login");
    String password = actionRequest.getParameter("password");
    boolean rememberMe = ParamUtil.getBoolean(actionRequest, "rememberMe");

    if (!themeDisplay.isSignedIn()) {
      String portletId = PortalUtil.getPortletId(actionRequest);

      PortletPreferences portletPreferences =
          PortletPreferencesFactoryUtil.getStrictPortletSetup(themeDisplay.getLayout(), portletId);

      String authType = portletPreferences.getValue("authType", null);

      AuthenticatedSessionManagerUtil.login(
          request, response, login, password, rememberMe, authType);
    }

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

    if (Validator.isNotNull(redirect)) {
      redirect = PortalUtil.escapeRedirect(redirect);

      if (Validator.isNotNull(redirect) && !redirect.startsWith(Http.HTTP)) {

        redirect = getCompleteRedirectURL(request, redirect);
      }
    }

    String mainPath = themeDisplay.getPathMain();

    if (PropsValues.PORTAL_JAAS_ENABLE) {
      if (Validator.isNotNull(redirect)) {
        redirect =
            mainPath.concat("/portal/protected?redirect=").concat(HttpUtil.encodeURL(redirect));
      } else {
        redirect = mainPath.concat("/portal/protected");
      }

      actionResponse.sendRedirect(redirect);
    } else {
      if (Validator.isNotNull(redirect)) {
        actionResponse.sendRedirect(redirect);
      } else {
        boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin");

        if (doActionAfterLogin) {
          return;
        } else {
          actionResponse.sendRedirect(mainPath);
        }
      }
    }
  }
コード例 #10
0
  protected Date getDate(String param, HttpServletRequest request) {
    int month = ParamUtil.getInteger(request, param + "Month");
    int day = ParamUtil.getInteger(request, param + "Day");
    int year = ParamUtil.getInteger(request, param + "Year");
    int hour = ParamUtil.getInteger(request, param + "Hour", -1);
    int minute = ParamUtil.getInteger(request, param + "Minute");

    int amPm = ParamUtil.getInteger(request, param + "AmPm");

    if (amPm == Calendar.PM) {
      hour += 12;
    }

    if (hour == -1) {
      return PortalUtil.getDate(month, day, year);
    }

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

    User user = themeDisplay.getUser();

    try {
      return PortalUtil.getDate(month, day, year, hour, minute, user.getTimeZone(), null);
    } catch (PortalException pe) {
      return null;
    }
  }
コード例 #11
0
  @Override
  public void processAction(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse)
      throws Exception {

    try {
      String csv = getUsersCSV(actionRequest, actionResponse);

      String fileName = "users.csv";
      byte[] bytes = csv.getBytes();

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

      ServletResponseUtil.sendFile(request, response, fileName, bytes, ContentTypes.TEXT_CSV_UTF8);

      setForward(actionRequest, ActionConstants.COMMON_NULL);
    } catch (Exception e) {
      SessionErrors.add(actionRequest, e.getClass());

      setForward(actionRequest, "portlet.users_admin.error");
    }
  }
コード例 #12
0
  protected void sendRedirect(
      ActionRequest actionRequest,
      ActionResponse actionResponse,
      ThemeDisplay themeDisplay,
      String login,
      String password)
      throws Exception {

    HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);

    String redirect = PortalUtil.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

    if (Validator.isNotNull(redirect)) {
      HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);

      AuthenticatedSessionManagerUtil.login(request, response, login, password, false, null);
    } else {
      PortletURL loginURL = LoginUtil.getLoginURL(request, themeDisplay.getPlid());

      loginURL.setParameter("login", login);

      redirect = loginURL.toString();
    }

    actionResponse.sendRedirect(redirect);
  }
コード例 #13
0
  @Override
  public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) {

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

      if (!MentionsUtil.isMentionsEnabled(themeDisplay.getSiteGroupId())) {

        return;
      }

      HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest);

      JSONArray jsonArray = getJSONArray(request);

      HttpServletResponse response = PortalUtil.getHttpServletResponse(resourceResponse);

      response.setContentType(ContentTypes.APPLICATION_JSON);

      ServletResponseUtil.write(response, jsonArray.toString());
    } catch (Exception e) {
      _log.error(e, e);
    }

    return;
  }
コード例 #14
0
ファイル: TrashImpl.java プロジェクト: Brokk88/liferay-portal
  protected void addBreadcrumbEntries(
      HttpServletRequest request,
      String className,
      long classPK,
      String paramName,
      PortletURL containerModelURL)
      throws PortalException, SystemException {

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

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

    List<ContainerModel> containerModels = trashHandler.getParentContainerModels(classPK);

    Collections.reverse(containerModels);

    for (ContainerModel containerModel : containerModels) {
      containerModelURL.setParameter(
          paramName, String.valueOf(containerModel.getContainerModelId()));

      PortalUtil.addPortletBreadcrumbEntry(
          request, containerModel.getContainerModelName(), containerModelURL.toString());
    }

    TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK);

    PortalUtil.addPortletBreadcrumbEntry(
        request, trashRenderer.getTitle(themeDisplay.getLocale()), null);
  }
コード例 #15
0
  protected void installExt(ServletContext servletContext, ClassLoader portletClassLoader)
      throws Exception {

    String servletContextName = servletContext.getServletContextName();

    String globalLibDir = PortalUtil.getGlobalLibDir();
    String portalWebDir = PortalUtil.getPortalWebDir();
    String portalLibDir = PortalUtil.getPortalLibDir();
    String pluginWebDir = WebDirDetector.getRootDir(portletClassLoader);

    copyJar(servletContext, globalLibDir, "ext-service");
    copyJar(servletContext, portalLibDir, "ext-impl");
    copyJar(servletContext, portalLibDir, "ext-util-bridges");
    copyJar(servletContext, portalLibDir, "ext-util-java");
    copyJar(servletContext, portalLibDir, "ext-util-taglib");

    mergeWebXml(portalWebDir, pluginWebDir);

    CopyTask.copyDirectory(
        pluginWebDir + "WEB-INF/ext-web/docroot",
        portalWebDir,
        StringPool.BLANK,
        "**/WEB-INF/web.xml",
        true,
        false);

    FileUtil.copyFile(
        pluginWebDir + "WEB-INF/ext-" + servletContextName + ".xml",
        portalWebDir + "WEB-INF/ext-" + servletContextName + ".xml");

    ExtRegistry.registerExt(servletContext);
  }
コード例 #16
0
  public void applyAction(
      MDRAction mdrAction, HttpServletRequest request, HttpServletResponse response) {

    long companyId = PortalUtil.getCompanyId(request);

    UnicodeProperties typeSettingsProperties = mdrAction.getTypeSettingsProperties();

    String themeId = GetterUtil.getString(typeSettingsProperties.getProperty("themeId"));

    Theme theme = _themeLocalService.fetchTheme(companyId, themeId);

    if (theme == null) {
      return;
    }

    request.setAttribute(WebKeys.THEME, theme);

    String colorSchemeId =
        GetterUtil.getString(typeSettingsProperties.getProperty("colorSchemeId"));

    ColorScheme colorScheme =
        _themeLocalService.fetchColorScheme(companyId, themeId, colorSchemeId);

    if (colorScheme == null) {
      colorScheme = ColorSchemeImpl.getNullColorScheme();
    }

    request.setAttribute(WebKeys.COLOR_SCHEME, colorScheme);

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

    String contextPath = PortalUtil.getPathContext();

    themeDisplay.setLookAndFeel(contextPath, theme, colorScheme);
  }
コード例 #17
0
  @Override
  public String getPortletFileEntryURL(
      ThemeDisplay themeDisplay, FileEntry fileEntry, String queryString, boolean absoluteURL) {

    StringBundler sb = new StringBundler(10);

    if (themeDisplay != null) {
      if (absoluteURL) {
        sb.append(themeDisplay.getPortalURL());
      }
    }

    sb.append(PortalUtil.getPathContext());
    sb.append("/documents/");
    sb.append(WebServerServlet.PATH_PORTLET_FILE_ENTRY);
    sb.append(StringPool.SLASH);
    sb.append(fileEntry.getGroupId());
    sb.append(StringPool.SLASH);

    String title = fileEntry.getTitle();

    if (fileEntry.isInTrash()) {
      title = TrashUtil.getOriginalTitle(fileEntry.getTitle());
    }

    sb.append(HttpUtil.encodeURL(HtmlUtil.unescape(title)));

    sb.append(StringPool.SLASH);
    sb.append(HttpUtil.encodeURL(fileEntry.getUuid()));

    if (themeDisplay != null) {
      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      if (portletDisplay != null) {
        String portletId = portletDisplay.getId();

        if (portletId.equals(PortletKeys.TRASH) && !queryString.contains("status=")) {

          if (Validator.isNotNull(queryString)) {
            queryString += StringPool.AMPERSAND;
          }

          queryString += "status=" + WorkflowConstants.STATUS_IN_TRASH;
        }
      }
    }

    if (Validator.isNotNull(queryString)) {
      sb.append(StringPool.QUESTION);
      sb.append(queryString);
    }

    String portletFileEntryURL = sb.toString();

    if ((themeDisplay != null) && themeDisplay.isAddSessionIdToURL()) {
      return PortalUtil.getURLWithSessionId(portletFileEntryURL, themeDisplay.getSessionId());
    }

    return portletFileEntryURL;
  }
コード例 #18
0
  public void addAttachment(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

    UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);

    String portletId = PortalUtil.getPortletId(actionRequest);

    long resourcePrimKey = ParamUtil.getLong(uploadPortletRequest, "resourcePrimKey");

    String dirName = ParamUtil.getString(uploadPortletRequest, "dirName");
    String fileName = uploadPortletRequest.getFileName("file");

    InputStream inputStream = null;

    try {
      inputStream = uploadPortletRequest.getFileAsStream("file");

      ServiceContext serviceContext =
          ServiceContextFactory.getInstance(KBArticle.class.getName(), actionRequest);

      KBArticleServiceUtil.addAttachment(
          portletId, resourcePrimKey, dirName, fileName, inputStream, serviceContext);
    } finally {
      StreamUtil.cleanUp(inputStream);
    }
  }
コード例 #19
0
  public void serveKBArticleRSS(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
      throws Exception {

    if (!PortalUtil.isRSSFeedsEnabled()) {
      PortalUtil.sendRSSFeedsDisabledError(resourceRequest, resourceResponse);

      return;
    }

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

    long resourcePrimKey = ParamUtil.getLong(resourceRequest, "resourcePrimKey");

    int rssDelta = ParamUtil.getInteger(resourceRequest, "rssDelta");
    String rssDisplayStyle = ParamUtil.getString(resourceRequest, "rssDisplayStyle");
    String rssFormat = ParamUtil.getString(resourceRequest, "rssFormat");

    String rss =
        KBArticleServiceUtil.getKBArticleRSS(
            resourcePrimKey,
            WorkflowConstants.STATUS_APPROVED,
            rssDelta,
            rssDisplayStyle,
            rssFormat,
            themeDisplay);

    PortletResponseUtil.sendFile(
        resourceRequest,
        resourceResponse,
        null,
        rss.getBytes(StringPool.UTF8),
        ContentTypes.TEXT_XML_UTF8);
  }
コード例 #20
0
ファイル: TrashImpl.java プロジェクト: Gubie/liferay-portal
  @Override
  public void addContainerModelBreadcrumbEntries(
      HttpServletRequest request, String className, long classPK, PortletURL containerModelURL)
      throws PortalException {

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

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

    String rootContainerModelName =
        LanguageUtil.get(themeDisplay.getLocale(), trashHandler.getRootContainerModelName());

    if (classPK == 0) {
      PortalUtil.addPortletBreadcrumbEntry(request, rootContainerModelName, null);

      return;
    }

    containerModelURL.setParameter("containerModelId", "0");

    PortalUtil.addPortletBreadcrumbEntry(
        request, rootContainerModelName, containerModelURL.toString());

    addBreadcrumbEntries(request, className, classPK, "containerModelId", containerModelURL);
  }
コード例 #21
0
  @BeforeClass
  public static void setUpClass() throws Exception {
    PortalUtil portalUtil = new PortalUtil();

    portalUtil.setPortal(new PortalImpl());

    PortalUUIDUtil portalUUIDUtil = new PortalUUIDUtil();

    portalUUIDUtil.setPortalUUID(new PortalUUIDImpl());

    Field field = ReflectionUtil.getDeclaredField(LockLocalServiceUtil.class, "_service");

    LockLocalService lockLocalService = new MockLockLocalService();

    field.set(null, lockLocalService);

    field = ClusterableContextThreadLocal.class.getDeclaredField("_contextThreadLocal");

    field.setAccessible(true);

    _threadLocalContext = (ThreadLocal<HashMap<String, Serializable>>) field.get(null);

    Method method = ClusterSchedulerEngine.class.getDeclaredMethod("delete", String.class);

    Clusterable clusterable = method.getAnnotation(Clusterable.class);

    Class<? extends ClusterInvokeAcceptor> clusterInvokeAcceptorClass = clusterable.acceptor();

    Constructor<? extends ClusterInvokeAcceptor> constructor =
        clusterInvokeAcceptorClass.getDeclaredConstructor();

    constructor.setAccessible(true);

    _clusterInvokeAcceptor = constructor.newInstance();
  }
コード例 #22
0
  protected void sendRedirect(
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse,
      String redirect,
      String closeRedirect)
      throws IOException {

    if (isDisplaySuccessMessage(actionRequest)) {
      addSuccessMessage(actionRequest, actionResponse);
    }

    if (Validator.isNull(redirect)) {
      redirect = (String) actionRequest.getAttribute(WebKeys.REDIRECT);
    }

    if (Validator.isNull(redirect)) {
      redirect = ParamUtil.getString(actionRequest, "redirect");
    }

    if ((portletConfig != null)
        && Validator.isNotNull(redirect)
        && Validator.isNotNull(closeRedirect)) {

      redirect = HttpUtil.setParameter(redirect, "closeRedirect", closeRedirect);

      SessionMessages.add(
          actionRequest,
          PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT,
          closeRedirect);
    }

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

    // LPS-1928

    HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);

    if (BrowserSnifferUtil.isIe(request)
        && (BrowserSnifferUtil.getMajorVersion(request) == 6.0)
        && redirect.contains(StringPool.POUND)) {

      String redirectToken = "&#";

      if (!redirect.contains(StringPool.QUESTION)) {
        redirectToken = StringPool.QUESTION + redirectToken;
      }

      redirect = StringUtil.replace(redirect, StringPool.POUND, redirectToken);
    }

    redirect = PortalUtil.escapeRedirect(redirect);

    if (Validator.isNotNull(redirect)) {
      actionResponse.sendRedirect(redirect);
    }
  }
コード例 #23
0
  @Override
  public void serveResource(
      StrutsPortletAction originalStrutsPortletAction,
      PortletConfig portletConfig,
      ResourceRequest resourceRequest,
      ResourceResponse resourceResponse) {

    long entryId = ParamUtil.getLong(resourceRequest, "entryId");
    ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);

    BlogsEntry entry;
    try {
      entry = BlogsEntryServiceUtil.getEntry(entryId);
      StringBundler sb = new StringBundler();

      sb.append("<html>");

      sb.append("<head>");
      sb.append("<meta content=\"");
      sb.append(ContentTypes.TEXT_HTML_UTF8);
      sb.append("\" http-equiv=\"content-type\" />");
      sb.append("<base href=\"");
      sb.append(themeDisplay.getPortalURL());
      sb.append("\" />");
      sb.append("</head>");

      sb.append("<body>");
      sb.append(entry.getContent());
      sb.append("</body>");
      sb.append("</html>");

      InputStream is = new UnsyncByteArrayInputStream(sb.toString().getBytes(StringPool.UTF8));
      File destinationFile = null;

      destinationFile = DocumentConversionUtil.convert(entry.getEntryId() + "", is, "html", "pdf");
      OutputStream out = resourceResponse.getPortletOutputStream();
      InputStream in = new FileInputStream(destinationFile);
      HttpServletResponse httpRes = PortalUtil.getHttpServletResponse(resourceResponse);
      HttpServletRequest httpReq = PortalUtil.getHttpServletRequest(resourceRequest);
      String contentType = MimeTypesUtil.getContentType(destinationFile);
      ServletResponseUtil.sendFile(httpReq, httpRes, destinationFile.getName(), in, contentType);
      out.close();

    } catch (PortalException e) {
      System.out.println("PortalException : " + getClass().getName() + "\n" + e);
      // e.printStackTrace();
    } catch (SystemException e) {
      System.out.println("SystemException : " + getClass().getName() + "\n" + e);
      // e.printStackTrace();
    } catch (UnsupportedEncodingException e) {
      System.out.println("UnsupportedEncodingException : " + getClass().getName() + "\n" + e);
      // e.printStackTrace();
    } catch (Exception e) {
      System.out.println("Exception : " + getClass().getName() + "\n" + e);
      // e.printStackTrace();
    }
  }
コード例 #24
0
  public ProjectsEntry addProjectsEntry(
      long userId,
      String title,
      String description,
      int startDateMonth,
      int startDateDay,
      int startDateYear,
      int endDateMonth,
      int endDateDay,
      int endDateYear,
      boolean current,
      String data)
      throws PortalException, SystemException {

    User user = userLocalService.getUserById(userId);

    Date startDate =
        PortalUtil.getDate(
            startDateMonth,
            startDateDay,
            startDateYear,
            user.getTimeZone(),
            new ProjectsEntryStartDateException());

    Date endDate = null;

    if (!current) {
      endDate =
          PortalUtil.getDate(
              endDateMonth,
              endDateDay,
              endDateYear,
              user.getTimeZone(),
              new ProjectsEntryEndDateException());
    }

    Date now = new Date();

    long projectsEntryId = counterLocalService.increment();

    ProjectsEntry projectsEntry = projectsEntryPersistence.create(projectsEntryId);

    projectsEntry.setCompanyId(user.getCompanyId());
    projectsEntry.setUserId(user.getUserId());
    projectsEntry.setUserName(user.getFullName());
    projectsEntry.setCreateDate(now);
    projectsEntry.setModifiedDate(now);
    projectsEntry.setTitle(title);
    projectsEntry.setDescription(description);
    projectsEntry.setStartDate(startDate);
    projectsEntry.setEndDate(endDate);
    projectsEntry.setData(data);

    projectsEntryPersistence.update(projectsEntry, false);

    return projectsEntry;
  }
  @Override
  public AnonymousUser getAnonymousUser(RenderRequest renderRequest, RenderResponse renderResponse)
      throws PortalException, SystemException {

    HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest);
    HttpServletResponse response = PortalUtil.getHttpServletResponse(renderResponse);

    return getAnonymousUser(request, response);
  }
コード例 #26
0
  protected String getLoginURL(String key, ThemeDisplay themeDisplay) throws Exception {

    Group group = groupLocalService.getGroup(themeDisplay.getCompanyId(), GroupConstants.GUEST);

    long plid = PortalUtil.getPlidFromPortletId(group.getGroupId(), PortletKeys.LOGIN);

    Layout layout = layoutLocalService.getLayout(plid);

    return PortalUtil.getLayoutFullURL(layout, themeDisplay, false) + "?key=" + key;
  }
コード例 #27
0
ファイル: TrashImpl.java プロジェクト: Brokk88/liferay-portal
  public String getViewContentURL(String className, long classPK, ThemeDisplay themeDisplay)
      throws PortalException, SystemException {

    if (!themeDisplay.isSignedIn()
        || !isTrashEnabled(themeDisplay.getScopeGroupId())
        || !PortletPermissionUtil.hasControlPanelAccessPermission(
            themeDisplay.getPermissionChecker(),
            themeDisplay.getScopeGroupId(),
            PortletKeys.TRASH)) {

      return null;
    }

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

    if (trashHandler.isInTrashContainer(classPK)) {
      ContainerModel containerModel = trashHandler.getTrashContainer(classPK);

      className = containerModel.getModelClassName();
      classPK = containerModel.getContainerModelId();

      trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);
    }

    TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK);

    if (trashRenderer == null) {
      return null;
    }

    String namespace = PortalUtil.getPortletNamespace(PortletKeys.TRASH);

    Map<String, String[]> params = new HashMap<String, String[]>();

    params.put(namespace + "struts_action", new String[] {"/trash/view_content"});
    params.put(namespace + "redirect", new String[] {themeDisplay.getURLCurrent()});

    TrashEntry trashEntry = TrashEntryLocalServiceUtil.getEntry(className, classPK);

    if (trashEntry.getRootEntry() != null) {
      params.put(namespace + "className", new String[] {className});
      params.put(namespace + "classPK", new String[] {String.valueOf(classPK)});
    } else {
      params.put(
          namespace + "trashEntryId", new String[] {String.valueOf(trashEntry.getEntryId())});
    }

    params.put(namespace + "type", new String[] {trashRenderer.getType()});
    params.put(namespace + "showActions", new String[] {Boolean.FALSE.toString()});
    params.put(namespace + "showAssetMetadata", new String[] {Boolean.TRUE.toString()});
    params.put(namespace + "showEditURL", new String[] {Boolean.FALSE.toString()});

    return PortalUtil.getControlPanelFullURL(
        themeDisplay.getScopeGroupId(), PortletKeys.TRASH, params);
  }
コード例 #28
0
ファイル: UploadAction.java プロジェクト: thaond/progate-lmis
  public void processAction(
      ActionMapping mapping,
      ActionForm form,
      PortletConfig portletConfig,
      ActionRequest actionRequest,
      ActionResponse actionResponse)
      throws Exception {

    UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
    String fileLogoParam = "file";
    File file = uploadRequest.getFile(fileLogoParam);
    ServiceContext sc;

    try {

      sc = ServiceContextFactory.getInstance(this.getClass().getName(), actionRequest);
      // Make sure the uploaded images can be view by any one;
      sc.setAddCommunityPermissions(true);
      sc.setAddGuestPermissions(true);

      IGFolder folder = Functions.getIGFolder(sc);
      // String fileName = uploadRequest.getFileName(fileLogoParam);
      String contentType = uploadRequest.getContentType(fileLogoParam);

      IGImage image =
          IGImageLocalServiceUtil.addImage(
              sc.getUserId(),
              folder.getFolderId(),
              file.getName() + (new Time()).toString(),
              file.getName(),
              file,
              contentType,
              sc);

      HttpServletRequest servletRequest = PortalUtil.getHttpServletRequest(actionRequest);
      String res =
          image.getImageId()
              + "|"
              + ProGateUtil.getImageURL(image.getSmallImageId(), servletRequest)
              + "|"
              + ProGateUtil.getImageURL(image.getLargeImageId(), servletRequest);
      ProGateUtil.servletPrint(actionResponse, res);

    } catch (PortalException e) {
      // TODO Auto-generated catch block

      e.printStackTrace();
    } catch (SystemException se) {

      se.printStackTrace();
    } catch (NullPointerException e2) {

      e2.printStackTrace();
    }
  }
コード例 #29
0
  public static void addPortletBreadcrumbEntries(
      Folder folder, HttpServletRequest request, PortletURL portletURL) throws Exception {

    long defaultFolderId = _getDefaultFolderId(request);

    List<Folder> ancestorFolders = Collections.emptyList();

    if ((folder != null) && (folder.getFolderId() != defaultFolderId)) {
      ancestorFolders = folder.getAncestors();

      int indexOfRootFolder = -1;

      for (int i = 0; i < ancestorFolders.size(); i++) {
        Folder ancestorFolder = ancestorFolders.get(i);

        if (defaultFolderId == ancestorFolder.getFolderId()) {
          indexOfRootFolder = i;
        }
      }

      if (indexOfRootFolder > -1) {
        ancestorFolders = ancestorFolders.subList(0, indexOfRootFolder);
      }
    }

    Collections.reverse(ancestorFolders);

    for (Folder ancestorFolder : ancestorFolders) {
      portletURL.setParameter("folderId", String.valueOf(ancestorFolder.getFolderId()));

      Map<String, Object> data = new HashMap<String, Object>();

      data.put("folder-id", ancestorFolder.getFolderId());

      PortalUtil.addPortletBreadcrumbEntry(
          request, ancestorFolder.getName(), portletURL.toString(), data);
    }

    long folderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;

    if (folder != null) {
      folderId = folder.getFolderId();
    }

    portletURL.setParameter("folderId", String.valueOf(folderId));

    if ((folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) && (folderId != defaultFolderId)) {

      Map<String, Object> data = new HashMap<String, Object>();

      data.put("folder-id", folderId);

      PortalUtil.addPortletBreadcrumbEntry(request, folder.getName(), portletURL.toString(), data);
    }
  }
コード例 #30
0
ファイル: TTUtils.java プロジェクト: taotran/eco
  /** @return */
  public static SearchContext getCurrentSearchContext() {
    final LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();

    final PortletRequest req =
        (PortletRequest) liferayFacesContext.getExternalContext().getRequest();

    final HttpServletRequest httpServletRequest =
        PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(req));
    final SearchContext searchContext = SearchContextFactory.getInstance(httpServletRequest);
    return searchContext;
  }