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

mcutout: besides results/mcutout.tar.gz adds publish of results/Report endpoint [in json]

parent 6fcd837e
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,16 @@ class MCutResult ...@@ -30,6 +30,16 @@ class MCutResult
cutFile.delete(); cutFile.delete();
} }
} }
}
void deleteResJson()
{
if(resJsonPathname != null)
{
File resJson = new File(resJsonPathname);
resJson.delete();
}
} }
public void deleteCutFiles() public void deleteCutFiles()
...@@ -41,6 +51,7 @@ class MCutResult ...@@ -41,6 +51,7 @@ class MCutResult
} }
public String fileName; public String fileName;
public String resJsonPathname;
public long fileSize; public long fileSize;
Cut[] cutResArr; Cut[] cutResArr;
} }
......
...@@ -313,6 +313,7 @@ class VlkbCli implements Vlkb ...@@ -313,6 +313,7 @@ class VlkbCli implements Vlkb
MCutResult mCutResult = new MCutResult(); MCutResult mCutResult = new MCutResult();
mCutResult.cutResArr = cutArr; mCutResult.cutResArr = cutArr;
mCutResult.fileName = tgzFileName; mCutResult.fileName = tgzFileName;
mCutResult.resJsonPathname = respJsonPathname;
mCutResult.fileSize = Files.size(output); mCutResult.fileSize = Files.size(output);
return mCutResult; return mCutResult;
......
...@@ -66,8 +66,6 @@ public class UWSMCutoutWork extends JobThread ...@@ -66,8 +66,6 @@ public class UWSMCutoutWork extends JobThread
long startTime_msec = System.currentTimeMillis(); long startTime_msec = System.currentTimeMillis();
boolean showDuration = true; boolean showDuration = true;
/* UWS -> SODA (JDL in POST body is part of SODA REC) */
UploadFile jsonFile = (UploadFile)job.getAdditionalParameterValue("mcutout"); UploadFile jsonFile = (UploadFile)job.getAdditionalParameterValue("mcutout");
InputStreamReader isr = new InputStreamReader(jsonFile.open()); InputStreamReader isr = new InputStreamReader(jsonFile.open());
...@@ -80,45 +78,27 @@ public class UWSMCutoutWork extends JobThread ...@@ -80,45 +78,27 @@ public class UWSMCutoutWork extends JobThread
} }
String reqJsonString = jsonStringBuffer.toString(); String reqJsonString = jsonStringBuffer.toString();
/* SODA -> Implementation */
MCutResult mresult = vlkb.doMCutout(reqJsonString); MCutResult mresult = vlkb.doMCutout(reqJsonString);
/* Implement -> SODA */ logger.logThread(LogLevel.INFO, this, "Prepare Result",
" job:requestUrl: " + job.getUrl().getRequestURL(), null);
final String contentType = "application/gzip";// FIXME force stream output
if(contentType.equals("text/xml") || contentType.equals("application/xml")) // publish Report
{
logger.logThread(LogLevel.INFO, this,
"Prepare Result", "content type:" + contentType, null);
Result result = createResult("Report");
result.setMimeType("text/xml");
OutputStream respOutputStream = getResultOutput(result);
final String RESPONSE_ENCODING = "utf-8";
PrintWriter writer = new PrintWriter(new OutputStreamWriter(respOutputStream, RESPONSE_ENCODING)); Result resultRes = new Result("Report", "none", null, false);
resultRes.setMimeType("application/json");
OutputStream respResOutputStream = getResultOutput(resultRes);
String accessUrl = convertLocalPathnameToRemoteUrl(mresult.fileName, String absResPathname = mresult.resJsonPathname;
settings.fitsPaths.cutouts(), File downloadResFile = new File(absResPathname);
settings.fitsPaths.cutoutsUrl()); FileInputStream fileResInput = new FileInputStream(downloadResFile);
XmlSerializer.serializeToLegacyCutResult(writer, RESPONSE_ENCODING, fileResInput.transferTo(respResOutputStream);
mresult, accessUrl, publishResult(resultRes);
//id, pos, band, time, pol, pixels, countNullValues,
showDuration, startTime_msec);
writer.close(); downloadResFile.delete();
/* SODA -> UWS */ // publish mcutout.tar.gz
publishResult(result);
}
else if(contentType.equals("application/gzip") || contentType.equals("application/x-tar+gzip"))
{
logger.logThread(LogLevel.INFO, this,
"Prepare Result", "content type:" + contentType + " job:requestUrl: " + job.getUrl().getRequestURL(), null);
final String id = "mcutout.tar.gz"; final String id = "mcutout.tar.gz";
Result result = new Result(id, "none", null, false); Result result = new Result(id, "none", null, false);
...@@ -130,16 +110,15 @@ public class UWSMCutoutWork extends JobThread ...@@ -130,16 +110,15 @@ public class UWSMCutoutWork extends JobThread
FileInputStream fileInput = new FileInputStream(downloadFile); FileInputStream fileInput = new FileInputStream(downloadFile);
fileInput.transferTo(respOutputStream); fileInput.transferTo(respOutputStream);
publishResult(result);
downloadFile.delete(); downloadFile.delete();
// delete cut-files (were published/copied to uws-file store)
mresult.deleteResJson();
mresult.deleteCutFiles(); mresult.deleteCutFiles();
publishResult(result);
}
else
{
throw new AssertionError("Unsupported contentType for output: " + contentType);
}
/* FIXME here was uws-check is-job-Interrupted */ /* FIXME here was uws-check is-job-Interrupted */
} }
...@@ -150,16 +129,4 @@ public class UWSMCutoutWork extends JobThread ...@@ -150,16 +129,4 @@ public class UWSMCutoutWork extends JobThread
} }
} }
private String convertLocalPathnameToRemoteUrl(String localPathname,
String FITScutpath, String FITSRemoteUrlCutouts)
{
//LOGGER.fine("trace " + localPathname);
String fileName = localPathname.replaceAll(FITScutpath + "/", "");
//LOGGER.finer("local filename: " + fileName);
String remotefname = FITSRemoteUrlCutouts + "/" + fileName;
//LOGGER.finer("remote url : " + remotefname);
return remotefname;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment