gpt4 book ai didi

xdi2.core.features.nodetypes.XdiCommonRoot类的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 10:25:05 24 4
gpt4 key购买 nike

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

XdiCommonRoot介绍

[英]An XDI common root, represented as a context node.
[中]XDI公共根,表示为上下文节点。

代码示例

代码示例来源:origin: projectdanube/xdi2

public static boolean ownsPeerRootXDIArc(Graph graph, XDIArc peerRootXDIArc) {
  XdiPeerRoot xdiPeerRoot = XdiCommonRoot.findCommonRoot(graph).getPeerRoot(peerRootXDIArc, false);
  if (xdiPeerRoot == null) return false;
  XdiRoot xdiRoot = xdiPeerRoot.dereference();
  return xdiRoot instanceof XdiCommonRoot;
}

代码示例来源:origin: projectdanube/xdi2

public static XDIArc getOwnerPeerRootXDIArc(Graph graph) {
  XdiPeerRoot selfPeerRoot = XdiCommonRoot.findCommonRoot(graph).getSelfPeerRoot();
  if (selfPeerRoot == null) return null;
  return selfPeerRoot.getXDIArc();
}

代码示例来源:origin: projectdanube/xdi2

public static void setOwnerXDIAddress(Graph graph, XDIAddress ownerXDIAddress) {
  XdiCommonRoot.findCommonRoot(graph).setSelfPeerRoot(ownerXDIAddress);
}

代码示例来源:origin: projectdanube/xdi2

public void testSelfPeerRoots() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();
    XdiCommonRoot.findCommonRoot(graph).setSelfPeerRoot(XDIAddress.create("=!1111"));

    XdiPeerRoot selfPeerRoot = XdiCommonRoot.findCommonRoot(graph).getSelfPeerRoot();

    assertEquals(selfPeerRoot.getContextNode().getXDIAddress(), XDIAddress.create("(=!1111)"));
    assertEquals(XdiCommonRoot.findCommonRoot(graph).getPeerRoot(XDIAddress.create("=!1111"), false), selfPeerRoot);
    assertTrue(selfPeerRoot.isSelfPeerRoot());

    graph.close();
  }
}

代码示例来源:origin: projectdanube/xdi2

@Override
public RSAPrivateKey getPrivateKey(XDIAddress signerXDIAddress) throws GeneralSecurityException {
  // signer address
  if (signerXDIAddress == null) {
    signerXDIAddress = GraphUtil.getOwnerXDIAddress(this.getPrivateKeyGraph());
  }
  // signer entity
  XdiEntity signerXdiEntity = XdiCommonRoot.findCommonRoot(this.getPrivateKeyGraph()).getXdiEntity(signerXDIAddress, false);
  signerXdiEntity = signerXdiEntity == null ? null : signerXdiEntity.dereference();
  if (log.isDebugEnabled()) log.debug("Signer entity: " + signerXdiEntity + " in graph " + GraphUtil.getOwnerPeerRootXDIArc(this.getPrivateKeyGraph()));
  if (signerXdiEntity == null) return null;
  // find private key
  RSAPrivateKey privateKey = rsaPrivateKeyFromPrivateKeyString(Keys.getSignaturePrivateKey(signerXdiEntity));
  // done
  return privateKey;
}

代码示例来源:origin: projectdanube/xdi2

XdiRoot xdiRoot = XdiCommonRoot.findCommonRoot(registryResultGraph).getPeerRoot(query, false);
if (xdiRoot == null) return;
XdiEntity authorityXdiEntity = XdiCommonRoot.findCommonRoot(registryResultGraph).getXdiEntity(this.cloudNumber.getXDIAddress(), false);

代码示例来源:origin: projectdanube/xdi2

XdiRoot xdiRoot = XdiCommonRoot.findCommonRoot(authorityResultGraph).getSelfPeerRoot();
if (xdiRoot == null) xdiRoot = XdiCommonRoot.findCommonRoot(authorityResultGraph);
if (xdiRoot == null) return;
XdiEntity authorityXdiEntity = XdiCommonRoot.findCommonRoot(authorityResultGraph).getXdiEntity(this.cloudNumber.getXDIAddress(), false);

代码示例来源:origin: projectdanube/xdi2

public void testSubGraph() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();
    XdiCommonRoot localRoot = XdiCommonRoot.findCommonRoot(graph);
    XdiPeerRoot peerRoot = localRoot.getPeerRoot(XDIAddress.create("=!:uuid:91f28153-f600-ae24-91f2-8153f600ae24"), true);
    XdiInnerRoot innerRoot = peerRoot.getInnerRoot(XDIAddress.create("=!1111"), XDIAddress.create("$add"), true);
    
    assertTrue(XdiAbstractContext.fromContextNode(localRoot.getContextNode()) instanceof XdiCommonRoot);
    assertTrue(XdiAbstractContext.fromContextNode(peerRoot.getContextNode()) instanceof XdiPeerRoot);
    assertTrue(XdiAbstractContext.fromContextNode(innerRoot.getContextNode()) instanceof XdiInnerRoot);
    
    graph.close();
  }
}

代码示例来源:origin: projectdanube/xdi2

public XdiPeerRoot setSelfPeerRoot(XDIAddress XDIaddress) {
  XdiPeerRoot selfPeerRoot = this.getSelfPeerRoot();
  if (selfPeerRoot != null) selfPeerRoot.getContextNode().delete();
  if (XDIaddress == null) return null;
  selfPeerRoot = this.getPeerRoot(XDIaddress, true);
  ContextNode commonRootContextNode = this.getContextNode();
  ContextNode selfPeerRootContextNode = selfPeerRoot.getContextNode();
  commonRootContextNode.delRelations(XDIDictionaryConstants.XDI_ADD_IS_REF);
  commonRootContextNode.setRelation(XDIDictionaryConstants.XDI_ADD_IS_REF, selfPeerRootContextNode);
  selfPeerRootContextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REF);
  selfPeerRootContextNode.setRelation(XDIDictionaryConstants.XDI_ADD_REF, commonRootContextNode);
  return selfPeerRoot;
}

代码示例来源:origin: projectdanube/xdi2

@Override
public XdiError getXdiError() {
  Graph resultGraph = this.getResultGraph();
  if (resultGraph == null) return null;
  return XdiError.findXdiError(XdiCommonRoot.findCommonRoot(resultGraph), false);
}

代码示例来源:origin: projectdanube/xdi2

@Override
public XdiRoot findRoot() {
  return XdiCommonRoot.findCommonRoot(this.getGraph()).getRoot(this.getContextNode().getXDIAddress(), false);
}

代码示例来源:origin: projectdanube/xdi2

@Override
public Iterator<XDIArc> getOwnerPeerRootXDIArcs() {
  Iterator<XdiPeerRoot> ownerPeerRoots = XdiCommonRoot.findCommonRoot(this.getRegistryGraph()).getPeerRoots();
  return new SelectingMappingIterator<XdiPeerRoot, XDIArc> (ownerPeerRoots) {
    @Override
    public boolean select(XdiPeerRoot ownerPeerRoot) {
      if (ownerPeerRoot.isSelfPeerRoot()) return false;
      if (ownerPeerRoot.dereference() != ownerPeerRoot) return false;
      return true;
    }
    @Override
    public XDIArc map(XdiPeerRoot ownerPeerRoot) {
      return ownerPeerRoot.getXDIArc();
    }
  };
}

代码示例来源:origin: projectdanube/xdi2

public void testCommonRoot() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();

    assertEquals(XdiCommonRoot.findCommonRoot(graph).getContextNode(), graph.getRootContextNode());
    assertEquals(XdiCommonRoot.findCommonRoot(graph).getContextNode().getXDIAddress(), XDIConstants.XDI_ADD_ROOT);

    graph.close();
  }
}

代码示例来源:origin: projectdanube/xdi2

assertEquals(graph30.getRootContextNode().getAllStatementCount(), 0);
XdiCommonRoot.findCommonRoot(graph30).getInnerRoot(XDIAddress.create("=a=b=c"), XDIAddress.create("+d"), true);

代码示例来源:origin: projectdanube/xdi2

/**
 * Checks if this XDI peer root is the self XDI peer root of the graph.
 * @return True, if this is the self XDI peer root.
 */
public boolean isSelfPeerRoot() {
  XdiPeerRoot selfPeerRoot = this.findCommonRoot().getSelfPeerRoot();
  if (this.equals(selfPeerRoot)) return true;
  ContextNode refContextNode = Equivalence.getReferenceContextNode(this.getContextNode());
  XdiPeerRoot refPeerRoot = refContextNode == null ? null : XdiPeerRoot.fromContextNode(refContextNode);
  if (refPeerRoot != null && refPeerRoot.equals(selfPeerRoot)) return true;
  ContextNode repContextNode = Equivalence.getReplacementContextNode(this.getContextNode());
  XdiPeerRoot repPeerRoot = repContextNode == null ? null : XdiPeerRoot.fromContextNode(repContextNode);
  if (repPeerRoot != null && repPeerRoot.equals(selfPeerRoot)) return true;
  return false;
}

代码示例来源:origin: projectdanube/xdi2

public XdiPeerRoot getSelfPeerRoot() {

    Relation relation = this.getContextNode().getRelation(XDIDictionaryConstants.XDI_ADD_IS_REF);
    if (relation == null) return null;

    ContextNode targetContextNode = relation.followContextNode();
    if (targetContextNode == null) return null;

    return XdiPeerRoot.fromContextNode(targetContextNode);
  }
}

代码示例来源:origin: projectdanube/xdi2

if (XdiCommonRoot.findCommonRoot(graph).getSelfPeerRoot() != null) return;
  bootstrapOwnerSelfPeerRootContextNode = XdiCommonRoot.findCommonRoot(graph).setSelfPeerRoot(this.getBootstrapOwner()).getContextNode();
      Equivalence.setReferenceContextNode(bootstrapOwnerSynonymContextNode, bootstrapOwnerContextNode, true);
      ContextNode bootstrapOwnerSynonymPeerRootContextNode = XdiCommonRoot.findCommonRoot(graph).getPeerRoot(bootstrapOwnerSynonym, true).getContextNode();
      Equivalence.setReferenceContextNode(bootstrapOwnerSynonymPeerRootContextNode, bootstrapOwnerSelfPeerRootContextNode, false);
  Timestamps.setTimestamp(XdiCommonRoot.findCommonRoot(graph), XDITimestampsConstants.XDI_ADD_AS_CREATION, new Date());

代码示例来源:origin: projectdanube/xdi2

@Override
public RSAPublicKey getPublicKey(XDIAddress signerXDIAddress) throws GeneralSecurityException {
  // signer address
  if (signerXDIAddress == null) {
    signerXDIAddress = GraphUtil.getOwnerXDIAddress(this.getPublicKeyGraph());
  }
  // signer entity
  XdiEntity signerXdiEntity = XdiCommonRoot.findCommonRoot(this.getPublicKeyGraph()).getXdiEntity(signerXDIAddress, false);
  signerXdiEntity = signerXdiEntity == null ? null : signerXdiEntity.dereference();
  if (log.isDebugEnabled()) log.debug("Signer entity: " + signerXdiEntity + " in graph " + GraphUtil.getOwnerPeerRootXDIArc(this.getPublicKeyGraph()));
  if (signerXdiEntity == null) return null;
  // find public key
  RSAPublicKey publicKey = rsaPublicKeyFromPublicKeyString(Keys.getSignaturePublicKey(signerXdiEntity));
  // done
  return publicKey;
}

代码示例来源:origin: projectdanube/xdi2

private void read(Graph graph, BufferedReader bufferedReader, State state) throws IOException, Xdi2ParseException {
  JsonElement jsonGraphElement = gson.getAdapter(JsonObject.class).fromJson(bufferedReader);
  if (! (jsonGraphElement instanceof JsonObject)) throw new Xdi2ParseException("JSON must be an object: " + jsonGraphElement);
  this.read(XdiCommonRoot.findCommonRoot(graph), (JsonObject) jsonGraphElement, state);
}

代码示例来源:origin: projectdanube/xdi2

XdiRoot relationContextNodeXdiRoot = XdiCommonRoot.findCommonRoot(copyRelation.getContextNode().getGraph()).getRoot(relationContextNodeXDIAddress, false);
XdiRoot targetContextNodeXdiRoot = XdiCommonRoot.findCommonRoot(targetContextNode.getGraph()).getRoot(targetXDIAddress, false);

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com