Hi Hayden,

Thanks for persisting with this - it's great to hear about the positive 
outcome.  Unfortunately I've not got a working copy of DSpace / SWORD on my PC 
since changing jobs.  If you're able to debug the PHP client's parsing of the 
result, that would be great.  The spec doesn't specify the response should be - 
it may be that no xml is returned, so the build hierarchy code may not be 
needed.  I don't know what DSpace does in this respect.

http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#protocoloperations_addingcontent_mediaresource

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: 01 May 2012 17:07
To: Richard Jones
Cc: sword-app-tech@lists.sourceforge.net
Subject: Re: [sword-app-tech] depositMultipart always results in a 500 error

Okay success with addExtraFileToMediaResource.

First of all we added a new SimpleZipContentIngester entry to the
SwordContentIngester:

   org.dspace.sword2.SimpleZipContentIngester = application/zip

So it now looks like:

plugin.named.org.dspace.sword2.SwordContentIngester = \
   org.dspace.sword2.SimpleZipContentIngester = 
http://purl.org/net/sword/package/SimpleZip, \
   org.dspace.sword2.SwordMETSContentIngester = 
http://purl.org/net/sword/package/METSDSpaceSIP, \
   org.dspace.sword2.BinaryContentIngester = 
http://purl.org/net/sword/package/Binary, \
   org.dspace.swordpackagers.SwordDocXIngester = 
application/vnd.openxmlformats-officedocument.wordprocessingml.document, \
   org.dspace.swordpackagers.SwordXifIngester = image/jpeg, \
   org.dspace.sword2.SimpleZipContentIngester = application/zip

I then zip all my assets; pdf, jpeg, even other zips; and send these to Sword 
using addExtraFileToMediaResource:

$response =
$client->addExtraFileToMediaResource((string)$response->sac_edit_media_iri,
self::USERNAME, self::PASSWORD, self::USERNAME, "package.zip", 
'application/zip', false);

Sword extracts the files and attaches them to my item. The content types are 
correct and the names are fully intact.

One issue I notice I am getting when addExtraFileToMediaResource is the
error: Error parsing response entry (String could not be parsed as XML). 
However, DSpace is not throwing an exception.

The offending code block is:

             try {
                 // Get the deposit results
                 $sac_xml = @new SimpleXMLElement($sac_resp);
                 $sac_ns = $sac_xml->getNamespaces(true);
                 // Build the deposit response object
                 $sac_dresponse->buildhierarchy($sac_xml, $sac_ns);
             } catch (Exception $e) {
                 throw new Exception("Error parsing response entry (" . 
$e->getMessage() . ")");
             }

On closer inspection I noticed that calling the edit iri doesn't return 
anything and so the $sac_resp is empty. Therefore I am assuming buildhierarchy 
throws an exception at some stage. I haven't had chance to step through the 
code using a debugger but I can if you would like me to investigate further.

Thanks again for everyone's assistance.

Cheers


Hayden

On 01/05/12 01:36, Hayden Young wrote:
> Thanks.
>
> Yes I at least have a php client that is working somewhat so we will 
> run the debugger against the sword server code and see if we can find 
> out where the problem is.
>
> Cheers
>
>
> Hayden
>
> On 01/05/12 01:27, Richard Jones wrote:
>> I've just looked this up in the spec, and no quote marks are expected
>> - sorry for the diversion.
>>
>> Furthermore, the java client doesn't strip quotes, so not sure where 
>> your missing characters are going.
>>
>> Cheers,
>>
>> Richard
>>
>>
>> On 30 April 2012 17:44, Hayden Young<haydenyo...@wijiti.com>  wrote:
>>> Okay I updated SwordAppClient and quoted the filename:
>>>
>>> array_push($headers, 'Content-Disposition: filename="' . 
>>> $sac_fname_trimmed . '"');
>>>
>>>
>>> The error logged:
>>>
>>> 30/04/2012 4:29:57 PM org.apache.catalina.core.StandardWrapperValve
>>> invoke
>>> SEVERE: Servlet.service() for servlet mediaresource threw exception
>>> org.apache.abdera.i18n.iri.IRISyntaxException:
>>> org.apache.abdera.i18n.text.InvalidCharacterException: Invalid 
>>> Character
>>> 0x22(")
>>>
>>> We'll look at getting the debugger onto the Java code tomorrow.
>>>
>>>
>>> On 30/04/12 23:36, LEWIS Stuart wrote:
>>>>>> filename="myfile.xxx" (this will get the name right in DSpace)
>>>>> So possibly the PHP client is not wrapping the filename in quote 
>>>>> marks, and the java server isn't clever enough to check that it's 
>>>>> actually stripping leading>and following quotes, which might 
>>>>> account for your missing letters.  I'll check the java one - 
>>>>> Stuart, could you have a look at the PHP client?
>>>> Yes - it looks like there might be a bug (copied from old v1 code):
>>>>
>>>> array_push($headers, "Content-Disposition: filename=" . 
>>>> $sac_fname_trimmed);
>>>>
>>>> It needs updating (three times in swordappclient.php) to:
>>>>
>>>> array_push($headers, 'Content-Disposition: filename="' . 
>>>> $sac_fname_trimmed . '"');
>>>>
>>>> Try that, and see if it helps.
>>>>
>>>> Cheers,
>>>>
>>>>
>>>> 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

------------------------------------------------------------------------------
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

Reply via email to