Revision 47297
Added by Argiro Kokogiannaki almost 7 years ago
ClaimValidation.java | ||
---|---|---|
15 | 15 |
private PrintWriter out; |
16 | 16 |
String pathToSaveReport = null; |
17 | 17 |
|
18 |
private Logger logger = Logger.getLogger(ClaimValidation.class); |
|
18 |
private static Logger logger = Logger.getLogger(ClaimValidation.class);
|
|
19 | 19 |
|
20 | 20 |
/* |
21 | 21 |
Claim: |
... | ... | |
26 | 26 |
logger.info("Validating..."); |
27 | 27 |
boolean isValid=true; |
28 | 28 |
try { |
29 |
out = new PrintWriter(new BufferedWriter(new FileWriter(pathToSaveReport+"./validationFile.txt", true)));
|
|
29 |
out = new PrintWriter(new BufferedWriter(new FileWriter(pathToSaveReport+"/validationFile.txt", true))); |
|
30 | 30 |
|
31 | 31 |
} catch (Exception e) { |
32 | 32 |
out = null; |
... | ... | |
217 | 217 |
public static boolean validateCollectedFrom(String collectedFrom) throws ClaimValidationException { |
218 | 218 |
//TODO add more collected from when they are available |
219 | 219 |
if (collectedFrom==null || collectedFrom.isEmpty()) { |
220 |
logger.error("CollectedFrom field of source and/or target is null or empty"); |
|
220 | 221 |
throw new ClaimValidationException("CollectedFrom field of source and/or target cannot be empty."); |
221 | 222 |
|
222 | 223 |
} else if (!collectedFrom.equals(ClaimUtils.OPENAIRE) && |
223 | 224 |
!collectedFrom.equals(ClaimUtils.DATACITE) && |
224 | 225 |
!collectedFrom.equals(ClaimUtils.CROSSREF) && |
225 | 226 |
!collectedFrom.equals(ClaimUtils.ORCID)) { |
226 |
|
|
227 |
logger.error("CollectedFrom field of source and/or target is invalid. Value is:"+collectedFrom); |
|
227 | 228 |
throw new ClaimValidationException("CollectedFrom field of source and/or target is invalid. The allowed " + |
228 | 229 |
"types are: " + ClaimUtils.OPENAIRE + ", " + ClaimUtils.DATACITE |
229 | 230 |
+ ", " + ClaimUtils.CROSSREF + ", " + ClaimUtils.ORCID +"."); |
230 | 231 |
|
232 |
|
|
231 | 233 |
} |
232 | 234 |
|
233 | 235 |
return true; |
Also available in: Unified diff
Use different API for Datacite that returns json