mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 08:26:10 +00:00
make propfind compatible with frontend
This commit is contained in:
parent
74c9430382
commit
ce86ebac8a
@ -35,6 +35,8 @@ import com.owncloud.android.lib.refactor.authentication.credentials.OCAnonymousC
|
|||||||
import com.owncloud.android.lib.refactor.authentication.credentials.OCCredentials;
|
import com.owncloud.android.lib.refactor.authentication.credentials.OCCredentials;
|
||||||
import com.owncloud.android.lib.refactor.exceptions.AccountNotFoundException;
|
import com.owncloud.android.lib.refactor.exceptions.AccountNotFoundException;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.auth.AuthenticationException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +58,7 @@ public class OCAccount {
|
|||||||
*
|
*
|
||||||
* Do not use for anonymous credentials.
|
* Do not use for anonymous credentials.
|
||||||
*/
|
*/
|
||||||
public OCAccount(Account savedAccount, Context context) throws AccountNotFoundException {
|
public OCAccount(Account savedAccount, Context context) throws AccountNotFoundException, IOException, OperationCanceledException, AuthenticatorException {
|
||||||
if (savedAccount == null) {
|
if (savedAccount == null) {
|
||||||
throw new IllegalArgumentException("Parameter 'savedAccount' cannot be null");
|
throw new IllegalArgumentException("Parameter 'savedAccount' cannot be null");
|
||||||
}
|
}
|
||||||
@ -67,7 +69,7 @@ public class OCAccount {
|
|||||||
|
|
||||||
mSavedAccount = savedAccount;
|
mSavedAccount = savedAccount;
|
||||||
mSavedAccountName = savedAccount.name;
|
mSavedAccountName = savedAccount.name;
|
||||||
mCredentials = null; // load of credentials is delayed
|
mCredentials = AccountUtils.getCredentialsForAccount(context, savedAccount);
|
||||||
|
|
||||||
AccountManager ama = AccountManager.get(context.getApplicationContext());
|
AccountManager ama = AccountManager.get(context.getApplicationContext());
|
||||||
String baseUrl = ama.getUserData(mSavedAccount, AccountUtils.Constants.KEY_OC_BASE_URL);
|
String baseUrl = ama.getUserData(mSavedAccount, AccountUtils.Constants.KEY_OC_BASE_URL);
|
||||||
|
@ -54,6 +54,7 @@ public class PropfindOperation extends RemoteOperation<DavResource> {
|
|||||||
return new Result(OK, davOCResource);
|
return new Result(OK, davOCResource);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
return new Result(e);
|
return new Result(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,7 @@ public class UploadRemoteFileOperation extends RemoteOperation<Void> {
|
|||||||
|
|
||||||
DavOCResource davOCResource = new DavOCResource(
|
DavOCResource davOCResource = new DavOCResource(
|
||||||
getClient(),
|
getClient(),
|
||||||
getWebDavHttpUrl(mRemotePath)
|
getWebDavHttpUrl(mRemotePath));
|
||||||
);
|
|
||||||
|
|
||||||
davOCResource.put(
|
davOCResource.put(
|
||||||
requestBody,
|
requestBody,
|
||||||
|
@ -32,6 +32,8 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.network.WebdavEntry;
|
import com.owncloud.android.lib.common.network.WebdavEntry;
|
||||||
|
import com.owncloud.android.lib.refactor.OCContext;
|
||||||
|
import com.owncloud.android.lib.refactor.RemoteOperation;
|
||||||
|
|
||||||
import at.bitfire.dav4android.DavResource;
|
import at.bitfire.dav4android.DavResource;
|
||||||
import at.bitfire.dav4android.PropertyCollection;
|
import at.bitfire.dav4android.PropertyCollection;
|
||||||
@ -45,6 +47,7 @@ import at.bitfire.dav4android.property.owncloud.OCId;
|
|||||||
import at.bitfire.dav4android.property.owncloud.OCPermissions;
|
import at.bitfire.dav4android.property.owncloud.OCPermissions;
|
||||||
import at.bitfire.dav4android.property.owncloud.OCPrivatelink;
|
import at.bitfire.dav4android.property.owncloud.OCPrivatelink;
|
||||||
import at.bitfire.dav4android.property.owncloud.OCSize;
|
import at.bitfire.dav4android.property.owncloud.OCSize;
|
||||||
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains the data of a Remote File from a WebDavEntry
|
* Contains the data of a Remote File from a WebDavEntry
|
||||||
@ -198,15 +201,15 @@ public class RemoteFile implements Parcelable, Serializable {
|
|||||||
this.setPrivateLink(webdavEntry.privateLink());
|
this.setPrivateLink(webdavEntry.privateLink());
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoteFile(final DavResource davResource) {
|
public RemoteFile(final DavResource davResource, OCContext context) {
|
||||||
this(Uri.decode(davResource.getLocation().encodedPath()));
|
this(getRemotePathFromUrl(davResource.getLocation(), context));
|
||||||
final PropertyCollection properties = davResource.getProperties();
|
final PropertyCollection properties = davResource.getProperties();
|
||||||
this.setCreationTimestamp(properties.get(CreationDate.class) != null
|
this.setCreationTimestamp(properties.get(CreationDate.class) != null
|
||||||
? Long.parseLong(properties.get(CreationDate.class).getCreationDate())
|
? Long.parseLong(properties.get(CreationDate.class).getCreationDate())
|
||||||
: 0);
|
: 0);
|
||||||
this.setMimeType(properties.get(GetContentType.class) != null
|
this.setMimeType(properties.get(GetContentType.class) != null
|
||||||
? properties.get(GetContentType.class).getType()
|
? properties.get(GetContentType.class).getType()
|
||||||
: "");
|
: "DIR");
|
||||||
this.setModifiedTimestamp(properties.get(GetLastModified.class).getLastModified());
|
this.setModifiedTimestamp(properties.get(GetLastModified.class).getLastModified());
|
||||||
this.setEtag(properties.get(GetETag.class).getETag());
|
this.setEtag(properties.get(GetETag.class).getETag());
|
||||||
this.setPermissions(properties.get(OCPermissions.class).getPermission());
|
this.setPermissions(properties.get(OCPermissions.class).getPermission());
|
||||||
@ -223,6 +226,13 @@ public class RemoteFile implements Parcelable, Serializable {
|
|||||||
this.setPrivateLink(properties.get(OCPrivatelink.class).getLink());
|
this.setPrivateLink(properties.get(OCPrivatelink.class).getLink());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static String getRemotePathFromUrl(HttpUrl url, OCContext context) {
|
||||||
|
final String pathToRemove =
|
||||||
|
"/" + RemoteOperation.WEBDAV_PATH_4_0 + "/" + context.getOCAccount().getDisplayName();
|
||||||
|
return Uri.decode(url.encodedPath()).replace(pathToRemove, "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used internally. Reset all file properties
|
* Used internally. Reset all file properties
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user