Examples of WebdavFile


Examples of com.googlecode.freewebdav.entities.WebdavFile

    if(wf == null) {
      resp.sendError(404);
      return;
    }
    log.finer("looking up file:" + fileName + " with parent:" + wf);
    WebdavFile file = ofy.query(WebdavFile.class).filter("parent", wf).filter("name", fileName).get();

    if(file == null) {
      resp.sendError(404);
      return;
    }
     
    log.fine("Sending file:" + fileName);
    String contentType = file.getContentType();
    String name = file.getName();

    resp.setContentType(contentType);
    //return images inline... by skipping this
    if (contentType == null || !contentType.toLowerCase().startsWith("image"))
      resp.setHeader("Content-Disposition", "attachment; filename=\"" + name + "\"");
   
    //TODO add cache headers.
    resp.getOutputStream().write(ofy.get(file.getData()).getData());
    resp.flushBuffer();
  }
View Full Code Here

Examples of com.googlecode.freewebdav.entities.WebdavFile

  @SuppressWarnings("rawtypes")
  private Resource getLastItem(Key parent, String[] path, int pos) {
    String name = path[pos];
   
    WebdavFile wfile = null;
    //try for a folder first
    WebdavFolder wfolder = ofy.query(WebdavFolder.class).filter("parent", parent).filter("name", name).get();
    if (wfolder == null) //try for a file next
      wfile = ofy.query(WebdavFile.class).filter("parent", parent).filter("name", name).get();
   
View Full Code Here

Examples of com.googlecode.freewebdav.entities.WebdavFile

  }
 
  @Override
  public void copyTo(CollectionResource toCollection, String name) throws NotAuthorizedException, BadRequestException, ConflictException {
    if (toCollection instanceof FolderResource) {
      WebdavFile file = getFile().copy();
      file.setParent(getKey(((FolderResource) toCollection).getFolder()));
      ofy.put(file);
      return;
    }
   
    throw new BadRequestException(this, "Cannot be copied to " + toCollection.toString());
View Full Code Here

Examples of com.googlecode.freewebdav.entities.WebdavFile

    StreamUtils.readTo(is, bos);

    byte[] data = bos.toByteArray();
    Key<WebdavFileData> dataKey = ofy.put(new WebdavFileData(data));
   
    WebdavFile wf = new WebdavFile();
    wf.setContentType(fixCT(contentType));
    wf.setBytes(data.length);
    wf.setName(s);
    wf.setData(dataKey);
    wf.setParent(parent);
    ofy.put(wf);
   
    log.info("Saved WebdavFile: " + wf.toString());
   
    return new FileResource(wf);
  }
View Full Code Here

Examples of org.apache.webdav.lib.WebdavFile

            if(StringUtils.isRelative(file))
            {
                tmp = getPWD() + file;
            }

            WebdavFile f = new WebdavFile(getURL(tmp));

            if(!f.getAbsolutePath().equals(f.getCanonicalPath()))
            {
                //Log.debug("WARNING: Symlink removed");//Skipping symlink, remove failed.");
                //Log.debug("This is necessary to prevent possible data loss when removing those symlinks.");
                //return -1;
                if(!f.delete())
                {
                    return -1;
                }
            }

            if(f.exists() && f.isDirectory())
            {
                cleanLocalDir(tmp);
            }

            //System.out.println(tmp);
            if(!f.delete())
            {
                Log.debug("Removal failed.");

                return -1;
            }
View Full Code Here

Examples of org.apache.webdav.lib.WebdavFile

                dir = dir + "/";
            }

            //String remoteDir = StringUtils.removeStart(dir,path);
            //System.out.println(">>> " + dir);
            WebdavFile f2 = new WebdavFile(getURL(dir));
            String[] tmp = f2.list();

            if(tmp == null)
            {
                return;
            }

            for(int i = 0; i < tmp.length; i++)
            {
                WebdavFile f3 = new WebdavFile(getURL(dir + tmp[i]));

                if(!f3.getAbsolutePath().equals(f3.getCanonicalPath()))
                {
                    //Log.debug("WARNING: Symlink remove");//Skipping symlink, remove may fail.");
                    f3.delete();

                    //Log.debug("This is necessary to prevent possible data loss when removing those symlinks.");
                    //continue;
                }

                if(f3.isDirectory())
                {
                    //System.out.println(dir);
                    cleanLocalDir(dir + tmp[i]);
                    f3.delete();
                }
                else
                {
                    //System.out.println(dir+tmp[i]);
                    f3.delete();
                }
            }
        }
        catch(Exception ex)
        {
View Full Code Here

Examples of org.apache.webdav.lib.WebdavFile

            if(StringUtils.isRelative(dirName))
            {
                dirName = getPWD() + dirName;
            }

            WebdavFile f = new WebdavFile(getURL(dirName));

            boolean x = f.mkdir();
            fireDirectoryUpdate();

            return x;
        }
        catch(Exception ex)
View Full Code Here

Examples of org.apache.webdav.lib.WebdavFile

        {
            fileCount = 0;
            shortProgress = true;
            baseFile = StringUtils.getDir(dir);

            WebdavFile f2 = new WebdavFile(getURL(dir));
            String[] tmp = f2.list();

            if(tmp == null)
            {
                return;
            }

            WebdavFile fx = new WebdavFile(getURL(out));

            if(!fx.mkdir())
            {
                Log.debug("Can not create directory: " + out +
                          " - already exist or permission denied?");
            }

            for(int i = 0; i < tmp.length; i++)
            {
                tmp[i] = tmp[i].replace('\\', '/');

                //System.out.println("1: " + dir+tmp[i] + ", " + out +tmp[i]);
                WebdavFile f3 = new WebdavFile(getURL(dir + tmp[i]));

                if(f3.isDirectory())
                {
                    if(!tmp[i].endsWith("/"))
                    {
                        tmp[i] = tmp[i] + "/";
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.