From: Vásáry Dániel Date: Sun, 3 Dec 2017 23:03:36 +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=bd988318a8e2e5a9bbc0586b6077db2a79c202d2;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30785 --- diff --git a/client/Maestro/Configuration/-configuration-playout-ingest.json b/client/Maestro/Configuration/-configuration-playout-ingest.json index ddd13040..aa818ef7 100644 --- a/client/Maestro/Configuration/-configuration-playout-ingest.json +++ b/client/Maestro/Configuration/-configuration-playout-ingest.json @@ -1,6 +1,6 @@ { "title": "Lebony betöltő", - "active": false, + "active": true, "startInTray": false, "enableCustomMetadataId": true, "player": { diff --git a/client/Maestro/Configuration/configuration-tqc-check.json b/client/Maestro/Configuration/-configuration-tqc-check.json similarity index 100% rename from client/Maestro/Configuration/configuration-tqc-check.json rename to client/Maestro/Configuration/-configuration-tqc-check.json diff --git a/client/Maestro/Configuration/-configuration-studio.json b/client/Maestro/Configuration/configuration-studio.json similarity index 100% rename from client/Maestro/Configuration/-configuration-studio.json rename to client/Maestro/Configuration/configuration-studio.json diff --git a/client/Maestro/Installer/installforge-installer-project.ifp b/client/Maestro/Installer/installforge-installer-project.ifp index 9ab745e6..8d9290ea 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/Maestro.csproj b/client/Maestro/Maestro.csproj index 22f34e5c..55f38c46 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -276,7 +276,7 @@ Always - + Always @@ -315,7 +315,7 @@ Always - + Always diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index b7f43ee6..73e069b6 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -13,6 +13,7 @@ using Model; using MaestroShared.Configuration; using MaestroShared.Metadata; using MaestroShared.Targets; +using MaestroShared.Commons; namespace Maestro { public partial class MaestroForm { @@ -157,17 +158,26 @@ namespace Maestro { return; Cursor = Cursors.WaitCursor; if (movieSegments == null || movieSegments.Count == 0) - QuerySegments(); + movieSegments = QuerySegments(); if (movieSegments == null) movieSegments = new BindingList(); - OpenFile(SelectedSource.FileInfo, true); + bool readOnly = true; + if (archiveMetadata == null) + MsgBox.Error("A metaadatok nem elérhetők, a szegmens definiálás nem engedélyezett."); + else { + readOnly = archiveMetadata.ok; + MsgBox.Warning("Az anyag már el van fogadva, a szegmens módosítás nem kerül mentésre. A szegmensek módosításához vissza kell vonni az anyag elfogadását az adástervező rendszerben."); + } + OpenFile(SelectedSource.FileInfo, true, readOnly); UpdateDefineSegmentsStatus(); } - private void QuerySegments() { + private BindingList QuerySegments() { + BindingList result = null; List storedSegments = GetSegments(); if (storedSegments != null && storedSegments.Count > 0) - movieSegments = new BindingList(storedSegments); + result = new BindingList(storedSegments); + return result; } private void UpdateDefineSegmentsStatus() { @@ -269,6 +279,7 @@ namespace Maestro { result.mediaHouseId = actualResult.EpisodeID; result.mediaTitle = !String.IsNullOrEmpty(actualResult.EpisodeTitle) ? actualResult.EpisodeTitle : actualResult.ProgTitle; result.mediaDescription = actualResult.EpisodeDescription; + result.ok = actualResult.OK; return result; } @@ -323,8 +334,23 @@ namespace Maestro { } } - movieSegments = null; - archiveMetadata = null; + switch (SelectedMetadata?.Kind) { + case MetadataType.OctopusStory: + case MetadataType.OctopusPlaceHolder: + archiveMetadata = GetArchiveMetadata(); + break; + case MetadataType.TrafficAD: + case MetadataType.TrafficMaterial: + case MetadataType.TrafficPromo: + archiveMetadata = GetArchiveMetadata(); + movieSegments = null; + movieSegments = QuerySegments(); + break; + default: + movieSegments = null; + archiveMetadata = null; + break; + } UpdateProcessorButtonsEnabled(); UpdateDefineSegmentEnabled(); diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index ae7a66ae..4657a1f2 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -227,12 +227,12 @@ namespace Maestro { if (fileSourceItem == null) return; dgSource.Enabled = false; - OpenFile(fileSourceItem.FileInfo, false); + OpenFile(fileSourceItem.FileInfo, false, false); dgSource.Enabled = true; } } - private void OpenFile(FileInfo fileInfo, bool segmentEditor) { + private void OpenFile(FileInfo fileInfo, bool segmentEditor, bool readOnly) { Cursor = Cursors.WaitCursor; try { string[] extensions = Configuration.Player?.Extensions; diff --git a/client/Maestro/Properties/AssemblyInfo.cs b/client/Maestro/Properties/AssemblyInfo.cs index ecb854a2..76d8cb52 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.1")] -[assembly: AssemblyFileVersion("2.0.6.1")] +[assembly: AssemblyVersion("2.0.6.2")] +[assembly: AssemblyFileVersion("2.0.6.2")] diff --git a/client/MaestroShared/Metadata/ArchiveMetadata.cs b/client/MaestroShared/Metadata/ArchiveMetadata.cs index 15e42ece..0aa11252 100644 --- a/client/MaestroShared/Metadata/ArchiveMetadata.cs +++ b/client/MaestroShared/Metadata/ArchiveMetadata.cs @@ -15,6 +15,7 @@ namespace MaestroShared.Metadata { public string mediaHouseId { get; set; } public string mediaTitle { get; set; } public string mediaDescription { get; set; } + public bool ok { get; set; } public override string ToString() { return JsonConvert.SerializeObject(this); diff --git a/client/MaestroShared/Targets/UNCTargetProcessor.cs b/client/MaestroShared/Targets/UNCTargetProcessor.cs index 01c68cc2..b57e04a2 100644 --- a/client/MaestroShared/Targets/UNCTargetProcessor.cs +++ b/client/MaestroShared/Targets/UNCTargetProcessor.cs @@ -110,18 +110,24 @@ namespace MaestroShared.Targets { private bool DeleteExisting(string currentFile) { bool result = true; - if (FileExists(currentFile) && (Parameters.TargetConfig.DisableFileVersioning || Parameters.TargetConfig.EnableOverride)) { + if (FileExists(currentFile) && (Parameters.TargetConfig.DisableFileVersioning || Parameters.TargetConfig.EnableOverride || Parameters.ArchiveMetadata.ok)) { if (Parameters.TargetConfig.NexioServer) { Status = REVOKED; ShowNexioFileExistsMessage(); result = false; } else { - if (Parameters.TargetConfig.EnableOverride) - DeleteFile(currentFile); + if (Parameters.TargetConfig.EnableOverride) { + if (Parameters.ArchiveMetadata.ok) { + Message = "A célállomány már létezik és el van fogadva, felülírása nem lehetséges."; + result = false; + return false; + } else + DeleteFile(currentFile); + } else { - Status = SKIPPED; Message = "A célállomány létezik, felülírása a konfiuráció alapján nem lehetséges."; result = false; + result = false; } } } diff --git a/client/PlanAIRClient/TrafficIDSelector.cs b/client/PlanAIRClient/TrafficIDSelector.cs index 3776caaa..daab33d9 100644 --- a/client/PlanAIRClient/TrafficIDSelector.cs +++ b/client/PlanAIRClient/TrafficIDSelector.cs @@ -256,6 +256,7 @@ namespace TrafficClient { public string EpisodeTitle { get; set; } public string EpisodeDescription { get; set; } public string EpisodeID { get; set; } + public bool OK { get; set; } } public class TrafficAPIMessage : IMessage { diff --git a/client/PlanAIRClient/Workers/MaterialWorker.cs b/client/PlanAIRClient/Workers/MaterialWorker.cs index 0833e765..ac5bfb6c 100644 --- a/client/PlanAIRClient/Workers/MaterialWorker.cs +++ b/client/PlanAIRClient/Workers/MaterialWorker.cs @@ -38,6 +38,7 @@ namespace TrafficClient.Workers { EpisodeTitle = data.v_EpTitle, ProgID = data.v_ProgrammeID.ToString(), ProgTitle = data.v_ProgTitle, + OK = data.v_OkForAir != null && true.Equals(data.v_OkForAir) }; } diff --git a/server/-configuration/log4j2.xml b/server/-configuration/log4j2.xml index 0471c374..9e0ab538 100644 --- a/server/-configuration/log4j2.xml +++ b/server/-configuration/log4j2.xml @@ -45,7 +45,7 @@ - + diff --git a/server/-configuration/scheduledjobs.json b/server/-configuration/scheduledjobs.json index 875e874f..f69349ae 100644 --- a/server/-configuration/scheduledjobs.json +++ b/server/-configuration/scheduledjobs.json @@ -61,9 +61,7 @@ "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": "o:\\_OLD", "type": "java.lang.String"} ] }, { @@ -90,7 +88,7 @@ ] }, { - "active": true, + "active": false, "name" : "OCTOPUS adatok teljes szinkronizálása", "template": "sync-octopus.xml", "executeimmediate": true, diff --git a/server/user.jobengine.executors/META-INF/MANIFEST.MF b/server/user.jobengine.executors/META-INF/MANIFEST.MF index 0cb3cc3a..a27b7ba9 100644 --- a/server/user.jobengine.executors/META-INF/MANIFEST.MF +++ b/server/user.jobengine.executors/META-INF/MANIFEST.MF @@ -13,3 +13,4 @@ Require-Bundle: user.jobengine.osgi.commons;bundle-version="1.0.0", org.apache.logging.log4j.api;bundle-version="2.8.2" Bundle-ClassPath: . Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Import-Package: org.apache.commons.io;version="2.2.0" diff --git a/server/user.jobengine.executors/config/config.xml b/server/user.jobengine.executors/config/config.xml index 58d87ef9..98f7388c 100644 --- a/server/user.jobengine.executors/config/config.xml +++ b/server/user.jobengine.executors/config/config.xml @@ -5,7 +5,7 @@ - + diff --git a/server/user.jobengine.executors/jobtemplates/delete-materials.xml b/server/user.jobengine.executors/jobtemplates/delete-materials.xml index 86f5c8ef..87a695ec 100644 --- a/server/user.jobengine.executors/jobtemplates/delete-materials.xml +++ b/server/user.jobengine.executors/jobtemplates/delete-materials.xml @@ -3,22 +3,14 @@ - - - + - - - - - - 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 new file mode 100644 index 00000000..aee7cff6 --- /dev/null +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CleanupMountedLocationStep.java @@ -0,0 +1,251 @@ +package user.jobengine.server.steps; + +import java.io.File; +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.FileVisitResult; +import java.nio.file.FileVisitor; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import user.jobengine.server.IJobEngine; +import user.jobengine.server.IJobRuntime; + +public class CleanupMountedLocationStep extends JobStep implements FileVisitor { + + private static final Logger logger = LogManager.getLogger(); + private static final String PROJECTFOLDER = "PROJECT"; + private static final String DATEFORMAT = "yyyyMMdd"; + private static final String DOT = "."; + private static final String STATUSFOLDER = ".STATUS"; + private static final String EWC2EXT = ".ewc2"; + private static final String CATCHEDEXT = ".catched"; + private static final String KILLDATEEXT = ".killdate"; + private static final String JSONEXT = ".json"; + + private static boolean isEmpty(final Path directory) throws IOException { + try (DirectoryStream dirStream = Files.newDirectoryStream(directory)) { + final int[] count = { 0 }; + final int[] specialCount = { 0 }; + dirStream.forEach(p -> { + count[0]++; + if (p.getFileName().toString().toLowerCase().equals(PROJECTFOLDER.toLowerCase())) + specialCount[0]++; + if (p.getFileName().toString().toLowerCase().equals(STATUSFOLDER.toLowerCase())) + specialCount[0]++; + + }); + if (specialCount[0] == count[0]) + return true; + } + return false; + } + + final int[] allCount = { 0 }; + final int[] currentCount = { 0 }; + + private Path sourcePath; + private SimpleDateFormat dateFormat; + + private Date checkExpiration(List killDateFiles) { + Date killDate = null; + for (Path killDateFile : killDateFiles) { + Date currentKillDate = getKillDate(killDateFile); + if (currentKillDate == null) + continue; + if ((killDate != null && currentKillDate.after(killDate)) || killDate == null) + killDate = currentKillDate; + } + return new Date().after(killDate) ? killDate : null; + } + + @StepEntry + public Object[] execute(String sourceFolder, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + sourcePath = Paths.get(sourceFolder); + DirectoryStream directoryStream = null; + if (StringUtils.isBlank(sourcePath.toString())) { + logger.error(getMarker(), "A folyamat 'sourcePath' bemeneti paramétere üres."); + throw new NullPointerException("System is not configured properly, 'sourceFolder' input parameter missing."); + } + + if (!sourcePath.toFile().exists() || !sourcePath.toFile().isDirectory()) { + logger.error(getMarker(), "A {} mappa nem létezik.", sourceFolder); + throw new NullPointerException(String.format("Directory %s not exists.", sourceFolder)); + } + try { + setProgress(1); + dateFormat = new SimpleDateFormat(DATEFORMAT); + Files.walkFileTree(sourcePath, new SimpleFileVisitor() { + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + allCount[0]++; + return super.visitFile(file, attrs); + } + }); + Files.walkFileTree(sourcePath, this); + } catch (Exception e) { + logger.catching(e); + logger.error(getMarker(), "Az '{}' mappa elérése sikertelen. A rendszer hibaüzenete: {}", sourcePath, e.getMessage()); + throw e; + } finally { + if (directoryStream != null) { + try { + directoryStream.close(); + } catch (IOException e) { + } + } + } + return null; + } + + private Date getKillDate(Path killDateFile) { + String fileName = killDateFile.getFileName().toString(); + int end = fileName.lastIndexOf(DOT); + if (end < 1) + return null; + int start = fileName.lastIndexOf(DOT, end - 1); + if (start < 0) + return null; + String strKillDate = fileName.substring(start + 1, end); + Date result = null; + if (StringUtils.isNumeric(strKillDate)) { + try { + result = dateFormat.parse(strKillDate); + } catch (ParseException e) { + logger.error(getMarker(), "A {} fájl 'killdate' állománya hibás formátumú, a {} karaktersorozat nem konvertálható dátummá.", fileName, + strKillDate); + return null; + } + } else + logger.error(getMarker(), "A {} fájl 'killdate' állománya hibás formátumú, az dátum helyett ez áll: '{}'.", fileName, strKillDate); + return result; + } + + private List getKillDateFiles(Path filePath) { + String killDateFilePattern = String.format("%s.*%s", filePath.getFileName().toString(), KILLDATEEXT); + List result = new ArrayList<>(); + Path statusPath = Paths.get(filePath.getParent().toString(), STATUSFOLDER); + File statusPathFile = statusPath.toFile(); + if (statusPathFile.exists() && statusPathFile.isDirectory()) { + try (DirectoryStream stream = Files.newDirectoryStream(statusPath, killDateFilePattern)) { + stream.forEach(p -> result.add(p)); + } catch (Exception e) { + logger.catching(e); + } + } + Collections.sort(result); + return result; + } + + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + if (!dir.equals(sourcePath) && isEmpty(dir)) { + if (!removeExistingSpecialDirectory(dir, PROJECTFOLDER)) + return FileVisitResult.CONTINUE; + if (!removeExistingSpecialDirectory(dir, STATUSFOLDER)) + return FileVisitResult.CONTINUE; + if (removeFile(dir)) + logger.info(getMarker(), "A {} üres mappa törlése sikeres.", dir); + + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { + return FileVisitResult.CONTINUE; + } + + private void processPathItem(Path filePath) { + currentCount[0]++; + + setProgress(currentCount[0] * 100 / allCount[0]); + + logger.debug("Checking {}", filePath); + List killDateFiles = getKillDateFiles(filePath); + if (killDateFiles.size() == 0) + return; + + if (killDateFiles.size() != 1) + logger.warn(getMarker(), "A {} fájlhoz több 'killdate' állomány található, a legújabb dátum határozza meg a törlés időpontját.", filePath); + + Date killDate = checkExpiration(killDateFiles); + if (killDate == null) + return; + + if (removeFiles(filePath, killDateFiles)) + logger.info(getMarker(), "A {} fájl és kapcsolódó állományai a {} killdate bejegyzés alapján sikeresen törlődtek.", filePath.getFileName(), + dateFormat.format(killDate)); + else + logger.warn(getMarker(), "A {} fájl és kapcsolódó állományai a {} killdate bejegyzés alapján csak részlegesen vagy egyáltalán nem törlődtek.", + filePath.getFileName(), dateFormat.format(killDate)); + } + + private boolean removeExistingSpecialDirectory(Path dir, String folderName) throws IOException { + File projectPath = Paths.get(dir.toString(), folderName).toFile(); + if (projectPath.exists() && projectPath.isDirectory()) { + FileUtils.deleteDirectory(projectPath); + if (projectPath.exists()) { + logger.warn(getMarker(), "A {} alatti {} mappa törlése nem sikerült.", dir, folderName); + return false; + } + } + return true; + } + + private boolean removeFile(Path filePath) { + boolean result = false; + try { + //logger.error("REMOVE {}", filePath); + File file = filePath.toFile(); + if (file.exists()) + result = file.delete(); + } catch (Exception e) { + logger.error(getMarker(), "A {} fájl nem törölhető. A rendszer hibaüzenete: {}", filePath, e.getMessage()); + } + return result; + } + + private boolean removeFiles(Path filePath, List killDateFiles) { + if (!removeFile(filePath)) + return false; + + removeFile(Paths.get(filePath.toString() + EWC2EXT)); + removeFile(Paths.get(Paths.get(filePath.getParent().toString(), STATUSFOLDER, filePath.getFileName().toString()) + CATCHEDEXT)); + removeFile(Paths.get(Paths.get(filePath.getParent().toString(), STATUSFOLDER, filePath.getFileName().toString()) + JSONEXT)); + + boolean result = true; + for (Path killDateFile : killDateFiles) { + if (removeFile(killDateFile)) + result = false; + } + + return result; + } + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + processPathItem(file); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFileFailed(Path file, IOException e) throws IOException { + logger.error(getMarker(), "A {} fájl nem érhető el. A rendszer hibaüzenete: {}", file.toString(), e.getMessage()); + return FileVisitResult.CONTINUE; + } +} diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteMaterialsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteMaterialsStep.java index 9c15de32..333f8d08 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteMaterialsStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/DeleteMaterialsStep.java @@ -29,6 +29,7 @@ public class DeleteMaterialsStep extends JobStep { logger.error(getMarker(), "A folyamat 'sourceFolder' bemeneti paramétere üres."); throw new NullPointerException("System is not configured properly, 'sourceFolder' input parameter missing."); } + IItemManager manager = jobEngine.getItemManager(); sourceUri = manager.createStoreUri(RemoteStoreProtocol.SMB, sourceFolder); sourceUri.setUserName(userName); 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 23359c04..851fdd76 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 @@ -164,9 +164,9 @@ public class NexioClipEventDispatcher implements ClipEventListener { logger.debug("clipEventPerformed clip: {} {}", evt.getClip().getId(), fileName); //cache??? - HashMap clipsForId = new HashMap(); - Map clipsForXID = loadClipsFromMongo(clipsForId); - saveClipIntoMongo(jsClip, clipsForXID, clipsForId); + // HashMap clipsForId = new HashMap(); + // Map clipsForXID = loadClipsFromMongo(clipsForId); + saveClipIntoMongo(jsClip); } else { logger.debug("clipEventPerformed clip: {}", evt.getClip() == null ? "null" : evt.getClip().getId()); } @@ -270,7 +270,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { */ private void copyClipsIntoMongo() throws Exception { logger.info("Starting initial NEXIO metadata import."); - Map emptyMap = new HashMap(); + // Map emptyMap = new HashMap(); Iterator clips = controller.getMediabase().getClips(); while (clips.hasNext()) { Clip clip = null; @@ -282,7 +282,7 @@ public class NexioClipEventDispatcher implements ClipEventListener { int duration = jsonClip.getInt(DURATION); if (fileName != null && !"".equals(fileName)) { logger.debug("Found NEXIO clip: {} duration: {} agency: {}", fileName, duration, agency); - this.saveClipIntoMongo(jsonClip, emptyMap, emptyMap); + this.saveClipIntoMongo(jsonClip); } else { logger.debug("Found NEXIO clip: {} XID IS MISSING!!", clip.getId()); } @@ -338,14 +338,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; @@ -397,13 +397,13 @@ public class NexioClipEventDispatcher implements ClipEventListener { progressListenerList.remove(IProgressEventListener.class, listener); } - private void saveClipIntoMongo(BasicDBObject clip, Map clipsForXID, Map clipsForID) { + private void saveClipIntoMongo(BasicDBObject clip) { DBCollection collection = db.getCollection(CLIP_COLLECTION_NAME); String xid = clip.getString(LONGNAMEID); String id = clip.getString(ID); - BasicDBObject clipForXID = clipsForXID.get(xid); - BasicDBObject clipForID = clipsForID.get(id); + BasicDBObject clipForXID = (BasicDBObject) collection.findOne(new BasicDBObject(LONGNAMEID, xid)); + BasicDBObject clipForID = (BasicDBObject) collection.findOne(new BasicDBObject(ID, id)); //rename-nel a clipForXID null lesz de a clipForID nem ezert nem kell create if (clipForXID == null && clipForID == null) { 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 72d1d27b..15859e91 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 @@ -240,42 +240,45 @@ public class OctopusDataMiner implements Runnable { FOLDER_COLLECTION = IOctopusAPI.FOLDER_COLLECTION + _TMP; STORY_COLLECTION = IOctopusAPI.STORY_COLLECTION + _TMP; - logger.info("Fetch rundowns"); + // ResteasyWebTarget target = webTarget.path(RUNDOWN); + // Builder result = target.request().header(OCTOPUS_DEVICE_ID, apiUser).header(OCTOPUS_DEVICE_NAME, apiPwd); + // Response r = result.get(); + // String x = r.readEntity(String.class); + // logger.info(x); + // return; - ResteasyWebTarget target = webTarget.path(RUNDOWN); - Builder result = target.request().header(OCTOPUS_DEVICE_ID, apiUser).header(OCTOPUS_DEVICE_NAME, apiPwd); - Response r = result.get(); - String x = r.readEntity(String.class); - logger.info(x); - return; - // BasicDBList rundowns = queryRundowns(); - // logger.info("Fetch rundown story references"); - // storyRundowns = buildRundownReferences(rundowns); - // logger.info("Fetch story folders"); - // BasicDBList storyFolders = queryStoryFolders(); - // logger.info("Fetch folder story references"); - // storyStoryFolders = buildFolderReferences(storyFolders); - // - // if (rundowns == null || rundowns.size() == 0) { - // progressEvent.setProgress(50); - // fireProgressEvent(progressEvent); - // } else { - // logger.info("Process rundowns"); - // storeRundowns(rundowns, null); - // } - // - // if (storyFolders == null || storyFolders.size() == 0) { - // progressEvent.setProgress(100); - // fireProgressEvent(progressEvent); - // } else { - // logger.info("Process story folders"); - // storeStoryFolders(storyFolders, null); - // } - // setLastUpdateTime(new Date()); - // logger.info("Activate"); - // db.getCollection(RUNDOWN_COLLECTION).rename(IOctopusAPI.RUNDOWN_COLLECTION, true); - // db.getCollection(FOLDER_COLLECTION).rename(IOctopusAPI.FOLDER_COLLECTION, true); - // db.getCollection(STORY_COLLECTION).rename(IOctopusAPI.STORY_COLLECTION, true); + BasicDBList rundowns = null; + BasicDBList storyFolders = null; + + rundowns = queryBuildRefRundowns(); + storyFolders = queryBuildRefFolders(); + + if (rundowns == null || rundowns.size() == 0) { + progressEvent.setProgress(50); + fireProgressEvent(progressEvent); + } else { + logger.info("Process rundowns"); + storeRundowns(rundowns, null); + } + + if (storyFolders == null || storyFolders.size() == 0) { + progressEvent.setProgress(100); + fireProgressEvent(progressEvent); + } else { + logger.info("Process story folders"); + storeStoryFolders(storyFolders, null); + } + setLastUpdateTime(new Date()); + logger.info("Activate"); + + // db.getCollection(IOctopusAPI.RUNDOWN_COLLECTION).drop(); + db.getCollection(RUNDOWN_COLLECTION).rename(IOctopusAPI.RUNDOWN_COLLECTION, true); + + // db.getCollection(IOctopusAPI.FOLDER_COLLECTION).drop(); + db.getCollection(FOLDER_COLLECTION).rename(IOctopusAPI.FOLDER_COLLECTION, true); + + // db.getCollection(IOctopusAPI.STORY_COLLECTION).drop(); + db.getCollection(STORY_COLLECTION).rename(IOctopusAPI.STORY_COLLECTION, true); } catch (Exception e) { logger.catching(e); @@ -325,14 +328,6 @@ public class OctopusDataMiner implements Runnable { return scriptContent; } - // private boolean isModified(Date date, BasicDBObject object, String name) { - // Date actualModifiedString = toDate(object, name); - // if (actualModifiedString == null) - // logger.trace(ACTUAL_MODIFIED_STRING_IS_NULL); - // int result = date.compareTo(actualModifiedString); - // return result <= 0; - // } - private String extractCustomColumnValue(String columnName, BasicDBObject story) { List customColumns = NoSQLUtils.asList(story, IOctopusAPI.CUSTOM_COLUMNS); if (customColumns == null) @@ -372,6 +367,14 @@ public class OctopusDataMiner implements Runnable { return result; } + // private boolean isModified(Date date, BasicDBObject object, String name) { + // Date actualModifiedString = toDate(object, name); + // if (actualModifiedString == null) + // logger.trace(ACTUAL_MODIFIED_STRING_IS_NULL); + // int result = date.compareTo(actualModifiedString); + // return result <= 0; + // } + private String extractScriptContent(BasicDBObject story) { BasicDBObject script = NoSQLUtils.asDBObject(story, IOctopusAPI.SCRIPT); if (script == null || script.isEmpty()) @@ -440,6 +443,24 @@ public class OctopusDataMiner implements Runnable { return result; } + private BasicDBList queryBuildRefFolders() { + BasicDBList storyFolders; + logger.info("Fetch story folders"); + storyFolders = queryStoryFolders(); + logger.info("Fetch folder story references"); + storyStoryFolders = buildFolderReferences(storyFolders); + return storyFolders; + } + + private BasicDBList queryBuildRefRundowns() { + BasicDBList rundowns; + logger.info("Fetch rundowns"); + rundowns = queryRundowns(); + logger.info("Fetch rundown story references"); + storyRundowns = buildRundownReferences(rundowns); + return rundowns; + } + private BasicDBObject queryRundown(long id) { logger.trace(ENTER); BasicDBObject result = null; diff --git a/server/user.jobengine.osgi.server/pages/index.zul b/server/user.jobengine.osgi.server/pages/index.zul index b19de165..911d0082 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/src/user/jobengine/server/JobEngine.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java index e08b3281..9fa90c54 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 @@ -236,7 +236,7 @@ public class JobEngine implements IJobEngine { @Override public void addToRunQueue(IJobRuntime jobRuntime) { try { - logger.info("{} ading to run queue", jobRuntime); + logger.debug("{} adding to run queue", jobRuntime); runQueue.put(jobRuntime); } catch (Exception e) { logger.error(e.getMessage(), e); 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 fe70ad8e..6d27e90b 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 IJobRuntime getJobRuntime() { + return jobRuntime; + } + protected Marker getMarker() { Marker parentMarker = MarkerManager.getMarker("MEDIACUBE"); Marker result = MarkerManager.getMarker(getRuntimeName()); @@ -68,4 +72,8 @@ public class JobStep implements IJobStep { } return result; } + + protected void setProgress(int progress) { + jobRuntime.incrementProgress(progress); + } }