private String get_deposit_id(String bo_id, boolean waitForPendingObjects) throws ArchiveServiceException, InterruptedException { String depositId; if (waitForPendingObjects) { depositId = getDepositIdWaitForPending(bo_id); } else { depositId = getDepositIdIgnoreFailedOrPending(bo_id); } return depositId; }
String deposit_id = get_deposit_id(mf_id, waitForPendingObjects); if (deposit_id != null) { MetadataFile mf = unwrap(archive_service.retrieveMetadataFile(deposit_id)); result.getChildren().add(generateMap(mf, alternate_id_map, waitForPendingObjects)); } else { MetadataFile failedDepositMF = new MetadataFile(); failedDepositMF.setId(mf_id); result.getChildren().add(buildFailedDepositBOMap(failedDepositMF)); result.getChildren().add(generateMap(col, alternate_id_map, waitForPendingObjects)); String deposit_id = get_deposit_id(sub_col_id, waitForPendingObjects); if (deposit_id != null) { Collection sub_col = unwrap(archive_service .retrieveCollection(deposit_id)); result.getChildren().add(generateMap(sub_col, alternate_id_map, waitForPendingObjects)); } else { Collection failedDepositSubCollection = new Collection(); failedDepositSubCollection.setId(sub_col_id); result.getChildren().add(buildFailedDepositBOMap(failedDepositSubCollection)); String deposit_id = get_deposit_id(col.getId(), waitForPendingObjects); ArchiveSearchResult<DataItem> sr = archive_service .retrieveDataSetsForCollection(deposit_id, -1, 0); result.getChildren().add(generateMap(di, alternate_id_map, waitForPendingObjects)); DataItem di = (DataItem) object; for (DataFile df : di.getFiles()) {
private void writeMap(Document doc, Node parent, BusinessObjectMap bo) { Element el = add(doc, parent, "bo", null); add(doc, el, "id", bo.getId()); add(doc, el, "name", bo.getName()); add(doc, el, "type", bo.getType()); add(doc, el, "depositStatus", bo.getDepositStatus()); for (String alt : bo.getAlternateIds()) { add(doc, el, "alternateid", alt); } for (BusinessObjectMap bo_child : bo.getChildren()) { writeMap(doc, el, bo_child); } }
@Override public void writeHtmlMap(BusinessObjectMap map, OutputStream os) throws IOException { // Grab the xml ByteArrayOutputStream bos = new ByteArrayOutputStream(); writeXmlMap(map, bos); // Transform with xslt to html Source xslt = new StreamSource( BusinessObjectMapServiceImpl.class .getResourceAsStream(XSLT_RESOURCE)); try { Transformer trans = TransformerFactory.newInstance() .newTransformer(xslt); Source xml = new StreamSource(new ByteArrayInputStream( bos.toByteArray())); trans.transform(xml, new StreamResult(os)); } catch (TransformerException e) { throw new IOException(e); } }
@Override public void writeXmlMap(BusinessObjectMap map, OutputStream os) throws IOException { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); writeMap(doc, doc, map); Transformer trans = TransformerFactory.newInstance() .newTransformer(); trans.transform(new DOMSource(doc), new StreamResult(os)); } catch (ParserConfigurationException e) { throw new IOException(e); } catch (TransformerConfigurationException e) { throw new IOException(e); } catch (TransformerFactoryConfigurationError e) { throw new IOException(e); } catch (TransformerException e) { throw new IOException(e); } }
String deposit_id = get_deposit_id(mf_id, waitForPendingObjects); if (deposit_id != null) { MetadataFile mf = unwrap(archive_service.retrieveMetadataFile(deposit_id)); result.getChildren().add(generateMap(mf, alternate_id_map, waitForPendingObjects)); } else { MetadataFile failedDepositMF = new MetadataFile(); failedDepositMF.setId(mf_id); result.getChildren().add(buildFailedDepositBOMap(failedDepositMF)); result.getChildren().add(generateMap(col, alternate_id_map, waitForPendingObjects)); String deposit_id = get_deposit_id(sub_col_id, waitForPendingObjects); if (deposit_id != null) { Collection sub_col = unwrap(archive_service .retrieveCollection(deposit_id)); result.getChildren().add(generateMap(sub_col, alternate_id_map, waitForPendingObjects)); } else { Collection failedDepositSubCollection = new Collection(); failedDepositSubCollection.setId(sub_col_id); result.getChildren().add(buildFailedDepositBOMap(failedDepositSubCollection)); String deposit_id = get_deposit_id(col.getId(), waitForPendingObjects); ArchiveSearchResult<DataItem> sr = archive_service .retrieveDataSetsForCollection(deposit_id, -1, 0); result.getChildren().add(generateMap(di, alternate_id_map, waitForPendingObjects)); DataItem di = (DataItem) object; for (DataFile df : di.getFiles()) {
private void writeMap(Document doc, Node parent, BusinessObjectMap bo) { Element el = add(doc, parent, "bo", null); add(doc, el, "id", bo.getId()); add(doc, el, "name", bo.getName()); add(doc, el, "type", bo.getType()); add(doc, el, "depositStatus", bo.getDepositStatus()); for (String alt : bo.getAlternateIds()) { add(doc, el, "alternateid", alt); } for (BusinessObjectMap bo_child : bo.getChildren()) { writeMap(doc, el, bo_child); } }
@Override public void writeHtmlMap(BusinessObjectMap map, OutputStream os) throws IOException { // Grab the xml ByteArrayOutputStream bos = new ByteArrayOutputStream(); writeXmlMap(map, bos); // Transform with xslt to html Source xslt = new StreamSource( BusinessObjectMapServiceImpl.class .getResourceAsStream(XSLT_RESOURCE)); try { Transformer trans = TransformerFactory.newInstance() .newTransformer(xslt); Source xml = new StreamSource(new ByteArrayInputStream( bos.toByteArray())); trans.transform(xml, new StreamResult(os)); } catch (TransformerException e) { throw new IOException(e); } }
@Override public void writeXmlMap(BusinessObjectMap map, OutputStream os) throws IOException { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory .newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); writeMap(doc, doc, map); Transformer trans = TransformerFactory.newInstance() .newTransformer(); trans.transform(new DOMSource(doc), new StreamResult(os)); } catch (ParserConfigurationException e) { throw new IOException(e); } catch (TransformerConfigurationException e) { throw new IOException(e); } catch (TransformerFactoryConfigurationError e) { throw new IOException(e); } catch (TransformerException e) { throw new IOException(e); } }
private String get_deposit_id(String bo_id, boolean waitForPendingObjects) throws ArchiveServiceException, InterruptedException { String depositId; if (waitForPendingObjects) { depositId = getDepositIdWaitForPending(bo_id); } else { depositId = getDepositIdIgnoreFailedOrPending(bo_id); } return depositId; }