Package ome.services.sharing
Class ShareBean
- java.lang.Object
-
- ome.logic.AbstractLevel2Service
-
- ome.services.sharing.ShareBean
-
- All Implemented Interfaces:
ome.api.IShare
,LocalShare
,ome.api.ServiceInterface
,ome.system.SelfConfigurableService
@Transactional(readOnly=true) public class ShareBean extends AbstractLevel2Service implements LocalShare
Note:SessionManager
should not be used to obtain theShare
data since it may not be completely in sync. i.e. Don't use SM.find()- Since:
- 3.0-Beta4
- See Also:
IShare
-
-
Field Summary
Fields Modifier and Type Field 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
-
Fields inherited from class ome.logic.AbstractLevel2Service
iQuery, iUpdate, metadata, queryFactory, readOnlyStatus, sec
-
-
Constructor Summary
Constructors Constructor Description ShareBean(LocalAdmin admin, SessionManager mgr, ShareStore store, Executor executor, MailUtil mailUtil)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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>
voidaddObject(long shareId, T object)
<T extends ome.model.IObject>
voidaddObjects(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>
longcreateShare(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 aexpiration
into a long which can be set onSession.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>
java.util.Map<java.lang.Class<T>,java.util.List<java.lang.Long>>getContentMap(long shareId)
<T extends ome.model.IObject>
java.util.List<T>getContents(long shareId)
int
getContentSize(long shareId)
<T extends ome.model.IObject>
java.util.List<T>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>
java.util.List<T>list(java.util.List<Obj> objectList)
protected java.util.List<ome.model.meta.Experimenter>
loadMembers(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)
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>
voidremoveObject(long shareId, T object)
<T extends ome.model.IObject>
voidremoveObjects(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)
-
Methods inherited from class ome.logic.AbstractLevel2Service
getBeanHelper, getExtendedMetadata, getQueryFactory, getSecuritySystem, selfConfigure, setExtendedMetadata, setQueryFactory, setQueryService, setReadOnlyStatus, setSecuritySystem, setUpdateService
-
-
-
-
Field Detail
-
log
public static final org.slf4j.Logger log
-
NS_ENABLED
public static final java.lang.String NS_ENABLED
- See Also:
- Constant Field Values
-
NS_COMMENT
public static final java.lang.String NS_COMMENT
- See Also:
- Constant Field Values
-
admin
protected final LocalAdmin admin
-
sessionManager
protected final SessionManager sessionManager
-
store
protected final ShareStore store
-
executor
protected final Executor executor
-
mailUtil
protected final MailUtil mailUtil
-
-
Constructor Detail
-
ShareBean
public ShareBean(LocalAdmin admin, SessionManager mgr, ShareStore store, Executor executor, MailUtil mailUtil)
-
-
Method Detail
-
getServiceInterface
public final java.lang.Class<? extends ome.api.ServiceInterface> getServiceInterface()
- Specified by:
getServiceInterface
in interfaceome.system.SelfConfigurableService
-
activate
public void activate(long shareId)
- Specified by:
activate
in interfaceome.api.IShare
-
deactivate
public void deactivate()
- Specified by:
deactivate
in interfaceome.api.IShare
-
resetReadFilter
public void resetReadFilter(org.hibernate.Session s)
- Specified by:
resetReadFilter
in interfaceLocalShare
- See Also:
- ticket:2219
-
getMemberCount
public java.util.Map<java.lang.Long,java.lang.Long> getMemberCount(java.util.Set<java.lang.Long> shareIds)
- Specified by:
getMemberCount
in interfaceome.api.IShare
-
getOwnShares
public java.util.Set<ome.model.meta.Session> getOwnShares(boolean active)
- Specified by:
getOwnShares
in interfaceome.api.IShare
-
getMemberShares
public java.util.Set<ome.model.meta.Session> getMemberShares(boolean active)
- Specified by:
getMemberShares
in interfaceome.api.IShare
-
getSharesOwnedBy
public java.util.Set<ome.model.meta.Session> getSharesOwnedBy(ome.model.meta.Experimenter user, boolean active)
- Specified by:
getSharesOwnedBy
in interfaceome.api.IShare
-
getMemberSharesFor
public java.util.Set<ome.model.meta.Session> getMemberSharesFor(ome.model.meta.Experimenter user, boolean active)
- Specified by:
getMemberSharesFor
in interfaceome.api.IShare
-
getShare
public ome.model.meta.Share getShare(long sessionId)
- Specified by:
getShare
in interfaceome.api.IShare
-
getContents
public <T extends ome.model.IObject> java.util.List<T> getContents(long shareId)
- Specified by:
getContents
in interfaceome.api.IShare
-
getContentSubList
public <T extends ome.model.IObject> java.util.List<T> getContentSubList(long shareId, int start, int finish)
- Specified by:
getContentSubList
in interfaceome.api.IShare
-
getContentMap
public <T extends ome.model.IObject> java.util.Map<java.lang.Class<T>,java.util.List<java.lang.Long>> getContentMap(long shareId)
- Specified by:
getContentMap
in interfaceome.api.IShare
-
getContentSize
public int getContentSize(long shareId)
- Specified by:
getContentSize
in interfaceome.api.IShare
-
createShare
@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)
- Specified by:
createShare
in interfaceome.api.IShare
-
setDescription
@Transactional(readOnly=false) public void setDescription(long shareId, java.lang.String description)
- Specified by:
setDescription
in interfaceome.api.IShare
-
setExpiration
@Transactional(readOnly=false) public void setExpiration(long shareId, java.sql.Timestamp expiration)
- Specified by:
setExpiration
in interfaceome.api.IShare
-
setActive
@Transactional(readOnly=false) public void setActive(long shareId, boolean active)
- Specified by:
setActive
in interfaceome.api.IShare
-
closeShare
@Transactional(readOnly=false) public void closeShare(long shareId)
- Specified by:
closeShare
in interfaceome.api.IShare
-
addObjects
@Transactional(readOnly=false) public <T extends ome.model.IObject> void addObjects(long shareId, T... objects)
- Specified by:
addObjects
in interfaceome.api.IShare
-
addObject
@Transactional(readOnly=false) public <T extends ome.model.IObject> void addObject(long shareId, T object)
- Specified by:
addObject
in interfaceome.api.IShare
-
removeObjects
@Transactional(readOnly=false) public <T extends ome.model.IObject> void removeObjects(long shareId, T... objects)
- Specified by:
removeObjects
in interfaceome.api.IShare
-
removeObject
@Transactional(readOnly=false) public <T extends ome.model.IObject> void removeObject(long shareId, T object)
- Specified by:
removeObject
in interfaceome.api.IShare
-
getCommentCount
public java.util.Map<java.lang.Long,java.lang.Long> getCommentCount(java.util.Set<java.lang.Long> ids)
- Specified by:
getCommentCount
in interfaceome.api.IShare
-
getComments
public java.util.List<ome.model.annotations.Annotation> getComments(long shareId)
- Specified by:
getComments
in interfaceome.api.IShare
-
addComment
@Transactional(readOnly=false) public ome.model.annotations.CommentAnnotation addComment(long shareId, java.lang.String commentText)
- Specified by:
addComment
in interfaceome.api.IShare
-
addReply
@Transactional(readOnly=false) public ome.model.annotations.CommentAnnotation addReply(long shareId, java.lang.String comment, ome.model.annotations.CommentAnnotation replyTo)
- Specified by:
addReply
in interfaceome.api.IShare
-
deleteComment
@Transactional(readOnly=false) public void deleteComment(ome.model.annotations.Annotation comment)
- Specified by:
deleteComment
in interfaceome.api.IShare
-
getAllMembers
public java.util.Set<ome.model.meta.Experimenter> getAllMembers(long shareId)
- Specified by:
getAllMembers
in interfaceome.api.IShare
-
getAllGuests
public java.util.Set<java.lang.String> getAllGuests(long shareId)
- Specified by:
getAllGuests
in interfaceome.api.IShare
-
getAllUsers
public java.util.Set<java.lang.String> getAllUsers(long shareId) throws ome.conditions.ValidationException
- Specified by:
getAllUsers
in interfaceome.api.IShare
- Throws:
ome.conditions.ValidationException
-
addUsers
@Transactional(readOnly=false) public void addUsers(long shareId, ome.model.meta.Experimenter... exps)
- Specified by:
addUsers
in interfaceome.api.IShare
-
addGuests
@Transactional(readOnly=false) public void addGuests(long shareId, java.lang.String... emailAddresses)
- Specified by:
addGuests
in interfaceome.api.IShare
-
removeUsers
@Transactional(readOnly=false) public void removeUsers(long shareId, java.util.List<ome.model.meta.Experimenter> exps)
- Specified by:
removeUsers
in interfaceome.api.IShare
-
removeGuests
@Transactional(readOnly=false) public void removeGuests(long shareId, java.lang.String... emailAddresses)
- Specified by:
removeGuests
in interfaceome.api.IShare
-
addUser
@Transactional(readOnly=false) public void addUser(long shareId, ome.model.meta.Experimenter exp)
- Specified by:
addUser
in interfaceome.api.IShare
-
addGuest
@Transactional(readOnly=false) public void addGuest(long shareId, java.lang.String emailAddress)
- Specified by:
addGuest
in interfaceome.api.IShare
-
removeUser
@Transactional(readOnly=false) public void removeUser(long shareId, ome.model.meta.Experimenter exp)
- Specified by:
removeUser
in interfaceome.api.IShare
-
removeGuest
@Transactional(readOnly=false) public void removeGuest(long shareId, java.lang.String emailAddress)
- Specified by:
removeGuest
in interfaceome.api.IShare
-
getActiveConnections
public java.util.Map<java.lang.String,ome.model.meta.Experimenter> getActiveConnections(long shareId)
- Specified by:
getActiveConnections
in interfaceome.api.IShare
-
getEvents
public java.util.List<ome.model.meta.Event> getEvents(long shareId, ome.model.meta.Experimenter experimenter, java.sql.Timestamp from, java.sql.Timestamp to)
- Specified by:
getEvents
in interfaceome.api.IShare
-
getPastConnections
public java.util.Map<java.lang.String,ome.model.meta.Experimenter> getPastConnections(long shareId)
- Specified by:
getPastConnections
in interfaceome.api.IShare
-
invalidateConnection
public void invalidateConnection(long shareId, ome.model.meta.Experimenter exp)
- Specified by:
invalidateConnection
in interfaceome.api.IShare
-
notifyMembersOfShare
@Transactional(readOnly=false) public void notifyMembersOfShare(long shareId, java.lang.String subject, java.lang.String message, boolean html)
- Specified by:
notifyMembersOfShare
in interfaceome.api.IShare
-
idToUuid
protected java.lang.String idToUuid(long shareId)
-
loadMembers
protected java.util.List<ome.model.meta.Experimenter> loadMembers(ShareData data)
-
expirationAsLong
public static long expirationAsLong(long started, java.sql.Timestamp expiration)
Convert aexpiration
into a long which can be set onSession.setTimeToLive(Long)
.- Returns:
- the time in milliseconds that this session can exist.
-
sharesToSessions
protected java.util.Set<ome.model.meta.Session> sharesToSessions(java.util.List<ShareData> datas)
-
shareToSession
protected ome.model.meta.Share shareToSession(ShareData data)
-
map
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)
-
list
protected <T extends ome.model.IObject> java.util.List<T> list(java.util.List<Obj> objectList)
-
adminFlush
protected void adminFlush()
-
throwOnNullData
protected void throwOnNullData(long shareId, ShareData data)
-
applyIfShareAccessible
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.
-
getShareIfAccessible
protected ShareData getShareIfAccessible(long shareId)
Loads share and checks it's owner and member data against the current context (owner/member/admin). This method must be kept in sync withapplyIfShareAccessible(QueryBuilder)
which does the same check at the database rather than binary data level.
-
_addGraph
protected void _addGraph(ShareData data, ome.services.sharing.ShareBean.Graph g)
-
storeShareData
protected void storeShareData(long shareId, ShareData data)
-
-