Interface UGCService<T extends UGC>
-
- All Known Implementing Classes:
UGCServiceImpl
public interface UGCService<T extends UGC>
Defines all Rest Services for UGCs.Implementers Must
- Audit all Calls
- Check that this call are made with an authenticated user and the the UGC belongs to the user's contextId.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.craftercms.commons.mongo.FileInfo
addAttachment(String ugcId, String contextId, InputStream attachment, String fileName, String contentType)
Adds and Attachment Information to the given UGC.long
count(String threadId, String contextId)
Counts all the First Level ugc of a target.long
countChildren(String ugcId, String contextId)
T
create(String contextId, String ugcParentId, String targetId, String textContent, String subject, Map<String,Object> attrs, boolean isAnonymous)
Creates an UGC.void
deleteAttribute(String ugcId, String[] name, String contextId)
Deletes a attribute of the given UGC.boolean
deleteUgc(String ugcId, String contextId)
Deletes a UGC If the Ugc is a parent it will delete the whole treeT
read(String ugcId, boolean includeChildren, int childCount, String contextId)
Gets a UGC with the given Id.T
read(String ugcId, String contextId)
Finds a single UGC.List<T>
read(String targetId, String contextId, int start, int limit, List<org.apache.commons.collections4.keyvalue.DefaultKeyValue<String,Boolean>> sortOrder, int upToLevel, int childrenPerLevel)
org.craftercms.commons.mongo.FileInfo
readAttachment(String ugcId, String contextId, String attachmentId)
<T extends UGC>
Iterable<T>readByTargetId(String targetId, String contextId)
List<T>
readChildren(String ugcId, String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel, int childrenPerLevel)
void
removeAttachment(String ugcId, String contextId, String attachmentId)
Deletes an attachment of the given UGC.Iterable<T>
search(String contextId, String query, String sort, int start, int limit)
Finds All UGC that match the given criteria.void
setAttributes(String ugcId, String contextId, Map<String,Object> attributes)
Sets an attribute to the given UGC Creates if does not existT
update(String ugcId, String body, String subject, String contextId, Map<String,Object> attributes)
Updates the given UGC with the given information.org.craftercms.commons.mongo.FileInfo
updateAttachment(String ugcId, String contextId, String attachmentId, InputStream newAttachment)
-
-
-
Method Detail
-
create
T create(String contextId, String ugcParentId, String targetId, String textContent, String subject, Map<String,Object> attrs, boolean isAnonymous) throws SocialException
Creates an UGC.
Implementers must check if the current user is allow to create UGC for that contextId
- Parameters:
contextId
- Context ID of the UGCugcParentId
- Parent Id of the UGC If not null or empty will be the parent of the UGC else it wont have any parent.targetId
- Target Id of the UGC.textContent
- Actual content of the UGC Must be cleanup to prevent XSS.subject
- Subject of the UGC.attrs
-isAnonymous
-- Returns:
- A new Public (secure) UGC.
- Throws:
SocialException
- If UGC can't be created.IllegalArgumentException
- If given parent UGC does not exist.
-
setAttributes
void setAttributes(String ugcId, String contextId, Map<String,Object> attributes) throws SocialException, UGCNotFound
Sets an attribute to the given UGC Creates if does not exist
Implementers must check if the current user is allow to removeWatcher UGC and that the user belongs to the same ugc contextId
.- Parameters:
ugcId
- Id of the Ugc to add Attribute.contextId
- Context ID of the UGC.attributes
- Attributes to set.Nested attributes Must be nested with in the map- Throws:
SocialException
- if attribute can be set.IllegalArgumentException
- If given UGC does not exist.*UGCNotFound
-
deleteAttribute
void deleteAttribute(String ugcId, String[] name, String contextId) throws SocialException
Deletes a attribute of the given UGC.Implementers must check if the current user is allow to removeWatcher UGC and that the user belongs to the same ugc contextId
.- Parameters:
ugcId
- id Id of the Ugc to add Attribute.name
- Attributes Name of the attribute to delete.contextId
- Context ID of the UGC- Throws:
SocialException
- if attribute can be deleted.IllegalArgumentException
- If given UGC does not exist.*
-
deleteUgc
boolean deleteUgc(String ugcId, String contextId) throws SocialException
Deletes a UGC If the Ugc is a parent it will delete the whole tree
Implementers must check if the current user is allow to delete UGC and that the user belongs to the same ugc contextId.t
. x- Parameters:
ugcId
- UGC id to delete.contextId
- Context ID of the UGC- Returns:
- True if UGC (and tree) can be deleted , false other wise.
- Throws:
SocialException
- if ugc (and or tree) can be deleted)IllegalArgumentException
- If given UGC does not exist.*
-
update
T update(String ugcId, String body, String subject, String contextId, Map<String,Object> attributes) throws SocialException, UGCNotFound
Updates the given UGC with the given information. Also it will removeWatcherImplementers must check if the current user is allow to removeWatcher UGC and that the user belongs to the same ugc contextId.
.- Parameters:
ugcId
- Id of the Ugc to removeWatcher.body
- new Text Content (empty of null to leave current value).subject
- new subject (empty of null to leave current value).contextId
-- Returns:
- the updated Public (secure) UGC.
- Throws:
SocialException
- If the UGC can be updated.IllegalArgumentException
- If given UGC does not exist.*UGCNotFound
-
read
T read(String ugcId, boolean includeChildren, int childCount, String contextId) throws UGCException
Gets a UGC with the given Id.Implementers must check if the current user is allow to read UGC and that the user belongs to the same ugc contextId.
.- Parameters:
ugcId
- Id of the desire UGCincludeChildren
- True to include the children of this UGC.childCount
- Amount of children to be include.negative Numbers to allcontextId
- contextId owner of the UGC- Returns:
- The UGC (and its children).
- Throws:
IllegalArgumentException
- If includeChildren is set to true and childCount is set to 0SocialException
- If is unable to get the UGC.UGCException
-
readByTargetId
<T extends UGC> Iterable<T> readByTargetId(String targetId, String contextId) throws UGCException
- Throws:
UGCException
-
search
Iterable<T> search(String contextId, String query, String sort, int start, int limit) throws UGCException
Finds All UGC that match the given criteria.- Parameters:
contextId
- Context ID of the UGCquery
- Query Map.sort
- Sort Map.start
- Where to start.limit
- How many results to return.- Returns:
- A list of all UGC that match the given criteria , if sort map is empty is unsorted
- Throws:
UGCException
-
addAttachment
org.craftercms.commons.mongo.FileInfo addAttachment(String ugcId, String contextId, InputStream attachment, String fileName, String contentType) throws org.apache.commons.io.FileExistsException, UGCException
Adds and Attachment Information to the given UGC.- Parameters:
ugcId
- Id of the desire UGC to attach a file.contextId
- Context ID of the UGCattachment
- Attachment to add.- Throws:
org.apache.commons.io.FileExistsException
UGCException
-
removeAttachment
void removeAttachment(String ugcId, String contextId, String attachmentId) throws UGCException, FileNotFoundException
Deletes an attachment of the given UGC.- Parameters:
ugcId
- UGC id to delete the attachment.contextId
- Context ID of the UGCattachmentId
- attachment Id to delete.- Throws:
FileNotFoundException
- If file is not foundIllegalUgcException
- If the given UGC id does not exists.UGCException
- If unable to delete the attachment or removeWatcher the UGC.
-
updateAttachment
org.craftercms.commons.mongo.FileInfo updateAttachment(String ugcId, String contextId, String attachmentId, InputStream newAttachment) throws UGCException, FileNotFoundException
- Throws:
UGCException
FileNotFoundException
-
readAttachment
org.craftercms.commons.mongo.FileInfo readAttachment(String ugcId, String contextId, String attachmentId) throws FileNotFoundException, UGCException
- Throws:
FileNotFoundException
UGCException
-
read
List<T> read(String targetId, String contextId, int start, int limit, List<org.apache.commons.collections4.keyvalue.DefaultKeyValue<String,Boolean>> sortOrder, int upToLevel, int childrenPerLevel) throws UGCException
- Throws:
UGCException
-
readChildren
List<T> readChildren(String ugcId, String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel, int childrenPerLevel) throws UGCException, UGCNotFound
- Throws:
UGCException
UGCNotFound
-
read
T read(String ugcId, String contextId) throws UGCException
Finds a single UGC.- Parameters:
ugcId
- Id of the Ugc.contextId
- Context ID of the UGC- Returns:
- The ugc with the given Id ,null if not found.
- Throws:
UGCException
-
count
long count(String threadId, String contextId) throws UGCException
Counts all the First Level ugc of a target.- Parameters:
threadId
- Id ot the target.contextId
- Context ID of the UGC- Returns:
- A count of all possible first level comments.
- Throws:
UGCException
-
countChildren
long countChildren(String ugcId, String contextId) throws UGCException
- Throws:
UGCException
-
-