Package com.ettrema.httpclient

Examples of com.ettrema.httpclient.Host


   */
  //@Test
  public void test_Download_Update_OverHTTP() throws FileNotFoundException, IOException, HttpException, Exception {
    // Get metadata from http server
    System.out.println("--------------------- test3 -----------------------");
    Host host = new Host("localhost", "webdav", 8080, "me", "pwd", null, null);
    final File fRemoteMeta = File.createTempFile("milton-zsync-remotemeta", null);
    String url = host.getHref(Path.path("/source.txt/.zsync"));
    host.doGet(url, new StreamReceiver() {

      @Override
      public void receive(InputStream in) throws IOException {
        FileOutputStream fout = new FileOutputStream(fRemoteMeta);
        StreamUtils.readTo(in, fout, true, true);
      }
    }, null);
    System.out.println("meta file: " + fRemoteMeta.getAbsolutePath());
    // Now build local file
    com.ettrema.httpclient.File remoteFile = (com.ettrema.httpclient.File) host.find("/source.txt");
    Assert.assertNotNull(remoteFile);
    HttpRangeLoader rangeLoader = new HttpRangeLoader(remoteFile);

    System.out.println("local: " + fLocal.getAbsolutePath());
    fileMaker.make(fLocal, fRemoteMeta, rangeLoader);
View Full Code Here


  @Test
  public void test_Upload_OverHTTP() throws FileNotFoundException, HttpException, IOException {
    System.out.println();
    System.out.println("--------------------- test4 -----------------------");
    Host host = new Host("localhost", "webdav", 8080, "me", "pwd", null, null);
   
    File metaFile = metaFileMaker.make("/test", 32, fIn);
    Part[] parts = {new FilePart("meta", metaFile)};
    String url = host.getHref(Path.path("/source.txt/.zsync"));
    String ranges = host.doPost(url, null, parts);
    System.out.println("ranges: " + ranges);
   
    RangeListParser listParser = new RangeListParser();
    List<Range> list = listParser.parse(new ByteArrayInputStream(ranges.getBytes()));
   
    LocalFileRangeLoader fileRangeLoader = new LocalFileRangeLoader(fIn);
    byte[] data = fileRangeLoader.get(list);
    System.out.println("sending bytes: " + data.length);
    InputStream in = new ByteArrayInputStream(data);
    int result = host.doPut(url, in, (long)data.length, null);
    Utils.processResultCode(result, url );
    System.out.println("done!!");
   
   
   
View Full Code Here

        String[] arr = hostConfig.split(",");
        String server = arr[0];
        int port = Integer.parseInt(arr[1]);
        String user = arr[2];
        String password = arr[3];
        Host h = new Host(server, port, user, password, null);
        try {
            return new HostNode(this, h);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
View Full Code Here

            String rootPath = JOptionPane.showInputDialog("Path");
            if (password == null) {
                return;
            }

            Host h = new Host(hostName,rootPath, port, username, password, null, null);
            HostNode hn;
            try {
                hn = new HostNode(HostsNode.this, h);
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(frame.getComponent(), "An error occured connecting to the host");
View Full Code Here

public class WebDavTest extends TestBase {
  @Test
  public void uploadTest() throws Exception {
    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(
View Full Code Here

      file.setModDate(Calendar.getInstance().getTime());
      file = APILocator.getFileAPI().saveFile(file, data, ff, user, false);
     
      // 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);
       
View Full Code Here

      file = APILocator.getContentletAPI().checkin(file, user, false);
      APILocator.getContentletAPI().isInodeIndexed(file.getInode());
     
     
      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();
View Full Code Here

        file = APILocator.getContentletAPI().checkin(file, user, false);
        APILocator.getContentletAPI().isInodeIndexed(file.getInode());
       
       
        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) {
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

        file = APILocator.getContentletAPI().checkin(file, user, false);
        APILocator.getContentletAPI().isInodeIndexed(file.getInode());
       
       
        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();
View Full Code Here

TOP

Related Classes of com.ettrema.httpclient.Host

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.