/*
  * (non-Javadoc)
  *
  * @see
  * org.magnum.dataup.service.VideoService#addVideo(org.magnum.dataup.model
  * .Video)
  */
 @Override
 public Video addVideo(Video video, String baseUrl) {
   videos.add(video);
   video.setId(videos.size() - 1);
   video.setDataUrl(baseUrl + "/video/" + video.getId() + "/data");
   return video;
 }
예제 #2
0
  /** {@inheritDoc} */
  @Multipart
  @RequestMapping(value = VIDEO_DATA_PATH, method = RequestMethod.POST)
  @ResponseBody
  public VideoStatus setVideoData(
      @PathVariable(ID_PARAMETER) final long id,
      @RequestParam(DATA_PARAMETER) final MultipartFile videoData) {
    try {
      final InputStream is = videoData.getInputStream();
      Video v = new Video();
      v.setId(id);
      v.setDataUrl(VIDEO_DATA_PATH + id);
      boolean containsVideo = false;
      for (Video video : videoList) {
        if (video.getId() == id) {
          containsVideo = true;
        }
      }
      if (containsVideo) {
        VideoFileManager fileManager = VideoFileManager.get();
        fileManager.saveVideoData(v, is);

      } else {
        throw new ResourceNotFoundException();
      }

    } catch (final IOException e) {
      e.printStackTrace();
    }
    final VideoStatus status = new VideoStatus(VideoState.READY);
    return status;
  }
예제 #3
0
 /** {@inheritDoc} */
 @RequestMapping(value = VIDEO_SVC_PATH, method = RequestMethod.POST)
 @ResponseBody
 public Video addVideo(final @RequestBody Video v) {
   this.videoList.add(v);
   v.setId(this.videoList.size());
   v.setDataUrl(VIDEO_DATA_PATH + v.getId());
   return v;
 }
 private Video getVideo(long id) {
   Video result = null;
   for (Iterator<Video> iterator = videos.iterator(); iterator.hasNext() && result == null; ) {
     Video video = iterator.next();
     if (id == video.getId()) {
       result = video;
     }
   }
   return result;
 }
예제 #5
0
  /** {@inheritDoc} */
  @RequestMapping(value = VIDEO_DATA_PATH, method = RequestMethod.GET)
  @ResponseBody
  public void getData(@PathVariable(ID_PARAMETER) final long id, HttpServletResponse response) {

    Video video = new Video();
    video.setId(id);
    try {
      VideoFileManager fileManager = VideoFileManager.get();
      if (fileManager.hasVideoData(video)) {
        VideoFileManager.get().copyVideoData(video, response.getOutputStream());
        response.flushBuffer();
      } else {
        throw new ResourceNotFoundException();
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
예제 #6
0
  @Test
  public void test() {
    Video video =
        Video.create()
            .withContentType("video/mpeg")
            .withDuration(123)
            .withSubject("Mobile Cloud")
            .withTitle("Programming Cloud Services for ...")
            .build();

    fail("Not yet implemented");
  }