001    /**
002     * Copyright (c) 2000-2010 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.lar;
016    
017    import com.liferay.portal.kernel.lar.PortletDataContext;
018    import com.liferay.portlet.journal.model.JournalArticle;
019    
020    /**
021     * <p>
022     * An interface defining how newly created content should be added to the
023     * Journal when imported from a LAR file. A class implementing this interface
024     * should be specified in <i>portal.properties</i> under the
025     * <b>journal.lar.creation.strategy</b> property.
026     * </p>
027     *
028     * @author Joel Kozikowski
029     */
030    public interface JournalCreationStrategy {
031    
032            /**
033             * Constant returned by getAuthorUserId() that indicates the default portlet
034             * data import user id strategy that should be used to determine the user
035             * id.
036             */
037            public static final long USE_DEFAULT_USER_ID_STRATEGY = 0;
038    
039            /**
040             * Constant returned by getTransformedContent() to indicate that the article
041             * text should remained unchanged.
042             */
043            public static final String ARTICLE_CONTENT_UNCHANGED = null;
044    
045            /**
046             * Returns the author's user id to assign to newly created content. If zero
047             * is returned, the default user id import strategy will determine the
048             * author id.
049             *
050             * @return the author's user id or USE_DEFAULT_USER_ID_STRATEGY to use the
051             *                 default user id strategy
052             */
053            public long getAuthorUserId(PortletDataContext context, Object journalObj)
054                    throws Exception;
055    
056            /**
057             * Gives the content creation strategy an opportunity to transform the
058             * content before the new article is saved to the database. Possible use
059             * cases include using Velocity to merge in community specific values into
060             * the text. Returns the new content to assign to the article. If
061             * <code>null</code> is returned, the article content will be added
062             * unchanged.
063             *
064             * @return the transformed content to save in the database or
065             *                 ARTICLE_CONTENT_UNCHANGED if the content should be added
066             *                 unchanged
067             */
068            public String getTransformedContent(
069                            PortletDataContext context, JournalArticle newArticle)
070                    throws Exception;
071    
072            /**
073             * Returns <code>true</code> if the default community permissions should be
074             * added when the specified journalObj is created.
075             *
076             * @return <code>true</code> if default community permissions should be
077             *                 added to the specified journalObj
078             */
079            public boolean addCommunityPermissions(
080                            PortletDataContext context, Object journalObj)
081                    throws Exception;
082    
083            /**
084             * Returns <code>true</code> if the default guest permissions should be
085             * added when the specified journalObj is created.
086             *
087             * @return <code>true</code> if default guest permissions should be added to
088             *                 the specified journalObj
089             */
090            public boolean addGuestPermissions(
091                            PortletDataContext context, Object journalObj)
092                    throws Exception;
093    
094    }