Package org.xrace.model

Examples of org.xrace.model.Resource


  private ImportationPuces getImportation(String fileName) throws Exception
  {
    ClassPathResource classPathResource = new ClassPathResource(fileName,
        getClass());

    Resource resource = getResourceService().newResourceFromFileName(
        classPathResource.getFilename());
    getResourceService().upload(
        new FileInputStream(classPathResource.getFile()), resource);

    ImportationPuces importationPuces = getImportationPucesService()
View Full Code Here


    }

    HSSFWorkbook workbook;
    try
    {
      Resource importFile = t.getImportFile();
      InputStream in = resourceService.download(importFile);

      workbook = new HSSFWorkbook(in);
    }
    catch (Exception e)
View Full Code Here

    }

    String fileContents;
    try
    {
      Resource importFile = importationPuces.getImportFile();
      InputStream in = resourceService.download(importFile);
      InputStreamReader reader = new InputStreamReader(in);
      fileContents = IOUtils.toString(reader);
    }
    catch (Exception e)
View Full Code Here

  public Resource newResourceFromFileName(String fileName)
  {
    String name = FilenameUtils.getName(fileName);
    String extension = FilenameUtils.getExtension(fileName);

    Resource resource = new Resource(name, extension, "");
    return resource;
  }
View Full Code Here

  }

  private ImportationDonneesTerrain getImportation(File file)
      throws Exception
  {
    Resource resource = getResourceService().newResourceFromFileName(
        file.getName());
    getResourceService().upload(new FileInputStream(file), resource);

    ImportationDonneesTerrain importationDonneesTerrain = new ImportationDonneesTerrain();
    importationDonneesTerrain.setCompte(compte);
View Full Code Here

        .size());
  }

  public void testNewResourceFromFileName() throws Exception
  {
    Resource resource = getResourceService().newResourceFromFileName(
        "c:\\mes documents\\mes images\\image1.jpg");
    Assert.assertEquals("image1.jpg", resource.getName());
    Assert.assertEquals("jpg", resource.getFormat());

    resource = getResourceService().newResourceFromFileName("image2.tif");
    Assert.assertEquals("image2.tif", resource.getName());
    Assert.assertEquals("tif", resource.getFormat());
  }
View Full Code Here

  public void testUpload() throws Exception
  {
    int nbFiles = FileUtils.listFiles(directory, FileFileFilter.FILE, null)
        .size();

    Resource resource = new Resource("image3.png", "png", "La image3");
    FileInputStream fis = new FileInputStream(image3);
    getResourceService().upload(fis, resource);
    fis.close();

    Assert.assertEquals(nbFiles + 1, FileUtils.listFiles(directory,
        FileFileFilter.FILE, null).size());
    Assert.assertTrue(getResourceService().getFile(resource).exists());
    Assert.assertTrue(resource.isValid());
    Assert.assertEquals(4, getResourceService().list().size());
  }
View Full Code Here

    Assert.assertEquals(4, getResourceService().list().size());
  }

  public void testDownload() throws Exception
  {
    Resource resource = getResourceService().findByName("image1.jpg")
        .get(0);
    InputStream in = getResourceService().download(resource);
    in.close();

    Assert.assertNotNull(in);
View Full Code Here

  public void testDownloadResourceNotFound() throws Exception
  {
    int nbFiles = FileUtils.listFiles(directory, FileFileFilter.FILE, null)
        .size();

    Resource resource = new Resource("image3.png", "png", "La image3");
    FileInputStream fis = new FileInputStream(image3);
    getResourceService().upload(fis, resource);
    fis.close();

    File file = getResourceService().getFile(resource);
View Full Code Here

  public void testValidate() throws Exception
  {
    int nbFiles = FileUtils.listFiles(directory, FileFileFilter.FILE, null)
        .size();

    Resource resource = new Resource("image3.png", "png", "La image3");
    FileInputStream fis = new FileInputStream(image3);
    getResourceService().upload(fis, resource);
    fis.close();

    File file = getResourceService().getFile(resource);
    file.delete();

    Assert.assertEquals(nbFiles, FileUtils.listFiles(directory,
        FileFileFilter.FILE, null).size());

    getResourceService().validate();

    resource = getResourceService().findByName("image3.png").get(0);
    Assert.assertFalse(resource.isValid());
  }
View Full Code Here

TOP

Related Classes of org.xrace.model.Resource

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.