AmdaUpdate.php
5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* @file AmdaUpdate.php
* @version $Id: AmdaUpdate.php 2855 2015-04-18 09:34:45Z elena $
* @brief Amda Update/Install Info by DD Server WebServices
*/
ini_set("soap.wsdl_cache_enabled", "0");
require_once "config.php";
// error_reporting(E_ALL);
// if 'install' argument => then system installation!!!! otherwise => updating (without copy)
$updateOnly = true;
if (isset($argv[1]))
{
if ($argv[1] != 'install')
{
$msg = "Error: Unknown argument ".$argv[1]."!".PHP_EOL;
print_r($msg);
exit(1);
}
$updateOnly = false;
}
$amda = new AmdaClient($updateOnly);
/*
* Get Shared TT id SHAREDTT dir doesn't exist
*/
if (!$updateOnly) {
//BRE ToDo SHARED
/*if (!is_dir(SHAREDPATH)) {
system("svn export ".SVN_DDMISSIONSINFO."SHAREDTT ".SHAREDPATH);
$amda->fsmodifyr(SHAREDPATH);
} */
}
/*
* Get available external bases if exist
*/
$extBases = $amda->getAvailableExternalBases();
/*
* Update Start Stop for AMDA remote data
*/
if(is_string($extBases)) {
$msg = "Warning: No Remote Amda Data info exists!".PHP_EOL;
print_r($msg);
}
else {
$paramMgr = new ParamMgr();
foreach ($extBases as $extBase) {
// check connection
if (!$amda->checkRemoteConnection($extBase->nodeValue)) {
$msg = "Warning: No connection for ".$extBase->nodeValue.PHP_EOL;
print_r($msg);
}
if ($updateOnly) {
if (!($extBase->hasAttribute('group') && $extBase->getAttribute('group') == 'IMPEX')) {
$ok = $amda->updateRemoteStartStop($extBase->nodeValue);
}
}
// if install - copy base.xml for all Bases
else {
$ok = $amda->getAvailableExternalData($extBase->nodeValue);
if (!$ok) {
$msg = "Warning: cannot copy base.xml for ".$extBase->nodeValue.PHP_EOL;
print_r($msg);
}
// Copy all default datasets descriptions and create default parameters
else {
if ($extBase->hasAttribute('default') &&
(!($extBase->hasAttribute('group') && $extBase->getAttribute('group') == 'IMPEX'))) {
$baseXML = new DomDocument("1.0");
$baseId = $extBase->nodeValue;
$baseXML->load(RemoteData.$baseId.'/base.xml');
$datasets = $baseXML->getElementsByTagName('dataset');
$paramMgr->baseId = $baseId;
foreach ($datasets as $dataset){
if ($baseId !== 'THEMIS') {
$infoFileName = $paramMgr->getInfoName($dataset->getAttribute('name'));
$paramMgr->localInfo = RemoteData.$baseId.'/'.$infoFileName;
if (!file_exists($paramMgr->localInfo)) {
$remoteInfo = INFOSITE.'INFO/'.$baseId.'/DATASETS/'.$infoFileName;
// call to DD Server to create new VI
$viId = $dataset->getAttribute('name');
$command = OLD_CLASSPATH.'AddVI '.$paramMgr->dataset2dd($viId).' '.$viId.' '.$baseId;
system($command, $err);
// no data set description; skip this data set
if(!copy($remoteInfo, $paramMgr->localInfo)) continue;
}
$params = $dataset->getElementsByTagName('parameter');
$paramMgr->remoteViId = $dataset->getAttribute('name');
foreach ($params as $param) {
$paramMgr->paramId = $param->getAttribute('name');
$paramGlobalId = $param->getAttribute('xml:id');
$paramMgr->paramXML = RemoteData.'PARAMS/'.$paramGlobalId.'.xml';
$info = $paramMgr->getParamInfo();
if (!file_exists($paramMgr->paramXML) && !$paramMgr->createParamXml($info)) continue;
}
}
}
}
}
}
}
}
echo 'Start IMPEx user initialisation'.PHP_EOL;
// update IMPEx workspace
$userID = 'impex'; $userPWD = 'impexfp7'; $sessionID = 'impex';
$wsUserMgr = new WSUserMgr();
$wsUserMgr->init($userID, $userPWD, $sessionID);
$wsUserMgr->makeUserWS();
echo 'IMPEx user was inited'.PHP_EOL;
echo PHP_EOL.'CHECK LOG IN '.log.PHP_EOL;
?>