Commit 415ff5560f8f9a8f2d8b9ed5d45c6718cea3f14c

Authored by Elena.Budnik
2 parents ef2dedb3 2b8ea2a7

Merge branch 'master' into fix-folders-fix-merge

php/RemoteDataCenter/RemoteParamManager.php
... ... @@ -6,7 +6,7 @@
6 6  
7 7 class RemoteParamManager
8 8 {
9   - protected $Bases, $basesDom;
  9 + public $Bases, $basesDom;
10 10 protected $baseDom;
11 11  
12 12 protected $center;
... ... @@ -16,31 +16,41 @@ class RemoteParamManager
16 16  
17 17 function __construct()
18 18 {
  19 + $this->basesDom = new DomDocument("1.0");
  20 +
  21 + if (!is_dir(RemoteData."/PARAMS"))
  22 + mkdir(RemoteData."/PARAMS", 0775, true);
  23 +
  24 + if (!is_dir(RemoteData."/PARAMS_INFO"))
  25 + mkdir(RemoteData."/PARAMS_INFO", 0775, true);
  26 +
  27 + $this->xmlName = USERWSDIR."RemoteParams.xml";
  28 + $this->xmlDom = new DomDocument("1.0");
  29 +
  30 + }
  31 +
  32 + public function init() {
  33 +
19 34 if (!file_exists(RemoteData."Bases.xml"))
20 35 return array("err" => "No Remote Data Bases");
21   -
22   - $this->basesDom = new DomDocument("1.0");
  36 +
23 37 if (!$this->basesDom->load(RemoteData."Bases.xml"))
24 38 return array("err" => "Can not load Remote Data Bases definitions");
  39 +
25 40 $bases = $this->basesDom->getElementsByTagName('dataCenter');
26 41  
27 42 foreach ($bases as $base)
28 43 $this->Bases[] = $base->getAttribute('xml:id');
29   -
  44 +
30 45 if (!file_exists(USERWSDIR."RemoteParams.xml"))
31   - return array("err" => "No RemoteParams.xml");
  46 + return array("err" => "RemoteParams file error");
32 47  
33   - if (!is_dir(RemoteData."/PARAMS"))
34   - mkdir(RemoteData."/PARAMS", 0775, true);
35   -
36   - if (!is_dir(RemoteData."/PARAMS_INFO"))
37   - mkdir(RemoteData."/PARAMS_INFO", 0775, true);
38   -
39   - $this->xmlName = USERWSDIR."RemoteParams.xml";
40   - $this->xmlDom = new DomDocument("1.0");
41   - $this->xmlDom->load($this->xmlName);
  48 + if (!$this->xmlDom->load($this->xmlName))
  49 + return array("err" => "RemoteParams file error");
  50 +
  51 + return array("success" => true);
42 52 }
43   -
  53 +
44 54 /*
45 55 * get baseId from parameter descriptor
46 56 */
... ...
php/classes/AmdaAction.php
... ... @@ -572,7 +572,12 @@ class AmdaAction
572 572 public function saveTree($obj)
573 573 {
574 574 $paramMgr = new RemoteParamManager();
575   - return $paramMgr->saveTree($obj);
  575 + $res = $paramMgr->init();
  576 +
  577 + if ($res['success'])
  578 + return $paramMgr->saveTree($obj);
  579 + else
  580 + return $res;
576 581 }
577 582  
578 583 /*
... ... @@ -581,7 +586,12 @@ class AmdaAction
581 586 public function deleteFromTree($obj)
582 587 {
583 588 $paramMgr = new RemoteParamManager();
584   - return $paramMgr->deleteFromTree($obj);
  589 + $res = $paramMgr->init();
  590 +
  591 + if ($res['success'])
  592 + return $paramMgr->deleteFromTree($obj);
  593 + else
  594 + return $res;
585 595 }
586 596  
587 597 public function doNothing($obj)
... ...