Author: sevein
Date: Thu Oct 13 17:33:50 2011
New Revision: 10090
Log:
Uploading digital objects and other fixes in SWORD
Modified:
trunk/plugins/qtSwordPlugin/lib/qtPackageExtractor.class.php
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/depositAction.class.php
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/depositSuccess.xml.php
Modified: trunk/plugins/qtSwordPlugin/lib/qtPackageExtractor.class.php
==============================================================================
--- trunk/plugins/qtSwordPlugin/lib/qtPackageExtractor.class.php Thu Oct
13 17:12:50 2011 (r10089)
+++ trunk/plugins/qtSwordPlugin/lib/qtPackageExtractor.class.php Thu Oct
13 17:33:50 2011 (r10090)
@@ -24,7 +24,8 @@
$filename = null,
$document = null,
$format = null,
- $type = null;
+ $type = null,
+ $resource = null;
public
$informationObject;
@@ -42,6 +43,11 @@
{
$this->type = $options['type'];
}
+
+ if (isset($options['resource']))
+ {
+ $this->resource = $options['resource'];
+ }
}
protected function processDmdSec($xml, $informationObject = null)
@@ -144,6 +150,10 @@
public function process()
{
$this->informationObject = new QubitInformationObject;
+ $this->informationObject->parentId = $this->resource->id;
+
+ $publicationStatus = sfConfig::get('app_defaultPubStatus',
QubitTerm::PUBLICATION_STATUS_DRAFT_ID);
+ $this->informationObject->setPublicationStatus($publicationStatus);
// Main object
$main = $this->getMainDmdSec();
@@ -155,11 +165,21 @@
$filename = $parts['filename'];
$uuid = $this->getUUID($filename);
- $fptr = $this->searchFptr($uuid);
- if (isset($fptr['DMID']))
+ $child = new QubitInformationObject;
+ $child->setPublicationStatus($publicationStatus);
+
+ if (null !== $fptr = $this->searchFptr($uuid) && isset($fptr['DMID']))
{
// processDmdSec()
}
+
+ $digitalObject = new QubitDigitalObject;
+ $digitalObject->assets[] = new QubitAsset($filename,
file_get_contents($item));
+ $digitalObject->usageId = QubitTerm::MASTER_ID;
+
+ $child->digitalObjects[] = $digitalObject;
+
+ $this->informationObject->informationObjectsRelatedByparentId[] = $child;
}
$this->informationObject->save();
Modified:
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/depositAction.class.php
==============================================================================
---
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/depositAction.class.php
Thu Oct 13 17:12:50 2011 (r10089)
+++
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/actions/depositAction.class.php
Thu Oct 13 17:33:50 2011 (r10090)
@@ -19,19 +19,20 @@
// TODO
// Check user authorization
-// Check upload limit
+// Check upload/repository limit
// Check attatchment size, zero?
// Package
// Response
-// Complete XML error documents (see templates/error/*)
+// Complete XML error documents and use them correctly for each http status
code
class qtSwordPluginDepositAction extends sfAction
{
public function execute($request)
{
- // TODO: Make possible to return 404 together with a XML document
- // QubitResourceroute throws 404 exception before this is executed
- $this->resource = $this->getRoute()->resource;
+ if (null === $this->resource = $this->getRoute()->resource)
+ {
+ return $this->generateResponse(404, 'error/ErrorContent');
+ }
$this->user = $request->getAttribute('user');
@@ -94,6 +95,7 @@
// Open the file, parse xml, get objects
$extractor = new qtPackageExtractor($filename, array(
'format' => $this->packageFormat,
+ 'resource' => $this->resource,
'type' => $this->packageContentType));
// Open package and XML document
Modified:
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/depositSuccess.xml.php
==============================================================================
---
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/depositSuccess.xml.php
Thu Oct 13 17:12:50 2011 (r10089)
+++
trunk/plugins/qtSwordPlugin/modules/qtSwordPlugin/templates/depositSuccess.xml.php
Thu Oct 13 17:33:50 2011 (r10090)
@@ -33,7 +33,7 @@
<generator uri="<?php echo url_for('@homepage', true) ?>" version="<?php
echo qubitConfiguration::VERSION ?>">Qubit <?php echo
qubitConfiguration::VERSION ?></generator>
- <link rel="edit" href="<?php echo url_for(array($informationObject, 'module'
=> 'informationobject')) ?>" />
+ <link rel="edit" href="<?php echo url_for(array($informationObject, 'module'
=> 'informationobject'), true) ?>" />
<sword:noOp>false</sword:noOp>
--
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.