コード例 #1
0
  private void addDCDatastream(DigitalObjectDocument.DigitalObject dobj) {
    DatastreamType ds = dobj.addNewDatastream();
    ds.setID("DC");
    ds.setCONTROLGROUP(DatastreamType.CONTROLGROUP.X);
    ds.setSTATE(StateType.A);

    DatastreamVersionType dsv = ds.addNewDatastreamVersion();
    dsv.setID("DC.0");
    dsv.setFORMATURI("http://www.openarchives.org/OAI/2.0/oai_dc/");
    dsv.setMIMETYPE("text/xml");
    dsv.setLABEL("Dublin Core Record for this object");

    XmlContentType content = dsv.addNewXmlContent();
    DcDocument dcDocument = getDcDocument();
    content.set(dcDocument);
  }
コード例 #2
0
  private void addRELSEXTDatastream(DigitalObjectDocument.DigitalObject dobj) {
    DatastreamType datastream = dobj.addNewDatastream();
    datastream.setID("RELS-EXT");
    datastream.setSTATE(StateType.A);
    datastream.setCONTROLGROUP(DatastreamType.CONTROLGROUP.X);

    DatastreamVersionType version = datastream.addNewDatastreamVersion();
    version.setID("RELS-EXT.0");
    version.setMIMETYPE("application/rdf+xml");
    version.setFORMATURI("info:fedora/fedora-system:FedoraRELSExt-1.0");
    version.setLABEL("RDF Statements about this object");

    XmlContentType content = version.addNewXmlContent();
    RDFDocument rdfDocument = getRDFDescription();
    content.set(rdfDocument);
  }
コード例 #3
0
  private void addQucosaXMLContentDatastream(DigitalObjectDocument.DigitalObject dobj)
      throws ParserConfigurationException {
    DatastreamType ds = dobj.addNewDatastream();
    ds.setID("QUCOSA-XML");
    ds.setCONTROLGROUP(DatastreamType.CONTROLGROUP.X);
    ds.setSTATE(StateType.A);

    DatastreamVersionType dsv = ds.addNewDatastreamVersion();
    dsv.setID("QUCOSA-XML.0");
    dsv.setMIMETYPE("text/xml");
    dsv.setLABEL("Qucosa XML Record for this Object (Opus4-XMLv2)");

    XmlContentType content = dsv.addNewXmlContent();

    // Workaround for https://issues.apache.org/jira/browse/XMLBEANS-100
    // XMLBeans does not work with jdk1.6 as calls made to methods within XObj.java
    // return with a runtime: "java.lang.RuntimeException: DOM Level 3 Not implemented"
    Node childNode =
        content
            .getDomNode()
            .getOwnerDocument()
            .importNode(qucosaXmlDocument.getDocumentElement(), true);
    content.getDomNode().appendChild(childNode);
  }
コード例 #4
0
ファイル: Utils.java プロジェクト: codebrane/sakai-chh-fedora
  public static byte[] getDCBytes(DigitalItemInfo item, Datastream ds) {
    DatastreamType dcDatastream = DatastreamType.Factory.newInstance();
    dcDatastream.setID("DC");
    dcDatastream.setSTATE(StateType.A);
    dcDatastream.setCONTROLGROUP(DatastreamType.CONTROLGROUP.X);

    DatastreamVersionType dcDatastreamVersion = dcDatastream.addNewDatastreamVersion();
    dcDatastreamVersion.setID(ds.getID());
    dcDatastreamVersion.setMIMETYPE(ds.getMIMEType());
    dcDatastreamVersion.setLABEL(ds.getLabel());

    XmlContentType xmlContent = dcDatastreamVersion.addNewXmlContent();

    Element dc = xmlContent.getDomNode().getOwnerDocument().createElementNS("oai_dc", "dc");

    // http://www.fedora.info/bugzilla/show_bug.cgi?id=153
    dc.setAttribute("xmlns:oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/");
    dc.setAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");

    Element dcTitle = xmlContent.getDomNode().getOwnerDocument().createElementNS("dc", "title");
    Text textNode = xmlContent.getDomNode().getOwnerDocument().createTextNode(item.getTitle());
    dcTitle.appendChild(textNode);
    dc.appendChild(dcTitle);

    Element dcCreator = xmlContent.getDomNode().getOwnerDocument().createElementNS("dc", "creator");
    textNode = xmlContent.getDomNode().getOwnerDocument().createTextNode(item.getCreator());
    dcCreator.appendChild(textNode);
    dc.appendChild(dcCreator);

    Element dcSubject = xmlContent.getDomNode().getOwnerDocument().createElementNS("dc", "subject");
    textNode = xmlContent.getDomNode().getOwnerDocument().createTextNode(item.getSubject());
    dcSubject.appendChild(textNode);
    dc.appendChild(dcSubject);

    Element dcDescription =
        xmlContent.getDomNode().getOwnerDocument().createElementNS("dc", "description");
    textNode = xmlContent.getDomNode().getOwnerDocument().createTextNode(item.getDescription());
    dcDescription.appendChild(textNode);
    dc.appendChild(dcDescription);

    Element dcPublisher =
        xmlContent.getDomNode().getOwnerDocument().createElementNS("dc", "publisher");
    textNode = xmlContent.getDomNode().getOwnerDocument().createTextNode(item.getPublisher());
    dcPublisher.appendChild(textNode);
    dc.appendChild(dcPublisher);

    Element dcIdentifier =
        xmlContent.getDomNode().getOwnerDocument().createElementNS("dc", "identifier");
    textNode = xmlContent.getDomNode().getOwnerDocument().createTextNode(item.getTitle());
    dcIdentifier.appendChild(textNode);
    dc.appendChild(dcIdentifier);

    xmlContent.getDomNode().appendChild(dc);

    return xmlContent.toString().getBytes();
  }