Exemplo n.º 1
0
  public boolean getRelation(
      XRI3Segment[] contributorXris,
      XRI3Segment relativeContextNodeXri,
      XRI3Segment arcXri,
      XRI3Segment targetContextNodeXri,
      XRI3Segment contextNodeXri,
      GetOperation operation,
      MessageResult messageResult,
      ExecutionContext executionContext)
      throws Xdi2MessagingException {

    MessageResult tempMessageResult = new MessageResult();

    this.getContext(
        contributorXris,
        relativeContextNodeXri,
        contextNodeXri,
        operation,
        tempMessageResult,
        executionContext);

    ContextNode tempContextNode =
        tempMessageResult.getGraph().findContextNode(contextNodeXri, false);
    if (tempContextNode == null) return false;

    if (Variables.isVariableSingle(targetContextNodeXri)) {

      Iterator<Relation> relations;

      if (Variables.isVariableSingle(arcXri)) {

        relations = tempContextNode.getRelations();
      } else {

        relations = tempContextNode.getRelations(arcXri);
      }

      while (relations.hasNext())
        CopyUtil.copyRelation(relations.next(), messageResult.getGraph(), null);
    } else {

      Relation relation = tempContextNode.getRelation(arcXri, targetContextNodeXri);
      if (relation == null) return false;

      CopyUtil.copyRelation(relation, messageResult.getGraph(), null);
    }

    return false;
  }
Exemplo n.º 2
0
  public boolean getLiteral(
      XRI3Segment[] contributorXris,
      XRI3Segment relativeContextNodeXri,
      XRI3Segment contextNodeXri,
      String literalData,
      GetOperation operation,
      MessageResult messageResult,
      ExecutionContext executionContext)
      throws Xdi2MessagingException {

    MessageResult tempMessageResult = new MessageResult();

    this.getContext(
        contributorXris,
        relativeContextNodeXri,
        contextNodeXri,
        operation,
        tempMessageResult,
        executionContext);

    ContextNode tempContextNode =
        tempMessageResult.getGraph().findContextNode(contextNodeXri, false);
    if (tempContextNode == null) return false;

    Literal tempLiteral = tempContextNode.getLiteral();
    if (tempLiteral == null) return false;

    if (literalData.isEmpty() || literalData.equals(tempLiteral.getLiteralData())) {

      CopyUtil.copyLiteral(tempLiteral, messageResult.getGraph(), null);
    }

    return false;
  }
Exemplo n.º 3
0
  @Override
  public void execute(
      MessageEnvelope messageEnvelope,
      ExecutionContext executionContext,
      ExecutionResult executionResult)
      throws Xdi2MessagingException {

    for (Operation operation : messageEnvelope.getOperations()) {

      Graph operationResultGraph = executionResult.createOperationResultGraph(operation);

      CopyUtil.copyContextNode(operation.getMessage().getContextNode(), operationResultGraph, null);
    }

    executionResult.finish();
  }