Changeset 6473


Ignore:
Timestamp:
Jun 11, 2014, 3:48:39 PM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1809: Upgrade 3-rd party libraries

Updated JDOM to 2.0.5. This is a not a plug-in replacement for JDOM 1.1. Since we expose some JDOM 1.1 classes in XMLUtil and other classes, we will ship both JDOM versions in BASE 3.4. All places which use JDOM 1.1 have been deprecated and they will be removed in BASE 3.5.

Location:
trunk
Files:
2 added
1 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/.classpath

    r6470 r6473  
    2323  <classpathentry kind="lib" path="lib/dist/httpcore-4.2.3.jar"/>
    2424  <classpathentry kind="lib" path="lib/dist/jcommon-1.0.17.jar"/>
    25   <classpathentry kind="lib" path="lib/dist/jdom-1.1.3.jar"/>
    2625  <classpathentry kind="lib" path="lib/dist/jfreechart-1.0.14.jar"/>
    2726  <classpathentry kind="lib" path="lib/dist/json-simple-1.1.1.jar"/>
     
    3231  <classpathentry kind="lib" path="lib/dist/hibernate-core-4.3.5.Final.jar"/>
    3332  <classpathentry kind="lib" path="lib/dist/postgresql-9.3-1101.jdbc41.jar"/>
     33  <classpathentry kind="lib" path="lib/dist/jdom-2.0.5.jar"/>
     34  <classpathentry kind="lib" path="lib/dist/jdom-1.1.3.jar"/>
    3435  <classpathentry kind="output" path="xbin"/>
    3536</classpath>
  • trunk/doc/3rd-party-components.txt

    r6471 r6473  
    7979
    8080More info : http://www.jdom.org/
    81 Version   : 1.1.3
     81Version   : 2.0.5 and 1.1.3 (deprecated)
    8282License   : Apache-style open source license (jdom.license.txt)
    83 Jar files : jdom-1.1.3.jar, jaxen-1.1.1.jar
     83Jar files : jdom-2.0.5.jar, jdom-1.1.3.jar, jaxen-1.1.6.jar
    8484
    8585
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/ServletLoader.java

    r5689 r6473  
    3131import net.sf.basedb.util.ClassUtil;
    3232import net.sf.basedb.util.Values;
    33 import net.sf.basedb.util.XMLUtil;
     33import net.sf.basedb.util.XmlUtil2;
    3434import net.sf.basedb.util.extensions.xml.XmlLoader;
    3535
    36 import org.jdom.Document;
    37 import org.jdom.Element;
    38 import org.jdom.JDOMException;
    39 import org.jdom.Namespace;
     36import org.jdom2.Document;
     37import org.jdom2.Element;
     38import org.jdom2.JDOMException;
     39import org.jdom2.Namespace;
    4040
    4141/**
     
    107107  public void loadXmlFile(InputStream xmlFile, String filename,
    108108      ClassLoader classLoader, boolean clear)
    109     throws JDOMException, IOException, ClassNotFoundException, NoSuchMethodException,
     109    throws IOException, ClassNotFoundException, NoSuchMethodException,
    110110      IllegalAccessException
    111111  {
     
    126126  */
    127127  public void validateXmlFile(InputStream xmlFile, String filename)
    128     throws IOException, JDOMException
     128    throws IOException
    129129  {
    130130    validatedDom = null;
     
    195195  */
    196196  protected Document loadDocument(InputStream xmlFile, String filename)
    197     throws IOException, JDOMException
    198   {
    199     return XMLUtil.getSchemaValidatedXML(xmlFile, filename, namespace, schemaFileURL);
     197    throws IOException
     198  {
     199    return XmlUtil2.getSchemaValidatedXML(xmlFile, filename, namespace, schemaFileURL);
    200200  }
    201201 
     
    203203    Load the servlet definitions from an XML document.
    204204  */
    205   @SuppressWarnings("unchecked")
    206205  protected int loadServlets(Document dom, ClassLoader classLoader)
    207206    throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException
  • trunk/src/clients/web/net/sf/basedb/clients/web/plugins/XMLTemplate.java

    r6127 r6473  
    3030import net.sf.basedb.core.Item;
    3131
    32 import org.jdom.DocType;
    33 import org.jdom.Element;
    34 import org.jdom.output.Format;
    35 import org.jdom.output.XMLOutputter;
     32import org.jdom2.DocType;
     33import org.jdom2.Element;
     34import org.jdom2.output.Format;
     35import org.jdom2.output.XMLOutputter;
    3636
    3737/**
  • trunk/src/clients/web/net/sf/basedb/clients/web/servlet/RssNewsFeed.java

    r5479 r6473  
    3535import javax.servlet.http.HttpServletResponse;
    3636
    37 import org.jdom.Document;
    38 import org.jdom.Element;
    39 import org.jdom.output.Format;
    40 import org.jdom.output.XMLOutputter;
     37import org.jdom2.Document;
     38import org.jdom2.Element;
     39import org.jdom2.output.Format;
     40import org.jdom2.output.XMLOutputter;
    4141
    4242import net.sf.basedb.core.Application;
  • trunk/src/core/net/sf/basedb/core/ExtendedProperties.java

    r6444 r6473  
    2626import net.sf.basedb.core.dbengine.DbEngine;
    2727import net.sf.basedb.util.Values;
    28 import net.sf.basedb.util.XMLUtil;
     28import net.sf.basedb.util.XmlUtil2;
    2929
    3030import java.util.HashSet;
     
    3737import java.net.URL;
    3838
    39 import org.jdom.Document;
    40 import org.jdom.Element;
     39import org.jdom2.Document;
     40import org.jdom2.Element;
    4141
    4242/**
     
    120120      {
    121121        log.debug("Loading extended properties from file: " + xmlFile);
    122         Document dom = XMLUtil.getValidatedXml(ExtendedProperties.class.getResource(xmlFile), dtdFile);
     122        Document dom = XmlUtil2.getValidatedXml(ExtendedProperties.class.getResource(xmlFile), dtdFile);
    123123        loadClasses(usedNames, dom, xmlFile);
    124124        log.info("Loaded extended properties from file: " + xmlFile);
     
    200200    variable.
    201201  */
    202   @SuppressWarnings("unchecked")
    203202  private static void loadClasses(Set<String> usedNames, Document dom, String xmlFile)
    204203  {
    205     List<Element> classTags = (List<Element>)dom.getRootElement().getChildren("class");
     204    List<Element> classTags = dom.getRootElement().getChildren("class");
    206205    for (Element el : classTags)
    207206    {
     
    220219    put the list in the {@link #allProperties} variable.
    221220  */
    222   @SuppressWarnings("unchecked")
    223221  private static void loadProperties(Set<String> usedNames, Element classElement, String xmlFile)
    224222  {
    225223    String className = classElement.getAttributeValue("name");
    226224    List<ExtendedProperty> properties = allProperties.get(className);
    227     List<Element> children = (List<Element>)classElement.getChildren("property");
     225    List<Element> children = classElement.getChildren("property");
    228226    DbEngine engine = HibernateUtil.getDbEngine();
    229227    for (Element property : children)
     
    258256      usedNames.add(idColumn);
    259257      String description = Values.getStringOrNull(property.getAttributeValue("description"));
    260       int length = XMLUtil.getIntAttribute(property, "length", 255);
     258      int length = XmlUtil2.getIntAttribute(property, "length", 255);
    261259      Type type = Type.fromValue(property.getAttributeValue("type"));
    262260      if (type == Type.STRING && length > 255) type = Type.TEXT;
    263       boolean nullable = XMLUtil.getBooleanAttribute(property, "null", true);
    264       boolean insertable = XMLUtil.getBooleanAttribute(property, "insert", true);
    265       boolean updateable = XMLUtil.getBooleanAttribute(property, "update", true);
    266       boolean restrictedEdit = XMLUtil.getBooleanAttribute(property, "restricted-edit", false);
     261      boolean nullable = XmlUtil2.getBooleanAttribute(property, "null", true);
     262      boolean insertable = XmlUtil2.getBooleanAttribute(property, "insert", true);
     263      boolean updateable = XmlUtil2.getBooleanAttribute(property, "update", true);
     264      boolean restrictedEdit = XmlUtil2.getBooleanAttribute(property, "restricted-edit", false);
    267265      String avgMethod = property.getAttributeValue("averagemethod");
    268266      Formula.AverageMethod averageMethod = null;
     
    280278      }
    281279     
    282       List<Element> links = (List<Element>)property.getChildren("link");
     280      List<Element> links = property.getChildren("link");
    283281      List<ExtendedPropertyLinker> epLinks = null;
    284282      if (links != null && links.size() > 0)
  • trunk/src/core/net/sf/basedb/core/HibernateUtil.java

    r6469 r6473  
    5050import net.sf.basedb.util.FileUtil;
    5151import net.sf.basedb.util.RegexpFileFilter;
    52 import net.sf.basedb.util.XMLUtil;
     52import net.sf.basedb.util.XmlUtil2;
    5353
    5454import java.util.ArrayList;
     
    6868import java.net.URL;
    6969
    70 import org.jdom.Document;
    71 import org.jdom.Element;
    72 import org.jdom.output.DOMOutputter;
     70import org.jdom2.Document;
     71import org.jdom2.Element;
     72import org.jdom2.output.DOMOutputter;
    7373import org.hibernate.Hibernate;
    7474import org.hibernate.Interceptor;
     
    307307      {
    308308        log.info("Loading mapping file: " + url);
    309         Document dom = XMLUtil.getValidatedXml(url, dtdFile);
     309        Document dom = XmlUtil2.getValidatedXml(url, dtdFile);
    310310        manipulateDocument(dom);
    311311        cfg.addDocument(out.output(dom));
     
    513513        try
    514514        {
    515           Document dom = XMLUtil.getValidatedXml(templateFile, dtdFile);
     515          Document dom = XmlUtil2.getValidatedXml(templateFile, dtdFile);
    516516          Element clazz = dom.getRootElement().getChild("class");
    517517          // Specify an entity name and database table for the raw data type
     
    581581   
    582582    // Find the class/property/column[name=`symbol`] tag
    583     Iterator match = classTag.getDescendants(
    584       new org.jdom.filter.Filter()
     583    Iterator<Element> match = classTag.getDescendants(
     584      new org.jdom2.filter.AbstractFilter<Element>()
    585585      {
    586586        private static final long serialVersionUID = -2876632679035736428L;
    587587        @Override
    588         public boolean matches(Object obj)
     588        public Element filter(Object obj)
    589589        {
    590           if (!(obj instanceof Element)) return false;
     590          if (!(obj instanceof Element)) return null;
    591591 
    592592          Element e = (Element)obj;
    593           return e.getName().equals("column") && e.getAttributeValue("name").equals("`symbol`");
     593          return e.getName().equals("column") && e.getAttributeValue("name").equals("`symbol`") ? e : null;
    594594        }
    595595      });
    596596    Element col = (Element)match.next();
    597     String sqlType = dbEngine.getCaseSensitiveVarchar(XMLUtil.getIntAttribute(col, "length", 255));
     597    String sqlType = dbEngine.getCaseSensitiveVarchar(XmlUtil2.getIntAttribute(col, "length", 255));
    598598    if (sqlType != null)
    599599    {
  • trunk/src/core/net/sf/basedb/core/Install.java

    r6468 r6473  
    6969import net.sf.basedb.util.FileUtil;
    7070import net.sf.basedb.util.Values;
    71 import net.sf.basedb.util.XMLUtil;
     71import net.sf.basedb.util.XmlUtil2;
    7272import net.sf.basedb.util.extensions.manager.Settings;
    7373import net.sf.basedb.util.extensions.xml.PluginInfo;
     
    8686import java.util.Set;
    8787
    88 import org.jdom.Document;
    89 import org.jdom.Element;
    90 import org.jdom.Namespace;
     88import org.jdom2.Document;
     89import org.jdom2.Element;
     90import org.jdom2.Namespace;
    9191
    9292/**
     
    13921392  }
    13931393 
    1394   @SuppressWarnings("unchecked")
    13951394  private static void installUnits(String xmlFile, boolean update)
    13961395  {
     
    14021401    try
    14031402    {
    1404       doc = XMLUtil.getSchemaValidatedXML(fileURL, namespace, schemaFileURL);
     1403      doc = XmlUtil2.getSchemaValidatedXML(fileURL, namespace, schemaFileURL);
    14051404    }
    14061405    catch (Exception ex)
     
    14131412    Namespace ns = root.getNamespace();
    14141413   
    1415     for (Element quantityElement : (List<Element>)root.getChildren("quantity", ns))
     1414    for (Element quantityElement : root.getChildren("quantity", ns))
    14161415    {
    14171416      String systemId = quantityElement.getAttributeValue("system-id");
     
    24592458    Create {@link PluginConfiguration}s from a XML file.
    24602459  */
    2461   @SuppressWarnings("unchecked")
    24622460  private static void createPluginConfigurations(String filePath, boolean update)
    24632461    throws BaseException
     
    24842482      }
    24852483     
    2486       List<Element> configurations = PluginConfiguration.loadXmlFile(Install.class.getResource(filePath).openStream(), filePath);
     2484      List<Element> configurations = PluginConfiguration.loadXmlFile2(Install.class.getResource(filePath).openStream(), filePath);
    24872485     
    24882486      for (Element configuration : configurations)
     
    25202518          config.setName(name);
    25212519          config.setDescription(description);
    2522           config.setParameterValues((List<Element>)configuration.getChildren("parameter"));
     2520          config.setParameterValues2((List<Element>)configuration.getChildren("parameter"));
    25232521        }       
    25242522        catch(Throwable ex)
  • trunk/src/core/net/sf/basedb/core/PluginConfiguration.java

    r6444 r6473  
    3535import net.sf.basedb.core.query.Hql;
    3636import net.sf.basedb.core.query.Expressions;
    37 import net.sf.basedb.util.XMLUtil;
     37import net.sf.basedb.util.XmlUtil2;
    3838
    3939import java.io.IOException;
     
    4848import java.util.Collections;
    4949
    50 import org.jdom.Document;
    51 import org.jdom.Element;
    52 import org.jdom.JDOMException;
     50import org.jdom2.Document;
     51import org.jdom2.Element;
     52//import org.jdom2.JDOMException;
    5353
    5454/**
     
    182182    @return A list with all &lt;configuration&gt; elements in the file
    183183    @since 3.0
     184    @deprecated In 3.4, use {@link #loadXmlFile2(InputStream, String)} instead
    184185  */
    185186  @SuppressWarnings("unchecked")
    186   public static List<Element> loadXmlFile(InputStream in, String fileName)
    187     throws IOException, JDOMException
     187  @Deprecated
     188  public static List<org.jdom.Element> loadXmlFile(InputStream in, String fileName)
     189    throws IOException, org.jdom.JDOMException
    188190  {
    189191    URL dtdURL = PluginConfiguration.class.getResource("/net/sf/basedb/core/dtd/plugin-configuration-file.dtd");
    190     Document doc = XMLUtil.getValidatedXML(in, dtdURL, fileName);
     192    org.jdom.Document doc = net.sf.basedb.util.XMLUtil.getValidatedXML(in, dtdURL, fileName);
     193    org.jdom.Element rootElement = doc.getRootElement();
     194    return (List<org.jdom.Element>)rootElement.getChildren();
     195  }
     196 
     197  /**
     198    Load a configurations xml file from the given stream.
     199    @param in The input stream to read from
     200    @param fileName The name of the originating file (optional)
     201    @return A list with all &lt;configuration&gt; elements in the file
     202    @since 3.4
     203  */
     204  public static List<Element> loadXmlFile2(InputStream in, String fileName)
     205    throws IOException
     206  {
     207    URL dtdURL = PluginConfiguration.class.getResource("/net/sf/basedb/core/dtd/plugin-configuration-file.dtd");
     208    Document doc = XmlUtil2.getValidatedXML(in, dtdURL, fileName);
    191209    Element rootElement = doc.getRootElement();
    192210    return (List<Element>)rootElement.getChildren();
     
    706724      @throws ClassNotFoundException If there is an error while trying to find the type of the parameters.
    707725      @since 3.0
     726      @deprecated In 3.4, use {@link #setParameterValues2} instead
    708727  */
    709728  @SuppressWarnings("unchecked")
    710   public void setParameterValues(List<Element> parameters)
     729  @Deprecated
     730  public void setParameterValues(List<org.jdom.Element> parameters)
    711731    throws ClassNotFoundException
    712732  {
    713733    checkPermission(Permission.WRITE);
    714734    // Set each configuration parameter for the plugin.
    715     for (Element parameter : parameters)
     735    for (org.jdom.Element parameter : parameters)
    716736    {
    717737      String name = parameter.getChildText("name");               
     
    734754 
    735755  /**
     756    Sets parameters for a PluginConfiguration from the elements in a xml
     757    configurations file.
     758   
     759      @param parameters A list of the parameters that shall be set to the configuration
     760      @throws ClassNotFoundException If there is an error while trying to find the type of the parameters.
     761      @since 3.4
     762  */
     763  @SuppressWarnings("unchecked")
     764  public void setParameterValues2(List<Element> parameters)
     765    throws ClassNotFoundException
     766  {
     767    checkPermission(Permission.WRITE);
     768    // Set each configuration parameter for the plugin.
     769    for (Element parameter : parameters)
     770    {
     771      String name = parameter.getChildText("name");               
     772      String cl = parameter.getChildText("class");
     773      String label = parameter.getChildText("label");
     774      if (label == null || label.length() == 0) label = name;   
     775      String description = parameter.getChildText("description");
     776      Class clazz = null;
     777      List values = null;
     778     
     779      if (cl.length() > 0)
     780      {
     781        clazz = Class.forName(cl);
     782        values = getValueList2(parameter, clazz);
     783        ParameterType pType = getParameterType(clazz, values);
     784        setParameterValues(name,label, description, pType, values);
     785      }
     786    }
     787  }
     788
     789 
     790  /**
    736791      Gets the list of values for a parameter from the XML-file.
    737792      Returns a list with parameter values.
    738793  */ 
    739794  @SuppressWarnings("unchecked")
    740   private <T> List<T> getValueList(Element parameter, Class<T> classType)
     795  @Deprecated
     796  private <T> List<T> getValueList(org.jdom.Element parameter, Class<T> classType)
    741797  {
    742     List<Element> children = (List<Element>)parameter.getChildren("value");
     798    List<org.jdom.Element> children = (List<org.jdom.Element>)parameter.getChildren("value");
    743799    List<T> values = new ArrayList<T>();
    744     for (Object ch : children)
    745     {
    746       String text = ((Element)ch).getText();
     800    for (org.jdom.Element ch : children)
     801    {
     802      String text = ch.getText();
    747803      if (classType.equals(Boolean.class)) values.add((T)Boolean.valueOf(text));
    748804      else if (classType.equals(Date.class)) values.add((T)DateUtil.parseString(text));
     
    755811  }
    756812 
     813  /**
     814      Gets the list of values for a parameter from the XML-file.
     815      Returns a list with parameter values.
     816  */
     817  @SuppressWarnings("unchecked")
     818  private <T> List<T> getValueList2(Element parameter, Class<T> classType)
     819  {
     820    List<Element> children = parameter.getChildren("value");
     821    List<T> values = new ArrayList<T>();
     822    for (Element ch : children)
     823    {
     824      String text = ch.getText();
     825      if (classType.equals(Boolean.class)) values.add((T)Boolean.valueOf(text));
     826      else if (classType.equals(Date.class)) values.add((T)DateUtil.parseString(text));
     827      else if (classType.equals(Double.class)) values.add((T)Double.valueOf(text));
     828      else if (classType.equals(Float.class)) values.add((T)Float.valueOf(text));
     829      else if (classType.equals(Long.class)) values.add((T)Long.valueOf(text));
     830      else if (classType.equals(String.class)) values.add((T)text);
     831    }
     832    return values;
     833  }
     834
    757835  /**
    758836      Gets the ParameterType to use with a class.
  • trunk/src/core/net/sf/basedb/core/PredefinedQuery.java

    r6444 r6473  
    2323package net.sf.basedb.core;
    2424
    25 import net.sf.basedb.util.XMLUtil;
     25import net.sf.basedb.util.XmlUtil2;
    2626
    2727import java.net.URL;
    2828import java.util.Arrays;
    2929
    30 import org.jdom.Document;
    31 import org.jdom.Element;
    32 import org.jdom.JDOMException;
    33 import org.jdom.xpath.XPath;
     30import org.jdom2.Document;
     31import org.jdom2.Element;
     32import org.jdom2.xpath.XPathExpression;
     33import org.jdom2.xpath.XPathFactory;
    3434
    3535/**
     
    106106    try
    107107    {
    108       commonDom = XMLUtil.getValidatedXml(PredefinedQuery.class.getResource(commonQueryFile), dtdFile);
     108      commonDom = XmlUtil2.getValidatedXml(PredefinedQuery.class.getResource(commonQueryFile), dtdFile);
    109109      log.info("Loaded predefined queries from file: " + commonQueryFile);
    110110      if (dialectQueryFile != null)
    111111      {
    112         dialectDom = XMLUtil.getValidatedXml(PredefinedQuery.class.getResource(dialectQueryFile), dtdFile);
     112        dialectDom = XmlUtil2.getValidatedXml(PredefinedQuery.class.getResource(dialectQueryFile), dtdFile);
    113113        log.info("Loaded predefined queries from file: " + dialectQueryFile);
    114114      }
     
    142142    throws BaseException
    143143  {
     144    XPathExpression findQuery = XPathFactory.instance().compile("//query[@id='"+name+"']");
     145 
    144146    Element query = null;
    145     try
    146     {
    147       XPath findQuery = XPath.newInstance("//query[@id='"+name+"']");
    148  
    149       if (dialectDom != null) query = (Element)findQuery.selectSingleNode(dialectDom);
    150       if (query == null) query = (Element)findQuery.selectSingleNode(commonDom);
    151     }
    152     catch (JDOMException ex)
    153     {
    154       throw new BaseException(ex);
    155     }
     147    if (dialectDom != null) query = (Element)findQuery.evaluateFirst(dialectDom);
     148    if (query == null) query = (Element)findQuery.evaluateFirst(commonDom);
     149   
    156150    if (query == null)
    157151    {
  • trunk/src/core/net/sf/basedb/core/Presets.java

    r6127 r6473  
    2222package net.sf.basedb.core;
    2323
    24 import net.sf.basedb.util.XMLUtil;
     24import net.sf.basedb.util.XmlUtil2;
    2525
    2626import java.util.ArrayList;
     
    3434import java.net.URL;
    3535
    36 import org.jdom.Document;
    37 import org.jdom.Element;
    38 import org.jdom.output.Format;
    39 import org.jdom.output.XMLOutputter;
     36import org.jdom2.Document;
     37import org.jdom2.Element;
     38import org.jdom2.output.Format;
     39import org.jdom2.output.XMLOutputter;
    4040
    4141/**
     
    9595    try
    9696    {
    97       Document dom = XMLUtil.getValidatedXml(xml, dtdFile);
     97      Document dom = XmlUtil2.getValidatedXml(xml, dtdFile);
    9898      loadPresets(dom);
    9999    }
     
    115115    try
    116116    {
    117       Document dom = XMLUtil.getValidatedXML(in, dtdFile, filename);
     117      Document dom = XmlUtil2.getValidatedXML(in, dtdFile, filename);
    118118      loadPresets(dom);
    119119    }
     
    156156  private Document buildDocument()
    157157  {
    158     Document dom = XMLUtil.createDom("presets", "presets.dtd");
     158    Document dom = XmlUtil2.createDom("presets", "presets.dtd");
    159159    Element root = dom.getRootElement();
    160160    if (defaultPreset != null)
     
    212212    Parse an XML Document and load all presets.
    213213  */
    214   @SuppressWarnings("unchecked")
    215214  private void loadPresets(Document dom)
    216215  {
     
    263262      @param preset
    264263    */
    265     @SuppressWarnings("unchecked")
    266264    private Preset(Element preset)
    267265    {
  • trunk/src/core/net/sf/basedb/core/RawDataTypes.java

    r6444 r6473  
    2828import net.sf.basedb.core.dbengine.DbEngine;
    2929import net.sf.basedb.util.Values;
    30 import net.sf.basedb.util.XMLUtil;
     30import net.sf.basedb.util.XmlUtil2;
    3131
    3232import java.util.Comparator;
     
    4343import java.util.Collection;
    4444
    45 import org.jdom.Document;
    46 import org.jdom.Element;
     45import org.jdom2.Document;
     46import org.jdom2.Element;
    4747
    4848/**
     
    165165      for (String xmlFile : files)
    166166      {
    167         Document dom = XMLUtil.getValidatedXml(RawDataTypes.class.getResource(xmlFile), dtdFile);
     167        Document dom = XmlUtil2.getValidatedXml(RawDataTypes.class.getResource(xmlFile), dtdFile);
    168168        loadRawDataTypes(dom, xmlFile);
    169169        log.info("Loaded raw data types from file: " + xmlFile);
     
    334334    {@link #rawDataTypes} map.
    335335  */
    336   @SuppressWarnings({"unchecked"})
    337336  private static void loadRawDataTypes(Document dom, String xmlFile)
    338337  {
     
    346345      String description = Values.getStringOrNull(el.getAttributeValue("description"));
    347346      String table = Values.getStringOrNull(el.getAttributeValue("table"));
    348       int channels = XMLUtil.getIntAttribute(el, "channels", 2);
     347      int channels = XmlUtil2.getIntAttribute(el, "channels", 2);
    349348     
    350349      if (!ExtendedProperty.isValidName(id))
     
    396395    return a list of {@link RawDataProperty} objects.
    397396  */
    398   @SuppressWarnings({"unchecked"})
    399397  private static List<RawDataProperty> loadProperties(Element rawDataTypeElement, int channels, String xmlFile)
    400398  {
     
    434432      String description = Values.getStringOrNull(property.getAttributeValue("description"));
    435433      Type type = Type.fromValue(property.getAttributeValue("type"));
    436       int length = XMLUtil.getIntAttribute(property, "length", 255);
     434      int length = XmlUtil2.getIntAttribute(property, "length", 255);
    437435      if (type == Type.STRING && length > 255) type = Type.TEXT;
    438       boolean nullable = XMLUtil.getBooleanAttribute(property, "null", true);
     436      boolean nullable = XmlUtil2.getBooleanAttribute(property, "null", true);
    439437      String avgMethod = property.getAttributeValue("averagemethod");
    440438      Formula.AverageMethod averageMethod = null;
     
    451449        averageMethod = Formula.AverageMethod.NONE;       
    452450      }
    453       int channel = XMLUtil.getIntAttribute(property, "channel", 0);
     451      int channel = XmlUtil2.getIntAttribute(property, "channel", 0);
    454452      if (channel < 0 || channel > channels)
    455453      {
     
    467465    return a list of {@link IntensityFormula} objects.
    468466  */
    469   @SuppressWarnings({"unchecked"})
    470467  private static List<IntensityFormula> loadIntensityFormulas(Element rawDataTypeElement, int channels, String xmlFile)
    471468  {
     
    494491      for (Element expression :  (List<Element>)formula.getChildren("formula"))
    495492      {
    496         int channel = XMLUtil.getIntAttribute(expression, "channel", 0);
     493        int channel = XmlUtil2.getIntAttribute(expression, "channel", 0);
    497494        String exp = Values.getStringOrNull(expression.getAttributeValue("expression"));
    498495        if (channel <= 0 || channel > channels)
  • trunk/src/core/net/sf/basedb/util/XMLUtil.java

    r6444 r6473  
    5353  @version 2.0
    5454  @base.modified $Date$
     55  @deprecated In 3.4, use {@link XmlUtil2} instead
    5556*/
     57@Deprecated
    5658public class XMLUtil
    5759{
  • trunk/src/core/net/sf/basedb/util/extensions/manager/processor/PluginInstallationProcessor.java

    r6444 r6473  
    2727import java.util.Map;
    2828
    29 import org.jdom.Element;
     29import org.jdom2.Element;
    3030
    3131import net.sf.basedb.core.DbControl;
     
    100100  }
    101101
    102   @SuppressWarnings("unchecked")
    103102  @Override
    104103  public void processFile(ExtensionsManager manager, WriteableExtensionsFile wFile)
     
    166165        if (in != null)
    167166        {
    168           List<Element> configurations = PluginConfiguration.loadXmlFile(in, "META-INF/plugin-configurations.xml");
     167          List<Element> configurations = PluginConfiguration.loadXmlFile2(in, "META-INF/plugin-configurations.xml");
    169168          FileUtil.close(in);
    170169          for (Element configuration : configurations)
     
    199198                config.setName(name);
    200199                config.setDescription(description);
    201                 config.setParameterValues((List<Element>)configuration.getChildren("parameter"));
     200                config.setParameterValues2((List<Element>)configuration.getChildren("parameter"));
    202201                numConfigurations++;
    203202              }
  • trunk/src/core/net/sf/basedb/util/extensions/xml/ExtensionPointFilter.java

    r5598 r6473  
    2424import java.util.regex.Pattern;
    2525
    26 import org.jdom.Element;
     26import org.jdom2.Element;
    2727
    2828import net.sf.basedb.util.Values;
  • trunk/src/core/net/sf/basedb/util/extensions/xml/PluginDefinitionFilter.java

    r5617 r6473  
    2222package net.sf.basedb.util.extensions.xml;
    2323
    24 import org.jdom.Element;
     24import org.jdom2.Element;
    2525
    2626import net.sf.basedb.util.filter.Filter;
  • trunk/src/core/net/sf/basedb/util/extensions/xml/XmlLoader.java

    r6444 r6473  
    3434import java.util.Set;
    3535
    36 import org.jdom.Attribute;
    37 import org.jdom.Document;
    38 import org.jdom.Element;
    39 import org.jdom.JDOMException;
    40 import org.jdom.Namespace;
    41 import org.jdom.output.Format;
    42 import org.jdom.output.XMLOutputter;
     36import org.jdom2.Attribute;
     37import org.jdom2.Document;
     38import org.jdom2.Element;
     39import org.jdom2.JDOMException;
     40//import org.jdom2.JDOMException;
     41import org.jdom2.Namespace;
     42import org.jdom2.output.Format;
     43import org.jdom2.output.XMLOutputter;
    4344
    4445import net.sf.basedb.core.BaseException;
     
    4950import net.sf.basedb.util.ClassUtil;
    5051import net.sf.basedb.util.Values;
    51 import net.sf.basedb.util.XMLUtil;
     52import net.sf.basedb.util.XmlUtil2;
    5253import net.sf.basedb.util.extensions.AboutBean;
    5354import net.sf.basedb.util.extensions.Action;
     
    258259  public About loadXmlFile(InputStream xmlFile, String filename,
    259260      ClassLoader classLoader, boolean clear)
    260     throws JDOMException, IOException, ClassNotFoundException, NoSuchMethodException,
     261    throws IOException, ClassNotFoundException, NoSuchMethodException,
    261262      IllegalAccessException, InstantiationException
    262263  {
     
    279280  */
    280281  public About validateXmlFile(InputStream xmlFile, String filename)
    281     throws IOException, JDOMException
     282    throws IOException
    282283  {
    283284    validatedDom = null;
     
    465466  */
    466467  protected Document loadDocument(InputStream xmlFile, String filename)
    467     throws IOException, JDOMException
     468    throws IOException
    468469  {
    469470    log.debug("Validating file: " + filename);
    470     Document dom = XMLUtil.getSchemaValidatedXML(xmlFile, filename, NAMESPACE, SCHEMA_FILE_URL);
    471     return dom;
     471    return XmlUtil2.getSchemaValidatedXML(xmlFile, filename, NAMESPACE, SCHEMA_FILE_URL);
    472472  }
    473473 
     
    511511    @param aboutTag The about tag
    512512  */
    513   @SuppressWarnings("unchecked")
    514513  protected AboutBean loadAbout(Element aboutTag)
    515514  {
     
    529528      about.setUrl(Values.getStringOrNull(aboutTag.getChildText("url", ns)));
    530529     
    531       List<Attribute> attributes = (List<Attribute>)aboutTag.getAttributes();
     530      List<Attribute> attributes = aboutTag.getAttributes();
    532531      for (Attribute a : attributes)
    533532      {
     
    800799    @since 3.0
    801800  */
    802   @SuppressWarnings("unchecked")
    803801  protected int loadPluginDefinitions(Document dom, ClassLoader classLoader, About globalAbout)
    804802    throws ClassNotFoundException, NoSuchMethodException,
     
    873871          if (settingsTag != null)
    874872          {
    875             for (Element propertyTag : (List<Element>)settingsTag.getChildren("property", ns))
     873            for (Element propertyTag : settingsTag.getChildren("property", ns))
    876874            {
    877875              String name = propertyTag.getAttributeValue("name");
     
    929927    @param root The root element, if null nothing is done
    930928  */
    931   @SuppressWarnings("unchecked")
    932929  protected void initBeanWithReflection(Object bean, Element root)
    933930  {
     
    935932    Class<?> beanClass = bean.getClass();
    936933   
    937     List<Element> parameters = (List<Element>)root.getChildren();
     934    List<Element> parameters = root.getChildren();
    938935    factoryParameters.put(bean, xmlOut.outputString(root));
    939936   
  • trunk/src/plugins/core/net/sf/basedb/plugins/Base1PluginExecuter.java

    r6372 r6473  
    7373import net.sf.basedb.util.FileUtil;
    7474import net.sf.basedb.util.Values;
    75 import net.sf.basedb.util.XMLUtil;
     75import net.sf.basedb.util.XmlUtil2;
    7676import net.sf.basedb.util.basefile.BaseFileWriter;
    7777import net.sf.basedb.util.export.spotdata.Base1FieldConverter;
     
    8787import net.sf.basedb.util.parser.FlatFileParser;
    8888
    89 import org.jdom.Document;
    90 import org.jdom.Element;
    91 import org.jdom.JDOMException;
    92 import org.jdom.filter.ElementFilter;
    93 import org.jdom.output.Format;
    94 import org.jdom.output.XMLOutputter;
     89import org.jdom2.Document;
     90import org.jdom2.Element;
     91//import org.jdom2.JDOMException;
     92import org.jdom2.filter.ElementFilter;
     93import org.jdom2.output.Format;
     94import org.jdom2.output.XMLOutputter;
    9595
    9696import java.io.ByteArrayOutputStream;
     
    10181018  }
    10191019
    1020 
    1021   @SuppressWarnings({ "unchecked" })
    10221020  private Map<String, JobParameter> getJobParameterObjectsFromXML(String xml, boolean hideRemoved)
    10231021  {
     
    10251023    {
    10261024      String doctype = "<!DOCTYPE jobparameters SYSTEM \"base1-plugin-configuration-file.dtd\">";
    1027       Document doc = XMLUtil.getValidatedXml(doctype+xml, dtdFile);
     1025      Document doc = XmlUtil2.getValidatedXml(doctype+xml, dtdFile);
    10281026      Iterator<Element> it = doc.getDescendants(new ElementFilter("parameter"));
    10291027      Map<String, JobParameter> pars = new TreeMap<String, JobParameter>();
     
    10441042      return pars;
    10451043    }
    1046     catch (JDOMException e1)
    1047     {
    1048       throw new BaseException(e1.getCause());
    1049     }
    10501044    catch (IOException e1)
    10511045    {
     
    10541048  }
    10551049
    1056 
    1057   @SuppressWarnings({ "unchecked" })
    10581050  private List<PluginParameter<?>> getJobParametersFromXML(String xml, boolean hideRemoved)
    10591051  {
     
    10611053    {
    10621054      String doctype = "<!DOCTYPE jobparameters SYSTEM \"base1-plugin-configuration-file.dtd\">";
    1063       Document doc = XMLUtil.getValidatedXml(doctype+xml, dtdFile);
     1055      Document doc = XmlUtil2.getValidatedXml(doctype+xml, dtdFile);
    10641056      Iterator<Element> it = doc.getDescendants(new ElementFilter("parameter"));
    10651057      Map<Integer, PluginParameter<?>> positionParameter =
     
    10801072      }
    10811073      return new ArrayList<PluginParameter<?>>(positionParameter.values());
    1082     }
    1083     catch (JDOMException e1)
    1084     {
    1085       throw new BaseException(e1.getCause());
    10861074    }
    10871075    catch (IOException e1)
     
    15771565    }
    15781566
    1579     @SuppressWarnings({ "unchecked" })
    15801567    JobParameter(Element e)
    15811568    {
    1582       try
    1583       {
    1584         position = e.getAttribute("position").getIntValue();
     1569        position = XmlUtil2.getIntAttribute(e, "position", 1);
    15851570        type = Base1JobParameterType.get(e.getAttribute("type").getValue().charAt(0));
    15861571        Iterator<Element> it = e.getDescendants(new ElementFilter());
     
    16241609          }
    16251610        }
    1626       }
    1627       catch (JDOMException ex)
    1628       {
    1629         throw new BaseException(ex);
    1630       }
    16311611    }
    16321612
  • trunk/src/plugins/core/net/sf/basedb/plugins/HelpExporter.java

    r6127 r6473  
    6161import java.util.Set;
    6262
    63 import org.jdom.DocType;
    64 import org.jdom.Element;
    65 import org.jdom.output.Format;
    66 import org.jdom.output.XMLOutputter;
     63import org.jdom2.DocType;
     64import org.jdom2.Element;
     65import org.jdom2.output.Format;
     66import org.jdom2.output.XMLOutputter;
    6767
    6868/**
  • trunk/src/plugins/core/net/sf/basedb/plugins/HelpImporter.java

    r6127 r6473  
    6666import net.sf.basedb.core.signal.SignalTarget;
    6767import net.sf.basedb.core.signal.ThreadSignalHandler;
    68 import net.sf.basedb.util.XMLUtil;
    69 
    70 import org.jdom.Document;
    71 import org.jdom.Element;
     68import net.sf.basedb.util.XmlUtil2;
     69
     70import org.jdom2.Document;
     71import org.jdom2.Element;
    7272
    7373/**
     
    325325
    326326  @Override
    327   @SuppressWarnings("unchecked")
    328327  public void doImport(InputStream in, ProgressReporter progress)
    329328    throws BaseException
     
    343342        filename = f.getPath().toString();
    344343      }
    345       Document doc = XMLUtil.getValidatedXML(in, dtdURL, filename);     
     344      Document doc = XmlUtil2.getValidatedXML(in, dtdURL, filename);     
    346345      Element rootElement = doc.getRootElement();
    347346      String clientExternalID = rootElement.getAttributeValue("clientExternalID");
     
    349348      if(client.getExternalId().equals(clientExternalID))
    350349      {
    351         List<Element> helpElements = (List<Element>)rootElement.getChildren(); 
     350        List<Element> helpElements = rootElement.getChildren();
    352351        float percentPerItem = 100.0f / helpElements.size();
    353352       
  • trunk/src/plugins/core/net/sf/basedb/plugins/PluginConfigurationExporter.java

    r6127 r6473  
    6666import java.util.Set;
    6767
    68 import org.jdom.DocType;
    69 import org.jdom.Element;
    70 import org.jdom.output.Format;
    71 import org.jdom.output.XMLOutputter;
     68import org.jdom2.DocType;
     69import org.jdom2.Element;
     70import org.jdom2.output.Format;
     71import org.jdom2.output.XMLOutputter;
    7272
    7373/**
  • trunk/src/plugins/core/net/sf/basedb/plugins/PluginConfigurationImporter.java

    r6127 r6473  
    6565import java.util.jar.JarFile;
    6666
    67 import org.jdom.Element;
    68 import org.jdom.JDOMException;
     67import org.jdom2.Element;
    6968
    7069/**
     
    339338
    340339  @Override
    341   @SuppressWarnings("unchecked")
    342340  public void doImport(InputStream in, ProgressReporter progress)
    343341    throws BaseException
     
    354352      }
    355353     
    356       List<Element> configurations = PluginConfiguration.loadXmlFile(in, filePath);
     354      List<Element> configurations = PluginConfiguration.loadXmlFile2(in, filePath);
    357355      int parameternumber = 0;
    358356      for (Element configuration : configurations)
     
    378376            config.setName(name);
    379377            config.setDescription(description);
    380             config.setParameterValues((List<Element>)configuration.getChildren("parameter"));
     378            config.setParameterValues2((List<Element>)configuration.getChildren("parameter"));
    381379            dc.saveItem(config);
    382380          }
     
    434432  public void importPluginConfigurationsFromJar(String jarPath, String xmlPath,
    435433        HashMap<Integer, Boolean> configurations,  boolean importAll, boolean setPermissions)
    436     throws IOException, JDOMException, BaseException
     434    throws IOException, BaseException
    437435  {
    438436    this.importAll = importAll;
     
    490488       
    491489        in = file.getDownloadStream(0);
    492         List<Element> configurations = PluginConfiguration.loadXmlFile(in, filePath);
     490        List<Element> configurations = PluginConfiguration.loadXmlFile2(in, filePath);
    493491        FileUtil.close(in);
    494492       
  • trunk/src/plugins/core/net/sf/basedb/plugins/executor/ParameterDefinition.java

    r5384 r6473  
    3434import java.util.Set;
    3535
    36 import org.jdom.Document;
    37 import org.jdom.Element;
    38 import org.jdom.JDOMException;
    39 import org.jdom.filter.ElementFilter;
    40 import org.jdom.output.Format;
    41 import org.jdom.output.XMLOutputter;
     36import org.jdom2.Document;
     37import org.jdom2.Element;
     38import org.jdom2.filter.ElementFilter;
     39import org.jdom2.output.Format;
     40import org.jdom2.output.XMLOutputter;
    4241
    4342import net.sf.basedb.core.AnnotationType;
     
    5958import net.sf.basedb.core.query.Orders;
    6059import net.sf.basedb.util.Values;
    61 import net.sf.basedb.util.XMLUtil;
     60import net.sf.basedb.util.XmlUtil2;
    6261
    6362/**
     
    102101    @return A list with parameter definition
    103102  */
    104   @SuppressWarnings("unchecked")
    105103  public static List<ParameterDefinition> parseXml(String xml, boolean validate)
    106104  {
     
    114112    try
    115113    {
    116       Document doc = XMLUtil.getXml(xml, dtdFile, validate);
     114      Document doc = XmlUtil2.getXml(xml, dtdFile, validate);
    117115      parameters = new ArrayList<ParameterDefinition>(doc.getContentSize());
    118116      Iterator<Element> it = doc.getDescendants(new ElementFilter("parameter"));
     
    124122        pd.setType(e.getAttributeValue("type"));
    125123        pd.setName(e.getAttributeValue("name"));
    126         pd.setRequired(XMLUtil.getBooleanAttribute(e, "required", false));
    127         pd.setMultiple(XMLUtil.getBooleanAttribute(e, "multiple", false));
     124        pd.setRequired(XmlUtil2.getBooleanAttribute(e, "required", false));
     125        pd.setMultiple(XmlUtil2.getBooleanAttribute(e, "multiple", false));
    128126        pd.setDefaultValue(Values.getStringOrNull(e.getChildText("default")));
    129127        pd.setDescription(Values.getStringOrNull(e.getChildText("description")));
     
    144142        parameters.add(pd);
    145143      }
    146     }
    147     catch (JDOMException e)
    148     {
    149       throw new BaseException(e);
    150144    }
    151145    catch (IOException e)
  • trunk/src/test/TestXMLUtil.java

    r4889 r6473  
    2121  along with BASE. If not, see <http://www.gnu.org/licenses/>.
    2222*/
    23 import net.sf.basedb.util.XMLUtil;
     23import net.sf.basedb.util.XmlUtil2;
    2424
    2525public class TestXMLUtil
     
    5353    try
    5454    {
    55       org.jdom.Document dom = XMLUtil.getValidatedXml(xmlFile, dtdFile);
     55      org.jdom2.Document dom = XmlUtil2.getValidatedXml(xmlFile, dtdFile);
    5656      if (!TestUtil.getSilent()) write(dom.toString());
    5757      write("--Create DOM OK");
     
    6969    try
    7070    {
    71       org.jdom.Document dom = XMLUtil.getSchemaValidatedXML(xmlFile, schemaFiles);
     71      org.jdom2.Document dom = XmlUtil2.getSchemaValidatedXML(xmlFile, schemaFiles);
    7272      if (!TestUtil.getSilent()) write(dom.toString());
    7373      write("--Create schema validated DOM OK");
  • trunk/src/test/data/JarPluginManifest.txt

    r5612 r6473  
    11Class-Path: ../../lib/dist/AffxFusion.jar
    2  ../../lib/dist/hibernate3.jar
     2 ../../lib/dist/hibernate-core-4.3.5.Final.jar
Note: See TracChangeset for help on using the changeset viewer.