Project

General

Profile

Download (2.1 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2014 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.remoting.source;
10

    
11
import org.apache.commons.lang3.StringUtils;
12

    
13
import eu.etaxonomy.cdm.config.CdmSource;
14

    
15
/**
16
 * Base class representing a CDM remote source.
17
 * This class handles all the configuration relating to the remoting aspect of
18
 * a CDM source.
19
 */
20
public abstract class CdmRemoteSourceBase extends CdmSource implements ICdmRemoteSource {
21

    
22
	protected static final String DEFAULT_NAME = "default";
23
	protected static final String DEFAULT_SERVER = "127.0.0.1";
24
	protected static final int DEFAULT_PORT = 8080;
25

    
26
	private String baseUrl;
27

    
28
	/**
29
	 * Constructs a CdmRemoteSourceBase object with default values.
30
	 */
31
	protected CdmRemoteSourceBase() {
32
		setName(DEFAULT_NAME);
33
		setServer(DEFAULT_SERVER);
34
		setPort(DEFAULT_PORT);
35
	}
36

    
37
	/**
38
	 * Constructs a CdmRemoteSourceBase
39
	 *
40
	 * @param name
41
	 * @param server
42
	 * @param port
43
	 * @param contextPath
44
	 * @param nomenclaturalCode
45
	 */
46
	public CdmRemoteSourceBase(String name, String server, int port) {
47
		setName(name);
48
		setServer(server);
49
		setPort(port);
50
	}
51

    
52
	/**
53
	 * @see #setBaseUrl(String)
54
	 */
55
	@Override
56
	public String getBaseUrl() {
57
		return baseUrl;
58
	}
59

    
60
	/**
61
	 * Sets the base url for the http-invoker services as listed in
62
	 * httpInvokerServicesClients.xml.
63
	 * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the
64
	 * base url would be 'http://127.0.0.1:8080/col'
65
	 *
66
	 * @param baseUrl
67
	 */
68
	public void setBaseUrl(String baseUrl) {
69
		this.baseUrl = baseUrl;
70
	}
71

    
72
    @Override
73
    public String getConnectionMessage() {
74
        return "Connecting to Remote CDM Instance " + getName() + ":" + getPort() + "/" + getContext();
75
    }
76

    
77
    @Override
78
    public String toString() {
79
        String result = getName();
80
        if (StringUtils.isBlank(result)){
81
            return super.toString();
82
        }else{
83
            return result.replace("cdmserver/", "");
84
        }
85
    }
86
}
(4-4/8)