001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.xml;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import java.io.File;
020    import java.io.InputStream;
021    import java.io.Reader;
022    
023    import java.net.MalformedURLException;
024    import java.net.URL;
025    
026    /**
027     * @author Tomas Polesovsky
028     */
029    public class UnsecureSAXReaderUtil {
030    
031            public static SAXReader getSAXReader() {
032                    PortalRuntimePermission.checkGetBeanProperty(SAXReaderUtil.class);
033    
034                    return _saxReader;
035            }
036    
037            public static Document read(File file) throws DocumentException {
038                    return getSAXReader().read(file);
039            }
040    
041            public static Document read(File file, boolean validate)
042                    throws DocumentException {
043    
044                    return getSAXReader().read(file, validate);
045            }
046    
047            public static Document read(InputStream is) throws DocumentException {
048                    return getSAXReader().read(is);
049            }
050    
051            public static Document read(InputStream is, boolean validate)
052                    throws DocumentException {
053    
054                    return getSAXReader().read(is, validate);
055            }
056    
057            public static Document read(Reader reader) throws DocumentException {
058                    return getSAXReader().read(reader);
059            }
060    
061            public static Document read(Reader reader, boolean validate)
062                    throws DocumentException {
063    
064                    return getSAXReader().read(reader, validate);
065            }
066    
067            public static Document read(String xml) throws DocumentException {
068                    return getSAXReader().read(xml);
069            }
070    
071            public static Document read(String xml, boolean validate)
072                    throws DocumentException {
073    
074                    return getSAXReader().read(xml, validate);
075            }
076    
077            public static Document read(String xml, XMLSchema xmlSchema)
078                    throws DocumentException {
079    
080                    return getSAXReader().read(xml, xmlSchema);
081            }
082    
083            public static Document read(URL url) throws DocumentException {
084                    return getSAXReader().read(url);
085            }
086    
087            public static Document read(URL url, boolean validate)
088                    throws DocumentException {
089    
090                    return getSAXReader().read(url, validate);
091            }
092    
093            public static Document readURL(String url)
094                    throws DocumentException, MalformedURLException {
095    
096                    return getSAXReader().readURL(url);
097            }
098    
099            public static Document readURL(String url, boolean validate)
100                    throws DocumentException, MalformedURLException {
101    
102                    return getSAXReader().readURL(url, validate);
103            }
104    
105            public void setSAXReader(SAXReader saxReader) {
106                    PortalRuntimePermission.checkSetBeanProperty(getClass());
107    
108                    _saxReader = saxReader;
109            }
110    
111            private static SAXReader _saxReader;
112    
113    }