From: Sweidan Omar Date: Mon, 2 May 2022 10:00:47 +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=3c1054b96fd44ae6e5777153df2c64cb941db71e;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C33261 --- 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 7bb46787..0637fb33 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 @@ -48,7 +48,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { private static final String XML_EXT = ".xml"; private static final String DURATION = "duration"; private static final String MXFEXT = ".MXF"; - private static final String NEXIOCLIPS = SystemConfiguration.getInstance().value("services.nexio.collection-name", "nexioclips"); + private static final String NEXIOCLIPS = SystemConfiguration.getInstance().value("services.nexio.collection-name", + "nexioclips"); private static final String LONGNAMEID = "longnameid"; private static final String ARCHIVEDRUNDOWNS = "archivedrundowns"; private static final String ID = "id"; @@ -71,7 +72,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { private int check(int value, String name) { if (value == 0) { logger.error(systemMarker, "A folyamat '{}' bemeneti paramétere 0.", name); - throw new NullPointerException(String.format("System is not configured properly, missing '%s' input parameter.", name)); + throw new NullPointerException( + String.format("System is not configured properly, missing '%s' input parameter.", name)); } return value; } @@ -79,7 +81,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { private String check(String value, String name) { if (value == null) { logger.error(systemMarker, "A folyamat '{}' bemeneti paramétere üres.", name); - throw new NullPointerException(String.format("System is not configured properly, missing '%s' input parameter.", name)); + throw new NullPointerException( + String.format("System is not configured properly, missing '%s' input parameter.", name)); } return value; } @@ -90,14 +93,16 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { try { copyFile(fileArchive, rundownArchive, storyArchive); } catch (Exception e) { - logger.error(systemMarker, "A '{}' clip archiválása sikertelen. A rendszer üzenete: {}", fileArchive.getFileName(), e.getMessage()); + logger.error(systemMarker, "A '{}' clip archiválása sikertelen. A rendszer üzenete: {}", + fileArchive.getFileName(), e.getMessage()); throw e; } } } } - private void copyFile(FileArchive fileArchive, RundownArchive rundownArchive, StoryArchive storyArchive) throws Exception { + private void copyFile(FileArchive fileArchive, RundownArchive rundownArchive, StoryArchive storyArchive) + throws Exception { String origFileName = fileArchive.getFileName(); String fileName = String.format("%s-%s", origFileName, rundownArchive.getItemHouseId()); String videoFileName = fileName + MXFEXT; @@ -105,11 +110,12 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { if (transferredFileNames == null) transferredFileNames = new ArrayList<>(); - //A mar letezo mozikat nem archivaljuk le ujra, csak a metaadatot + // A mar letezo mozikat nem archivaljuk le ujra, csak a metaadatot long existingMediaId = 0; boolean transferDone = false; if (transferredFileNames.contains(origFileName)) { - logger.info(systemMarker, "A '{}' file archiválásra felkészítése egy másik story kapcsán már megtörtént, ezért csak metaadat archiválás szükséges.", + logger.info(systemMarker, + "A '{}' file archiválásra felkészítése egy másik story kapcsán már megtörtént, ezért csak metaadat archiválás szükséges.", origFileName); if (!demo) transferDone = transferChunk(videoFileName); @@ -122,7 +128,9 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { logger.info(systemMarker, "A '{}' file archiválásra felkészítése sikeres volt.", origFileName); } else { - logger.info(systemMarker, "A '{}' file archiválása már megtörtént, ezért csak metaadat archiválás szükséges.", origFileName); + logger.info(systemMarker, + "A '{}' file archiválása már megtörtént, ezért csak metaadat archiválás szükséges.", + origFileName); if (!demo) transferDone = transferChunk(videoFileName); } @@ -135,7 +143,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { } } - private BasicDBObject createMetadata(RundownArchive rundownArchive, StoryArchive storyArchive, FileArchive fileArchive, long existingMediaId) { + private BasicDBObject createMetadata(RundownArchive rundownArchive, StoryArchive storyArchive, + FileArchive fileArchive, long existingMediaId) { BasicDBObject result = new BasicDBObject(); result.put("itemHouseId", rundownArchive.getItemHouseId()); result.put("itemTitle", rundownArchive.getItemTitle()); @@ -160,7 +169,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { byte[] killDateFile = EscortFiles.createNEXIOKillDateFile(fileName, killDate.getTime(), null, nexioAgency); outStream = sourceFtp.storeFileStream(fileName + XML_EXT); if (outStream == null) { - throw new NullPointerException("Can not open: " + fileName + XML_EXT + " Reply:" + sourceFtp.getReplyString()); + throw new NullPointerException( + "Can not open: " + fileName + XML_EXT + " Reply:" + sourceFtp.getReplyString()); } outStream.write(killDateFile); outStream.flush(); @@ -175,11 +185,13 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { } @StepEntry - public Object[] execute(int nexioPort, String nexioUserName, String nexioPassword, String archiveFtp, String archiveUserName, String archivePassword, - int daysBeforeNow, int nexioKillDateDays, String nexioAgency, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + public Object[] execute(int nexioPort, String nexioUserName, String nexioPassword, String archiveFtp, + String archiveUserName, String archivePassword, int daysBeforeNow, int nexioKillDateDays, + String nexioAgency, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { systemMarker = getMarker(); logger.debug(systemMarker, "debug test"); - setAndCheck(nexioPort, nexioUserName, nexioPassword, archiveFtp, archiveUserName, archivePassword, nexioKillDateDays, nexioAgency, jobEngine); + 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); @@ -193,29 +205,31 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { return null; } - // private String getVersionedFileName(String fileName, String extension) throws Exception { - // String result = fileName; - // try { - // targetFtp = ((FtpDirectoryLister) targetUri.getLister()).connect(); - // FTPFile[] listFiles = targetFtp.listFiles(); - // List fileNames = new ArrayList<>(); - // for (FTPFile ftpFile : listFiles) { - // fileNames.add(ftpFile.getName()); - // } - // while (fileNames.contains(result + extension)) { + // private String getVersionedFileName(String fileName, String extension) throws + // Exception { + // String result = fileName; + // try { + // targetFtp = ((FtpDirectoryLister) targetUri.getLister()).connect(); + // FTPFile[] listFiles = targetFtp.listFiles(); + // List fileNames = new ArrayList<>(); + // for (FTPFile ftpFile : listFiles) { + // fileNames.add(ftpFile.getName()); + // } + // while (fileNames.contains(result + extension)) { // - // } + // } // - // } catch (Exception e) { - // logger.catching(e); - // throw e; - // } finally { - // targetUri.cleanUp(); - // } - // return result; - // } - - private FileArchive processMosObject(BasicDBObject rundown, BasicDBObject story, BasicDBObject mosObject) throws Exception { + // } catch (Exception e) { + // logger.catching(e); + // throw e; + // } finally { + // targetUri.cleanUp(); + // } + // return result; + // } + + 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.info(systemMarker, "Skipping MOS object {}", mosID); @@ -224,9 +238,9 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { DBCollection clips = db.getCollection(NEXIOCLIPS); BasicDBObject clip = (BasicDBObject) clips.findOne(new BasicDBObject(LONGNAMEID, mosID)); if (clip == null) { - logger.info(systemMarker, "File {} NOT exists", mosID); + logger.info(systemMarker, "File {} does NOT exist", mosID); return null; - //throw new Exception(String.format("File NOT exists %s", mosID)); + // throw new Exception(String.format("File does NOT exist %s", mosID)); } else { logger.debug(systemMarker, "File {} exists", mosID); } @@ -266,7 +280,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { String channel = NoSQLUtils.asString(NoSQLUtils.asDBObject(rundown, IOctopusAPI.CHANNEL), IOctopusAPI.NAME); Date scheduledStart = rundown.getDate(IOctopusAPI.SCHEDULED_START); if (scheduledStart == null) { - logger.info(systemMarker, "Rundown {} {} schedule is empty", rundownID, rundown.getString(IOctopusAPI.NAME)); + logger.info(systemMarker, "Rundown {} {} schedule is empty", rundownID, + rundown.getString(IOctopusAPI.NAME)); return null; } String start = CalendarUtils.toString(CalendarUtils.createCalendar(scheduledStart), SCHEDULED_FORMAT); @@ -274,7 +289,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { result.setItemHouseId(String.valueOf(id)); result.setItemTitle(String.format("%s %s %s", start, name, channel)); - logger.info(systemMarker, "Processing stories in rundown {} {}", rundownID, rundown.getString(IOctopusAPI.NAME)); + logger.info(systemMarker, "Processing stories in rundown {} {}", rundownID, + rundown.getString(IOctopusAPI.NAME)); for (DBObject s : stories) { StoryArchive storyArchive = processStory(rundown, s); if (storyArchive == null) @@ -286,8 +302,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { private void processRundowns(List rundowns) { - //TODO kiveni publikálás előtt - //db.getCollection(v).drop(); + // TODO kiveni publikálás előtt + // db.getCollection(v).drop(); List archivedRundowns = queryArchivedRundowns(); logger.info(systemMarker, "Found {} rundowns to archive", archivedRundowns.size()); @@ -317,16 +333,16 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { logger.info(systemMarker, "Saving rundown {} {}", rundownID, rundownName); copy(rundownArchive); if (!demo) - logger.info(systemMarker, "A '{}' tükör {}db bejátszójának archiválása sikeres volt", rundownArchive.getItemTitle(), - rundownArchive.getStoryArchives().size()); + logger.info(systemMarker, "A '{}' tükör {}db bejátszójának archiválása sikeres volt", + rundownArchive.getItemTitle(), rundownArchive.getStoryArchives().size()); if (!demo) db.getCollection(ARCHIVEDRUNDOWNS).save(currentRundownID); } catch (Exception e) { logger.catching(e); - logger.error(systemMarker, - String.format("A %s %s tükör archiválása nem lehetséges, mert a annak ellenőrzése hibát jelzett. A rendszer üzenete: %s", rundownID, - rundownName, e.getMessage())); + logger.error(systemMarker, String.format( + "A %s %s tükör archiválása nem lehetséges, mert a annak ellenőrzése hibát jelzett. A rendszer üzenete: %s", + rundownID, rundownName, e.getMessage())); } index++; } @@ -337,7 +353,7 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { BasicDBObject story = (BasicDBObject) s; String parentStoryID = story.getString(IOctopusAPI.PARENT_STORY_ID); String storyID = story.getString(IOctopusAPI.ID); - + if (StringUtils.isBlank(parentStoryID)) { logger.warn(systemMarker, "Story parentStoryID is null: {}", story.toPrettyString(null)); return null; @@ -371,14 +387,16 @@ 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)); + 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, - int nexioKillDateDays, String nexioAgency, IJobEngine jobEngine) throws Exception { + private void setAndCheck(int nexioPort, String nexioUserName, String nexioPassword, String archiveFtp, + String archiveUserName, String archivePassword, int nexioKillDateDays, String nexioAgency, + IJobEngine jobEngine) throws Exception { db = NoSQLUtils.getNoSQLDB(); if (db == null) { logger.error(systemMarker, "Az NoSQL adatkezelő réteg nem elérhető."); @@ -397,7 +415,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { if (StringUtils.isBlank(NEXIO_HOST)) { logger.error(systemMarker, "A 'nexio.host' rendszer paraméter nem található."); - throw new NullPointerException("System is not configured properly, 'jobengine.selenio.address' startup parameter missing."); + throw new NullPointerException( + "System is not configured properly, 'jobengine.selenio.address' startup parameter missing."); } check(nexioPort, "nexioPort"); check(nexioUserName, "nexioUserName"); @@ -437,7 +456,8 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { try { targetFtp = ((FtpDirectoryLister) targetUri.getLister()).connect(); - //ha ugyan abban a tukorben szerepel meg 1x a mozi, akkor a chunk felulirja a tenyleges file-t, es az sosem archivalodik + // ha ugyan abban a tukorben szerepel meg 1x a mozi, akkor a chunk felulirja a + // tenyleges file-t, es az sosem archivalodik String[] names = targetFtp.listNames(); if (names != null) { if (Arrays.asList(names).contains(fileName)) @@ -522,11 +542,12 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { outStream = targetFtp.storeFileStream(fileName + JSON_EXT); if (outStream == null) { - throw new NullPointerException("Can not open: " + fileName + JSON_EXT + " Reply:" + targetFtp.getReplyString()); + throw new NullPointerException( + "Can not open: " + fileName + JSON_EXT + " Reply:" + targetFtp.getReplyString()); } outStream.write(metadata.toString().getBytes(UTF_8)); outStream.flush(); - //targetFtp.changeToParentDirectory(); + // targetFtp.changeToParentDirectory(); } catch (Exception e) { logger.catching(e); throw e;