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

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


  @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


      if ((currentSegmentIndex < 0) || (segmentPosition == GaeFile.SEGMENT_SIZE)) {
        currentSegmentIndex++;
        switchCurrentSegment();
      }
 
      FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();
     
      FileSegment fileSegment = getCurrentSegment();
      byte[] segmentData = getSegmentData(fileSegment, segmentPosition + 1);
      segmentData[segmentPosition++] = b;
      fileSegmentDAO.updateData(fileSegment, segmentData);
    } catch (Exception e) {
      throw new IOException(e);
    }
  }
View Full Code Here

        if ((currentSegmentIndex < 0) || (segmentPosition == GaeFile.SEGMENT_SIZE)) {
          currentSegmentIndex++;
          switchCurrentSegment();
        }
       
        FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();
        FileSegment fileSegment = getCurrentSegment();
        int remainInSegment = GaeFile.SEGMENT_SIZE - segmentPosition;
        int bytesToCopy = len < remainInSegment ? len : remainInSegment;
       
        byte[] segmentData = getSegmentData(fileSegment, segmentPosition + bytesToCopy);
 
        System.arraycopy(b, offset, segmentData, segmentPosition, bytesToCopy);
        fileSegmentDAO.updateData(fileSegment, segmentData);
       
        offset += bytesToCopy;
        len -= bytesToCopy;
        segmentPosition += bytesToCopy;
      }
View Full Code Here

    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 fileDAO = new FileDAO();
    fileDAO.updateDataLength(getFile(), length);
  }
 
  protected synchronized int getFileSegmentsCount() {
    FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();
    return fileSegmentDAO.countByFile(getFile());
  }
View Full Code Here

    FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();
    return fileSegmentDAO.countByFile(getFile());
  }
 
  protected synchronized FileSegment getFileSegment(int index) {
    FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();
    return fileSegmentDAO.findByFileAndSegmentNo(getFile(), index);
  }
View Full Code Here

    return fileSegmentDAO.findByFileAndSegmentNo(getFile(), index);
  }
 
  protected synchronized FileSegment getNewSegment() {
    int newIndex = getFileSegmentsCount();
    FileSegmentDAO fileSegmentDAO = new FileSegmentDAO();
    return fileSegmentDAO.create(getFile(), new Long(newIndex), null);
  }
View Full Code Here

TOP

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

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.