|
@@ -11,20 +11,33 @@ class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
|
|
|
|
|
|
|
|
public function defaultAction() {
|
|
public function defaultAction() {
|
|
|
UI::gora();
|
|
UI::gora();
|
|
|
|
|
+ UI::menu();
|
|
|
|
|
+ UI::startContainer();
|
|
|
UI::tag('h1', [], 'Ant');
|
|
UI::tag('h1', [], 'Ant');
|
|
|
try {
|
|
try {
|
|
|
$taskList = $this->getAntUrlActionList();
|
|
$taskList = $this->getAntUrlActionList();
|
|
|
- DBG::nicePrint($taskList, 'ant-url_action');
|
|
|
|
|
|
|
|
|
|
- $featureID = V::get('featureID', '', $_GET);
|
|
|
|
|
- $typeName = V::get('typeName', '', $_GET);
|
|
|
|
|
- // TODO: validate missing ...
|
|
|
|
|
|
|
+ // $featureID = V::get('featureID', '', $_GET);
|
|
|
|
|
+ $primaryKey = V::get('primaryKey', '', $_GET, 'word');
|
|
|
|
|
+ $typeName = V::get('typeName', '', $_GET, 'word');
|
|
|
|
|
+ if (empty($typeName)) throw new Exception("Missing typeName");
|
|
|
|
|
+ if (empty($primaryKey)) throw new Exception("Missing primaryKey");
|
|
|
|
|
+ $parsedInfo = Core_AclHelper::parseTypeName($typeName);
|
|
|
|
|
+ DBG::log($parsedInfo, '', "Ant parseTypeName({$typeName})");
|
|
|
|
|
+ $acl = ACL::getAclByNamespace("{$parsedInfo['url']}/{$parsedInfo['name']}");
|
|
|
|
|
+ $pkField = $acl->getPrimaryKeyField();
|
|
|
|
|
|
|
|
UI::startTag('ul');
|
|
UI::startTag('ul');
|
|
|
foreach ($taskList as $path => $label) {
|
|
foreach ($taskList as $path => $label) {
|
|
|
- $link = "index.php?_route=UrlAction_Ant&_task=ant&path={$path}&typeName={$typeName}&featureID={$featureID}";
|
|
|
|
|
echo UI::h('li', [], [
|
|
echo UI::h('li', [], [
|
|
|
- UI::h('a', ['href'=>$link], "Uruchom '{$label}'")
|
|
|
|
|
|
|
+ UI::h('a', [
|
|
|
|
|
+ 'href' => $this->getLink('ant', [
|
|
|
|
|
+ 'path' => $path,
|
|
|
|
|
+ 'typeName' => $typeName,
|
|
|
|
|
+ 'primaryKey' => $primaryKey,
|
|
|
|
|
+ 'primaryKeyField' => $pkField
|
|
|
|
|
+ ])
|
|
|
|
|
+ ], "Uruchom '{$label}'")
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
UI::endTag('ul');
|
|
UI::endTag('ul');
|
|
@@ -32,6 +45,7 @@ class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
|
|
|
UI::alert('danger', $e->getMessage());
|
|
UI::alert('danger', $e->getMessage());
|
|
|
DBG::log($e);
|
|
DBG::log($e);
|
|
|
}
|
|
}
|
|
|
|
|
+ UI::endContainer();
|
|
|
UI::dol();
|
|
UI::dol();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -47,45 +61,82 @@ class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
|
|
|
|
|
|
|
|
public function antAction() {
|
|
public function antAction() {
|
|
|
UI::gora();
|
|
UI::gora();
|
|
|
|
|
+ UI::startContainer();
|
|
|
try {
|
|
try {
|
|
|
- echo UI::h('h1', [], "Ant action");
|
|
|
|
|
$path = V::get('path', '', $_GET);
|
|
$path = V::get('path', '', $_GET);
|
|
|
if (!$path) throw new Exception("Missing Ant path!");
|
|
if (!$path) throw new Exception("Missing Ant path!");
|
|
|
- $primaryKey = V::get('primaryKey', '', $_GET);
|
|
|
|
|
- $xpath = V::get('xpath', '', $_GET);
|
|
|
|
|
-
|
|
|
|
|
$typeName = V::get('typeName', '', $_GET);
|
|
$typeName = V::get('typeName', '', $_GET);
|
|
|
- list($nsPrefix, $objectName) = explode(':', $typeName);// TODO: get wfs prefix from typeName
|
|
|
|
|
|
|
+ if (!$typeName) throw new Exception("Missing typeName");
|
|
|
|
|
+ $primaryKey = V::get('primaryKey', '', $_GET);
|
|
|
|
|
+ if (!$primaryKey) throw new Exception("Missing primaryKey");
|
|
|
|
|
+ $pkField = V::get('primaryKeyField', '', $_GET);
|
|
|
|
|
+ if (!$pkField) throw new Exception("Missing primaryKeyField");
|
|
|
|
|
+ // list($nsPrefix, $objectName) = explode(':', $typeName);// TODO: get wfs prefix from typeName
|
|
|
|
|
+ $parsedInfo = Core_AclHelper::parseTypeName($typeName);
|
|
|
|
|
+ DBG::log($parsedInfo, '', "Ant parseTypeName({$typeName})");
|
|
|
|
|
+ $nsPrefix = $parsedInfo['prefix'];
|
|
|
|
|
+ $objectName = $parsedInfo['name'];
|
|
|
|
|
|
|
|
// TODO: validate missing ...
|
|
// TODO: validate missing ...
|
|
|
|
|
+ DBG::log($_GET, 'array', '$_GET');
|
|
|
DBG::log([ 'msg'=>'$path', '$path'=>$path]);
|
|
DBG::log([ 'msg'=>'$path', '$path'=>$path]);
|
|
|
DBG::log([ 'msg'=>'$primaryKey', '$primaryKey'=>$primaryKey]);
|
|
DBG::log([ 'msg'=>'$primaryKey', '$primaryKey'=>$primaryKey]);
|
|
|
DBG::log([ 'msg'=>'$typeName', '$typeName'=>$typeName]);
|
|
DBG::log([ 'msg'=>'$typeName', '$typeName'=>$typeName]);
|
|
|
|
|
|
|
|
$taskList = $this->getAntUrlActionList();
|
|
$taskList = $this->getAntUrlActionList();
|
|
|
if (!array_key_exists($path, $taskList)) throw new Exception("Ant path not exists! '{$path}'");
|
|
if (!array_key_exists($path, $taskList)) throw new Exception("Ant path not exists! '{$path}'");
|
|
|
|
|
+ echo UI::h('h3', [], [
|
|
|
|
|
+ "Druk",
|
|
|
|
|
+ '<br>',
|
|
|
|
|
+ UI::h('small', [], $taskList[$path])
|
|
|
|
|
+ ]);
|
|
|
|
|
|
|
|
echo UI::h('hr');
|
|
echo UI::h('hr');
|
|
|
|
|
|
|
|
$webRootUrl = Request::getPathUri() . "schema/ant-url_action/{$path}";// TODO: security - only for test
|
|
$webRootUrl = Request::getPathUri() . "schema/ant-url_action/{$path}";// TODO: security - only for test
|
|
|
- $outputFunctionUrl = Request::getPathUri() . "index.php?_route=UrlAction_Ant&_task=output&path={$path}&file=";
|
|
|
|
|
|
|
+ $outputFunctionUrl = $this->getLink('output') . "&path={$path}&file=";
|
|
|
DBG::log([ 'msg'=>'$webRootUrl', '$webRootUrl'=>$webRootUrl]);
|
|
DBG::log([ 'msg'=>'$webRootUrl', '$webRootUrl'=>$webRootUrl]);
|
|
|
DBG::log([ 'msg'=>'$outputFunctionUrl', '$outputFunctionUrl'=>$outputFunctionUrl]);
|
|
DBG::log([ 'msg'=>'$outputFunctionUrl', '$outputFunctionUrl'=>$outputFunctionUrl]);
|
|
|
- $testUrl = Request::getPathUri() . "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=".$typeName."&SRSNAME=EPSG:3003&featureID={$objectName}.{$primaryKey}";
|
|
|
|
|
|
|
+ $testUrl = Request::getPathUri() . "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME={$typeName}&SRSNAME=EPSG:3003&featureID={$objectName}.{$primaryKey}";
|
|
|
$cryptedPass = base64_encode(User::getLogin() . ":" . Crypt::decrypt($_SESSION['ADM_PASS_HASH']));
|
|
$cryptedPass = base64_encode(User::getLogin() . ":" . Crypt::decrypt($_SESSION['ADM_PASS_HASH']));
|
|
|
-// $cmd = "cd {$this->pathUrlActions}{$path} && {$this->antBin} -DoutputFunctionUrl='{$outputFunctionUrl}' -DwebRootUrl='{$webRootUrl}' -Durl='{$testUrl}' -DpasswordBase64Basic=\"{$cryptedPass}\" -Duuid=\"".session_id()."\" -Dxpath=".$xpath." -Dxpath_value=".$primaryKey." -DtypeName=\"".$typeName."\" 2>&1";
|
|
|
|
|
- $cmd = "{$this->pathUrlActions}{$path}/do_build.sh -DoutputFunctionUrl='{$outputFunctionUrl}' -DwebRootUrl='{$webRootUrl}' -Durl='{$testUrl}' -DpasswordBase64Basic=\"{$cryptedPass}\" -Duuid=\"".session_id()."\" -Dxpath=".$xpath." -Dxpath_value=".$primaryKey." -DtypeName=\"".$typeName."\" ";
|
|
|
|
|
|
|
+ $uniqID = session_id();// TODO: uniq id for every request
|
|
|
|
|
+ // $cmd = "{$this->pathUrlActions}{$path}/do_build.sh";
|
|
|
|
|
+ $cmd = "cd {$this->pathUrlActions}{$path} && ant -S";
|
|
|
|
|
+ $cmd .= " -DoutputFunctionUrl='{$outputFunctionUrl}'";
|
|
|
|
|
+ $cmd .= " -DwebRootUrl='{$webRootUrl}'";
|
|
|
|
|
+ $cmd .= " -Durl='{$testUrl}'";
|
|
|
|
|
+ $cmd .= " -DpasswordBase64Basic=\"{$cryptedPass}\"";
|
|
|
|
|
+ $cmd .= " -Duuid=\"{$uniqID}\"";
|
|
|
|
|
+ $cmd .= " -Dxpath={$pkField}";
|
|
|
|
|
+ $cmd .= " -Dxpath_value={$primaryKey}";
|
|
|
|
|
+ $cmd .= " -DtypeName=\"{$typeName}\"";
|
|
|
|
|
+ $cmd .= " 2>&1";
|
|
|
|
|
+
|
|
|
|
|
+ $pathCmd = [];
|
|
|
|
|
+ $pathCmd[] = '/opt/local/bin/ant';
|
|
|
|
|
+ $pathCmd[] = '/bin';
|
|
|
|
|
+ $pathCmd[] = '/usr/bin';
|
|
|
|
|
+ $pathCmd[] = '/usr/local/bin';
|
|
|
|
|
+ $pathCmd[] = '/opt/local/bin';
|
|
|
|
|
+ $pathCmd[] = '/sbin';
|
|
|
|
|
+ $pathCmd[] = '/usr/sbin';
|
|
|
|
|
+ $pathCmd[] = '/opt/local/sbin/skrypty';
|
|
|
|
|
+ $pathCmd[] = '/opt/local/var/macports/software';
|
|
|
|
|
+ $pathCmd[] = '/Applications/Server.app/Contents/ServerRoot/usr/bin';
|
|
|
|
|
+ $pathCmd[] = '/Applications/Server.app/Contents/ServerRoot/usr/sbin';
|
|
|
|
|
+ $cmd = 'export PATH=' . implode(':', $pathCmd) . "\n" .
|
|
|
|
|
+ 'JAVA_HOME="/usr/bin/java"' . "\n" .
|
|
|
|
|
+ 'MAVEN_OPTS="-Xms256m -Xmx512m"' . "\n" .
|
|
|
|
|
+ $cmd;
|
|
|
|
|
+ $useShellExec = true;
|
|
|
|
|
+ if ($useShellExec) $out = shell_exec($cmd);
|
|
|
|
|
+ else V::exec($cmd, $out, $ret);
|
|
|
|
|
+ DBG::log([ 'msg'=>"cmd and returns({$ret})", 'output'=>$out, 'cmd'=>str_replace(APP_PATH_ROOT, 'SE', $cmd) ]);
|
|
|
|
|
+ if (empty($out)) throw new Exception("Empty output");
|
|
|
|
|
+ if ($useShellExec) $out = explode("\n", $out);
|
|
|
|
|
|
|
|
- DBG::log([ 'msg'=>"cmd", 'cmd'=>str_replace(APP_PATH_ROOT, 'SE', $cmd) ]);
|
|
|
|
|
- //V::exec($cmd, $out, $ret); to nie dziala prawidlowo
|
|
|
|
|
- putenv('PATH=/opt/local/bin/ant');
|
|
|
|
|
- $out=shell_exec($cmd);
|
|
|
|
|
- DBG::log([ 'msg'=>"cmd and returns({$ret})", 'output'=>$out ]);
|
|
|
|
|
$html = []; $startRead = false;
|
|
$html = []; $startRead = false;
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- echo "<hr>".$out."<hr>"; //do poprawy, chce ruszyc, bo lokalnie mi dziala
|
|
|
|
|
- /* foreach ($out as $line) {
|
|
|
|
|
|
|
+ foreach ($out as $line) {
|
|
|
if (!$startRead) {
|
|
if (!$startRead) {
|
|
|
if ('OUTPUT__START' == $line) {
|
|
if ('OUTPUT__START' == $line) {
|
|
|
$startRead = true;
|
|
$startRead = true;
|
|
@@ -99,15 +150,16 @@ class Route_UrlAction_Ant extends Route_Ant {// @doc @see Route_Ant
|
|
|
$html[]= $line;
|
|
$html[]= $line;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- echo UI::h('h3', [], "output:");
|
|
|
|
|
if (empty($html)) UI::alert('danger', "Empty output!");
|
|
if (empty($html)) UI::alert('danger', "Empty output!");
|
|
|
- // echo UI::h('pre', [], htmlspecialchars(implode("\n", $html)));
|
|
|
|
|
- echo UI::h('div', ['class'=>"container", 'style'=>"padding:12px; border:1px solid #ddd"], $html);
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ else {
|
|
|
|
|
+ // echo UI::h('pre', [], htmlspecialchars(implode("\n", $html)));
|
|
|
|
|
+ echo UI::h('div', ['class'=>"container", 'style'=>"padding:12px; border:1px solid #ddd"], $html);
|
|
|
|
|
+ }
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
UI::alert('danger', $e->getMessage());
|
|
UI::alert('danger', $e->getMessage());
|
|
|
DBG::log($e);
|
|
DBG::log($e);
|
|
|
}
|
|
}
|
|
|
|
|
+ UI::endContainer();
|
|
|
UI::dol();
|
|
UI::dol();
|
|
|
}
|
|
}
|
|
|
|
|
|