Search in sources :

Example 1 with StorageService

use of org.eclipse.userstorage.internal.StorageService in project epp.mpc by eclipse.

the class MarketplaceStorageService method cleanupExtraStorageService.

private static IStorageService cleanupExtraStorageService(IStorageService service, IStorageService extraService) {
    IStorageService.Dynamic removeDynamic;
    IStorageService keepService;
    if (extraService instanceof IStorageService.Dynamic) {
        removeDynamic = (IStorageService.Dynamic) extraService;
        keepService = service;
    } else if (service instanceof IStorageService.Dynamic) {
        removeDynamic = (IStorageService.Dynamic) service;
        keepService = extraService;
    } else {
        return service;
    }
    if (removeDynamic instanceof StorageService && keepService instanceof StorageService) {
        StorageService removeImpl = (StorageService) removeDynamic;
        StorageService keepImpl = (StorageService) keepService;
        ISecurePreferences removeSecurePreferences = removeImpl.getSecurePreferences();
        ISecurePreferences keepSecurePreferences = keepImpl.getSecurePreferences();
        try {
            copySecurePreferences(removeSecurePreferences, keepSecurePreferences);
        } catch (Exception e) {
            MarketplaceClientCore.error(NLS.bind("Failed to migrate secure storage values from {0} to {1}", removeDynamic.getServiceURI(), keepService.getServiceURI()), e);
        }
    }
    removeDynamic.remove();
    return keepService;
}
Also used : IStorageService(org.eclipse.userstorage.IStorageService) ISecurePreferences(org.eclipse.equinox.security.storage.ISecurePreferences) URISyntaxException(java.net.URISyntaxException) StorageException(org.eclipse.equinox.security.storage.StorageException) IOException(java.io.IOException) IStorageService(org.eclipse.userstorage.IStorageService) IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService) StorageService(org.eclipse.userstorage.internal.StorageService)

Example 2 with StorageService

use of org.eclipse.userstorage.internal.StorageService in project epp.mpc by eclipse.

the class UserFavoritesServiceTest method assureService.

private static void assureService() {
    StorageService service = StorageServiceRegistry.INSTANCE.getService(USERSTORAGE_SERVICE_URI);
    if (service == null) {
        StorageServiceRegistry.INSTANCE.addService("Staging", USERSTORAGE_SERVICE_URI);
        service = StorageServiceRegistry.INSTANCE.getService(USERSTORAGE_SERVICE_URI);
    }
    assertNotNull(service);
}
Also used : IStorageService(org.eclipse.userstorage.IStorageService) IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService) StorageService(org.eclipse.userstorage.internal.StorageService)

Aggregations

IMarketplaceStorageService (org.eclipse.epp.mpc.core.service.IMarketplaceStorageService)2 IStorageService (org.eclipse.userstorage.IStorageService)2 StorageService (org.eclipse.userstorage.internal.StorageService)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ISecurePreferences (org.eclipse.equinox.security.storage.ISecurePreferences)1 StorageException (org.eclipse.equinox.security.storage.StorageException)1