From 341f0218990f941e100752e9812ce4a70eaaf1e0 Mon Sep 17 00:00:00 2001 From: Sweidan Omar Date: Fri, 21 Jan 2022 08:56:39 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C32856 --- .../server/steps/shared/EscortFiles.java | 50 +++++++++++-------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/shared/EscortFiles.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/shared/EscortFiles.java index da308d3c..2657f768 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/shared/EscortFiles.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/shared/EscortFiles.java @@ -73,8 +73,7 @@ public class EscortFiles { /* * * 02-02-2018 TEST - * TEST AGENT AGENT - * + * TEST AGENT AGENT */ private static String composeKillDateFileName(String fileName, int days) { @@ -113,7 +112,8 @@ public class EscortFiles { Files.write(metadataPath, metadata.getBytes()); } - public static boolean createMetadataIfNotExists(String filePath, String fileName, String metadata) throws IOException { + public static boolean createMetadataIfNotExists(String filePath, String fileName, String metadata) + throws IOException { boolean result = false; if (!EscortFiles.isMetadataExists(filePath, fileName)) { EscortFiles.createMetadata(filePath, fileName, metadata); @@ -138,17 +138,20 @@ public class EscortFiles { Element root = xmlDocument.createElement(ID); root.setAttribute(EXTENDEDID, fileName); - // 07-13-2020 (19:36:52) - // 05-18-2013 (18:52:24) + // 07-13-2020 (19:36:52) + // 05-18-2013 (18:52:24) SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy (HH:mm:ss)"); - root.appendChild(xmlDocument.createElement(MODIFIEDTIMESTAMP)).appendChild(xmlDocument.createTextNode(df.format(modified))); - root.appendChild(xmlDocument.createElement(RECORDTIMESTAMP)).appendChild(xmlDocument.createTextNode(df.format(recorded))); + root.appendChild(xmlDocument.createElement(MODIFIEDTIMESTAMP)) + .appendChild(xmlDocument.createTextNode(df.format(modified))); + root.appendChild(xmlDocument.createElement(RECORDTIMESTAMP)) + .appendChild(xmlDocument.createTextNode(df.format(recorded))); xmlDocument.appendChild(root); return xmDocumentToString(xmlDocument); } - public static byte[] createNEXIOKillDateFile(String fileName, Date killDate, String description, String agency) throws Exception { + 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(); @@ -162,7 +165,8 @@ public class EscortFiles { } if (StringUtils.isNotBlank(description)) - root.appendChild(xmlDocument.createElement(EXTENDEDDESCRIPTION)).appendChild(xmlDocument.createTextNode(description)); + root.appendChild(xmlDocument.createElement(EXTENDEDDESCRIPTION)) + .appendChild(xmlDocument.createTextNode(description)); if (StringUtils.isNotBlank(agency)) root.appendChild(xmlDocument.createElement(EXTENDEDAGENCY)).appendChild(xmlDocument.createTextNode(agency)); xmlDocument.appendChild(root); @@ -216,7 +220,7 @@ public class EscortFiles { FileAttribute> attr = PosixFilePermissions.asFileAttribute(perms); Files.createDirectories(filePath, attr); } catch (Exception e) { - //logger.catching(e); + // logger.catching(e); try { Files.createDirectories(filePath); } catch (Exception e1) { @@ -234,30 +238,31 @@ public class EscortFiles { public static boolean isCatchedFileExists(Path escortFile) { Path catchedFilePath = Paths.get(escortFile.toString() + DOT_CATCHED); - return catchedFilePath.toFile().exists(); + return Files.exists(catchedFilePath); } /*** - * A media eleresi utjan alapjan a .STATUS almappaban vizsgalja .catch fajl letezeset. + * A media eleresi utjan alapjan a .STATUS almappaban vizsgalja .catch fajl + * letezeset. * * @param mediaFile * @return */ public static boolean isMediaCatched(Path mediaFile) { Path catchedFile = createMediaCathFilePath(mediaFile); - return catchedFile.toFile().exists(); + return Files.exists(catchedFile); } public static boolean isMetadataExists(String filePath, String fileName) throws IOException { boolean result = false; String metadataFileName = fileName + DOT_JSON; Path metadataPath = Paths.get(filePath, STATUSFOLDER, metadataFileName); - result = metadataPath.toFile().exists(); + result = Files.exists(metadataPath); return result; } public static void notifyRecipient(Path escortFile, Logger logger, Message msg) { - if (escortFile.toFile().exists()) { + if (Files.exists(escortFile)) { try { BasicDBObject downloadable = EscortFiles.decode(escortFile); String recipientKey = "recipient"; @@ -295,7 +300,8 @@ public class EscortFiles { remove(catchedFile); } - public static void setNEXIOKillDate(int killDateDays, String targetFileName, String nexioAgency, StoreUri targetUri) throws Exception { + public static void setNEXIOKillDate(int killDateDays, String targetFileName, String nexioAgency, StoreUri targetUri) + throws Exception { OutputStream outStream = null; try { FTPClient targetFTP = ((FtpDirectoryLister) targetUri.getLister()).connect(); @@ -303,12 +309,14 @@ public class EscortFiles { killDate.add(Calendar.DAY_OF_YEAR, killDateDays); if (targetFileName.toLowerCase().contains(".mxf")) targetFileName = targetFileName.substring(0, targetFileName.lastIndexOf('.')); - byte[] killDateFile = EscortFiles.createNEXIOKillDateFile(targetFileName, killDate.getTime(), null, nexioAgency); + byte[] killDateFile = EscortFiles.createNEXIOKillDateFile(targetFileName, killDate.getTime(), null, + nexioAgency); String xml = targetFileName + ".xml"; outStream = targetFTP.storeFileStream(xml); if (outStream == null) { - throw new NullPointerException("Can not open: " + targetFileName.substring(0, targetFileName.lastIndexOf('.')) + ".xml" + " Reply:" - + targetFTP.getReplyString()); + throw new NullPointerException( + "Can not open: " + targetFileName.substring(0, targetFileName.lastIndexOf('.')) + ".xml" + + " Reply:" + targetFTP.getReplyString()); } outStream.write(killDateFile); outStream.flush(); @@ -321,8 +329,8 @@ public class EscortFiles { } } - private static byte[] xmDocumentToString(Document xmlDocument) - throws TransformerFactoryConfigurationError, TransformerConfigurationException, TransformerException, IOException, UnsupportedEncodingException { + private static byte[] xmDocumentToString(Document xmlDocument) throws TransformerFactoryConfigurationError, + TransformerConfigurationException, TransformerException, IOException, UnsupportedEncodingException { DOMSource domSource = new DOMSource(xmlDocument); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); -- 2.54.0