Skip to content
Snippets Groups Projects
Commit f67a5012 authored by Robert Butora's avatar Robert Butora
Browse files

resolver: adds support for HTTP-dav (http:// https://) and files (file://)

parent a3330a6e
No related branches found
No related tags found
No related merge requests found
...@@ -27,52 +27,116 @@ class ResolverFromId implements Resolver ...@@ -27,52 +27,116 @@ class ResolverFromId implements Resolver
{ {
LOGGER.fine("trace " + pubdid); LOGGER.fine("trace " + pubdid);
boolean isIvoid = pubdid.substring(0,6).equals("ivo://"); final boolean isIvoid = pubdid.substring(0,6).equals("ivo://");
final boolean isDav = pubdid.startsWith("http://") || pubdid.startsWith("https://");
final boolean isFile = pubdid.startsWith("file://");
if(isIvoid) if(isIvoid)
{ {
LOGGER.finer("isIvoid");
resolveIvoid(pubdid); resolveIvoid(pubdid);
// FIXME resolve subsurveyId by matching relPathname to subsurveys::storage-path & file-filter // FIXME resolve subsurveyId by matching relPathname to subsurveys::storage-path & file-filter
LOGGER.finer("relPathname : " + relPathname);
LOGGER.finer("hdunum : " + String.valueOf(hdunum));
LOGGER.finer("subsurveyId : " + ((subsurveyId == null) ? "null" : this.subsurveyId) );
} }
else else if(isDav)
{ {
throw new IllegalArgumentException("IVOID expected: ID must start with 'ivo://' but received: " + pubdid); LOGGER.finer("isDav");
resolveDav(pubdid);
} }
} else if(isFile)
private void resolveIvoid(String pubdid)
{
LOGGER.fine("trace " + pubdid);
int qmarkIx = pubdid.lastIndexOf("?");
int dhashIx = pubdid.lastIndexOf("#");// returns -1 if hash not found
boolean hash_not_found = (dhashIx < 0);
if(hash_not_found)
{ {
relPathname = pubdid.substring( qmarkIx + 1 ); LOGGER.finer("isFile");
hdunum = 1; resolveFile(pubdid);
} }
else else
{ {
relPathname = pubdid.substring( qmarkIx + 1, dhashIx ); throw new IllegalArgumentException("IVOID expected: ID must start with 'ivo://' but received: " + pubdid);
}
if((dhashIx+1) == pubdid.length())
throw new IllegalArgumentException( LOGGER.finer("relPathname : " + relPathname);
"if ID's last hash must be followed by HDU extension number however: " + pubdid); LOGGER.finer("hdunum : " + String.valueOf(hdunum));
else LOGGER.finer("subsurveyId : " + ((subsurveyId == null) ? "null" : this.subsurveyId) );
hdunum = 1 + Integer.parseInt( pubdid.substring( dhashIx + 1 ) ); }
}
}
private void resolveIvoid(String pubdid)
{
LOGGER.fine("trace " + pubdid);
int qmarkIx = pubdid.lastIndexOf("?");
int dhashIx = pubdid.lastIndexOf("#");// returns -1 if hash not found
boolean hash_not_found = (dhashIx < 0);
if(hash_not_found)
{
relPathname = pubdid.substring( qmarkIx + 1 );
hdunum = 1;
}
else
{
relPathname = pubdid.substring( qmarkIx + 1, dhashIx );
if((dhashIx+1) == pubdid.length())
throw new IllegalArgumentException(
"if ID's last hash must be followed by HDU extension number however: " + pubdid);
else
hdunum = 1 + Integer.parseInt( pubdid.substring( dhashIx + 1 ) );
}
}
private void resolveDav(String pubdid)
{
LOGGER.fine("trace " + pubdid);
int dhashIx = pubdid.lastIndexOf("#");// returns -1 if hash not found
boolean hash_not_found = (dhashIx < 0);
if(hash_not_found)
{
relPathname = pubdid;
hdunum = 1;
}
else
{
relPathname = pubdid.substring( 0, dhashIx );
if((dhashIx+1) == pubdid.length())
throw new IllegalArgumentException(
"if ID's last hash must be followed by HDU extension number however: " + pubdid);
else
hdunum = 1 + Integer.parseInt( pubdid.substring( dhashIx + 1 ) );
}
}
private void resolveFile(String pubdid)
{
LOGGER.fine("trace " + pubdid);
int slashIx = pubdid.indexOf("/"); // first slash in ://
int dhashIx = pubdid.lastIndexOf("#");// returns -1 if hash not found
boolean hash_not_found = (dhashIx < 0);
if(hash_not_found)
{
relPathname = pubdid.substring( slashIx+2, dhashIx );
hdunum = 1;
}
else
{
relPathname = pubdid.substring( slashIx+2, dhashIx );
if((dhashIx+1) == pubdid.length())
throw new IllegalArgumentException(
"if ID's last hash must be followed by HDU extension number however: " + pubdid);
else
hdunum = 1 + Integer.parseInt( pubdid.substring( dhashIx + 1 ) );
}
}
} }
...@@ -55,7 +55,13 @@ class SodaImpl implements Soda ...@@ -55,7 +55,13 @@ class SodaImpl implements Soda
boolean pixels_valid = (pixels != null); boolean pixels_valid = (pixels != null);
String boundsString = ""; String boundsString = "";
String absPathname = fitsPaths.surveys() + "/" + relPathname;
final boolean isDavCall = relPathname.startsWith("http://") || relPathname.startsWith("https://");
final boolean isAbsPath = relPathname.startsWith("/"); // Resolver removes schema from file://
// file:///some_abs_path -> /soma_abs_path
// file://some_rel_path -> some_rel_path
String absPathname = (isDavCall || isAbsPath) ? relPathname : (fitsPaths.surveys() +"/"+ relPathname);
if( !pixels_valid ) if( !pixels_valid )
{ {
...@@ -116,7 +122,7 @@ class SodaImpl implements Soda ...@@ -116,7 +122,7 @@ class SodaImpl implements Soda
String[] cmdCut = new String[5]; String[] cmdCut = new String[5];
cmdCut[0] = "/usr/local/bin/vlkb"; cmdCut[0] = "/usr/local/bin/vlkb";
cmdCut[1] = "imcopy"; cmdCut[1] = isDavCall ? "imcopydav" : "imcopy";
cmdCut[2] = absPathname; cmdCut[2] = absPathname;
cmdCut[3] = String.valueOf(hdunum-1); cmdCut[3] = String.valueOf(hdunum-1);
cmdCut[4] = pixFilterString; cmdCut[4] = pixFilterString;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment