001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }