private Foxml11Document createFoxmlObject(String spid, String contentLocation) throws Exception { PID pid = PID.getInstance(spid); Date date = new Date(1); Foxml11Document doc = new Foxml11Document(pid.toString()); doc.addObjectProperty(Property.STATE, "A"); if (contentLocation != null && contentLocation.length() > 0) { String ds = "DS"; String dsv = "DS1.0"; doc.addDatastream(ds, State.A, ControlGroup.M, true); doc.addDatastreamVersion(ds, dsv, "text/plain", "label", 1, date); doc.setContentLocation(dsv, contentLocation, org.fcrepo.server.storage.types.Datastream.DS_LOCATION_TYPE_URL); } return doc; }
public void addObjectProperty(Property name, String value) { addObjectProperties(); Element property = doc.createElementNS(FOXML_NS, "foxml:property"); property.setAttribute("NAME", name.uri); property.setAttribute("VALUE", value); objectProperties.appendChild(property); }
private Element addContentLocation(String dsvId) { Node node = getDatastreamVersion(dsvId); Element location = doc.createElementNS(FOXML_NS, "foxml:contentLocation"); node.appendChild(location); return location; }
private byte[] getFoxmlObject(String pid, String contentLocation) throws Exception { Foxml11Document doc = createFoxmlObject(pid, contentLocation); ByteArrayOutputStream out = new ByteArrayOutputStream(); doc.serialize(out); return out.toByteArray(); }
public void setContentLocation(String dsvId, String ref, String type) { String expr = String.format("//foxml:datastreamVersion[@ID='%s']/foxml:contentLocation", dsvId); try { NodeList nodes = (NodeList)xpath.evaluate(expr, doc, XPathConstants.NODESET); Element location = (Element)nodes.item(0); if (location == null) { location = addContentLocation(dsvId); } location.setAttribute("REF", ref); location.setAttribute("TYPE", type); } catch (XPathExpressionException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private byte[] getFoxmlObject(String pid, String contentLocation) throws Exception { Foxml11Document doc = createFoxmlObject(pid, contentLocation); ByteArrayOutputStream out = new ByteArrayOutputStream(); doc.serialize(out); return out.toByteArray(); }
public void setContentLocation(String dsvId, String ref, String type) { String expr = String.format("//foxml:datastreamVersion[@ID='%s']/foxml:contentLocation", dsvId); try { NodeList nodes = (NodeList)xpath.evaluate(expr, doc, XPathConstants.NODESET); Element location = (Element)nodes.item(0); if (location == null) { location = addContentLocation(dsvId); } location.setAttribute("REF", ref); location.setAttribute("TYPE", type); } catch (XPathExpressionException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private Foxml11Document createFoxmlObject(String spid, String contentLocation) throws Exception { PID pid = PID.getInstance(spid); Date date = new Date(1); Foxml11Document doc = new Foxml11Document(pid.toString()); doc.addObjectProperty(Property.STATE, "A"); if (contentLocation != null && contentLocation.length() > 0) { String ds = "DS"; String dsv = "DS1.0"; doc.addDatastream(ds, State.A, ControlGroup.E, true); doc.addDatastreamVersion(ds, dsv, "text/plain", "label", 1, date); doc.setContentLocation(dsv, contentLocation, org.fcrepo.server.storage.types.Datastream.DS_LOCATION_TYPE_URL); } return doc; }
private Element addContentLocation(String dsvId) { Node node = getDatastreamVersion(dsvId); Element location = doc.createElementNS(FOXML_NS, "foxml:contentLocation"); node.appendChild(location); return location; }
private byte[] getFoxmlObject(String pid, String contentLocation) throws Exception { Foxml11Document doc = createFoxmlObject(pid, contentLocation); ByteArrayOutputStream out = new ByteArrayOutputStream(); doc.serialize(out); return out.toByteArray(); }
public void addObjectProperty(Property name, String value) { addObjectProperties(); Element property = doc.createElementNS(FOXML_NS, "foxml:property"); property.setAttribute("NAME", name.uri); property.setAttribute("VALUE", value); objectProperties.appendChild(property); }
private Foxml11Document createFoxmlObject(String spid, String contentLocation) throws Exception { PID pid = PID.getInstance(spid); Date date = new Date(1); Foxml11Document doc = new Foxml11Document(pid.toString()); doc.addObjectProperty(Property.STATE, "A"); if (contentLocation != null && contentLocation.length() > 0) { String ds = "DS"; String dsv = "DS1.0"; doc.addDatastream(ds, State.A, ControlGroup.E, true); doc.addDatastreamVersion(ds, dsv, "text/html", "label", 1, date); doc.setContentLocation(dsv, contentLocation, org.fcrepo.server.storage.types.Datastream.DS_LOCATION_TYPE_URL); } return doc; } }
public void addXmlContent(String dsvId, String xmlContent) { DocumentBuilder builder = null; try { builder = XmlTransformUtility.borrowDocumentBuilder(); Document contentDoc = builder.parse(new InputSource(new StringReader(xmlContent))); Node importedContent = doc.adoptNode(contentDoc.getDocumentElement()); Node dsv = getDatastreamVersion(dsvId); Element content = doc.createElementNS(FOXML_NS, "foxml:xmlContent"); dsv.appendChild(content); content.appendChild(importedContent); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (builder != null) { XmlTransformUtility.returnDocumentBuilder(builder); } } }
public void addXmlContent(String dsvId, String xmlContent) { DocumentBuilder builder = null; try { builder = XmlTransformUtility.borrowDocumentBuilder(); Document contentDoc = builder.parse(new InputSource(new StringReader(xmlContent))); Node importedContent = doc.adoptNode(contentDoc.getDocumentElement()); Node dsv = getDatastreamVersion(dsvId); Element content = doc.createElementNS(FOXML_NS, "foxml:xmlContent"); dsv.appendChild(content); content.appendChild(importedContent); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (builder != null) { XmlTransformUtility.returnDocumentBuilder(builder); } } }