001: /**
002: * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.journal.lar;
022:
023: import com.liferay.portlet.journal.model.JournalArticle;
024:
025: /**
026: * <a href="JournalCreationStrategy.java.html"><b><i>View Source</i></b></a>
027: *
028: * <p>
029: * An interface defining how newly created content should be added to the
030: * Journal when imported from a LAR file. A class implementing this interface
031: * should be specified in <i>portal.properties</i> under the
032: * <b>journal.lar.creation.strategy</b> property.
033: * </p>
034: *
035: * @author Joel Kozikowski
036: *
037: */
038: public interface JournalCreationStrategy {
039:
040: /**
041: * Constant returned by getAuthorUserId() and/or getApprovalUserId()
042: * that indicates the default portlet data import user id strategy that
043: * should be used to determine the user id.
044: */
045: public static final long USE_DEFAULT_USER_ID_STRATEGY = 0;
046:
047: /**
048: * Constant returned by getTransformedContent() to indicate that the
049: * article text should remained unchanged.
050: */
051: public static final String ARTICLE_CONTENT_UNCHANGED = null;
052:
053: /**
054: * Returns the author's user id to assign to newly created content. If zero
055: * is returned, the default user id import strategy will determine the
056: * author id.
057: *
058: * @param companyId the company id of the layout
059: * @param groupId the group id of the layout
060: * @param journalObj the new object must be an instance of
061: * JournalArticle, JournalStructure, or JournalTemplate
062: * @return the author's user id or USE_DEFAULT_USER_ID_STRATEGY to use
063: * the default user id strategy
064: */
065: public long getAuthorUserId(long companyId, long groupId,
066: Object journalObj) throws Exception;
067:
068: /**
069: * Returns the approver's user id to assign to newly created content. If
070: * zero is returned, the default user id import strategy will determine the
071: * author id.
072: *
073: * @param companyId the company id of the layout
074: * @param groupId the group id of the layout
075: * @param journalObj the new object must be an instance of
076: * JournalArticle, JournalStructure, or JournalTemplate
077: * @return the approver's user id or USE_DEFAULT_USER_ID_STRATEGY to
078: * use the default user id strategy
079: */
080: public long getApprovalUserId(long companyId, long groupId,
081: Object journalObj) throws Exception;
082:
083: /**
084: * Gives the content creation strategy an opportunity to transform the
085: * content before the new article is saved to the database. Possible use
086: * cases include using Velocity to merge in community specific values into
087: * the text. Returns the new content to assign to the article. If null is
088: * returned, the article content will be added unchanged.
089: *
090: * @param companyId the company id of the layout
091: * @param groupId the group id of the layout
092: * @param newArticle the new article being created
093: * @return the transformed content to save in the database or
094: * ARTICLE_CONTENT_UNCHANGED if the content should be added
095: * unchanged
096: */
097: public String getTransformedContent(long companyId, long groupId,
098: JournalArticle newArticle) throws Exception;
099:
100: /**
101: * Returns true if the default community permissions should be added when
102: * the specified journalObj is created.
103: *
104: * @param companyId the company id of the layout
105: * @param groupId the group id of the layout
106: * @param journalObj the new object must be an instance of
107: * JournalArticle, JournalStructure, or JournalTemplate
108: * @return true if default community permissions should be added to the
109: * specified journalObj
110: */
111: public boolean addCommunityPermissions(long companyId,
112: long groupId, Object journalObj) throws Exception;
113:
114: /**
115: * Returns true if the default guest permissions should be added when the
116: * specified journalObj is created.
117: *
118: * @param companyId the company id of the layout
119: * @param groupId the group id of the layout
120: * @param journalObj the new object must be an instance of
121: * JournalArticle, JournalStructure, or JournalTemplate
122: * @return true if default guest permissions should be added to the
123: * specified journalObj
124: */
125: public boolean addGuestPermissions(long companyId, long groupId,
126: Object journalObj) throws Exception;
127:
128: }
|