com.atlassian.confluence.core
Class DefaultContentEntityManager

java.lang.Object
  extended by com.atlassian.confluence.core.DefaultContentEntityManager
All Implemented Interfaces:
ContentEntityManager, ContentEntityManagerInternal
Direct Known Subclasses:
DefaultCommentManager, DefaultCustomContentManager, DefaultPageManager, DefaultPersonalInformationManager, DefaultSpaceDescriptionManager, DefaultUserStatusManager

public class DefaultContentEntityManager
extends java.lang.Object
implements ContentEntityManagerInternal


Field Summary
protected  AttachmentManager attachmentManager
           
protected  ContentEntityObjectDao contentEntityObjectDao
           
protected  com.atlassian.event.EventManager eventManager
           
protected  HibernateSessionManager hibernateSessionManager
           
protected  ConfluenceIndexer indexer
           
protected  LabelManager labelManager
           
protected  LinkManager linkManager
           
 
Fields inherited from interface com.atlassian.confluence.core.ContentEntityManager
ITERATE_ALL
 
Constructor Summary
DefaultContentEntityManager()
           
 
Method Summary
protected  BodyContent getBodyContentForRevert(ContentEntityObject historicalVersion)
           
 ContentEntityObject getById(ContentId id)
           
 ContentEntityObject getById(long id)
           
protected  com.atlassian.event.EventManager getEventManager()
           
 ContentEntityObject getNextVersion(ContentEntityObject ceo)
           
 ContentEntityObject getOtherVersion(ContentEntityObject ceo, int version)
           
protected  PageDao getPageDao()
           
 ContentEntityObject getPreviousVersion(ContentEntityObject ceo)
           
 java.util.Iterator getRecentlyAddedEntities(java.lang.String spaceKey, int maxResults)
          Retrieve an iterator of recently added entities, in order of most recent to last.
 java.util.Iterator getRecentlyModifiedEntities(java.lang.String spaceKey, int maxResults)
          Retrieve an iterator of recently modified entities, in order of most recent to last.
 java.util.Iterator getRecentlyModifiedEntitiesForUser(java.lang.String username)
          Retrieve an iterator of recently modified entities, in order of most recent to last.
 java.util.List getRecentlyModifiedForChangeDigest(java.util.Date fromDate)
          Retrieves a list of ContentEntityObjects that have been newly added or modified since the date specified.
 java.util.List<VersionHistorySummary> getVersionHistorySummaries(ContentEntityObject ceo)
          Get a VersionHistorySummary for all previous versions of a ContentEntityObject, starting with the current content.
protected  void publishCreateEvent(ContentEntityObject obj)
          This method publishes *CreateEventss.
protected  void publishCreateEvent(ContentEntityObject obj, SaveContext saveContext)
           
protected  void publishRemoveEvent(ContentEntityObject obj)
          This method publishes *RemoveEvents.
protected  void publishUpdateEvent(ContentEntityObject obj, ContentEntityObject origObj, SaveContext saveContext)
          This method publishes *UpdateEvents.
 void refreshContentEntity(ContentEntityObject obj)
          Refreshes the specified entity (including content) in the Hibernate session to ensure that subsequent retrievals are up-to-date.
 void removeContentEntity(ContentEntityObject obj)
          Removes given content entity object and all associated domain objects i.e.
 void removeHistoricalVersion(ContentEntityObject historicalVersion)
          Removes a historical ContentEntityObject.
 void revertContentEntityBackToVersion(ContentEntityObject entity, int version, java.lang.String revertComment, boolean revertTitle)
           Reverts a ContentEntityObject back to its state at the version specified by version.
 void saveContentEntity(ContentEntityObject obj, ContentEntityObject origObj, SaveContext saveContext)
          In order to create a history for this object, we need to pass in the modified as well as the original version of the object.
 void saveContentEntity(ContentEntityObject obj, SaveContext saveContext)
           
<T extends ContentEntityObject>
void
saveNewVersion(T current, Modification<T> modification)
          Applies the state changes supplied by modification and persists those changes to a new version.
<T extends ContentEntityObject>
void
saveNewVersion(T current, Modification<T> modification, SaveContext saveContext)
          Applies the state changes supplied by modification and persists those changes to a new version.
 void setAttachmentManager(AttachmentManager attachmentManager)
           
 void setContentEntityObjectDao(ContentEntityObjectDao contentEntityObjectDao)
           
 void setEventManager(com.atlassian.event.EventManager eventManager)
           
 void setHibernateSessionManager(HibernateSessionManager hibernateSessionManager)
           
 void setIndexer(ConfluenceIndexer indexer)
           
 void setLabelManager(LabelManager labelManager)
           
 void setLinkManager(LinkManager linkManager)
           
protected  void suppressNotificationsOnEventIfRequired(ContentEvent event, SaveContext saveContext)
          Sets suppressNotifications on the event if required by the SaveContext
 void updateContentLinkingTo(SpaceContentEntityObject contentBeingRefactored, java.lang.String newSpaceKey, java.lang.String newTitle)
          Deprecated. since 4.0.
 void updateContentLinkingTo(SpaceContentEntityObject contentBeingRefactored, java.lang.String newSpaceKey, java.lang.String newTitle, boolean saveNewVersion)
          Deprecated. since 4.0.
 void updateOutgoingLinksInContent(SpaceContentEntityObject contentBeingRefactored, java.lang.String newSpaceKey)
          Deprecated. since 4.0.
 void updateOutgoingLinksInContent(SpaceContentEntityObject contentBeingRefactored, java.lang.String newSpaceKey, boolean saveNewVersion)
          Deprecated. since 4.0.
 void updateSingleContentLinkinTo(ContentEntityObject referringContent, SpaceContentEntityObject contentBeingRefactored, java.lang.String newSpaceKey, java.lang.String newTitle)
          Deprecated. since 4.0.
 void updateSingleContentLinkinTo(ContentEntityObject referringContent, SpaceContentEntityObject contentBeingRefactored, java.lang.String newSpaceKey, java.lang.String newTitle, SaveContext saveContext)
          Deprecated. since 4.0.
 void updateSingleContentLinkinTo(ContentEntityObject referringContent, SpaceContentEntityObject contentBeingRefactored, java.lang.String newSpaceKey, java.lang.String newTitle, SaveContext saveContext, boolean saveNewVersion)
          Deprecated. since 4.0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contentEntityObjectDao

protected ContentEntityObjectDao contentEntityObjectDao

linkManager

protected LinkManager linkManager

indexer

protected ConfluenceIndexer indexer

eventManager

protected com.atlassian.event.EventManager eventManager

labelManager

protected LabelManager labelManager

attachmentManager

protected AttachmentManager attachmentManager

hibernateSessionManager

protected HibernateSessionManager hibernateSessionManager
Constructor Detail

DefaultContentEntityManager

public DefaultContentEntityManager()
Method Detail

refreshContentEntity

public void refreshContentEntity(ContentEntityObject obj)
Description copied from interface: ContentEntityManager
Refreshes the specified entity (including content) in the Hibernate session to ensure that subsequent retrievals are up-to-date.

Specified by:
refreshContentEntity in interface ContentEntityManager
Parameters:
obj - the object to be refreshed in the Hibernate session.

saveContentEntity

public void saveContentEntity(ContentEntityObject obj,
                              SaveContext saveContext)
Specified by:
saveContentEntity in interface ContentEntityManager
Parameters:
obj - - the ContentEntityObject to save
saveContext - - a SaveContext object for the manager.

saveContentEntity

public void saveContentEntity(ContentEntityObject obj,
                              ContentEntityObject origObj,
                              SaveContext saveContext)
Description copied from interface: ContentEntityManager
In order to create a history for this object, we need to pass in the modified as well as the original version of the object.

Specified by:
saveContentEntity in interface ContentEntityManager
saveContext - - a SaveContext holding additional parameters for the manager to use when saving.

saveNewVersion

public <T extends ContentEntityObject> void saveNewVersion(T current,
                                                           Modification<T> modification)
Description copied from interface: ContentEntityManager
Applies the state changes supplied by modification and persists those changes to a new version.
 manager.<Page>saveNewVersion(page, new Modification<Page>() {
      public void modify(Page page) {
          page.setTitle("foobar");
      }
 });
 

Specified by:
saveNewVersion in interface ContentEntityManager
Type Parameters:
T - the type content. This ensures that the type of current is the same as the type passed to the modification
Parameters:
current - the current / latest version
modification - an implementation of Modification which describes the state changes you require

saveNewVersion

public <T extends ContentEntityObject> void saveNewVersion(T current,
                                                           Modification<T> modification,
                                                           SaveContext saveContext)
Description copied from interface: ContentEntityManager
Applies the state changes supplied by modification and persists those changes to a new version.
 manager.<Page>saveNewVersion(page, new Modification<Page>() {
      public void modify(Page page) {
          page.setTitle("foobar");
      }
 }, new DefaultSaveContext());
 

Specified by:
saveNewVersion in interface ContentEntityManager
Type Parameters:
T - the type content. This ensures that the type of current is the same as the type passed to the modification
Parameters:
current - the current / latest version
modification - an implementation of Modification which describes the state changes you require
saveContext - the save context (null if you have no specific requirements - or just use ContentEntityManager.saveNewVersion(ContentEntityObject, Modification)).

removeContentEntity

public void removeContentEntity(ContentEntityObject obj)
Description copied from interface: ContentEntityManager
Removes given content entity object and all associated domain objects i.e. if we remove a page it removes all its labels and attachments

Specified by:
removeContentEntity in interface ContentEntityManager

getById

public ContentEntityObject getById(long id)
Specified by:
getById in interface ContentEntityManager
Returns:
ContentEntityObject with the given id.

getById

public ContentEntityObject getById(ContentId id)
Specified by:
getById in interface ContentEntityManagerInternal
Returns:
ContentEntityObject with the given id.

revertContentEntityBackToVersion

public void revertContentEntityBackToVersion(ContentEntityObject entity,
                                             int version,
                                             java.lang.String revertComment,
                                             boolean revertTitle)
Description copied from interface: ContentEntityManager

Reverts a ContentEntityObject back to its state at the version specified by version. Creates a new latest version that resembles the previous state.

Since Confluence 4.0 most ContentEntityObjects are assumed to be XHTML formatted. So in reverting a ContentEntityObject which actually has a WIKI BodyType this will be migrated on the fly to XHTML.

Specified by:
revertContentEntityBackToVersion in interface ContentEntityManager
Parameters:
entity - The ContentEntityObject to revert
version - The version to revert to
revertComment - A comment to be associated with the revert
revertTitle - If true, the ContentEntityObject title will be reverted to the old state

getBodyContentForRevert

protected BodyContent getBodyContentForRevert(ContentEntityObject historicalVersion)

getRecentlyAddedEntities

public java.util.Iterator getRecentlyAddedEntities(java.lang.String spaceKey,
                                                   int maxResults)
Description copied from interface: ContentEntityManager
Retrieve an iterator of recently added entities, in order of most recent to last. The iterator is lazy-loading, so you can filter the output and return the first 'n' that interest you. For performance reasons, it's a VERY bad idea to supply both a space key, and infinite results. If you supply a space key, this WILL NOT RETURN ANY COMMENTS. There is currently no way around this, you have to retrieve comments separately and splice the results together. Sorry.

Specified by:
getRecentlyAddedEntities in interface ContentEntityManager
Parameters:
spaceKey - the space key to look up the entities for. If spaceKey is null, there is assumed to be no space, and things like user info and space descriptions will also be returned.
maxResults - the maximum number of entities to return in the iterator. Any number zero or less (Use the ITERATE_ALL constant) will cause the iterator to go over every entity.

getRecentlyModifiedEntities

public java.util.Iterator getRecentlyModifiedEntities(java.lang.String spaceKey,
                                                      int maxResults)
Description copied from interface: ContentEntityManager
Retrieve an iterator of recently modified entities, in order of most recent to last. The iterator is lazy-loading, so you can filter the output and return the first 'n' that interest you. For performance reasons, it's a VERY bad idea to supply both a space key, and infinite results.

Specified by:
getRecentlyModifiedEntities in interface ContentEntityManager
Parameters:
spaceKey - the space key to look up the entities for.
maxResults - the maximum number of entities to return in the iterator. Any number zero or less (Use the ITERATE_ALL constant) will cause the iterator to go over every entity.

getRecentlyModifiedEntitiesForUser

public java.util.Iterator getRecentlyModifiedEntitiesForUser(java.lang.String username)
Description copied from interface: ContentEntityManager
Retrieve an iterator of recently modified entities, in order of most recent to last. The iterator is lazy-loading, so you can filter the output and return the first 'n' that interest you.

Specified by:
getRecentlyModifiedEntitiesForUser in interface ContentEntityManager
Parameters:
username - the user for which to retrieve the modified content

getRecentlyModifiedForChangeDigest

public java.util.List getRecentlyModifiedForChangeDigest(java.util.Date fromDate)
Description copied from interface: ContentEntityManager
Retrieves a list of ContentEntityObjects that have been newly added or modified since the date specified. This list excludes drafts, space descriptions and mail.

Specified by:
getRecentlyModifiedForChangeDigest in interface ContentEntityManager
Parameters:
fromDate - content modified after this date will be returned
Returns:
a list of ContentEntityObjects that have been newly added or modified since the date specified

updateOutgoingLinksInContent

@Deprecated
public void updateOutgoingLinksInContent(SpaceContentEntityObject contentBeingRefactored,
                                                    java.lang.String newSpaceKey)
Deprecated. since 4.0.

Description copied from interface: ContentEntityManager
Update the links on the page itself. If links are local (refering to the current space), a spacekey has to be added to the link

Specified by:
updateOutgoingLinksInContent in interface ContentEntityManager

updateOutgoingLinksInContent

@Deprecated
public void updateOutgoingLinksInContent(SpaceContentEntityObject contentBeingRefactored,
                                                    java.lang.String newSpaceKey,
                                                    boolean saveNewVersion)
Deprecated. since 4.0.

Update the links on the page itself. If links are local (refering to the current space), a spacekey has to be added to the link


updateContentLinkingTo

@Deprecated
public void updateContentLinkingTo(SpaceContentEntityObject contentBeingRefactored,
                                              java.lang.String newSpaceKey,
                                              java.lang.String newTitle)
Deprecated. since 4.0.

Description copied from interface: ContentEntityManager
Loops through all the content that currently links to 'contentBeingChanged' and renames all the links.
This will skip any referring content that is the 'contentBeingChanged' (i.e. content links to itself).
If you only want to change the links of a specific content object, use the 'updateSingleContentLinkinTo' function.
This rename will be recorded in the content's history

Specified by:
updateContentLinkingTo in interface ContentEntityManager

updateContentLinkingTo

@Deprecated
public void updateContentLinkingTo(SpaceContentEntityObject contentBeingRefactored,
                                              java.lang.String newSpaceKey,
                                              java.lang.String newTitle,
                                              boolean saveNewVersion)
Deprecated. since 4.0.


updateSingleContentLinkinTo

@Deprecated
public void updateSingleContentLinkinTo(ContentEntityObject referringContent,
                                                   SpaceContentEntityObject contentBeingRefactored,
                                                   java.lang.String newSpaceKey,
                                                   java.lang.String newTitle)
Deprecated. since 4.0.

Description copied from interface: ContentEntityManager
Renames all links contained in the 'referringContent' that currently links to 'contentBeingRefactored'.
This rename will be recorded in the content's history

Specified by:
updateSingleContentLinkinTo in interface ContentEntityManager

updateSingleContentLinkinTo

@Deprecated
public void updateSingleContentLinkinTo(ContentEntityObject referringContent,
                                                   SpaceContentEntityObject contentBeingRefactored,
                                                   java.lang.String newSpaceKey,
                                                   java.lang.String newTitle,
                                                   SaveContext saveContext)
Deprecated. since 4.0.

Specified by:
updateSingleContentLinkinTo in interface ContentEntityManager

updateSingleContentLinkinTo

@Deprecated
public void updateSingleContentLinkinTo(ContentEntityObject referringContent,
                                                   SpaceContentEntityObject contentBeingRefactored,
                                                   java.lang.String newSpaceKey,
                                                   java.lang.String newTitle,
                                                   SaveContext saveContext,
                                                   boolean saveNewVersion)
Deprecated. since 4.0.


getPreviousVersion

public ContentEntityObject getPreviousVersion(ContentEntityObject ceo)
Specified by:
getPreviousVersion in interface ContentEntityManager

getNextVersion

public ContentEntityObject getNextVersion(ContentEntityObject ceo)
Specified by:
getNextVersion in interface ContentEntityManager

getOtherVersion

public ContentEntityObject getOtherVersion(ContentEntityObject ceo,
                                           int version)
Specified by:
getOtherVersion in interface ContentEntityManager

getVersionHistorySummaries

public java.util.List<VersionHistorySummary> getVersionHistorySummaries(ContentEntityObject ceo)
Description copied from interface: ContentEntityManager
Get a VersionHistorySummary for all previous versions of a ContentEntityObject, starting with the current content.

Specified by:
getVersionHistorySummaries in interface ContentEntityManager
Parameters:
ceo - the entity object to return the version history of
Returns:
the full version history of that object, as VersionHistorySummary objects.

removeHistoricalVersion

public void removeHistoricalVersion(ContentEntityObject historicalVersion)
Description copied from interface: ContentEntityManager
Removes a historical ContentEntityObject.

Specified by:
removeHistoricalVersion in interface ContentEntityManager
Parameters:
historicalVersion - a historical entity object to remove

getPageDao

protected PageDao getPageDao()

publishCreateEvent

protected void publishCreateEvent(ContentEntityObject obj)
This method publishes *CreateEventss. Specific content entity object manager that need to publish those events should override this method.

Parameters:
obj - the created content entity object

publishCreateEvent

protected void publishCreateEvent(ContentEntityObject obj,
                                  SaveContext saveContext)

publishUpdateEvent

protected void publishUpdateEvent(ContentEntityObject obj,
                                  ContentEntityObject origObj,
                                  SaveContext saveContext)
This method publishes *UpdateEvents. Specific content entity object manager that need to publish those events should override this method.

Parameters:
obj - the updated content entity object
origObj - the old version of the content entity object, for history purpose
saveContext - the associated SaveContext

publishRemoveEvent

protected void publishRemoveEvent(ContentEntityObject obj)
This method publishes *RemoveEvents. Specific content entity object manager that need to publish those events should override this method.

Parameters:
obj - the removed content entity object

suppressNotificationsOnEventIfRequired

protected void suppressNotificationsOnEventIfRequired(ContentEvent event,
                                                      SaveContext saveContext)
Sets suppressNotifications on the event if required by the SaveContext

Parameters:
event -
saveContext -

setEventManager

public void setEventManager(com.atlassian.event.EventManager eventManager)
Specified by:
setEventManager in interface ContentEntityManager

setLabelManager

public void setLabelManager(LabelManager labelManager)

getEventManager

protected com.atlassian.event.EventManager getEventManager()

setIndexer

public void setIndexer(ConfluenceIndexer indexer)

setAttachmentManager

public void setAttachmentManager(AttachmentManager attachmentManager)

setContentEntityObjectDao

public void setContentEntityObjectDao(ContentEntityObjectDao contentEntityObjectDao)

setLinkManager

public void setLinkManager(LinkManager linkManager)

setHibernateSessionManager

public void setHibernateSessionManager(HibernateSessionManager hibernateSessionManager)


Copyright © 2003-2014 Atlassian. All Rights Reserved.