public class UGCServiceImpl<T extends UGC> extends Object implements UGCService
| Constructor and Description |
|---|
UGCServiceImpl() |
| 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.
|
protected T |
buildUgcTree(List<T> ugs)
Given a list of results Builds A UGC Tree.
|
protected List<T> |
buildUgcTreeList(List<T> ugs,
int childrenPerLevel)
Given a list of results Builds A UGC Tree.
|
long |
count(String threadId,
String contextId)
Counts all the First Level ugc of a target.
|
long |
countChildren(String ugcId,
String contextId) |
UGC |
create(String contextId,
String ugcParentId,
String targetId,
String textContent,
String subject,
Map attrs,
boolean isAnonymous)
Creates an UGC.
|
void |
deleteAttribute(String ugcId,
String[] attributesName,
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
|
protected void |
findMyParent(Collection<T> possibleParents,
UGC orphanChild)
Finds the parent of the orphanChild in the list of possible parents.
|
protected boolean |
findRelatives(List<T> ugs,
T ugcToTest,
int childrenPerLevel)
Using ugcToTest goes though ugs one by one and checks if the element
either it's parent or one of it's children.
|
T |
read(String ugcId,
boolean includeChildren,
int childCount,
String contextId)
Gets a UGC with the given Id.
|
UGC |
read(String ugcId,
String contextId)
Finds a single UGC.
|
List<T> |
read(String targetId,
String contextId,
int start,
int limit,
List sortOrder,
int upToLevel,
int childrenPerLevel) |
org.craftercms.commons.mongo.FileInfo |
readAttachment(String ugcId,
String contextId,
String attachmentId) |
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 |
setArraySortFields(String arraySortFields) |
void |
setAttributes(String ugcId,
String contextId,
Map attributes)
Sets an attribute to the given UGC Creates if does not exist
|
void |
setInvalidQueryKeys(String invalidQueryKeysPattern) |
void |
setNotificationServiceImpl(NotificationService notificationService) |
void |
setPipeline(UgcPipeline pipeline) |
void |
setProfileService(org.craftercms.profile.api.services.ProfileService profileService) |
void |
setReactor(reactor.core.Reactor reactor) |
void |
setSocialUgcFactory(UgcFactory ugcFactory) |
void |
setTenantConfigurationService(TenantConfigurationService tenantConfigurationService) |
void |
setUGCRepositoryImpl(UGCRepository UGCRepositoryImpl) |
void |
setVirusScanner(VirusScanner virusScanner) |
UGC |
update(String ugcId,
String body,
String subject,
String contextId,
Map attributes)
Updates the given UGC with the given information.
|
org.craftercms.commons.mongo.FileInfo |
updateAttachment(String ugcId,
String contextId,
String attachmentId,
InputStream newAttachment) |
public UGC create(String contextId, String ugcParentId, String targetId, String textContent, String subject, Map attrs, boolean isAnonymous) throws SocialException
UGCServiceCreates an UGC.
Implementers must check if the current user is allow to create UGC for that contextId
create in interface UGCServicecontextId - 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.SocialException - If UGC can't be created.public void setNotificationServiceImpl(NotificationService notificationService)
public void setAttributes(String ugcId, String contextId, Map attributes) throws SocialException, UGCNotFound
UGCServiceSets 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
.setAttributes in interface UGCServiceugcId - 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.UGCNotFoundpublic void deleteAttribute(String ugcId, String[] attributesName, String contextId) throws SocialException
UGCServiceImplementers must check if the current user is allow to removeWatcher UGC and that the user belongs to the same ugc contextId
.deleteAttribute in interface UGCServiceugcId - id Id of the Ugc to add Attribute.attributesName - Attributes Name of the attribute to delete.contextId - Context ID of the UGCSocialException - if attribute can be deleted.public boolean deleteUgc(String ugcId, String contextId) throws SocialException
UGCServiceDeletes 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
. xdeleteUgc in interface UGCServiceugcId - UGC id to delete.contextId - Context ID of the UGCSocialException - if ugc (and or tree) can be deleted)public UGC update(String ugcId, String body, String subject, String contextId, Map attributes) throws SocialException, UGCNotFound
UGCServiceImplementers must check if the current user is allow to removeWatcher UGC and that the user belongs to the same ugc contextId.
.update in interface UGCServiceugcId - 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).SocialException - If the UGC can be updated.UGCNotFoundpublic T read(String ugcId, boolean includeChildren, int childCount, String contextId) throws UGCException
UGCServiceImplementers must check if the current user is allow to read UGC and that the user belongs to the same ugc contextId.
.read in interface UGCServiceugcId - 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 UGCUGCExceptionpublic Iterable<T> readByTargetId(String targetId, String contextId) throws UGCException
readByTargetId in interface UGCServiceUGCExceptionpublic Iterable<T> search(String contextId, String query, String sort, int start, int limit) throws UGCException
UGCServicesearch in interface UGCServicecontextId - Context ID of the UGCquery - Query Map.sort - Sort Map.start - Where to start.limit - How many results to return.UGCExceptionpublic org.craftercms.commons.mongo.FileInfo addAttachment(String ugcId, String contextId, InputStream attachment, String fileName, String contentType) throws org.apache.commons.io.FileExistsException, UGCException
UGCServiceaddAttachment in interface UGCServiceugcId - Id of the desire UGC to attach a file.contextId - Context ID of the UGCattachment - Attachment to add.org.apache.commons.io.FileExistsExceptionUGCExceptionpublic void removeAttachment(String ugcId, String contextId, String attachmentId) throws UGCException, FileNotFoundException
UGCServiceremoveAttachment in interface UGCServiceugcId - UGC id to delete the attachment.contextId - Context ID of the UGCattachmentId - attachment Id to delete.UGCException - If unable to delete the attachment or removeWatcher the
UGC.FileNotFoundException - If file is not foundpublic org.craftercms.commons.mongo.FileInfo updateAttachment(String ugcId, String contextId, String attachmentId, InputStream newAttachment) throws UGCException, FileNotFoundException
updateAttachment in interface UGCServiceUGCExceptionFileNotFoundExceptionpublic org.craftercms.commons.mongo.FileInfo readAttachment(String ugcId, String contextId, String attachmentId) throws FileNotFoundException, UGCException
readAttachment in interface UGCServiceFileNotFoundExceptionUGCExceptionpublic List<T> read(String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel, int childrenPerLevel) throws UGCException
read in interface UGCServiceUGCExceptionpublic List<T> readChildren(String ugcId, String targetId, String contextId, int start, int limit, List sortOrder, int upToLevel, int childrenPerLevel) throws UGCException, UGCNotFound
readChildren in interface UGCServiceUGCExceptionUGCNotFoundpublic UGC read(String ugcId, String contextId) throws UGCException
UGCServiceread in interface UGCServiceugcId - Id of the Ugc.contextId - Context ID of the UGCUGCExceptionpublic long count(String threadId, String contextId) throws UGCException
UGCServicecount in interface UGCServicethreadId - Id ot the target.contextId - Context ID of the UGCUGCExceptionpublic long countChildren(String ugcId, String contextId) throws UGCException
countChildren in interface UGCServiceUGCExceptionprotected List<T> buildUgcTreeList(List<T> ugs, int childrenPerLevel)
Given a list of results Builds A UGC Tree.
The main difference from buildUgcTree(java.util.List) is that this method allows
for multiple Roots or not roots at all
ugs - List of the UGS to build the tree.childrenPerLevel - Levels of Children.protected boolean findRelatives(List<T> ugs, T ugcToTest, int childrenPerLevel)
ugs - List of UGC to check against.ugcToTest - Ugc to check.childrenPerLevel - public void setReactor(reactor.core.Reactor reactor)
public void setUGCRepositoryImpl(UGCRepository UGCRepositoryImpl)
public void setPipeline(UgcPipeline pipeline)
public void setInvalidQueryKeys(String invalidQueryKeysPattern)
public void setArraySortFields(String arraySortFields)
public void setSocialUgcFactory(UgcFactory ugcFactory)
public void setVirusScanner(VirusScanner virusScanner)
protected T buildUgcTree(List<T> ugs)
Given a list of results Builds A UGC Tree.
The first element of the list will be taken as the root of the tree
ugs - List of the UGS to build the tree. First Element will be the root.protected void findMyParent(Collection<T> possibleParents, UGC orphanChild)
possibleParents - Possible parent of orphanChildorphanChild - UGC to find it's parent.public void setTenantConfigurationService(TenantConfigurationService tenantConfigurationService)
public void setProfileService(org.craftercms.profile.api.services.ProfileService profileService)
Copyright © 2018 CrafterCMS. All rights reserved.