From: Rendek RĂ³bert Date: Tue, 3 Oct 2017 14:05:18 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=0380dc92df6f0dc6892b156615e6fca70572a92f;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30517 --- diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java index 26eaee08..e7d8db2d 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java @@ -80,6 +80,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { private Controller controller = null; + //KONSTRUKTOR //KONSTRUKTOR public NexioClipEventDispatcher() { try { @@ -101,6 +102,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { logger.info("NexioClipEventDispatcher nexio server is connected."); this.progressListenerList = new EventListenerList(); + this.dropAllClipsFromMongo(); this.ensureIndexes(); @@ -132,15 +134,18 @@ public class NexioClipEventDispatcher implements ClipEventListener { @Override public void clipEventPerformed(ClipEvent evt) { try { - if (isValidClip(evt.getClip())) { - BasicDBObject jsClip = convertClipToJSON(evt.getClip()); - if (evt.getEventType() == ClipEventType.CLIP_ADDED) { + //DELETE-nel csak az id van kitoltve a CLIP-en, ezert exception jon!!! + if (evt.getEventType() == ClipEventType.CLIP_ADDED) { +// if (isValidClip(evt.getClip())) { + BasicDBObject jsClip = convertClipToJSON(evt.getClip()); //cache??? Map mongoClips = loadClipsFromMongo(); saveClipIntoMongo(jsClip, mongoClips); - } else if (evt.getEventType() == ClipEventType.CLIP_DELETED) { - removeDeleted(jsClip); - } +// } + } else if (evt.getEventType() == ClipEventType.CLIP_DELETED) { + BasicDBObject jsClip = new BasicDBObject(); + jsClip.put(ID, evt.getClip().getId().get()); //Unique internal ID + removeDeleted(jsClip); } } catch (Exception exc) { logger.error("", exc); @@ -148,9 +153,8 @@ public class NexioClipEventDispatcher implements ClipEventListener { } //END OF R - - private BasicDBObject convertClipToJSON(Clip clip) throws Exception { - BasicDBObject jsClip = new BasicDBObject(); +/* + private void extendJSONClip(BasicDBObject jsClip, Clip clip) throws Exception { jsClip.put(ID, clip.getId().get()); //Unique internal ID jsClip.put(LONGNAMEID, clip.getXid().get()); //Extended ID (Filename) jsClip.put(DURATION, clip.getDuration()); @@ -163,6 +167,55 @@ public class NexioClipEventDispatcher implements ClipEventListener { //jsClip.put(EXTAGENCY, rs.getString(i++)); //jsClip.put(START, rs.getString(i++)); //System.out.println(String.format("ID = '%s'\tXID = '%s'\tDuration = '%s'\tModified = '%s'\tVideoFormat = '%s'\tVideoBitrate = '%s'", id, xid, duration, modifiedTimestamp.getTime(), videoFormat, videoBitrate)); + } +*/ + + private BasicDBObject convertClipToJSON(Clip clip) throws Exception { + BasicDBObject jsClip = new BasicDBObject(); + try{ + jsClip.put(ID, clip.getId().get()); //Unique internal ID + }catch(Exception e){ + System.out.println(e); + } + try{ + jsClip.put(LONGNAMEID, clip.getXid().get()); //Extended ID (Filename) + }catch(Exception e){ + System.out.println(e); + } + try{ + jsClip.put(DURATION, clip.getDuration()); + }catch(Exception e){ + System.out.println(e); + } + try{ + jsClip.put(MODIFIEDTIMESTAMP, clip.getModifiedTimestamp().getTime()); + }catch(Exception e){ + System.out.println(e); + } + try{ + jsClip.put(VIDEO_FORMAT, clip.getVideoFormat()); + }catch(Exception e){ + System.out.println(e); + } + try{ + jsClip.put(VIDEO_BITRATE, clip.getVideoBitrate()); + }catch(Exception e){ + System.out.println(e); + } + try{ + jsClip.put(FILESIZE, clip.getFileSize()); + }catch(Exception e){ + System.out.println(e); + } + try{ + jsClip.put(EXTAGENCY, clip.getExtendedField(GetExtendedFieldCommand.FN_AGENCY)); + }catch(Exception e){ + System.out.println(e); + } + //jsClip.put(RECORDDATE, new DateTime(rs.getString(i++)).toDate()); + //jsClip.put(EXTAGENCY, rs.getString(i++)); + //jsClip.put(START, rs.getString(i++)); + //System.out.println(String.format("ID = '%s'\tXID = '%s'\tDuration = '%s'\tModified = '%s'\tVideoFormat = '%s'\tVideoBitrate = '%s'", id, xid, duration, modifiedTimestamp.getTime(), videoFormat, videoBitrate)); return jsClip; } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/ClipEvent.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/ClipEvent.java index eca3e1e6..a4e57068 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/ClipEvent.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/ClipEvent.java @@ -9,7 +9,7 @@ public class ClipEvent { } public ClipEvent(Clip _clip, ClipEventType _eventType){ - this.clip = clip; + this.clip = _clip; this.eventType = _eventType; } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediaListener.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediaListener.java index b15c6efc..e04d2017 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediaListener.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediaListener.java @@ -88,7 +88,8 @@ public class MediaListener implements Runnable { if (notificationNumber == NN_ID_ADDED) { evt = new ClipEvent(mediaBase.getClip(id), ClipEventType.CLIP_ADDED); } else if (notificationNumber == NN_ID_DELETED) { - evt = new ClipEvent(mediaBase.getClip(id), ClipEventType.CLIP_DELETED); + Clip deletedClip = new ClipImpl(mediaBase.getProtocol(), id); + evt = new ClipEvent(deletedClip, ClipEventType.CLIP_DELETED); } for (ClipEventListener cel : this.clipEventListeners) { cel.clipEventPerformed(evt); diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/Mediabase.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/Mediabase.java index d9529906..d16c3bbd 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/Mediabase.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/Mediabase.java @@ -13,4 +13,6 @@ public interface Mediabase { public Iterator getClips() throws IOException, ProtocolException; public MediaListener getMediaListener(); + + public NexioServerProtocol getProtocol(); } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediabaseImpl.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediabaseImpl.java index 6fc16c39..67a36a4a 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediabaseImpl.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/MediabaseImpl.java @@ -50,7 +50,10 @@ class MediabaseImpl implements Mediabase { return this.mediaListener; } - + @Override + public NexioServerProtocol getProtocol() { + return this.protocol; + } private class Itr implements Iterator { private Clip next; @@ -94,5 +97,7 @@ class MediabaseImpl implements Mediabase { } } + + } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/samples/ListMetabaseContents.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/samples/ListMetabaseContents.java index 47cf63f2..8eebed25 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/samples/ListMetabaseContents.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/samples/ListMetabaseContents.java @@ -49,7 +49,7 @@ public class ListMetabaseContents implements ClipEventListener{ private Mediabase mediaBase = null; private int nexioPort = 557; - private String nexioHost = "10.228.43.18"; //echo: "10.10.1.55"; vmware: "10.228.43.18" + private String nexioHost = "10.228.43.38"; //echo: "10.10.1.55"; vmware: "10.228.43.18" private Connection connection = null;