public Record getRecord(String identifier, String metadataPrefix)
throws CannotDisseminateFormatException, IDDoesNotExistException,
RepositoryException {
if (!metadataPrefix.equals("oai_dc")) {
throw new CannotDisseminateFormatException("Repository does not provide that format in OAI-PMH responses.");
}
String pid = getPID(identifier);
List l = null;
try {
//FIXME: use maxResults from... config instead of hardcoding 100?
l =
m_fieldSearch
.findObjects(s_headerAndDCFields,
100,
new FieldSearchQuery(Condition
.getConditions("pid='"
+ pid
+ "' dcmDate>'2000-01-01'")))
.objectFieldsList();
} catch (ServerException se) {
throw new RepositoryException(se.getClass().getName() + ": "
+ se.getMessage());
}
if (l.size() > 0) {
ObjectFields f = (ObjectFields) l.get(0);
return new SimpleRecord(getHeader(f), getDCXML(f), s_emptySet);
} else {
// see if it exists
try {
l =
m_fieldSearch
.findObjects(new String[] {"pid"},
1,
new FieldSearchQuery(Condition
.getConditions("pid='"
+ pid + "'")))
.objectFieldsList();
} catch (ServerException se) {
throw new RepositoryException(se.getClass().getName() + ": "
+ se.getMessage());
}
if (l.size() == 0) {
throw new IDDoesNotExistException("The provided id does not match any item in the repository.");
} else {
throw new CannotDisseminateFormatException("The item doesn't even have dc_oai metadata.");
}
}
}