mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +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.exceptions.AccountNotFoundException;
|
||||
|
||||
import org.apache.commons.httpclient.auth.AuthenticationException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@ -56,7 +58,7 @@ public class OCAccount {
|
||||
*
|
||||
* 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) {
|
||||
throw new IllegalArgumentException("Parameter 'savedAccount' cannot be null");
|
||||
}
|
||||
@ -67,7 +69,7 @@ public class OCAccount {
|
||||
|
||||
mSavedAccount = savedAccount;
|
||||
mSavedAccountName = savedAccount.name;
|
||||
mCredentials = null; // load of credentials is delayed
|
||||
mCredentials = AccountUtils.getCredentialsForAccount(context, savedAccount);
|
||||
|
||||
AccountManager ama = AccountManager.get(context.getApplicationContext());
|
||||
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);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new Result(e);
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,7 @@ public class UploadRemoteFileOperation extends RemoteOperation<Void> {
|
||||
|
||||
DavOCResource davOCResource = new DavOCResource(
|
||||
getClient(),
|
||||
getWebDavHttpUrl(mRemotePath)
|
||||
);
|
||||
getWebDavHttpUrl(mRemotePath));
|
||||
|
||||
davOCResource.put(
|
||||
requestBody,
|
||||
|
@ -32,6 +32,8 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
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.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.OCPrivatelink;
|
||||
import at.bitfire.dav4android.property.owncloud.OCSize;
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
/**
|
||||
* Contains the data of a Remote File from a WebDavEntry
|
||||
@ -198,15 +201,15 @@ public class RemoteFile implements Parcelable, Serializable {
|
||||
this.setPrivateLink(webdavEntry.privateLink());
|
||||
}
|
||||
|
||||
public RemoteFile(final DavResource davResource) {
|
||||
this(Uri.decode(davResource.getLocation().encodedPath()));
|
||||
public RemoteFile(final DavResource davResource, OCContext context) {
|
||||
this(getRemotePathFromUrl(davResource.getLocation(), context));
|
||||
final PropertyCollection properties = davResource.getProperties();
|
||||
this.setCreationTimestamp(properties.get(CreationDate.class) != null
|
||||
? Long.parseLong(properties.get(CreationDate.class).getCreationDate())
|
||||
: 0);
|
||||
this.setMimeType(properties.get(GetContentType.class) != null
|
||||
? properties.get(GetContentType.class).getType()
|
||||
: "");
|
||||
: "DIR");
|
||||
this.setModifiedTimestamp(properties.get(GetLastModified.class).getLastModified());
|
||||
this.setEtag(properties.get(GetETag.class).getETag());
|
||||
this.setPermissions(properties.get(OCPermissions.class).getPermission());
|
||||
@ -223,6 +226,13 @@ public class RemoteFile implements Parcelable, Serializable {
|
||||
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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user