@Test public void testFindUnknownBucket() throws Exception { final Host host = new Host(new SpectraProtocol() { @Override public Scheme getScheme() { return Scheme.http; } }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials( System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key") )); final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Path test = new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.volume, Path.Type.directory)); assertFalse(new SpectraFindFeature(session).find(test)); session.close(); }
@Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); if(containerService.isContainer(file)) { final HeadBucketResponse response = client.headBucket(new HeadBucketRequest(containerService.getContainer(file).getName())); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } else { final HeadObjectResponse response = client.headObject(new HeadObjectRequest(containerService.getContainer(file).getName(), containerService.getKey(file))); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, file); } }
SpectraFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); if(containerService.isContainer(file)) { final HeadBucketResponse response = client.headBucket(new HeadBucketRequest(containerService.getContainer(file).getName())); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } else { final HeadObjectResponse response = client.headObject(new HeadObjectRequest(containerService.getContainer(file).getName(), containerService.getKey(file))); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, file); } } }
SpectraFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); if(containerService.isContainer(file)) { final HeadBucketResponse response = client.headBucket(new HeadBucketRequest(containerService.getContainer(file).getName())); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } else { final HeadObjectResponse response = client.headObject(new HeadObjectRequest(containerService.getContainer(file).getName(), containerService.getKey(file))); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, file); } } SpectraFindFeature(final SpectraSession session); }
SpectraFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); if(containerService.isContainer(file)) { final HeadBucketResponse response = client.headBucket(new HeadBucketRequest(containerService.getContainer(file).getName())); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } else { final HeadObjectResponse response = client.headObject(new HeadObjectRequest(containerService.getContainer(file).getName(), containerService.getKey(file))); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, file); } } SpectraFindFeature(final SpectraSession session); @Override boolean find(final Path file); }
SpectraFindFeature implements Find { @Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); if(containerService.isContainer(file)) { final HeadBucketResponse response = client.headBucket(new HeadBucketRequest(containerService.getContainer(file).getName())); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } else { final HeadObjectResponse response = client.headObject(new HeadObjectRequest(containerService.getContainer(file).getName(), containerService.getKey(file))); switch(response.getStatus()) { case DOESNTEXIST: return false; } return true; } } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, file); } } SpectraFindFeature(final SpectraSession session); @Override boolean find(final Path file);  }