Java Code Examples for com.hazelcast.core.IMap#delete()

The following examples show how to use com.hazelcast.core.IMap#delete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheStartupHookProviderTest.java    From light-oauth2 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testClientCache() {
    CacheStartupHookProvider start = new CacheStartupHookProvider();
    start.onStartup();

    final IMap<String, Client> clients = CacheStartupHookProvider.hz.getMap("clients");

    Client client = clients.get("f7d42348-c647-4efb-a52d-4c5787421e72");
    System.out.println("client = " + client);

    client.setClientType(Client.ClientTypeEnum.fromValue("trusted"));

    clients.put("f7d42348-c647-4efb-a52d-4c5787421e72", client);
    System.out.println("clients size = " + clients.size());

    clients.delete("f7d42348-c647-4efb-a52d-4c5787421e72");
    System.out.println("clients size = " + clients.size());

    CacheShutdownHookProvider shutdown = new CacheShutdownHookProvider();
    shutdown.onShutdown();

}
 
Example 2
Source File: Oauth2RefreshTokenRefreshTokenDeleteHandler.java    From light-oauth2 with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    String refreshToken = exchange.getQueryParameters().get("refreshToken").getFirst();
    if(logger.isDebugEnabled()) logger.debug("refreshToken = " + refreshToken);
    IMap<String, RefreshToken> tokens = CacheStartupHookProvider.hz.getMap("tokens");
    if(tokens.get(refreshToken) == null) {
        setExchangeStatus(exchange, REFRESH_TOKEN_NOT_FOUND, refreshToken);
    } else {
        tokens.delete(refreshToken);
    }
    processAudit(exchange);
}
 
Example 3
Source File: Oauth2UserUserIdDeleteHandler.java    From light-oauth2 with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    String userId = exchange.getQueryParameters().get("userId").getFirst();
    IMap<String, User> users = CacheStartupHookProvider.hz.getMap("users");
    if(users.get(userId) == null) {
        setExchangeStatus(exchange, USER_NOT_FOUND, userId);
    } else {
        users.delete(userId);
    }
    processAudit(exchange);
}
 
Example 4
Source File: Oauth2ServiceServiceIdDeleteHandler.java    From light-oauth2 with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    String serviceId = exchange.getQueryParameters().get("serviceId").getFirst();
    IMap<String, ServiceEndpoint> serviceEndpoints = CacheStartupHookProvider.hz.getMap("serviceEndpoints");
    IMap<String, Service> services = CacheStartupHookProvider.hz.getMap("services");
    if(services.get(serviceId) == null) {
        setExchangeStatus(exchange, SERVICE_NOT_FOUND, serviceId);
    } else {
        serviceEndpoints.delete(serviceId);
        services.delete(serviceId);
    }
    processAudit(exchange);
}
 
Example 5
Source File: Oauth2ServiceServiceIdEndpointDeleteHandler.java    From light-oauth2 with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    String serviceId = exchange.getQueryParameters().get("serviceId").getFirst();
    if(logger.isDebugEnabled()) logger.debug("Delete service endpoint for serviceId " + serviceId);
    IMap<String, List<ServiceEndpoint>> serviceEndpoints = CacheStartupHookProvider.hz.getMap("serviceEndpoints");
    if(serviceEndpoints.get(serviceId) == null || serviceEndpoints.get(serviceId).size() == 0) {
        setExchangeStatus(exchange, SERVICE_ENDPOINT_NOT_FOUND, serviceId);
    } else {
        serviceEndpoints.delete(serviceId);
    }
    processAudit(exchange);
}
 
Example 6
Source File: Oauth2ClientClientIdDeleteHandler.java    From light-oauth2 with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    String clientId = exchange.getQueryParameters().get("clientId").getFirst();

    IMap<String, Client> clients = CacheStartupHookProvider.hz.getMap("clients");
    if(clients.get(clientId) == null) {
        setExchangeStatus(exchange, CLIENT_NOT_FOUND, clientId);
    } else {
        clients.delete(clientId);
    }
    processAudit(exchange);
}
 
Example 7
Source File: Oauth2ProviderProviderIdDeleteHandler.java    From light-oauth2 with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
    String providerId = exchange.getQueryParameters().get("providerId").getFirst();

    IMap<String, Provider> providers = CacheStartupHookProvider.hz.getMap("providers");
    if(providers.get(providerId) == null) {
        setExchangeStatus(exchange, PROVIDER_ID_NOT_EXISTING, providerId);
    } else {
        providers.delete(providerId);
    }
    processAudit(exchange);
}
 
Example 8
Source File: InventoryItemDeactivatedHandler.java    From cqrs-eventsourcing-kafka with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(InventoryItemDeactivated event) {
    IMap<String, InventoryItemListItem> inventoryItems = getInventoryItemsMap();

    String id = event.id.toString();
    inventoryItems.delete(id);
}
 
Example 9
Source File: CacheStartupHookProviderTest.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testServiceCache() {
    CacheStartupHookProvider start = new CacheStartupHookProvider();
    start.onStartup();

    final IMap<String, Service> services = CacheStartupHookProvider.hz.getMap("services");

    Service service = services.get("AACT0001");
    System.out.println("service = " + service);

    service.setServiceType(Service.ServiceTypeEnum.fromValue("swagger"));

    services.replace("AACT0001", service);

    System.out.println("services size = " + services.size());

    services.delete("AACT0001");

    System.out.println("services size = " + services.size());

    CacheShutdownHookProvider shutdown = new CacheShutdownHookProvider();
    shutdown.onShutdown();

}
 
Example 10
Source File: CacheStartupHookProviderTest.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
@Test
public void testCodeCache() {
    CacheStartupHookProvider start = new CacheStartupHookProvider();
    start.onStartup();

    final IMap<String, Object> codes = CacheStartupHookProvider.hz.getMap("codes");
    Map<String, String> codeMap = new HashMap<>();
    codeMap.put("userId", "admin");
    codeMap.put("redirectUri", "https://localhost:8080/authorization");

    codes.put("code1", codeMap);

    System.out.println("codes size = " + codes.size());

    codes.delete("code1");

    System.out.println("codes size = " + codes.size());

    CacheShutdownHookProvider shutdown = new CacheShutdownHookProvider();
    shutdown.onShutdown();

}
 
Example 11
Source File: CacheStartupHookProviderTest.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
@Test
public void testReferenceCache() {
    CacheStartupHookProvider start = new CacheStartupHookProvider();
    start.onStartup();

    final IMap<String, Object> references = CacheStartupHookProvider.hz.getMap("references");
    Map<String, String> referenceMap = new HashMap<>();
    referenceMap.put("ref", "jwt");
    referenceMap.put("clientId", "client1");

    references.put("ref", referenceMap);

    System.out.println("references size = " + references.size());

    references.delete("ref");

    System.out.println("references size = " + references.size());

    CacheShutdownHookProvider shutdown = new CacheShutdownHookProvider();
    shutdown.onShutdown();

}
 
Example 12
Source File: CacheStartupHookProviderTest.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testServiceEndpointCache() {
    CacheStartupHookProvider start = new CacheStartupHookProvider();
    start.onStartup();

    final IMap<String, List<ServiceEndpoint>> serviceEndpoints = CacheStartupHookProvider.hz.getMap("serviceEndpoints");

    List<ServiceEndpoint> list = serviceEndpoints.get("AACT0001");
    System.out.println("list size = " + list.size());

    serviceEndpoints.delete("AACT0001");

    System.out.println("list size = " + serviceEndpoints.size());

    CacheShutdownHookProvider shutdown = new CacheShutdownHookProvider();
    shutdown.onShutdown();

}
 
Example 13
Source File: CacheStartupHookProviderTest.java    From light-oauth2 with Apache License 2.0 3 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void testUserCache() {
    CacheStartupHookProvider start = new CacheStartupHookProvider();
    start.onStartup();

    final IMap<String, User> users = CacheStartupHookProvider.hz.getMap("users");

    User user = (User)users.get("admin");
    System.out.println("user = " + user);

    user.setUserType(User.UserTypeEnum.fromValue("customer"));

    users.put("admin", user);

    System.out.println("users size = " + users.size());

    // query email as it is indexed.
    String email = "adm%";
    Predicate predicate = new SqlPredicate(String.format("email like %s", email));
    Set<User> uSet = (Set<User>) users.values(predicate);

    System.out.println("uSet = " + uSet);

    users.delete("admin");

    System.out.println("users size = " + users.size());

    CacheShutdownHookProvider shutdown = new CacheShutdownHookProvider();
    shutdown.onShutdown();

}
 
Example 14
Source File: CacheStartupHookProviderTest.java    From light-oauth2 with Apache License 2.0 3 votes vote down vote up
@Test
public void testRefreshTokenCache() {
    CacheStartupHookProvider start = new CacheStartupHookProvider();
    start.onStartup();

    final IMap<String, RefreshToken> tokens = CacheStartupHookProvider.hz.getMap("tokens");
    RefreshToken token = new RefreshToken();
    token.setUserId("admin2");
    token.setClientId("59f347a0-c92d-11e6-9d9d-cec0c932ce01");

    token.setScope("todo.r");
    token.setRemember("N");
    token.setRefreshToken("token1");


    tokens.put("token1", token);

    System.out.println("tokens size = " + tokens.size());

    tokens.delete("token1");

    System.out.println("tokens size = " + tokens.size());

    CacheShutdownHookProvider shutdown = new CacheShutdownHookProvider();
    shutdown.onShutdown();

}