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.journal.template;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.template.TemplateVariableGroup;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.portal.util.PortalUtil;
021    import com.liferay.portal.util.PortletKeys;
022    import com.liferay.portlet.ddm.template.BaseDDMTemplateHandler;
023    import com.liferay.portlet.dynamicdatamapping.service.DDMStructureLocalService;
024    import com.liferay.portlet.dynamicdatamapping.service.DDMStructureService;
025    import com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLocalService;
026    import com.liferay.portlet.dynamicdatamapping.service.DDMTemplateService;
027    import com.liferay.portlet.journal.model.JournalArticle;
028    import com.liferay.portlet.journal.service.JournalArticleLocalService;
029    import com.liferay.portlet.journal.service.JournalArticleService;
030    
031    import java.util.Locale;
032    import java.util.Map;
033    
034    /**
035     * @author Jorge Ferrer
036     */
037    public class JournalTemplateHandler extends BaseDDMTemplateHandler {
038    
039            public String getClassName() {
040                    return JournalArticle.class.getName();
041            }
042    
043            public String getName(Locale locale) {
044                    String portletTitle = PortalUtil.getPortletTitle(
045                            PortletKeys.JOURNAL, locale);
046    
047                    return portletTitle.concat(StringPool.SPACE).concat(
048                            LanguageUtil.get(locale, "template"));
049            }
050    
051            public String getResourceName() {
052                    return "com.liferay.portlet.journal";
053            }
054    
055            @Override
056            public Map<String, TemplateVariableGroup> getTemplateVariableGroups(
057                            long classPK, Locale locale)
058                    throws Exception {
059    
060                    Map<String, TemplateVariableGroup> templateVariableGroups =
061                            super.getTemplateVariableGroups(classPK, locale);
062    
063                    TemplateVariableGroup journalServicesTemplateVariableGroup =
064                            new TemplateVariableGroup("web-content-services");
065    
066                    journalServicesTemplateVariableGroup.setAutocompleteEnabled(false);
067    
068                    journalServicesTemplateVariableGroup.addServiceLocatorVariables(
069                            JournalArticleLocalService.class, JournalArticleService.class,
070                            DDMStructureLocalService.class, DDMStructureService.class,
071                            DDMTemplateLocalService.class, DDMTemplateService.class);
072    
073                    templateVariableGroups.put(
074                            journalServicesTemplateVariableGroup.getLabel(),
075                            journalServicesTemplateVariableGroup);
076    
077                    return templateVariableGroups;
078            }
079    
080    }