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

Examples of fi.foyt.hibernate.gae.search.persistence.domainmodel.File


  @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


   */
  @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

   */
  @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

    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);
      }
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 FileDAO() {
    super("FILE", true);
  }

  public File create(Directory directory, String name, Long dataLength, Long modified) {
    File file = new File(directory);
    file.setDataLength(dataLength);
    file.setModified(modified);
    file.setName(name);
    file = persist(file);
   
    String lookupKey = DIRECTORY_NAME_LOOKUP + directory.getKey() + "," + name;
    putLookupKey(lookupKey, file.getKey());

    return file;
  }
View Full Code Here

    }
   
    Query query = new Query(getKind(), directory.getKey())
      .addFilter("name", FilterOperator.EQUAL, name);
   
    File file = getSingleObject(query);
    if (file != null) {
      putLookupKey(lookupKey, file.getKey());
    } else {
      putLookupKey(lookupKey, createNullLookupKey());
    }
   
    return file;
View Full Code Here

    return getFile().getModified();
  }

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

 
  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);
      }
View Full Code Here

    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.domainmodel.File

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.