예제 #1
1
  public final String getNameFromUuid(@NonNull UUID player, boolean expensiveLookups) {
    // If the player is online, give them their UUID.
    // Remember, local data > remote data.
    if (ProxyServer.getInstance().getPlayer(player) != null)
      return ProxyServer.getInstance().getPlayer(player).getName();

    // Check if it exists in the map
    CachedUUIDEntry cachedUUIDEntry = uuidToNameMap.get(player);
    if (cachedUUIDEntry != null) {
      if (!cachedUUIDEntry.expired()) return cachedUUIDEntry.getName();
      else uuidToNameMap.remove(player);
    }

    // Okay, it wasn't locally cached. Let's try Redis.
    try (Jedis jedis = plugin.getPool().getResource()) {
      String stored = jedis.hget("uuid-cache", player.toString());
      if (stored != null) {
        // Found an entry value. Deserialize it.
        CachedUUIDEntry entry = RedisBungee.getGson().fromJson(stored, CachedUUIDEntry.class);

        // Check for expiry:
        if (entry.expired()) {
          jedis.hdel("uuid-cache", player.toString());
          // Doesn't hurt to also remove the named entry as well.
          // TODO: Since UUIDs are fixed, we could look up the name and see if the UUID matches.
          jedis.hdel("uuid-cache", entry.getName());
        } else {
          nameToUuidMap.put(entry.getName().toLowerCase(), entry);
          uuidToNameMap.put(player, entry);
          return entry.getName();
        }
      }

      if (!expensiveLookups || !ProxyServer.getInstance().getConfig().isOnlineMode()) return null;

      // That didn't work. Let's ask Mojang. This call may fail, because Mojang is insane.
      String name;
      try {
        List<String> nameHist = NameFetcher.nameHistoryFromUuid(player);
        name = Iterables.getLast(nameHist, null);
      } catch (Exception e) {
        plugin.getLogger().log(Level.SEVERE, "Unable to fetch name from Mojang for " + player, e);
        return null;
      }

      if (name != null) {
        persistInfo(name, player, jedis);
        return name;
      }

      return null;
    } catch (JedisException e) {
      plugin.getLogger().log(Level.SEVERE, "Unable to fetch name for " + player, e);
      return null;
    }
  }
  @Override
  public void createCustomAPI(
      UUID subscriptionId, String serviceName, String tableName, CustomAPIPermissions permissions)
      throws AzureCmdException {

    String[] cmd;
    if (permissions == null)
      cmd =
          new String[] {
            "mobile", "api", "create", "-s", subscriptionId.toString(), serviceName, tableName
          };
    else
      cmd =
          new String[] {
            "mobile",
            "api",
            "create",
            "-p",
            permissions.toString(),
            "-s",
            subscriptionId.toString(),
            serviceName,
            tableName
          };

    AzureCommandHelper.getInstance().consoleExec(cmd);
  }
예제 #3
0
  private void handleIndexOperation(final ElasticsearchIndexEvent elasticsearchIndexEvent)
      throws IndexDocNotFoundException {

    Preconditions.checkNotNull(elasticsearchIndexEvent, "elasticsearchIndexEvent cannot be null");

    final UUID messageId = elasticsearchIndexEvent.getIndexBatchId();
    Preconditions.checkNotNull(messageId, "messageId must not be null");

    final String message = esMapPersistence.getString(messageId.toString());

    final IndexOperationMessage indexOperationMessage;
    if (message == null) {

      // provide some time back pressure before performing a quorum read
      if (queueFig.getQuorumFallback()
          && System.currentTimeMillis()
              > elasticsearchIndexEvent.getCreationTime() + queueFig.getLocalQuorumTimeout()) {

        if (logger.isDebugEnabled()) {
          logger.debug("ES batch with id {} not found, reading with strong consistency", messageId);
        }

        final String highConsistency =
            esMapPersistence.getStringHighConsistency(messageId.toString());
        if (highConsistency == null) {

          throw new RuntimeException(
              "ES batch with id " + messageId + " not found when reading with strong consistency");
        }

        indexOperationMessage =
            ObjectJsonSerializer.INSTANCE.fromString(highConsistency, IndexOperationMessage.class);

      } else {

        throw new IndexDocNotFoundException(elasticsearchIndexEvent.getIndexBatchId());
      }

    } else {

      indexOperationMessage =
          ObjectJsonSerializer.INSTANCE.fromString(message, IndexOperationMessage.class);
    }

    // don't let this continue if there's nothing to index
    if (indexOperationMessage == null || indexOperationMessage.isEmpty()) {
      throw new RuntimeException(
          "IndexOperationMessage cannot be null or empty after retrieving from map persistence");
    }

    // always do a check to ensure the indexes are initialized for the index requests
    initializeEntityIndexes(indexOperationMessage);

    // send it to to be indexed
    indexProducer.put(indexOperationMessage).toBlocking().last();
  }
  @Override
  public void updateJob(
      UUID subscriptionId,
      String serviceName,
      String jobName,
      int interval,
      String intervalUnit,
      String startDate,
      boolean enabled)
      throws AzureCmdException {
    String[] cmd = null;

    if (startDate == null)
      cmd =
          new String[] {
            "mobile",
            "job",
            "update",
            "-s",
            subscriptionId.toString(),
            "-i",
            String.valueOf(interval),
            "-u",
            intervalUnit,
            "-a",
            enabled ? "enabled" : "disabled",
            serviceName,
            jobName
          };
    else
      cmd =
          new String[] {
            "mobile",
            "job",
            "update",
            "-s",
            subscriptionId.toString(),
            "-i",
            String.valueOf(interval),
            "-u",
            intervalUnit,
            "-a",
            enabled ? "enabled" : "disabled",
            "-t",
            startDate,
            serviceName,
            jobName
          };

    AzureCommandHelper.getInstance().consoleExec(cmd);
  }
예제 #5
0
  /**
   * Queue up an indexOperationMessage for multi region execution
   *
   * @param indexOperationMessage
   */
  public void queueIndexOperationMessage(final IndexOperationMessage indexOperationMessage) {

    // don't try to produce something with nothing
    if (indexOperationMessage == null || indexOperationMessage.isEmpty()) {
      return;
    }

    final String jsonValue = ObjectJsonSerializer.INSTANCE.toString(indexOperationMessage);

    final UUID newMessageId = UUIDGenerator.newTimeUUID();

    final int expirationTimeInSeconds =
        (int) TimeUnit.MILLISECONDS.toSeconds(indexProcessorFig.getIndexMessageTtl());

    // write to the map in ES
    esMapPersistence.putString(newMessageId.toString(), jsonValue, expirationTimeInSeconds);

    // now queue up the index message

    final ElasticsearchIndexEvent elasticsearchIndexEvent =
        new ElasticsearchIndexEvent(queueFig.getPrimaryRegion(), newMessageId);

    // send to the topic so all regions index the batch

    offerTopic(elasticsearchIndexEvent);
  }
예제 #6
0
 public boolean hasRestoration(Player player) {
   UUID uuid = player.getUniqueId();
   if (multipleInventories()) {
     return RESTORATIONS.containsKey(uuid + "." + getWorldGroups(player));
   }
   return RESTORATIONS.containsKey(uuid.toString());
 }
  @Override
  public List<Table> getTableList(UUID subscriptionId, String serviceName)
      throws AzureCmdException {

    String[] cmd =
        new String[] {
          "mobile", "table", "list", "--json", "-s", subscriptionId.toString(), serviceName
        };

    String json = AzureCommandHelper.getInstance().consoleExec(cmd);

    CustomJsonSlurper slurper = new CustomJsonSlurper();
    List<Map<String, String>> tempRes = (List<Map<String, String>>) slurper.parseText(json);

    List<Table> res = new ArrayList<Table>();
    for (Map<String, String> item : tempRes) {
      Table t = new Table();
      t.setName(item.get("name"));
      t.setSelfLink(item.get("selflink"));

      res.add(t);
    }

    return res;
  }
  public List<SqlDb> getSqlDb(
      UUID subscriptionId, String serverName, String admin, String adminPassword)
      throws AzureCmdException {
    String[] cmd =
        new String[] {
          "sql",
          "db",
          "list",
          "--json",
          "-s",
          subscriptionId.toString(),
          serverName,
          admin,
          adminPassword
        };

    String json = AzureCommandHelper.getInstance().consoleExec(cmd);

    CustomJsonSlurper slurper = new CustomJsonSlurper();
    List<Map<String, String>> tempRes = (List<Map<String, String>>) slurper.parseText(json);

    List<SqlDb> res = new ArrayList<SqlDb>();
    for (Map<String, String> item : tempRes) {

      SqlDb sqls = new SqlDb();
      sqls.setName(item.get("Name"));
      sqls.setEdition(item.get("Edition"));
      res.add(sqls);
    }

    return res;
  }
  @Override
  public List<CustomAPI> getAPIList(UUID subscriptionId, String serviceName)
      throws AzureCmdException {

    String[] cmd =
        new String[] {
          "mobile", "api", "list", "--json", "-s", subscriptionId.toString(), serviceName
        };

    String json = AzureCommandHelper.getInstance().consoleExec(cmd);

    CustomJsonSlurper slurper = new CustomJsonSlurper();
    List<Map<String, String>> tempRes = (List<Map<String, String>>) slurper.parseText(json);

    List<CustomAPI> res = new ArrayList<CustomAPI>();
    for (Map<String, String> item : tempRes) {
      CustomAPI c = new CustomAPI();
      c.setName(item.get("name"));
      CustomAPIPermissions permissions = new CustomAPIPermissions();
      permissions.setPutPermission(PermissionItem.getPermitionType(item.get("put")));
      permissions.setPostPermission(PermissionItem.getPermitionType(item.get("post")));
      permissions.setGetPermission(PermissionItem.getPermitionType(item.get("get")));
      permissions.setDeletePermission(PermissionItem.getPermitionType(item.get("delete")));
      permissions.setPatchPermission(PermissionItem.getPermitionType(item.get("patch")));
      c.setCustomAPIPermissions(permissions);
      res.add(c);
    }

    return res;
  }
 public CFSecuritySecDeviceBuff lockBuff(
     CFSecurityAuthorization Authorization, CFSecuritySecDevicePKey PKey) {
   final String S_ProcName = "lockBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     UUID SecUserId = PKey.getRequiredSecUserId();
     String DevName = PKey.getRequiredDevName();
     String sql =
         "SELECT * FROM "
             + schema.getLowerDbSchemaName()
             + ".sp_lock_secdev( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtLockBuffByPKey == null) {
       stmtLockBuffByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtLockBuffByPKey.setString(argIdx++, SecUserId.toString());
     stmtLockBuffByPKey.setString(argIdx++, DevName);
     resultSet = stmtLockBuffByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecuritySecDeviceBuff buff = unpackSecDeviceResultSetToBuff(resultSet);
       if (resultSet.next()) {
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  @Override
  public List<Job> listJobs(UUID subscriptionId, String serviceName) throws AzureCmdException {
    String[] cmd =
        new String[] {
          "mobile", "job", "list", "--json", "-s", subscriptionId.toString(), serviceName,
        };

    String json = AzureCommandHelper.getInstance().consoleExec(cmd);

    CustomJsonSlurper slurper = new CustomJsonSlurper();
    List<Map<String, Object>> tempRes = (List<Map<String, Object>>) slurper.parseText(json);

    List<Job> res = new ArrayList<Job>();
    for (Map<String, Object> item : tempRes) {
      Job j = new Job();
      j.setAppName(item.get("appName").toString());
      j.setName(item.get("name").toString());
      j.setEnabled(item.get("status").equals("enabled"));
      j.setId(UUID.fromString(item.get("id").toString()));

      if (item.get("intervalPeriod") != null) {
        j.setIntervalPeriod((Integer) item.get("intervalPeriod"));
        j.setIntervalUnit(item.get("intervalUnit").toString());
      }

      res.add(j);
    }

    return res;
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFSecurityMssCFBindSecGroupMemberSecUserId.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFSecuritySecGroupMemberObj) {
      UUID secUserId = ((ICFSecuritySecGroupMemberObj) genDef).getRequiredSecUserId();
      if (secUserId == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), "expandBody", 0, "Value");
      }
      ret = secUserId.toString();
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(),
              "expandBody",
              "genContext.getGenDef()",
              genDef,
              "ICFSecuritySecGroupMemberObj");
    }

    return (ret);
  }
 public CFSecuritySecDeviceBuff[] readBuffByUserIdx(
     CFSecurityAuthorization Authorization, UUID SecUserId) {
   final String S_ProcName = "readBuffByUserIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "call "
             + schema.getLowerDbSchemaName()
             + ".sp_read_secdev_by_useridx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + " )";
     if (stmtReadBuffByUserIdx == null) {
       stmtReadBuffByUserIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByUserIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUserIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByUserIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByUserIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUserIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByUserIdx.setString(argIdx++, SecUserId.toString());
     try {
       resultSet = stmtReadBuffByUserIdx.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     List<CFSecuritySecDeviceBuff> buffList = new LinkedList<CFSecuritySecDeviceBuff>();
     while ((resultSet != null) && resultSet.next()) {
       CFSecuritySecDeviceBuff buff = unpackSecDeviceResultSetToBuff(resultSet);
       buffList.add(buff);
     }
     int idx = 0;
     CFSecuritySecDeviceBuff[] retBuff = new CFSecuritySecDeviceBuff[buffList.size()];
     Iterator<CFSecuritySecDeviceBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  @Override
  public List<LogEntry> listLog(UUID subscriptionId, String serviceName)
      throws AzureCmdException, ParseException {
    String[] cmd =
        new String[] {
          "mobile", "log", "--json", "-s", subscriptionId.toString(), serviceName,
        };

    String json = AzureCommandHelper.getInstance().consoleExec(cmd);

    CustomJsonSlurper slurper = new CustomJsonSlurper();

    Map<String, Object> results = (Map<String, Object>) slurper.parseText(json);
    List<Map<String, String>> tempRes = (List<Map<String, String>>) results.get("results");

    List<LogEntry> res = new ArrayList<LogEntry>();
    for (Map<String, String> item : tempRes) {
      LogEntry logEntry = new LogEntry();

      logEntry.setMessage(item.get("message"));
      logEntry.setSource(item.get("source"));
      logEntry.setType(item.get("type"));

      SimpleDateFormat ISO8601DATEFORMAT =
          new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH);
      logEntry.setTimeCreated(ISO8601DATEFORMAT.parse(item.get("timeCreated")));

      res.add(logEntry);
    }

    return res;
  }
예제 #15
0
  @Override
  public State retrieveState(String id, String activityId, Agent agent, UUID registration)
      throws Exception {
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("stateId", id);
    params.put("activityId", activityId);
    params.put("agent", agent.toJSON(this.getVersion(), this.usePrettyJSON()));
    if (registration != null) {
      params.put("registration", registration.toString());
    }

    String queryString = "?";
    Boolean first = true;
    for (Map.Entry<String, String> parameter : params.entrySet()) {
      queryString +=
          (first ? "" : "&")
              + URLEncoder.encode(parameter.getKey(), "UTF-8")
              + "="
              + URLEncoder.encode(parameter.getValue(), "UTF-8").replace("+", "%20");
      first = false;
    }

    HTTPRequest request = new HTTPRequest();
    request.setURL(this.getEndpoint() + "activities/state" + queryString);

    HTTPResponse response = this.sendRequest(request);
    int status = response.getStatus();

    if (status == 200) {
      return new State(id, response.getContentBytes(), activityId, agent, registration);
    } else if (status == 404) {
      return null;
    }
    throw new UnexpectedHTTPResponse(response);
  }
예제 #16
0
  public static String primaryRowKey(Object obj)
      throws CassandraMappingNullIndexException, IOException {
    if (obj instanceof String) {
      String str = (String) obj;
      if (str.length() == 0) {
        throw new CassandraMappingNullIndexException(
            "Primary keys and indexed properties cannot have null values");
      } else {
        return str;
      }
    } else if (obj instanceof UUID) {
      UUID id = (UUID) obj;
      if (id.version() == 1) {
        long time = UuidDynamicMethods.time(id);
        return timePrefix(time) + "_" + id.toString();
      } else {
        return id.toString();
      }

    } else if (obj instanceof Date) {
      return timePrefix(((Date) obj).getTime());
    } else if (obj instanceof GroovyObject) {
      GroovyObject g = (GroovyObject) obj;
      if (OrmHelper.isMappedObject(g)) {
        return (String) g.getProperty("id");
      }
    } else if (obj == null) {
      throw new CassandraMappingNullIndexException(
          "Primary keys and indexed properties cannot have null values");
    } else if (obj instanceof Collection) {
      Collection c = (Collection) obj;
      List<String> items = new ArrayList<String>(c.size());
      for (Object it : c) {
        items.add(primaryRowKey(it));
      }
      return makeComposite(items);
    } else if (obj instanceof Number || obj instanceof Boolean) {
      return obj.toString();
    }

    try {
      return String.valueOf(DataMapper.dataProperty(obj));
    } catch (IllegalArgumentException e) {
      // TODO - why do we get this for enums in counters and not in simple properties?
      return obj.toString();
    }
  }
  @Override
  public Table showTableDetails(UUID subscriptionId, String serviceName, String tableName)
      throws AzureCmdException {
    String[] cmd =
        new String[] {
          "mobile",
          "table",
          "show",
          "--json",
          "-s",
          subscriptionId.toString(),
          serviceName,
          tableName
        };

    String json = AzureCommandHelper.getInstance().consoleExec(cmd);

    CustomJsonSlurper slurper = new CustomJsonSlurper();
    Map<String, Object> tempRes = (Map<String, Object>) slurper.parseText(json);

    Table t = new Table();

    Map<String, Object> tableData = (Map<String, Object>) tempRes.get("table");
    t.setName(tableData.get("name").toString());
    t.setSelfLink(tableData.get("selflink").toString());

    Map<String, String> per = (Map<String, String>) tempRes.get("permissions");

    TablePermissions tablePermissions = new TablePermissions();
    tablePermissions.setInsert(PermissionItem.getPermitionType(per.get("insert")));
    tablePermissions.setUpdate(PermissionItem.getPermitionType(per.get("update")));
    tablePermissions.setRead(PermissionItem.getPermitionType(per.get("read")));
    tablePermissions.setDelete(PermissionItem.getPermitionType(per.get("delete")));
    t.setTablePermissions(tablePermissions);

    for (Map<String, Object> column : (List<Map<String, Object>>) tempRes.get("columns")) {
      Column c = new Column();
      c.setName(column.get("name").toString());
      c.setType(column.get("type").toString());
      c.setSelfLink(column.get("selflink").toString());
      c.setIndexed((Boolean) column.get("indexed"));
      c.setZumoIndex((Boolean) column.get("zumoIndex"));

      t.getColumns().add(c);
    }

    for (Map<String, Object> script : (List<Map<String, Object>>) tempRes.get("scripts")) {
      Script s = new Script();

      s.setOperation(script.get("operation").toString());
      s.setBytes((Integer) script.get("sizeBytes"));
      s.setSelfLink(script.get("selflink").toString());
      s.setName(String.format("%s.%s", tableData.get("name"), script.get("operation").toString()));

      t.getScripts().add(s);
    }

    return t;
  }
예제 #18
0
 @Test
 public void stringLikes() throws IOException {
   ServiceLocator locator = container;
   CompositeRepository repository = locator.resolve(CompositeRepository.class);
   UUID id = UUID.randomUUID();
   repository.insert(
       new Composite().setId(id).setSimple(new Simple().setText("xxx" + id + "yyy")));
   List<Composite> found =
       repository
           .query()
           .filter(it -> it.getSimple().getText().contains(id.toString()))
           .filter(it -> it.getSimple().getText().startsWith("xxx" + id.toString()))
           .filter(it -> it.getSimple().getText().endsWith(id.toString() + "yyy"))
           .list();
   Assert.assertEquals(1, found.size());
   Assert.assertEquals(id, found.get(0).getId());
 }
  @Override
  public void createService(
      UUID subscriptionId,
      String region,
      String username,
      String password,
      String serviceName,
      String server,
      String database)
      throws AzureCmdException {
    String[] cmd;
    if (database == null || server == null)
      cmd =
          new String[] {
            "mobile",
            "create",
            "--json",
            "-s",
            subscriptionId.toString(),
            "-l",
            region,
            serviceName,
            username,
            password
          };
    else
      cmd =
          new String[] {
            "mobile",
            "create",
            "--json",
            "-s",
            subscriptionId.toString(),
            "-l",
            region,
            "-r",
            server,
            "-d",
            database,
            serviceName,
            username,
            password
          };

    AzureCommandHelper.getInstance().consoleExec(cmd);
  }
예제 #20
0
 public static void setPlayerForTracker(ItemStack stack, EntityPlayer player) {
   NBTTagCompound stackTag =
       stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound();
   UUID id = player.getGameProfile().getId();
   TEC.idToUsername.put(id, player.getCommandSenderName());
   stackTag.setString("playerUUID", id.toString());
   stackTag.setString("playerName", player.getCommandSenderName());
   stack.setTagCompound(stackTag);
 }
 public void deleteSecDeviceByIdIdx(
     CFSecurityAuthorization Authorization, UUID argSecUserId, String argDevName) {
   final String S_ProcName = "deleteSecDeviceByIdIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "SELECT "
             + schema.getLowerDbSchemaName()
             + ".sp_delete_secdev_by_ididx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " ) as DeletedFlag";
     if (stmtDeleteByIdIdx == null) {
       stmtDeleteByIdIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtDeleteByIdIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByIdIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtDeleteByIdIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtDeleteByIdIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByIdIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtDeleteByIdIdx.setString(argIdx++, argSecUserId.toString());
     stmtDeleteByIdIdx.setString(argIdx++, argDevName);
     resultSet = stmtDeleteByIdIdx.executeQuery();
     if (resultSet.next()) {
       boolean deleteFlag = resultSet.getBoolean(1);
       if (resultSet.next()) {
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response");
       }
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected 1 record result set to be returned by delete, not 0 rows");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  /**
   * Delete a term document
   *
   * @param pictureId
   * @param conf
   * @throws IOException
   */
  public static void delete(UUID pictureId, IndexWriterConfig conf) throws IOException {

    /* create term to delete document */
    Term term = new Term(DocumentBuilder.FIELD_NAME_IDENTIFIER, pictureId.toString());

    for (FeatureEnumerate f : FeatureEnumerate.values()) {
      deleteFromFeature(pictureId, term, f.getText(), conf);
    }
  }
예제 #23
0
  @Override
  public LRSResponse clearState(Activity activity, Agent agent, UUID registration) {
    HashMap<String, String> queryParams = new HashMap<String, String>();

    queryParams.put("activityId", activity.getId().toString());
    queryParams.put("agent", agent.toJSON(this.getVersion(), this.usePrettyJSON()));
    if (registration != null) {
      queryParams.put("registration", registration.toString());
    }
    return deleteDocument("activities/state", queryParams);
  }
예제 #24
0
 public void addRestoration(Player player, Restoration restoration) {
   UUID uuid = player.getUniqueId();
   if (multipleInventories()) {
     String keyName = uuid + "." + getWorldGroups(player);
     RESTORATIONS.put(keyName, restoration);
     plugin.logDebug("Adding: " + player.getDisplayName() + ":" + keyName);
   } else {
     RESTORATIONS.put(uuid.toString(), restoration);
     plugin.logDebug("Adding: " + player.getDisplayName() + ":" + uuid);
   }
 }
 public CFSecuritySecDeviceBuff readBuffByIdIdx(
     CFSecurityAuthorization Authorization, UUID SecUserId, String DevName) {
   final String S_ProcName = "readBuffByIdIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "SELECT * FROM "
             + schema.getLowerDbSchemaName()
             + ".sp_read_secdev_by_ididx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtReadBuffByIdIdx == null) {
       stmtReadBuffByIdIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByIdIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByIdIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByIdIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByIdIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByIdIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByIdIdx.setString(argIdx++, SecUserId.toString());
     stmtReadBuffByIdIdx.setString(argIdx++, DevName);
     resultSet = stmtReadBuffByIdIdx.executeQuery();
     if (resultSet.next()) {
       CFSecuritySecDeviceBuff buff = unpackSecDeviceResultSetToBuff(resultSet);
       if (resultSet.next()) {
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
예제 #26
0
 public ClientSession(
     UUID clientId, Transport transport, Collection<Address> members, Serializer serializer) {
   this.clientId = Assert.notNull(clientId, "clientId");
   this.client = Assert.notNull(transport, "transport").client();
   this.members = new HashSet<>(Assert.notNull(members, "members"));
   this.context =
       new SingleThreadContext(
           "copycat-client-" + clientId.toString(),
           Assert.notNull(serializer, "serializer").clone());
   this.connectMembers = new ArrayList<>(members);
 }
예제 #27
0
  @Override
  public ProfileKeysLRSResponse retrieveStateIds(
      Activity activity, Agent agent, UUID registration) {
    HashMap<String, String> queryParams = new HashMap<String, String>();
    queryParams.put("activityId", activity.getId().toString());
    queryParams.put("agent", agent.toJSON(this.getVersion(), this.usePrettyJSON()));
    if (registration != null) {
      queryParams.put("registration", registration.toString());
    }

    return getProfileKeys("activities/state", queryParams);
  }
  public void deleteSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) {
    final String S_ProcName = "deleteSecDevice";
    ResultSet resultSet = null;
    try {
      Connection cnx = schema.getCnx();
      UUID SecUserId = Buff.getRequiredSecUserId();
      String DevName = Buff.getRequiredDevName();

      String sql =
          "call "
              + schema.getLowerDbSchemaName()
              + ".sp_delete_secdev( ?, ?, ?, ?, ?"
              + ", "
              + "?"
              + ", "
              + "?"
              + ", "
              + "?"
              + " )";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setString(argIdx++, SecUserId.toString());
      stmtDeleteByPKey.setString(argIdx++, DevName);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      stmtDeleteByPKey.executeUpdate();
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
      if (resultSet != null) {
        try {
          resultSet.close();
        } catch (SQLException e) {
        }
        resultSet = null;
      }
    }
  }
예제 #29
0
 public void setLocalTraderData(
     UUID accountId, InMemoryPrivateKey privateKey, Address address, String nickname) {
   _session = null;
   _localTraderAddress = Preconditions.checkNotNull(address);
   _localTraderAccountId = Preconditions.checkNotNull(accountId);
   _localTraderPrivateKey = Preconditions.checkNotNull(privateKey);
   _localTraderPrivateKeyString = privateKey.getBase58EncodedPrivateKey(_mbwManager.getNetwork());
   _nickname = Preconditions.checkNotNull(nickname);
   SharedPreferences.Editor editor = getEditor();
   editor.putString(Constants.LOCAL_TRADER_KEY_SETTING, _localTraderPrivateKeyString);
   editor.putString(Constants.LOCAL_TRADER_ACCOUNT_ID_SETTING, accountId.toString());
   editor.putString(Constants.LOCAL_TRADER_ADDRESS_SETTING, address.toString());
   editor.putString(Constants.LOCAL_TRADER_NICKNAME_SETTING, nickname);
   editor.commit();
 }
 public CFSecurityCursor openSecDeviceCursorByUserIdx(
     CFSecurityAuthorization Authorization, UUID SecUserId) {
   String sql =
       getSqlSelectSecDeviceBuff()
           + "WHERE "
           + "sdev.SecUserId = '"
           + SecUserId.toString()
           + "' "
           + "ORDER BY "
           + "sdev.SecUserId ASC"
           + ", "
           + "sdev.DevName ASC";
   CFSecurityCursor cursor = new CFSecurityMySqlCursor(Authorization, schema, sql);
   return (cursor);
 }