source: main/trunk/gli/src/org/greenstone/gatherer/metadata/ProfileXMLFileManager.java@ 29793

Last change on this file since 29793 was 10006, checked in by mdewsnip, 19 years ago

Moved Utility.parse to XMLTools.parseXMLFile, as part of tidying up the Utility class.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/**
2 *############################################################################
3 * A component of the Greenstone Librarian Interface, part of the Greenstone
4 * digital library suite from the New Zealand Digital Library Project at the
5 * University of Waikato, New Zealand.
6 *
7 * Author: Michael Dewsnip, NZDL Project, University of Waikato, NZ
8 *
9 * Copyright (C) 2004 New Zealand Digital Library Project
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *############################################################################
25 */
26
27package org.greenstone.gatherer.metadata;
28
29
30import java.io.*;
31import java.util.*;
32import org.greenstone.gatherer.util.XMLTools;
33
34
35/** This class is a static class that manages the profile.xml file */
36public class ProfileXMLFileManager
37{
38 static private ProfileXMLFile profile_xml_file = null;
39
40
41 static public void clearProfileXMLFile()
42 {
43 profile_xml_file = null;
44 }
45
46
47 static public void loadProfileXMLFile(File directory)
48 {
49 // Make sure the directory (metadata) exists
50 if (directory.exists() == false) {
51 directory.mkdir();
52 }
53
54 File profile_xml_file_file = new File(directory, "profile.xml");
55 if (!profile_xml_file_file.exists()) {
56 // Create a new (empty) profile.xml file in this directory...
57 XMLTools.writeXMLFile(profile_xml_file_file, XMLTools.parseXMLFile("xml/profile.xml", true));
58 }
59
60 profile_xml_file = new ProfileXMLFile(profile_xml_file_file.getAbsolutePath());
61 }
62
63
64 static public String getMetadataElementFor(String metadata_element_name_full)
65 {
66 if (profile_xml_file == null) {
67 return null;
68 }
69
70 return profile_xml_file.getMetadataElementFor(metadata_element_name_full);
71 }
72
73
74 static public HashMap getMetadataMapping()
75 {
76 if (profile_xml_file == null) {
77 return null;
78 }
79
80 return profile_xml_file.getMetadataMapping();
81 }
82
83
84 static public void mapElement(String metadata_element_name_full, String target_metadata_element_name_full)
85 {
86 if (profile_xml_file != null) {
87 profile_xml_file.mapElement(metadata_element_name_full, target_metadata_element_name_full);
88 }
89 }
90}
Note: See TracBrowser for help on using the repository browser.