1
|
/**
|
2
|
* Copyright (C) 2008 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*/
|
6
|
|
7
|
package eu.etaxonomy.cdm.io.common;
|
8
|
|
9
|
import org.apache.log4j.Logger;
|
10
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
11
|
|
12
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
13
|
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
|
14
|
import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor;
|
15
|
import eu.etaxonomy.cdm.config.Configuration;
|
16
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
17
|
|
18
|
/**
|
19
|
* Base class for all import/export configurators.
|
20
|
* @author a.babadshanjan
|
21
|
* @created 16.11.2008
|
22
|
*/
|
23
|
public abstract class IoConfiguratorBase extends ObservableBase implements IIoConfigurator, IIoObservable{
|
24
|
|
25
|
private static final long serialVersionUID = -2254648962451309933L;
|
26
|
|
27
|
@SuppressWarnings("unused")
|
28
|
private static final Logger logger = Logger.getLogger(IoConfiguratorBase.class);
|
29
|
|
30
|
//im-/export uses Classification for is_taxonomically_included_in relationships
|
31
|
private boolean useClassification = true;
|
32
|
|
33
|
// protected Class<ICdmIO>[] ioClassList;
|
34
|
private DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
|
35
|
|
36
|
protected ICdmRepository cdmApp = null;
|
37
|
|
38
|
//authentification token
|
39
|
protected UsernamePasswordAuthenticationToken authenticationToken;
|
40
|
|
41
|
|
42
|
|
43
|
// private Set<IIoObserver> observers = new HashSet<>();
|
44
|
|
45
|
|
46
|
//etc
|
47
|
private IProgressMonitor progressMonitor;
|
48
|
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see eu.etaxonomy.cdm.io.common.IIoConfigurator#getDbSchemaValidation()
|
52
|
*/
|
53
|
@Override
|
54
|
public DbSchemaValidation getDbSchemaValidation() {
|
55
|
return dbSchemaValidation;
|
56
|
}
|
57
|
|
58
|
/* (non-Javadoc)
|
59
|
* @see eu.etaxonomy.cdm.io.common.IIoConfigurator#setDbSchemaValidation(eu.etaxonomy.cdm.database.DbSchemaValidation)
|
60
|
*/
|
61
|
@Override
|
62
|
public void setDbSchemaValidation(DbSchemaValidation dbSchemaValidation) {
|
63
|
this.dbSchemaValidation = dbSchemaValidation;
|
64
|
}
|
65
|
|
66
|
@Override
|
67
|
public ICdmRepository getCdmAppController(){
|
68
|
return this.cdmApp;
|
69
|
}
|
70
|
|
71
|
/**
|
72
|
* @param cdmApp the cdmApp to set
|
73
|
*/
|
74
|
@Override
|
75
|
public void setCdmAppController(ICdmRepository cdmApp) {
|
76
|
this.cdmApp = cdmApp;
|
77
|
}
|
78
|
|
79
|
/**
|
80
|
* @return the useClassification
|
81
|
*/
|
82
|
public boolean isUseClassification() {
|
83
|
return useClassification;
|
84
|
}
|
85
|
|
86
|
|
87
|
/**
|
88
|
* @param useClassification the useClassification to set
|
89
|
*/
|
90
|
public void setUseClassification(boolean useClassification) {
|
91
|
this.useClassification = useClassification;
|
92
|
}
|
93
|
|
94
|
@Override
|
95
|
public void setProgressMonitor(IProgressMonitor monitor) {
|
96
|
this.progressMonitor = monitor;
|
97
|
}
|
98
|
|
99
|
@Override
|
100
|
public IProgressMonitor getProgressMonitor(){
|
101
|
return progressMonitor != null ? progressMonitor : new NullProgressMonitor();
|
102
|
}
|
103
|
|
104
|
@Override
|
105
|
public UsernamePasswordAuthenticationToken getAuthenticationToken() {
|
106
|
return this.authenticationToken;
|
107
|
}
|
108
|
|
109
|
@Override
|
110
|
public void setAuthenticationToken(UsernamePasswordAuthenticationToken authenticationToken) {
|
111
|
this.authenticationToken = authenticationToken;
|
112
|
|
113
|
}
|
114
|
|
115
|
@Override
|
116
|
public void setAuthentication(String login, String password) {
|
117
|
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(login, password);
|
118
|
this.authenticationToken = token;
|
119
|
}
|
120
|
|
121
|
@Override
|
122
|
public void authenticateAsDefaultAdmin() {
|
123
|
setAuthentication(Configuration.adminLogin, Configuration.adminPassword);
|
124
|
}
|
125
|
|
126
|
|
127
|
}
|