public InputStream execute (Parameters parameters) throws HttpException { try { HttpResponse response = httpclient.execute(createGetRequest(parameters)); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) return response.getEntity().getContent(); else throw new HttpException("Error querying service. Returned HTTP Status Code: "+response.getStatusLine().getStatusCode()); } catch (IOException e) { throw new HttpException(e); } }
public Identify handle () { try { return new IdentifyParser(client.execute(parameters() .withVerb(Identify))) .parse(); } catch (OAIRequestException e) { throw new InvalidOAIResponse(e); } } }
private ServiceProvider getServiceProvider() throws OaiHandlerException { if (serviceProvider == null) { if (baseOaiUrl == null) { throw new OaiHandlerException("Could not instantiate Service Provider, missing OAI server URL."); } Context context = new Context(); context.withBaseUrl(baseOaiUrl); context.withGranularity(Granularity.Second); context.withOAIClient(new HttpOAIClient(baseOaiUrl)); serviceProvider = new ServiceProvider(context); } return serviceProvider; }
public List<MetadataFormat> handle(ListMetadataParameters parameters) { List<MetadataFormat> result = new ArrayList<MetadataFormat>(); try { MetadataFormatParser parser = new MetadataFormatParser(client.execute(parameters() .withVerb(ListMetadataFormats) .include(parameters))); while (parser.hasNext()) result.add(parser.next()); return result; } catch (XmlReaderException e) { throw new InvalidOAIResponse(e); } catch (OAIRequestException e) { throw new InvalidOAIResponse(e); } } }
public Record handle(GetRecordParameters parameters) throws IdDoesNotExistException, CannotDisseminateFormatException { try { return new GetRecordParser(client.execute(parameters() .withVerb(GetRecord) .include(parameters)), context, parameters.getMetadataPrefix()).parse(); } catch (OAIRequestException e) { throw new InvalidOAIResponse(e); } } }