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.portlet.dynamicdatamapping.util;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.kernel.xml.Document;
019    import com.liferay.portal.kernel.xml.DocumentException;
020    
021    import java.io.IOException;
022    
023    import java.util.Locale;
024    
025    /**
026     * @author Bruno Basto
027     * @author Brian Wing Shun Chan
028     */
029    public class DDMXMLUtil {
030    
031            public static String formatXML(Document document) throws IOException {
032                    return getDDMXML().formatXML(document);
033            }
034    
035            public static String formatXML(String xml)
036                    throws DocumentException, IOException {
037    
038                    return getDDMXML().formatXML(xml);
039            }
040    
041            public static DDMXML getDDMXML() {
042                    PortalRuntimePermission.checkGetBeanProperty(DDMXMLUtil.class);
043    
044                    return _ddmXML;
045            }
046    
047            public static String updateXMLDefaultLocale(
048                            String xml, Locale contentDefaultLocale,
049                            Locale contentNewDefaultLocale)
050                    throws DocumentException, IOException {
051    
052                    return getDDMXML().updateXMLDefaultLocale(
053                            xml, contentDefaultLocale, contentNewDefaultLocale);
054            }
055    
056            public void setDDMXML(DDMXML ddmXML) {
057                    PortalRuntimePermission.checkSetBeanProperty(getClass());
058    
059                    _ddmXML = ddmXML;
060            }
061    
062            private static DDMXML _ddmXML;
063    
064    }