Interface UGCService<T extends UGC>
- All Known Implementing Classes:
UGCServiceImpl
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
Modifier and TypeMethodDescriptionorg.craftercms.commons.mongo.FileInfoaddAttachment(String ugcId, String contextId, InputStream attachment, String fileName, String contentType) Adds and Attachment Information to the given UGC.longCounts all the First Level ugc of a target.longcountChildren(String ugcId, String contextId) create(String contextId, String ugcParentId, String targetId, String textContent, String subject, Map<String, Object> attrs, boolean isAnonymous) Creates an UGC.voiddeleteAttribute(String ugcId, String[] name, String contextId) Deletes a attribute of the given UGC.booleanDeletes a UGC If the Ugc is a parent it will delete the whole treeGets a UGC with the given Id.Finds a single UGC.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.FileInforeadAttachment(String ugcId, String contextId, String attachmentId) readByTargetId(String targetId, String contextId) readChildren(String ugcId, String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel, int childrenPerLevel) voidremoveAttachment(String ugcId, String contextId, String attachmentId) Deletes an attachment of the given UGC.Finds All UGC that match the given criteria.voidSets an attribute to the given UGC Creates if does not existUpdates the given UGC with the given information.org.craftercms.commons.mongo.FileInfoupdateAttachment(String ugcId, String contextId, String attachmentId, InputStream newAttachment)
-
Method Details
-
create
T create(String contextId, String ugcParentId, String targetId, String textContent, String subject, Map<String, Object> attrs, boolean isAnonymous) throws SocialExceptionCreates 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, UGCNotFoundSets 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
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
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, UGCNotFoundUpdates 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
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 0UGCException- If is unable to get the UGC.
-
readByTargetId
- 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.FileExistsExceptionUGCException
-
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:
UGCExceptionFileNotFoundException
-
readAttachment
org.craftercms.commons.mongo.FileInfo readAttachment(String ugcId, String contextId, String attachmentId) throws FileNotFoundException, UGCException - Throws:
FileNotFoundExceptionUGCException
-
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:
UGCExceptionUGCNotFound
-
read
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
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
- Throws:
UGCException
-