From 00d7b7e8a6c7f3cb0bbb0be61069c8919056b7b1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Mon, 16 Oct 2017 16:05:47 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30630 --- server/-configuration/log4j2.xml | 2 +- .../run-mediacube-server-localhost.launch | 2 +- .../nexio/NexioClipEventDispatcher.java | 52 +++++++++---------- .../src/user/commons/nexio/api/Clip.java | 2 + .../src/user/commons/nexio/api/ClipImpl.java | 13 +++++ 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/server/-configuration/log4j2.xml b/server/-configuration/log4j2.xml index b549b819..49bce29b 100644 --- a/server/-configuration/log4j2.xml +++ b/server/-configuration/log4j2.xml @@ -57,6 +57,6 @@ - + \ No newline at end of file diff --git a/server/-configuration/run-mediacube-server-localhost.launch b/server/-configuration/run-mediacube-server-localhost.launch index 1da64ac2..62c83bb5 100644 --- a/server/-configuration/run-mediacube-server-localhost.launch +++ b/server/-configuration/run-mediacube-server-localhost.launch @@ -19,7 +19,7 @@ - + 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 62d090f5..95065b8f 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 @@ -36,20 +36,14 @@ import user.commons.remotestore.ProgressEvent; */ public class NexioClipEventDispatcher implements ClipEventListener { - private static final Logger logger = LogManager.getLogger(); private static final String ID = "id"; private static final String VIDEO_FORMAT = "videoformat"; private static final String VIDEO_BITRATE = "videobitrate"; private static final String FILESIZE = "filesize"; - - private static final String SQLSERVER_JDBC_SQL_SERVER_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - private static final String JOBENGINE_NEXIO_DB_PASSWORD = "jobengine.nexio.db.password"; - private static final String JOBENGINE_NEXIO_DB_USER = "jobengine.nexio.db.user"; - private static final String JOBENGINE_NEXIO_DB_URL = "jobengine.nexio.db.url"; + private static final String KILLDATE = "killdate"; private static final String DURATION = "duration"; - private static final String START = "start"; private static final String MODIFIEDTIMESTAMP = "modifiedtimestamp"; private static final String EXTAGENCY = "extagency"; private static final String RECORDDATE = "recorddate"; @@ -123,7 +117,6 @@ public class NexioClipEventDispatcher implements ClipEventListener { } }); importThread.start(); - } catch (Exception exc) { logger.error("", exc); @@ -141,19 +134,19 @@ public class NexioClipEventDispatcher implements ClipEventListener { if (evt.getEventType() == ClipEventType.CLIP_ADDED) { // if (isValidClip(evt.getClip())) { BasicDBObject jsClip = convertClipToJSON(evt.getClip()); - + String fileName = jsClip.getString(LONGNAMEID); - if(fileName != null && !"".equals(fileName)){ + if (fileName != null && !"".equals(fileName)) { logger.debug("clipEventPerformed clip: {} {}", evt.getClip().getId(), fileName); //cache??? - + HashMap clipsForId = new HashMap(); Map clipsForXID = loadClipsFromMongo(clipsForId); - saveClipIntoMongo(jsClip, clipsForXID, clipsForId); - }else{ + saveClipIntoMongo(jsClip, clipsForXID, clipsForId); + } else { logger.debug("clipEventPerformed clip: {}", evt.getClip() == null ? "null" : evt.getClip().getId()); } - + // } } else if (evt.getEventType() == ClipEventType.CLIP_DELETED) { BasicDBObject jsClip = new BasicDBObject(); @@ -200,6 +193,13 @@ public class NexioClipEventDispatcher implements ClipEventListener { } catch (Exception e) { // System.out.println(e); } + + try { + if ("2931346-3".equals(jsClip.getString(LONGNAMEID))) + jsClip.put(KILLDATE, clip.getKillDate()); + } catch (Exception e) { + // System.out.println(e); + } try { jsClip.put(MODIFIEDTIMESTAMP, clip.getModifiedTimestamp().getTime()); } catch (Exception e) { @@ -253,17 +253,17 @@ public class NexioClipEventDispatcher implements ClipEventListener { Iterator clips = controller.getMediabase().getClips(); while (clips.hasNext()) { Clip clip = null; - try{ + try { clip = clips.next(); BasicDBObject jsonClip = convertClipToJSON(clip); String fileName = jsonClip.getString(LONGNAMEID); - if(fileName != null && !"".equals(fileName)){ - logger.debug("Found NEXIO clip: {} {}", clip.getId(), fileName); //clip.getXid() hibat dob + if (fileName != null && !"".equals(fileName)) { + logger.debug("Found NEXIO clip: {} {}", clip.getId(), fileName); //clip.getXid() hibat dob this.saveClipIntoMongo(jsonClip, emptyMap, emptyMap); - }else{ + } else { logger.debug("Found NEXIO clip: {} XID IS MISSING!!", clip.getId()); } - }catch(Exception e){ + } catch (Exception e) { logger.error("", e); } } @@ -335,9 +335,9 @@ public class NexioClipEventDispatcher implements ClipEventListener { if (find.hasNext()) { List clips = ListUtils.cast(find.toArray()); result = ListUtils.map(clips, item -> item.getString(LONGNAMEID)); - for (BasicDBObject clip : clips){ + for (BasicDBObject clip : clips) { result.put(clip.getString(LONGNAMEID), clip); - if(clipsForId != null){ + if (clipsForId != null) { clipsForId.put(clip.getString(ID), clip); } } @@ -390,20 +390,20 @@ public class NexioClipEventDispatcher implements ClipEventListener { } */ - private void saveClipIntoMongo(BasicDBObject clip, Map clipsForXID, Map clipsForID) { + private void saveClipIntoMongo(BasicDBObject clip, Map clipsForXID, Map clipsForID) { DBCollection collection = db.getCollection(CLIP_COLLECTION_NAME); String xid = clip.getString(LONGNAMEID); String id = clip.getString(ID); - + BasicDBObject clipForXID = clipsForXID.get(xid); BasicDBObject clipForID = clipsForID.get(id); - - //rename-nel a clipForXID null lesz de a clipForID nem ezert nem kell create + + //rename-nel a clipForXID null lesz de a clipForID nem ezert nem kell create if (clipForXID == null && clipForID == null) { collection.save(clip); onCreate(clip); } else { - if(clipForID != null){ + if (clipForID != null) { clip.put("_id", clipForID.get("_id")); if (!clip.equals(clipForID)) { collection.save(clip); diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/Clip.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/Clip.java index 58cd56db..114fb300 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/Clip.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/Clip.java @@ -16,6 +16,8 @@ public interface Clip { public Id getId(); + public Calendar getKillDate() throws ClipNotFoundException, IOException, ProtocolException; + public Calendar getModifiedTimestamp() throws ClipNotFoundException, IOException, ProtocolException; Calendar getRecordDateTimestamp() throws ClipNotFoundException, IOException, ProtocolException; diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/ClipImpl.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/ClipImpl.java index 1a92f3e2..a722d73e 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/ClipImpl.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/api/ClipImpl.java @@ -84,6 +84,19 @@ class ClipImpl implements Clip { return id; } + @Override + public Calendar getKillDate() throws ClipNotFoundException, IOException, ProtocolException { + if (metadata == null) { + metadata = protocol.executeGetIDMetadata(id); + checkClipExists(metadata); + } + byte[] filetime = { metadata[42], metadata[43] }; + + Calendar result = Calendar.getInstance(); + + return null; + } + @Override public Calendar getModifiedTimestamp() throws ClipNotFoundException, IOException, ProtocolException { if (timestamp == null) { -- 2.54.0