diff --git a/openbis/.classpath b/openbis/.classpath index 6402971b848a0d342eaf33eafe403b952d4e608d..bd9b8a222dda8021c8a888ac4ee21b0395a8fb37 100644 --- a/openbis/.classpath +++ b/openbis/.classpath @@ -5,16 +5,17 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/authentication"/> <classpathentry combineaccessrules="false" kind="src" path="/common"/> - <classpathentry combineaccessrules="false" kind="src" path="/dbmigration"/> - <classpathentry combineaccessrules="false" kind="src" path="/lims"/> - <classpathentry combineaccessrules="false" kind="src" path="/lims_base"/> - <classpathentry combineaccessrules="false" kind="src" path="/server-common"/> <classpathentry kind="lib" path="/libraries/gwt1.5/gwt-user.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/server-common"/> <classpathentry kind="lib" path="/libraries/testng/testng-jdk15.jar" sourcepath="/libraries/testng/src.zip"/> <classpathentry kind="lib" path="/libraries/ext-gwt/gxt.jar"> <attributes> <attribute name="javadoc_location" value="jar:platform:/resource/libraries/ext-gwt/gxt-api.zip!/"/> </attributes> </classpathentry> + <classpathentry kind="lib" path="/libraries/log4j/log4j.jar" sourcepath="/libraries/log4j/src.zip"/> + <classpathentry kind="lib" path="/libraries/spring/spring.jar" sourcepath="/libraries/spring/src.jar"/> + <classpathentry kind="lib" path="/libraries/spring/webmvc/spring-webmvc.jar" sourcepath="/libraries/spring/webmvc/src.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/lims_base"/> <classpathentry kind="output" path="targets/classes"/> </classpath> diff --git a/openbis/build/build.xml b/openbis/build/build.xml index 6df23b699d8257b087688433ecf6ce3c492bfa98..991e30d2b745f4b5a607399f1f9e465a35e2b97a 100644 --- a/openbis/build/build.xml +++ b/openbis/build/build.xml @@ -1,9 +1,14 @@ <project name="openbis" basedir=".."> - <import file="../../build_resources/ant/build-common.xml" /> + <import file="../../server-common/build/build-common.xml" /> <project-classpath name="ecp" classes="${classes}" /> <property name="mainfolder" value="openbis" /> + <property name="gwt.lib" value="${lib}/gwt1.5" /> + <property name="gwt.dev.lib" value="${gwt.lib}/mac/gwt-dev-mac.jar" /> + <property name="gwt.user.lib" value="${gwt.lib}/gwt-user.jar" /> + <property name="gwt.tomcat.web-inf" value="../${ant.project.name}/tomcat/webapps/ROOT/WEB-INF" /> + <target name="ci" depends="build-common.ci, check-dependencies"/> </project> \ No newline at end of file diff --git a/openbis/resource/eclipse/openBIS GWT Preparation (1).launch b/openbis/resource/eclipse/openBIS GWT Preparation (1).launch new file mode 100644 index 0000000000000000000000000000000000000000..70a5c768d92d646f1b06dacf00673623a0ff1be8 --- /dev/null +++ b/openbis/resource/eclipse/openBIS GWT Preparation (1).launch @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="org.eclipse.ant.AntLaunchConfigurationType"> +<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="true"/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/openbis/build/build.xml"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="1"/> +</listAttribute> +<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> +<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> +<listEntry value="org.eclipse.ui.externaltools.launchGroup"/> +</listAttribute> +<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> +<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/> +<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="openbis"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> +<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="jdk1.5.0_11"/> +<stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_TYPE_ID" value="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_TARGETS" value="prepare-gwt,"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/openbis/build/build.xml}"/> +<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/> +</launchConfiguration> diff --git a/openbis/resource/server/spring-servlet.xml b/openbis/resource/server/spring-servlet.xml new file mode 100644 index 0000000000000000000000000000000000000000..d098187fc0e117a766b0a75ed8908e45a0ea56ed --- /dev/null +++ b/openbis/resource/server/spring-servlet.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:tx="http://www.springframework.org/schema/tx" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/tx + http://www.springframework.org/schema/tx/spring-tx.xsd"> + + <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> + <property name="mappings"> + <value> + generic=generic-servlet + </value> + </property> + </bean> + + <bean id="generic-servlet" class="ch.systemsx.cisd.openbis.generic.client.web.server.GenericClientServiceServlet" /> + +</beans> \ No newline at end of file diff --git a/openbis/resource/server/web.xml b/openbis/resource/server/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..f4ec7405524ec84ea6fb0671fd60f16e243d2497 --- /dev/null +++ b/openbis/resource/server/web.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE web-app [ + <!ENTITY common SYSTEM "web-common.xml"> + <!ENTITY gwt SYSTEM "gwt.xml"> +]> +<web-app> + + <display-name>openBIS</display-name> + <description>openBIS server</description> + + &common; + + <listener> + <listener-class>ch.systemsx.cisd.openbis.generic.client.web.server.LogHttpSessionListener</listener-class> + </listener> + + <!-- Trying kind of extension (i.e., '*.do') here as 'url-pattern' does not work. --> + <servlet-mapping> + <servlet-name>spring</servlet-name> + <url-pattern>/openbis/*</url-pattern> + </servlet-mapping> + + <!-- + // Additional servlets + --> + + &gwt; +</web-app> diff --git a/openbis/source/java/applicationContext.xml b/openbis/source/java/applicationContext.xml new file mode 100644 index 0000000000000000000000000000000000000000..aefea0ff9c78003bf41d5ce4cd6e9f52168d5da3 --- /dev/null +++ b/openbis/source/java/applicationContext.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:tx="http://www.springframework.org/schema/tx" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/tx + http://www.springframework.org/schema/tx/spring-tx.xsd"> + + <import resource="genericCommonContext.xml"/> + + <!-- + // Server + --> + + <bean id="generic-service" class="ch.systemsx.cisd.openbis.generic.client.web.server.GenericClientService"> + <!-- constructor-arg ref="${authentication-service}" /> + <constructor-arg ref="request-context-provider" /> + <constructor-arg ref="console-factory" /> + <constructor-arg ref="action-log" /> + <property name="sessionExpirationPeriodInMinutes" value="${session-timeout}" /--> + </bean> + + <bean id="action-log" class="ch.systemsx.cisd.openbis.generic.client.web.server.GenericActionLog"> + </bean> + +</beans> \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java new file mode 100644 index 0000000000000000000000000000000000000000..bb9b3c21149cd80d1c19cadb38c8b41c60e4ded9 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientService.java @@ -0,0 +1,40 @@ +/* + * 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.client.web.client; + +import com.google.gwt.user.client.rpc.RemoteService; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; + +/** + * Service interface for the generic GWT client. + * + * @author Franz-Josef Elmer + */ +public interface IGenericClientService extends RemoteService +{ + /** + * Returns static information of the application needed by the client. + */ + public ApplicationInfo getApplicationInfo(); + + /** + * Tries to return the current session context. If failed <code>null</code> is returned. + */ + public SessionContext tryToGetCurrentSessionContext(); +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.java new file mode 100644 index 0000000000000000000000000000000000000000..d0e460f26373b8f9e8fd5c4086fb399587a5b917 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/IGenericClientServiceAsync.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.generic.client.web.client; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; + +/** + * Asynchronous version of {@link IGenericClientService}. + * + * @author Franz-Josef Elmer + */ +public interface IGenericClientServiceAsync +{ + /** @see IGenericClientService#getApplicationInfo() */ + public void getApplicationInfo(AsyncCallback<ApplicationInfo> callback); + + /** @see IGenericClientService#tryToGetCurrentSessionContext() */ + public void tryToGetCurrentSessionContext(AsyncCallback<SessionContext> callback); +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..e7f96df42cdc6169c09d7de1e7fda81a3ca9f6b8 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/AbstractAsyncCallback.java @@ -0,0 +1,45 @@ +/* + * 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.client.web.client.application; + +import com.extjs.gxt.ui.client.widget.Info; +import com.google.gwt.user.client.rpc.AsyncCallback; + + +/** + * Abstract super class of call backs. Its implements {@link #onFailure(Throwable)}. + * + * @author Franz-Josef Elmer + */ +public abstract class AbstractAsyncCallback<T> implements AsyncCallback<T> +{ + protected final GenericViewContext viewContext; + + /** + * Creates an instance for the specified view context. + */ + public AbstractAsyncCallback(GenericViewContext viewContext) + { + this.viewContext = viewContext; + } + + public void onFailure(Throwable caught) + { + Info.display("Error", caught.toString()); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Application.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Application.java new file mode 100644 index 0000000000000000000000000000000000000000..198261bee7696f076c89d93356358bece32f5f31 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Application.java @@ -0,0 +1,41 @@ +/* + * 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.client.web.client.application; + +import com.extjs.gxt.ui.client.widget.LayoutContainer; +import com.extjs.gxt.ui.client.widget.Text; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class Application extends LayoutContainer +{ + private final GenericViewContext viewContext; + + Application(GenericViewContext viewContext) + { + this.viewContext = viewContext; + createGUI(); + } + + private void createGUI() + { + add(new Text(viewContext.getModel().getApplicationInfo().getVersion())); + } +} 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 001498a1d8868589fee3733119dfa9e9faa10c7b..a05068ddd70f0a2f868fe495e8cf2189a8d9c40b 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 @@ -19,18 +19,27 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application; import java.util.Date; import com.extjs.gxt.ui.client.Style.HorizontalAlignment; +import com.extjs.gxt.ui.client.Style.LayoutRegion; +import com.extjs.gxt.ui.client.widget.Component; import com.extjs.gxt.ui.client.widget.HorizontalPanel; import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.extjs.gxt.ui.client.widget.Text; import com.extjs.gxt.ui.client.widget.VerticalPanel; +import com.extjs.gxt.ui.client.widget.layout.BorderLayout; +import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; import com.extjs.gxt.ui.client.widget.layout.CenterLayout; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.ServiceDefTarget; import com.google.gwt.user.client.ui.RootPanel; +import ch.systemsx.cisd.openbis.generic.client.web.client.IGenericClientService; +import ch.systemsx.cisd.openbis.generic.client.web.client.IGenericClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.LoginWidget; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.DictonaryBasedMessageProvider; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; /** * @@ -39,9 +48,55 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMess */ public class Client implements EntryPoint { + private GenericViewContext viewContext; + public void onModuleLoad() { - GenericViewContext viewContext = createViewContext(); + if (viewContext == null) + { + viewContext = createViewContext(); + } + final IGenericClientServiceAsync service = viewContext.getService(); + service.getApplicationInfo(new AbstractAsyncCallback<ApplicationInfo>(viewContext) + { + public void onSuccess(ApplicationInfo info) + { + viewContext.getModel().setApplicationInfo(info); + service.tryToGetCurrentSessionContext(new AbstractAsyncCallback<SessionContext>(viewContext) + { + public void onSuccess(SessionContext sessionContext) + { + RootPanel rootPanel = RootPanel.get(); + rootPanel.clear(); + Component widget; + if (sessionContext == null) + { + widget = createLoginPage(); + } else + { + viewContext.getModel().setSessionContext(sessionContext); + widget = new Application(viewContext); + } + rootPanel.add(decorateWithFooter(widget)); + } + }); + + } + }); + } + + private GenericViewContext createViewContext() + { + IGenericClientServiceAsync service = GWT.create(IGenericClientService.class); + ServiceDefTarget endpoint = (ServiceDefTarget) service; + endpoint.setServiceEntryPoint(GenericConstants.SERVER_NAME); + IGenericImageBundle imageBundle = GWT.<IGenericImageBundle> create(IGenericImageBundle.class); + IMessageProvider messageProvider = new DictonaryBasedMessageProvider("generic"); + return new GenericViewContext(service, messageProvider, imageBundle); + } + + private LayoutContainer createLoginPage() + { LayoutContainer container = new LayoutContainer(); container.setLayout(new CenterLayout()); VerticalPanel verticalPanel = new VerticalPanel(); @@ -61,16 +116,24 @@ public class Client implements EntryPoint verticalPanel.add(horizontalPanel); LoginWidget loginWidget = new LoginWidget(viewContext); - verticalPanel.add(loginWidget); - - RootPanel.get().add(container); + verticalPanel.add(loginWidget); + return container; } - private GenericViewContext createViewContext() + private Component decorateWithFooter(Component widget) { - IGenericImageBundle imageBundle = GWT.<IGenericImageBundle> create(IGenericImageBundle.class); - IMessageProvider messageProvider = new DictonaryBasedMessageProvider("generic"); - return new GenericViewContext(messageProvider, imageBundle); + LayoutContainer container = new LayoutContainer(); + container.setLayout(new BorderLayout()); + container.add(widget, new BorderLayoutData(LayoutRegion.CENTER)); + HorizontalPanel footerPanel = new HorizontalPanel(); + footerPanel.setHorizontalAlign(HorizontalAlignment.CENTER); + footerPanel.setStyleName("footer"); + String version = viewContext.getModel().getApplicationInfo().getVersion(); + Text footerText = new Text(viewContext.getMessage("footer", version)); + footerText.setStyleName("footer-text"); + footerPanel.add(footerText); + container.add(footerPanel, new BorderLayoutData(LayoutRegion.SOUTH)); + return container; } - + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericConstants.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericConstants.java new file mode 100644 index 0000000000000000000000000000000000000000..b2722248fb992ebf6821030a342d7d551aabd998 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericConstants.java @@ -0,0 +1,28 @@ +/* + * 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.client.web.client.application; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class GenericConstants +{ + public static final String SERVER_NAME = "/openbis/generic"; + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewContext.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewContext.java index 5af0b2b8fb952af3c8377952fd9f3f6beb6b6cfb..0fd7ccf907cb09131655594f2d9affe840d8bbf3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewContext.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewContext.java @@ -16,6 +16,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application; +import ch.systemsx.cisd.openbis.generic.client.web.client.IGenericClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider; /** @@ -25,13 +26,28 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMess */ public class GenericViewContext implements IMessageProvider { + private final IGenericClientServiceAsync service; private final IMessageProvider messageProvider; private final IGenericImageBundle imageBundle; + private final GenericViewModel viewModel; - GenericViewContext(IMessageProvider messageProvider, IGenericImageBundle imageBundle) + GenericViewContext(IGenericClientServiceAsync service, IMessageProvider messageProvider, + IGenericImageBundle imageBundle) { + this.service = service; this.messageProvider = messageProvider; this.imageBundle = imageBundle; + viewModel = new GenericViewModel(); + } + + public final GenericViewModel getModel() + { + return viewModel; + } + + public final IGenericClientServiceAsync getService() + { + return service; } public String getMessage(String key, Object... parameters) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewModel.java new file mode 100644 index 0000000000000000000000000000000000000000..da952d2c80aaa0b21f3eddbd4ff4f334d25f79c0 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/GenericViewModel.java @@ -0,0 +1,52 @@ +/* + * 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.client.web.client.application; + +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class GenericViewModel +{ + private ApplicationInfo applicationInfo; + private SessionContext sessionContext; + + public final ApplicationInfo getApplicationInfo() + { + return applicationInfo; + } + + public final void setApplicationInfo(ApplicationInfo applicationInfo) + { + this.applicationInfo = applicationInfo; + } + + public final SessionContext getSessionContext() + { + return sessionContext; + } + + public final void setSessionContext(SessionContext sessionContext) + { + this.sessionContext = sessionContext; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/ApplicationInfo.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/ApplicationInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..43597421a2cda39d76c80eaee68a4d4e942899fb --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/ApplicationInfo.java @@ -0,0 +1,40 @@ +/* + * 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.client.web.client.dto; + +import com.google.gwt.user.client.rpc.IsSerializable; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class ApplicationInfo implements IsSerializable +{ + private String version; + + public final String getVersion() + { + return version; + } + + public final void setVersion(String version) + { + this.version = version; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/SessionContext.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/SessionContext.java new file mode 100644 index 0000000000000000000000000000000000000000..bf4570e12522796c542a0f04bf6d266b3efd9210 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/SessionContext.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.client.web.client.dto; + +import com.google.gwt.user.client.rpc.IsSerializable; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class SessionContext implements IsSerializable +{ + private User user; + + public final User getUser() + { + return user; + } + + public final void setUser(User user) + { + this.user = user; + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/User.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/User.java new file mode 100644 index 0000000000000000000000000000000000000000..af7a1f7ed9e8de5577ebea6189d7a2fb435ff2c8 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/User.java @@ -0,0 +1,62 @@ +/* + * 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.client.web.client.dto; + +import com.google.gwt.user.client.rpc.IsSerializable; + +/** + * User information to be shown in Web client. + * + * @author Franz-Josef Elmer + */ +public final class User implements IsSerializable +{ + private String userName; + + private String homeGroupCode; + + public User() + { + } + + public User(String userName, String homeGroupCodeOrNull) + { + this.userName = userName; + this.homeGroupCode = homeGroupCodeOrNull; + } + + /** can be null */ + public final String getHomeGroupCode() + { + return homeGroupCode; + } + + public final void setHomeGroupCode(final String homeGroupCode) + { + this.homeGroupCode = homeGroupCode; + } + + public final String getUserName() + { + return userName; + } + + public final void setUserName(final String userName) + { + this.userName = userName; + } +} \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/public/generic-dictionary.js b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/public/generic-dictionary.js index 504251d68042d95b217abb552ab72b06b1441440..8431a66f8e44ac8ac2c4652c5da0b067812e8f89 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/public/generic-dictionary.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/public/generic-dictionary.js @@ -4,5 +4,6 @@ var generic = { login_invitation: "Please login to start your session:", login_userLabel: "User", login_passwordLabel: "Password", - login_buttonLabel: "login" + login_buttonLabel: "login", + footer: "openBIS (Version {0})" }; \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericActionLog.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericActionLog.java new file mode 100644 index 0000000000000000000000000000000000000000..da98c8262e83eb43507933ba7fd37286d712ea73 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericActionLog.java @@ -0,0 +1,49 @@ +/* + * 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.client.web.server; + +import javax.servlet.http.HttpSession; + +import ch.systemsx.cisd.common.servlet.IActionLog; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class GenericActionLog implements IActionLog +{ + + public void logFailedLoginAttempt(String userCode) + { + // TODO Auto-generated method stub + + } + + public void logLogout(HttpSession httpSession) + { + // TODO Auto-generated method stub + + } + + public void logSuccessfulLogin() + { + // TODO Auto-generated method stub + + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java new file mode 100644 index 0000000000000000000000000000000000000000..76ae804f0031de6a3befa98cc75a5e2ad222a251 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientService.java @@ -0,0 +1,49 @@ +/* + * 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.client.web.server; + +import ch.systemsx.cisd.common.utilities.BuildAndEnvironmentInfo; +import ch.systemsx.cisd.openbis.generic.client.web.client.IGenericClientService; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class GenericClientService implements IGenericClientService +{ + void setConfigParameters(GenericConfigParameters configParameters) + { + } + + public ApplicationInfo getApplicationInfo() + { + System.out.println("GenericClientService.getApplicationInfo()"); + ApplicationInfo applicationInfo = new ApplicationInfo(); + applicationInfo.setVersion(BuildAndEnvironmentInfo.INSTANCE.getFullVersion()); + return applicationInfo; + } + + public SessionContext tryToGetCurrentSessionContext() + { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..de53c8e57ac21cd833243322b7c67ed2ceb627c3 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericClientServiceServlet.java @@ -0,0 +1,102 @@ +/* + * 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.client.web.server; + +import static ch.systemsx.cisd.common.spring.ExposablePropertyPaceholderConfigurer.PROPERTY_CONFIGURER_BEAN_NAME; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +import org.apache.log4j.Logger; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.web.context.support.WebApplicationContextUtils; + +import ch.systemsx.cisd.common.logging.LogCategory; +import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.common.servlet.GWTSpringController; +import ch.systemsx.cisd.common.spring.ExposablePropertyPaceholderConfigurer; +import ch.systemsx.cisd.openbis.generic.client.web.client.IGenericClientService; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ApplicationInfo; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.SessionContext; + +/** + * + * + * @author Franz-Josef Elmer + */ +public class GenericClientServiceServlet extends GWTSpringController implements + IGenericClientService +{ + private static final long serialVersionUID = 1L; + + private static final Logger notificationLog = + LogFactory.getLogger(LogCategory.NOTIFY, GenericClientServiceServlet.class); + + private static final Logger operationLog = + LogFactory.getLogger(LogCategory.OPERATION, GenericClientServiceServlet.class); + + private IGenericClientService service; + + @Override + public final void init(final ServletConfig config) throws ServletException + { + super.init(config); + try + { + initService(config.getServletContext()); + if (operationLog.isInfoEnabled()) + { + operationLog.info(String.format("'%s' successfully initialized.", getClass() + .getName())); + } + } catch (final Exception ex) + { + notificationLog.fatal("Failure during servlet initialization.", ex); + throw new ServletException(ex); + } + } + + private final void initService(final ServletContext servletContext) + { + final BeanFactory context = + WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); + service = + (IGenericClientService) context.getBean("generic-service", + IGenericClientService.class); + if (service instanceof GenericClientService) + { + GenericClientService genericService = (GenericClientService) service; + final ExposablePropertyPaceholderConfigurer configurer = + (ExposablePropertyPaceholderConfigurer) context + .getBean(PROPERTY_CONFIGURER_BEAN_NAME); + + genericService.setConfigParameters(new GenericConfigParameters(configurer.getResolvedProps())); + } + } + + public ApplicationInfo getApplicationInfo() + { + return service.getApplicationInfo(); + } + + public SessionContext tryToGetCurrentSessionContext() + { + return service.tryToGetCurrentSessionContext(); + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericConfigParameters.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericConfigParameters.java new file mode 100644 index 0000000000000000000000000000000000000000..8cd951eaf165870db9dc32ae16c86ad7da76367f --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/GenericConfigParameters.java @@ -0,0 +1,33 @@ +/* + * 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.client.web.server; + +import java.util.Properties; + +/** + * Configuration parameters for the generic openBIS module. Source of parameters is a + * {@link Properties} object. + * + * @author Franz-Josef Elmer + */ +public class GenericConfigParameters +{ + public GenericConfigParameters(Properties properties) + { + + } +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/LogHttpSessionListener.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/LogHttpSessionListener.java new file mode 100644 index 0000000000000000000000000000000000000000..0a66c885a107ddbc38016eed6aed0995478401b8 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/LogHttpSessionListener.java @@ -0,0 +1,55 @@ +/* + * 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.client.web.server; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpSessionEvent; +import javax.servlet.http.HttpSessionListener; + +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +import ch.systemsx.cisd.common.servlet.IActionLog; + +/** + * Implementation which logs logouts caused by timeouts. + * + * @author Franz-Josef Elmer + */ +public class LogHttpSessionListener implements HttpSessionListener +{ + + public void sessionCreated(HttpSessionEvent event) + { + } + + public void sessionDestroyed(HttpSessionEvent event) + { + HttpSession session = event.getSession(); + if (session != null) + { + ServletContext servletContext = session.getServletContext(); + WebApplicationContext applicationContext = + WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); + IActionLog actionLog = + (IActionLog) applicationContext.getBean("action-log", IActionLog.class); + actionLog.logLogout(session); + } + } + +} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/css/openbis.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/css/openbis.css index 85fb79ac64a3fd064c9e62fe35cb9d1d079b3ed7..2fd20b5e83542eac9c28857c216ee50adbbd09f4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/css/openbis.css +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/css/openbis.css @@ -17,7 +17,7 @@ height: 100%; } -.footer-label { +.footer-text { width: 100%; text-align: center; font-size: 80%; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/.gitignore b/openbis/source/java/service.properties similarity index 100% rename from openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/.gitignore rename to openbis/source/java/service.properties