1 |
5523
|
berkley
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Copyright: 2000 Regents of the University of California and the
|
4 |
|
|
* National Center for Ecological Analysis and Synthesis
|
5 |
|
|
*
|
6 |
|
|
* '$Author: $'
|
7 |
|
|
* '$Date: 2009-06-13 15:28:13 +0300 $'
|
8 |
|
|
*
|
9 |
|
|
* This program is free software; you can redistribute it and/or modify
|
10 |
|
|
* it under the terms of the GNU General Public License as published by
|
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
12 |
|
|
* (at your option) any later version.
|
13 |
|
|
*
|
14 |
|
|
* This program is distributed in the hope that it will be useful,
|
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
* GNU General Public License for more details.
|
18 |
|
|
*
|
19 |
|
|
* You should have received a copy of the GNU General Public License
|
20 |
|
|
* along with this program; if not, write to the Free Software
|
21 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22 |
|
|
*/
|
23 |
|
|
package edu.ucsb.nceas.metacat.dataone;
|
24 |
|
|
|
25 |
|
|
import java.io.*;
|
26 |
|
|
import java.util.*;
|
27 |
|
|
|
28 |
|
|
import edu.ucsb.nceas.metacat.properties.*;
|
29 |
|
|
|
30 |
|
|
import org.apache.log4j.Logger;
|
31 |
|
|
import org.dataone.service.types.*;
|
32 |
|
|
|
33 |
|
|
import edu.ucsb.nceas.metacat.properties.PropertyService;
|
34 |
|
|
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
|
35 |
|
|
|
36 |
|
|
/**
|
37 |
|
|
* @author berkley
|
38 |
|
|
* A class to determine data types for metadata documents
|
39 |
|
|
*/
|
40 |
|
|
public class MetadataTypeRegister
|
41 |
|
|
{
|
42 |
|
|
private static Logger log = null;
|
43 |
|
|
|
44 |
|
|
public static boolean isMetadataType(ObjectFormat format)
|
45 |
|
|
{
|
46 |
|
|
log = Logger.getLogger(MetadataTypeRegister.class);
|
47 |
|
|
if(format == null)
|
48 |
|
|
{
|
49 |
|
|
return false;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
try
|
53 |
|
|
{
|
54 |
|
|
Map<String, String> types = PropertyService.getPropertiesByGroup("dataone");
|
55 |
|
|
//System.out.println("types: " + types.toString());
|
56 |
|
|
Iterator<String> vals = types.values().iterator();
|
57 |
|
|
//System.out.println("MetadataTypeRegister: looking through dataone types for type " + format.toString());
|
58 |
|
|
while(vals.hasNext())
|
59 |
|
|
{
|
60 |
|
|
String val = vals.next();
|
61 |
|
|
String ofVal = format.toString();
|
62 |
5549
|
berkley
|
//System.out.println("val: " + val);
|
63 |
5523
|
berkley
|
if(val.trim().equals(ofVal.trim()))
|
64 |
|
|
{
|
65 |
|
|
//System.out.println("returning true");
|
66 |
|
|
log.info("type " + val + " IS a dataone metadata type");
|
67 |
|
|
return true;
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
}
|
71 |
|
|
catch(PropertyNotFoundException pnfe)
|
72 |
|
|
{
|
73 |
|
|
log.error("Could not find the property 'dataone': " + pnfe.getMessage());
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
if(format != null)
|
77 |
|
|
{
|
78 |
|
|
log.info("type " + format.toString() + " is NOT a dataone metadata type");
|
79 |
|
|
}
|
80 |
|
|
else
|
81 |
|
|
{
|
82 |
|
|
log.info("A null format is not a dataone metadata type");
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
return false;
|
86 |
|
|
}
|
87 |
|
|
}
|