1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Renamed StorageImportExportException to SettingsImportExportException

This commit is contained in:
cketti 2011-10-14 06:00:10 +02:00
parent c835bb757a
commit f5e684310e
5 changed files with 41 additions and 41 deletions

View File

@ -73,7 +73,7 @@ import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.store.StorageManager; import com.fsck.k9.mail.store.StorageManager;
import com.fsck.k9.view.ColorChip; import com.fsck.k9.view.ColorChip;
import com.fsck.k9.preferences.SettingsExporter; import com.fsck.k9.preferences.SettingsExporter;
import com.fsck.k9.preferences.StorageImportExportException; import com.fsck.k9.preferences.SettingsImportExportException;
import com.fsck.k9.preferences.SettingsImporter; import com.fsck.k9.preferences.SettingsImporter;
import com.fsck.k9.preferences.SettingsImporter.AccountDescription; import com.fsck.k9.preferences.SettingsImporter.AccountDescription;
import com.fsck.k9.preferences.SettingsImporter.ImportContents; import com.fsck.k9.preferences.SettingsImporter.ImportContents;
@ -1322,7 +1322,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
try { try {
mFileName = SettingsExporter.exportToFile(mContext, mIncludeGlobals, mFileName = SettingsExporter.exportToFile(mContext, mIncludeGlobals,
mAccountUuids); mAccountUuids);
} catch (StorageImportExportException e) { } catch (SettingsImportExportException e) {
Log.w(K9.LOG_TAG, "Exception during export", e); Log.w(K9.LOG_TAG, "Exception during export", e);
return false; return false;
} }
@ -1387,7 +1387,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
is.close(); is.close();
} catch (IOException e) { /* Ignore */ } } catch (IOException e) { /* Ignore */ }
} }
} catch (StorageImportExportException e) { } catch (SettingsImportExportException e) {
Log.w(K9.LOG_TAG, "Exception during import", e); Log.w(K9.LOG_TAG, "Exception during import", e);
return false; return false;
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
@ -1455,7 +1455,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
is.close(); is.close();
} catch (IOException e) { /* Ignore */ } } catch (IOException e) { /* Ignore */ }
} }
} catch (StorageImportExportException e) { } catch (SettingsImportExportException e) {
Log.w(K9.LOG_TAG, "Exception during export", e); Log.w(K9.LOG_TAG, "Exception during export", e);
return false; return false;
} }

View File

@ -77,7 +77,7 @@ public class SettingsExporter {
public static String exportToFile(Context context, boolean includeGlobals, public static String exportToFile(Context context, boolean includeGlobals,
Set<String> accountUuids) Set<String> accountUuids)
throws StorageImportExportException { throws SettingsImportExportException {
OutputStream os = null; OutputStream os = null;
String filename = null; String filename = null;
@ -95,7 +95,7 @@ public class SettingsExporter {
// If all went well, we return the name of the file just written. // If all went well, we return the name of the file just written.
return filename; return filename;
} catch (Exception e) { } catch (Exception e) {
throw new StorageImportExportException(e); throw new SettingsImportExportException(e);
} finally { } finally {
if (os != null) { if (os != null) {
try { try {
@ -108,7 +108,7 @@ public class SettingsExporter {
} }
public static void exportPreferences(Context context, OutputStream os, boolean includeGlobals, public static void exportPreferences(Context context, OutputStream os, boolean includeGlobals,
Set<String> accountUuids) throws StorageImportExportException { Set<String> accountUuids) throws SettingsImportExportException {
try { try {
XmlSerializer serializer = Xml.newSerializer(); XmlSerializer serializer = Xml.newSerializer();
@ -160,7 +160,7 @@ public class SettingsExporter {
serializer.flush(); serializer.flush();
} catch (Exception e) { } catch (Exception e) {
throw new StorageImportExportException(e.getLocalizedMessage(), e); throw new SettingsImportExportException(e.getLocalizedMessage(), e);
} }
} }

View File

@ -0,0 +1,21 @@
package com.fsck.k9.preferences;
public class SettingsImportExportException extends Exception {
public SettingsImportExportException() {
super();
}
public SettingsImportExportException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
public SettingsImportExportException(String detailMessage) {
super(detailMessage);
}
public SettingsImportExportException(Throwable throwable) {
super(throwable);
}
}

View File

@ -111,11 +111,11 @@ public class SettingsImporter {
* @return An {@link ImportContents} instance containing information about the contents of the * @return An {@link ImportContents} instance containing information about the contents of the
* settings file. * settings file.
* *
* @throws StorageImportExportException * @throws SettingsImportExportException
* In case of an error. * In case of an error.
*/ */
public static ImportContents getImportStreamContents(InputStream inputStream) public static ImportContents getImportStreamContents(InputStream inputStream)
throws StorageImportExportException { throws SettingsImportExportException {
try { try {
// Parse the import stream but don't save individual settings (overview=true) // Parse the import stream but don't save individual settings (overview=true)
@ -137,10 +137,10 @@ public class SettingsImporter {
return new ImportContents(globalSettings, accounts); return new ImportContents(globalSettings, accounts);
} catch (StorageImportExportException e) { } catch (SettingsImportExportException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new StorageImportExportException(e); throw new SettingsImportExportException(e);
} }
} }
@ -165,12 +165,12 @@ public class SettingsImporter {
* @return An {@link ImportResults} instance containing information about errors and * @return An {@link ImportResults} instance containing information about errors and
* successfully imported accounts. * successfully imported accounts.
* *
* @throws StorageImportExportException * @throws SettingsImportExportException
* In case of an error. * In case of an error.
*/ */
public static ImportResults importSettings(Context context, InputStream inputStream, public static ImportResults importSettings(Context context, InputStream inputStream,
boolean globalSettings, List<String> accountUuids, boolean overwrite) boolean globalSettings, List<String> accountUuids, boolean overwrite)
throws StorageImportExportException { throws SettingsImportExportException {
try try
{ {
@ -274,7 +274,7 @@ public class SettingsImporter {
} }
if (!editor.commit()) { if (!editor.commit()) {
throw new StorageImportExportException("Failed to set default account"); throw new SettingsImportExportException("Failed to set default account");
} }
} else { } else {
Log.w(K9.LOG_TAG, "Was asked to import at least one account but none found."); Log.w(K9.LOG_TAG, "Was asked to import at least one account but none found.");
@ -288,10 +288,10 @@ public class SettingsImporter {
return new ImportResults(globalSettingsImported, importedAccounts, errorneousAccounts); return new ImportResults(globalSettingsImported, importedAccounts, errorneousAccounts);
} catch (StorageImportExportException e) { } catch (SettingsImportExportException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
throw new StorageImportExportException(e); throw new SettingsImportExportException(e);
} }
} }
@ -578,7 +578,7 @@ public class SettingsImporter {
private static Imported parseSettings(InputStream inputStream, boolean globalSettings, private static Imported parseSettings(InputStream inputStream, boolean globalSettings,
List<String> accountUuids, boolean overview) List<String> accountUuids, boolean overview)
throws StorageImportExportException { throws SettingsImportExportException {
if (!overview && accountUuids == null) { if (!overview && accountUuids == null) {
throw new IllegalArgumentException("Argument 'accountUuids' must not be null."); throw new IllegalArgumentException("Argument 'accountUuids' must not be null.");
@ -607,12 +607,12 @@ public class SettingsImporter {
if (imported == null || (overview && imported.globalSettings == null && if (imported == null || (overview && imported.globalSettings == null &&
imported.accounts == null)) { imported.accounts == null)) {
throw new StorageImportExportException("Invalid import data"); throw new SettingsImportExportException("Invalid import data");
} }
return imported; return imported;
} catch (Exception e) { } catch (Exception e) {
throw new StorageImportExportException(e); throw new SettingsImportExportException(e);
} }
} }

View File

@ -1,21 +0,0 @@
package com.fsck.k9.preferences;
public class StorageImportExportException extends Exception {
public StorageImportExportException() {
super();
}
public StorageImportExportException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
public StorageImportExportException(String detailMessage) {
super(detailMessage);
}
public StorageImportExportException(Throwable throwable) {
super(throwable);
}
}