From: Vásáry Dániel Date: Mon, 4 Dec 2017 15:15:21 +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=69f4e8afe605e7c71abac2a37173f68d4be2084b;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30787 --- diff --git a/server/-configuration/run-mediacube-server-bsh.launch b/server/-configuration/run-mediacube-server-bsh.launch index f957593d..d0240306 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/-configuration/scheduledjobs.json b/server/-configuration/scheduledjobs.json index f69349ae..a430fef5 100644 --- a/server/-configuration/scheduledjobs.json +++ b/server/-configuration/scheduledjobs.json @@ -27,6 +27,23 @@ {"name": "killDateDays", "value": 1, "type": "java.lang.Integer"} ] }, + { + "active": false, + "name" : "NEXIO anyagok másolása az ISILON/ARCHIVE mappába", + "template": "copyforarchive-nexio-materials.xml", + "executeimmediate": true, + "cronexpression": "0 0 0/1 1/1 * ? *", + "parameters": [ + {"name": "nexioPort", "value": 2098, "type": "java.lang.Integer"}, + {"name": "nexioUserName", "value": "administrator", "type": "java.lang.String"}, + {"name": "nexioPassword", "value": "system", "type": "java.lang.String"}, + {"name": "archiveFtp", "value": "ftp://10.10.1.100/ARCHIVE/TEST", "type": "java.lang.String"}, + {"name": "archiveUserName", "value": "administrator", "type": "java.lang.String"}, + {"name": "archivePassword", "value": "system", "type": "java.lang.String"}, + {"name": "daysBeforeNow", "value": 1, "type": "java.lang.Integer"} + ] + }, + { "active": false, "name" : "TRAFFIC anyagok visszatöltése", @@ -61,7 +78,7 @@ "executeimmediate": true, "cronexpression": "0 0 0/1 1/1 * ? *", "parameters": [ - {"name": "sourcePath", "value": "o:\\_OLD", "type": "java.lang.String"} + {"name": "sourcePath", "value": "q:/TEST", "type": "java.lang.String"} ] }, { diff --git a/server/user.jobengine.executors/config/config.xml b/server/user.jobengine.executors/config/config.xml index 98f7388c..cd6c2e21 100644 --- a/server/user.jobengine.executors/config/config.xml +++ b/server/user.jobengine.executors/config/config.xml @@ -13,4 +13,5 @@ + \ No newline at end of file diff --git a/server/user.jobengine.executors/config/scheduledjobs.json b/server/user.jobengine.executors/config/scheduledjobs.json index f7014c18..95786867 100644 --- a/server/user.jobengine.executors/config/scheduledjobs.json +++ b/server/user.jobengine.executors/config/scheduledjobs.json @@ -56,14 +56,12 @@ }, { "active": false, - "name" : "Anyagok törlése", + "name" : "Lejárt ISISLON/ARCHIVE anyagok törlése", "template": "delete-materials.xml", "executeimmediate": true, "cronexpression": "0 0 0/1 1/1 * ? *", "parameters": [ - {"name": "sourcePath", "value": "\\\\10.10.1.100\\BRAAVOS\\ARCHIVE", "type": "java.lang.String"}, - {"name": "userName", "value": "mediacube", "type": "java.lang.String"}, - {"name": "password", "value": "Broadca5T", "type": "java.lang.String"} + {"name": "sourcePath", "value": "/mnt/ISILON/ARCHIVE", "type": "java.lang.String"} ] }, { diff --git a/server/user.jobengine.executors/jobtemplates/copyforarchive-nexio-materials.xml b/server/user.jobengine.executors/jobtemplates/copyforarchive-nexio-materials.xml new file mode 100644 index 00000000..17c4eda5 --- /dev/null +++ b/server/user.jobengine.executors/jobtemplates/copyforarchive-nexio-materials.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/user.jobengine.executors/jobtemplates/delete-materials.xml b/server/user.jobengine.executors/jobtemplates/delete-materials.xml index 87a695ec..9e8c02ff 100644 --- a/server/user.jobengine.executors/jobtemplates/delete-materials.xml +++ b/server/user.jobengine.executors/jobtemplates/delete-materials.xml @@ -1,5 +1,5 @@ - + diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CleanupMountedLocationStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CleanupMountedLocationStep.java index aee7cff6..88f20501 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/CleanupMountedLocationStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CleanupMountedLocationStep.java @@ -175,7 +175,10 @@ public class CleanupMountedLocationStep extends JobStep implements FileVisitor

killDateFiles = getKillDateFiles(filePath); if (killDateFiles.size() == 0) return; @@ -230,7 +233,7 @@ public class CleanupMountedLocationStep extends JobStep implements FileVisitor

rundowns = octopusAPI.getRundowns(scheduledDate.getTime()); + if (rundowns == null) { + logger.warn(getMarker(), "Nem található adástükör a {} napra.", CalendarUtils.toDateString(scheduledDate)); + return null; + } + try { + int index = 1; + for (DBObject r : rundowns) { + setProgress(index * 100 / rundowns.size()); + processRundow(r); + index++; + } + } catch (Exception e) { + logger.catching(e); + logger.error(getMarker(), e.getMessage()); + throw e; + } + return null; + } + + private void processMosObject(BasicDBObject rundown, BasicDBObject story, BasicDBObject mosObject) throws Exception { + String mosID = mosObject.getString(IOctopusAPI.OBJ_ID); + if (MetadataTypeDetector.GuessMetadataType(mosID) != MetadataType.OCTOPUSPLACEHOLDER) { + logger.warn("Skipping MOS object {}", mosID); + return; + } + + DBCollection clips = db.getCollection(NEXIOCLIPS); + DBObject clip = clips.findOne(new BasicDBObject(LONGNAMEID, mosID)); + if (clip == null) { + logger.info("File NOT exists {}", mosID); + throw new Exception("Not exists"); + } else { + logger.info("File exists {}", mosID); + } + + BasicDBObject metadata = createMetadata(rundown, story, mosObject); + } + + private void processRundow(DBObject r) throws Exception { + BasicDBObject rundown = (BasicDBObject) r; + long rundownID = rundown.getLong(ID); + logger.info("Processing rundown {}", rundownID); + List stories = octopusAPI.getRundownStories(rundownID); + if (stories == null) + return; + for (DBObject s : stories) + processStory(rundown, s); + } + + private void processStory(BasicDBObject rundown, DBObject s) throws Exception { + BasicDBObject story = (BasicDBObject) s; + String parentStoryID = story.getString(IOctopusAPI.PARENT_STORY_ID); + logger.info("Processing story {}", parentStoryID); + List mosObjects = NoSQLUtils.asList(story, IOctopusAPI.MOS_OBJECTS); + if (mosObjects == null) + return; + for (BasicDBObject mosObject : mosObjects) + processMosObject(rundown, story, mosObject); + + } + + private void setAndCheck(int nexioPort, String nexioUserName, String nexioPassword, String archiveFtp, String archiveUserName, String archivePassword, + IJobEngine jobEngine) throws JobEngineException, IOException, URISyntaxException { + db = NoSQLUtils.getNoSQLDB(); + if (db == null) { + logger.error(getMarker(), "Az NoSQL adatkezelő réteg nem elérhető."); + throw new NullPointerException("Internal error, missing NoSQL DB reference."); + } + + if (jobEngine == null) { + logger.error(getMarker(), "Az folyamatkezelő réteg nem elérhető."); + throw new NullPointerException("Internal error, missing JobEngine reference."); + } + manager = jobEngine.getItemManager(); + if (manager == null) { + logger.error(getMarker(), "Az adatbáziskezelő réteg nem elérhető."); + throw new NullPointerException("Internal error, missing ItemManager reference."); + } + String nexioHost = System.getProperty("nexio.host"); + if (StringUtils.isBlank(nexioHost)) { + logger.error(getMarker(), "A 'nexio.host' rendszer paraméter nem található."); + throw new NullPointerException("System is not configured properly, 'jobengine.selenio.address' startup parameter missing."); + } + check(nexioPort, "nexioPort"); + check(nexioUserName, "nexioUserName"); + check(nexioPassword, "nexioPassword"); + + sourceUri = manager.createStoreUri(RemoteStoreProtocol.FTP, nexioHost); + sourceUri.setPortNumber(nexioPort); + sourceUri.setUserName(nexioUserName); + sourceUri.setPassword(nexioPassword); + + check(archiveFtp, "archiveFtp"); + check(archiveUserName, "archiveUserName"); + check(archivePassword, "archivePassword"); + + targetUri = manager.createStoreUri(new URI(archiveFtp)); + targetUri.setUserName(archiveUserName); + targetUri.setPassword(archivePassword); + } + +} diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteNEXIOMaterialsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteNEXIOMaterialsStep.java index 515000b8..0f872bd5 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteNEXIOMaterialsStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteNEXIOMaterialsStep.java @@ -49,7 +49,7 @@ public class DeleteNEXIOMaterialsStep extends JobStep { throw new NullPointerException("System is not configured properly, 'jobengine.selenio.address' startup parameter missing."); } - DB db = NoSQLUtils.getDB(); + DB db = NoSQLUtils.getNoSQLDB(); DBCollection collection = db.getCollection(NEXIOCLIPS); //https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/MetadataTypeDetector.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/MetadataTypeDetector.java new file mode 100644 index 00000000..bfa97f50 --- /dev/null +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/MetadataTypeDetector.java @@ -0,0 +1,29 @@ +package user.jobengine.server.steps; + +import org.apache.commons.lang.StringUtils; + +public class MetadataTypeDetector { + public enum MetadataType { + TRAFFIC, OCTOPUSSTORY, OCTOPUSPLACEHOLDER, GENERIC + } + + private static final String REGEXP_TRAFFIC = "^[MRP]{1}[0-9]{6}[A-Z]{1}$"; + private static final String REGEXP_OCTOPUSSTORYID = "^[0-9]+$"; + private static final String REGEXP_OCTOPUSPLACEHOLDERID = "^[0-9]+_[0-9]+$"; + private static final String REGEXP_OCTOPUSPLACEHOLDERVERSIONEDID = "^[0-9]+_[0-9]+-[0-9]{3}$"; + + public static MetadataType GuessMetadataType(String id) { + if (StringUtils.isBlank(id)) + return MetadataType.GENERIC; + if (id.matches(REGEXP_TRAFFIC)) + return MetadataType.TRAFFIC; + if (id.matches(REGEXP_OCTOPUSSTORYID)) + return MetadataType.OCTOPUSSTORY; + if (id.matches(REGEXP_OCTOPUSPLACEHOLDERID)) + return MetadataType.OCTOPUSPLACEHOLDER; + if (id.matches(REGEXP_OCTOPUSPLACEHOLDERVERSIONEDID)) + return MetadataType.OCTOPUSPLACEHOLDER; + return MetadataType.GENERIC; + } + +} diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/OutputPathAndNameSelectorStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/OutputPathAndNameSelectorStep.java index 323c7e74..cb85b8d0 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/OutputPathAndNameSelectorStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/OutputPathAndNameSelectorStep.java @@ -15,17 +15,13 @@ import org.apache.logging.log4j.Logger; import user.jobengine.server.IJobEngine; import user.jobengine.server.IJobRuntime; +import user.jobengine.server.steps.MetadataTypeDetector.MetadataType; public class OutputPathAndNameSelectorStep extends JobStep { - private enum MetadataType { - TRAFFIC, OCTOPUS, GENERIC - } private static final String TARGETNAMEPATTERN = "-ARCH-%s"; private static final Logger logger = LogManager.getLogger(); - private static final String REGEXP_TRAFFIC = "^[MRP]{1}[0-9]{6}[A-Z]{1}$"; - private static final String REGEXP_OCTOPUSID = "^[0-9]+$"; private void check(String trafficOutputPath, String octopusOutputPath, String genericOutputPath, String houseId) { if (StringUtils.isBlank(trafficOutputPath)) { @@ -63,13 +59,14 @@ public class OutputPathAndNameSelectorStep extends JobStep { check(trafficOutputPath, octopusOutputPath, genericOutputPath, houseId); String id = houseId.toUpperCase(); - MetadataType mdType = GuessMetadataType(id); + MetadataType mdType = MetadataTypeDetector.GuessMetadataType(id); String targetPath = null; switch (mdType) { case GENERIC: targetPath = Paths.get(genericOutputPath, id).toString(); break; - case OCTOPUS: + case OCTOPUSPLACEHOLDER: + case OCTOPUSSTORY: targetPath = Paths.get(octopusOutputPath, id).toString(); break; case TRAFFIC: @@ -86,12 +83,4 @@ public class OutputPathAndNameSelectorStep extends JobStep { return new Object[] { targetPath, targetNamePattern }; } - private MetadataType GuessMetadataType(String id) { - if (id.matches(REGEXP_TRAFFIC)) - return MetadataType.TRAFFIC; - if (id.matches(REGEXP_OCTOPUSID)) - return MetadataType.OCTOPUS; - return MetadataType.GENERIC; - } - } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java b/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java index f5d9dbe0..0771926f 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/StoreUri.java @@ -153,6 +153,11 @@ public class StoreUri extends EntityBase implements Serializable { throw new Exception("InputLister is null."); } + public boolean fileExists(String fileName) throws Exception { + ensureLister(); + return lister.exists(fileName); + } + public void fireProgressEvent(ProgressEvent evt) { Object[] listeners = progressListenerList.getListenerList(); for (int i = 0; i < listeners.length; i += 2) { diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioAPI.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioAPI.java index 01b9d946..b8c95520 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioAPI.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioAPI.java @@ -24,7 +24,7 @@ public class NexioAPI implements INexioAPI { List result = null; DB db; try { - db = NoSQLUtils.getDB(); + db = NoSQLUtils.getNoSQLDB(); DBCollection collection = db.getCollection(NexioDataMiner.CLIP_COLLECTION_NAME); DBCursor find = collection.find().sort(new BasicDBObject(MODIFIEDTIMESTAMP, new BasicDBList(-1, "$date"))); if (find.hasNext()) 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 851fdd76..712fff3e 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 @@ -5,6 +5,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import javax.swing.event.EventListenerList; @@ -26,7 +28,6 @@ import user.commons.nexio.server.protocol.Connection; import user.commons.nexio.server.protocol.GetExtendedFieldCommand; import user.commons.nosql.NoSQLUtils; import user.commons.remotestore.IProgressEventListener; -import user.commons.remotestore.ProgressEvent; /** * NexioWSServlet hozza letre. Indulaskor betolti a teljes nexio clip listat mongodb-be. Beregisztralja magat ClipEventListener-nek. Az erkezo esemenyekkel @@ -52,6 +53,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { public static final String CLIP_COLLECTION_NAME = "nexioclips"; static private final byte[] GET_SPECIAL_ID_ATTRIBUTES_REQ = { (byte) 0xC8, (byte) 0x84 }; static private final char[] hexArray = "0123456789ABCDEF".toCharArray(); + private static final ExecutorService executor = Executors.newFixedThreadPool(1); public static String bytesToBin(byte[] bytes) { StringBuilder result = new StringBuilder(); @@ -87,64 +89,14 @@ public class NexioClipEventDispatcher implements ClipEventListener { } private EventListenerList progressListenerList; - private ProgressEvent progressEvent = new ProgressEvent(this, 0); private INexioChangeListener nexioChangeListener; private DB db; - //BEGIN OF R - - //R - private String NEXIO_HOST = System.getProperty("nexio.host"); //"10.228.43.18"; //echo: "10.10.1.55"; vmware: "10.228.43.18" - + private String NEXIO_HOST = System.getProperty("nexio.host"); private Controller controller = null; - //KONSTRUKTOR - //KONSTRUKTOR public NexioClipEventDispatcher() { - try { - this.db = NoSQLUtils.getDB(); - - // BasicDBObject jsClip = new BasicDBObject(); - // jsClip.put(ID, "%00001"); //Unique internal ID - // jsClip.put(LONGNAMEID, "valami1"); //Extended ID (Filename) - // jsClip.put(DURATION, 100); - // jsClip.put(MODIFIEDTIMESTAMP, new Date()); - // jsClip.put(EXTAGENCY, "TEST1"); - // Map emptyMap = new HashMap(); - // this.saveClipIntoMongo(jsClip, emptyMap); - - //nexio init - this.controller = new Controller(NEXIO_HOST); - this.controller.connect(); - //this.controller.getMediabase().getMediaListener().addClipEventListener(this); - logger.info("NEXIO server is connected."); - - this.progressListenerList = new EventListenerList(); - - this.dropAllClipsFromMongo(); - this.ensureIndexes(); - - //load clips into mongo - - Thread importThread = new Thread(new Runnable() { - @Override - public void run() { - try { - //1. kezdeti masolas - copyClipsIntoMongo(); - //2. esemeny feliratkozas - NexioClipEventDispatcher.this.controller.getMediabase().startMediaListener(); - NexioClipEventDispatcher.this.controller.getMediabase().getMediaListener().addClipEventListener(NexioClipEventDispatcher.this); - } catch (Exception e) { - logger.catching(e); - } - } - }); - importThread.start(); - - } catch (Exception exc) { - logger.error("", exc); - } + this.db = NoSQLUtils.getNoSQLDB(); } public void addProgressListener(IProgressEventListener listener) { @@ -157,7 +109,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { //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()); + BasicDBObject jsClip = clipToJSON(evt.getClip()); String fileName = jsClip.getString(LONGNAMEID); if (fileName != null && !"".equals(fileName)) { @@ -182,25 +134,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { } } - //END OF R - /* - 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()); - jsClip.put(MODIFIEDTIMESTAMP, clip.getModifiedTimestamp().getTime()); - jsClip.put(VIDEO_FORMAT, clip.getVideoFormat()); - jsClip.put(VIDEO_BITRATE, clip.getVideoBitrate()); - jsClip.put(FILESIZE, clip.getFileSize()); - jsClip.put(EXTAGENCY, clip.getExtendedField(GetExtendedFieldCommand.FN_AGENCY)); - //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)); - } - */ - - private BasicDBObject convertClipToJSON(Clip clip) throws Exception { + private BasicDBObject clipToJSON(Clip clip) throws Exception { BasicDBObject jsClip = new BasicDBObject(); try { String xid = clip.getId().get(); @@ -276,7 +210,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { Clip clip = null; try { clip = clips.next(); - BasicDBObject jsonClip = convertClipToJSON(clip); + BasicDBObject jsonClip = clipToJSON(clip); String fileName = jsonClip.getString(LONGNAMEID); String agency = jsonClip.getString(EXTAGENCY); int duration = jsonClip.getInt(DURATION); @@ -293,6 +227,24 @@ public class NexioClipEventDispatcher implements ClipEventListener { logger.info("NEXIO metadata import completed."); } + //END OF R + /* + 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()); + jsClip.put(MODIFIEDTIMESTAMP, clip.getModifiedTimestamp().getTime()); + jsClip.put(VIDEO_FORMAT, clip.getVideoFormat()); + jsClip.put(VIDEO_BITRATE, clip.getVideoBitrate()); + jsClip.put(FILESIZE, clip.getFileSize()); + jsClip.put(EXTAGENCY, clip.getExtendedField(GetExtendedFieldCommand.FN_AGENCY)); + //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)); + } + */ + public void dropAllClipsFromMongo() { db.getCollection(CLIP_COLLECTION_NAME).drop(); } @@ -338,14 +290,14 @@ public class NexioClipEventDispatcher implements ClipEventListener { } /* - + int c = connection.read(buffer, 0, 2); //2 bytes hosszan az idokozben hozzaadott id-k szamossaga if (c < 2) { throw new ProtocolException("c, 2, 2"); } //MSB, LSB - + return nofIds; */ return ret; @@ -420,6 +372,14 @@ public class NexioClipEventDispatcher implements ClipEventListener { } } + public void setNexioChangeListener(INexioChangeListener nexioChangeListener) { + this.nexioChangeListener = nexioChangeListener; + } + + public void shutdown() { + executor.shutdownNow(); + } + /* BasicDBObject clip = new BasicDBObject(); clip.put(LONGNAMEID, rs.getString(i++)); @@ -436,8 +396,31 @@ public class NexioClipEventDispatcher implements ClipEventListener { } */ - public void setNexioChangeListener(INexioChangeListener nexioChangeListener) { - this.nexioChangeListener = nexioChangeListener; + public void startup() { + this.controller = new Controller(NEXIO_HOST); + try { + this.controller.connect(); + } catch (Exception e) { + logger.catching(e); + return; + } + logger.info("NEXIO server is connected."); + + this.progressListenerList = new EventListenerList(); + this.dropAllClipsFromMongo(); + this.ensureIndexes(); + + executor.submit(() -> { + try { + //1. kezdeti masolas + copyClipsIntoMongo(); + //2. esemeny feliratkozas + NexioClipEventDispatcher.this.controller.getMediabase().startMediaListener(); + NexioClipEventDispatcher.this.controller.getMediabase().getMediaListener().addClipEventListener(NexioClipEventDispatcher.this); + } catch (Exception e) { + logger.catching(e); + } + }); } private String toUTF8(String iso88592) throws UnsupportedEncodingException { 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 7df5813b..b937f65f 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 @@ -58,7 +58,7 @@ public class NexioDataMiner implements Runnable, INexioChangeListener { public NexioDataMiner() { this.progressListenerList = new EventListenerList(); - db = NoSQLUtils.getDB(); + db = NoSQLUtils.getNoSQLDB(); ensureIndexes(); } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nosql/NoSQLUtils.java b/server/user.jobengine.osgi.commons/src/user/commons/nosql/NoSQLUtils.java index 08eb93f8..e81b8f63 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nosql/NoSQLUtils.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nosql/NoSQLUtils.java @@ -66,7 +66,7 @@ public class NoSQLUtils { return result; } - public static DB getDB() { + public static DB getNoSQLDB() { DB result = null; try { result = NoSQLClient.getDB(NoSQLUtils.Url, NoSQLUtils.User, NoSQLUtils.Pass); diff --git a/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java b/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java index fa6674af..595fd762 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java @@ -24,7 +24,7 @@ public class OctopusAPI implements IOctopusAPI { private DB db; public OctopusAPI() throws SQLException { - db = NoSQLUtils.getDB(); + db = NoSQLUtils.getNoSQLDB(); } private void addReferences(List result) { @@ -33,11 +33,11 @@ public class OctopusAPI implements IOctopusAPI { continue; BasicDBObject story = (BasicDBObject) storyObject; if (story.containsKey(REF_RUNDOWN) && story.get(REF_RUNDOWN) != null) { - List rundowns = getReferencedObjects(result, RUNDOWN_COLLECTION_NAME, REF_RUNDOWN); + List rundowns = getReferencedObjects(result, RUNDOWN_COLLECTION, REF_RUNDOWN); story.put(REF_RUNDOWN, rundowns); } if (story.containsKey(REF_STORYFOLDER) && story.get(REF_STORYFOLDER) != null) { - List storyFolders = getReferencedObjects(result, STORY_FOLDER_COLLECTION_NAME, REF_STORYFOLDER); + List storyFolders = getReferencedObjects(result, FOLDER_COLLECTION, REF_STORYFOLDER); story.put(REF_STORYFOLDER, storyFolders); } } @@ -74,7 +74,7 @@ public class OctopusAPI implements IOctopusAPI { @Override public List getRundowns(Date scheduledDate) { List result = null; - DBCollection collection = db.getCollection(RUNDOWN_COLLECTION_NAME); + DBCollection collection = db.getCollection(RUNDOWN_COLLECTION); Calendar calStart = CalendarUtils.createZeroCalendar(scheduledDate); Calendar calStop = CalendarUtils.createZeroCalendar(scheduledDate); calStop.add(Calendar.DAY_OF_MONTH, 1); @@ -97,22 +97,22 @@ public class OctopusAPI implements IOctopusAPI { @Override public List getRundownsByParentStoryID(String id) { - DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection storyCollection = db.getCollection(STORY_COLLECTION); DBCursor find = storyCollection.find(new BasicDBObject(PARENT_STORY_ID, id), new BasicDBObject(REF_RUNDOWN, 1)); if (!find.hasNext()) return null; - return getReferencedObjects(find.toArray(), RUNDOWN_COLLECTION_NAME, REF_RUNDOWN); + return getReferencedObjects(find.toArray(), RUNDOWN_COLLECTION, REF_RUNDOWN); } @Override public List getRundownsByPlaceHolderID(String id) { //db.testStoryCollection.find({"mosObjects": {$elemMatch: {"globalId": "OCTOPUS-ECHOTV-2429902"}}}) - DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection storyCollection = db.getCollection(STORY_COLLECTION); BasicDBObject criteria = new BasicDBObject(MOS_OBJECTS, new BasicDBObject($ELEMMATCH, new BasicDBObject(OBJ_ID, id))); DBCursor find = storyCollection.find(criteria, new BasicDBObject(REF_RUNDOWN, 1)); if (!find.hasNext()) return null; - return getReferencedObjects(find.toArray(), RUNDOWN_COLLECTION_NAME, REF_RUNDOWN); + return getReferencedObjects(find.toArray(), RUNDOWN_COLLECTION, REF_RUNDOWN); } @Override @@ -120,7 +120,7 @@ public class OctopusAPI implements IOctopusAPI { // db.stories.find({ rundown: { $elemMatch: { id: 92950867 } }}) // { rundown: { $elemMatch: { id: 44622396 } }} List result = null; - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection collection = db.getCollection(STORY_COLLECTION); DBCursor find = collection .find(new BasicDBObject(REF_RUNDOWN, new BasicDBObject($ELEMMATCH, new BasicDBObject(ID, id))), new BasicDBObject(ID, 1) .append(PARENT_STORY_ID, 1).append(NAME, 1).append(MODIFIED, 1).append(REF_RUNDOWN, 1).append(FORMAT, 1).append(MOS_OBJECTS, 1)) @@ -133,7 +133,7 @@ public class OctopusAPI implements IOctopusAPI { @Override public List getStories() { List result = null; - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection collection = db.getCollection(STORY_COLLECTION); DBCursor find = collection.find(); if (find.hasNext()) result = find.toArray(); @@ -143,7 +143,7 @@ public class OctopusAPI implements IOctopusAPI { @Override public List getStoriesByID(String id) { List result = null; - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection collection = db.getCollection(STORY_COLLECTION); DBCursor find = collection.find(new BasicDBObject(ID, id)); if (find.hasNext()) { result = find.toArray(); @@ -157,7 +157,7 @@ public class OctopusAPI implements IOctopusAPI { //Pattern regex = Pattern.compile(id, Pattern.CASE_INSENSITIVE); //BasicDBObject query = new BasicDBObject("id", Pattern.compile(id)); List result = null; - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection collection = db.getCollection(STORY_COLLECTION); DBCursor find = collection.find(new BasicDBObject(PARENT_STORY_ID, id)); if (find.hasNext()) { result = find.toArray(); @@ -169,7 +169,7 @@ public class OctopusAPI implements IOctopusAPI { @Override public List getStoriesByPlaceHolderID(String id) { List result = new ArrayList<>(); - DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection storyCollection = db.getCollection(STORY_COLLECTION); BasicDBObject criteria = new BasicDBObject(MOS_OBJECTS, new BasicDBObject($ELEMMATCH, new BasicDBObject(OBJ_ID, id))); DBCursor find = storyCollection.find(criteria); if (find.hasNext()) { @@ -182,7 +182,7 @@ public class OctopusAPI implements IOctopusAPI { @Override public List getStoryFolders() { List result = null; - DBCollection collection = db.getCollection(STORY_FOLDER_COLLECTION_NAME); + DBCollection collection = db.getCollection(FOLDER_COLLECTION); DBCursor find = collection.find(); if (find.hasNext()) result = find.toArray(); @@ -191,27 +191,27 @@ public class OctopusAPI implements IOctopusAPI { @Override public List getStoryFoldersByParentStoryID(String id) { - DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); - DBCursor find = storyCollection.find(new BasicDBObject(ID, id), new BasicDBObject(REF_STORYFOLDER, 1)); + DBCollection storyCollection = db.getCollection(STORY_COLLECTION); + DBCursor find = storyCollection.find(new BasicDBObject(PARENT_STORY_ID, id), new BasicDBObject(REF_STORYFOLDER, 1)); if (!find.hasNext()) return null; - return getReferencedObjects(find.toArray(), STORY_FOLDER_COLLECTION_NAME, REF_STORYFOLDER); + return getReferencedObjects(find.toArray(), FOLDER_COLLECTION, REF_STORYFOLDER); } @Override public List getStoryFoldersByPlaceHolderID(String id) { - DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection storyCollection = db.getCollection(STORY_COLLECTION); BasicDBObject criteria = new BasicDBObject(MOS_OBJECTS, new BasicDBObject($ELEMMATCH, new BasicDBObject(OBJ_ID, id))); DBCursor find = storyCollection.find(criteria, new BasicDBObject(REF_STORYFOLDER, 1)); if (!find.hasNext()) return null; - return getReferencedObjects(find.toArray(), STORY_FOLDER_COLLECTION_NAME, REF_STORYFOLDER); + return getReferencedObjects(find.toArray(), FOLDER_COLLECTION, REF_STORYFOLDER); } @Override public List getStoryFolderStories(long storyFolderId) { List result = null; - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection collection = db.getCollection(STORY_COLLECTION); DBCursor find = collection .find(new BasicDBObject(REF_STORYFOLDER, new BasicDBObject($ELEMMATCH, new BasicDBObject(ID, storyFolderId))), new BasicDBObject(ID, 1) .append(PARENT_STORY_ID, 1).append(NAME, 1).append(MODIFIED, 1).append(REF_STORYFOLDER, 1).append(FORMAT, 1).append(MOS_OBJECTS, 1)) diff --git a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/FtpDirectoryLister.java b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/FtpDirectoryLister.java index 6b479bcb..1dafa89e 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/FtpDirectoryLister.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/FtpDirectoryLister.java @@ -11,6 +11,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.apache.commons.net.ftp.FTPFile; +import org.apache.commons.net.ftp.FTPFileFilter; import user.commons.IRemoteFileListCallback; import user.commons.RemoteFile; @@ -76,25 +77,26 @@ public class FtpDirectoryLister implements IDirectoryLister { } private void connect() throws Exception { + if (ftpClient != null) + return; String path = storeUri.toString(true); String[] pathElements = path.split("/"); - if (ftpClient == null) { - ftpClient = new FTPClient(); - if (storeUri.getPortNumber() != null) - ftpClient.connect(pathElements[0], storeUri.getPortNumber().intValue()); - else - ftpClient.connect(pathElements[0]); - String userName = storeUri.getUserName(); - userName = StringUtils.isEmpty(userName) ? "anonymous" : userName; - ftpClient.login(userName, storeUri.getPassword()); - ftpClient.setFileType(FTP.BINARY_FILE_TYPE); - ftpClient.enterLocalPassiveMode(); - if (pathElements.length > 1) { - for (int i = 1; i < pathElements.length; i++) { - ftpClient.changeWorkingDirectory(pathElements[i]); - } + ftpClient = new FTPClient(); + if (storeUri.getPortNumber() != null) + ftpClient.connect(pathElements[0], storeUri.getPortNumber().intValue()); + else + ftpClient.connect(pathElements[0]); + String userName = storeUri.getUserName(); + userName = StringUtils.isEmpty(userName) ? "anonymous" : userName; + ftpClient.login(userName, storeUri.getPassword()); + ftpClient.setFileType(FTP.BINARY_FILE_TYPE); + ftpClient.enterLocalPassiveMode(); + if (pathElements.length > 1) { + for (int i = 1; i < pathElements.length; i++) { + ftpClient.changeWorkingDirectory(pathElements[i]); } } + } @Override @@ -107,6 +109,27 @@ public class FtpDirectoryLister implements IDirectoryLister { } } + @Override + public boolean exists(String fileName) throws Exception { + connect(); + if (ftpClient == null) + return false; + // FTPFile[] files = ftpClient.listFiles(ftpClient.printWorkingDirectory(), new FTPFileFilter() { + // @Override + // public boolean accept(FTPFile paramFTPFile) { + // return fileName.equals(paramFTPFile.getName()); + // } + // }); + FTPFile[] files = ftpClient.listFiles(null, new FTPFileFilter() { + @Override + public boolean accept(FTPFile paramFTPFile) { + return !paramFTPFile.isDirectory() && fileName.toLowerCase().equals(paramFTPFile.getName().toLowerCase()); + } + }); + + return files.length == 1; + } + @Override public RemoteFile get(String fileName) throws Exception { RemoteFile result = null; diff --git a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/IDirectoryLister.java b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/IDirectoryLister.java index d3df2407..fb4a1421 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/IDirectoryLister.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/IDirectoryLister.java @@ -15,6 +15,8 @@ public interface IDirectoryLister { void delete(RemoteFile remoteFile) throws Exception; + boolean exists(String fileName) throws Exception; + RemoteFile get(String fileName) throws Exception; InputStream getInputStream(RemoteFile remoteFile) throws Exception; diff --git a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/LocalDirectoryLister.java b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/LocalDirectoryLister.java index dd9f3b83..93d9a9e4 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/LocalDirectoryLister.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/LocalDirectoryLister.java @@ -5,6 +5,8 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Path; +import java.nio.file.Paths; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; @@ -44,6 +46,12 @@ public class LocalDirectoryLister implements IDirectoryLister { } + @Override + public boolean exists(String fileName) throws Exception { + Path path = Paths.get(storeUri.toString(true), fileName); + return path.toFile().exists(); + } + @Override public RemoteFile get(String fileName) throws Exception { String path = storeUri.toString(true); diff --git a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/SambaDirectoryLister.java b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/SambaDirectoryLister.java index 9be67791..73ca4045 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/SambaDirectoryLister.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/SambaDirectoryLister.java @@ -48,6 +48,12 @@ public class SambaDirectoryLister implements IDirectoryLister { } } + @Override + public boolean exists(String fileName) throws Exception { + // TODO Auto-generated method stub + return false; + } + @Override public RemoteFile get(String fileName) throws Exception { RemoteFile result = null; diff --git a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/TSMLister.java b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/TSMLister.java index aab159d4..ad3331db 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/remotestore/TSMLister.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/remotestore/TSMLister.java @@ -46,6 +46,12 @@ public class TSMLister implements IDirectoryLister { } + @Override + public boolean exists(String fileName) throws Exception { + // TODO Auto-generated method stub + return false; + } + @Override public RemoteFile get(String fileName) throws Exception { RemoteFile result = null; diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/db/IItemManager.java b/server/user.jobengine.osgi.db/src/user/jobengine/db/IItemManager.java index 251a19f0..73081aa4 100644 --- a/server/user.jobengine.osgi.db/src/user/jobengine/db/IItemManager.java +++ b/server/user.jobengine.osgi.db/src/user/jobengine/db/IItemManager.java @@ -1,5 +1,6 @@ package user.jobengine.db; +import java.net.URI; import java.sql.Timestamp; import java.util.Date; import java.util.List; @@ -18,12 +19,11 @@ import user.jobengine.db.ItemManagerData.StaticTables; import user.jobengine.db.ItemManagerData.UserRight; /*** - * Adatbázis kezelő API. Az implementáció OSGI szolgáltatásként érhető el ezen - * az interfészen keresztül. Az API főbb szolgáltatásai: az adatmodell - * objektumainak létrehozása, módosítása, törlése az adatbázisban. - * + * Adatbázis kezelő API. Az implementáció OSGI szolgáltatásként érhető el ezen az interfészen keresztül. Az API főbb szolgáltatásai: az adatmodell objektumainak + * létrehozása, módosítása, törlése az adatbázisban. + * * @author comtrans - * + * */ public interface IItemManager extends IEntityPersister { /** @@ -33,7 +33,7 @@ public interface IItemManager extends IEntityPersister { /** * A megfelelő bemeneti paramétrekekkel meghívja a connect() függvényt. - * + * * @param dbUrl * Adatbázis elérési útvonala * @param dbUser @@ -43,8 +43,9 @@ public interface IItemManager extends IEntityPersister { */ void connect(String dbUrl, String dbUser, String dbPassword); - FileType createFileType(String name, String description, String videoCodec, String audioCodec, int videoTracks, - int audioTracks, float frameRate); + FileType createFileType(String name, String description, String videoCodec, String audioCodec, int videoTracks, int audioTracks, float frameRate); + + Item createItem(String name, String description, String houseId); Item createItem(String itemTypeName, String name, String description, String houseId); @@ -58,8 +59,8 @@ public interface IItemManager extends IEntityPersister { Metadata createMetadata(MetadataElement mde, ListType listType, GuiType guiType, MdType... flags); - Metadata createMetadata(MetadataElement mde, ListType listType, GuiType guiType, String sqlField, - StaticTables staticTable, String pojoField, MdType... flags); + Metadata createMetadata(MetadataElement mde, ListType listType, GuiType guiType, String sqlField, StaticTables staticTable, String pojoField, + MdType... flags); Metadata createMetadata(MetadataElement mde, MdType... flags); @@ -81,17 +82,21 @@ public interface IItemManager extends IEntityPersister { StoreUri createStoreUri(RemoteStoreProtocol protocol, String uri); - StoreUri createStoreUri(RemoteStoreProtocol protocol, String uri, int portNumber, boolean isStream, - boolean isSource, boolean isTarget, String userName, String password, String rootPath); + StoreUri createStoreUri(RemoteStoreProtocol protocol, String uri, int portNumber, boolean isStream, boolean isSource, boolean isTarget, String userName, + String password, String rootPath); + + StoreUri createStoreUri(URI uri); UserInfo createUser(String fullName, String userName, String password, UserRight[] rights); + WorkflowAction createWorkflowAction(Timestamp touched, Timestamp started, Timestamp finished, boolean successful, String houseId, String description, + String source, String destination, String tag, long size); + void disconnect(); /** - * A type paraméterből lekéri az entitás DAO objektumát, amin keresztül - * visszakapjuk az összes entitást. - * + * A type paraméterből lekéri az entitás DAO objektumát, amin keresztül visszakapjuk az összes entitást. + * * @param type * @return */ @@ -99,7 +104,7 @@ public interface IItemManager extends IEntityPersister { /** * Entitás típus és azonosító alapján visszaad egy listát. - * + * * @param type * @param id * @return @@ -108,7 +113,7 @@ public interface IItemManager extends IEntityPersister { /** * Visszaadja egy átmeneti tárolóban tárolt entitás listáját. - * + * * @param baseClass * @return */ @@ -116,7 +121,7 @@ public interface IItemManager extends IEntityPersister { /** * Visszaadja az entitásnak megfelelő DAO objektumot. - * + * * @param classInfo * @return */ @@ -125,9 +130,15 @@ public interface IItemManager extends IEntityPersister { Break getBreak(long id); /** - * Elkéri a FileTypeDAO-tól a bemeneti paraméterként kapott névvel - * rendelekző FileType-ot. - * + * Elkéri az összes dinamikus anyag típust. + * + * @return + */ + List getDynamicItemTypes(); + + /** + * Elkéri a FileTypeDAO-tól a bemeneti paraméterként kapott névvel rendelekző FileType-ot. + * * @param name * @return */ @@ -135,7 +146,7 @@ public interface IItemManager extends IEntityPersister { /** * Visszaad egy szűrési feltételeknek megfelelő Domain listát. - * + * * @param domainCategoryId * @param filter * @return @@ -144,7 +155,7 @@ public interface IItemManager extends IEntityPersister { /** * Visszaad egy szűrési feltételeknek megfelelő QueryObject listát. - * + * * @param filter * @param isChunked * @return @@ -153,7 +164,7 @@ public interface IItemManager extends IEntityPersister { /** * Visszaad egy szűrési feltételeknek megfelelő Vágólista listát. - * + * * @param name * @param isChunked * @return @@ -161,47 +172,27 @@ public interface IItemManager extends IEntityPersister { List getFilteredScene(String name, boolean isChunked); /** - * A bemenő paraméterként kapott azonosító alaján lekéri a megfelelő Mappa - * objektumokat. - * + * A bemenő paraméterként kapott azonosító alaján lekéri a megfelelő Mappa objektumokat. + * * @param id * @return */ List getFolders(long id); - /** - * A bemenő paraméterként kapott azonosító alaján lekéri a megfelelő Szkript - * objektumokat. - * - * @param id - * @return - */ - List getShots(long id); + Item getItemByHouseID(String houseID); + + ItemType getItemType(String itemTypeName); /** * Elkéri az összes anyag típust. - * + * * @return */ List getItemTypes(); - /** - * Elkéri az összes dinamikus anyag típust. - * - * @return - */ - List getDynamicItemTypes(); - - /** - * Elkéri az fix anyag típust. - * - * @return - */ - ItemType getStaticItemType(); - /** * Azonosító alapján elkér egy Verzió objektumot. - * + * * @param id * @return */ @@ -209,7 +200,7 @@ public interface IItemManager extends IEntityPersister { /** * Azonosító alapján elkér egy Metaadat elem objektumot. - * + * * @param id * @return */ @@ -217,22 +208,24 @@ public interface IItemManager extends IEntityPersister { /** * Visszaadja az adatbázisban tárolt összes Metaadat elem listáját. - * + * * @return */ List getMetadataElements(); /** * Azonosító alapján elkér egy Metadatat típus objektumot. - * + * * @param id * @return */ MetadataType getMetadataType(long id); + List getRunningJobs(String template); + /** * Azonosító alapján elkér egy Vágólista objektumot. - * + * * @param id * @return */ @@ -240,7 +233,7 @@ public interface IItemManager extends IEntityPersister { /** * Név és időpont alapján elkéri a megfelelő Vágólista objektumokat. - * + * * @param name * @param created * @return @@ -249,15 +242,30 @@ public interface IItemManager extends IEntityPersister { /** * Azonosító alapján elkér egy Szkript objektumot. - * + * * @param id * @return */ Shot getShot(long id); + /** + * A bemenő paraméterként kapott azonosító alaján lekéri a megfelelő Szkript objektumokat. + * + * @param id + * @return + */ + List getShots(long id); + + /** + * Elkéri az fix anyag típust. + * + * @return + */ + ItemType getStaticItemType(); + /** * Azonosító alapján elkér egy Tároló objektumot. - * + * * @param id * @return */ @@ -265,26 +273,23 @@ public interface IItemManager extends IEntityPersister { /** * Név alapján elkér egy Szkript objektumot. - * + * * @param name * @return */ Store getStore(String name); /** - * Elkér a StoreDAO-tól, egy olyan Rendszer tárolót, amely a lowres - * paraméterben kapott érték alapján vagy kisfelbontású videók tárolója, - * vagy nem. - * + * Elkér a StoreDAO-tól, egy olyan Rendszer tárolót, amely a lowres paraméterben kapott érték alapján vagy kisfelbontású videók tárolója, vagy nem. + * * @param lowres * @return */ Store getSystemStore(boolean lowres); /** - * Ha a bemeneti paraméter alapján létezik ilyen felhasználó, akkor true-val - * tér vissza. - * + * Ha a bemeneti paraméter alapján létezik ilyen felhasználó, akkor true-val tér vissza. + * * @param userName * @param password * @return @@ -292,37 +297,39 @@ public interface IItemManager extends IEntityPersister { boolean getUser(String userName, String password); /** - * A bemeneti paraméterként megadott felhasználónév/jelszó páros alapján - * visszaad egy UserInfo objektumot. - * + * A bemeneti paraméterként megadott felhasználónév/jelszó páros alapján visszaad egy UserInfo objektumot. + * * @param userName * @param password * @return */ UserInfo getUserInfo(String userName, String password); + List getWorkflowActions(Date date); + + void merge(IEntityBase entity); + + void mergeItemStructure(Item item); + /** - * A bemeneti paraméterként kapott típus és azonosító lista alapján - * eltávolítja a megfelelő adatbázis bejegyzéseket. - * + * A bemeneti paraméterként kapott típus és azonosító lista alapján eltávolítja a megfelelő adatbázis bejegyzéseket. + * * @param type * @param ids */ void remove(Class type, List ids); /** - * A bemeneti paraméterként kapott típus és azonosító alapján az objektumot - * eltávolítja az átmeneti tárolóból. - * + * A bemeneti paraméterként kapott típus és azonosító alapján az objektumot eltávolítja az átmeneti tárolóból. + * * @param baseClass * @param key */ void removeCached(Class baseClass, Object key); /** - * A bemeneti paraméterként kapott típus és kulcs alapján elkéri a megfelelő - * objektumot az átmeneti tárolóból. - * + * A bemeneti paraméterként kapott típus és kulcs alapján elkéri a megfelelő objektumot az átmeneti tárolóból. + * * @param baseClass * @param key * @return @@ -330,28 +337,26 @@ public interface IItemManager extends IEntityPersister { IEntityBase retrieveCached(Class baseClass, Object key); /** - * A bemeneti paraméterként kapott keresési feltételeknek megfelelő - * Anyagokat lekéri az adatbázisból és SearchResult objektumba csomagolva - * visszatér. - * + * A bemeneti paraméterként kapott keresési feltételeknek megfelelő Anyagokat lekéri az adatbázisból és SearchResult objektumba csomagolva visszatér. + * * @param parameter * @return */ List searchItem(QueryObject parameter); + SearchResult searchItem(String criteria, int fromResult, int toResult); + /** - * A bemeneti paraméterként kapott keresési feltételeknek megfelelő - * Munkafolyamatokat lekéri az adaatbázisból. - * + * A bemeneti paraméterként kapott keresési feltételeknek megfelelő Munkafolyamatokat lekéri az adaatbázisból. + * * @param parameter * @return */ List searchJob(QueryObject parameter); /** - * A kapott három paraméter alapján létrehoz egy Signal objektumot, - * átkonvertálja bájt tömbbé és beteszi a Signalserver üzenetküldő sorába. - * + * A kapott három paraméter alapján létrehoz egy Signal objektumot, átkonvertálja bájt tömbbé és beteszi a Signalserver üzenetküldő sorába. + * * @param id * @param signalType * @param staticTable @@ -360,7 +365,7 @@ public interface IItemManager extends IEntityPersister { /** * Egy azonosítót és entitást elhelyez az átmeneti tárolóban. - * + * * @param key * @param entity * @return @@ -368,22 +373,19 @@ public interface IItemManager extends IEntityPersister { boolean storeCached(Object key, IEntityBase entity); /** - * Kivétel dobása esetén a kivétel üzenetét és a keletkezés helyét - * becsomagolja egy string-be, majd átadja a logger-nek. - * + * Kivétel dobása esetén a kivétel üzenetét és a keletkezés helyét becsomagolja egy string-be, majd átadja a logger-nek. + * * @param e */ void throwError(Exception e); /** - * Kiloggolja az kapott művelethez tartozó objektum típusát és a metódus - * nevét. + * Kiloggolja az kapott művelethez tartozó objektum típusát és a metódus nevét. */ void traceIn(); /** - * Kiloggolja az kapott művelet végén az objektum típusát és a metódus - * nevét. + * Kiloggolja az kapott művelet végén az objektum típusát és a metódus nevét. */ void traceOut(); @@ -394,27 +396,8 @@ public interface IItemManager extends IEntityPersister { /** * Törli a bemeneti paraméterként kapott entitás adatbázis bejegyzéseit. - * + * * @param classInfo */ void truncate(Class classInfo); - - Item createItem(String name, String description, String houseId); - - SearchResult searchItem(String criteria, int fromResult, int toResult); - - Item getItemByHouseID(String houseID); - - List getRunningJobs(String template); - - ItemType getItemType(String itemTypeName); - - WorkflowAction createWorkflowAction(Timestamp touched, Timestamp started, Timestamp finished, boolean successful, - String houseId, String description, String source, String destination, String tag, long size); - - List getWorkflowActions(Date date); - - void mergeItemStructure(Item item); - - void merge(IEntityBase entity); } \ No newline at end of file diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemManager.java b/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemManager.java index b144e136..41ceb080 100644 --- a/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemManager.java +++ b/server/user.jobengine.osgi.db/src/user/jobengine/db/ItemManager.java @@ -1,5 +1,6 @@ package user.jobengine.db; +import java.net.URI; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -341,6 +342,13 @@ public class ItemManager extends MemoryCache implements IItemManager { return entity; } + @Override + public StoreUri createStoreUri(URI uri) { + StoreUri result = createStoreUri(RemoteStoreProtocol.fromString(uri.toString()), uri.getHost(), uri.getPort(), false, false, false, null, null, null); + result.setRootPath(uri.getPath()); + return result; + } + @Override public UserInfo createUser(String fullName, String userName, String password, UserRight[] rights) { traceIn(); diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java index 9fa90c54..e4052726 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java @@ -495,6 +495,7 @@ public class JobEngine implements IJobEngine { Parser parser = new Parser(stream); Encoder encoder = new Encoder(); JobTemplate template = parser.parse(); + template.validate(); template.setFileName(fileName); IProgram program = (IProgram) encoder.visitJobTemplate(template, null); @@ -536,6 +537,7 @@ public class JobEngine implements IJobEngine { Parser parser = new Parser(stream); Encoder encoder = new Encoder(); JobTemplate jobTemplate = parser.parse(); + jobTemplate.validate(); jobTemplate.setFileName(name); IProgram program = (IProgram) encoder.visitJobTemplate(jobTemplate, null); programs.put(name, program); diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/ast/JobTemplate.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/ast/JobTemplate.java index 93981324..5819d99f 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/ast/JobTemplate.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/ast/JobTemplate.java @@ -1,5 +1,10 @@ package user.jobengine.server.ast; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * Gy�k�r oszt�ly. */ @@ -28,48 +33,110 @@ public class JobTemplate extends AST { return declarationSequence; } - public void setCommandSequence(CommandSequence commandSequence) { - this.commandSequence = commandSequence; - } - - public void setDeclarationSequence(DeclarationSequence declarationSequence) { - this.declarationSequence = declarationSequence; - } - - @Override - public Object visit(Visitor v, Object o) { - return v.visitJobTemplate(this, o); + public String getDescription() { + return description; } public String getFileName() { return fileName; } - public void setFileName(String fileName) { - this.fileName = fileName; - } - public String getName() { return name; } - public void setName(String name) { - this.name = name; + public boolean isMultiInstance() { + return multiInstance; } - public String getDescription() { - return description; + public void setCommandSequence(CommandSequence commandSequence) { + this.commandSequence = commandSequence; + } + + public void setDeclarationSequence(DeclarationSequence declarationSequence) { + this.declarationSequence = declarationSequence; } public void setDescription(String description) { this.description = description; } - public boolean isMultiInstance() { - return multiInstance; + public void setFileName(String fileName) { + this.fileName = fileName; } public void setMultiInstance(boolean multiInstance) { this.multiInstance = multiInstance; } + + public void setName(String name) { + this.name = name; + } + + public List validate() throws Exception { + Map parameters = new HashMap<>(); + Map variables = new HashMap<>(); + List inputvariables = new ArrayList<>(); + List inputparameters = new ArrayList<>(); + List errors = new ArrayList<>(); + if (declarationSequence != null) { + for (Declaration declaration : declarationSequence.getDeclarations()) { + if (declaration instanceof ParameterDeclaration) + parameters.put(declaration.getName(), declaration.getType()); + if (declaration instanceof VariableDeclaration) + variables.put(declaration.getName(), declaration.getType()); + } + } + + if (commandSequence != null) { + for (Command command : commandSequence.getCommands()) { + if (command instanceof CallJobStepCommand) { + ParameterSequence inputParameterSequence = ((CallJobStepCommand) command).getInputParameterSequence(); + if (inputParameterSequence != null) { + for (Parameter parameter : inputParameterSequence.getParameters()) { + Expression expression = ((InputParameter) parameter).getExpression(); + if (expression instanceof VariableExpression) { + if (!inputvariables.contains(expression.getName())) + inputvariables.add(expression.getName()); + } + if (expression instanceof ParameterExpression) { + if (!inputparameters.contains(expression.getName())) + inputparameters.add(expression.getName()); + } + } + } + ParameterSequence outputParameterSequence = ((CallJobStepCommand) command).getOutputParameterSequence(); + if (outputParameterSequence != null) { + for (Parameter parameter : outputParameterSequence.getParameters()) { + VariableName name = ((OutputParameter) parameter).getVariableName(); + if (!inputvariables.contains(name.getName())) + inputvariables.add(name.getName()); + } + } + } + } + + for (String input : inputvariables) { + if (!variables.containsKey(input)) + errors.add(String.format("Variable declaration missing for '%s'.", input)); + } + for (String input : inputparameters) { + if (!parameters.containsKey(input)) + errors.add(String.format("Parameter declaration missing for '%s'.", input)); + } + + } + + if (errors.size() > 0) { + StringBuilder sb = new StringBuilder(); + errors.forEach(e -> sb.append(e)); + throw new Exception("JobTemplate validation error: " + sb.toString()); + } + return errors; + } + + @Override + public Object visit(Visitor v, Object o) { + return v.visitJobTemplate(this, o); + } } diff --git a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/ws/nexio/NexioWSServlet.java b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/ws/nexio/NexioWSServlet.java index 4dda6423..24dced10 100644 --- a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/ws/nexio/NexioWSServlet.java +++ b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/ws/nexio/NexioWSServlet.java @@ -37,15 +37,16 @@ public class NexioWSServlet extends WebSocketServlet implements INexioChangeList logger.info("NexioAPIServlet created"); // messagePool = new NexioAPIServletMessagePool(3, sessions); instance = this; - this.dispatcher = new NexioClipEventDispatcher(); - this.dispatcher.setNexioChangeListener(this); + dispatcher = new NexioClipEventDispatcher(); + dispatcher.setNexioChangeListener(this); + //dispatcher.startup(); logger.info("NexioWSServlet has been initialized."); /* BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); if (bundleContext != null) { ServiceRegistration registerService = bundleContext .registerService(INexioChangeListener.class, this, null); - + logger.info("{} successfully registered", INexioChangeListener.class.getSimpleName()); } */