/** * Extracts url server from the account * * @deprecated This method will be removed in version 1.0. * Use {@link #getBaseUrlForAccount(Context, Account)} * instead. * * @param context * @param account * @return url server or null on failure * @throws AccountNotFoundException When 'account' is unknown for the AccountManager */ @Deprecated public static String constructBasicURLForAccount(Context context, Account account) throws AccountNotFoundException { return getBaseUrlForAccount(context, account); }
/** * Constructor for already saved OC accounts. * * Do not use for anonymous credentials. */ public OwnCloudAccount(Account savedAccount, Context context) throws AccountNotFoundException { if (savedAccount == null) { throw new IllegalArgumentException("Parameter 'savedAccount' cannot be null"); } if (context == null) { throw new IllegalArgumentException("Parameter 'context' cannot be null"); } mSavedAccount = savedAccount; 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)); mDisplayName = ama.getUserData(mSavedAccount, AccountUtils.Constants.KEY_DISPLAY_NAME); }
/** * Constructor for already saved OC accounts. * * Do not use for anonymous credentials. */ public OwnCloudAccount(Account savedAccount, Context context) throws AccountNotFoundException { if (savedAccount == null) { throw new IllegalArgumentException("Parameter 'savedAccount' cannot be null"); } if (context == null) { throw new IllegalArgumentException("Parameter 'context' cannot be null"); } mSavedAccount = savedAccount; 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)); mDisplayName = ama.getUserData(mSavedAccount, AccountUtils.Constants.KEY_DISPLAY_NAME); }
/** * Constructs full url to host and webdav resource basing on host version * * @param context Valid Android {@link Context}, needed to access the {@link AccountManager} * @param account A stored ownCloud {@link Account} * @return Full URL to WebDAV endpoint in the server corresponding to 'account'. * @throws AccountNotFoundException When 'account' is unknown for the AccountManager */ public static String getWebDavUrlForAccount(Context context, Account account) throws AccountNotFoundException { String webDavUrlForAccount = ""; try { OwnCloudCredentials ownCloudCredentials = getCredentialsForAccount(context, account); webDavUrlForAccount = getBaseUrlForAccount(context, account) + OwnCloudClient.WEBDAV_FILES_PATH_4_0 + ownCloudCredentials.getUsername(); } catch (OperationCanceledException e) { e.printStackTrace(); } catch (AuthenticatorException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return webDavUrlForAccount; }
throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { Uri baseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(appContext, account)); AccountManager am = AccountManager.get(appContext);
throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { Uri baseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(appContext, account)); AccountManager am = AccountManager.get(appContext);
AccountNotFoundException { Uri baseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(appContext, account)); AccountManager am = AccountManager.get(appContext);