/** * Update ffmpeg metadata. * * @param video the video * @param model the model * @throws IOException Signals that an I/O exception has occurred. */ private void updateFfmpegMetadata(Video video, ProducerVideoDataInputEditModel model) throws IOException { Host host = model.getHost(); Producer producer = model.getProducer(); // FFMPEG if (video.getFileSize().longValue() == 0) { try { String videopfad = ""; if (video.isOpenaccess()) videopfad = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getName() + "/" + producer.getHomeDir() + "/" + video.getFilename(); else videopfad = L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getName() + "/" + producer.getHomeDir() + "/" + video.getSecureFilename(); FFmpegManager ffmpegp = new FFmpegManager(videopfad); video.setDuration(ffmpegp.getVideoDuration()); video.setResolution(ffmpegp.getVideoResolution()); video.setBitrate(ffmpegp.getVideoBitRate()); video.setFileSize(new File(videopfad).length()); ((VideoDao) getDaoBeanFactory().getBean("videoDao")) .updateById( video.getTitle(), video.getTags(), video.getLectureseriesId(), video.getEigentuemerId(), video.getProducerId(), video.getContainerFormat(), video.getFilename(), video.getResolution(), video.getDuration(), video.getHostId(), video.getTextId(), video.getFileSize(), video.getGenerationDate(), video.isOpenaccess(), video.isDownloadAllawed(), video.getMetadataId(), video.getSecureFilename(), video.getHits(), video.isPermittedToSegment(), video.getFacilityId(), video.getCitation2go(), video.getId()); } catch (NullPointerException npe) { } } }
/** * Delete video. * * @param model the model */ private void deleteVideo(ProducerVideoDataInputEditModel model) { Video video = model.getVideo(); String preffix = ""; if (video.isOpenaccess()) preffix = video.getPreffix(); else preffix = video.getSPreffix(); // delete this video from the filesystem File originalFile = new File( L2goPropsUtil.get("lecture2go.media.repository") + "/" + model.getHost().getName() + "/" + model.getProducer().getHomeDir() + "/" + preffix + ".mp4"); // delete image ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")).deleteThumbnails(video); // delete segments List<Mark> segmentList = ((SegmentDao) getDaoBeanFactory().getBean("segmentDao")) .getSegmentsByVideoId(video.getId()); ((SegmentDao) getDaoBeanFactory().getBean("segmentDao")) .deleteThumbhailsFromSegments(segmentList); // delete all segment data from table ((SegmentDao) getDaoBeanFactory().getBean("segmentDao")).deleteByVideoId(video.getId()); originalFile.delete(); // delete the symbolic link File symLink = new File( L2goPropsUtil.get("lecture2go.media.repository") + "/" + "abo" + "/" + video.getFilename()); symLink.delete(); // update the data row video.setFilename(null); video.setGenerationDate(null); video.setOpenaccess(false); video.setDownloadAllawed(false); ((VideoDao) getDaoBeanFactory().getBean("videoDao")) .updateById( video.getTitle(), video.getTags(), video.getLectureseriesId(), video.getEigentuemerId(), video.getProducerId(), video.getContainerFormat(), video.getFilename(), null, null, video.getHostId(), 0, // textId new Long("0"), null, false, // openAccess false, // downloadLink video.getMetadataId(), // metadataId null, video.getHits(), video.isPermittedToSegment(), video.getFacilityId(), video.getCitation2go(), video.getId()); // update RSS try { ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")).RSS(video, "mp4", model); ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")).RSS(video, "mp3", model); ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")).RSS(video, "m4v", model); ((ProzessManager) getUtilityBeanFactory().getBean("prozessManager")).RSS(video, "m4a", model); } catch (Exception e) { } }
/** * Form backing object. * * @param request the request * @return the object */ @Override protected Object formBackingObject(PortletRequest request) { ProducerVideoDataInputEditModel model = new ProducerVideoDataInputEditModel(); String vid = request.getParameter("videoId"); try { int vidId = new Integer(vid); Video video = ((VideoDao) getDaoBeanFactory().getBean("videoDao")).getById(vidId).iterator().next(); Host host = ((HostDao) getDaoBeanFactory().getBean("hostDao")) .getById(video.getHostId()) .iterator() .next(); model.setHost(host); String remoteUserId = request.getRemoteUser(); Integer ruid = new Integer(remoteUserId); // check user if (video.getProducerId() != ruid) { video.setId(-1); } Producer producer = ((ProducerDao) getDaoBeanFactory().getBean("producerDao")) .getByUserId(ruid) .iterator() .next(); model.setProducer(producer); Metadata metadata = ((MetadataDao) getDaoBeanFactory().getBean("metadataDao")) .getById(video.getMetadataId()) .iterator() .next(); model.setMetadata(metadata); Lectureseries lectureseries = ((LectureseriesDao) getDaoBeanFactory().getBean("lectureseriesDao")) .getById(video.getLectureseriesId()) .iterator() .next(); model.setLectureseries(lectureseries); if (video.getFilename() == null) { model.setM4vFile(null); model.setMp3File(null); model.setPdfFile(null); model.setM4aFile(null); } else { String preffix = ""; if (video.isOpenaccess()) { preffix = video.getPreffix(); model.setOpenaccess(true); model.setSecureUrl(null); } else { preffix = video.getSPreffix(); model.setOpenaccess(false); model.setSecureUrl(video.getSecureUrl()); } // check, if existent on the hard disc String mp3File = preffix + ".mp3"; String pdfFile = preffix + ".pdf"; String m4vFile = preffix + ".m4v"; String m4aFile = preffix + ".m4a"; File fMp3 = new File( L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getServerRoot() + "/" + producer.getHomeDir() + "/" + mp3File); File fPdf = new File( L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getServerRoot() + "/" + producer.getHomeDir() + "/" + pdfFile); File fM4v = new File( L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getServerRoot() + "/" + producer.getHomeDir() + "/" + m4vFile); File fM4a = new File( L2goPropsUtil.get("lecture2go.media.repository") + "/" + host.getServerRoot() + "/" + producer.getHomeDir() + "/" + m4aFile); if (fMp3.isFile()) model.setMp3File(mp3File); else model.setMp3File(null); if (fPdf.isFile()) model.setPdfFile(pdfFile); else model.setPdfFile(null); if (fM4v.isFile()) model.setM4vFile(m4vFile); else model.setM4vFile(null); if (fM4a.isFile()) model.setM4aFile(m4aFile); else model.setM4aFile(null); if (video.isDownloadAllawed()) model.setDownloadAllawed(true); else model.setDownloadAllawed(false); } model.setDomainURL(L2goPropsUtil.get("lecture2go.web.home")); model.setVideo(video); model.setLectureseriesId(video.getLectureseriesId()); model.setCommsyEmbed(true); model.setVideoId(video.getId()); } catch (Exception e) { model.setVideoId(-1); } // set current seite for browsing! int currentSeite = 1; try { currentSeite = new Integer(request.getParameter("videoSeite")); } catch (Exception e) { // nothing to do } model.setCurrentSeite(currentSeite); model.setURL(null); return model; }