Project

General

Profile

« Previous | Next » 

Revision 47449

moving to dnet45

View differences:

modules/uoa-validator-web/trunk/deploy.info
1
{
2
  "type_source": "SVN", 
3
  "goal": "package -U -T 4C source:jar", 
4
  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-validator-web/trunk", 
5
  "deploy_repository": "dnet4-snapshots", 
6
  "version": "4", 
7
  "mail": "nikonas@di.uoa.gr", 
8
  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
9
  "name": "uoa-validator-web"
10
}
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/browsejobs/SummaryExport.java
1
package eu.dnetlib.validator.web.actions.browsejobs;
2

  
3
import java.io.File;
4
import java.io.FileInputStream;
5
import java.io.FileNotFoundException;
6
import java.io.FileOutputStream;
7
import java.io.InputStream;
8
import java.util.ArrayList;
9
import java.util.HashMap;
10
import java.util.List;
11
import java.util.Map;
12
import java.util.Set;
13

  
14
import org.apache.log4j.Logger;
15
import org.apache.poi.ss.usermodel.Cell;
16
import org.apache.poi.ss.usermodel.CellStyle;
17
import org.apache.poi.ss.usermodel.IndexedColors;
18
import org.apache.poi.ss.usermodel.Row;
19
import org.apache.poi.xssf.usermodel.XSSFSheet;
20
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
21

  
22
import eu.dnetlib.domain.functionality.validator.JobResultEntry;
23
import eu.dnetlib.domain.functionality.validator.StoredJob;
24
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
25
import eu.dnetlib.validator.web.api.ValidatorWebException;
26

  
27
public class SummaryExport extends BaseValidatorAction {
28

  
29
	/**
30
	 * 
31
	 */
32
	private static final long serialVersionUID = -9171201866627765708L;
33

  
34
	private static final Logger logger = Logger.getLogger(SummaryExport.class);
35

  
36
	private InputStream inputStream;
37
	private long contentLength;
38
	private String fileName;
39
	private String fileType;
40

  
41
	private int jobId;
42

  
43
	public String execute() throws FileNotFoundException {
44

  
45
		try {
46

  
47
			this.fileType = ".xlsx";
48
			this.fileName = "jobReport_" + jobId;
49
			File fileToDownload = new File("/tmp/" + fileName + fileType);
50

  
51
			if (!fileToDownload.exists())
52
				this.prepareSummary();
53

  
54
			inputStream = new FileInputStream(fileToDownload);
55
			fileName = fileToDownload.getName();
56
			contentLength = fileToDownload.length();
57

  
58
			return SUCCESS;
59
		} catch (Exception e) {
60
			this.addActionError(this.getText("generic.error"));
61
			reportException(e);
62
			return "exception";
63
		}
64
	}
65

  
66
	public static Logger getLogger() {
67
		return logger;
68
	}
69

  
70
	public InputStream getInputStream() {
71
		return inputStream;
72
	}
73

  
74
	public long getContentLength() {
75
		return contentLength;
76
	}
77

  
78
	public String getFileName() {
79
		return fileName;
80
	}
81

  
82
	public int getJobId() {
83
		return jobId;
84
	}
85

  
86
	public void setJobId(int jobId) {
87
		this.jobId = jobId;
88
	}
89

  
90
	private void prepareSummary() throws Exception {
91

  
92
		try {
93

  
94
			StoredJob job = this.getValidatorWebAPI().getJobSummary(jobId,
95
					"all");
96
			Set<String> groupBy_values = null;
97
			int filteredScore;
98

  
99
			if (job.getFilteredScores() != null)
100
				groupBy_values = job.getFilteredScores().keySet();
101

  
102
			Map<String, List<String>> setMap = new HashMap<String, List<String>>();
103
			for (String set : groupBy_values) {
104
				logger.debug("set: " + set);
105
				if (!set.contains(".")) {
106
					logger.debug("don't contain");
107
					List<String> group = new ArrayList<String>();
108
					group.add(set);
109
					setMap.put(set, group);
110
				} else {
111
					logger.debug("contains: " + set.split("\\.")[0]);
112

  
113
					if (setMap.containsKey(set.split("\\.")[0])) {
114
						setMap.get(set.split("\\.")[0]).add(set);
115
					} else {
116
						List<String> group = new ArrayList<String>();
117
						group.add(set);
118
						setMap.put(set.split("\\.")[0], group);
119
					}
120
				}
121
			}
122

  
123
			for (Map.Entry<String, List<String>> entry : setMap.entrySet()) {
124
				String key = entry.getKey();
125
				List<String> value = entry.getValue();
126
				logger.debug("[" + key + "]");
127
				logger.debug("    |    ");
128
				String groupp = "";
129
				for (String set : value)
130
					groupp = groupp + "-" + set;
131
				logger.debug(groupp);
132
				// ...
133
			}
134

  
135
			// Blank workbook
136
			XSSFWorkbook workbook = new XSSFWorkbook();
137

  
138
			CellStyle style = workbook.createCellStyle();
139
			style.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT
140
					.getIndex());
141

  
142
			for (Map.Entry<String, List<String>> entry : setMap.entrySet()) {
143
				String key = entry.getKey();
144
				List<String> value = entry.getValue();
145

  
146
				// Create a blank sheet
147
				XSSFSheet sheet = workbook.createSheet(key);
148
				int rownum = 0;
149
				Row row = sheet.createRow(rownum++);
150
				// sheet.setColumnWidth(0, 4330);
151
				Cell cell = row.createCell(0);
152
				cell.setCellStyle(style);
153
				cell.setCellValue("Filter By");
154
				// sheet.setColumnWidth(1, 7500);
155
				cell = row.createCell(1);
156
				cell.setCellStyle(style);
157
				cell.setCellValue("Rule ID");
158
				cell = row.createCell(2);
159
				cell.setCellStyle(style);
160
				cell.setCellValue("Rule name");
161
				cell = row.createCell(3);
162
				cell.setCellStyle(style);
163
				cell.setCellValue("Status");
164
				cell = row.createCell(4);
165
				cell.setCellStyle(style);
166
				cell.setCellValue("Used for Score Calculation");
167
				cell = row.createCell(5);
168
				cell.setCellStyle(style);
169
				cell.setCellValue("# of records tested");
170
				cell = row.createCell(6);
171
				cell.setCellStyle(style);
172
				cell.setCellValue("# of records succeed");
173
				// cell = row.createCell(7);
174
				// cell.setCellStyle(style);
175
				// cell.setCellValue("FAIL/SUCCESS");
176
				cell = row.createCell(7);
177
				cell.setCellStyle(style);
178
				cell.setCellValue("Score Rate %");
179

  
180
				for (String groupBy : value) {
181
					List<JobResultEntry> entries = this.getValidatorWebAPI()
182
							.getJobSummary(jobId, groupBy).getResultEntries();
183
					int ruleId = 1;
184
					rownum++;
185
					for (JobResultEntry entry1 : entries) {
186

  
187
						row = sheet.createRow(rownum++);
188
						if (ruleId == 1) {
189
							filteredScore = job.getFilteredScores()
190
									.get(groupBy);
191
							cell = row.createCell(9);
192
							cell.setCellStyle(style);
193
							cell.setCellValue("Scores: ");
194
							cell = row.createCell(10);
195
							cell.setCellValue("Content");
196
							cell = row.createCell(11);
197
							cell.setCellValue(filteredScore);
198
							if (!job.getUsageJobStatus().equalsIgnoreCase(
199
									"none")) {
200
								cell = row.createCell(12);
201
								cell.setCellValue("Usage");
202
								cell = row.createCell(13);
203
								cell.setCellValue(job.getUsageJobScore());
204
							}
205

  
206
						}
207
						cell = row.createCell(0);
208
						cell.setCellValue(groupBy);
209
						cell = row.createCell(1);
210
						cell.setCellValue(ruleId);
211
						cell = row.createCell(2);
212
						cell.setCellValue(entry1.getName().split("\\(")[0]);
213
						if (entry1.getName().contains("(M)")) {
214
							cell = row.createCell(3);
215
							cell.setCellValue("M");
216
							cell = row.createCell(4);
217
							cell.setCellValue("YES");
218
						}
219
						if (entry1.getName().contains("(MA)")) {
220
							cell = row.createCell(3);
221
							cell.setCellValue("MA");
222
							cell = row.createCell(4);
223
							cell.setCellValue("YES");
224
						}
225
						if (entry1.getName().contains("(R)")) {
226
							cell = row.createCell(3);
227
							cell.setCellValue("R");
228
							cell = row.createCell(4);
229
							cell.setCellValue("NO");
230
						}
231
						if (entry1.getName().contains("(O)")) {
232
							cell = row.createCell(3);
233
							cell.setCellValue("O");
234
							cell = row.createCell(4);
235
							cell.setCellValue("NO");
236
						}
237
						if (entry1.getName().contains("(MA/O)")) {
238
							cell = row.createCell(3);
239
							cell.setCellValue("MA/O");
240
							cell = row.createCell(4);
241
							cell.setCellValue("YES");
242
						}
243

  
244
						cell = row.createCell(5);
245
						cell.setCellValue(Integer.parseInt(entry1
246
								.getSuccesses().split("/")[1]));
247
						cell = row.createCell(6);
248
						cell.setCellValue(Integer.parseInt(entry1
249
								.getSuccesses().split("/")[0]));
250
						// cell = row.createCell(7);
251
						// if
252
						// (Integer.parseInt(entry1.getSuccesses().split("/")[1])
253
						// ==
254
						// Integer.parseInt(entry1.getSuccesses().split("/")[0]))
255
						// cell.setCellValue("SUCCESS");
256
						// else
257
						// cell.setCellValue("FAIL");
258
						cell = row.createCell(7);
259
						cell.setCellValue((Integer.parseInt(entry1
260
								.getSuccesses().split("/")[0]) * 100)
261
								/ Integer.parseInt(entry1.getSuccesses().split(
262
										"/")[1]));
263
						ruleId++;
264
					}
265
				}
266
				for (int i = 0; i < 14; i++) {
267
					sheet.autoSizeColumn(i);
268
				}
269

  
270
			}
271

  
272
			XSSFSheet sheetScores = workbook.createSheet("Scores");
273
			int rownumScores = 0;
274
			Row rowScores = sheetScores.createRow(rownumScores++);
275
			Cell cellS = rowScores.createCell(0);
276
			cellS.setCellStyle(style);
277
			cellS.setCellValue("Filter By");
278
			cellS = rowScores.createCell(1);
279
			cellS.setCellStyle(style);
280
			cellS.setCellValue("Score for Content");
281
			for (String groupBy : groupBy_values) {
282
				rowScores = sheetScores.createRow(rownumScores++);
283
				int score;
284
				if (groupBy.equalsIgnoreCase("all"))
285
					score = job.getContentJobScore();
286
				else
287
					score = job.getFilteredScores().get(groupBy);
288
				cellS = rowScores.createCell(0);
289
				cellS.setCellValue(groupBy);
290
				cellS = rowScores.createCell(1);
291
				cellS.setCellValue(score);
292

  
293
			}
294
			for (int i = 0; i < 2; i++) {
295
				sheetScores.autoSizeColumn(i);
296
			}
297

  
298
			// Write the workbook in file system
299
			FileOutputStream out = new FileOutputStream(new File("/tmp/"
300
					+ fileName + fileType));
301
			workbook.write(out);
302
			out.close();
303
		} catch (Exception e) {
304
			logger.error("Error creating xls file", e);
305
			throw e;
306
		}
307
	}
308
}
0 309

  
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/browsejobs/FetchValidationErrors.java
1
package eu.dnetlib.validator.web.actions.browsejobs;
2

  
3
import java.util.List;
4
import java.util.Map;
5

  
6
import org.apache.log4j.Logger;
7
import org.apache.struts2.interceptor.RequestAware;
8

  
9
import com.opensymphony.xwork2.Action;
10

  
11
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
12

  
13
public class FetchValidationErrors extends BaseValidatorAction implements RequestAware {
14

  
15
	private static final long serialVersionUID = -6630957729077819377L;
16
	private int ruleId;
17
	private int jobId;
18
	private String urlPrefix;
19
	private List<String> valErrors;
20
	private Logger logger = Logger.getLogger( FetchValidationErrors.class);
21
	
22
	public String execute() throws Exception {
23
		logger.debug("fetching val errors");
24
		this.clearErrorsAndMessages();
25
//		valErrors = this.getOpenAIREValidator().getValidationErrors(jobId, ruleId);
26
		
27
		request.put("jsonization", jsonise(valErrors));
28
		
29
		return Action.SUCCESS;
30
	}
31
	
32
	private String jsonise(List<String> errors) {
33
		StringBuilder sb = new StringBuilder();
34
		sb.append("{\"errors\":[");
35
		
36
		for (int i=0; i < errors.size(); i++) {
37
			if (i > 0)
38
				sb.append(", ");
39
			
40
			if (errors.get(i) == null){
41
				sb.append("{\"description\":").append("\"No record available\"");
42
				sb.append(", \"url\":\"").append("#").append("\"");
43

  
44
			} else {
45
				sb.append("{\"description\":\"").append(errors.get(i)).append("\"");
46
				sb.append(", \"url\":\"").append(createUrls(errors.get(i))).append("\"");
47
			}
48
			
49
			sb.append("}");
50
		}
51
		
52
		sb.append("]}");
53
		
54
		return sb.toString();
55
	}
56
	
57
	private String createUrls(String label){
58
		StringBuilder sb = new StringBuilder();
59
		sb.append(urlPrefix).append(label);		
60
		return sb.toString();
61
	}
62
	
63

  
64
	public int getRuleId() {
65
		return ruleId;
66
	}
67

  
68
	public void setRuleId(int ruleId) {
69
		this.ruleId = ruleId;
70
	}
71

  
72
	public int getJobId() {
73
		return jobId;
74
	}
75

  
76
	public void setJobId(int jobId) {
77
		this.jobId = jobId;
78
	}
79

  
80
	public List<String> getValErrors() {
81
		return valErrors;
82
	}
83

  
84
	public void setValErrors(List<String> valErrors) {
85
		this.valErrors = valErrors;
86
	}
87

  
88
	public void setUrlPrefix(String urlPrefix) {
89
		this.urlPrefix = urlPrefix;
90
	}
91

  
92
	public String getUrlPrefix() {
93
		return urlPrefix;
94
	}
95

  
96
	private Map<String, Object> request;
97
	@Override
98
	public void setRequest(Map<String, Object> request) {
99
		this.request = request;		
100
	}
101

  
102
	
103
}
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/browsejobs/DatabaseCurator.java
1
package eu.dnetlib.validator.web.actions.browsejobs;
2

  
3
import java.text.ParseException;
4
import java.text.SimpleDateFormat;
5

  
6
import com.opensymphony.xwork2.Action;
7

  
8
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
9

  
10
public class DatabaseCurator extends BaseValidatorAction {
11

  
12
	private static final long serialVersionUID = -1868055729316139461L;
13
//	private static final Logger logger = Logger.getLogger(DatabaseCurator.class);
14
	private String inDate = null;
15
	private String mode;
16

  
17
	public String getMode() {
18
		return mode;
19
	}
20

  
21

  
22
	public void setMode(String mode) {
23
		this.mode = mode;
24
	}
25

  
26

  
27
	public String execute() {
28
		this.clearErrorsAndMessages();
29

  
30
//		try {
31
//			logger.error("deleting old jobs");
32
//			this.getOpenAIREValidator().deleteOldJobs(inDate,mode);
33
//		} catch (OpenAIREValidatorException e) {
34
//			logger.error("Error deleting old jobs", e);
35
//			this.addActionError(this.getText("generic.error"));
36
//			reportException(e);
37
//			return "input-problem";
38
//		}
39

  
40
		return Action.SUCCESS;
41
	}
42
	
43

  
44
	public void validate() {
45
		this.clearErrors();
46
		if (!mode.equalsIgnoreCase("uncompleted_only")){
47
			if (inDate == null) {
48
				this.addActionError(this.getText("wrongFieldValue"));
49
				return;
50
			}
51
			SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
52
			if (inDate.trim().length() != dateFormat.toPattern().length()) {
53
				this.addActionError(this.getText("wrongFieldValue"));
54
				return;
55
			}
56
			dateFormat.setLenient(false);
57
			try {
58
				dateFormat.parse(inDate.trim());
59
			} catch (ParseException pe) {
60
				this.addActionError(this.getText("wrongFieldValue"));
61
				return;
62
			}
63
		}
64
	}
65

  
66
	public String getInDate() {
67
		return inDate;
68
	}
69

  
70
	public void setInDate(String inDate) {
71
		this.inDate = inDate;
72
	}
73
}
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/browsejobs/PrepareJobBrowsing.java
1
package eu.dnetlib.validator.web.actions.browsejobs;
2

  
3
import java.io.File;
4
import java.io.FileOutputStream;
5
import java.util.HashMap;
6
import java.util.List;
7
import java.util.Map;
8

  
9
import org.apache.log4j.Logger;
10
import org.apache.poi.ss.usermodel.Cell;
11
import org.apache.poi.ss.usermodel.CellStyle;
12
import org.apache.poi.ss.usermodel.IndexedColors;
13
import org.apache.poi.ss.usermodel.Row;
14
import org.apache.poi.xssf.usermodel.XSSFSheet;
15
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
16
import org.apache.struts2.interceptor.SessionAware;
17

  
18
import com.opensymphony.xwork2.Action;
19

  
20
import eu.dnetlib.domain.data.Repository;
21
import eu.dnetlib.domain.functionality.validator.StoredJob;
22
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
23
import eu.dnetlib.validator.web.actions.configs.Constants;
24
import eu.dnetlib.validator.web.api.ValidatorWebException;
25

  
26
public class PrepareJobBrowsing extends BaseValidatorAction implements SessionAware {
27

  
28
	private static final long serialVersionUID = 7391643068980907156L;
29
	private Logger logger = Logger.getLogger(PrepareJobBrowsing.class);
30

  
31
	private List<StoredJob> compTests, registrations, workflows;
32
	private String jobType;
33
	private int startPage = 1 , pageSize = 10, totalPages, totalJobs;
34
	private Map<String, Object> session;
35

  
36
	public String execute() {
37
		this.clearErrorsAndMessages();
38
		try {
39
			logger.debug("preparing job browsing for type: " + jobType);
40
			int offset = (startPage-1)*pageSize;
41
			if (jobType == null) {
42
//				this.downloadRegistrationsReport(null, null, null, null);
43
				compTests = this.getValidatorWebAPI().getJobsOfUser((String) session.get(Constants.loggedInField),"Compatibility Test", 0 , pageSize, null, null);
44
				totalJobs =  this.getValidatorWebAPI().getJobsTotalNumberOfUser((String) session.get(Constants.loggedInField),"Compatibility Test");
45
				registrations = this.getValidatorWebAPI().getJobsOfUser((String) session.get(Constants.loggedInField),"Registration Request", 0 , pageSize, null, null);
46
				workflows = this.getValidatorWebAPI().getJobsOfUser((String) session.get(Constants.loggedInField),"Workflow Request", 0 , pageSize, null, null);
47
			} else if (jobType.equalsIgnoreCase("compTests")) {
48
				compTests = this.getValidatorWebAPI().getJobsOfUser((String) session.get(Constants.loggedInField),"Compatibility Test", offset , pageSize, null, null);
49
				totalJobs =  this.getValidatorWebAPI().getJobsTotalNumberOfUser((String) session.get(Constants.loggedInField),"Compatibility Test");
50
			} else if (jobType.equalsIgnoreCase("registrations")) {
51
				registrations = this.getValidatorWebAPI().getJobsOfUser((String) session.get(Constants.loggedInField),"Registration Request", offset, pageSize, null, null);
52
				totalJobs =  this.getValidatorWebAPI().getJobsTotalNumberOfUser((String) session.get(Constants.loggedInField),"Registration Request");
53
			} else if (jobType.equalsIgnoreCase("workflows")) {
54
				workflows = this.getValidatorWebAPI().getJobsOfUser((String) session.get(Constants.loggedInField),"Workflow Request", offset , pageSize, null, null);
55
				totalJobs =  this.getValidatorWebAPI().getJobsTotalNumberOfUser((String) session.get(Constants.loggedInField),"Workflow Request");
56
			}
57
			logger.debug("total jobs: " + totalJobs);
58
			totalPages = totalJobs/pageSize;
59
			if ( (totalJobs % pageSize > 0) || (totalJobs == 0))
60
				totalPages++;
61
			
62
			return Action.SUCCESS;
63
		} catch (Exception e) {
64
			logger.error("error while preparing job browsing", e);
65
			this.addActionError(this.getText("generic.error"));
66
			reportException(e);
67
			return "exception";
68
		}
69
	}
70

  
71
	
72
	public String downloadRegistrationsReport(String dateFrom, String dateTo, String month, String year) throws ValidatorWebException {
73
		try {
74
			List <StoredJob> jobs = null;
75
			
76
			Map<String, StoredJob> passedJobsMap = new HashMap<String, StoredJob>();
77
			Map<String, StoredJob> failedJobsMap = new HashMap<String, StoredJob>();
78
			
79
			logger.debug("Preparing registrations Report for period: " + dateFrom + " to: " + dateTo);
80
			jobs = this.getValidatorWebAPI().getJobsOfUser(null, "Registration Request", null, null, null, null);
81
			
82
			// Blank workbook
83
			XSSFWorkbook workbook = new XSSFWorkbook();
84

  
85
			CellStyle style = workbook.createCellStyle();
86
			style.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT
87
					.getIndex());
88
			
89
			
90
				
91
			for (StoredJob job : jobs) {
92
				String key = job.getBaseUrl()+"|"+job.getDesiredCompatibilityLevel();
93
				if (job.getContentJobScore() >= 50 && job.getUsageJobScore() >= 50) {
94
					failedJobsMap.remove(key);
95
					passedJobsMap.put (key, job);
96
				} else {
97
					if (!passedJobsMap.containsKey(key)) {
98
						failedJobsMap.put (key, job);
99
					}
100
				}
101
			}
102
			
103
			boolean oldFormat = false;
104
			
105
			// Create a blank sheet
106
						XSSFSheet sheet = workbook.createSheet("Successful Registrations");
107
						int rownum = 0;
108
						Row row = sheet.createRow(rownum++);
109
						// sheet.setColumnWidth(0, 4330);
110
						Cell cell = row.createCell(0);
111
						cell.setCellStyle(style);
112
						cell.setCellValue("OAI BaseUrl");
113
						// sheet.setColumnWidth(1, 7500);
114
						cell = row.createCell(1);
115
						cell.setCellStyle(style);
116
						cell.setCellValue("Guidelines");
117
						cell = row.createCell(2);
118
						cell.setCellStyle(style);
119
						cell.setCellValue("# of Publications");
120
						cell = row.createCell(3);
121
						cell.setCellStyle(style);
122
						cell.setCellValue("Date of Registration");
123
						cell = row.createCell(4);
124
						cell.setCellStyle(style);
125
						cell.setCellValue("Score for Content");
126
						cell = row.createCell(5);
127
						cell.setCellStyle(style);
128
						cell.setCellValue("Score for Usage");
129
						cell = row.createCell(6);
130
						cell.setCellStyle(style);
131
						cell.setCellValue("Datasource Name");
132
						cell = row.createCell(7);
133
						cell.setCellStyle(style);
134
						cell.setCellValue("Datasource Type");
135
						cell = row.createCell(8);
136
						cell.setCellStyle(style);
137
						cell.setCellValue("Country");
138
						cell = row.createCell(9);
139
						cell.setCellStyle(style);
140
						cell.setCellValue("Organization");
141
						
142
			for (StoredJob job : passedJobsMap.values()) {
143
				
144
				row = sheet.createRow(rownum++);
145
				cell = row.createCell(0);
146
				cell.setCellValue(job.getBaseUrl());
147
				cell = row.createCell(1);
148
				cell.setCellValue(job.getDesiredCompatibilityLevel());
149
				cell = row.createCell(2);
150
				cell.setCellValue(job.getRecordsTested());
151
				cell = row.createCell(3);
152
				cell.setCellValue(job.getStarted());
153
				cell = row.createCell(4);
154
				cell.setCellValue(job.getContentJobScore());
155
				cell = row.createCell(5);
156
				cell.setCellValue(job.getUsageJobScore());
157
				if (job.getOfficialName() != null) {
158
					Repository repo = this.getRepoAPI().getRepository(job.getOfficialName(), job.getDatasourceId());
159
					cell = row.createCell(6);
160
					cell.setCellValue(job.getOfficialName());
161
					cell = row.createCell(7);
162
					cell.setCellValue(job.getRepoType());
163
					cell = row.createCell(8);
164
					cell.setCellValue(repo.getCountryName());
165
					cell = row.createCell(9);
166
					cell.setCellValue(repo.getOrganization());
167
				} else {
168
					cell = row.createCell(6);
169
					cell.setCellValue("-UNAVAILABLE-");
170
					cell = row.createCell(7);
171
					cell.setCellValue("-UNAVAILABLE-");
172
					cell = row.createCell(8);
173
					cell.setCellValue("-UNAVAILABLE-");
174
					cell = row.createCell(9);
175
					cell.setCellValue("-UNAVAILABLE-");
176
				}
177
			}
178
			
179
			for (int i = 0; i < 10; i++) {
180
				sheet.autoSizeColumn(i);
181
			}
182
			
183
			// Create a blank sheet
184
			sheet = workbook.createSheet("Failed Registrations");
185
			rownum = 0;
186
			row = sheet.createRow(rownum++);
187
			// sheet.setColumnWidth(0, 4330);
188
			cell = row.createCell(0);
189
			cell.setCellStyle(style);
190
			cell.setCellValue("OAI BaseUrl");
191
			// sheet.setColumnWidth(1, 7500);
192
			cell = row.createCell(1);
193
			cell.setCellStyle(style);
194
			cell.setCellValue("Guidelines");
195
			cell = row.createCell(2);
196
			cell.setCellStyle(style);
197
			cell.setCellValue("# of Publications");
198
			cell = row.createCell(3);
199
			cell.setCellStyle(style);
200
			cell.setCellValue("Date of Registration");
201
			cell = row.createCell(4);
202
			cell.setCellStyle(style);
203
			cell.setCellValue("Score for Content");
204
			cell = row.createCell(5);
205
			cell.setCellStyle(style);
206
			cell.setCellValue("Score for Usage");
207
			cell = row.createCell(6);
208
			cell.setCellStyle(style);
209
			cell.setCellValue("Datasource Name");
210
			cell = row.createCell(7);
211
			cell.setCellStyle(style);
212
			cell.setCellValue("Datasource Type");
213

  
214
			for (StoredJob job : failedJobsMap.values()) {
215
				
216
				row = sheet.createRow(rownum++);
217
				cell = row.createCell(0);
218
				cell.setCellValue(job.getBaseUrl());
219
				cell = row.createCell(1);
220
				cell.setCellValue(job.getDesiredCompatibilityLevel());
221
				cell = row.createCell(2);
222
				cell.setCellValue(job.getRecordsTested());
223
				cell = row.createCell(3);
224
				cell.setCellValue(job.getStarted());
225
				cell = row.createCell(4);
226
				cell.setCellValue(job.getContentJobScore());
227
				cell = row.createCell(5);
228
				cell.setCellValue(job.getUsageJobScore());
229
				if (job.getOfficialName() != null) {
230
					Repository repo = this.getRepoAPI().getRepository(job.getOfficialName(), job.getDatasourceId());
231
					cell = row.createCell(6);
232
					cell.setCellValue(job.getOfficialName());
233
					cell = row.createCell(7);
234
					cell.setCellValue(job.getRepoType());
235
					cell = row.createCell(8);
236
					cell.setCellValue(repo.getCountryName());
237
					cell = row.createCell(9);
238
					cell.setCellValue(repo.getOrganization());
239
				} else {
240
					cell = row.createCell(6);
241
					cell.setCellValue("-UNAVAILABLE-");
242
					cell = row.createCell(7);
243
					cell.setCellValue("-UNAVAILABLE-");
244
					cell = row.createCell(8);
245
					cell.setCellValue("-UNAVAILABLE-");
246
					cell = row.createCell(9);
247
					cell.setCellValue("-UNAVAILABLE-");
248
				}			
249
			}
250
			
251
			for (int i = 0; i < 10; i++) {
252
				sheet.autoSizeColumn(i);
253
			}
254
			
255
			FileOutputStream out = new FileOutputStream(new File("/tmp/validator_registrations/report.xlsx"));
256
			workbook.write(out);
257
			out.close();
258
			
259
			return "ok";
260
		} catch (Exception e) {
261
			logger.error("Error preparing registrations report", e);
262
			throw new ValidatorWebException(e);
263
		}
264
	}
265

  
266
	@Override
267
	public void setSession(Map<String, Object> session) {
268
		this.session = session;
269
	}
270

  
271
	public List<StoredJob> getCompTests() {
272
		return compTests;
273
	}
274

  
275
	public void setCompTests(List<StoredJob> compTests) {
276
		this.compTests = compTests;
277
	}
278

  
279
	public List<StoredJob> getRegistrations() {
280
		return registrations;
281
	}
282

  
283
	public void setRegistrations(List<StoredJob> registrations) {
284
		this.registrations = registrations;
285
	}
286

  
287
	public List<StoredJob> getWorkflows() {
288
		return workflows;
289
	}
290

  
291
	public void setWorkflows(List<StoredJob> workflows) {
292
		this.workflows = workflows;
293
	}
294

  
295
	public String getJobType() {
296
		return jobType;
297
	}
298

  
299
	public void setJobType(String jobType) {
300
		this.jobType = jobType;
301
	}
302

  
303
	public int getStartPage() {
304
		return startPage;
305
	}
306

  
307
	public void setStartPage(int startPage) {
308
		this.startPage = startPage;
309
	}
310

  
311
	public int getPageSize() {
312
		return pageSize;
313
	}
314

  
315
	public void setPageSize(int pageSize) {
316
		this.pageSize = pageSize;
317
	}
318

  
319
	public int getTotalPages() {
320
		return totalPages;
321
	}
322

  
323
	public void setTotalPages(int totalPages) {
324
		this.totalPages = totalPages;
325
	}
326

  
327
	public int getTotalJobs() {
328
		return totalJobs;
329
	}
330

  
331
	public void setTotalJobs(int totalJobs) {
332
		this.totalJobs = totalJobs;
333
	}
334
}
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/browsejobs/PrepareSummary.java
1
package eu.dnetlib.validator.web.actions.browsejobs;
2

  
3
import java.util.ArrayList;
4
import java.util.HashMap;
5
import java.util.List;
6
import java.util.Map;
7
import java.util.Set;
8

  
9
import org.apache.log4j.Logger;
10

  
11
import com.opensymphony.xwork2.Action;
12

  
13
import eu.dnetlib.domain.functionality.validator.JobResultEntry;
14
import eu.dnetlib.domain.functionality.validator.StoredJob;
15
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
16
import eu.dnetlib.validator.web.api.ValidatorWebException;
17

  
18
public class PrepareSummary extends BaseValidatorAction {
19
	private static final long serialVersionUID = -462318678652799883L;
20
	private String groupBy;
21
	private int jobId;
22
	private StoredJob job;
23
	private Map<String, List<JobResultEntry>> entries;
24
	private String urlPrefix = null;
25
	private String errorMessage_usage = "";
26
	private String errorMessage0_usage = "";
27
	private String errorMessage_content = "";
28
	private String errorMessage0_content = "";
29
	private Set<String> groupBy_values;
30
	private String filteredScore;
31
	private Boolean cris = false;
32
	private static final Logger logger = Logger.getLogger(PrepareSummary.class);
33

  
34
	public String execute() {
35
		this.clearErrorsAndMessages();
36
		try {
37
			logger.debug("preparing job summary for job "+jobId);
38
			if (groupBy == null)
39
				groupBy = "all";
40
			job = this.getValidatorWebAPI().getJobSummary(jobId,groupBy);
41
			
42
			entries = this.splitEntries(job.getResultEntries());
43
			if (job.getFilteredScores() != null) {
44
				groupBy_values = job.getFilteredScores().keySet();
45
				if (groupBy_values.toString().contains("_cris_")) {
46
					cris = true;				
47
				}
48
				if (job.getFilteredScores().get(groupBy) != null)
49
					filteredScore = Integer.toString(job.getFilteredScores().get(groupBy));
50
			}
51
				
52
//			this.writeExcelDemo1();
53
			
54
//			String mtdPrfx = "oai_dc";
55
//			logger.debug("set of job: "+job.getSet());
56
//			if (job.getSet()!=null && job.getSet().equalsIgnoreCase("openaire_data"))
57
//				mtdPrfx = "oai_datacite";\
58
			
59
			urlPrefix = job.getBaseUrl() + "?verb=GetRecord&metadataPrefix=" + job.getMetadataPrefix() +"&identifier=";
60
			logger.debug("job summary for job "+jobId + "prepared correctly");
61
			
62
			if(entries == null || entries.get("content").size() == 0) {
63
				errorMessage_content=job.getError();
64
				errorMessage0_content = getText("job.noTasks");
65
			}
66
			if(entries == null || entries.get("usage").size() == 0) {
67
				errorMessage_usage=job.getError();
68
				errorMessage0_usage = getText("job.noTasks");
69
			}
70
	
71
			return Action.SUCCESS;
72
		} catch(Exception e) {
73
			logger.error("Error redirecting to job", e);
74
			this.addActionError(this.getText("generic.error"));
75
			reportException(e);
76
			return "exception";
77
		}
78
	}
79
	
80
	private Map<String, List<JobResultEntry>> splitEntries(
81
			List<JobResultEntry> resultEntries) throws ValidatorWebException {
82
		Map<String, List<JobResultEntry>> retMap = new HashMap<String, List<JobResultEntry>>();
83
		List<JobResultEntry> entriesForContent = new ArrayList<JobResultEntry>();
84
		List<JobResultEntry> entriesForUsage = new ArrayList<JobResultEntry>();
85
		if (resultEntries != null) {
86
			try {
87
				for(JobResultEntry entry : resultEntries)
88
				{
89
					if (entry.getType().equals("content")) {
90
						entriesForContent.add(entry);
91
					} else if (entry.getType().equals("usage")) {
92
						entriesForUsage.add(entry);
93
					}
94
				}
95
			} catch (Exception e) {
96
				logger.error("Error splitting entries", e);
97
				throw new ValidatorWebException(e);
98
			}
99
		} 
100
		retMap.put("content", entriesForContent);
101
		retMap.put("usage", entriesForUsage);
102
		return retMap;
103
	}
104

  
105
	public String getUrlPrefix() {
106
		return urlPrefix;
107
	}
108

  
109
	public void setUrlPrefix(String urlPrefix) {
110
		this.urlPrefix = urlPrefix;
111
	}
112

  
113
	public int getJobId() {
114
		return jobId;
115
	}
116

  
117
	public void setJobId(int jobId) {
118
		this.jobId = jobId;
119
	}
120

  
121
	public String getGroupBy() {
122
		return groupBy;
123
	}
124

  
125
	public void setGroupBy(String groupBy) {
126
		this.groupBy = groupBy;
127
	}
128

  
129
	public StoredJob getJob() {
130
		return job;
131
	}
132

  
133
	public void setJob(StoredJob job) {
134
		this.job = job;
135
	}
136

  
137
	public Map<String, List<JobResultEntry>> getEntries() {
138
		return entries;
139
	}
140

  
141
	public void setEntries(Map<String, List<JobResultEntry>> entries) {
142
		this.entries = entries;
143
	}
144

  
145
	public Set<String> getGroupBy_values() {
146
		return groupBy_values;
147
	}
148

  
149
	public void setGroupBy_values(Set<String> groupBy_values) {
150
		this.groupBy_values = groupBy_values;
151
	}
152

  
153
	public String getFilteredScore() {
154
		return filteredScore;
155
	}
156

  
157
	public void setFilteredScore(String filteredScore) {
158
		this.filteredScore = filteredScore;
159
	}
160

  
161

  
162
	public Boolean getCris() {
163
		return cris;
164
	}
165

  
166
	public void setCris(Boolean cris) {
167
		this.cris = cris;
168
	}
169

  
170
	public String getErrorMessage_usage() {
171
		return errorMessage_usage;
172
	}
173

  
174
	public void setErrorMessage_usage(String errorMessage_usage) {
175
		this.errorMessage_usage = errorMessage_usage;
176
	}
177

  
178
	public String getErrorMessage0_usage() {
179
		return errorMessage0_usage;
180
	}
181

  
182
	public void setErrorMessage0_usage(String errorMessage0_usage) {
183
		this.errorMessage0_usage = errorMessage0_usage;
184
	}
185

  
186
	public String getErrorMessage_content() {
187
		return errorMessage_content;
188
	}
189

  
190
	public void setErrorMessage_content(String errorMessage_content) {
191
		this.errorMessage_content = errorMessage_content;
192
	}
193

  
194
	public String getErrorMessage0_content() {
195
		return errorMessage0_content;
196
	}
197

  
198
	public void setErrorMessage0_content(String errorMessage0_content) {
199
		this.errorMessage0_content = errorMessage0_content;
200
	}
201

  
202
}
203

  
204

  
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/users/EditUser.java
1
package eu.dnetlib.validator.web.actions.users;
2

  
3
import java.util.Map;
4

  
5
import org.apache.log4j.Logger;
6
import org.apache.struts2.interceptor.SessionAware;
7

  
8
import com.opensymphony.xwork2.Action;
9

  
10
import eu.dnetlib.domain.functionality.UserProfile;
11
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
12
import eu.dnetlib.validator.web.actions.configs.Constants;
13

  
14
public class EditUser extends BaseValidatorAction implements SessionAware {
15

  
16
	private static final long serialVersionUID = -362061491263257713L;
17
	private Logger logger = Logger.getLogger(EditUser.class);
18

  
19
	private UserProfile user;
20

  
21
	private Map<String, Object> session;
22

  
23
	public String execute() {
24
		this.clearErrorsAndMessages();
25
		try {
26
			logger.debug("getting for edit user " + (String) session.get(Constants.loggedInField));
27
				user = this.getUserAPI().getUser((String) session.get(Constants.loggedInField));
28
			return Action.SUCCESS;
29
		} catch (Exception e) {
30
			logger.error("error getting for edit user " + (String) session.get(Constants.loggedInField), e);
31
			this.addActionError(this.getText("generic.error"));
32
			reportException(e);
33
			return "exception";
34
		}
35
	}
36

  
37
	public String edit() {
38
		this.clearErrorsAndMessages();
39
		try {
40
			logger.debug("editing user " + (String) session.get(Constants.loggedInField));
41
			this.getUserAPI().editUser(user);
42
			this.addActionMessage(this.getText("editUser.success"));
43
			return Action.SUCCESS;
44
		} catch (Exception e) {
45
			logger.error("error editing user " + (String) session.get(Constants.loggedInField), e);
46
			this.addActionError(this.getText("generic.error"));
47
			reportException(e);
48
			return "exception";
49
		}
50

  
51
	}
52

  
53

  
54
	public UserProfile getUser() {
55
		return user;
56
	}
57

  
58
	public void setUser(UserProfile user) {
59
		this.user = user;
60
	}
61

  
62
	@Override
63
	public void setSession(Map<String, Object> session) {
64
		this.session = session;
65
	}
66
}
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/users/Register.java
1
package eu.dnetlib.validator.web.actions.users;
2

  
3
import java.util.ArrayList;
4
import java.util.regex.Pattern;
5

  
6
import org.apache.log4j.Logger;
7

  
8
import com.opensymphony.xwork2.Action;
9

  
10
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
11

  
12
public class Register extends BaseValidatorAction {
13

  
14
	private static final long serialVersionUID = 4906485913149844710L;
15
	private Logger logger = Logger.getLogger(Register.class);
16
	
17
	private String email, password, repassword;
18
	private String username, firstName, lastName, institution;
19

  
20
	public String execute() {
21
		this.clearErrorsAndMessages();
22
		try {
23
			logger.debug("registering user " + email);
24
			String activationId = null;
25

  
26
			activationId = this.getUserAPI().addUser(username, email, password, firstName, lastName, institution);
27

  
28
			this.addActionMessage((this.getText("registration.successful")));
29
			this.addActionMessage((this.getText("general.unblock") + " " + this.getEmailer().getFrom()));
30

  
31
			ArrayList<String> to = new ArrayList<String>();
32
			to.add(this.getEmail());
33

  
34
			this.getEmailer().sendMail(to, this.getText("registration.mail.subject"), this.getText("registration.mail.message") + ": " + this.getValBaseUrl() + "/activateAccount.action?activationId=" + activationId, false, null);
35

  
36
			return Action.SUCCESS;
37
		} catch (Exception e) {
38
			logger.error("error registering user " + email, e);
39
			this.addActionError(this.getText("generic.error"));
40
			reportException(e);
41
			return "exception";
42
		}
43
	}
44

  
45
	public void validate() {
46
		this.clearErrors();
47
		if (this.getEmail() == null || this.getEmail().length() == 0)
48
			this.addFieldError("email", this.getText("compulsoryField"));
49
		if (this.getPassword() == null || this.getPassword().length() == 0)
50
			this.addFieldError("password", this.getText("compulsoryField"));
51
		if (this.getRepassword() == null || this.getRepassword().length() == 0)
52
			this.addFieldError("repassword", this.getText("compulsoryField"));
53
		if (this.getUsername() == null || this.getUsername().length() == 0)
54
			this.addFieldError("username", this.getText("compulsoryField"));
55
		if (this.getFirstName() == null || this.getFirstName().length() == 0)
56
			this.addFieldError("firstName", this.getText("compulsoryField"));
57
		if (this.getLastName() == null || this.getLastName().length() == 0)
58
			this.addFieldError("lastName", this.getText("compulsoryField"));
59

  
60
		if (!this.getPassword().equals(this.getRepassword()))
61
			this.addFieldError("password", this.getText("identicalPasswords"));
62

  
63
		Pattern rfc2822 = Pattern.compile("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$");
64
		if (!rfc2822.matcher(this.getEmail().trim().toLowerCase()).matches()) {
65
			this.addFieldError("email", this.getText("notValidEmail"));
66
		}
67

  
68
		try {
69
			if (this.getUserAPI().userExists(this.getEmail()))
70
				this.addFieldError("email", this.getText("userAlreadyExists"));
71
			if (this.getUserAPI().usernameExists(this.getUsername()))
72
				this.addFieldError("username", this.getText("userAlreadyExists"));
73

  
74
		} catch (Exception e) {
75
			this.addFieldError("email", this.getText("userAlreadyExists"));
76
		}
77
	}
78

  
79
	public String getEmail() {
80
		return email;
81
	}
82

  
83
	public void setEmail(String email) {
84
		this.email = email;
85
	}
86

  
87
	public String getPassword() {
88
		return password;
89
	}
90

  
91
	public void setPassword(String password) {
92
		this.password = password;
93
	}
94

  
95
	public String getRepassword() {
96
		return repassword;
97
	}
98

  
99
	public void setRepassword(String repassword) {
100
		this.repassword = repassword;
101
	}
102

  
103
	public String getUsername() {
104
		return username;
105
	}
106

  
107
	public void setUsername(String username) {
108
		this.username = username;
109
	}
110

  
111
	public String getFirstName() {
112
		return firstName;
113
	}
114

  
115
	public void setFirstName(String firstName) {
116
		this.firstName = firstName;
117
	}
118

  
119
	public String getLastName() {
120
		return lastName;
121
	}
122

  
123
	public void setLastName(String lastName) {
124
		this.lastName = lastName;
125
	}
126

  
127
	public String getInstitution() {
128
		return institution;
129
	}
130

  
131
	public void setInstitution(String institution) {
132
		this.institution = institution;
133
	}
134
	
135
}
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/users/ActivateAccount.java
1
package eu.dnetlib.validator.web.actions.users;
2

  
3
import org.apache.log4j.Logger;
4

  
5
import com.opensymphony.xwork2.Action;
6

  
7
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
8

  
9
public class ActivateAccount extends BaseValidatorAction {
10

  
11
	private static final long serialVersionUID = 4680016183168923054L;
12
	private Logger logger = Logger.getLogger(ActivateAccount.class);
13
	
14
	private String activationId;
15

  
16
	public String execute() {
17
		this.clearErrorsAndMessages();
18
		try {
19
			logger.debug("activating user account with activation id " + activationId);
20
			if (this.getUserAPI().activateUser(this.getActivationId()))
21
				this.addActionMessage(this.getText("registration.okAccountActivation"));
22
			else
23
				this.addActionMessage(this.getText("registration.okAccountAlreadyActivation"));
24
			return Action.SUCCESS;
25
		} catch (Exception e) {
26
			logger.error("error activating user account with activation id " + activationId, e);
27
			this.addActionError(this.getText("generic.error"));
28
			reportException(e);
29
			return "exception";
30
		}
31
	}
32

  
33
	public void validate() {
34
		this.clearErrors();
35
		if (this.getActivationId() == null || this.getActivationId().length() == 0) {
36
			this.addActionError(this.getText("noActivationId"));
37
			return;
38
		}
39
	}
40

  
41
	public String getActivationId() {
42
		return activationId;
43
	}
44

  
45
	public void setActivationId(String activationId) {
46
		this.activationId = activationId;
47
	}
48
}
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/feedback/FeedBackPage.java
1
package eu.dnetlib.validator.web.actions.feedback;
2

  
3
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
4

  
5
@SuppressWarnings("serial")
6
public class FeedBackPage extends BaseValidatorAction{
7

  
8
}
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/feedback/SendFeedback.java
1
package eu.dnetlib.validator.web.actions.feedback;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.Map;
6

  
7
import org.apache.log4j.Logger;
8
import org.apache.struts2.interceptor.SessionAware;
9

  
10
import com.opensymphony.xwork2.Action;
11

  
12
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
13
import eu.dnetlib.validator.web.actions.configs.Constants;
14

  
15
public class SendFeedback extends BaseValidatorAction implements SessionAware {
16

  
17
	private static final long serialVersionUID = -4610293868659763433L;
18
	private Logger logger = Logger.getLogger(SendFeedback.class);
19

  
20
	private String reason, message;
21
	private Map<String, Object> session;
22

  
23
	public String execute() {
24
		this.clearErrorsAndMessages();
25
		try {
26
			logger.debug("sending feedback from user " + (String) session.get(Constants.loggedInField));
27
			List<String> recipients = new ArrayList<String>();
28
			recipients.add(this.getValAdminEmail());
29
			String message = "The following message was sent from " + (String) session.get(Constants.loggedInField) + "\n\n" + this.message;
30
			String subject = this.reason;
31
			this.getEmailer().sendMail(recipients, subject, message, false, null);
32
			this.addActionMessage(this.getText("feedback.success"));
33
			return Action.SUCCESS;
34
		} catch (Exception e) {
35
			logger.error("error sending feedback", e);
36
			this.addActionError(this.getText("generic.error"));
37
			reportException(e);
38
			return "exception";
39
		}
40
	}
41

  
42
	@Override
43
	public void setSession(Map<String, Object> session) {
44
		this.session = session;
45
	}
46

  
47
	public String getReason() {
48
		return reason;
49
	}
50

  
51
	public void setReason(String reason) {
52
		this.reason = reason;
53
	}
54

  
55
	public String getMessage() {
56
		return message;
57
	}
58

  
59
	public void setMessage(String message) {
60
		this.message = message;
61
	}
62
}
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/rulesets/FetchRuleDescriptions.java
1
package eu.dnetlib.validator.web.actions.rulesets;
2

  
3
import org.apache.log4j.Logger;
4

  
5
import com.opensymphony.xwork2.Action;
6

  
7
import eu.dnetlib.domain.functionality.validator.RuleSet;
8
import eu.dnetlib.validator.web.actions.BaseValidatorAction;
9

  
10
public class FetchRuleDescriptions extends BaseValidatorAction {
11

  
12
	private static final long serialVersionUID = -2095636309367991598L;
13
	private RuleSet ruleSet;
14
	private String ruleSetId;
15
	private static final Logger logger = Logger.getLogger(FetchRuleDescriptions.class);
16

  
17
	public String execute() {
18
		this.clearErrorsAndMessages();
19
		
20
		try {
21
			logger.debug("fetching description for ruleset: " + ruleSetId);
22
			ruleSet = this.getValidatorWebAPI().getRuleSet(ruleSetId);
23

  
24
			return Action.SUCCESS;
25
		}
26
		catch(Exception e) {
27
			logger.error("Error fetching rule descriptions", e);
28
			this.addActionError(this.getText("generic.error"));
29
			reportException(e);
30
			return "exception";
31
		}
32
	}
33

  
34
	public String getRuleSetId() {
35
		return ruleSetId;
36
	}
37

  
38
	public void setRuleSetId(String ruleSetId) {
39
		this.ruleSetId = ruleSetId;
40
	}
41

  
42
	public RuleSet getRuleSet() {
43
		return ruleSet;
44
	}
45

  
46
	public void setRuleSet(RuleSet ruleSet) {
47
		this.ruleSet = ruleSet;
48
	}
49
	
50
}
51

  
modules/uoa-validator-web/trunk/src/main/java/eu/dnetlib/validator/web/actions/configs/CXFStruts2ActionMapper.java
1
/*
2
 * Copyright (c) 2008 Logentis GmbH. All Rights Reserved.
3
 *
4
 * This software is the proprietary information of Logentis GmbH
5
 * Use is subject to license terms as seen in LICENSE.txt in the
6
 * distribution. Logentis GmbH PROPRIETARY/CONFIDENTIAL.
7
 *
8
 */
9
package eu.dnetlib.validator.web.actions.configs;
10

  
11
import javax.servlet.http.HttpServletRequest;
12

  
13
import org.apache.struts2.RequestUtils;
14
import org.apache.struts2.dispatcher.mapper.ActionMapping;
15
import org.apache.struts2.dispatcher.mapper.DefaultActionMapper;
16

  
17
import com.opensymphony.xwork2.config.ConfigurationManager;
18

  
19
/**
20
 * ActionMapper that excludes all /services/* URLs. A shame that this can't be
21
 * done simpler w/o a custom ActionMapper
22
 * 
23
 */
24
public class CXFStruts2ActionMapper extends DefaultActionMapper {
25

  
26
	@Override
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff