/** * '$RCSfile: XSLTransform.java,v $' * Copyright: 2003 Regents of the University of California and the * National Center for Ecological Analysis and Synthesis * * '$Author: jones $' * '$Date: 2003/08/18 20:27:03 $' * '$Revision: 1.4 $' * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package edu.ucsb.nceas.metacat.util; import java.io.*; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; import org.apache.log4j.Logger; import edu.ucsb.nceas.metacat.DocumentImpl; import edu.ucsb.nceas.metacat.DocumentImplWrapper; import edu.ucsb.nceas.metacat.McdbException; import edu.ucsb.nceas.metacat.database.DBConnection; import edu.ucsb.nceas.metacat.database.DBConnectionPool; import edu.ucsb.nceas.metacat.properties.PropertyService; import edu.ucsb.nceas.metacat.service.XMLSchemaService; import javax.xml.transform.TransformerFactory; import javax.xml.transform.Transformer; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.URIResolver; import org.dataone.service.types.v1.Checksum; import org.ecoinformatics.eml.EMLParser; /** * A Class that transforms older eml version to newer eml version utitlizing XSL style sheets. */ public class EMLVersionsTransformer { private static org.apache.log4j.Logger logMetacat = Logger.getLogger(EMLVersionsTransformer.class); private static String eml210StyleFile = null; static{ try { eml210StyleFile =PropertyService.getProperty("application.deployDir")+"/"+PropertyService .getProperty("application.context")+ "/style/common/eml201to210.xsl"; //eml201to210.xsl place } catch(Exception e) { logMetacat.warn("Couldn't get eml201to210.xsl stylesheet"); } } private static String DOT = "."; private static int CAP = 100000; // How many documents you want to transform. /** * Public constructor because all methods are static and do not need * an instance. */ public EMLVersionsTransformer() { } /** * Method to upgrade old versions of eml to new version */ public void upgrade() { upgradeEML200ToEML210(); } /* * Upgrade every eml200 or eml210 documents into eml210 */ private void upgradeEML200ToEML210() { Vector list = getEML2DocList(); if(list != null) { // Choose the smaller value between the size of vector and CAP int size = list.size(); if (size > CAP) { size = CAP; } for(int i=0; i