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

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

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

Item.refresh介绍

[英]If keepChanges is false, this method discards 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)and returns all items to reflect the current saved state. Outside a transaction this state is simple the current state of persistent storage. Within a transaction, this state will reflect persistent storage as modified by changes that have been saved but not yet committed.

If keepChanges is true then pending change are not discarded but items that do not have changes pending have their state refreshed to reflect the current saved state, thus revealing changes made by other sessions.
[中]如果keepChangesfalse,则此方法将放弃当前在此Session中记录的所有应用于此项或其任何子项(即,根在此项上的子图)的挂起更改,并返回所有项以反映当前保存的状态。在事务外部,该状态是持久存储的当前状态。在事务中,此状态将反映已保存但尚未提交的更改所修改的持久存储。
如果keepChanges为true,则不会放弃挂起的更改,但是没有挂起更改的项目会刷新其状态以反映当前保存的状态,从而显示其他会话所做的更改。

代码示例

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

/** {@inheritDoc} */
public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException {
  item.refresh(keepChanges);
}

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

public void refresh(boolean b) throws RepositoryException
  { this.item.refresh(b); }
}

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

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

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

public void execute() throws Exception {
    getDelegate().refresh(keepChanges);
  }
});

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

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

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

public Long call() throws Exception {
  if (items.isEmpty()) {
    return 0L;
  }
  Item item = items.get(rnd.nextInt(items.size()));
  long t1 = System.currentTimeMillis();
  item.refresh(rnd.nextBoolean());
  long t2 = System.currentTimeMillis();
  return t2 - t1;
}

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

public void refresh(boolean keepChanges) throws RepositoryException {
  getActionHandler().beforeItemRefresh(this, keepChanges);
  getDelegate().refresh(keepChanges);
  getActionHandler().afterItemRefresh(this, keepChanges);
}

代码示例来源: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

/**
 * @see IOHandler#importContent(ImportContext, boolean)
 */
public boolean importContent(ImportContext context, boolean isCollection) throws IOException {
  if (!canImport(context, isCollection)) {
    throw new IOException(getName() + ": Cannot import " + context.getSystemId());
  }
  boolean success = false;
  try {
    Node contentNode = getContentNode(context, isCollection);
    success = importData(context, isCollection, contentNode);
    if (success) {
      success = importProperties(context, isCollection, contentNode);
    }
  } catch (RepositoryException e) {
    success = false;
    throw new IOException(e.getMessage());
  } finally {
    // revert any changes made in case the import failed.
    if (!success) {
      try {
        context.getImportRoot().refresh(false);
      } catch (RepositoryException e) {
        throw new IOException(e.getMessage());
      }
    }
  }
  return success;
}

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

public void testNodeIsModifiedAfterRemovePolicy() throws RepositoryException, AccessDeniedException, NotExecutableException {
  checkCanReadAc(path);
  checkCanModifyAc(path);
  Item item = superuser.getItem(path);
  if (acMgr.getPolicies(path).length == 0) {
    // no policy to remove ->> apply one
    AccessControlPolicyIterator it = acMgr.getApplicablePolicies(path);
    if (it.hasNext()) {
      AccessControlPolicy policy = it.nextAccessControlPolicy();
      acMgr.setPolicy(path, policy);
      superuser.save();
      // remember for teardown
      addedPolicies.put(path, policy);
    } else {
      throw new NotExecutableException();
    }
  }
  // test transient behaviour of the removal
  try {
    AccessControlPolicy[] plcs = acMgr.getPolicies(path);
    if (plcs.length > 0) {
      acMgr.removePolicy(path, plcs[0]);
      assertTrue("After removing a policy the node must be marked modified.", item.isModified());
    }
  } finally {
    item.refresh(false);
  }
}

相关文章