function oneTask($task) { if ($task['type'] == 0) { $this_path = ProdsDir::fromURI($task['src'], false); $new_path = ProdsDir::fromURI($task['dest'], false); } else { $this_path = ProdsFile::fromURI($task['src'], false); $new_path = ProdsFile::fromURI($task['dest'], false); } if (empty($parent->account->pass)) { $acct = $_SESSION['acct_manager']->findAcct($this_path->account); if (empty($acct)) { $response = array('success' => false, 'errmsg' => 'Authentication Required'); echo json_encode($response); exit(0); } $this_path->account = $acct; } if (empty($this_path->account->zone)) { $this_path->account->getUserInfo(); } $this_path->rename($new_path->path_str); }
/** * opendir() handler. * * @access private */ public function dir_opendir($path, $options) { try { $this->dir = ProdsDir::fromURI($path, true); $this->metadata = $this->dir->getMeta(); return true; } catch (Exception $e) { trigger_error("Got an exception:{$e}", E_USER_WARNING); return false; } }
public function __construct(RODSAccount $account, $path_str, $verify = false, RODSDirStats $stats = NULL) { parent::__construct($account, $path_str, $verify, $stats); }
$account = $acct; $mservices = array(); $input_params = array("*desc_resc" => $resc); $num_files = 0; foreach ($files as $fileuri) { if (strlen($fileuri) > 0) { $myfile = ProdsFile::fromURI($fileuri); $mservices[] = "msiDataObjRepl(*desc_file{$num_files},*desc_resc,*outbuf)"; $input_params["*desc_file{$num_files}"] = $myfile->getPath(); $num_files++; } } $num_dirs = 0; foreach ($dirs as $diruri) { if (strlen($diruri) > 0) { $mydir = ProdsDir::fromURI($diruri); $mservices[] = "msiReplColl(*desc_dir{$num_dirs},*desc_resc,backupMode,*outbuf)"; $input_params["*desc_dir{$num_dirs}"] = $mydir->getPath(); $num_dirs++; } } $rule_body = 'myTestRule||' . 'delayExec(<PLUSET>0m</PLUSET>,' . implode("##", $mservices) . ',nop)|nop'; /* --debug code here in case when delayed exec not working */ //$rule_body='myTestRule||'.implode("##", $mservices).'|nop'; $rule = new ProdsRule($account, $rule_body, $input_params); $results = $rule->execute(); $response = array('success' => true, 'log' => "{$num_files} files and {$num_dirs} scheduled for replication!"); echo json_encode($response); } catch (Exception $e) { $response = array('success' => false, 'errmsg' => $e->getMessage(), 'errcode' => $e->getCode()); echo json_encode($response);
<?php require_once "../config.inc.php"; require_once PRODS_INC_PATH; session_start(); if (!isset($_SESSION['acct_manager'])) { $_SESSION['acct_manager'] = new RODSAcctManager(); } $ruri = isset($_REQUEST['node']) ? $_REQUEST['node'] : '/'; $ruri = "rods:/" . $ruri; $collection = ProdsDir::fromURI($ruri, false); if (empty($collection->account->pass)) { $acct = $_SESSION['acct_manager']->findAcct($collection->account); if (empty($acct)) { $arr = array(); $arr['success'] = false; $arr['errmsg'] = "You don't have permission for this directory! Please sign-on"; $arr['errcode'] = -99; $str = json_encode($arr); echo "({$str})"; exit(0); } $collection->account = $acct; } $recursive = isset($_REQUEST['recursive']) && $_REQUEST['recursive'] == '1' ? true : false; try { listChildDirJson($collection); } catch (RODSException $e) { $arr = array(); $arr['success'] = false; $arr['errmsg'] = $e->getMessage();
echo "--- trying to connect --- " . microtime() . " <br/>\n"; $conn = RODSConnManager::getConn($account); $que_result = $conn->dirExists($home_dir_str); if ($que_result === true) { echo "{$home_dir_str} exists! <br/>\n"; } else { echo "{$home_dir_str} doesn't exists! <br/>\n"; } $que_result = $conn->dirExists($home_dir_str . "/blah"); if ($que_result === true) { echo "{$home_dir_str}/blah exists! <br/>\n"; } else { echo "{$home_dir_str}/blah doesn't exists! <br/>\n"; } RODSConnManager::releaseConn($conn); $dir = new ProdsDir($account, "/tempZone/home/rods"); $childdirs = $dir->getChildDirs(); echo "Child dirs: <br/>\n"; foreach ($childdirs as $childdir) { echo $childdir . "<br/>\n"; } $childfiles = $dir->getChildFiles(); echo "Child files: <br/>\n"; foreach ($childfiles as $childfile) { echo $childfile . " <br/>\n"; /* $childfile->open("r"); echo "desc=".$childfile->getL1desc()."<br/>\n"; echo "<pre>".$childfile->read($childfile->stats->size)."</pre><br/>\n"; $cur_offset=$childfile->seek(3); echo "offsetted '$cur_offset' bytes <br/> \n";
/** * Get user's home directory * @param string init_path, if specified, it will overwrite the default path * @return ProdsDir User's home directory */ public function getUserHomeDir($init_path = NULL) { if (empty($this->zone)) { $this->getUserInfo(); } if (isset($init_path)) { $dir = new ProdsDir($this, $init_path); if ($dir->exists()) { return $dir; } } return new ProdsDir($this, "/{$this->zone}/home/{$this->user}"); }
$mod_batch = json_decode(urldecode($_REQUEST['batch']), true); if (!is_array($mod_batch)) { $response = array('success' => false, 'errmsg' => "Mal-formated Mod batch"); echo json_encode($response); exit(0); } } } if ($action == NULL) { $response = array('success' => false, 'errmsg' => 'Expected type not specified'); echo json_encode($response); exit(0); } try { if ($type == 0) { $this_path = ProdsDir::fromURI($ruri, false); } else { $this_path = ProdsFile::fromURI($ruri, false); } if (empty($parent->account->pass)) { $acct = $_SESSION['acct_manager']->findAcct($this_path->account); if (empty($acct)) { $response = array('success' => false, 'errmsg' => 'Authentication Required'); echo json_encode($response); exit(0); } $this_path->account = $acct; } if (empty($this_path->account->zone)) { $this_path->account->getUserInfo(); }
} else { $response = array('success' => false, 'log' => 'Expected RODS URI not found'); echo json_encode($response); exit(0); } $name = ''; if (isset($_REQUEST['name'])) { $name = $_REQUEST['name']; } if (empty($name)) { $response = array('success' => false, 'log' => 'New collection name not specified'); echo json_encode($response); exit(0); } try { $parent = ProdsDir::fromURI($ruri, false); if (empty($parent->account->pass)) { $acct = $_SESSION['acct_manager']->findAcct($parent->account); if (empty($acct)) { $response = array('success' => false, 'log' => 'Authentication Required'); echo json_encode($response); exit(0); } $parent->account = $acct; } if (empty($parent->account->zone)) { $parent->account->getUserInfo(); } $parent->mkdir($name); $response = array('success' => true, 'log' => 'new collection created!'); echo json_encode($response);
<?php require_once "../src/Prods.inc.php"; $account = new RODSAccount("localhost", 1247, "rods", "rods", "tempZone"); $target_dir = '/tempZone/home/rods'; try { $start_time = microtime(true); $dir = new ProdsDir($account, $target_dir); $terms = array('descendantOnly' => true, 'recursive' => true); $total_count = 0; $results = $dir->findFiles($terms, $total_count); foreach ($results as $file) { echo $file->path_str . "\n"; } echo "Total: {$total_count} files"; $end_time = microtime(true); $exec_time = $end_time - $start_time; echo "--- test successful! in ({$exec_time} sec) --- <br/>\n"; } catch (RODSException $e) { echo "--- test failed! --- <br/>\n"; echo $e; echo $e->showStackTrace(); }
$response = array('success' => false, 'errmsg' => 'Authentication Required'); echo json_encode($response); exit(0); } $parent->account = $acct; } if (empty($parent->account->zone)) { $parent->account->getUserInfo(); } $num_files = 0; foreach ($files as $filename) { if (strlen($filename) > 0) { $myfile = new ProdsFile($parent->account, $parent->path_str . '/' . $filename); $myfile->unlink(NULL, $force_delete); $num_files++; } } $num_dirs = 0; foreach ($dirs as $dirname) { if (strlen($dirname) > 0) { $mydir = new ProdsDir($parent->account, $parent->path_str . '/' . $dirname); $mydir->rmdir(true, $force_delete); $num_dirs++; } } $response = array('success' => true, 'log' => "{$num_files} files and {$num_dirs} collections deleted!"); echo json_encode($response); } catch (Exception $e) { $response = array('success' => false, 'errmsg' => $e->getMessage(), 'errcode' => $e->getCode()); echo json_encode($response); }
<?php require_once "/Path/to/Prods/src/Prods.inc.php"; // make an iRODS account object for connection, assuming: // username: demouser, password: demopass, server: srbbrick15.sdsc.edu, port: 1247 $account = new RODSAccount("srbbrick15.sdsc.edu", 1247, "demouser", "demopass"); //create an dir object, assuming the path is "/tempZone/home/demouser" $home = new ProdsDir($account, "/tempZone/home/demouser"); //make a new child directory called "mydir" under home $mydir = $home->mkdir("mydir"); //list home directory $children = $home->getAllChildren(); //print each child's name echo "children are: \n"; foreach ($children as $child) { echo $child->getName() . "\n"; }
<?php require_once "/Path/to/Prods/src/Prods.inc.php"; // make an iRODS account object for connection, assuming: // username: demouser, password: demopass, server: srbbrick15.sdsc.edu, port: 1247 $account = new RODSAccount("srbbrick15.sdsc.edu", 1247, "demouser", "demopass"); //create an dir object, assuming the path is "/tempZone/home/demouser" $home = new ProdsDir($account, "/tempZone/home/demouser"); //search under home directory, recursively, by specified metadata: // any file with metadata "myname" has a value of "myvalue" $meta = new RODSMeta("myname", "myvalue", null, null, "="); $files = $mydir = $home->findFiles(array('descendantOnly' => true, 'recursive' => true, 'metadata' => array($meta))); // print the found files foreach ($files as $file) { echo "Found file: " . $file->getPath() . "\n"; }