@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 java.lang.String |
NS_COMMENT |
static java.lang.String |
NS_ENABLED |
protected SessionManager |
sessionManager |
protected ShareStore |
store |
iQuery, iUpdate, metadata, queryFactory, readOnlyStatus, sec
Constructor and Description |
---|
ShareBean(LocalAdmin admin,
SessionManager mgr,
ShareStore store,
Executor executor,
MailUtil mailUtil) |
Modifier and Type | Method and Description |
---|---|
protected void |
_addGraph(ShareData data,
ome.services.sharing.ShareBean.Graph g) |
void |
activate(long shareId) |
ome.model.annotations.CommentAnnotation |
addComment(long shareId,
java.lang.String commentText) |
void |
addGuest(long shareId,
java.lang.String emailAddress) |
void |
addGuests(long shareId,
java.lang.String... emailAddresses) |
<T extends ome.model.IObject> |
addObject(long shareId,
T object) |
<T extends ome.model.IObject> |
addObjects(long shareId,
T... objects) |
ome.model.annotations.CommentAnnotation |
addReply(long shareId,
java.lang.String comment,
ome.model.annotations.CommentAnnotation replyTo) |
void |
addUser(long shareId,
ome.model.meta.Experimenter exp) |
void |
addUsers(long shareId,
ome.model.meta.Experimenter... exps) |
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) |
<T extends ome.model.IObject> |
createShare(java.lang.String description,
java.sql.Timestamp expiration,
java.util.List<T> items,
java.util.List<ome.model.meta.Experimenter> exps,
java.util.List<java.lang.String> guests,
boolean enabled) |
void |
deactivate() |
void |
deleteComment(ome.model.annotations.Annotation comment) |
static long |
expirationAsLong(long started,
java.sql.Timestamp expiration)
Convert a
expiration into a long which can be set on
Session.setTimeToLive(Long) . |
java.util.Map<java.lang.String,ome.model.meta.Experimenter> |
getActiveConnections(long shareId) |
java.util.Set<java.lang.String> |
getAllGuests(long shareId) |
java.util.Set<ome.model.meta.Experimenter> |
getAllMembers(long shareId) |
java.util.Set<java.lang.String> |
getAllUsers(long shareId) |
java.util.Map<java.lang.Long,java.lang.Long> |
getCommentCount(java.util.Set<java.lang.Long> ids) |
java.util.List<ome.model.annotations.Annotation> |
getComments(long shareId) |
<T extends ome.model.IObject> |
getContentMap(long shareId) |
<T extends ome.model.IObject> |
getContents(long shareId) |
int |
getContentSize(long shareId) |
<T extends ome.model.IObject> |
getContentSubList(long shareId,
int start,
int finish) |
java.util.List<ome.model.meta.Event> |
getEvents(long shareId,
ome.model.meta.Experimenter experimenter,
java.sql.Timestamp from,
java.sql.Timestamp to) |
java.util.Map<java.lang.Long,java.lang.Long> |
getMemberCount(java.util.Set<java.lang.Long> shareIds) |
java.util.Set<ome.model.meta.Session> |
getMemberShares(boolean active) |
java.util.Set<ome.model.meta.Session> |
getMemberSharesFor(ome.model.meta.Experimenter user,
boolean active) |
java.util.Set<ome.model.meta.Session> |
getOwnShares(boolean active) |
java.util.Map<java.lang.String,ome.model.meta.Experimenter> |
getPastConnections(long shareId) |
java.lang.Class<? extends ome.api.ServiceInterface> |
getServiceInterface() |
ome.model.meta.Share |
getShare(long sessionId) |
protected ShareData |
getShareIfAccessible(long shareId)
Loads share and checks it's owner and member data against the current
context (owner/member/admin).
|
java.util.Set<ome.model.meta.Session> |
getSharesOwnedBy(ome.model.meta.Experimenter user,
boolean active) |
protected java.lang.String |
idToUuid(long shareId) |
void |
invalidateConnection(long shareId,
ome.model.meta.Experimenter exp) |
protected <T extends ome.model.IObject> |
list(java.util.List<Obj> objectList) |
protected java.util.List<ome.model.meta.Experimenter> |
loadMembers(ShareData data) |
protected <T extends ome.model.IObject> |
map(java.util.Map<java.lang.String,java.util.List<java.lang.Long>> map) |
void |
notifyMembersOfShare(long shareId,
java.lang.String subject,
java.lang.String message,
boolean html) |
void |
removeGuest(long shareId,
java.lang.String emailAddress) |
void |
removeGuests(long shareId,
java.lang.String... emailAddresses) |
<T extends ome.model.IObject> |
removeObject(long shareId,
T object) |
<T extends ome.model.IObject> |
removeObjects(long shareId,
T... objects) |
void |
removeUser(long shareId,
ome.model.meta.Experimenter exp) |
void |
removeUsers(long shareId,
java.util.List<ome.model.meta.Experimenter> exps) |
void |
resetReadFilter(org.hibernate.Session s) |
void |
setActive(long shareId,
boolean active) |
void |
setDescription(long shareId,
java.lang.String description) |
void |
setExpiration(long shareId,
java.sql.Timestamp expiration) |
protected java.util.Set<ome.model.meta.Session> |
sharesToSessions(java.util.List<ShareData> datas) |
protected ome.model.meta.Share |
shareToSession(ShareData data) |
protected void |
storeShareData(long shareId,
ShareData data) |
protected void |
throwOnNullData(long shareId,
ShareData data) |
getBeanHelper, getExtendedMetadata, getQueryFactory, getSecuritySystem, selfConfigure, setExtendedMetadata, setQueryFactory, setQueryService, setReadOnlyStatus, setSecuritySystem, setUpdateService
public static final org.slf4j.Logger log
public static final java.lang.String NS_ENABLED
public static final java.lang.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 java.lang.Class<? extends ome.api.ServiceInterface> getServiceInterface()
getServiceInterface
in interface ome.system.SelfConfigurableService
public void activate(long shareId)
activate
in interface ome.api.IShare
public void deactivate()
deactivate
in interface ome.api.IShare
public void resetReadFilter(org.hibernate.Session s)
resetReadFilter
in interface LocalShare
public java.util.Map<java.lang.Long,java.lang.Long> getMemberCount(java.util.Set<java.lang.Long> shareIds)
getMemberCount
in interface ome.api.IShare
public java.util.Set<ome.model.meta.Session> getOwnShares(boolean active)
getOwnShares
in interface ome.api.IShare
public java.util.Set<ome.model.meta.Session> getMemberShares(boolean active)
getMemberShares
in interface ome.api.IShare
public java.util.Set<ome.model.meta.Session> getSharesOwnedBy(ome.model.meta.Experimenter user, boolean active)
getSharesOwnedBy
in interface ome.api.IShare
public java.util.Set<ome.model.meta.Session> getMemberSharesFor(ome.model.meta.Experimenter user, boolean active)
getMemberSharesFor
in interface ome.api.IShare
public ome.model.meta.Share getShare(long sessionId)
getShare
in interface ome.api.IShare
public <T extends ome.model.IObject> java.util.List<T> getContents(long shareId)
getContents
in interface ome.api.IShare
public <T extends ome.model.IObject> java.util.List<T> getContentSubList(long shareId, int start, int finish)
getContentSubList
in interface ome.api.IShare
public <T extends ome.model.IObject> java.util.Map<java.lang.Class<T>,java.util.List<java.lang.Long>> getContentMap(long shareId)
getContentMap
in interface ome.api.IShare
public int getContentSize(long shareId)
getContentSize
in interface ome.api.IShare
@Transactional(readOnly=false) public <T extends ome.model.IObject> long createShare(java.lang.String description, java.sql.Timestamp expiration, java.util.List<T> items, java.util.List<ome.model.meta.Experimenter> exps, java.util.List<java.lang.String> guests, boolean enabled)
createShare
in interface ome.api.IShare
@Transactional(readOnly=false) public void setDescription(long shareId, java.lang.String description)
setDescription
in interface ome.api.IShare
@Transactional(readOnly=false) public void setExpiration(long shareId, java.sql.Timestamp expiration)
setExpiration
in interface ome.api.IShare
@Transactional(readOnly=false) public void setActive(long shareId, boolean active)
setActive
in interface ome.api.IShare
@Transactional(readOnly=false) public void closeShare(long shareId)
closeShare
in interface ome.api.IShare
@Transactional(readOnly=false) public <T extends ome.model.IObject> void addObjects(long shareId, T... objects)
addObjects
in interface ome.api.IShare
@Transactional(readOnly=false) public <T extends ome.model.IObject> void addObject(long shareId, T object)
addObject
in interface ome.api.IShare
@Transactional(readOnly=false) public <T extends ome.model.IObject> void removeObjects(long shareId, T... objects)
removeObjects
in interface ome.api.IShare
@Transactional(readOnly=false) public <T extends ome.model.IObject> void removeObject(long shareId, T object)
removeObject
in interface ome.api.IShare
public java.util.Map<java.lang.Long,java.lang.Long> getCommentCount(java.util.Set<java.lang.Long> ids)
getCommentCount
in interface ome.api.IShare
public java.util.List<ome.model.annotations.Annotation> getComments(long shareId)
getComments
in interface ome.api.IShare
@Transactional(readOnly=false) public ome.model.annotations.CommentAnnotation addComment(long shareId, java.lang.String commentText)
addComment
in interface ome.api.IShare
@Transactional(readOnly=false) public ome.model.annotations.CommentAnnotation addReply(long shareId, java.lang.String comment, ome.model.annotations.CommentAnnotation replyTo)
addReply
in interface ome.api.IShare
@Transactional(readOnly=false) public void deleteComment(ome.model.annotations.Annotation comment)
deleteComment
in interface ome.api.IShare
public java.util.Set<ome.model.meta.Experimenter> getAllMembers(long shareId)
getAllMembers
in interface ome.api.IShare
public java.util.Set<java.lang.String> getAllGuests(long shareId)
getAllGuests
in interface ome.api.IShare
public java.util.Set<java.lang.String> getAllUsers(long shareId) throws ome.conditions.ValidationException
getAllUsers
in interface ome.api.IShare
ome.conditions.ValidationException
@Transactional(readOnly=false) public void addUsers(long shareId, ome.model.meta.Experimenter... exps)
addUsers
in interface ome.api.IShare
@Transactional(readOnly=false) public void addGuests(long shareId, java.lang.String... emailAddresses)
addGuests
in interface ome.api.IShare
@Transactional(readOnly=false) public void removeUsers(long shareId, java.util.List<ome.model.meta.Experimenter> exps)
removeUsers
in interface ome.api.IShare
@Transactional(readOnly=false) public void removeGuests(long shareId, java.lang.String... emailAddresses)
removeGuests
in interface ome.api.IShare
@Transactional(readOnly=false) public void addUser(long shareId, ome.model.meta.Experimenter exp)
addUser
in interface ome.api.IShare
@Transactional(readOnly=false) public void addGuest(long shareId, java.lang.String emailAddress)
addGuest
in interface ome.api.IShare
@Transactional(readOnly=false) public void removeUser(long shareId, ome.model.meta.Experimenter exp)
removeUser
in interface ome.api.IShare
@Transactional(readOnly=false) public void removeGuest(long shareId, java.lang.String emailAddress)
removeGuest
in interface ome.api.IShare
public java.util.Map<java.lang.String,ome.model.meta.Experimenter> getActiveConnections(long shareId)
getActiveConnections
in interface ome.api.IShare
public java.util.List<ome.model.meta.Event> getEvents(long shareId, ome.model.meta.Experimenter experimenter, java.sql.Timestamp from, java.sql.Timestamp to)
getEvents
in interface ome.api.IShare
public java.util.Map<java.lang.String,ome.model.meta.Experimenter> getPastConnections(long shareId)
getPastConnections
in interface ome.api.IShare
public void invalidateConnection(long shareId, ome.model.meta.Experimenter exp)
invalidateConnection
in interface ome.api.IShare
@Transactional(readOnly=false) public void notifyMembersOfShare(long shareId, java.lang.String subject, java.lang.String message, boolean html)
notifyMembersOfShare
in interface ome.api.IShare
protected java.lang.String idToUuid(long shareId)
protected java.util.List<ome.model.meta.Experimenter> loadMembers(ShareData data)
public static long expirationAsLong(long started, java.sql.Timestamp expiration)
expiration
into a long which can be set on
Session.setTimeToLive(Long)
.protected java.util.Set<ome.model.meta.Session> sharesToSessions(java.util.List<ShareData> datas)
protected ome.model.meta.Share shareToSession(ShareData data)
protected <T extends ome.model.IObject> java.util.Map<java.lang.Class<T>,java.util.List<java.lang.Long>> map(java.util.Map<java.lang.String,java.util.List<java.lang.Long>> map)
protected <T extends ome.model.IObject> java.util.List<T> list(java.util.List<Obj> objectList)
protected void adminFlush()
protected void throwOnNullData(long shareId, ShareData data)
protected void applyIfShareAccessible(QueryBuilder qb)
QueryBuilder.where()
should already have been called.protected ShareData getShareIfAccessible(long shareId)
applyIfShareAccessible(QueryBuilder)
which does the same check
at the database rather than binary data level.protected void _addGraph(ShareData data, ome.services.sharing.ShareBean.Graph g)
protected void storeShareData(long shareId, ShareData data)