You are here

function cmis_get_repository in CMIS API 6.3

Same name and namespace in other branches
  1. 6.4 cmis.module \cmis_get_repository()
  2. 7.2 cmis.module \cmis_get_repository()
  3. 7 cmis.module \cmis_get_repository()

Returns a CMIS repository properties, based on local configuration.

Config sample: $conf['cmis_repositories'] = array( 'default' => array ( 'label' => 'Local', 'url' => 'http://127.0.0.1:8080/alfresco/s/cmis', 'transport' => 'cmis_headerswing', 'headerswing_headers' => array ( // headers copied from $_SERVER[] to CMIS repository curl call 'HTTP_HOST' => 'FRONTENT_HOST', 'HTTP_HOST' => 'FRONTENT_HOST_AGAIN', 'HTTP_USER' => 'FRONTENT_USER', 'PHP_AUTH_USER' => 'FRONTENT_USER' 'PHP_AUTH_DIGEST' => 'FRONTEND_AUTH' ) ),

'demo cmis alfresco' => array( 'label' => 'cmis.alfresco.com', 'user' => 'admin', 'password' => 'admin', 'url' => 'http://cmis.alfresco.com/s/cmis' ),

'demo cmis nuxeo' => array( 'label' => 'cmis.demo.nuxeo.org', 'user' => 'Administrator', 'password' => 'Administrator', 'url' => 'http://cmis.demo.nuxeo.org/nuxeo/site/cmis', 'repository_id' => '8006e8e1-2298-4764-998c-5800383ac88a' ) );

Usage: // get default CMIS repository info $cmis_repo = cmis_get_repository();

// get CMIS repository info based on config alias $cmis_repo = cmis_get_repository('demo cmis alfresco');

// get CMIS repository info based on repository id. // INTERNAL USE ONLY! $cmis_repo = cmis_get_repository('8006e8e1-22...');

// CMIS getRepositoryInfo result print_r($cmis_repo->info)

// repository id print $cmis_repo->repositoryId

// config settings print_r($cmis_repo->settings)

Parameters

$id_or_alias :

Return value

stdClass

13 calls to cmis_get_repository()
cmis_browser_autocomplete in cmis_browser/cmis_browser.content_autocomplete.inc
Cmis folder picker autocomplete callback.
cmis_browser_content_delete_confirm in cmis_browser/cmis_browser.content_delete.inc
Menu callback -- ask for confirmation of CMIS object deletion
cmis_browser_content_delete_confirm_submit in cmis_browser/cmis_browser.content_delete.inc
Execute CMIS object deletion.
cmis_browser_content_get in cmis_browser/cmis_browser.content_get.inc
Build cmis_browser browse page.
cmis_browser_content_properties in cmis_browser/cmis_browser.content_properties.inc
CMIS object properties page.

... See full list

File

./cmis.module, line 61

Code

function cmis_get_repository($id_or_alias = NULL) {
  static $repositories_cache;
  $cmis_repository = NULL;
  if (empty($id_or_alias)) {
    global $user;
    $id_or_alias = isset($user->cmis_repository) ? $user->cmis_repository : 'default';
  }

  // init repository cache
  if (is_null($repositories_cache)) {
    $repositories_cache = array();
  }

  // lookup repository in cache
  if (array_key_exists($id_or_alias, $repositories_cache)) {
    $cmis_repository = $repositories_cache[$id_or_alias];
  }
  else {
    $config_cmis_repos = variable_get('cmis_repositories', array());
    if (array_key_exists($id_or_alias, $config_cmis_repos)) {

      // setup temp repository details
      $cmis_repository = new stdClass();
      $repositories_cache[$id_or_alias] = $cmis_repository;

      // setup settings
      $cmis_repository->settings = $config_cmis_repos[$id_or_alias];

      // merge in defaults.
      $cmis_repository->settings += array(
        'transport' => 'cmis_common',
      );

      // init cmis repository
      $cmis_repository->info = cmisapi_getRepositoryInfo($id_or_alias);
      $cmis_repository->repositoryId = $cmis_repository->info->repositoryInfo['cmis:repositoryId'];

      // save repo description in cache
      $repositories_cache[$cmis_repository->repositoryId] =& $repositories_cache[$id_or_alias];
    }
    else {
      throw new CMISException(t('Unable to lookup CMIS repository [@cmis_id_or_alias]', array(
        '@cmis_id_or_alias' => $id_or_alias,
      )));
    }
  }
  return $cmis_repository;
}