[Mapbender-commits] r9100 - trunk/mapbender/http/plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Oct 17 02:34:16 PDT 2014
Author: armin11
Date: 2014-10-17 02:34:16 -0700 (Fri, 17 Oct 2014)
New Revision: 9100
Modified:
trunk/mapbender/http/plugins/mb_downloadFeedServer.php
Log:
new possibility to log requests to inspire download services
Modified: trunk/mapbender/http/plugins/mb_downloadFeedServer.php
===================================================================
--- trunk/mapbender/http/plugins/mb_downloadFeedServer.php 2014-10-16 10:58:09 UTC (rev 9099)
+++ trunk/mapbender/http/plugins/mb_downloadFeedServer.php 2014-10-17 09:34:16 UTC (rev 9100)
@@ -59,7 +59,83 @@
}
}
+function logDlsUsage ($link, $s_title, $datasetid) {
+ $logId = isLinkAlreadyInDB($link);
+ if ($logId != false) {
+ $e = new mb_exception("logId: ".$logId);
+ //update the load_count for this log entry
+ $e = new mb_notice("existing inspire_dls_log link found - load count will be incremented");
+ $sql = <<<SQL
+UPDATE inspire_dls_log SET log_count = log_count + 1 WHERE log_id = $1
+SQL;
+ $v = array(
+ $logId
+ );
+ $t = array('i');
+ $res = db_prep_query($sql,$v,$t);
+ return true;
+ } else {
+ //create new record cause service has not been invoced so far
+ $sql = <<<SQL
+INSERT INTO inspire_dls_log (createdate, link, linktype, service_title, datasetid, log_count) VALUES (now(), $1, 'ATOM', $2, $3, 1)
+SQL;
+ $v = array(
+ $link,
+ $s_title,
+ $datasetid
+ );
+ $t = array('s','s','s');
+ $res = db_prep_query($sql,$v,$t);
+ return true;
+ }
+}
+function isLinkAlreadyInDB($link){
+ $sql = <<<SQL
+SELECT log_id FROM inspire_dls_log WHERE link = $1 AND link <> '' ORDER BY lastchanged DESC
+SQL;
+ $v = array(
+ $link
+ );
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+ while ($row = db_fetch_array($res)){
+ $logId[] = $row['log_id'];
+ }
+ if (count($logId) > 0) {
+ return $logId[0];
+ } else {
+ return false;
+ }
+}
+
+function isFileIdentifierAlreadyInDB($uuid){
+ $sql = <<<SQL
+SELECT log_id, createdate FROM inspire_dls_log WHERE dls_service_uuid = $1 AND dls_service_uuid <> '' ORDER BY lastchanged DESC
+SQL;
+ if (!isset($uuid) || $uuid == '') {
+ $e = new mb_exception("plugins/mb_downloadFeedServer.php:"."Empty or no fileIdentifier found in the inspire_dls_log table! No log entry will be updated");
+ return false;
+ }
+ $v = array(
+ $uuid
+ );
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+ $logId = array();
+ while ($row = db_fetch_array($res)){
+ $logId[] = $row['log_id'];
+ }
+ if (count($logId) > 0) {
+ return $logId;
+ } else {
+ return false;
+ }
+}
+
+
+
+
function DOMNodeListObjectValuesToArray($domNodeList) {
$iterator = 0;
$array = array();
@@ -213,6 +289,9 @@
}
}
}
+ //log usage
+ //logDlsUsage ($link, $s_title, $datasetid)
+ logDlsUsage ($serviceFeedUrl, $feature->properties["title"], $feature->properties["namespace"]."#".$feature->properties["code"]);
echo $featureCollection->toGeoJSON();
break;
case "getDatasetFeedObjectFromUrl" :
More information about the Mapbender_commits
mailing list