javax.jcr.Item.isNew()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中javax.jcr.Item.isNew()方法的一些代码示例,展示了Item.isNew()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Item.isNew()方法的具体详情如下:
包路径:javax.jcr.Item
类名称:Item
方法名:isNew

Item.isNew介绍

[英]Returns true if this is a new item, meaning that it exists only in transient storage on the Session and has not yet been saved. Within a transaction, isNew on an Item may return false (because the item has been saved) even if that Item is not in persistent storage (because the transaction has not yet been committed).

Note that if an item returns true on isNew, then by definition is parent will return true on isModified.

Note that in read-only implementations, this method will always return false.
[中]如果这是一个新项目,则返回true,这意味着它仅存在于Session上的临时存储中,尚未保存。在事务中,Item上的isNew可能返回false(因为项目已保存),即使Item未在持久存储中(因为事务尚未提交)。
请注意,如果项目在isNew上返回true,则根据定义,父项将在isModified上返回true
请注意,在只读实现中,此方法将始终返回false

代码示例

代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector

/** {@inheritDoc} */
public boolean isNew() {
  return item.isNew();
}

代码示例来源:origin: apache/jackrabbit

/** {@inheritDoc} */
public boolean isNew() throws RemoteException {
  return item.isNew();
}

代码示例来源:origin: net.adamcin.oakpal/oakpal-core

@Override
public boolean isNew() {
  return delegate.isNew();
}

代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr

public boolean isNew()
{ return this.item.isNew(); }

代码示例来源:origin: brix-cms/brix-cms

public boolean isNew() {
  return getDelegate().isNew();
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test if Item.isNew() returns true directly after a new NodeItem is added
 * (before node is saved (transient)).
 *
 * @see javax.jcr.Item#isNew()
 */
public void testTransientNodeItemIsNew () throws RepositoryException {
  Node testNode = testRootNode.addNode(nodeName1, testNodeType);
  Item testNodeItem = superuser.getItem(testNode.getPath());
  // check testNodeItem is new before save
  assertTrue("Item.isNew() must return true directly after a new NodeItem is added (before save of the parent node)", testNodeItem.isNew());
}

代码示例来源:origin: brix-cms/brix-cms

public boolean isNew() {
  return getDelegate().isNew();
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test if Item.isNew() returns false after a NodeItem is added and
 * the node is saved (persistent).
 *
 * @see javax.jcr.Item#isNew()
 */
public void testPersistentNodeItemIsNew () throws RepositoryException {
  Node testNode = testRootNode.addNode(nodeName1, testNodeType);
  testRootNode.getSession().save();
  Item testNodeItem = superuser.getItem(testNode.getPath());
  // check testNodeItem is new after save
  assertFalse("Item.isNew() must return false after a new NodeItem is added and the parent Node is saved", testNodeItem.isNew());
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test if Item.isNew() returns true direct after a new PropertyItem is set
 * (before node is saved (transient)).
 *
 * @see javax.jcr.Item#isNew()
 */
public void testTransientPropertyItemIsNew () throws RepositoryException {
  Property testProperty = testNode.setProperty(propertyName1, "test");
  Item testPropertyItem = superuser.getItem(testProperty.getPath());
  // check testPropertyItem.isNew() before save
  assertTrue("Item.isNew() must return true directly after a new Property is set (before current node is saved)", testPropertyItem.isNew());
}

代码示例来源:origin: apache/jackrabbit

builder.append("Property: ");
if (item.isNew()) {
  builder.append("new ");
} else if (item.isModified()) {

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr2spi

builder.append("Property: ");
if (item.isNew()) {
  builder.append("new ");
} else if (item.isModified()) {

代码示例来源:origin: apache/jackrabbit

/**
 * Test if Item.isNew() returns false after a new PropertyItem is set and
 * the node is saved (persistent).
 * This is equivalent to the test if Item.isNew() returns false for an
 * already exixting and not modified PropertyItem.
 *
 * @see javax.jcr.Item#isNew()
 */
public void testPersistentPropertyItemIsNew () throws RepositoryException {
  Property testProperty = testNode.setProperty(propertyName1, "test");
  testNode.save();
  Item testPropertyItem = superuser.getItem(testProperty.getPath());
  // check testPropertyItem.isNew() after save
  assertFalse("Item.isNew() must return false after a new PropertyItem is set and the current Node is saved", testPropertyItem.isNew());
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test if a node, that has been transiently removed is not 'New'.
 */
public void testNotNewRemovedItem() throws RepositoryException {
  removeItem.remove();
  assertFalse("Transiently removed node must not be 'new'.", removeItem.isNew());
}

代码示例来源:origin: apache/jackrabbit

/**
 * Same as {@link #testNotNewRemovedItem()} but calls save() before
 * executing the test.
 */
public void testNotNewRemovedItem2() throws RepositoryException {
  removeItem.remove();
  testRootNode.save();
  assertFalse("Removed node must not be 'new'.", removeItem.isNew());
}

代码示例来源:origin: apache/jackrabbit

public void testRefreshMovedTree() throws RepositoryException {
    testRootNode.refresh(true);
    String msg = "Refresh must not revert a moved tree.";

    assertFalse(msg, superuser.itemExists(srcPath + "/" + nodeName2 + "/" + nodeName3));
    int degree = destParentNode.getDepth();

    List<Item> l = new ArrayList<Item>();
    l.add(childNode);
    l.add(childProperty);
    l.add(grandChildNode);

    for (Iterator<Item> it = l.iterator(); it.hasNext();) {
      Item item = it.next();
      assertTrue(msg, item.isNew());
      assertTrue(msg, childNode.getAncestor(degree).isSame(destParentNode));
    }
  }
}

代码示例来源:origin: apache/jackrabbit

@Override
protected void initPropertyNames() {
  super.initPropertyNames();
  if (exists()) {
    names.addAll(JcrDavPropertyNameSet.EXISTING_ITEM_BASE_SET);
    try {
      if (item.getDepth() > 0) {
        names.add(JCR_PARENT);
      }
    } catch (RepositoryException e) {
      log.warn("Error while accessing node depth: " + e.getMessage());
    }
    if (item.isNew()) {
      names.add(JCR_ISNEW);
    } else if (item.isModified()) {
      names.add(JCR_ISMODIFIED);
    }
  } else {
    names.addAll(JcrDavPropertyNameSet.ITEM_BASE_SET);
  }
}

代码示例来源:origin: apache/jackrabbit

public void testSystemUsersAreSaved() throws Exception {
  String adminId = ((UserPerWorkspaceSecurityManager) secMgr).adminId;
  UserManager umgr = ((JackrabbitSession) superuser).getUserManager();
  Principal p = umgr.getAuthorizable(adminId).getPrincipal();
  if (p instanceof ItemBasedPrincipal) {
    Item item = superuser.getItem(((ItemBasedPrincipal) p).getPath());
    assertFalse(item.isNew());
    assertFalse(item.isModified());
  }
}

代码示例来源:origin: apache/jackrabbit

if (exists() && item.isNew()) {
  prop = new DefaultDavProperty<String>(JCR_ISNEW, null, true);

代码示例来源:origin: org.chromattic/chromattic.core

assertTrue(virtualRoot.isNew());
assertFalse(virtualRoot.isNew());

代码示例来源:origin: org.chromattic/chromattic.core

public void testRootNodeLifeCycle() throws Exception {
  // First check it does not exist
  ChromatticSession session = login();
  Session jcrSession = session.getJCRSession();
  String path = getRootNodePath();
  assertFalse(jcrSession.itemExists(path));

  // Perform an operation
  session.insert(A.class, "a");

  // It should exist and be saved
  assertTrue(jcrSession.itemExists(path));
  Item virtualRoot = jcrSession.getItem(path);
  assertFalse(virtualRoot.isNew());

  // Save and close
  session.save();
  session.close();

  // Check it exists
  session = login();
  jcrSession = session.getJCRSession();
  assertTrue(jcrSession.itemExists(path));
  session.close();
 }
}

相关文章