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); }
/** * fopen() handler. * * @access private */ public function stream_open($path, $mode, $options, &$opened_path) { // get rid of tailing 'b', if any. if ($mode[strlen($mode) - 1] == 'b' && strlen($mode) > 1) { $mode = substr($mode, 0, strlen($mode) - 1); } try { if ($mode === 'm' || $mode === 'm-') { $url = parse_url($path); $args = array(); parse_str($url['query'], $args); unset($url['query']); $path = strstr($path, '?', true); $this->file = ProdsFile::fromURI($path); $old = NULL; if (!empty($args['id'])) { $oldMeta = $this->file->getMeta(); foreach ($oldMeta as $meta) { if ($meta->id === $args['id']) { $old = $meta; break; } } } if ($mode === 'm-') { if (!empty($old)) { $this->file->rmMeta($old); } else { // meta doesn't exist - already deleted? } return true; } if (!empty($old)) { $new = new RODSMeta($old->name, $old->value, $old->units, $old->id); if ($args['name'] === 'name') { $new->name = $args['value']; } else { if ($args['name'] === 'value') { $new->value = $args['value']; } else { if ($args['name'] === 'units') { $new->units = $args['value']; } } } $this->file->updateMeta($old, $new); } else { $new = new RODSMeta("name", "value", "units"); if ($args['name'] === 'name') { $new->name = $args['value']; } else { if ($args['name'] === 'value') { $new->value = $args['value']; } else { if ($args['name'] == 'units') { $new->units = $args['units']; } } } $this->file->addMeta($new); } $this->metadata = $this->file->getMeta(); return true; } $this->file = ProdsFile::fromURI($path); $this->file->open($mode); $this->metadata = $this->file->getMeta(); return true; } catch (Exception $e) { trigger_error("Got an exception:{$e} while trying to stream_open {$path} with mode {$mode}", E_USER_WARNING); return false; } }
/** * fopen() handler. * * @access private */ public function stream_open($path, $mode, $options, &$opened_path) { // get rid of tailing 'b', if any. if ($mode[strlen($mode) - 1] == 'b' && strlen($mode) > 1) { $mode = substr($mode, 0, strlen($mode) - 1); } try { $this->file = ProdsFile::fromURI($path); $this->file->open($mode); return true; } catch (Exception $e) { trigger_error("Got an exception:{$e}", E_USER_WARNING); return false; } }
if (empty($acct)) { if (empty($account->pass)) { $response = array('success' => false, 'errmsg' => 'Authentication Required'); echo json_encode($response); exit(0); } else { $_SESSION['acct_manager']->add($account); } } $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';
$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(); } switch ($action) { case "get":
$resource = $_REQUEST['resource']; } else { $response = array('success' => false, 'errmsg' => 'Expected resource not found'); echo json_encode($response); exit(0); } $action = ""; if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } else { $response = array('success' => false, 'errmsg' => 'Expected action not found'); echo json_encode($response); exit(0); } try { $file = ProdsFile::fromURI($ruri, false); if (empty($file->account->pass)) { $acct = $_SESSION['acct_manager']->findAcct($file->account); if (empty($acct)) { $response = array('success' => false, 'errmsg' => 'Authentication Required'); echo json_encode($response); exit(0); } $file->account = $acct; } switch ($action) { case 'add': $file->repl($resource, array('backupMode' => true)); $response = array('success' => true, 'log' => "file replicated to resource {$resource}"); break; case 'remove':
$ruri = $_REQUEST['ruri']; } else { $response = array('success' => false, 'errmsg' => 'Required RODS URI not found'); echo json_encode($response); exit(0); } $action = ""; if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } else { $response = array('success' => false, 'errmsg' => 'Action type not specified'); echo json_encode($response); exit(0); } try { $file = ProdsFile::fromURI($ruri); if (empty($file->account->pass)) { $acct = $_SESSION['acct_manager']->findAcct($file->account); if (empty($acct)) { $response = array('success' => false, 'errmsg' => 'Authentication Required'); echo json_encode($response); exit(0); } $file->account = $acct; } switch ($action) { case 'replica': $repl_info = $file->getReplInfo(); $response = array('success' => true, 'totalCount' => count($repl_info), 'que_results' => $repl_info); $str = json_encode($response); echo "({$str})";