use of cz.mzk.recordmanager.server.util.identifier.NoDataException in project RecordManager2 by moravianlibrary.
the class MetadataDublinCoreRecord method getISBNs.
/**
* go through all identifiers, look for isbn:.*, validate isbn
*
* @return list of {@link Isbn}
*/
@Override
public List<Isbn> getISBNs() {
List<Isbn> isbns = new ArrayList<>();
Matcher matcher;
Long isbnCounter = 0L;
for (String identifier : dcRecord.getIdentifiers()) {
String rawIsbnStr = "";
if ((matcher = DC_ISBN_PATTERN.matcher(identifier)).find())
rawIsbnStr = matcher.group(1);
else if (!DC_IDENTIFIER_PATTERN.matcher(identifier).matches())
rawIsbnStr = identifier;
Long isbnLong;
try {
isbnLong = ISBNUtils.toISBN13LongThrowing(rawIsbnStr);
} catch (NoDataException nde) {
continue;
} catch (NumberFormatException nfe) {
logger.info(String.format("Invalid ISBN: %s", rawIsbnStr));
continue;
}
isbns.add(Isbn.create(isbnLong, ++isbnCounter, ""));
}
return isbns;
}
use of cz.mzk.recordmanager.server.util.identifier.NoDataException in project RecordManager2 by moravianlibrary.
the class MetadataDublinCoreRecord method getISSNs.
@Override
public List<Issn> getISSNs() {
List<Issn> results = new ArrayList<>();
Long issnCounter = 0L;
Matcher matcher;
for (String identifier : dcRecord.getIdentifiers()) {
String rawIssnStr = "";
if ((matcher = DC_ISSN_PATTERN.matcher(identifier)).find())
rawIssnStr = matcher.group(1);
else if (!DC_IDENTIFIER_PATTERN.matcher(identifier).matches())
rawIssnStr = identifier;
String validIssn;
try {
validIssn = ISSNUtils.getValidIssnThrowing(rawIssnStr);
} catch (NoDataException nde) {
continue;
} catch (NumberFormatException nfe) {
logger.info(String.format("Invalid ISSN: %s", rawIssnStr));
continue;
}
results.add(Issn.create(validIssn, ++issnCounter, ""));
}
return results;
}
Aggregations