Project configuration
authorVásáry Dániel <vasary@elgekko.net>
Thu, 14 Mar 2024 13:36:33 +0000 (14:36 +0100)
committerVásáry Dániel <vasary@elgekko.net>
Thu, 14 Mar 2024 13:36:33 +0000 (14:36 +0100)
server/-configuration/run-mediacube-server.launch
server/-dependencies/pom.xml
server/RemoteSystemsTempFiles/.project [deleted file]
server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/OutputPathSelectorTests.java [new file with mode: 0644]
server/user.jobengine.executors/src/user/jobengine/server/steps/OutputPathAndNameSelectorStep.java

index b8e978aadcfca57ee7d4338fd6f0375214ddf0dd..aba4e6ed1b95ce1a3a79de0d0da2a94a6e7ac334 100644 (file)
@@ -18,7 +18,7 @@
         <listEntry value="org.eclipse.debug.ui.launchGroup.run"/>\r
     </listAttribute>\r
     <booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>\r
-    <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/oracle-1.8"/>\r
+    <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-1.8-202"/>\r
     <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console"/>\r
     <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>\r
     <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dcom.sun.management.jmxremote&#13;&#10;-Dcom.sun.management.jmxremote.port=9010&#13;&#10;-Dcom.sun.management.jmxremote.local.only=false&#13;&#10;-Dcom.sun.management.jmxremote.authenticate=false&#13;&#10;-Dcom.sun.management.jmxremote.ssl=false&#13;&#10;-Djavax.ws.rs.ext.RuntimeDelegate=org.jboss.resteasy.spi.ResteasyProviderFactory&#13;&#10;-Dorg.eclipse.epp.logging.aeri.skipReports=true &#13;&#10;-Declipse.ignoreApp=true &#13;&#10;-Dosgi.noShutdown=true&#13;&#10;-Dlog4j.configurationFile=settings/log4j2.xml&#13;&#10;-Djetty.home=settings/jetty&#13;&#10;-Djetty.etc.config.urls=jetty.xml,jetty-ssl.xml,jetty-ssl-context.xml,jetty-http.xml,jetty-https.xml&#13;&#10;-Dgosh.home=configuration&#13;&#10;-Djava.io.tmpdir=tmp&#13;&#10;-Dorg.slf4j.simpleLogger.defaultLogLevel=error"/>\r
index 293e6158289c56eb216f1601a8d1c37b9a8f8d3e..bac4f50b75032f18916781a8a94863a840f867ab 100644 (file)
                                                                        <id>org.eclipse.platform:org.eclipse.equinox.launcher:1.3.201</id>\r
                                                                </artifact>\r
                                                                <artifact>\r
-                                                                       <id>net.java.dev.jna:jna:5.8.0</id>\r
+                                                                       <id>net.java.dev.jna:jna:5.14.0</id>\r
                                                                </artifact>\r
                                                                <artifact>\r
-                                                                       <id>net.java.dev.jna:jna-platform:5.8.0</id>\r
+                                                                       <id>net.java.dev.jna:jna-platform:5.14.0</id>\r
                                                                </artifact>\r
 <!-- \r
                                                                <artifact>\r
diff --git a/server/RemoteSystemsTempFiles/.project b/server/RemoteSystemsTempFiles/.project
deleted file mode 100644 (file)
index 7675629..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<projectDescription>\r
-       <name>RemoteSystemsTempFiles</name>\r
-       <comment></comment>\r
-       <projects>\r
-       </projects>\r
-       <buildSpec>\r
-       </buildSpec>\r
-       <natures>\r
-               <nature>org.eclipse.rse.ui.remoteSystemsTempNature</nature>\r
-       </natures>\r
-</projectDescription>\r
diff --git a/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/OutputPathSelectorTests.java b/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/OutputPathSelectorTests.java
new file mode 100644 (file)
index 0000000..7e738b0
--- /dev/null
@@ -0,0 +1,40 @@
+package hu.user.mediacube.executors.tests;\r
+\r
+import static org.junit.Assert.assertEquals;\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
+import org.junit.Test;\r
+\r
+import user.jobengine.server.JobRuntime;\r
+import user.jobengine.server.steps.OutputPathAndNameSelectorStep;\r
+\r
+public class OutputPathSelectorTests {\r
+       private static final Logger logger = LogManager.getLogger();\r
+\r
+       @Test\r
+       public void testOctopusIdSelect() throws Throwable {\r
+\r
+               System.out.println(System.getProperty("os.name"));\r
+\r
+               JobRuntime rt = new JobRuntime();\r
+               OutputPathAndNameSelectorStep sut = new OutputPathAndNameSelectorStep();\r
+\r
+               String id = "123456789_1";\r
+               Path octopusTargetPath = Paths.get("/temp");\r
+               Path existingTargetPath = Paths.get("/temp", id + "-blabla");\r
+               if (!Files.isDirectory(existingTargetPath)) {\r
+                       Files.createDirectory(existingTargetPath);\r
+               }\r
+               Object[] params = { "", "", "", "", octopusTargetPath.toString(), "", "", id, "0", null };\r
+               Object[] result = sut.run(null, rt, params);\r
+\r
+               assertEquals(existingTargetPath.toString(), result[0].toString());\r
+               Files.delete(existingTargetPath);\r
+       }\r
+\r
+}\r
index 52e30e913e892564036040db17072af9f0df2cee..00b48155055b831081d23d30a77daf0010457f78 100644 (file)
@@ -32,31 +32,38 @@ public class OutputPathAndNameSelectorStep extends JobStep {
 \r
        private String octopusAddress = SystemConfiguration.getInstance().value("services.octopus.api.address", "");\r
 \r
-       private void check(String localRetrievePath, String materialOutputFolder, String promoOutputFolder, String advertisementOutputFolder,\r
-                       String octopusOutputFolder, String genericOutputFolder, String houseId, String targetPathType) {\r
+       private void check(String localRetrievePath, String materialOutputFolder, String promoOutputFolder,\r
+                       String advertisementOutputFolder, String octopusOutputFolder, String genericOutputFolder, String houseId,\r
+                       String targetPathType) {\r
                if (StringUtils.isBlank(localRetrievePath)) {\r
                        logger.error(marker, "A folyamat 'localRetrievePath' bemeneti paramétere üres.");\r
-                       throw new NullPointerException("System is not configured properly, 'localRetrievePath' input parameter missing.");\r
+                       throw new NullPointerException(\r
+                                       "System is not configured properly, 'localRetrievePath' input parameter missing.");\r
                }\r
                if (StringUtils.isBlank(materialOutputFolder)) {\r
                        logger.error(marker, "A folyamat 'materialOutputFolder' bemeneti paramétere üres.");\r
-                       throw new NullPointerException("System is not configured properly, 'materialOutputFolder' input parameter missing.");\r
+                       throw new NullPointerException(\r
+                                       "System is not configured properly, 'materialOutputFolder' input parameter missing.");\r
                }\r
                if (StringUtils.isBlank(promoOutputFolder)) {\r
                        logger.error(marker, "A folyamat 'promoOutputFolder' bemeneti paramétere üres.");\r
-                       throw new NullPointerException("System is not configured properly, 'promoOutputFolder' input parameter missing.");\r
+                       throw new NullPointerException(\r
+                                       "System is not configured properly, 'promoOutputFolder' input parameter missing.");\r
                }\r
                if (StringUtils.isBlank(advertisementOutputFolder)) {\r
                        logger.error(marker, "A folyamat 'advertisementOutputFolder' bemeneti paramétere üres.");\r
-                       throw new NullPointerException("System is not configured properly, 'advertisementOutputFolder' input parameter missing.");\r
+                       throw new NullPointerException(\r
+                                       "System is not configured properly, 'advertisementOutputFolder' input parameter missing.");\r
                }\r
                if (StringUtils.isBlank(octopusOutputFolder)) {\r
                        logger.error(marker, "A folyamat 'octopusOutputFolder' bemeneti paramétere üres.");\r
-                       throw new NullPointerException("System is not configured properly, 'octopusOutputFolder' input parameter missing.");\r
+                       throw new NullPointerException(\r
+                                       "System is not configured properly, 'octopusOutputFolder' input parameter missing.");\r
                }\r
                if (StringUtils.isBlank(genericOutputFolder)) {\r
                        logger.error(marker, "A folyamat 'genericOutputFolder' bemeneti paramétere üres.");\r
-                       throw new NullPointerException("System is not configured properly, 'genericOutputFolder' input parameter missing.");\r
+                       throw new NullPointerException(\r
+                                       "System is not configured properly, 'genericOutputFolder' input parameter missing.");\r
                }\r
                if (StringUtils.isBlank(houseId)) {\r
                        logger.error(marker, "A folyamat 'houseId' bemeneti paramétere üres.");\r
@@ -64,26 +71,30 @@ public class OutputPathAndNameSelectorStep extends JobStep {
                }\r
                if (StringUtils.isBlank(targetPathType)) {\r
                        logger.error(marker, "A folyamat 'targetPathType' bemeneti paramétere üres.");\r
-                       throw new NullPointerException("System is not configured properly, 'targetPathType' input parameter missing.");\r
+                       throw new NullPointerException(\r
+                                       "System is not configured properly, 'targetPathType' input parameter missing.");\r
                }\r
        }\r
 \r
        @StepEntry\r
-       public Object[] execute(String localRetrievePath, String materialOutputFolder, String promoOutputFolder, String advertisementOutputFolder,\r
-                       String octopusOutputFolder, String genericOutputFolder, String onlineOutputFolder, String houseId, String targetPathType,\r
-                       ArchivedMedia archivedMedia, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception {\r
-               marker = jobRuntime.getSessionMarker();\r
-               check(localRetrievePath, materialOutputFolder, promoOutputFolder, advertisementOutputFolder, octopusOutputFolder, genericOutputFolder, houseId,\r
-                               targetPathType);\r
+       public Object[] execute(String localRetrievePath, String materialOutputFolder, String promoOutputFolder,\r
+                       String advertisementOutputFolder, String octopusOutputFolder, String genericOutputFolder,\r
+                       String onlineOutputFolder, String houseId, String targetPathType, ArchivedMedia archivedMedia,\r
+                       IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception {\r
+               marker = getSessionMarker();\r
+               check(localRetrievePath, materialOutputFolder, promoOutputFolder, advertisementOutputFolder,\r
+                               octopusOutputFolder, genericOutputFolder, houseId, targetPathType);\r
                Object[] result = null;\r
+               boolean isOctopusTarget = false;\r
                switch (Integer.parseInt(targetPathType)) {\r
                case 0:\r
-                       String outputFolder = getFolderById(materialOutputFolder, promoOutputFolder, advertisementOutputFolder, octopusOutputFolder, genericOutputFolder,\r
-                                       houseId, archivedMedia);\r
-                       result = localTargetInit(localRetrievePath, outputFolder, houseId, jobRuntime);\r
+                       String outputFolder = getFolderById(materialOutputFolder, promoOutputFolder, advertisementOutputFolder,\r
+                                       octopusOutputFolder, genericOutputFolder, houseId, archivedMedia);\r
+                       isOctopusTarget = outputFolder.equals(octopusOutputFolder);\r
+                       result = localTargetInit(localRetrievePath, outputFolder, houseId, isOctopusTarget);\r
                        break;\r
                case 1:\r
-                       result = localTargetInit(localRetrievePath, onlineOutputFolder, houseId, jobRuntime);\r
+                       result = localTargetInit(localRetrievePath, onlineOutputFolder, houseId, isOctopusTarget);\r
                        break;\r
                case 2:\r
 \r
@@ -96,8 +107,9 @@ public class OutputPathAndNameSelectorStep extends JobStep {
                return result;\r
        }\r
 \r
-       private String getFolderById(String materialOutputFolder, String promoOutputFolder, String advertisementOutputFolder, String octopusOutputFolder,\r
-                       String genericOutputFolder, String houseId, ArchivedMedia archivedMedia) throws Exception {\r
+       private String getFolderById(String materialOutputFolder, String promoOutputFolder,\r
+                       String advertisementOutputFolder, String octopusOutputFolder, String genericOutputFolder, String houseId,\r
+                       ArchivedMedia archivedMedia) throws Exception {\r
                String id = houseId.toUpperCase();\r
                MetadataType mdType = MetadataTypeDetector.GuessMetadataType(id);\r
                String result = null;\r
@@ -145,14 +157,41 @@ public class OutputPathAndNameSelectorStep extends JobStep {
                return result[0];\r
        }\r
 \r
-       private Object[] localTargetInit(String localRetrievePath, String outputFolder, String houseId, IJobRuntime jobRuntime) throws IOException {\r
+       private String getPossibleOctopusPath(String id, Path targetPath) throws IOException {\r
+               String[] result = new String[] { targetPath.toString() };\r
+               FileVisitor<Path> matcherVisitor = new SimpleFileVisitor<Path>() {\r
+                       @Override\r
+                       public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {\r
+                               String dirName = dir.getFileName().toString();\r
+                               if (dirName.startsWith(id + "-") || dirName.equals(id)) {\r
+                                       result[0] = dir.toString();\r
+                                       return FileVisitResult.TERMINATE;\r
+                               }\r
+                               return FileVisitResult.CONTINUE;\r
+                       }\r
+               };\r
+               Files.walkFileTree(targetPath.getParent(), matcherVisitor);\r
+               return result[0];\r
+       }\r
+\r
+       private Object[] localTargetInit(String localRetrievePath, String outputFolder, String houseId,\r
+                       boolean isOctopusTarget) throws IOException {\r
                String id = houseId.toUpperCase();\r
-               String targetPath = getPossiblePath(id, Paths.get(localRetrievePath, outputFolder, id)).toString();\r
+               String targetPath = null;\r
+\r
+               if (isOctopusTarget) {\r
+                       String[] tokens = id.split("_");\r
+                       targetPath = getPossibleOctopusPath(tokens[0], Paths.get(localRetrievePath, outputFolder, id)).toString();\r
+               } else {\r
+                       targetPath = getPossiblePath(id, Paths.get(localRetrievePath, outputFolder, id)).toString();\r
+               }\r
+\r
                String targetNamePattern = houseId + TARGETNAMEPATTERN;\r
                try {\r
                        EscortFiles.ensureUNCFolder(Paths.get(targetPath));\r
                } catch (Exception e) {\r
-                       logger.error(jobRuntime.getSessionMarker(), "A cél mappa '{}' nem létezik és nem hozható létre. A rendszer hibaüzenete: {}", targetPath,\r
+                       logger.error(getSessionMarker(),\r
+                                       "A cél mappa '{}' nem létezik és nem hozható létre. A rendszer hibaüzenete: {}", targetPath,\r
                                        e.getMessage());\r
                        throw e;\r
                }\r