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

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

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

Item.getSession介绍

[英]Returns the Session through which this Item was acquired.
[中]返回获取此ItemSession

代码示例

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

public void execute() throws Exception {
    getDelegate().getSession().save();
  }
});

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

public Node getNode() throws ValueFormatException, RepositoryException {
  return origin.getSession().getNodeByUUID(getValue().getString());
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public boolean isSame(Item otherItem) throws RepositoryException {
  if (this == otherItem) {
    return true;
  }
  if (otherItem instanceof Node) {
    return this.getIdentifier().equals(((Node) otherItem).getIdentifier())
        && getSession().getWorkspace().getName().equals(
        otherItem.getSession().getWorkspace().getName());
  }
  return false;
}

代码示例来源:origin: org.fcrepo/modeshape-jcr

protected boolean isSameRepository( Item otherItem ) throws RepositoryException {
  assert getSession() != null;
  assert otherItem.getSession() != null;
  assert getSession().getRepository() != null;
  assert otherItem.getSession().getRepository() != null;
  if (getSession().getRepository() != otherItem.getSession().getRepository()) {
    return false;
  }
  return true;
}

代码示例来源:origin: ModeShape/modeshape

protected boolean isSameRepository( Item otherItem ) throws RepositoryException {
  assert getSession() != null;
  assert otherItem.getSession() != null;
  assert getSession().getRepository() != null;
  assert otherItem.getSession().getRepository() != null;
  if (getSession().getRepository() != otherItem.getSession().getRepository()) {
    return false;
  }
  return true;
}

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

/**
 *
 * @param item
 * @return
 */
private boolean isFilteredNamespace(Item item) {
  try {
    return isFilteredNamespace(item.getName(), item.getSession());
  } catch (RepositoryException e) {
    log.warn(e.getMessage());
  }
  return false;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.servlets.post

public void move(Object src, Object dstParent, String name)
throws PersistenceException {
  try {
    final Session session = ((Item)src).getSession();
    final Item source = ((Item)src);
    final String targetParentPath = ((Node)dstParent).getPath();
    final String targetPath = (targetParentPath.equals("/") ? "" : targetParentPath) + '/' + name;
    session.move(source.getPath(), targetPath);
  } catch ( final RepositoryException re) {
    throw new PersistenceException(re.getMessage(), re);
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public boolean execute(Context ctx) throws Exception {
  log.debug("Going to remove item [{}].", getPath());
  Item jcrItem = MgnlContext.getJCRSession(this.getRepository()).getItem(getPath());
  jcrItem.remove();
  jcrItem.getSession().save();
  return true;
}

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

public ConsoleFile getFile(String path, boolean mustExist)
    throws IOException {
  try {
    if (item.isNode()) {
      if (path.startsWith("/")) {
        return new RepositoryCFile(item.getSession().getItem(path));
      } else {
        return new RepositoryCFile(((Node) item).getNode(path));
      }
    } else {
      throw new ExecutionException("can't cd into property");
    }
  } catch (PathNotFoundException e) {
    throw new FileNotFoundException(path);
  } catch (RepositoryException e) {
    throw new IOException(e.toString());
  }
}

代码示例来源:origin: org.exoplatform.jcr/exo.jcr.component.core

try
 item.getSession().refresh(false);

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

try {
  Item item = context.getExportRoot();
  Repository rep = item.getSession().getRepository();
  String repName = rep.getDescriptor(Repository.REP_NAME_DESC);
  String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);

代码示例来源:origin: org.onehippo.cms7/jcrdiff-core

public void moveTo(TreeItem newParent) throws JcrDiffException {
  if (!(newParent instanceof JcrTreeNode)) {
    throw new IllegalArgumentException("newParent must be a JcrTreeNode");
  }
  JcrTreeItem jcrTreeNode = (JcrTreeItem) newParent;
  try {
    String name = jcrItem.getName();
    Session session = jcrItem.getSession();
    Node targetParent = (Node) jcrTreeNode.jcrItem;
    if (jcrItem instanceof Node) {
      session.move(jcrItem.getPath(), targetParent.getPath() + "/" + name);
      NodeIterator nodes = targetParent.getNodes(name);
      while (nodes.hasNext()) {
        jcrItem = nodes.nextNode();
      }
    } else {
      Property property = (Property) jcrItem;
      Property newProp;
      if (!property.isMultiple()) {
        newProp = targetParent.setProperty(property.getName(), property.getValue());
      } else {
        newProp = targetParent.setProperty(property.getName(), property.getValues(), property.getType());
      }
      property.remove();
      jcrItem = newProp;
    }
  } catch (RepositoryException e) {
    throw new JcrDiffException("Could not move item to new parent", e);
  }
}

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

try {
  Item item = context.getExportRoot();
  Repository rep = item.getSession().getRepository();
  String repName = rep.getDescriptor(Repository.REP_NAME_DESC);
  String repURL = rep.getDescriptor(Repository.REP_VENDOR_URL_DESC);

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

/**
 * @see Item#isSame(javax.jcr.Item)
 */
@Override
public boolean isSame(Item otherItem) throws RepositoryException {
  if (this == otherItem) {
    return true;
  }
  // The objects are either both Node objects or both Property objects.
  if (isNode() != otherItem.isNode()) {
    return false;
  }
  // Test if both items belong to the same repository
  // created by the same Repository object
  if (!getSession().getRepository().equals(otherItem.getSession().getRepository())) {
    return false;
  }
  // Both objects were acquired through Session objects bound to the same
  // repository workspace.
  if (!getSession().getWorkspace().getName().equals(otherItem.getSession().getWorkspace().getName())) {
    return false;
  }
  if (isNode()) {
    return ((Node) this).getIdentifier().equals(((Node) otherItem).getIdentifier());
  } else {
    return getName().equals(otherItem.getName()) && getParent().isSame(otherItem.getParent());
  }
}

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

/**
 * @see Item#isSame(javax.jcr.Item)
 */
@Override
public boolean isSame(Item otherItem) throws RepositoryException {
  if (this == otherItem) {
    return true;
  }
  // The objects are either both Node objects or both Property objects.
  if (isNode() != otherItem.isNode()) {
    return false;
  }
  // Test if both items belong to the same repository
  // created by the same Repository object
  if (!getSession().getRepository().equals(otherItem.getSession().getRepository())) {
    return false;
  }
  // Both objects were acquired through Session objects bound to the same
  // repository workspace.
  if (!getSession().getWorkspace().getName().equals(otherItem.getSession().getWorkspace().getName())) {
    return false;
  }
  if (isNode()) {
    return ((Node) this).getIdentifier().equals(((Node) otherItem).getIdentifier());
  } else {
    return getName().equals(otherItem.getName()) && getParent().isSame(otherItem.getParent());
  }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

/**
 * @see Item#isSame(javax.jcr.Item)
 */
@Override
public boolean isSame(Item otherItem) throws RepositoryException {
  if (this == otherItem) {
    return true;
  }
  // The objects are either both Node objects or both Property objects.
  if (isNode() != otherItem.isNode()) {
    return false;
  }
  // Test if both items belong to the same repository
  // created by the same Repository object
  if (!getSession().getRepository().equals(otherItem.getSession().getRepository())) {
    return false;
  }
  // Both objects were acquired through Session objects bound to the same
  // repository workspace.
  if (!getSession().getWorkspace().getName().equals(otherItem.getSession().getWorkspace().getName())) {
    return false;
  }
  if (isNode()) {
    return ((Node) this).getIdentifier().equals(((Node) otherItem).getIdentifier());
  } else {
    return getName().equals(otherItem.getName()) && getParent().isSame(otherItem.getParent());
  }
}

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

origin.getSession().move(origin.getPath(), (parent.origin.getPath().equals("/") ? "/"+name : parent.origin.getPath()+"/"+name));
  origin = null;
  for(NodeIterator findMoved = ((Node)parent.origin).getNodes(name); findMoved.hasNext(); ) {
NodeTypeManager ntMgr = origin.getSession().getWorkspace().getNodeTypeManager();
nodetypes.add(ntMgr.getNodeType(getInternalProperty("jcr:primaryType")[0]));
for(String mixin : newMixins) {
  parent.origin.getSession().move(parent.origin.getPath() + "/" + noSameNameSiblingWorkaround, parent.origin.getPath() + "/" + nodeName);

相关文章