From: Sweidan Omar Date: Tue, 18 Jan 2022 13:01:12 +0000 (+0000) Subject: #311 X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=db2e4b97c98f75e606149655470de226ef575f9c;p=mediacube.git #311 git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C32761 --- diff --git a/server/-product/production/LOCAL/jobs/steps/MoveJpegToIsilonStep.java b/server/-product/production/LOCAL/jobs/steps/MoveJpegToIsilonStep.java new file mode 100644 index 00000000..24a178f4 --- /dev/null +++ b/server/-product/production/LOCAL/jobs/steps/MoveJpegToIsilonStep.java @@ -0,0 +1,62 @@ +package user.jobengine.server.steps; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.net.URI; +import java.nio.file.FileVisitResult; +import java.nio.file.FileVisitor; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import user.commons.StoreUri; + +public class MoveJpegToIsilonStep extends JobStep { + private static final Logger logger = LogManager.getLogger(); + + @StepEntry + public Object[] execute(StoreUri uri, String protocol) throws Exception { + // TODO szerezzük a path-t meg az uri-ból + + Path sourcePath = Paths.get(sourceFolder); + List files = new ArrayList<>(); + + Pattern pattern = Pattern.compile(fileNamePattern, Pattern.CASE_INSENSITIVE); + + FileVisitor visitor = new SimpleFileVisitor() { + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + if (!file.getFileName().toString().contains("_DONE")) { + Matcher matcher = pattern.matcher(file.getFileName().toString()); + if (matcher.find()){ + files.add(file.toString()); + } + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { + return FileVisitResult.CONTINUE; + } + }; + + try { + Files.walkFileTree(sourcePath, visitor); + } catch (Exception e) { + logger.error(getMarker(), "Error processing '{}'. System message: {}", sourcePath, e.getMessage()); + logger.catching(e); + throw e; + } + finally { } + + logger.info(getMarker(), "Found {} files", files.size()); + +// return new Object[] { files }; + return null; + } +} \ No newline at end of file