コード例 #1
0
function add_Datastream($pid, $datastream, $dsLabel, $mimetype, $xml_url)
{
    module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
    module_load_include('php', 'Fedora_Repository', 'ConnectionHelper');
    global $user;
    if (!fedora_repository_access(OBJECTHELPER::$ADD_FEDORA_STREAMS, $pid, $user)) {
        drupal_set_message('You do not have permission to add datastreams to this object!');
        return false;
    }
    global $base_url;
    module_load_include('php', 'Fedora_Repository', 'ConnectionHelper');
    $controlGroup = "M";
    $params = array('pid' => $pid, 'dsID' => $datastream, 'altIDs' => "", 'dsLabel' => $dsLabel, 'versionable' => "true", 'MIMEType' => $mimetype, 'formatURI' => "URL", 'dsLocation' => $xml_url, 'controlGroup' => "{$controlGroup}", 'dsState' => "A", 'checksumType' => "DISABLED", 'checksum' => "none", 'logMessage' => "datastream added");
    try {
        $soapHelper = new ConnectionHelper();
        $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
        if ($client == null) {
            drupal_set_message(t('Error Getting Soap Client.'), 'error');
            return false;
        }
        $object = $client->__soapCall('addDatastream', array('parameters' => $params));
        return true;
    } catch (exception $e) {
        try {
            $params['force'] = 'true';
            $object = $client->__soapCall('ModifyDatastreamByReference', array($params));
            return true;
        } catch (exception $e1) {
            drupal_set_message(t($e1->getMessage()), 'error');
            return false;
        }
    }
}
コード例 #2
0
ファイル: CollectionClass.php プロジェクト: ratzeni/islandora
 /**
  * Gets objects related to this item.  It will query the object for a Query stream and use that as a itql query
  * or if there is no query stream it will use the default.  If you pass a query to this method it will use the passed in query no matter what
  */
 function getRelatedItems($pid, $itqlquery = NULL, $limit = NULL, $offset = NULL)
 {
     module_load_include('php', 'fedora_repository', 'ObjectHelper');
     module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
     if (!isset($limit)) {
         $limit = 1000;
     }
     if (!isset($offset)) {
         $offset = 0;
     }
     global $user;
     if (!fedora_repository_access(OBJECTHELPER::$VIEW_FEDORA, $pid, $user)) {
         drupal_set_message(t("You do not have access to Fedora Objects within the attempted namespace or access to Fedora denied!"), 'error');
         return ' ';
     }
     $objectHelper = new ObjectHelper();
     $query_string = $itqlquery;
     if (!isset($query_string)) {
         $query_string = $objectHelper->getStream($pid, 'QUERY', 0);
         if ($query_string == null) {
             $query_string = 'select $object $title $content from <#ri>
                          where ($object <dc:title> $title
                          and $object <fedora-model:hasModel> $content
                          and ($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/' . $pid . '>
                          or $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>)
                          and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>)
                          minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
                          order by $title';
         }
     }
     $query_string = htmlentities(urlencode($query_string));
     $content = '';
     $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
     $url .= "?type=tuples&flush=true&format=Sparql&limit={$limit}&offset={$offset}&lang=itql&stream=on&query=" . $query_string;
     $content .= do_curl($url);
     return $content;
 }
コード例 #3
0
/**
 * Returns an array of pids that match the query contained in teh collection
 * object's QUERY datastream or in the suppled $query parameter.
 * @param <type> $collection_pid
 * @param <type> $query
 * @param <type> $query_format R
 */
function get_related_items_as_xml($collection_pid, $relationship = array('isMemberOfCollection'), $limit = 10000, $offset = 0, $active_objects_only = TRUE)
{
    module_load_include('php', 'fedora_repository', 'ObjectHelper');
    $collection_item = new Fedora_Item($collection_pid);
    global $user;
    if (!fedora_repository_access(OBJECTHELPER::$VIEW_FEDORA, $pid, $user)) {
        drupal_set_message(t("You do not have access to Fedora Objects within the attempted namespace or access to Fedora denied!"), 'error');
        return array();
    }
    $query_string = 'select $object $title $content from <#ri>
                             where ($object <dc:title> $title
                             and $object <fedora-model:hasModel> $content
                             and (';
    $query_string .= $relationship;
    if (is_array($relationship)) {
        foreach ($relationship as $rel) {
            $query_string .= '$object <fedora-rels-ext:' . $rel . '> <info:fedora/' . $collection_pid . '>';
            if (next($relationship)) {
                $query_string .= ' OR ';
            }
        }
    } elseif (is_string($relationship)) {
        $query_string .= '$object <fedora-rels-ext:' . $relationship . '> <info:fedora/' . $collection_pid . '>';
    } else {
        return '';
    }
    $query_string .= ') ' . ($active_objects_only ? 'and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>' : '') . ')
                             minus $content <mulgara:is> <info:fedora/fedora-system:FedoraObject-3.0>
                             order by $title';
    $query_string = htmlentities(urlencode($query_string));
    $content = '';
    $url = variable_get('fedora_repository_url', 'http://localhost:8080/fedora/risearch');
    $url .= "?type=tuples&flush=true&format=Sparql&limit={$limit}&offset={$offset}&lang=itql&stream=on&query=" . $query_string;
    $content .= do_curl($url);
    return $content;
}
コード例 #4
0
ファイル: ObjectHelper.php プロジェクト: ratzeni/islandora
 function addStream($pid, $dsid, $fileObject, $xacmlOnly = false)
 {
     global $user;
     if (!fedora_repository_access(OBJECTHELPER::$ADD_FEDORA_STREAMS, $pid, $user) && !$xacmlOnly) {
         drupal_set_message('You do not have permission to add datastreams to this object!');
         return false;
     }
     global $base_url;
     module_load_include('php', 'Fedora_Repository', 'mimetype');
     module_load_include('php', 'Fedora_Repository', 'ConnectionHelper');
     $dsLabel = $fileObject->filename;
     $pathToModule = drupal_get_path('module', 'Fedora_Repository');
     $file = $fileObject->filepath;
     //$streamUrl = 'http://' . $_SERVER['HTTP_HOST'] .$base_url. $file;
     $streamUrl = str_replace("https", "http", $base_url) . '/' . drupal_urlencode($file);
     $mimetype = $fileObject->filemime;
     $controlGroup = "M";
     if ($mimetype == 'text/xml') {
         $controlGroup = 'X';
     }
     $params = array('pid' => $pid, 'dsID' => $dsid, 'altIDs' => "", 'dsLabel' => $dsLabel, 'versionable' => "true", 'MIMEType' => $mimetype, 'formatURI' => "URL", 'dsLocation' => $streamUrl, 'controlGroup' => "{$controlGroup}", 'dsState' => "A", 'checksumType' => "DISABLED", 'checksum' => "none", 'logMessage' => "datastream added");
     try {
         $soapHelper = new ConnectionHelper();
         $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
         if ($client == null) {
             drupal_set_message(t('Error Getting Soap Client.'), 'error');
             return false;
         }
         $object = $client->__soapCall('addDatastream', array('parameters' => $params));
     } catch (exception $e) {
         drupal_set_message(t($e->getMessage()), 'error');
         return false;
     }
     unlink($fileObject->filepath);
     return true;
 }