コード例 #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 void delete() throws NotAuthorizedException, ConflictException, BadRequestException {
   try {
     folder.delete();
   } catch (NotFoundException ex) {
     return; // ok, not there to delete
   } catch (IOException ex) {
     throw new RuntimeException(ex);
   } catch (HttpException ex) {
     throw new RuntimeException(ex);
   }
 }
コード例 #3
0
 @Override
 public com.bradmcevoy.http.Resource createNew(
     String newName, InputStream inputStream, Long length, String contentType)
     throws IOException, ConflictException, NotAuthorizedException, BadRequestException {
   try {
     File newFile = folder.upload(newName, inputStream, length, null);
     return new FileResourceAdapter(newFile, getSecurityManager(), getHostName(), remoteManager);
   } catch (HttpException ex) {
     throw new RuntimeException(ex);
   } catch (NotFoundException ex) {
     throw new RuntimeException(ex);
   }
 }
コード例 #4
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);
 }
コード例 #5
0
 @Override
 public Date getCreateDate() {
   return folder.getCreatedDate();
 }