@Override public void loadDuIds(List<String> statusUrl) { if (statusUrl == null) return; if (statusUrl.size() == 0) return; Iterator<String> iterator = statusUrl.iterator(); while (iterator.hasNext()) { URL status; try { status = new URL(iterator.next()); InputStream inputStream = status.openStream(); ResearchObject sip = new SeadXstreamStaxModelBuilder().buildSip(inputStream); for (DcsDeliverableUnit du : sip.getDeliverableUnits()) { for (DcsResourceIdentifier id : du.getAlternateIds()) { if (id.getTypeId().equalsIgnoreCase("medici") || id.getTypeId().equalsIgnoreCase("lowermississipppi")) if (!Constants.duIds.containsKey(id.getIdValue())) { Constants.duIds.put(id.getIdValue(), du.getId()); break; } } } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvalidXmlException e) { // TODO Auto-generated catch block e.printStackTrace(); } break; // It is enough to just load the first one } }
public void setUp() throws Exception { solrhome = FileUtil.createTempDir("solrhome"); SolrService.createSolrInstall(solrhome); solr = new SolrService(solrhome); archivehome = FileUtil.createTempDir("archive"); archive = createTestArchiveStore(archivehome); index_service = new DcpIndexService(archive, solr); RandomEntityBuilder rb = new RandomEntityBuilder(); DcsDeliverableUnit du = rb.createDeliverableUnit(null, null, false); du.setTitle("blah"); List<DcsFile> files = new ArrayList<DcsFile>(); DcsManifestation man = rb.createManifestation(du.getId(), files); dcp = new Dcp(); dcp.addDeliverableUnit(du); dcp.addManifestation(man); dcp.addEvent(rb.createEvent(null)); dcp.addCollection(rb.createCollection(null)); for (DcsFile file : files) { dcp.addFile(file); } index(dcp); servletContainer = new ServletTester(); servletContainer.setContextPath("/access"); servletContainer.addServlet(QueryServlet.class, "/query/*"); servletContainer .getContext() .getServletContext() .setAttribute( "dcpquery.impl", "org.dataconservancy.dcs.query.dcpsolr.DcsDataModelQueryService"); String dsbaseurl = "/access/datastream"; servletContainer.getContext().getServletContext().setAttribute("datastream.url", dsbaseurl); servletContainer.start(); }