PGETaskInstance implements WorkflowTaskInstance { protected ProductCrawler createProductCrawler() throws MalformedURLException, IllegalAccessException, CrawlerActionException, MetExtractionException, InstantiationException, FileNotFoundException, ClassNotFoundException { logger.info("Configuring ProductCrawler..."); ProductCrawler crawler; if (pgeMetadata.getMetadata(MIME_EXTRACTOR_REPO) != null && !pgeMetadata.getMetadata(MIME_EXTRACTOR_REPO).equals("")) { crawler = new AutoDetectProductCrawler(); ((AutoDetectProductCrawler) crawler). setMimeExtractorRepo(pgeMetadata.getMetadata(MIME_EXTRACTOR_REPO)); } else { crawler = new StdProductCrawler(); } crawler.setClientTransferer(pgeMetadata .getMetadata(INGEST_CLIENT_TRANSFER_SERVICE_FACTORY)); crawler.setFilemgrUrl(pgeMetadata.getMetadata(INGEST_FILE_MANAGER_URL)); String crawlerConfigFile = pgeMetadata.getMetadata(CRAWLER_CONFIG_FILE); if (!Strings.isNullOrEmpty(crawlerConfigFile)) { crawler.setApplicationContext( new FileSystemXmlApplicationContext(crawlerConfigFile)); List<String> actionIds = pgeMetadata.getAllMetadata(ACTION_IDS); if (actionIds != null) { crawler.setActionIds(actionIds); } } crawler.setRequiredMetadata(pgeMetadata.getAllMetadata(REQUIRED_METADATA)); crawler.setCrawlForDirs(Boolean.parseBoolean(pgeMetadata .getMetadata(CRAWLER_CRAWL_FOR_DIRS))); crawler.setNoRecur(!Boolean.parseBoolean( pgeMetadata.getMetadata(CRAWLER_RECUR))); logger.debug("Passing Workflow Metadata to CAS-Crawler as global metadata . . ."); crawler.setGlobalMetadata(pgeMetadata.asMetadata(PgeMetadata.Type.DYNAMIC)); logger.debug("Created ProductCrawler [{}]", crawler.getClass().getCanonicalName()); return crawler; } protected  PGETaskInstance(); @Override void run(Metadata metadata, WorkflowTaskConfiguration config); String getWorkflowInstId(); void setWorkflowInstId(String workflowInstId); void setWmClient(WorkflowManagerClient wmClient); @Override void finalize();  }
@Test public void testCreateProductCrawler() throws Exception { PGETaskInstance pgeTask = createTestInstance(); pgeTask.pgeMetadata.replaceMetadata(MIME_EXTRACTOR_REPO, "src/main/resources/examples/Crawler/mime-extractor-map.xml"); pgeTask.pgeMetadata.replaceMetadata( INGEST_CLIENT_TRANSFER_SERVICE_FACTORY, "org.apache.oodt.cas.filemgr.datatransfer.LocalDataTransferFactory"); pgeTask.pgeMetadata.replaceMetadata(INGEST_FILE_MANAGER_URL, "http: pgeTask.pgeMetadata.replaceMetadata(CRAWLER_CONFIG_FILE, "src/main/resources/examples/Crawler/crawler-config.xml"); pgeTask.pgeMetadata.replaceMetadata(ACTION_IDS, Lists.newArrayList("DeleteDataFile", "MoveMetadataFileToFailureDir")); pgeTask.pgeMetadata.replaceMetadata(REQUIRED_METADATA, Lists.newArrayList("Owners")); pgeTask.pgeMetadata.replaceMetadata(CRAWLER_CRAWL_FOR_DIRS, Boolean.toString(false)); pgeTask.pgeMetadata.replaceMetadata(CRAWLER_RECUR, Boolean.toString(true)); ProductCrawler pc = pgeTask.createProductCrawler(); assertEquals( "org.apache.oodt.cas.filemgr.datatransfer.LocalDataTransferFactory", pc.getClientTransferer()); assertEquals("http: assertEquals( Sets.newHashSet("DeleteDataFile", "MoveMetadataFileToFailureDir"), Sets.newHashSet(pc.getActionIds())); CrawlerAction action = (CrawlerAction) pc.getApplicationContext().getBean("DeleteDataFile"); assertNotNull(action); MoveFile moveFileAction = (MoveFile) pc.getApplicationContext().getBean("MoveMetadataFileToFailureDir"); Properties properties = new Properties(); properties.load(new FileInputStream(new File( "src/main/resources/examples/Crawler/action-beans.properties"))); assertEquals(properties.get("crawler.failure.dir"), moveFileAction.getToDir()); assertTrue(pc.getRequiredMetadata().contains("Owners")); assertFalse(pc.isCrawlForDirs()); assertFalse(pc.isNoRecur()); }