From 84c92911508252c66449770a61a3e3f0419b9291 Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Mon, 10 May 2010 12:17:21 +0000 Subject: [PATCH] LMS-1527 Moved RpcServiceNameServer to common. SVN: 15868 --- .../dss/component/impl/DssComponent.java | 25 ++-- .../dss/generic/server/DataStoreServer.java | 31 +++- .../server/DssServiceRpcNameServer.java | 71 --------- .../dss/rpc/client/DssServiceRpcFactory.java | 13 +- .../dss/rpc/client/IDssServiceRpcFactory.java | 11 +- .../dss/rpc/shared/IDssServiceRpcGeneric.java | 3 + .../openbis/dss/rpc/shared/IRpcService.java | 45 ------ .../dss/rpc/shared/IRpcServiceNameServer.java | 29 ---- .../rpc/shared/RpcServiceInterfaceDTO.java | 138 ------------------ .../source/java/dssApplicationContext.xml | 4 +- .../dss/component/impl/DssComponentTest.java | 43 +++++- .../impl/RpcServiceInterfaceTest.java | 38 +++-- .../impl/RpcServiceInterfaceVersionTest.java | 62 ++++++++ 13 files changed, 183 insertions(+), 330 deletions(-) delete mode 100644 datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcNameServer.java delete mode 100644 datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IRpcService.java delete mode 100644 datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IRpcServiceNameServer.java delete mode 100644 datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/RpcServiceInterfaceDTO.java create mode 100644 datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/RpcServiceInterfaceVersionTest.java diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/component/impl/DssComponent.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/component/impl/DssComponent.java index 3203c2c95cb..1b8c14adcaf 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/component/impl/DssComponent.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/component/impl/DssComponent.java @@ -22,6 +22,8 @@ import java.util.List; import org.springframework.remoting.RemoteAccessException; import org.springframework.remoting.RemoteConnectFailureException; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceDTO; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; import ch.systemsx.cisd.common.exceptions.AuthorizationFailureException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.InvalidSessionException; @@ -31,7 +33,6 @@ import ch.systemsx.cisd.openbis.dss.component.IDataSetDss; import ch.systemsx.cisd.openbis.dss.component.IDssComponent; import ch.systemsx.cisd.openbis.dss.rpc.client.DssServiceRpcFactory; import ch.systemsx.cisd.openbis.dss.rpc.client.IDssServiceRpcFactory; -import ch.systemsx.cisd.openbis.dss.rpc.shared.RpcServiceInterfaceDTO; import ch.systemsx.cisd.openbis.dss.rpc.shared.FileInfoDssDTO; import ch.systemsx.cisd.openbis.dss.rpc.shared.IDssServiceRpcGeneric; import ch.systemsx.cisd.openbis.generic.shared.IETLLIMSService; @@ -195,8 +196,6 @@ class UnauthenticatedState extends AbstractDssComponentState */ class AuthenticatedState extends AbstractDssComponentState { - private static final String V1_INTERFACE_NAME = "V1"; - private final SessionContextDTO session; private final IDssServiceRpcFactory dssServiceFactory; @@ -304,17 +303,25 @@ class AuthenticatedState extends AbstractDssComponentState IDssServiceRpcGeneric dssService = null; List<RpcServiceInterfaceDTO> ifaces = dssServiceFactory.getSupportedInterfaces(serverURL, false); + for (RpcServiceInterfaceDTO iface : ifaces) { - if (V1_INTERFACE_NAME.equals(iface.getInterfaceName())) + if (IDssServiceRpcGeneric.DSS_SERVICE_NAME.equals(iface.getInterfaceName())) { - dssService = - dssServiceFactory.getService(iface, IDssServiceRpcGeneric.class, serverURL, - false); - break; + for (RpcServiceInterfaceVersionDTO ifaceVersion : iface.getVersions()) + { + if (1 == ifaceVersion.getInterfaceMajorVersion()) + { + dssService = + dssServiceFactory.getService(ifaceVersion, + IDssServiceRpcGeneric.class, serverURL, false); + return dssService; + } + } } } - return dssService; + throw new IllegalArgumentException("Server does not support the " + + IDssServiceRpcGeneric.DSS_SERVICE_NAME + " interface."); } private String getSessionToken() diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServer.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServer.java index 37382692bf5..28d31529a9e 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServer.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServer.java @@ -43,6 +43,9 @@ import org.springframework.web.context.WebApplicationContext; import com.marathon.util.spring.StreamSupportingHttpInvokerServiceExporter; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceDTO; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; +import ch.systemsx.cisd.common.api.server.RpcServiceNameServer; import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.logging.LogCategory; @@ -53,7 +56,7 @@ import ch.systemsx.cisd.openbis.dss.generic.server.ConfigParameters.PluginServle import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.utils.PropertyParametersUtil; -import ch.systemsx.cisd.openbis.dss.rpc.shared.RpcServiceInterfaceDTO; +import ch.systemsx.cisd.openbis.dss.rpc.shared.IDssServiceRpcGeneric; import ch.systemsx.cisd.openbis.generic.shared.IServer; /** @@ -220,17 +223,31 @@ public class DataStoreServer // N.b. In the future, this could be done using spring instead of programmatically StreamSupportingHttpInvokerServiceExporter nameServiceExporter = ServiceProvider.getDssServiceRpcNameServer(); - DssServiceRpcNameServer rpcNameServer = - (DssServiceRpcNameServer) nameServiceExporter.getService(); - RpcServiceInterfaceDTO v1Interface = new RpcServiceInterfaceDTO(); - v1Interface.setInterfaceName("V1"); + RpcServiceNameServer rpcNameServer = + (RpcServiceNameServer) nameServiceExporter.getService(); + + RpcServiceInterfaceDTO dssInterface = new RpcServiceInterfaceDTO(); + dssInterface.setInterfaceName(IDssServiceRpcGeneric.DSS_SERVICE_NAME); + + RpcServiceInterfaceVersionDTO v1Interface = new RpcServiceInterfaceVersionDTO(); + v1Interface.setInterfaceName(DssServiceRpcGeneric.DSS_SERVICE_NAME); v1Interface.setInterfaceUrlSuffix("/rpc/v1"); - rpcNameServer.addSupportedInterface(v1Interface); + v1Interface.setInterfaceMajorVersion(1); + v1Interface.setInterfaceMinorVersion(0); + dssInterface.addVersion(v1Interface); + rpcNameServer.addSupportedInterface(dssInterface); String nameServerPath = "/" + DATA_STORE_SERVER_RPC_SERVICE_NAME; RpcServiceInterfaceDTO nameServerInterface = new RpcServiceInterfaceDTO(); nameServerInterface.setInterfaceName("NameServer"); - nameServerInterface.setInterfaceUrlSuffix("/rpc"); + + RpcServiceInterfaceVersionDTO nameServerVersion = new RpcServiceInterfaceVersionDTO(); + nameServerVersion.setInterfaceName("NameServer"); + nameServerVersion.setInterfaceUrlSuffix("/rpc"); + nameServerVersion.setInterfaceMajorVersion(1); + nameServerVersion.setInterfaceMinorVersion(0); + nameServerInterface.addVersion(nameServerVersion); + rpcNameServer.addSupportedInterface(nameServerInterface); context.addServlet(new ServletHolder(new HttpInvokerServlet(nameServiceExporter, diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcNameServer.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcNameServer.java deleted file mode 100644 index 8daefcaf657..00000000000 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcNameServer.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2010 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.dss.generic.server; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; - -import ch.systemsx.cisd.common.logging.LogCategory; -import ch.systemsx.cisd.common.logging.LogFactory; -import ch.systemsx.cisd.openbis.dss.rpc.shared.RpcServiceInterfaceDTO; -import ch.systemsx.cisd.openbis.dss.rpc.shared.IRpcServiceNameServer; - -/** - * Implementation of the IDssServiceRpcNameServer interface which registry for accessing the RPC - * services supported by a server. - * - * @author Chandrasekhar Ramakrishnan - */ -public class DssServiceRpcNameServer implements IRpcServiceNameServer -{ - private final ArrayList<RpcServiceInterfaceDTO> supportedInterfaces; - - static private final Logger operationLog = - LogFactory.getLogger(LogCategory.OPERATION, DssServiceRpcNameServer.class); - - DssServiceRpcNameServer() - { - supportedInterfaces = new ArrayList<RpcServiceInterfaceDTO>(); - } - - public List<RpcServiceInterfaceDTO> getSupportedInterfaces() - { - return supportedInterfaces; - } - - public int getMajorVersion() - { - return 1; - } - - public int getMinorVersion() - { - return 0; - } - - /** - * Package-visible method for configuring the registry - */ - void addSupportedInterface(RpcServiceInterfaceDTO iface) - { - supportedInterfaces.add(iface); - operationLog.info("Registered RPC Interface " + iface.toString()); - } - -} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/client/DssServiceRpcFactory.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/client/DssServiceRpcFactory.java index dce530b55a0..aef9d228770 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/client/DssServiceRpcFactory.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/client/DssServiceRpcFactory.java @@ -23,11 +23,12 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.List; +import ch.systemsx.cisd.common.api.IRpcService; +import ch.systemsx.cisd.common.api.IRpcServiceNameServer; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceDTO; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; import ch.systemsx.cisd.common.spring.HttpInvokerUtils; import ch.systemsx.cisd.common.ssl.SslCertificateHelper; -import ch.systemsx.cisd.openbis.dss.rpc.shared.IRpcService; -import ch.systemsx.cisd.openbis.dss.rpc.shared.IRpcServiceNameServer; -import ch.systemsx.cisd.openbis.dss.rpc.shared.RpcServiceInterfaceDTO; /** * Client-side factory for DssServiceRpc objects. @@ -59,11 +60,11 @@ public class DssServiceRpcFactory implements IDssServiceRpcFactory return nameServer.getSupportedInterfaces(); } - public <T extends IRpcService> T getService(RpcServiceInterfaceDTO iface, Class<T> ifaceClazz, - String serverURL, boolean getServerCertificateFromServer) + public <T extends IRpcService> T getService(RpcServiceInterfaceVersionDTO ifaceVersion, + Class<T> ifaceClazz, String serverURL, boolean getServerCertificateFromServer) throws IncompatibleAPIVersionsException { - String serviceURL = serverURL + iface.getInterfaceUrlSuffix(); + String serviceURL = serverURL + ifaceVersion.getInterfaceUrlSuffix(); if (getServerCertificateFromServer) { new SslCertificateHelper(serviceURL, getConfigDirectory(), "dss").setUpKeyStore(); diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/client/IDssServiceRpcFactory.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/client/IDssServiceRpcFactory.java index 0d9fc3f55e9..f49997ef951 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/client/IDssServiceRpcFactory.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/client/IDssServiceRpcFactory.java @@ -18,8 +18,9 @@ package ch.systemsx.cisd.openbis.dss.rpc.client; import java.util.List; -import ch.systemsx.cisd.openbis.dss.rpc.shared.RpcServiceInterfaceDTO; -import ch.systemsx.cisd.openbis.dss.rpc.shared.IRpcService; +import ch.systemsx.cisd.common.api.IRpcService; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceDTO; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; /** * A factory for creating proxies to RPC services on a data store server. @@ -45,7 +46,7 @@ public interface IDssServiceRpcFactory /** * Get get RPC service interface specified by <code>iface</code>. */ - public abstract <T extends IRpcService> T getService(RpcServiceInterfaceDTO iface, - Class<T> ifaceClazz, String serverURL, boolean getServerCertificateFromServer) - throws IncompatibleAPIVersionsException; + public abstract <T extends IRpcService> T getService( + RpcServiceInterfaceVersionDTO ifaceVersion, Class<T> ifaceClazz, String serverURL, + boolean getServerCertificateFromServer) throws IncompatibleAPIVersionsException; } \ No newline at end of file diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IDssServiceRpcGeneric.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IDssServiceRpcGeneric.java index 82e20115e40..cafe217857c 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IDssServiceRpcGeneric.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IDssServiceRpcGeneric.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.dss.rpc.shared; import java.io.InputStream; import ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked; +import ch.systemsx.cisd.common.api.IRpcService; /** * Generic functionality for interacting with the DSS. @@ -27,6 +28,8 @@ import ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked; */ public interface IDssServiceRpcGeneric extends IRpcService { + public String DSS_SERVICE_NAME = "DSS Service"; + /** * Get an array of FileInfoDss objects that describe the file-system structure of the data set. * diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IRpcService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IRpcService.java deleted file mode 100644 index 041a2d9ecfe..00000000000 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IRpcService.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2010 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.dss.rpc.shared; - -/** - * The most generic interface for RPC invocations into openBIS. - * <p> - * This interface defines a minimal interface presented by RPC services. It lets clients determine - * which version of the interface the server supports. To do anything interesting, clients need to - * get a reference to a specific interface using the {@link IRpcServiceNameServer}. - * - * @author Chandrasekhar Ramakrishnan - */ -public interface IRpcService -{ - // - // Protocol versioning - // - /** - * Returns the major version of the server side interface. Different major versions are - * incompatible with one another. - */ - public int getMajorVersion(); - - /** - * Returns the minor version of this server side interface. Different minor versions, within the - * same major version, are compatible with one another. - */ - public int getMinorVersion(); - -} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IRpcServiceNameServer.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IRpcServiceNameServer.java deleted file mode 100644 index 0b1cc7e86d3..00000000000 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/IRpcServiceNameServer.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2010 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.dss.rpc.shared; - -import java.util.List; - -/** - * An Interface for finding out about the IRpcService interfaces supported by a server. - * - * @author Chandrasekhar Ramakrishnan - */ -public interface IRpcServiceNameServer extends IRpcService -{ - List<RpcServiceInterfaceDTO> getSupportedInterfaces(); -} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/RpcServiceInterfaceDTO.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/RpcServiceInterfaceDTO.java deleted file mode 100644 index 4efd1c58b12..00000000000 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/RpcServiceInterfaceDTO.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2010 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.dss.rpc.shared; - -import java.io.Serializable; - -/** - * Describes an RPC interface supported by the server. - * - * @author Chandrasekhar Ramakrishnan - */ -public class RpcServiceInterfaceDTO implements Serializable -{ - private static final long serialVersionUID = 1L; - - private String interfaceName; - - private String interfaceUrlSuffix; - - private int interfaceMajorVersion; - - private int interfaceMinorVersion; - - public RpcServiceInterfaceDTO() - { - interfaceName = "Unknown"; - interfaceUrlSuffix = "unknown"; - interfaceMajorVersion = 0; - interfaceMinorVersion = 0; - } - - /** - * The name of this interface used for identification. - */ - public String getInterfaceName() - { - return interfaceName; - } - - public void setInterfaceName(String interfaceName) - { - this.interfaceName = interfaceName; - } - - /** - * The suffix added to the server's URL to produce the URL for this interface. Used by a service - * factory to create a proxy to the service. - */ - public String getInterfaceUrlSuffix() - { - return interfaceUrlSuffix; - } - - public void setInterfaceUrlSuffix(String interfaceUrlSuffix) - { - this.interfaceUrlSuffix = interfaceUrlSuffix; - } - - /** - * The major version of the interface. E.g., an interface with version 2.11 has major version 2. - */ - public int getInterfaceMajorVersion() - { - return interfaceMajorVersion; - } - - public void setInterfaceMajorVersion(int interfaceMajorVersion) - { - this.interfaceMajorVersion = interfaceMajorVersion; - } - - /** - * The major version of the interface. E.g., an interface with version 2.11 has minor version - * 11. - */ - public int getInterfaceMinorVersion() - { - return interfaceMinorVersion; - } - - public void setInterfaceMinorVersion(int interfaceMinorVersion) - { - this.interfaceMinorVersion = interfaceMinorVersion; - } - - @Override - public boolean equals(Object obj) - { - if (false == obj instanceof RpcServiceInterfaceDTO) - return false; - - RpcServiceInterfaceDTO other = (RpcServiceInterfaceDTO) obj; - return getInterfaceName().equals(other.getInterfaceName()) - && getInterfaceUrlSuffix().equals(other.getInterfaceUrlSuffix()) - && getInterfaceMajorVersion() == other.getInterfaceMajorVersion() - && getInterfaceMinorVersion() == other.getInterfaceMinorVersion(); - } - - @Override - public int hashCode() - { - int hash = getInterfaceName().hashCode(); - hash = hash * 31 + getInterfaceUrlSuffix().hashCode(); - hash = hash * 31 + getInterfaceMajorVersion(); - hash = hash * 31 + getInterfaceMinorVersion(); - return hash; - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - sb.append("RpcServiceInterface["); - sb.append(getInterfaceName()); - sb.append(","); - sb.append(getInterfaceUrlSuffix()); - sb.append(",v."); - sb.append(getInterfaceMajorVersion()); - sb.append("."); - sb.append(getInterfaceMinorVersion()); - sb.append("]"); - return sb.toString(); - } -} diff --git a/datastore_server/source/java/dssApplicationContext.xml b/datastore_server/source/java/dssApplicationContext.xml index 1b2cc6ca7c8..1899b092227 100644 --- a/datastore_server/source/java/dssApplicationContext.xml +++ b/datastore_server/source/java/dssApplicationContext.xml @@ -70,10 +70,10 @@ <bean id="data-store-rpc-name-server" class="com.marathon.util.spring.StreamSupportingHttpInvokerServiceExporter"> <property name="service"> - <bean class="ch.systemsx.cisd.openbis.dss.generic.server.DssServiceRpcNameServer"> + <bean class="ch.systemsx.cisd.common.api.server.RpcServiceNameServer"> </bean> </property> - <property name="serviceInterface" value="ch.systemsx.cisd.openbis.dss.rpc.shared.IRpcServiceNameServer" /> + <property name="serviceInterface" value="ch.systemsx.cisd.common.api.IRpcServiceNameServer" /> </bean> <bean id="session-token-manager" class="ch.systemsx.cisd.openbis.dss.generic.server.SessionTokenManager"/> diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/DssComponentTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/DssComponentTest.java index 18340a707ad..c92e1e41387 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/DssComponentTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/DssComponentTest.java @@ -31,9 +31,10 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceDTO; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; import ch.systemsx.cisd.openbis.dss.component.IDataSetDss; import ch.systemsx.cisd.openbis.dss.rpc.client.IDssServiceRpcFactory; -import ch.systemsx.cisd.openbis.dss.rpc.shared.RpcServiceInterfaceDTO; import ch.systemsx.cisd.openbis.dss.rpc.shared.FileInfoDssDTO; import ch.systemsx.cisd.openbis.dss.rpc.shared.FileInfoDssBuilder; import ch.systemsx.cisd.openbis.dss.rpc.shared.IDssServiceRpcGeneric; @@ -109,6 +110,24 @@ public class DssComponentTest extends AbstractFileSystemTestCase context.assertIsSatisfied(); } + @Test + public void testUnsupportedInterface() throws IOException + { + setupExpectations("Some Server Interface"); + + dssComponent.login("foo", "bar"); + try + { + dssComponent.getDataSet("DummyDataSetCode"); + fail("Should have thrown an IllegalArgumentException"); + } catch (IllegalArgumentException e) + { + // correct behavior + } + + context.assertIsSatisfied(); + } + @Test public void testGetFileContents() throws IOException { @@ -143,6 +162,11 @@ public class DssComponentTest extends AbstractFileSystemTestCase } private void setupExpectations() throws IOException + { + setupExpectations(IDssServiceRpcGeneric.DSS_SERVICE_NAME); + } + + private void setupExpectations(String serviceName) throws IOException { final SessionContextDTO session = getDummySession(); final ExternalData dataSetExternalData = new ExternalData(); @@ -160,10 +184,15 @@ public class DssComponentTest extends AbstractFileSystemTestCase final ArrayList<RpcServiceInterfaceDTO> ifaces = new ArrayList<RpcServiceInterfaceDTO>(1); final RpcServiceInterfaceDTO iface = new RpcServiceInterfaceDTO(); - iface.setInterfaceName("V1"); - iface.setInterfaceUrlSuffix("/rpc/v1"); - iface.setInterfaceMajorVersion(1); - iface.setInterfaceMinorVersion(0); + final RpcServiceInterfaceVersionDTO ifaceVersion = new RpcServiceInterfaceVersionDTO(); + ifaceVersion.setInterfaceName(serviceName); + ifaceVersion.setInterfaceUrlSuffix("/rpc/v1"); + ifaceVersion.setInterfaceMajorVersion(1); + ifaceVersion.setInterfaceMinorVersion(0); + + iface.setInterfaceName(serviceName); + iface.addVersion(ifaceVersion); + ifaces.add(iface); context.checking(new Expectations() @@ -177,8 +206,8 @@ public class DssComponentTest extends AbstractFileSystemTestCase will(returnValue(dataSetExternalData)); allowing(dssServiceFactory).getSupportedInterfaces(DUMMY_DSS_URL, false); will(returnValue(ifaces)); - allowing(dssServiceFactory).getService(iface, IDssServiceRpcGeneric.class, - DUMMY_DSS_URL, false); + allowing(dssServiceFactory).getService(ifaceVersion, + IDssServiceRpcGeneric.class, DUMMY_DSS_URL, false); will(returnValue(dssService)); allowing(dssService).listFilesForDataSet(DUMMY_SESSSION_TOKEN, dataSetCode, "/", true); diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/RpcServiceInterfaceTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/RpcServiceInterfaceTest.java index eac66db9f9b..55f8dfd146e 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/RpcServiceInterfaceTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/RpcServiceInterfaceTest.java @@ -19,7 +19,8 @@ package ch.systemsx.cisd.openbis.dss.component.impl; import org.testng.AssertJUnit; import org.testng.annotations.Test; -import ch.systemsx.cisd.openbis.dss.rpc.shared.RpcServiceInterfaceDTO; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceDTO; +import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; /** * @author Chandrasekhar Ramakrishnan @@ -29,12 +30,19 @@ public class RpcServiceInterfaceTest extends AssertJUnit @Test public void testToString() { + final RpcServiceInterfaceVersionDTO ifaceVersion = new RpcServiceInterfaceVersionDTO(); + ifaceVersion.setInterfaceName("DSS Generic"); + ifaceVersion.setInterfaceUrlSuffix("/rpc/dss-generic/v1"); + ifaceVersion.setInterfaceMajorVersion(1); + ifaceVersion.setInterfaceMinorVersion(7); + final RpcServiceInterfaceDTO iface = new RpcServiceInterfaceDTO(); + iface.setInterfaceName("DSS Generic"); - iface.setInterfaceUrlSuffix("/rpc/dss-generic/v1"); - iface.setInterfaceMajorVersion(1); - iface.setInterfaceMinorVersion(7); - assertEquals("RpcServiceInterface[DSS Generic,/rpc/dss-generic/v1,v.1.7]", iface.toString()); + iface.addVersion(ifaceVersion); + assertEquals( + "RpcServiceInterfaceDTO[DSS Generic [RpcServiceInterfaceVersionDTO[DSS Generic,/rpc/dss-generic/v1,v.1.7]]]", + iface.toString()); } @Test @@ -42,17 +50,25 @@ public class RpcServiceInterfaceTest extends AssertJUnit { final int majorVersion = (int) (Math.random() * 10); final int minorVersion = (int) (Math.random() * 100); + final RpcServiceInterfaceVersionDTO ifaceVersion1 = new RpcServiceInterfaceVersionDTO(); + ifaceVersion1.setInterfaceName("DSS Generic"); + ifaceVersion1.setInterfaceUrlSuffix("/rpc/dss-generic/v1"); + ifaceVersion1.setInterfaceMajorVersion(majorVersion); + ifaceVersion1.setInterfaceMinorVersion(minorVersion); + + final RpcServiceInterfaceVersionDTO ifaceVersion2 = new RpcServiceInterfaceVersionDTO(); + ifaceVersion2.setInterfaceName("DSS Generic"); + ifaceVersion2.setInterfaceUrlSuffix("/rpc/dss-generic/v1"); + ifaceVersion2.setInterfaceMajorVersion(majorVersion); + ifaceVersion2.setInterfaceMinorVersion(minorVersion); + final RpcServiceInterfaceDTO iface1 = new RpcServiceInterfaceDTO(); iface1.setInterfaceName("DSS Generic"); - iface1.setInterfaceUrlSuffix("/rpc/dss-generic/v1"); - iface1.setInterfaceMajorVersion(majorVersion); - iface1.setInterfaceMinorVersion(minorVersion); + iface1.addVersion(ifaceVersion1); final RpcServiceInterfaceDTO iface2 = new RpcServiceInterfaceDTO(); iface2.setInterfaceName("DSS Generic"); - iface2.setInterfaceUrlSuffix("/rpc/dss-generic/v1"); - iface2.setInterfaceMajorVersion(majorVersion); - iface2.setInterfaceMinorVersion(minorVersion); + iface2.addVersion(ifaceVersion2); assertTrue(iface1 != iface2); assertEquals(iface1, iface2); diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/RpcServiceInterfaceVersionTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/RpcServiceInterfaceVersionTest.java new file mode 100644 index 00000000000..e3b6a015d6c --- /dev/null +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/component/impl/RpcServiceInterfaceVersionTest.java @@ -0,0 +1,62 @@ +/* + * Copyright 2010 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.dss.component.impl; + +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + +import ch.systemsx.cisd.common.api.RpcServiceInterfaceVersionDTO; + +/** + * @author Chandrasekhar Ramakrishnan + */ +public class RpcServiceInterfaceVersionTest extends AssertJUnit +{ + @Test + public void testToString() + { + final RpcServiceInterfaceVersionDTO ifaceVersion = new RpcServiceInterfaceVersionDTO(); + ifaceVersion.setInterfaceName("DSS Generic"); + ifaceVersion.setInterfaceUrlSuffix("/rpc/dss-generic/v1"); + ifaceVersion.setInterfaceMajorVersion(1); + ifaceVersion.setInterfaceMinorVersion(7); + assertEquals("RpcServiceInterfaceVersionDTO[DSS Generic,/rpc/dss-generic/v1,v.1.7]", + ifaceVersion.toString()); + } + + @Test + public void testEquality() + { + final int majorVersion = (int) (Math.random() * 10); + final int minorVersion = (int) (Math.random() * 100); + final RpcServiceInterfaceVersionDTO ifaceVersion1 = new RpcServiceInterfaceVersionDTO(); + ifaceVersion1.setInterfaceName("DSS Generic"); + ifaceVersion1.setInterfaceUrlSuffix("/rpc/dss-generic/v1"); + ifaceVersion1.setInterfaceMajorVersion(majorVersion); + ifaceVersion1.setInterfaceMinorVersion(minorVersion); + + final RpcServiceInterfaceVersionDTO ifaceVersion2 = new RpcServiceInterfaceVersionDTO(); + ifaceVersion2.setInterfaceName("DSS Generic"); + ifaceVersion2.setInterfaceUrlSuffix("/rpc/dss-generic/v1"); + ifaceVersion2.setInterfaceMajorVersion(majorVersion); + ifaceVersion2.setInterfaceMinorVersion(minorVersion); + + assertTrue(ifaceVersion1 != ifaceVersion2); + assertEquals(ifaceVersion1, ifaceVersion2); + assertEquals(ifaceVersion1.hashCode(), ifaceVersion2.hashCode()); + } +} -- GitLab