Revision 34342
Added by Nikon Gasparis over 9 years ago
ValidatorServiceImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.validator.service.impl; |
|
2 |
|
|
3 |
import eu.dnetlib.api.functionality.ValidatorService; |
|
4 |
import eu.dnetlib.api.functionality.ValidatorServiceException; |
|
5 |
import eu.dnetlib.domain.ActionType; |
|
6 |
import eu.dnetlib.domain.ResourceType; |
|
7 |
import eu.dnetlib.domain.enabling.Notification; |
|
8 |
import eu.dnetlib.domain.functionality.validator.JobForValidation; |
|
9 |
import eu.dnetlib.domain.functionality.validator.RuleSet; |
|
10 |
import eu.dnetlib.domain.functionality.validator.StoredJob; |
|
11 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardNotificationHandler; |
|
12 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
|
13 |
import eu.dnetlib.validator.engine.ValidatorException; |
|
14 |
import gr.uoa.di.driver.app.DriverServiceImpl; |
|
15 |
import gr.uoa.di.driver.enabling.issn.NotificationListener; |
|
16 |
|
|
17 |
import java.util.ArrayList; |
|
18 |
import java.util.List; |
|
19 |
import java.util.Map; |
|
20 |
|
|
21 |
import org.apache.log4j.Logger; |
|
22 |
|
|
23 |
public class ValidatorServiceImpl extends DriverServiceImpl implements |
|
24 |
ValidatorService { |
|
25 |
|
|
26 |
private BlackboardNotificationHandler<BlackboardServerHandler> blackboardNotificationHandler = null; |
|
27 |
private Logger logger = Logger.getLogger(ValidatorServiceImpl.class); |
|
28 |
|
|
29 |
private ValidatorManager valManager; |
|
30 |
|
|
31 |
// do NOT call directly. It will be called by the |
|
32 |
// InitializingServiceRegistrationManager |
|
33 |
// after it sets the service EPR and id. |
|
34 |
@Override |
|
35 |
public void init() { |
|
36 |
super.init(); |
|
37 |
if (this.blackboardNotificationHandler != null) { |
|
38 |
this.subscribe(ActionType.UPDATE, |
|
39 |
ResourceType.VALIDATORSERVICERESOURCETYPE, this.getServiceEPR() |
|
40 |
.getParameter("serviceId"), |
|
41 |
"RESOURCE_PROFILE/BODY/BLACKBOARD/LAST_REQUEST", |
|
42 |
new NotificationListener() { |
|
43 |
@Override |
|
44 |
public void processNotification(Notification notification) { |
|
45 |
blackboardNotificationHandler.notified( |
|
46 |
notification.getSubscriptionId(), |
|
47 |
notification.getTopic(), |
|
48 |
notification.getIsId(), |
|
49 |
notification.getMessage()); |
|
50 |
logger.debug(notification.getSubscriptionId()); |
|
51 |
logger.debug(notification.getTopic()); |
|
52 |
logger.debug(notification.getIsId()); |
|
53 |
logger.debug(notification.getMessage()); |
|
54 |
} |
|
55 |
}); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public StoredJob getStoredJob(int jobId, String groupBy) |
|
61 |
throws ValidatorServiceException { |
|
62 |
try { |
|
63 |
logger.debug("received request for job " + jobId); |
|
64 |
return valManager.getStoredJob(jobId, groupBy); |
|
65 |
} catch (ValidatorException e) { |
|
66 |
throw new ValidatorServiceException(e); |
|
67 |
} |
|
68 |
|
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public List<StoredJob> getStoredJobs(String userMail) |
|
73 |
throws ValidatorServiceException { |
|
74 |
try { |
|
75 |
logger.debug("received request for jobs of user " + userMail); |
|
76 |
return valManager.getStoredJobs(userMail); |
|
77 |
} catch (ValidatorException e) { |
|
78 |
throw new ValidatorServiceException(e); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public List<RuleSet> getRuleSets() throws ValidatorServiceException { |
|
84 |
try { |
|
85 |
logger.debug("received request for rulesets "); |
|
86 |
return valManager.getRuleSets(); |
|
87 |
} catch (ValidatorException e) { |
|
88 |
throw new ValidatorServiceException(e); |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public void submitValidationJob(JobForValidation job) |
|
94 |
throws ValidatorServiceException { |
|
95 |
try { |
|
96 |
logger.debug("received request to submit job"); |
|
97 |
this.valManager.submitJob(job); |
|
98 |
} catch (ValidatorException e) { |
|
99 |
throw new ValidatorServiceException(e); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
public BlackboardNotificationHandler<BlackboardServerHandler> getBlackboardNotificationHandler() { |
|
104 |
return blackboardNotificationHandler; |
|
105 |
} |
|
106 |
|
|
107 |
public ValidatorManager getValManager() { |
|
108 |
return valManager; |
|
109 |
} |
|
110 |
|
|
111 |
public void setValManager(ValidatorManager valManager) { |
|
112 |
this.valManager = valManager; |
|
113 |
} |
|
114 |
|
|
115 |
public void setBlackboardNotificationHandler( |
|
116 |
BlackboardNotificationHandler<BlackboardServerHandler> blackboardNotificationHandler) { |
|
117 |
this.blackboardNotificationHandler = blackboardNotificationHandler; |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
public Map<String, ArrayList<StoredJob>> getValidationJobs(String userMail, |
|
122 |
boolean repoAdmin) { |
|
123 |
// TODO Auto-generated method stub |
|
124 |
return null; |
|
125 |
} |
|
126 |
|
|
127 |
} |
Also available in: Unified diff
*new version of validator service
*it now includes the validator implementation(replaces uoa-validator)
*registry for jobs,rules and providers is now removed.
*supports and implements the new ValidatorService interface
*new way to submit a new job (a common method is used for tests,registrations,or cris)
*content and usage jobs are now merged to one.
*listeners updated to support job merging
*works as standalone or with IS (BETA)