01: //=============================================================================
02: //=== Copyright (C) 2001-2007 Food and Agriculture Organization of the
03: //=== United Nations (FAO-UN), United Nations World Food Programme (WFP)
04: //=== and United Nations Environment Programme (UNEP)
05: //===
06: //=== This program is free software; you can redistribute it and/or modify
07: //=== it under the terms of the GNU General Public License as published by
08: //=== the Free Software Foundation; either version 2 of the License, or (at
09: //=== your option) any later version.
10: //===
11: //=== This program is distributed in the hope that it will be useful, but
12: //=== WITHOUT ANY WARRANTY; without even the implied warranty of
13: //=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: //=== General Public License for more details.
15: //===
16: //=== You should have received a copy of the GNU General Public License
17: //=== along with this program; if not, write to the Free Software
18: //=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19: //===
20: //=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
21: //=== Rome - Italy. email: geonetwork@osgeo.org
22: //==============================================================================
23:
24: package org.fao.geonet.kernel.mef;
25:
26: import java.io.File;
27: import jeeves.exceptions.BadInputEx;
28: import jeeves.exceptions.BadParameterEx;
29: import jeeves.exceptions.MissingParameterEx;
30: import jeeves.server.context.ServiceContext;
31: import java.io.IOException;
32: import org.jdom.JDOMException;
33: import jeeves.exceptions.BadFormatEx;
34:
35: //=============================================================================
36:
37: public class MEFLib {
38: //--------------------------------------------------------------------------
39: //---
40: //--- API methods
41: //---
42: //--------------------------------------------------------------------------
43:
44: public static int doImport(ServiceContext context, File mefFile)
45: throws Exception {
46: return Importer.doImport(context, mefFile);
47: }
48:
49: //--------------------------------------------------------------------------
50:
51: public static String doExport(ServiceContext context, String uuid,
52: String format, boolean skipUUID) throws Exception {
53: return Exporter.doExport(context, uuid, Format.parse(format),
54: skipUUID);
55: }
56:
57: //--------------------------------------------------------------------------
58:
59: public static void visit(File mefFile, MEFVisitor v)
60: throws Exception {
61: Visitor.visit(mefFile, v);
62: }
63:
64: //--------------------------------------------------------------------------
65: //---
66: //--- Types
67: //---
68: //--------------------------------------------------------------------------
69:
70: enum Format {
71: SIMPLE, PARTIAL, FULL;
72:
73: //------------------------------------------------------------------------
74:
75: public static Format parse(String format) throws BadInputEx {
76: if (format == null)
77: throw new MissingParameterEx("format");
78:
79: if (format.equals("simple"))
80: return SIMPLE;
81: if (format.equals("partial"))
82: return PARTIAL;
83: if (format.equals("full"))
84: return FULL;
85:
86: throw new BadParameterEx("format", format);
87: }
88:
89: //------------------------------------------------------------------------
90:
91: public String toString() {
92: return super .toString().toLowerCase();
93: }
94: };
95: }
96:
97: //=============================================================================
|