Package com.ettrema.httpclient

Examples of com.ettrema.httpclient.Folder


    public Enumeration children() {
        return Collections.enumeration( getChildren() );
    }

    void createNewFolder( String name ) throws Exception {
        Folder newFolder = this.folder.createFolder( name );
    }
View Full Code Here


    final HttpServletRequest req=ServletTestRunner.localRequest.get();
    Host host=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
   
   
    // this is mostly capturing https://github.com/dotCMS/dotCMS/issues/2815
    Folder demo=(Folder)host.child("demo.dotcms.com");
    Folder webdavtest=demo.createFolder("webdavtest_"+System.currentTimeMillis());
    Folder ff1=webdavtest.createFolder("ff1");
    Folder ff2=webdavtest.createFolder("ff2");
     
    java.io.File tmpDir1=new java.io.File(
          APILocator.getFileAPI().getRealAssetPathTmpBinary()+java.io.File.separator+"webdavtest_1_"+System.currentTimeMillis());
      tmpDir1.mkdirs();
      java.io.File tmpDir2=new java.io.File(
          APILocator.getFileAPI().getRealAssetPathTmpBinary()+java.io.File.separator+"webdavtest_2_"+System.currentTimeMillis());
      tmpDir2.mkdirs();
      java.io.File f1=new java.io.File(tmpDir1,"test.txt");
      java.io.File f2=new java.io.File(tmpDir2,"test.txt");
      FileWriter w = new FileWriter(f1,true); w.write("text1"); w.close();
      w = new FileWriter(f2,true); w.write("text2"); w.close();
     
      ff1.upload(f1);
      ff2.upload(f2);
     
      Thread.sleep(1000); // wait for the index
     
      List<? extends Resource> children1 = ff1.children();
      List<? extends Resource> children2 = ff2.children();
      assertEquals(1,children1.size());
      assertEquals(1,children2.size());
     
      File r1 = (File)children1.get(0);
      File r2 = (File)children2.get(0);
View Full Code Here

     
      // webdav connection
      final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Host hh=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
       
        Folder demo=(Folder)hh.child("demo.dotcms.com");
        Folder wt=(Folder)((Folder)demo.child("wt")).child(ff.getName());
        File wtFile=(File)wt.child("legacy.txt");
        final String newContent="new File content";
        wtFile.setContent(new ByteArrayInputStream(newContent.getBytes()), (long)newContent.getBytes().length);
       
        file = APILocator.getFileAPI().getWorkingFileById(file.getIdentifier(), user, false);
       
View Full Code Here

     
     
      final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Host hh=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
       
        Folder demo=(Folder)hh.child("demo.dotcms.com");
        File f1=(File)demo.child(filename);
        f1.copyTo(demo, copyfilename);
        Thread.sleep(1000);
        File f2=(File)demo.child(copyfilename);
        ByteArrayOutputStream out1=new ByteArrayOutputStream(),out2=new ByteArrayOutputStream();
        f1.download(out1, null);
        f2.download(out2, null);
        Assert.assertEquals("this is a test text", out1.toString());
        Assert.assertEquals("this is a test text", out2.toString());
View Full Code Here

       
       
        final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Host hh=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
       
        Folder demo=(Folder)hh.child("demo.dotcms.com");
        File f1=(File)demo.child(filename);
        f1.delete();
       
        for(Resource rr: demo.children()) {
            if(rr instanceof File) {
                Assert.assertNotSame(filename, ((File)rr).name);
            }
        }
       
View Full Code Here

          throw ex;
      }
     
         
      final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Folder hh=new Host(req.getServerName(),"/webdav/autopub/demo.dotcms.com/wt/"+folder.getName(),
                req.getServerPort(),limited.getEmailAddress(),"123",null,null);
       
        java.io.File tmp=java.io.File.createTempFile("filetest", ".txt");
        FileUtils.writeStringToFile(tmp, "this is a test text 888");
       
        try{
          File uploaded = hh.uploadFile(tmp);
        } catch (Exception e){
          //This is expected: User does not have permission to publish contentlets
          Assert.assertTrue(e instanceof InternalServerError);
        }
View Full Code Here

       
       
        final HttpServletRequest req=ServletTestRunner.localRequest.get();
        Host hh=new Host(req.getServerName(),"/webdav/autopub",req.getServerPort(),"admin@dotcms.com","admin",null,null);
       
        Folder demo=(Folder)hh.child("demo.dotcms.com");
        File f1=(File)demo.child(filename);
        f1.rename(renamefilename);
        Thread.sleep(1000);
        File f2=(File)demo.child(renamefilename);
        ByteArrayOutputStream out=new ByteArrayOutputStream();
        f2.download(out, null);
        Assert.assertEquals("this is a test text", out.toString());
        f2.delete();
  }
View Full Code Here

TOP

Related Classes of com.ettrema.httpclient.Folder

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.