Project

General

Profile

1
package edu.ucsb.nceas.metacat.admin.upgrade;
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: jones $'
10
 *     '$Date: 2012-01-20 22:46:38 -0800 (Fri, 20 Jan 2012) $'
11
 * '$Revision: 6933 $'
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 edu.ucsb.nceas.metacat.admin.AdminException;
30
import edu.ucsb.nceas.metacat.properties.PropertyService;
31
import edu.ucsb.nceas.utilities.SortedProperties;
32

    
33
public class Upgrade2_0_0 implements UpgradeUtilityInterface {
34

    
35
    public boolean upgrade() throws AdminException {
36
        boolean success = true;
37
        
38
        // empty replicated files
39
        UpgradeEmptyReplicatedDataFile emptyDataUpgrader = new UpgradeEmptyReplicatedDataFile();
40
        success = emptyDataUpgrader.upgrade();
41
        
42
        // node data datetime
43
        UpgradeNodeDataDatetime dateTimeUpgrade = new UpgradeNodeDataDatetime();
44
        success = success && dateTimeUpgrade.upgrade();
45
        
46
        // dataone system metadata generation
47
        GenerateSystemMetadata systemMetadataUpgrade = new GenerateSystemMetadata();
48
        systemMetadataUpgrade.upgrade();  // TODO:  why aren't we checking success return value here?
49
        
50
        // Optionally upgrade GUIDs to use DOI syntax if configured
51
        GenerateGlobalIdentifiers globalIDUpgrade = new GenerateGlobalIdentifiers();
52
        success = success && globalIDUpgrade.upgrade();
53

    
54
    	return success;
55
    }
56
    
57
    public static void main(String [] ags){
58

    
59
        try {
60
        	// set up the properties based on the test/deployed configuration of the workspace
61
        	SortedProperties testProperties = 
62
				new SortedProperties("test/test.properties");
63
			testProperties.load();
64
			String metacatContextDir = testProperties.getProperty("metacat.contextDir");
65
			PropertyService.getInstance(metacatContextDir + "/WEB-INF");
66
			// now run it
67
            Upgrade2_0_0 upgrader = new Upgrade2_0_0();
68
	        upgrader.upgrade();
69
	        
70
        } catch (Exception ex) {
71
            System.out.println("Exception:" + ex.getMessage());
72
            ex.printStackTrace();
73
        }
74
    }
75
}
(5-5/8)