Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fedora4 #5

Open
wants to merge 18 commits into
base: fedora4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
view object in fedora.
  • Loading branch information
Yuqing Jiang authored and Yuqing Jiang committed Sep 12, 2013
commit 741f0c1b3b3cda1e9a04ba252b62c8e83c2ba9b6
2 changes: 0 additions & 2 deletions implementations/fedora4/Datastream.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,10 @@ public function __construct($id, $control_group, AbstractFedoraObject $object, F
parent::__construct($id, $object, $repository);
$this->ingested = FALSE;
$group = $this->validateControlGroup($control_group);

if ($group === FALSE) {
trigger_error("Invalid control group \"$control_group\", using managed instead.", E_USER_WARNING);
$group = 'M';
}

// Set defaults!
$this->datastreamInfo['dsControlGroup'] = $group;
$this->datastreamInfo['dsState'] = 'A';
Expand Down
25 changes: 18 additions & 7 deletions implementations/fedora4/FedoraApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public function getObjectHistory($pid) {
* latest.
*/
public function getObjectProfile($pid, $as_of_date_time = NULL, $params = array()) {
;
$request = "/{$pid}";

if (isset($params['txID'])) {
Expand Down Expand Up @@ -227,6 +226,9 @@ public function listDatastreams($pid, $as_of_date_time = NULL, $params = array()
$out[$dsid] = array(
'label' => $datastream['dsLabel'],
'mimetype' => $datastream['dsMIME'],
'controlGroup'=>$datastream['dsControlGroup'],
'size'=>$datastream['dsSize'],
'created'=>$datastream['dsCreateDate'],
);
}
} else {
Expand All @@ -240,6 +242,9 @@ public function listDatastreams($pid, $as_of_date_time = NULL, $params = array()
$out[$dsid] = array(
'label' => $datastream['dsLabel'],
'mimetype' => $datastream['dsMIME'],
'controlGroup'=>$datastream['dsControlGroup'],
'size'=>$datastream['dsSize'],
'created'=>$datastream['dsCreateDate'],
);
}
}
Expand Down Expand Up @@ -418,7 +423,6 @@ public function export($pid, $params = array()) {
* See add Datastream for what is stubbed etc.
*/
public function getDatastream($pid, $dsid, $params = array()) {

$request = "/{$pid}/$dsid";
if (isset($params['txID'])) {
$request = "/tx:" . $params['txID'] . $request;
Expand All @@ -429,14 +433,12 @@ public function getDatastream($pid, $dsid, $params = array()) {
$responseArray = json_decode($response['content'], TRUE);
$id = $this->connection->buildUrl($request);
$id = str_replace('%3A', ':', $id);
$ds = $this->serializer->getNode($id, $responseArray);

$ds = $this->serializer->getNode($id, $responseArray);
$return_array = array(
// Datastream Labels are not implemented yet.
'dsLabel' => 'Default Label',
// Versioning doesn't work currently.
'dsVersionID' => "$dsid.0",
//'dsCreateDate' => $ds['http://fedora.info/definitions/v4/repository#created'],
// Datastream state not implemented yet.
'dsState' => 'A',
// Format URI is no longer supported.
Expand All @@ -458,14 +460,23 @@ public function getDatastream($pid, $dsid, $params = array()) {
// No message system for versions at the moment.
'dsLogMessage' => '',
);
$request =$request."/fcr:content";
$id = $this->connection->buildUrl($request);
$id = str_replace('%3A', ':', $id);
$ds_content = $this->serializer->getNode($id, $responseArray);
if (isset($ds['http://fedora.info/definitions/v4/repository#created'])) {
$return_array['dsCreateDate'] = $ds['http://fedora.info/definitions/v4/repository#created'];
}
if (isset($ds['http://fedora.info/definitions/v4/rest-api#mimeType'])) {
$return_array['dsMIME'] = $ds['http://fedora.info/definitions/v4/rest-api#mimeType'];
if (isset($ds_content['http://fedora.info/definitions/v4/repository#mimeType'])) {
$return_array['dsMIME'] = $ds_content['http://fedora.info/definitions/v4/repository#mimeType'];
} else {
$return_array['dsMIME'] = 'application/rdf+xml';
}
if (isset($ds_content['http://fedora.info/definitions/v4/rest-api#size'])) {
$return_array['dsSize'] = $ds_content['http://fedora.info/definitions/v4/rest-api#size'];
} else {
$return_array['dsSize'] = '0';
}
return $return_array;
}

Expand Down
4 changes: 2 additions & 2 deletions implementations/fedora4/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set_include_path("sites/all/libraries/tuque/");
require_once 'AbstractObject.php';
require_once 'implementations/fedora3/FedoraDate.php';
require_once 'implementations/fedora3/Datastream.php';
require_once 'implementations/fedora4/Datastream.php';
require_once 'implementations/fedora3/FedoraRelationships.php';

/**
Expand Down Expand Up @@ -525,7 +525,7 @@ protected function populateDatastreams() {
$datastreams = $this->repository->api->a->listDatastreams($this->id);
$this->datastreams = array();
foreach ($datastreams as $key => $value) {
$this->datastreams[$key] = new $this->fedoraDatastreamClass($key, $this, $this->repository, array("dsLabel" => $value['label'], "dsMIME" => $value['mimetype']));
$this->datastreams[$key] = new $this->fedoraDatastreamClass($key, $this, $this->repository, array("dsLabel" => $value['label'], "dsMIME" => $value['mimetype'],"dsSize"=>$value['size'],"dsSize"=>$value['size'],"dsControlGroup"=>$value['controlGroup'],'dsCreateDate'=>$value['created']));
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions implementations/fedora4/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,6 @@ public function ingestObject(AbstractObject &$object) {
* the exception
*/
public function getObject($id) {

//$fobject =$this->constructObject($id);
$fobject =new FedoraObject($id,$this);
$this->cache->set($id,$fobject);
$object = $this->cache->get($id);
if ($object !== FALSE) {
return $object;
Expand Down
2 changes: 1 addition & 1 deletion tests/implementations/fedora4/FedoraApi/FedoraApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function setUp() {
'2010-03-13T14:12:59.272Z' => array(
'DC' => Array(
'label' => 'Default Label',
'mimetype' => 'application/rdf+xml',
'mimetype' => 'text/html',
),
),
);
Expand Down