diff --git a/src/com/owncloud/android/lib/refactor/account/OCAccount.java b/src/com/owncloud/android/lib/refactor/account/OCAccount.java index 007722ec..a84eac2d 100644 --- a/src/com/owncloud/android/lib/refactor/account/OCAccount.java +++ b/src/com/owncloud/android/lib/refactor/account/OCAccount.java @@ -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); diff --git a/src/com/owncloud/android/lib/refactor/resources/files/PropfindOperation.java b/src/com/owncloud/android/lib/refactor/resources/files/PropfindOperation.java index 85d2192f..83ce0964 100644 --- a/src/com/owncloud/android/lib/refactor/resources/files/PropfindOperation.java +++ b/src/com/owncloud/android/lib/refactor/resources/files/PropfindOperation.java @@ -54,6 +54,7 @@ public class PropfindOperation extends RemoteOperation { return new Result(OK, davOCResource); } catch (Exception e) { + e.printStackTrace(); return new Result(e); } } diff --git a/src/com/owncloud/android/lib/refactor/resources/files/UploadRemoteFileOperation.java b/src/com/owncloud/android/lib/refactor/resources/files/UploadRemoteFileOperation.java index 8f6b1c2c..1152ad44 100644 --- a/src/com/owncloud/android/lib/refactor/resources/files/UploadRemoteFileOperation.java +++ b/src/com/owncloud/android/lib/refactor/resources/files/UploadRemoteFileOperation.java @@ -63,8 +63,7 @@ public class UploadRemoteFileOperation extends RemoteOperation { DavOCResource davOCResource = new DavOCResource( getClient(), - getWebDavHttpUrl(mRemotePath) - ); + getWebDavHttpUrl(mRemotePath)); davOCResource.put( requestBody, diff --git a/src/com/owncloud/android/lib/resources/files/RemoteFile.java b/src/com/owncloud/android/lib/resources/files/RemoteFile.java index f2e85871..939031db 100644 --- a/src/com/owncloud/android/lib/resources/files/RemoteFile.java +++ b/src/com/owncloud/android/lib/resources/files/RemoteFile.java @@ -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 */