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.json.JSONArray;
018    import com.liferay.portal.kernel.json.JSONException;
019    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
020    import com.liferay.portal.kernel.xml.Document;
021    import com.liferay.portal.kernel.xml.DocumentException;
022    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
023    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
024    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
025    
026    import java.util.Locale;
027    
028    import javax.servlet.jsp.PageContext;
029    
030    /**
031     * @author Eduardo Lundgren
032     * @author Brian Wing Shun Chan
033     */
034    public class DDMXSDUtil {
035    
036            public static DDMXSD getDDMXSD() {
037                    PortalRuntimePermission.checkGetBeanProperty(DDMXSDUtil.class);
038    
039                    return _ddmXSD;
040            }
041    
042            public static String getHTML(
043                            PageContext pageContext, DDMStructure ddmStructure, Fields fields,
044                            String namespace, boolean readOnly, Locale locale)
045                    throws Exception {
046    
047                    return getDDMXSD().getHTML(
048                            pageContext, ddmStructure, fields, namespace, readOnly, locale);
049            }
050    
051            public static String getHTML(
052                            PageContext pageContext, DDMTemplate ddmTemplate, Fields fields,
053                            String namespace, boolean readOnly, Locale locale)
054                    throws Exception {
055    
056                    return getDDMXSD().getHTML(
057                            pageContext, ddmTemplate, fields, namespace, readOnly, locale);
058            }
059    
060            public static String getHTML(
061                            PageContext pageContext, String xml, Fields fields, Locale locale)
062                    throws Exception {
063    
064                    return getDDMXSD().getHTML(pageContext, xml, fields, locale);
065            }
066    
067            public static String getHTML(
068                            PageContext pageContext, String xml, Fields fields,
069                            String namespace, boolean readOnly, Locale locale)
070                    throws Exception {
071    
072                    return getDDMXSD().getHTML(
073                            pageContext, xml, fields, namespace, readOnly, locale);
074            }
075    
076            public static String getHTML(
077                            PageContext pageContext, String xml, Fields fields,
078                            String namespace, Locale locale)
079                    throws Exception {
080    
081                    return getDDMXSD().getHTML(pageContext, xml, fields, namespace, locale);
082            }
083    
084            public static String getHTML(
085                            PageContext pageContext, String xml, Locale locale)
086                    throws Exception {
087    
088                    return getDDMXSD().getHTML(pageContext, xml, locale);
089            }
090    
091            public static JSONArray getJSONArray(Document document)
092                    throws JSONException {
093    
094                    return getDDMXSD().getJSONArray(document);
095            }
096    
097            public static JSONArray getJSONArray(String xml)
098                    throws DocumentException, JSONException {
099    
100                    return getDDMXSD().getJSONArray(xml);
101            }
102    
103            public void setDDMXSD(DDMXSD ddmXSD) {
104                    PortalRuntimePermission.checkSetBeanProperty(getClass());
105    
106                    _ddmXSD = ddmXSD;
107            }
108    
109            private static DDMXSD _ddmXSD;
110    
111    }