Project

General

Profile

« Previous | Next » 

Revision 5a20c932

Added by Andreas Müller almost 4 years ago

ref #9025 improve localhost mgd. handling for schema create and update and some general minor improvements and refactorings

View differences:

eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmRemoteSourceBase.java
14 14

  
15 15
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration;
16 16
import eu.etaxonomy.cdm.api.service.IMetadataService;
17
import eu.etaxonomy.cdm.common.CdmUtils;
18 17
import eu.etaxonomy.cdm.config.CdmSource;
19 18
import eu.etaxonomy.cdm.config.CdmSourceException;
20 19
import eu.etaxonomy.cdm.model.metadata.CdmMetaDataPropertyName;
......
24 23
 * This class handles all the configuration relating to the remoting aspect of
25 24
 * a CDM source.
26 25
 */
27
public class CdmRemoteSourceBase extends CdmSource implements ICdmRemoteSource {
26
public abstract class CdmRemoteSourceBase extends CdmSource implements ICdmRemoteSource {
28 27

  
29 28
	protected static final String DEFAULT_NAME = "default";
30 29
	protected static final String DEFAULT_SERVER = "127.0.0.1";
31 30
	protected static final int DEFAULT_PORT = 8080;
32
	protected static final String DEFAULT_CONTEXT_PATH = "";
33
	private String contextPath;
31

  
34 32
	private String baseUrl;
35 33

  
36 34
	private IMetadataService metadataService;
......
42 40
		setName(DEFAULT_NAME);
43 41
		setServer(DEFAULT_SERVER);
44 42
		setPort(DEFAULT_PORT);
45
		setContextPath(DEFAULT_CONTEXT_PATH);
46 43
	}
47 44

  
48 45
	/**
......
54 51
	 * @param contextPath
55 52
	 * @param nomenclaturalCode
56 53
	 */
57
	public CdmRemoteSourceBase(String name, String server, int port, String contextPath) {
54
	public CdmRemoteSourceBase(String name, String server, int port) {
58 55
		setName(name);
59 56
		setServer(server);
60 57
		setPort(port);
61
		setContextPath(contextPath);
62 58
		metadataService = CdmApplicationRemoteConfiguration.getMetadataService(this);
63 59
	}
64 60

  
61
	/**
62
	 * @see #setBaseUrl(String)
63
	 */
65 64
	@Override
66 65
	public String getBaseUrl() {
67 66
		return baseUrl;
......
79 78
		this.baseUrl = baseUrl;
80 79
	}
81 80

  
82
	@Override
83
	public String getContextPath() {
84
		return contextPath;
85
	}
86

  
87
	/**
88
	 * Sets the context path.
89
	 * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the
90
	 * context path would be 'col'
91
	 *
92
	 * @param contextPath
93
	 */
94
	public void setContextPath(String contextPath) {
95
		this.contextPath = contextPath;
96
	}
81
    @Override
82
    public String getConnectionMessage() {
83
        return "Connecting to Remote CDM Instance " + getName() + ":" + getPort() + "/" + getContext();
84
    }
97 85

  
98 86
	@Override
99 87
	public String getDbSchemaVersion() throws CdmSourceException {
......
117 105
		return true;
118 106
	}
119 107

  
120
	@Override
121
	public String getConnectionMessage() {
122
		return "Connecting to Remote CDM Instance " + getName() + ":" + getPort() + "/" + getContextPath();
123
	}
124

  
125 108
	@Override
126 109
	public Map<CdmMetaDataPropertyName, String> getMetaDataMap() throws CdmSourceException {
127 110
		return metadataService.getCdmMetadataMap();
128 111
	}
129 112

  
130
	@Override
131
	public String toString() {
132
		String result = CdmUtils.concat("/", getName(),contextPath);
133
		if (StringUtils.isBlank(result)){
134
			return super.toString();
135
		}else{
136
			return result.replace("cdmserver/", "");
137
		}
138
	}
113
    @Override
114
    public String toString() {
115
        String result = getName();
116
        if (StringUtils.isBlank(result)){
117
            return super.toString();
118
        }else{
119
            return result.replace("cdmserver/", "");
120
        }
121
    }
139 122
}

Also available in: Unified diff