|
39 | 39 | import omero.gateway.exception.DSAccessException; |
40 | 40 | import omero.gateway.exception.DSOutOfServiceException; |
41 | 41 | import omero.gateway.facility.ROIFacility; |
| 42 | +import omero.gateway.facility.TransferFacility; |
42 | 43 | import omero.gateway.model.ChannelData; |
43 | 44 | import omero.gateway.model.FolderData; |
44 | 45 | import omero.gateway.model.ImageData; |
|
52 | 53 | import java.awt.Color; |
53 | 54 | import java.awt.image.BufferedImage; |
54 | 55 | import java.io.ByteArrayInputStream; |
| 56 | +import java.io.File; |
55 | 57 | import java.io.IOException; |
56 | 58 | import java.sql.Timestamp; |
57 | 59 | import java.util.ArrayList; |
|
62 | 64 | import java.util.logging.Level; |
63 | 65 | import java.util.logging.Logger; |
64 | 66 |
|
65 | | -import static fr.igred.omero.exception.ExceptionHandler.handleServiceOrAccess; |
66 | | -import static fr.igred.omero.exception.ExceptionHandler.handleServiceOrServer; |
| 67 | +import static fr.igred.omero.exception.ExceptionHandler.*; |
67 | 68 | import static omero.rtypes.rint; |
68 | 69 |
|
69 | 70 |
|
@@ -572,4 +573,28 @@ public BufferedImage getThumbnail(Client client, int size) throws ServiceExcepti |
572 | 573 | return thumbnail; |
573 | 574 | } |
574 | 575 |
|
| 576 | + |
| 577 | + /** |
| 578 | + * Downloads the original files from the server. |
| 579 | + * |
| 580 | + * @param client The client handling the connection. |
| 581 | + * @param path Path to the file. |
| 582 | + * |
| 583 | + * @return See above. |
| 584 | + * |
| 585 | + * @throws OMEROServerError Server error. |
| 586 | + * @throws ServiceException Cannot connect to OMERO. |
| 587 | + * @throws AccessException Cannot access data. |
| 588 | + */ |
| 589 | + public List<File> download(Client client, String path) |
| 590 | + throws OMEROServerError, ServiceException, AccessException { |
| 591 | + try { |
| 592 | + TransferFacility transfer = client.getGateway().getFacility(TransferFacility.class); |
| 593 | + return transfer.downloadImage(client.getCtx(), path, getId()); |
| 594 | + } catch (DSAccessException | DSOutOfServiceException | ExecutionException e) { |
| 595 | + handleException(e, "Could not download image " + getId() + ": " + e.getMessage()); |
| 596 | + } |
| 597 | + return new ArrayList<>(); |
| 598 | + } |
| 599 | + |
575 | 600 | } |
0 commit comments