Package fi.foyt.hibernate.gae.search.persistence.dao

Examples of fi.foyt.hibernate.gae.search.persistence.dao.FileDAO


  @Override
  public final String[] listAll() {
    ensureOpen();
   
    FileDAO fileDAO = new FileDAO();
    List<File> files = fileDAO.listByDirectory(getDirectory());
    String[] result = new String[files.size()];
       
    int i = 0;
    for (File file : files) {
      result[i++] = file.getName();
View Full Code Here


  }

  @Override
  public final boolean fileExists(String name) {
    ensureOpen();
    FileDAO fileDAO = new FileDAO();
    File file = fileDAO.findByDirectoryAndName(getDirectory(), name);
    return file != null;
  }
View Full Code Here

   * @throws IOException if the file does not exist
   */
  @Override
  public final long fileModified(String name) throws IOException {
    ensureOpen();
    FileDAO fileDAO = new FileDAO();
    File file = fileDAO.findByDirectoryAndName(getDirectory(), name);
    if (file == null)
      throw new FileNotFoundException();
   
    return file.getModified();
  }
View Full Code Here

   * @throws IOException if the file does not exist
   */
  @Override
  public final long fileLength(String name) throws IOException {
    ensureOpen();
    FileDAO fileDAO = new FileDAO();
    File file = fileDAO.findByDirectoryAndName(getDirectory(), name);
    if (file == null)
      throw new FileNotFoundException();

    return file.getDataLength();
  }
View Full Code Here

   */
  @Override
  public void deleteFile(String name) throws IOException {
    ensureOpen();
   
    FileDAO fileDAO = new FileDAO();
    FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();

    File file = fileDAO.findByDirectoryAndName(getDirectory(), name);
    if (file != null) {
      List<FileSegment> segments = fileSegmentDAO.listByFile(file);
      for (FileSegment segment : segments) {
        fileSegmentDAO.delete(segment);
      }
      fileDAO.delete(file);     
      LOG.fine("Deleted search index file " + name + " from directory " + getDirectory().getName());
    } else {
      throw new FileNotFoundException();
    }
  }
View Full Code Here

   */
  @Override
  public IndexInput openInput(String name) throws IOException {
    ensureOpen();
   
    FileDAO fileDAO = new FileDAO();
    File file = fileDAO.findByDirectoryAndName(getDirectory(), name);
    if ((file == null) || (file.getDataLength() < 1))
      throw new FileNotFoundException(name);

    return new GaeIndexInput(new GaeFile(name, this));
  }
View Full Code Here

  public synchronized long getLastModified() {
    return getFile().getModified();
  }

  protected synchronized void setLastModified(long lastModified) {
    FileDAO fileDAO = new FileDAO();
    File file = getFile();
    fileDAO.updateModified(file, lastModified);
  }
View Full Code Here

    File file = getFile();
    fileDAO.updateModified(file, lastModified);
  }
 
  protected synchronized void resetFile() {
    FileDAO fileDAO = new FileDAO();
    FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();

    File file = getFile();
    if (file != null) {
      List<FileSegment> segments = fileSegmentDAO.listByFile(file);
      for (FileSegment segment : segments) {
        fileSegmentDAO.delete(segment);
      }
     
      fileDAO.updateDataLength(file, 0l)
    }
  }
View Full Code Here

      fileDAO.updateDataLength(file, 0l)
    }
  }
 
  public void updateLength(long length) {
    FileDAO fileDAO = new FileDAO();
    fileDAO.updateDataLength(getFile(), length);
  }
View Full Code Here

    FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();
    return fileSegmentDAO.create(getFile(), new Long(newIndex), null);
  }
 
  private synchronized File getFile() {
    FileDAO fileDAO = new FileDAO();
    File file = fileDAO.findByDirectoryAndName(directory.getDirectory(), fileName);
    if (file == null) {
      file = fileDAO.create(directory.getDirectory(), fileName, 0l, System.currentTimeMillis());
    }
   
    return file;
  }
View Full Code Here

TOP

Related Classes of fi.foyt.hibernate.gae.search.persistence.dao.FileDAO

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.