Package com.googlecode.freewebdav.entities

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


  @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

  }
 
  @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

    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

TOP

Related Classes of com.googlecode.freewebdav.entities.WebdavFile

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.