Author: sevein
Date: Sat Oct 8 14:31:54 2011
New Revision: 9990
Log:
Partial implementation of developer features in SWORD and other requirements
like sword:userAgent, etc...
Modified:
trunk/plugins/qtSwordPlugin/lib/qtSwordPluginHttpAuthFilter.class.php
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/depositAction.class.php
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/servicedocumentAction.class.php
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/depositSuccess.xml.php
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/servicedocumentSuccess.xml.php
Modified: trunk/plugins/qtSwordPlugin/lib/qtSwordPluginHttpAuthFilter.class.php
==============================================================================
--- trunk/plugins/qtSwordPlugin/lib/qtSwordPluginHttpAuthFilter.class.php
Sat Oct 8 12:59:29 2011 (r9989)
+++ trunk/plugins/qtSwordPlugin/lib/qtSwordPluginHttpAuthFilter.class.php
Sat Oct 8 14:31:54 2011 (r9990)
@@ -38,6 +38,11 @@
return;
}
+
+ // We'll need username/email details later
+ $request = sfContext::getInstance()->request;
+ $request->setAttribute('username', $user->username);
+ $request->setAttribute('email', $user->email);
}
$filterChain->execute();
Modified:
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/depositAction.class.php
==============================================================================
---
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/depositAction.class.php
Sat Oct 8 12:59:29 2011 (r9989)
+++
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/depositAction.class.php
Sat Oct 8 14:31:54 2011 (r9990)
@@ -25,12 +25,40 @@
if ($request->isMethod('post'))
{
- if (!in_array($request->getHttpHeader('X-Packaging'),
qtSwordPluginConfiguration::$packaging))
+ $this->packaging = $request->getHttpHeader('X-Packaging');
+
+ // Check if the packaging format is supported
+ if (!in_array($this->packaging, qtSwordPluginConfiguration::$packaging))
{
// HTTP status code 415: Unsupported Media Type
$this->response->setStatusCode('415');
+ $this->response->setHttpHeader('Content-Type', 'application/atom+xml;
charset="utf-8"');
+
+ $request->setRequestFormat('xml');
+ $this->setTemplate('error/ErrorContent');
+
+ return;
+ }
+
+ // TODO: Mediation (see [2])
+ // $request->getHttpHeader('X-On-Behalf-Of');
+
+ // TODO: Development features
+ // X-No-Op (dry run)
+ // X-Verbose (verbose output)
+
+ // Clarify that we don't support this extension yet
+ if ('true' == $request->getHttpHeader('X-No-Op'))
+ {
+ $this->response->setStatusCode('400');
+
+ $this->response->setHttpHeader('Content-Type', 'application/atom+xml;
charset="utf-8"');
+
$request->setRequestFormat('xml');
+ $this->setTemplate('error/ErrorBadRequest');
+
+ return;
}
// HTTP status code 201: Created
Modified:
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/servicedocumentAction.class.php
==============================================================================
---
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/servicedocumentAction.class.php
Sat Oct 8 12:59:29 2011 (r9989)
+++
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/servicedocumentAction.class.php
Sat Oct 8 14:31:54 2011 (r9990)
@@ -25,6 +25,7 @@
$this->verbose = 'false';
$this->noOp = 'false';
$this->maxUploadSize = QubitDigitalObject::getMaxUploadSize() / 1024; //
From bytes to kilobytes
+ $this->mediation = 'false'; // Should be based in auth + X-On-Behalf-Of
if (isset($request->getAttribute('sf_route')->resource))
{
Modified:
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/depositSuccess.xml.php
==============================================================================
---
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/depositSuccess.xml.php
Sat Oct 8 12:59:29 2011 (r9989)
+++
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/depositSuccess.xml.php
Sat Oct 8 14:31:54 2011 (r9990)
@@ -0,0 +1,36 @@
+<?php echo '<?xml version="1.0" encoding="'.sfConfig::get('sf_charset',
'UTF-8').'" ?>' ?>
+<entry xmlns="http://www.w3.org/2005/Atom"
+ xmlns:sword="http://purl.org/net/sword/">
+
+ <title>My Deposit</title>
+
+ <id>info:something:1</id>
+
+ <updated>2008-08-18T14:27:08Z</updated>
+
+ <author><name><?php echo $sf_request->getAttribute('username')
?></name></author>
+
+ <?php
+ /*
+ TODO. See X-On-Behalf-Of [2] and medation
+ <contributor><name><?php echo $.. ?></name></contributor>
+ */
+ ?>
+
+ <summary type="text">A summary</summary>
+
+ <content type="application/zip"
src="http://www.myrepository.ac.uk/geography-collection/deposit1.zip"/>
+
+ <link rel="edit"
href="http://www.myrepository.ac.uk/geography-collection/atom/my_deposit.atom"
/>
+
+ <link rel="edit-media"
href="http://www.myrepository.ac.uk/geography-collection/atom/my_deposit.atom"
/>
+
+ <sword:packaging><?php echo $packaging ?></sword:packaging>
+
+ <sword:userAgent><?php echo $_SERVER['HTTP_USER_AGENT'] ?></sword:userAgent>
+
+ <generator uri="http://www.myrepository.ac.uk/engine" version="1.0"/>
+
+ <sword:treatment>Treatment description</sword:treatment>
+
+</entry>
Modified:
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/servicedocumentSuccess.xml.php
==============================================================================
---
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/servicedocumentSuccess.xml.php
Sat Oct 8 12:59:29 2011 (r9989)
+++
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/servicedocumentSuccess.xml.php
Sat Oct 8 14:31:54 2011 (r9990)
@@ -26,7 +26,7 @@
<sword:collectionPolicy>No guarantee of service, or that deposits will
be retained for any length of time.</sword:collectionPolicy>
<!-- SHOULD be included. Used to indicate if mediated deposit is
allowed on the defined collection. -->
- <sword:mediation>true</sword:mediation>
+ <sword:mediation><?php echo $mediation ?></sword:mediation>
<!-- MAY be included. Used for a human-readable statement about what
treatment the deposited resource will receive. -->
<sword:treatment>This is a server</sword:treatment>
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.