本文整理匯總了Java中org.commcare.resources.model.ResourceTable.RESOURCE_TABLE_UNSTAGED屬性的典型用法代碼示例。如果您正苦於以下問題:Java ResourceTable.RESOURCE_TABLE_UNSTAGED屬性的具體用法?Java ResourceTable.RESOURCE_TABLE_UNSTAGED怎麽用?Java ResourceTable.RESOURCE_TABLE_UNSTAGED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.commcare.resources.model.ResourceTable
的用法示例。
在下文中一共展示了ResourceTable.RESOURCE_TABLE_UNSTAGED屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepareUpgradeResources
/**
* Download resources referenced by upgrade table's profile into the
* upgrade table itself.
*
* @throws InstallCancelledException The user/system has cancelled the
* installation process
*/
public void prepareUpgradeResources()
throws UnfullfilledRequirementsException,
UnresolvedResourceException, IllegalArgumentException,
InstallCancelledException {
synchronized (updateLock) {
ensureMasterTableValid();
// TODO: Table's acceptable states here may be incomplete
int upgradeTableState = upgradeTable.getTableReadiness();
if (upgradeTableState == ResourceTable.RESOURCE_TABLE_UNCOMMITED ||
upgradeTableState == ResourceTable.RESOURCE_TABLE_UNSTAGED ||
upgradeTableState == ResourceTable.RESOURCE_TABLE_EMPTY) {
throw new IllegalArgumentException("Upgrade table is not in an appropriate state");
}
tempTable.destroy();
upgradeTable.prepareResources(masterTable, this.platform);
}
}
示例2: prepareUpgradeResources
/**
* Download resources referenced by upgrade table's profile into the
* upgrade table itself.
*
* @throws InstallCancelledException The user/system has cancelled the
* installation process
*/
public void prepareUpgradeResources()
throws UnfullfilledRequirementsException,
UnresolvedResourceException, IllegalArgumentException,
InstallCancelledException {
synchronized (platform) {
ensureMasterTableValid();
// TODO: Table's acceptable states here may be incomplete
int upgradeTableState = upgradeTable.getTableReadiness();
if (upgradeTableState == ResourceTable.RESOURCE_TABLE_UNCOMMITED ||
upgradeTableState == ResourceTable.RESOURCE_TABLE_UNSTAGED ||
upgradeTableState == ResourceTable.RESOURCE_TABLE_EMPTY) {
throw new IllegalArgumentException("Upgrade table is not in an appropriate state");
}
tempTable.destroy();
upgradeTable.setResourceProgressStale();
upgradeTable.prepareResources(masterTable, this.platform);
}
}
示例3: repair
/**
* This method is responsible for recovering the state of the application
* to installed after anything happens during an upgrade. After it is
* finished, the global resource table should be valid.
*
* NOTE: this does not currently repair resources which have been
* corrupted, merely returns all of the tables to the appropriate states
*/
private void repair() {
// First we need to figure out what state we're in currently. There are
// a few possibilities
// TODO: Handle: Upgrade complete (upgrade table empty, all resources
// pushed to global), recovery table not empty
// First possibility is needing to restore from the recovery table.
if (!tempTable.isEmpty()) {
// If the recovery table isn't empty, we're likely restoring from
// there. We need to check first whether the global table has the
// same profile, or the recovery table simply doesn't have one in
// which case the recovery table didn't get copied correctly.
Resource tempProfile =
tempTable.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
Resource masterProfile =
masterTable.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
if (tempProfile == null ||
(masterProfile.getVersion() == tempProfile.getVersion())) {
Logger.log("resource", "Invalid recovery table detected. Wiping recovery table");
// This means the recovery table should be empty. Invalid copy.
tempTable.destroy();
} else {
// We need to recover the global resources from the recovery
// table.
Logger.log("resource", "Recovering global resources from recovery table");
masterTable.destroy();
tempTable.copyToTable(masterTable);
Logger.log("resource", "Global resources recovered. Wiping recovery table");
tempTable.destroy();
}
}
// Global and incoming are now in the right places. Ensure we have no
// uncommitted resources.
if (masterTable.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNCOMMITED) {
masterTable.rollbackCommits();
}
if (upgradeTable.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNCOMMITED) {
upgradeTable.rollbackCommits();
}
// If the global table needed to be recovered from the recovery table,
// it has. There are now two states: Either the global table is fully
// installed (no conflicts with the upgrade table) or it has unstaged
// resources to restage
if (masterTable.getTableReadiness() == ResourceTable.RESOURCE_TABLE_INSTALLED) {
Logger.log("resource", "Global table in fully installed mode. Repair complete");
} else if (masterTable.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNSTAGED) {
Logger.log("resource", "Global table needs to restage some resources");
masterTable.repairTable(upgradeTable);
}
}
示例4: initializeApplicationHelper
private boolean initializeApplicationHelper() {
setupSandbox();
ResourceTable global = platform.getGlobalResourceTable();
ResourceTable upgrade = platform.getUpgradeResourceTable();
ResourceTable recovery = platform.getRecoveryTable();
logTable("Global", global);
logTable("Upgrade", upgrade);
logTable("Recovery", recovery);
// See if any of our tables got left in a weird state
if (global.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNCOMMITED) {
global.rollbackCommits(platform);
logTable("Global after rollback", global);
}
if (upgrade.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNCOMMITED) {
upgrade.rollbackCommits(platform);
logTable("Upgrade after rollback", upgrade);
}
// See if we got left in the middle of an update
if (global.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNSTAGED) {
// If so, repair the global table. (Always takes priority over maintaining the update)
global.repairTable(upgrade, platform);
}
Resource profile = global.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
if (profile != null && profile.getStatus() == Resource.RESOURCE_STATUS_INSTALLED) {
platform.initialize(global, false);
try {
Localization.setLocale(
getAppPreferences().getString(MainConfigurablePreferences.PREFS_LOCALE_KEY, "default"));
} catch (UnregisteredLocaleException urle) {
Localization.setLocale(Localization.getGlobalLocalizerAdvanced().getAvailableLocales()[0]);
}
initializeStylizer();
try {
HybridFileBackedSqlHelpers.removeOrphanedFiles(buildAndroidDbHelper().getHandle());
} catch (SessionUnavailableException e) {
Logger.log(LogTypes.SOFT_ASSERT,
"Unable to get app db handle to clear orphaned files");
}
return true;
}
String failureReason = profile == null ? "profle being null" : "profile status value " + String.valueOf(profile.getStatus());
Logger.log(LogTypes.TYPE_RESOURCES, "Initializing application failed because of " + failureReason);
return false;
}
示例5: repair
/**
* This method is responsible for recovering the state of the application
* to installed after anything happens during an upgrade. After it is
* finished, the global resource table should be valid.
*
* NOTE: this does not currently repair resources which have been
* corrupted, merely returns all of the tables to the appropriate states
*/
private void repair() {
// First we need to figure out what state we're in currently. There are
// a few possibilities
// TODO: Handle: Upgrade complete (upgrade table empty, all resources
// pushed to global), recovery table not empty
// First possibility is needing to restore from the recovery table.
if (!tempTable.isEmpty()) {
// If the recovery table isn't empty, we're likely restoring from
// there. We need to check first whether the global table has the
// same profile, or the recovery table simply doesn't have one in
// which case the recovery table didn't get copied correctly.
Resource tempProfile =
tempTable.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
Resource masterProfile =
masterTable.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);
if (tempProfile == null ||
(masterProfile.getVersion() == tempProfile.getVersion())) {
Logger.log("resource", "Invalid recovery table detected. Wiping recovery table");
// This means the recovery table should be empty. Invalid copy.
tempTable.destroy();
} else {
// We need to recover the global resources from the recovery
// table.
Logger.log("resource", "Recovering global resources from recovery table");
masterTable.destroy();
tempTable.copyToTable(masterTable);
Logger.log("resource", "Global resources recovered. Wiping recovery table");
tempTable.destroy();
}
}
// Global and incoming are now in the right places. Ensure we have no
// uncommitted resources.
if (masterTable.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNCOMMITED) {
masterTable.rollbackCommits(platform);
}
if (upgradeTable.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNCOMMITED) {
upgradeTable.rollbackCommits(platform);
}
// If the global table needed to be recovered from the recovery table,
// it has. There are now two states: Either the global table is fully
// installed (no conflicts with the upgrade table) or it has unstaged
// resources to restage
if (masterTable.getTableReadiness() == ResourceTable.RESOURCE_TABLE_INSTALLED) {
Logger.log("resource", "Global table in fully installed mode. Repair complete");
} else if (masterTable.getTableReadiness() == ResourceTable.RESOURCE_TABLE_UNSTAGED) {
Logger.log("resource", "Global table needs to restage some resources");
masterTable.repairTable(upgradeTable, platform);
}
}