root/trunk/components/common/src/ome/api/ISession.java
| Revision 2284, 5.4 kB (checked in by jmoore, 11 months ago) |
|---|
| Line | |
|---|---|
| 1 | /* |
| 2 | * $Id$ |
| 3 | * |
| 4 | * Copyright 2007 Glencoe Software, Inc. All rights reserved. |
| 5 | * Use is subject to license terms supplied in LICENSE.txt |
| 6 | */ |
| 7 | |
| 8 | package ome.api; |
| 9 | |
| 10 | import java.util.Set; |
| 11 | |
| 12 | import ome.annotations.Hidden; |
| 13 | import ome.annotations.NotNull; |
| 14 | import ome.conditions.ApiUsageException; |
| 15 | import ome.conditions.RemovedSessionException; |
| 16 | import ome.conditions.SecurityViolation; |
| 17 | import ome.conditions.SessionTimeoutException; |
| 18 | import ome.model.meta.Session; |
| 19 | import ome.system.Principal; |
| 20 | |
| 21 | /** |
| 22 | * <em>Start here</em>: {@link Session} creation service for OMERO. Access to |
| 23 | * all other services is dependent upon a properly created and still active |
| 24 | * {@link Session}. |
| 25 | * |
| 26 | * The {@link Session session's} {@link Session#getUuid() uuid} can be |
| 27 | * considered a capability token, or temporary single use password. Simply by |
| 28 | * possessing it the client has access to all information available to the |
| 29 | * {@link Session}. |
| 30 | * |
| 31 | * Note: Both the RMI {@link ome.system.ServiceFactory} as well as the Ice |
| 32 | * {@link omero.api.ServiceFactoryPrx} use {@link ISession} to acquire a |
| 33 | * {@link Session}. In the RMI case, the {@link ISession} instance is the first |
| 34 | * remote proxy accessed. In the Ice case, Glacier2 contacts {@link ISession} |
| 35 | * itself and returns a ServiceFactory remote proxy. From both ServiceFactory |
| 36 | * instances, it is possible but not necessary to access {@link ISession}. |
| 37 | * |
| 38 | * @author Josh Moore, josh at glencoesoftware.com |
| 39 | * @since 3.0-Beta3 |
| 40 | */ |
| 41 | public interface ISession extends ServiceInterface { |
| 42 | |
| 43 | /** |
| 44 | * Allows an admin to create a {@link Session} for the give |
| 45 | * {@link Principal} |
| 46 | * |
| 47 | * @param principal |
| 48 | * Non-null {@link Principal} with the target user's name |
| 49 | * @param seconds |
| 50 | * The time that this {@link Session} has until destruction. This |
| 51 | * is useful to override the server default so that an initial |
| 52 | * delay before the user is given the token will not be construed |
| 53 | * as idle time. A value less than 1 will cause the default max |
| 54 | * timeToLive to be used; but timeToIdle will be disabled. |
| 55 | */ |
| 56 | Session createSessionWithTimeout(@NotNull |
| 57 | Principal principal, long milliseconds); |
| 58 | |
| 59 | /** |
| 60 | * Creates a new session and returns it to the user. |
| 61 | * |
| 62 | * @throws ApiUsageException |
| 63 | * if principal is null |
| 64 | * @throws SecurityViolation |
| 65 | * if the password check fails |
| 66 | */ |
| 67 | Session createSession(@NotNull |
| 68 | Principal principal, @Hidden |
| 69 | String credentials); |
| 70 | |
| 71 | /** |
| 72 | * Updates subset of the fields from the {@link Session} object. |
| 73 | * |
| 74 | * Updated: group, {@link Session#userAgent}, {@link Session#message}, |
| 75 | * {@link Session#defaultUmask}, |
| 76 | * {@link Session#setDefaultEventType(String)} |
| 77 | * |
| 78 | * Ignored: All others, but especially user, {@link Session#events} |
| 79 | * {@link Session#uuid}, and the timestamps |
| 80 | * |
| 81 | * @param session |
| 82 | * The {@link Session} instance to be updated. |
| 83 | * @return The {@link Session} updated instance. Should replace the current |
| 84 | * value: <code> session = iSession.updateSession(session); </code> |
| 85 | */ |
| 86 | Session updateSession(@NotNull |
| 87 | Session session); |
| 88 | |
| 89 | /** |
| 90 | * Retrieves the session associated with this uuid. Throws a |
| 91 | * {@link RemovedSessionException} if not present, or a |
| 92 | * {@link SessionTimeoutException} if expired. |
| 93 | * |
| 94 | * This method can be used as a {@link Session} ping. |
| 95 | */ |
| 96 | Session getSession(@NotNull |
| 97 | String sessionUuid); |
| 98 | |
| 99 | /** |
| 100 | * Closes session and releases all resources. It is preferred that all |
| 101 | * clients call this method as soon as possible to free memory, but it is |
| 102 | * possible to not call close, and rejoin a session later. |
| 103 | */ |
| 104 | void closeSession(@NotNull |
| 105 | Session session); |
| 106 | |
| 107 | // void addNotification(String notification); |
| 108 | // void removeNotification(String notification); |
| 109 | // List<String> listNotifications(); |
| 110 | // void defaultNotifications(); |
| 111 | // void clearNotifications(); |
| 112 | |
| 113 | // Session joinSessionByName(@NotNull String sessionName); // Here you don't |
| 114 | // have a |
| 115 | // void disconnectSession(@NotNull Session session); |
| 116 | // void pingSession(@NotNull Session session); // Add to ServiceFactoryI |
| 117 | |
| 118 | // Environment contents |
| 119 | // ========================================================================= |
| 120 | |
| 121 | /** |
| 122 | * Retrieves an entry from the given {@link Session session's} input |
| 123 | * environment. If the value is null, the key will be removed. |
| 124 | */ |
| 125 | Object getInput(String session, String key); |
| 126 | |
| 127 | /** |
| 128 | * Retrieves all keys in the {@link Session sesson's} input environment. |
| 129 | * |
| 130 | * @param session |
| 131 | * @return |
| 132 | */ |
| 133 | Set<String> getInputKeys(String session); |
| 134 | |
| 135 | /** |
| 136 | * Places an entry in the given {@link Session session's} input environment. |
| 137 | * If the value is null, the key will be removed. |
| 138 | */ |
| 139 | void setInput(String session, String key, Object objection); |
| 140 | |
| 141 | /** |
| 142 | * Retrieves all keys in the {@link Session sesson's} output environment. |
| 143 | */ |
| 144 | Set<String> getOutputKeys(String session); |
| 145 | |
| 146 | /** |
| 147 | * Retrieves an entry from the {@link Session session's} output environment. |
| 148 | */ |
| 149 | Object getOutput(String session, String key); |
| 150 | |
| 151 | /** |
| 152 | * Places an entry in the given {@link Session session's} output |
| 153 | * environment. If the value is null, the key will be removed. |
| 154 | */ |
| 155 | void setOutput(String session, String key, Object objection); |
| 156 | } |
Note: See TracBrowser
for help on using the browser.
