Package com.enioka.jqm.jpamodel

Examples of com.enioka.jqm.jpamodel.Deliverable


    @Override
    public InputStream getDeliverableContent(com.enioka.jqm.api.Deliverable d)
    {
        EntityManager em = null;
        Deliverable deliverable = null;

        try
        {
            em = getEm();
            deliverable = em.find(Deliverable.class, d.getId());
View Full Code Here


        return i;
    }

    private Integer addDeliverable(String path, String fileLabel) throws IOException
    {
        Deliverable d = null;
        EntityManager em = Helpers.getNewEm();
        try
        {
            this.ji = em.find(JobInstance.class, ji.getId());

            String outputRoot = this.ji.getNode().getDlRepo();
            String ext = FilenameUtils.getExtension(path);
            String destPath = FilenameUtils.concat(outputRoot,
                    "" + ji.getJd().getApplicationName() + "/" + ji.getId() + "/" + UUID.randomUUID() + "." + ext);
            String fileName = FilenameUtils.getName(path);
            FileUtils.moveFile(new File(path), new File(destPath));
            jqmlogger.debug("A deliverable is added. Stored as " + destPath + ". Initial name: " + fileName);

            em.getTransaction().begin();
            d = Helpers.createDeliverable(destPath, fileName, fileLabel, this.ji.getId(), em);
            em.getTransaction().commit();
        }
        finally
        {
            em.close();
        }
        return d.getId();
    }
View Full Code Here

     *            the EM to use.
     * @return
     */
    static Deliverable createDeliverable(String path, String originalFileName, String fileFamily, Integer jobId, EntityManager em)
    {
        Deliverable j = new Deliverable();

        j.setFilePath(path);
        j.setRandomId(UUID.randomUUID().toString());
        j.setFileFamily(fileFamily);
        j.setJobId(jobId);
        j.setOriginalFileName(originalFileName);

        em.persist(j);
        return j;
    }
View Full Code Here

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    {
        String fileRandomId = request.getParameter("file");
        FileInputStream fis = null;
        OutputStream out = null;
        Deliverable d = null;
        EntityManager em = null;
        try
        {
            em = Helpers.getNewEm();
            d = em.createQuery("SELECT d from Deliverable d WHERE d.randomId = :ii", Deliverable.class).setParameter("ii", fileRandomId)
                    .getSingleResult();
        }
        catch (Exception e)
        {
            jqmlogger.info("A request for an unexisting file was received", e);
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            return;
        }
        finally
        {
            if (em != null)
            {
                em.close();
            }
        }
        File f = new File(d.getFilePath());
        jqmlogger.trace("A file will be returned: " + f.getAbsolutePath());

        try
        {
            out = response.getOutputStream();
View Full Code Here

TOP

Related Classes of com.enioka.jqm.jpamodel.Deliverable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.