HadoopWorkflowUtils { public static WorkflowArtifacts getWorkflowArtifacts(File workflowArtifactFolder) { if (!workflowArtifactFolder.exists()) { return null; } WorkflowArtifacts result = null; String[] descriptor = getWorkflowDescriptor(workflowArtifactFolder); if (descriptor == null) { return null; } String workflowDescriptorFileName = descriptor[0]; Resource resource = new FileSystemResource(new File(workflowDescriptorFileName)); URL[] urls = HadoopWorkflowUtils.getWorkflowLibararies(workflowArtifactFolder); if (urls == null || urls.length == 0) { return null; } ClassLoader parentLoader = HadoopWorkflowUtils.class.getClassLoader(); ClassLoader loader = new URLClassLoader(urls, parentLoader); result = new WorkflowArtifacts(resource, loader); return result; }  static WorkflowArtifacts getWorkflowArtifacts(File workflowArtifactFolder); static String[] getWorkflowDescriptor(File workflowArtifactFolder); static boolean isValidWorkflow(List<FileInfo> files); static URL[] getWorkflowLibararies(File workflowArtifactFolder); static ClassLoader getWorkflowClassLoader(File workflowArtifactFolder); static boolean isSpringBatchJob(ApplicationContext context, WorkflowArtifacts artifacts); static void createAndRegisterSpringBatchJob(ApplicationContext context, final WorkflowArtifacts artifacts); static String generateSpringBatchJobName(final WorkflowArtifacts artifacts); static void unregisterSpringBatchJob(ApplicationContext context, String springBatchJobName); static String getWorkflowDescriptor(final WorkflowArtifacts artifacts); static void processAndRegisterWorkflow(File parentFolder, ApplicationContext context); static WorkflowArtifacts processUploadedFile(final File parentFolder); static void registerSpringBatchJob(WorkflowArtifacts artifacts, ApplicationContext context); static String fileURLPrefix; static String springHadoopJobPrefix; static String springHadoopTaskName; }
@Test public void testGetWorkflowArtifacts() { File folder = new File("src/test/resources/org/springframework/data/hadoop/admin/util/test"); WorkflowArtifacts artifacts = HadoopWorkflowUtils.getWorkflowArtifacts(folder); Assert.assertNotNull(artifacts); }
@Test public void testGetWorkflowArtifacts_withoutFiles() { File folder = new File("src/test/resources/org/springframework/data/hadoop/admin/util/testWithoutFiles"); WorkflowArtifacts artifacts = HadoopWorkflowUtils.getWorkflowArtifacts(folder); Assert.assertNull(artifacts); }
@Test public void testGetWorkflowArtifacts_withoutDescriptor() { File folder = new File("src/test/resources/org/springframework/data/hadoop/admin/util/testWithoutDescriptor"); WorkflowArtifacts artifacts = HadoopWorkflowUtils.getWorkflowArtifacts(folder); Assert.assertNull(artifacts); }
@Test public void testGetWorkflowArtifacts_withoutProperties() { File folder = new File("src/test/resources/org/springframework/data/hadoop/admin/util/testWithoutProperties"); WorkflowArtifacts artifacts = HadoopWorkflowUtils.getWorkflowArtifacts(folder); Assert.assertNull(artifacts); }
@Test public void testGetWorkflowArtifacts_withoutJars() { File folder = new File("src/test/resources/org/springframework/data/hadoop/admin/util/testWithoutJars"); WorkflowArtifacts artifacts = HadoopWorkflowUtils.getWorkflowArtifacts(folder); Assert.assertNull(artifacts); }