Blame view

php/RemoteDataCenter/RemoteDataCenterClass.php 2.85 KB
bf74fc2d   Elena.Budnik   IMPEX
1
2
3
4
5
6
7
8
<?php
/**
 * @class RemoteDataCenterClass
 * @brief  
 * @details
 */
abstract class RemoteDataCenterClass
{
6657f68b   Elena.Budnik   monitor impex ser...
9
	protected $url = null, $WSDL = null, $treeXML = null;	
28c19276   Elena.Budnik   generic template def
10
11
12
13
14
15
16
17
18
19
20
		
	protected $needsArgs = false;
	protected $hasAccessUrl = false;

	public $domAmda = null, $dataCenter = null;  
	public $domAmdaName = "base.xml";
	public $additionalArgs = null;
	public $templateFile, $plotSettings;
	public $baseID = null;

	public $tree = null;
bf74fc2d   Elena.Budnik   IMPEX
21
22
23
24
25
26
   
	/*
	 * @brief Constructor
	*/
	function __construct()
	{		
28c19276   Elena.Budnik   generic template def
27
28
29
		$this->baseID = get_class($this);
		$this->templateFile = $this->baseID."_Templates.xml";
		$this->plotSettings = $this->baseID."_PlotSettings.xml";
bf74fc2d   Elena.Budnik   IMPEX
30
31
32
33
	}		
	
	public function param2dd($paramID) 
	{
28c19276   Elena.Budnik   generic template def
34
35
		$pairs = array(" " => "_","-" => "_","/" => "_","%" => "_","\\" => "_","$" => "_",":" => "_","+" =>"_","#" => "_","@" => "_","." => "_", ">" => "_", "<" => "_", "," => "_", ")" => "", "(" => "_");    
		return strtr($paramID,$pairs); 
bf74fc2d   Elena.Budnik   IMPEX
36
37
38
39
40
41
42
43
	}
	
	public function saveProxy()
	{		
		$this->domAmda->save(RemoteData.$this->baseID."/".$this->domAmdaName);		 		
	}
	
	abstract public function init(); 
bf74fc2d   Elena.Budnik   IMPEX
44
45
46
47
	abstract protected function getRemoteTree();
	abstract protected function setDataCenterAttributes();
	abstract protected function createMissionNodes();
	abstract protected function makeArgumentsList();
28c19276   Elena.Budnik   generic template def
48
	
bf74fc2d   Elena.Budnik   IMPEX
49
50
51
52
53
54
55
// 	abstract protected function createDatasetNodes();
// 	abstract protected function createParameterNodes();
// 	abstract protected function createDatasetGroupNodes($data);
	
	public function initProxy() 
	{	 
		if (!is_dir(RemoteData.$this->baseID))
05961422   Elena.Budnik   permissions on dirs
56
			mkdir(RemoteData.$this->baseID, 0775, true);	
d444ba30   Elena.Budnik   mkdir...,0775 doe...
57
			chmod(RemoteData.$this->baseID,0775);
bf74fc2d   Elena.Budnik   IMPEX
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
		
		$this->getRemoteTree();
	} 
	
	public function makeProxy()
	{	
		$this->domAmda = new DOMDocument('1.0', 'utf-8');
		$this->domAmda->formatOutput = TRUE;
		$this->domAmda->preserveWhiteSpace = FALSE;
		
		$dataRoot = $this->domAmda->createElement('dataRoot');
		$dataRoot->setAttribute('xml:id', 'myRemoteData-treeRootNode');
		$this->domAmda->appendChild($dataRoot);	
		
		$this->dataCenter=$this->domAmda->createElement('dataCenter');

		$this->dataCenter->setAttribute('xml:id', $this->baseID);
		$this->dataCenter->setAttribute('name', $this->baseID);		 
		
		$dataRoot->appendChild($this->dataCenter);
		
		$this->setDataCenterAttributes();	
		
		$missionNodes = $this->createMissionNodes();
		
		foreach ($missionNodes as $missionNode)
			$this->dataCenter->appendChild($missionNode);
	}
6657f68b   Elena.Budnik   monitor impex ser...
86
87
88
89
90
91
	
	public function monitor()
	{		 		
		$ch = curl_init($this->url."/".$this->WSDL);  
		curl_setopt($ch, CURLOPT_TIMEOUT, 3);  
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);  
99ae8744   Benjamin Renard   Use config variab...
92
93
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		ProxyUtils::addProxyForCurl($ch);
6657f68b   Elena.Budnik   monitor impex ser...
94
95
96
97
98
99
100
101
102
103
104
105
		$data = curl_exec($ch);  
		$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);		
		curl_close($ch); 
		
		if($httpcode >= 200 && $httpcode < 300)
		{  
			return true;  
		} else 
		{  
			return false;  
		}  
	}
bf74fc2d   Elena.Budnik   IMPEX
106
107
}
?>