<!DOCTYPE xml>\r
\r
<executors>\r
+ <executor className="ProResArchiveCheckerStep.java" maxConcurrent="1" isRemote="false" />\r
+ <executor className="AnalyzeMediaFilesStep.java" maxConcurrent="1" isRemote="false" />\r
+ <executor className="ValidateProResStep.java" maxConcurrent="1" isRemote="false" />\r
+ <executor className="GenerateJSONMetadataStep.java" maxConcurrent="1" isRemote="false" />\r
+\r
<executor className="EscortFileUpdaterStep.java" maxConcurrent="1" isRemote="false" />\r
<executor className="PBARCHIVETransferFromStep.java" maxConcurrent="2" isRemote="false" />\r
<executor className="PBArchiveCheckerStep.java" maxConcurrent="1" isRemote="false" />\r
<executor className="TestForkCancelableStep.java" maxConcurrent="3" isRemote="false" />\r
<executor className="DirMXFValidatorStep.java" maxConcurrent="1" isRemote="false" />\r
\r
- <executor className="ProResArchiveStep.java" maxConcurrent="1" isRemote="false" />\r
- <executor className="AnalyzeMediaFilesStep.java" maxConcurrent="1" isRemote="false" />\r
- <executor className="ValidateProResStep.java" maxConcurrent="1" isRemote="false" />\r
- <executor className="GenerateJSONMetadataStep.java" maxConcurrent="1" isRemote="false" />\r
</executors>
\ No newline at end of file
</variables>\r
</declarations>\r
<commands>\r
- <calljobstep type="ProResArchiveStep.java" weight="5">\r
+ <calljobstep type="ProResArchiveCheckerStep.java" weight="5">\r
<inputs>\r
<input>\r
- <parameter name="sourceStoreFolder" />\r
+ <parameter name="sourceStoreName" />\r
</input>\r
<input>\r
<parameter name="filter" />\r
import java.util.TreeSet;\r
import java.util.concurrent.TimeUnit;\r
import java.util.regex.Pattern;\r
+import java.util.stream.Collectors;\r
\r
import org.apache.commons.io.FileUtils;\r
import org.apache.commons.io.FilenameUtils;\r
\r
@Test\r
public void test999999() throws Exception {\r
- System.out.println("Hello");\r
-\r
+// Path path = Paths.get("c:\\data\\output.mov");\r
+// System.out.println(FilenameUtils.removeExtension(path.getFileName().toString()));\r
+// System.out.println(path.getParent().toString());\r
+//\r
+// try {\r
+// throw new RuntimeException();\r
+// } catch (Exception e) {\r
+// System.out.println("Catched");\r
+// }\r
+\r
+// Stream<Path> stream = Files.walk(Paths.get("/opt"));\r
+// Set<String> collect = stream.map(Path::toString).collect(Collectors.toSet());\r
+// collect.forEach(file -> {\r
+// System.out.println(file);\r
+// });\r
+\r
+// MediaArea m = new MediaArea(Paths.get("/data/video/sample_960x400_ocean_with_audio.mxf"));\r
+// m.process();\r
+// System.out.println(m.getFrameCount());\r
+\r
+// String string = Paths.get("/data/video/sample_960x400_ocean_with_audio.mxf").toAbsolutePath().toString();\r
+// System.out.println(string);\r
+// MediaArea m = new MediaArea(Paths.get(string));\r
+// System.out.println(m.getFrameCount());\r
+\r
+ Map<String, Integer> inputFiles = new HashMap<String, Integer>();\r
+ inputFiles.put("A", 1);\r
+ inputFiles.put("B", 2);\r
+\r
+ Map<String, Integer> result = inputFiles.entrySet().stream().filter(fileEntry -> {\r
+ return fileEntry.getValue() > 1;\r
+ }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));\r
+\r
+ result.entrySet().forEach(i -> {\r
+ System.out.println(i.getKey() + " " + i.getValue());\r
+ });\r
}\r
\r
}\r
private static final Logger logger = LogManager.getLogger();\r
\r
@StepEntry\r
- public Object[] execute(List<String> foundFiles) {\r
- Map<String, MediaArea> proResFiles = new HashMap<String, MediaArea>(foundFiles.size());\r
-\r
- for (int i = 0; i < foundFiles.size(); i++) {\r
- MediaArea mediaArea = new MediaArea(Paths.get(foundFiles.get(i)));\r
- mediaArea.process();\r
- proResFiles.put(Paths.get(foundFiles.get(i)).toAbsolutePath().toString(), mediaArea);\r
+ public Object[] execute(List<String> inputFiles) {\r
+ Map<String, MediaArea> result = new HashMap<String, MediaArea>();\r
+ for (int i = 0; i < inputFiles.size(); i++) {\r
+ String inputFileLocation = inputFiles.get(i);\r
+ MediaArea mediaArea = new MediaArea(Paths.get(inputFileLocation));\r
+ try {\r
+ mediaArea.process();\r
+ result.put(inputFileLocation, mediaArea);\r
+ } catch (Exception e) {\r
+ logger.error(getSessionMarker(), "Can't analize input {}, skipping. System message is: {}",\r
+ e.getMessage());\r
+ }\r
}\r
-\r
- return new Object[] { proResFiles };\r
+ return new Object[] { result };\r
}\r
}\r
package user.jobengine.server.steps;\r
\r
import java.io.IOException;\r
+import java.nio.file.Path;\r
import java.nio.file.Paths;\r
import java.sql.Timestamp;\r
import java.util.Map;\r
+import java.util.Set;\r
\r
import org.apache.commons.io.FilenameUtils;\r
import org.apache.logging.log4j.LogManager;\r
@StepEntry\r
public Object[] execute(Map<String, MediaArea> files, String sourceStoreName, String targetStoreName,\r
String escortStoreFolder) {\r
- if (!files.isEmpty()) {\r
- for (String fullPath : files.keySet()) {\r
- MediaArea mediaArea = files.get(fullPath);\r
- String title = FilenameUtils.getBaseName(fullPath).replace(FilenameUtils.getExtension(fullPath), "");\r
- String pathOnly = fullPath.substring(0, fullPath.lastIndexOf("\\") + 1);\r
- String filenameOnly = FilenameUtils.getBaseName(fullPath);\r
- Timestamp created = null;\r
- Timestamp modified = null;\r
- long frameCount = mediaArea.getFrameCount();\r
- long mediaId = 0;\r
- StoreUri sourceStoreUri = getManager().getStoreUri(sourceStoreName, RemoteStoreProtocol.LOCAL);\r
- StoreUri targetStoreUri = getManager().getStoreUri(targetStoreName, RemoteStoreProtocol.LOCAL);\r
- StoreUri escortStoreUri = getManager().getStoreUri(escortStoreFolder, RemoteStoreProtocol.LOCAL);\r
-\r
+ if (files != null && !files.isEmpty()) {\r
+ Set<String> keys = files.keySet();\r
+ for (String inputFileLocation : keys) {\r
+ MediaArea mediaArea = files.get(inputFileLocation);\r
try {\r
- String outputPath = Paths.get(escortStoreUri.toString(true)).toString();\r
- } catch (Exception e1) {\r
- e1.printStackTrace();\r
- }\r
-\r
- DownloadableMedia downloadable = DownloadableMedia.create(title, filenameOnly, modified, created,\r
- frameCount, 0, sourceStoreUri.getId(), targetStoreUri.getId(), mediaId);\r
- String escortFileName = targetStoreName + "." + downloadable.getString("fileName"); // needed without\r
- // extension\r
- try {\r
- if (EscortFiles.createMetadataIfNotExists(pathOnly, escortFileName,\r
- downloadable.toPrettyString(""))) {\r
- logger.info(getMarker(), "Archive status file created for {}", fullPath);\r
- } else {\r
- logger.info(getMarker(), "Archive status file already exists for {}", fullPath);\r
- }\r
- } catch (IOException e) {\r
- logger.error("{}", e.getCause());\r
- e.printStackTrace();\r
+ processItem(sourceStoreName, targetStoreName, escortStoreFolder, inputFileLocation, mediaArea);\r
+ } catch (Exception e) {\r
+ logger.error(getSessionMarker(), e.getMessage());\r
+ logger.catching(e);\r
}\r
}\r
} else {\r
}\r
return null;\r
}\r
+\r
+ private void processItem(String sourceStoreName, String targetStoreName, String escortStoreFolder,\r
+ String inputFileLocation, MediaArea mediaArea) throws Exception {\r
+ Path inputPath = Paths.get(inputFileLocation);\r
+\r
+ String fileName = inputPath.getFileName().toString();\r
+ String title = FilenameUtils.removeExtension(fileName);\r
+ Timestamp created = null;\r
+ Timestamp modified = null;\r
+ long frameCount = mediaArea.getFrameCount();\r
+ StoreUri sourceStoreUri = getManager().getStoreUri(sourceStoreName, RemoteStoreProtocol.LOCAL);\r
+ StoreUri targetStoreUri = getManager().getStoreUri(targetStoreName, RemoteStoreProtocol.LOCAL);\r
+ StoreUri escortStoreUri = getManager().getStoreUri(escortStoreFolder, RemoteStoreProtocol.LOCAL);\r
+ String outputPath = Paths.get(escortStoreUri.toString(true)).toString();\r
+\r
+ DownloadableMedia downloadable = DownloadableMedia.create(title, fileName, modified, created, frameCount, 0,\r
+ sourceStoreUri.getId(), targetStoreUri.getId(), 0);\r
+ String escortFileName = targetStoreName + "." + downloadable.getString("fileName"); // needed without\r
+ // extension\r
+ try {\r
+ if (EscortFiles.createMetadataIfNotExists(outputPath, escortFileName, downloadable.toPrettyString(""))) {\r
+ logger.info(getMarker(), "Archive status file created for {}", inputFileLocation);\r
+ } else {\r
+ logger.info(getMarker(), "Archive status file already exists for {}", inputFileLocation);\r
+ }\r
+ } catch (IOException e) {\r
+ logger.error("{}", e.getCause());\r
+ e.printStackTrace();\r
+ }\r
+ }\r
}\r
--- /dev/null
+\r
+package user.jobengine.server.steps;\r
+\r
+import java.nio.file.Path;\r
+\r
+import com.ibm.nosql.json.api.BasicDBObject;\r
+\r
+import user.commons.StoreUri;\r
+import user.commons.remotestore.RemoteStoreProtocol;\r
+import user.jobengine.server.steps.shared.EscortFiles;\r
+import user.jobengine.server.steps.shared.FileSearchFilterOptions;\r
+\r
+public class ProResArchiveCheckerStep extends PathItemsCollectorStep {\r
+ public static final String DOT_CATCHED = ".catched";\r
+ public static final String STATUSFOLDER = ".STATUS";\r
+\r
+ @Override\r
+ protected FileSearchFilterOptions createFileFilter(BasicDBObject filter) {\r
+ FileSearchFilterOptions result = new FileSearchFilterOptions(filter) {\r
+ @Override\r
+ public boolean acceptFile(Path file) {\r
+ return EscortFiles.isMediaCatched(file) ? false : super.acceptFile(file);\r
+ }\r
+ };\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ @StepEntry\r
+ public Object[] execute(String sourceStoreName, BasicDBObject filter) throws Exception {\r
+ StoreUri sourceStoreUri = getManager().getStoreUri(sourceStoreName, RemoteStoreProtocol.LOCAL);\r
+ String sourceStoreFolder = sourceStoreUri.toString(false);\r
+ return super.execute(sourceStoreFolder, filter);\r
+ }\r
+}\r
+++ /dev/null
-\r
-package user.jobengine.server.steps;\r
-\r
-import java.nio.file.Files;\r
-import java.nio.file.Path;\r
-import java.nio.file.Paths;\r
-\r
-import org.apache.logging.log4j.LogManager;\r
-import org.apache.logging.log4j.Logger;\r
-\r
-import com.ibm.nosql.json.api.BasicDBObject;\r
-\r
-import user.jobengine.server.steps.shared.FileSearchFilterOptions;\r
-\r
-public class ProResArchiveStep extends PathItemsCollectorStep {\r
- private static final Logger logger = LogManager.getLogger();\r
- public static final String DOT_CATCHED = ".catched";\r
- public static final String STATUSFOLDER = ".STATUS";\r
-\r
- @Override\r
- protected FileSearchFilterOptions createFileFilter(BasicDBObject filter) {\r
- String fileName = filter.getString("fileName").replaceAll("[^a-zA-Z0-9]", "");\r
-\r
- FileSearchFilterOptions result = new FileSearchFilterOptions(filter) {\r
- @Override\r
- public boolean acceptFile(Path file) {\r
- if (!isMediaCatched(file)) {/* !catched van-e */\r
- return super.acceptFile(file);\r
- }\r
- return false;\r
- }\r
- };\r
- return result;\r
- }\r
-\r
- @Override\r
- @StepEntry\r
- public Object[] execute(String sourceStoreFolder, BasicDBObject filter) throws Exception {\r
- return super.execute(sourceStoreFolder, filter);\r
- }\r
-\r
- /***\r
- * A média elérési útján alapján a .STATUS almappában vizsgálja .catch fajl\r
- * létezését.\r
- *\r
- * @param mediaFile\r
- * @return\r
- */\r
- public static boolean isMediaCatched(Path mediaFile) {\r
- Path catchedFile = createMediaCatchFilePath(mediaFile);\r
- return Files.exists(catchedFile);\r
- }\r
-\r
- public static Path createMediaCatchFilePath(Path mediaFile) {\r
- String fileName = mediaFile.getFileName().toString() + DOT_CATCHED;\r
- return Paths.get(mediaFile.getParent().toString(), STATUSFOLDER, fileName);\r
- }\r
-}\r
package user.jobengine.server.steps;\r
\r
-import java.util.HashMap;\r
import java.util.Map;\r
+import java.util.stream.Collectors;\r
\r
import org.apache.logging.log4j.LogManager;\r
import org.apache.logging.log4j.Logger;\r
import user.commons.mediaarea.MediaArea;\r
\r
public class ValidateProResStep extends JobStep {\r
+ private static final double FRAMERATE = 23.976;\r
+ private static final String PRORES = "PRORES";\r
private static final Logger logger = LogManager.getLogger();\r
\r
@StepEntry\r
- public Object[] execute(Map<String, MediaArea> proResFiles) {\r
- Map<String, MediaArea> files = new HashMap<String, MediaArea>();\r
+ public Object[] execute(Map<String, MediaArea> inputFiles) {\r
\r
- if (!proResFiles.isEmpty()) {\r
- for (String fileName : proResFiles.keySet()) {\r
- MediaArea mediaArea = proResFiles.get(fileName);\r
- String videoFormat = mediaArea.getFormat();\r
+ Map<String, MediaArea> result = inputFiles.entrySet().stream().filter(fileEntry -> {\r
+ String fileLocation = fileEntry.getKey();\r
+ MediaArea mediaArea = inputFiles.get(fileLocation);\r
+ String videoFormat = mediaArea.getFormat();\r
+ boolean isProRes = mediaArea.getFrameRate() == FRAMERATE && videoFormat.equals(PRORES);\r
+ logger.info(getSessionMarker(), "{} is PRORES {}", fileLocation, isProRes);\r
+ return isProRes;\r
+ }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));\r
\r
- if (mediaArea.getFrameRate() == 23.976 && videoFormat.equals("PRORES")) {\r
- files.put(fileName, mediaArea);\r
- }\r
- }\r
- } else {\r
- logger.info("proResFiles is empty!");\r
- }\r
- return new Object[] { files };\r
+ return new Object[] { result };\r
}\r
}\r
return result;\r
}\r
\r
- public void process() {\r
+ public void process() throws Exception {\r
// auto closable\r
try (MediaInfo mi = new MediaInfo(filePath.toAbsolutePath().toString())) {\r
height = Integer.parseInt(mi.get(StreamKind.Video, 0, "Height"));\r
frameRate = Double.parseDouble(mi.get(StreamKind.Video, 0, "FrameRate"));\r
frameCount = Integer.parseInt(mi.get(StreamKind.Video, 0, "FrameCount"));\r
} catch (Exception ex) {\r
- throw new RuntimeException(ex);\r
+ throw new Exception(ex);\r
}\r
}\r
}\r
--- /dev/null
+-- // Creates a store entry in STORE table\r
+-- Migration SQL that makes the change goes here.\r
+\r
+INSERT INTO STORE(NAME,ISSYSTEM,ISLOWRES) VALUES\r
+('PRORES','N','N')\r
+@\r
+\r
+INSERT INTO STOREURI(STOREID,PROTOCOL,DELIVERY,URI,ISSTREAM,ISSOURCE,ISTARGET,USERNAME,PASSWORD,ROOTPATH,PORTNUMBER) VALUES\r
+((SELECT ID FROM STORE WHERE NAME='PRORES'),'LOCAL',null,'/mediacube/data','N','Y','Y',null,null,null,null)\r
+@\r
+\r
+-- //@UNDO\r
+-- SQL to undo the change goes here.\r
+DELETE FROM STOREURI WHERE STOREID=(SELECT ID FROM STORE WHERE NAME='AMC_LOCAL')\r
+@\r
+DELETE FROM STORE WHERE NAME='AMC_LOCAL'\r
+@\r