/** * Version of {@link JqmClient#getDeliverableContent(Deliverable)} which does not require the web service APIs to be enabled to work. * Also, returned files do not self-destruct on stream close.<br> * See the javadoc of the original method for details. * * @throws FileNotFoundException */ public InputStream getDeliverableContent(Deliverable file) throws FileNotFoundException { List<com.enioka.jqm.model.Deliverable> dd = com.enioka.jqm.model.Deliverable.select(cnx, "deliverable_select_by_id", file.getId()); if (dd.isEmpty()) { throw new JqmInvalidRequestException("no deliverable with this ID"); } com.enioka.jqm.model.Deliverable d = dd.get(0); JobInstance ji = Query.create().setJobInstanceId(d.getJobId()).run().get(0); String nodeName = ji.getNodeName(); Node n = nodes.get(nodeName); return new FileInputStream(FilenameUtils.concat(n.getDlRepo(), file.getFilePath())); } }
@Override public InputStream getDeliverableContent(com.enioka.jqm.api.Deliverable d) { return getDeliverableContent(d.getId()); }
@Override public List<com.enioka.jqm.api.Deliverable> getJobDeliverables(int idJob) { DbConn cnx = null; try { cnx = getDbSession(); // TODO: no intermediate entity here: directly SQL => API object. List<Deliverable> deliverables = Deliverable.select(cnx, "deliverable_select_all_for_ji", idJob); List<com.enioka.jqm.api.Deliverable> res = new ArrayList<>(); for (Deliverable d : deliverables) { res.add(new com.enioka.jqm.api.Deliverable(d.getFilePath(), d.getFileFamily(), d.getId(), d.getOriginalFileName())); } return res; } catch (Exception e) { throw new JqmClientException("Could not query files for job instance " + idJob, e); } finally { closeQuietly(cnx); } }
Assert.assertEquals("test.txt", deliverables.get(0).getFileFamily());
/** * Version of {@link JqmClient#getDeliverableContent(Deliverable)} which does not require the web service APIs to be enabled to work. * Also, returned files do not self-destruct on stream close.<br> * See the javadoc of the original method for details. * * @throws FileNotFoundException */ public InputStream getDeliverableContent(Deliverable file) throws FileNotFoundException { List<com.enioka.jqm.model.Deliverable> dd = com.enioka.jqm.model.Deliverable.select(cnx, "deliverable_select_by_id", file.getId()); if (dd.isEmpty()) { throw new JqmInvalidRequestException("no deliverable with this ID"); } com.enioka.jqm.model.Deliverable d = dd.get(0); JobInstance ji = Query.create().setJobInstanceId(d.getJobId()).run().get(0); String nodeName = ji.getNodeName(); Node n = nodes.get(nodeName); return new FileInputStream(FilenameUtils.concat(n.getDlRepo(), file.getFilePath())); } }