Fedora exceptions
From Devwiki
Contents
Can't declare any more prefixes in this context
Reason
If you add JDOM Elements to a JDOM document without declaring the Namespaces you get the following XML:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="info:fedora/llgc-id:109"> <rel:isMemberOf rdf:resource="info:fedora/collection:digitisation" xmlns:rel="info:fedora/fedora-system:def/relations-external#"/> <rel:isMemberOf rdf:resource="info:fedora/collection:jth" xmlns:rel="info:fedora/fedora-system:def/relations-external#"/> <oai:itemID xmlns:oai="http://www.openarchives.org/OAI/2.0/">oai:llgc.org.uk:llgc-id:109</oai:itemID> </rdf:Description> </rdf:RDF>
Example Code
Namespace REL = Namespace.getNamespace("rel", "info:fedora/fedora-system:def/relations-external#"); Element tDesc = this.getDescription(); Element tRelation = new Element("isMemberOf", REL); tRelation.setAttribute("resource", "info:fedora/" + pPIDofCollection, RDF); tDesc.addContent(tRelation);
Solution
Add the namespaces to the Root Element of the document to get the following XML:
<?xml version="1.0" encoding="UTF-8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rel="info:fedora/fedora-system:def/relations-external#" xmlns:oai="http://www.openarchives.org/OAI/2.0/"> <rdf:Description rdf:about="info:fedora/llgc-id:4527"> <rel:isMemberOf rdf:resource="info:fedora/collection:digitisation" /> <rel:isMemberOf rdf:resource="info:fedora/collection:jth" /> <oai:itemID>oai:llgc.org.uk:llgc-id:4527</oai:itemID> </rdf:Description> </rdf:RDF>
Example Code
Namespace RDF = Namespace.getNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); Namespace REL = Namespace.getNamespace("rel", "info:fedora/fedora-system:def/relations-external#"); Namespace OAI = Namespace.getNamespace("oai", "http://www.openarchives.org/OAI/2.0/"); _rdf = new Document(); Element tRoot = new Element("RDF", RDF); _rdf.setRootElement(tRoot); tRoot.addContent(new Element("Description", RDF)); tRoot.addNamespaceDeclaration(REL); tRoot.addNamespaceDeclaration(OAI);
Back End Exception
fedora.server.errors.ResourceIndexException: RDF Parse Error. at fedora.server.resourceIndex.ResourceIndexImpl.addRelsDatastream(ResourceIndexImpl.java:892) at fedora.server.resourceIndex.ResourceIndexImpl.addDatastream(ResourceIndexImpl.java:281) at fedora.server.resourceIndex.ResourceIndexImpl.addDigitalObject(ResourceIndexImpl.java:225) at fedora.server.resourceIndex.ResourceIndexImpl.modifyDigitalObject(ResourceIndexImpl.java:381) at fedora.server.resourceIndex.ResourceIndexModule.modifyDigitalObject(ResourceIndexModule.java:205) at fedora.server.storage.DefaultDOManager.doCommit(DefaultDOManager.java:1010) at fedora.server.storage.SimpleDOWriter.commit(SimpleDOWriter.java:342) at fedora.server.management.DefaultManagement.addDatastream(DefaultManagement.java:447) at fedora.server.management.FedoraAPIMBindingSOAPHTTPImpl.addDatastream(FedoraAPIMBindingSOAPHTTPImpl.java:328) Caused by: org.trippi.TrippiException: RDF Parse Error. at org.trippi.io.RIOTripleIterator.getNext(RIOTripleIterator.java:89) at org.trippi.io.RIOTripleIterator.<init>(RIOTripleIterator.java:65) at org.trippi.TripleIterator.fromStream(TripleIterator.java:139) at org.trippi.TripleIterator.fromStream(TripleIterator.java:147) at fedora.server.resourceIndex.ResourceIndexImpl.addRelsDatastream(ResourceIndexImpl.java:886) at fedora.server.resourceIndex.ResourceIndexImpl.addDatastream(ResourceIndexImpl.java:281) at fedora.server.resourceIndex.ResourceIndexImpl.addDigitalObject(ResourceIndexImpl.java:225) at fedora.server.resourceIndex.ResourceIndexImpl.modifyDigitalObject(ResourceIndexImpl.java:381) at fedora.server.resourceIndex.ResourceIndexModule.modifyDigitalObject(ResourceIndexModule.java:205) at fedora.server.storage.DefaultDOManager.doCommit(DefaultDOManager.java:1010) at fedora.server.storage.SimpleDOWriter.commit(SimpleDOWriter.java:342) at fedora.server.management.DefaultManagement.addDatastream(DefaultManagement.java:447) at fedora.server.management.FedoraAPIMBindingSOAPHTTPImpl.addDatastream(FedoraAPIMBindingSOAPHTTPImpl.java:328) Caused by: org.openrdf.rio.ParseException: java.lang.IllegalStateException: can't declare any more prefixes in this context at org.openrdf.rio.rdfxml.RdfXmlParser._parse(RdfXmlParser.java:416) at org.openrdf.rio.rdfxml.RdfXmlParser.parse(RdfXmlParser.java:363) at org.trippi.io.RIOTripleIterator.run(RIOTripleIterator.java:134) at java.lang.Thread.run(Thread.java:534) Caused by: java.lang.IllegalStateException: can't declare any more prefixes in this context at org.xml.sax.helpers.NamespaceSupport$Context.declarePrefix(Unknown Source) at org.xml.sax.helpers.NamespaceSupport.declarePrefix(Unknown Source) at org.apache.crimson.parser.Parser2.processAttributeNS(Parser2.java:1771) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1620) at org.apache.crimson.parser.Parser2.content(Parser2.java:1963) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691) at org.apache.crimson.parser.Parser2.content(Parser2.java:1963) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691) at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667) at org.apache.crimson.parser.Parser2.parse(Parser2.java:337) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448) at org.openrdf.rio.rdfxml.RdfXmlParser._parse(RdfXmlParser.java:409) at org.openrdf.rio.rdfxml.RdfXmlParser.parse(RdfXmlParser.java:363) at org.trippi.io.RIOTripleIterator.run(RIOTripleIterator.java:134) at java.lang.Thread.run(Thread.java:534)
Front End Exception
AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: fedora.server.errors.ResourceIndexException: RDF Parse Error. faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}hostname:teilo.llgc.org.uk fedora.server.errors.ResourceIndexException: RDF Parse Error. at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129) at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:345) at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) at org.apache.axis.client.Call.invokeEngine(Call.java:2784) at org.apache.axis.client.Call.invoke(Call.java:2767) at org.apache.axis.client.Call.invoke(Call.java:2443) at org.apache.axis.client.Call.invoke(Call.java:2366) at org.apache.axis.client.Call.invoke(Call.java:1812) at fedora.server.management.FedoraAPIMBindingSOAPHTTPStub.addDatastream(FedoraAPIMBindingSOAPHTTPStub.java:902) at fedora.client.APIMStubWrapper$9.construct(APIMStubWrapper.java:761) at fedora.client.SwingWorker$2.run(SwingWorker.java:137) at java.lang.Thread.run(Thread.java:534)