[Mapbender-commits] r7887 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Jun 27 09:31:39 EDT 2011


Author: armin11
Date: 2011-06-27 06:31:39 -0700 (Mon, 27 Jun 2011)
New Revision: 7887

Modified:
   trunk/mapbender/http/plugins/mb_metadata_server.php
Log:
Bugfix. Stores now the metadata xml to tmp folder before parsing it. But there is a further problem: Some metadata can be parsed, other cannot :-(

Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php	2011-06-24 08:43:03 UTC (rev 7886)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php	2011-06-27 13:31:39 UTC (rev 7887)
@@ -746,19 +746,35 @@
 			$metadataConnector = new connector();
 			$metadataConnector->set("timeOut", "5");
 			$metaData = $metadataConnector->load($link);
+			//$e = new mb_exception($metaData);
 			if (!$metaData) {
-    				$ajaxResponse->setSuccess(false);
-				$ajaxResponse->setMessage("Could not load data via resolving link location!");
-				break;
+    				abort(_mb("Could not load metadata from source url!"));
 			}
+
+			//***
+			//write metadata to temporary file:
+			$randomFileId = new Uuid();
+				
+			$tmpMetadataFile = fopen(TMPDIR.'/link_metadata_file_'.$randomFileId.'.xml', 'w');
+			fwrite($tmpMetadataFile, $metaData);
+			fclose($tmpMetadataFile);
+			$e = new mb_exception("File which has been written: link_metadata_file_".$randomFileId.".xml");
+			//read out objects from xml structure
+			if (file_exists(TMPDIR.'/link_metadata_file_'.$randomFileId.'.xml')) {
+				$iso19139Xml=simplexml_load_file(TMPDIR.'/link_metadata_file_'.$randomFileId.'.xml');
+				//$metaData = file_get_contents(TMPDIR.'/link_metadata_file_'.$randomFileId.'.xml');
+			} else {
+				abort(_mb("Temporary file could not be parsed!"));
+			}
+
 			//$metaData = $metadataConnector->file;
 			//parse metadata
-			try {
+			/*try {
 				$iso19139Xml =  new SimpleXMLElement($metaData);
 			}
 			catch (Exception $e) {
 				abort(_mb("Parsing ISO19139 XML failed!"));
-			}
+			}*/
 			if ($iso19139Xml != false) {
 				//get elements for database from xml by using xpath
 				//uuid
@@ -779,11 +795,11 @@
 				if (isset($codeSpace[0]) && isset($code[0]) && $codeSpace[0] != '' && $code[0] != '') {
 						
 					$datasetid = $codeSpace[0]."#".$code[0];
-					$e = new mb_notice("class_wms.php: datasetid: ".$datasetid);
+					$e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
 				} else {
 						
 					$datasetid = 'undefined';# in sense of INSPIRE TODO control MD_Identifier too!
-					$e = new mb_notice("class_wms.php: datasetid: ".$datasetid);
+					$e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
 				}
 				//abstract
 				$abstract = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
@@ -821,6 +837,7 @@
 				}
 			
 			} else {
+				abort(_mb("Problem with parsing the XML structure with SimpleXML! Record was not inserted into database! Ask your administrator."));
 				//give back error message - cause parsing has problems
 			}
 		} else { //fill only links into db - do not try to load data



More information about the Mapbender_commits mailing list