From: Vásáry Dániel Date: Mon, 28 Jan 2019 15:40:16 +0000 (+0000) Subject: #108 Nexio listában recorddate helyett a modified értéke van X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=a1b3f35123d3b3a1fd3e72e97b333f3a36267630;p=mediacube.git #108 Nexio listában recorddate helyett a modified értéke van git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C31395 --- diff --git a/server/-configuration/run-mediacube-server-bsh.launch b/server/-configuration/run-mediacube-server-bsh.launch index 60593dc9..b5abf0ff 100644 --- a/server/-configuration/run-mediacube-server-bsh.launch +++ b/server/-configuration/run-mediacube-server-bsh.launch @@ -19,7 +19,7 @@ - + diff --git a/server/-dependencies/pom.xml b/server/-dependencies/pom.xml index b39ff8fe..89bfc124 100644 --- a/server/-dependencies/pom.xml +++ b/server/-dependencies/pom.xml @@ -1,7 +1,6 @@ - + 4.0.0 hu.user.chronos hu.user.chronos.dependencies @@ -113,15 +112,15 @@ org.reficio p2-maven-plugin - 1.3.0 + 1.2.0-SNAPSHOT default-cli - - - + + + humble.video:linux:0.2.1 @@ -135,7 +134,7 @@ com.google.guava:guava:18.0 - + com.fasterxml.jackson.core:jackson-core:${fasterxml-jackson-core} diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDataMiner.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDataMiner.java index d2ed899f..01d515c1 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDataMiner.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDataMiner.java @@ -5,6 +5,7 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Timestamp; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -298,8 +299,15 @@ public class NexioDataMiner implements Runnable, INexioChangeListener { clip.put(VIDEOBITRATE, rs.getString(VIDEOBITRATE)); clip.put(VIDEOFORMAT, rs.getString(VIDEOFORMAT)); clip.put(DURATION, rs.getLong(DURATION)); - clip.put(MODIFIEDTIMESTAMP, rs.getTimestamp(MODIFIEDTIMESTAMP)); - clip.put(RECORDDATE, rs.getTimestamp(RECORDTIMESTAMP)); + + Timestamp record = rs.getTimestamp(RECORDTIMESTAMP); + clip.put(RECORDDATE, record); + //NEXIO GW modified date nem jo a regi klippeknel + Timestamp modified = rs.getTimestamp(MODIFIEDTIMESTAMP); + if (modified.before(record)) + clip.put(MODIFIEDTIMESTAMP, record); + else + clip.put(MODIFIEDTIMESTAMP, modified); clip.put(KILLDATE, rs.getTimestamp(KILLDATE)); collection.insert(clip); count++; diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java index 7c63f705..e6c0ddaf 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java @@ -155,35 +155,35 @@ public class NexioDispatcher implements ClipEventListener { } catch (Exception e) { // System.out.println(e); } - try { - jsClip.put(KILLDATE, clip.getKillDate().getTime()); + jsClip.put(MODIFIEDTIMESTAMP, clip.getModifiedTimestamp().getTime()); } catch (Exception e) { // System.out.println(e); } try { - jsClip.put(MODIFIEDTIMESTAMP, clip.getModifiedTimestamp().getTime()); + jsClip.put(RECORDDATE, clip.getRecordDateTimestamp().getTime()); } catch (Exception e) { // System.out.println(e); } + try { - jsClip.put(VIDEO_FORMAT, clip.getVideoFormat()); + jsClip.put(KILLDATE, clip.getKillDate().getTime()); } catch (Exception e) { // System.out.println(e); } try { - jsClip.put(VIDEO_BITRATE, clip.getVideoBitrate()); + jsClip.put(VIDEO_FORMAT, clip.getVideoFormat()); } catch (Exception e) { // System.out.println(e); } try { - String agency = new String(clip.getExtendedField(GetExtendedFieldCommand.FN_AGENCY), INexioAPI.ENCODING); - jsClip.put(EXTAGENCY, agency); + jsClip.put(VIDEO_BITRATE, clip.getVideoBitrate()); } catch (Exception e) { // System.out.println(e); } try { - jsClip.put(RECORDDATE, clip.getRecordDateTimestamp().getTime()); + String agency = new String(clip.getExtendedField(GetExtendedFieldCommand.FN_AGENCY), INexioAPI.ENCODING); + jsClip.put(EXTAGENCY, agency); } catch (Exception e) { // System.out.println(e); } @@ -209,7 +209,7 @@ public class NexioDispatcher implements ClipEventListener { String agency = jsonClip.getString(EXTAGENCY); int duration = jsonClip.getInt(DURATION); if (fileName != null && !"".equals(fileName)) { - logger.debug("Found NEXIO clip: {} duration: {} agency: {}", fileName, duration, agency); + logger.info("Found NEXIO clip: {} duration: {} agency: {}", fileName, duration, agency); this.saveClipIntoMongo(jsonClip); } else { logger.debug("Found NEXIO clip: {} XID IS MISSING!!", clip.getId()); 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 3eeb9c54..295b9730 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 @@ -21,7 +21,8 @@ class ClipImpl implements Clip { private Xid xid = null; private final NexioServerProtocol protocol; private byte[] metadata = null; - private Calendar timestamp = null; + private Calendar modified = null; + private Calendar record = null; private long fileSize = -1; ClipImpl(NexioServerProtocol protocol, Id id) { @@ -124,22 +125,20 @@ class ClipImpl implements Clip { @Override public Calendar getModifiedTimestamp() throws ClipNotFoundException, IOException, ProtocolException { - if (timestamp == null) { - timestamp = protocol.executeGetExtendedFieldGetModifiedTimestamp(id); - checkClipExists(timestamp); + if (modified == null) { + modified = protocol.executeGetExtendedFieldGetModifiedTimestamp(id); + checkClipExists(modified); } - return timestamp; + return modified; } @Override public Calendar getRecordDateTimestamp() throws ClipNotFoundException, IOException, ProtocolException { - if (timestamp == null) { - //TODO - timestamp = protocol.executeGetExtendedFieldGetModifiedTimestamp(id); - //timestamp = protocol.executeGetExtendedFieldGetRecordDateTimestamp(id); - checkClipExists(timestamp); + if (record == null) { + record = protocol.executeGetExtendedFieldGetRecordDateTimestamp(id); + checkClipExists(record); } - return timestamp; + return record; } @Override diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldGetModifiedTimestampCommand.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldGetModifiedTimestampCommand.java index 26f6867e..a6303d69 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldGetModifiedTimestampCommand.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldGetModifiedTimestampCommand.java @@ -1,79 +1,14 @@ package user.commons.nexio.server.protocol; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Calendar; - -public class GetExtendedFieldGetModifiedTimestampCommand extends Command { - - private final static byte[] GET_EXTENDED_FIELD = { (byte) 0xc9, (byte) 0xc3 }; +public class GetExtendedFieldGetModifiedTimestampCommand extends GetExtendedFieldTimestampCommand { private final static byte[] EXTENDED_FIELD_NUMBER = { (byte) 20 }; - private byte[] buffer; - private byte filetime[]; - public GetExtendedFieldGetModifiedTimestampCommand(Connection connection) { super(connection); } - private Calendar convertFromFILETIME(byte[] filetime) { - Calendar result = Calendar.getInstance(); - - ByteBuffer b = ByteBuffer.wrap(filetime); - b.order(ByteOrder.LITTLE_ENDIAN); - int lo = b.asIntBuffer().get(0); - int hi = b.asIntBuffer().get(1); - - long wFILETIME = ((long) hi << 32) + lo; - - final long EPOCH_DIFF = 11644473600000L; - final long ms_since_16010101 = wFILETIME / (10000); - final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF; - - result.setTimeInMillis(ms_since_19700101); - - return result; - } - - public Calendar execute(Id id) throws IOException, ProtocolException { - - Calendar ret = null; - - connection.write(GET_EXTENDED_FIELD); - connection.write(id.get().getBytes()); - connection.write(EXTENDED_FIELD_NUMBER); - connection.flush(); - - buffer = new byte[2]; - int c = connection.read(buffer, 0, 2); - if (c < 2) { - throw getException_InvalidResponseLength(c, 2, 2); - } - - // Not found - if (buffer[0] == (byte) 0xd0 && buffer[1] == (byte) 0xc3) { - throw new ProtocolException("ID handle is not found!"); - } else - // 1. Found - if (buffer[0] == (byte) 0xdf && buffer[1] == (byte) 0xc3) { - - // 2. read NOF BYTES - buffer = new byte[1]; - c = connection.read(buffer, 0, 1); - - int toRead = buffer[0]; - if (toRead != 8) { - throw new ProtocolException("Invalid ModifiedTimeStamp's data length: " + toRead); - } else { - filetime = new byte[8]; - c = connection.read(filetime, 0, 8); - if (c != 8) { - throw getException_InvalidResponseLength(c, 8, 8); - } - ret = convertFromFILETIME(filetime); - } - } - return ret; + @Override + protected byte[] getExtendedFieldNumber() { + return EXTENDED_FIELD_NUMBER; } } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldGetRecordDateTimestampCommand.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldGetRecordDateTimestampCommand.java index e7301606..ed17ab69 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldGetRecordDateTimestampCommand.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldGetRecordDateTimestampCommand.java @@ -1,79 +1,14 @@ package user.commons.nexio.server.protocol; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Calendar; - -public class GetExtendedFieldGetRecordDateTimestampCommand extends Command { - - private final static byte[] GET_EXTENDED_FIELD = { (byte) 0xc9, (byte) 0xc3 }; +public class GetExtendedFieldGetRecordDateTimestampCommand extends GetExtendedFieldTimestampCommand { private final static byte[] EXTENDED_FIELD_NUMBER = { (byte) 0 }; - private byte[] buffer; - private byte filetime[]; - public GetExtendedFieldGetRecordDateTimestampCommand(Connection connection) { super(connection); } - private Calendar convertFromFILETIME(byte[] filetime) { - Calendar result = Calendar.getInstance(); - - ByteBuffer b = ByteBuffer.wrap(filetime); - b.order(ByteOrder.LITTLE_ENDIAN); - int lo = b.asIntBuffer().get(0); - int hi = b.asIntBuffer().get(1); - - long wFILETIME = ((long) hi << 32) + lo; - - final long EPOCH_DIFF = 11644473600000L; - final long ms_since_16010101 = wFILETIME / (10000); - final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF; - - result.setTimeInMillis(ms_since_19700101); - - return result; - } - - public Calendar execute(Id id) throws IOException, ProtocolException { - - Calendar ret = null; - - connection.write(GET_EXTENDED_FIELD); - connection.write(id.get().getBytes()); - connection.write(EXTENDED_FIELD_NUMBER); - connection.flush(); - - buffer = new byte[2]; - int c = connection.read(buffer, 0, 2); - if (c < 2) { - throw getException_InvalidResponseLength(c, 2, 2); - } - - // Not found - if (buffer[0] == (byte) 0xd0 && buffer[1] == (byte) 0xc3) { - throw new ProtocolException("ID handle is not found!"); - } else - // 1. Found - if (buffer[0] == (byte) 0xdf && buffer[1] == (byte) 0xc3) { - - // 2. read NOF BYTES - buffer = new byte[1]; - c = connection.read(buffer, 0, 1); - - int toRead = buffer[0]; - if (toRead != 8) { - throw new ProtocolException("Invalid ModifiedTimeStamp's data length: " + toRead); - } else { - filetime = new byte[8]; - c = connection.read(filetime, 0, 8); - if (c != 8) { - throw getException_InvalidResponseLength(c, 8, 8); - } - ret = convertFromFILETIME(filetime); - } - } - return ret; + @Override + protected byte[] getExtendedFieldNumber() { + return EXTENDED_FIELD_NUMBER; } } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldTimestampCommand.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldTimestampCommand.java new file mode 100644 index 00000000..638ba2a5 --- /dev/null +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/server/protocol/GetExtendedFieldTimestampCommand.java @@ -0,0 +1,78 @@ +package user.commons.nexio.server.protocol; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Calendar; + +public abstract class GetExtendedFieldTimestampCommand extends Command { + private final static byte[] GET_EXTENDED_FIELD = { (byte) 0xc9, (byte) 0xc3 }; + private byte[] buffer; + private byte filetime[]; + + public GetExtendedFieldTimestampCommand(Connection connection) { + super(connection); + } + + private Calendar convertFromFILETIME(byte[] filetime) { + Calendar result = Calendar.getInstance(); + + ByteBuffer b = ByteBuffer.wrap(filetime); + b.order(ByteOrder.LITTLE_ENDIAN); + int lo = b.asIntBuffer().get(0); + int hi = b.asIntBuffer().get(1); + + long wFILETIME = ((long) hi << 32) + lo; + + final long EPOCH_DIFF = 11644473600000L; + final long ms_since_16010101 = wFILETIME / (10000); + final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF; + + result.setTimeInMillis(ms_since_19700101); + + return result; + } + + public Calendar execute(Id id) throws IOException, ProtocolException { + + Calendar ret = null; + + connection.write(GET_EXTENDED_FIELD); + connection.write(id.get().getBytes()); + connection.write(getExtendedFieldNumber()); + connection.flush(); + + buffer = new byte[2]; + int c = connection.read(buffer, 0, 2); + if (c < 2) { + throw getException_InvalidResponseLength(c, 2, 2); + } + + // Not found + if (buffer[0] == (byte) 0xd0 && buffer[1] == (byte) 0xc3) { + throw new ProtocolException("ID handle is not found!"); + } else + // 1. Found + if (buffer[0] == (byte) 0xdf && buffer[1] == (byte) 0xc3) { + + // 2. read NOF BYTES + buffer = new byte[1]; + c = connection.read(buffer, 0, 1); + + int toRead = buffer[0]; + if (toRead != 8) { + throw new ProtocolException("Invalid TimeStamp's data length: " + toRead); + } else { + filetime = new byte[8]; + c = connection.read(filetime, 0, 8); + if (c != 8) { + throw getException_InvalidResponseLength(c, 8, 8); + } + ret = convertFromFILETIME(filetime); + } + } + return ret; + } + + protected abstract byte[] getExtendedFieldNumber(); +}