public SearchMethod(String uri, SearchInfo searchInfo) throws IOException { super(uri, searchInfo); setRequestHeader(HEADER_CONTENT_TYPE, HEADER_CONTENT_TYPE_VALUE); setRequestBody(createQuery()); }
/** * Reconstruct from parcel * * @param source The source parcel */ protected RemoteFile(Parcel source) { readFromParcel(source); }
private void startRefresh() { ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR); refreshOperation.execute(mClient, this, mHandler); }
@Test public void testCreateNonExistingSubFolder() { String path = "/testFolder/1/2/3/4/5/"; String top = "/testFolder/"; assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); // verify folder assertTrue(new ReadFolderRemoteOperation(path).execute(client).isSuccess()); // remove folder assertTrue(new RemoveFileRemoteOperation(top).execute(client).isSuccess()); } }
@Test public void testUploadWithoutExistingChunksBig() { long length = 4 * chunkSize; List<Chunk> existingChunks = new ArrayList<>(); List<Chunk> expectedMissingChunks = new ArrayList<>(); expectedMissingChunks.add(new Chunk(0, 1023)); expectedMissingChunks.add(new Chunk(1024, 2047)); expectedMissingChunks.add(new Chunk(2048, 3071)); expectedMissingChunks.add(new Chunk(3072, 4095)); expectedMissingChunks.add(new Chunk(4096, 4096)); assertTrue(test(existingChunks, expectedMissingChunks, chunkSize, length)); }
@Test public void testCreateFolderFailure() { String path = "/testFolder/"; // create folder assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); // create folder a second time will fail assertFalse(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); // remove folder assertTrue(new RemoveFileRemoteOperation(path).execute(client).isSuccess()); }
/** * Performs the operation * * @param client Client object to communicate with the remote ownCloud server. */ @Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result; result = createFolder(client); if (!result.isSuccess() && mCreateFullPath && RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) { result = createParentFolder(FileUtils.getParentPath(mRemotePath), client); if (result.isSuccess()) { result = createFolder(client); // second (and last) try } } return result; }
private void startDownload() { File downFolder = new File(getCacheDir(), getString(R.string.download_folder_path)); downFolder.mkdir(); File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path)); File fileToUpload = upFolder.listFiles()[0]; String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remotePath, downFolder.getAbsolutePath()); downloadOperation.addDatatransferProgressListener(this); downloadOperation.execute(mClient, this, mHandler); }
private boolean test(List<Chunk> existingChunks, List<Chunk> expectedMissingChunks, long chunkSize, long length) { ChunkedFileUploadRemoteOperation sut = new ChunkedFileUploadRemoteOperation(null, null, null, null, null, null, false); List<Chunk> missingChunks = sut.checkMissingChunks(existingChunks, length, chunkSize); assertEquals(expectedMissingChunks.size(), missingChunks.size()); for (Chunk expectedMissingChunk : expectedMissingChunks) { assertTrue(missingChunks.contains(expectedMissingChunk)); } return true; } }
/** * Checks if a file with the new name already exists. * * @return 'True' if the target path is already used by an existing file. */ private boolean targetPathIsUsed(OwnCloudClient client) { ExistenceCheckRemoteOperation existenceCheckRemoteOperation = new ExistenceCheckRemoteOperation(mNewRemotePath, false, false); RemoteOperationResult exists = existenceCheckRemoteOperation.run(client); return exists.isSuccess(); } }
private RemoteOperationResult createParentFolder(String parentPath, OwnCloudClient client) { RemoteOperation operation = new CreateFolderRemoteOperation(parentPath, mCreateFullPath); return operation.execute(client); }
private void startRemoteDeletion() { File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path)); File fileToUpload = upFolder.listFiles()[0]; String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName(); RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath); removeOperation.execute(mClient, this, mHandler); }
public RemoteFile() { resetData(); }
private RemoteOperationResult createParentFolder(String parentPath, OwnCloudClient client) { RemoteOperation operation = new CreateRemoteFolderOperation(parentPath, mCreateFullPath); return operation.execute(client); } }
@Test public void testCreateFolderSuccess() { String path = "/testFolder/"; // create folder assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); // verify folder assertTrue(new ReadFolderRemoteOperation(path).execute(client).isSuccess()); // remove folder assertTrue(new RemoveFileRemoteOperation(path).execute(client).isSuccess()); }
@Test public void testUploadChunksMissingChunks2() { long length = 2 * chunkSize; List<Chunk> existingChunks = new ArrayList<>(); existingChunks.add(new Chunk(50, 1023)); existingChunks.add(new Chunk(1028, 1100)); List<Chunk> expectedMissingChunks = new ArrayList<>(); expectedMissingChunks.add(new Chunk(0, 49)); expectedMissingChunks.add(new Chunk(1024, 1027)); expectedMissingChunks.add(new Chunk(1101, 2048)); assertTrue(test(existingChunks, expectedMissingChunks, chunkSize, length)); }
@Test public void testUploadChunksMissingChunks() { long length = 2 * chunkSize; List<Chunk> existingChunks = new ArrayList<>(); existingChunks.add(new Chunk(0, 1023)); existingChunks.add(new Chunk(1028, 1100)); List<Chunk> expectedMissingChunks = new ArrayList<>(); expectedMissingChunks.add(new Chunk(1024, 1027)); expectedMissingChunks.add(new Chunk(1101, 2048)); assertTrue(test(existingChunks, expectedMissingChunks, chunkSize, length)); }
@Test public void testUploadWithoutExistingChunksSmallChunks() { long chunkSize = 512; long length = 4 * chunkSize; List<Chunk> existingChunks = new ArrayList<>(); List<Chunk> expectedMissingChunks = new ArrayList<>(); expectedMissingChunks.add(new Chunk(0, 511)); expectedMissingChunks.add(new Chunk(512, 1023)); expectedMissingChunks.add(new Chunk(1024, 1535)); expectedMissingChunks.add(new Chunk(1536, 2047)); expectedMissingChunks.add(new Chunk(2048, 2048)); assertTrue(test(existingChunks, expectedMissingChunks, chunkSize, length)); }
@Test public void testChunksSmallSizeMissingChunks() { long chunkSize = 512; long length = 4 * chunkSize; List<Chunk> existingChunks = new ArrayList<>(); existingChunks.add(new Chunk(50, 89)); existingChunks.add(new Chunk(551, 580)); List<Chunk> expectedMissingChunks = new ArrayList<>(); expectedMissingChunks.add(new Chunk(0, 49)); expectedMissingChunks.add(new Chunk(90, 550)); expectedMissingChunks.add(new Chunk(581, 1092)); expectedMissingChunks.add(new Chunk(1093, 1604)); expectedMissingChunks.add(new Chunk(1605, 2048)); assertTrue(test(existingChunks, expectedMissingChunks, chunkSize, length)); }
@Test public void testUploadWithoutExistingChunks() { long length = 2 * chunkSize; List<Chunk> existingChunks = new ArrayList<>(); List<Chunk> expectedMissingChunks = new ArrayList<>(); expectedMissingChunks.add(new Chunk(0, 1023)); expectedMissingChunks.add(new Chunk(1024, 2047)); expectedMissingChunks.add(new Chunk(2048, 2048)); assertTrue(test(existingChunks, expectedMissingChunks, chunkSize, length)); }