From: Vásáry Dániel Date: Fri, 15 Dec 2017 16:02:25 +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=707020e45408fb22bc42a68e4aefaa9e8940b5a8;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30811 --- diff --git a/client/AudioRecorder/AudioRecorderSettings.cs b/client/AudioRecorder/AudioRecorderSettings.cs index fcd3a9a8..8319a080 100644 --- a/client/AudioRecorder/AudioRecorderSettings.cs +++ b/client/AudioRecorder/AudioRecorderSettings.cs @@ -7,6 +7,7 @@ namespace AudioRecorder { public int PeekMeterStep { get; set; } public Uri WorkingDirectory { get; set; } public MetadataProvider[] Metadatas { get; set; } - public Target Target { get; set; } + public Target OctopusTarget { get; set; } + public Target TrafficTarget { get; set; } } } diff --git a/client/AudioRecorder/Configuration/audiorecorder.json b/client/AudioRecorder/Configuration/audiorecorder.json index 51dd7751..c586c7aa 100644 --- a/client/AudioRecorder/Configuration/audiorecorder.json +++ b/client/AudioRecorder/Configuration/audiorecorder.json @@ -2,7 +2,7 @@ "deviceName": "", "workingDirectory": "file://C:\\temp", "peekMeterStep": 200, - "target": { + "octopusTarget": { "label": "Octopus mappába küldés", "processor": "FTPTargetProcessor", "tag": "Betöltés", @@ -16,6 +16,20 @@ "timeout": 1000 } }, + "trafficTarget": { + "label": "Traffic mappába küldés", + "processor": "FTPTargetProcessor", + "tag": "Betöltés", + "outputFormat": "%ID%", + "subFolderFormat": "%IDROOT%-%TEXT%", + "killDateDays": 7, + "remote": { + "address": "ftp://10.10.1.100/PLAYOUT_NLE", + "userName": "mediacube", + "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", + "timeout": 1000 + } + }, "metadatas": [ { "$type": "OctopusMetadata", diff --git a/client/AudioRecorder/MainForm.cs b/client/AudioRecorder/MainForm.cs index fb621b7a..055828ec 100644 --- a/client/AudioRecorder/MainForm.cs +++ b/client/AudioRecorder/MainForm.cs @@ -12,6 +12,7 @@ using MaestroShared.Target; using System.Security.Principal; using MaestroShared.Targets; using static AudioRecorder.MetadataSelectorForm; +using MaestroShared.Metadata; namespace AudioRecorder { public delegate void RefreshPanelDelegate(); @@ -33,8 +34,8 @@ namespace AudioRecorder { private bool pausing; private BackgroundWorker volumeMonitor; private string currentRecordingPath; - private Metadata currentStory; - ITargetProcessor processor; + private Metadata currentMetadata; + public MainForm() { InitializeComponent(); @@ -77,7 +78,6 @@ namespace AudioRecorder { try { Type[] knownTypes = { typeof(AudioRecorderSettings), typeof(Target), typeof(Connection), typeof(OctopusMetadata), typeof(TrafficMetadata), typeof(MediaCubeMetadata) }; parameters = ConfigurationSerializer.Load(CONFIG_FILE, knownTypes); - processor = TargetProcessor.Create(parameters.Target.Processor); UpdateGUI(); timeCodeWorker = new TimeCodeWorker(timecodeLabel); @@ -207,8 +207,8 @@ namespace AudioRecorder { MetadataSelectorForm idSelectorForm = new MetadataSelectorForm(parameters); if (idSelectorForm.ShowDialog() == DialogResult.Cancel) return; - currentStory = idSelectorForm.SelectedMetadata; - currentRecordingPath = CreateCurrenRecordingPath(parameters.WorkingDirectory.LocalPath, currentStory.ID); + currentMetadata = idSelectorForm.SelectedMetadata; + currentRecordingPath = CreateCurrenRecordingPath(parameters.WorkingDirectory.LocalPath, currentMetadata.ID); txtRecordFilePath.Text = currentRecordingPath; if (String.IsNullOrEmpty(currentRecordingPath)) return; @@ -278,20 +278,41 @@ namespace AudioRecorder { } private void Export() { + if (String.IsNullOrEmpty(currentMetadata.ID)) { + MsgBox.Error("A kiválasztott metaadat azonosító nem lehet üres."); + return; + } + + MetadataType metadataType = MetadataTypeUtil.Guess(currentMetadata.ID); + + Target target = parameters.OctopusTarget; + + switch (metadataType) { + case MetadataType.TrafficAD: + case MetadataType.TrafficPromo: + case MetadataType.TrafficMaterial: + target = parameters.TrafficTarget; + break; + } + if (target == null) { + MsgBox.Error("Hiányos az 'audiorecorder.json' konfigurációs állomány, nem található 'target' beállítás."); + return; + } + TargetProcessorParameter processorParameter = new TargetProcessorParameter() { SourceConfig = new Source() { Local = new Connection() { Address = parameters.WorkingDirectory } }, - TargetConfig = parameters.Target, - ID = currentStory.ID, - MetadataText = currentStory.Text, + TargetConfig = target, + ID = currentMetadata.ID, + MetadataText = currentMetadata.Text, InputFileName = Path.GetFileName(currentRecordingPath), UserName = WindowsIdentity.GetCurrent().Name }; - ITargetProcessor processor = TargetProcessor.Create(parameters.Target.Processor); + ITargetProcessor processor = TargetProcessor.Create(target.Processor); processor.Initialize(null, processorParameter); processor.Execute(); diff --git a/client/AudioRecorder/Properties/AssemblyInfo.cs b/client/AudioRecorder/Properties/AssemblyInfo.cs index 4b7aa6b0..91267681 100644 --- a/client/AudioRecorder/Properties/AssemblyInfo.cs +++ b/client/AudioRecorder/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.0.6.8")] +[assembly: AssemblyFileVersion("2.0.6.8")] diff --git a/client/Maestro/Installer/installforge-installer-project.ifp b/client/Maestro/Installer/installforge-installer-project.ifp index abebe935..02cc44e2 100644 Binary files a/client/Maestro/Installer/installforge-installer-project.ifp and b/client/Maestro/Installer/installforge-installer-project.ifp differ diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index 23c11a6d..33883632 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -18,12 +18,6 @@ using MaestroShared.Commons; namespace Maestro { public partial class MaestroForm { private const string ARCHIVEID_PREFIX = "MC-"; - private const string REGEXP_TRAFFICMATERIALID = "^M{1}[0-9]{6}[A-Z]{1}$"; - private const string REGEXP_TRAFFICADID = "^R{1}[0-9]{6}[A-Z]{1}$"; - private const string REGEXP_TRAFFICPROMOID = "^P{1}[0-9]{6}[A-Z]{1}$"; - private const string REGEXP_OCTOPUSSTORYID = "^[0-9]+$"; - private const string REGEXP_OCTOPUSPLACEHOLDERID = "^[0-9]+_[0-9]+$"; - private const string REGEXP_OCTOPUSPLACEHOLDERVERSIONEDID = "^[0-9]+_[0-9]+-[0-9]{3}$"; private MetadataInfo selectedMetadata; private BindingList movieSegments; @@ -129,38 +123,6 @@ namespace Maestro { UpdateEditArchiveMetadataStatus(); } - private MetadataType GuessMetadataType(string id) { - if (String.IsNullOrEmpty(id)) - return MetadataType.None; - Match match = null; - - match = Regex.Match(id, REGEXP_TRAFFICMATERIALID); - if (match.Success) - return MetadataType.TrafficMaterial; - - match = Regex.Match(id, REGEXP_TRAFFICPROMOID); - if (match.Success) - return MetadataType.TrafficPromo; - - match = Regex.Match(id, REGEXP_TRAFFICADID); - if (match.Success) - return MetadataType.TrafficAD; - - match = Regex.Match(id, REGEXP_OCTOPUSSTORYID); - if (match.Success) - return MetadataType.OctopusStory; - - match = Regex.Match(id, REGEXP_OCTOPUSPLACEHOLDERID); - if (match.Success) - return MetadataType.OctopusPlaceHolder; - - match = Regex.Match(id, REGEXP_OCTOPUSPLACEHOLDERVERSIONEDID); - if (match.Success) - return MetadataType.OctopusPlaceHolder; - - return MetadataType.MediaCube; - } - private void OnDefineSegments(object sender, EventArgs e) { if (SelectedSource?.FileInfo == null) return; @@ -230,7 +192,7 @@ namespace Maestro { private ArchiveMetadata GetArchiveMetadata() { ArchiveMetadata result = null; Cursor.Current = Cursors.WaitCursor; - MetadataType metadataType = GuessMetadataType(textSelectedMetadata.Text); + MetadataType metadataType = MetadataTypeUtil.Guess(textSelectedMetadata.Text); switch (metadataType) { case MetadataType.None: case MetadataType.MediaCube: @@ -340,7 +302,7 @@ namespace Maestro { string text = textSelectedMetadata.Text; if (SelectedMetadata == null || !text.Equals(SelectedMetadata.ID)) { SelectedMetadata = new MetadataInfo() { - Kind = GuessMetadataType(text), + Kind = MetadataTypeUtil.Guess(text), ID = text }; } @@ -379,7 +341,7 @@ namespace Maestro { return; } trafficIDSelector.ClearSelection(); - MetadataType metadataType = GuessMetadataType(name); + MetadataType metadataType = MetadataTypeUtil.Guess(name); SelectedMetadata = new MetadataInfo() { Kind = metadataType, ID = name, @@ -395,7 +357,7 @@ namespace Maestro { return; } octopusIDSelector.ClearSelection(); - MetadataType metadataType = GuessMetadataType(id); + MetadataType metadataType = MetadataTypeUtil.Guess(id); SelectedMetadata = new MetadataInfo() { Kind = metadataType, ID = id, @@ -438,7 +400,7 @@ namespace Maestro { private void Lookup(string id) { MetadataProvider config = null; - MetadataType metadataType = GuessMetadataType(id); + MetadataType metadataType = MetadataTypeUtil.Guess(id); switch (metadataType) { case MetadataType.TrafficMaterial: config = Configuration.GetMetadataProvider(); @@ -495,7 +457,7 @@ namespace Maestro { } private void UpdateLookupByMetadataEnabled() { - MetadataType metadataType = GuessMetadataType(SelectedMetadata?.ID); + MetadataType metadataType = MetadataTypeUtil.Guess(SelectedMetadata?.ID); btnLookupMetadata.Enabled = metadataType != MetadataType.None && metadataType != MetadataType.MediaCube; } diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 96e9d7c8..dfd46f4d 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -355,7 +355,7 @@ namespace Maestro { return null; string nameWithoutExtension = name.Contains(".") ? name.Split('.')[0] : name; - var t = GuessMetadataType(nameWithoutExtension); + var t = MetadataTypeUtil.Guess(nameWithoutExtension); if (t != MetadataType.MediaCube && t != MetadataType.None) return nameWithoutExtension; @@ -374,7 +374,7 @@ namespace Maestro { start = o - 1; x = nameWithoutExtension.Substring(0, o); } - var z = GuessMetadataType(x); + var z = MetadataTypeUtil.Guess(x); if (z != MetadataType.MediaCube && z != MetadataType.None) return x; } @@ -459,7 +459,7 @@ namespace Maestro { } private void UpdateLookupBySourceEnabled() { - MetadataType metadataType = GuessMetadataType(SelectedSource?.Prefix); + MetadataType metadataType = MetadataTypeUtil.Guess(SelectedSource?.Prefix); btnLookupBySource.Enabled = metadataType != MetadataType.MediaCube && metadataType != MetadataType.None; } diff --git a/client/Maestro/Properties/AssemblyInfo.cs b/client/Maestro/Properties/AssemblyInfo.cs index 268a2a22..d54db5b5 100644 --- a/client/Maestro/Properties/AssemblyInfo.cs +++ b/client/Maestro/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.6.7")] -[assembly: AssemblyFileVersion("2.0.6.7")] +[assembly: AssemblyVersion("2.0.6.8")] +[assembly: AssemblyFileVersion("2.0.6.8")] diff --git a/client/MaestroShared/Metadata/MetadataType.cs b/client/MaestroShared/Metadata/MetadataType.cs index 537457e3..f5bf35c1 100644 --- a/client/MaestroShared/Metadata/MetadataType.cs +++ b/client/MaestroShared/Metadata/MetadataType.cs @@ -1,5 +1,51 @@ -namespace MaestroShared.Metadata { +using System; +using System.Text.RegularExpressions; + +namespace MaestroShared.Metadata { public enum MetadataType { None, MediaCube, OctopusStory, OctopusPlaceHolder, TrafficMaterial, TrafficPromo, TrafficAD } + + public class MetadataTypeUtil { + private const string REGEXP_TRAFFICMATERIALID = "^M{1}[0-9]{6}[A-Z]{1}$"; + private const string REGEXP_TRAFFICADID = "^R{1}[0-9]{6}[A-Z]{1}$"; + private const string REGEXP_TRAFFICPROMOID = "^P{1}[0-9]{6}[A-Z]{1}$"; + private const string REGEXP_OCTOPUSSTORYID = "^[0-9]+$"; + private const string REGEXP_OCTOPUSPLACEHOLDERID = "^[0-9]+_[0-9]+$"; + private const string REGEXP_OCTOPUSPLACEHOLDERVERSIONEDID = "^[0-9]+_[0-9]+-[0-9]{3}$"; + + public static MetadataType Guess(string id) { + if (String.IsNullOrEmpty(id)) + return MetadataType.None; + Match match = null; + + match = Regex.Match(id, REGEXP_TRAFFICMATERIALID); + if (match.Success) + return MetadataType.TrafficMaterial; + + match = Regex.Match(id, REGEXP_TRAFFICPROMOID); + if (match.Success) + return MetadataType.TrafficPromo; + + match = Regex.Match(id, REGEXP_TRAFFICADID); + if (match.Success) + return MetadataType.TrafficAD; + + match = Regex.Match(id, REGEXP_OCTOPUSSTORYID); + if (match.Success) + return MetadataType.OctopusStory; + + match = Regex.Match(id, REGEXP_OCTOPUSPLACEHOLDERID); + if (match.Success) + return MetadataType.OctopusPlaceHolder; + + match = Regex.Match(id, REGEXP_OCTOPUSPLACEHOLDERVERSIONEDID); + if (match.Success) + return MetadataType.OctopusPlaceHolder; + + return MetadataType.MediaCube; + } + + + } } diff --git a/client/OctopusClient/OctopusIDSelector.cs b/client/OctopusClient/OctopusIDSelector.cs index 819574e9..ff66331e 100644 --- a/client/OctopusClient/OctopusIDSelector.cs +++ b/client/OctopusClient/OctopusIDSelector.cs @@ -92,8 +92,14 @@ namespace OctopusClient { } private void AddStories(IEnumerable stories, bool isFolderView = false) { + + IEnumerable sortedStories = stories; + if (isFolderView) + sortedStories = stories.OrderBy(s => s.ParentStoryID); + if (sortedStories == null) + return; treeOctopus.BeginUpdate(); - foreach (var story in stories) { + foreach (var story in sortedStories) { string name = story.Name == null ? OctopusAPI.UNNAMED : story.Name; //String ID = isFolderView ? story.ID : story.ParentStoryID; string label = String.Empty; @@ -103,10 +109,7 @@ namespace OctopusClient { } else label = String.Format($"{parentStoryID} {story.Name}"); - logger.Debug("Adding story {0} {1}", parentStoryID, label); - if ("21519676".Equals(parentStoryID)) { - logger.Debug(":"); - } + //logger.Debug("Adding story {0} {1}", parentStoryID, label); TreeNode storyNode = treeOctopus.Nodes.Add(parentStoryID, label); storyNode.Tag = story; @@ -143,8 +146,6 @@ namespace OctopusClient { } } } - if (isFolderView) - treeOctopus.Sort(); treeOctopus.EndUpdate(); if (selectedNode != null) { diff --git a/server/-configuration/jetty/etc/user-jetty-http.xml b/server/-configuration/jetty/etc/user-jetty-http.xml index 1de4649a..95b63984 100644 --- a/server/-configuration/jetty/etc/user-jetty-http.xml +++ b/server/-configuration/jetty/etc/user-jetty-http.xml @@ -32,7 +32,7 @@ - + diff --git a/server/-configuration/run-mediacube-server-bsh.launch b/server/-configuration/run-mediacube-server-bsh.launch index 7b162214..5b9bf249 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/run-mediacube-server-localhost.launch b/server/-configuration/run-mediacube-server-localhost.launch index e0055ef3..49372acd 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/-configuration/run-mediacube-server.launch b/server/-configuration/run-mediacube-server.launch index cae3cc97..2ecf882c 100644 --- a/server/-configuration/run-mediacube-server.launch +++ b/server/-configuration/run-mediacube-server.launch @@ -19,7 +19,7 @@ - + diff --git a/server/-configuration/run-mediacube-server2_adam.launch b/server/-configuration/run-mediacube-server2_adam.launch deleted file mode 100644 index c3b8743c..00000000 --- a/server/-configuration/run-mediacube-server2_adam.launch +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/server/-configuration/scheduledjobs.json b/server/-configuration/scheduledjobs.json index 7a8ea8cc..c18a56ad 100644 --- a/server/-configuration/scheduledjobs.json +++ b/server/-configuration/scheduledjobs.json @@ -38,12 +38,13 @@ {"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"} + {"name": "archiveUserName", "value": "mediacube", "type": "java.lang.String"}, + {"name": "archivePassword", "value": "Broadca5T", "type": "java.lang.String"}, + {"name": "daysBeforeNow", "value": 1, "type": "java.lang.Integer"}, + {"name": "nexioKillDateDays", "value": 7, "type": "java.lang.Integer"}, + {"name": "nexioAgency", "value": "ARCHIVED", "type": "java.lang.String"} ] }, - { "active": false, "name" : "TRAFFIC anyagok visszatöltése", @@ -91,7 +92,7 @@ {"name": "port", "value": 2098, "type": "java.lang.Integer"}, {"name": "userName", "value": "administrator", "type": "java.lang.String"}, {"name": "password", "value": "system", "type": "java.lang.String"}, - {"name": "gracePeriodDays", "value": 1, "type": "java.lang.Integer"} + {"name": "gracePeriodDays", "value": 12, "type": "java.lang.Integer"} ] }, { @@ -123,11 +124,11 @@ "parameters": [ {"name": "itemID", "value": 1, "type": "java.lang.Long"} ] }, { - "active": false, + "active": true, "name" : "Teszt folyamat", "template": "fake-noparams.xml", "executeimmediate": false, - "cronexpression": "0/10 * * ? * *", + "cronexpression": "0 40 22 * * ?", "parameters": [ {"name": "itemID", "value": 1, "type": "java.lang.Long"} ] } ]} diff --git a/server/user.jobengine.executors/config/scheduledjobs.json b/server/user.jobengine.executors/config/scheduledjobs.json index 657888a1..c0c9dff6 100644 --- a/server/user.jobengine.executors/config/scheduledjobs.json +++ b/server/user.jobengine.executors/config/scheduledjobs.json @@ -14,7 +14,7 @@ "executeimmediate": false, "name" : "Archiválás az ISILON/ARCHIVE mappából", "template": "archive-ondemand.xml", - "cronexpression": "0 0 12 * * ?", + "cronexpression": "0 0 23 * * ?", "parameters": [ {"name": "sourcePath", "value": "/mnt/ISILON/ARCHIVE", "type": "java.lang.String"}, {"name": "globalSourcePath", "value": "\\\\10.10.1.100\\BRAAVOS\\ARCHIVE", "type": "java.lang.String"}, @@ -24,6 +24,24 @@ ] }, { + "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": "mediacube", "type": "java.lang.String"}, + {"name": "archivePassword", "value": "Broadca5T", "type": "java.lang.String"}, + {"name": "daysBeforeNow", "value": 1, "type": "java.lang.Integer"}, + {"name": "nexioKillDateDays", "value": 7, "type": "java.lang.Integer"}, + {"name": "nexioAgency", "value": "ARCHIVED", "type": "java.lang.String"} + ] + }, + { "active": true, "name" : "Lejárt ISISLON/ARCHIVE anyagok törlése", "template": "delete-materials.xml", diff --git a/server/user.jobengine.executors/jobtemplates/copyforarchive-nexio-materials.xml b/server/user.jobengine.executors/jobtemplates/copyforarchive-nexio-materials.xml index 17c4eda5..2abc5ae5 100644 --- a/server/user.jobengine.executors/jobtemplates/copyforarchive-nexio-materials.xml +++ b/server/user.jobengine.executors/jobtemplates/copyforarchive-nexio-materials.xml @@ -10,6 +10,8 @@ + + @@ -36,6 +38,12 @@ + + + + + + diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteMaterialsStep.java b/server/user.jobengine.executors/src/obsolate/DeleteMaterialsStep.java similarity index 94% rename from server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteMaterialsStep.java rename to server/user.jobengine.executors/src/obsolate/DeleteMaterialsStep.java index 333f8d08..4e6d2217 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteMaterialsStep.java +++ b/server/user.jobengine.executors/src/obsolate/DeleteMaterialsStep.java @@ -1,4 +1,4 @@ -package user.jobengine.server.steps; +package obsolate; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -15,6 +15,8 @@ import user.commons.remotestore.RemoteStoreProtocol; import user.jobengine.db.IItemManager; import user.jobengine.server.IJobEngine; import user.jobengine.server.IJobRuntime; +import user.jobengine.server.steps.JobStep; +import user.jobengine.server.steps.StepEntry; public class DeleteMaterialsStep extends JobStep { private static final Logger logger = LogManager.getLogger(); diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java index 3570e102..b2a474c8 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java @@ -1,10 +1,8 @@ package user.jobengine.server.steps; -import java.io.IOException; import java.io.OutputStream; import java.net.InetAddress; import java.net.URI; -import java.net.URISyntaxException; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -19,9 +17,11 @@ import org.apache.logging.log4j.Logger; import com.ibm.nosql.json.api.BasicDBObject; import com.ibm.nosql.json.api.DB; import com.ibm.nosql.json.api.DBCollection; +import com.ibm.nosql.json.api.DBCursor; import com.ibm.nosql.json.api.DBObject; import user.commons.CalendarUtils; +import user.commons.ListUtils; import user.commons.StoreUri; import user.commons.nosql.NoSQLUtils; import user.commons.octopus.IOctopusAPI; @@ -32,25 +32,31 @@ import user.commons.remotestore.RemoteStoreProtocol; import user.jobengine.db.IItemManager; import user.jobengine.server.IJobEngine; import user.jobengine.server.IJobRuntime; -import user.jobengine.server.JobEngineException; import user.jobengine.server.steps.MetadataTypeDetector.MetadataType; public class CopyForArchiveNEXIOMaterialsStep extends JobStep { + private static final String SCHEDULED_FORMAT = "yyyy.MM.dd HH:mm"; + private static final Logger logger = LogManager.getLogger(); + private static final String ARCHIVED = "ARCHIVED"; private static final String UTF_8 = "utf-8"; private static final String JSON_EXT = ".json"; + private static final String XML_EXT = ".xml"; private static final String DURATION = "duration"; private static final String MXFEXT = ".MXF"; - private static final Logger logger = LogManager.getLogger(); private static final String NEXIOCLIPS = "nexioclips"; - private static final String KILLDATE = "killdate"; private static final String LONGNAMEID = "longnameid"; + private static final String ARCHIVEDRUNDOWNS = "archivedrundowns"; private static final String ID = "id"; - private StoreUri sourceUri; - private StoreUri targetUri; private OctopusAPI octopusAPI; private IItemManager manager; private DB db; + private FTPClient sourceFtp; + private FTPClient targetFtp; + private StoreUri sourceUri; + private StoreUri targetUri; + private int nexioKillDateDays; + private String nexioAgency; private int check(int value, String name) { if (value == 0) { @@ -77,22 +83,22 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { } private void copyFile(FileArchive fileArchive, RundownArchive rundownArchive, StoryArchive storyArchive) throws Exception { - FTPClient source = ((FtpDirectoryLister) RemoteFileHandler.createLister(sourceUri)).connect(); - FTPClient target = ((FtpDirectoryLister) RemoteFileHandler.createLister(targetUri)).connect(); String fileName = fileArchive.getFileName(); - transferFile(source, target, fileName); + String videoFileName = fileName + MXFEXT; + transferFile(videoFileName); BasicDBObject metadata = createMetadata(rundownArchive, storyArchive, fileArchive); try { - if (!target.changeWorkingDirectory(EscortFiles.STATUSFOLDER)) - target.makeDirectory(EscortFiles.STATUSFOLDER); - if (!target.changeWorkingDirectory(EscortFiles.STATUSFOLDER)) + if (!targetFtp.changeWorkingDirectory(EscortFiles.STATUSFOLDER)) + targetFtp.makeDirectory(EscortFiles.STATUSFOLDER); + if (!targetFtp.changeWorkingDirectory(EscortFiles.STATUSFOLDER)) throw new Exception("!STATUSFOLDER"); } catch (Exception e) { logger.catching(e); throw e; } - transferMetadata(target, fileName, metadata); - createSourceKillDateFile(source, fileName); + transferMetadata(videoFileName, metadata); + targetFtp.changeToParentDirectory(); + createSourceKillDateFile(rundownArchive, fileName); } private BasicDBObject createMetadata(RundownArchive rundownArchive, StoryArchive storyArchive, FileArchive fileArchive) { @@ -120,13 +126,23 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { return result; } - private void createSourceKillDateFile(FTPClient source, String fileName) { + private void createSourceKillDateFile(RundownArchive rundownArchive, String fileName) throws Exception { + Calendar killDate = CalendarUtils.createCalendar(rundownArchive.getScheduleDate()); + killDate.add(Calendar.DAY_OF_YEAR, nexioKillDateDays); + byte[] killDateFile = EscortFiles.createNEXIOKillDateFile(fileName, killDate.getTime(), null, nexioAgency); + try (OutputStream outStream = sourceFtp.storeFileStream(fileName + XML_EXT)) { + outStream.write(killDateFile); + outStream.flush(); + } catch (Exception e) { + logger.catching(e); + throw e; + } } @StepEntry public Object[] execute(int nexioPort, String nexioUserName, String nexioPassword, String archiveFtp, String archiveUserName, String archivePassword, - int daysBeforeNow, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { - setAndCheck(nexioPort, nexioUserName, nexioPassword, archiveFtp, archiveUserName, archivePassword, jobEngine); + int daysBeforeNow, int nexioKillDateDays, String nexioAgency, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + setAndCheck(nexioPort, nexioUserName, nexioPassword, archiveFtp, archiveUserName, archivePassword, nexioKillDateDays, nexioAgency, jobEngine); octopusAPI = new OctopusAPI(); Calendar scheduledDate = Calendar.getInstance(); scheduledDate.add(Calendar.DAY_OF_YEAR, -1 * daysBeforeNow); @@ -135,42 +151,31 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { logger.warn(getMarker(), "Nem található adástükör a {} napra.", CalendarUtils.toDateString(scheduledDate)); return null; } - int index = 1; - - for (DBObject r : rundowns) { - setProgress(index * 100 / rundowns.size()); - try { - RundownArchive rundownArchive = processRundow(r); - if (rundownArchive == null || rundownArchive.isEmpty()) - continue; - copy(rundownArchive); - } catch (Exception e) { - logger.catching(e); - logger.error(getMarker(), - "A {} tükör archiválása nem lehetséges, mert a annak ellenőrzése hibát jelzett. A rendszer üzenete: " + e.getMessage()); - } - index++; - } + processRundowns(rundowns); + if (sourceUri != null) + sourceUri.cleanUp(); + if (targetUri != null) + targetUri.cleanUp(); return null; } private FileArchive 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); + logger.trace("Skipping MOS object {}", mosID); return null; } DBCollection clips = db.getCollection(NEXIOCLIPS); BasicDBObject clip = (BasicDBObject) clips.findOne(new BasicDBObject(LONGNAMEID, mosID)); if (clip == null) { - logger.info("File NOT exists {}", mosID); + logger.debug("File NOT exists {}", mosID); throw new Exception(String.format("File NOT exists %s", mosID)); } else { - logger.info("File exists {}", mosID); + logger.debug("File exists {}", mosID); } long duration = NoSQLUtils.asLong(clip, DURATION); - return new FileArchive(mosID + MXFEXT, duration); + return new FileArchive(mosID, duration); } private RundownArchive processRundow(DBObject r) throws Exception { @@ -181,11 +186,6 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { if (stories == null) return null; RundownArchive result = new RundownArchive(); - // { - // "id":22358752, - // "rundownType":{"name":"Híradó"}, - // "scheduledStart":{"$date":"2017-12-09T19:00:00.000Z"} - // } long id = NoSQLUtils.asLong(rundown, IOctopusAPI.ID); if (id == 0) @@ -193,13 +193,14 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { String name = NoSQLUtils.asString(NoSQLUtils.asDBObject(rundown, IOctopusAPI.RUNDOWN_TYPE), IOctopusAPI.NAME); if (StringUtils.isBlank(name)) return null; + String channel = NoSQLUtils.asString(NoSQLUtils.asDBObject(rundown, IOctopusAPI.CHANNEL), IOctopusAPI.NAME); Date scheduledStart = rundown.getDate(IOctopusAPI.SCHEDULED_START); if (scheduledStart == null) return null; - String start = CalendarUtils.toHunString(CalendarUtils.createCalendar(scheduledStart)); - + String start = CalendarUtils.toString(CalendarUtils.createCalendar(scheduledStart), SCHEDULED_FORMAT); + result.setScheduleDate(scheduledStart); result.setItemHouseId(String.valueOf(id)); - result.setItemTitle(String.format("%s - %s", start, name)); + result.setItemTitle(String.format("%s %s %s", start, name, channel)); for (DBObject s : stories) { StoryArchive storyArchive = processStory(rundown, s); @@ -210,6 +211,42 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { return result; } + private void processRundowns(List rundowns) { + //db.getCollection(ARCHIVEDRUNDOWNS).drop(); + List archivedRundowns = queryArchivedRundowns(); + + int index = 1; + for (DBObject r : rundowns) { + BasicDBObject rundown = (BasicDBObject) r; + setProgress(index * 100 / rundowns.size()); + try { + long rundownID = NoSQLUtils.asLong(rundown, IOctopusAPI.ID); + BasicDBObject currentRundownID = new BasicDBObject(IOctopusAPI.ID, rundownID); + String rundownName = rundown.getString(IOctopusAPI.NAME); + if (archivedRundowns != null && archivedRundowns.contains(currentRundownID)) { + logger.info("Skipping archived rundown {} {}", rundownID, rundownName); + continue; + } + + RundownArchive rundownArchive = processRundow(r); + if (rundownArchive == null || rundownArchive.isEmpty()) { + logger.info("Skipping rundown {} {}", NoSQLUtils.asLong(rundown, IOctopusAPI.ID), rundown.getString(IOctopusAPI.NAME)); + continue; + } + + logger.info("Saving rundown {} {}", rundownID, rundownName); + copy(rundownArchive); + + db.getCollection(ARCHIVEDRUNDOWNS).save(currentRundownID); + } catch (Exception e) { + logger.catching(e); + logger.error(getMarker(), + "A {} tükör archiválása nem lehetséges, mert a annak ellenőrzése hibát jelzett. A rendszer üzenete: " + e.getMessage()); + } + index++; + } + } + private StoryArchive processStory(BasicDBObject rundown, DBObject s) throws Exception { BasicDBObject story = (BasicDBObject) s; String parentStoryID = story.getString(IOctopusAPI.PARENT_STORY_ID); @@ -217,7 +254,7 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { logger.warn("Story parentStoryID is null: {}", story.toPrettyString(null)); return null; } else - logger.info("Processing story {}", parentStoryID); + logger.debug("Processing story {}", parentStoryID); List mosObjects = NoSQLUtils.asList(story, IOctopusAPI.MOS_OBJECTS); if (mosObjects == null) return null; @@ -239,8 +276,17 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { } + private List queryArchivedRundowns() { + List result = null; + DBCollection collection = db.getCollection(ARCHIVEDRUNDOWNS); + DBCursor find = collection.find(new BasicDBObject(), new BasicDBObject(IOctopusAPI._ID, 0).append(IOctopusAPI.ID, 1)); + if (find.hasNext()) + result = ListUtils.cast(find.toArray()); + return result; + } + private void setAndCheck(int nexioPort, String nexioUserName, String nexioPassword, String archiveFtp, String archiveUserName, String archivePassword, - IJobEngine jobEngine) throws JobEngineException, IOException, URISyntaxException { + int nexioKillDateDays, String nexioAgency, IJobEngine jobEngine) throws Exception { db = NoSQLUtils.getNoSQLDB(); if (db == null) { logger.error(getMarker(), "Az NoSQL adatkezelő réteg nem elérhető."); @@ -265,6 +311,11 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { check(nexioUserName, "nexioUserName"); check(nexioPassword, "nexioPassword"); + check(nexioKillDateDays, "nexioKillDateDays"); + this.nexioKillDateDays = nexioKillDateDays; + check(nexioAgency, "nexioAgency"); + this.nexioAgency = nexioAgency; + sourceUri = manager.createStoreUri(RemoteStoreProtocol.FTP, nexioHost); sourceUri.setPortNumber(nexioPort); sourceUri.setUserName(nexioUserName); @@ -277,41 +328,45 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { targetUri = manager.createStoreUri(new URI(archiveFtp)); targetUri.setUserName(archiveUserName); targetUri.setPassword(archivePassword); + + sourceFtp = ((FtpDirectoryLister) RemoteFileHandler.createLister(sourceUri)).connect(); + targetFtp = ((FtpDirectoryLister) RemoteFileHandler.createLister(targetUri)).connect(); + } - private void transferFile(FTPClient source, FTPClient target, String fileName) throws Exception { + private void transferFile(String fileName) throws Exception { int reply = 0; - if (!target.enterRemotePassiveMode()) + if (!targetFtp.enterRemotePassiveMode()) throw new Exception("!PASV"); - reply = source.port(InetAddress.getByName(target.getPassiveHost()), target.getPassivePort()); + reply = sourceFtp.port(InetAddress.getByName(targetFtp.getPassiveHost()), targetFtp.getPassivePort()); if (!FTPReply.isPositiveCompletion(reply)) throw new Exception("!PORT"); - if (!source.setFileType(FTP.BINARY_FILE_TYPE)) + if (!sourceFtp.setFileType(FTP.BINARY_FILE_TYPE)) throw new Exception("!SOURCE TYPE"); - source.retr(fileName); + sourceFtp.retr(fileName); - if (!target.setFileType(FTP.BINARY_FILE_TYPE)) + if (!targetFtp.setFileType(FTP.BINARY_FILE_TYPE)) throw new Exception("!TARGET TYPE"); - target.stor(fileName); + targetFtp.stor(fileName); while (true) { - reply = source.stat(); + reply = sourceFtp.stat(); if (!FTPReply.isPositiveCompletion(reply)) throw new Exception("!STAT"); - String replyText = source.getReplyString(); - if ("Transaction completed".equals(replyText)) + String replyText = sourceFtp.getReplyString(); + if ("226 RETR Transfer Complete(TRANSACTION_SUCCESS)".equals(replyText)) break; Thread.sleep(500); } } - private void transferMetadata(FTPClient target, String fileName, BasicDBObject metadata) throws Exception { - try (OutputStream outStream = target.storeFileStream(fileName + JSON_EXT)) { + private void transferMetadata(String fileName, BasicDBObject metadata) throws Exception { + try (OutputStream outStream = targetFtp.storeFileStream(fileName + JSON_EXT)) { outStream.write(metadata.toString().getBytes(UTF_8)); outStream.flush(); } catch (Exception e) { diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java new file mode 100644 index 00000000..cc38abec --- /dev/null +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java @@ -0,0 +1,18 @@ +package user.jobengine.server.steps; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import user.jobengine.db.IItemManager; +import user.jobengine.server.IJobEngine; +import user.jobengine.server.IJobRuntime; + +public class CreateMissingLowresStep extends JobStep { + private static final Logger logger = LogManager.getLogger(); + private IItemManager manager; + + @StepEntry + public Object[] execute(IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + return null; + } +} 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 0f872bd5..ac3add9c 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 @@ -1,18 +1,21 @@ package user.jobengine.server.steps; import java.util.Calendar; +import java.util.Date; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.ibm.nosql.json.api.BasicDBObject; import com.ibm.nosql.json.api.DB; import com.ibm.nosql.json.api.DBCollection; import com.ibm.nosql.json.api.DBCursor; -import com.ibm.nosql.json.api.DBObject; import com.ibm.nosql.json.api.QueryBuilder; +import user.commons.CalendarUtils; +import user.commons.ListUtils; import user.commons.RemoteFile; import user.commons.StoreUri; import user.commons.nosql.NoSQLUtils; @@ -26,6 +29,7 @@ public class DeleteNEXIOMaterialsStep extends JobStep { private static final String NEXIOCLIPS = "nexioclips"; private static final String KILLDATE = "killdate"; private static final String LONGNAMEID = "longnameid"; + private static final String EXTAGENCY = "extagency"; private StoreUri sourceUri; private void delete(String name) { @@ -42,7 +46,7 @@ public class DeleteNEXIOMaterialsStep extends JobStep { } @StepEntry - public Object[] execute(int port, String userName, String password, int gracePeriodDays, IJobEngine jobEngine, IJobRuntime jobRuntime) { + public Object[] execute(int port, String userName, String password, int gracePeriodDays, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { String nexioHost = System.getProperty("nexio.host"); if (StringUtils.isBlank(nexioHost)) { logger.error(getMarker(), "A 'nexio.host' rendszer paraméter nem található."); @@ -72,9 +76,11 @@ public class DeleteNEXIOMaterialsStep extends JobStep { sourceUri.setUserName(userName); sourceUri.setPassword(password); - List clips = cursor.toArray(); - for (DBObject dbObject : clips) { - String name = String.valueOf(dbObject.get(LONGNAMEID)); + List clips = ListUtils.cast(cursor.toArray()); + for (BasicDBObject clip : clips) { + String name = String.valueOf(clip.get(LONGNAMEID)); + Date killdate = clip.getDate(KILLDATE); + logger.info("{}, {}, {}", name, CalendarUtils.toDateString(CalendarUtils.createCalendar(killdate)), clip.getString(EXTAGENCY)); delete(name); } diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMBackupStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMBackupStep.java index 64e2384c..c2b093bc 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMBackupStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMBackupStep.java @@ -7,6 +7,8 @@ import java.util.Date; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.message.Message; +import org.apache.logging.log4j.message.ParameterizedMessage; import user.commons.RemoteFile; import user.commons.StoreUri; @@ -32,14 +34,20 @@ public class TSMBackupStep extends JobStep { private StoreUri targetUri; private FileType fileType; + // @Override + // public String getDescription() { + // } + @StepEntry public Object[] execute(ArchiveItem archiveItem, Media mediaCubeMedia, int killDateDays, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + File sourceMediaFile = new File(archiveItem.getMediaFile()); + String sourceFileName = sourceMediaFile.getName(); + String details = String.format("%s (%d bytes)", sourceFileName, sourceMediaFile.length()); try { setAndCheck(archiveItem, mediaCubeMedia, jobEngine); - File sourceMediaFile = new File(archiveItem.getMediaFile()); - String sourceFileName = sourceMediaFile.getName(); - jobRuntime.setDescription(String.format("%s: %s (%d bytes)", jobRuntime.getDescription(), sourceFileName, sourceMediaFile.length())); + + jobRuntime.setDescription(String.format("%s: %s", jobRuntime.getDescription(), details)); StoreUri sourceUri = manager.createStoreUri(RemoteStoreProtocol.LOCAL, sourceMediaFile.getParent().toString()); @@ -59,18 +67,19 @@ public class TSMBackupStep extends JobStep { RemoteFile remoteFile = sourceUri.transferFrom(targetUri, sourceFileName, sourceFileName); saveMetadata(mediaCubeMedia, sourceFileName); - logger.info(getMarker(), "Az '{}' állomány archiválása sikeres.", sourceMediaFile.getName()); + logger.info(getMarker(), "Az '{}' állomány archiválása sikeres.", sourceFileName); if (killDateDays > 0) - EscortFiles.createUNCKillDate(sourceMediaFile.getParent().toString(), sourceMediaFile.getName().toString(), killDateDays, getMarker()); + EscortFiles.createUNCKillDate(sourceMediaFile.getParent(), sourceFileName, killDateDays, getMarker()); } catch (Exception e) { logger.catching(e); - logger.error(getMarker(), "Az '{}' állomány archiválása sikertelen. A rendszer hibaüzenete: {}", sourceMediaFile.getName(), e.getMessage()); + Message m = new ParameterizedMessage("Az '{}' állomány archiválása sikertelen. A rendszer hibaüzenete: {}", details, e.getMessage()); + logger.error(getMarker(), m); if (!archiveItem.removeCatchedFile()) logger.error(getMarker(), "Az '{}' állomány .catched jelző állománya nem törölhető. Az újabb archiválási kísérlethez annak kézi eltávolítása szükséges!", sourceMediaFile.getName()); - throw e; + throw new Exception(m.getFormattedMessage()); } return null; } diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java index 964841e9..5a9dce91 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java @@ -15,6 +15,8 @@ import javax.xml.namespace.QName; import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.message.Message; +import org.apache.logging.log4j.message.ParameterizedMessage; import user.commons.selenio.wsclient.AudioSource; import user.commons.selenio.wsclient.Clip; @@ -125,29 +127,29 @@ public class TranscodeSELENIOStep extends JobStep { throw new NullPointerException("System is not configured properly, 'webPath' parameter missing."); this.webPath = webPath; - // StoreUri sourceStoreUri = store.getSourceStoreUri(RemoteStoreProtocol.SMB); - // if (sourceStoreUri == null) - // throw new NullPointerException("System is not configured properly, low-res system store SMB store URI definition missing."); - - Path inputPath = Paths.get(globalSourcePath, new File(archiveItem.getMediaFile()).getName()); - String sourceFilePath = inputPath.toString(); - // String outputPath = sourceStoreUri.getRootPath(); - TranscodeRequest transcodeRequest = buildTranscodeRequest(projectFilePath, sourceFilePath); - TranscodeTask transcodeTask = transcoder.submitTranscodeTask(transcodeRequest); - - if (transcodeTask == null) - throw new NullPointerException("Unable to submit transcode task, server response is empty for transcode input: " + sourceFilePath); - File sourceMediaFile = new File(archiveItem.getMediaFile()); String sourceFileName = sourceMediaFile.getName(); - jobRuntime.setDescription(String.format("%s: %s (%d bytes)", jobRuntime.getDescription(), sourceFileName, sourceMediaFile.length())); + String details = String.format("%s (%d bytes)", sourceFileName, sourceMediaFile.length()); + try { + Path inputPath = Paths.get(globalSourcePath, sourceFileName); + String sourceFilePath = inputPath.toString(); + TranscodeRequest transcodeRequest = buildTranscodeRequest(projectFilePath, sourceFilePath); + TranscodeTask transcodeTask = transcoder.submitTranscodeTask(transcodeRequest); - transcodeTask = monitor(jobRuntime, sourceFilePath, transcodeTask); + if (transcodeTask == null) + throw new NullPointerException("Unable to submit transcode task, server response is empty for transcode input: " + sourceFilePath); - jobRuntime.incrementProgress(100); + jobRuntime.setDescription(String.format("%s: %s", jobRuntime.getDescription(), details)); - //jobRuntime.setDescription(String.valueOf(jobRuntime.getDescription()) + transcodeTask.getStatusDetail()); - processState(transcodeTask, jobEngine, mediaCubeMedia); + transcodeTask = monitor(jobRuntime, sourceFilePath, transcodeTask); + jobRuntime.incrementProgress(100); + processState(transcodeTask, jobEngine, mediaCubeMedia); + } catch (Exception e) { + logger.catching(e); + Message m = new ParameterizedMessage("Az '{}' állomány átkódolása sikertelen. A rendszer hibaüzenete: {}", details, e.getMessage()); + logger.error(getMarker(), m); + throw new Exception(m.getFormattedMessage()); + } return null; } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/CalendarUtils.java b/server/user.jobengine.osgi.commons/src/user/commons/CalendarUtils.java index f6202d32..4b49cfea 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/CalendarUtils.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/CalendarUtils.java @@ -36,8 +36,7 @@ public class CalendarUtils { if (timePart == null) { result = createCalendar(datePart); } else { - result = createCalendar(timePart.get(Calendar.HOUR), timePart.get(Calendar.MINUTE), - timePart.get(Calendar.SECOND), datePart); + result = createCalendar(timePart.get(Calendar.HOUR), timePart.get(Calendar.MINUTE), timePart.get(Calendar.SECOND), datePart); } return result; } @@ -236,8 +235,7 @@ public class CalendarUtils { } public static boolean isSameDay(Calendar left, Calendar right) { - return left.get(Calendar.YEAR) == right.get(Calendar.YEAR) - && left.get(Calendar.DAY_OF_YEAR) == right.get(Calendar.DAY_OF_YEAR); + return left.get(Calendar.YEAR) == right.get(Calendar.YEAR) && left.get(Calendar.DAY_OF_YEAR) == right.get(Calendar.DAY_OF_YEAR); } public static boolean isToday(Calendar base) { diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java similarity index 88% rename from server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java rename to server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java index 1f217724..b17a4b69 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioDispatcher.java @@ -37,11 +37,12 @@ import user.commons.remotestore.IProgressEventListener; * @author robi */ -public class NexioClipEventDispatcher implements ClipEventListener { +public class NexioDispatcher implements ClipEventListener { private static final Logger logger = LogManager.getLogger(); private static final String NEXIO_USE_MOS_GATEWAY = "nexio.useMOSGateway"; + private static final String NEXIO_DISABLE = "nexio.disable"; private static final String ID = "id"; private static final String VIDEO_FORMAT = "videoformat"; private static final String VIDEO_BITRATE = "videobitrate"; @@ -97,7 +98,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { private String NEXIO_HOST = System.getProperty("nexio.host"); private Controller controller = null; - public NexioClipEventDispatcher() { + public NexioDispatcher() { this.db = NoSQLUtils.getNoSQLDB(); } @@ -302,7 +303,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { private Map loadClipsFromMongo(Map clipsForId) { Map result = new HashMap<>(); - DBCollection collection = db.getCollection(NexioClipEventDispatcher.CLIP_COLLECTION_NAME); + DBCollection collection = db.getCollection(NexioDispatcher.CLIP_COLLECTION_NAME); DBCursor find = collection.find(); if (find.hasNext()) { List clips = ListUtils.cast(find.toArray()); @@ -337,7 +338,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { } private void removeDeleted(BasicDBObject clipToDelete) { - DBCollection collection = db.getCollection(NexioClipEventDispatcher.CLIP_COLLECTION_NAME); + DBCollection collection = db.getCollection(NexioDispatcher.CLIP_COLLECTION_NAME); collection.remove(clipToDelete); onDelete(clipToDelete); } @@ -384,22 +385,6 @@ public class NexioClipEventDispatcher implements ClipEventListener { executor.shutdownNow(); } - /* - BasicDBObject clip = new BasicDBObject(); - clip.put(LONGNAMEID, rs.getString(i++)); - clip.put(RECORDDATE, new DateTime(rs.getString(i++)).toDate()); - clip.put(EXTAGENCY, rs.getString(i++)); - clip.put(MODIFIEDTIMESTAMP, new DateTime(rs.getString(i++)).toDate()); - clip.put(START, rs.getString(i++)); - clip.put(DURATION, rs.getLong(i++)); - result.put(clip.getString(LONGNAMEID), clip); - int progress = idx * 50 / count; - if (progress - progressEvent.getProgress() > 0) { - progressEvent.setProgress(progress); - fireProgressEvent(progressEvent); - } - */ - public void startup() { this.controller = new Controller(NEXIO_HOST); try { @@ -411,23 +396,25 @@ public class NexioClipEventDispatcher implements ClipEventListener { logger.info("NEXIO server connected"); this.progressListenerList = new EventListenerList(); - // this.dropAllClipsFromMongo(); - // this.ensureIndexes(); - boolean[] useMOSGateway = { false }; - try { - useMOSGateway[0] = Boolean.parseBoolean(System.getProperty(NEXIO_USE_MOS_GATEWAY)); - } finally { - } + + boolean disableNexio = Boolean.parseBoolean(System.getProperty(NEXIO_DISABLE)); + if (disableNexio) + return; + + this.dropAllClipsFromMongo(); + this.ensureIndexes(); + + boolean[] useMOSGateway = { Boolean.parseBoolean(System.getProperty(NEXIO_USE_MOS_GATEWAY)) }; executor.submit(() -> { try { if (useMOSGateway[0]) { - // NexioDataMiner dm = new NexioDataMiner(); - // dm.transferClips(); + NexioDataMiner dm = new NexioDataMiner(); + dm.transferClips(); } else { copyClipsIntoMongo(); } - NexioClipEventDispatcher.this.controller.getMediabase().startMediaListener(); - NexioClipEventDispatcher.this.controller.getMediabase().getMediaListener().addClipEventListener(NexioClipEventDispatcher.this); + NexioDispatcher.this.controller.getMediabase().startMediaListener(); + NexioDispatcher.this.controller.getMediabase().getMediaListener().addClipEventListener(NexioDispatcher.this); } catch (Exception e) { logger.catching(e); } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/octopus/IOctopusAPI.java b/server/user.jobengine.osgi.commons/src/user/commons/octopus/IOctopusAPI.java index 00a55210..1dc7b900 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/octopus/IOctopusAPI.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/octopus/IOctopusAPI.java @@ -12,6 +12,7 @@ public interface IOctopusAPI { static final String TIME_COLLECTION_NAME = "time"; static final String SCRIPT_CONTENT = "script_content"; static final String RUNDOWN_TYPE = "rundownType"; + static final String CHANNEL = "channel"; static final String LASTUPDATE_TIME = "lastUpdateTime"; static final String NEXIO_MOS = "NEXIO.MOS"; static final String PARENT_STORY_ID = "parentStoryId"; diff --git a/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusDataMiner.java b/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusDataMiner.java index 91aad6aa..77826451 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusDataMiner.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusDataMiner.java @@ -44,7 +44,7 @@ public class OctopusDataMiner implements Runnable { private static final String CHECKING_RUNDOWN = "Checking Rundown {} ({}/{})"; private static final String FIELDS_STORIES = "stories,Story.modified,Story.name,Story.id,Story.mosObjects,Story.script,Story.type,Story.format,Story.customColumns,CustomColumn.label,CustomColumn.value"; private static final String FIELDS_SLUGS = "slugs,Slug.story,Slug.position,Story.name,Story.id,Story.modified,Story.mosObjects,Story.script,Story.type,Story.format,Story.customColumns,CustomColumn.label,CustomColumn.value"; - private static final String FIELDS_RUNDOWN_LIST = "id,name,modified,scheduledStart,rundownType,RundownType.name,slugs,Slug.storyId,Slug.position"; + private static final String FIELDS_RUNDOWN_LIST = "id,name,modified,scheduledStart,channel,Channel.name,Channel.id,rundownType,RundownType.name,slugs,Slug.storyId,Slug.position"; private static final String FIELDS_STORY_FOLDER_LIST = "id,name,modified,stories,Story.id"; //private static final String FIELDS_STORY_FOLDER_LIST = "id,name,modified"; private static final String RUNDOWN = "Rundown"; 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 4c8e088c..c6edf856 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 @@ -82,10 +82,10 @@ public class FtpDirectoryLister implements IDirectoryLister { String path = storeUri.toString(true); String[] pathElements = path.split("/"); ftpClient = new FTPClient(); - if (storeUri.getPortNumber() != null) - ftpClient.connect(pathElements[0], storeUri.getPortNumber().intValue()); - else + if (storeUri.getPortNumber() == null || storeUri.getPortNumber() < 1) ftpClient.connect(pathElements[0]); + else + ftpClient.connect(pathElements[0], storeUri.getPortNumber().intValue()); String userName = storeUri.getUserName(); userName = StringUtils.isEmpty(userName) ? "anonymous" : userName; ftpClient.login(userName, storeUri.getPassword()); 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 41ceb080..0d12cf51 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 @@ -345,7 +345,7 @@ public class ItemManager extends MemoryCache implements IItemManager { @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()); + result.setCurrentPath(uri.getPath()); return result; } diff --git a/server/user.jobengine.osgi.server/pages/index.zul b/server/user.jobengine.osgi.server/pages/index.zul index 09f9b490..7b98f918 100644 --- a/server/user.jobengine.osgi.server/pages/index.zul +++ b/server/user.jobengine.osgi.server/pages/index.zul @@ -57,7 +57,7 @@ - +
diff --git a/server/user.jobengine.osgi.server/pages/statistics.zul b/server/user.jobengine.osgi.server/pages/statistics.zul index 253ccb34..4089aa3a 100644 --- a/server/user.jobengine.osgi.server/pages/statistics.zul +++ b/server/user.jobengine.osgi.server/pages/statistics.zul @@ -43,8 +43,8 @@ var obj = eval("(" + value.name + ')'); return String .format( - 'Befejezve . {0}
Azonosító . {1}
Forrás . {2}
Cél . {3}
Cimke . {5}
Sikeres . {6}
Felhasználó . {7}', - obj.Finished, obj.HouseId, obj.Source, obj.Destination, + 'Kézbesítve . {0}
Elkezdve . {1}
Befejezve . {2}
Azonosító . {3}
Forrás . {4}
Cél . {5}
Cimke . {7}
Sikeres . {8}
Felhasználó . {9}', + obj.Touched, obj.Started, obj.Finished, obj.HouseId, obj.Source, obj.Destination, obj.Tag, obj.Tag, obj.Successful, obj.UserName); } diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/EscortFiles.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/EscortFiles.java index 5bea5ed4..998d84f2 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/EscortFiles.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/EscortFiles.java @@ -2,6 +2,7 @@ package user.jobengine.server.steps; import java.io.File; import java.io.IOException; +import java.io.StringWriter; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -10,11 +11,26 @@ import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; import java.util.Set; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Marker; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import user.commons.CalendarUtils; public class EscortFiles { private static final Logger logger = LogManager.getLogger(); @@ -22,11 +38,56 @@ public class EscortFiles { private static final String YYYYMMDD = "yyyyMMdd"; public static final String STATUSFOLDER = ".STATUS"; - private static String composeKillDateFileName(String fileName, int days) { + public static String composeKillDate(int days) { Calendar killDate = Calendar.getInstance(); killDate.add(Calendar.DAY_OF_YEAR, days); SimpleDateFormat dateFormat = new SimpleDateFormat(YYYYMMDD); - return String.format(KILLDATE_NAME, fileName, dateFormat.format(killDate.getTime())); + return dateFormat.format(killDate.getTime()); + } + /* + + + 02-02-2018 + TEST TEST + AGENT AGENT + + */ + + private static String composeKillDateFileName(String fileName, int days) { + return String.format(KILLDATE_NAME, fileName, composeKillDate(days)); + } + + public static byte[] createNEXIOKillDateFile(String fileName, Date killDate, String description, String agency) throws Exception { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + DOMImplementation impl = db.getDOMImplementation(); + Document xmlDocument = impl.createDocument(null, null, null); + + Element root = xmlDocument.createElement("ID"); + root.setAttribute("extendedId", fileName); + if (killDate != null) { + String sKillDate = CalendarUtils.toString(CalendarUtils.createCalendar(killDate), "MM-dd-yyyy"); + root.appendChild(xmlDocument.createElement("KillDate")).setNodeValue(sKillDate); + } + if (StringUtils.isNotBlank(description)) + root.appendChild(xmlDocument.createElement("ExtendedDescription")).setNodeValue(description); + if (StringUtils.isNotBlank(agency)) + root.appendChild(xmlDocument.createElement("ExtendedAgency")).setNodeValue(agency); + xmlDocument.appendChild(root); + + DOMSource domSource = new DOMSource(xmlDocument); + TransformerFactory tf = TransformerFactory.newInstance(); + Transformer transformer = tf.newTransformer(); + //transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-16"); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + StringWriter sw = new StringWriter(); + StreamResult sr = new StreamResult(sw); + transformer.transform(domSource, sr); + String result = sw.toString(); + sw.close(); + return result.getBytes("UTF-16"); } public static void createUNCKillDate(String filePath, String fileName, int days, Marker marker) throws IOException { @@ -48,5 +109,4 @@ public class EscortFiles { Files.createDirectory(statusPath, attr); } } - } diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/JobStep.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/JobStep.java index 6d27e90b..1b3bbb02 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/JobStep.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/JobStep.java @@ -40,6 +40,10 @@ public class JobStep implements IJobStep { public void cleanup() { } + public String getDescription() { + return null; + } + public IJobRuntime getJobRuntime() { return jobRuntime; } diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/RundownArchive.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/RundownArchive.java index 5328cef3..dae4e17b 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/RundownArchive.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/RundownArchive.java @@ -1,6 +1,7 @@ package user.jobengine.server.steps; import java.util.ArrayList; +import java.util.Date; import java.util.List; public class RundownArchive { @@ -8,6 +9,7 @@ public class RundownArchive { private String itemTitle; private String itemDesc; private List storyArchives; + private Date scheduleDate; public void addStoryArchive(StoryArchive storyArchive) { if (storyArchives == null) @@ -27,6 +29,10 @@ public class RundownArchive { return itemTitle; } + public Date getScheduleDate() { + return scheduleDate; + } + public List getStoryArchives() { return storyArchives; } @@ -46,4 +52,8 @@ public class RundownArchive { public void setItemTitle(String itemTitle) { this.itemTitle = itemTitle; } + + public void setScheduleDate(Date scheduleDate) { + this.scheduleDate = scheduleDate; + } } \ No newline at end of file diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/zk/model/StatisticsComposer.java b/server/user.jobengine.osgi.server/src/user/jobengine/zk/model/StatisticsComposer.java index d1cc0dfe..db8e4f08 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/zk/model/StatisticsComposer.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/zk/model/StatisticsComposer.java @@ -75,10 +75,10 @@ public class StatisticsComposer extends SelectorComposer { int x = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE); Color color = colors.get(action.getTag()); BasicDBObject data = new BasicDBObject(); + data.put("Started", action.getStarted().toString()); data.put("Finished", action.getFinished().toString()); + data.put("Touched", action.getTouched().toString()); data.put("HouseId", action.getHouseId()); - data.put("Touched", action.getTouched()); - data.put("Started", action.getStarted()); data.put("Source", action.getSource()); data.put("Destination", action.getDestination()); data.put("Tag", action.getTag()); 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 71709d09..3cde24ec 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 @@ -14,7 +14,7 @@ import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; import com.ibm.nosql.json.api.BasicDBObject; import user.commons.nexio.INexioChangeListener; -import user.commons.nexio.NexioClipEventDispatcher; +import user.commons.nexio.NexioDispatcher; @SuppressWarnings("serial") public class NexioWSServlet extends WebSocketServlet implements INexioChangeListener { @@ -31,13 +31,13 @@ public class NexioWSServlet extends WebSocketServlet implements INexioChangeList private Set sessions = new ConcurrentHashSet<>(); //private NexioAPIServletMessagePool messagePool; - private NexioClipEventDispatcher dispatcher = null; + private NexioDispatcher dispatcher = null; public NexioWSServlet() { logger.info("Created"); // messagePool = new NexioAPIServletMessagePool(3, sessions); instance = this; - dispatcher = new NexioClipEventDispatcher(); + dispatcher = new NexioDispatcher(); dispatcher.setNexioChangeListener(this); dispatcher.startup(); logger.info("Initialized");