git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorSweidan Omar <TFS\sweidan.omar>
Fri, 21 Jan 2022 08:56:39 +0000 (08:56 +0000)
committerSweidan Omar <TFS\sweidan.omar>
Fri, 21 Jan 2022 08:56:39 +0000 (08:56 +0000)
server/user.jobengine.executors/src/user/jobengine/server/steps/shared/EscortFiles.java

index da308d3c02d81a04b60870004bf91ddbcec1b832..2657f768e5e1d7ffe536f3f2f0245b86256931c0 100644 (file)
@@ -73,8 +73,7 @@ public class EscortFiles {
        /*\r
         * <?xml version="1.0" encoding="UTF-16"?> <ID extendedId="aaaaaaa">\r
         * <KillDate>02-02-2018</KillDate> <ExtendedDescription>TEST\r
-        * TEST</ExtendedDescription> <ExtendedAgency>AGENT AGENT</ExtendedAgency>\r
-        * </ID>\r
+        * TEST</ExtendedDescription> <ExtendedAgency>AGENT AGENT</ExtendedAgency> </ID>\r
         */\r
 \r
        private static String composeKillDateFileName(String fileName, int days) {\r
@@ -113,7 +112,8 @@ public class EscortFiles {
                Files.write(metadataPath, metadata.getBytes());\r
        }\r
 \r
-       public static boolean createMetadataIfNotExists(String filePath, String fileName, String metadata) throws IOException {\r
+       public static boolean createMetadataIfNotExists(String filePath, String fileName, String metadata)\r
+                       throws IOException {\r
                boolean result = false;\r
                if (!EscortFiles.isMetadataExists(filePath, fileName)) {\r
                        EscortFiles.createMetadata(filePath, fileName, metadata);\r
@@ -138,17 +138,20 @@ public class EscortFiles {
 \r
                Element root = xmlDocument.createElement(ID);\r
                root.setAttribute(EXTENDEDID, fileName);\r
-               //      <ModifiedTimeStamp>07-13-2020 (19:36:52)</ModifiedTimeStamp>\r
-               //      <RecordTimeStamp>05-18-2013 (18:52:24)</RecordTimeStamp>\r
+               // <ModifiedTimeStamp>07-13-2020 (19:36:52)</ModifiedTimeStamp>\r
+               // <RecordTimeStamp>05-18-2013 (18:52:24)</RecordTimeStamp>\r
                SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy (HH:mm:ss)");\r
-               root.appendChild(xmlDocument.createElement(MODIFIEDTIMESTAMP)).appendChild(xmlDocument.createTextNode(df.format(modified)));\r
-               root.appendChild(xmlDocument.createElement(RECORDTIMESTAMP)).appendChild(xmlDocument.createTextNode(df.format(recorded)));\r
+               root.appendChild(xmlDocument.createElement(MODIFIEDTIMESTAMP))\r
+                               .appendChild(xmlDocument.createTextNode(df.format(modified)));\r
+               root.appendChild(xmlDocument.createElement(RECORDTIMESTAMP))\r
+                               .appendChild(xmlDocument.createTextNode(df.format(recorded)));\r
                xmlDocument.appendChild(root);\r
 \r
                return xmDocumentToString(xmlDocument);\r
        }\r
 \r
-       public static byte[] createNEXIOKillDateFile(String fileName, Date killDate, String description, String agency) throws Exception {\r
+       public static byte[] createNEXIOKillDateFile(String fileName, Date killDate, String description, String agency)\r
+                       throws Exception {\r
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
                DocumentBuilder db = dbf.newDocumentBuilder();\r
                DOMImplementation impl = db.getDOMImplementation();\r
@@ -162,7 +165,8 @@ public class EscortFiles {
                }\r
 \r
                if (StringUtils.isNotBlank(description))\r
-                       root.appendChild(xmlDocument.createElement(EXTENDEDDESCRIPTION)).appendChild(xmlDocument.createTextNode(description));\r
+                       root.appendChild(xmlDocument.createElement(EXTENDEDDESCRIPTION))\r
+                                       .appendChild(xmlDocument.createTextNode(description));\r
                if (StringUtils.isNotBlank(agency))\r
                        root.appendChild(xmlDocument.createElement(EXTENDEDAGENCY)).appendChild(xmlDocument.createTextNode(agency));\r
                xmlDocument.appendChild(root);\r
@@ -216,7 +220,7 @@ public class EscortFiles {
                                FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);\r
                                Files.createDirectories(filePath, attr);\r
                        } catch (Exception e) {\r
-                               //logger.catching(e);\r
+                               // logger.catching(e);\r
                                try {\r
                                        Files.createDirectories(filePath);\r
                                } catch (Exception e1) {\r
@@ -234,30 +238,31 @@ public class EscortFiles {
 \r
        public static boolean isCatchedFileExists(Path escortFile) {\r
                Path catchedFilePath = Paths.get(escortFile.toString() + DOT_CATCHED);\r
-               return catchedFilePath.toFile().exists();\r
+               return Files.exists(catchedFilePath);\r
        }\r
 \r
        /***\r
-        * A media eleresi utjan alapjan a .STATUS almappaban vizsgalja .catch fajl letezeset.\r
+        * A media eleresi utjan alapjan a .STATUS almappaban vizsgalja .catch fajl\r
+        * letezeset.\r
         *\r
         * @param mediaFile\r
         * @return\r
         */\r
        public static boolean isMediaCatched(Path mediaFile) {\r
                Path catchedFile = createMediaCathFilePath(mediaFile);\r
-               return catchedFile.toFile().exists();\r
+               return Files.exists(catchedFile);\r
        }\r
 \r
        public static boolean isMetadataExists(String filePath, String fileName) throws IOException {\r
                boolean result = false;\r
                String metadataFileName = fileName + DOT_JSON;\r
                Path metadataPath = Paths.get(filePath, STATUSFOLDER, metadataFileName);\r
-               result = metadataPath.toFile().exists();\r
+               result = Files.exists(metadataPath);\r
                return result;\r
        }\r
 \r
        public static void notifyRecipient(Path escortFile, Logger logger, Message msg) {\r
-               if (escortFile.toFile().exists()) {\r
+               if (Files.exists(escortFile)) {\r
                        try {\r
                                BasicDBObject downloadable = EscortFiles.decode(escortFile);\r
                                String recipientKey = "recipient";\r
@@ -295,7 +300,8 @@ public class EscortFiles {
                remove(catchedFile);\r
        }\r
 \r
-       public static void setNEXIOKillDate(int killDateDays, String targetFileName, String nexioAgency, StoreUri targetUri) throws Exception {\r
+       public static void setNEXIOKillDate(int killDateDays, String targetFileName, String nexioAgency, StoreUri targetUri)\r
+                       throws Exception {\r
                OutputStream outStream = null;\r
                try {\r
                        FTPClient targetFTP = ((FtpDirectoryLister) targetUri.getLister()).connect();\r
@@ -303,12 +309,14 @@ public class EscortFiles {
                        killDate.add(Calendar.DAY_OF_YEAR, killDateDays);\r
                        if (targetFileName.toLowerCase().contains(".mxf"))\r
                                targetFileName = targetFileName.substring(0, targetFileName.lastIndexOf('.'));\r
-                       byte[] killDateFile = EscortFiles.createNEXIOKillDateFile(targetFileName, killDate.getTime(), null, nexioAgency);\r
+                       byte[] killDateFile = EscortFiles.createNEXIOKillDateFile(targetFileName, killDate.getTime(), null,\r
+                                       nexioAgency);\r
                        String xml = targetFileName + ".xml";\r
                        outStream = targetFTP.storeFileStream(xml);\r
                        if (outStream == null) {\r
-                               throw new NullPointerException("Can not open: " + targetFileName.substring(0, targetFileName.lastIndexOf('.')) + ".xml" + " Reply:"\r
-                                               + targetFTP.getReplyString());\r
+                               throw new NullPointerException(\r
+                                               "Can not open: " + targetFileName.substring(0, targetFileName.lastIndexOf('.')) + ".xml"\r
+                                                               + " Reply:" + targetFTP.getReplyString());\r
                        }\r
                        outStream.write(killDateFile);\r
                        outStream.flush();\r
@@ -321,8 +329,8 @@ public class EscortFiles {
                }\r
        }\r
 \r
-       private static byte[] xmDocumentToString(Document xmlDocument)\r
-                       throws TransformerFactoryConfigurationError, TransformerConfigurationException, TransformerException, IOException, UnsupportedEncodingException {\r
+       private static byte[] xmDocumentToString(Document xmlDocument) throws TransformerFactoryConfigurationError,\r
+                       TransformerConfigurationException, TransformerException, IOException, UnsupportedEncodingException {\r
                DOMSource domSource = new DOMSource(xmlDocument);\r
                TransformerFactory tf = TransformerFactory.newInstance();\r
                Transformer transformer = tf.newTransformer();\r