Revision 27295
Added by Katerina Iatropoulou about 10 years ago
modules/uoa-validator-service/newrepos/deploy.info | ||
---|---|---|
1 |
<module> |
|
2 |
<name>uoa-madgik-validator</name> |
|
3 |
<source type="SVN">http://svn-public.driver.research-infrastructures.eu/driver/dnet11/modules/uoa-madgik-validator/trunk</source> |
|
4 |
<goal>package</goal> |
|
5 |
<mail>antleb@di.uoa.gr, nikonas@di.uoa.gr, kiatrop@di.uoa.gr</mail> |
|
6 |
<sonar>no</sonar> |
|
7 |
<deploy> |
|
8 |
<RepositoryId>dnet-snapshot</RepositoryId> |
|
9 |
<RepositoryURL>http://maven.research-infrastructures.eu/nexus/content/repositories/dnet-snapshots</RepositoryURL> |
|
10 |
</deploy> |
|
11 |
<nigthly>no</nigthly> |
|
12 |
</module> |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/browsejobs/FetchValidationErrors.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.browsejobs; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import java.util.List; |
|
6 |
import java.util.Map; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
import org.apache.struts2.interceptor.RequestAware; |
|
10 |
|
|
11 |
import com.opensymphony.xwork2.Action; |
|
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-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/browsejobs/DatabaseCurator.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.browsejobs; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.api.OpenAIREValidatorException; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
|
|
6 |
import java.text.ParseException; |
|
7 |
import java.text.SimpleDateFormat; |
|
8 |
|
|
9 |
import org.apache.log4j.Logger; |
|
10 |
|
|
11 |
import com.opensymphony.xwork2.Action; |
|
12 |
|
|
13 |
public class DatabaseCurator extends BaseValidatorAction { |
|
14 |
|
|
15 |
private static final long serialVersionUID = -1868055729316139461L; |
|
16 |
private static final Logger logger = Logger.getLogger(DatabaseCurator.class); |
|
17 |
private String inDate = null; |
|
18 |
private String mode; |
|
19 |
|
|
20 |
public String getMode() { |
|
21 |
return mode; |
|
22 |
} |
|
23 |
|
|
24 |
|
|
25 |
public void setMode(String mode) { |
|
26 |
this.mode = mode; |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
public String execute() { |
|
31 |
this.clearErrorsAndMessages(); |
|
32 |
|
|
33 |
try { |
|
34 |
this.getOpenAIREValidator().deleteOldJobs(inDate,mode); |
|
35 |
} catch (OpenAIREValidatorException e) { |
|
36 |
logger.error("Error deleting old jobs", e); |
|
37 |
this.addActionError(this.getText("generic.error")); |
|
38 |
reportException(e); |
|
39 |
return "input-problem"; |
|
40 |
} |
|
41 |
|
|
42 |
return Action.SUCCESS; |
|
43 |
} |
|
44 |
|
|
45 |
|
|
46 |
public void validate() { |
|
47 |
this.clearErrors(); |
|
48 |
if (!mode.equalsIgnoreCase("uncompleted_only")){ |
|
49 |
if (inDate == null) { |
|
50 |
this.addActionError(this.getText("wrongFieldValue")); |
|
51 |
return; |
|
52 |
} |
|
53 |
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
54 |
if (inDate.trim().length() != dateFormat.toPattern().length()) { |
|
55 |
this.addActionError(this.getText("wrongFieldValue")); |
|
56 |
return; |
|
57 |
} |
|
58 |
dateFormat.setLenient(false); |
|
59 |
try { |
|
60 |
dateFormat.parse(inDate.trim()); |
|
61 |
} catch (ParseException pe) { |
|
62 |
this.addActionError(this.getText("wrongFieldValue")); |
|
63 |
return; |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
public String getInDate() { |
|
69 |
return inDate; |
|
70 |
} |
|
71 |
|
|
72 |
public void setInDate(String inDate) { |
|
73 |
this.inDate = inDate; |
|
74 |
} |
|
75 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/browsejobs/PrepareJobBrowsing.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.browsejobs; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.dao.JobSubmitted; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
import gr.uoa.di.validatorweb.configs.Constants; |
|
6 |
|
|
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
9 |
|
|
10 |
import org.apache.log4j.Logger; |
|
11 |
import org.apache.struts2.interceptor.SessionAware; |
|
12 |
|
|
13 |
import com.opensymphony.xwork2.Action; |
|
14 |
|
|
15 |
public class PrepareJobBrowsing extends BaseValidatorAction implements SessionAware { |
|
16 |
|
|
17 |
private static final long serialVersionUID = 7391643068980907156L; |
|
18 |
private Logger logger = Logger.getLogger(PrepareJobBrowsing.class); |
|
19 |
|
|
20 |
private boolean enableCuration = false; |
|
21 |
private List<JobSubmitted> jobs; |
|
22 |
|
|
23 |
public List<JobSubmitted> getJobs() { |
|
24 |
return jobs; |
|
25 |
} |
|
26 |
|
|
27 |
public void setJobs(List<JobSubmitted> jobs) { |
|
28 |
this.jobs = jobs; |
|
29 |
} |
|
30 |
|
|
31 |
private Map<String, Object> session; |
|
32 |
|
|
33 |
public String execute() { |
|
34 |
this.clearErrorsAndMessages(); |
|
35 |
try { |
|
36 |
logger.debug("preparing job browsing"); |
|
37 |
jobs = this.getOpenAIREValidator().getJobsOfUser((String) session.get(Constants.loggedInField)); |
|
38 |
enableCuration = getOpenAIREValidator().userOverridesRepoRegistration((String) session.get(Constants.loggedInField)); |
|
39 |
return Action.SUCCESS; |
|
40 |
} catch (Exception e) { |
|
41 |
logger.error("error while preparing job browsing", e); |
|
42 |
this.addActionError(this.getText("generic.error")); |
|
43 |
reportException(e); |
|
44 |
return "exception"; |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public void setSession(Map<String, Object> session) { |
|
50 |
this.session = session; |
|
51 |
} |
|
52 |
|
|
53 |
public void setEnableCuration(boolean enableCuration) { |
|
54 |
this.enableCuration = enableCuration; |
|
55 |
} |
|
56 |
|
|
57 |
public boolean isEnableCuration() { |
|
58 |
return enableCuration; |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/browsejobs/PrepareSummary.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.browsejobs; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.dao.Entry; |
|
4 |
import gr.uoa.di.validator.dao.JobSubmitted; |
|
5 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
6 |
|
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.apache.log4j.Logger; |
|
10 |
|
|
11 |
import com.opensymphony.xwork2.Action; |
|
12 |
|
|
13 |
public class PrepareSummary extends BaseValidatorAction { |
|
14 |
private static final long serialVersionUID = -462318678652799883L; |
|
15 |
private String jobId, groupBy; |
|
16 |
private JobSubmitted job; |
|
17 |
private List<Entry> entries; |
|
18 |
private String urlPrefix = null; |
|
19 |
private String errorMessage = ""; |
|
20 |
private String errorMessage0 = ""; |
|
21 |
private List<String> groupBy_values; |
|
22 |
private String filteredScore; |
|
23 |
private static final Logger logger = Logger.getLogger(PrepareSummary.class); |
|
24 |
|
|
25 |
public String execute() { |
|
26 |
this.clearErrorsAndMessages(); |
|
27 |
errorMessage = ""; |
|
28 |
try { |
|
29 |
logger.debug("preparing job summary for job "+jobId); |
|
30 |
entries = this.getOpenAIREValidator().getJobSummary(jobId,groupBy); |
|
31 |
groupBy_values = this.getOpenAIREValidator().getDistinctGroupByValues(jobId); |
|
32 |
filteredScore = this.getOpenAIREValidator().getFilteredScore(jobId, groupBy); |
|
33 |
job = this.getOpenAIREValidator().getJobSubmitted(jobId); |
|
34 |
|
|
35 |
// String mtdPrfx = "oai_dc"; |
|
36 |
// logger.debug("set of job: "+job.getSet()); |
|
37 |
// if (job.getSet()!=null && job.getSet().equalsIgnoreCase("openaire_data")) |
|
38 |
// mtdPrfx = "oai_datacite";\ |
|
39 |
|
|
40 |
urlPrefix = job.getRepo() + "?verb=GetRecord&metadataPrefix=" + job.getMetadata_prefix() +"&identifier="; |
|
41 |
|
|
42 |
|
|
43 |
if(entries == null || entries.size() == 0) { |
|
44 |
errorMessage=job.getError(); |
|
45 |
errorMessage0 = getText("job.noTasks"); |
|
46 |
} |
|
47 |
|
|
48 |
; |
|
49 |
return Action.SUCCESS; |
|
50 |
} |
|
51 |
catch(Exception e) { |
|
52 |
logger.error("Error redirecting to job", e); |
|
53 |
this.addActionError(this.getText("generic.error")); |
|
54 |
reportException(e); |
|
55 |
return "exception"; |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
public String getUrlPrefix() { |
|
60 |
return urlPrefix; |
|
61 |
} |
|
62 |
|
|
63 |
public void setUrlPrefix(String urlPrefix) { |
|
64 |
this.urlPrefix = urlPrefix; |
|
65 |
} |
|
66 |
|
|
67 |
public String getJobId() { |
|
68 |
return jobId; |
|
69 |
} |
|
70 |
|
|
71 |
public void setJobId(String jobId) { |
|
72 |
this.jobId = jobId; |
|
73 |
} |
|
74 |
|
|
75 |
public JobSubmitted getJob() { |
|
76 |
return job; |
|
77 |
} |
|
78 |
|
|
79 |
public void setJob(JobSubmitted job) { |
|
80 |
this.job = job; |
|
81 |
} |
|
82 |
|
|
83 |
public List<Entry> getEntries() { |
|
84 |
return entries; |
|
85 |
} |
|
86 |
|
|
87 |
public void setEntries(List<Entry> entries) { |
|
88 |
this.entries = entries; |
|
89 |
} |
|
90 |
|
|
91 |
public String getGroupBy() { |
|
92 |
return groupBy; |
|
93 |
} |
|
94 |
|
|
95 |
public void setGroupBy(String groupBy) { |
|
96 |
this.groupBy = groupBy; |
|
97 |
} |
|
98 |
|
|
99 |
public List<String> getGroupBy_values() { |
|
100 |
return groupBy_values; |
|
101 |
} |
|
102 |
|
|
103 |
public void setGroupBy_values(List<String> groupBy_values) { |
|
104 |
this.groupBy_values = groupBy_values; |
|
105 |
} |
|
106 |
|
|
107 |
public void setErrorMessage(String errorMessage) { |
|
108 |
this.errorMessage = errorMessage; |
|
109 |
} |
|
110 |
|
|
111 |
public String getErrorMessage() { |
|
112 |
return errorMessage; |
|
113 |
} |
|
114 |
|
|
115 |
public String getFilteredScore() { |
|
116 |
return filteredScore; |
|
117 |
} |
|
118 |
|
|
119 |
public void setFilteredScore(String filteredScore) { |
|
120 |
this.filteredScore = filteredScore; |
|
121 |
} |
|
122 |
|
|
123 |
public String getErrorMessage0() { |
|
124 |
return errorMessage0; |
|
125 |
} |
|
126 |
|
|
127 |
public void setErrorMessage0(String errorMessage0) { |
|
128 |
this.errorMessage0 = errorMessage0; |
|
129 |
} |
|
130 |
|
|
131 |
|
|
132 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/BugReporter.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions; |
|
2 |
|
|
3 |
|
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.apache.log4j.Logger; |
|
8 |
|
|
9 |
import com.opensymphony.xwork2.Action; |
|
10 |
|
|
11 |
public class BugReporter extends BaseValidatorAction { |
|
12 |
|
|
13 |
private static final long serialVersionUID = -3331529072364646515L; |
|
14 |
|
|
15 |
private transient Logger logger = Logger.getLogger(BugReporter.class); |
|
16 |
|
|
17 |
private String ex = null; |
|
18 |
|
|
19 |
public String execute() { |
|
20 |
List<String> recipients = new ArrayList<String>(); |
|
21 |
this.addActionError(this.getText("generic.error")); |
|
22 |
try { |
|
23 |
recipients.add(this.getValAdminEmail()); |
|
24 |
String message = "An exception has occurred:\n"+ex; |
|
25 |
String subject = "Automatic Bug Report"; |
|
26 |
this.getEmailer().sendMail(recipients, subject, message, false, null); |
|
27 |
} catch (Exception e) { |
|
28 |
logger.error("error sending error report", e); |
|
29 |
} |
|
30 |
return Action.SUCCESS; |
|
31 |
} |
|
32 |
|
|
33 |
public void setEx(String ex) { |
|
34 |
this.ex = ex; |
|
35 |
} |
|
36 |
|
|
37 |
public String getEx() { |
|
38 |
return ex; |
|
39 |
} |
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/users/EditUser.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.users; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.api.user.UserProfileIS; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
import gr.uoa.di.validatorweb.configs.Constants; |
|
6 |
|
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import org.apache.log4j.Logger; |
|
10 |
import org.apache.struts2.interceptor.SessionAware; |
|
11 |
|
|
12 |
import com.opensymphony.xwork2.Action; |
|
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 String fname, lname, inst; |
|
20 |
|
|
21 |
public String getFname() { |
|
22 |
return fname; |
|
23 |
} |
|
24 |
|
|
25 |
public void setFname(String fname) { |
|
26 |
this.fname = fname; |
|
27 |
} |
|
28 |
|
|
29 |
public String getLname() { |
|
30 |
return lname; |
|
31 |
} |
|
32 |
|
|
33 |
public void setLname(String lname) { |
|
34 |
this.lname = lname; |
|
35 |
} |
|
36 |
|
|
37 |
public String getInst() { |
|
38 |
return inst; |
|
39 |
} |
|
40 |
|
|
41 |
public void setInst(String inst) { |
|
42 |
this.inst = inst; |
|
43 |
} |
|
44 |
|
|
45 |
private Map<String, Object> session; |
|
46 |
|
|
47 |
public String execute() { |
|
48 |
this.clearErrorsAndMessages(); |
|
49 |
try { |
|
50 |
logger.debug("getting for edit user " + (String) session.get(Constants.loggedInField)); |
|
51 |
// if (isModeLdap() || isModeOpenAIRE()) { |
|
52 |
if (isModeLdap()) { |
|
53 |
UserProfileIS profile = (UserProfileIS) this.getUserAPI().getUser((String) session.get(Constants.loggedInField)); |
|
54 |
fname = profile.getFname(); |
|
55 |
lname = profile.getLname(); |
|
56 |
inst = profile.getInstitution(); |
|
57 |
} |
|
58 |
return Action.SUCCESS; |
|
59 |
} catch (Exception e) { |
|
60 |
logger.error("error getting for edit user " + (String) session.get(Constants.loggedInField), e); |
|
61 |
this.addActionError(this.getText("generic.error")); |
|
62 |
reportException(e); |
|
63 |
return "exception"; |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
public String edit() { |
|
68 |
this.clearErrorsAndMessages(); |
|
69 |
try { |
|
70 |
logger.debug("editing user " + (String) session.get(Constants.loggedInField)); |
|
71 |
this.getUserAPI().editUser((String) session.get(Constants.loggedInField), fname, lname, inst); |
|
72 |
this.addActionMessage(this.getText("editUser.success")); |
|
73 |
return Action.SUCCESS; |
|
74 |
} catch (Exception e) { |
|
75 |
logger.error("error editing user " + (String) session.get(Constants.loggedInField), e); |
|
76 |
this.addActionError(this.getText("generic.error")); |
|
77 |
reportException(e); |
|
78 |
return "exception"; |
|
79 |
} |
|
80 |
|
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public void setSession(Map<String, Object> session) { |
|
85 |
this.session = session; |
|
86 |
} |
|
87 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/users/Register.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.users; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.regex.Pattern; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
|
|
10 |
import com.opensymphony.xwork2.Action; |
|
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; |
|
19 |
|
|
20 |
public String execute() { |
|
21 |
this.clearErrorsAndMessages(); |
|
22 |
try { |
|
23 |
logger.debug("registering user " + email); |
|
24 |
String activationId = null; |
|
25 |
|
|
26 |
if (isModeLdap() || isModeOpenAIRE()) |
|
27 |
activationId = this.getUserAPI().addUser(username, email, password, firstName, lastName); |
|
28 |
else |
|
29 |
activationId = this.getUserAPI().addUser(this.getEmail(), this.getPassword()); |
|
30 |
|
|
31 |
this.addActionMessage((this.getText("registration.successful"))); |
|
32 |
this.addActionMessage((this.getText("general.unblock") + " " + this.getEmailer().getFrom())); |
|
33 |
|
|
34 |
ArrayList<String> to = new ArrayList<String>(); |
|
35 |
to.add(this.getEmail()); |
|
36 |
|
|
37 |
this.getEmailer().sendMail(to, this.getText("registration.mail.subject"), this.getText("registration.mail.message") + ": " + this.getValBaseUrl() + "/activateAccount.action?activationId=" + activationId, false, null); |
|
38 |
|
|
39 |
return Action.SUCCESS; |
|
40 |
} catch (Exception e) { |
|
41 |
logger.error("error registering user " + email, e); |
|
42 |
this.addActionError(this.getText("generic.error")); |
|
43 |
reportException(e); |
|
44 |
return "exception"; |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
48 |
public void validate() { |
|
49 |
this.clearErrors(); |
|
50 |
if (this.getEmail() == null || this.getEmail().length() == 0) |
|
51 |
this.addFieldError("email", this.getText("compulsoryField")); |
|
52 |
if (this.getPassword() == null || this.getPassword().length() == 0) |
|
53 |
this.addFieldError("password", this.getText("compulsoryField")); |
|
54 |
if (this.getRepassword() == null || this.getRepassword().length() == 0) |
|
55 |
this.addFieldError("repassword", this.getText("compulsoryField")); |
|
56 |
|
|
57 |
if (isModeLdap()) { |
|
58 |
if (this.getUsername() == null || this.getUsername().length() == 0) |
|
59 |
this.addFieldError("username", this.getText("compulsoryField")); |
|
60 |
if (this.getFirstName() == null || this.getFirstName().length() == 0) |
|
61 |
this.addFieldError("firstName", this.getText("compulsoryField")); |
|
62 |
if (this.getLastName() == null || this.getLastName().length() == 0) |
|
63 |
this.addFieldError("lastName", this.getText("compulsoryField")); |
|
64 |
} |
|
65 |
|
|
66 |
if (!this.getPassword().equals(this.getRepassword())) |
|
67 |
this.addFieldError("password", this.getText("identicalPasswords")); |
|
68 |
|
|
69 |
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])?$"); |
|
70 |
if (!rfc2822.matcher(this.getEmail().trim().toLowerCase()).matches()) { |
|
71 |
this.addFieldError("email", this.getText("notValidEmail")); |
|
72 |
} |
|
73 |
|
|
74 |
try { |
|
75 |
if (this.getUserAPI().userExists(this.getEmail())) |
|
76 |
this.addFieldError("email", this.getText("userAlreadyExists")); |
|
77 |
if (isModeLdap() && this.getUserAPI().usernameExists(this.getUsername())) |
|
78 |
this.addFieldError("username", this.getText("userAlreadyExists")); |
|
79 |
|
|
80 |
} catch (Exception e) { |
|
81 |
this.addFieldError("email", this.getText("userAlreadyExists")); |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
public String getEmail() { |
|
86 |
return email; |
|
87 |
} |
|
88 |
|
|
89 |
public void setEmail(String email) { |
|
90 |
this.email = email; |
|
91 |
} |
|
92 |
|
|
93 |
public String getPassword() { |
|
94 |
return password; |
|
95 |
} |
|
96 |
|
|
97 |
public void setPassword(String password) { |
|
98 |
this.password = password; |
|
99 |
} |
|
100 |
|
|
101 |
public String getRepassword() { |
|
102 |
return repassword; |
|
103 |
} |
|
104 |
|
|
105 |
public void setRepassword(String repassword) { |
|
106 |
this.repassword = repassword; |
|
107 |
} |
|
108 |
|
|
109 |
public String getUsername() { |
|
110 |
return username; |
|
111 |
} |
|
112 |
|
|
113 |
public void setUsername(String username) { |
|
114 |
this.username = username; |
|
115 |
} |
|
116 |
|
|
117 |
public String getFirstName() { |
|
118 |
return firstName; |
|
119 |
} |
|
120 |
|
|
121 |
public void setFirstName(String firstName) { |
|
122 |
this.firstName = firstName; |
|
123 |
} |
|
124 |
|
|
125 |
public String getLastName() { |
|
126 |
return lastName; |
|
127 |
} |
|
128 |
|
|
129 |
public void setLastName(String lastName) { |
|
130 |
this.lastName = lastName; |
|
131 |
} |
|
132 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/users/ActivateAccount.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.users; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
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-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/feedback/FeedBackPage.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.feedback; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
@SuppressWarnings("serial") |
|
6 |
public class FeedBackPage extends BaseValidatorAction{ |
|
7 |
|
|
8 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/feedback/SendFeedback.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.feedback; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
import gr.uoa.di.validatorweb.configs.Constants; |
|
5 |
|
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
9 |
|
|
10 |
import org.apache.log4j.Logger; |
|
11 |
import org.apache.struts2.interceptor.SessionAware; |
|
12 |
|
|
13 |
import com.opensymphony.xwork2.Action; |
|
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-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/DeleteRuleSet.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
8 |
|
|
9 |
public class DeleteRuleSet extends BaseValidatorAction { |
|
10 |
|
|
11 |
private static final long serialVersionUID = 4858147485197818532L; |
|
12 |
private int setId; |
|
13 |
private static final Logger logger = Logger.getLogger(DeleteRuleSet.class); |
|
14 |
|
|
15 |
public int getSetId() { |
|
16 |
return setId; |
|
17 |
} |
|
18 |
|
|
19 |
public void setSetId(int setId) { |
|
20 |
this.setId = setId; |
|
21 |
} |
|
22 |
|
|
23 |
public String execute() { |
|
24 |
this.clearErrorsAndMessages(); |
|
25 |
try { |
|
26 |
logger.debug("deleting rule set "+setId); |
|
27 |
this.getOpenAIREValidator().deleteRuleSet(setId); |
|
28 |
this.addActionMessage(this.getText("deleteRuleSet.success")); |
|
29 |
return Action.SUCCESS; |
|
30 |
} |
|
31 |
catch(Exception e) { |
|
32 |
logger.error("Error deleting ruleset", e); |
|
33 |
this.addActionError(this.getText("generic.error")); |
|
34 |
reportException(e); |
|
35 |
return "exception"; |
|
36 |
} |
|
37 |
} |
|
38 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/GetRuleSets.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.dao.RuleSet; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
|
|
10 |
import com.opensymphony.xwork2.Action; |
|
11 |
|
|
12 |
public class GetRuleSets extends BaseValidatorAction { |
|
13 |
|
|
14 |
private static final long serialVersionUID = -5220242100308666597L; |
|
15 |
private List<RuleSet> sets; |
|
16 |
private static final Logger logger = Logger.getLogger(GetRuleSets.class); |
|
17 |
|
|
18 |
public List<RuleSet> getSets() { |
|
19 |
return sets; |
|
20 |
} |
|
21 |
|
|
22 |
public void setSets(List<RuleSet> sets) { |
|
23 |
this.sets = sets; |
|
24 |
} |
|
25 |
|
|
26 |
public String execute() throws Exception { |
|
27 |
this.clearErrorsAndMessages(); |
|
28 |
try { |
|
29 |
logger.debug("getting all rule sets"); |
|
30 |
sets = this.getOpenAIREValidator().getRuleSetIdNames(); |
|
31 |
return Action.SUCCESS; |
|
32 |
} catch (Exception e) { |
|
33 |
logger.error("Error getting rule sets", e); |
|
34 |
this.addActionError(this.getText("generic.error")); |
|
35 |
reportException(e); |
|
36 |
return "exception"; |
|
37 |
} |
|
38 |
} |
|
39 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/CreateRuleSet.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
8 |
|
|
9 |
public class CreateRuleSet extends BaseValidatorAction { |
|
10 |
|
|
11 |
private static final long serialVersionUID = 5623461974078831740L; |
|
12 |
|
|
13 |
private String[] chosenContentRules = null; |
|
14 |
private String[] chosenUsageRules = null; |
|
15 |
private String name = null; |
|
16 |
private String description = null; |
|
17 |
private String funct = null; |
|
18 |
private int setId = -1; |
|
19 |
private static final Logger logger = Logger.getLogger(CreateRuleSet.class); |
|
20 |
|
|
21 |
public String execute() { |
|
22 |
this.clearErrorsAndMessages(); |
|
23 |
try { |
|
24 |
logger.debug("creating a new rule set "+name); |
|
25 |
if(funct.equals("create")) { |
|
26 |
this.getOpenAIREValidator().createRuleSet(name, description, chosenContentRules,chosenUsageRules); |
|
27 |
this.addActionMessage(this.getText("createRuleSet.success")); |
|
28 |
} |
|
29 |
else if(funct.equals("edit")) { |
|
30 |
this.getOpenAIREValidator().editRuleSet(setId, name, description, chosenContentRules,chosenUsageRules); |
|
31 |
this.addActionMessage(this.getText("createRuleSet.success")); |
|
32 |
} |
|
33 |
return Action.SUCCESS; |
|
34 |
} |
|
35 |
catch(Exception e) { |
|
36 |
logger.error("Error creating/editing ruleset", e); |
|
37 |
this.addActionError(this.getText("generic.error")); |
|
38 |
reportException(e); |
|
39 |
return "exception"; |
|
40 |
} |
|
41 |
} |
|
42 |
|
|
43 |
public void validate() { |
|
44 |
this.clearErrors(); |
|
45 |
if((chosenContentRules == null || chosenContentRules.length < 1)||(chosenUsageRules == null || chosenUsageRules.length < 1)) |
|
46 |
this.addActionError(this.getText("createRuleSets.atLeastOneRule")); |
|
47 |
if(funct == null) |
|
48 |
this.addActionError(this.getText("uknownError")); |
|
49 |
} |
|
50 |
public String getDescription() { |
|
51 |
return description; |
|
52 |
} |
|
53 |
public void setDescription(String description) { |
|
54 |
this.description = description; |
|
55 |
} |
|
56 |
|
|
57 |
|
|
58 |
public int getSetId() { |
|
59 |
return setId; |
|
60 |
} |
|
61 |
public void setSetId(int setId) { |
|
62 |
this.setId = setId; |
|
63 |
} |
|
64 |
public String getFunct() { |
|
65 |
return funct; |
|
66 |
} |
|
67 |
public void setFunct(String funct) { |
|
68 |
this.funct = funct; |
|
69 |
} |
|
70 |
public String[] getChosenContentRules() { |
|
71 |
return chosenContentRules; |
|
72 |
} |
|
73 |
public void setChosenContentRules(String[] chosenContentRules) { |
|
74 |
this.chosenContentRules = chosenContentRules; |
|
75 |
} |
|
76 |
public String[] getChosenUsageRules() { |
|
77 |
return chosenUsageRules; |
|
78 |
} |
|
79 |
public void setChosenUsageRules(String[] chosenUsageRules) { |
|
80 |
this.chosenUsageRules = chosenUsageRules; |
|
81 |
} |
|
82 |
public String getName() { |
|
83 |
return name; |
|
84 |
} |
|
85 |
public void setName(String name) { |
|
86 |
this.name = name; |
|
87 |
} |
|
88 |
|
|
89 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/FetchRuleDescriptions.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
import gr.uoa.di.validatorweb.actions.compTest.RuleD; |
|
5 |
|
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.apache.log4j.Logger; |
|
10 |
|
|
11 |
import com.opensymphony.xwork2.Action; |
|
12 |
|
|
13 |
public class FetchRuleDescriptions extends BaseValidatorAction { |
|
14 |
|
|
15 |
private static final long serialVersionUID = -2095636309367991598L; |
|
16 |
private List<RuleD> rulesContent; |
|
17 |
private List<RuleD> rulesUsage; |
|
18 |
private String ruleSetDescription; |
|
19 |
private String ruleSetId; |
|
20 |
private static final Logger logger = Logger.getLogger(FetchRuleDescriptions.class); |
|
21 |
|
|
22 |
public String execute() { |
|
23 |
this.clearErrorsAndMessages(); |
|
24 |
|
|
25 |
String ruleSetName = null; |
|
26 |
List<String> ruleIdsContent = new ArrayList<String>(); |
|
27 |
List<String> ruleIdsUsage = new ArrayList<String>(); |
|
28 |
int id; |
|
29 |
|
|
30 |
try { |
|
31 |
id = Integer.parseInt(ruleSetId); |
|
32 |
|
|
33 |
} catch (NumberFormatException nfe) { |
|
34 |
// case of wrong url |
|
35 |
id = -1; |
|
36 |
} |
|
37 |
|
|
38 |
try { |
|
39 |
|
|
40 |
ruleSetName = this.getOpenAIREValidator().getRuleSetName(id); |
|
41 |
//case of wrong given id |
|
42 |
if (ruleSetName == null) { |
|
43 |
id = -1; |
|
44 |
} |
|
45 |
|
|
46 |
if (id == -1) { |
|
47 |
ruleSetName = "All"; |
|
48 |
ruleIdsContent = this.getOpenAIREValidator().getAllRuleIdsByJobType("content"); |
|
49 |
ruleIdsUsage = this.getOpenAIREValidator().getAllRuleIdsByJobType("usage"); |
|
50 |
|
|
51 |
} else { |
|
52 |
ruleSetName = this.getOpenAIREValidator().getRuleSetName(id); |
|
53 |
ruleIdsContent = this.getOpenAIREValidator().getRuleSetRuleIdsByJobType(id,"content"); |
|
54 |
ruleIdsUsage = this.getOpenAIREValidator().getRuleSetRuleIdsByJobType(id,"usage"); |
|
55 |
} |
|
56 |
|
|
57 |
rulesContent = this.getOpenAIREValidator().convertRuleIdsListToRuleDList(ruleIdsContent); |
|
58 |
rulesUsage = this.getOpenAIREValidator().convertRuleIdsListToRuleDList(ruleIdsUsage); |
|
59 |
|
|
60 |
ruleSetDescription = "ruleSetInfo."+ruleSetName; |
|
61 |
|
|
62 |
logger.debug("ruleset descr " + ruleSetDescription); |
|
63 |
logger.debug("rulesContent" + rulesContent.size()); |
|
64 |
logger.debug("rulesUsage" + rulesUsage.size()); |
|
65 |
|
|
66 |
return Action.SUCCESS; |
|
67 |
} |
|
68 |
catch(Exception e) { |
|
69 |
logger.error("Error fetching rule descriptions", e); |
|
70 |
this.addActionError(this.getText("generic.error")); |
|
71 |
reportException(e); |
|
72 |
return "exception"; |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
|
|
77 |
public List<RuleD> getRulesContent() { |
|
78 |
return rulesContent; |
|
79 |
} |
|
80 |
|
|
81 |
public void setRulesContent(List<RuleD> rulesContent) { |
|
82 |
this.rulesContent = rulesContent; |
|
83 |
} |
|
84 |
|
|
85 |
public List<RuleD> getRulesUsage() { |
|
86 |
return rulesUsage; |
|
87 |
} |
|
88 |
|
|
89 |
public void setRulesUsage(List<RuleD> rulesUsage) { |
|
90 |
this.rulesUsage = rulesUsage; |
|
91 |
} |
|
92 |
|
|
93 |
public void setRuleSetDescription(String ruleSetDescription) { |
|
94 |
this.ruleSetDescription = ruleSetDescription; |
|
95 |
} |
|
96 |
|
|
97 |
public String getRuleSetDescription() { |
|
98 |
return ruleSetDescription; |
|
99 |
} |
|
100 |
|
|
101 |
public String getRuleSetId() { |
|
102 |
return ruleSetId; |
|
103 |
} |
|
104 |
|
|
105 |
public void setRuleSetId(String ruleSetId) { |
|
106 |
this.ruleSetId = ruleSetId; |
|
107 |
} |
|
108 |
} |
|
109 |
|
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/GetRules.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.dao.RuleSet; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
|
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.apache.log4j.Logger; |
|
10 |
|
|
11 |
import com.opensymphony.xwork2.Action; |
|
12 |
|
|
13 |
public class GetRules extends BaseValidatorAction { |
|
14 |
|
|
15 |
private static final long serialVersionUID = 3336444896590055688L; |
|
16 |
private int setId = -1; |
|
17 |
private List<RuleS> rulesContent; |
|
18 |
private List<RuleS> rulesUsage; |
|
19 |
private List<String> ruleIdsContent; |
|
20 |
private List<String> ruleIdsUsage; |
|
21 |
private String funct = null; |
|
22 |
private String name = ""; |
|
23 |
private String description = ""; |
|
24 |
|
|
25 |
private static final Logger logger = Logger.getLogger(GetRules.class); |
|
26 |
|
|
27 |
public String execute() { |
|
28 |
this.clearErrorsAndMessages(); |
|
29 |
try { |
|
30 |
logger.debug("getting rules in rule set "+setId); |
|
31 |
if (setId == -1) { |
|
32 |
funct = "create"; |
|
33 |
ruleIdsContent = new ArrayList<String>(); |
|
34 |
rulesContent = this.getOpenAIREValidator().getAllRulesForPresentationByJobType("content"); |
|
35 |
ruleIdsUsage = new ArrayList<String>(); |
|
36 |
rulesUsage = this.getOpenAIREValidator().getAllRulesForPresentationByJobType("usage"); |
|
37 |
} else { |
|
38 |
funct = "edit"; |
|
39 |
ruleIdsContent = this.getOpenAIREValidator().getRuleSetRuleIdsByJobType(setId,"content"); |
|
40 |
rulesContent = this.getOpenAIREValidator().getAllRulesForPresentationByJobTypeByRuleSet(ruleIdsContent,"content"); |
|
41 |
ruleIdsUsage = this.getOpenAIREValidator().getRuleSetRuleIdsByJobType(setId,"usage"); |
|
42 |
rulesUsage = this.getOpenAIREValidator().getAllRulesForPresentationByJobTypeByRuleSet(ruleIdsContent,"usage"); |
|
43 |
RuleSet set = this.getOpenAIREValidator().getRuleSet(setId); |
|
44 |
name = set.getName(); |
|
45 |
description = set.getDescription(); |
|
46 |
|
|
47 |
} |
|
48 |
return Action.SUCCESS; |
|
49 |
} |
|
50 |
catch(Exception e) { |
|
51 |
logger.error("Error getting rules", e); |
|
52 |
this.addActionError(this.getText("generic.error")); |
|
53 |
reportException(e); |
|
54 |
return "exception"; |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
public String getDescription() { |
|
60 |
return description; |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
public void setDescription(String description) { |
|
65 |
this.description = description; |
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
public String getName() { |
|
70 |
return name; |
|
71 |
} |
|
72 |
|
|
73 |
public void setName(String name) { |
|
74 |
this.name = name; |
|
75 |
} |
|
76 |
|
|
77 |
public String getFunct() { |
|
78 |
return funct; |
|
79 |
} |
|
80 |
|
|
81 |
public void setFunct(String funct) { |
|
82 |
this.funct = funct; |
|
83 |
} |
|
84 |
|
|
85 |
public int getSetId() { |
|
86 |
return setId; |
|
87 |
} |
|
88 |
|
|
89 |
public void setSetId(int setId) { |
|
90 |
this.setId = setId; |
|
91 |
} |
|
92 |
|
|
93 |
public List<RuleS> getRulesContent() { |
|
94 |
return rulesContent; |
|
95 |
} |
|
96 |
|
|
97 |
public void setRulesContent(List<RuleS> rulesContent) { |
|
98 |
this.rulesContent = rulesContent; |
|
99 |
} |
|
100 |
|
|
101 |
public List<RuleS> getRulesUsage() { |
|
102 |
return rulesUsage; |
|
103 |
} |
|
104 |
|
|
105 |
public void setRulesUsage(List<RuleS> rulesUsage) { |
|
106 |
this.rulesUsage = rulesUsage; |
|
107 |
} |
|
108 |
|
|
109 |
public List<String> getRuleIdsContent() { |
|
110 |
return ruleIdsContent; |
|
111 |
} |
|
112 |
|
|
113 |
public void setRuleIdsContent(List<String> ruleIdsContent) { |
|
114 |
this.ruleIdsContent = ruleIdsContent; |
|
115 |
} |
|
116 |
|
|
117 |
public List<String> getRuleIdsUsage() { |
|
118 |
return ruleIdsUsage; |
|
119 |
} |
|
120 |
|
|
121 |
public void setRuleIdsUsage(List<String> ruleIdsUsage) { |
|
122 |
this.ruleIdsUsage = ruleIdsUsage; |
|
123 |
} |
|
124 |
|
|
125 |
} |
|
126 |
|
|
127 |
|
|
128 |
|
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rulesets/RuleS.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rulesets; |
|
2 |
|
|
3 |
public class RuleS { |
|
4 |
|
|
5 |
private String id; |
|
6 |
private String name; |
|
7 |
private boolean chosen = false; |
|
8 |
|
|
9 |
|
|
10 |
public String getId() { |
|
11 |
return id; |
|
12 |
} |
|
13 |
public void setId(String id) { |
|
14 |
this.id = id; |
|
15 |
} |
|
16 |
public String getName() { |
|
17 |
return name; |
|
18 |
} |
|
19 |
public void setName(String name) { |
|
20 |
this.name = name; |
|
21 |
} |
|
22 |
public boolean isChosen() { |
|
23 |
return chosen; |
|
24 |
} |
|
25 |
public void setChosen(boolean chosen) { |
|
26 |
this.chosen = chosen; |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rules/FieldPair.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rules; |
|
2 |
|
|
3 |
public class FieldPair { |
|
4 |
|
|
5 |
private String fieldName, fieldValue; |
|
6 |
|
|
7 |
public String getFieldName() { |
|
8 |
return fieldName; |
|
9 |
} |
|
10 |
|
|
11 |
public void setFieldName(String fieldName) { |
|
12 |
this.fieldName = fieldName; |
|
13 |
} |
|
14 |
|
|
15 |
public String getFieldValue() { |
|
16 |
return fieldValue; |
|
17 |
} |
|
18 |
|
|
19 |
public void setFieldValue(String fieldValue) { |
|
20 |
this.fieldValue = fieldValue; |
|
21 |
} |
|
22 |
|
|
23 |
|
|
24 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rules/PrepareAddRule.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rules; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.api.OpenAIREValidatorException; |
|
4 |
import gr.uoa.di.validator.dao.RulePair; |
|
5 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
6 |
|
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
import org.apache.log4j.Logger; |
|
10 |
|
|
11 |
import com.opensymphony.xwork2.Action; |
|
12 |
|
|
13 |
public class PrepareAddRule extends BaseValidatorAction { |
|
14 |
|
|
15 |
private static final long serialVersionUID = -8414397033694574297L; |
|
16 |
private Logger logger = Logger.getLogger(PrepareAddRule.class); |
|
17 |
|
|
18 |
private String type; |
|
19 |
private List<String> labels; |
|
20 |
private String[] jobTypes; |
|
21 |
private List<RulePair> rules; |
|
22 |
|
|
23 |
|
|
24 |
public String execute() { |
|
25 |
this.clearErrorsAndMessages(); |
|
26 |
logger.debug("preparing to add rule of type " + type); |
|
27 |
try { |
|
28 |
labels = getOpenAIREValidator().getRuleLabels(type); |
|
29 |
} catch (OpenAIREValidatorException e) { |
|
30 |
return Action.ERROR; |
|
31 |
} |
|
32 |
try { |
|
33 |
jobTypes = getOpenAIREValidator().getJobTypesAsArray(); |
|
34 |
} catch (OpenAIREValidatorException e) { |
|
35 |
return Action.ERROR; |
|
36 |
} |
|
37 |
if (type.equals("ChainRule")) { |
|
38 |
try { |
|
39 |
rules = this.getOpenAIREValidator().getAllRulesToRulePair(); |
|
40 |
} catch (OpenAIREValidatorException e) { |
|
41 |
return Action.ERROR; |
|
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
return Action.SUCCESS; |
|
46 |
} |
|
47 |
|
|
48 |
public String[] getJobTypes() { |
|
49 |
return jobTypes; |
|
50 |
} |
|
51 |
|
|
52 |
public void setJobTypes(String[] jobTypes) { |
|
53 |
this.jobTypes = jobTypes; |
|
54 |
} |
|
55 |
|
|
56 |
public List<String> getLabels() { |
|
57 |
return labels; |
|
58 |
} |
|
59 |
|
|
60 |
public void setLabels(List<String> labels) { |
|
61 |
this.labels = labels; |
|
62 |
} |
|
63 |
|
|
64 |
public String getType() { |
|
65 |
return type; |
|
66 |
} |
|
67 |
|
|
68 |
public void setType(String type) { |
|
69 |
this.type = type; |
|
70 |
} |
|
71 |
|
|
72 |
|
|
73 |
public List<RulePair> getRules() { |
|
74 |
return rules; |
|
75 |
} |
|
76 |
|
|
77 |
public void setRules(List<RulePair> rules) { |
|
78 |
this.rules = rules; |
|
79 |
} |
|
80 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rules/AddRule.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rules; |
|
2 |
|
|
3 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
4 |
|
|
5 |
import org.apache.log4j.Logger; |
|
6 |
|
|
7 |
import com.opensymphony.xwork2.Action; |
|
8 |
|
|
9 |
public class AddRule extends BaseValidatorAction { |
|
10 |
|
|
11 |
private static final long serialVersionUID = -4636737264204104816L; |
|
12 |
private String[] inputs; |
|
13 |
private String type, jobType; |
|
14 |
private static final Logger logger = Logger.getLogger(AddRule.class); |
|
15 |
|
|
16 |
public String getJobType() { |
|
17 |
return jobType; |
|
18 |
} |
|
19 |
|
|
20 |
public void setJobType(String jobType) { |
|
21 |
this.jobType = jobType; |
|
22 |
} |
|
23 |
|
|
24 |
public String getType() { |
|
25 |
return type; |
|
26 |
} |
|
27 |
|
|
28 |
public void setType(String type) { |
|
29 |
this.type = type; |
|
30 |
} |
|
31 |
|
|
32 |
public String[] getInputs() { |
|
33 |
return inputs; |
|
34 |
} |
|
35 |
|
|
36 |
public void setInputs(String[] inputs) { |
|
37 |
this.inputs = inputs; |
|
38 |
} |
|
39 |
|
|
40 |
public String execute() { |
|
41 |
this.clearErrorsAndMessages(); |
|
42 |
try { |
|
43 |
logger.debug("adding rule of type "+type+" using user inputs"); |
|
44 |
String ret = this.getOpenAIREValidator().addNewRule(this.type, this.jobType, inputs); |
|
45 |
|
|
46 |
if (ret != null) { |
|
47 |
this.addActionError(this.getText(ret)); |
|
48 |
return "input-problem"; |
|
49 |
} |
|
50 |
|
|
51 |
this.addActionMessage(this.getText("addRule.success")); |
|
52 |
|
|
53 |
return Action.SUCCESS; |
|
54 |
} catch(Exception e) { |
|
55 |
logger.error("Error adding rule", e); |
|
56 |
this.addActionError(this.getText("generic.error")); |
|
57 |
reportException(e); |
|
58 |
return "exception"; |
|
59 |
} |
|
60 |
} |
|
61 |
} |
modules/uoa-validator-service/newrepos/src/main/java/gr/uoa/di/validatorweb/actions/admin/rules/PopulateRuleCategories.java | ||
---|---|---|
1 |
package gr.uoa.di.validatorweb.actions.admin.rules; |
|
2 |
|
|
3 |
import gr.uoa.di.validator.api.OpenAIREValidatorException; |
|
4 |
import gr.uoa.di.validatorweb.actions.BaseValidatorAction; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.apache.log4j.Logger; |
|
9 |
|
|
10 |
import com.opensymphony.xwork2.Action; |
|
11 |
|
|
12 |
public class PopulateRuleCategories extends BaseValidatorAction { |
|
13 |
|
|
14 |
private static final long serialVersionUID = 3845749201114926778L; |
|
15 |
private Logger logger = Logger.getLogger(PopulateRuleCategories.class); |
|
16 |
|
|
17 |
private List<String> ruleTypes; |
|
18 |
|
|
19 |
public List<String> getRuleTypes() { |
|
20 |
return ruleTypes; |
|
21 |
} |
|
22 |
|
|
23 |
public void setRuleTypes(List<String> ruleTypes) { |
|
24 |
this.ruleTypes = ruleTypes; |
|
25 |
} |
|
26 |
|
|
27 |
public String execute() { |
|
28 |
this.clearErrorsAndMessages(); |
|
29 |
logger.debug("populating rule categories"); |
|
30 |
try { |
Also available in: Unified diff
copying uoa-validator-service for spring update