Package org.waveprotocol.box.server.persistence

Examples of org.waveprotocol.box.server.persistence.PersistenceException


  public void removeAccount(ParticipantId id) throws PersistenceException {
    synchronized (accounts) {
      File file = new File(participantIdToFileName(id));
      if (file.exists()) {
        if (!file.delete()) {
          throw new PersistenceException("Failed to delete account data associated with "
              + id.getAddress());
        }
      }
      accounts.remove(id);
    }
View Full Code Here


      file = new FileInputStream(accountFile);
      ProtoAccountData data = ProtoAccountData.newBuilder().mergeFrom(file).build();
      return ProtoAccountDataSerializer.deserialize(data);
    } catch (IOException e) {
      LOG.severe("Failed to read account data from file: " + accountFile.getAbsolutePath(), e);
      throw new PersistenceException(e);
    } finally {
      FileUtils.closeAndIgnoreException(file, accountFile, LOG);
    }
  }
View Full Code Here

      ProtoAccountData data = ProtoAccountDataSerializer.serialize(account);
      file.write(data.toByteArray());
      file.flush();
    } catch (IOException e) {
      LOG.severe("Failed to write account data to file: " + accountFile.getAbsolutePath(), e);
      throw new PersistenceException(e);
    } finally {
      FileUtils.closeAndIgnoreException(file, accountFile, LOG);
    }
  }
View Full Code Here

        ImmutableList<WaveletDeltaRecord> deltas = readAll(deltasAccess, null);
        WaveletData snapshot = WaveletDataUtil.buildWaveletFromDeltas(deltasAccess.getWaveletName(),
            Iterators.transform(deltas.iterator(), TRANSFORMED));
        return new DeltaStoreBasedWaveletState(deltasAccess, deltas, snapshot, persistExecutor);
      } catch (IOException e) {
        throw new PersistenceException("Failed to read stored deltas", e);
      } catch (OperationException e) {
        throw new PersistenceException("Failed to compose stored deltas", e);
      }
    }
  }
View Full Code Here

          WaveletDataUtil.buildWaveletFromDeltas(reader.getWaveletName(),
              new TransformedWaveletDeltaIterator(reader));
      Preconditions.checkState(wavelet.getHashedVersion().equals(reader.getEndVersion()));
      return wavelet;
    } catch (OperationException e) {
      throw new PersistenceException(e);
    } catch (RuntimeIOException e) {
      throw new PersistenceException(e.getIOException());
    }
  }
View Full Code Here

      if (!index.delete()) {
        error += "Could not delete index file: " + index.getAbsolutePath();
      }
    }
    if (!error.isEmpty()) {
      throw new PersistenceException(error);
    }
  }
View Full Code Here

      // fsync() before returning.
      file.getChannel().force(true);
      endVersion = lastDelta.getTransformedDelta().getResultingVersion();
    } catch (IOException e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

          ByteStringMessage.parseProtocolAppliedWaveletDelta(ByteString.copyFrom((byte[]) dbObject
              .get(FIELD_APPLIED))),
          deserializeTransformedWaveletDelta((DBObject) dbObject.get(FIELD_TRANSFORMED)));

    } catch (InvalidProtocolBufferException e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

  private static DocOp deserializeDocOp(DBObject dbObject) throws PersistenceException {
    try {
      return CoreWaveletOperationSerializer.deserialize(ProtocolDocumentOperation
          .parseFrom(((byte[]) dbObject.get(FIELD_BYTES))));
    } catch (InvalidProtocolBufferException e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

    try {
      // Using Journaled Write Concern
      // (http://docs.mongodb.org/manual/core/write-concern/#journaled)
      getDeltaDbCollection().remove(criteria, WriteConcern.JOURNALED);
    } catch (MongoException e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.box.server.persistence.PersistenceException

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.