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.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.json.JSONArray;
020    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
021    import com.liferay.portal.kernel.xml.Document;
022    import com.liferay.portal.kernel.xml.Element;
023    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
024    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
025    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
026    
027    import java.util.Locale;
028    
029    import javax.servlet.jsp.PageContext;
030    
031    /**
032     * @author Eduardo Lundgren
033     * @author Brian Wing Shun Chan
034     */
035    public class DDMXSDUtil {
036    
037            public static DDMXSD getDDMXSD() {
038                    PortalRuntimePermission.checkGetBeanProperty(DDMXSDUtil.class);
039    
040                    return _ddmXSD;
041            }
042    
043            public static String getFieldHTML(
044                            PageContext pageContext, Element element, Fields fields,
045                            String portletNamespace, String namespace, String mode,
046                            boolean readOnly, Locale locale)
047                    throws Exception {
048    
049                    return getDDMXSD().getFieldHTML(
050                            pageContext, element, fields, portletNamespace, namespace, mode,
051                            readOnly, locale);
052            }
053    
054            public static String getFieldHTMLByName(
055                            PageContext pageContext, long classNameId, long classPK,
056                            String fieldName, Fields fields, String portletNamespace,
057                            String namespace, String mode, boolean readOnly, Locale locale)
058                    throws Exception {
059    
060                    return getDDMXSD().getFieldHTMLByName(
061                            pageContext, classNameId, classPK, fieldName, fields,
062                            portletNamespace, namespace, mode, readOnly, locale);
063            }
064    
065            public static String getFieldHTMLByName(
066                            PageContext pageContext, long classNameId, long classPK,
067                            String fieldName, String portletNamespace, String namespace,
068                            String mode, boolean readOnly, Locale locale)
069                    throws Exception {
070    
071                    return getDDMXSD().getFieldHTMLByName(
072                            pageContext, classNameId, classPK, fieldName, portletNamespace,
073                            namespace, mode, readOnly, locale);
074            }
075    
076            public static String getHTML(
077                            PageContext pageContext, DDMStructure ddmStructure, Fields fields,
078                            String portletNamespace, String namespace, boolean readOnly,
079                            Locale locale)
080                    throws Exception {
081    
082                    return getDDMXSD().getHTML(
083                            pageContext, ddmStructure, fields, portletNamespace, namespace,
084                            readOnly, locale);
085            }
086    
087            public static String getHTML(
088                            PageContext pageContext, DDMTemplate ddmTemplate, Fields fields,
089                            String portletNamespace, String namespace, boolean readOnly,
090                            Locale locale)
091                    throws Exception {
092    
093                    return getDDMXSD().getHTML(
094                            pageContext, ddmTemplate, fields, portletNamespace, namespace,
095                            readOnly, locale);
096            }
097    
098            public static String getHTML(
099                            PageContext pageContext, String xml, Fields fields,
100                            String portletNamespace, Locale locale)
101                    throws Exception {
102    
103                    return getDDMXSD().getHTML(
104                            pageContext, xml, fields, portletNamespace, locale);
105            }
106    
107            public static String getHTML(
108                            PageContext pageContext, String xml, Fields fields,
109                            String portletNamespace, String namespace, boolean readOnly,
110                            Locale locale)
111                    throws Exception {
112    
113                    return getDDMXSD().getHTML(
114                            pageContext, xml, fields, portletNamespace, namespace, readOnly,
115                            locale);
116            }
117    
118            public static String getHTML(
119                            PageContext pageContext, String xml, Fields fields,
120                            String portletNamespace, String namespace, Locale locale)
121                    throws Exception {
122    
123                    return getDDMXSD().getHTML(
124                            pageContext, xml, fields, portletNamespace, namespace, locale);
125            }
126    
127            public static String getHTML(
128                            PageContext pageContext, String xml, String portletNamespace,
129                            Locale locale)
130                    throws Exception {
131    
132                    return getDDMXSD().getHTML(pageContext, xml, portletNamespace, locale);
133            }
134    
135            public static JSONArray getJSONArray(DDMStructure structure, String xsd)
136                    throws PortalException, SystemException {
137    
138                    return getDDMXSD().getJSONArray(structure, xsd);
139            }
140    
141            public static JSONArray getJSONArray(Document document)
142                    throws PortalException {
143    
144                    return getDDMXSD().getJSONArray(document);
145            }
146    
147            public static JSONArray getJSONArray(Element element)
148                    throws PortalException {
149    
150                    return getDDMXSD().getJSONArray(element);
151            }
152    
153            public static JSONArray getJSONArray(String xml)
154                    throws PortalException, SystemException {
155    
156                    return getDDMXSD().getJSONArray(xml);
157            }
158    
159            public static String getXSD(long classNameId, long classPK)
160                    throws PortalException, SystemException {
161    
162                    return getDDMXSD().getXSD(classNameId, classPK);
163            }
164    
165            public void setDDMXSD(DDMXSD ddmXSD) {
166                    PortalRuntimePermission.checkSetBeanProperty(getClass());
167    
168                    _ddmXSD = ddmXSD;
169            }
170    
171            private static DDMXSD _ddmXSD;
172    
173    }