1
|
package eu.dnetlib.validator.web.actions;
|
2
|
|
3
|
import com.opensymphony.xwork2.ActionSupport;
|
4
|
import eu.dnetlib.repos.RepoApi;
|
5
|
import eu.dnetlib.users.UserApi;
|
6
|
import eu.dnetlib.validator.web.actions.configs.Constants;
|
7
|
import eu.dnetlib.validator.web.api.ValidatorWebApi;
|
8
|
import org.apache.log4j.Logger;
|
9
|
|
10
|
import java.io.PrintWriter;
|
11
|
import java.io.StringWriter;
|
12
|
import java.io.Writer;
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.List;
|
15
|
|
16
|
public class BaseValidatorAction extends ActionSupport {
|
17
|
|
18
|
/**
|
19
|
*
|
20
|
*/
|
21
|
private static final long serialVersionUID = -622158192564945303L;
|
22
|
private UserApi userAPI = null;
|
23
|
private RepoApi repoAPI = null;
|
24
|
private ValidatorWebApi validatorWebAPI = null;
|
25
|
private Emailer emailer = null;
|
26
|
|
27
|
private String valBaseUrl = null;
|
28
|
private String validatorAdminBaseUrl = null;
|
29
|
|
30
|
private String valAdminEmail = null;
|
31
|
private String userMode = null;
|
32
|
private String repoMode = null;
|
33
|
private String deployEnvironment = null;
|
34
|
private Boolean registrationFilesDownload = null;
|
35
|
private Boolean dnetWorkflow = null;
|
36
|
|
37
|
public void reportException(Exception exception) {
|
38
|
Writer writer = new StringWriter();
|
39
|
PrintWriter printWriter = new PrintWriter(writer);
|
40
|
exception.printStackTrace(printWriter);
|
41
|
|
42
|
List<String> recipients = new ArrayList<String>();
|
43
|
|
44
|
try {
|
45
|
recipients.add(this.getValAdminEmail());
|
46
|
String message = "An exception has occurred:\n"+writer.toString();
|
47
|
String subject = "Automatic Bug Report";
|
48
|
this.getEmailer().sendMail(recipients, subject, message, false, null);
|
49
|
} catch (Exception e) {
|
50
|
Logger logger = Logger.getLogger(BaseValidatorAction.class);
|
51
|
logger.error("error sending error report", e);
|
52
|
}
|
53
|
}
|
54
|
|
55
|
public boolean isEnvLareferencia() {
|
56
|
return deployEnvironment.trim().toLowerCase().equals(Constants.ENV_LAREFERENCIA);
|
57
|
}
|
58
|
|
59
|
public boolean isEnvOpenaire() {
|
60
|
return ( deployEnvironment.trim().toLowerCase().equals(Constants.ENV_OPENAIRE_BETA) ||
|
61
|
deployEnvironment.trim().toLowerCase().equals(Constants.ENV_OPENAIRE_PRODUCTION));
|
62
|
}
|
63
|
|
64
|
public UserApi getUserAPI() {
|
65
|
return userAPI;
|
66
|
}
|
67
|
|
68
|
public void setUserAPI(UserApi userAPI) {
|
69
|
this.userAPI = userAPI;
|
70
|
}
|
71
|
|
72
|
public RepoApi getRepoAPI() {
|
73
|
return repoAPI;
|
74
|
}
|
75
|
|
76
|
public void setRepoAPI(RepoApi repoAPI) {
|
77
|
this.repoAPI = repoAPI;
|
78
|
}
|
79
|
|
80
|
public ValidatorWebApi getValidatorWebAPI() {
|
81
|
return validatorWebAPI;
|
82
|
}
|
83
|
|
84
|
public void setValidatorWebAPI(ValidatorWebApi validatorWebAPI) {
|
85
|
this.validatorWebAPI = validatorWebAPI;
|
86
|
}
|
87
|
|
88
|
public Emailer getEmailer() {
|
89
|
return emailer;
|
90
|
}
|
91
|
|
92
|
public void setEmailer(Emailer emailer) {
|
93
|
this.emailer = emailer;
|
94
|
}
|
95
|
|
96
|
public String getUserMode() {
|
97
|
return userMode;
|
98
|
}
|
99
|
|
100
|
public void setUserMode(String userMode) {
|
101
|
this.userMode = userMode;
|
102
|
}
|
103
|
|
104
|
public void setValBaseUrl(String valBaseUrl) {
|
105
|
this.valBaseUrl = valBaseUrl;
|
106
|
}
|
107
|
|
108
|
public String getValBaseUrl() {
|
109
|
return valBaseUrl;
|
110
|
}
|
111
|
|
112
|
public void setValAdminEmail(String valAdminEmail) {
|
113
|
this.valAdminEmail = valAdminEmail;
|
114
|
}
|
115
|
|
116
|
public String getValAdminEmail() {
|
117
|
return valAdminEmail;
|
118
|
}
|
119
|
|
120
|
|
121
|
public String getRepoMode() {
|
122
|
return repoMode;
|
123
|
}
|
124
|
|
125
|
public void setRepoMode(String repoMode) {
|
126
|
this.repoMode = repoMode;
|
127
|
}
|
128
|
|
129
|
public String getDeployEnvironment() {
|
130
|
return deployEnvironment;
|
131
|
}
|
132
|
|
133
|
public void setDeployEnvironment(String deployEnvironment) {
|
134
|
this.deployEnvironment = deployEnvironment;
|
135
|
}
|
136
|
|
137
|
public Boolean getRegistrationFilesDownload() {
|
138
|
return registrationFilesDownload;
|
139
|
}
|
140
|
|
141
|
public void setRegistrationFilesDownload(Boolean registrationFilesDownload) {
|
142
|
this.registrationFilesDownload = registrationFilesDownload;
|
143
|
}
|
144
|
|
145
|
public Boolean getDnetWorkflow() {
|
146
|
return dnetWorkflow;
|
147
|
}
|
148
|
|
149
|
public void setDnetWorkflow(Boolean dnetWorkflow) {
|
150
|
this.dnetWorkflow = dnetWorkflow;
|
151
|
}
|
152
|
|
153
|
public String getValidatorAdminBaseUrl() {
|
154
|
return validatorAdminBaseUrl;
|
155
|
}
|
156
|
|
157
|
public void setValidatorAdminBaseUrl(String validatorAdminBaseUrl) {
|
158
|
this.validatorAdminBaseUrl = validatorAdminBaseUrl;
|
159
|
}
|
160
|
|
161
|
|
162
|
}
|