001    /**
002     * Copyright (c) 2000-present 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.journal.util;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
020    import com.liferay.portal.kernel.xml.Document;
021    import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
022    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
023    
024    import java.util.Locale;
025    
026    /**
027     * @author Marcellus Tavares
028     * @author Bruno Basto
029     */
030    @ProviderType
031    public class JournalConverterUtil {
032    
033            public static String getContent(DDMStructure ddmStructure, Fields ddmFields)
034                    throws Exception {
035    
036                    return getJournalConverter().getContent(ddmStructure, ddmFields);
037            }
038    
039            public static Fields getDDMFields(
040                            DDMStructure ddmStructure, Document document)
041                    throws Exception {
042    
043                    return getJournalConverter().getDDMFields(ddmStructure, document);
044            }
045    
046            public static Fields getDDMFields(DDMStructure ddmStructure, String content)
047                    throws Exception {
048    
049                    return getJournalConverter().getDDMFields(ddmStructure, content);
050            }
051    
052            public static String getDDMXSD(String journalXSD) throws Exception {
053                    return getJournalConverter().getDDMXSD(journalXSD);
054            }
055    
056            public static String getDDMXSD(String journalXSD, Locale defaultLocale)
057                    throws Exception {
058    
059                    return getJournalConverter().getDDMXSD(journalXSD, defaultLocale);
060            }
061    
062            public static JournalConverter getJournalConverter() {
063                    PortalRuntimePermission.checkGetBeanProperty(
064                            JournalConverterUtil.class);
065    
066                    return _journalConverter;
067            }
068    
069            public static String getJournalXSD(String ddmXSD) throws Exception {
070                    return getJournalConverter().getJournalXSD(ddmXSD);
071            }
072    
073            public void setJournalConverter(JournalConverter journalConverter) {
074                    PortalRuntimePermission.checkSetBeanProperty(getClass());
075    
076                    _journalConverter = journalConverter;
077            }
078    
079            private static JournalConverter _journalConverter;
080    
081    }