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,22 +27,34 @@ class ResolverFromId implements Resolver
{
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)
{
LOGGER.finer("isIvoid");
resolveIvoid(pubdid);
// 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 if(isDav)
{
LOGGER.finer("isDav");
resolveDav(pubdid);
}
else if(isFile)
{
LOGGER.finer("isFile");
resolveFile(pubdid);
}
else
{
throw new IllegalArgumentException("IVOID expected: ID must start with 'ivo://' but received: " + pubdid);
}
LOGGER.finer("relPathname : " + relPathname);
LOGGER.finer("hdunum : " + String.valueOf(hdunum));
LOGGER.finer("subsurveyId : " + ((subsurveyId == null) ? "null" : this.subsurveyId) );
}
......@@ -74,5 +86,57 @@ class ResolverFromId implements Resolver
}
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
boolean pixels_valid = (pixels != null);
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 )
{
......@@ -116,7 +122,7 @@ class SodaImpl implements Soda
String[] cmdCut = new String[5];
cmdCut[0] = "/usr/local/bin/vlkb";
cmdCut[1] = "imcopy";
cmdCut[1] = isDavCall ? "imcopydav" : "imcopy";
cmdCut[2] = absPathname;
cmdCut[3] = String.valueOf(hdunum-1);
cmdCut[4] = pixFilterString;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment