示例#1
0
 public com.ettrema.httpclient.Folder getOrCreateFolder(Path remoteParentPath, boolean create)
     throws com.ettrema.httpclient.HttpException, IOException, NotAuthorizedException,
         ConflictException, BadRequestException, NotFoundException {
   log.trace("getOrCreateFolder: {}", remoteParentPath);
   com.ettrema.httpclient.Folder f = this;
   if (remoteParentPath != null) {
     for (String childName : remoteParentPath.getParts()) {
       if (childName.equals("_code")) {
         f = new Folder(f, childName, cache);
       } else {
         com.ettrema.httpclient.Resource child = f.child(childName);
         if (child == null) {
           if (create) {
             f = f.createFolder(childName);
           } else {
             return null;
           }
         } else if (child instanceof com.ettrema.httpclient.Folder) {
           f = (com.ettrema.httpclient.Folder) child;
         } else {
           log.warn(
               "Can't upload. A resource exists with the same name as a folder, but is a file: "
                   + remoteParentPath
                   + " - "
                   + child.getClass());
           return null;
         }
       }
     }
   }
   return f;
 }