public interface UGCService<T extends UGC>
Implementers Must
Modifier and Type | Method and 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 tree
|
T |
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> |
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 exist
|
T |
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) |
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
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
- SocialException
- If UGC can't be created.IllegalArgumentException
- If given parent UGC does not exist.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
.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 mapSocialException
- if attribute can be set.IllegalArgumentException
- If given UGC does not exist.*UGCNotFound
void deleteAttribute(String ugcId, String[] name, String contextId) throws SocialException
Implementers must check if the current user is allow to removeWatcher UGC and that the user belongs to the same ugc contextId
.ugcId
- id Id of the Ugc to add Attribute.name
- Attributes Name of the attribute to delete.contextId
- Context ID of the UGCSocialException
- if attribute can be deleted.IllegalArgumentException
- If given UGC does not exist.*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
. xugcId
- UGC id to delete.contextId
- Context ID of the UGCSocialException
- if ugc (and or tree) can be deleted)IllegalArgumentException
- If given UGC does not exist.*T update(String ugcId, String body, String subject, String contextId, Map<String,Object> attributes) throws SocialException, UGCNotFound
Implementers must check if the current user is allow to removeWatcher UGC and that the user belongs to the same ugc contextId.
.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
- SocialException
- If the UGC can be updated.IllegalArgumentException
- If given UGC does not exist.*UGCNotFound
T read(String ugcId, boolean includeChildren, int childCount, String contextId) throws UGCException
Implementers must check if the current user is allow to read UGC and that the user belongs to the same ugc contextId.
.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 UGCIllegalArgumentException
- If includeChildren is set to true and childCount is
set to 0SocialException
- If is unable to get the UGC.UGCException
<T extends UGC> Iterable<T> readByTargetId(String targetId, String contextId) throws UGCException
UGCException
Iterable<T> search(String contextId, String query, String sort, int start, int limit) throws UGCException
contextId
- Context ID of the UGCquery
- Query Map.sort
- Sort Map.start
- Where to start.limit
- How many results to return.UGCException
org.craftercms.commons.mongo.FileInfo addAttachment(String ugcId, String contextId, InputStream attachment, String fileName, String contentType) throws org.apache.commons.io.FileExistsException, UGCException
ugcId
- Id of the desire UGC to attach a file.contextId
- Context ID of the UGCattachment
- Attachment to add.org.apache.commons.io.FileExistsException
UGCException
void removeAttachment(String ugcId, String contextId, String attachmentId) throws UGCException, FileNotFoundException
ugcId
- UGC id to delete the attachment.contextId
- Context ID of the UGCattachmentId
- attachment Id to delete.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.org.craftercms.commons.mongo.FileInfo updateAttachment(String ugcId, String contextId, String attachmentId, InputStream newAttachment) throws UGCException, FileNotFoundException
UGCException
FileNotFoundException
org.craftercms.commons.mongo.FileInfo readAttachment(String ugcId, String contextId, String attachmentId) throws FileNotFoundException, UGCException
FileNotFoundException
UGCException
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
UGCException
List<T> readChildren(String ugcId, String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel, int childrenPerLevel) throws UGCException, UGCNotFound
UGCException
UGCNotFound
T read(String ugcId, String contextId) throws UGCException
ugcId
- Id of the Ugc.contextId
- Context ID of the UGCUGCException
long count(String threadId, String contextId) throws UGCException
threadId
- Id ot the target.contextId
- Context ID of the UGCUGCException
long countChildren(String ugcId, String contextId) throws UGCException
UGCException
Copyright © 2018 CrafterCMS. All rights reserved.