Package org.waveprotocol.box.server.persistence

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


    DBCursor cursor = null;

    try {
      cursor = getDeltaDbCollection().find(query, projection);
    } catch (MongoException e) {
      throw new PersistenceException(e);
    }


    if (cursor == null || !cursor.hasNext()) {
      return ImmutableSet.of();
View Full Code Here


      for (Object o : results)
        builder.add(WaveId.deserialise((String) o));

    } catch (MongoException e) {
      throw new PersistenceException(e);
    }


    return ExceptionalIterator.FromIterator.create(builder.build().iterator());
  }
View Full Code Here

  @Override
  public FileDeltaCollection open(WaveletName waveletName) throws PersistenceException {
    try {
      return FileDeltaCollection.open(waveletName, basePath);
    } catch (IOException e) {
      throw new PersistenceException("Failed to open deltas for wavelet " + waveletName, e);
    }
  }
View Full Code Here

        return name.endsWith(extension);
      }
    });

    if (files == null) {
      throw new PersistenceException(String.format(
          "Configured %s directory (%s) does not appear to be readable!", dirType, dir));
    }

    /*
     * If file list isn't empty, try opening the first file in the list to make sure it
     * is readable. If the first file is readable, then it is likely that the rest will
     * be readable as well.
     */
    if (files.length > 0) {
      try {
        FileInputStream file = new FileInputStream(files[0]);
        file.read();
      } catch (IOException e) {
        throw new PersistenceException(
            String.format(
              "Failed to read '%s' in configured %s directory '%s'. "
              + "The directory's contents do not appear to be readable.",
              dirType, files[0].getName(), dir),
            e);
      }
    }

    // Make sure the dir is writable.
    try {
      File tmp = File.createTempFile("tempInitialization", ".temp", baseDir);
      FileOutputStream stream = new FileOutputStream(tmp);
      stream.write(new byte[]{'H','e','l','l','o'});
      stream.close();
      tmp.delete();
    } catch (IOException e) {
      throw new PersistenceException(String.format(
          "Configured %s directory (%s) does not appear to be writable!", dirType, dir), e);
    }
  }
View Full Code Here

    // Make sure the dir exists.
    if (!baseDir.exists()) {
      // It doesn't so try and create it.
      if (!baseDir.mkdirs()) {
        throw new PersistenceException(String.format(
            "Configured %s directory (%s) doesn't exist and could not be created!", dirType, dir));
      }
    }

    // Make sure the dir is a directory.
    if (!baseDir.isDirectory()) {
      throw new PersistenceException(String.format(
          "Configured %s path (%s) isn't a directory!", dirType, dir));
    }
    return baseDir;
  }
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

  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

      if (!index.delete()) {
        error += "Could not delete index file: " + index.getAbsolutePath();
      }
    }
    if (!error.isEmpty()) {
      throw new PersistenceException(error);
    }
  }
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.