List of usage examples for java.util UUID UUID
public UUID(long mostSigBits, long leastSigBits)
From source file:io.lavagna.service.calendarutils.CalendarVEventHandler.java
public void addCardEvent(CardFullWithCounts card, LabelAndValue lav) throws URISyntaxException { URI uri = new URI(String.format("%s%s/%s-%s", applicationUrl, card.getProjectShortName(), card.getBoardShortName(), card.getSequence())); CardDataHistory cardDesc = cardDataService.findLatestDescriptionByCardId(card.getId()); String name = getEventName(card); final UUID id = new UUID(getLong(card.getColumnId(), card.getId()), getLong(lav.getLabelId(), lav.getLabelValueId())); // Organizer//w ww. j a v a 2 s .c o m UserDescription ud = getUserDescription(card.getCreationUser(), usersCache); DateTime dueDate = new DateTime(lav.getLabelValueTimestamp()); dueDate.setUtc(true); final VEvent event = new VEvent(dueDate, name); event.getProperties().getProperty(Property.DTSTART).getParameters().add(Value.DATE_TIME); event.getProperties().add(new Created(new DateTime(card.getCreationDate()))); event.getProperties().add(new LastModified(new DateTime(card.getLastUpdateTime()))); event.getProperties().add(new Uid(id.toString())); // Reminder on label's date if (card.getColumnDefinition() != ColumnDefinition.CLOSED) { event.getAlarms().add(createReminder(name)); } // Organizer Organizer organizer = new Organizer(URI.create(ud.getEmail())); organizer.getParameters().add(new Cn(ud.getName())); event.getProperties().add(organizer); // Url event.getProperties().add(new Url(uri)); // Description if (cardDesc != null) { event.getProperties().add(new Description(cardDesc.getContent())); } events.add(event); }
From source file:info.archinnov.achilles.compound.ThriftCompoundKeyMapperTest.java
@Test public void should_build_composite_row_key() throws Exception { Long id = RandomUtils.nextLong(); ThriftPersistenceContext context = mock(ThriftPersistenceContext.class); EmbeddedKey embeddedKey = new EmbeddedKey(); UUID date = new UUID(10, 10); List<Object> components = Arrays.<Object>asList(id, "type", date); when(context.getIdMeta()).thenReturn(compoundKeyMeta); when(context.getPrimaryKey()).thenReturn(embeddedKey); when(compoundKeyMeta.isCompositePartitionKey()).thenReturn(true); when(compoundKeyMeta.encodeToComponents(embeddedKey)).thenReturn(components); when(compoundKeyMeta.extractPartitionComponents(components)).thenReturn(Arrays.<Object>asList(id, "type")); when(compoundKeyMeta.getPartitionComponentClasses()) .thenReturn(Arrays.<Class<?>>asList(Long.class, String.class)); Composite actual = (Composite) mapper.buildRowKey(context); assertThat(actual.getComponents()).hasSize(2); assertThat(actual.getComponents().get(0).getValue(LONG_SRZ)).isEqualTo(id); assertThat(actual.getComponents().get(1).getValue(STRING_SRZ)).isEqualTo("type"); }
From source file:org.brekka.phalanx.core.services.impl.AbstractCryptoService.java
/** * From private {@link UUID} constructor * @param data//from ww w . ja va2 s . c om * @return */ public static UUID toUUID(byte[] data) { long msb = 0; long lsb = 0; assert data.length == 16 : "data must be 16 bytes in length"; for (int i = 0; i < 8; i++) { msb = (msb << 8) | (data[i] & 0xff); } for (int i = 8; i < 16; i++) { lsb = (lsb << 8) | (data[i] & 0xff); } UUID result = new UUID(msb, lsb); return result; }
From source file:org.midonet.benchmarks.mpi.MPIBenchApp.java
/** * Broadcast an UUID value from the 'source' process to the rest. * Note: an UUID with all bytes to zero is considered equivalent to null * (and therefore, converted to null)./* ww w.j ava 2s.co m*/ * * @param id is the UUID to transmit, only needs to be set in the * source process. * @param source is the rank of the source process. * @return for all processes, the transmitted UUID */ protected UUID broadcastUUID(UUID id, int source) throws MPIException { long[] msg = { 0, 0 }; if (source == mpiRank) { if (id != null) { msg[0] = id.getMostSignificantBits(); msg[1] = id.getLeastSignificantBits(); } } MPI.COMM_WORLD.bcast(msg, 2, MPI.LONG, source); return (msg[0] == 0 && msg[1] == 0) ? null : new UUID(msg[0], msg[1]); }
From source file:com.sap.dirigible.runtime.scripting.AbstractScriptExecutor.java
protected void registerDefaultVariables(HttpServletRequest request, HttpServletResponse response, Object input, Map<Object, Object> executionContext, IRepository repository, Object scope) { // put the execution context registerDefaultVariable(scope, "context", executionContext); //$NON-NLS-1$ // put the system out registerDefaultVariable(scope, "out", System.out); //$NON-NLS-1$ // put the default data source DataSource dataSource = null; if (repository instanceof DBRepository) { dataSource = ((DBRepository) repository).getDataSource(); } else {//from ww w. j a va 2 s. co m dataSource = RepositoryFacade.getInstance().getDataSource(); } registerDefaultVariable(scope, "datasource", dataSource); //$NON-NLS-1$ // put request registerDefaultVariable(scope, "request", request); //$NON-NLS-1$ // put response registerDefaultVariable(scope, "response", response); //$NON-NLS-1$ // put repository registerDefaultVariable(scope, "repository", repository); //$NON-NLS-1$ // put mail sender MailSender mailSender = new MailSender(); registerDefaultVariable(scope, "mail", mailSender); //$NON-NLS-1$ // put Apache Commons IOUtils IOUtils ioUtils = new IOUtils(); registerDefaultVariable(scope, "io", ioUtils); //$NON-NLS-1$ // put Apache Commons HttpClient and related classes wrapped with a // factory like HttpUtils HttpUtils httpUtils = new HttpUtils(); registerDefaultVariable(scope, "http", httpUtils); //$NON-NLS-1$ // put Apache Commons Codecs Base64 base64Codec = new Base64(); registerDefaultVariable(scope, "base64", base64Codec); //$NON-NLS-1$ Hex hexCodec = new Hex(); registerDefaultVariable(scope, "hex", hexCodec); //$NON-NLS-1$ DigestUtils digestUtils = new DigestUtils(); registerDefaultVariable(scope, "digest", digestUtils); //$NON-NLS-1$ // standard URLEncoder and URLDecoder functionality URLUtils urlUtils = new URLUtils(); registerDefaultVariable(scope, "url", urlUtils); //$NON-NLS-1$ // user name registerDefaultVariable(scope, "user", RepositoryFacade.getUser(request)); //$NON-NLS-1$ // file upload ServletFileUpload fileUpload = new ServletFileUpload(new DiskFileItemFactory()); registerDefaultVariable(scope, "upload", fileUpload); //$NON-NLS-1$ // UUID UUID uuid = new UUID(0, 0); registerDefaultVariable(scope, "uuid", uuid); //$NON-NLS-1$ // the input from the execution chain if any registerDefaultVariable(scope, "input", input); //$NON-NLS-1$ // DbUtils DbUtils dbUtils = new DbUtils(dataSource); registerDefaultVariable(scope, "db", dbUtils); //$NON-NLS-1$ // EscapeUtils StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); registerDefaultVariable(scope, "xss", stringEscapeUtils); //$NON-NLS-1$ // Extension Manager ExtensionManager extensionManager = new ExtensionManager(repository, dataSource); registerDefaultVariable(scope, "extensionManager", extensionManager); //$NON-NLS-1$ // Apache Lucene Indexer IndexerUtils indexerUtils = new IndexerUtils(); registerDefaultVariable(scope, "indexer", indexerUtils); //$NON-NLS-1$ // Mylyn Confluence Format WikiUtils wikiUtils = new WikiUtils(); registerDefaultVariable(scope, "wiki", wikiUtils); //$NON-NLS-1$ // Simple binary storage StorageUtils storageUtils = new StorageUtils(dataSource); registerDefaultVariable(scope, "storage", storageUtils); //$NON-NLS-1$ // Simple file storage FileStorageUtils fileStorageUtils = new FileStorageUtils(dataSource); registerDefaultVariable(scope, "fileStorage", fileStorageUtils); //$NON-NLS-1$ // Simple binary storage ConfigStorageUtils configStorageUtils = new ConfigStorageUtils(dataSource); registerDefaultVariable(scope, "config", configStorageUtils); //$NON-NLS-1$ // XML to JSON and vice-versa XMLUtils xmlUtils = new XMLUtils(); registerDefaultVariable(scope, "xml", xmlUtils); //$NON-NLS-1$ }
From source file:com.joyent.manta.util.MantaUtilsTest.java
public void lastItemInPathIsCorrectFile() { final String expected = new UUID(24, 48).toString(); final String path = String.format("/foo/bar/%s", expected); final String actual = MantaUtils.lastItemInPath(path); Assert.assertEquals(actual, expected); }
From source file:io.selendroid.server.model.SelendroidStandaloneDriverTest.java
@Test public void shouldCreateNewTestSession() throws Exception { // Setting up driver with test app and device stub SelendroidStandaloneDriver driver = getSelendroidStandaloneDriver(); SelendroidConfiguration conf = new SelendroidConfiguration(); conf.addSupportedApp(new File(APK_FILE).getAbsolutePath()); driver.initApplicationsUnderTest(conf); DeviceStore store = new DeviceStore(false, EMULATOR_PORT, anDeviceManager()); DeviceForTest emulator = new DeviceForTest(DeviceTargetPlatform.ANDROID16); Random random = new Random(); final UUID definedSessionId = new UUID(random.nextLong(), random.nextLong()); emulator.testSessionListener = new TestSessionListener(definedSessionId.toString(), "test") { @Override//from www . jav a 2 s . c o m public SelendroidResponse executeSelendroidRequest(Properties params) { return null; } }; store.addDeviceToStore(emulator); driver.setDeviceStore(store); // testing new session creation SelendroidCapabilities capa = new SelendroidCapabilities(); capa.setAut(TEST_APP_ID); capa.setAndroidTarget(DeviceTargetPlatform.ANDROID16.name()); try { String sessionId = driver.createNewTestSession(new JSONObject(capa.asMap()), 0); Assert.assertNotNull(UUID.fromString(sessionId)); } finally { // this will also stop the http server emulator.stop(); } }
From source file:forestry.mail.gui.ContainerLetter.java
public void handleSetRecipient(EntityPlayer player, PacketUpdate packet) { String recipientName = packet.payload.stringPayload[0]; String typeName = packet.payload.stringPayload[1]; EnumAddressee type = EnumAddressee.fromString(typeName); IMailAddress recipient;//from w w w.j a va 2 s . c o m if (type == EnumAddressee.PLAYER) { GameProfile gameProfile = MinecraftServer.getServer().func_152358_ax().func_152655_a(recipientName); if (gameProfile == null) gameProfile = new GameProfile(new UUID(0, 0), recipientName); recipient = PostManager.postRegistry.getMailAddress(gameProfile); } else if (type == EnumAddressee.TRADER) { recipient = PostManager.postRegistry.getMailAddress(recipientName); } else { return; } getLetter().setRecipient(recipient); // Update the trading info if (recipient == null || recipient.isTrader()) updateTradeInfo(player.worldObj, recipient); // Update info on client Proxies.net.sendToPlayer(new PacketLetterInfo(PacketIds.LETTER_INFO, type, tradeInfo, recipient), player); }
From source file:org.apache.jackrabbit.oak.plugins.segment.PartialCompactionMapTest.java
private void removeRandomEntries(int count) { assert reference != null; assert map != null; Set<SegmentId> remove = newHashSet(); for (int k = 0; k < count && !reference.isEmpty(); k++) { int j = rnd.nextInt(reference.size()); remove.add(get(reference.keySet(), j).getSegmentId()); }/*from www . j ava2s. c o m*/ Set<UUID> removeUUIDs = newHashSet(); for (SegmentId sid : remove) { removeUUIDs.add(new UUID(sid.getMostSignificantBits(), sid.getLeastSignificantBits())); Iterator<RecordId> it = reference.keySet().iterator(); while (it.hasNext()) { if (sid.equals(it.next().getSegmentId())) { it.remove(); } } } map.remove(removeUUIDs); }
From source file:com.strategicgains.docussandra.controller.QueryControllerTest.java
/** * Tests that the POST /{databases}/{table}/query endpoint properly runs a * query with limits.//w w w .java 2s.c o m */ @Test public void postQueryTestWithLimit() { Query q = new Query(); q.setWhere("field1 = 'this is my data'"); q.setTable("mytable"); //act given().header("limit", "1").header("offset", "0").body("{\"where\":\"" + q.getWhere() + "\"}").expect() .statusCode(206) //.header("Location", startsWith(RestAssured.basePath + "/")) .body("", notNullValue()).body("id", notNullValue()) .body("id[0]", equalTo(new UUID(Long.MAX_VALUE - 33, 1l).toString())) .body("object[0]", notNullValue()) .body("object[0]", containsString("this is some more random data32")).when().post(""); }