How does the Facebook SWORD client actually work?

I’ve been asked a few questions recently about how SWORD clients work, and in particular how the SWORD Facebook client works. The Facebook client is one of the most complete demonstration clients that there is, and as such ‘hides’ a lot of the work that goes on behind the scenes. This post will explain how a SWORD deposit from within Facebook actually works:

1-select-repo

2-username-password

require("swordappclient.php");
$sac = new SWORDAPPClient();
$sdr = $sac->servicedocument($url, $user, $password, $onbehalfof);

3-service-document

4-deposit-form

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<mets ID="sort-mets_mets" OBJID="sword-mets" LABEL="DSpace SWORD Item" PROFILE="DSpace METS SIP Profile 1.0" xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/mets.xsd">
<metsHdr CREATEDATE="2008-09-04T00:00:00"><br /><agent ROLE="CUSTODIAN" TYPE="ORGANIZATION">
<name>Stuart Lewis</name>
</agent>
</metsHdr>
<dmdSec ID="sword-mets-dmd-1" GROUPID="sword-mets-dmd-1_group-1">
<mdWrap LABEL="SWAP Metadata" MDTYPE="OTHER" OTHERMDTYPE="EPDCX" MIMETYPE="text/xml">
<xmlData>
<epdcx:descriptionSet xmlns:epdcx="http://purl.org/eprint/epdcx/2006-11-16/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://purl.org/eprint/epdcx/2006-11-16/ http://purl.org/eprint/epdcx/xsd/2006-11-16/epdcx.xsd">
<epdcx:description epdcx:resourceId="sword-mets-epdcx-1">
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/elements/1.1/type" epdcx:valueURI="http://purl.org/eprint/entityType/ScholarlyWork" />
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/elements/1.1/title">
<epdcx:valueString>Item Title</epdcx:valueString>
</epdcx:statement>
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/terms/abstract">
<epdcx:valueString>Item Abstract</epdcx:valueString>
</epdcx:statement>
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/elements/1.1/creator">
<epdcx:valueString>Lewis, Stuart</epdcx:valueString>
</epdcx:statement>
<epdcx:statement epdcx:propertyURI="http://purl.org/eprint/terms/isExpressedAs" epdcx:valueRef="sword-mets-expr-1" />
</epdcx:description>
<epdcx:description epdcx:resourceId="sword-mets-expr-1">
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/elements/1.1/type" epdcx:valueURI="http://purl.org/eprint/entityType/Expression" />
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/elements/1.1/language" epdcx:vesURI="http://purl.org/dc/terms/RFC3066">
<epdcx:valueString>en</epdcx:valueString>
</epdcx:statement>
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/elements/1.1/type" epdcx:vesURI="http://purl.org/eprint/terms/Type" epdcx:valueURI="http://purl.org/eprint/entityType/Expression" />
<epdcx:statement epdcx:propertyURI="http://purl.org/dc/terms/available">
<epdcx:valueString epdcx:sesURI="http://purl.org/dc/terms/W3CDTF">2009-04-28</epdcx:valueString>
</epdcx:statement>
<epdcx:statement epdcx:propertyURI="http://purl.org/eprint/terms/Status" epdcx:vesURI="http://purl.org/eprint/terms/Status"  epdcx:valueURI="http://purl.org/eprint/status/PeerReviewed" />
<epdcx:statement epdcx:propertyURI="http://purl.org/eprint/terms/copyrightHolder">
<epdcx:valueString>Stuart Lewis</epdcx:valueString>
</epdcx:statement>
</epdcx:description>
</epdcx:descriptionSet>
</xmlData>
</mets>
<fileSec>
<fileGrp ID="sword-mets-fgrp-1" USE="CONTENT">
<file GROUPID="sword-mets-fgid-0" ID="sword-mets-file-0" MIMETYPE="application/pdf">
<FLocat LOCTYPE="URL" xlink:href="SWORD Ariadne Jan 2008.pdf" />
</file>
</fileGrp>
</fileSec>
<structMap ID="sword-mets-struct-1" LABEL="structure" TYPE="LOGICAL">
<div ID="sword-mets-div-1" DMDID="sword-mets-dmd-1" TYPE="SWORD Object">
<div ID="sword-mets-div-2" TYPE="File">
<fptr FILEID="sword-mets-file-0" />
</div>
</div>
</structMap>
require('packager_mets_swap.php');
// Create a new package with the root and directory of the input files, and the root and directory of the created package
$package = new PackagerMetsSwap($rootin, $dirin, $rootout, $fileout);

// Add metadata to the package
$package->setType($test_type);
$package->setTitle($title);
$package->setAbstract($abstract);
foreach ($creators as $creator) {
$package->addCreator($creator);
}

// Add a file to the package
$package->addFile($filename, $mimetype);

// Now deposit the package
require("swordappclient.php");
$sac = new SWORDAPPClient();
$dr = $sac->deposit($depositurl, $username, $password, $onbehalfof, $filename, $packageformat, $pacakgecontenttype);
<!-- creator element: dc.contributor.author -->
<xsl:if test="./@epdcx:propertyURI='http://purl.org/dc/elements/1.1/creator'">
<dim:field mdschema="dc" element="contributor" qualifier="author">
<xsl:value-of select="epdcx:valueString"/>
</dim:field>
</xsl:if>

I hope this post clears up a bit of what goes on ‘behind the scenes’ of a SWORD client. I hope it also shows how easy it can be to create a SWORD client using the PHP library which provides not only code to request service documents and deposit items, but also to create pacakges in a format that is accepted by DSpace and EPrints. Any questions?

Bookmark and Share
Posted on June 2, 2009 at 12:05 am by Stuart · Permalink
In: Uncategorized · Tagged with: , ,

6 Responses

Subscribe to comments via RSS

  1. Written by Jason Fowler
    on September 17, 2009 at 8:46 am
    Permalink

    Stuart,

    Nice work on this project. This is the type of project that has the potential for extending the use of DSpace exponentially.

    I’ve been testing the app with my own repository, and I get the following message whenever the upload takes place. My connection is good. Any idea what could be causing it?

    ——

    Fatal error: Uncaught exception ‘Exception’ with message ‘Error parsing response entry (String could not be parsed as XML)’ in /var/www/fb.swordapp.org/swordapp-php-library-0.9/swordappclient.php:129 Stack trace: #0 /var/www/fb.swordapp.org/htdocs/deposit/process/deposit.php(35): SWORDAPPClient->deposit(”, ‘myusername@myhost.com’, ‘mypassword’, ”, ‘/var/www/fb.swo…’, ‘http://purl.org…’, ‘application/zip’) #1 {main} thrown in /var/www/fb.swordapp.org/swordapp-php-library-0.9/swordappclient.php on line 129

  2. Written by Stuart
    on September 17, 2009 at 9:19 am
    Permalink

    Hi Jason,

    Which version of DSpace are you using? It will only work with 1.5.2.

    Thanks,

    Stuart

  3. Written by Jason Fowler
    on September 17, 2009 at 1:59 pm
    Permalink

    That’s it. I’m still on 1.5.1. Will try again when I update.

    Really, really nice app, though. Love the work you’re doing with SWORD. All of it has serious potential at integrating a DSpace submission step into the regular workflow of normal people.

  4. Written by Jason Fowler
    on October 7, 2009 at 4:38 am
    Permalink

    Stuart,

    I have updated to 1.5.2 and after adjusting a few options in my config file, I have gotten close with getting the Facebook app to work with my repository. I can now submit the package, and I can see the atom entry generated when I tail the logs. Unfortunately, I now get a code 202 error from the app.

    Any suggestions?

  5. Written by Jason Fowler
    on October 7, 2009 at 9:51 am
    Permalink

    Stuart,

    A little further information on the problem. Actually, the package is being uploaded, and I see it when I look at my submissions within DSpace. But I still get the 200 error code in the Sword Facebook App, and I cannot see my submission from within the it.

    Thanks,
    Jason

  6. Written by Stuart
    on October 7, 2009 at 11:25 am
    Permalink

    Hi Jason,

    The application has been playing up slightly this morning. I’ve done two things which may help (changed the way the transfer works to not use chunked transfer, and set a Content-Length header). I’ve also restarted the web server which seems to have made it a bit better.

    Could you email me a screen shot of the page that fails if it still doesn’t work for you?

    Thanks,

    Stuart

Subscribe to comments via RSS

Leave a Reply