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             * Returns the content of the given page converted to HTML using the view
031             * and edit 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 the content of the given page converted to HTML
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             * Returns a map of the links included in the given page. The key of each
048             * map entry is the title of the linked page. The value is a Boolean object
049             * that indicates if the linked page exists or not.
050             *
051             * @param  page the page
052             * @return a map of links included in the given page
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 configuration to support quick links to other wikis. The format
060             * of the configuration is specific to the wiki engine.
061             *
062             * @param interWikiConfiguration the configuration to support quick links to
063             *        other wikis
064             */
065            public void setInterWikiConfiguration(String interWikiConfiguration);
066    
067            /**
068             * Sets the main wiki configuration as a String. The format of the
069             * configuration is specific to the wiki engine.
070             *
071             * @param mainConfiguration the main configuration of the wiki engine
072             */
073            public void setMainConfiguration(String mainConfiguration);
074    
075            /**
076             * Returns <code>true</code> if the content of a wiki page for this engine
077             * is valid.
078             *
079             * @param  nodeId the ID of the wiki page node
080             * @param  content the page content
081             * @return <code>true</code> if the content of a wiki page for this engine
082             *         is valid; <code>false</code> otherwise
083             */
084            public boolean validate(long nodeId, String content);
085    
086    }