Ejemplo n.º 1
1
  public static UUID generateUuidForName(String name) {
    TFM_Log.info("Generating spoof UUID for " + name);
    name = name.toLowerCase();
    try {
      final MessageDigest mDigest = MessageDigest.getInstance("SHA1");
      byte[] result = mDigest.digest(name.getBytes());
      final StringBuilder sb = new StringBuilder();
      for (int i = 0; i < result.length; i++) {
        sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
      }

      return UUID.fromString(
          sb.substring(0, 8)
              + "-"
              + sb.substring(8, 12)
              + "-"
              + sb.substring(12, 16)
              + "-"
              + sb.substring(16, 20)
              + "-"
              + sb.substring(20, 32));
    } catch (NoSuchAlgorithmException ex) {
      TFM_Log.severe(ex);
    }

    return UUID.randomUUID();
  }
Ejemplo n.º 2
0
  @Test
  public void queryWithOrderingAndSearchFilter() throws IOException, NoSuchMethodException {
    ServiceLocator locator = container;
    ArticleRepository repository = locator.resolve(ArticleRepository.class);

    Random random = new Random();
    int projectID = random.nextInt();
    Article article1 =
        new Article()
            .setProjectID(projectID)
            .setSku(UUID.randomUUID().toString().substring(0, 10))
            .setTitle("Article A");
    Article article2 =
        new Article()
            .setProjectID(projectID)
            .setSku(UUID.randomUUID().toString().substring(0, 10))
            .setTitle("Article Z");
    repository.insert(Arrays.asList(article1, article2));

    ArticleGridRepository gridRepository = locator.resolve(ArticleGridRepository.class);
    Specification<ArticleGrid> spec =
        new ArticleGrid.filterSearch().setProjectID(projectID).setFilter("article");

    JinqMetaModel jmm = locator.resolve(JinqMetaModel.class);
    Method method = ArticleGrid.class.getMethod("getTitle");
    Query.Compare<ArticleGrid, ?> order = jmm.findGetter(method);

    List<ArticleGrid> list = gridRepository.query(spec).sortedDescendingBy(order).list();

    Assert.assertEquals(2, list.size());
    Assert.assertEquals(article2.getID(), list.get(0).getID());
    Assert.assertEquals(article1.getID(), list.get(1).getID());
  }
Ejemplo n.º 3
0
  /**
   * Store an end-point to host ID mapping. Each ID must be unique, and cannot be changed after the
   * fact.
   *
   * @param hostId
   * @param endpoint
   */
  public void updateHostId(UUID hostId, InetAddress endpoint) {
    assert hostId != null;
    assert endpoint != null;

    lock.writeLock().lock();
    try {
      InetAddress storedEp = endpointToHostIdMap.inverse().get(hostId);
      if (storedEp != null) {
        if (!storedEp.equals(endpoint) && (FailureDetector.instance.isAlive(storedEp))) {
          throw new RuntimeException(
              String.format(
                  "Host ID collision between active endpoint %s and %s (id=%s)",
                  storedEp, endpoint, hostId));
        }
      }

      UUID storedId = endpointToHostIdMap.get(endpoint);
      if ((storedId != null) && (!storedId.equals(hostId)))
        logger.warn("Changing {}'s host ID from {} to {}", endpoint, storedId, hostId);

      endpointToHostIdMap.forcePut(endpoint, hostId);
    } finally {
      lock.writeLock().unlock();
    }
  }
  public boolean isSameObject(
      DatabaseObject object1, DatabaseObject object2, Database accordingTo) {
    if (object1 == null && object2 == null) {
      return true;
    }
    if (object1 == null || object2 == null) {
      return false;
    }

    UUID snapshotId1 = object1.getSnapshotId();
    UUID snapshotId2 = object2.getSnapshotId();
    if (snapshotId1 != null && snapshotId2 != null) {
      if (snapshotId1.equals(snapshotId2)) {
        return true;
      }
    }

    boolean aHashMatches = false;

    List<String> hash1 = Arrays.asList(hash(object1, accordingTo));
    List<String> hash2 = Arrays.asList(hash(object2, accordingTo));
    for (String hash : hash1) {
      if (hash2.contains(hash)) {
        aHashMatches = true;
        break;
      }
    }

    if (!aHashMatches) {
      return false;
    }

    return createComparatorChain(object1.getClass(), accordingTo)
        .isSameObject(object1, object2, accordingTo);
  }
Ejemplo n.º 5
0
 public boolean hasRestoration(Player player) {
   UUID uuid = player.getUniqueId();
   if (multipleInventories()) {
     return RESTORATIONS.containsKey(uuid + "." + getWorldGroups(player));
   }
   return RESTORATIONS.containsKey(uuid.toString());
 }
  /**
   * JUnit.
   *
   * @throws Exception If failed.
   */
  public void testPrepareQueue() throws Exception {
    // Random sequence names.
    String queueName1 = UUID.randomUUID().toString();
    String queueName2 = UUID.randomUUID().toString();

    CollectionConfiguration colCfg = config(false);

    IgniteQueue queue1 = grid(0).queue(queueName1, 0, colCfg);
    IgniteQueue queue2 = grid(0).queue(queueName2, 0, colCfg);
    IgniteQueue queue3 = grid(0).queue(queueName1, 0, colCfg);

    assertNotNull(queue1);
    assertNotNull(queue2);
    assertNotNull(queue3);
    assert queue1.equals(queue3);
    assert queue3.equals(queue1);
    assert !queue3.equals(queue2);

    queue1.close();
    queue2.close();
    queue3.close();

    assertNull(grid(0).queue(queueName1, 0, null));
    assertNull(grid(0).queue(queueName2, 0, null));
  }
Ejemplo n.º 7
0
 public static JpsRemoteProto.Message.UUID toProtoUUID(UUID requestId) {
   return JpsRemoteProto.Message.UUID
       .newBuilder()
       .setMostSigBits(requestId.getMostSignificantBits())
       .setLeastSigBits(requestId.getLeastSignificantBits())
       .build();
 }
Ejemplo n.º 8
0
 @Test(priority = 3)
 public void testSearchStoreJob() throws Exception {
   // Store more jobs with the one user and search
   XJob job = getTestJob();
   long currentTime = System.currentTimeMillis();
   SchedulerJobInfo info =
       new SchedulerJobInfo(
           SchedulerJobHandle.fromString(UUID.randomUUID().toString()),
           job,
           "lens",
           SchedulerJobState.NEW,
           currentTime,
           currentTime);
   // Store the job
   schedulerDAO.storeJob(info);
   info =
       new SchedulerJobInfo(
           SchedulerJobHandle.fromString(UUID.randomUUID().toString()),
           job,
           "lens",
           SchedulerJobState.NEW,
           currentTime,
           currentTime);
   schedulerDAO.storeJob(info);
   // There should be 3 jobs till now.
   Assert.assertEquals(schedulerDAO.getJobs("lens", null, null, null).size(), 3);
   Assert.assertEquals(
       schedulerDAO.getJobs("lens", SchedulerJobState.NEW, 1L, System.currentTimeMillis()).size(),
       2);
   Assert.assertEquals(schedulerDAO.getJobs("Alice", SchedulerJobState.NEW, null, null).size(), 0);
 }
Ejemplo n.º 9
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);
  }
  @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);
  }
Ejemplo n.º 11
0
    @Override
    public void readFromNBT(NBTTagCompound tagCom) {
      TEC.idToUsername.clear();
      NBTTagList idUsernameTag = tagCom.getTagList("idUsernames", 10);
      for (int i = 0; i < idUsernameTag.tagCount(); i++) {
        NBTTagCompound tag = idUsernameTag.getCompoundTagAt(i);
        TEC.idToUsername.put(
            UUID.fromString(tagCom.getString("UUID")), tagCom.getString("playerName"));
      }

      TEC.aspectBuffer.clear();
      NBTTagList bufferTag = tagCom.getTagList("bufferTag", 10);
      for (int i = 0; i < bufferTag.tagCount(); i++) {
        NBTTagCompound idedBuffer = bufferTag.getCompoundTagAt(i);
        UUID playerID = UUID.fromString(idedBuffer.getString("playerID"));
        NBTTagList playersBuffer = idedBuffer.getTagList("buffer", 10);
        for (int j = 0; j < playersBuffer.tagCount(); j++) {
          NBTTagCompound bufferEntry = playersBuffer.getCompoundTagAt(j);

          NBTTagCompound scanTag = bufferEntry.getCompoundTag("scan");
          ScanResult scan =
              new ScanResult(
                  scanTag.getByte("type"),
                  scanTag.getInteger("id"),
                  scanTag.getInteger("meta"),
                  EntityList.createEntityFromNBT(
                      scanTag.getCompoundTag("entityTag"), DimensionManager.getWorld(0)),
                  scanTag.getString("phenomena"));

          TEC.addAspect(
              playerID, scan, bufferEntry.getDouble("chance"), bufferEntry.getDouble("percent"));
        }
      }
    }
  @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;
  }
Ejemplo n.º 13
0
 public String resend() {
   String id = getRequest().getParameter("id");
   NoteSend noteSend = noteSendManager.getById(this.id);
   String[] sendids = noteSend.getSendid().split(",");
   String[] sendnames = noteSend.getRecipient().split(",");
   // 发件人存档
   noteSend.setCid(0);
   noteSend.setCdate(new Date());
   noteSend.setSendid(sendid);
   noteSend.setNotestatus("nosee");
   noteSend.setUuid(UUID.randomUUID().toString());
   noteSendManager.save(noteSend);
   noteSend.setUrl("/pages/NoteSend/showNoteReceiveView.do?id=" + noteSend.getId());
   // 收件人存档
   for (int i = 0; i < sendids.length; i++) {
     NoteReceive noteReceive = new NoteReceive();
     noteReceive.setCid(0);
     noteReceive.setCdate(new Date());
     noteReceive.setRecipient(sendnames[i]);
     noteReceive.setSendid(sendids[i]);
     noteReceive.setNotestatus("nosee");
     noteReceive.setUuid(UUID.randomUUID().toString());
     noteReceive.setMessage(noteSend.getMessage());
     noteReceive.setMsgTxt(noteSend.getMessage());
     noteReceiveManager.save(noteReceive);
     noteReceive.setUrl(
         "/pages/NoteSend/showNoteReceiveView.do?id="
             + noteReceive.getId()
             + "&uuid="
             + noteReceive.getUuid());
     noteReceiveManager.saveOrUpdate(noteReceive);
   }
   showMessage2("发送短信成功!", "/pages/NoteSend/list.do");
   return LIST_ACTION;
 }
  /** @throws Exception If failed. */
  public void testDisabledRest() throws Exception {
    restEnabled = false;

    final Grid g = startGrid("disabled-rest");

    try {
      Thread.sleep(2 * TOP_REFRESH_FREQ);

      // As long as we have round robin load balancer this will cause every node to be queried.
      for (int i = 0; i < NODES_CNT + 1; i++)
        assertEquals(NODES_CNT + 1, client.compute().refreshTopology(false, false).size());

      final GridClientData data = client.data(PARTITIONED_CACHE_NAME);

      // Check rest-disabled node is unavailable.
      try {
        String affKey;

        do {
          affKey = UUID.randomUUID().toString();
        } while (!data.affinity(affKey).equals(g.localNode().id()));

        data.put(affKey, "asdf");

        assertEquals("asdf", cache(0, PARTITIONED_CACHE_NAME).get(affKey));
      } catch (GridServerUnreachableException e) {
        // Thrown for direct client-node connections.
        assertTrue(
            "Unexpected exception message: " + e.getMessage(),
            e.getMessage()
                .startsWith("No available endpoints to connect (is rest enabled for this node?)"));
      } catch (GridClientException e) {
        // Thrown for routed client-router-node connections.
        String msg = e.getMessage();

        assertTrue(
            "Unexpected exception message: " + msg,
            protocol() == GridClientProtocol.TCP
                ? msg.contains("No available endpoints to connect (is rest enabled for this node?)")
                : // TCP router.
                msg.startsWith(
                    "No available nodes on the router for destination node ID")); // HTTP router.
      }

      // Check rest-enabled nodes are available.
      String affKey;

      do {
        affKey = UUID.randomUUID().toString();
      } while (data.affinity(affKey).equals(g.localNode().id()));

      data.put(affKey, "fdsa");

      assertEquals("fdsa", cache(0, PARTITIONED_CACHE_NAME).get(affKey));
    } finally {
      restEnabled = true;

      G.stop(g.name(), true);
    }
  }
 protected void assignUUIDs(List<SolrInputDocument> solrDocs, List<String> ids) throws Exception {
   if ((null == solrDocs) || (solrDocs.size() == 0)) {
     return;
   }
   if ((null != ids) && (ids.size() < solrDocs.size())) {
     throw new Exception(
         "Insufficient UUIDs("
             + ids.size()
             + ") specified for documents("
             + solrDocs.size()
             + ".");
   }
   for (int i = 0; i < solrDocs.size(); i++) {
     SolrInputDocument solrInputDocument = solrDocs.get(i);
     SolrInputField idField = solrInputDocument.getField("id");
     String uuid = null;
     if (null != ids) {
       // Get the supplied UUID.
       uuid = ids.get(i);
     }
     if (null == idField) {
       if (null == uuid) {
         // Generate UUID.
         uuid = UUID.randomUUID().toString();
         uuid = ID_FIELD_PREFIX + uuid; // identifies the uuid generated by discovery module.
       }
       solrInputDocument.addField(ID, uuid);
       solrInputDocument.addField(UNIQUE_ID, uuid);
     } else {
       if (null != uuid) {
         // Use the supplied UUID.
         solrInputDocument.setField(ID, uuid);
         solrInputDocument.setField(UNIQUE_ID, uuid);
       } else {
         // Leave the existing id value and make sure uniqueId is set.
         //                    uuid = (String) idField.getValue();
         if (idField.getValue() instanceof List) {
           List<String> uuidList = (List<String>) idField.getValue();
           uuid = uuidList.get(0);
         } else if (idField.getValue() instanceof String) {
           uuid = (String) idField.getValue();
         }
         if (null == uuid) {
           // Generate UUID.
           uuid = UUID.randomUUID().toString();
           uuid = ID_FIELD_PREFIX + uuid; // identifies the uuid generated by discovery module.
           idField.setValue(uuid, 1.0f);
         }
         SolrInputField uniqueIdField = solrInputDocument.getField(UNIQUE_ID);
         if (null == uniqueIdField) {
           solrInputDocument.addField(UNIQUE_ID, uuid);
         } else {
           if (uniqueIdField.getValue() == null) {
             solrInputDocument.setField(UNIQUE_ID, uuid);
           }
         }
       }
     }
   }
 }
Ejemplo n.º 16
0
  private void checkFeed(String leader, List<String> followers) {
    JsonNode userFeed;
    // create user
    createUser(leader);
    String preFollowContent =
        leader + ": pre-something to look for " + UUID.randomUUID().toString();
    addActivity(leader, leader + " " + leader + "son", preFollowContent);
    String lastUser = followers.get(followers.size() - 1);
    int i = 0;
    for (String user : followers) {
      createUser(user);
      follow(user, leader);
    }
    userFeed = getUserFeed(lastUser);
    assertTrue(userFeed.size() == 1);

    // retrieve feed
    userFeed = getUserFeed(lastUser);
    assertTrue(userFeed.size() == 1);
    String postFollowContent = leader + ": something to look for " + UUID.randomUUID().toString();
    addActivity(leader, leader + " " + leader + "son", postFollowContent);
    // check feed
    userFeed = getUserFeed(lastUser);
    assertNotNull(userFeed);
    assertTrue(userFeed.size() > 1);
    String serialized = userFeed.toString();
    assertTrue(serialized.indexOf(postFollowContent) > 0);
    assertTrue(serialized.indexOf(preFollowContent) > 0);
  }
Ejemplo n.º 17
0
 protected void putUUID(String name, UUID val) {
   _put(BINARY, name);
   _buf.writeInt(16);
   _buf.write(B_UUID);
   _buf.writeLong(val.getMostSignificantBits());
   _buf.writeLong(val.getLeastSignificantBits());
 }
  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 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;
     }
   }
 }
Ejemplo n.º 20
0
  @Test
  public void testQueryByDataIdentifier() throws IOException, ClassNotFoundException {

    org.seadva.registry.database.model.obj.vaRegistry.Collection collection =
        new org.seadva.registry.database.model.obj.vaRegistry.Collection();
    String altId = "fakedoi:" + UUID.randomUUID().toString();
    collection.setId(UUID.randomUUID().toString());
    collection.setName("test");
    collection.setVersionNum("1");
    collection.setIsObsolete(0);
    collection.setEntityName("test");
    collection.setEntityCreatedTime(new Date());
    collection.setEntityLastUpdatedTime(new Date());
    collection.setState(client.getStateByName("PublishedObject"));

    DataIdentifier dataIdentifier = new DataIdentifier();
    DataIdentifierPK dataIdentifierPK = new DataIdentifierPK();
    dataIdentifierPK.setDataIdentifierType(client.getDataIdentifierType("doi"));
    dataIdentifier.setId(dataIdentifierPK);
    dataIdentifier.setDataIdentifierValue(altId);
    collection.addDataIdentifier(dataIdentifier);

    client.postCollection(collection);

    List<BaseEntity> entityList =
        client.queryByProperty(null, altId, QueryAttributeType.DATA_IDENTIFIER);
    assertTrue(entityList.size() > 0);
  }
  protected CFSecurityTSecGroupBuff unpackTSecGroupResultSetToBuff(ResultSet resultSet)
      throws SQLException {
    final String S_ProcName = "unpackTSecGroupResultSetToBuff";
    int idxcol = 1;
    CFSecurityTSecGroupBuff buff = schema.getFactoryTSecGroup().newBuff();
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedAt(null);
      } else {
        buff.setCreatedAt(CFSecurityMySqlSchema.convertTimestampString(colString));
      }
    }
    idxcol++;
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedByUserId(null);
      } else {
        buff.setCreatedByUserId(UUID.fromString(colString));
      }
    }
    idxcol++;
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedAt(null);
      } else {
        buff.setUpdatedAt(CFSecurityMySqlSchema.convertTimestampString(colString));
      }
    }
    idxcol++;
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedByUserId(null);
      } else {
        buff.setUpdatedByUserId(UUID.fromString(colString));
      }
    }
    idxcol++;
    buff.setRequiredTenantId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredTSecGroupId(resultSet.getInt(idxcol));
    idxcol++;
    buff.setRequiredName(resultSet.getString(idxcol));
    idxcol++;

    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
  }
 @Override
 public void writeCustomNBT(NBTTagCompound cmp) {
   super.writeCustomNBT(cmp);
   if (golemConnected != null) {
     cmp.setLong(TAG_UUID_MOST, golemConnected.getMostSignificantBits());
     cmp.setLong(TAG_UUID_LEAST, golemConnected.getLeastSignificantBits());
   }
 }
Ejemplo n.º 23
0
  @Before
  public void setup() {
    MockitoAnnotations.initMocks(this);
    AnalyticsResource resource = new AnalyticsResource();
    resource.setService(service);
    restUserMockMvc = MockMvcBuilders.standaloneSetup(resource).build();

    mapper = new ObjectMapper();
    testData = new ArrayList<AnalyticsLog>();

    app = new App();
    app.setName("Testapp");
    app.setId(5L);
    app.setDateCreated(new DateTime());
    app.setDateUpdated(new DateTime());
    app.setApplicationKey(UUID.randomUUID());

    secondApp = new App();
    secondApp.setName("Testapp 2");
    secondApp.setId(2L);
    secondApp.setDateCreated(new DateTime());
    secondApp.setDateUpdated(new DateTime());
    secondApp.setApplicationKey(UUID.randomUUID());

    event = new NotificationEvent();
    event.setName("Event 2");
    event.setId(1L);
    event.setMessage("Test");
    event.setTitle("test");
    event.setDateUpdated(new DateTime());
    event.setDateCreated(new DateTime());
    event.getApps().add(app);

    beacon = new Beacon();
    beacon.setName("Event 2");
    beacon.setId(1L);
    beacon.setDateUpdated(new DateTime());
    beacon.setDateCreated(new DateTime());

    AnalyticsLog log = new AnalyticsLog();
    log.setId(11L);
    log.setDateUpdated(new DateTime());
    log.setDateCreated(new DateTime());
    log.setOccuredEvent(event);
    log.setBeacon(beacon);
    log.setApp(app);

    AnalyticsLog secondLog = new AnalyticsLog();
    secondLog.setId(1212L);
    secondLog.setDateUpdated(new DateTime());
    secondLog.setDateCreated(new DateTime().minusDays(5));
    secondLog.setOccuredEvent(event);
    secondLog.setBeacon(beacon);
    secondLog.setApp(app);

    testData.add(log);
    testData.add(secondLog);
  }
  protected CFAccFeeDetailBuff unpackFeeDetailResultSetToBuff(ResultSet resultSet)
      throws SQLException {
    final String S_ProcName = "unpackFeeDetailResultSetToBuff";
    int idxcol = 1;
    CFAccFeeDetailBuff buff = schema.getFactoryFeeDetail().newBuff();
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedByUserId(null);
      } else {
        buff.setCreatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedAt(null);
      } else {
        buff.setCreatedAt(CFAccSybaseSchema.convertTimestampString(colString));
      }
      idxcol++;
      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedByUserId(null);
      } else {
        buff.setUpdatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedAt(null);
      } else {
        buff.setUpdatedAt(CFAccSybaseSchema.convertTimestampString(colString));
      }
      idxcol++;
    }
    buff.setRequiredTenantId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredFeeId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredFeeDetailId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredDescription(resultSet.getString(idxcol));
    idxcol++;
    buff.setRequiredAmountCharged(resultSet.getBigDecimal(idxcol));
    idxcol++;
    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
  }
  protected CFSecurityHostNodeBuff unpackHostNodeResultSetToBuff(ResultSet resultSet)
      throws SQLException {
    final String S_ProcName = "unpackHostNodeResultSetToBuff";
    int idxcol = 1;
    CFSecurityHostNodeBuff buff = schema.getFactoryHostNode().newBuff();
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedByUserId(null);
      } else {
        buff.setCreatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedAt(null);
      } else {
        buff.setCreatedAt(CFSecurityPgSqlSchema.convertTimestampString(colString));
      }
      idxcol++;
      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedByUserId(null);
      } else {
        buff.setUpdatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedAt(null);
      } else {
        buff.setUpdatedAt(CFSecurityPgSqlSchema.convertTimestampString(colString));
      }
      idxcol++;
    }
    buff.setRequiredClusterId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredHostNodeId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredDescription(resultSet.getString(idxcol));
    idxcol++;
    buff.setRequiredHostName(resultSet.getString(idxcol));
    idxcol++;

    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
  }
  protected CFInternetURLProtocolBuff unpackURLProtocolResultSetToBuff(ResultSet resultSet)
      throws SQLException {
    final String S_ProcName = "unpackURLProtocolResultSetToBuff";
    int idxcol = 1;
    CFInternetURLProtocolBuff buff = schema.getFactoryURLProtocol().newBuff();
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedByUserId(null);
      } else {
        buff.setCreatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedAt(null);
      } else {
        buff.setCreatedAt(CFDbTestPgSqlSchema.convertTimestampString(colString));
      }
      idxcol++;
      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedByUserId(null);
      } else {
        buff.setUpdatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedAt(null);
      } else {
        buff.setUpdatedAt(CFDbTestPgSqlSchema.convertTimestampString(colString));
      }
      idxcol++;
    }
    buff.setRequiredURLProtocolId(resultSet.getInt(idxcol));
    idxcol++;
    buff.setRequiredName(resultSet.getString(idxcol));
    idxcol++;
    buff.setRequiredDescription(resultSet.getString(idxcol));
    idxcol++;
    buff.setRequiredIsSecure(resultSet.getBoolean(idxcol));
    idxcol++;

    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
  }
Ejemplo n.º 27
0
 /**
  * Returns a sorted map with annotations to be sent with each message. Default behavior is to
  * include the current correlation id (if it is set).
  */
 public SortedMap<String, byte[]> annotations() {
   SortedMap<String, byte[]> ann = new TreeMap<String, byte[]>();
   if (correlation_id != null) {
     long hi = correlation_id.getMostSignificantBits();
     long lo = correlation_id.getLeastSignificantBits();
     ann.put("CORR", ByteBuffer.allocate(16).putLong(hi).putLong(lo).array());
   }
   return ann;
 }
Ejemplo n.º 28
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);
 }
Ejemplo n.º 29
0
  /**
   * Creates a ModuleSpecID in a given class, with a given class unique id. A UUID of a class and
   * another UUID are provided.
   *
   * @param classUUID the class to which this will belong.
   * @param specUUID the unique id of this spec in that class.
   */
  protected ModuleSpecID(UUID classUUID, UUID specUUID) {

    this();
    id.longIntoBytes(ModuleSpecID.moduleClassIdOffset, classUUID.getMostSignificantBits());
    id.longIntoBytes(ModuleSpecID.moduleClassIdOffset + 8, classUUID.getLeastSignificantBits());

    id.longIntoBytes(ModuleSpecID.moduleSpecIdOffset, specUUID.getMostSignificantBits());
    id.longIntoBytes(ModuleSpecID.moduleSpecIdOffset + 8, specUUID.getLeastSignificantBits());
  }
  protected CFSecuritySecFormBuff unpackSecFormResultSetToBuff(ResultSet resultSet)
      throws SQLException {
    final String S_ProcName = "unpackSecFormResultSetToBuff";
    int idxcol = 1;
    CFSecuritySecFormBuff buff = schema.getFactorySecForm().newBuff();
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedByUserId(null);
      } else {
        buff.setCreatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedAt(null);
      } else {
        buff.setCreatedAt(CFCrmDb2LUWSchema.convertTimestampString(colString));
      }
      idxcol++;
      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedByUserId(null);
      } else {
        buff.setUpdatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedAt(null);
      } else {
        buff.setUpdatedAt(CFCrmDb2LUWSchema.convertTimestampString(colString));
      }
      idxcol++;
    }
    buff.setRequiredClusterId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredSecFormId(resultSet.getInt(idxcol));
    idxcol++;
    buff.setRequiredSecAppId(resultSet.getInt(idxcol));
    idxcol++;
    buff.setRequiredJEEServletMapName(resultSet.getString(idxcol));
    idxcol++;

    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
  }