@Test public final void testHandle() { try { ModelAndView mav = getHandelMav(); assertTrue(mav != null); assertTrue(mav.getViewName().equals("quality-review-toc")); List<SeedMapElement> seeds = (List<SeedMapElement>)mav.getModel().get(QualityReviewToolCommand.MDL_SEEDS); assertTrue(seeds.size() == 1 ); Iterator<SeedMapElement> it = seeds.iterator(); assertTrue(it.hasNext()); SeedMapElement sme = it.next(); assertEquals("http: assertEquals("curator/tools/browse/111000/http: assertEquals("http: } catch (Exception e) { String message = e.getClass().toString() + " - " + e.getMessage(); log.debug(message); fail(message); } }
@Override protected ModelAndView handle(HttpServletRequest req, HttpServletResponse ress, Object comm, BindException error) throws Exception { QualityReviewToolCommand cmd = (QualityReviewToolCommand) comm; TargetInstance ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceOid()); HarvestResult result = targetInstanceDao.getHarvestResult(cmd.getHarvestResultId(), false); Set<Seed> seeds = new LinkedHashSet<Seed>(); Iterator<String> originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); if (seed.getSeed().equals(seedUrl)) { seeds.add(seed); } } } if(seeds.isEmpty()){ originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<SeedHistory> currentSeedHistory = ti.getSeedHistory().iterator(); while (currentSeedHistory.hasNext()) { SeedHistory seedHistoryObj = currentSeedHistory.next(); if (seedHistoryObj.getSeed().equals(seedUrl)) { Target existingTarget = null; Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); existingTarget = seed.getTarget(); if(existingTarget != null) break; } if(existingTarget != null){ Seed newSeed = businessObjectFactory.newSeed(existingTarget); newSeed.setPrimary(seedHistoryObj.isPrimary()); newSeed.setSeed(seedHistoryObj.getSeed()); seeds.add(newSeed); } } } } } List<SeedMapElement> seedMap = new ArrayList<SeedMapElement>(); for(Seed seed: seeds) { load(seedMap, seed, true, result); } for(Seed seed: seeds) { load(seedMap, seed, false, result); } ModelAndView mav = new ModelAndView("quality-review-toc", "command", comm); mav.addObject(QualityReviewToolCommand.MDL_SEEDS, seedMap); mav.addObject("targetInstanceOid", ti.getOid()); mav.addObject("archiveUrl", archiveUrl); mav.addObject("archiveName", archiveName); mav.addObject("archiveAlternative", archiveUrlAlternative); mav.addObject("archiveAlternativeName", archiveUrlAlternativeName); mav.addObject("webArchiveTarget", webArchiveTarget); mav.addObject("targetOid", ti.getTarget().getOid()); return mav; }
QualityReviewToolController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest req, HttpServletResponse ress, Object comm, BindException error) throws Exception { QualityReviewToolCommand cmd = (QualityReviewToolCommand) comm; TargetInstance ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceOid()); HarvestResult result = targetInstanceDao.getHarvestResult(cmd.getHarvestResultId(), false); Set<Seed> seeds = new LinkedHashSet<Seed>(); Iterator<String> originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); if (seed.getSeed().equals(seedUrl)) { seeds.add(seed); } } } if(seeds.isEmpty()){ originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<SeedHistory> currentSeedHistory = ti.getSeedHistory().iterator(); while (currentSeedHistory.hasNext()) { SeedHistory seedHistoryObj = currentSeedHistory.next(); if (seedHistoryObj.getSeed().equals(seedUrl)) { Target existingTarget = null; Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); existingTarget = seed.getTarget(); if(existingTarget != null) break; } if(existingTarget != null){ Seed newSeed = businessObjectFactory.newSeed(existingTarget); newSeed.setPrimary(seedHistoryObj.isPrimary()); newSeed.setSeed(seedHistoryObj.getSeed()); seeds.add(newSeed); } } } } } List<SeedMapElement> seedMap = new ArrayList<SeedMapElement>(); for(Seed seed: seeds) { load(seedMap, seed, true, result); } for(Seed seed: seeds) { load(seedMap, seed, false, result); } ModelAndView mav = new ModelAndView("quality-review-toc", "command", comm); mav.addObject(QualityReviewToolCommand.MDL_SEEDS, seedMap); mav.addObject("targetInstanceOid", ti.getOid()); mav.addObject("archiveUrl", archiveUrl); mav.addObject("archiveName", archiveName); mav.addObject("archiveAlternative", archiveUrlAlternative); mav.addObject("archiveAlternativeName", archiveUrlAlternativeName); mav.addObject("webArchiveTarget", webArchiveTarget); mav.addObject("targetOid", ti.getTarget().getOid()); return mav; } }
QualityReviewToolController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest req, HttpServletResponse ress, Object comm, BindException error) throws Exception { QualityReviewToolCommand cmd = (QualityReviewToolCommand) comm; TargetInstance ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceOid()); HarvestResult result = targetInstanceDao.getHarvestResult(cmd.getHarvestResultId(), false); Set<Seed> seeds = new LinkedHashSet<Seed>(); Iterator<String> originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); if (seed.getSeed().equals(seedUrl)) { seeds.add(seed); } } } if(seeds.isEmpty()){ originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<SeedHistory> currentSeedHistory = ti.getSeedHistory().iterator(); while (currentSeedHistory.hasNext()) { SeedHistory seedHistoryObj = currentSeedHistory.next(); if (seedHistoryObj.getSeed().equals(seedUrl)) { Target existingTarget = null; Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); existingTarget = seed.getTarget(); if(existingTarget != null) break; } if(existingTarget != null){ Seed newSeed = businessObjectFactory.newSeed(existingTarget); newSeed.setPrimary(seedHistoryObj.isPrimary()); newSeed.setSeed(seedHistoryObj.getSeed()); seeds.add(newSeed); } } } } } List<SeedMapElement> seedMap = new ArrayList<SeedMapElement>(); for(Seed seed: seeds) { load(seedMap, seed, true, result); } for(Seed seed: seeds) { load(seedMap, seed, false, result); } ModelAndView mav = new ModelAndView("quality-review-toc", "command", comm); mav.addObject(QualityReviewToolCommand.MDL_SEEDS, seedMap); mav.addObject("targetInstanceOid", ti.getOid()); mav.addObject("archiveUrl", archiveUrl); mav.addObject("archiveName", archiveName); mav.addObject("archiveAlternative", archiveUrlAlternative); mav.addObject("archiveAlternativeName", archiveUrlAlternativeName); mav.addObject("webArchiveTarget", webArchiveTarget); mav.addObject("targetOid", ti.getTarget().getOid()); return mav; } QualityReviewToolController(); }
QualityReviewToolController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest req, HttpServletResponse ress, Object comm, BindException error) throws Exception { QualityReviewToolCommand cmd = (QualityReviewToolCommand) comm; TargetInstance ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceOid()); HarvestResult result = targetInstanceDao.getHarvestResult(cmd.getHarvestResultId(), false); Set<Seed> seeds = new LinkedHashSet<Seed>(); Iterator<String> originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); if (seed.getSeed().equals(seedUrl)) { seeds.add(seed); } } } if(seeds.isEmpty()){ originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<SeedHistory> currentSeedHistory = ti.getSeedHistory().iterator(); while (currentSeedHistory.hasNext()) { SeedHistory seedHistoryObj = currentSeedHistory.next(); if (seedHistoryObj.getSeed().equals(seedUrl)) { Target existingTarget = null; Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); existingTarget = seed.getTarget(); if(existingTarget != null) break; } if(existingTarget != null){ Seed newSeed = businessObjectFactory.newSeed(existingTarget); newSeed.setPrimary(seedHistoryObj.isPrimary()); newSeed.setSeed(seedHistoryObj.getSeed()); seeds.add(newSeed); } } } } } List<SeedMapElement> seedMap = new ArrayList<SeedMapElement>(); for(Seed seed: seeds) { load(seedMap, seed, true, result); } for(Seed seed: seeds) { load(seedMap, seed, false, result); } ModelAndView mav = new ModelAndView("quality-review-toc", "command", comm); mav.addObject(QualityReviewToolCommand.MDL_SEEDS, seedMap); mav.addObject("targetInstanceOid", ti.getOid()); mav.addObject("archiveUrl", archiveUrl); mav.addObject("archiveName", archiveName); mav.addObject("archiveAlternative", archiveUrlAlternative); mav.addObject("archiveAlternativeName", archiveUrlAlternativeName); mav.addObject("webArchiveTarget", webArchiveTarget); mav.addObject("targetOid", ti.getTarget().getOid()); return mav; } QualityReviewToolController(); void setTargetInstanceManager(TargetInstanceManager targetInstanceManager); void setTargetManager(TargetManager targetManager); String getArchiveUrl(); void setArchiveUrl(String archiveUrl); String getArchiveUrlAlternative(); void setArchiveUrlAlternative(String archiveUrlAlternative); HarvestResourceUrlMapper getHarvestResourceUrlMapper(); void setHarvestResourceUrlMapper(
			HarvestResourceUrlMapper harvestResourceUrlMapper); TargetInstanceDAO getTargetInstanceDao(); void setTargetInstanceDao(TargetInstanceDAO targetInstanceDao); void setEnableBrowseTool(boolean enableBrowseTool); boolean isEnableBrowseTool(); void setEnableAccessTool(boolean enableAccessTool); boolean isEnableAccessTool(); void setWebArchiveTarget(String webArchiveTarget); String getArchiveName(); void setArchiveName(String archiveName); String getArchiveUrlAlternativeName(); void setArchiveUrlAlternativeName(String archiveUrlAlternativeName); }
QualityReviewToolController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest req, HttpServletResponse ress, Object comm, BindException error) throws Exception { QualityReviewToolCommand cmd = (QualityReviewToolCommand) comm; TargetInstance ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceOid()); HarvestResult result = targetInstanceDao.getHarvestResult(cmd.getHarvestResultId(), false); Set<Seed> seeds = new LinkedHashSet<Seed>(); Iterator<String> originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); if (seed.getSeed().equals(seedUrl)) { seeds.add(seed); } } } if(seeds.isEmpty()){ originalSeedsIt = ti.getOriginalSeeds().iterator(); while (originalSeedsIt.hasNext()) { String seedUrl = originalSeedsIt.next(); Iterator<SeedHistory> currentSeedHistory = ti.getSeedHistory().iterator(); while (currentSeedHistory.hasNext()) { SeedHistory seedHistoryObj = currentSeedHistory.next(); if (seedHistoryObj.getSeed().equals(seedUrl)) { Target existingTarget = null; Iterator<Seed> currentSeedsIt = targetManager.getSeeds(ti).iterator(); while (currentSeedsIt.hasNext()) { Seed seed = currentSeedsIt.next(); existingTarget = seed.getTarget(); if(existingTarget != null) break; } if(existingTarget != null){ Seed newSeed = businessObjectFactory.newSeed(existingTarget); newSeed.setPrimary(seedHistoryObj.isPrimary()); newSeed.setSeed(seedHistoryObj.getSeed()); seeds.add(newSeed); } } } } } List<SeedMapElement> seedMap = new ArrayList<SeedMapElement>(); for(Seed seed: seeds) { load(seedMap, seed, true, result); } for(Seed seed: seeds) { load(seedMap, seed, false, result); } ModelAndView mav = new ModelAndView("quality-review-toc", "command", comm); mav.addObject(QualityReviewToolCommand.MDL_SEEDS, seedMap); mav.addObject("targetInstanceOid", ti.getOid()); mav.addObject("archiveUrl", archiveUrl); mav.addObject("archiveName", archiveName); mav.addObject("archiveAlternative", archiveUrlAlternative); mav.addObject("archiveAlternativeName", archiveUrlAlternativeName); mav.addObject("webArchiveTarget", webArchiveTarget); mav.addObject("targetOid", ti.getTarget().getOid()); return mav; } QualityReviewToolController(); void setTargetInstanceManager(TargetInstanceManager targetInstanceManager); void setTargetManager(TargetManager targetManager); String getArchiveUrl(); void setArchiveUrl(String archiveUrl); String getArchiveUrlAlternative(); void setArchiveUrlAlternative(String archiveUrlAlternative); HarvestResourceUrlMapper getHarvestResourceUrlMapper(); void setHarvestResourceUrlMapper(
			HarvestResourceUrlMapper harvestResourceUrlMapper); TargetInstanceDAO getTargetInstanceDao(); void setTargetInstanceDao(TargetInstanceDAO targetInstanceDao); void setEnableBrowseTool(boolean enableBrowseTool); boolean isEnableBrowseTool(); void setEnableAccessTool(boolean enableAccessTool); boolean isEnableAccessTool(); void setWebArchiveTarget(String webArchiveTarget); String getArchiveName(); void setArchiveName(String archiveName); String getArchiveUrlAlternativeName(); void setArchiveUrlAlternativeName(String archiveUrlAlternativeName);  }