public function init() { $response = Sahara_Soap::getSchedServerSessionClient()->getSessionInformation(array('userQName' => Zend_Auth::getInstance()->getIdentity())); $home = new Sahara_Home(Sahara_Home::getHomeDirectoryLocation(), time() - $response->time); $home->loadContents(); $this->_view->files = $home->getFlattenedContents(); $this->view->refreshTime = $this->_config->home->sessionrefresh; if (!$this->view->refreshTime) { $this->view->refreshTime = self::DEFAULT_REFRESH_SEC; } }
/** * Terminates a running batch invocation. */ public function abortAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout()->disableLayout(); $response = Sahara_Soap::getSchedServerSessionClient()->getSessionInformation(array('userQName' => $this->_auth->getIdentity())); if (!$response->isInSession) { /* Not in session, so unable to determine the rig clients address. */ $error = array('success' => 'false', 'error' => array('code' => -1, 'operation' => 'Batch abort request', 'reason' => 'not in session')); echo $this->view->json($error); return; } try { list($ns, $name) = explode(':', $this->_auth->getIdentity()); $rigClient = new Sahara_Soap($response->contactURL . '?wsdl'); echo $this->view->json($rigClient->abortBatchControl(array('requestor' => $name))); } catch (Exception $ex) { $this->_logger->error("Soap error calling batch 'abortBatchControl'. Message: " . $ex->getMessage() . ', code: ' . $ex->getCode() . '.'); echo $this->view->json(array('success' => false, 'error' => array('code' => -4, 'operation' => 'Batch abort request', 'reason' => 'Exception aborting batch, message: ' . $ex->getMessage()))); } }
/** * Action to bridge a primitive call to the in session rigclient. If a * response parameter name is specified, its value is as a file to download. * If no response parameter is specifed, all the response paramters are * returned as a file in the format: * name=value,name=value,... * <br /> * The mandatory parameters are: * <ul> * <li>pc | primitiveController => The name of the primitive controller.</li> * <lI>pa | primitiveAction => The name of the action to run on the specified * controller.</li> * </ul> * The optional parameters are: * <ul> * <li>rp | responseParam => The name of the response pasrameter.</li> * <li>mime => The mime type of returned file.</li> * <li>fn | filename => The name of file (also forces file downlod)</li> * <li>tf | transform => A transform to apply to the code. The transform * options are: * 1) 'base64' - this base64 decodes the return value and should be used * if the response is binary data.</li> * </ul> * Any other provided parameters are used as primitive request parameters. * <br /> * If the called failed 'FAILED' is returned. */ public function fileAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout()->disableLayout(); $mime = $this->_config->primitive->file->mime; $response = Sahara_Soap::getSchedServerSessionClient()->getSessionInformation(array('userQName' => $this->_auth->getIdentity())); if (!$response->isInSession) { /* Not in session, so unable to determine the rig clients address. */ echo 'FAILED'; return; } /* Set up the correct object model. */ list($junk, $allocUser) = explode(':', $this->_auth->getIdentity(), 2); $request = array('requestor' => $allocUser, 'param' => array()); foreach ($this->_request->getParams() as $key => $val) { switch ($key) { case 'pc': case 'primitiveController': $request['controller'] = $val; break; case 'pa': case 'primitiveAction': $request['action'] = $val; break; case 'rp': case 'responseParam': $responseParam = $val; break; /* MIME type of file. */ /* MIME type of file. */ case 'mime': // Mime type $mime = implode('/', explode('-', $val, 2)); break; /* Filename of file (forces download). */ /* Filename of file (forces download). */ case 'fn': case 'downloadedname': $filename = $val; break; /* Transform for string. */ /* Transform for string. */ case 'tf': case 'transform': $transform = $val; break; /* These are Zend request parameters and irrelevant to the * primitive call. */ /* These are Zend request parameters and irrelevant to the * primitive call. */ case 'controller': case 'action': case 'module': break; /* Parameters to provide to primitive call. */ /* Parameters to provide to primitive call. */ default: $param = array('name' => $key, 'value' => $val); array_push($request['param'], $param); break; } } /* Set header about the response. */ header("Content-Type: {$mime}"); if (isset($filename)) { header("Content-disposition: attachment; filename={$filename}"); } try { $rigClient = new Sahara_Soap($response->contactURL . '?wsdl'); $response = $rigClient->performPrimitiveControl($request); if (!$response->success) { echo "FAILED " . $response->error->reason; return; } $response = $response->result; /* Return the specified response. */ if ($responseParam) { if (isset($response->name) && $response->name == $responseParam) { echo $this->_echoWithTransform($response->value, $transform); return; } else { foreach ($response as $r) { if ($r->name == $responseParam) { echo $this->_echoWithTransform($r->value, $transform); return; } } } echo 'FAILED'; return; } /** Return all the response parameters. */ if (isset($response->name)) { echo $this->_echoWithTransform($response->value, $transform); return; } foreach ($response as $r) { $str .= $r->name . '=' . $r->value . ','; } if (isset($str)) { echo $this->_echoWithTransform(substr($str, 0, strlen($str) - 1), $transform); return; } echo 'FAILED'; } catch (Exception $ex) { echo 'FAILED'; } }
/** * Action to bridge a primitive call to the in session rigclient. The * response is returned as a JSON string (either the response object or * a Zend fault). * <br /> * The mandatory parameters are: * <ul> * <li>primitiveController => The name of the primitive controller.</li> * <lI>primitiveAction => The name of the action to run on the specified controller.</li> * </ul> * Any other provided parameters are used as primitive request parameters. */ public function primitivebridgeAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout()->disableLayout(); $response = Sahara_Soap::getSchedServerSessionClient()->getSessionInformation(array('userQName' => $this->_auth->getIdentity())); if (!$response->isInSession) { /* Not in session, so unable to determine the rig clients address. */ $error = array('success' => 'false', 'error' => array('code' => -1, 'operation' => 'Primitive bridge request', 'reason' => 'not in session')); echo $this->view->json($error); return; } /* Set up the correct object model. */ list($junk, $allocUser) = explode(':', $this->_auth->getIdentity(), 2); $request = array('requestor' => $allocUser, 'param' => array()); foreach ($this->_request->getParams() as $key => $val) { switch ($key) { case 'primitiveController': $request['controller'] = $val; break; case 'primitiveAction': $request['action'] = $val; break; case 'controller': case 'action': case 'module': /* These are Zend request parameters and irrelevant to the * primitive call. */ break; default: $param = array('name' => $key, 'value' => $val); array_push($request['param'], $param); break; } } try { $rigClient = new Sahara_Soap($response->contactURL . '?wsdl'); echo $this->view->json($rigClient->performPrimitiveControl($request)); } catch (Exception $ex) { echo $this->view->json($ex); } }
/** * Action to delete a file. */ public function deletesessionAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout()->disableLayout(); $path = $homePath = Sahara_Home::getHomeDirectoryLocation(); $reqPath = $this->_getParam('path'); if ($reqPath) { $reqPath = implode('/', explode(':', $reqPath)); } $reqFile = $this->_getParam('file'); list($junk, $user) = explode(':', $this->_auth->getIdentity(), 2); if ($reqPath && !($path = realpath($path . '/' . $reqPath))) { $this->_logger->warn("Unable to delete {$reqFile} because path {$path} does not exist in home directory " . "{$homeDir}."); echo "FAILED: Path {$reqPath} does not exist."; return; } if (strpos($path, $user) === false) { $this->_logger->warn("Unable to delete {$reqFile} because path {$path} does not contain user name {$user}."); echo "FAILED: Path does not include name {$user}."; return; } $file = $path . '/' . $reqFile; if (!is_file($file)) { $this->_logger->warn("Unable to delete {$reqFile} because it does not exist."); echo "FAILED: File {$reqFile} does not exist."; return; } if (!unlink($file)) { echo 'FAILED: Permission denied.'; return; } $response = Sahara_Soap::getSchedServerSessionClient()->getSessionInformation(array('userQName' => $this->_auth->getIdentity())); $home = new Sahara_Home($homePath, time() - $response->time); $home->loadContents(); echo $this->view->json($home->getFlattenedContents()); }