Package org.rssowl.core.persist.service

Examples of org.rssowl.core.persist.service.PersistenceException


        else
          fDb.ext().set(conditionalGet, 1);
      }
      fDb.commit();
    } catch (Db4oException e) {
      throw new PersistenceException(e);
    } finally {
      fWriteLock.unlock();
    }
    DBHelper.cleanUpAndFireEvents();
  }
View Full Code Here


        return DBManager.this.createConfiguration();
      }
    };
    Migration migration = new Migrations().getMigration(workspaceFormat, currentFormat);
    if (migration == null) {
      throw new PersistenceException("No migration found for originFormat: " + workspaceFormat + ", and destinationFormat: " + currentFormat);
    }

    /* Create a copy of the db file to use for the migration */
    File dbFile = new File(getDBFilePath());
    String migDbFileName = getDBFilePath() + ".mig";
    File migDbFile = new File(migDbFileName);
    copyFile(dbFile, migDbFile);

    /* Migrate the copy */
    boolean reindexRequired = migration.migrate(configFactory, migDbFileName, progressMonitor);

    /*
     * Copy the db file to a permanent back where the file name includes the
     * workspaceFormat number.
     */
    File backupDbFile = new File(getDBFilePath() + ".bak." + workspaceFormat);
    copyFile(dbFile, backupDbFile);

    File dbFormatFile = getDBFormatFile();
    File migFormatFile = new File(dbFormatFile.getAbsolutePath() + ".mig");
    try {
      if (!migFormatFile.exists()) {
        migFormatFile.createNewFile();
      }
      if (!dbFormatFile.exists()) {
        dbFormatFile.createNewFile();
      }
    } catch (IOException ioe) {
      throw new PersistenceException("Error creating database", ioe); //$NON-NLS-1$
    }
    setFormatVersion(migFormatFile);

    /* If rename fails, fall-back to delete and rename */
    if (!migFormatFile.renameTo(dbFormatFile)) {
      dbFormatFile.delete();
      if (!migFormatFile.renameTo(dbFormatFile)) {
        throw new PersistenceException("Failed to migrate data.");
      }
    }

    /* Finally, rename the actual db file */
    /* If rename fails, fall-back to delete and rename */
    if (!migDbFile.renameTo(dbFile)) {
      dbFile.delete();
      if (!migDbFile.renameTo(dbFile)) {
        throw new PersistenceException("Failed to migrate data.");
      }
    }

    return reindexRequired;
  }
View Full Code Here

      FileChannel dstChannel = outputStream.getChannel();

      dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

    } catch (IOException e) {
      throw new PersistenceException(e);
    } finally {
      closeCloseable(inputStream);
      closeCloseable(outputStream);
    }
  }
View Full Code Here

        String versionText = reader.readLine();
        try {
          int version = Integer.parseInt(versionText);
          return version;
        } catch (NumberFormatException e) {
          throw new PersistenceException("Format file does not contain a number as the version", e);
        }
      } catch (IOException e) {
        throw new PersistenceException(e);
      } finally {
        closeCloseable(reader);
      }
    }
    /*
     * In case there is no database file, we just set the version as the current
     * version.
     */
    if (!formatFileExists) {
      try {
        formatFile.createNewFile();
      } catch (IOException ioe) {
        throw new PersistenceException("Error creating database", ioe); //$NON-NLS-1$
      }
    }
    setFormatVersion(formatFile);
    return getCurrentFormatVersion();
  }
View Full Code Here

      writer = new BufferedWriter(new FileWriter(formatFile));
      String s = String.valueOf(getCurrentFormatVersion());
      writer.write(s);
      writer.flush();
    } catch (IOException e) {
      throw new PersistenceException(e);
    } finally {
      closeCloseable(writer);
    }
  }
View Full Code Here

    DefragmentConfig defragConfig = new DefragmentConfig(getDBFilePath());
    defragConfig.db4oConfig(config);
    try {
      Defragment.defrag(defragConfig);
    } catch (IOException e) {
      throw new PersistenceException("Error creating database", e);
    }
  }
View Full Code Here

      query.descend("fParent").constrain(null); //$NON-NLS-1$
      List<IFolder> folders = getList(query);
      activateAll(folders);
      return new ArrayList<IFolder>(folders);
    } catch (Db4oException e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

    try {
      Collection<IBookMark> marks = DBHelper.loadAllBookMarks(fDb, feedRef);
      activateAll(marks);
      return new ArrayList<IBookMark>(marks);
    } catch (Db4oException e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

  public boolean exists(FeedLinkReference feedRef) {
    try {
      Collection<IBookMark> marks = DBHelper.loadAllBookMarks(fDb, feedRef);
      return !marks.isEmpty();
    } catch (Db4oException e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

          strings.add(person.getEmail().toString());
      }

      return strings;
    } catch (Db4oException e) {
      throw new PersistenceException(e);
    }
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.service.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.