@Transactional(readOnly=true) public class ShareBean extends AbstractLevel2Service implements LocalShare
SessionManager should not be used to obtain the Share
data since it may not be completely in sync. i.e. Don't use SM.find()IShare| Modifier and Type | Field and Description |
|---|---|
protected LocalAdmin |
admin |
protected Executor |
executor |
static org.slf4j.Logger |
log |
protected MailUtil |
mailUtil |
static String |
NS_COMMENT |
static String |
NS_ENABLED |
protected SessionManager |
sessionManager |
protected ShareStore |
store |
iQuery, iUpdate, metadata, queryFactory, sec| Constructor and Description |
|---|
ShareBean(LocalAdmin admin,
SessionManager mgr,
ShareStore store,
Executor executor,
MailUtil mailUtil) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_addGraph(ome.services.sharing.data.ShareData data,
ome.services.sharing.ShareBean.Graph g) |
void |
activate(long shareId)
Turns on the access control lists attached to the given share for the
current session.
|
CommentAnnotation |
addComment(long shareId,
String commentText)
|
void |
addGuest(long shareId,
String emailAddress)
Add guest email address to the share.
|
void |
addGuests(long shareId,
String... emailAddresses)
Adds guest email addresses to the share.
|
<T extends IObject> |
addObject(long shareId,
T object)
|
<T extends IObject> |
addObjects(long shareId,
T... objects)
|
CommentAnnotation |
addReply(long shareId,
String comment,
CommentAnnotation replyTo)
Creates
comment which replies to an existing
comment. |
void |
addUser(long shareId,
Experimenter exp)
Adds
experimenter to
share |
void |
addUsers(long shareId,
Experimenter... exps)
Adds
experimenters to
share |
protected void |
adminFlush() |
protected void |
applyIfShareAccessible(QueryBuilder qb)
If the current user is not an admin, then this methods adds a subclause
to the HQL:
AND ( share.owner.id = :userId or user.id = :userId )
QueryBuilder.where() should already have been called. |
void |
closeShare(long shareId)
Closes
share. |
<T extends IObject> |
createShare(String description,
Timestamp expiration,
List<T> items,
List<Experimenter> exps,
List<String> guests,
boolean enabled)
|
void |
deactivate()
Turns off the access control lists with the current share.
|
void |
deleteComment(Annotation comment)
Deletes
comment from the
database. |
static long |
expirationAsLong(long started,
Timestamp expiration)
Convert a
expiration into a long which can be set on
Session.setTimeToLive(Long). |
Map<String,Experimenter> |
getActiveConnections(long shareId)
Gets actual active connections to
share. |
Set<String> |
getAllGuests(long shareId)
Get the email addresses for all share guests.
|
Set<Experimenter> |
getAllMembers(long shareId)
Get all
users who are a member of the share. |
Set<String> |
getAllUsers(long shareId)
Get a single set containing the
login names
of the users as well email addresses for guests. |
Map<Long,Long> |
getCommentCount(Set<Long> ids)
Returns a map from share id to comment count.
|
List<Annotation> |
getComments(long shareId)
|
<T extends IObject> |
getContentMap(long shareId)
Returns the contents of the share keyed by type.
|
<T extends IObject> |
getContents(long shareId)
|
int |
getContentSize(long shareId)
Returns the number of items in the share.
|
<T extends IObject> |
getContentSubList(long shareId,
int start,
int finish)
Returns a range of items from the share.
|
List<Event> |
getEvents(long shareId,
Experimenter experimenter,
Timestamp from,
Timestamp to)
Gets events for
share per
experimenter for period of time. |
Map<Long,Long> |
getMemberCount(Set<Long> shareIds)
Returns a map from share id to the count of total members (including the
owner).
|
Set<Session> |
getMemberShares(boolean active)
Gets all shares where current
Experimenter is a member. |
Set<Session> |
getMemberSharesFor(Experimenter user,
boolean active)
Gets all shares where given
Experimenter is a member. |
Set<Session> |
getOwnShares(boolean active)
Gets all owned shares for the current
Experimenter |
Map<String,Experimenter> |
getPastConnections(long shareId)
Gets previous connections to
share. |
Class<? extends ServiceInterface> |
getServiceInterface() |
Share |
getShare(long sessionId)
|
protected ome.services.sharing.data.ShareData |
getShareIfAccessible(long shareId)
Loads share and checks it's owner and member data against the current
context (owner/member/admin).
|
Set<Session> |
getSharesOwnedBy(Experimenter user,
boolean active)
Gets all shares owned by the given
Experimenter. |
protected String |
idToUuid(long shareId) |
void |
invalidateConnection(long shareId,
Experimenter exp)
Makes the connection invalid for
share for
specifiec user. |
protected <T extends IObject> |
list(List<ome.services.sharing.data.Obj> objectList) |
protected List<Experimenter> |
loadMembers(ome.services.sharing.data.ShareData data) |
protected <T extends IObject> |
map(Map<String,List<Long>> map) |
void |
notifyMembersOfShare(long shareId,
String subject,
String message,
boolean html)
Notify via email selected members of share.
|
void |
removeGuest(long shareId,
String emailAddress)
Removes guest email address from share.
|
void |
removeGuests(long shareId,
String... emailAddresses)
Removes guest email addresses from the share.
|
<T extends IObject> |
removeObject(long shareId,
T object)
|
<T extends IObject> |
removeObjects(long shareId,
T... objects)
Remove existing items from the share.
|
void |
removeUser(long shareId,
Experimenter exp)
Removes
experimenter from
share |
void |
removeUsers(long shareId,
List<Experimenter> exps)
Removes
experimenters from
share |
void |
resetReadFilter(org.hibernate.Session s) |
void |
setActive(long shareId,
boolean active) |
void |
setDescription(long shareId,
String description) |
void |
setExpiration(long shareId,
Timestamp expiration) |
protected Set<Session> |
sharesToSessions(List<ome.services.sharing.data.ShareData> datas) |
protected Share |
shareToSession(ome.services.sharing.data.ShareData data) |
protected void |
storeShareData(long shareId,
ome.services.sharing.data.ShareData data) |
protected void |
throwOnNullData(long shareId,
ome.services.sharing.data.ShareData data) |
getBeanHelper, getExtendedMetadata, getQueryFactory, getSecuritySystem, selfConfigure, setExtendedMetadata, setQueryFactory, setQueryService, setSecuritySystem, setUpdateServicepublic static final org.slf4j.Logger log
public static final String NS_ENABLED
public static final String NS_COMMENT
protected final LocalAdmin admin
protected final SessionManager sessionManager
protected final ShareStore store
protected final Executor executor
protected final MailUtil mailUtil
public ShareBean(LocalAdmin admin, SessionManager mgr, ShareStore store, Executor executor, MailUtil mailUtil)
public final Class<? extends ServiceInterface> getServiceInterface()
getServiceInterface in interface SelfConfigurableServicepublic void activate(long shareId)
IShareValidationException is thrown.public void deactivate()
ISharedeactivate in interface ISharepublic void resetReadFilter(org.hibernate.Session s)
resetReadFilter in interface LocalSharepublic Map<Long,Long> getMemberCount(Set<Long> shareIds)
IShareShareMember links.getMemberCount in interface IShareshareIds - Not null.public Set<Session> getOwnShares(boolean active)
IShareExperimentergetOwnShares in interface IShareactive - if true, then only shares which can be used for login will be
returned. All "draft" shares (see
IShare.createShare(String, Timestamp, List, List, List, boolean)
and closed shares will be filtered.public Set<Session> getMemberShares(boolean active)
IShareExperimenter is a member.getMemberShares in interface IShareactive - if true, then only shares which can be used for login will be
returned. All "draft" shares (see
IShare.createShare(String, Timestamp, List, List, List, boolean)
and closed shares will be filtered.public Set<Session> getSharesOwnedBy(Experimenter user, boolean active)
IShareExperimenter.getSharesOwnedBy in interface IShareactive - if true, then only shares which can be used for login will be
returned. All "draft" shares (see
IShare.createShare(String, Timestamp, List, List, List, boolean)
and closed shares will be filtered.public Set<Session> getMemberSharesFor(Experimenter user, boolean active)
IShareExperimenter is a member.getMemberSharesFor in interface IShareactive - if true, then only shares which can be used for login will be
returned. All "draft" shares (see
IShare.createShare(String, Timestamp, List, List, List, boolean)
and closed shares will be filtered.public Share getShare(long sessionId)
IShareSession with all related:
comments,
members, fully loaded. Unlike the
other methods on this interface, if the sessionId is unknown, does not
throw a ValidationException.public <T extends IObject> List<T> getContents(long shareId)
ISharegetContents in interface ISharepublic <T extends IObject> List<T> getContentSubList(long shareId, int start, int finish)
ISharegetContentSubList in interface IShareIShare.getContents(long)public <T extends IObject> Map<Class<T>,List<Long>> getContentMap(long shareId)
ISharegetContentMap in interface ISharepublic int getContentSize(long shareId)
ISharegetContentSize in interface IShare@Transactional(readOnly=false) public <T extends IObject> long createShare(String description, Timestamp expiration, List<T> items, List<Experimenter> exps, List<String> guests, boolean enabled)
ISharecreateShare in interface IShareenabled - if true, then the share is immediately available for use. If
false, then the share is in draft state. All methods on this
interface will work for shares except
IShare.activate(long). Similarly, the share password cannot
be used by guests to login.@Transactional(readOnly=false) public void setDescription(long shareId, String description)
setDescription in interface IShare@Transactional(readOnly=false) public void setExpiration(long shareId, Timestamp expiration)
setExpiration in interface IShare@Transactional(readOnly=false) public void setActive(long shareId, boolean active)
@Transactional(readOnly=false) public void closeShare(long shareId)
IShareshare. No further logins will be
possible and all getters (e.g. IShare.getMemberShares(boolean),
IShare.getOwnShares(boolean), ...) will filter these results if
onlyActive is true.closeShare in interface IShare@Transactional(readOnly=false) public <T extends IObject> void addObjects(long shareId, T... objects)
IShareitems to
share. Conceptually calls
IShare.addObjects(long, IObject...) for every argument passed, but the
graphs will be merged.addObjects in interface IShare@Transactional(readOnly=false) public <T extends IObject> void addObject(long shareId, T object)
IShare@Transactional(readOnly=false) public <T extends IObject> void removeObjects(long shareId, T... objects)
IShareremoveObjects in interface IShare@Transactional(readOnly=false) public <T extends IObject> void removeObject(long shareId, T object)
IShareremoveObject in interface ISharepublic Map<Long,Long> getCommentCount(Set<Long> ids)
ISharegetCommentCount in interface IShareids - Not null.public List<Annotation> getComments(long shareId)
ISharegetComments in interface IShare@Transactional(readOnly=false) public CommentAnnotation addComment(long shareId, String commentText)
IShareaddComment in interface IShare@Transactional(readOnly=false) public CommentAnnotation addReply(long shareId, String comment, CommentAnnotation replyTo)
ISharecomment which replies to an existing
comment.addReply in interface IShareCommentAnnotation@Transactional(readOnly=false) public void deleteComment(Annotation comment)
ISharecomment from the
database.deleteComment in interface ISharepublic Set<Experimenter> getAllMembers(long shareId)
IShareusers who are a member of the share.getAllMembers in interface ISharepublic Set<String> getAllGuests(long shareId)
ISharegetAllGuests in interface ISharepublic Set<String> getAllUsers(long shareId) throws ValidationException
ISharelogin names
of the users as well email addresses for guests.getAllUsers in interface IShareSet containing the login of all usersValidationException - if there is a conflict between email addresses and user
names.@Transactional(readOnly=false) public void addUsers(long shareId, Experimenter... exps)
IShareexperimenters to
share@Transactional(readOnly=false) public void addGuests(long shareId, String... emailAddresses)
IShare@Transactional(readOnly=false) public void removeUsers(long shareId, List<Experimenter> exps)
IShareexperimenters from
shareremoveUsers in interface IShare@Transactional(readOnly=false) public void removeGuests(long shareId, String... emailAddresses)
IShareremoveGuests in interface IShare@Transactional(readOnly=false) public void addUser(long shareId, Experimenter exp)
IShareexperimenter to
share@Transactional(readOnly=false) public void addGuest(long shareId, String emailAddress)
IShare@Transactional(readOnly=false) public void removeUser(long shareId, Experimenter exp)
IShareexperimenter from
shareremoveUser in interface IShare@Transactional(readOnly=false) public void removeGuest(long shareId, String emailAddress)
IShareremoveGuest in interface ISharepublic Map<String,Experimenter> getActiveConnections(long shareId)
IShareshare.getActiveConnections in interface ISharepublic List<Event> getEvents(long shareId, Experimenter experimenter, Timestamp from, Timestamp to)
IShareshare per
experimenter for period of time.public Map<String,Experimenter> getPastConnections(long shareId)
IShareshare.getPastConnections in interface ISharepublic void invalidateConnection(long shareId,
Experimenter exp)
IShareshare for
specifiec user.invalidateConnection in interface IShareexp - - connection@Transactional(readOnly=false) public void notifyMembersOfShare(long shareId, String subject, String message, boolean html)
ISharenotifyMembersOfShare in interface IShareprotected String idToUuid(long shareId)
protected List<Experimenter> loadMembers(ome.services.sharing.data.ShareData data)
public static long expirationAsLong(long started,
Timestamp expiration)
expiration into a long which can be set on
Session.setTimeToLive(Long).protected Set<Session> sharesToSessions(List<ome.services.sharing.data.ShareData> datas)
protected Share shareToSession(ome.services.sharing.data.ShareData data)
protected void adminFlush()
protected void throwOnNullData(long shareId,
ome.services.sharing.data.ShareData data)
protected void applyIfShareAccessible(QueryBuilder qb)
QueryBuilder.where() should already have been called.protected ome.services.sharing.data.ShareData getShareIfAccessible(long shareId)
applyIfShareAccessible(QueryBuilder) which does the same check
at the database rather than binary data level.protected void _addGraph(ome.services.sharing.data.ShareData data,
ome.services.sharing.ShareBean.Graph g)
protected void storeShareData(long shareId,
ome.services.sharing.data.ShareData data)
Version: 5.3.3-ice35-b63
Copyright © 2017 The University of Dundee & Open Microscopy Environment. All Rights Reserved.