Search in sources :

Example 6 with IMarketplaceStorageService

use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.

the class ServiceLocator method registerFavoritesService.

public IUserFavoritesService registerFavoritesService(String marketplaceBaseUrl, String apiServerUrl, String apiKey) {
    IMarketplaceStorageService storageService = getStorageService(marketplaceBaseUrl);
    if (storageService == null) {
        storageService = registerStorageService(marketplaceBaseUrl, apiServerUrl, apiKey);
    }
    UserFavoritesService favoritesService = new UserFavoritesService();
    favoritesService.bindStorageService(storageService);
    registerService(marketplaceBaseUrl, IUserFavoritesService.class, favoritesService);
    return favoritesService;
}
Also used : UserFavoritesService(org.eclipse.epp.internal.mpc.core.service.UserFavoritesService) IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService)

Example 7 with IMarketplaceStorageService

use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.

the class MarketplaceStorageServiceRegistrationTest method testCleanupDuplicateStorageService.

@Test
public void testCleanupDuplicateStorageService() throws Exception {
    IStorageService withSlash = storageServices.provide("WithSlash", "https://api-test.example.org/");
    IStorageService withoutSlash = storageServices.provide("WithoutSlash", "https://api-test.example.org");
    ((StorageService) withSlash).getSecurePreferences().remove("username");
    ((StorageService) withoutSlash).getSecurePreferences().put("username", "testuser", false);
    IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api-test.example.org", null);
    assertNotNull(registered);
    assertEquals("https://api-test.example.org/", registered.getServiceUri().toString());
    assertSame(withSlash, registered.getStorage().getService());
    withoutSlash = IStorageService.Registry.INSTANCE.getService(URI.create("https://api-test.example.org"));
    assertNull(withoutSlash);
    String username = ((StorageService) withSlash).getSecurePreferences().get("username", null);
    assertEquals("testuser", username);
}
Also used : IStorageService(org.eclipse.userstorage.IStorageService) IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService) Test(org.junit.Test)

Example 8 with IMarketplaceStorageService

use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.

the class MarketplaceStorageServiceRegistrationTest method testCleanupDuplicateEclipseOrgStorageService.

@Test
public void testCleanupDuplicateEclipseOrgStorageService() throws Exception {
    IStorageService withSlash = storageServices.provide("WithSlash", "https://api.eclipse.org/");
    assertFalse(withSlash instanceof IStorageService.Dynamic);
    IStorageService withoutSlash = storageServices.provide("WithoutSlash", "https://api.eclipse.org");
    assertTrue(withoutSlash instanceof IStorageService.Dynamic);
    IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api.eclipse.org/", null);
    assertNotNull(registered);
    assertSame(withSlash, registered.getStorage().getService());
    withoutSlash = IStorageService.Registry.INSTANCE.getService(URI.create("https://api.eclipse.org"));
    assertNull(withoutSlash);
}
Also used : IStorageService(org.eclipse.userstorage.IStorageService) Dynamic(org.eclipse.userstorage.IStorageService.Dynamic) IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService) Test(org.junit.Test)

Example 9 with IMarketplaceStorageService

use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.

the class MarketplaceStorageServiceRegistrationTest method testRegisterNewStorageServiceWithSlash.

@Test
public void testRegisterNewStorageServiceWithSlash() {
    IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api-test.example.org/", null);
    assertNotNull(registered);
    assertEquals("https://api-test.example.org/", registered.getServiceUri().toString());
}
Also used : IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService) Test(org.junit.Test)

Example 10 with IMarketplaceStorageService

use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.

the class MarketplaceStorageServiceRegistrationTest method testRegisterNewStorageServiceWithoutSlash.

@Test
public void testRegisterNewStorageServiceWithoutSlash() {
    IMarketplaceStorageService registered = serviceLocator.registerStorageService(DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION, "https://api-test.example.org", null);
    assertNotNull(registered);
    assertEquals("https://api-test.example.org/", registered.getServiceUri().toString());
    IStorageService withoutSlash = IStorageService.Registry.INSTANCE.getService(URI.create("https://api-test.example.org"));
    assertNull(withoutSlash);
}
Also used : IStorageService(org.eclipse.userstorage.IStorageService) IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService) Test(org.junit.Test)

Aggregations

IMarketplaceStorageService (org.eclipse.epp.mpc.core.service.IMarketplaceStorageService)14 IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)7 Test (org.junit.Test)6 IStorageService (org.eclipse.userstorage.IStorageService)5 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2 NoSuchElementException (java.util.NoSuchElementException)2 CoreException (org.eclipse.core.runtime.CoreException)2 NotAuthorizedException (org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException)2 UserFavoritesService (org.eclipse.epp.internal.mpc.core.service.UserFavoritesService)2 LoginListener (org.eclipse.epp.mpc.core.service.IMarketplaceStorageService.LoginListener)2 BundleContext (org.osgi.framework.BundleContext)2 URL (java.net.URL)1 Hashtable (java.util.Hashtable)1 Callable (java.util.concurrent.Callable)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1