예제 #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;
 }
예제 #2
0
 @Override
 public CollectionResource createCollection(String newName)
     throws NotAuthorizedException, ConflictException, BadRequestException {
   Folder newRemoteFolder;
   try {
     newRemoteFolder = folder.createFolder(newName);
   } catch (IOException ex) {
     throw new RuntimeException(ex);
   } catch (NotFoundException ex) {
     throw new RuntimeException(ex);
   } catch (HttpException ex) {
     throw new RuntimeException(ex);
   }
   return new FolderResourceAdapter(
       newRemoteFolder, getSecurityManager(), newName, contentGenerator, remoteManager);
 }