Thanks all. Stuart, taking your suggestion about adding the metadata then the bitstream, I'm a lot closer to a working solution.
$response = $client->depositAtomEntry(self::URL, self::USERNAME, self::PASSWORD, self::USERNAME, './tmp/atom_multipart_package', true); where atom_multipart_package is my atom xml, successfully creates an item and populates the associated metadata fields. However, $response = $client->addExtraFileToMediaResource((string)$response->sac_edit_media_iri, self::USERNAME, self::PASSWORD, self::USERNAME, "./tmp/logo.jpg", 'image/jpeg', false); is throwing an error, although I suspect this may be more of a DSpace configuration issue rather than an issue between the sword client and server. The above will throw a DSpace error: 30/04/2012 10:53:38 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet mediaresource threw exception org.dspace.core.PluginInstantiationException: Cannot load plugin class: java.lang.ClassNotFoundException: org.dspace.swordpackagers.SwordXifIngester at org.dspace.core.PluginManager.getNamedPlugin(PluginManager.java:459) at org.dspace.sword2.SwordIngesterFactory.getContentInstance(SwordIngesterFactory.java:49) at org.dspace.sword2.MediaResourceManagerDSpace.addContent(MediaResourceManagerDSpace.java:818) at org.dspace.sword2.MediaResourceManagerDSpace.addResource(MediaResourceManagerDSpace.java:553) at org.swordapp.server.MediaResourceAPI.post(MediaResourceAPI.java:239) at org.swordapp.server.servlets.MediaResourceServletDefault.doPost(MediaResourceServletDefault.java:49) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:679) Caused by: java.lang.ClassNotFoundException: org.dspace.swordpackagers.SwordXifIngester at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:186) at org.dspace.core.PluginManager.getNamedPlugin(PluginManager.java:424) ... 19 more Alternatively, if I try a PDF $response = $client->addExtraFileToMediaResource((string)$response->sac_edit_media_iri, self::USERNAME, self::PASSWORD, self::USERNAME, "./tmp/logo.pdf", 'application/pdf', false); DSpace throws the error: <html><head><title>Apache Tomcat/6.0.28 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>javax.servlet.ServletException: org.swordapp.server.SwordServerException: There was a problem depositing the item org.swordapp.server.MediaResourceAPI.post(MediaResourceAPI.java:270) org.swordapp.server.servlets.MediaResourceServletDefault.doPost(MediaResourceServletDefault.java:49) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) </pre></p><p><b>root cause</b> <pre>org.swordapp.server.SwordServerException: There was a problem depositing the item org.dspace.sword2.MediaResourceManagerDSpace.addResource(MediaResourceManagerDSpace.java:633) org.swordapp.server.MediaResourceAPI.post(MediaResourceAPI.java:239) org.swordapp.server.servlets.MediaResourceServletDefault.doPost(MediaResourceServletDefault.java:49) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) </pre></p><p><b>root cause</b> <pre>org.dspace.sword2.DSpaceSwordException: java.io.IOException: No such file or directory org.dspace.sword2.BinaryContentIngester.ingestToItem(BinaryContentIngester.java:183) org.dspace.sword2.BinaryContentIngester.ingest(BinaryContentIngester.java:46) org.dspace.sword2.BinaryContentIngester.ingest(BinaryContentIngester.java:34) org.dspace.sword2.MediaResourceManagerDSpace.addContent(MediaResourceManagerDSpace.java:822) org.dspace.sword2.MediaResourceManagerDSpace.addResource(MediaResourceManagerDSpace.java:553) org.swordapp.server.MediaResourceAPI.post(MediaResourceAPI.java:239) org.swordapp.server.servlets.MediaResourceServletDefault.doPost(MediaResourceServletDefault.java:49) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) </pre></p><p><b>root cause</b> <pre>java.io.IOException: No such file or directory java.io.UnixFileSystem.createFileExclusively(Native Method) java.io.File.createNewFile(File.java:900) edu.sdsc.grid.io.local.LocalFile.createNewFile(LocalFile.java:486) org.dspace.storage.bitstore.BitstreamStorageManager.store(BitstreamStorageManager.java:300) org.dspace.content.Bitstream.create(Bitstream.java:205) org.dspace.content.Bundle.createBitstream(Bundle.java:384) org.dspace.content.Item.createSingleBitstream(Item.java:1345) org.dspace.content.Item.createSingleBitstream(Item.java:1365) org.dspace.sword2.BinaryContentIngester.ingestToItem(BinaryContentIngester.java:148) org.dspace.sword2.BinaryContentIngester.ingest(BinaryContentIngester.java:46) org.dspace.sword2.BinaryContentIngester.ingest(BinaryContentIngester.java:34) org.dspace.sword2.MediaResourceManagerDSpace.addContent(MediaResourceManagerDSpace.java:822) org.dspace.sword2.MediaResourceManagerDSpace.addResource(MediaResourceManagerDSpace.java:553) org.swordapp.server.MediaResourceAPI.post(MediaResourceAPI.java:239) org.swordapp.server.servlets.MediaResourceServletDefault.doPost(MediaResourceServletDefault.java:49) javax.servlet.http.HttpServlet.service(HttpServlet.java:637) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) </pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/6.0.28 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.28</h3></body></html> Cheers Hayden On 30/04/12 16:20, Richard Jones wrote: > Hi Guys, > > It looks like you are making progress. Just to add that the existing > SWORDv2 implementation in DSpace is pretty experimental, but I have > been working through it in the last couple of weeks, finding and > fixing all the oddities that I can find. This is all happening in a > fork I have made of the github repo, from the 1.8.2 release: > > https://github.com/nye-duo/DSpace/tree/duo > > I hope to have this stable in the next couple of weeks, but note that > I'm not currently trying to get the multipart issues resolved, just > all the other bits and bobs. > > Cheers, > > Richard > > On 30 April 2012 09:09, LEWIS Stuart<stuart.le...@ed.ac.uk> wrote: >> Hi Hayden, >> >> The two options would be either: >> >> PackagerMetsSwap::create (to create a METS/SWAP package, which can be used >> in SWORD v1 or v2), followed by SWORDAppClient::deposit to deposit the >> package >> >> Or >> >> SWORDAppClient::depositAtomEntry to create the metadata-only object, >> followed by SWORDAppClient::addExtraFileToMediaResource >> >> (I think that should work - I've not got a computer set up with this code >> running right now). >> >> Thanks, >> >> >> Stuart >> >> >> >> -- >> The University of Edinburgh is a charitable body, registered in >> Scotland, with registration number SC005336. >> >> >> -----Original Message----- >> From: Hayden Young [mailto:haydenyo...@wijiti.com] >> Sent: 30 April 2012 08:55 >> To: LEWIS Stuart >> Cc: sword-app-tech@lists.sourceforge.net >> Subject: Re: [sword-app-tech] depositMultipart always results in a 500 error >> >> Hi Stuart >> >> Thanks for your assistance. >> >> So if I need to use a two step process to deposit an item to DSpace, am I >> using the correct methods to overcome DSpace's SWORDv2 limitations? >> >> I.e. >> >> SWORDAppClient::deposit to create the item >> >> SWORDAppClient::replaceMetadata or >> SWORDAppClient::replaceMetadataWithFile to update the item's metadata. >> >> >> >> On 30/04/12 15:32, LEWIS Stuart wrote: >>> Hi Hayden, >>> >>> === >>> Okay I've tried a couple of methods for adding metadata and completing the >>> deposit. >>> >>> Both: >>> >>> $response = >>> $client->replaceMetadata((string)$response->sac_edit_media_iri, >>> self::USERNAME, self::PASSWORD, self::USERNAME, './tmp/atom2', false); >>> >>> $response = >>> $client->replaceMetadataAndFile((string)$response->sac_edit_media_iri, >>> self::USERNAME, self::PASSWORD, self::USERNAME, >>> './tmp/atom_multipart_package2.zip', false); >>> >>> result in the error: >>> >>> <atom:summary xmlns:atom="http://www.w3.org/2005/Atom">Filename could not >>> be extracted from >>> Content-Disposition</atom:summary><sword:verboseDescription>org.swordapp.server.SwordError: >>> Filename could not be extracted from Content-Disposition >>> >>> Looking at both these methods shows that they call depositAtomEntryByMethod >>> and depositMultipartByMethod but from what I can see, neither of these >>> methods sets the curl Content-Disposition header. Could this be what is >>> causing this error? >>> === >>> >>> I don't think that is what should be causing it - when replacing metadata >>> (the first case, depositing a new atom entry) no filename >>> (content-disposition) is required. See the example in the spec at "6.5.2. >>> Replacing the Metadata of a Resource". >>> >>> In the second case, the problem might be that you're trying to deposit a >>> package (zip file, SWORD v1-style, which requires the use of the deposit() >>> function) using the depositMultipartByMethod function. This requires a >>> multipart file, which can be created using the packager_atom_multipart.php >>> class. For an example of this in use, see >>> test/test-packager-atom_multipart.php >>> >>> Thanks, >>> >>> >>> Stuart >>> >> -- >> Hayden Young >> Managing Director >> Wijiti Pty Ltd >> p. +61 (0) 08 6398 5010 >> e. haydenyo...@wijiti.com >> w. www.wijiti.com >> vcard. www.wijiti.com/vcard/haydenyoung.vcf >> >> NOTICE >> This e-mail and any attachments are intended for the addressee(s) only and >> may be confidential. They may contain legally privileged or copyright >> material. You should not read, copy, use or disclose them without >> authorization. If you are not the intended recipient please contact the >> sender as soon as possible by return e-mail and then please delete both >> messages. This notice should not be removed. >> >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> sword-app-tech mailing list >> sword-app-tech@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/sword-app-tech > > -- Hayden Young Managing Director Wijiti Pty Ltd p. +61 (0) 08 6398 5010 e. haydenyo...@wijiti.com w. www.wijiti.com vcard. www.wijiti.com/vcard/haydenyoung.vcf NOTICE This e-mail and any attachments are intended for the addressee(s) only and may be confidential. They may contain legally privileged or copyright material. You should not read, copy, use or disclose them without authorization. If you are not the intended recipient please contact the sender as soon as possible by return e-mail and then please delete both messages. This notice should not be removed. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ sword-app-tech mailing list sword-app-tech@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sword-app-tech