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.wiki.engines;
016    
017    import com.liferay.portlet.wiki.PageContentException;
018    import com.liferay.portlet.wiki.model.WikiPage;
019    
020    import java.util.Map;
021    
022    import javax.portlet.PortletURL;
023    
024    /**
025     * @author Jorge Ferrer
026     */
027    public interface WikiEngine {
028    
029            /**
030             * Convert the content of the given page to HTML using the view and edit
031             * URLs to build links.
032             *
033             * @param  page the wiki page
034             * @param  viewPageURL the URL to view the page
035             * @param  editPageURL the URL to edit the page
036             * @param  attachmentURLPrefix the URL prefix to use for attachments to the
037             *         page
038             * @return HTML string
039             * @throws PageContentException if a page content exception occurred
040             */
041            public String convert(
042                            WikiPage page, PortletURL viewPageURL, PortletURL editPageURL,
043                            String attachmentURLPrefix)
044                    throws PageContentException;
045    
046            /**
047             * Get a map with the links included in the given page. The key of each map
048             * entry is the title of the linked page. The value is a Boolean object that
049             * indicates if the linked page exists or not.
050             *
051             * @param  page the page
052             * @return a map of links
053             * @throws PageContentException if a page content exception occurred
054             */
055            public Map<String, Boolean> getOutgoingLinks(WikiPage page)
056                    throws PageContentException;
057    
058            /**
059             * Set the configuraton to support quick links to other wikis. The format of
060             * the configuration is specific to the wiki engine.
061             */
062            public void setInterWikiConfiguration(String interWikiConfiguration);
063    
064            /**
065             * Set the main wiki configuraiton as a String. The format of the
066             * configuration is specific to the wiki engine.
067             */
068            public void setMainConfiguration(String mainConfiguration);
069    
070            /**
071             * Validate the content of a wiki page for this engine.
072             *
073             * @param  nodeId the ID of the wiki page node
074             * @param  content the page content
075             * @return <code>true</code> if the content is valid
076             */
077            public boolean validate(long nodeId, String content);
078    
079    }