mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Modify requests to get the properties, adding properties specifically instead of DavConstants.PROPFIND_ALL_PROP
This commit is contained in:
parent
bbe8836365
commit
8edf9fdaf6
@ -37,13 +37,13 @@ import android.net.Uri;
|
|||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
|
|
||||||
public class WebdavEntry {
|
public class WebdavEntry {
|
||||||
private static final String NAMESPACE_OC = "http://owncloud.org/ns";
|
public static final String NAMESPACE_OC = "http://owncloud.org/ns";
|
||||||
private static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions";
|
public static final String EXTENDED_PROPERTY_NAME_PERMISSIONS = "permissions";
|
||||||
private static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id";
|
public static final String EXTENDED_PROPERTY_NAME_REMOTE_ID = "id";
|
||||||
private static final String EXTENDED_PROPERTY_NAME_SIZE = "size";
|
public static final String EXTENDED_PROPERTY_NAME_SIZE = "size";
|
||||||
|
|
||||||
private static final String PROPERTY_QUOTA_USED_BYTES = "quota-used-bytes";
|
public static final String PROPERTY_QUOTA_USED_BYTES = "quota-used-bytes";
|
||||||
private static final String PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes";
|
public static final String PROPERTY_QUOTA_AVAILABLE_BYTES = "quota-available-bytes";
|
||||||
|
|
||||||
private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId;
|
private String mName, mPath, mUri, mContentType, mEtag, mPermissions, mRemoteId;
|
||||||
private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize;
|
private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize;
|
||||||
|
@ -29,6 +29,9 @@ import org.apache.http.HttpStatus;
|
|||||||
import org.apache.jackrabbit.webdav.DavConstants;
|
import org.apache.jackrabbit.webdav.DavConstants;
|
||||||
import org.apache.jackrabbit.webdav.MultiStatus;
|
import org.apache.jackrabbit.webdav.MultiStatus;
|
||||||
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
||||||
|
import org.apache.jackrabbit.webdav.property.DavPropertyName;
|
||||||
|
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
|
||||||
|
import org.apache.jackrabbit.webdav.xml.Namespace;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.network.WebdavEntry;
|
import com.owncloud.android.lib.common.network.WebdavEntry;
|
||||||
@ -75,8 +78,27 @@ public class ReadRemoteFileOperation extends RemoteOperation {
|
|||||||
|
|
||||||
/// take the duty of check the server for the current state of the file there
|
/// take the duty of check the server for the current state of the file there
|
||||||
try {
|
try {
|
||||||
|
// PropFind Properties ( instead of DavConstants.PROPFIND_ALL_PROP )
|
||||||
|
DavPropertyNameSet propSet = new DavPropertyNameSet();
|
||||||
|
propSet.add(DavPropertyName.DISPLAYNAME);
|
||||||
|
propSet.add(DavPropertyName.GETCONTENTTYPE);
|
||||||
|
propSet.add(DavPropertyName.RESOURCETYPE);
|
||||||
|
propSet.add(DavPropertyName.GETCONTENTLENGTH);
|
||||||
|
propSet.add(DavPropertyName.GETLASTMODIFIED);
|
||||||
|
propSet.add(DavPropertyName.CREATIONDATE);
|
||||||
|
propSet.add(DavPropertyName.GETETAG);
|
||||||
|
propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_USED_BYTES));
|
||||||
|
propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_AVAILABLE_BYTES));
|
||||||
|
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS,
|
||||||
|
Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
|
||||||
|
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID,
|
||||||
|
Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
|
||||||
|
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE,
|
||||||
|
Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
|
||||||
|
|
||||||
|
// remote request
|
||||||
propfind = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath),
|
propfind = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath),
|
||||||
DavConstants.PROPFIND_ALL_PROP,
|
propSet,
|
||||||
DavConstants.DEPTH_0);
|
DavConstants.DEPTH_0);
|
||||||
int status;
|
int status;
|
||||||
status = client.executeMethod(propfind, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
status = client.executeMethod(propfind, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||||
@ -88,7 +110,8 @@ public class ReadRemoteFileOperation extends RemoteOperation {
|
|||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
// Parse response
|
// Parse response
|
||||||
MultiStatus resp = propfind.getResponseBodyAsMultiStatus();
|
MultiStatus resp = propfind.getResponseBodyAsMultiStatus();
|
||||||
WebdavEntry we = new WebdavEntry(resp.getResponses()[0], client.getWebdavUri().getPath());
|
WebdavEntry we = new WebdavEntry(resp.getResponses()[0],
|
||||||
|
client.getWebdavUri().getPath());
|
||||||
RemoteFile remoteFile = new RemoteFile(we);
|
RemoteFile remoteFile = new RemoteFile(we);
|
||||||
ArrayList<Object> files = new ArrayList<Object>();
|
ArrayList<Object> files = new ArrayList<Object>();
|
||||||
files.add(remoteFile);
|
files.add(remoteFile);
|
||||||
@ -105,7 +128,8 @@ public class ReadRemoteFileOperation extends RemoteOperation {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult(e);
|
result = new RemoteOperationResult(e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log_OC.e(TAG, "Synchronizing file " + mRemotePath + ": " + result.getLogMessage(), result.getException());
|
Log_OC.e(TAG, "Synchronizing file " + mRemotePath + ": " + result.getLogMessage(),
|
||||||
|
result.getException());
|
||||||
} finally {
|
} finally {
|
||||||
if (propfind != null)
|
if (propfind != null)
|
||||||
propfind.releaseConnection();
|
propfind.releaseConnection();
|
||||||
|
@ -30,6 +30,9 @@ import org.apache.http.HttpStatus;
|
|||||||
import org.apache.jackrabbit.webdav.DavConstants;
|
import org.apache.jackrabbit.webdav.DavConstants;
|
||||||
import org.apache.jackrabbit.webdav.MultiStatus;
|
import org.apache.jackrabbit.webdav.MultiStatus;
|
||||||
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
||||||
|
import org.apache.jackrabbit.webdav.property.DavPropertyName;
|
||||||
|
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
|
||||||
|
import org.apache.jackrabbit.webdav.xml.Namespace;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.network.WebdavEntry;
|
import com.owncloud.android.lib.common.network.WebdavEntry;
|
||||||
@ -72,9 +75,27 @@ public class ReadRemoteFolderOperation extends RemoteOperation {
|
|||||||
PropFindMethod query = null;
|
PropFindMethod query = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// PropFind Properties ( instead of DavConstants.PROPFIND_ALL_PROP )
|
||||||
|
DavPropertyNameSet propSet = new DavPropertyNameSet();
|
||||||
|
propSet.add(DavPropertyName.DISPLAYNAME);
|
||||||
|
propSet.add(DavPropertyName.GETCONTENTTYPE);
|
||||||
|
propSet.add(DavPropertyName.RESOURCETYPE);
|
||||||
|
propSet.add(DavPropertyName.GETCONTENTLENGTH);
|
||||||
|
propSet.add(DavPropertyName.GETLASTMODIFIED);
|
||||||
|
propSet.add(DavPropertyName.CREATIONDATE);
|
||||||
|
propSet.add(DavPropertyName.GETETAG);
|
||||||
|
propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_USED_BYTES));
|
||||||
|
propSet.add(DavPropertyName.create(WebdavEntry.PROPERTY_QUOTA_AVAILABLE_BYTES));
|
||||||
|
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS,
|
||||||
|
Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
|
||||||
|
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID,
|
||||||
|
Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
|
||||||
|
propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE,
|
||||||
|
Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
|
||||||
|
|
||||||
// remote request
|
// remote request
|
||||||
query = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath),
|
query = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath),
|
||||||
DavConstants.PROPFIND_ALL_PROP,
|
propSet,
|
||||||
DavConstants.DEPTH_1);
|
DavConstants.DEPTH_1);
|
||||||
int status = client.executeMethod(query);
|
int status = client.executeMethod(query);
|
||||||
|
|
||||||
@ -111,7 +132,8 @@ public class ReadRemoteFolderOperation extends RemoteOperation {
|
|||||||
Log_OC.i(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage());
|
Log_OC.i(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage());
|
||||||
} else {
|
} else {
|
||||||
if (result.isException()) {
|
if (result.isException()) {
|
||||||
Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage(), result.getException());
|
Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage(),
|
||||||
|
result.getException());
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage());
|
Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage());
|
||||||
}
|
}
|
||||||
@ -139,7 +161,8 @@ public class ReadRemoteFolderOperation extends RemoteOperation {
|
|||||||
mFolderAndFiles = new ArrayList<Object>();
|
mFolderAndFiles = new ArrayList<Object>();
|
||||||
|
|
||||||
// parse data from remote folder
|
// parse data from remote folder
|
||||||
WebdavEntry we = new WebdavEntry(remoteData.getResponses()[0], client.getWebdavUri().getPath());
|
WebdavEntry we = new WebdavEntry(remoteData.getResponses()[0],
|
||||||
|
client.getWebdavUri().getPath());
|
||||||
mFolderAndFiles.add(fillOCFile(we));
|
mFolderAndFiles.add(fillOCFile(we));
|
||||||
|
|
||||||
// loop to update every child
|
// loop to update every child
|
||||||
|
Loading…
x
Reference in New Issue
Block a user