2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.remoting
.source
;
13 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationRemoteConfiguration
;
14 import eu
.etaxonomy
.cdm
.api
.service
.IMetadataService
;
15 import eu
.etaxonomy
.cdm
.config
.CdmSource
;
16 import eu
.etaxonomy
.cdm
.config
.CdmSourceException
;
17 import eu
.etaxonomy
.cdm
.model
.metadata
.CdmMetaData
.MetaDataPropertyName
;
20 * Base class representing a CDM remote source.
21 * This class handles all the configuration relating to the remoting aspect of
25 public class CdmRemoteSourceBase
extends CdmSource
implements ICdmRemoteSource
{
27 protected static final String DEFAULT_NAME
= "default";
28 protected static final String DEFAULT_SERVER
= "127.0.0.1";
29 protected static final int DEFAULT_PORT
= 8080;
30 protected static final String DEFAULT_CONTEXT_PATH
= "";
31 private String contextPath
;
32 private String baseUrl
;
34 private IMetadataService metadataService
;
37 * Constructs a CdmRemoteSourceBase object with default values.
40 protected CdmRemoteSourceBase() {
41 setName(DEFAULT_NAME
);
42 setServer(DEFAULT_SERVER
);
43 setPort(DEFAULT_PORT
);
44 setContextPath(DEFAULT_CONTEXT_PATH
);
48 * Constructs a CdmRemoteSourceBase
54 * @param nomenclaturalCode
56 public CdmRemoteSourceBase(String name
, String server
, int port
, String contextPath
) {
60 setContextPath(contextPath
);
61 metadataService
= CdmApplicationRemoteConfiguration
.getMetadataService(this);
65 public String
getBaseUrl() {
70 * Sets the base url for the http-invoker services as listed in
71 * httpInvokerServicesClients.xml.
72 * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the
73 * base url would be 'http://127.0.0.1:8080/col'
77 public void setBaseUrl(String baseUrl
) {
78 this.baseUrl
= baseUrl
;
82 public String
getContextPath() {
87 * Sets the context path.
88 * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the
89 * context path would be 'col'
93 public void setContextPath(String contextPath
) {
94 this.contextPath
= contextPath
;
98 public String
getDbSchemaVersion() throws CdmSourceException
{
99 return metadataService
.getDbSchemaVersion();
104 public boolean isDbEmpty() throws CdmSourceException
{
105 return metadataService
.isDbEmpty();
110 public boolean checkConnection() throws CdmSourceException
{
111 // assuming that database service works implies
112 // the connection is up
113 // if no exception is thrown then we assume that the
115 // FIXME:Remoting is this really correct?
116 metadataService
.getDbSchemaVersion();
122 public String
getConnectionMessage() {
123 return "Connecting to Remote CDM Instance " + getName() + ":" + getPort() + "/" + getContextPath();
128 public Map
<MetaDataPropertyName
, String
> getMetaDataMap() throws CdmSourceException
{
129 return metadataService
.getCdmMetadataMap();