com.liferay.portlet.journal.lar
Class JournalCreationStrategyImpl

java.lang.Object
  extended bycom.liferay.portlet.journal.lar.JournalCreationStrategyImpl
All Implemented Interfaces:
JournalCreationStrategy

public class JournalCreationStrategyImpl
extends java.lang.Object
implements JournalCreationStrategy

View Source

Provides the strategy for creating new content when new Journal content is imported into a layout set from a LAR. The default strategy implemented by this class is to return the first user in the database that is a member of the specified group as the author Id. If the group contains no users, the original author will remain unchanged.

Content will be added as is (i.e. no transformations).

Author:
Joel Kozikowski
See Also:
JournalContentPortletDataHandlerImpl

Constructor Summary
JournalCreationStrategyImpl()
           
 
Method Summary
 boolean addCommunityPermissions(long companyId, long groupId, java.lang.Object journalObj)
          Returns true if the default community permissions should be added when the specified journalObj is created.
 boolean addGuestPermissions(long companyId, long groupId, java.lang.Object journalObj)
          Returns true if the default guest permissions should be added when the specified journalObj is created.
 long getApprovalUserId(long companyId, long groupId, java.lang.Object journalObj)
          Returns the approver's user id to assign to newly created content.
 java.lang.String getApprovalUserName(long companyId, long groupId, java.lang.Object journalObj)
          Returns the approver's user name.
 long getAuthorUserId(long companyId, long groupId, java.lang.Object journalObj)
          Returns the author's user id to assign to newly created content.
 java.lang.String getAuthorUserName(long companyId, long groupId, java.lang.Object journalObj)
          Returns the author's user name.
protected  com.liferay.portal.model.User getFirstUser(long groupId)
           
 java.lang.String getTransformedContent(long companyId, long groupId, com.liferay.portlet.journal.model.JournalArticle newArticle)
          Gives the content creation strategy an opportunity to transform the content before the new article is saved to the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JournalCreationStrategyImpl

public JournalCreationStrategyImpl()
Method Detail

getAuthorUserId

public long getAuthorUserId(long companyId,
                            long groupId,
                            java.lang.Object journalObj)
                     throws java.lang.Exception
Description copied from interface: JournalCreationStrategy
Returns the author's user id to assign to newly created content. If null is returned, the original author of the exported content will be used.

Specified by:
getAuthorUserId in interface JournalCreationStrategy
Parameters:
companyId - the company id of the layout
groupId - the group id of the layout
journalObj - the new object must be an instance of JournalArticle, JournalStructure or JournalTemplate
Returns:
the author's user id, or 0 to use the original author
Throws:
java.lang.Exception

getAuthorUserName

public java.lang.String getAuthorUserName(long companyId,
                                          long groupId,
                                          java.lang.Object journalObj)
                                   throws java.lang.Exception
Description copied from interface: JournalCreationStrategy
Returns the author's user name. This method should be ignored if getAuthorUserId() returns null.

Specified by:
getAuthorUserName in interface JournalCreationStrategy
Parameters:
companyId - the company id of the layout
groupId - the group id of the layout
journalObj - the new object must be an instance of JournalArticle, JournalStructure or JournalTemplate
Returns:
the author's user name must not be null if getAuthorUserId() does not return null
Throws:
java.lang.Exception

getApprovalUserName

public java.lang.String getApprovalUserName(long companyId,
                                            long groupId,
                                            java.lang.Object journalObj)
                                     throws java.lang.Exception
Description copied from interface: JournalCreationStrategy
Returns the approver's user name. This method should be ignored if getApprovalUserId() returns null.

Specified by:
getApprovalUserName in interface JournalCreationStrategy
Parameters:
companyId - the company id of the layout
groupId - the group id of the layout
journalObj - the new object must be an instance of JournalArticle, JournalStructure or JournalTemplate
Returns:
the approver's user name must not be null if getApprovalUserId() does not return null
Throws:
java.lang.Exception

getApprovalUserId

public long getApprovalUserId(long companyId,
                              long groupId,
                              java.lang.Object journalObj)
                       throws java.lang.Exception
Description copied from interface: JournalCreationStrategy
Returns the approver's user id to assign to newly created content. If null is returned, the article will not be marked as approved.

Specified by:
getApprovalUserId in interface JournalCreationStrategy
Parameters:
companyId - the company id of the layout
groupId - the group id of the layout
journalObj - the new object must be an instance of JournalArticle, JournalStructure or JournalTemplate
Returns:
the approver's user id, or 0 if the article should not be approved
Throws:
java.lang.Exception

getTransformedContent

public java.lang.String getTransformedContent(long companyId,
                                              long groupId,
                                              com.liferay.portlet.journal.model.JournalArticle newArticle)
                                       throws java.lang.Exception
Description copied from interface: JournalCreationStrategy
Gives the content creation strategy an opportunity to transform the content before the new article is saved to the database. Possible use cases include using Velocity to merge in community specific values into the text. Returns the new content to assign to the article. If null is returned, the article content will be added unchanged.

Specified by:
getTransformedContent in interface JournalCreationStrategy
Parameters:
companyId - the company id of the layout
groupId - the group id of the layout
newArticle - the new article being created
Returns:
the transformed content to save in the database or null if the content should be added unchanged
Throws:
java.lang.Exception

addCommunityPermissions

public boolean addCommunityPermissions(long companyId,
                                       long groupId,
                                       java.lang.Object journalObj)
                                throws java.lang.Exception
Description copied from interface: JournalCreationStrategy
Returns true if the default community permissions should be added when the specified journalObj is created.

Specified by:
addCommunityPermissions in interface JournalCreationStrategy
Parameters:
companyId - the company id of the layout
groupId - the group id of the layout
journalObj - the new object must be an instance of JournalArticle, JournalStructure or JournalTemplate
Returns:
true if default community permissions should be added to the specified journalObj
Throws:
java.lang.Exception

addGuestPermissions

public boolean addGuestPermissions(long companyId,
                                   long groupId,
                                   java.lang.Object journalObj)
                            throws java.lang.Exception
Description copied from interface: JournalCreationStrategy
Returns true if the default guest permissions should be added when the specified journalObj is created.

Specified by:
addGuestPermissions in interface JournalCreationStrategy
Parameters:
companyId - the company id of the layout
groupId - the group id of the layout
journalObj - the new object must be an instance of JournalArticle, JournalStructure or JournalTemplate
Returns:
true if default guest permissions should be added to the specified journalObj
Throws:
java.lang.Exception

getFirstUser

protected com.liferay.portal.model.User getFirstUser(long groupId)
                                              throws java.lang.Exception
Throws:
java.lang.Exception