com.atlassian.confluence.content.apisupport
Class BaseContentTypeApiSupport<T extends ContentConvertible>

java.lang.Object
  extended by com.atlassian.confluence.content.apisupport.BaseContentTypeApiSupport<T>
All Implemented Interfaces:
ContentTypeApiSupport<T>
Direct Known Subclasses:
AttachmentContentTypeApiSupport, BlogPostContentTypeApiSupport, CommentContentTypeApiSupport, CustomContentTypeApiSupport, DummyCurrentVersionContentTypeApiSupport, DummyOriginalVersionContentTypeApiSupport, PageContentTypeApiSupport

@ExperimentalSpi
public abstract class BaseContentTypeApiSupport<T extends ContentConvertible>
extends Object
implements ContentTypeApiSupport<T>

A subclass for extensible content type support in the api

Since:
5.7

Constructor Summary
protected BaseContentTypeApiSupport(ApiSupportProvider provider)
           
 
Method Summary
 T create(Content content)
          Create a new persistent entity for the given api content
 PageResponse<Content> getChildren(ContentConvertible content, LimitedRequest limitedRequest, Expansions expansions, Depth depth, com.google.common.base.Predicate<? super ContentEntityObject> predicate)
          Retrieve the children of an item of Content.
protected abstract  PageResponse<Content> getChildrenForThisType(T content, LimitedRequest limitedRequest, Expansions expansions, Depth depth)
           
protected  PageResponse<Content> getChildrenForThisType(T content, LimitedRequest limitedRequest, Expansions expansions, Depth depth, com.google.common.base.Predicate<? super ContentEntityObject> predicate)
          This method includes an additional parameter "location", it will call the default one if not overridden
protected abstract  PageResponse<Content> getChildrenOfThisTypeForOtherType(ContentConvertible otherTypeParent, LimitedRequest limitedRequest, Expansions expansions, Depth depth)
           
protected  PageResponse<Content> getChildrenOfThisTypeForOtherType(ContentConvertible otherTypeParent, LimitedRequest limitedRequest, Expansions expansions, Depth depth, com.google.common.base.Predicate<? super ContentEntityObject> predicate)
          This method includes an additional parameter "location", it will call the default one if not overridden
 com.atlassian.fugue.Option<Object> getContainer(T contentEntity, Expansions expansions)
          The return type of this method is intentionly broad.
 Map<ContentId,Map<String,Object>> getExtensions(Iterable<T> contentEntities, Expansions expansions)
          Get the set of extension properties for the collection of contentEntity Ids.
 List<Link> getLinks(T contentEntity)
          Get additional link properties for the _links map Implementors should override and provide links for the given contentEntity
abstract  boolean supportsChildrenForParentType(ContentType parentType)
           
abstract  boolean supportsChildrenOfType(ContentType otherType)
          A check that to allow other ContentTypeApiSupports to provide children for this type
 T update(Content content, T entity)
          Updates an existing persistent entity from the given api content
 ValidationResult validateCreate(Content newContent)
          Validate the create operation
 ValidationResult validateUpdate(Content updatedContent, T existingEntity)
          Validate the update operation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.confluence.content.apisupport.ContentTypeApiSupport
getEntityClass, getHandledType
 

Constructor Detail

BaseContentTypeApiSupport

protected BaseContentTypeApiSupport(ApiSupportProvider provider)
Method Detail

getChildren

public final PageResponse<Content> getChildren(ContentConvertible content,
                                               LimitedRequest limitedRequest,
                                               Expansions expansions,
                                               Depth depth,
                                               com.google.common.base.Predicate<? super ContentEntityObject> predicate)
Retrieve the children of an item of Content.

Specified by:
getChildren in interface ContentTypeApiSupport<T extends ContentConvertible>

getChildrenForThisType

protected abstract PageResponse<Content> getChildrenForThisType(T content,
                                                                LimitedRequest limitedRequest,
                                                                Expansions expansions,
                                                                Depth depth)

getChildrenForThisType

protected PageResponse<Content> getChildrenForThisType(T content,
                                                       LimitedRequest limitedRequest,
                                                       Expansions expansions,
                                                       Depth depth,
                                                       com.google.common.base.Predicate<? super ContentEntityObject> predicate)
This method includes an additional parameter "location", it will call the default one if not overridden

Since:
5.7

getChildrenOfThisTypeForOtherType

protected abstract PageResponse<Content> getChildrenOfThisTypeForOtherType(ContentConvertible otherTypeParent,
                                                                           LimitedRequest limitedRequest,
                                                                           Expansions expansions,
                                                                           Depth depth)

getChildrenOfThisTypeForOtherType

protected PageResponse<Content> getChildrenOfThisTypeForOtherType(ContentConvertible otherTypeParent,
                                                                  LimitedRequest limitedRequest,
                                                                  Expansions expansions,
                                                                  Depth depth,
                                                                  com.google.common.base.Predicate<? super ContentEntityObject> predicate)
This method includes an additional parameter "location", it will call the default one if not overridden

Since:
5.7

supportsChildrenOfType

public abstract boolean supportsChildrenOfType(ContentType otherType)
A check that to allow other ContentTypeApiSupports to provide children for this type

Specified by:
supportsChildrenOfType in interface ContentTypeApiSupport<T extends ContentConvertible>
Parameters:
otherType - - the other Content type that wants to offer children of our type
Returns:
true if the children should be allowed

supportsChildrenForParentType

public abstract boolean supportsChildrenForParentType(ContentType parentType)
Specified by:
supportsChildrenForParentType in interface ContentTypeApiSupport<T extends ContentConvertible>
Returns:
true if Content of this binding's ContentType can be a child of contentEntity of the given type

getExtensions

public Map<ContentId,Map<String,Object>> getExtensions(Iterable<T> contentEntities,
                                                       Expansions expansions)
Get the set of extension properties for the collection of contentEntity Ids. Dealing with collections here may help reduce the number of db queries we need to execute. Implementors should override to provide extensions for the given contentEntity.

Specified by:
getExtensions in interface ContentTypeApiSupport<T extends ContentConvertible>

getLinks

public List<Link> getLinks(T contentEntity)
Get additional link properties for the _links map Implementors should override and provide links for the given contentEntity

Specified by:
getLinks in interface ContentTypeApiSupport<T extends ContentConvertible>

getContainer

public com.atlassian.fugue.Option<Object> getContainer(T contentEntity,
                                                       Expansions expansions)
The return type of this method is intentionly broad. Implementors can choose to return the commonly handled container hibernate entities, namely Space, Page or BlogPost, or can choose to provide a model object that implements the api Container interface, no further conversion of instances of Container objects will occur.

Specified by:
getContainer in interface ContentTypeApiSupport<T extends ContentConvertible>
Parameters:
contentEntity - - the content entity to get the container object for
Returns:
either a Space, Page or BlogPost or an instance of Container

create

public T create(Content content)
Description copied from interface: ContentTypeApiSupport
Create a new persistent entity for the given api content

Specified by:
create in interface ContentTypeApiSupport<T extends ContentConvertible>
Parameters:
content - the model object to create a persistent entity for
Returns:
the newly created persistent entity

validateCreate

public ValidationResult validateCreate(Content newContent)
Description copied from interface: ContentTypeApiSupport
Validate the create operation

Specified by:
validateCreate in interface ContentTypeApiSupport<T extends ContentConvertible>
Parameters:
newContent - the content that will be used to create an entity
Returns:
a validation result wrapping any validation errors that were encountered

update

public T update(Content content,
                T entity)
Description copied from interface: ContentTypeApiSupport
Updates an existing persistent entity from the given api content

Specified by:
update in interface ContentTypeApiSupport<T extends ContentConvertible>
Parameters:
content - the updated content
entity - the existing entity
Returns:
the updated entity

validateUpdate

public ValidationResult validateUpdate(Content updatedContent,
                                       T existingEntity)
Description copied from interface: ContentTypeApiSupport
Validate the update operation

Specified by:
validateUpdate in interface ContentTypeApiSupport<T extends ContentConvertible>
Parameters:
updatedContent - the content that will be used to update the entity
existingEntity - the existing entity to be updated
Returns:
a validation result wrapping any validation errors that were encountered


Copyright © 2003–2015 Atlassian. All rights reserved.