From f56a8beae4906a0f4d55c894447eb0fdd338b93d Mon Sep 17 00:00:00 2001 From: ribeaudc <ribeaudc> Date: Fri, 17 Oct 2008 10:07:12 +0000 Subject: [PATCH] [LMS-604] change: - Extract an 'AbstractServerLogger'. - Use an unique instance of 'DefaultSessionManager' (to be able to share the session). SVN: 8679 --- .../authentication/DefaultSessionManager.java | 60 ++++---- .../application/AbstractAsyncCallback.java | 4 +- .../client/web/client/application/Client.java | 5 +- .../application/SessionContextCallback.java | 5 +- .../generic/server/AbstractServer.java | 20 +-- .../generic/server/AbstractServerLogger.java | 135 +++++++++++++++++ .../openbis/generic/server/GenericServer.java | 30 ++-- .../generic/server/GenericServerLogger.java | 142 ++++-------------- .../bo/AbstractBusinessObjectFactory.java | 39 +++++ .../bo/GenericBusinessObjectFactory.java | 21 ++- .../bo/IGenericBusinessObjectFactory.java | 2 + .../application/ClientPluginFactory.java | 23 ++- .../application/ScreeningViewContext.java | 20 +-- .../web/server/ScreeningClientService.java | 4 +- .../screening/server/ScreeningServer.java | 51 +++---- .../server/ScreeningServerLogger.java | 48 ++++++ .../bo/IScreeningBusinessObjectFactory.java | 27 ++++ .../bo/ScreeningBusinessObjectFactory.java | 36 +++++ .../source/java/genericApplicationContext.xml | 17 +++ openbis/source/java/genericServiceContext.xml | 8 +- .../source/java/screeningServiceContext.xml | 6 +- 21 files changed, 463 insertions(+), 240 deletions(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServerLogger.java create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObjectFactory.java create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerLogger.java create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/business/bo/IScreeningBusinessObjectFactory.java create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/business/bo/ScreeningBusinessObjectFactory.java diff --git a/authentication/source/java/ch/systemsx/cisd/authentication/DefaultSessionManager.java b/authentication/source/java/ch/systemsx/cisd/authentication/DefaultSessionManager.java index f8239cab855..1f9838d0d46 100644 --- a/authentication/source/java/ch/systemsx/cisd/authentication/DefaultSessionManager.java +++ b/authentication/source/java/ch/systemsx/cisd/authentication/DefaultSessionManager.java @@ -33,27 +33,28 @@ import ch.systemsx.cisd.common.server.IRemoteHostProvider; import ch.systemsx.cisd.common.utilities.TokenGenerator; /** - * Default session manager. Needs - * <ul><li>a {@link ISessionFactory} for creating new session objects, - * <li>a {@link ILogMessagePrefixGenerator} for generating log messages which are - * logged by a logger with category {@link LogCategory#AUTH}, - * <li>a {@link IAuthenticationService} for authenticating users, - * <li>a {@link IRemoteHostProvider} for providing the remote host of the user client. - * </ul> - * + * Default session manager. Needs + * <ul> + * <li>a {@link ISessionFactory} for creating new session objects, + * <li>a {@link ILogMessagePrefixGenerator} for generating log messages which are logged by a + * logger with category {@link LogCategory#AUTH}, + * <li>a {@link IAuthenticationService} for authenticating users, + * <li>a {@link IRemoteHostProvider} for providing the remote host of the user client. + * </ul> + * * @author Franz-Josef Elmer */ public class DefaultSessionManager<T extends BasicSession> implements ISessionManager<T> { private static final String LOGOUT_PREFIX = "LOGOUT: "; + private static final String LOGIN_PREFIX = "LOGIN: "; - private static final Logger authenticationLog = LogFactory.getLogger(LogCategory.AUTH, DefaultSessionManager.class); - + private static final Logger operationLog = - LogFactory.getLogger(LogCategory.OPERATION, DefaultSessionManager.class); + LogFactory.getLogger(LogCategory.OPERATION, DefaultSessionManager.class); private static final TokenGenerator tokenGenerator = new TokenGenerator(); @@ -100,14 +101,15 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa } private final ISessionFactory<T> sessionFactory; - + private final ILogMessagePrefixGenerator<T> prefixGenerator; - + /** * The map of session tokens to sessions. Access to this data structure needs to be * synchronized. */ - private final Map<String, FullSession<T>> sessions = new LinkedHashMap<String, FullSession<T>>(); + private final Map<String, FullSession<T>> sessions = + new LinkedHashMap<String, FullSession<T>>(); private final IAuthenticationService authenticationService; @@ -127,7 +129,7 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa assert remoteHostProvider != null : "Missing remote host provider."; assert sessionExpirationPeriodMinutes >= 0 : "Session experation time has to be a positive value: " + sessionExpirationPeriodMinutes; // == 0 is for unit test - + this.sessionFactory = sessionFactory; this.prefixGenerator = prefixGenerator; this.authenticationService = authenticationService; @@ -141,7 +143,7 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa sessionExpirationPeriodMillis)); authenticationService.check(); } - + private final T createAndStoreSession(final String user, final Principal principal, final long now) { @@ -149,9 +151,9 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa synchronized (sessions) { final T session = - sessionFactory.create(sessionToken, user, principal, getRemoteHost(), now, sessionExpirationPeriodMillis); - final FullSession<T> createdSession = - new FullSession<T>(session); + sessionFactory.create(sessionToken, user, principal, getRemoteHost(), now, + sessionExpirationPeriodMillis); + final FullSession<T> createdSession = new FullSession<T>(session); sessions.put(user, createdSession); return session; } @@ -165,7 +167,7 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa throw UserFailureException.fromTemplate("No '%s' specified.", name); } } - + private boolean isSessionUnavailable(final FullSession<T> session) { return session == null || doSessionExpiration(session); @@ -201,22 +203,22 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa operationLog.error(LOGIN_PREFIX + "Error when trying to authenticate user '" + user + "'.", ex); } - + private void logAuthenticationFailure(String user) { String prefix = prefixGenerator.createPrefix(user, getRemoteHost()); authenticationLog.info(prefix + ": login ...FAILED"); } - + private void logSessionExpired(FullSession<T> fullSession) { T session = fullSession.getSession(); if (operationLog.isInfoEnabled()) { operationLog.info(String.format("%sExpiring session '%s' for user '%s' " - + "after %d minutes of inactivity.", LOGOUT_PREFIX, - session.getSessionToken(), session.getUserName(), - sessionExpirationPeriodMillis / DateUtils.MILLIS_PER_MINUTE)); + + "after %d minutes of inactivity.", LOGOUT_PREFIX, session.getSessionToken(), + session.getUserName(), sessionExpirationPeriodMillis + / DateUtils.MILLIS_PER_MINUTE)); } String prefix = prefixGenerator.createPrefix(session); authenticationLog.info(prefix + ": session_expired [inactive " @@ -235,7 +237,7 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa + "'."); } } - + public T getSession(String sessionToken) throws UserFailureException { checkIfNotBlank(sessionToken, "sessionToken"); @@ -278,7 +280,7 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa return session.getSession(); } } - + public String tryToOpenSession(String user, String password) { checkIfNotBlank(user, "user"); @@ -322,7 +324,7 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa throw ex; } } - + public void closeSession(String sessionToken) { synchronized (sessions) @@ -337,5 +339,5 @@ public class DefaultSessionManager<T extends BasicSession> implements ISessionMa { return remoteHostProvider.getRemoteHost(); } - + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AbstractAsyncCallback.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AbstractAsyncCallback.java index 2b24b2b6c79..d4c5c127fd3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AbstractAsyncCallback.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AbstractAsyncCallback.java @@ -75,14 +75,14 @@ public abstract class AbstractAsyncCallback<T> implements AsyncCallback<T> callbackListener = listenerOrNull == null ? DUMMY_LISTENER : listenerOrNull; } - protected final GenericViewContext viewContext; + protected final IViewContext<?> viewContext; private boolean silent; /** * Creates an instance for the specified view context. */ - public AbstractAsyncCallback(final GenericViewContext viewContext) + public AbstractAsyncCallback(final IViewContext<?> viewContext) { this.viewContext = viewContext; if (callbackListener != DUMMY_LISTENER) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java index 179a32cd700..ac36d6a7fc9 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java @@ -66,6 +66,7 @@ public class Client implements EntryPoint if (viewContext == null) { viewContext = createViewContext(); + ClientPluginProvider.setOriginalViewContext(viewContext); } final IGenericClientServiceAsync service = viewContext.getService(); service.getApplicationInfo(new AbstractAsyncCallback<ApplicationInfo>(viewContext) @@ -74,9 +75,9 @@ public class Client implements EntryPoint public void process(ApplicationInfo info) { viewContext.getModel().setApplicationInfo(info); - service.tryToGetCurrentSessionContext(new SessionContextCallback(viewContext)); + service.tryToGetCurrentSessionContext(new SessionContextCallback( + (GenericViewContext) viewContext)); } }); } - } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SessionContextCallback.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SessionContextCallback.java index b23c6d49bc5..9ca7ecd71ab 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SessionContextCallback.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/SessionContextCallback.java @@ -44,12 +44,11 @@ public final class SessionContextCallback extends AbstractAsyncCallback<SessionC Component widget; if (sessionContext == null) { - widget = new LoginPage(viewContext); + widget = new LoginPage((GenericViewContext) viewContext); } else { viewContext.getModel().setSessionContext(sessionContext); - widget = new Application(viewContext); - ClientPluginProvider.setOriginalViewContext(viewContext); + widget = new Application((GenericViewContext) viewContext); } rootPanel.add(widget); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java index 6c91cd465b2..f6420e6f236 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java @@ -26,7 +26,6 @@ import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.authentication.Principal; import ch.systemsx.cisd.common.spring.IInvocationLoggerFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; -import ch.systemsx.cisd.openbis.generic.shared.IGenericServer; import ch.systemsx.cisd.openbis.generic.shared.IServer; import ch.systemsx.cisd.openbis.generic.shared.authorization.ISessionProvider; import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSession; @@ -40,17 +39,20 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.Session; * * @author Christian Ribeaud */ -public class AbstractServer implements IServer, ISessionProvider, - IInvocationLoggerFactory<IGenericServer> +public abstract class AbstractServer<T extends IServer> implements IServer, ISessionProvider, + IInvocationLoggerFactory<T> { - private ISessionManager<Session> sessionManager; + private static ISessionManager<Session> sessionManager; private IDAOFactory daoFactory; protected AbstractServer(final ISessionManager<Session> sessionManager, final IDAOFactory daoFactory) { - this.sessionManager = sessionManager; + if (AbstractServer.sessionManager == null) + { + AbstractServer.sessionManager = sessionManager; + } this.daoFactory = daoFactory; } @@ -80,14 +82,6 @@ public class AbstractServer implements IServer, ISessionProvider, // IServer // - /** - * Creates a logger used to log invocations of objects of this class. - */ - public final GenericServerLogger createLogger(final boolean invocationSuccessful) - { - return new GenericServerLogger(sessionManager, invocationSuccessful); - } - public final IAuthSession getSession(final String sessionToken) { return sessionManager.getSession(sessionToken); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServerLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServerLogger.java new file mode 100644 index 00000000000..8ebc5b8f2ac --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServerLogger.java @@ -0,0 +1,135 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.server; + +import org.apache.log4j.Logger; + +import ch.systemsx.cisd.authentication.ISessionManager; +import ch.systemsx.cisd.common.logging.LogCategory; +import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.openbis.generic.shared.IServer; +import ch.systemsx.cisd.openbis.generic.shared.authorization.ISessionProvider; +import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSession; +import ch.systemsx.cisd.openbis.generic.shared.dto.Session; + +/** + * An <i>abstract</i> server logger. + * + * @author Christian Ribeaud + */ +public abstract class AbstractServerLogger implements ISessionProvider, IServer +{ + private static final String RESULT_SUCCESS = ""; + + private static final String RESULT_FAILURE = " ...FAILED"; + + private static final Logger accessLog = + LogFactory.getLogger(LogCategory.ACCESS, AbstractServerLogger.class); + + private static final Logger trackingLog = + LogFactory.getLogger(LogCategory.TRACKING, AbstractServerLogger.class); + + protected final ISessionManager<Session> sessionManager; + + protected final boolean invocationSuccessful; + + protected final LogMessagePrefixGenerator logMessagePrefixGenerator; + + public AbstractServerLogger(final ISessionManager<Session> sessionManager, + final boolean invocationSuccessful) + { + this.sessionManager = sessionManager; + this.invocationSuccessful = invocationSuccessful; + logMessagePrefixGenerator = new LogMessagePrefixGenerator(); + } + + protected final void logAccess(final String sessionToken, final String commandName) + { + logAccess(sessionToken, commandName, ""); + } + + protected final void logAccess(final String sessionToken, final String commandName, + final String parameterDisplayFormat, final Object... parameters) + { + logMessage(accessLog, sessionToken, commandName, parameterDisplayFormat, parameters); + } + + protected final void logTracking(final String sessionToken, final String commandName, + final String parameterDisplayFormat, final Object... parameters) + { + logMessage(trackingLog, sessionToken, commandName, parameterDisplayFormat, parameters); + } + + private final void logMessage(final Logger logger, final String sessionToken, + final String commandName, final String parameterDisplayFormat, final Object[] parameters) + { + final Session session = sessionManager.getSession(sessionToken); + final String prefix = logMessagePrefixGenerator.createPrefix(session); + for (int i = 0; i < parameters.length; i++) + { + final Object parameter = parameters[i]; + if (parameter == null) + { + parameters[i] = LogMessagePrefixGenerator.UNDEFINED; + } else + { + parameters[i] = "'" + parameter + "'"; + } + } + final String message = String.format(parameterDisplayFormat, parameters); + final String invocationStatusMessage = getInvocationStatusMessage(); + // We put on purpose 2 spaces between the command and the message derived from the + // parameters. + logger.info(prefix + + String.format(": %s %s%s", commandName, message, invocationStatusMessage)); + } + + private String getInvocationStatusMessage() + { + return invocationSuccessful ? RESULT_SUCCESS : RESULT_FAILURE; + } + + // + // ISessionProvider + // + + public final IAuthSession getSession(final String sessionToken) + { + return null; + } + + // + // IServer + // + + public final int getVersion() + { + return 0; + } + + public final Session tryToAuthenticate(final String user, final String password) + { + // No logging because already done by the session manager + return null; + } + + public final void logout(final String sessionToken) + { + // No logging because already done by the session manager + } + +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServer.java index 1f70d754b12..e48a211553c 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServer.java @@ -23,14 +23,11 @@ import java.util.Map; import org.springframework.transaction.annotation.Transactional; import ch.rinn.restrictions.Private; -import ch.systemsx.cisd.authentication.DefaultSessionManager; import ch.systemsx.cisd.authentication.IAuthenticationService; import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.authentication.Principal; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.common.servlet.IRequestContextProvider; -import ch.systemsx.cisd.common.servlet.RequestContextProviderAdapter; import ch.systemsx.cisd.openbis.generic.server.business.bo.GenericBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGenericBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.business.bo.IGroupBO; @@ -59,20 +56,16 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleOwnerIdentif * * @author Franz-Josef Elmer */ -public class GenericServer extends AbstractServer implements IGenericServer +public class GenericServer extends AbstractServer<IGenericServer> implements IGenericServer { private final IGenericBusinessObjectFactory boFactory; private final IAuthenticationService authenticationService; public GenericServer(final IAuthenticationService authenticationService, - final IRequestContextProvider requestContextProvider, final IDAOFactory daoFactory, - final int sessionExpirationPeriodInMinutes) + final ISessionManager<Session> sessionManager, final IDAOFactory daoFactory) { - this(authenticationService, new DefaultSessionManager<Session>(new SessionFactory(), - new LogMessagePrefixGenerator(), authenticationService, - new RequestContextProviderAdapter(requestContextProvider), - sessionExpirationPeriodInMinutes), daoFactory, new GenericBusinessObjectFactory( + this(authenticationService, sessionManager, daoFactory, new GenericBusinessObjectFactory( daoFactory)); } @@ -86,6 +79,18 @@ public class GenericServer extends AbstractServer implements IGenericServer this.boFactory = boFactory; } + // + // IInvocationLoggerFactory + // + + /** + * Creates a logger used to log invocations of objects of this class. + */ + public final IGenericServer createLogger(final boolean invocationSuccessful) + { + return new GenericServerLogger(getSessionManager(), invocationSuccessful); + } + // // IGenericServer // @@ -273,13 +278,12 @@ public class GenericServer extends AbstractServer implements IGenericServer } @Transactional - public Map<SampleIdentifier, List<SamplePropertyPE>> listSamplesProperties(String sessionToken, - List<SampleIdentifier> sampleIdentifiers, List<PropertyTypePE> propertyCodes) + public Map<SampleIdentifier, List<SamplePropertyPE>> listSamplesProperties(final String sessionToken, + final List<SampleIdentifier> sampleIdentifiers, final List<PropertyTypePE> propertyCodes) { getSessionManager().getSession(sessionToken); return getDAOFactory().getSamplePropertyDAO().listSampleProperties(sampleIdentifiers, propertyCodes); } - } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServerLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServerLogger.java index 2ffcfb145d2..50b728827c9 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServerLogger.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/GenericServerLogger.java @@ -19,15 +19,9 @@ package ch.systemsx.cisd.openbis.generic.server; import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; - import ch.systemsx.cisd.authentication.ISessionManager; -import ch.systemsx.cisd.common.logging.LogCategory; -import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.openbis.generic.shared.IGenericServer; -import ch.systemsx.cisd.openbis.generic.shared.authorization.ISessionProvider; import ch.systemsx.cisd.openbis.generic.shared.dto.GroupPE; -import ch.systemsx.cisd.openbis.generic.shared.dto.IAuthSession; import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; import ch.systemsx.cisd.openbis.generic.shared.dto.PropertyTypePE; import ch.systemsx.cisd.openbis.generic.shared.dto.RoleAssignmentPE; @@ -46,113 +40,26 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleOwnerIdentif * * @author Franz-Josef Elmer */ -class GenericServerLogger implements IGenericServer, ISessionProvider +final class GenericServerLogger extends AbstractServerLogger implements IGenericServer { - private final static String RESULT_SUCCESS = ""; - - private final static String RESULT_FAILURE = " ...FAILED"; - - private static final Logger accessLog = - LogFactory.getLogger(LogCategory.ACCESS, GenericServer.class); - - private static final Logger trackingLog = - LogFactory.getLogger(LogCategory.TRACKING, GenericServer.class); - - private final ISessionManager<Session> sessionManager; - - private final boolean invocationSuccessful; - - private final LogMessagePrefixGenerator logMessagePrefixGenerator; - /** * Creates an instance for the specified session manager and invocation status. The session * manager is used to retrieve user information which will be a part of the log message. */ - GenericServerLogger(ISessionManager<Session> sessionManager, boolean invocationSuccessful) - { - this.sessionManager = sessionManager; - this.invocationSuccessful = invocationSuccessful; - logMessagePrefixGenerator = new LogMessagePrefixGenerator(); - } - - private void logAccess(final String sessionToken, final String commandName) - { - logAccess(sessionToken, commandName, ""); - } - - private void logAccess(final String sessionToken, final String commandName, - final String parameterDisplayFormat, final Object... parameters) - { - logMessage(accessLog, sessionToken, commandName, parameterDisplayFormat, parameters); - } - - private void logTracking(final String sessionToken, final String commandName, - final String parameterDisplayFormat, final Object... parameters) - { - logMessage(trackingLog, sessionToken, commandName, parameterDisplayFormat, parameters); - } - - private void logMessage(final Logger logger, final String sessionToken, - final String commandName, final String parameterDisplayFormat, final Object[] parameters) - { - final Session session = sessionManager.getSession(sessionToken); - final String prefix = logMessagePrefixGenerator.createPrefix(session); - for (int i = 0; i < parameters.length; i++) - { - Object parameter = parameters[i]; - if (parameter == null) - { - parameters[i] = LogMessagePrefixGenerator.UNDEFINED; - } else - { - parameters[i] = "'" + parameter + "'"; - } - } - final String message = String.format(parameterDisplayFormat, parameters); - final String invocationStatusMessage = getInvocationStatusMessage(); - // We put on purpose 2 spaces between the command and the message derived from the - // parameters. - logger.info(prefix - + String.format(": %s %s%s", commandName, message, invocationStatusMessage)); - } - - private String getInvocationStatusMessage() + GenericServerLogger(final ISessionManager<Session> sessionManager, + final boolean invocationSuccessful) { - return invocationSuccessful ? RESULT_SUCCESS : RESULT_FAILURE; - } - - // - // ISessionProvider - // - - public IAuthSession getSession(String sessionToken) - { - return null; + super(sessionManager, invocationSuccessful); } // // IGenericServer // - public int getVersion() - { - return 0; - } - - public Session tryToAuthenticate(String user, String password) - { - // No logging because already done by the session manager - return null; - } - - public void logout(String sessionToken) - { - // No logging because already done by the session manager - } - - public List<GroupPE> listGroups(String sessionToken, DatabaseInstanceIdentifier identifier) + public List<GroupPE> listGroups(final String sessionToken, + final DatabaseInstanceIdentifier identifier) { - String command = "list_groups"; + final String command = "list_groups"; if (identifier == null || identifier.getDatabaseInstanceCode() == null) { logAccess(sessionToken, command); @@ -163,73 +70,76 @@ class GenericServerLogger implements IGenericServer, ISessionProvider return null; } - public void registerGroup(String sessionToken, String groupCode, String descriptionOrNull, - String groupLeaderOrNull) + public void registerGroup(final String sessionToken, final String groupCode, + final String descriptionOrNull, final String groupLeaderOrNull) { logTracking(sessionToken, "register_group", "CODE(%s)", groupCode); } - public List<PersonPE> listPersons(String sessionToken) + public List<PersonPE> listPersons(final String sessionToken) { logAccess(sessionToken, "list_persons"); return null; } - public void registerPerson(String sessionToken, String userID) + public void registerPerson(final String sessionToken, final String userID) { logTracking(sessionToken, "register_person", "CODE(%s)", userID); } - public List<RoleAssignmentPE> listRoles(String sessionToken) + public List<RoleAssignmentPE> listRoles(final String sessionToken) { logAccess(sessionToken, "list_roles"); return null; } - public void registerGroupRole(String sessionToken, RoleCode roleCode, - GroupIdentifier groupIdentifier, String person) + public void registerGroupRole(final String sessionToken, final RoleCode roleCode, + final GroupIdentifier groupIdentifier, final String person) { logTracking(sessionToken, "register_role", "ROLE(%s) GROUP(%s) PERSON(%s)", roleCode, groupIdentifier, person); } - public void registerInstanceRole(String sessionToken, RoleCode roleCode, String person) + public void registerInstanceRole(final String sessionToken, final RoleCode roleCode, + final String person) { logTracking(sessionToken, "register_role", "ROLE(%s) PERSON(%s)", roleCode, person); } - public void deleteGroupRole(String sessionToken, RoleCode roleCode, - GroupIdentifier groupIdentifier, String person) + public void deleteGroupRole(final String sessionToken, final RoleCode roleCode, + final GroupIdentifier groupIdentifier, final String person) { logTracking(sessionToken, "delete_role", "ROLE(%s) GROUP(%s) PERSON(%s)", roleCode, groupIdentifier, person); } - public void deleteInstanceRole(String sessionToken, RoleCode roleCode, String person) + public void deleteInstanceRole(final String sessionToken, final RoleCode roleCode, + final String person) { logTracking(sessionToken, "delete_role", "ROLE(%s) PERSON(%s)", roleCode, person); } - public List<SampleTypePE> listSampleTypes(String sessionToken) + public List<SampleTypePE> listSampleTypes(final String sessionToken) { logAccess(sessionToken, "list_sample_types"); return null; } - public List<SamplePE> listSamples(String sessionToken, - List<SampleOwnerIdentifier> ownerIdentifiers, SampleTypePE sampleType) + public List<SamplePE> listSamples(final String sessionToken, + final List<SampleOwnerIdentifier> ownerIdentifiers, final SampleTypePE sampleType) { logAccess(sessionToken, "list_samples", "TYPE(%s) OWNERS(%s)", sampleType, ownerIdentifiers); return null; } - public Map<SampleIdentifier, List<SamplePropertyPE>> listSamplesProperties(String sessionToken, - List<SampleIdentifier> samples, List<PropertyTypePE> propertyCodes) + public Map<SampleIdentifier, List<SamplePropertyPE>> listSamplesProperties( + final String sessionToken, final List<SampleIdentifier> samples, + final List<PropertyTypePE> propertyCodes) { logAccess(sessionToken, "list_samples_properties", "SAMPLES(%s) PROPERTIES(%s)", samples .size(), propertyCodes.size()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObjectFactory.java new file mode 100644 index 00000000000..a5f0f4e65f2 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/AbstractBusinessObjectFactory.java @@ -0,0 +1,39 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.server.business.bo; + +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; + +/** + * An <i>abstract</i> <i>Business Object</i> factory. + * + * @author Christian Ribeaud + */ +public abstract class AbstractBusinessObjectFactory +{ + private final IDAOFactory daoFactory; + + protected AbstractBusinessObjectFactory(final IDAOFactory daoFactory) + { + this.daoFactory = daoFactory; + } + + protected final IDAOFactory getDaoFactory() + { + return daoFactory; + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/GenericBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/GenericBusinessObjectFactory.java index 1453dc4f067..f13b8948d5f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/GenericBusinessObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/GenericBusinessObjectFactory.java @@ -20,29 +20,34 @@ import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; /** + * The unique {@link IGenericBusinessObjectFactory} implementation. + * * @author Tomasz Pylak */ -public class GenericBusinessObjectFactory implements IGenericBusinessObjectFactory +public class GenericBusinessObjectFactory extends AbstractBusinessObjectFactory implements + IGenericBusinessObjectFactory { - private final IDAOFactory daoFactory; - - public GenericBusinessObjectFactory(IDAOFactory daoFactory) + public GenericBusinessObjectFactory(final IDAOFactory daoFactory) { - this.daoFactory = daoFactory; + super(daoFactory); } + // + // IGenericBusinessObjectFactory + // + public final IGroupBO createGroupBO(final Session session) { - return new GroupBO(daoFactory, session); + return new GroupBO(getDaoFactory(), session); } public final IRoleAssignmentTable createRoleAssignmentTable(final Session session) { - return new RoleAssignmentTable(daoFactory, session); + return new RoleAssignmentTable(getDaoFactory(), session); } public final ISampleBO createSampleBO(final Session session) { - return new SampleBO(daoFactory, session); + return new SampleBO(getDaoFactory(), session); } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IGenericBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IGenericBusinessObjectFactory.java index 111cf3ecb6d..d42d42c9c5f 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IGenericBusinessObjectFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/IGenericBusinessObjectFactory.java @@ -19,6 +19,8 @@ package ch.systemsx.cisd.openbis.generic.server.business.bo; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; /** + * The <i>generic</i> specific <i>Business Object</i> factory. + * * @author Tomasz Pylak */ public interface IGenericBusinessObjectFactory diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/ClientPluginFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/ClientPluginFactory.java index 98e9e882ef3..409c1a208a7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/ClientPluginFactory.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/ClientPluginFactory.java @@ -23,10 +23,12 @@ import java.util.TreeSet; import com.extjs.gxt.ui.client.widget.MessageBox; import ch.systemsx.cisd.openbis.generic.client.web.client.IGenericClientServiceAsync; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractClientPluginFactory; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IClientPluginFactory; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ISampleViewClientPlugin; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Sample; import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.IScreeningClientServiceAsync; /** @@ -66,8 +68,7 @@ public final class ClientPluginFactory extends protected final IViewContext<IScreeningClientServiceAsync> createViewContext( final IViewContext<IGenericClientServiceAsync> originalViewContext) { - return new ScreeningViewContext(originalViewContext.getImageBundle(), originalViewContext - .getModel(), originalViewContext.getPageController()); + return new ScreeningViewContext(originalViewContext); } // @@ -88,7 +89,7 @@ public final class ClientPluginFactory extends // Helper classes // - private final static class SampleViewClientPlugin implements ISampleViewClientPlugin + private final class SampleViewClientPlugin implements ISampleViewClientPlugin { // @@ -97,7 +98,21 @@ public final class ClientPluginFactory extends public final void viewSample(final String sampleIdentifier) { - MessageBox.alert("Screening", sampleIdentifier, null); + final IViewContext<IScreeningClientServiceAsync> viewContext = getViewContext(); + viewContext.getService().getSampleInfo(sampleIdentifier, + new AbstractAsyncCallback<Sample>(viewContext) + { + + // + // AbstractAsyncCallback + // + + @Override + protected final void process(final Sample result) + { + MessageBox.alert("Screening", result.getCode(), null); + } + }); } } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/ScreeningViewContext.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/ScreeningViewContext.java index 1e2eb2b731e..6bd489477a0 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/ScreeningViewContext.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/ScreeningViewContext.java @@ -3,6 +3,7 @@ package ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.ServiceDefTarget; +import ch.systemsx.cisd.openbis.generic.client.web.client.IGenericClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericConstants; import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericViewModel; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IGenericImageBundle; @@ -20,22 +21,15 @@ import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.IScreeningCli */ public final class ScreeningViewContext implements IViewContext<IScreeningClientServiceAsync> { - private final IGenericImageBundle imageBundle; - - private final GenericViewModel model; - - private final IPageController pageController; + private final IViewContext<IGenericClientServiceAsync> originalViewContext; private final IMessageProvider messageProvider; private final IScreeningClientServiceAsync service; - public ScreeningViewContext(final IGenericImageBundle imageBundle, - final GenericViewModel model, final IPageController pageController) + public ScreeningViewContext(final IViewContext<IGenericClientServiceAsync> originalViewContext) { - this.imageBundle = imageBundle; - this.model = model; - this.pageController = pageController; + this.originalViewContext = originalViewContext; this.messageProvider = new DictonaryBasedMessageProvider("screening"); this.service = createScreeningClientService(); } @@ -54,7 +48,7 @@ public final class ScreeningViewContext implements IViewContext<IScreeningClient public final IGenericImageBundle getImageBundle() { - return imageBundle; + return originalViewContext.getImageBundle(); } public final String getMessage(final String key, final Object... parameters) @@ -64,12 +58,12 @@ public final class ScreeningViewContext implements IViewContext<IScreeningClient public final GenericViewModel getModel() { - return model; + return originalViewContext.getModel(); } public final IPageController getPageController() { - return pageController; + return originalViewContext.getPageController(); } public final IScreeningClientServiceAsync getService() diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java index 0883d416981..738e4da5302 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/ScreeningClientService.java @@ -61,7 +61,9 @@ public final class ScreeningClientService extends AbstractClientService implemen final String sessionToken = getSessionToken(); final SampleIdentifier identifier = SampleIdentifierFactory.parse(sampleIdentifier); final SamplePE samplePE = screeningServer.getSampleInfo(sessionToken, identifier); - return null; + final Sample sample = new Sample(); + sample.setCode(samplePE.getCode()); + return sample; } catch (final ch.systemsx.cisd.common.exceptions.UserFailureException e) { throw UserFailureExceptionTranslater.translate(e); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java index c6c077aa671..0fdad16be29 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServer.java @@ -18,24 +18,16 @@ package ch.systemsx.cisd.openbis.plugin.screening.server; import org.springframework.transaction.annotation.Transactional; -import ch.rinn.restrictions.Private; -import ch.systemsx.cisd.authentication.DefaultSessionManager; import ch.systemsx.cisd.authentication.IAuthenticationService; import ch.systemsx.cisd.authentication.ISessionManager; -import ch.systemsx.cisd.common.servlet.IRequestContextProvider; -import ch.systemsx.cisd.common.servlet.RequestContextProviderAdapter; import ch.systemsx.cisd.openbis.generic.server.AbstractServer; -import ch.systemsx.cisd.openbis.generic.server.LogMessagePrefixGenerator; -import ch.systemsx.cisd.openbis.generic.server.SessionFactory; -import ch.systemsx.cisd.openbis.generic.server.business.bo.GenericBusinessObjectFactory; -import ch.systemsx.cisd.openbis.generic.server.business.bo.IGenericBusinessObjectFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; -import ch.systemsx.cisd.openbis.plugin.ISampleServerPlugin; -import ch.systemsx.cisd.openbis.plugin.SampleServerPluginRegistry; import ch.systemsx.cisd.openbis.plugin.Technology; +import ch.systemsx.cisd.openbis.plugin.screening.server.business.bo.IScreeningBusinessObjectFactory; +import ch.systemsx.cisd.openbis.plugin.screening.server.business.bo.ScreeningBusinessObjectFactory; import ch.systemsx.cisd.openbis.plugin.screening.shared.IScreeningServer; /** @@ -43,27 +35,31 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.IScreeningServer; * * @author Christian Ribeaud */ -public final class ScreeningServer extends AbstractServer implements IScreeningServer +@SuppressWarnings("unused") +public final class ScreeningServer extends AbstractServer<IScreeningServer> implements + IScreeningServer { + private final IScreeningBusinessObjectFactory businessObjectFactory; + private static final Technology SCREENING_TECHNOLOGY = new Technology("SCREENING"); public ScreeningServer(final IAuthenticationService authenticationService, - final IRequestContextProvider requestContextProvider, final IDAOFactory daoFactory, - final int sessionExpirationPeriodInMinutes) + final ISessionManager<Session> sessionManager, final IDAOFactory daoFactory) { - this(authenticationService, new DefaultSessionManager<Session>(new SessionFactory(), - new LogMessagePrefixGenerator(), authenticationService, - new RequestContextProviderAdapter(requestContextProvider), - sessionExpirationPeriodInMinutes), daoFactory, new GenericBusinessObjectFactory( - daoFactory)); + super(sessionManager, daoFactory); + this.businessObjectFactory = new ScreeningBusinessObjectFactory(daoFactory); } - @Private - ScreeningServer(final IAuthenticationService authenticationService, - final ISessionManager<Session> sessionManager, final IDAOFactory daoFactory, - final IGenericBusinessObjectFactory boFactory) + // + // IInvocationLoggerFactory + // + + /** + * Creates a logger used to log invocations of objects of this class. + */ + public final IScreeningServer createLogger(final boolean invocationSuccessful) { - super(sessionManager, daoFactory); + return new ScreeningServerLogger(getSessionManager(), invocationSuccessful); } // @@ -75,9 +71,10 @@ public final class ScreeningServer extends AbstractServer implements IScreeningS { final Session session = getSessionManager().getSession(sessionToken); final SamplePE samplePE = new SamplePE(); - final ISampleServerPlugin plugin = - SampleServerPluginRegistry - .getPlugin(SCREENING_TECHNOLOGY, samplePE.getSampleType()); - return null; + samplePE.setCode("CHOUBIDOU"); + // final ISampleServerPlugin plugin = + // SampleServerPluginRegistry + // .getPlugin(SCREENING_TECHNOLOGY, samplePE.getSampleType()); + return samplePE; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerLogger.java new file mode 100644 index 00000000000..f4571fd642e --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerLogger.java @@ -0,0 +1,48 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.plugin.screening.server; + +import ch.systemsx.cisd.authentication.ISessionManager; +import ch.systemsx.cisd.openbis.generic.server.AbstractServerLogger; +import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; +import ch.systemsx.cisd.openbis.generic.shared.dto.Session; +import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; +import ch.systemsx.cisd.openbis.plugin.screening.shared.IScreeningServer; + +/** + * The <i>screening</i> specific {@link AbstractServerLogger} extension. + * + * @author Christian Ribeaud + */ +final class ScreeningServerLogger extends AbstractServerLogger implements IScreeningServer +{ + ScreeningServerLogger(final ISessionManager<Session> sessionManager, + final boolean invocationSuccessful) + { + super(sessionManager, invocationSuccessful); + } + + // + // IScreeningServer + // + + public final SamplePE getSampleInfo(final String sessionToken, final SampleIdentifier identifier) + { + logTracking(sessionToken, "get_sample_info", "CODE(%s)", identifier); + return null; + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/business/bo/IScreeningBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/business/bo/IScreeningBusinessObjectFactory.java new file mode 100644 index 00000000000..b9958993996 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/business/bo/IScreeningBusinessObjectFactory.java @@ -0,0 +1,27 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.plugin.screening.server.business.bo; + +/** + * The <i>screening</i> specific <i>Business Object</i> factory. + * + * @author Christian Ribeaud + */ +public interface IScreeningBusinessObjectFactory +{ + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/business/bo/ScreeningBusinessObjectFactory.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/business/bo/ScreeningBusinessObjectFactory.java new file mode 100644 index 00000000000..72a8efe3289 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/business/bo/ScreeningBusinessObjectFactory.java @@ -0,0 +1,36 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.plugin.screening.server.business.bo; + +import ch.systemsx.cisd.openbis.generic.server.business.bo.AbstractBusinessObjectFactory; +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; + +/** + * The unique {@link IScreeningBusinessObjectFactory} implementation. + * + * @author Christian Ribeaud + */ +public final class ScreeningBusinessObjectFactory extends AbstractBusinessObjectFactory implements + IScreeningBusinessObjectFactory +{ + + public ScreeningBusinessObjectFactory(final IDAOFactory daoFactory) + { + super(daoFactory); + } + +} diff --git a/openbis/source/java/genericApplicationContext.xml b/openbis/source/java/genericApplicationContext.xml index 5aa8b5c00d3..b76680070db 100644 --- a/openbis/source/java/genericApplicationContext.xml +++ b/openbis/source/java/genericApplicationContext.xml @@ -43,6 +43,23 @@ <constructor-arg ref="hibernate-session-factory" /> </bean> + <bean id="session-manager" class="ch.systemsx.cisd.authentication.DefaultSessionManager"> + <constructor-arg> + <bean class="ch.systemsx.cisd.openbis.generic.server.SessionFactory" /> + </constructor-arg> + <constructor-arg> + <bean class="ch.systemsx.cisd.openbis.generic.server.LogMessagePrefixGenerator" /> + </constructor-arg> + <constructor-arg ref="${authentication-service}" /> + <constructor-arg> + <bean class="ch.systemsx.cisd.common.servlet.RequestContextProviderAdapter"> + <constructor-arg ref="request-context-provider" /> + </bean> + </constructor-arg> + <!-- The time after which an inactive session is expired by the service (in minutes). --> + <constructor-arg value="${session-timeout}" /> + </bean> + <!-- // Transaction --> diff --git a/openbis/source/java/genericServiceContext.xml b/openbis/source/java/genericServiceContext.xml index a8e145b42ee..42414e5fb24 100644 --- a/openbis/source/java/genericServiceContext.xml +++ b/openbis/source/java/genericServiceContext.xml @@ -21,18 +21,16 @@ <property name="target"> <bean class="ch.systemsx.cisd.openbis.generic.server.GenericServer"> <constructor-arg ref="${authentication-service}" /> - <constructor-arg ref="request-context-provider" /> + <constructor-arg ref="session-manager" /> <constructor-arg ref="generic-dao-factory" /> - <!-- The time after which an inactive session is expired by the service (in minutes). --> - <constructor-arg value="${session-timeout}" /> </bean> </property> - + <property name="interceptorNames"> <list> <value>logInterceptor</value> </list> </property> </bean> - + </beans> \ No newline at end of file diff --git a/openbis/source/java/screeningServiceContext.xml b/openbis/source/java/screeningServiceContext.xml index c82c095a74d..edf1bd72ba8 100644 --- a/openbis/source/java/screeningServiceContext.xml +++ b/openbis/source/java/screeningServiceContext.xml @@ -21,10 +21,8 @@ <property name="target"> <bean class="ch.systemsx.cisd.openbis.plugin.screening.server.ScreeningServer"> <constructor-arg ref="${authentication-service}" /> - <constructor-arg ref="request-context-provider" /> + <constructor-arg ref="session-manager" /> <constructor-arg ref="generic-dao-factory" /> - <!-- The time after which an inactive session is expired by the service (in minutes). --> - <constructor-arg value="${session-timeout}" /> </bean> </property> <property name="interceptorNames"> @@ -33,5 +31,5 @@ </list> </property> </bean> - + </beans> \ No newline at end of file -- GitLab