/** * Check if a file exists in the OC server * * @deprecated Use ExistenceCheckOperation instead * * @return 'true' if the file exists; 'false' it doesn't exist * @throws Exception When the existence could not be determined */ @Deprecated public boolean existsFile(String path) throws IOException { HeadMethod head = new HeadMethod(getWebdavUri() + WebdavUtils.encodePath(path)); try { int status = executeMethod(head); Log_OC.d(TAG, "HEAD to " + path + " finished with HTTP status " + status + ((status != HttpStatus.SC_OK)?"(FAIL)":"")); exhaustResponse(head.getResponseBodyAsStream()); return (status == HttpStatus.SC_OK); } finally { head.releaseConnection(); // let the connection available for other methods } }
int status = -1; boolean savedFile = false; mGet = new GetMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath)); Iterator<OnDatatransferProgressListener> it = null; Date d = WebdavUtils.parseResponseDate(modificationTime.getValue()); mModificationTimestamp = (d != null) ? d.getTime() : 0; } else { mEtag = WebdavUtils.getEtagFromResponse(mGet); if (mEtag.length() == 0) { Log_OC.e(TAG, "Could not read eTag from response downloading " + mRemotePath);
propSet.add(DavPropertyName.GETETAG); PropFindMethod propfind = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(path), propSet, 0); int status = client.executeMethod(propfind, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT); MultiStatusResponse resp = propfind.getResponseBodyAsMultiStatus().getResponses()[0]; String etag = WebdavUtils.parseEtag((String) resp.getProperties(HttpStatus.SC_OK) .get(DavPropertyName.GETETAG).getValue());
propfind = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath), WebdavUtils.getFilePropSet(), // PropFind Properties DavConstants.DEPTH_0); int status;
DavPropertyNameSet propSet = WebdavUtils.getTrashbinPropSet(); query = new PropFindMethod(baseUri + WebdavUtils.encodePath(remotePath), propSet, DavConstants.DEPTH_1); int status = client.executeMethod(query);
Date d = WebdavUtils.parseResponseDate((String) prop.getValue()); modifiedTimestamp = (d != null) ? d.getTime() : 0; Date d = WebdavUtils.parseResponseDate((String) prop.getValue()); createTimestamp = (d != null) ? d.getTime() : 0; if (prop != null) { eTag = (String) prop.getValue(); eTag = WebdavUtils.parseEtag(eTag);
query = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath), WebdavUtils.getAllPropSet(), // PropFind Properties DavConstants.DEPTH_1); int status = client.executeMethod(query);
private RemoteOperationResult createResult(GetMethod get, byte[] avatarData, String mimeType) throws IOException { // find out etag String etag = WebdavUtils.getEtagFromResponse(get); if (etag.length() == 0) { Log_OC.w(TAG, "Could not read Etag from avatar"); } RemoteOperationResult result = new RemoteOperationResult(true, get); ResultData resultData = new ResultData(avatarData, mimeType, etag); ArrayList<Object> data = new ArrayList<>(); data.add(resultData); result.setData(data); return result; }
String value = readNode(parser, NODE_EXPIRATION); if (!(value.length() == 0)) { share.setExpirationDate(WebdavUtils.parseResponseDate(value).getTime());
/** * * @param method * @return */ public static String getEtagFromResponse(HttpMethod method) { Header eTag = method.getResponseHeader("OC-ETag"); if (eTag == null) { eTag = method.getResponseHeader("oc-etag"); } if (eTag == null) { eTag = method.getResponseHeader("ETag"); } if (eTag == null) { eTag = method.getResponseHeader("etag"); } String result = ""; if (eTag != null) { result = parseEtag(eTag.getValue()); } return result; }
DavPropertyNameSet propSet = WebdavUtils.getFileVersionPropSet();
PropFindMethod listChunks = new PropFindMethod(uploadFolderUri, WebdavUtils.getFilePropSet(), DavConstants.DEPTH_1); String destinationUri = client.getNewWebdavUri() + "/files/" + userId + WebdavUtils.encodePath(remotePath); String originUri = uploadFolderUri + "/.file"; MoveMethod moveMethod = new MoveMethod(originUri, destinationUri, false);
String etag = WebdavUtils.getEtagFromResponse(getMethod); if (etag.length() == 0) { Log_OC.w(TAG, "Could not read Etag from avatar");
String value = readNode(parser, NODE_EXPIRATION); if (!(value.length() == 0)) { share.setExpirationDate(WebdavUtils.parseResponseDate(value).getTime());
try { copyMethod = new CopyMethod( client.getWebdavUri() + WebdavUtils.encodePath(mSrcRemotePath), client.getWebdavUri() + WebdavUtils.encodePath(mTargetRemotePath), mOverwrite );
int status; boolean savedFile = false; mGet = new GetMethod(new URL(client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mRemotePath))); Iterator<OnDatatransferProgressListener> it; final Date d = WebdavUtils.parseResponseDate(modificationTime); mModificationTimestamp = (d != null) ? d.getTime() : 0; } else { mEtag = WebdavUtils.getEtagFromResponse(mGet);
/** * Performs the rename operation. * * @param client Client object to communicate with the remote ownCloud server. */ @Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result; try { Uri srcWebDavUri = removeChunksFolder ? client.getUploadsWebDavUri() : client.getUserFilesWebDavUri(); DeleteMethod deleteMethod = new DeleteMethod( new URL(srcWebDavUri + WebdavUtils.encodePath(mRemotePath))); int status = client.executeHttpMethod(deleteMethod); result = isSuccess(status) ? new RemoteOperationResult<>(OK) : new RemoteOperationResult<>(deleteMethod); Log_OC.i(TAG, "Remove " + mRemotePath + ": " + result.getLogMessage()); } catch (Exception e) { result = new RemoteOperationResult<>(e); Log_OC.e(TAG, "Remove " + mRemotePath + ": " + result.getLogMessage(), e); } return result; }
String stringUrl = mIsLogin ? client.getBaseFilesWebDavUri().toString() : client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mPath); PropfindMethod propfindMethod = new PropfindMethod( new URL(stringUrl), Log_OC.d(TAG, "Existence check for " + stringUrl + WebdavUtils.encodePath(mPath) + " targeting for " + (mSuccessIfAbsent ? " absence " : " existence ") + "finished with HTTP status " + status + (!isSuccess(status) ? "(FAIL)" : "")); final RemoteOperationResult result = new RemoteOperationResult<>(e); Log_OC.e(TAG, "Existence check for " + client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mPath) + " targeting for " + (mSuccessIfAbsent ? " absence " : " existence ") + ": " + result.getLogMessage(), result.getException());
/** * Performs the operation. * * @param client Client object to communicate with the remote ownCloud server. */ @Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result; try { String source = client.getNewWebdavUri() + WebdavUtils.encodePath(sourcePath); String target = client.getNewWebdavUri() + "/trashbin/" + userId + "/restore/" + fileName; MoveMethod move = new MoveMethod(source, target, true); int status = client.executeMethod(move, RESTORE_READ_TIMEOUT, RESTORE_CONNECTION_TIMEOUT); result = new RemoteOperationResult(isSuccess(status), move); client.exhaustResponse(move.getResponseBodyAsStream()); } catch (IOException e) { result = new RemoteOperationResult(e); Log.e(TAG, "Restore trashbin file " + sourcePath + " failed: " + result.getLogMessage(), e); } return result; }
new URL(srcWebDavUri + WebdavUtils.encodePath(mSrcRemotePath)), client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mTargetRemotePath), mOverwrite);