Package org.restlet.representation

Examples of org.restlet.representation.FileRepresentation


            // its already a restlet response, so dont do anything
            LOG.debug("Using existing Restlet Response from exchange body: {}", body);
        } else if (body instanceof InputStream) {
            response.setEntity(new InputRepresentation(out.getBody(InputStream.class), mediaType));
        } else if (body instanceof File) {
            response.setEntity(new FileRepresentation(out.getBody(File.class), mediaType));
        } else {
            // fallback and use string
            String text = out.getBody(String.class);
            response.setEntity(text, mediaType);
        }
View Full Code Here


            // its already a restlet response, so dont do anything
            LOG.debug("Using existing Restlet Response from exchange body: {}", body);
        } else if (body instanceof InputStream) {
            response.setEntity(new InputRepresentation(out.getBody(InputStream.class), mediaType));
        } else if (body instanceof File) {
            response.setEntity(new FileRepresentation(out.getBody(File.class), mediaType));
        } else {
            // fallback and use string
            String text = out.getBody(String.class);
            response.setEntity(text, mediaType);
        }
View Full Code Here

     
      fos.write(respImage.getImage());
     
      fos.close();
             
      FileRepresentation resp = new FileRepresentation(f, MediaType.IMAGE_ALL);
     
      return resp;
     
    }catch (ObjectRetrievalFailureException e) {
      getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
View Full Code Here

  public FileRepresentation getRepresentation(){   
    Integer id = RequestUtil.getInteger(getRequestAttributes().get("id"));
    String type = RequestUtil.getString(getRequestAttributes().get("type"));

    File respFile = null;
    FileRepresentation output = null;

    InputStream jasperFileStream = getClass().getResourceAsStream("/report/roreport.jasper");
    Map<String, Object> paramMap = new HashMap<String, Object>();
   
   
    List<ReceivingOrderDetail> list = coreManager.getReceivingOrderDetails(id);
   
    if(list.size() > 0){
      Integer storeId = list.get(0).getReceivingOrder().getPo().getDeliverStoreId();
      Store store = coreManager.get(Store.class, storeId);
      paramMap.put("storeName", store.getName());
      paramMap.put("storeAddress", store.getAddress());
      paramMap.put("storeCity", store.getCity());
    }
       
    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
   
    try {
      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperFileStream, paramMap, ds);
      if("pdf".equalsIgnoreCase(type)){
        respFile = File.createTempFile("sunflower_", ".pdf");
        JasperExportManager.exportReportToPdfFile(jasperPrint, respFile.getPath());
      }else{
        respFile = File.createTempFile("sunflower_", ".txt")
        jtextExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        jtextExporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new Float(10));
        jtextExporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, new Float(5.25));
        jtextExporter.setParameter(JRExporterParameter.OUTPUT_FILE, respFile);
        jtextExporter.exportReport();
      }
     
    } catch (Exception e) {
      e.printStackTrace();
    }finally{
      if(jasperFileStream != null){
        try {
          jasperFileStream.close();
        } catch (IOException e) {
        }
      }
    }

    if("pdf".equalsIgnoreCase(type)){
      output = new FileRepresentation(respFile, MediaType.APPLICATION_PDF);
    }else{
      output = new FileRepresentation(respFile, MediaType.TEXT_PLAIN);
    }
    return output;   
  }
View Full Code Here

  public FileRepresentation getRepresentation(){   
    Integer id = RequestUtil.getInteger(getRequestAttributes().get("id"));
    String type = RequestUtil.getString(getRequestAttributes().get("type"));

    File respFile = null;
    FileRepresentation output = null;

    InputStream jasperFileStream = getClass().getResourceAsStream("/report/returnreport.jasper");
    Map<String, Object> paramMap = new HashMap<String, Object>();
       
    List<ReturnToSupplierDetail> list = coreManager.getReturnToSupplierDetails(id);
   
/*    if(list.size() > 0){
      Integer storeId = list.get(0).getPurchasingOrder().getDeliverStoreId();
      Store store = coreManager.get(Store.class, storeId);
      paramMap.put("storeName", store.getName());
      paramMap.put("storeAddress", store.getAddress());
      paramMap.put("storeCity", store.getCity());
    }
*/       
    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
   
    try {
      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperFileStream, paramMap, ds);
      if("pdf".equalsIgnoreCase(type)){
        respFile = File.createTempFile("sunflower_", ".pdf");
        JasperExportManager.exportReportToPdfFile(jasperPrint, respFile.getPath());
      }else{
        respFile = File.createTempFile("sunflower_", ".txt")
        jtextExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        jtextExporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new Float(10));
        jtextExporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, new Float(5.25));
        jtextExporter.setParameter(JRExporterParameter.OUTPUT_FILE, respFile);
        jtextExporter.exportReport();
      }
     
    } catch (Exception e) {
      e.printStackTrace();
    }finally{
      if(jasperFileStream != null){
        try {
          jasperFileStream.close();
        } catch (IOException e) {
        }
      }
    }

    if("pdf".equalsIgnoreCase(type)){
      output = new FileRepresentation(respFile, MediaType.APPLICATION_PDF);
    }else{
      output = new FileRepresentation(respFile, MediaType.TEXT_PLAIN);
    }
    return output;   
  }
View Full Code Here

  public FileRepresentation getRepresentation(){   
    Integer id = RequestUtil.getInteger(getRequestAttributes().get("id"));
    String type = RequestUtil.getString(getRequestAttributes().get("type"));

    File respFile = null;
    FileRepresentation output = null;

    InputStream jasperFileStream = getClass().getResourceAsStream("/report/poreport.jasper");
    Map<String, Object> paramMap = new HashMap<String, Object>();
   
   
    List<PurchasingOrderDetail> list = coreManager.getPurchasingOrderDetails(id);
   
    if(list.size() > 0){
      Integer storeId = list.get(0).getPurchasingOrder().getDeliverStoreId();
      Store store = coreManager.get(Store.class, storeId);
      paramMap.put("storeName", store.getName());
      paramMap.put("storeAddress", store.getAddress());
      paramMap.put("storeCity", store.getCity());
    }
       
    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
   
    try {
      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperFileStream, paramMap, ds);
      if("pdf".equalsIgnoreCase(type)){
        respFile = File.createTempFile("sunflower_", ".pdf");
        JasperExportManager.exportReportToPdfFile(jasperPrint, respFile.getPath());
      }else{
        respFile = File.createTempFile("sunflower_", ".txt")
        jtextExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        jtextExporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new Float(10));
        jtextExporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, new Float(5.25));
        jtextExporter.setParameter(JRExporterParameter.OUTPUT_FILE, respFile);
        jtextExporter.exportReport();
      }
     
    } catch (Exception e) {
      e.printStackTrace();
    }finally{
      if(jasperFileStream != null){
        try {
          jasperFileStream.close();
        } catch (IOException e) {
        }
      }
    }

    if("pdf".equalsIgnoreCase(type)){
      output = new FileRepresentation(respFile, MediaType.APPLICATION_PDF);
    }else{
      output = new FileRepresentation(respFile, MediaType.TEXT_PLAIN);
    }
    return output;   
  }
View Full Code Here

  public FileRepresentation getRepresentation(){   
    Integer id = RequestUtil.getInteger(getRequestAttributes().get("id"));
    String type = RequestUtil.getString(getRequestAttributes().get("type"));

    File respFile = null;
    FileRepresentation output = null;

    InputStream jasperFileStream = getClass().getResourceAsStream("/report/transfer.jasper");
    Map<String, Object> paramMap = new HashMap<String, Object>();
       
    List<TransferOrderDetail> list = coreManager.getTransferOrderDetails(id);
           
    JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
   
    try {
      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperFileStream, paramMap, ds);
      if("pdf".equalsIgnoreCase(type)){
        respFile = File.createTempFile("sunflower_", ".pdf");
        JasperExportManager.exportReportToPdfFile(jasperPrint, respFile.getPath());
      }else{
        respFile = File.createTempFile("sunflower_", ".txt")
        jtextExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        jtextExporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, new Float(10));
        jtextExporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, new Float(5.25));
        jtextExporter.setParameter(JRExporterParameter.OUTPUT_FILE, respFile);
        jtextExporter.exportReport();
      }
     
    } catch (Exception e) {
      e.printStackTrace();
    }finally{
      if(jasperFileStream != null){
        try {
          jasperFileStream.close();
        } catch (IOException e) {
        }
      }
    }

    if("pdf".equalsIgnoreCase(type)){
      output = new FileRepresentation(respFile, MediaType.APPLICATION_PDF);
    }else{
      output = new FileRepresentation(respFile, MediaType.TEXT_PLAIN);
    }
    return output;   
  }
View Full Code Here

            // its already a restlet response, so dont do anything
            LOG.debug("Using existing Restlet Response from exchange body: {}", body);
        } else if (body instanceof InputStream) {
            response.setEntity(new InputRepresentation(out.getBody(InputStream.class), mediaType));
        } else if (body instanceof File) {
            response.setEntity(new FileRepresentation(out.getBody(File.class), mediaType));
        } else {
            // fallback and use string
            String text = out.getBody(String.class);
            response.setEntity(text, mediaType);
        }
View Full Code Here

TOP

Related Classes of org.restlet.representation.FileRepresentation

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.