當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceTable.RESOURCE_TABLE_INSTALLED屬性代碼示例

本文整理匯總了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");
        }
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:9,代碼來源:ResourceManager.java

示例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);
        }
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:63,代碼來源:ResourceManager.java

示例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);
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:64,代碼來源:ResourceManager.java

示例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);
        }
    }
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:66,代碼來源:ResourceManager.java

示例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);
    }
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:64,代碼來源:ResourceManager.java


注:本文中的org.commcare.resources.model.ResourceTable.RESOURCE_TABLE_INSTALLED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。