/** * @param <T> * @param worker * @param url * @return some object from the url * @throws MalformedURLException * @throws IOException */ public static <T> T retrieve( Worker<T> worker, String url ) throws MalformedURLException, IOException { return retrieve( worker, new DURL( url ) ); }
/** * Performs an HTTP-Get request and provides typed access to the response. * * @param <T> * @param worker * @param url * @param postBody * @param headers * may be null * @return some object from the url * @throws IOException */ public static <T> T post( Worker<T> worker, String url, InputStream postBody, Map<String, String> headers ) throws IOException { DURL u = new DURL( url ); DefaultHttpClient client = enableProxyUsage( new DefaultHttpClient(), u ); HttpPost post = new HttpPost( url ); post.setEntity( new InputStreamEntity( postBody, -1 ) ); if ( headers != null ) { for ( String key : headers.keySet() ) { post.addHeader( key, headers.get( key ) ); } } return worker.work( client.execute( post ).getEntity().getContent() ); }
if ( schemaFile != null ) { try { StreamSource origSchema = new StreamSource( new DURL( schemaFile.toExternalForm() ).openStream(), schemaFile.toExternalForm() ); URL descUrl = JAXBUtils.class.getResource( "/META-INF/schemas/commons/description/3.4.0/description.xsd" ); URL spatUrl = JAXBUtils.class.getResource( "/META-INF/schemas/commons/spatialmetadata/3.4.0/spatialmetadata.xsd" ); URL layUrl = JAXBUtils.class.getResource( "/META-INF/schemas/layers/base/3.4.0/base.xsd" ); StreamSource desc = new StreamSource( new DURL( descUrl.toExternalForm() ).openStream(), descUrl.toExternalForm() ); List<Source> list = new ArrayList<Source>(); list.add( desc ); if ( spatUrl != null ) { StreamSource spat = new StreamSource( new DURL( spatUrl.toExternalForm() ).openStream(), spatUrl.toExternalForm() ); list.add( spat ); StreamSource lay = new StreamSource( new DURL( layUrl.toExternalForm() ).openStream(), layUrl.toExternalForm() ); list.add( lay );
final int readTimeout ) throws IOException { DURL u = new DURL( url ); LOG.debug( "Sending HTTP POST against {}", url ); DefaultHttpClient client = enableProxyUsage( new DefaultHttpClient(), u );
Map<String, String> headers, final int readTimeout ) throws IOException { DURL u = new DURL( url ); LOG.debug( "Sending HTTP POST against {}", url ); DefaultHttpClient client = enableProxyUsage( new DefaultHttpClient(), u );
String pass ) throws IOException { DURL u = new DURL( url ); DefaultHttpClient client = enableProxyUsage( new DefaultHttpClient(), u ); HttpPost post = new HttpPost( url );
String user, String pass ) throws IOException { DURL u = new DURL( url ); if ( !u.valid() ) { return null;
public static <T> Pair<T, HttpResponse> getFullResponse( Worker<T> worker, String url, Map<String, String> headers, String user, String pass, final int readTimeout ) throws IOException { DURL u = new DURL( url ); if ( !u.valid() ) { return null; } DefaultHttpClient client = enableProxyUsage( new DefaultHttpClient(), u ); client.setKeepAliveStrategy( new DefaultConnectionKeepAliveStrategy() { @Override public long getKeepAliveDuration( HttpResponse response, HttpContext context ) { long keepAlive = super.getKeepAliveDuration( response, context ); if ( keepAlive == -1 ) { keepAlive = readTimeout * 1000; } return keepAlive; } } ); if ( user != null && pass != null ) { authenticate( client, user, pass, u ); } HttpGet get = new HttpGet( url ); if ( headers != null ) { for ( String key : headers.keySet() ) { get.addHeader( key, headers.get( key ) ); } } HttpResponse response = client.execute( get ); return new Pair<T, HttpResponse>( worker.work( response.getEntity().getContent() ), response ); }
new DURL( mdurl.toExternalForm() ).openStream(), workspace ) ).getValue() ); setMainConfig( (DeegreeServiceControllerType) ( (JAXBElement<?>) JAXBUtils.unmarshall( CONTROLLER_JAXB_PACKAGE, CONTROLLER_CONFIG_SCHEMA, new DURL( main.toURI().toURL().toExternalForm() ).openStream(), workspace ) ).getValue() );
DURL u = new DURL( url ); if ( !u.valid() ) { return null;
DeegreeCRSStoreConfig config = (DeegreeCRSStoreConfig) unmarshall( CONFIG_JAXB_PACKAGE, CONFIG_SCHEMA, new DURL( configURL.toExternalForm() ).openStream(), workspace ); XMLAdapter adapter = new XMLAdapter();
@Override public CRSStore getCRSStore( URL configURL, Workspace workspace ) throws CRSStoreException { try { PROJ4CRSStoreConfig config = (PROJ4CRSStoreConfig) unmarshall( CONFIG_JAXB_PACKAGE, CONFIG_SCHEMA, new DURL( configURL.toExternalForm() ).openStream(), workspace ); PROJ4CRSStore crsStore = new PROJ4CRSStore( DSTransform.fromSchema( config ) ); ProjFileResource resource = null; XMLAdapter adapter = new XMLAdapter( configURL ); URL fileUrl = adapter.resolve( config.getFile() ); resource = new ProjFileResource( new File( fileUrl.toExternalForm() ) ); crsStore.setResolver( resource ); return crsStore; } catch ( JAXBException e ) { String msg = "Error in proj4 crs store configuration file '" + configURL + "': " + e.getMessage(); LOG.error( msg ); throw new CRSStoreException( msg, e ); } catch ( Exception e ) { String msg = "Error in file declaraition inproj4 crs store configuration file '" + configURL + "': " + e.getMessage(); LOG.error( msg ); throw new CRSStoreException( msg, e ); } }
GMLCRSStoreConfig config = (GMLCRSStoreConfig) unmarshall( CONFIG_JAXB_PACKAGE, CONFIG_SCHEMA, new DURL( configURL.toExternalForm() ).openStream(), workspace );