comments and javadoc
[taxeditor.git] / eu.etaxonomy.taxeditor.cdmlib / src / main / java / eu / etaxonomy / cdm / remote / CdmRemoteSourceBase.java
index 2cb83fc6bff166d935e69a639ad0b7582507087d..e2b4c4490551a890436e04060fdd87bbe8ec8c4b 100644 (file)
@@ -1,6 +1,13 @@
+/**
+* Copyright (C) 2014 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
 package eu.etaxonomy.cdm.remote;
 
-import org.springframework.remoting.RemoteConnectFailureException;
 import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
 
 import eu.etaxonomy.cdm.api.service.IDatabaseService;
@@ -8,6 +15,12 @@ import eu.etaxonomy.cdm.config.CdmSource;
 import eu.etaxonomy.cdm.config.CdmSourceException;
 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
 
+/**
+ * Base class representing a CDM remote source. 
+ * This class handles all the configuration relating to the remoting aspect of
+ * a CDM source.
+ *
+ */
 public class CdmRemoteSourceBase extends CdmSource implements ICdmRemoteSource {
 
        private String contextPath;
@@ -15,6 +28,15 @@ public class CdmRemoteSourceBase extends CdmSource implements ICdmRemoteSource {
        
        private IDatabaseService databaseService;
        
+       /**
+        * Constructs a CdmRemoteSourceBase
+        * 
+        * @param name
+        * @param server
+        * @param port
+        * @param contextPath
+        * @param nomenclaturalCode
+        */
        protected CdmRemoteSourceBase(String name, String server, int port, String contextPath, NomenclaturalCode nomenclaturalCode) {
                setName(name);
                setServer(server);
@@ -26,6 +48,9 @@ public class CdmRemoteSourceBase extends CdmSource implements ICdmRemoteSource {
                } else {
                        setBaseUrl("http://" + server + ":" + String.valueOf(port) + "/" + contextPath);
                }
+               // the database service needs to be initialised (before the spring
+               // application context initialsation) since it is required to 
+               // to make queries related to the source database
            HttpInvokerProxyFactoryBean proxy = new HttpInvokerProxyFactoryBean();
            proxy.setServiceInterface(IDatabaseService.class);
            proxy.setServiceUrl(getBaseUrl() + "/remoting/database.service");
@@ -33,48 +58,81 @@ public class CdmRemoteSourceBase extends CdmSource implements ICdmRemoteSource {
            databaseService = (IDatabaseService) proxy.getObject();
        }
        
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.remote.ICdmRemoteSource#getBaseUrl()
+        */
        @Override
        public String getBaseUrl() {
                return baseUrl;
        }
 
+       /**
+        * Sets the base url for the http-invoker services as listed in 
+        * httpInvokerServicesClients.xml.
+        * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the 
+        * base url would be 'http://127.0.0.1:8080/col'
+        * 
+        * @param baseUrl
+        */
        public void setBaseUrl(String baseUrl) {
                this.baseUrl = baseUrl;
        }
 
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.remote.ICdmRemoteSource#getContextPath()
+        */
        @Override
        public String getContextPath() {
                return contextPath;
        }
 
+       /**
+        * Sets the context path.
+        * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the 
+        * context path would be 'col'
+        * 
+        * @param contextPath
+        */
        public void setContextPath(String contextPath) {
                this.contextPath = contextPath;
        }
 
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.config.CdmSource#getDbSchemaVersion()
+        */
        @Override
        public String getDbSchemaVersion() throws CdmSourceException {
                return databaseService.getDbSchemaVersion();
 
        }
 
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.config.CdmSource#isDbEmpty()
+        */
        @Override
        public boolean isDbEmpty() throws CdmSourceException {
                return databaseService.isDbEmpty();
 
        }
 
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.config.CdmSource#checkConnection()
+        */
        @Override
        public boolean checkConnection() throws CdmSourceException {
                // assuming that database service works implies 
                // the connection is up
                // if no exception is thrown then we assume that the 
                // connection is up
-
+               // FIXME:Remoting is this really correct?
                databaseService.getDbSchemaVersion();
 
                return true;
        }
 
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.cdm.config.CdmSource#getConnectionMessage()
+        */
        @Override
        public String getConnectionMessage() {
                return "Conncting to Remote CDM Server " + getName();