mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 08:26:10 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
df743af8c5
10
.travis.yml
10
.travis.yml
@ -2,8 +2,11 @@ sudo: false
|
|||||||
language: android
|
language: android
|
||||||
android:
|
android:
|
||||||
components:
|
components:
|
||||||
- build-tools-22.0.1
|
- platform-tools
|
||||||
- android-19
|
- tools
|
||||||
|
- build-tools-23.0.3
|
||||||
|
- android-23
|
||||||
|
- sys-img-armeabi-v7a-android-23
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
@ -32,8 +35,9 @@ env:
|
|||||||
- secure: gPCBnpGLA2sdSMtfhT+/InThmXNEU8XrrS54uuIP8iXBLvVe0yZrNl76GbMosV0ry3YtDngsmsbHwRjPPb0+3mTTdAqZ60HHzGaNPgEm6b5t0t4bpJ3LW9osLZsuf9jRsI2LD66zxblaMrK2+8hN/dUrj707ijsZHp3SPSQJ6g8=
|
- secure: gPCBnpGLA2sdSMtfhT+/InThmXNEU8XrrS54uuIP8iXBLvVe0yZrNl76GbMosV0ry3YtDngsmsbHwRjPPb0+3mTTdAqZ60HHzGaNPgEm6b5t0t4bpJ3LW9osLZsuf9jRsI2LD66zxblaMrK2+8hN/dUrj707ijsZHp3SPSQJ6g8=
|
||||||
- secure: AnxLVarfwM7IhJ7Sca35USyRlFHFvlcBhWTt2TVDcyQ+ldDyb+U6IWXFK0Yy82QP0ZH/RCLu7FnmHK/rKG0BHNRt1Ymco1VkTQql0MZcHXP+4IKgEvgJyUn1TqYj+hSVmM6lgTA+QUjZYGSfwU8mhUFiU7644ZTdTe6ALdqa+v8=
|
- secure: AnxLVarfwM7IhJ7Sca35USyRlFHFvlcBhWTt2TVDcyQ+ldDyb+U6IWXFK0Yy82QP0ZH/RCLu7FnmHK/rKG0BHNRt1Ymco1VkTQql0MZcHXP+4IKgEvgJyUn1TqYj+hSVmM6lgTA+QUjZYGSfwU8mhUFiU7644ZTdTe6ALdqa+v8=
|
||||||
- secure: ezKyZbb3q1Phcv/vJntuJe0C2req+Hp4/C+tFZIWZ3o8wRO9jVI3bnED9TWQyQOOT0SoRYjJ5zqp0UcEOGCzPeWFO6bA7RWp+zA/R9sziLNcVWMVv3WXnuClQjPBHJeXRnP7YmNjxDmSfV97a14dk5d9LgJZYliTDepH4dLsxro=
|
- secure: ezKyZbb3q1Phcv/vJntuJe0C2req+Hp4/C+tFZIWZ3o8wRO9jVI3bnED9TWQyQOOT0SoRYjJ5zqp0UcEOGCzPeWFO6bA7RWp+zA/R9sziLNcVWMVv3WXnuClQjPBHJeXRnP7YmNjxDmSfV97a14dk5d9LgJZYliTDepH4dLsxro=
|
||||||
|
- secure: HV8REF7bB1i6cBEe4YCZvjgTf6tGiptAPzp9qZXGUH9Lxh6yUjYMXXP8flDaIFcE2JuAakW6P4SPr7/SQ+X4f8/84cNhmU1I+6Y1nG37WvelRHQVslOUDbl1TNUnynYZ+ybkb3BtrQvggCGMdQKvGZXYiggFhN/TWuDo0c7Q2Ro=
|
||||||
matrix:
|
matrix:
|
||||||
- ANDROID_TARGET=android-19 ANDROID_ABI=armeabi-v7a
|
- ANDROID_TARGET=android-23 ANDROID_ABI=armeabi-v7a
|
||||||
addons:
|
addons:
|
||||||
coverity_scan:
|
coverity_scan:
|
||||||
project:
|
project:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="8"
|
android:minSdkVersion="8"
|
||||||
android:targetSdkVersion="19" />
|
android:targetSdkVersion="23" />
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
ownCloud Android Library is available under MIT license
|
ownCloud Android Library is available under MIT license
|
||||||
|
|
||||||
Copyright (C) 2014 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
Copyright (C) 2012 Bartek Przybylski
|
Copyright (C) 2012 Bartek Przybylski
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -3,7 +3,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
classpath 'com.android.tools.build:gradle:2.1.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,8 +18,8 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 19
|
compileSdkVersion 23
|
||||||
buildToolsVersion "22.0.1"
|
buildToolsVersion "23.0.3"
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
@ -45,9 +45,7 @@ android {
|
|||||||
release.setRoot('build-types/release')
|
release.setRoot('build-types/release')
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
abortOnError false
|
abortOnError false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Mon Jan 19 11:03:11 CET 2015
|
#Mon Dec 28 10:00:20 PST 2015
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
||||||
|
@ -11,5 +11,5 @@
|
|||||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-19
|
target=android-23
|
||||||
android.library=true
|
android.library=true
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -30,7 +30,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="8"
|
android:minSdkVersion="8"
|
||||||
android:targetSdkVersion="19" />
|
android:targetSdkVersion="23" />
|
||||||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
||||||
<activity android:name="MainActivity"
|
<activity android:name="MainActivity"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
@ -9,8 +9,8 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 19
|
compileSdkVersion 23
|
||||||
buildToolsVersion "22.0.1"
|
buildToolsVersion "23.0.3"
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
|
BIN
sample_client/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
sample_client/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
#Wed Apr 10 15:27:10 PDT 2013
|
#Mon Dec 28 10:00:20 PST 2015
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
||||||
|
@ -11,5 +11,5 @@
|
|||||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-19
|
target=android-23
|
||||||
android.library.reference.1=..
|
android.library.reference.1=..
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -31,6 +31,7 @@ import com.owncloud.android.lib.common.accounts.AccountUtils;
|
|||||||
import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
|
import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
|
import android.accounts.AccountManager;
|
||||||
import android.accounts.AuthenticatorException;
|
import android.accounts.AuthenticatorException;
|
||||||
import android.accounts.OperationCanceledException;
|
import android.accounts.OperationCanceledException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -47,6 +48,8 @@ public class OwnCloudAccount {
|
|||||||
|
|
||||||
private OwnCloudCredentials mCredentials;
|
private OwnCloudCredentials mCredentials;
|
||||||
|
|
||||||
|
private String mDisplayName;
|
||||||
|
|
||||||
private String mSavedAccountName;
|
private String mSavedAccountName;
|
||||||
|
|
||||||
private Account mSavedAccount;
|
private Account mSavedAccount;
|
||||||
@ -68,52 +71,17 @@ public class OwnCloudAccount {
|
|||||||
|
|
||||||
mSavedAccount = savedAccount;
|
mSavedAccount = savedAccount;
|
||||||
mSavedAccountName = savedAccount.name;
|
mSavedAccountName = savedAccount.name;
|
||||||
|
mCredentials = null; // load of credentials is delayed
|
||||||
|
|
||||||
|
AccountManager ama = AccountManager.get(context.getApplicationContext());
|
||||||
|
String baseUrl = ama.getUserData(mSavedAccount, AccountUtils.Constants.KEY_OC_BASE_URL);
|
||||||
|
if (baseUrl == null ) {
|
||||||
|
throw new AccountNotFoundException(mSavedAccount, "Account not found", null);
|
||||||
|
}
|
||||||
mBaseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(context, mSavedAccount));
|
mBaseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(context, mSavedAccount));
|
||||||
mCredentials = null;
|
mDisplayName = ama.getUserData(mSavedAccount, AccountUtils.Constants.KEY_DISPLAY_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method for deferred load of account attributes from AccountManager
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
* @throws AccountNotFoundException
|
|
||||||
* @throws AuthenticatorException
|
|
||||||
* @throws IOException
|
|
||||||
* @throws OperationCanceledException
|
|
||||||
*/
|
|
||||||
public void loadCredentials(Context context)
|
|
||||||
throws AccountNotFoundException, AuthenticatorException,
|
|
||||||
IOException, OperationCanceledException {
|
|
||||||
|
|
||||||
if (context == null) {
|
|
||||||
throw new IllegalArgumentException("Parameter 'context' cannot be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mSavedAccount != null) {
|
|
||||||
mCredentials = AccountUtils.getCredentialsForAccount(context, mSavedAccount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
public OwnCloudAccount(Account savedAccount, Context context)
|
|
||||||
throws AccountNotFoundException, AuthenticatorException,
|
|
||||||
IOException, OperationCanceledException {
|
|
||||||
|
|
||||||
if (savedAccount == null) {
|
|
||||||
throw new IllegalArgumentException("Parameter 'savedAccount' cannot be null");
|
|
||||||
}
|
|
||||||
if (context == null) {
|
|
||||||
throw new IllegalArgumentException("Parameter 'context' cannot be null");
|
|
||||||
}
|
|
||||||
|
|
||||||
mSavedAccountName = savedAccount.name;
|
|
||||||
mBaseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(context, savedAccount));
|
|
||||||
mCredentials = AccountUtils.getCredentialsForAccount(context, savedAccount);
|
|
||||||
if (mCredentials == null) {
|
|
||||||
mCredentials = OwnCloudCredentialsFactory.getAnonymousCredentials();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for non yet saved OC accounts.
|
* Constructor for non yet saved OC accounts.
|
||||||
@ -137,9 +105,27 @@ public class OwnCloudAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isAnonymous() {
|
/**
|
||||||
return (mCredentials == null);
|
* Method for deferred load of account attributes from AccountManager
|
||||||
} // TODO no more
|
*
|
||||||
|
* @param context
|
||||||
|
* @throws AccountNotFoundException
|
||||||
|
* @throws AuthenticatorException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws OperationCanceledException
|
||||||
|
*/
|
||||||
|
public void loadCredentials(Context context)
|
||||||
|
throws AccountNotFoundException, AuthenticatorException,
|
||||||
|
IOException, OperationCanceledException {
|
||||||
|
|
||||||
|
if (context == null) {
|
||||||
|
throw new IllegalArgumentException("Parameter 'context' cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSavedAccount != null) {
|
||||||
|
mCredentials = AccountUtils.getCredentialsForAccount(context, mSavedAccount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Uri getBaseUri() {
|
public Uri getBaseUri() {
|
||||||
return mBaseUri;
|
return mBaseUri;
|
||||||
@ -153,5 +139,16 @@ public class OwnCloudAccount {
|
|||||||
return mSavedAccountName;
|
return mSavedAccountName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
if (mDisplayName != null && mDisplayName.length() > 0) {
|
||||||
|
return mDisplayName;
|
||||||
|
} else if (mCredentials != null) {
|
||||||
|
return mCredentials.getUsername();
|
||||||
|
} else if (mSavedAccount != null) {
|
||||||
|
return AccountUtils.getUsernameForAccount(mSavedAccount);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -47,6 +47,7 @@ public class OwnCloudBasicCredentials implements OwnCloudCredentials {
|
|||||||
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
|
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
|
||||||
|
|
||||||
client.getParams().setAuthenticationPreemptive(true);
|
client.getParams().setAuthenticationPreemptive(true);
|
||||||
|
client.getParams().setCredentialCharset(OwnCloudCredentialsFactory.CREDENTIAL_CHARSET);
|
||||||
client.getState().setCredentials(
|
client.getState().setCredentials(
|
||||||
AuthScope.ANY,
|
AuthScope.ANY,
|
||||||
new UsernamePasswordCredentials(mUsername, mPassword)
|
new UsernamePasswordCredentials(mUsername, mPassword)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -49,6 +49,7 @@ public class OwnCloudBearerCredentials implements OwnCloudCredentials {
|
|||||||
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
|
client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
|
||||||
|
|
||||||
client.getParams().setAuthenticationPreemptive(true);
|
client.getParams().setAuthenticationPreemptive(true);
|
||||||
|
client.getParams().setCredentialCharset(OwnCloudCredentialsFactory.CREDENTIAL_CHARSET);
|
||||||
client.getState().setCredentials(
|
client.getState().setCredentials(
|
||||||
AuthScope.ANY,
|
AuthScope.ANY,
|
||||||
new BearerCredentials(mAccessToken)
|
new BearerCredentials(mAccessToken)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
* Copyright (C) 2012 Bartek Przybylski
|
* Copyright (C) 2012 Bartek Przybylski
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -36,14 +36,13 @@ import org.apache.commons.httpclient.HttpConnectionManager;
|
|||||||
import org.apache.commons.httpclient.HttpException;
|
import org.apache.commons.httpclient.HttpException;
|
||||||
import org.apache.commons.httpclient.HttpMethod;
|
import org.apache.commons.httpclient.HttpMethod;
|
||||||
import org.apache.commons.httpclient.HttpMethodBase;
|
import org.apache.commons.httpclient.HttpMethodBase;
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.HttpVersion;
|
import org.apache.commons.httpclient.HttpVersion;
|
||||||
import org.apache.commons.httpclient.URI;
|
import org.apache.commons.httpclient.URI;
|
||||||
import org.apache.commons.httpclient.cookie.CookiePolicy;
|
import org.apache.commons.httpclient.cookie.CookiePolicy;
|
||||||
import org.apache.commons.httpclient.methods.HeadMethod;
|
import org.apache.commons.httpclient.methods.HeadMethod;
|
||||||
import org.apache.commons.httpclient.params.HttpMethodParams;
|
import org.apache.commons.httpclient.params.HttpMethodParams;
|
||||||
import org.apache.commons.httpclient.params.HttpParams;
|
import org.apache.commons.httpclient.params.HttpParams;
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
import org.apache.http.params.CoreProtocolPNames;
|
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
@ -60,6 +59,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
public static final int MAX_REDIRECTIONS_COUNT = 3;
|
public static final int MAX_REDIRECTIONS_COUNT = 3;
|
||||||
private static final String PARAM_SINGLE_COOKIE_HEADER = "http.protocol.single-cookie-header";
|
private static final String PARAM_SINGLE_COOKIE_HEADER = "http.protocol.single-cookie-header";
|
||||||
private static final boolean PARAM_SINGLE_COOKIE_HEADER_VALUE = true;
|
private static final boolean PARAM_SINGLE_COOKIE_HEADER_VALUE = true;
|
||||||
|
private static final String PARAM_PROTOCOL_VERSION = "http.protocol.version";
|
||||||
|
|
||||||
private static byte[] sExhaustBuffer = new byte[1024];
|
private static byte[] sExhaustBuffer = new byte[1024];
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
String userAgent = OwnCloudClientManagerFactory.getUserAgent();
|
String userAgent = OwnCloudClientManagerFactory.getUserAgent();
|
||||||
getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent);
|
getParams().setParameter(HttpMethodParams.USER_AGENT, userAgent);
|
||||||
getParams().setParameter(
|
getParams().setParameter(
|
||||||
CoreProtocolPNames.PROTOCOL_VERSION,
|
PARAM_PROTOCOL_VERSION,
|
||||||
HttpVersion.HTTP_1_1);
|
HttpVersion.HTTP_1_1);
|
||||||
|
|
||||||
getParams().setCookiePolicy(
|
getParams().setCookiePolicy(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -83,7 +83,7 @@ public class OwnCloudClientFactory {
|
|||||||
am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||||
OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso);
|
OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso);
|
||||||
|
|
||||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
String username = AccountUtils.getUsernameForAccount(account);
|
||||||
if (isOauth2) {
|
if (isOauth2) {
|
||||||
String accessToken = am.blockingGetAuthToken(
|
String accessToken = am.blockingGetAuthToken(
|
||||||
account,
|
account,
|
||||||
@ -137,7 +137,7 @@ public class OwnCloudClientFactory {
|
|||||||
am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||||
OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso);
|
OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso);
|
||||||
|
|
||||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
String username = AccountUtils.getUsernameForAccount(account);
|
||||||
if (isOauth2) { // TODO avoid a call to getUserData here
|
if (isOauth2) { // TODO avoid a call to getUserData here
|
||||||
AccountManagerFuture<Bundle> future = am.getAuthToken(
|
AccountManagerFuture<Bundle> future = am.getAuthToken(
|
||||||
account,
|
account,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -26,6 +26,8 @@ package com.owncloud.android.lib.common;
|
|||||||
|
|
||||||
public class OwnCloudCredentialsFactory {
|
public class OwnCloudCredentialsFactory {
|
||||||
|
|
||||||
|
public static final String CREDENTIAL_CHARSET = "UTF-8";
|
||||||
|
|
||||||
private static OwnCloudAnonymousCredentials sAnonymousCredentials;
|
private static OwnCloudAnonymousCredentials sAnonymousCredentials;
|
||||||
|
|
||||||
public static OwnCloudCredentials newBasicCredentials(String username, String password) {
|
public static OwnCloudCredentials newBasicCredentials(String username, String password) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -41,6 +41,7 @@ public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials {
|
|||||||
@Override
|
@Override
|
||||||
public void applyTo(OwnCloudClient client) {
|
public void applyTo(OwnCloudClient client) {
|
||||||
client.getParams().setAuthenticationPreemptive(false);
|
client.getParams().setAuthenticationPreemptive(false);
|
||||||
|
client.getParams().setCredentialCharset(OwnCloudCredentialsFactory.CREDENTIAL_CHARSET);
|
||||||
client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
|
client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
|
||||||
client.setFollowRedirects(false);
|
client.setFollowRedirects(false);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
* Copyright (C) 2012 Bartek Przybylski
|
* Copyright (C) 2012 Bartek Przybylski
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -147,6 +147,22 @@ public class AccountUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the username corresponding to an OC account.
|
||||||
|
*
|
||||||
|
* @param account An OC account
|
||||||
|
* @return Username for the given account, extracted from the account.name
|
||||||
|
*/
|
||||||
|
public static String getUsernameForAccount(Account account) {
|
||||||
|
String username = null;
|
||||||
|
try {
|
||||||
|
username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log_OC.e(TAG, "Couldn't get a username for the given account", e);
|
||||||
|
}
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
@ -168,7 +184,7 @@ public class AccountUtils {
|
|||||||
account,
|
account,
|
||||||
AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||||
|
|
||||||
String username = account.name.substring(0, account.name.lastIndexOf('@'));
|
String username = AccountUtils.getUsernameForAccount(account);
|
||||||
|
|
||||||
if (isOauth2) {
|
if (isOauth2) {
|
||||||
String accessToken = am.blockingGetAuthToken(
|
String accessToken = am.blockingGetAuthToken(
|
||||||
@ -363,6 +379,12 @@ public class AccountUtils {
|
|||||||
* OC account version
|
* OC account version
|
||||||
*/
|
*/
|
||||||
public static final String KEY_OC_ACCOUNT_VERSION = "oc_account_version";
|
public static final String KEY_OC_ACCOUNT_VERSION = "oc_account_version";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User's display name
|
||||||
|
*/
|
||||||
|
public static final String KEY_DISPLAY_NAME = "oc_display_name";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -25,6 +25,7 @@
|
|||||||
package com.owncloud.android.lib.common.network;
|
package com.owncloud.android.lib.common.network;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -58,7 +59,9 @@ public class ChunkFromFileChannelRequestEntity implements RequestEntity, Progres
|
|||||||
Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>();
|
Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>();
|
||||||
private ByteBuffer mBuffer = ByteBuffer.allocate(4096);
|
private ByteBuffer mBuffer = ByteBuffer.allocate(4096);
|
||||||
|
|
||||||
public ChunkFromFileChannelRequestEntity(final FileChannel channel, final String contentType, long chunkSize, final File file) {
|
public ChunkFromFileChannelRequestEntity(
|
||||||
|
final FileChannel channel, final String contentType, long chunkSize, final File file
|
||||||
|
) {
|
||||||
super();
|
super();
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
throw new IllegalArgumentException("File may not be null");
|
throw new IllegalArgumentException("File may not be null");
|
||||||
@ -127,7 +130,12 @@ public class ChunkFromFileChannelRequestEntity implements RequestEntity, Progres
|
|||||||
long maxCount = Math.min(mOffset + mChunkSize, mChannel.size());
|
long maxCount = Math.min(mOffset + mChunkSize, mChannel.size());
|
||||||
while (mChannel.position() < maxCount) {
|
while (mChannel.position() < maxCount) {
|
||||||
readCount = mChannel.read(mBuffer);
|
readCount = mChannel.read(mBuffer);
|
||||||
|
try {
|
||||||
out.write(mBuffer.array(), 0, readCount);
|
out.write(mBuffer.array(), 0, readCount);
|
||||||
|
} catch (IOException io) {
|
||||||
|
// work-around try catch to filter exception in writing
|
||||||
|
throw new FileRequestEntity.WriteException(io);
|
||||||
|
}
|
||||||
mBuffer.clear();
|
mBuffer.clear();
|
||||||
if (mTransferred < maxCount) { // condition to avoid accumulate progress for repeated chunks
|
if (mTransferred < maxCount) { // condition to avoid accumulate progress for repeated chunks
|
||||||
mTransferred += readCount;
|
mTransferred += readCount;
|
||||||
@ -141,10 +149,19 @@ public class ChunkFromFileChannelRequestEntity implements RequestEntity, Progres
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException io) {
|
} catch (IOException io) {
|
||||||
Log_OC.e(TAG, io.getMessage());
|
// any read problem will be handled as if the file is not there
|
||||||
throw new RuntimeException("Ugly solution to workaround the default policy of retries when the server falls while uploading ; temporal fix; really", io);
|
if (io instanceof FileNotFoundException) {
|
||||||
|
throw io;
|
||||||
|
} else {
|
||||||
|
FileNotFoundException fnf = new FileNotFoundException("Exception reading source file");
|
||||||
|
fnf.initCause(io);
|
||||||
|
throw fnf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (FileRequestEntity.WriteException we) {
|
||||||
|
throw we.getWrapped();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
* Copyright (C) 2012 Bartek Przybylski
|
* Copyright (C) 2012 Bartek Przybylski
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -26,6 +26,7 @@
|
|||||||
package com.owncloud.android.lib.common.network;
|
package com.owncloud.android.lib.common.network;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
@ -100,12 +101,9 @@ public class FileRequestEntity implements RequestEntity, ProgressiveDataTransfer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeRequest(final OutputStream out) throws IOException {
|
public void writeRequest(final OutputStream out) throws IOException {
|
||||||
//byte[] tmp = new byte[4096];
|
|
||||||
ByteBuffer tmp = ByteBuffer.allocate(4096);
|
ByteBuffer tmp = ByteBuffer.allocate(4096);
|
||||||
int readResult = 0;
|
int readResult = 0;
|
||||||
|
|
||||||
// TODO(bprzybylski): each mem allocation can throw OutOfMemoryError we need to handle it
|
|
||||||
// globally in some fashionable manner
|
|
||||||
RandomAccessFile raf = new RandomAccessFile(mFile, "r");
|
RandomAccessFile raf = new RandomAccessFile(mFile, "r");
|
||||||
FileChannel channel = raf.getChannel();
|
FileChannel channel = raf.getChannel();
|
||||||
Iterator<OnDatatransferProgressListener> it = null;
|
Iterator<OnDatatransferProgressListener> it = null;
|
||||||
@ -114,7 +112,12 @@ public class FileRequestEntity implements RequestEntity, ProgressiveDataTransfer
|
|||||||
if (size == 0) size = -1;
|
if (size == 0) size = -1;
|
||||||
try {
|
try {
|
||||||
while ((readResult = channel.read(tmp)) >= 0) {
|
while ((readResult = channel.read(tmp)) >= 0) {
|
||||||
|
try {
|
||||||
out.write(tmp.array(), 0, readResult);
|
out.write(tmp.array(), 0, readResult);
|
||||||
|
} catch (IOException io) {
|
||||||
|
// work-around try catch to filter exception in writing
|
||||||
|
throw new WriteException(io);
|
||||||
|
}
|
||||||
tmp.clear();
|
tmp.clear();
|
||||||
transferred += readResult;
|
transferred += readResult;
|
||||||
synchronized (mDataTransferListeners) {
|
synchronized (mDataTransferListeners) {
|
||||||
@ -126,12 +129,37 @@ public class FileRequestEntity implements RequestEntity, ProgressiveDataTransfer
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException io) {
|
} catch (IOException io) {
|
||||||
Log_OC.e("FileRequestException", io.getMessage());
|
// any read problem will be handled as if the file is not there
|
||||||
throw new RuntimeException("Ugly solution to workaround the default policy of retries when the server falls while uploading ; temporal fix; really", io);
|
if (io instanceof FileNotFoundException) {
|
||||||
|
throw io;
|
||||||
|
} else {
|
||||||
|
FileNotFoundException fnf = new FileNotFoundException("Exception reading source file");
|
||||||
|
fnf.initCause(io);
|
||||||
|
throw fnf;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (WriteException we) {
|
||||||
|
throw we.getWrapped();
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
try {
|
||||||
channel.close();
|
channel.close();
|
||||||
raf.close();
|
raf.close();
|
||||||
|
} catch (IOException io) {
|
||||||
|
// ignore failures closing source file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static class WriteException extends Exception {
|
||||||
|
IOException mWrapped;
|
||||||
|
|
||||||
|
WriteException(IOException wrapped) {
|
||||||
|
mWrapped = wrapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOException getWrapped() {
|
||||||
|
return mWrapped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
* Copyright (C) 2012 Bartek Przybylski
|
* Copyright (C) 2012 Bartek Przybylski
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.common.network;
|
package com.owncloud.android.lib.common.network;
|
||||||
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@ -53,7 +53,6 @@ public class RedirectionPath {
|
|||||||
private String[] mLocations = null;
|
private String[] mLocations = null;
|
||||||
|
|
||||||
private int mLastLocation = -1;
|
private int mLastLocation = -1;
|
||||||
private int maxRedirections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public constructor.
|
* Public constructor.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
* Copyright (C) 2012 Bartek Przybylski
|
* Copyright (C) 2012 Bartek Przybylski
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -306,7 +306,8 @@ public abstract class RemoteOperation implements Runnable {
|
|||||||
* to trigger authentication update */
|
* to trigger authentication update */
|
||||||
if (mCallerActivity != null && mAccount != null && mContext != null &&
|
if (mCallerActivity != null && mAccount != null && mContext != null &&
|
||||||
!result.isSuccess() &&
|
!result.isSuccess() &&
|
||||||
(result.getCode() == ResultCode.UNAUTHORIZED || result.isIdPRedirection())) {
|
ResultCode.UNAUTHORIZED.equals(result.getCode())
|
||||||
|
) {
|
||||||
/// possible fail due to lack of authorization
|
/// possible fail due to lack of authorization
|
||||||
// in an operation performed in foreground
|
// in an operation performed in foreground
|
||||||
OwnCloudCredentials cred = mClient.getCredentials();
|
OwnCloudCredentials cred = mClient.getCredentials();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -25,6 +25,7 @@
|
|||||||
package com.owncloud.android.lib.common.operations;
|
package com.owncloud.android.lib.common.operations;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -108,7 +109,10 @@ public class RemoteOperationResult implements Serializable {
|
|||||||
PARTIAL_MOVE_DONE,
|
PARTIAL_MOVE_DONE,
|
||||||
PARTIAL_COPY_DONE,
|
PARTIAL_COPY_DONE,
|
||||||
SHARE_WRONG_PARAMETER,
|
SHARE_WRONG_PARAMETER,
|
||||||
WRONG_SERVER_RESPONSE, INVALID_CHARACTER_DETECT_IN_SERVER
|
WRONG_SERVER_RESPONSE,
|
||||||
|
INVALID_CHARACTER_DETECT_IN_SERVER,
|
||||||
|
DELAYED_FOR_WIFI,
|
||||||
|
LOCAL_FILE_NOT_FOUND
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mSuccess = false;
|
private boolean mSuccess = false;
|
||||||
@ -180,6 +184,9 @@ public class RemoteOperationResult implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isIdPRedirection()) {
|
||||||
|
mCode = ResultCode.UNAUTHORIZED; // overrides default ResultCode.UNKNOWN
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoteOperationResult(boolean success, String bodyResponse, int httpCode) {
|
public RemoteOperationResult(boolean success, String bodyResponse, int httpCode) {
|
||||||
@ -254,6 +261,9 @@ public class RemoteOperationResult implements Serializable {
|
|||||||
mCode = ResultCode.SSL_ERROR;
|
mCode = ResultCode.SSL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (e instanceof FileNotFoundException) {
|
||||||
|
mCode = ResultCode.LOCAL_FILE_NOT_FOUND;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mCode = ResultCode.UNKNOWN_ERROR;
|
mCode = ResultCode.UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2014 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -36,8 +36,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
import org.apache.commons.httpclient.Header;
|
import org.apache.commons.httpclient.Header;
|
||||||
import org.apache.commons.httpclient.HttpException;
|
import org.apache.commons.httpclient.HttpException;
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
|
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -25,7 +25,7 @@ package com.owncloud.android.lib.resources.files;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.commons.httpclient.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;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -26,7 +26,7 @@ package com.owncloud.android.lib.resources.files;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.commons.httpclient.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;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -32,9 +32,11 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.methods.PutMethod;
|
import org.apache.commons.httpclient.methods.PutMethod;
|
||||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.commons.httpclient.params.HttpMethodParams;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.network.FileRequestEntity;
|
import com.owncloud.android.lib.common.network.FileRequestEntity;
|
||||||
@ -87,8 +89,16 @@ public class UploadRemoteFileOperation extends RemoteOperation {
|
|||||||
@Override
|
@Override
|
||||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||||
RemoteOperationResult result = null;
|
RemoteOperationResult result = null;
|
||||||
|
DefaultHttpMethodRetryHandler oldRetryHandler =
|
||||||
|
(DefaultHttpMethodRetryHandler) client.getParams().getParameter(HttpMethodParams.RETRY_HANDLER);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// prevent that uploads are retried automatically by network library
|
||||||
|
client.getParams().setParameter(
|
||||||
|
HttpMethodParams.RETRY_HANDLER,
|
||||||
|
new DefaultHttpMethodRetryHandler(0, false)
|
||||||
|
);
|
||||||
|
|
||||||
mPutMethod = new PutMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
|
mPutMethod = new PutMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
|
||||||
|
|
||||||
if (mCancellationRequested.get()) {
|
if (mCancellationRequested.get()) {
|
||||||
@ -114,6 +124,12 @@ public class UploadRemoteFileOperation extends RemoteOperation {
|
|||||||
} else {
|
} else {
|
||||||
result = new RemoteOperationResult(e);
|
result = new RemoteOperationResult(e);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
// reset previous retry handler
|
||||||
|
client.getParams().setParameter(
|
||||||
|
HttpMethodParams.RETRY_HANDLER,
|
||||||
|
oldRetryHandler
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author masensio
|
* @author masensio
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.resources.shares;
|
package com.owncloud.android.lib.resources.shares;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.methods.PostMethod;
|
import org.apache.commons.httpclient.methods.PostMethod;
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -30,8 +30,8 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
|
|||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the data about a Share resource, known its remote ID.
|
* Get the data about a Share resource, known its remote ID.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* @author masensio
|
* @author masensio
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -34,8 +34,8 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
|
|||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public class GetRemoteShareesOperation extends RemoteOperation{
|
|||||||
|
|
||||||
// Arguments - constant values
|
// Arguments - constant values
|
||||||
private static final String VALUE_FORMAT = "json";
|
private static final String VALUE_FORMAT = "json";
|
||||||
private static final String VALUE_ITEM_TYPE = "search"; // to get the server search for users / groups
|
private static final String VALUE_ITEM_TYPE = "file"; // to get the server search for users / groups
|
||||||
|
|
||||||
|
|
||||||
// JSON Node names
|
// JSON Node names
|
||||||
@ -87,15 +87,12 @@ public class GetRemoteShareesOperation extends RemoteOperation{
|
|||||||
private static final String NODE_EXACT = "exact";
|
private static final String NODE_EXACT = "exact";
|
||||||
private static final String NODE_USERS = "users";
|
private static final String NODE_USERS = "users";
|
||||||
private static final String NODE_GROUPS = "groups";
|
private static final String NODE_GROUPS = "groups";
|
||||||
|
private static final String NODE_REMOTES = "remotes";
|
||||||
public static final String NODE_VALUE = "value";
|
public static final String NODE_VALUE = "value";
|
||||||
public static final String PROPERTY_LABEL = "label";
|
public static final String PROPERTY_LABEL = "label";
|
||||||
public static final String PROPERTY_SHARE_TYPE = "shareType";
|
public static final String PROPERTY_SHARE_TYPE = "shareType";
|
||||||
public static final String PROPERTY_SHARE_WITH = "shareWith";
|
public static final String PROPERTY_SHARE_WITH = "shareWith";
|
||||||
|
|
||||||
// Result types
|
|
||||||
public static final Byte USER_TYPE = 0;
|
|
||||||
public static final Byte GROUP_TYPE = 1;
|
|
||||||
|
|
||||||
private String mSearchString;
|
private String mSearchString;
|
||||||
private int mPage;
|
private int mPage;
|
||||||
private int mPerPage;
|
private int mPerPage;
|
||||||
@ -146,17 +143,21 @@ public class GetRemoteShareesOperation extends RemoteOperation{
|
|||||||
JSONObject respExact = respData.getJSONObject(NODE_EXACT);
|
JSONObject respExact = respData.getJSONObject(NODE_EXACT);
|
||||||
JSONArray respExactUsers = respExact.getJSONArray(NODE_USERS);
|
JSONArray respExactUsers = respExact.getJSONArray(NODE_USERS);
|
||||||
JSONArray respExactGroups = respExact.getJSONArray(NODE_GROUPS);
|
JSONArray respExactGroups = respExact.getJSONArray(NODE_GROUPS);
|
||||||
|
JSONArray respExactRemotes = respExact.getJSONArray(NODE_REMOTES);
|
||||||
JSONArray respPartialUsers = respData.getJSONArray(NODE_USERS);
|
JSONArray respPartialUsers = respData.getJSONArray(NODE_USERS);
|
||||||
JSONArray respPartialGroups = respData.getJSONArray(NODE_GROUPS);
|
JSONArray respPartialGroups = respData.getJSONArray(NODE_GROUPS);
|
||||||
|
JSONArray respPartialRemotes = respData.getJSONArray(NODE_REMOTES);
|
||||||
JSONArray[] jsonResults = {
|
JSONArray[] jsonResults = {
|
||||||
respExactUsers,
|
respExactUsers,
|
||||||
respExactGroups,
|
respExactGroups,
|
||||||
|
respExactRemotes,
|
||||||
respPartialUsers,
|
respPartialUsers,
|
||||||
respPartialGroups
|
respPartialGroups,
|
||||||
|
respPartialRemotes
|
||||||
};
|
};
|
||||||
|
|
||||||
ArrayList<Object> data = new ArrayList<Object>(); // For result data
|
ArrayList<Object> data = new ArrayList<Object>(); // For result data
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<6; i++) {
|
||||||
for(int j=0; j< jsonResults[i].length(); j++){
|
for(int j=0; j< jsonResults[i].length(); j++){
|
||||||
JSONObject jsonResult = jsonResults[i].getJSONObject(j);
|
JSONObject jsonResult = jsonResults[i].getJSONObject(j);
|
||||||
data.add(jsonResult);
|
data.add(jsonResult);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author masensio
|
* @author masensio
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -26,9 +26,9 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.resources.shares;
|
package com.owncloud.android.lib.resources.shares;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.NameValuePair;
|
import org.apache.commons.httpclient.NameValuePair;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author masensio
|
* @author masensio
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -26,8 +26,8 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.resources.shares;
|
package com.owncloud.android.lib.resources.shares;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -41,7 +41,9 @@ import com.owncloud.android.lib.resources.files.FileUtils;
|
|||||||
*/
|
*/
|
||||||
public class OCShare implements Parcelable, Serializable {
|
public class OCShare implements Parcelable, Serializable {
|
||||||
|
|
||||||
/** Generated - should be refreshed every time the class changes!! */
|
/**
|
||||||
|
* Generated - should be refreshed every time the class changes!!
|
||||||
|
*/
|
||||||
private static final long serialVersionUID = 4124975224281327921L;
|
private static final long serialVersionUID = 4124975224281327921L;
|
||||||
|
|
||||||
private static final String TAG = OCShare.class.getSimpleName();
|
private static final String TAG = OCShare.class.getSimpleName();
|
||||||
@ -62,6 +64,25 @@ public class OCShare implements Parcelable, Serializable {
|
|||||||
CREATE_PERMISSION_FLAG +
|
CREATE_PERMISSION_FLAG +
|
||||||
DELETE_PERMISSION_FLAG
|
DELETE_PERMISSION_FLAG
|
||||||
;
|
;
|
||||||
|
public static final int FEDERATED_PERMISSIONS_FOR_FILE_UP_TO_OC9 =
|
||||||
|
READ_PERMISSION_FLAG +
|
||||||
|
UPDATE_PERMISSION_FLAG
|
||||||
|
;
|
||||||
|
public static final int FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9 =
|
||||||
|
READ_PERMISSION_FLAG +
|
||||||
|
UPDATE_PERMISSION_FLAG +
|
||||||
|
SHARE_PERMISSION_FLAG
|
||||||
|
;
|
||||||
|
public static final int FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 =
|
||||||
|
READ_PERMISSION_FLAG +
|
||||||
|
UPDATE_PERMISSION_FLAG +
|
||||||
|
CREATE_PERMISSION_FLAG +
|
||||||
|
DELETE_PERMISSION_FLAG
|
||||||
|
;
|
||||||
|
public static final int FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 =
|
||||||
|
FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 +
|
||||||
|
SHARE_PERMISSION_FLAG
|
||||||
|
;
|
||||||
|
|
||||||
private long mId;
|
private long mId;
|
||||||
private long mFileSource;
|
private long mFileSource;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author masensio
|
* @author masensio
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -43,7 +43,8 @@ public enum ShareType {
|
|||||||
GROUP (1),
|
GROUP (1),
|
||||||
PUBLIC_LINK (3),
|
PUBLIC_LINK (3),
|
||||||
EMAIL (4),
|
EMAIL (4),
|
||||||
CONTACT (5);
|
CONTACT (5),
|
||||||
|
FEDERATED (6);
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
@ -72,6 +73,8 @@ public enum ShareType {
|
|||||||
return EMAIL;
|
return EMAIL;
|
||||||
case 5:
|
case 5:
|
||||||
return CONTACT;
|
return CONTACT;
|
||||||
|
case 6:
|
||||||
|
return FEDERATED;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -353,7 +353,6 @@ public class ShareXMLParser {
|
|||||||
share.setSharedWithDisplayName(readNode(parser, NODE_SHARE_WITH_DISPLAY_NAME));
|
share.setSharedWithDisplayName(readNode(parser, NODE_SHARE_WITH_DISPLAY_NAME));
|
||||||
|
|
||||||
} else if (name.equalsIgnoreCase(NODE_URL)) {
|
} else if (name.equalsIgnoreCase(NODE_URL)) {
|
||||||
share.setShareType(ShareType.PUBLIC_LINK);
|
|
||||||
String value = readNode(parser, NODE_URL);
|
String value = readNode(parser, NODE_URL);
|
||||||
share.setShareLink(value);
|
share.setShareLink(value);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -25,28 +25,28 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.resources.shares;
|
package com.owncloud.android.lib.resources.shares;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.methods.PutMethod;
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
import org.apache.commons.httpclient.methods.PutMethod;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates parameters of an existing Share resource, known its remote ID.
|
* Updates parameters of an existing Share resource, known its remote ID.
|
||||||
*
|
* <p/>
|
||||||
* Allow updating several parameters, triggering a request to the server per parameter.
|
* Allow updating several parameters, triggering a request to the server per parameter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -57,23 +57,37 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
private static final String PARAM_PASSWORD = "password";
|
private static final String PARAM_PASSWORD = "password";
|
||||||
private static final String PARAM_EXPIRATION_DATE = "expireDate";
|
private static final String PARAM_EXPIRATION_DATE = "expireDate";
|
||||||
private static final String PARAM_PERMISSIONS = "permissions";
|
private static final String PARAM_PERMISSIONS = "permissions";
|
||||||
|
private static final String PARAM_PUBLIC_UPLOAD = "publicUpload";
|
||||||
private static final String FORMAT_EXPIRATION_DATE = "yyyy-MM-dd";
|
private static final String FORMAT_EXPIRATION_DATE = "yyyy-MM-dd";
|
||||||
private static final String ENTITY_CONTENT_TYPE = "application/x-www-form-urlencoded";
|
private static final String ENTITY_CONTENT_TYPE = "application/x-www-form-urlencoded";
|
||||||
private static final String ENTITY_CHARSET = "UTF-8";
|
private static final String ENTITY_CHARSET = "UTF-8";
|
||||||
|
|
||||||
|
|
||||||
/** Identifier of the share to update */
|
/**
|
||||||
|
* Identifier of the share to update
|
||||||
|
*/
|
||||||
private long mRemoteId;
|
private long mRemoteId;
|
||||||
|
|
||||||
/** Password to set for the public link */
|
/**
|
||||||
|
* Password to set for the public link
|
||||||
|
*/
|
||||||
private String mPassword;
|
private String mPassword;
|
||||||
|
|
||||||
/** Expiration date to set for the public link */
|
/**
|
||||||
|
* Expiration date to set for the public link
|
||||||
|
*/
|
||||||
private long mExpirationDateInMillis;
|
private long mExpirationDateInMillis;
|
||||||
|
|
||||||
/** Access permissions for the file bound to the share */
|
/**
|
||||||
|
* Access permissions for the file bound to the share
|
||||||
|
*/
|
||||||
private int mPermissions;
|
private int mPermissions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upload permissions for the public link (only folders)
|
||||||
|
*/
|
||||||
|
private Boolean mPublicUpload;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. No update is initialized by default, need to be applied with setters below.
|
* Constructor. No update is initialized by default, need to be applied with setters below.
|
||||||
@ -84,6 +98,7 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
mRemoteId = remoteId;
|
mRemoteId = remoteId;
|
||||||
mPassword = null; // no update
|
mPassword = null; // no update
|
||||||
mExpirationDateInMillis = 0; // no update
|
mExpirationDateInMillis = 0; // no update
|
||||||
|
mPublicUpload = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -115,13 +130,23 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
/**
|
/**
|
||||||
* Set permissions to update in Share resource.
|
* Set permissions to update in Share resource.
|
||||||
*
|
*
|
||||||
* @param permissions Permissions date to set to the target share.
|
* @param permissions Permissions to set to the target share.
|
||||||
* Values <= 0 result in no update applied to the permissions.
|
* Values <= 0 result in no update applied to the permissions.
|
||||||
*/
|
*/
|
||||||
public void setPermissions(int permissions) {
|
public void setPermissions(int permissions) {
|
||||||
mPermissions = permissions;
|
mPermissions = permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable upload permissions to update in Share resource.
|
||||||
|
*
|
||||||
|
* @param publicUpload Upload permission to set to the target share.
|
||||||
|
* Null results in no update applied to the upload permission.
|
||||||
|
*/
|
||||||
|
public void setPublicUpload(Boolean publicUpload) {
|
||||||
|
mPublicUpload = publicUpload;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||||
RemoteOperationResult result = null;
|
RemoteOperationResult result = null;
|
||||||
@ -150,17 +175,15 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
parametersToUpdate.add(new Pair(PARAM_PERMISSIONS, Integer.toString(mPermissions)));
|
parametersToUpdate.add(new Pair(PARAM_PERMISSIONS, Integer.toString(mPermissions)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO complete rest of parameters
|
|
||||||
if (mPublicUpload != null) {
|
if (mPublicUpload != null) {
|
||||||
parametersToUpdate.add(new Pair("publicUpload", mPublicUpload.toString());
|
parametersToUpdate.add(new Pair(PARAM_PUBLIC_UPLOAD, Boolean.toString(mPublicUpload)));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/// perform required PUT requests
|
/// perform required PUT requests
|
||||||
PutMethod put = null;
|
PutMethod put = null;
|
||||||
String uriString = null;
|
String uriString = null;
|
||||||
|
|
||||||
try{
|
try {
|
||||||
Uri requestUri = client.getBaseUri();
|
Uri requestUri = client.getBaseUri();
|
||||||
Uri.Builder uriBuilder = requestUri.buildUpon();
|
Uri.Builder uriBuilder = requestUri.buildUpon();
|
||||||
uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH.substring(1));
|
uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH.substring(1));
|
||||||
@ -195,6 +218,9 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
|
|||||||
} else {
|
} else {
|
||||||
result = new RemoteOperationResult(false, status, put.getResponseHeaders());
|
result = new RemoteOperationResult(false, status, put.getResponseHeaders());
|
||||||
}
|
}
|
||||||
|
if (!result.isSuccess()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
* @author masensio
|
* @author masensio
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author masensio
|
* @author masensio
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -32,8 +32,8 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
|
|||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* @author masensio
|
* @author masensio
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
/* ownCloud Android Library is available under MIT license
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
* Copyright (C) 2012 Bartek Przybylski
|
* Copyright (C) 2012 Bartek Przybylski
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
@ -37,6 +37,8 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
|
|||||||
public static final OwnCloudVersion owncloud_v4_5 = new OwnCloudVersion(
|
public static final OwnCloudVersion owncloud_v4_5 = new OwnCloudVersion(
|
||||||
0x04050000);
|
0x04050000);
|
||||||
|
|
||||||
|
public static final int MINIMUN_VERSION_FOR_CHUNKED_UPLOADS = 0x04050000; // 4.5
|
||||||
|
|
||||||
public static final int MINIMUM_VERSION_FOR_SHARING_API = 0x05001B00; // 5.0.27
|
public static final int MINIMUM_VERSION_FOR_SHARING_API = 0x05001B00; // 5.0.27
|
||||||
|
|
||||||
public static final int MINIMUM_VERSION_WITH_FORBIDDEN_CHARS = 0x08010000; // 8.1
|
public static final int MINIMUM_VERSION_WITH_FORBIDDEN_CHARS = 0x08010000; // 8.1
|
||||||
@ -49,6 +51,8 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
|
|||||||
|
|
||||||
public static final int MINIMUM_VERSION_CAPABILITIES_API = 0x08010000; // 8.1
|
public static final int MINIMUM_VERSION_CAPABILITIES_API = 0x08010000; // 8.1
|
||||||
|
|
||||||
|
private static final int MINIMUM_VERSION_WITH_NOT_RESHAREABLE_FEDERATED = 0x09010000; // 9.1
|
||||||
|
|
||||||
private static final int MAX_DOTS = 3;
|
private static final int MAX_DOTS = 3;
|
||||||
|
|
||||||
// format is in version
|
// format is in version
|
||||||
@ -127,6 +131,10 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isChunkedUploadSupported() {
|
||||||
|
return (mVersion >= MINIMUN_VERSION_FOR_CHUNKED_UPLOADS);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSharedSupported() {
|
public boolean isSharedSupported() {
|
||||||
return (mVersion >= MINIMUM_VERSION_FOR_SHARING_API);
|
return (mVersion >= MINIMUM_VERSION_FOR_SHARING_API);
|
||||||
}
|
}
|
||||||
@ -151,5 +159,7 @@ public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
|
|||||||
return (mVersion>= MINIMUM_VERSION_CAPABILITIES_API);
|
return (mVersion>= MINIMUM_VERSION_CAPABILITIES_API);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNotReshareableFederatedSupported() {
|
||||||
|
return (mVersion >= MINIMUM_VERSION_WITH_NOT_RESHAREABLE_FEDERATED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,129 @@
|
|||||||
|
/* ownCloud Android Library is available under MIT license
|
||||||
|
* Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.owncloud.android.lib.resources.users;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets information (id, display name, and e-mail address) about the user logged in.
|
||||||
|
*
|
||||||
|
* @author masensio
|
||||||
|
* @author David A. Velasco
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GetRemoteUserInfoOperation extends RemoteOperation {
|
||||||
|
|
||||||
|
private static final String TAG = GetRemoteUserInfoOperation.class.getSimpleName();
|
||||||
|
|
||||||
|
// OCS Route
|
||||||
|
private static final String OCS_ROUTE = "/index.php/ocs/cloud/user?format=json";
|
||||||
|
|
||||||
|
// JSON Node names
|
||||||
|
private static final String NODE_OCS = "ocs";
|
||||||
|
private static final String NODE_DATA = "data";
|
||||||
|
private static final String NODE_ID = "id";
|
||||||
|
private static final String NODE_DISPLAY_NAME = "display-name";
|
||||||
|
private static final String NODE_EMAIL = "email";
|
||||||
|
|
||||||
|
public GetRemoteUserInfoOperation() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||||
|
RemoteOperationResult result = null;
|
||||||
|
int status = -1;
|
||||||
|
GetMethod get = null;
|
||||||
|
|
||||||
|
//Get the user
|
||||||
|
try {
|
||||||
|
get = new GetMethod(client.getBaseUri() + OCS_ROUTE);
|
||||||
|
get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||||
|
status = client.executeMethod(get);
|
||||||
|
if (isSuccess(status)) {
|
||||||
|
String response = get.getResponseBodyAsString();
|
||||||
|
Log_OC.d(TAG, "Successful response: " + response);
|
||||||
|
|
||||||
|
// Parse the response
|
||||||
|
JSONObject respJSON = new JSONObject(response);
|
||||||
|
JSONObject respOCS = respJSON.getJSONObject(NODE_OCS);
|
||||||
|
JSONObject respData = respOCS.getJSONObject(NODE_DATA);
|
||||||
|
|
||||||
|
UserInfo userInfo = new UserInfo();
|
||||||
|
userInfo.mId = respData.getString(NODE_ID);
|
||||||
|
userInfo.mDisplayName = respData.getString(NODE_DISPLAY_NAME);
|
||||||
|
userInfo.mEmail = respData.getString(NODE_EMAIL);
|
||||||
|
|
||||||
|
// Result
|
||||||
|
result = new RemoteOperationResult(true, status, get.getResponseHeaders());
|
||||||
|
// Username in result.data
|
||||||
|
ArrayList<Object> data = new ArrayList<Object>();
|
||||||
|
data.add(userInfo);
|
||||||
|
result.setData(data);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
result = new RemoteOperationResult(false, status, get.getResponseHeaders());
|
||||||
|
String response = get.getResponseBodyAsString();
|
||||||
|
Log_OC.e(TAG, "Failed response while getting user information ");
|
||||||
|
if (response != null) {
|
||||||
|
Log_OC.e(TAG, "*** status code: " + status + " ; response message: " + response);
|
||||||
|
} else {
|
||||||
|
Log_OC.e(TAG, "*** status code: " + status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
result = new RemoteOperationResult(e);
|
||||||
|
Log_OC.e(TAG, "Exception while getting OC user information", e);
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
if (get != null) {
|
||||||
|
get.releaseConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSuccess(int status) {
|
||||||
|
return (status == HttpStatus.SC_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class UserInfo {
|
||||||
|
public String mId = "";
|
||||||
|
public String mDisplayName = "";
|
||||||
|
public String mEmail = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,130 +0,0 @@
|
|||||||
/* ownCloud Android Library is available under MIT license
|
|
||||||
* Copyright (C) 2015 ownCloud Inc.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
||||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.owncloud.android.lib.resources.users;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
|
||||||
import org.apache.http.HttpStatus;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author masensio
|
|
||||||
*
|
|
||||||
* Get the UserName for a SAML connection, from a JSON with the format:
|
|
||||||
* id
|
|
||||||
* display-name
|
|
||||||
* email
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class GetRemoteUserNameOperation extends RemoteOperation {
|
|
||||||
|
|
||||||
private static final String TAG = GetRemoteUserNameOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
// OCS Route
|
|
||||||
private static final String OCS_ROUTE ="/index.php/ocs/cloud/user?format=json";
|
|
||||||
|
|
||||||
// JSON Node names
|
|
||||||
private static final String NODE_OCS = "ocs";
|
|
||||||
private static final String NODE_DATA = "data";
|
|
||||||
private static final String NODE_ID = "id";
|
|
||||||
private static final String NODE_DISPLAY_NAME= "display-name";
|
|
||||||
private static final String NODE_EMAIL= "email";
|
|
||||||
|
|
||||||
private String mUserName;
|
|
||||||
|
|
||||||
public String getUserName() {
|
|
||||||
return mUserName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public GetRemoteUserNameOperation() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
|
||||||
RemoteOperationResult result = null;
|
|
||||||
int status = -1;
|
|
||||||
GetMethod get = null;
|
|
||||||
|
|
||||||
//Get the user
|
|
||||||
try {
|
|
||||||
get = new GetMethod(client.getBaseUri() + OCS_ROUTE);
|
|
||||||
get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
|
||||||
status = client.executeMethod(get);
|
|
||||||
if(isSuccess(status)) {
|
|
||||||
String response = get.getResponseBodyAsString();
|
|
||||||
Log_OC.d(TAG, "Successful response: " + response);
|
|
||||||
|
|
||||||
// Parse the response
|
|
||||||
JSONObject respJSON = new JSONObject(response);
|
|
||||||
JSONObject respOCS = respJSON.getJSONObject(NODE_OCS);
|
|
||||||
JSONObject respData = respOCS.getJSONObject(NODE_DATA);
|
|
||||||
String id = respData.getString(NODE_ID);
|
|
||||||
String displayName = respData.getString(NODE_DISPLAY_NAME);
|
|
||||||
String email = respData.getString(NODE_EMAIL);
|
|
||||||
|
|
||||||
// Result
|
|
||||||
result = new RemoteOperationResult(true, status, get.getResponseHeaders());
|
|
||||||
// Username in result.data
|
|
||||||
ArrayList<Object> data = new ArrayList<Object>();
|
|
||||||
data.add(displayName);
|
|
||||||
result.setData(data);
|
|
||||||
mUserName = displayName;
|
|
||||||
|
|
||||||
Log_OC.d(TAG, "*** Parsed user information: " + id + " - " + displayName + " - " + email);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
result = new RemoteOperationResult(false, status, get.getResponseHeaders());
|
|
||||||
String response = get.getResponseBodyAsString();
|
|
||||||
Log_OC.e(TAG, "Failed response while getting user information ");
|
|
||||||
if (response != null) {
|
|
||||||
Log_OC.e(TAG, "*** status code: " + status + " ; response message: " + response);
|
|
||||||
} else {
|
|
||||||
Log_OC.e(TAG, "*** status code: " + status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
result = new RemoteOperationResult(e);
|
|
||||||
Log_OC.e(TAG, "Exception while getting OC user information", e);
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
get.releaseConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSuccess(int status) {
|
|
||||||
return (status == HttpStatus.SC_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="8"
|
android:minSdkVersion="8"
|
||||||
android:targetSdkVersion="19" />
|
android:targetSdkVersion="23" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
@ -1,18 +1,27 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:2.0.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'commons-httpclient:commons-httpclient:3.1'
|
compile 'commons-httpclient:commons-httpclient:3.1'
|
||||||
compile 'com.android.support:support-v4:20.0.0'
|
|
||||||
compile project(':')
|
compile project(':')
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 19
|
compileSdkVersion 23
|
||||||
buildToolsVersion "22.0.1"
|
buildToolsVersion "23.0.3"
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
|
@ -15,6 +15,20 @@
|
|||||||
</then>
|
</then>
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
|
<!-- Replace OC server URL 2 if set in environment -->
|
||||||
|
<if>
|
||||||
|
<condition>
|
||||||
|
<isset property="env.OCTEST_SERVER_BASE_URL_2" />
|
||||||
|
</condition>
|
||||||
|
<then>
|
||||||
|
<replaceregexp
|
||||||
|
file="res/values/setup.xml"
|
||||||
|
match='("server_base_url_2">)\s*(<)'
|
||||||
|
replace="\1${env.OCTEST_SERVER_BASE_URL_2}\2"
|
||||||
|
byline="true" />
|
||||||
|
</then>
|
||||||
|
</if>
|
||||||
|
|
||||||
<!-- Replace test username if set in environment -->
|
<!-- Replace test username if set in environment -->
|
||||||
<if>
|
<if>
|
||||||
<condition>
|
<condition>
|
||||||
|
BIN
test_client/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
test_client/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
#Wed Apr 10 15:27:10 PDT 2013
|
#Mon Dec 28 10:00:20 PST 2015
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
|
||||||
|
@ -11,5 +11,5 @@
|
|||||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-19
|
target=android-23
|
||||||
android.library.reference.1=..
|
android.library.reference.1=..
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- ownCloud Android Library is available under MIT license
|
<!-- ownCloud Android Library is available under MIT license
|
||||||
Copyright (C) 2015 ownCloud Inc.
|
Copyright (C) 2016 ownCloud GmbH.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user