git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorSweidan Omar <TFS\sweidan.omar>
Mon, 10 Jan 2022 14:14:38 +0000 (14:14 +0000)
committerSweidan Omar <TFS\sweidan.omar>
Mon, 10 Jan 2022 14:14:38 +0000 (14:14 +0000)
server/user.jobengine.executors/src/user/jobengine/server/steps/PeableBeachMissingMaterialCheckerStep.java

index f171cdf9f15a6c5209c9b25226b220758a56f198..47f460537888eb6bf9784e98a284f2f76d54e739 100644 (file)
@@ -31,8 +31,9 @@ public class PeableBeachMissingMaterialCheckerStep extends JobStep {
        private static final String appendExtension = ".mxf";\r
 \r
        @StepEntry\r
-       public Object[] execute(String escortStoreName, BasicDBList lookupStoreNames, String targetStoreName, String targetProtocol, String primaryEndPoint,\r
-                       String primaryUserName, String primaryPassword, String secondaryEndPoint, String secondaryUserName, String secondaryPassword, int rangeForwardHours)\r
+       public Object[] execute(String escortStoreName, BasicDBList lookupStoreNames, String targetStoreName,\r
+                       String targetProtocol, String primaryEndPoint, String primaryUserName, String primaryPassword,\r
+                       String secondaryEndPoint, String secondaryUserName, String secondaryPassword, int rangeForwardHours)\r
                        throws Exception {\r
                StoreUri escortStoreUri = null;\r
                try {\r
@@ -40,7 +41,8 @@ public class PeableBeachMissingMaterialCheckerStep extends JobStep {
 \r
                        escortStoreUri = getManager().getStoreUri(escortStoreName, RemoteStoreProtocol.LOCAL);\r
                        StoreUri sourceStoreUri = getManager().getStoreUri("TSM", RemoteStoreProtocol.TSM);\r
-                       StoreUri targetStoreUri = getManager().getStoreUri(targetStoreName, Enum.valueOf(RemoteStoreProtocol.class, targetProtocol));\r
+                       StoreUri targetStoreUri = getManager().getStoreUri(targetStoreName,\r
+                                       Enum.valueOf(RemoteStoreProtocol.class, targetProtocol));\r
 \r
                        LinkedHashSet<String> poolContent = new LinkedHashSet<>();\r
 \r
@@ -55,7 +57,8 @@ public class PeableBeachMissingMaterialCheckerStep extends JobStep {
                                }\r
                                String lookupStoreName = String.valueOf(lookup);\r
 \r
-                               StoreUri lookupStoreUri = getManager().getStoreUri(lookupStoreName, Enum.valueOf(RemoteStoreProtocol.class, targetProtocol));\r
+                               StoreUri lookupStoreUri = getManager().getStoreUri(lookupStoreName,\r
+                                               Enum.valueOf(RemoteStoreProtocol.class, targetProtocol));\r
                                logger.info(getMarker(), "Checking pool {}", lookupStoreName);\r
                                List<String> lookupContent = getPoolContent(lookupStoreName, lookupStoreUri);\r
                                poolContent.addAll(lookupContent);\r
@@ -64,15 +67,14 @@ public class PeableBeachMissingMaterialCheckerStep extends JobStep {
                                setProgress(progress);\r
                        }\r
                        /*\r
-                                               if (1 == 1) {\r
-\r
-                                                       logger.info(getMarker(), "Kikapcsolva");\r
-                                                       return null;\r
-                                               }\r
-                       */\r
+                        * if (1 == 1) {\r
+                        * \r
+                        * logger.info(getMarker(), "Kikapcsolva"); return null; }\r
+                        */\r
 \r
                        PBQuery query = new PBQuery();\r
-                       query.init(primaryEndPoint, primaryUserName, primaryPassword, secondaryEndPoint, secondaryUserName, secondaryPassword, rangeForwardHours);\r
+                       query.init(primaryEndPoint, primaryUserName, primaryPassword, secondaryEndPoint, secondaryUserName,\r
+                                       secondaryPassword, rangeForwardHours);\r
                        Collection<MMMedia> medias = query.getPossibelMissingMaterialNames(new ArrayList<>(poolContent));\r
                        logger.info(getMarker(), "API returned {} items", medias == null ? 0 : medias.size());\r
 \r
@@ -124,7 +126,7 @@ public class PeableBeachMissingMaterialCheckerStep extends JobStep {
                                                int pos = name.lastIndexOf(".");\r
                                                if (pos > -1) {\r
                                                        name = name.substring(0, pos);\r
-                                                       //logger.info(getMarker(), "Adding {}", name);\r
+                                                       // logger.info(getMarker(), "Adding {}", name);\r
                                                        poolContent.add(name);\r
                                                }\r
                                        }\r
@@ -135,50 +137,52 @@ public class PeableBeachMissingMaterialCheckerStep extends JobStep {
                        }\r
                }\r
 \r
-               //              List<RemoteFile> remoteFiles = targetStoreUri.getRemoteFiles();\r
-               //              if (remoteFiles != null) {\r
-               //                      logger.info(getMarker(), "Remote file list size :{}", remoteFiles.size());\r
-               //                      for (RemoteFile rf : remoteFiles) {\r
-               //                              try {\r
-               //                                      String name = rf.getName();\r
-               //                                      if (name.toLowerCase().endsWith(".mxf")) {\r
-               //                                              int pos = name.lastIndexOf(".");\r
-               //                                              if (pos > -1) {\r
-               //                                                      name = name.substring(0, pos);\r
-               //                                                      //logger.info(getMarker(), "Adding {}", name);\r
-               //                                                      poolContent.add(name);\r
-               //                                              }\r
-               //                                      }\r
-               //                              } catch (Exception e) {\r
-               //                                      logger.error(e.getMessage());\r
-               //                              }\r
+               // List<RemoteFile> remoteFiles = targetStoreUri.getRemoteFiles();\r
+               // if (remoteFiles != null) {\r
+               // logger.info(getMarker(), "Remote file list size :{}", remoteFiles.size());\r
+               // for (RemoteFile rf : remoteFiles) {\r
+               // try {\r
+               // String name = rf.getName();\r
+               // if (name.toLowerCase().endsWith(".mxf")) {\r
+               // int pos = name.lastIndexOf(".");\r
+               // if (pos > -1) {\r
+               // name = name.substring(0, pos);\r
+               // //logger.info(getMarker(), "Adding {}", name);\r
+               // poolContent.add(name);\r
+               // }\r
+               // }\r
+               // } catch (Exception e) {\r
+               // logger.error(e.getMessage());\r
+               // }\r
                //\r
-               //                      }\r
-               //              }\r
+               // }\r
+               // }\r
                logger.info(getMarker(), "Pool {} contains {} items", storeName, poolContent == null ? 0 : poolContent.size());\r
                return poolContent;\r
        }\r
 \r
-       //csak visszaterunk\r
+       // csak visszaterunk\r
        private String normalizeName(String mediaName) {\r
                String result = mediaName;\r
                if (StringUtils.isNotBlank(appendExtension))\r
                        result += appendExtension;\r
-               //              if (StringUtils.isNotBlank(mediaName)) {\r
-               //                      result = mediaName.trim().toLowerCase();\r
-               //              }\r
+               // if (StringUtils.isNotBlank(mediaName)) {\r
+               // result = mediaName.trim().toLowerCase();\r
+               // }\r
                return result;\r
        }\r
 \r
-       private void processRecord(MMMedia mmedia, StoreUri sourceStoreUri, String targetStoreName, StoreUri targetStoreUri, StoreUri escortStoreUri) {\r
-               //TODO kisbetu/nagybetu problema kezelese\r
+       private void processRecord(MMMedia mmedia, StoreUri sourceStoreUri, String targetStoreName, StoreUri targetStoreUri,\r
+                       StoreUri escortStoreUri) {\r
+               // TODO kisbetu/nagybetu problema kezelese\r
 \r
                Media media = null;\r
-               //duplikatum miatt\r
+               // duplikatum miatt\r
                try {\r
                        media = getManager().getMedia(mmedia.getName());\r
                } catch (Exception e) {\r
-                       logger.error(getMarker(), "Can't identify missing material {}. System message is: {}", mmedia.getName(), e.getMessage());\r
+                       logger.error(getMarker(), "Can't identify missing material {}. System message is: {}", mmedia.getName(),\r
+                                       e.getMessage());\r
                        return;\r
                }\r
 \r
@@ -189,8 +193,9 @@ public class PeableBeachMissingMaterialCheckerStep extends JobStep {
                        return;\r
                }\r
 \r
-               DownloadableMedia downloadable = DownloadableMedia.create(mmedia.getName(), fileName, media.getModified(), media.getCreated(), media.getLength(), 0L,\r
-                               sourceStoreUri.getId(), targetStoreUri.getId(), media.getId());\r
+               DownloadableMedia downloadable = DownloadableMedia.create(mmedia.getName(), fileName, media.getModified(),\r
+                               media.getCreated(), media.getLength(), 0L, sourceStoreUri.getId(), targetStoreUri.getId(),\r
+                               media.getId());\r
                downloadable.put("priority", 50);\r
                String usage = mmedia.getUsage();\r
                usage = usage.replace("-", "").replace(":", "");\r
@@ -198,30 +203,31 @@ public class PeableBeachMissingMaterialCheckerStep extends JobStep {
                Path outputPath = null;\r
                try {\r
                        outputPath = Paths.get(escortStoreUri.toString(true));\r
-                       boolean exsists = statusFileExists(outputPath, fileName);\r
-                       if (exsists)\r
+                       boolean exists = statusFileExists(outputPath, fileName);\r
+                       if (exists)\r
                                return;\r
                        EscortFiles.createMetadata(outputPath.toString(), escortFileName, downloadable.toPrettyString(""));\r
                        logger.info(getMarker(), "Status file created {}", escortFileName);\r
                } catch (Exception e) {\r
-                       logger.error(getSessionMarker(), "Can't create status file {}", Paths.get(outputPath.toString(), escortFileName));\r
+                       logger.error(getSessionMarker(), "Can't create status file {}",\r
+                                       Paths.get(outputPath.toString(), escortFileName));\r
                }\r
 \r
        }\r
 \r
        private boolean statusFileExists(Path outputPath, String fileName) {\r
-               boolean exsists = false;\r
+               boolean exists = false;\r
                Path statusPath = Paths.get(outputPath.toString(), EscortFiles.STATUSFOLDER);\r
                try (DirectoryStream<Path> p = Files.newDirectoryStream(statusPath, "*" + fileName + EscortFiles.DOT_JSON)) {\r
                        if (p.iterator().hasNext()) {\r
                                logger.info(getMarker(), "Status file for {} already exists", fileName);\r
-                               exsists = true;\r
+                               exists = true;\r
                        }\r
 \r
                } catch (Exception e1) {\r
                        logger.error(getSessionMarker(), e1.getMessage());\r
                }\r
-               return exsists;\r
+               return exists;\r
        }\r
 \r
 }\r