deleted records
This commit is contained in:
parent
367983cb6b
commit
1e48360693
|
@ -182,11 +182,13 @@ public class OaiServerController {
|
|||
private void insertSingleRecord(final Element parentNode, final OaiRecord record) {
|
||||
final Element recordNode = parentNode.addElement("record");
|
||||
insertRecordHeader(recordNode, record);
|
||||
try {
|
||||
final Document doc2 = DocumentHelper.parseText(record.getBody());
|
||||
recordNode.addElement("metadata").add(doc2.getRootElement());
|
||||
} catch (final DocumentException e) {
|
||||
log.warn("Error parsing record: " + record.getBody());
|
||||
if (!record.isDeleted()) {
|
||||
try {
|
||||
final Document doc2 = DocumentHelper.parseText(record.getBody());
|
||||
recordNode.addElement("metadata").add(doc2.getRootElement());
|
||||
} catch (final DocumentException e) {
|
||||
log.warn("Error parsing record: " + record.getBody());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,6 +223,7 @@ public class OaiServerController {
|
|||
|
||||
private void insertRecordHeader(final Element parentNode, final OaiRecord r) {
|
||||
final Element headerNode = parentNode.addElement("header");
|
||||
|
||||
headerNode.addElement("identifier").setText(r.getId());
|
||||
headerNode.addElement("datestamp").setText(DateUtils.calculate_ISO8601(r.getDate()));
|
||||
if (r.getOaiSets() != null) {
|
||||
|
@ -228,6 +231,10 @@ public class OaiServerController {
|
|||
headerNode.addElement("setSpec").setText(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (r.isDeleted()) {
|
||||
headerNode.addAttribute("status", "deleted");
|
||||
}
|
||||
}
|
||||
|
||||
private void insertResumptionToken(final Element parentNode, final OaiPage page) {
|
||||
|
|
|
@ -124,11 +124,18 @@ public class OaiService {
|
|||
private RowMapper<OaiRecord> rowMapper(final String metadataPrefix) {
|
||||
final Function<String, String> mapper = prepareXsltMapper(metadataPrefix);
|
||||
return (rs, rowNum) -> {
|
||||
final String xml = GzipUtils.decompress(rs.getBytes("body"));
|
||||
|
||||
final OaiRecord r = new OaiRecord();
|
||||
r.setId(rs.getString("id"));
|
||||
r.setBody(mapper != null ? mapper.apply(xml) : xml);
|
||||
|
||||
final byte[] bb = rs.getBytes("body");
|
||||
if (bb != null && bb.length > 0) {
|
||||
final String xml = GzipUtils.decompress(bb);
|
||||
if (StringUtils.isNotBlank(xml)) {
|
||||
r.setBody(mapper != null ? mapper.apply(xml) : xml);
|
||||
}
|
||||
}
|
||||
|
||||
r.setDate(Instant.ofEpochMilli(rs.getLong("date"))
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime());
|
||||
|
|
|
@ -3,6 +3,8 @@ package eu.dnetlib.apps.oai.domain;
|
|||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class OaiRecord implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8383104201424481929L;
|
||||
|
@ -48,6 +50,6 @@ public class OaiRecord implements Serializable {
|
|||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return false;
|
||||
return StringUtils.isBlank(body);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue