Revision 5a20c932
Added by Andreas Müller almost 4 years ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java | ||
---|---|---|
15 | 15 |
import java.util.List; |
16 | 16 |
import java.util.Map; |
17 | 17 |
|
18 |
import org.apache.commons.lang3.StringUtils; |
|
18 | 19 |
import org.apache.log4j.Logger; |
19 | 20 |
import org.springframework.beans.BeansException; |
20 | 21 |
import org.springframework.context.ApplicationContext; |
... | ... | |
87 | 88 |
import eu.etaxonomy.cdm.persistence.permission.voter.GrantAlwaysVoter; |
88 | 89 |
import eu.etaxonomy.cdm.persistence.permission.voter.TaxonBaseVoter; |
89 | 90 |
import eu.etaxonomy.cdm.persistence.permission.voter.TaxonNodeVoter; |
91 |
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource; |
|
90 | 92 |
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource; |
91 | 93 |
import eu.etaxonomy.taxeditor.service.AuthenticatingHttpInvokerRequestExecutor; |
92 | 94 |
import eu.etaxonomy.taxeditor.service.CachedCommonServiceImpl; |
... | ... | |
178 | 180 |
|
179 | 181 |
String baseUrl; |
180 | 182 |
String protocol = remoteSource.getPort() == 443 ? "https" : "http"; |
181 |
if(remoteSource.getContextPath() == null || remoteSource.getContextPath().equals("")) { |
|
183 |
|
|
184 |
String contextPath = (remoteSource instanceof CdmRemoteSource)? ((CdmRemoteSource)remoteSource).getContextPath() : ""; |
|
185 |
if(StringUtils.isBlank(contextPath)) { |
|
182 | 186 |
baseUrl = protocol + "://" + remoteSource.getServer() + ":" + String.valueOf(remoteSource.getPort()); |
183 | 187 |
} else { |
184 |
baseUrl = protocol + "://" + remoteSource.getServer() + ":" + String.valueOf(remoteSource.getPort()) + "/" + remoteSource.getContextPath();
|
|
188 |
baseUrl = protocol + "://" + remoteSource.getServer() + ":" + String.valueOf(remoteSource.getPort()) + "/" + contextPath;
|
|
185 | 189 |
} |
186 | 190 |
CachingHttpInvokerProxyFactoryBean proxyFactory = new CachingHttpInvokerProxyFactoryBean(); |
187 | 191 |
proxyFactory.setServiceInterface(clazz); |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmPersistentRemoteSource.java | ||
---|---|---|
33 | 33 |
/** |
34 | 34 |
* Class representing a CDM remote source which can be persisted to a source config file |
35 | 35 |
*/ |
36 |
public class CdmPersistentRemoteSource extends CdmRemoteSourceBase implements ICdmPersistentSource{ |
|
37 |
@SuppressWarnings("unused") |
|
36 |
public class CdmPersistentRemoteSource |
|
37 |
extends CdmRemoteSource |
|
38 |
implements ICdmPersistentSource{ |
|
39 |
|
|
40 |
@SuppressWarnings("unused") |
|
38 | 41 |
private static final Logger logger = Logger.getLogger(CdmPersistentRemoteSource.class); |
39 | 42 |
|
40 | 43 |
public static final String REMOTESOURCE_BEAN_POSTFIX = "RemoteSource"; |
... | ... | |
72 | 75 |
* @throws CdmRemoteSourceException |
73 | 76 |
*/ |
74 | 77 |
private CdmPersistentRemoteSource(String remoteSource) throws CdmRemoteSourceException { |
75 |
|
|
78 |
super(DEFAULT_NAME, DEFAULT_SERVER, DEFAULT_PORT, DEFAULT_CONTEXT_PATH); |
|
76 | 79 |
CdmPersistentXMLSource cdmPersistentXMLSource = CdmPersistentXMLSource.NewInstance(remoteSource, REMOTESOURCE_BEAN_POSTFIX); |
77 | 80 |
if(cdmPersistentXMLSource.getElement() != null) { |
78 | 81 |
beanName = cdmPersistentXMLSource.getBeanName(); |
... | ... | |
124 | 127 |
return cdmSourceProperties.getProperty(CdmSourceProperties.CONTEXTPATH.toString()); |
125 | 128 |
} |
126 | 129 |
|
127 |
public static CdmPersistentRemoteSource save(String strRemoteSourceName, ICdmRemoteSource remoteSource) throws CdmRemoteSourceException {
|
|
130 |
public static CdmPersistentRemoteSource save(String strRemoteSourceName, CdmRemoteSource remoteSource) throws CdmRemoteSourceException { |
|
128 | 131 |
Properties cdmSourceProperties = new Properties(); |
129 | 132 |
cdmSourceProperties.put(CdmSourceProperties.SERVER.toString(), remoteSource.getServer()); |
130 | 133 |
cdmSourceProperties.put(CdmSourceProperties.PORT.toString(), String.valueOf(remoteSource.getPort())); |
... | ... | |
147 | 150 |
} |
148 | 151 |
bean = insertXmlBean(root, CdmPersistentSourceUtils.getBeanName(strRemoteSourceName, REMOTESOURCE_BEAN_POSTFIX), CdmPersistentRemoteSource.class.getName()); |
149 | 152 |
|
150 |
|
|
151 | 153 |
Properties props = cdmSourceProperties; |
152 | 154 |
Enumeration<?> e = props.propertyNames(); |
153 | 155 |
|
... | ... | |
173 | 175 |
* the updated dataSource, null if not succesful |
174 | 176 |
*/ |
175 | 177 |
public static CdmPersistentRemoteSource update(String strRemoteSourceName, |
176 |
ICdmRemoteSource remoteSource) throws CdmRemoteSourceException {
|
|
178 |
CdmRemoteSource remoteSource) throws CdmRemoteSourceException { |
|
177 | 179 |
CdmPersistentSourceUtils.delete(CdmPersistentSourceUtils.getBeanName(strRemoteSourceName,REMOTESOURCE_BEAN_POSTFIX)); |
178 | 180 |
return save(strRemoteSourceName, remoteSource); |
179 | 181 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmRemoteLocalhostSource.java | ||
---|---|---|
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.common.CdmUtils; |
|
14 |
|
|
15 |
/** |
|
16 |
* Class representing a CDM remote source |
|
17 |
*/ |
|
18 |
public class CdmRemoteLocalhostSource extends CdmRemoteSourceBase { |
|
19 |
|
|
20 |
private String datasourceName; |
|
21 |
|
|
22 |
/** |
|
23 |
* Creates a new instance of CdmRemoteSource |
|
24 |
*/ |
|
25 |
public static CdmRemoteLocalhostSource NewInstance(String name, String server, int port, String datasourceName) { |
|
26 |
return new CdmRemoteLocalhostSource(name, server, port, datasourceName); |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* Creates a new CdmRemoteSource |
|
31 |
* |
|
32 |
* @param name |
|
33 |
* @param server |
|
34 |
* @param port |
|
35 |
* @param contextPath |
|
36 |
*/ |
|
37 |
private CdmRemoteLocalhostSource(String name, String server, int port, String datasourceName) { |
|
38 |
super(name, server, port); |
|
39 |
this.datasourceName = datasourceName; |
|
40 |
} |
|
41 |
|
|
42 |
public String getDatasourceName() { |
|
43 |
return datasourceName; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public String toString() { |
|
48 |
String result = CdmUtils.concat("/", getName(), datasourceName); |
|
49 |
if (StringUtils.isBlank(result)){ |
|
50 |
return super.toString(); |
|
51 |
}else{ |
|
52 |
return result.replace("cdmserver/", ""); |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public String getContext() { |
|
58 |
return getDatasourceName(); |
|
59 |
} |
|
60 |
|
|
61 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmRemoteSource.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.remoting.source; |
10 | 10 |
|
11 |
import org.apache.commons.lang3.StringUtils; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
14 |
|
|
11 | 15 |
/** |
12 | 16 |
* Class representing a CDM remote source |
13 | 17 |
*/ |
14 | 18 |
public class CdmRemoteSource extends CdmRemoteSourceBase { |
15 | 19 |
|
20 |
protected static final String DEFAULT_CONTEXT_PATH = ""; |
|
21 |
|
|
22 |
private String contextPath; |
|
23 |
|
|
24 |
|
|
16 | 25 |
/** |
17 | 26 |
* Creates a new instance of CdmRemoteSource |
18 | 27 |
*/ |
... | ... | |
41 | 50 |
* @param port |
42 | 51 |
* @param contextPath |
43 | 52 |
*/ |
44 |
private CdmRemoteSource(String name, String server, int port, String contextPath) { |
|
45 |
super(name, server, port, contextPath); |
|
53 |
protected CdmRemoteSource(String name, String server, int port, String contextPath) { |
|
54 |
super(name, server, port); |
|
55 |
this.contextPath = contextPath; |
|
46 | 56 |
} |
57 |
|
|
58 |
@Override |
|
59 |
public String getContext() { |
|
60 |
return contextPath; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* @see #setContextPath(String) |
|
65 |
*/ |
|
66 |
public String getContextPath() { |
|
67 |
return contextPath; |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Sets the context path. |
|
72 |
* e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the |
|
73 |
* context path would be 'col' |
|
74 |
* |
|
75 |
* @param contextPath |
|
76 |
*/ |
|
77 |
public void setContextPath(String contextPath) { |
|
78 |
this.contextPath = contextPath; |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public String toString() { |
|
83 |
String result = CdmUtils.concat("/", getName(), contextPath); |
|
84 |
if (StringUtils.isBlank(result)){ |
|
85 |
return super.toString(); |
|
86 |
}else{ |
|
87 |
return result.replace("cdmserver/", ""); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
47 | 91 |
} |
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 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmServerInfo.java | ||
---|---|---|
41 | 41 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
42 | 42 |
import eu.etaxonomy.cdm.config.CdmSourceException; |
43 | 43 |
import eu.etaxonomy.cdm.config.ConfigFileUtil; |
44 |
import eu.etaxonomy.cdm.config.ICdmSource; |
|
44 | 45 |
import eu.etaxonomy.cdm.database.CdmPersistentDataSource; |
45 | 46 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
46 | 47 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData; |
... | ... | |
96 | 97 |
this.port = parameterObject.getPort(); |
97 | 98 |
this.prefix = parameterObject.getPrefix(); |
98 | 99 |
this.ignoreCdmLibVersion = parameterObject.isIgnoreCdmLibVersion(); |
99 |
instances = new ArrayList<>(); |
|
100 |
this.instances = new ArrayList<>(); |
|
101 |
} |
|
102 |
|
|
103 |
public CdmInstanceInfo addInstance(String name, ICdmDataSource dataSource) { |
|
104 |
CdmInstanceInfo cii = new CdmInstanceInfo(name, dataSource); |
|
105 |
instances.add(cii); |
|
106 |
return cii; |
|
100 | 107 |
} |
101 | 108 |
|
102 | 109 |
public CdmInstanceInfo addInstance(String name, String basePath) { |
103 |
String _basePath = basePath; |
|
104 |
if(isLocalhostMgd()) { |
|
105 |
_basePath = ""; |
|
106 |
} |
|
107 |
CdmInstanceInfo cii = new CdmInstanceInfo(name, _basePath); |
|
110 |
CdmInstanceInfo cii = new CdmInstanceInfo(name, basePath); |
|
108 | 111 |
instances.add(cii); |
109 | 112 |
return cii; |
110 | 113 |
} |
... | ... | |
134 | 137 |
} |
135 | 138 |
Collections.sort(instances, new Comparator<CdmInstanceInfo>() { |
136 | 139 |
@Override |
137 |
public int compare(CdmInstanceInfo cii1, CdmInstanceInfo cii2) |
|
138 |
{ |
|
140 |
public int compare(CdmInstanceInfo cii1, CdmInstanceInfo cii2){ |
|
139 | 141 |
return cii1.getName().toString().compareTo(cii2.getName().toString()); |
140 | 142 |
} |
141 | 143 |
}); |
... | ... | |
237 | 239 |
for(ICdmDataSource dataSource : CdmPersistentDataSource.getAllDataSources()){ |
238 | 240 |
String datasourceNCName = CdmServerUtils.xmlNCNamefrom(dataSource.getName()); |
239 | 241 |
logger.info("Adding local instance " + dataSource.getName() + " as " + datasourceNCName); |
240 |
addInstance(datasourceNCName, datasourceNCName);
|
|
242 |
addInstance(datasourceNCName, dataSource);
|
|
241 | 243 |
} |
242 | 244 |
} |
243 | 245 |
|
... | ... | |
258 | 260 |
return null; |
259 | 261 |
} |
260 | 262 |
|
261 |
public CdmRemoteSource getCdmRemoteSource(CdmInstanceInfo instance, int port) { |
|
263 |
public ICdmRemoteSource getCdmRemoteSource(CdmInstanceInfo instance, int port) {
|
|
262 | 264 |
if(instance != null) { |
263 |
return CdmRemoteSource.NewInstance(name, |
|
264 |
server, |
|
265 |
port, |
|
266 |
instance.getBasePath() |
|
267 |
); |
|
265 |
if (instance.getDataSource()!=null){ |
|
266 |
return CdmRemoteLocalhostSource.NewInstance(name, |
|
267 |
server, |
|
268 |
port, |
|
269 |
instance.name |
|
270 |
); |
|
271 |
}else{ |
|
272 |
return CdmRemoteSource.NewInstance(name, |
|
273 |
server, |
|
274 |
port, |
|
275 |
instance.getBasePath() |
|
276 |
); |
|
277 |
} |
|
268 | 278 |
} |
269 | 279 |
return null; |
270 | 280 |
} |
... | ... | |
282 | 292 |
} |
283 | 293 |
|
284 | 294 |
public boolean pingInstance(CdmInstanceInfo instance, int port) throws CdmServerException { |
285 |
ICdmRemoteSource cdmRemoteSource = getCdmRemoteSource(instance, port);
|
|
295 |
ICdmSource cdmRemoteSource = getCdmRemoteSource(instance, port); |
|
286 | 296 |
try { |
287 | 297 |
if(cdmRemoteSource != null && cdmRemoteSource.checkConnection()) { |
288 | 298 |
logger.info("[CDM-Server] Running @ " + server + ":" + port + " for instance " + instance); |
... | ... | |
298 | 308 |
|
299 | 309 |
public int compareDbSchemaVersion(CdmInstanceInfo instance, int port) throws CdmServerException { |
300 | 310 |
|
301 |
ICdmRemoteSource crs = getCdmRemoteSource(instance, port);
|
|
302 |
String dbSchemaVersion;
|
|
311 |
ICdmSource remoteSource = getCdmRemoteSource(instance, port);
|
|
312 |
String remoteDbSchemaVersion;
|
|
303 | 313 |
try { |
304 |
dbSchemaVersion = crs.getDbSchemaVersion();
|
|
314 |
remoteDbSchemaVersion = remoteSource.getDbSchemaVersion();
|
|
305 | 315 |
} catch (CdmSourceException e) { |
306 | 316 |
throw new CdmServerException(e); |
307 | 317 |
} |
308 | 318 |
|
309 |
|
|
310 |
if(dbSchemaVersion != null) { |
|
311 |
return CdmMetaData.compareVersion(dbSchemaVersion, CdmMetaData.getDbSchemaVersion(), 3, null); |
|
319 |
if(remoteDbSchemaVersion != null) { |
|
320 |
return CdmMetaData.compareVersion(remoteDbSchemaVersion, CdmMetaData.getDbSchemaVersion(), 3, null); |
|
312 | 321 |
} else { |
313 |
throw new CdmServerException("Cannot determine editor db. schema version");
|
|
322 |
throw new CdmServerException("Cannot determine editor db schema version"); |
|
314 | 323 |
} |
315 | 324 |
} |
316 | 325 |
|
... | ... | |
413 | 422 |
} |
414 | 423 |
|
415 | 424 |
return serverList; |
416 |
|
|
417 |
|
|
418 | 425 |
} |
419 | 426 |
|
420 | 427 |
private static List<CdmServerInfoConfig> createDefaultServerConfigList() { |
... | ... | |
449 | 456 |
return instances; |
450 | 457 |
} |
451 | 458 |
|
452 |
public static CdmRemoteSource getDevServerRemoteSource() {
|
|
459 |
public static ICdmSource getDevServerRemoteSource() {
|
|
453 | 460 |
String value = System.getProperty("cdm.server.dev.port"); |
454 | 461 |
boolean available = false; |
455 | 462 |
CdmInstanceInfo devInstance = null; |
... | ... | |
486 | 493 |
*/ |
487 | 494 |
private final String basePath; |
488 | 495 |
|
496 |
private final ICdmDataSource dataSource; |
|
497 |
|
|
489 | 498 |
public CdmInstanceInfo(String name, String basePath) { |
490 | 499 |
this.name = name; |
491 | 500 |
this.basePath = basePath; |
501 |
this.dataSource = null; |
|
502 |
} |
|
503 |
|
|
504 |
public CdmInstanceInfo(String name, ICdmDataSource dataSource) { |
|
505 |
this.name = name; |
|
506 |
this.basePath = ""; |
|
507 |
this.dataSource = dataSource; |
|
492 | 508 |
} |
493 | 509 |
|
494 | 510 |
public String getName() { |
... | ... | |
498 | 514 |
public String getBasePath() { |
499 | 515 |
return basePath; |
500 | 516 |
} |
517 |
|
|
518 |
public ICdmDataSource getDataSource() { |
|
519 |
return dataSource; |
|
520 |
} |
|
501 | 521 |
} |
502 | 522 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/ICdmRemoteSource.java | ||
---|---|---|
20 | 20 |
* e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the |
21 | 21 |
* context path would be 'col' |
22 | 22 |
*/ |
23 |
public String getContextPath();
|
|
23 |
public String getContext(); |
|
24 | 24 |
|
25 | 25 |
/** |
26 | 26 |
* Gets the base url for the http-invoker services as listed in |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/datasource/CdmDataSourceRepository.java | ||
---|---|---|
29 | 29 |
import eu.etaxonomy.taxeditor.model.MementoHelper; |
30 | 30 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
31 | 31 |
import eu.etaxonomy.taxeditor.remoting.source.CdmPersistentRemoteSource; |
32 |
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource; |
|
32 | 33 |
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceException; |
33 | 34 |
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource; |
34 | 35 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
35 | 36 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
37 |
|
|
36 | 38 |
public class CdmDataSourceRepository{ |
37 | 39 |
|
38 | 40 |
/** Constant <code>TAG_DATASOURCE="tagDataSource"</code> */ |
... | ... | |
207 | 209 |
|
208 | 210 |
return true; |
209 | 211 |
} |
210 |
|
|
211 |
/** |
|
212 |
* <p>save</p> |
|
213 |
* |
|
214 |
* @param dataSource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object. |
|
215 |
* @param strDataSourceName a {@link java.lang.String} object. |
|
216 |
* @return a {@link eu.etaxonomy.cdm.database.CdmPersistentDataSource} object. |
|
217 |
* @throws CdmRemoteSourceException |
|
218 |
*/ |
|
219 |
public static ICdmPersistentSource save(String strCdmSourceName, ICdmRemoteSource cdmSource) throws CdmRemoteSourceException { |
|
220 |
return CdmPersistentRemoteSource.save(strCdmSourceName, cdmSource); |
|
221 |
} |
|
212 |
// |
|
213 |
// /**
|
|
214 |
// * <p>save</p>
|
|
215 |
// *
|
|
216 |
// * @param dataSource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object.
|
|
217 |
// * @param strDataSourceName a {@link java.lang.String} object.
|
|
218 |
// * @return a {@link eu.etaxonomy.cdm.database.CdmPersistentDataSource} object.
|
|
219 |
// * @throws CdmRemoteSourceException
|
|
220 |
// */
|
|
221 |
// public static ICdmPersistentSource save(String strCdmSourceName, ICdmRemoteSource cdmSource) throws CdmRemoteSourceException {
|
|
222 |
// return CdmPersistentRemoteSource.save(strCdmSourceName, cdmSource);
|
|
223 |
// }
|
|
222 | 224 |
|
223 | 225 |
/** |
224 | 226 |
* <p>save</p> |
... | ... | |
264 | 266 |
* @param dataSource a {@link eu.etaxonomy.cdm.database.ICdmDataSource} object. |
265 | 267 |
* @return a {@link eu.etaxonomy.cdm.database.CdmPersistentDataSource} object. |
266 | 268 |
*/ |
267 |
public static ICdmPersistentSource update(String strCdmSourceName, ICdmRemoteSource cdmSource){
|
|
269 |
public static ICdmPersistentSource update(String strCdmSourceName, CdmRemoteSource cdmSource){ |
|
268 | 270 |
try { |
269 | 271 |
return CdmPersistentRemoteSource.update(strCdmSourceName, cdmSource); |
270 | 272 |
} catch (Exception e) { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java | ||
---|---|---|
207 | 207 |
public static String RemotingLoginDialog_LABEL_CDM_INSTANCE; |
208 | 208 |
public static String RemotingLoginDialog_LABEL_CDM_SERVER; |
209 | 209 |
public static String RemotingLoginDialog_LABEL_CONNECT; |
210 |
public static String RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION; |
|
210 |
public static String RemotingLoginDialog_LABEL_CREATE_SCHEMA; |
|
211 |
public static String RemotingLoginDialog_LABEL_UPDATE_SCHEMA_VERSION; |
|
212 |
public static String RemotingLoginDialog_MSG_UPDATE_SCHEMA_VERSION; |
|
213 |
public static String RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION; |
|
211 | 214 |
public static String RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION; |
212 | 215 |
public static String RemotingLoginDialog_LABEL_LOGIN; |
213 | 216 |
public static String RemotingLoginDialog_LABEL_LOGIN_COLON; |
... | ... | |
246 | 249 |
public static String RemotingLoginDialog_STARTING_MGD_SERVER; |
247 | 250 |
public static String RemotingLoginDialog_TASK_LAUNCHING_SERVER; |
248 | 251 |
public static String RemotingLoginDialog_MISSING_PERMISSION; |
249 |
|
|
252 |
public static String RemotingLoginDialog_SCHEMA_MISSING; |
|
253 |
public static String RemotingLoginDialog_NO_SCHEMA; |
|
250 | 254 |
|
251 | 255 |
public static String SearchManager_LARGE_RESULT_EXPECTED; |
252 | 256 |
public static String SearchManager_LONG_SEARCH_WARNING; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties | ||
---|---|---|
106 | 106 |
RemotingLoginDialog_CONNECTION_FAILED_TITLE=Connection to CDM server failed |
107 | 107 |
RemotingLoginDialog_DEFAULT_LOGIN=Default: %s (login), %s (password) |
108 | 108 |
RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER=Please choose a compatible cdm-server or update the chosen cdm-server |
109 |
RemotingLoginDialog_SCHEMA_MISSING=Database schema is missing. Please create database schema.\nNOTE: This will delete all existing data!! |
|
110 |
RemotingLoginDialog_NO_SCHEMA=No Schema |
|
111 |
RemotingLoginDialog_MSG_UPDATE_SCHEMA_VERSION=Database requires schema update. Please update to latest schema |
|
109 | 112 |
RemotingLoginDialog_LABEL_ADVANCED=advanced |
110 | 113 |
RemotingLoginDialog_LABEL_CDM_INSTANCE=Database : |
111 | 114 |
RemotingLoginDialog_LABEL_CDM_SERVER=CDM Server : |
112 | 115 |
RemotingLoginDialog_LABEL_CONNECT=Connect |
116 |
RemotingLoginDialog_LABEL_CREATE_SCHEMA=Create Schema |
|
117 |
RemotingLoginDialog_LABEL_UPDATE_SCHEMA_VERSION=Update Schema |
|
113 | 118 |
RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION=Editor CDM Version : |
114 | 119 |
RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION=Editor Cdmlib Version : |
115 | 120 |
RemotingLoginDialog_LABEL_LOGIN=Login |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties | ||
---|---|---|
105 | 105 |
RemotingLoginDialog_CONNECTION_FAILED_TITLE=Verbindung fehlgeschlagen |
106 | 106 |
RemotingLoginDialog_DEFAULT_LOGIN=Standard: %s (Login), %s (Kennwort) |
107 | 107 |
RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER=Bitte w?hlen Sie einen kompatiblen CDM-Server oder aktualisieren sie den CDM-Server |
108 |
RemotingLoginDialog_SCHEMA_MISSING=Das Datenbankschema existiert nicht. Bitte erzeugen Sie das Datenbankschema.\nANMERKUNG: Dadurch werden alle existierenden Daten gel?scht!! |
|
109 |
RemotingLoginDialog_MSG_UPDATE_SCHEMA_VERSION=Das Datenbankschema ist veraltet. Bitte aktualisieren sie das Schema. |
|
110 |
RemotingLoginDialog_NO_SCHEMA=Kein Schema |
|
108 | 111 |
RemotingLoginDialog_LABEL_ADVANCED=Erweitert |
109 | 112 |
RemotingLoginDialog_LABEL_CDM_INSTANCE=Datenbank : |
110 | 113 |
RemotingLoginDialog_LABEL_CDM_SERVER=CDM-Server : |
111 | 114 |
RemotingLoginDialog_LABEL_CONNECT=Verbinden |
115 |
RemotingLoginDialog_LABEL_CREATE_SCHEMA=Schema generieren |
|
116 |
RemotingLoginDialog_LABEL_UPDATE_SCHEMA_VERSION=Schema aktualisieren |
|
112 | 117 |
RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION=Editor CDM Version : |
113 | 118 |
RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION=Editor Cdmlib Version : |
114 | 119 |
RemotingLoginDialog_LABEL_LOGIN=Login |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java | ||
---|---|---|
20 | 20 |
import eu.etaxonomy.cdm.config.ICdmSource; |
21 | 21 |
import eu.etaxonomy.cdm.persistence.permission.SecurityExceptionUtils; |
22 | 22 |
import eu.etaxonomy.taxeditor.remoting.RemoteExecutionTimestampsUtil; |
23 |
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource; |
|
23 |
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
|
|
24 | 24 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
25 | 25 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
26 | 26 |
|
... | ... | |
186 | 186 |
name = activeCdmSource.getName(); |
187 | 187 |
schemaVersion = activeCdmSource.getDbSchemaVersion(); |
188 | 188 |
server = activeCdmSource.getServer(); |
189 |
if(activeCdmSource instanceof CdmRemoteSource){ |
|
190 |
contextPath = ((CdmRemoteSource) activeCdmSource).getContextPath();
|
|
189 |
if(activeCdmSource instanceof ICdmRemoteSource){
|
|
190 |
contextPath = ((ICdmRemoteSource)activeCdmSource).getContext();
|
|
191 | 191 |
if (contextPath != null && contextPath.startsWith("cdmserver/")){ |
192 | 192 |
contextPath = contextPath.substring("cdmserver/".length()); |
193 | 193 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java | ||
---|---|---|
79 | 79 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
80 | 80 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
81 | 81 |
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper; |
82 |
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource; |
|
82 |
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
|
|
83 | 83 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
84 | 84 |
import eu.etaxonomy.taxeditor.store.TermStore; |
85 | 85 |
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin; |
... | ... | |
183 | 183 |
} |
184 | 184 |
|
185 | 185 |
private static String prefKey(String name) { |
186 |
return name + "_"+ ((CdmRemoteSource)CdmStore.getActiveCdmSource()).toString(); |
|
186 |
return name + "_"+ ((ICdmRemoteSource)CdmStore.getActiveCdmSource()).toString();
|
|
187 | 187 |
} |
188 | 188 |
|
189 | 189 |
public static String prefOverrideKey(String name) { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java | ||
---|---|---|
122 | 122 |
} |
123 | 123 |
} |
124 | 124 |
return Status.CANCEL_STATUS; |
125 |
|
|
126 | 125 |
} |
127 | 126 |
|
128 | 127 |
public void start(final RemotingLoginDialog loginDialog) { |
... | ... | |
171 | 170 |
applicationController = getApplicationController(cdmSource,subprogressMonitor); |
172 | 171 |
} |
173 | 172 |
|
174 |
|
|
175 | 173 |
if (!monitor.isCanceled()) { |
176 | 174 |
CdmStore.setInstance(applicationController, cdmSource); |
177 | 175 |
monitor.subTask(Messages.CdmStoreConnector_AUTHENTICATING_USER); |
178 |
display.syncExec(new Runnable() { |
|
179 |
|
|
180 |
@Override |
|
181 |
public void run() { |
|
182 |
|
|
183 |
try { |
|
184 |
// create new security context |
|
185 |
CdmStore.getLoginManager().doAuthenticate(loginDialog.getUsername(), loginDialog.getPassword()); |
|
186 |
//loginDialog.onComplete(); |
|
187 |
CdmStore.getContextManager().notifyContextStart(); |
|
188 |
loginDialog.onComplete(); |
|
189 |
getInstance(Rank.class).resetTerms(); |
|
190 |
getInstance(NomenclaturalStatusType.class).resetTerms(); |
|
191 |
Rank.initDefaultTerms(); |
|
192 |
NomenclaturalStatusType.initDefaultTerms(); |
|
193 |
} catch(CdmAuthenticationException cae) { |
|
194 |
loginDialog.hide(false); |
|
195 |
loginDialog.setMessage(Messages.RemotingLoginDialog_MISSING_PERMISSION); |
|
196 |
} |
|
176 |
display.syncExec(()-> { |
|
177 |
try { |
|
178 |
// create new security context |
|
179 |
CdmStore.getLoginManager().doAuthenticate(loginDialog.getUsername(), loginDialog.getPassword()); |
|
180 |
//loginDialog.onComplete(); |
|
181 |
CdmStore.getContextManager().notifyContextStart(); |
|
182 |
loginDialog.onComplete(); |
|
183 |
getInstance(Rank.class).resetTerms(); |
|
184 |
getInstance(NomenclaturalStatusType.class).resetTerms(); |
|
185 |
Rank.initDefaultTerms(); |
|
186 |
NomenclaturalStatusType.initDefaultTerms(); |
|
187 |
} catch(CdmAuthenticationException cae) { |
|
188 |
loginDialog.hide(false); |
|
189 |
loginDialog.setMessage(Messages.RemotingLoginDialog_MISSING_PERMISSION); |
|
197 | 190 |
} |
198 | 191 |
}); |
199 | 192 |
} else { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/bar/AuthenticatedUserBar.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
import eu.etaxonomy.cdm.model.permission.User; |
23 | 23 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
24 |
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource; |
|
24 |
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
|
|
25 | 25 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
26 | 26 |
import eu.etaxonomy.taxeditor.util.ApplicationUtil; |
27 | 27 |
|
... | ... | |
67 | 67 |
if(authenticatedUser == null) { |
68 | 68 |
text = Messages.AuthenticatedUserBar_NOT_LOGGED_IN ; |
69 | 69 |
} else { |
70 |
CdmRemoteSource source = (CdmRemoteSource) CdmStore.getActiveCdmSource();
|
|
71 |
String loginInfo = String.format("%s@%s:%s",authenticatedUser.getUsername(), source.getName(), source.getContextPath()); //$NON-NLS-1$
|
|
70 |
ICdmRemoteSource source = (ICdmRemoteSource) CdmStore.getActiveCdmSource();
|
|
71 |
String loginInfo = String.format("%s@%s:%s",authenticatedUser.getUsername(), source.getName(), source.getContext()); //$NON-NLS-1$ |
|
72 | 72 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setText(ApplicationUtil.getTitle() + " " + loginInfo); //$NON-NLS-1$ |
73 | 73 |
|
74 | 74 |
text = String.format(Messages.AuthenticatedUserBar_LOGGED_IN_AS, authenticatedUser.getUsername()); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java | ||
---|---|---|
60 | 60 |
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration; |
61 | 61 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
62 | 62 |
import eu.etaxonomy.cdm.api.service.IUserService; |
63 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
64 |
import eu.etaxonomy.cdm.config.CdmSourceException; |
|
65 |
import eu.etaxonomy.cdm.config.ICdmSource; |
|
63 | 66 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData; |
64 | 67 |
import eu.etaxonomy.cdm.persistence.permission.Role; |
65 | 68 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
... | ... | |
68 | 71 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
69 | 72 |
import eu.etaxonomy.taxeditor.remoting.server.CdmServerException; |
70 | 73 |
import eu.etaxonomy.taxeditor.remoting.server.CdmServerUtils; |
71 |
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource; |
|
74 |
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteLocalhostSource;
|
|
72 | 75 |
import eu.etaxonomy.taxeditor.remoting.source.CdmServerInfo; |
73 | 76 |
import eu.etaxonomy.taxeditor.remoting.source.CdmServerInfo.CdmInstanceInfo; |
74 | 77 |
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource; |
... | ... | |
111 | 114 |
|
112 | 115 |
private final static String MESG_COMPATIBLE_EDITOR_OLD = Messages.RemotingLoginDialog_UPDATE_EDITOR; |
113 | 116 |
private final static String MESG_COMPATIBLE_SERVER_OLD = Messages.RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER; |
117 |
private final static String MESG_SCHEMA_MISSING = Messages.RemotingLoginDialog_SCHEMA_MISSING; |
|
118 |
private final static String MESG_NO_SCHEMA = Messages.RemotingLoginDialog_NO_SCHEMA; |
|
119 |
|
|
120 |
private final static String LABEL_CONNECT = Messages.RemotingLoginDialog_LABEL_CONNECT; |
|
121 |
private final static String LABEL_CREATE_SCHEMA = Messages.RemotingLoginDialog_LABEL_CREATE_SCHEMA; |
|
122 |
private final static String LABEL_UPDATE_SCHEMA_VERSION = Messages.RemotingLoginDialog_LABEL_UPDATE_SCHEMA_VERSION; |
|
123 |
private final static String MESG_UPDATE_SCHEMA_VERSION = Messages.RemotingLoginDialog_MSG_UPDATE_SCHEMA_VERSION; |
|
114 | 124 |
|
115 | 125 |
private final static String STORE_PREFERENCES_NODE = "eu.etaxonomy.taxeditor.store"; //$NON-NLS-1$ |
116 | 126 |
|
... | ... | |
123 | 133 |
private final static String LAST_INSTANCE_KEY = "lastInstanceKey"; //$NON-NLS-1$ |
124 | 134 |
|
125 | 135 |
private Composite remotingComposite; |
126 |
private CdmServerInfo selectedCsii;
|
|
136 |
private CdmServerInfo selectedServerInfo;
|
|
127 | 137 |
private CdmInstanceInfo selectedCdmInstance; |
128 | 138 |
private Button btnCdmServerRefresh; |
129 | 139 |
private Button btnCdmInstanceRefresh; |
... | ... | |
137 | 147 |
private Composite compAdvanced; |
138 | 148 |
private Label lblPort; |
139 | 149 |
private Text txtPort; |
140 |
private Label lblServerVersion; |
|
141 |
private Text txtServerVersion; |
|
142 |
private ExpandableComposite xpndblcmpstAdvanced;
|
|
150 |
private Label lblServerCdmlibVersion;
|
|
151 |
private Text txtServerCdmlibVersion;
|
|
152 |
private ExpandableComposite expandableCompositeAdvanced;
|
|
143 | 153 |
private StyledText styledTxtMessage; |
144 | 154 |
|
145 | 155 |
// private final int MIN_WIDTH = 530; |
... | ... | |
147 | 157 |
// private final int MIN_EXP_HEIGHT = 380; |
148 | 158 |
|
149 | 159 |
private final int MESSAGE_HEIGHT = 50; |
150 |
private Label lblEditorVersion; |
|
151 |
private Text txtEditorVersion; |
|
152 |
private Label lblServerCDMVersion;
|
|
153 |
private Text txtServerCDMVersion;
|
|
154 |
private Label lblEditorCDMVersion;
|
|
155 |
private Text txtEditorCDMVersion;
|
|
160 |
private Label lblEditorCdmlibVersion;
|
|
161 |
private Text txtEditorCdmlibVersion;
|
|
162 |
private Label lblServerSchemaVersion;
|
|
163 |
private Text txtServerSchemaVersion;
|
|
164 |
private Label lblEditorCdmVersion;
|
|
165 |
private Text txtEditorCdmVersion;
|
|
156 | 166 |
|
157 | 167 |
private String serverName, instanceName; |
158 | 168 |
private boolean autoConnect = false; |
... | ... | |
170 | 180 |
setText(Messages.RemotingLoginDialog_LABEL_LOGIN); |
171 | 181 |
} |
172 | 182 |
|
173 |
public Object open(CdmRemoteSource source, boolean loadLoginPrefs, boolean autoConnect) { |
|
183 |
public Object open(ICdmRemoteSource source, boolean loadLoginPrefs, boolean autoConnect) {
|
|
174 | 184 |
this.loadLoginPrefs = loadLoginPrefs; |
175 | 185 |
this.serverName = source.getName(); |
176 |
String contextPath = source.getContextPath(); |
|
177 |
this.instanceName = contextPath.substring(contextPath.lastIndexOf("/") + 1); //$NON-NLS-1$ |
|
186 |
if (source instanceof CdmRemoteLocalhostSource){ |
|
187 |
this.instanceName = ((CdmRemoteLocalhostSource)source).getDatasourceName(); |
|
188 |
}else{ |
|
189 |
String contextPath = source.getContext(); |
|
190 |
this.instanceName = contextPath == null? "" : contextPath.substring(contextPath.lastIndexOf("/") + 1); //$NON-NLS-1$ |
|
191 |
} |
|
178 | 192 |
return open(serverName, instanceName, loadLoginPrefs, autoConnect); |
179 | 193 |
} |
180 | 194 |
|
181 |
|
|
182 | 195 |
public Object open(String serverName, String instanceName, boolean loadLoginPrefs, boolean autoConnect) { |
183 | 196 |
this.serverName = serverName; |
184 | 197 |
this.instanceName = instanceName; |
... | ... | |
203 | 216 |
shlConnect.pack(true); |
204 | 217 |
shlConnect.open(); |
205 | 218 |
|
206 |
xpndblcmpstAdvanced.setExpanded(false);
|
|
219 |
expandableCompositeAdvanced.setExpanded(false);
|
|
207 | 220 |
|
208 | 221 |
Display display = getParent().getDisplay(); |
209 | 222 |
|
... | ... | |
223 | 236 |
*/ |
224 | 237 |
private void createContents() { |
225 | 238 |
shlConnect = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); |
226 |
shlConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT);
|
|
239 |
shlConnect.setText(LABEL_CONNECT); |
|
227 | 240 |
shlConnect.setLayout(new FillLayout(SWT.HORIZONTAL)); |
228 | 241 |
|
229 | 242 |
remotingComposite = new Composite(shlConnect, SWT.NONE); |
230 | 243 |
remotingComposite.setLayout(new GridLayout(1, false)); |
231 | 244 |
|
245 |
//server |
|
232 | 246 |
Composite cdmServerComposite = new Composite(remotingComposite, SWT.NONE); |
233 | 247 |
GridData gd_cdmServerComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); |
234 | 248 |
cdmServerComposite.setLayoutData(gd_cdmServerComposite); |
... | ... | |
267 | 281 |
btnCdmServerRefresh.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); |
268 | 282 |
btnCdmServerRefresh.setText(Messages.RemotingLoginDialog_LABEL_REFRESH); |
269 | 283 |
|
284 |
//instance |
|
270 | 285 |
Label lblCdmInstance = new Label(cdmServerComposite, SWT.NONE); |
271 | 286 |
GridData gd_lblCdmInstance = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); |
272 | 287 |
//gd_lblCdmInstance.heightHint = 30; |
... | ... | |
302 | 317 |
btnCdmInstanceRefresh.setLayoutData(gd_btnCdmInstanceRefresh); |
303 | 318 |
btnCdmInstanceRefresh.setText(Messages.RemotingLoginDialog_LABEL_REFRESH); |
304 | 319 |
|
320 |
//login |
|
305 | 321 |
loginComposite = new Composite(remotingComposite, SWT.NONE); |
306 | 322 |
GridData gd_loginComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); |
307 | 323 |
loginComposite.setLayoutData(gd_loginComposite); |
... | ... | |
329 | 345 |
GridData gd_txtPassword = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1); |
330 | 346 |
gd_txtPassword.minimumWidth = 80; |
331 | 347 |
txtPassword.setLayoutData(gd_txtPassword); |
332 |
new Label(loginComposite, SWT.NONE); |
|
348 |
@SuppressWarnings("unused") |
|
349 |
Label nope = new Label(loginComposite, SWT.NONE); |
|
333 | 350 |
txtPassword.addKeyListener(new KeyAdapter() { |
334 | 351 |
@Override |
335 | 352 |
public void keyPressed(KeyEvent e) { |
... | ... | |
347 | 364 |
connectButtonPressed(); |
348 | 365 |
} |
349 | 366 |
}); |
350 |
btnConnect.setText(Messages.RemotingLoginDialog_LABEL_CONNECT);
|
|
367 |
btnConnect.setText(LABEL_CONNECT); |
|
351 | 368 |
|
352 | 369 |
btnRememberMe = new Button(loginComposite, SWT.CHECK); |
353 | 370 |
btnRememberMe.setSelection(true); |
... | ... | |
375 | 392 |
|
376 | 393 |
styledTxtMessage.setLayoutData(gd_styledTxtMessage); |
377 | 394 |
|
378 |
xpndblcmpstAdvanced = new ExpandableComposite(remotingComposite, SWT.NONE, ExpandableComposite.TWISTIE); |
|
395 |
//Advanced |
|
396 |
expandableCompositeAdvanced = new ExpandableComposite(remotingComposite, SWT.NONE, ExpandableComposite.TWISTIE); |
|
379 | 397 |
GridData gd_xpndblcmpstAdvanced = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1); |
380 |
xpndblcmpstAdvanced.setLayoutData(gd_xpndblcmpstAdvanced);
|
|
381 |
xpndblcmpstAdvanced.addExpansionListener(new IExpansionListener() {
|
|
398 |
expandableCompositeAdvanced.setLayoutData(gd_xpndblcmpstAdvanced);
|
|
399 |
expandableCompositeAdvanced.addExpansionListener(new IExpansionListener() {
|
|
382 | 400 |
@Override |
383 | 401 |
public void expansionStateChanged(ExpansionEvent e) { |
384 | 402 |
shlConnect.pack(true); |
... | ... | |
387 | 405 |
public void expansionStateChanging(ExpansionEvent e) { |
388 | 406 |
} |
389 | 407 |
}); |
390 |
xpndblcmpstAdvanced.setText(Messages.RemotingLoginDialog_LABEL_ADVANCED);
|
|
391 |
xpndblcmpstAdvanced.setExpanded(true);
|
|
408 |
expandableCompositeAdvanced.setText(Messages.RemotingLoginDialog_LABEL_ADVANCED);
|
|
409 |
expandableCompositeAdvanced.setExpanded(true);
|
|
392 | 410 |
|
393 |
compAdvanced = new Composite(xpndblcmpstAdvanced, SWT.NONE);
|
|
394 |
xpndblcmpstAdvanced.setClient(compAdvanced);
|
|
411 |
compAdvanced = new Composite(expandableCompositeAdvanced, SWT.NONE);
|
|
412 |
expandableCompositeAdvanced.setClient(compAdvanced);
|
|
395 | 413 |
compAdvanced.setLayout(new GridLayout(4, false)); |
396 | 414 |
|
397 | 415 |
lblPort = new Label(compAdvanced, SWT.CENTER); |
... | ... | |
404 | 422 |
gd_txtPort.minimumWidth = 50; |
405 | 423 |
txtPort.setLayoutData(gd_txtPort); |
406 | 424 |
|
407 |
lblServerVersion = new Label(compAdvanced, SWT.CENTER); |
|
408 |
lblServerVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); |
|
409 |
lblServerVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDMLIB_VERSION); |
|
410 |
lblServerVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL)); |
|
425 |
lblServerCdmlibVersion = new Label(compAdvanced, SWT.CENTER); |
|
426 |
lblServerCdmlibVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); |
|
427 |
lblServerCdmlibVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDMLIB_VERSION); |
|
428 |
lblServerCdmlibVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL)); |
|
429 |
|
|
430 |
txtServerCdmlibVersion = new Text(compAdvanced, SWT.BORDER); |
|
431 |
txtServerCdmlibVersion.setEditable(false); |
|
432 |
txtServerCdmlibVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); |
|
411 | 433 |
|
412 |
txtServerVersion = new Text(compAdvanced, SWT.BORDER); |
|
413 |
txtServerVersion.setEditable(false); |
|
414 |
txtServerVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); |
|
415 | 434 |
btnStopServer = new Button(compAdvanced, SWT.FLAT); |
416 | 435 |
btnStopServer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); |
417 | 436 |
btnStopServer.addMouseListener(new MouseAdapter() { |
... | ... | |
422 | 441 |
}); |
423 | 442 |
btnStopServer.setText(Messages.RemotingLoginDialog_LABEL_STOP_MANAGED_SERVER); |
424 | 443 |
|
425 |
lblEditorVersion = new Label(compAdvanced, SWT.CENTER); |
|
426 |
lblEditorVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); |
|
427 |
lblEditorVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION); |
|
428 |
lblEditorVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL)); |
|
444 |
lblEditorCdmlibVersion = new Label(compAdvanced, SWT.CENTER);
|
|
445 |
lblEditorCdmlibVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
|
446 |
lblEditorCdmlibVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION);
|
|
447 |
lblEditorCdmlibVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
|
|
429 | 448 |
|
430 |
txtEditorVersion = new Text(compAdvanced, SWT.BORDER); |
|
431 |
txtEditorVersion.setEditable(false); |
|
432 |
txtEditorVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); |
|
449 |
txtEditorCdmlibVersion = new Text(compAdvanced, SWT.BORDER);
|
|
450 |
txtEditorCdmlibVersion.setEditable(false);
|
|
451 |
txtEditorCdmlibVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
|
433 | 452 |
addEmptyCells(2); |
434 | 453 |
|
435 |
lblServerCDMVersion = new Label(compAdvanced, SWT.CENTER);
|
|
436 |
lblServerCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
|
437 |
lblServerCDMVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDM_VERSION);
|
|
438 |
lblServerCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
|
|
454 |
lblServerSchemaVersion = new Label(compAdvanced, SWT.CENTER);
|
|
455 |
lblServerSchemaVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
|
456 |
lblServerSchemaVersion.setText(Messages.RemotingLoginDialog_LABEL_SERVER_CDM_VERSION);
|
|
457 |
lblServerSchemaVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
|
|
439 | 458 |
|
440 |
txtServerCDMVersion = new Text(compAdvanced, SWT.BORDER);
|
|
441 |
txtServerCDMVersion.setEditable(false);
|
|
442 |
txtServerCDMVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER , true, false, 1, 1));
|
|
459 |
txtServerSchemaVersion = new Text(compAdvanced, SWT.BORDER);
|
|
460 |
txtServerSchemaVersion.setEditable(false);
|
|
461 |
txtServerSchemaVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
|
443 | 462 |
addEmptyCells(2); |
444 | 463 |
|
445 |
lblEditorCDMVersion = new Label(compAdvanced, SWT.CENTER);
|
|
446 |
lblEditorCDMVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
|
447 |
lblEditorCDMVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION);
|
|
448 |
lblEditorCDMVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
|
|
464 |
lblEditorCdmVersion = new Label(compAdvanced, SWT.CENTER);
|
|
465 |
lblEditorCdmVersion.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
|
466 |
lblEditorCdmVersion.setText(Messages.RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION);
|
|
467 |
lblEditorCdmVersion.setFont(SWTResourceManager.getFont(UBUNTU, 9, SWT.NORMAL));
|
|
449 | 468 |
|
450 |
txtEditorCDMVersion = new Text(compAdvanced, SWT.BORDER);
|
|
451 |
txtEditorCDMVersion.setEditable(false);
|
|
452 |
txtEditorCDMVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
|
469 |
txtEditorCdmVersion = new Text(compAdvanced, SWT.BORDER);
|
|
470 |
txtEditorCdmVersion.setEditable(false);
|
|
471 |
txtEditorCdmVersion.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
|
453 | 472 |
} |
454 | 473 |
|
455 | 474 |
@SuppressWarnings("unused") |
... | ... | |
460 | 479 |
} |
461 | 480 |
|
462 | 481 |
private void connectButtonPressed() { |
463 |
if(selectedCsii.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) {
|
|
482 |
if(selectedServerInfo.isLocalhostMgd() && !isSelectedCdmInstanceRunningInManagedServer()) {
|
|
464 | 483 |
startManagedServer(); |
465 | 484 |
} else { |
466 | 485 |
connect(); |
... | ... | |
491 | 510 |
} else { |
492 | 511 |
comboCdmServer.select(serverIndex); |
493 | 512 |
} |
494 |
CdmRemoteSource devRemoteSource = CdmServerInfo.getDevServerRemoteSource();
|
|
513 |
ICdmSource devRemoteSource = CdmServerInfo.getDevServerRemoteSource();
|
|
495 | 514 |
if(devRemoteSource != null) { |
496 | 515 |
isDevRemoteSource = true; |
497 | 516 |
String username = System.getProperty("cdm.server.dev.username"); //$NON-NLS-1$ |
... | ... | |
534 | 553 |
private void updateSelectedCdmServer() { |
535 | 554 |
int selIndex = comboCdmServer.getSelectionIndex(); |
536 | 555 |
if(selIndex != -1) { |
537 |
selectedCsii = csiiMap.get(comboCdmServer.getItem(selIndex));
|
|
556 |
selectedServerInfo = csiiMap.get(comboCdmServer.getItem(selIndex));
|
|
538 | 557 |
} |
539 | 558 |
} |
540 | 559 |
|
541 | 560 |
private void updatePort() { |
542 | 561 |
txtPort.setText(""); //$NON-NLS-1$ |
543 |
if(selectedCsii != null) {
|
|
544 |
int port = selectedCsii.getPort();
|
|
562 |
if(selectedServerInfo != null) {
|
|
563 |
int port = selectedServerInfo.getPort();
|
|
545 | 564 |
if(port == CdmServerInfo.NULL_PORT) { |
546 | 565 |
txtPort.setText(CdmServerInfo.NULL_PORT_STRING); |
547 | 566 |
} else { |
... | ... | |
564 | 583 |
|
565 | 584 |
private void checkSelectedCdmServer() { |
566 | 585 |
try{ |
567 |
if(selectedCsii != null) {
|
|
568 |
if(selectedCsii.isLocalhost()) {
|
|
586 |
if(selectedServerInfo != null) {
|
|
587 |
if(selectedServerInfo.isLocalhost()) {
|
|
569 | 588 |
txtPort.setEditable(true); |
570 | 589 |
txtPort.setEnabled(true); |
590 |
setCdmlibVersion(txtServerCdmlibVersion); |
|
571 | 591 |
} |
572 | 592 |
try { |
573 |
if(selectedCsii.pingServer()) {
|
|
593 |
if(selectedServerInfo.pingServer()) {
|
|
574 | 594 |
txtCdmServerStatus.setText(STATUS_AVAILABLE); |
575 | 595 |
populateCdmInstanceCombo(true); |
576 |
String serverVersionTimestamp = generateLastModifiedTooltip(selectedCsii.getCdmlibLastModified());
|
|
577 |
txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
|
|
596 |
String serverVersionTimestamp = generateLastModifiedTooltip(selectedServerInfo.getCdmlibLastModified());
|
|
597 |
txtServerCdmlibVersion.setText(selectedServerInfo.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
|
|
578 | 598 |
} else { |
579 | 599 |
txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE); |
580 | 600 |
comboCdmInstance.removeAll(); |
... | ... | |
615 | 635 |
@Override |
616 | 636 |
protected IStatus run(IProgressMonitor monitor) { |
617 | 637 |
try { |
618 |
if(selectedCsii != null) {
|
|
638 |
if(selectedServerInfo != null) {
|
|
619 | 639 |
if(forceRefresh) { |
620 |
selectedCsii.refreshInstances();
|
|
640 |
selectedServerInfo.refreshInstances();
|
|
621 | 641 |
} |
622 |
final List<CdmInstanceInfo> instances = selectedCsii.getInstances();
|
|
642 |
final List<CdmInstanceInfo> instances = selectedServerInfo.getInstances();
|
|
623 | 643 |
Display.getDefault().asyncExec(new Runnable() { |
624 | 644 |
@Override |
625 | 645 |
public void run() { |
... | ... | |
688 | 708 |
private void updateSelectedCdmInstance() { |
689 | 709 |
int selIndex = comboCdmInstance.getSelectionIndex(); |
690 | 710 |
if(selIndex != -1) { |
691 |
selectedCdmInstance = selectedCsii.getInstanceFromName(comboCdmInstance.getItem(selIndex)); |
|
692 |
|
|
711 |
selectedCdmInstance = selectedServerInfo.getInstanceFromName(comboCdmInstance.getItem(selIndex)); |
|
693 | 712 |
if(loadLoginPrefs) { |
694 | 713 |
readPrefCredentials(); |
695 | 714 |
} |
... | ... | |
697 | 716 |
} |
698 | 717 |
|
699 | 718 |
private void updateManagedServerControls() { |
700 |
if(selectedCsii.isLocalhostMgd()) {
|
|
719 |
if(selectedServerInfo.isLocalhostMgd()) {
|
|
701 | 720 |
if(isSelectedCdmInstanceRunningInManagedServer()) { |
702 | 721 |
txtCdmInstanceStatus.setText(STATUS_STARTED); |
703 | 722 |
} else { |
704 | 723 |
txtCdmInstanceStatus.setText(STATUS_NOT_STARTED); |
705 | 724 |
} |
706 | 725 |
btnConnect.setEnabled(true); |
707 |
selectedCsii.setPort(getManagedServerPort());
|
|
726 |
selectedServerInfo.setPort(getManagedServerPort());
|
|
708 | 727 |
updatePort(); |
709 | 728 |
} |
710 | 729 |
|
... | ... | |
722 | 741 |
private boolean isSelectedCdmInstanceRunningInManagedServer() { |
723 | 742 |
return CdmStore.getManagedServer() != null && |
724 | 743 |
CdmStore.getManagedServer().isAlive() && |
725 |
selectedCsii.isLocalhostMgd() &&
|
|
744 |
selectedServerInfo.isLocalhostMgd() &&
|
|
726 | 745 |
CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName()); |
727 | 746 |
} |
728 | 747 |
|
... | ... | |
740 | 759 |
} |
741 | 760 |
} |
742 | 761 |
|
762 |
boolean forceSchemaCreate = !schemaExists(selectedCdmInstance); |
|
763 |
boolean forceSchemaUpdate = LABEL_UPDATE_SCHEMA_VERSION.equals(btnConnect.getText()); |
|
764 |
|
|
743 | 765 |
Job job = new Job(Messages.RemotingLoginDialog_JOB_SERVER_LAUNCH) { |
744 | 766 |
|
745 | 767 |
@Override |
... | ... | |
752 | 774 |
monitor.subTask(String.format(Messages.RemotingLoginDialog_GENERATING_CONFIG_FILE, selectedCdmInstance.getName())); |
753 | 775 |
File managedServerConfigFile = CdmServerUtils.writeManagedServerConfig(config, mgdServerConfigFileName); |
754 | 776 |
monitor.worked(1); |
755 |
boolean forceSchemaCreate = CdmStore.getManagedServer() != null |
|
756 |
&& CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName()) |
|
757 |
&& CdmStore.getManagedServer().isForceSchemaCreate(); |
|
758 |
CdmStore.setManagedServer(new CdmServer(selectedCdmInstance.getName(), managedServerConfigFile)); |
|
759 |
CdmStore.getManagedServer().setForceSchemaCreate(forceSchemaCreate); |
|
777 |
CdmServer cdmServer = new CdmServer(selectedCdmInstance.getName(), managedServerConfigFile); |
|
778 |
// boolean forceSchemaCreate = CdmStore.getManagedServer() != null |
|
779 |
// && CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName()) |
|
780 |
// && CdmStore.getManagedServer().isForceSchemaCreate(); |
|
781 |
cdmServer.setForceSchemaCreate(forceSchemaCreate); |
|
782 |
cdmServer.setForceSchemaUpdate(forceSchemaUpdate); |
|
783 |
CdmStore.setManagedServer(cdmServer); |
|
760 | 784 |
monitor.subTask(Messages.RemotingLoginDialog_STARTING_MGD_SERVER); |
761 |
CdmStore.getManagedServer().start(false, RemotingLoginDialog.this);
|
|
785 |
cdmServer.start(false, RemotingLoginDialog.this);
|
|
762 | 786 |
int serverUnits = 0; |
763 | 787 |
|
764 | 788 |
// the following loop is a 'fake' progress monitoring where the progress |
... | ... | |
773 | 797 |
serverUnits++; |
774 | 798 |
} |
775 | 799 |
} |
776 |
Display.getDefault().asyncExec(new Runnable() { |
|
777 |
@Override |
|
778 |
public void run() { |
|
800 |
Display.getDefault().syncExec(()->{ |
|
779 | 801 |
hide(false); |
780 | 802 |
updateManagedServerControls(); |
781 | 803 |
connect(); |
782 |
} |
|
783 | 804 |
}); |
784 | 805 |
} catch (IOException ioe) { |
785 | 806 |
MessagingUtils.errorDialog(Messages.RemotingLoginDialog_ERROR_GENERATING_CONFIG_FILE, |
... | ... | |
803 | 824 |
|
804 | 825 |
return Status.OK_STATUS; |
805 | 826 |
} |
806 |
};
|
|
827 |
}; |
|
807 | 828 |
|
808 | 829 |
// configure the job |
809 | 830 |
job.setProperty(IProgressConstants.KEEP_PROPERTY, true); |
... | ... | |
813 | 834 |
job.schedule(); |
814 | 835 |
} |
815 | 836 |
|
837 |
private boolean schemaExists(CdmInstanceInfo instanceInfo) { |
|
838 |
if (instanceInfo.getDataSource() != null){ |
|
839 |
try { |
|
840 |
//TODO we need a new method in cdmlib to check for existing schema |
|
841 |
String schemaVersion = instanceInfo.getDataSource().getDbSchemaVersion(); |
|
842 |
return schemaVersion != null; |
|
843 |
} catch (CdmSourceException e) { |
|
844 |
return false; |
|
845 |
} |
|
846 |
}else{ |
|
847 |
return true; |
|
848 |
} |
|
849 |
} |
|
850 |
|
|
851 |
private String managedSchemaVersion(CdmInstanceInfo instanceInfo) throws CdmSourceException{ |
|
852 |
if (instanceInfo.getDataSource() != null){ |
|
853 |
return instanceInfo.getDataSource().getDbSchemaVersion(); |
|
854 |
}else{ |
|
855 |
throw new RuntimeException("ManagedSchemaVersion only available for managed server instances."); |
|
856 |
} |
|
857 |
} |
|
858 |
private int compareSchemaVersion(CdmInstanceInfo instanceInfo) throws CdmSourceException { |
|
859 |
return CdmMetaData.compareVersion(managedSchemaVersion(instanceInfo), CdmMetaData.getDbSchemaVersion(), 3, null); |
|
860 |
} |
|
861 |
|
|
816 | 862 |
@Override |
817 | 863 |
public void handleError(final Throwable t) { |
818 | 864 |
|
819 | 865 |
if(CdmStore.getManagedServer().isFailed() && CdmStore.getManagedServer().isPotentiallyMissingSchema()) { |
820 | 866 |
CdmStore.getManagedServer().setForceSchemaCreate(true); |
821 | 867 |
// we are in a separate thread here, thus update the screen via |
822 |
Display.getDefault().asyncExec(new Runnable() { |
|
823 |
@Override |
|
824 |
public void run() { |
|
825 |
btnConnect.setEnabled(true); |
|
826 |
btnConnect.setText("Create Schema"); |
|
827 |
btnConnect.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
828 |
btnConnect.requestLayout(); |
|
829 |
} |
|
830 |
}); |
|
868 |
checkManagedSelectedInstance(); |
|
831 | 869 |
} else { |
832 | 870 |
Display.getDefault().syncExec(new Runnable() { |
833 | 871 |
@Override |
... | ... | |
868 | 906 |
} |
869 | 907 |
|
870 | 908 |
private void checkSelectedCdmInstance() { |
871 |
boolean available = false; |
|
872 |
String status = STATUS_NOT_AVAILABLE; |
|
873 |
String message = null; |
|
874 | 909 |
|
875 |
if(txtCdmServerStatus.getText().equals(STATUS_AVAILABLE)) { |
|
910 |
if (selectedServerInfo.isLocalhostMgd()){ |
|
911 |
checkManagedSelectedInstance(); |
|
912 |
}else if (txtCdmServerStatus.getText().equals(STATUS_AVAILABLE)) { |
|
913 |
boolean available = false; |
|
914 |
String instanceStatus = STATUS_NOT_AVAILABLE; |
|
915 |
String message = null; |
|
876 | 916 |
try { |
877 |
if(selectedCsii.pingInstance(selectedCdmInstance, getPort())) {
|
|
878 |
status = STATUS_AVAILABLE;
|
|
917 |
if(selectedServerInfo.pingInstance(selectedCdmInstance, getPort())) {
|
|
918 |
instanceStatus = STATUS_AVAILABLE;
|
|
879 | 919 |
available = true; |
880 | 920 |
} else { |
881 |
status = STATUS_NOT_AVAILABLE;
|
|
921 |
instanceStatus = STATUS_NOT_AVAILABLE;
|
|
882 | 922 |
available = false; |
883 | 923 |
} |
884 | 924 |
|
885 | 925 |
if(available) { |
886 |
txtServerCDMVersion.setText(selectedCsii.getCdmRemoteSource(selectedCdmInstance, getPort()).getDbSchemaVersion()); |
|
887 |
int compareDbSchemaVersion = selectedCsii.compareDbSchemaVersion(selectedCdmInstance, getPort()); |
|
926 |
txtServerSchemaVersion.setText(selectedServerInfo.getCdmRemoteSource(selectedCdmInstance, getPort()).getDbSchemaVersion()); |
|
927 |
|
|
928 |
int compareDbSchemaVersion = selectedServerInfo.compareDbSchemaVersion(selectedCdmInstance, getPort()); |
|
929 |
|
|
888 | 930 |
int compareCdmlibServicesVersion = 0; |
889 | 931 |
boolean disableServicesApiTimestampCheck = |
890 | 932 |
PreferencesUtil.getBooleanValue((IPreferenceKeys.DISABLE_SERVICES_API_TIMESTAMP_CHECK)); |
891 | 933 |
if(!disableServicesApiTimestampCheck) { |
892 |
compareCdmlibServicesVersion = selectedCsii.compareCdmlibServicesVersion();
|
|
934 |
compareCdmlibServicesVersion = selectedServerInfo.compareCdmlibServicesVersion();
|
|
893 | 935 |
} |
936 |
|
|
894 | 937 |
if(compareDbSchemaVersion > 0 || compareCdmlibServicesVersion > 0) { |
895 |
status = STATUS_NOT_COMPATIBLE;
|
|
938 |
instanceStatus = STATUS_NOT_COMPATIBLE;
|
|
896 | 939 |
available = false; |
897 | 940 |
message = MESG_COMPATIBLE_EDITOR_OLD; |
898 | 941 |
} else if(compareDbSchemaVersion < 0 || compareCdmlibServicesVersion < 0) { |
899 |
status = STATUS_NOT_COMPATIBLE;
|
|
942 |
instanceStatus = STATUS_NOT_COMPATIBLE;
|
|
900 | 943 |
available = false; |
901 | 944 |
message = MESG_COMPATIBLE_SERVER_OLD; |
902 | 945 |
} else { |
903 |
status = STATUS_AVAILABLE;
|
|
946 |
instanceStatus = STATUS_AVAILABLE;
|
|
904 | 947 |
available = true; |
905 | 948 |
message = ""; //$NON-NLS-1$ |
906 | 949 |
} |
... | ... | |
909 | 952 |
txtCdmInstanceStatus.setToolTipText(e.getMessage()); |
910 | 953 |
} finally { |
911 | 954 |
btnConnect.setEnabled(available); |
912 |
txtCdmInstanceStatus.setText(status);
|
|
955 |
txtCdmInstanceStatus.setText(instanceStatus);
|
|
913 | 956 |
if(!StringUtils.isBlank(message)) { |
914 | 957 |
setMessage(message); |
915 | 958 |
} |
... | ... | |
917 | 960 |
} |
918 | 961 |
} |
919 | 962 |
|
963 |
private void checkManagedSelectedInstance() { |
|
964 |
boolean available = false; |
|
965 |
String instanceStatus = STATUS_NOT_AVAILABLE; |
|
966 |
String message = null; |
|
967 |
String connect = LABEL_CONNECT; |
|
968 |
int color = SWT.COLOR_BLACK; |
|
969 |
String schemaVersion = CdmMetaData.getDbSchemaVersion(); |
|
970 |
|
|
971 |
if (!schemaExists(selectedCdmInstance)){ |
|
972 |
message = MESG_SCHEMA_MISSING; |
|
973 |
connect = LABEL_CREATE_SCHEMA; |
|
974 |
color = SWT.COLOR_RED; |
|
975 |
schemaVersion = MESG_NO_SCHEMA; |
|
976 |
} else { |
|
977 |
int compare; |
|
978 |
try { |
|
979 |
schemaVersion = managedSchemaVersion(selectedCdmInstance); |
|
980 |
compare = compareSchemaVersion(selectedCdmInstance); |
|
981 |
if (compare > 0){ |
|
982 |
instanceStatus = STATUS_NOT_COMPATIBLE; |
|
983 |
message = MESG_COMPATIBLE_EDITOR_OLD; |
|
984 |
available = false; |
|
985 |
}else if (compare < 0){ |
|
986 |
instanceStatus = STATUS_NOT_COMPATIBLE; |
|
987 |
message = MESG_UPDATE_SCHEMA_VERSION; |
|
988 |
available = true; |
|
989 |
connect = LABEL_UPDATE_SCHEMA_VERSION; |
|
990 |
color = SWT.COLOR_RED; |
|
991 |
}else{ |
|
992 |
available = true; |
|
993 |
instanceStatus = STATUS_AVAILABLE; |
|
994 |
} |
|
995 |
} catch (CdmSourceException e) { |
|
996 |
available = false; |
|
997 |
} |
|
998 |
} |
|
999 |
|
|
1000 |
setManagedValues(available, instanceStatus, connect, color, schemaVersion); |
|
1001 |
setMessage(message); |
|
1002 |
} |
|
1003 |
|
|
1004 |
private void setManagedValues(boolean available, String instanceStatus, String connect, int color, |
|
1005 |
String schemaVersion) { |
|
1006 |
Display.getDefault().syncExec(()->{ |
|
1007 |
btnConnect.setEnabled(available); |
|
1008 |
btnConnect.setText(connect); |
|
1009 |
btnConnect.setBackground(Display.getCurrent().getSystemColor(color)); |
|
1010 |
btnConnect.requestLayout(); |
|
1011 |
txtCdmInstanceStatus.setText(instanceStatus); |
|
1012 |
txtServerSchemaVersion.setText(schemaVersion); |
|
1013 |
}); |
|
1014 |
} |
|
1015 |
|
|
920 | 1016 |
private void connect() { |
921 | 1017 |
checkSelectedCdmInstance(); |
922 | 1018 |
|
... | ... | |
924 | 1020 |
return; |
925 | 1021 |
} |
926 | 1022 |
|
927 |
ICdmRemoteSource source = selectedCsii.getCdmRemoteSource(selectedCdmInstance, getPort());
|
|
1023 |
ICdmRemoteSource source = selectedServerInfo.getCdmRemoteSource(selectedCdmInstance, getPort());
|
|
928 | 1024 |
|
929 | 1025 |
if(!validateLogin(source)) { |
930 | 1026 |
return; |
... | ... | |
947 | 1043 |
IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(STORE_PREFERENCES_NODE); |
948 | 1044 |
Preferences lastServerInstancePrefs = preferences.node(LAST_SERVER_INSTANCE_NODE); |
949 | 1045 |
|
950 |
lastServerInstancePrefs.put(LAST_SERVER_KEY, selectedCsii.getName());
|
|
1046 |
lastServerInstancePrefs.put(LAST_SERVER_KEY, selectedServerInfo.getName());
|
|
951 | 1047 |
lastServerInstancePrefs.put(LAST_INSTANCE_KEY, selectedCdmInstance.getName()); |
952 | 1048 |
|
953 | 1049 |
flushPreferences(lastServerInstancePrefs); |
... | ... | |
1012 | 1108 |
} |
1013 | 1109 |
|
1014 | 1110 |
private String getUsernamePrefKey() { |
1015 |
return selectedCsii.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + USERNAME_SUFFIX;
|
|
1111 |
return selectedServerInfo.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + USERNAME_SUFFIX;
|
|
1016 | 1112 |
} |
1017 | 1113 |
|
1018 | 1114 |
private String getPasswordPrefKey() { |
1019 |
return selectedCsii.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + PASSWORD_SUFFIX;
|
|
1115 |
return selectedServerInfo.toString(selectedCdmInstance.getName(), isDevRemoteSource?getPort():-1) + PASSWORD_SUFFIX;
|
|
1020 | 1116 |
} |
1021 | 1117 |
|
1022 | 1118 |
private boolean validateLogin(ICdmRemoteSource remoteSource) { |
... | ... | |
1055 | 1151 |
} |
1056 | 1152 |
|
1057 | 1153 |
public void setMessage(String message) { |
1058 |
if(message != null && !message.isEmpty()) {
|
|
1154 |
if(CdmUtils.isNotBlank(message)) {
|
|
1059 | 1155 |
// if(message.length() > 50) { |
1060 | 1156 |
// styledTxtMessage.setToolTipText(message); |
1061 | 1157 |
// message = message.substring(0,50) + "..."; //$NON-NLS-1$ |
... | ... | |
1136 | 1232 |
} |
1137 | 1233 |
|
1138 | 1234 |
private void setEditorInfo() { |
1139 |
txtEditorCDMVersion.setText(CdmMetaData.getDbSchemaVersion()); |
|
1235 |
txtEditorCdmVersion.setText(CdmMetaData.getDbSchemaVersion()); |
|
1236 |
setCdmlibVersion(txtEditorCdmlibVersion); |
|
1237 |
String editorVersionTimestamp = generateLastModifiedTooltip(CdmApplicationState.getCdmlibLastModified()); |
|
1238 |
txtEditorCdmlibVersion.setText(CdmApplicationState.getCdmlibVersion() + ":" + editorVersionTimestamp); //$NON-NLS-1$ |
|
1239 |
} |
|
1240 |
|
|
1241 |
private void setCdmlibVersion(Text txt) { |
|
1140 | 1242 |
String editorVersionTimestamp = generateLastModifiedTooltip(CdmApplicationState.getCdmlibLastModified()); |
1141 |
txtEditorVersion.setText(CdmApplicationState.getCdmlibVersion() + ":" + editorVersionTimestamp); //$NON-NLS-1$
|
|
1243 |
txt.setText(CdmApplicationState.getCdmlibVersion() + ":" + editorVersionTimestamp); //$NON-NLS-1$ |
|
1142 | 1244 |
} |
1143 | 1245 |
|
1144 | 1246 |
private void clearOnServerChange() { |
1145 | 1247 |
setMessage(""); //$NON-NLS-1$ |
1146 |
txtServerCDMVersion.setText(""); //$NON-NLS-1$
|
|
1147 |
txtServerVersion.setText(""); //$NON-NLS-1$ |
|
1148 |
txtServerVersion.setToolTipText(""); //$NON-NLS-1$ |
|
1149 |
txtServerCDMVersion.setText(""); //$NON-NLS-1$
|
|
1248 |
txtServerSchemaVersion.setText(""); //$NON-NLS-1$
|
|
1249 |
txtServerCdmlibVersion.setText(""); //$NON-NLS-1$
|
|
1250 |
txtServerCdmlibVersion.setToolTipText(""); //$NON-NLS-1$
|
|
1251 |
txtServerSchemaVersion.setText(""); //$NON-NLS-1$
|
|
1150 | 1252 |
comboCdmInstance.removeAll(); |
1151 | 1253 |
txtCdmInstanceStatus.setText(""); //$NON-NLS-1$ |
1152 | 1254 |
txtPort.setEditable(false); |
... | ... | |
1155 | 1257 |
|
1156 | 1258 |
private void clearOnInstanceChange() { |
1157 | 1259 |
setMessage(""); //$NON-NLS-1$ |
1158 |
txtServerCDMVersion.setText(""); //$NON-NLS-1$
|
|
1260 |
txtServerSchemaVersion.setText(""); //$NON-NLS-1$
|
|
1159 | 1261 |
} |
1160 | 1262 |
} |
eu.etaxonomy.taxeditor.webapp/src/main/java/eu/etaxonomy/taxeditor/webapp/CdmServer.java | ||
---|---|---|
49 | 49 |
|
50 | 50 |
public static final Logger logger = Logger.getLogger(CdmServer.class); |
51 | 51 |
|
52 |
//TODO use the constants defined in eu.etaxonomy.cdm.opt.config.DataSourceConfigurer |
|
53 |
private static final String ATTRIBUTE_FORCE_SCHEMA_CREATE = "cdm.forceSchemaCreate"; |
|
54 |
private static final String ATTRIBUTE_FORCE_SCHEMA_UPDATE = "cdm.forceSchemaUpdate"; |
|
55 |
private static final String ATTRIBUTE_DATASOURCE_NAME = "cdm.datasource"; |
|
56 |
private static final String CDM_BEAN_DEFINITION_FILE = "cdm.beanDefinitionFile"; |
|
57 |
|
|
58 |
//see eu.etaxonomy.cdm.server.Bootloader.SPRING_PROFILES_ACTIVE |
|
59 |
private static final String SPRING_PROFILES_ACTIVE = "spring.profiles.active"; |
|
60 |
|
|
61 |
|
|
52 | 62 |
private final String dataSourceName; |
53 | 63 |
private final String host = "127.0.0.1"; |
54 | 64 |
private int httpPort = 9090; |
... | ... | |
59 | 69 |
|
60 | 70 |
private boolean potentiallyMissingSchema; |
61 | 71 |
private boolean forceSchemaCreate = false; |
72 |
private boolean forceSchemaUpdate = false; |
|
62 | 73 |
|
63 | 74 |
public CdmServer(String dataSourceName, File dataSourcesFile) throws CdmEmbeddedServerException { |
64 | 75 |
if(StringUtil.isBlank(dataSourceName)) { |
... | ... | |
88 | 99 |
throw new CdmEmbeddedServerException(ioe); |
89 | 100 |
} |
90 | 101 |
|
91 |
//TODO instead of strings, use the constants defined in eu.etaxonomy.cdm.opt.config.DataSourceConfigurer |
|
92 |
System.setProperty("spring.profiles.active", "remoting"); |
|
93 |
System.setProperty("cdm.beanDefinitionFile", dataSourcesFile.getAbsolutePath()); |
|
94 |
System.setProperty("cdm.datasource", dataSourceName); |
|
102 |
System.setProperty(SPRING_PROFILES_ACTIVE, "remoting"); |
Also available in: Unified diff
ref #9025 improve localhost mgd. handling for schema create and update and some general minor improvements and refactorings