Hi Jeroen, that's useful to get the metadata based on the uuid.
The change is using the DB to search for the uuid. And the uuid is also
indexed by lucene.
Could we have in some configuration (harvesting? gast import/export?
migration), a uuid in the xml different from the uuid in the metadata
table ?
Francois
ticheler@anonymised.com wrote:
Revision: 1187
http://geonetwork.svn.sourceforge.net/geonetwork/?rev=1187&view=rev
Author: ticheler
Date: 2008-03-05 07:59:04 -0800 (Wed, 05 Mar 2008)Log Message:
-----------
Added the option to retrieve metadata records based on the uuid (using the uuid as parameter on metadata.show)Modified Paths:
--------------
trunk/src/org/fao/geonet/kernel/DataManager.java
trunk/src/org/fao/geonet/services/metadata/Show.javaModified: trunk/src/org/fao/geonet/kernel/DataManager.java
--- trunk/src/org/fao/geonet/kernel/DataManager.java 2008-03-04 16:10:10 UTC (rev 1186)
+++ trunk/src/org/fao/geonet/kernel/DataManager.java 2008-03-05 15:59:04 UTC (rev 1187)
@@ -480,7 +480,19 @@return record.getChildText("id");
}
+
+ //--------------------------------------------------------------------------+ public String getMetadataId(ServiceContext srvContext, String uuid) throws Exception {
+ Dbms dbms = (Dbms) srvContext.getResourceManager().open(Geonet.Res.MAIN_DB);
+ String query = "SELECT id FROM Metadata WHERE uuid=?";
+ List list = dbms.select(query, uuid).getChildren();
+ if (list.size() == 0)
+ return null;
+ Element record = (Element) list.get(0);
+ return record.getChildText("id");
+ }
+
//--------------------------------------------------------------------------public String getMetadataUuid(Dbms dbms, String id) throws Exception
Modified: trunk/src/org/fao/geonet/services/metadata/Show.java
--- trunk/src/org/fao/geonet/services/metadata/Show.java 2008-03-04 16:10:10 UTC (rev 1186)
+++ trunk/src/org/fao/geonet/services/metadata/Show.java 2008-03-05 15:59:04 UTC (rev 1187)
@@ -23,6 +23,7 @@package org.fao.geonet.services.metadata;
+import jeeves.exceptions.MissingParameterEx;
import jeeves.interfaces.Service;
import jeeves.resources.dbms.Dbms;
import jeeves.server.ServiceConfig;
@@ -82,13 +83,32 @@
GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
DataManager dm = gc.getDataManager();- String id = Util.getParam(params, Params.ID);
-
+ // the metadata ID
+ String id;
+
+ // does the request contain a UUID ?
+ try {
+ String uuid = Util.getParam(params, Params.UUID);
+ // lookup ID by UUID
+ id = dm.getMetadataId(context, uuid);
+ }
+ catch(MissingParameterEx x) {
+ // request does not contain UUID; use ID from request
+ try {
+ id = Util.getParam(params, Params.ID);
+ }
+ // request does not contain ID
+ catch(MissingParameterEx xx) {
+ // give up
+ throw new Exception("Request must contain a UUID or an ID");
+ }
+ }
+
Lib.resource.checkPrivilege(context, id, AccessManager.OPER_VIEW);//-----------------------------------------------------------------------
//--- get metadata
-
+
Element elMd = dm.getMetadata(context, id, false);if (elMd == null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
GeoNetwork-commit mailing list
GeoNetwork-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-commit