[Mapbender-commits] r10070 - in trunk/mapbender: http/classes http/php tools

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Mar 7 09:05:02 PST 2019


Author: armin11
Date: 2019-03-07 09:05:02 -0800 (Thu, 07 Mar 2019)
New Revision: 10070

Added:
   trunk/mapbender/tools/monitorCapabilities.sh-dist
Removed:
   trunk/mapbender/tools/monitorCapabilities.sh
Modified:
   trunk/mapbender/http/classes/class_ckanApi.php
   trunk/mapbender/http/classes/class_syncCkan.php
   trunk/mapbender/http/php/mod_syncCkan_server.php
Log:
Fix for ckan sync interface and alter shell script for monitoring to -dist version - because there are hard coded ids in it!

Modified: trunk/mapbender/http/classes/class_ckanApi.php
===================================================================
--- trunk/mapbender/http/classes/class_ckanApi.php	2019-03-07 15:50:25 UTC (rev 10069)
+++ trunk/mapbender/http/classes/class_ckanApi.php	2019-03-07 17:05:02 UTC (rev 10070)
@@ -148,6 +148,7 @@
 		'organization_revision_list' => 'action/organization_revision_list',
 		'user_create' => 'action/user_create',
 		'user_show' => 'action/user_show',
+		'user_update' => 'action/user_update',
 		'group_create' => 'action/group_create',
 		'group_update' => 'action/group_update',
 		'group_delete' => 'action/group_delete',
@@ -446,6 +447,22 @@
 			$data);
 	}
 
+	// user update
+
+	/**
+	 * @access	public
+	 * @param  	
+	 * @return	the user to update
+	 * @link	http://docs.ckan.org/en/latest/apiv3.html#ckan.logic.action.create.package_create
+	 */
+	public function action_user_update($data)
+	{
+		return $this->make_request('POST', 
+			$this->actionList['user_update'], 
+			$data);
+	}
+
+
 	// group create 
 
 	/**

Modified: trunk/mapbender/http/classes/class_syncCkan.php
===================================================================
--- trunk/mapbender/http/classes/class_syncCkan.php	2019-03-07 15:50:25 UTC (rev 10069)
+++ trunk/mapbender/http/classes/class_syncCkan.php	2019-03-07 17:05:02 UTC (rev 10070)
@@ -190,6 +190,15 @@
         return json_encode($result);
    }
 
+   //function to create user in special group/organization
+   public function updateRemoteCkanUser ($userJson) {
+	$ckan = new ckanApi($this->ckanApiKey, CKAN_SERVER_IP);
+        $ckan->base_url = $this->ckanApiProtocol.'://'.$this->ckanApiUrl.'/api/3/';
+        $ckan->api_version = $this->ckanApiVersion;
+        $result = $ckan->action_user_update($userJson);
+        return json_encode($result);
+   }
+
    //function to get member info
    public function getRemoteCkanMember ($userJson) {
 	$ckan = new ckanApi($this->ckanApiKey, CKAN_SERVER_IP);
@@ -915,6 +924,7 @@
                         }
                         $res = db_prep_query($sql, $v, $t);
                         $countMetadataArray = 0;
+			$metadataArray = array();
                         $featuretypeArray = array();
                         $layerArray = array();
                         //echo "List of datasets in geoportal instance:"."<br>";
@@ -1006,7 +1016,7 @@
                 $e = new mb_exception("classes/class_syncCkan.php: Coupled ckan cannot be synchronized, cause the required organization-id and/or API-Key is was not found for ".$organization["name"]);
                 //echo "<br> - ".$numberGeoportalOrga."<br>";
             }
-        $numberGeoportalOrga++;
+            $numberGeoportalOrga++;
         }
 	if (count($syncListResult->geoportal_organization) >= 1) {
 	    $syncList->result = $syncListResult;
@@ -1159,7 +1169,7 @@
                                    $viewsUpdateProtocol = $this->recreateResourceViews($ckan, $result, $resultCkanRepresentation);
                                 }
                             } else {
-                                $e = new mb_exception("classes/class_syncCkan.php: An error occured while trying to create ".$resultCkanRepresentation['json']);
+                                $e = new mb_exception("classes/class_syncCkan.php: An error occured while trying to create ".$resultCkanRepresentation['json']." error: ".json_encode($result));
                             }
                         } else {
                             $e = new mb_exception("classes/class_syncCkan.php: A problem occured while trying to create the json object from ".$dataSourceType." metadata!");

Modified: trunk/mapbender/http/php/mod_syncCkan_server.php
===================================================================
--- trunk/mapbender/http/php/mod_syncCkan_server.php	2019-03-07 15:50:25 UTC (rev 10069)
+++ trunk/mapbender/http/php/mod_syncCkan_server.php	2019-03-07 17:05:02 UTC (rev 10070)
@@ -411,6 +411,7 @@
 			}
 			//wether ckan orga was identified or created - check editor account !
 			//check if user for editing exists - if not create him automagically
+//TODO: add other editor for other template! - data_document_editor_{orga_id}
 			$editingUserName = "geoportal_editor_".$orga->serialId;
 			$requestPost = new stdClass();
 			$requestPost->{'id'} = $editingUserName;
@@ -421,7 +422,18 @@
 		
 			if ($ckanResultUserObject->success == true) {
 				//check if user has already editor role in organization
-			
+			        //update user
+				$requestPost = new stdClass();
+				$requestPost->{'name'} = $editingUserName;
+				$requestPost->{'email'} = "kontakt at geoportal.rlp.de";
+				$requestPost->{'password'} = "1234".$editingUserName."5678";
+				//groups for rlp:(transparenzgesetz,opendata), TODO configure this in ckan.conf
+				$requestPost->groups[0]->name = "transparenzgesetz";
+				$requestPost->groups[1]->name = "opendata";
+				$requestPostJson = json_encode($requestPost);
+				$ckanResultUser = $syncCkanClass->updateRemoteCkanUser($requestPostJson);
+$e = new mb_exception("update user:  ".$ckanResultUser);
+				$ckanResultUserObject = json_decode($ckanResultUser);
 			} else {
 				//create user
 				$requestPost = new stdClass();
@@ -566,7 +578,6 @@
 //second parameter is listAllMetadataInJson ( = true) - it is needed if we want to sync afterwards. The syncList includes all necessary information about one organization
 
 $syncListJson = $syncCkanClass->getSyncListJson($departmentsArray, true);
-
 $syncList = json_decode($syncListJson);
 if ($syncList->success = true) {
     foreach ($syncList->result->geoportal_organization as $orga) {

Deleted: trunk/mapbender/tools/monitorCapabilities.sh
===================================================================
--- trunk/mapbender/tools/monitorCapabilities.sh	2019-03-07 15:50:25 UTC (rev 10069)
+++ trunk/mapbender/tools/monitorCapabilities.sh	2019-03-07 17:05:02 UTC (rev 10070)
@@ -1,3 +0,0 @@
-. /etc/profile
-cd /data/mapbender/tools/
-[ -f /tmp/wmsmonitorlock ] && : || /usr/bin/php5 /data/mapbender/tools/mod_monitorCapabilities_main.php group:36 > /dev/null

Added: trunk/mapbender/tools/monitorCapabilities.sh-dist
===================================================================
--- trunk/mapbender/tools/monitorCapabilities.sh-dist	                        (rev 0)
+++ trunk/mapbender/tools/monitorCapabilities.sh-dist	2019-03-07 17:05:02 UTC (rev 10070)
@@ -0,0 +1,3 @@
+. /etc/profile
+cd /data/mapbender/tools/
+[ -f /tmp/wmsmonitorlock ] && : || /usr/bin/php5 /data/mapbender/tools/mod_monitorCapabilities_main.php group:36 > /dev/null



More information about the Mapbender_commits mailing list