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

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

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

Item.save介绍

[英]Validates all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subgraph rooted at this Item). If validation of all pending changes succeeds, then this change information is cleared from the Session. If the save occurs outside a transaction, the changes are persisted and thus made visible to other Sessions. If the save occurs within a transaction, the changes are not persisted until the transaction is committed.

If validation fails, then no pending changes are saved and they remain recorded on the Session. There is no best-effort or partial save.

The item in persistent storage to which a transient item is saved is
[中]验证当前在此Session中记录的、应用于此Item或其任何子体(即根于此项的子图)的所有挂起更改。如果所有挂起更改的验证成功,则此更改信息将从Session中清除。如果save发生在事务之外,则更改将被持久化,从而使其他Sessions可见。如果save发生在事务中,则在提交事务之前,不会保留更改。
如果验证失败,则不会保存任何挂起的更改,这些更改将保留在Session上。没有尽最大努力或部分节省。
永久存储器中保存临时项的项为

代码示例

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

/** {@inheritDoc} */
public void save() throws AccessDeniedException, ConstraintViolationException, InvalidItemStateException,
    ReferentialIntegrityException, VersionException, LockException, RepositoryException {
  item.save();
}

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

public void save() throws RepositoryException
{ this.item.save(); }

代码示例来源:origin: stackoverflow.com

public Item patch(Long id, JsonNode json) {

  //find the store item
  Item item = Item.find.byId(id);
  if(item == null) {
    return null;
  }

  //convert json to update item
  Item updateItem;
  updateItem = Json.fromJson(json, Item.class);

  if(updateItem.name != null){
    item.name = updateItem.name;
  }
  if(updateItem.price != null){
    item.price = updateItem.price;
  }
  item.save();

  return item;
}

代码示例来源:origin: stackoverflow.com

Item item = new Item();
item.category = restaurants;
item.name = "Outback Steakhouse";
item.save();

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

/** {@inheritDoc} */
public void save() throws RepositoryException, RemoteException {
  try {
    item.save();
  } catch (RepositoryException ex) {
    throw getRepositoryException(ex);
  }
}

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

/**
 * @see org.apache.jackrabbit.webdav.jcr.transaction.TxLockManagerImpl.Transaction#commit(TransactionResource) 
 */
public void commit(TransactionResource resource) throws DavException {
  try {
    getItem(resource).save();
  } catch (RepositoryException e) {
    throw new JcrDavException(e);
  }
}

代码示例来源:origin: org.exoplatform.jcr/exo.jcr.framework.command

public boolean execute(Context context) throws Exception
{
 Session session = ((JCRAppContext)context).getSession();
 String relPath = (String)context.get(pathKey);
 if (relPath == null)
   session.save();
 else
   ((Item)session.getItem(relPath)).save();
 return true;
}

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

/**
 * @deprecated
 */
@Deprecated
public void save() throws RepositoryException {
  getActionHandler().beforeItemSave(this);
  getDelegate().save();
  getActionHandler().afterItemSave(this);
}

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

context.getImportRoot().save();

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

/**
 * If this resource exists but does not contain a transaction id, complete
 * will try to persist any modifications present on the underlying
 * repository item.
 *
 * @throws DavException if calling {@link Item#save()} fails
 */
void complete() throws DavException {
  if (exists() && getTransactionId() == null) {
    try {
      if (item.isModified()) {
        item.save();
      }
    } catch (RepositoryException e) {
      // this includes LockException, ConstraintViolationException etc. not detected before
      log.error("Error while completing request: " + e.getMessage() +" -> reverting changes.");
      try {
        item.refresh(false);
      } catch (RepositoryException re) {
        log.error("Error while reverting changes: " + re.getMessage());
      }
      throw new JcrDavException(e);
    }
  }
}

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

/**
 * Adds version control to this resource. If the resource is already under
 * version control, this method has no effect.
 *
 * @throws org.apache.jackrabbit.webdav.DavException if this resource does not
 * exist yet or if an error occurs while making the underlying node versionable.
 * @see org.apache.jackrabbit.webdav.version.VersionableResource#addVersionControl()
 */
@Override
public void addVersionControl() throws DavException {
  if (!exists()) {
    throw new DavException(DavServletResponse.SC_NOT_FOUND);
  }
  if (!isVersionControlled()) {
    try {
      ((Node)item).addMixin(JcrConstants.MIX_VERSIONABLE);
      item.save();
    } catch (RepositoryException e) {
      throw new JcrDavException(e);
    }
  } // else: is already version controlled -> ignore
}

代码示例来源:origin: stackoverflow.com

List <Category> categories = new Select()
    .from(Category.class)
    .where("your where clause here")    // your where clause
    .execute();

if (categories != null && categories.size() > 0 ) {
   // data is inserted before 
} else {
   Category newCategory = new Category("category");
   newCategory.save();
} 

List <Item> items = new Select()
    .from(Item.class)
    .where("your where clause")
    .execute();

if (items != null && items.size() > 0 ) {
   // data is inserted before 
} else {
   Item item = new Item("item");
   item.save();
}

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

/**
 * A removed item must throw InvalidItemStateException upon any call to an
 * item specific method.
 */
public void testInvalidStateRemovedItem() throws RepositoryException {
  removeItem.remove();
  try {
    removeItem.getName();
    fail("Calling getName() on a removed node must throw InvalidItemStateException.");
  } catch (InvalidItemStateException e) {
    //ok
  }
  try {
    removeItem.getPath();
    fail("Calling getPath() on a removed node must throw InvalidItemStateException.");
  } catch (InvalidItemStateException e) {
    //ok
  }
  try {
    removeItem.save();
    fail("Calling save() on a removed node must throw InvalidItemStateException.");
  } catch (InvalidItemStateException e) {
    //ok
  }
}

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

/**
   * Same as {@link #testInvalidStateRemovedItem()} but calls save() before
   * executing the test.
   */
  public void testInvalidStateRemovedItem2() throws RepositoryException {
    removeItem.remove();
    testRootNode.save();
    try {
      removeItem.getName();
      fail("Calling getName() on a removed node must throw InvalidItemStateException.");
    } catch (InvalidItemStateException e) {
      //ok
    }

    try {
      removeItem.getPath();
      fail("Calling getPath() on a removed node must throw InvalidItemStateException.");
    } catch (InvalidItemStateException e) {
      //ok
    }

    try {
      removeItem.save();
      fail("Calling save() on a removed node must throw InvalidItemStateException.");
    } catch (InvalidItemStateException e) {
      //ok
    }
  }
}

相关文章