当前位置: 首页>>代码示例>>Java>>正文


Java UnresolvedResourceException类代码示例

本文整理汇总了Java中org.commcare.resources.model.UnresolvedResourceException的典型用法代码示例。如果您正苦于以下问题:Java UnresolvedResourceException类的具体用法?Java UnresolvedResourceException怎么用?Java UnresolvedResourceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UnresolvedResourceException类属于org.commcare.resources.model包,在下文中一共展示了UnresolvedResourceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadProfileIntoTable

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
protected void loadProfileIntoTable(ResourceTable table,
                                    String profileRef,
                                    int authority)
        throws UnfullfilledRequirementsException,
        UnresolvedResourceException,
        InstallCancelledException {
    Vector<ResourceLocation> locations = new Vector<ResourceLocation>();
    locations.addElement(new ResourceLocation(authority, profileRef));

    Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
            CommCarePlatform.APP_PROFILE_RESOURCE_ID, locations,
            "Application Descriptor");

    table.addResource(r,
            table.getInstallers().getProfileInstaller(false),
            null);

    prepareProfileResource(table);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:20,代码来源:ResourceManager.java

示例2: prepareUpgradeResources

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:28,代码来源:ResourceManager.java

示例3: installStagedUpdate

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
public static AppInstallStatus installStagedUpdate() {
    CommCareApp app = CommCareApplication.instance().getCurrentApp();
    app.setupSandbox();

    AndroidCommCarePlatform platform = app.getCommCarePlatform();
    AndroidResourceManager resourceManager =
            new AndroidResourceManager(platform);

    if (!resourceManager.isUpgradeTableStaged()) {
        resourceManager.recordUpdateInstallFailure(AppInstallStatus.UnknownFailure);
        return AppInstallStatus.UnknownFailure;
    }

    try {
        resourceManager.upgrade();
    } catch (UnresolvedResourceException e) {
        resourceManager.recordUpdateInstallFailure(e);
        return AppInstallStatus.MissingResources;
    }

    ResourceInstallUtils.initAndCommitApp(app);

    return AppInstallStatus.Installed;
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:25,代码来源:InstallStagedUpdateTask.java

示例4: instantiateLatestUpgradeProfile

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
/**
 * Load the latest profile into the upgrade table. Clears the upgrade table
 * if it's partially populated with an out-of-date version.
 */
private void instantiateLatestUpgradeProfile(int authority)
        throws UnfullfilledRequirementsException,
        UnresolvedResourceException,
        InstallCancelledException {

    ensureMasterTableValid();

    if (updateStats.isUpgradeStale()) {
        Log.i(TAG, "Clearing upgrade table because resource downloads " +
                "failed too many times or started too long ago");
        upgradeTable.destroy();
        updateStats.resetStats(app);
    }

    Resource upgradeProfile =
            upgradeTable.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);

    if (upgradeProfile == null) {
        loadProfileIntoTable(upgradeTable, profileRef, authority);
    } else {
        loadProfileViaTemp(upgradeProfile, authority);
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:28,代码来源:AndroidResourceManager.java

示例5: loadProfileViaTemp

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
/**
 * Download the latest profile into the temporary table and if the version
 * higher than the upgrade table's profile, copy it into the upgrade table.
 *
 * @param upgradeProfile the profile currently in the upgrade table.
 */
private void loadProfileViaTemp(Resource upgradeProfile, int profileAuthority)
        throws UnfullfilledRequirementsException,
        UnresolvedResourceException,
        InstallCancelledException {
    tempUpgradeTable.destroy();
    loadProfileIntoTable(tempUpgradeTable, profileRef, profileAuthority);
    Resource tempProfile =
            tempUpgradeTable.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);

    if (tempProfile != null && tempProfile.isNewer(upgradeProfile)) {
        upgradeTable.destroy();
        tempUpgradeTable.copyToTable(upgradeTable);
    }

    tempUpgradeTable.destroy();
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:23,代码来源:AndroidResourceManager.java

示例6: processUnresolvedResource

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
/**
 * Handle exception that occurs when a resource can't be found during an
 * install or update
 *
 * @return Appropriate failure status based on exception properties
 */
public static AppInstallStatus processUnresolvedResource(UnresolvedResourceException exception) {
    // couldn't find a resource, which isn't good.
    exception.printStackTrace();

    if (ResourceInstallUtils.isBadCertificateError(exception)) {
        return AppInstallStatus.BadCertificate;
    }

    Logger.log(LogTypes.TYPE_WARNING_NETWORK,
            "A resource couldn't be found, almost certainly due to the network|" +
                    exception.getMessage());
    if (exception.isMessageUseful()) {
        return AppInstallStatus.MissingResourcesWithMessage;
    } else {
        return AppInstallStatus.MissingResources;
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:24,代码来源:ResourceInstallUtils.java

示例7: customInstall

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
@Override
protected int customInstall(Resource r, Reference local, boolean upgrade)
        throws IOException, UnresolvedResourceException {

    // To make sure that we won't fail on this later, after we have already committed to
    // the upgrade being good to go
    try {
        initDemoUserRestore();
    } catch (RuntimeException e) {
        throw new UnresolvedResourceException(r, e, e.getMessage(), true);
    }

    if (upgrade) {
        OfflineUserRestore currentOfflineUserRestore =
                CommCareApplication.instance().getCommCarePlatform().getDemoUserRestore();
        if (currentOfflineUserRestore != null) {
            AppUtils.wipeSandboxForUser(currentOfflineUserRestore.getUsername());
        }
        return Resource.RESOURCE_STATUS_UPGRADE;
    } else {
        return Resource.RESOURCE_STATUS_INSTALLED;
    }
}
 
开发者ID:dimagi,项目名称:commcare-android,代码行数:24,代码来源:OfflineUserRestoreAndroidInstaller.java

示例8: install

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
@Override
public boolean install(Resource r, ResourceLocation location,
                       Reference ref, ResourceTable table,
                       CommCarePlatform platform, boolean upgrade)
        throws UnresolvedResourceException, UnfullfilledRequirementsException {
    try {
        OfflineUserRestore offlineUserRestore = OfflineUserRestore.buildInMemoryUserRestore(ref.getStream());
        storage(platform).write(offlineUserRestore);
        if (upgrade) {
            table.commit(r, Resource.RESOURCE_STATUS_INSTALLED);
        } else {
            table.commit(r, Resource.RESOURCE_STATUS_UPGRADE);
        }
        cacheLocation = offlineUserRestore.getID();
    } catch (IOException | XmlPullParserException | InvalidStructureException e) {
        throw new UnresolvedResourceException(r, e.getMessage());
    }
    return true;
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:20,代码来源:OfflineUserRestoreInstaller.java

示例9: loadProfileIntoTable

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
protected void loadProfileIntoTable(ResourceTable table,
                                    String profileRef,
                                    int authority)
        throws UnfullfilledRequirementsException,
        UnresolvedResourceException,
        InstallCancelledException {
    Vector<ResourceLocation> locations = new Vector<>();
    locations.addElement(new ResourceLocation(authority, profileRef));

    Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
            CommCarePlatform.APP_PROFILE_RESOURCE_ID, locations,
            "Application Descriptor");

    table.addResource(r,
            table.getInstallers().getProfileInstaller(false),
            null);

    prepareProfileResource(table);
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:20,代码来源:ResourceManager.java

示例10: prepareUpgradeResources

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:29,代码来源:ResourceManager.java

示例11: initFromArchive

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
public void initFromArchive(String archiveURL) throws InstallCancelledException,
        UnresolvedResourceException, UnfullfilledRequirementsException {
    String fileName;
    if (archiveURL.startsWith("http")) {
        fileName = downloadToTemp(archiveURL);
    } else {
        fileName = archiveURL;
    }
    ZipFile zip;
    try {
        zip = new ZipFile(fileName);
    } catch (IOException e) {
        print.println("File at " + archiveURL + ": is not a valid CommCare Package. Downloaded to: " + fileName);
        e.printStackTrace(print);
        return;
    }
    String archiveGUID = this.mArchiveRoot.addArchiveFile(zip);

    init("jr://archive/" + archiveGUID + "/profile.ccpr");
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:21,代码来源:CommCareConfigEngine.java

示例12: testDisplayBlockParsing_invalidXPathExpr

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
@Test
public void testDisplayBlockParsing_invalidXPathExpr() throws Exception {
    boolean exceptionThrown = false;
    try {
        new MockApp("/app_with_bad_numeric_badge/");
    } catch (UnresolvedResourceException e) {
        exceptionThrown = true;
        String expectedErrorMsg = "Invalid XPath Expression : ,3";
        Assert.assertTrue(
                "The exception that was thrown was due to an unexpected cause",
                e.getMessage().contains(expectedErrorMsg));
    }
    if (!exceptionThrown) {
        fail("A Text block of form badge whose xpath element contains an invalid xpath " +
                "expression should throw an exception");
    }
}
 
开发者ID:dimagi,项目名称:commcare-core,代码行数:18,代码来源:AppStructureTests.java

示例13: upgrade

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
public boolean upgrade(Resource r) throws UnresolvedResourceException {
    //Basically some content as revert. Merge;
    FormDef form = storage().read(cacheLocation);
    String tempString = form.getInstance().schema;

    //Atomic. Don't re-do this if it was already done.
    if (tempString.indexOf(UPGRADE_EXT) != -1) {
        form.getInstance().schema = tempString.substring(0, tempString.indexOf(UPGRADE_EXT));
        storage().write(form);
    }
    return true;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:13,代码来源:XFormInstaller.java

示例14: install

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
public boolean install(Resource r, ResourceLocation location, Reference ref, ResourceTable table, CommCareInstance instance, boolean upgrade) throws UnresolvedResourceException {
    boolean result = super.install(r, location, ref, table, instance, upgrade);
    if (result) {
        table.commit(r, Resource.RESOURCE_STATUS_INSTALLED);
        return true;
    }
    return false;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:9,代码来源:MediaInstaller.java

示例15: installAppResources

import org.commcare.resources.model.UnresolvedResourceException; //导入依赖的package包/类
/**
 * Installs resources described by profile reference into the provided
 * resource table. If the resource table is ready or already has a profile,
 * don't do anything.
 *
 * @param profileReference URL to profile file
 * @param global           Add profile ref to this table and install its
 *                         resources
 * @param forceInstall     Should installation be performed regardless of
 *                         version numbers?
 */
public static void installAppResources(CommCarePlatform platform, String profileReference,
                                       ResourceTable global, boolean forceInstall)
        throws UnfullfilledRequirementsException,
        UnresolvedResourceException,
        InstallCancelledException {
    synchronized (updateLock) {
        try {
            if (!global.isReady()) {
                global.prepareResources(null, platform);
            }

            // First, see if the appropriate profile exists
            Resource profile =
                    global.getResourceWithId(CommCarePlatform.APP_PROFILE_RESOURCE_ID);

            if (profile == null) {
                // grab the local profile and parse it
                Vector<ResourceLocation> locations = new Vector<ResourceLocation>();
                locations.addElement(new ResourceLocation(Resource.RESOURCE_AUTHORITY_LOCAL, profileReference));

                // We need a way to identify this version...
                Resource r = new Resource(Resource.RESOURCE_VERSION_UNKNOWN,
                        CommCarePlatform.APP_PROFILE_RESOURCE_ID,
                        locations, "Application Descriptor");

                global.addResource(r, global.getInstallers().getProfileInstaller(forceInstall), "");
                global.prepareResources(null, platform);
            }
        } catch (StorageFullException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:45,代码来源:ResourceManager.java


注:本文中的org.commcare.resources.model.UnresolvedResourceException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。