static private ServiceType checkIfDap4 ( String location ) throws IOException { // Strip off any trailing DAP4 prefix if ( location . endsWith ( ".dap" ) ) location = location . substring ( 0 , location . length ( ) - ".dap" . length ( ) ) ; else if ( location . endsWith ( ".dmr" ) ) location = location . substring ( 0 , location . length ( ) - ".dmr" . length ( ) ) ; else if ( location . endsWith ( ".dmr.xml" ) ) location = location . substring ( 0 , location . length ( ) - ".dmr.xml" . length ( ) ) ; else if ( location . endsWith ( ".dsr" ) ) location = location . substring ( 0 , location . length ( ) - ".dsr" . length ( ) ) ; try ( HTTPMethod method = HTTPFactory . Get ( location + ".dmr.xml" ) ) { int status = method . execute ( ) ; if ( status == 200 ) { Header h = method . getResponseHeader ( "Content-Type" ) ; if ( ( h != null ) && ( h . getValue ( ) != null ) ) { String v = h . getValue ( ) ; if ( v . startsWith ( "application/vnd.opendap.org" ) ) return ServiceType . DAP4 ; } } if ( status == HttpStatus . SC_UNAUTHORIZED || status == HttpStatus . SC_FORBIDDEN ) throw new IOException ( "Unauthorized to open dataset " + location ) ; // not dods return null ; } }
check for dmr