Skip to content

Commit

Permalink
Remote Job API and DSV export fixes (#207)
Browse files Browse the repository at this point in the history
* [core] return IStatus specified by the request where applicable
* [dsv] propagate exception when dsv export request doesn't succeed
  • Loading branch information
AAAlinaaa authored and cmark committed Mar 2, 2018
1 parent 56ec475 commit cfdcbac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.jobs.Job;

import com.b2international.commons.status.Statuses;
Expand All @@ -38,6 +39,7 @@
*/
public final class RemoteJob extends Job {

public static final QualifiedName REQUEST_STATUS = new QualifiedName(null, "requestStatus");
private final String id;
private final ServiceProvider context;
private final Request<ServiceProvider, ?> request;
Expand Down Expand Up @@ -77,7 +79,9 @@ protected final IStatus run(IProgressMonitor monitor) {
this.response = mapper.writeValueAsString(response);
}
}
return (response instanceof IStatus) ? (IStatus) response : Statuses.ok();

IStatus status = (IStatus) getProperty(REQUEST_STATUS);
return (status != null) ? status : Statuses.ok();
} catch (OperationCanceledException e) {
return Statuses.cancel();
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.File;
import java.io.FileInputStream;
import java.rmi.server.ExportException;
import java.util.List;
import java.util.UUID;

Expand Down Expand Up @@ -85,11 +86,14 @@ public UUID execute(BranchContext context) {

private File doExport(SnomedRefSetDSVExportModel exportModel) throws Exception {
SnomedRefSetDSVExportClientRequest dsvRequest = new SnomedRefSetDSVExportClientRequest(SnomedClientProtocol.getInstance(), exportModel);
File exportFile = dsvRequest.send(new Monitor());

File exportFile = dsvRequest.send(new Monitor());
SnomedExportResult result = dsvRequest.getExportResult();
exportModel.getExportResult().setResultAndMessage(result.getResult(), result.getMessage());
if (result.getResult().equals(SnomedExportResult.Result.CANCELED) || result.getResult().equals(SnomedExportResult.Result.EXCEPTION)) {
throw new ExportException(result.getMessage());
}

exportModel.getExportResult().setResultAndMessage(result.getResult(), result.getMessage());
return exportFile;
}

Expand Down

0 comments on commit cfdcbac

Please sign in to comment.