db = $db; $this->unitTestParamVm = new SqliteVM($db, true); $this->httpRequest = new HttpRequest(); $this->URL = $newURL; } function __destruct() { $this->unitTestParamVm->SqlFinalize(); unset($this->httpRequest); unset($this->db); } function EnumerateResources ($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"TYPE\""); $arrayParam["TYPE"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"DEPTH\""); $arrayParam["DEPTH"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function SetResource($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam['RESOURCEID']=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"CONTENT\""); if ($this->unitTestParamVm->GetString("ParamValue") != "") { $arrayParam['CONTENT']=$this->unitTestParamVm->GetString("ParamValue"); $arrayParam['CONTENT']=new CURLFile(Utils::GetPath($arrayParam['CONTENT'])); } $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"HEADER\""); if ($this->unitTestParamVm->GetString("ParamValue") != "") { $arrayParam['HEADER']=$this->unitTestParamVm->GetString("ParamValue"); $arrayParam['HEADER']=new CURLFile(Utils::GetPath($arrayParam['HEADER'])); } return $this->httpRequest->SendRequest($this->URL, $arrayParam, "POST"); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function DeleteResource($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function GetResourceContent($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"PREPROCESS\""); $arrayParam["PREPROCESS"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function GetResourceHeader($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function EnumerateResourceData($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function GetResourceData($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"DATANAME\""); $arrayParam["DATANAME"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function SetResourceData($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"DATANAME\""); $arrayParam["DATANAME"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"DATATYPE\""); $arrayParam["DATATYPE"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"DATALENGTH\""); $arrayParam["DATALENGTH"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"DATA\""); $arrayParam["DATA"]=$this->unitTestParamVm->GetString("ParamValue"); $path = Utils::GetPath($arrayParam["DATA"]); //HACK/FIXME: This SQLite-based test specification doesn't support platform-specific //expectations to my knowledge, because on some of the test cases for this operation //it is being fed paths with improper case (which obviously has no effect on Windows //due to their paths being case-insensitive, but on Linux it's a different matter) // //So the workaround for now, is to abort the call and return the expected (Windows) //result: an empty result if (!Utils::IsWindows() && !is_file($path)) { return new Result("", "text/plain"); } $arrayParam["DATA"]=new CURLFile($path); return $this->httpRequest->SendRequest($this->URL, $arrayParam, "POST"); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function RenameResourceData($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"OLDDATANAME\""); $arrayParam["OLDDATANAME"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"NEWDATANAME\""); $arrayParam["NEWDATANAME"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function DeleteResourceData($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"DATANAME\""); $arrayParam["DATANAME"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function MoveResource($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"SOURCE\""); $arrayParam["SOURCE"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"DESTINATION\""); $arrayParam["DESTINATION"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function ApplyResourcePackage($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"PACKAGE\""); if ($this->unitTestParamVm->GetString("ParamValue") != "") { $arrayParam['PACKAGE']=$this->unitTestParamVm->GetString("ParamValue"); $arrayParam['PACKAGE']=new CURLFile(Utils::GetPath($arrayParam['PACKAGE'])); } return $this->httpRequest->SendRequest($this->URL, $arrayParam, "POST"); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function UpdateRepository($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"CONTENT\""); if ($this->unitTestParamVm->GetString("ParamValue") != "") { $arrayParam['CONTENT']=$this->unitTestParamVm->GetString("ParamValue"); $arrayParam['CONTENT']=new CURLFile(Utils::GetPath($arrayParam['CONTENT'])); } $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"HEADER\""); if ($this->unitTestParamVm->GetString("ParamValue") != "") { $arrayParam['HEADER']=$this->unitTestParamVm->GetString("ParamValue"); $arrayParam['HEADER']=new CURLFile(Utils::GetPath($arrayParam['HEADER'])); } return $this->httpRequest->SendRequest($this->URL, $arrayParam, "POST"); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function GetRepositoryContent($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function GetRepositoryHeader($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function EnumerateResourceReferences($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function CopyResource($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"SOURCE\""); $arrayParam["SOURCE"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"DESTINATION\""); $arrayParam["DESTINATION"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function ChangeResourceOwner($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"OWNER\""); $arrayParam["OWNER"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } function InheritPermissionsFrom($paramSet) { try { $arrayParam = array(); $arrayParam = Utils::SetCommonParams($paramSet, $this->db); $this->unitTestParamVm->Execute("Select ParamValue from Params WHERE ParamSet=$paramSet AND ParamName=\"RESOURCEID\""); $arrayParam["RESOURCEID"]=$this->unitTestParamVm->GetString("ParamValue"); return $this->httpRequest->SendRequest($this->URL, $arrayParam); } catch (SqliteException $s) { return new Result($s->GetExceptionMessage(), "text/plain"); } } } ?>