本文整理汇总了Java中org.commcare.resources.model.ResourceTable.RESOURCE_TABLE_INSTALLED属性的典型用法代码示例。如果您正苦于以下问题:Java ResourceTable.RESOURCE_TABLE_INSTALLED属性的具体用法?Java ResourceTable.RESOURCE_TABLE_INSTALLED怎么用?Java ResourceTable.RESOURCE_TABLE_INSTALLED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.commcare.resources.model.ResourceTable
的用法示例。
在下文中一共展示了ResourceTable.RESOURCE_TABLE_INSTALLED属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ensureMasterTableValid
protected void ensureMasterTableValid() {
if (masterTable.getTableReadiness() != ResourceTable.RESOURCE_TABLE_INSTALLED) {
repair();
if (masterTable.getTableReadiness() != ResourceTable.RESOURCE_TABLE_INSTALLED) {
throw new IllegalArgumentException("Global resource table was not ready for upgrading");
}
}
}
示例2: upgrade
/**
* Install staged upgrade table into the global table.
*/
public void upgrade()
throws UnresolvedResourceException, IllegalArgumentException {
synchronized (updateLock) {
boolean upgradeSuccess = false;
try {
Logger.log("Resource", "Upgrade table fetched, beginning upgrade");
// Try to stage the upgrade table to replace the incoming table
if (!masterTable.upgradeTable(upgradeTable)) {
throw new RuntimeException("global table failed to upgrade!");
} else if (upgradeTable.getTableReadiness() != ResourceTable.RESOURCE_TABLE_INSTALLED) {
throw new RuntimeException("not all incoming resources were installed!!");
} else {
Logger.log("Resource", "Global table unstaged, upgrade table ready");
}
// We now replace the global resource table with the upgrade table
Logger.log("Resource", "Copying global resources to recovery area");
try {
masterTable.copyToTable(tempTable);
} catch (RuntimeException e) {
// The _only_ time the recovery table should have data is if we
// were in the middle of an install. Since global hasn't been
// modified if there is a problem here we want to wipe out the
// recovery stub
tempTable.destroy();
throw e;
}
Logger.log("Resource", "Wiping global");
// clear the global table to make room (but not the data, just the records)
masterTable.destroy();
Logger.log("Resource", "Moving update resources");
upgradeTable.copyToTable(masterTable);
Logger.log("Resource", "Upgrade Succesful!");
upgradeSuccess = true;
Logger.log("Resource", "Wiping redundant update table");
upgradeTable.destroy();
Logger.log("Resource", "Clearing out old resources");
tempTable.uninstall(masterTable);
} finally {
if (!upgradeSuccess) {
repair();
}
platform.clearAppState();
//Is it really possible to verify that we've un-registered
//everything here? Locale files are registered elsewhere, and we
//can't guarantee we're the only thing in there, so we can't
//straight up clear it...
platform.initialize(masterTable);
}
}
}
示例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: upgrade
/**
* Install staged upgrade table into the global table.
*/
public void upgrade()
throws UnresolvedResourceException, IllegalArgumentException {
synchronized (platform) {
boolean upgradeSuccess = false;
try {
Logger.log("Resource", "Upgrade table fetched, beginning upgrade");
// Try to stage the upgrade table to replace the incoming table
masterTable.upgradeTable(upgradeTable, platform);
if (upgradeTable.getTableReadiness() != ResourceTable.RESOURCE_TABLE_INSTALLED) {
throw new RuntimeException("not all incoming resources were installed!!");
} else {
Logger.log("Resource", "Global table unstaged, upgrade table ready");
}
// We now replace the global resource table with the upgrade table
Logger.log("Resource", "Copying global resources to recovery area");
try {
masterTable.copyToTable(tempTable);
} catch (RuntimeException e) {
// The _only_ time the recovery table should have data is if we
// were in the middle of an install. Since global hasn't been
// modified if there is a problem here we want to wipe out the
// recovery stub
tempTable.destroy();
throw e;
}
Logger.log("Resource", "Wiping global");
// clear the global table to make room (but not the data, just the records)
masterTable.destroy();
Logger.log("Resource", "Moving update resources");
upgradeTable.copyToTable(masterTable);
Logger.log("Resource", "Upgrade Succesful!");
upgradeSuccess = true;
Logger.log("Resource", "Wiping redundant update table");
upgradeTable.destroy();
Logger.log("Resource", "Clearing out old resources");
tempTable.uninstall(masterTable, platform);
} finally {
if (!upgradeSuccess) {
repair();
}
platform.clearAppState();
//Is it really possible to verify that we've un-registered
//everything here? Locale files are registered elsewhere, and we
//can't guarantee we're the only thing in there, so we can't
//straight up clear it...
// NOTE PLM: if the upgrade is successful but crashes before
// reaching this point, any suite fixture updates won't be
// applied
platform.initialize(masterTable, true);
}
}
}
示例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);
}
}