Class 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 the Share data since it may not be completely in sync. i.e. Don't use SM.find()
    Since:
    3.0-Beta4
    See Also:
    IShare
    • Method Detail

      • getServiceInterface

        public final java.lang.Class<? extends ome.api.ServiceInterface> getServiceInterface()
        Specified by:
        getServiceInterface in interface ome.system.SelfConfigurableService
      • activate

        public void activate​(long shareId)
        Specified by:
        activate in interface ome.api.IShare
      • deactivate

        public void deactivate()
        Specified by:
        deactivate in interface ome.api.IShare
      • getMemberCount

        public java.util.Map<java.lang.Long,​java.lang.Long> getMemberCount​(java.util.Set<java.lang.Long> shareIds)
        Specified by:
        getMemberCount in interface ome.api.IShare
      • getOwnShares

        public java.util.Set<ome.model.meta.Session> getOwnShares​(boolean active)
        Specified by:
        getOwnShares in interface ome.api.IShare
      • getMemberShares

        public java.util.Set<ome.model.meta.Session> getMemberShares​(boolean active)
        Specified by:
        getMemberShares in interface ome.api.IShare
      • getSharesOwnedBy

        public java.util.Set<ome.model.meta.Session> getSharesOwnedBy​(ome.model.meta.Experimenter user,
                                                                      boolean active)
        Specified by:
        getSharesOwnedBy in interface ome.api.IShare
      • getMemberSharesFor

        public java.util.Set<ome.model.meta.Session> getMemberSharesFor​(ome.model.meta.Experimenter user,
                                                                        boolean active)
        Specified by:
        getMemberSharesFor in interface ome.api.IShare
      • getShare

        public ome.model.meta.Share getShare​(long sessionId)
        Specified by:
        getShare in interface ome.api.IShare
      • getContents

        public <T extends ome.model.IObject> java.util.List<T> getContents​(long shareId)
        Specified by:
        getContents in interface ome.api.IShare
      • getContentSubList

        public <T extends ome.model.IObject> java.util.List<T> getContentSubList​(long shareId,
                                                                                 int start,
                                                                                 int finish)
        Specified by:
        getContentSubList in interface ome.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 interface ome.api.IShare
      • getContentSize

        public int getContentSize​(long shareId)
        Specified by:
        getContentSize in interface ome.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 interface ome.api.IShare
      • setDescription

        @Transactional(readOnly=false)
        public void setDescription​(long shareId,
                                   java.lang.String description)
        Specified by:
        setDescription in interface ome.api.IShare
      • setExpiration

        @Transactional(readOnly=false)
        public void setExpiration​(long shareId,
                                  java.sql.Timestamp expiration)
        Specified by:
        setExpiration in interface ome.api.IShare
      • setActive

        @Transactional(readOnly=false)
        public void setActive​(long shareId,
                              boolean active)
        Specified by:
        setActive in interface ome.api.IShare
      • closeShare

        @Transactional(readOnly=false)
        public void closeShare​(long shareId)
        Specified by:
        closeShare in interface ome.api.IShare
      • addObjects

        @Transactional(readOnly=false)
        public <T extends ome.model.IObject> void addObjects​(long shareId,
                                                             T... objects)
        Specified by:
        addObjects in interface ome.api.IShare
      • addObject

        @Transactional(readOnly=false)
        public <T extends ome.model.IObject> void addObject​(long shareId,
                                                            T object)
        Specified by:
        addObject in interface ome.api.IShare
      • removeObjects

        @Transactional(readOnly=false)
        public <T extends ome.model.IObject> void removeObjects​(long shareId,
                                                                T... objects)
        Specified by:
        removeObjects in interface ome.api.IShare
      • removeObject

        @Transactional(readOnly=false)
        public <T extends ome.model.IObject> void removeObject​(long shareId,
                                                               T object)
        Specified by:
        removeObject in interface ome.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 interface ome.api.IShare
      • getComments

        public java.util.List<ome.model.annotations.Annotation> getComments​(long shareId)
        Specified by:
        getComments in interface ome.api.IShare
      • addComment

        @Transactional(readOnly=false)
        public ome.model.annotations.CommentAnnotation addComment​(long shareId,
                                                                  java.lang.String commentText)
        Specified by:
        addComment in interface ome.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 interface ome.api.IShare
      • deleteComment

        @Transactional(readOnly=false)
        public void deleteComment​(ome.model.annotations.Annotation comment)
        Specified by:
        deleteComment in interface ome.api.IShare
      • getAllMembers

        public java.util.Set<ome.model.meta.Experimenter> getAllMembers​(long shareId)
        Specified by:
        getAllMembers in interface ome.api.IShare
      • getAllGuests

        public java.util.Set<java.lang.String> getAllGuests​(long shareId)
        Specified by:
        getAllGuests in interface ome.api.IShare
      • getAllUsers

        public java.util.Set<java.lang.String> getAllUsers​(long shareId)
                                                    throws ome.conditions.ValidationException
        Specified by:
        getAllUsers in interface ome.api.IShare
        Throws:
        ome.conditions.ValidationException
      • addUsers

        @Transactional(readOnly=false)
        public void addUsers​(long shareId,
                             ome.model.meta.Experimenter... exps)
        Specified by:
        addUsers in interface ome.api.IShare
      • addGuests

        @Transactional(readOnly=false)
        public void addGuests​(long shareId,
                              java.lang.String... emailAddresses)
        Specified by:
        addGuests in interface ome.api.IShare
      • removeUsers

        @Transactional(readOnly=false)
        public void removeUsers​(long shareId,
                                java.util.List<ome.model.meta.Experimenter> exps)
        Specified by:
        removeUsers in interface ome.api.IShare
      • removeGuests

        @Transactional(readOnly=false)
        public void removeGuests​(long shareId,
                                 java.lang.String... emailAddresses)
        Specified by:
        removeGuests in interface ome.api.IShare
      • addUser

        @Transactional(readOnly=false)
        public void addUser​(long shareId,
                            ome.model.meta.Experimenter exp)
        Specified by:
        addUser in interface ome.api.IShare
      • addGuest

        @Transactional(readOnly=false)
        public void addGuest​(long shareId,
                             java.lang.String emailAddress)
        Specified by:
        addGuest in interface ome.api.IShare
      • removeUser

        @Transactional(readOnly=false)
        public void removeUser​(long shareId,
                               ome.model.meta.Experimenter exp)
        Specified by:
        removeUser in interface ome.api.IShare
      • removeGuest

        @Transactional(readOnly=false)
        public void removeGuest​(long shareId,
                                java.lang.String emailAddress)
        Specified by:
        removeGuest in interface ome.api.IShare
      • getActiveConnections

        public java.util.Map<java.lang.String,​ome.model.meta.Experimenter> getActiveConnections​(long shareId)
        Specified by:
        getActiveConnections in interface ome.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 interface ome.api.IShare
      • getPastConnections

        public java.util.Map<java.lang.String,​ome.model.meta.Experimenter> getPastConnections​(long shareId)
        Specified by:
        getPastConnections in interface ome.api.IShare
      • invalidateConnection

        public void invalidateConnection​(long shareId,
                                         ome.model.meta.Experimenter exp)
        Specified by:
        invalidateConnection in interface ome.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 interface ome.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 a expiration into a long which can be set on Session.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 with applyIfShareAccessible(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)