예제 #1
0
  @Override
  public GatewayClient storeClient(GatewayClient client) throws DatastoreException {

    log.debug("Storing client: [%s]", client);
    Application application = getApplication(client.getBareJid());
    if (application == null) {
      log.debug("Client [%s] already exists", client);
      throw new ApplicationNotFoundException();
    }

    Mutator mutator = Pelops.createMutator(schemaName);
    mutator.writeColumns(
        "clients",
        client.getBareJid(),
        mutator.newColumnList(mutator.newColumn(client.getResource(), client.getResource())));
    try {
      mutator.execute(ConsistencyLevel.ONE);
      log.debug("Client [%s] stored successfully", client);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
      throw new DatastoreException(
          String.format("Could not create client application [%s]", client));
    }

    return client;
  }