Package com.google.nigori.common

Examples of com.google.nigori.common.Revision


      return null;
    }
    Collection<Node<Revision>> heads = history.getHeads();
    List<RevValue> answer = new ArrayList<RevValue>();
    for (Node<Revision> rev : heads) {
      Revision revision = rev.getValue();
      byte[] value = getRevision(index, revision);
      // TODO(drt24) value might be null
      if (value != null) {
        answer.add(new RevValue(revision, value));
      }
View Full Code Here


  @Override
  public RevValue put(Index index, byte[] value, RevValue... parents) throws IOException,
      NigoriCryptographyException, UnauthorisedException {
    byte[] revBytes = generateHash(value, toIDByte(parents));
    Revision rev = new Revision(revBytes);
    RevValue rv = new RevValue(rev, value);
    boolean success = store.put(index, rev, value);
    if (!success) {
      throw new IOException("Could not put into the store");
    }
View Full Code Here

        return null;
      }
      List<ByteString> revisions = getResponse.getRevisionsList();
      List<Revision> answer = new ArrayList<Revision>(revisions.size());
      for (ByteString revision : revisions) {
        answer.add(new Revision(keyManager.decrypt(revision.toByteArray())));
      }
      return answer;

    } catch (NotFoundException e) {
      return null;
View Full Code Here

        assertTrue("Not registered" + i, nigori.register());
        assertTrue("Not a clean store " + i, nigori.getIndices().isEmpty());

        for (IndexValue iv : testCases) {// once round for each
          final Index index = iv.index;
          final Revision revision = iv.revvalue.getRevision();
          final byte[] value = iv.revvalue.getValue();

          assertTrue("Not put " + i, nigori.put(index, revision, value));
          List<RevValue> revs = nigori.get(index);
          assertFalse("Revisions must exist" + i, revs.isEmpty());
          assertThat(revs, hasItem(iv.revvalue));
          assertEquals("Not one revision " + i, 1, revs.size());
          assertTrue("Not deleted" + i, nigori.delete(index, NULL_DELETE_TOKEN));
          assertNull("Not deleted" + i, nigori.get(index));
          assertFalse("Could redelete", nigori.delete(index, NULL_DELETE_TOKEN));
        }
        // allow them to accumulate
        for (IndexValue iv : testCases) {
          final Index index = iv.index;
          final byte[] value = iv.revvalue.getValue();
          final Revision revision = iv.revvalue.getRevision();
          assertTrue("Not put" + i, nigori.put(index, revision, value));
        }
        try {
          for (IndexValue iv : testCases) {
            final Index index = iv.index;
            final byte[] value = iv.revvalue.getValue();
            final Revision revision = iv.revvalue.getRevision();
            assertArrayEquals("Got different" + i, value, nigori.getRevision(index, revision));
          }
        } finally {
          for (IndexValue iv : testCases) {
            final Index index = iv.index;
View Full Code Here

  public void getRevisions() throws IOException, NigoriCryptographyException, UnauthorisedException {
    NigoriDatastore nigori = getStore();
    try {
      assertTrue("Not registered", nigori.register());
      final Index index = new Index("index");
      final Revision a = new Revision("a");
      final Revision b = new Revision("b");
      assertTrue("Not put", nigori.put(index, a, toBytes("aa")));
      assertTrue("Not put", nigori.put(index, b, toBytes("bb")));
      try {
        List<Revision> revisions = nigori.getRevisions(index);
        assertNotNull("No revisions", revisions);
View Full Code Here

    NigoriDatastore nigori = getStore();
    try {
      assertTrue("Not registered", nigori.register());
      final Index indexa = new Index("indexa");
      final Index indexb = new Index("indexb");
      final Revision revision = new Revision("a");
      assertTrue("Not put", nigori.put(indexa, revision, toBytes("aa")));
      assertTrue("Not put", nigori.put(indexb, revision, toBytes("bb")));
      try {
        List<Index> indices = nigori.getIndices();
        assertNotNull("No indices", indices);
View Full Code Here

      UnauthorisedException {
    NigoriDatastore nigori = getStore();
    try {
      assertTrue("Not registered", nigori.register());
      final Index index = new Index("index");
      final Revision revision = new Revision("rev");
      assertTrue("Not put", nigori.put(index, revision, Util.int2bin(0)));
      assertFalse("Could replace revision value", nigori.put(index, revision, Util.int2bin(1)));
      nigori.delete(index, NULL_DELETE_TOKEN);
    } finally {
      assertTrue("Not unregistered", nigori.unregister());
View Full Code Here

              assertTrue("Not registered" + i, nigori.register());
              try {
                for (IndexValue iv : SetGetDeleteTest.testCases) {// once round for each
                  final Index index = iv.index;
                  final byte[] value = iv.revvalue.getValue();
                  final Revision revision = iv.revvalue.getRevision();
                  assertTrue("Not put" + i, nigori.put(index, revision, value));
                  assertArrayEquals("Got different" + i, value, nigori.getRevision(index, revision));
                  assertTrue("Not deleted " + i, nigori.delete(index, NULL_DELETE_TOKEN));
                  assertNull("Still there after deletion " + i, nigori.get(index));
                }
View Full Code Here

                // check we can do this more than once
                for (IndexValue iv : SetGetDeleteTest.testCases) {// once round for each
                  final Index index = new Index(new byte[16]);
                  r.nextBytes(index.getBytes());// need to generate some different indices
                  final byte[] value = iv.revvalue.getValue();
                  final Revision revision = iv.revvalue.getRevision();
                  assertTrue("Not put" + i, nigori.put(index, revision, value));
                  try {
                    assertArrayEquals("Got different" + i, value, nigori.getRevision(index,
                        revision));
                  } finally {
View Full Code Here

TOP

Related Classes of com.google.nigori.common.Revision

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.