* @return A process result's object.
*/
public static FlowResult processSetupCollectionHarvesting(Context context, int collectionID, Request request) throws SQLException, IOException, AuthorizeException
{
FlowResult result = new FlowResult();
HarvestedCollection hc = HarvestedCollection.find(context, collectionID);
String contentSource = request.getParameter("source");
// First, if this is not a harvested collection (anymore), set the harvest type to 0; possibly also wipe harvest settings
if (contentSource.equals("source_normal"))
{
if (hc != null)
hc.delete();
result.setContinue(true);
}
else
{
FlowResult subResult = testOAISettings(context, request);
// create a new harvest instance if all the settings check out
if (hc == null) {
hc = HarvestedCollection.create(context, collectionID);
}
// if the supplied options all check out, set the harvesting parameters on the collection
if (subResult.getErrors().isEmpty()) {
String oaiProvider = request.getParameter("oai_provider");
boolean oaiAllSets = "all".equals(request.getParameter("oai-set-setting"));
String oaiSetId;
if(oaiAllSets)
oaiSetId = "all";
else
oaiSetId = request.getParameter("oai_setid");
String metadataKey = request.getParameter("metadata_format");
String harvestType = request.getParameter("harvest_level");
hc.setHarvestParams(Integer.parseInt(harvestType), oaiProvider, oaiSetId, metadataKey);
hc.setHarvestStatus(HarvestedCollection.STATUS_READY);
}
else {
result.setErrors(subResult.getErrors());
result.setContinue(false);
return result;
}
hc.update();
}
// Save everything
context.commit();