You are here

function _cmis_sync_cmis_drupal_file_id in CMIS API 6.3

Same name and namespace in other branches
  1. 6.4 cmis_sync/cmis_sync.cmis.inc \_cmis_sync_cmis_drupal_file_id()

+ * Create a file path/name that matches the CMIS path/name to avoid an ugly generated name. + * + *

Parameters

$cmis_repository: + * @param $cmis_object + * @return file id +

1 call to _cmis_sync_cmis_drupal_file_id()
_cmis_sync_cmis_drupal_prepare in cmis_sync/cmis_sync.cmis.inc
Maps a cmis_object to a drupal node.

File

cmis_sync/cmis_sync.cmis.inc, line 241

Code

function _cmis_sync_cmis_drupal_file_id($repository, $cmis_object) {
  $cmis_folder = cmisapi_getFolderParent($repository->repositoryId, $cmis_object->id)->objectList;
  $cmis_sub_dir = $cmis_folder[0]->properties['cmis:path'];
  $files_path = file_directory_path() . $cmis_sub_dir;

  // Recursively create directory structure
  $full_path = '';
  foreach (explode('/', $files_path) as $path) {
    $full_path .= $path;
    file_check_directory($full_path, FILE_CREATE_DIRECTORY);
    $full_path .= '/';
  }
  if (file_check_directory($files_path)) {
    return $cmis_sub_dir . '/' . $cmis_object->properties['cmis:contentStreamFileName'];
  }
  else {
    throw new CMISException(t("Unable to find or create writable path %path.", array(
      '%path' => $files_path,
    )));
  }
}