示例#1
0
  protected void handleData(
      List<BBCodeItem> bbCodeItems,
      BBCodeLexer bbCodeLexer,
      IntegerWrapper marker,
      BBCodeToken bbCodeToken,
      String data) {

    int length = data.length();

    int lastIndex = length;

    if (bbCodeToken != null) {
      length = bbCodeToken.getStart();

      lastIndex = bbCodeLexer.getLastIndex();
    }

    if (length > marker.getValue()) {
      BBCodeItem bbCodeItem =
          new BBCodeItem(TYPE_DATA, null, data.substring(marker.getValue(), length));

      bbCodeItems.add(bbCodeItem);
    }

    marker.setValue(lastIndex);
  }
  @Override
  public int doEndTag() throws JspException {
    try {
      HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

      IntegerWrapper panelCount =
          (IntegerWrapper) request.getAttribute("liferay-ui:panel-container:panelCount" + _id);

      request.removeAttribute("liferay-ui:panel-container:panelCount" + _id);

      if ((panelCount != null) && (panelCount.getValue() >= 1)) {
        PortalIncludeUtil.include(pageContext, getStartPage());
      }

      writeBodyContent(pageContext.getOut());

      if ((panelCount != null) && (panelCount.getValue() >= 1)) {
        PortalIncludeUtil.include(pageContext, getEndPage());
      }

      request.removeAttribute("liferay-ui:panel-container:id");
      request.removeAttribute("liferay-ui:panel-container:accordion");
      request.removeAttribute("liferay-ui:panel-container:persistState");
      request.removeAttribute("liferay-ui:panel-container:extended");
      request.removeAttribute("liferay-ui:panel-container:cssClass");

      return EVAL_PAGE;
    } catch (Exception e) {
      throw new JspException(e);
    }
  }
  @Override
  public int doAfterBody() {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    IntegerWrapper panelCount =
        (IntegerWrapper) request.getAttribute("liferay-ui:panel-container:panelCount" + _id);

    if ((panelCount != null) && (panelCount.getValue() == 1)) {

      bodyContent.clearBody();

      return EVAL_BODY_AGAIN;
    } else {
      return SKIP_BODY;
    }
  }
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        new VirtualHostActionableDynamicQuery() {
          @Override
          protected void performAction(Object object) {
            VirtualHost virtualHost = (VirtualHost) object;

            Assert.assertNotNull(virtualHost);

            count.increment();
          }
        };

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        new DDMStructureLinkActionableDynamicQuery() {
          @Override
          protected void performAction(Object object) {
            DDMStructureLink ddmStructureLink = (DDMStructureLink) object;

            Assert.assertNotNull(ddmStructureLink);

            count.increment();
          }
        };

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }
示例#6
0
  @Override
  public int doAfterBody() {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    IntegerWrapper iconCount =
        (IntegerWrapper) request.getAttribute("liferay-ui:icon-menu:icon-count");

    Boolean singleIcon = (Boolean) request.getAttribute("liferay-ui:icon-menu:single-icon");

    if ((iconCount != null) && (iconCount.getValue() == 1) && (singleIcon == null)) {

      bodyContent.clearBody();

      request.setAttribute("liferay-ui:icon-menu:single-icon", Boolean.TRUE);

      return EVAL_BODY_AGAIN;
    } else {
      return SKIP_BODY;
    }
  }
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        OrgLaborLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(
        new ActionableDynamicQuery.PerformActionMethod<OrgLabor>() {
          @Override
          public void performAction(OrgLabor orgLabor) {
            Assert.assertNotNull(orgLabor);

            count.increment();
          }
        });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }
示例#8
0
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        new ExportImportConfigurationActionableDynamicQuery() {
          @Override
          protected void performAction(Object object) {
            ExportImportConfiguration exportImportConfiguration =
                (ExportImportConfiguration) object;

            Assert.assertNotNull(exportImportConfiguration);

            count.increment();
          }
        };

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        CalendarResourceLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(
        new ActionableDynamicQuery.PerformActionMethod() {
          @Override
          public void performAction(Object object) {
            CalendarResource calendarResource = (CalendarResource) object;

            Assert.assertNotNull(calendarResource);

            count.increment();
          }
        });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        KaleoTaskInstanceTokenLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(
        new ActionableDynamicQuery.PerformActionMethod() {
          @Override
          public void performAction(Object object) {
            KaleoTaskInstanceToken kaleoTaskInstanceToken = (KaleoTaskInstanceToken) object;

            Assert.assertNotNull(kaleoTaskInstanceToken);

            count.increment();
          }
        });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        SocialActivitySettingLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(
        new ActionableDynamicQuery.PerformActionMethod() {
          @Override
          public void performAction(Object object) {
            SocialActivitySetting socialActivitySetting = (SocialActivitySetting) object;

            Assert.assertNotNull(socialActivitySetting);

            count.increment();
          }
        });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }
  @Test
  public void testActionableDynamicQuery() throws Exception {
    final IntegerWrapper count = new IntegerWrapper();

    ActionableDynamicQuery actionableDynamicQuery =
        ExportImportConfigurationLocalServiceUtil.getActionableDynamicQuery();

    actionableDynamicQuery.setPerformActionMethod(
        new ActionableDynamicQuery.PerformActionMethod() {
          @Override
          public void performAction(Object object) {
            ExportImportConfiguration exportImportConfiguration =
                (ExportImportConfiguration) object;

            Assert.assertNotNull(exportImportConfiguration);

            count.increment();
          }
        });

    actionableDynamicQuery.performActions();

    Assert.assertEquals(count.getValue(), _persistence.countAll());
  }
示例#13
0
  @Test
  public void testProcessLoginEvents() throws Exception {
    final IntegerWrapper counter = new IntegerWrapper();

    JAASHelper jaasHelper = JAASHelper.getInstance();

    JAASHelper.setInstance(
        new JAASHelper() {

          @Override
          protected long doGetJaasUserId(long companyId, String name)
              throws PortalException, SystemException {

            try {
              return super.doGetJaasUserId(companyId, name);
            } finally {
              counter.increment();
            }
          }
        });

    if (mainServlet == null) {
      MockServletContext mockServletContext =
          new AutoDeployMockServletContext(getResourceBasePath(), new FileSystemResourceLoader());

      MockServletConfig mockServletConfig = new MockServletConfig(mockServletContext);

      MainServlet mainServlet = new MainServlet();

      try {
        mainServlet.init(mockServletConfig);
      } catch (ServletException se) {
        throw new RuntimeException("The main servlet could not be initialized");
      }
    }

    Date lastLoginDate = _user.getLastLoginDate();

    MockHttpServletRequest mockHttpServletRequest =
        new MockHttpServletRequest(
            mainServlet.getServletContext(), HttpMethods.GET, StringPool.SLASH);

    mockHttpServletRequest.setRemoteUser(String.valueOf(_user.getUserId()));

    JAASAction preJAASAction = new JAASAction();
    JAASAction postJAASAction = new JAASAction();

    try {
      EventsProcessorUtil.registerEvent(PropsKeys.LOGIN_EVENTS_PRE, preJAASAction);
      EventsProcessorUtil.registerEvent(PropsKeys.LOGIN_EVENTS_POST, postJAASAction);

      mainServlet.service(mockHttpServletRequest, new MockHttpServletResponse());

      Assert.assertEquals(2, counter.getValue());
      Assert.assertTrue(preJAASAction.isRan());
      Assert.assertTrue(postJAASAction.isRan());

      _user = UserLocalServiceUtil.getUser(_user.getUserId());

      Assert.assertFalse(lastLoginDate.after(_user.getLastLoginDate()));
    } finally {
      EventsProcessorUtil.unregisterEvent(PropsKeys.LOGIN_EVENTS_PRE, postJAASAction);
      EventsProcessorUtil.unregisterEvent(PropsKeys.LOGIN_EVENTS_POST, postJAASAction);

      JAASHelper.setInstance(jaasHelper);
    }
  }
示例#14
0
  protected int processEndTag() throws Exception {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    IntegerWrapper iconCount =
        (IntegerWrapper) request.getAttribute("liferay-ui:icon-menu:icon-count");

    request.removeAttribute("liferay-ui:icon-menu:icon-count");

    Boolean singleIcon = (Boolean) request.getAttribute("liferay-ui:icon-menu:single-icon");

    request.removeAttribute("liferay-ui:icon-menu:single-icon");

    JspWriter jspWriter = pageContext.getOut();

    if ((iconCount != null)
        && (iconCount.getValue() >= 1)
        && ((singleIcon == null) || _showWhenSingleIcon)) {

      if (!FileAvailabilityUtil.isAvailable(pageContext.getServletContext(), getStartPage())) {

        if (_showExpanded) {
          jspWriter.write("<div class=\"lfr-component ");
          jspWriter.write("lfr-menu-list lfr-menu-expanded align-");
          jspWriter.write(_align);
          jspWriter.write(" ");
          jspWriter.print(_cssClass);
          jspWriter.write("\" id=\"");
          jspWriter.write(_id);
          jspWriter.write("\">");
        } else {
          jspWriter.write("<span title=\"");
          jspWriter.write(LanguageUtil.get(pageContext, _message));
          jspWriter.write("\"><ul class='lfr-component lfr-actions ");
          jspWriter.write("align-");
          jspWriter.write(_align);
          jspWriter.write(" direction-");
          jspWriter.write(_direction);
          jspWriter.write(" max-display-items-");
          jspWriter.write(String.valueOf(_maxDisplayItems));
          jspWriter.write(" ");

          if (Validator.isNotNull(_cssClass)) {
            jspWriter.print(_cssClass);
          }

          if (_disabled) {
            jspWriter.write(" disabled");
          }

          if (_extended) {
            jspWriter.write(" lfr-extended");
          }

          if (_showArrow) {
            jspWriter.write(" show-arrow");
          }

          jspWriter.write("\' id=\"");
          jspWriter.write(_id);
          jspWriter.write("\">");
          jspWriter.write("<li class=\"lfr-trigger\"><strong>");
          jspWriter.write("<a class=\"nobr\" href=\"javascript:;\">");

          if (Validator.isNotNull(_icon)) {
            jspWriter.write("<img alt=\"\" src=\"");
            jspWriter.write(_icon);
            jspWriter.write("\" />");
          }

          jspWriter.write("<span class=\"taglib-text\">");
          jspWriter.write(LanguageUtil.get(pageContext, _message));
          jspWriter.write("</span></a></strong>");
        }

        jspWriter.write("<ul>");
      } else {
        PortalIncludeUtil.include(pageContext, getStartPage());
      }
    }

    writeBodyContent(jspWriter);

    if ((iconCount != null)
        && (iconCount.getValue() >= 1)
        && ((singleIcon == null) || _showWhenSingleIcon)) {

      if (!FileAvailabilityUtil.isAvailable(pageContext.getServletContext(), getEndPage())) {

        jspWriter.write("</ul>");

        if (_showExpanded) {
          jspWriter.write("</div>");

          ScriptTag.doTag(
              null, "liferay-menu", "Liferay.Menu.handleFocus('#" + _id + "menu');", pageContext);
        } else {
          jspWriter.write("</li></ul></span>");
        }
      } else {
        PortalIncludeUtil.include(pageContext, getEndPage());
      }
    }

    request.removeAttribute("liferay-ui:icon-menu:showWhenSingleIcon");

    return EVAL_PAGE;
  }