@Test public void testDeleteFolderRoomWithContent() throws Exception { final StoregateIdProvider nodeid = new StoregateIdProvider(session).withCache(cache); final Path room = new StoregateDirectoryFeature(session, nodeid).mkdir(new Path( String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume, Path.Type.triplecrypt)), null, new TransferStatus()); final Path folder = new StoregateDirectoryFeature(session, nodeid).mkdir(new Path(room, new AlphanumericRandomStringService().random().toLowerCase(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); assertTrue(new DefaultFindFeature(session).find(folder)); final Path file = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new StoregateTouchFeature(session, nodeid).touch(file, new TransferStatus()); assertTrue(new DefaultFindFeature(session).find(file)); new StoregateDeleteFeature(session, nodeid).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertFalse(new DefaultFindFeature(session).find(folder)); new StoregateDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertFalse(new DefaultFindFeature(session).find(room)); }
@Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { try { callback.delete(file.getKey()); final StoregateApiClient client = session.getClient(); final HttpRequestBase request; request = new HttpDelete(String.format("%s/v4/files/%s", client.getBasePath(), fileid.getFileid(file.getKey(), new DisabledListProgressListener()))); if(file.getValue().getLockId() != null) { request.addHeader("X-Lock-Id", file.getValue().getLockId().toString()); } request.addHeader(HTTP.CONTENT_TYPE, MEDIA_TYPE); final HttpResponse response = client.getClient().execute(request); try { switch(response.getStatusLine().getStatusCode()) { case HttpStatus.SC_NO_CONTENT: break; default: throw new StoregateExceptionMappingService().map(new ApiException(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase())); } } finally { EntityUtils.consume(response.getEntity()); } } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
StoregateDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { try { callback.delete(file.getKey()); final StoregateApiClient client = session.getClient(); final HttpRequestBase request; request = new HttpDelete(String.format("%s/v4/files/%s", client.getBasePath(), fileid.getFileid(file.getKey(), new DisabledListProgressListener()))); if(file.getValue().getLockId() != null) { request.addHeader("X-Lock-Id", file.getValue().getLockId().toString()); } request.addHeader(HTTP.CONTENT_TYPE, MEDIA_TYPE); final HttpResponse response = client.getClient().execute(request); try { switch(response.getStatusLine().getStatusCode()) { case HttpStatus.SC_NO_CONTENT: break; default: throw new StoregateExceptionMappingService().map(new ApiException(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase())); } } finally { EntityUtils.consume(response.getEntity()); } } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } }
StoregateDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { try { callback.delete(file.getKey()); final StoregateApiClient client = session.getClient(); final HttpRequestBase request; request = new HttpDelete(String.format("%s/v4/files/%s", client.getBasePath(), fileid.getFileid(file.getKey(), new DisabledListProgressListener()))); if(file.getValue().getLockId() != null) { request.addHeader("X-Lock-Id", file.getValue().getLockId().toString()); } request.addHeader(HTTP.CONTENT_TYPE, MEDIA_TYPE); final HttpResponse response = client.getClient().execute(request); try { switch(response.getStatusLine().getStatusCode()) { case HttpStatus.SC_NO_CONTENT: break; default: throw new StoregateExceptionMappingService().map(new ApiException(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase())); } } finally { EntityUtils.consume(response.getEntity()); } } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } StoregateDeleteFeature(final StoregateSession session, final StoregateIdProvider fileid); }
StoregateDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { try { callback.delete(file.getKey()); final StoregateApiClient client = session.getClient(); final HttpRequestBase request; request = new HttpDelete(String.format("%s/v4/files/%s", client.getBasePath(), fileid.getFileid(file.getKey(), new DisabledListProgressListener()))); if(file.getValue().getLockId() != null) { request.addHeader("X-Lock-Id", file.getValue().getLockId().toString()); } request.addHeader(HTTP.CONTENT_TYPE, MEDIA_TYPE); final HttpResponse response = client.getClient().execute(request); try { switch(response.getStatusLine().getStatusCode()) { case HttpStatus.SC_NO_CONTENT: break; default: throw new StoregateExceptionMappingService().map(new ApiException(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase())); } } finally { EntityUtils.consume(response.getEntity()); } } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } StoregateDeleteFeature(final StoregateSession session, final StoregateIdProvider fileid); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isRecursive(); }
StoregateDeleteFeature implements Delete { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { for(Map.Entry<Path, TransferStatus> file : files.entrySet()) { try { callback.delete(file.getKey()); final StoregateApiClient client = session.getClient(); final HttpRequestBase request; request = new HttpDelete(String.format("%s/v4/files/%s", client.getBasePath(), fileid.getFileid(file.getKey(), new DisabledListProgressListener()))); if(file.getValue().getLockId() != null) { request.addHeader("X-Lock-Id", file.getValue().getLockId().toString()); } request.addHeader(HTTP.CONTENT_TYPE, MEDIA_TYPE); final HttpResponse response = client.getClient().execute(request); try { switch(response.getStatusLine().getStatusCode()) { case HttpStatus.SC_NO_CONTENT: break; default: throw new StoregateExceptionMappingService().map(new ApiException(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase())); } } finally { EntityUtils.consume(response.getEntity()); } } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } } StoregateDeleteFeature(final StoregateSession session, final StoregateIdProvider fileid); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isRecursive();  }