@Test
  public void testResetOriginalValues() throws Exception {
    CalendarResource newCalendarResource = addCalendarResource();

    _persistence.clearCache();

    CalendarResource existingCalendarResource =
        _persistence.findByPrimaryKey(newCalendarResource.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingCalendarResource.getUuid(),
            ReflectionTestUtil.invoke(
                existingCalendarResource, "getOriginalUuid", new Class<?>[0])));
    Assert.assertEquals(
        Long.valueOf(existingCalendarResource.getGroupId()),
        ReflectionTestUtil.<Long>invoke(
            existingCalendarResource, "getOriginalGroupId", new Class<?>[0]));

    Assert.assertEquals(
        Long.valueOf(existingCalendarResource.getClassNameId()),
        ReflectionTestUtil.<Long>invoke(
            existingCalendarResource, "getOriginalClassNameId", new Class<?>[0]));
    Assert.assertEquals(
        Long.valueOf(existingCalendarResource.getClassPK()),
        ReflectionTestUtil.<Long>invoke(
            existingCalendarResource, "getOriginalClassPK", new Class<?>[0]));
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    DLFileVersion newDLFileVersion = addDLFileVersion();

    _persistence.clearCache();

    DLFileVersionModelImpl existingDLFileVersionModelImpl =
        (DLFileVersionModelImpl) _persistence.findByPrimaryKey(newDLFileVersion.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingDLFileVersionModelImpl.getUuid(),
            existingDLFileVersionModelImpl.getOriginalUuid()));
    Assert.assertEquals(
        existingDLFileVersionModelImpl.getGroupId(),
        existingDLFileVersionModelImpl.getOriginalGroupId());

    Assert.assertEquals(
        existingDLFileVersionModelImpl.getFileEntryId(),
        existingDLFileVersionModelImpl.getOriginalFileEntryId());
    Assert.assertTrue(
        Validator.equals(
            existingDLFileVersionModelImpl.getVersion(),
            existingDLFileVersionModelImpl.getOriginalVersion()));
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    DLFolder newDLFolder = addDLFolder();

    _persistence.clearCache();

    DLFolderModelImpl existingDLFolderModelImpl =
        (DLFolderModelImpl) _persistence.findByPrimaryKey(newDLFolder.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingDLFolderModelImpl.getUuid(), existingDLFolderModelImpl.getOriginalUuid()));
    Assert.assertEquals(
        existingDLFolderModelImpl.getGroupId(), existingDLFolderModelImpl.getOriginalGroupId());

    Assert.assertEquals(
        existingDLFolderModelImpl.getRepositoryId(),
        existingDLFolderModelImpl.getOriginalRepositoryId());

    Assert.assertEquals(
        existingDLFolderModelImpl.getGroupId(), existingDLFolderModelImpl.getOriginalGroupId());
    Assert.assertEquals(
        existingDLFolderModelImpl.getParentFolderId(),
        existingDLFolderModelImpl.getOriginalParentFolderId());
    Assert.assertTrue(
        Validator.equals(
            existingDLFolderModelImpl.getName(), existingDLFolderModelImpl.getOriginalName()));
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    JournalContentSearch newJournalContentSearch = addJournalContentSearch();

    _persistence.clearCache();

    JournalContentSearch existingJournalContentSearch =
        _persistence.findByPrimaryKey(newJournalContentSearch.getPrimaryKey());

    Assert.assertEquals(
        existingJournalContentSearch.getGroupId(),
        ReflectionTestUtil.invoke(
            existingJournalContentSearch, "getOriginalGroupId", new Class<?>[0]));
    Assert.assertEquals(
        existingJournalContentSearch.getPrivateLayout(),
        ReflectionTestUtil.invoke(
            existingJournalContentSearch, "getOriginalPrivateLayout", new Class<?>[0]));
    Assert.assertEquals(
        existingJournalContentSearch.getLayoutId(),
        ReflectionTestUtil.invoke(
            existingJournalContentSearch, "getOriginalLayoutId", new Class<?>[0]));
    Assert.assertTrue(
        Validator.equals(
            existingJournalContentSearch.getPortletId(),
            ReflectionTestUtil.invoke(
                existingJournalContentSearch, "getOriginalPortletId", new Class<?>[0])));
    Assert.assertTrue(
        Validator.equals(
            existingJournalContentSearch.getArticleId(),
            ReflectionTestUtil.invoke(
                existingJournalContentSearch, "getOriginalArticleId", new Class<?>[0])));
  }
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    JournalFeed newJournalFeed = addJournalFeed();

    _persistence.clearCache();

    JournalFeedModelImpl existingJournalFeedModelImpl =
        (JournalFeedModelImpl) _persistence.findByPrimaryKey(newJournalFeed.getPrimaryKey());

    assertTrue(
        Validator.equals(
            existingJournalFeedModelImpl.getUuid(),
            existingJournalFeedModelImpl.getOriginalUuid()));
    assertEquals(
        existingJournalFeedModelImpl.getGroupId(),
        existingJournalFeedModelImpl.getOriginalGroupId());

    assertEquals(
        existingJournalFeedModelImpl.getGroupId(),
        existingJournalFeedModelImpl.getOriginalGroupId());
    assertTrue(
        Validator.equals(
            existingJournalFeedModelImpl.getFeedId(),
            existingJournalFeedModelImpl.getOriginalFeedId()));
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    Country newCountry = addCountry();

    _persistence.clearCache();

    CountryModelImpl existingCountryModelImpl =
        (CountryModelImpl) _persistence.findByPrimaryKey(newCountry.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingCountryModelImpl.getName(), existingCountryModelImpl.getOriginalName()));

    Assert.assertTrue(
        Validator.equals(
            existingCountryModelImpl.getA2(), existingCountryModelImpl.getOriginalA2()));

    Assert.assertTrue(
        Validator.equals(
            existingCountryModelImpl.getA3(), existingCountryModelImpl.getOriginalA3()));
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    ResourceBlock newResourceBlock = addResourceBlock();

    _persistence.clearCache();

    ResourceBlockModelImpl existingResourceBlockModelImpl =
        (ResourceBlockModelImpl) _persistence.findByPrimaryKey(newResourceBlock.getPrimaryKey());

    Assert.assertEquals(
        existingResourceBlockModelImpl.getCompanyId(),
        existingResourceBlockModelImpl.getOriginalCompanyId());
    Assert.assertEquals(
        existingResourceBlockModelImpl.getGroupId(),
        existingResourceBlockModelImpl.getOriginalGroupId());
    Assert.assertTrue(
        Validator.equals(
            existingResourceBlockModelImpl.getName(),
            existingResourceBlockModelImpl.getOriginalName()));
    Assert.assertTrue(
        Validator.equals(
            existingResourceBlockModelImpl.getPermissionsHash(),
            existingResourceBlockModelImpl.getOriginalPermissionsHash()));
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    WikiNode newWikiNode = addWikiNode();

    _persistence.clearCache();

    WikiNodeModelImpl existingWikiNodeModelImpl =
        (WikiNodeModelImpl) _persistence.findByPrimaryKey(newWikiNode.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingWikiNodeModelImpl.getUuid(), existingWikiNodeModelImpl.getOriginalUuid()));
    Assert.assertEquals(
        existingWikiNodeModelImpl.getGroupId(), existingWikiNodeModelImpl.getOriginalGroupId());

    Assert.assertEquals(
        existingWikiNodeModelImpl.getGroupId(), existingWikiNodeModelImpl.getOriginalGroupId());
    Assert.assertTrue(
        Validator.equals(
            existingWikiNodeModelImpl.getName(), existingWikiNodeModelImpl.getOriginalName()));
  }
  /**
   * Returns <code>true</code> if this service context contains an add command (i.e. has command
   * value {@link com.liferay.portal.kernel.util.Constants#ADD})
   *
   * @return <code>true</code> if this service context contains an add command; <code>false</code>
   *     otherwise
   */
  public boolean isCommandAdd() {
    if (Validator.equals(_command, Constants.ADD)
        || Validator.equals(_command, Constants.ADD_DYNAMIC)
        || Validator.equals(_command, Constants.ADD_MULTIPLE)) {

      return true;
    } else {
      return false;
    }
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    Layout newLayout = addLayout();

    _persistence.clearCache();

    LayoutModelImpl existingLayoutModelImpl =
        (LayoutModelImpl) _persistence.findByPrimaryKey(newLayout.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingLayoutModelImpl.getUuid(), existingLayoutModelImpl.getOriginalUuid()));
    Assert.assertEquals(
        existingLayoutModelImpl.getGroupId(), existingLayoutModelImpl.getOriginalGroupId());
    Assert.assertEquals(
        existingLayoutModelImpl.getPrivateLayout(),
        existingLayoutModelImpl.getOriginalPrivateLayout());

    Assert.assertEquals(
        existingLayoutModelImpl.getIconImageId(), existingLayoutModelImpl.getOriginalIconImageId());

    Assert.assertEquals(
        existingLayoutModelImpl.getGroupId(), existingLayoutModelImpl.getOriginalGroupId());
    Assert.assertEquals(
        existingLayoutModelImpl.getPrivateLayout(),
        existingLayoutModelImpl.getOriginalPrivateLayout());
    Assert.assertEquals(
        existingLayoutModelImpl.getLayoutId(), existingLayoutModelImpl.getOriginalLayoutId());

    Assert.assertEquals(
        existingLayoutModelImpl.getGroupId(), existingLayoutModelImpl.getOriginalGroupId());
    Assert.assertEquals(
        existingLayoutModelImpl.getPrivateLayout(),
        existingLayoutModelImpl.getOriginalPrivateLayout());
    Assert.assertTrue(
        Validator.equals(
            existingLayoutModelImpl.getFriendlyURL(),
            existingLayoutModelImpl.getOriginalFriendlyURL()));

    Assert.assertEquals(
        existingLayoutModelImpl.getGroupId(), existingLayoutModelImpl.getOriginalGroupId());
    Assert.assertEquals(
        existingLayoutModelImpl.getPrivateLayout(),
        existingLayoutModelImpl.getOriginalPrivateLayout());
    Assert.assertTrue(
        Validator.equals(
            existingLayoutModelImpl.getSourcePrototypeLayoutUuid(),
            existingLayoutModelImpl.getOriginalSourcePrototypeLayoutUuid()));
  }
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    JournalArticle newJournalArticle = addJournalArticle();

    _persistence.clearCache();

    JournalArticleModelImpl existingJournalArticleModelImpl =
        (JournalArticleModelImpl) _persistence.findByPrimaryKey(newJournalArticle.getPrimaryKey());

    assertTrue(
        Validator.equals(
            existingJournalArticleModelImpl.getUuid(),
            existingJournalArticleModelImpl.getOriginalUuid()));
    assertEquals(
        existingJournalArticleModelImpl.getGroupId(),
        existingJournalArticleModelImpl.getOriginalGroupId());

    assertEquals(
        existingJournalArticleModelImpl.getGroupId(),
        existingJournalArticleModelImpl.getOriginalGroupId());
    assertEquals(
        existingJournalArticleModelImpl.getClassNameId(),
        existingJournalArticleModelImpl.getOriginalClassNameId());
    assertEquals(
        existingJournalArticleModelImpl.getClassPK(),
        existingJournalArticleModelImpl.getOriginalClassPK());

    assertEquals(
        existingJournalArticleModelImpl.getGroupId(),
        existingJournalArticleModelImpl.getOriginalGroupId());
    assertEquals(
        existingJournalArticleModelImpl.getClassNameId(),
        existingJournalArticleModelImpl.getOriginalClassNameId());
    assertTrue(
        Validator.equals(
            existingJournalArticleModelImpl.getStructureId(),
            existingJournalArticleModelImpl.getOriginalStructureId()));

    assertEquals(
        existingJournalArticleModelImpl.getGroupId(),
        existingJournalArticleModelImpl.getOriginalGroupId());
    assertTrue(
        Validator.equals(
            existingJournalArticleModelImpl.getArticleId(),
            existingJournalArticleModelImpl.getOriginalArticleId()));
    assertEquals(
        existingJournalArticleModelImpl.getVersion(),
        existingJournalArticleModelImpl.getOriginalVersion());
  }
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    User newUser = addUser();

    _persistence.clearCache();

    UserModelImpl existingUserModelImpl =
        (UserModelImpl) _persistence.findByPrimaryKey(newUser.getPrimaryKey());

    assertEquals(
        existingUserModelImpl.getContactId(), existingUserModelImpl.getOriginalContactId());

    assertEquals(
        existingUserModelImpl.getPortraitId(), existingUserModelImpl.getOriginalPortraitId());

    assertEquals(
        existingUserModelImpl.getCompanyId(), existingUserModelImpl.getOriginalCompanyId());
    assertEquals(existingUserModelImpl.getUserId(), existingUserModelImpl.getOriginalUserId());

    assertEquals(
        existingUserModelImpl.getCompanyId(), existingUserModelImpl.getOriginalCompanyId());
    assertEquals(
        existingUserModelImpl.getDefaultUser(), existingUserModelImpl.getOriginalDefaultUser());

    assertEquals(
        existingUserModelImpl.getCompanyId(), existingUserModelImpl.getOriginalCompanyId());
    assertTrue(
        Validator.equals(
            existingUserModelImpl.getScreenName(), existingUserModelImpl.getOriginalScreenName()));

    assertEquals(
        existingUserModelImpl.getCompanyId(), existingUserModelImpl.getOriginalCompanyId());
    assertTrue(
        Validator.equals(
            existingUserModelImpl.getEmailAddress(),
            existingUserModelImpl.getOriginalEmailAddress()));

    assertEquals(
        existingUserModelImpl.getCompanyId(), existingUserModelImpl.getOriginalCompanyId());
    assertEquals(
        existingUserModelImpl.getFacebookId(), existingUserModelImpl.getOriginalFacebookId());

    assertEquals(
        existingUserModelImpl.getCompanyId(), existingUserModelImpl.getOriginalCompanyId());
    assertTrue(
        Validator.equals(
            existingUserModelImpl.getOpenId(), existingUserModelImpl.getOriginalOpenId()));
  }
  protected void validateTestSuiteDocument(String fileName, Element rootElement) {

    if (!Validator.equals(rootElement.getName(), "definition")) {
      throwValidationException(1000, fileName, rootElement);
    }

    List<Element> elements = rootElement.elements();

    if (elements.isEmpty()) {
      throwValidationException(1001, fileName, rootElement, new String[] {"execute"});
    }

    for (Element element : elements) {
      String elementName = element.getName();

      if (elementName.equals("execute")) {
        validateExecuteElement(
            fileName,
            element,
            new String[] {"test-case", "test-class", "test-suite"},
            ".+",
            new String[0]);
      } else {
        throwValidationException(1002, fileName, element, elementName);
      }
    }
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    VirtualHost newVirtualHost = addVirtualHost();

    _persistence.clearCache();

    VirtualHostModelImpl existingVirtualHostModelImpl =
        (VirtualHostModelImpl) _persistence.findByPrimaryKey(newVirtualHost.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingVirtualHostModelImpl.getHostname(),
            existingVirtualHostModelImpl.getOriginalHostname()));

    Assert.assertEquals(
        existingVirtualHostModelImpl.getCompanyId(),
        existingVirtualHostModelImpl.getOriginalCompanyId());
    Assert.assertEquals(
        existingVirtualHostModelImpl.getLayoutSetId(),
        existingVirtualHostModelImpl.getOriginalLayoutSetId());
  }
Beispiel #15
0
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    PollsVote newPollsVote = addPollsVote();

    _persistence.clearCache();

    PollsVoteModelImpl existingPollsVoteModelImpl =
        (PollsVoteModelImpl) _persistence.findByPrimaryKey(newPollsVote.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingPollsVoteModelImpl.getUuid(), existingPollsVoteModelImpl.getOriginalUuid()));
    Assert.assertEquals(
        existingPollsVoteModelImpl.getGroupId(), existingPollsVoteModelImpl.getOriginalGroupId());

    Assert.assertEquals(
        existingPollsVoteModelImpl.getQuestionId(),
        existingPollsVoteModelImpl.getOriginalQuestionId());
    Assert.assertEquals(
        existingPollsVoteModelImpl.getUserId(), existingPollsVoteModelImpl.getOriginalUserId());
  }
    @Override
    public boolean equals(Object obj) {
      PermissionKey permissionKey = (PermissionKey) obj;

      if ((permissionKey._userId == _userId)
          && (permissionKey._signedIn == _signedIn)
          && (permissionKey._groupId == _groupId)
          && Validator.equals(permissionKey._name, _name)
          && Validator.equals(permissionKey._primKey, _primKey)
          && Validator.equals(permissionKey._actionId, _actionId)) {

        return true;
      }

      return false;
    }
  @Test
  public void testResetOriginalValues() throws Exception {
    MBDiscussion newMBDiscussion = addMBDiscussion();

    _persistence.clearCache();

    MBDiscussion existingMBDiscussion =
        _persistence.findByPrimaryKey(newMBDiscussion.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingMBDiscussion.getUuid(),
            ReflectionTestUtil.invoke(existingMBDiscussion, "getOriginalUuid", new Class<?>[0])));
    Assert.assertEquals(
        Long.valueOf(existingMBDiscussion.getGroupId()),
        ReflectionTestUtil.<Long>invoke(
            existingMBDiscussion, "getOriginalGroupId", new Class<?>[0]));

    Assert.assertEquals(
        Long.valueOf(existingMBDiscussion.getThreadId()),
        ReflectionTestUtil.<Long>invoke(
            existingMBDiscussion, "getOriginalThreadId", new Class<?>[0]));

    Assert.assertEquals(
        Long.valueOf(existingMBDiscussion.getClassNameId()),
        ReflectionTestUtil.<Long>invoke(
            existingMBDiscussion, "getOriginalClassNameId", new Class<?>[0]));
    Assert.assertEquals(
        Long.valueOf(existingMBDiscussion.getClassPK()),
        ReflectionTestUtil.<Long>invoke(
            existingMBDiscussion, "getOriginalClassPK", new Class<?>[0]));
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    SocialActivitySetting newSocialActivitySetting = addSocialActivitySetting();

    _persistence.clearCache();

    SocialActivitySettingModelImpl existingSocialActivitySettingModelImpl =
        (SocialActivitySettingModelImpl)
            _persistence.findByPrimaryKey(newSocialActivitySetting.getPrimaryKey());

    Assert.assertEquals(
        existingSocialActivitySettingModelImpl.getGroupId(),
        existingSocialActivitySettingModelImpl.getOriginalGroupId());
    Assert.assertEquals(
        existingSocialActivitySettingModelImpl.getClassNameId(),
        existingSocialActivitySettingModelImpl.getOriginalClassNameId());
    Assert.assertEquals(
        existingSocialActivitySettingModelImpl.getActivityType(),
        existingSocialActivitySettingModelImpl.getOriginalActivityType());
    Assert.assertTrue(
        Validator.equals(
            existingSocialActivitySettingModelImpl.getName(),
            existingSocialActivitySettingModelImpl.getOriginalName()));
  }
  protected PortletURL getDynamicPortletURL(long plid, int status, HttpServletRequest request)
      throws Exception {

    String portletId = getPortletId(plid);

    PortletURL portletURL = getKBArticleURL(plid, portletId, null, request);

    if (status != WorkflowConstants.STATUS_APPROVED) {
      portletURL.setParameter("status", String.valueOf(status));
    }

    if (_PORTLET_ADD_DEFAULT_RESOURCE_CHECK_ENABLED) {
      String token = AuthTokenUtil.getToken(request, plid, portletId);

      portletURL.setParameter("p_p_auth", token);
    }

    portletURL.setPortletMode(PortletMode.VIEW);

    if (Validator.equals(portletId, PortletKeys.KNOWLEDGE_BASE_ARTICLE_DEFAULT_INSTANCE)) {

      portletURL.setWindowState(LiferayWindowState.MAXIMIZED);
    }

    return portletURL;
  }
  protected void setThemeSettingProperties(
      ActionRequest actionRequest,
      UnicodeProperties typeSettingsProperties,
      Map<String, ThemeSetting> themeSettings,
      String device,
      boolean isLayout)
      throws PortalException {

    Layout layout = null;

    if (isLayout) {
      long groupId = ParamUtil.getLong(actionRequest, "groupId");
      boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");
      long layoutId = ParamUtil.getLong(actionRequest, "layoutId");

      layout = layoutLocalService.getLayout(groupId, privateLayout, layoutId);
    }

    for (String key : themeSettings.keySet()) {
      ThemeSetting themeSetting = themeSettings.get(key);

      String property = device + "ThemeSettingsProperties--" + key + StringPool.DOUBLE_DASH;

      String value = ParamUtil.getString(actionRequest, property, themeSetting.getValue());

      if ((isLayout && !Validator.equals(value, layout.getDefaultThemeSetting(key, device, false)))
          || (!isLayout && !value.equals(themeSetting.getValue()))) {

        typeSettingsProperties.setProperty(ThemeSettingImpl.namespaceProperty(device, key), value);
      }
    }
  }
 /**
  * Returns <code>true</code> if this service context contains an update command (i.e. has command
  * value {@link com.liferay.portal.kernel.util.Constants#UPDATE})
  *
  * @return <code>true</code> if this service context contains an update command; <code>false
  *     </code> otherwise
  */
 public boolean isCommandUpdate() {
   if (Validator.equals(_command, Constants.UPDATE)) {
     return true;
   } else {
     return false;
   }
 }
  @Override
  public void render(RenderRequest renderRequest, RenderResponse renderResponse)
      throws IOException, PortletException {

    PortletURL portletURL = renderResponse.createRenderURL();

    portletURL.setParameter("mvcPath", "hello_soy_description");

    template.put("descriptionURL", portletURL.toString());

    String path = getPath(renderRequest, renderResponse);

    if (Validator.equals(path, "hello_soy_edit")) {
      portletURL.setParameter("mvcPath", "hello_soy_view");
    } else {
      portletURL.setParameter("mvcPath", "hello_soy_edit");
    }

    template.put("portletURL", portletURL.toString());

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

    User user = themeDisplay.getUser();

    template.put("userName", user.getFirstName());

    super.render(renderRequest, renderResponse);
  }
  protected void validateActionDocument(String fileName, Element rootElement) {

    if (!Validator.equals(rootElement.getName(), "definition")) {
      throwValidationException(1000, fileName, rootElement);
    }

    List<Element> elements = rootElement.elements();

    if (elements.isEmpty()) {
      throwValidationException(1001, fileName, rootElement, new String[] {"command"});
    }

    for (Element element : elements) {
      String elementName = element.getName();

      if (elementName.equals("command")) {
        String attributeValue = element.attributeValue("name");

        if (attributeValue == null) {
          throwValidationException(1003, fileName, element, "name");
        } else if (Validator.isNull(attributeValue)) {
          throwValidationException(1006, fileName, element, "name");
        }

        validateActionCommandElement(
            fileName, element, new String[] {"execute"}, new String[] {"function"}, new String[0]);
      } else {
        throwValidationException(1002, fileName, element, elementName);
      }
    }
  }
  public boolean isNavigationHome() {
    if (Validator.equals(getNavigation(), "all")) {
      return true;
    }

    return false;
  }
  public boolean isNavigationMine() {
    if (Validator.equals(getNavigation(), "mine")) {
      return true;
    }

    return false;
  }
  protected void validate() {
    try {
      Dictionary<String, Object> fileSystemDictionary =
          getConfigurationDictionary(FileSystemStoreConfiguration.class);

      Dictionary<String, Object> advancedFileSystemDictionary =
          getConfigurationDictionary(AdvancedFileSystemStoreConfiguration.class);

      if ((fileSystemDictionary != null) && (advancedFileSystemDictionary != null)) {

        String fileSystemRootDir = (String) fileSystemDictionary.get("rootdir");

        String advancedFileSystemRootDir = (String) advancedFileSystemDictionary.get("rootdir");

        if (Validator.equals(fileSystemRootDir, advancedFileSystemRootDir)) {

          throw new IllegalArgumentException(
              "File system root directory and advanced file "
                  + "system root directory are identical",
              new FileSystemStoreRootDirException());
        }
      }
    } catch (IOException ioe) {
      throw new IllegalArgumentException(ioe);
    }
  }
Beispiel #27
0
  public static boolean isViewableMessage(
      ThemeDisplay themeDisplay, MBMessage message, MBMessage parentMessage) throws Exception {

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!MBMessagePermission.contains(permissionChecker, parentMessage, ActionKeys.VIEW)) {

      return false;
    }

    if ((message.getMessageId() != parentMessage.getMessageId())
        && !MBMessagePermission.contains(permissionChecker, message, ActionKeys.VIEW)) {

      return false;
    }

    if (!message.isApproved()
        && !Validator.equals(message.getUserId(), themeDisplay.getUserId())
        && !permissionChecker.isGroupAdmin(themeDisplay.getScopeGroupId())) {

      return false;
    }

    return true;
  }
  public boolean isNavigationRecent() {
    if (Validator.equals(getNavigation(), "recent")) {
      return true;
    }

    return false;
  }
  public boolean isNavigationStructure() {
    if (Validator.equals(getNavigation(), "structure")) {
      return true;
    }

    return false;
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    PasswordPolicy newPasswordPolicy = addPasswordPolicy();

    _persistence.clearCache();

    PasswordPolicyModelImpl existingPasswordPolicyModelImpl =
        (PasswordPolicyModelImpl) _persistence.findByPrimaryKey(newPasswordPolicy.getPrimaryKey());

    Assert.assertEquals(
        existingPasswordPolicyModelImpl.getCompanyId(),
        existingPasswordPolicyModelImpl.getOriginalCompanyId());
    Assert.assertEquals(
        existingPasswordPolicyModelImpl.getDefaultPolicy(),
        existingPasswordPolicyModelImpl.getOriginalDefaultPolicy());

    Assert.assertEquals(
        existingPasswordPolicyModelImpl.getCompanyId(),
        existingPasswordPolicyModelImpl.getOriginalCompanyId());
    Assert.assertTrue(
        Validator.equals(
            existingPasswordPolicyModelImpl.getName(),
            existingPasswordPolicyModelImpl.getOriginalName()));
  }