317 |
317 |
* Update an existed document. First, remove the index of the old one. Second,
|
318 |
318 |
* insert the new document
|
319 |
319 |
* @param newPid the new id of the document
|
|
320 |
* @param obsoleteIds the chain of the obsoletes by this id
|
320 |
321 |
* @param systemMetadata the system metadata associated with the data object
|
321 |
322 |
* @param data the data object itself
|
322 |
323 |
* @throws SolrServerException
|
323 |
324 |
* @throws JiBXException
|
324 |
325 |
*/
|
325 |
|
public void update(String newPid, SystemMetadata systemMetadata, InputStream data)
|
|
326 |
public void update(String newPid, List<String> obsoleteIds, SystemMetadata systemMetadata, InputStream data)
|
326 |
327 |
throws IOException, SAXException, ParserConfigurationException,
|
327 |
328 |
XPathExpressionException, SolrServerException, JiBXException {
|
328 |
329 |
checkParams(newPid, systemMetadata, data);
|
329 |
330 |
Identifier oldIdentifier = systemMetadata.getObsoletes();
|
330 |
331 |
if(oldIdentifier == null) {
|
331 |
332 |
throw new SolrServerException("The system metadata of the new document doesn't have the obsoletes element in the update operation.");
|
|
333 |
}
|
|
334 |
|
|
335 |
if(obsoleteIds == null || obsoleteIds.isEmpty()) {
|
|
336 |
throw new SolrServerException("The obsoletes chain can't be null in the update operation.");
|
332 |
337 |
}
|
333 |
|
String oldIdStr = oldIdentifier.getValue();
|
334 |
|
remove(oldIdStr);
|
|
338 |
if(!obsoleteIds.contains(oldIdentifier.getValue())) {
|
|
339 |
throw new SolrServerException("The obsoletes elment in thesystem metadata is not in the obsoleteIds list in the update operation.");
|
|
340 |
}
|
|
341 |
remove(obsoleteIds);
|
335 |
342 |
insert(newPid, systemMetadata, data);
|
336 |
343 |
}
|
|
344 |
|
|
345 |
/**
|
|
346 |
* Remove all the indexes associated with the pids in the list.
|
|
347 |
* @param pidList
|
|
348 |
* @throws IOException
|
|
349 |
* @throws SolrServerException
|
|
350 |
*/
|
|
351 |
public void remove(List<String> pidList) throws IOException, SolrServerException {
|
|
352 |
if(pidList != null) {
|
|
353 |
for(String id : pidList) {
|
|
354 |
remove(id);
|
|
355 |
}
|
|
356 |
}
|
|
357 |
}
|
337 |
358 |
|
338 |
359 |
/**
|
339 |
360 |
* Remove the indexed associated with specified pid.
|
Add a remove(List) method in the class and an obsoletes list parameter in the update method.