Package de.sosd.mediaserver.domain.db

Examples of de.sosd.mediaserver.domain.db.FileDomain


//    return q.getResultList();
//  }

  @Transactional(propagation = Propagation.SUPPORTS)
  public String getPathForFile(final String id) {
    final FileDomain file = this.manager.find(FileDomain.class, id);
    if (file != null) {
      return file.getPath();
    }
    return null;
  }
View Full Code Here


  }
 
  @Transactional(propagation = Propagation.REQUIRED)
  public void createFile(final String id, final String folderId, final File source) {
    final ScanFolderDomain parent = this.manager.find(ScanFolderDomain.class, folderId);
    final FileDomain f = new FileDomain(id, parent, source)
    this.manager.persist(f);
  }
View Full Code Here

    this.manager.remove(d);   
  }
 
  @Transactional(propagation = Propagation.REQUIRED)
  public void removeFile(final String id) {
    final FileDomain d = this.manager.find(FileDomain.class, id);
    removeFile(d);
  }
View Full Code Here

    }
  }

  @Transactional(propagation = Propagation.REQUIRED)
  private void imageIoUpdateMetaInfo(String fileId) {
    FileDomain file = fsDao.getFile(fileId);
   
    try {
      BufferedImage read = ImageIO.read(new File(file.getPath()));
      read.flush();
      file.getDidl().setResolution(read.getWidth() + "x" + read.getHeight());
      file.getDidl().setGenerateThumbnail(false);
      // TODO set protocolInfo accordingly (depends on resolution here)
    } catch (IOException t) {
      // if we can't read it, clients probably can't as well -> ignore
      file.getDidl().setGenerateThumbnail(false);
    } catch (NullPointerException t) {
      // if we can't read it, clients probably can't as well -> ignore (this happened on some MacOsx files ...)
      file.getDidl().setGenerateThumbnail(false);
    }
    didlDao.store(file.getDidl());
  }
View Full Code Here

 
  @Transactional(propagation=Propagation.REQUIRED)
  private void update() {
    debug();
    this.thumbnailFolder.mkdirs();
    final FileDomain fd = this.fsDao.getFile(this.fileId);
    final DidlDomain dd = fd.getDidl();
    File screenshot = new File(this.tempFolder, "00000001.jpg");
    long max_size = 0l;
    final File[] fileList = this.tempFolder.listFiles();
    if (fileList != null) {
      for (final File sf : this.tempFolder.listFiles()) {
View Full Code Here

  @Override
  @Transactional(propagation=Propagation.REQUIRED)
  public void notifyProcessKilled() {
    debug();
    final FileDomain fd = this.fsDao.getFile(this.fileId);
    final DidlDomain dd = fd.getDidl();
    dd.setGenerateThumbnail(false);
    this.didlDao.store(dd)
  }
View Full Code Here

//  }
 
  @Transactional(propagation=Propagation.REQUIRED)
  private void update() {
    try {
    final FileDomain fd = this.fsDao.getFile(this.fileId);
    final String filtered_text = this.out.toString().replace('\r', '\n');
   
    final String[] lines = filtered_text.split("\n");
    final Map<String,String> parsedValues = new HashMap<String,String>();

    /**
    ID_VIDEO_ID=0
    ID_AUDIO_ID=1
    ID_CLIP_INFO_NAME0=Software
    ID_CLIP_INFO_VALUE0=VirtualDubMod 1.5.10.2 (build 2540/release)
    ID_CLIP_INFO_N=1
    ID_FILENAME=
    ID_DEMUXER=avi
    ID_VIDEO_FORMAT=XVID
    ID_VIDEO_BITRATE=930680
    ID_VIDEO_WIDTH=640
    ID_VIDEO_HEIGHT=272
    ID_VIDEO_FPS=23.976
    ID_VIDEO_ASPECT=0.0000
    ID_LENGTH=5502.62
    ID_SEEKABLE=1
    ID_CHAPTERS=0
    ID_VIDEO_CODEC=ffodivx
    ID_VIDEO_ASPECT=2.3529
    ID_AUDIO_CODEC=ffmp3

    ID_DEMUXER=audio
    ID_AUDIO_FORMAT=85
    ID_AUDIO_BITRATE=192000
    ID_AUDIO_RATE=44100
    ID_AUDIO_NCH=0
    ID_LENGTH=80.00
    ID_SEEKABLE=1
    ID_CHAPTERS=0
    ID_CLIP_INFO_NAME0=Title
    ID_CLIP_INFO_VALUE0=b-vert�re
    ID_CLIP_INFO_NAME1=Artist
    ID_CLIP_INFO_VALUE1=Bela B.
    ID_CLIP_INFO_NAME2=Album
    ID_CLIP_INFO_VALUE2=Bingo
    ID_CLIP_INFO_NAME3=Year
    ID_CLIP_INFO_VALUE3=2006
    ID_CLIP_INFO_NAME4=Comment
    ID_CLIP_INFO_VALUE4=-] MST [-
    ID_CLIP_INFO_NAME5=Track
    ID_CLIP_INFO_VALUE5=1
    ID_CLIP_INFO_NAME6=Genre
    ID_CLIP_INFO_VALUE6=Punk Rock
    ID_CLIP_INFO_N=7
     * */   
    for (final String line : lines) {
     
     
      if (line.startsWith("ID")) {
        final String[] split = line.split("=");
        if (split.length ==2) {
          parsedValues.put(split[0].substring(3).toLowerCase(), split[1]);
         }
      }


    }
    // optimize
    final String infoNr = parsedValues.remove("clip_info_n");
    if (infoNr != null) {
      final int idx = Integer.parseInt(infoNr);
      for (int i = 0; i < idx; ++i) {
        final String name = parsedValues.remove("clip_info_name" + i);
        final String value = parsedValues.remove("clip_info_value" + i);
       
        parsedValues.put(name.toLowerCase(), value);
      }
    }
    // duration="01:56:36.780" resolution="620x256" bitrate="107520" nrAudioChannels="2" sampleFrequency="48000"
    final DidlDomain dd = fd.getDidl();
//      if (dd.getUrl().toLowerCase().endsWith("mp3")) {
//        System.out.println("mp3");
//      }
   
    dd.setAlbum(parsedValues.get("album"));
    dd.setBitrate(getBitrate(parsedValues.get("video_bitrate"), parsedValues.get("audio_bitrate")));
    dd.setArtist(parsedValues.get("artist"));
    dd.setAudioCodec(parsedValues.get("audio_codec"));
    dd.setTrack(getInteger(parsedValues.get("track")));
    dd.setVideoCodec(parsedValues.get("video_codec"));
    dd.setYear(getInteger(parsedValues.get("year")));
//    String title = parsedValues.get("title");
//    if (title != null) {
//      dd.setTitle(title);
//    }
//      dd.setBitsPerSample(bitsPerSample);
//      dd.setColorDepth(colorDepth);

    dd.setDuration(getDuration(parsedValues.get("length")));
    dd.setGenre(parsedValues.get("genre"));
//      dd.setLanguage(language);
    dd.setNrAudioChannels(getInteger(parsedValues.get("audio_nch")));
    dd.setResolution(getResoulution(parsedValues.get("video_width"), parsedValues.get("video_height")));
    dd.setSampleFrequency(getInteger(parsedValues.get("audio_rate")));
   
//      if (preview != null && preview.exists()) {
//        service.
//      }
//      dd.setThumbnail(thumbnail)
    final boolean notReadable = filtered_text.toLowerCase().contains("file not found") || filtered_text.toLowerCase().contains("failed to open");
    dd.setPassedMPlayer(! notReadable);
    dd.increaseUpdateId();
   
    logger.info("update meta-infos [" + fd.getId() + "]");
    this.fsDao.store(fd)
    } finally {
      try {
        this.err.close();
        this.out.close();
View Full Code Here

  }

  @Override
  @Transactional(propagation=Propagation.REQUIRED)
  public void notifyProcessKilled() {
    final FileDomain fd = this.fsDao.getFile(this.fileId);
    final DidlDomain dd = fd.getDidl();
    dd.setPassedMPlayer(true);
    this.didlDao.store(dd)
  }
View Full Code Here

      for (final ScanFolderDomain sfd : system.getScanFolder()) {
        if (idScanContextMap.containsKey(sfd.getId())) {
          final ScanContext sc = idScanContextMap.get(sfd.getId());
          logger.info("scanner [filter] "+sc.getScanFolder());
          for (final ScanFile f : sc.getFiles()) {
            final FileDomain fd = new FileDomain(f.getId(), null, f.getFile());         
            if (this.didl.createDidl(fd, f, touchedDidlMap, sfd)) {
              sc.getMediaFiles().add(fd);
            }
          }
          logger.info("scanner [found new files] " + sc.getMediaFiles().size() + " " +sc.getScanFolder());
        }
      } 
    }
     
    // update folders
    for (final ScanFolderDomain sfd : system.getScanFolder()) {
      if (idScanContextMap.containsKey(sfd.getId())) {
        final ScanContext sc = idScanContextMap.get(sfd.getId());
        boolean changedFiles = false;
        for (final FileDomain fd : sc.getMediaFiles()) {   
          changedFiles |= sfd.addFile(fd);
          logger.info("scanner [add file] " + fd.getName() + "\t\t(" + fd.getPath() + ")");
        }       
        if (changedFiles || !sc.getDeletedMediaFiles().isEmpty()) {
          changedFiles |= updateDidl(sfd.getDidlRoot(), sfd, touchedDidlMap,sc.getDeletedMediaFiles(), itemsToPurge);
        }
        // remove scanfolder mark
View Full Code Here

    boolean changed = false;   
    DidlDomain parent;
    if (item.getParent() != null) {
      parent = map.getDidl(item.getParent().getId());
      // remove child
      final FileDomain file = item.getFile();
      changed = parent.removeChild(item);     
      didlDao.store(parent);
//      item.setFile(null);
//      item.setParent(null);
//      item.setReference(null);
//      for (DidlDomain ref : item.getReferences()) {
//        removeDidl(root, map, ref, itemsToPurge);
//      }
//      for (DidlDomain content : item.getContainerContent()) {
//        removeDidl(root, map, content, itemsToPurge);
//      }
//      item.getContainerContent().clear();
     
      if (file != null) {
        changed |= file.getParent().removeFile(file);
//        file.setParent(null);
//        file.setDidl(null);
//        storage.removeFile(file);
        logger.info("scanner [removed file] " + file.getName() + "\t(" + file.getPath() + ")")
      } else {
        logger.info("scanner [removed folder] " + item.getTitle() + "\t(" + item.getId() + ")");
      }
     
      if (parent.getContainerContent().isEmpty()) {
View Full Code Here

TOP

Related Classes of de.sosd.mediaserver.domain.db.FileDomain

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.