1
|
package edu.ucsb.nceas.metacat.admin.upgrade.dataone;
|
2
|
/**
|
3
|
* '$RCSfile$'
|
4
|
* Purpose: A Class for upgrading the database to version 1.5
|
5
|
* Copyright: 2000 Regents of the University of California and the
|
6
|
* National Center for Ecological Analysis and Synthesis
|
7
|
* Authors: Saurabh Garg
|
8
|
*
|
9
|
* '$Author: leinfelder $'
|
10
|
* '$Date: 2012-02-08 10:58:29 -0800 (Wed, 08 Feb 2012) $'
|
11
|
* '$Revision: 6999 $'
|
12
|
*
|
13
|
* This program is free software; you can redistribute it and/or modify
|
14
|
* it under the terms of the GNU General Public License as published by
|
15
|
* the Free Software Foundation; either version 2 of the License, or
|
16
|
* (at your option) any later version.
|
17
|
*
|
18
|
* This program is distributed in the hope that it will be useful,
|
19
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
* GNU General Public License for more details.
|
22
|
*
|
23
|
* You should have received a copy of the GNU General Public License
|
24
|
* along with this program; if not, write to the Free Software
|
25
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
26
|
*/
|
27
|
|
28
|
|
29
|
import java.util.Collections;
|
30
|
import java.util.List;
|
31
|
|
32
|
import org.apache.commons.logging.Log;
|
33
|
import org.apache.commons.logging.LogFactory;
|
34
|
|
35
|
import edu.ucsb.nceas.metacat.DBUtil;
|
36
|
import edu.ucsb.nceas.metacat.admin.AdminException;
|
37
|
import edu.ucsb.nceas.metacat.admin.upgrade.UpgradeUtilityInterface;
|
38
|
import edu.ucsb.nceas.metacat.dataone.SystemMetadataFactory;
|
39
|
import edu.ucsb.nceas.metacat.properties.PropertyService;
|
40
|
import edu.ucsb.nceas.utilities.SortedProperties;
|
41
|
|
42
|
public class GenerateORE implements UpgradeUtilityInterface {
|
43
|
|
44
|
private static Log log = LogFactory.getLog(GenerateORE.class);
|
45
|
|
46
|
public boolean upgrade() throws AdminException {
|
47
|
boolean success = true;
|
48
|
|
49
|
// include ORE, data, for this server only
|
50
|
boolean includeOre = true;
|
51
|
boolean downloadData = true;
|
52
|
int serverLocation = 1;
|
53
|
|
54
|
try {
|
55
|
// get only local ids for this server
|
56
|
List<String> idList = DBUtil.getAllDocidsByType(null, true, serverLocation);
|
57
|
Collections.sort(idList);
|
58
|
|
59
|
// generate based on this list
|
60
|
SystemMetadataFactory.generateSystemMetadata(idList, includeOre, downloadData);
|
61
|
} catch (Exception e) {
|
62
|
String msg = "Problem generating missing system metadata: " + e.getMessage();
|
63
|
log.error(msg, e);
|
64
|
success = false;
|
65
|
throw new AdminException(msg);
|
66
|
}
|
67
|
return success;
|
68
|
}
|
69
|
|
70
|
public static void main(String [] ags){
|
71
|
|
72
|
try {
|
73
|
// set up the properties based on the test/deployed configuration of the workspace
|
74
|
SortedProperties testProperties =
|
75
|
new SortedProperties("test/test.properties");
|
76
|
testProperties.load();
|
77
|
String metacatContextDir = testProperties.getProperty("metacat.contextDir");
|
78
|
PropertyService.getInstance(metacatContextDir + "/WEB-INF");
|
79
|
// now run it
|
80
|
GenerateORE upgrader = new GenerateORE();
|
81
|
upgrader.upgrade();
|
82
|
|
83
|
} catch (Exception ex) {
|
84
|
System.out.println("Exception:" + ex.getMessage());
|
85
|
ex.printStackTrace();
|
86
|
}
|
87
|
}
|
88
|
}
|