[Mapbender-commits] r9544 - in trunk/mapbender/http: classes php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Jul 14 08:01:52 PDT 2016
Author: armin11
Date: 2016-07-14 08:01:52 -0700 (Thu, 14 Jul 2016)
New Revision: 9544
Modified:
trunk/mapbender/http/classes/class_administration.php
trunk/mapbender/http/classes/class_cswClient.php
trunk/mapbender/http/php/mod_deleteWMS.php
Log:
New possibility to sync mapbender registry with external csw via csw-t - done for wms layer resources
Modified: trunk/mapbender/http/classes/class_administration.php
===================================================================
--- trunk/mapbender/http/classes/class_administration.php 2016-07-14 15:01:01 UTC (rev 9543)
+++ trunk/mapbender/http/classes/class_administration.php 2016-07-14 15:01:52 UTC (rev 9544)
@@ -1803,25 +1803,29 @@
return false;
}
$array_guis = $this->getGuisByPermission($user_id,true);
- $v = array();
- $t = array();
- $sql = "SELECT * FROM gui_layer WHERE fkey_gui_id IN (";
- $c = 1;
- for($i=0; $i<count($array_guis); $i++){
- if($i>0){ $sql .= ",";}
- $sql .= "$".$c;
- $c++;
- array_push($v, $array_guis[$i]);
- array_push($t, 's');
- }
- $sql .= ") AND fkey_layer_id = $".$c." AND gui_layer_status = 1";
- array_push($v,$layer_id);
- array_push($t,'i');
- $res = db_prep_query($sql,$v,$t);
- if($row = db_fetch_array($res)){
- return true;
- }
- else{
+ if (count($array_guis) > 0) {
+ $v = array();
+ $t = array();
+ $sql = "SELECT * FROM gui_layer WHERE fkey_gui_id IN (";
+ $c = 1;
+ for($i=0; $i<count($array_guis); $i++){
+ if($i>0){ $sql .= ",";}
+ $sql .= "$".$c;
+ $c++;
+ array_push($v, $array_guis[$i]);
+ array_push($t, 's');
+ }
+ $sql .= ") AND fkey_layer_id = $".$c." AND gui_layer_status = 1";
+ array_push($v,$layer_id);
+ array_push($t,'i');
+ $res = db_prep_query($sql,$v,$t);
+ if($row = db_fetch_array($res)){
+ return true;
+ }
+ else{
+ return false;
+ }
+ } else {
return false;
}
}
Modified: trunk/mapbender/http/classes/class_cswClient.php
===================================================================
--- trunk/mapbender/http/classes/class_cswClient.php 2016-07-14 15:01:01 UTC (rev 9543)
+++ trunk/mapbender/http/classes/class_cswClient.php 2016-07-14 15:01:52 UTC (rev 9544)
@@ -181,7 +181,7 @@
if (is_array($metadataRecord) && count($metadataRecord) <> 1 || !is_array($metadataRecord)) {
//$err = new mb_exception(count($metadataRecord));
//$err = new mb_exception($metadataRecord[0]->asXml());
- $err = new mb_exception("class_cswClient.php: More or less than one metadata returned for a getrecordby id response!");
+ //$err = new mb_exception("class_cswClient.php: More or less than one metadata returned for a getrecordby id response!");
$this->operationResult = "More or less than one metadata returned for a getrecordby id response!";
return false;
} else {
@@ -202,10 +202,10 @@
public function pushRecord($isoMetadataObject, $auth=false) {
//check if metadata already in catalogue
if ($this->doRequest($this->cswId, 'getrecordbyid', $isoMetadataObject->fileIdentifier)) {
- $err = new mb_exception("class_cswClient.php: do a transaction update");
+ //$err = new mb_exception("class_cswClient.php: do a transaction update");
$response = $this->doRequest($this->cswId, 'transactionupdate', false, $isoMetadataObject);
} else {
- $err = new mb_exception("class_cswClient.php: do a transaction insert");
+ //$err = new mb_exception("class_cswClient.php: do a transaction insert");
$response = $this->doRequest($this->cswId, 'transactioninsert', false, $isoMetadataObject);
}
return $response;
@@ -230,7 +230,14 @@
public function deleteRecord($fileIdentifier, $auth=false) {
- $response = $this->doRequest($this->cswId, 'transactiondelete', $fileIdentifier, false);
+ //check if exists before!
+ if ($this->doRequest($this->cswId, 'getrecordbyid', $fileIdentifier, false)) {
+ //$err = new mb_exception("class_cswClient.php: do a transaction delete");
+ $response = $this->doRequest($this->cswId, 'transactiondelete', $fileIdentifier, false);
+ } else {
+ //$err = new mb_exception("class_cswClient.php: Don't delete object - cause it doen't exists!");
+ $response = "<cswClient>Don't delete record ".$fileIdentifier." - cause it doen't exists!</cswClient>";
+ }
return $response;
}
Modified: trunk/mapbender/http/php/mod_deleteWMS.php
===================================================================
--- trunk/mapbender/http/php/mod_deleteWMS.php 2016-07-14 15:01:01 UTC (rev 9543)
+++ trunk/mapbender/http/php/mod_deleteWMS.php 2016-07-14 15:01:52 UTC (rev 9544)
@@ -20,7 +20,8 @@
$e_id="deleteWMS";
require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
-
+require_once dirname(__FILE__) . "/../classes/class_iso19139.php";
+require_once(dirname(__FILE__) . "/../classes/class_cswClient.php");
/*
* @security_patch irv done
*/
@@ -223,6 +224,19 @@
$v = array($wmsList);
$t = array('i');
$res = db_prep_query($sql,$v,$t);
+ //before delete the wms get the published layers to delete their metadata afterwards
+ //select all layer which are searchable
+ $sql = "SELECT layer_id, uuid FROM layer WHERE fkey_wms_id = $1 and layer_searchable = 1";
+ $v = array($wmsList);
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ $layerArray = array();
+ while($row = db_fetch_array($res)){
+ $layerArray[] = array(
+ "id" => $row['layer_id'],
+ "uuid" => $row['uuid']
+ );
+ }
//***
$sql = "DELETE FROM wms WHERE wms_id = $1";
$v = array($wmsList);
@@ -243,7 +257,26 @@
$timestamp = date(DATE_RSS,time());
$geoRssItem->setPubDate($timestamp);
$geoRss->appendTop($geoRssItem);
- $geoRss->saveAsFile();
+ $geoRss->saveAsFile();
+ //delete metadata of connected catalogue
+ //Propagate information for each new layer to csw if configured
+ if (defined("SYNC_CHANGES_TO_CSW") && SYNC_CHANGES_TO_CSW == true && defined("SYNC_CATALOGUE_ID") && is_int(SYNC_CATALOGUE_ID)) {
+ /*if (defined("MAPBENDER_PATH") && MAPBENDER_PATH !== "") {
+ //layer service metadata generator
+ $servMdPath = MAPBENDER_PATH."/php/mod_layerISOMetadata.php?SERVICE=WMS&outputFormat=iso19139&Id=";
+ } else {
+ $servMdPath = "http://".$_SERVER['HTTP_HOST']."/mapbender"."/php/mod_layerISOMetadata.php?SERVICE=WMS&outputFormat=iso19139&Id=";
+ }*/
+ $cswClient = new cswClient();
+ $cswClient->cswId = SYNC_CATALOGUE_ID;
+ //$isoMetadata = new Iso19139();
+ foreach ($layerArray as $layer) {
+ $result = $cswClient->deleteRecord($layer['uuid']);
+ $e = new mb_notice($result);
+ //$metadata = $isoMetadata->createFromUrl($servMdPath.$layer['id']);
+ //$result = $cswClient->pushRecord($metadata);
+ }
+ }
}
}
// display WMS List
More information about the Mapbender_commits
mailing list