com.liferay.wiki.engine.text.internal.TextEngine Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.wiki.engine.text.internal;
import com.liferay.petra.string.StringPool;
import com.liferay.portal.kernel.util.AggregateResourceBundleLoader;
import com.liferay.portal.kernel.util.ResourceBundleLoader;
import com.liferay.portal.language.LanguageResources;
import com.liferay.wiki.engine.BaseWikiEngine;
import com.liferay.wiki.engine.WikiEngine;
import com.liferay.wiki.model.WikiPage;
import java.util.Collections;
import java.util.Map;
import javax.portlet.PortletURL;
import javax.servlet.ServletContext;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Jorge Ferrer
*/
@Component(service = WikiEngine.class)
public class TextEngine extends BaseWikiEngine {
@Override
public String convert(
WikiPage page, PortletURL viewPageURL, PortletURL editPageURL,
String attachmentURLPrefix) {
if (page.getContent() == null) {
return StringPool.BLANK;
}
else {
return "" + page.getContent() + "
";
}
}
@Override
public String getEditorName() {
return null;
}
@Override
public String getFormat() {
return "plain_text";
}
@Override
public String getHelpURL() {
return null;
}
@Override
public Map getOutgoingLinks(WikiPage page) {
return Collections.emptyMap();
}
@Override
protected ServletContext getEditPageServletContext() {
return _servletContext;
}
@Override
protected ServletContext getHelpPageServletContext() {
return null;
}
@Override
protected ResourceBundleLoader getResourceBundleLoader() {
return _resourceBundleLoader;
}
@Reference(
target = "(bundle.symbolic.name=com.liferay.wiki.engine.text)",
unbind = "-"
)
protected void setResourceBundleLoader(
ResourceBundleLoader resourceBundleLoader) {
_resourceBundleLoader = new AggregateResourceBundleLoader(
resourceBundleLoader, LanguageResources.RESOURCE_BUNDLE_LOADER);
}
@Reference(
target = "(osgi.web.symbolicname=com.liferay.wiki.engine.text)",
unbind = "-"
)
protected void setServletContext(ServletContext servletContext) {
_servletContext = servletContext;
}
private ResourceBundleLoader _resourceBundleLoader;
private ServletContext _servletContext;
}