Пример #1
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;
  }
  public static void storeAccessToken(Graph graph, XDI3Segment userXri, String accessToken) {

    XDI3Segment contextNodeXri =
        new XDI3Segment(
            ""
                + GoogleCalendarMapping.XRI_S_GOOGLE_CALENDAR_CONTEXT
                + userXri
                + XDIMessagingConstants.XRI_S_OAUTH_TOKEN);

    ContextNode contextNode = graph.findContextNode(contextNodeXri, true);

    if (contextNode.containsLiteral()) contextNode.getLiteral().setLiteralData(accessToken);
    else contextNode.createLiteral(accessToken);
  }
  public static String retrieveAccessToken(Graph graph, XDI3Segment userXri) {

    XDI3Segment contextNodeXri =
        new XDI3Segment(
            ""
                + GoogleCalendarMapping.XRI_S_GOOGLE_CALENDAR_CONTEXT
                + userXri
                + XDIMessagingConstants.XRI_S_OAUTH_TOKEN);

    ContextNode contextNode = graph.findContextNode(contextNodeXri, false);
    if (contextNode == null) return null;

    Literal literal = contextNode.getLiteral();
    if (literal == null) return null;

    return literal.getLiteralData();
  }