/** * Build another product for use during testing. * * @return product for use during testing. */ public Product getOtherProduct() { // BUILD PRODUCT ProductId id = ProductId.parse("urn:usgs-product:us:shakemap2:efgh5678:" + new Date().getTime()); Product product = new Product(id); try { product.setTrackerURL(new URL("http://localhost/tracker")); } catch (Exception e) { // ignore } product .getContents() .put( "test2.txt", new ByteContent( ("I am also test product content\n" + "that has several lines of text\n" + "blah, blah, blah, content, blah") .getBytes())); product.getProperties().put("testprop2", "testvalue2"); try { product.addLink("testrelation2", new URI("http://google.com/")); } catch (Exception e) { e.printStackTrace(); // ignore } return product; }
/** * Build a product for use during testing. * * @return product for use during testing. */ public Product getProduct() { // BUILD PRODUCT ProductId id = ProductId.parse("urn:usgs-product:us:shakemap:abcd1234:" + new Date().getTime()); Product product = new Product(id); try { product.setTrackerURL(new URL("http://localhost/tracker")); } catch (Exception e) { // ignore } ByteContent inlineContent = new ByteContent(("I am <em>inline</em> html content").getBytes()); inlineContent.setContentType("text/html"); product.getContents().put("", inlineContent); product .getContents() .put( "test.txt", new ByteContent( ("I am a test product content\n" + "that has several lines of text\n" + "blah, blah, blah, content, blah") .getBytes())); try { // URL eidsInstaller = new URL( // "http://earthquake.usgs.gov/research/software/eids/EIDSInstaller.jar"); FileContent file = new FileContent(new File("etc/examples/hub/bin/EIDSInstaller.jar")); product.getContents().put("jar/EIDSInstaller.jar", file); } catch (Exception e) { // ignore } product.getProperties().put("testprop", "testvalue"); try { product.addLink("testrelation", new URI("http://google.com/")); } catch (Exception e) { e.printStackTrace(); // ignore } try { // generate a signature product.sign(SIGNATURE_KEY_PAIR.getPrivate()); } catch (Exception e) { System.err.println(e); } return product; }