git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorSweidan Omar <TFS\sweidan.omar>
Mon, 2 May 2022 10:00:47 +0000 (10:00 +0000)
committerSweidan Omar <TFS\sweidan.omar>
Mon, 2 May 2022 10:00:47 +0000 (10:00 +0000)
server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java

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