1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.journal.lar;
16  
17  import com.liferay.portal.lar.PortletDataContext;
18  import com.liferay.portlet.journal.model.JournalArticle;
19  
20  /**
21   * <a href="JournalCreationStrategy.java.html"><b><i>View Source</i></b></a>
22   *
23   * <p>
24   * An interface defining how newly created content should be added to the
25   * Journal when imported from a LAR file. A class implementing this interface
26   * should be specified in <i>portal.properties</i> under the
27   * <b>journal.lar.creation.strategy</b> property.
28   * </p>
29   *
30   * @author Joel Kozikowski
31   */
32  public interface JournalCreationStrategy {
33  
34      /**
35       * Constant returned by getAuthorUserId() and/or getApprovalUserId() that
36       * indicates the default portlet data import user id strategy that should be
37       * used to determine the user id.
38       */
39      public static final long USE_DEFAULT_USER_ID_STRATEGY = 0;
40  
41      /**
42       * Constant returned by getTransformedContent() to indicate that the article
43       * text should remained unchanged.
44       */
45      public static final String ARTICLE_CONTENT_UNCHANGED = null;
46  
47      /**
48       * Returns the author's user id to assign to newly created content. If zero
49       * is returned, the default user id import strategy will determine the
50       * author id.
51       *
52       * @return the author's user id or USE_DEFAULT_USER_ID_STRATEGY to use the
53       *         default user id strategy
54       */
55      public long getAuthorUserId(PortletDataContext context, Object journalObj)
56          throws Exception;
57  
58      /**
59       * Returns the approver's user id to assign to newly created content. If
60       * zero is returned, the default user id import strategy will determine the
61       * author id.
62       *
63       * @return the approver's user id or USE_DEFAULT_USER_ID_STRATEGY to use the
64       *         default user id strategy
65       */
66      public long getApprovalUserId(PortletDataContext context, Object journalObj)
67          throws Exception;
68  
69      /**
70       * Gives the content creation strategy an opportunity to transform the
71       * content before the new article is saved to the database. Possible use
72       * cases include using Velocity to merge in community specific values into
73       * the text. Returns the new content to assign to the article. If null is
74       * returned, the article content will be added unchanged.
75       *
76       * @return the transformed content to save in the database or
77       *         ARTICLE_CONTENT_UNCHANGED if the content should be added
78       *         unchanged
79       */
80      public String getTransformedContent(
81              PortletDataContext context, JournalArticle newArticle)
82          throws Exception;
83  
84      /**
85       * Returns true if the default community permissions should be added when
86       * the specified journalObj is created.
87       *
88       * @return true if default community permissions should be added to the
89       *         specified journalObj
90       */
91      public boolean addCommunityPermissions(
92              PortletDataContext context, Object journalObj)
93          throws Exception;
94  
95      /**
96       * Returns true if the default guest permissions should be added when the
97       * specified journalObj is created.
98       *
99       * @return true if default guest permissions should be added to the
100      *         specified journalObj
101      */
102     public boolean addGuestPermissions(
103             PortletDataContext context, Object journalObj)
104         throws Exception;
105 
106 }