001    /**
002     * Copyright (c) 2000-2012 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 namespace, String mode, boolean readOnly, Locale locale)
046                    throws Exception {
047    
048                    return getDDMXSD().getFieldHTML(
049                            pageContext, element, fields, namespace, mode, readOnly, locale);
050            }
051    
052            public static String getFieldHTMLByName(
053                            PageContext pageContext, long classNameId, long classPK,
054                            String fieldName, Fields fields, String namespace, String mode,
055                            boolean readOnly, Locale locale)
056                    throws Exception {
057    
058                    return getDDMXSD().getFieldHTMLByName(
059                            pageContext, classNameId, classPK, fieldName, fields, namespace,
060                            mode, readOnly, locale);
061            }
062    
063            public static String getHTML(
064                            PageContext pageContext, DDMStructure ddmStructure, Fields fields,
065                            String namespace, boolean readOnly, Locale locale)
066                    throws Exception {
067    
068                    return getDDMXSD().getHTML(
069                            pageContext, ddmStructure, fields, namespace, readOnly, locale);
070            }
071    
072            public static String getHTML(
073                            PageContext pageContext, DDMTemplate ddmTemplate, Fields fields,
074                            String namespace, boolean readOnly, Locale locale)
075                    throws Exception {
076    
077                    return getDDMXSD().getHTML(
078                            pageContext, ddmTemplate, fields, namespace, readOnly, locale);
079            }
080    
081            public static String getHTML(
082                            PageContext pageContext, String xml, Fields fields, Locale locale)
083                    throws Exception {
084    
085                    return getDDMXSD().getHTML(pageContext, xml, fields, locale);
086            }
087    
088            public static String getHTML(
089                            PageContext pageContext, String xml, Fields fields,
090                            String namespace, boolean readOnly, Locale locale)
091                    throws Exception {
092    
093                    return getDDMXSD().getHTML(
094                            pageContext, xml, fields, namespace, readOnly, locale);
095            }
096    
097            public static String getHTML(
098                            PageContext pageContext, String xml, Fields fields,
099                            String namespace, Locale locale)
100                    throws Exception {
101    
102                    return getDDMXSD().getHTML(pageContext, xml, fields, namespace, locale);
103            }
104    
105            public static String getHTML(
106                            PageContext pageContext, String xml, Locale locale)
107                    throws Exception {
108    
109                    return getDDMXSD().getHTML(pageContext, xml, locale);
110            }
111    
112            public static JSONArray getJSONArray(DDMStructure structure, String xsd)
113                    throws PortalException, SystemException {
114    
115                    return getDDMXSD().getJSONArray(structure, xsd);
116            }
117    
118            public static JSONArray getJSONArray(Document document)
119                    throws PortalException {
120    
121                    return getDDMXSD().getJSONArray(document);
122            }
123    
124            public static JSONArray getJSONArray(Element element)
125                    throws PortalException {
126    
127                    return getDDMXSD().getJSONArray(element);
128            }
129    
130            public static JSONArray getJSONArray(String xml)
131                    throws PortalException, SystemException {
132    
133                    return getDDMXSD().getJSONArray(xml);
134            }
135    
136            public static String getXSD(long classNameId, long classPK)
137                    throws PortalException, SystemException {
138    
139                    return getDDMXSD().getXSD(classNameId, classPK);
140            }
141    
142            public void setDDMXSD(DDMXSD ddmXSD) {
143                    PortalRuntimePermission.checkSetBeanProperty(getClass());
144    
145                    _ddmXSD = ddmXSD;
146            }
147    
148            private static DDMXSD _ddmXSD;
149    
150    }