Example usage for java.util UUID randomUUID

List of usage examples for java.util UUID randomUUID

Introduction

In this page you can find the example usage for java.util UUID randomUUID.

Prototype

public static UUID randomUUID() 

Source Link

Document

Static factory to retrieve a type 4 (pseudo randomly generated) UUID.

Usage

From source file:is.artefact.flume.source.kafka.KafkaSourceEmbeddedZookeeper.java

public KafkaSourceEmbeddedZookeeper(int zkPort) {
    int tickTime = 2000;

    this.zkPort = zkPort;

    String dataDirectory = System.getProperty("java.io.tmpdir");
    dir = new File(dataDirectory, "zookeeper" + UUID.randomUUID()).getAbsoluteFile();

    try {//from   w ww  .j ava  2s.com
        FileUtils.deleteDirectory(dir);
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }

    try {
        this.zookeeper = new ZooKeeperServer(dir, dir, tickTime);
        this.factory = new NIOServerCnxnFactory();
        factory.configure(new InetSocketAddress(KafkaSourceEmbeddedKafka.HOST, zkPort), 0);
        factory.startup(zookeeper);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:com.ning.billing.invoice.dao.InvoiceItemDaoTests.java

@Test
public void testInvoiceItemCreation() {
    UUID invoiceId = UUID.randomUUID();
    UUID subscriptionId = UUID.randomUUID();
    DateTime startDate = new DateTime(2011, 10, 1, 0, 0, 0, 0);
    DateTime endDate = new DateTime(2011, 11, 1, 0, 0, 0, 0);
    BigDecimal rate = new BigDecimal("20.00");

    InvoiceItem item = new DefaultInvoiceItem(invoiceId, subscriptionId, startDate, endDate, "test", rate, rate,
            Currency.USD);// w  w w . j a v a 2s .  c  om
    invoiceItemDao.create(item);

    InvoiceItem thisItem = invoiceItemDao.getById(item.getId().toString());
    assertNotNull(thisItem);
    assertEquals(thisItem.getId(), item.getId());
    assertEquals(thisItem.getInvoiceId(), item.getInvoiceId());
    assertEquals(thisItem.getSubscriptionId(), item.getSubscriptionId());
    assertEquals(thisItem.getStartDate(), item.getStartDate());
    assertEquals(thisItem.getEndDate(), item.getEndDate());
    assertEquals(thisItem.getDescription(), item.getDescription());
    assertEquals(thisItem.getAmount().compareTo(item.getAmount()), 0);
    assertEquals(thisItem.getRate().compareTo(item.getRate()), 0);
    assertEquals(thisItem.getCurrency(), item.getCurrency());
}

From source file:controllers.Send.java

public static Result create() {
    String token = UUID.randomUUID().toString();
    SessionHelper.putToken(token);/*from   w  w w  .j ava  2  s.c  o m*/
    Logger.debug("Tracking ID : " + token);

    Form<models.forms.CashInForm> transactionForm = form(models.forms.CashInForm.class)
            .bindFromRequest(request());
    Logger.debug("Send create request : " + transactionForm.data());
    if (transactionForm.data().isEmpty()) {
        CashInForm fillForm = new CashInForm();
        fillForm.senderCountry = SessionHelper.getUser().corporate.country;
        fillForm.senderCurrency = SessionHelper.getUser().corporate.currency;
        transactionForm = transactionForm.fill(fillForm);
    }

    models.Corporate corporate = SessionHelper.getUser().corporate;
    corporate.refresh();
    CorporateStatistic cs = corporate.getStatistic();
    if (cs.hasExceedCreditLimit()) {
        flash("error", "YOUR CREDIT LEFT HAS REACH ITS LIMIT, PLEASE CONTACT YOUR FINANCE FOR SETTLEMENT.");
    } else if (cs.hasExceedCreditAlertLimit()) {
        flash("warning", "YOUR CREDIT LEFT HAS REACH ALERT LIMIT, PLEASE CONTACT YOUR FINANCE FOR SETTLEMENT.");
    }

    String channelCode = "";

    transactionForm.get().trackingId = token;

    TreeMap<String, String> mapChannel = new TreeMap<String, String>();
    try {
        channelCode = corporate.configuration.channelCode;

        if (channelCode != null && !channelCode.trim().equals("")) {
            Object[] channel = channelCode.split(";");
            List<Channel> channels = null;
            channels = Channel.find.where().in("code", channel).orderBy("code").findList();
            for (Iterator<Channel> iterator = channels.iterator(); iterator.hasNext();) {
                Channel channelItem = (Channel) iterator.next();
                if (!channelItem.code.equals("10"))
                    mapChannel.put(channelItem.code, channelItem.name);
            }
        }
    } catch (Exception e) {
        channelCode = "empty";
    }

    if (channelCode == null || channelCode == "")
        channelCode = "empty";
    return ok(create.render(transactionForm, channelCode, mapChannel));
}

From source file:us.swcraft.springframework.cache.aerospike.usage.spring.SomeCacheableService.java

/**
 * Uses default cache./*  ww w. j  a va  2s.  co m*/
 * @param id
 * @return
 */
@Override
@Cacheable(cacheManager = "aerospikeCacheManager")
public String getValue(Integer id) {
    return new StringBuilder().append(id).append(":").append(UUID.randomUUID()).toString();
}

From source file:ch.bfh.srs.srv.entity.User.java

public User(String surname, String lastname, String password, String mail) {
    this.surname = surname;
    this.lastname = lastname;
    this.salt = UUID.randomUUID().toString();
    this.password = generateHash(password, this.getSalt());
    this.mail = mail;
    this.state = false;
}

From source file:br.eti.danielcamargo.backend.common.core.business.UsuarioService.java

@Transactional
public void create(Usuario usuario, String urlConfirmacao) {
    usuario.setChaveConfirmacao(UUID.randomUUID().toString());

    em.persist(usuario);//  ww w . j  a v a  2s. c  om

    StringBuilder chaveConfirmacao = new StringBuilder();
    chaveConfirmacao.append(usuario.getId());
    chaveConfirmacao.append(":");
    chaveConfirmacao.append(usuario.getChaveConfirmacao());

    Map<String, Object> params = new HashMap<>();
    params.put("titulo", "Bem Vindo!");
    params.put("chave", chaveConfirmacao);
    params.put("urlConfirmacao", urlConfirmacao);

    mailService.enviarEmail("/emails/common", "confirmacao-email.html", params, "Confirmao de Registro",
            usuario.getEmail());
}

From source file:Main.java

@Override
public void run() {
    for (int i = 0; i < 100; i++) {
        this.map.remove("key" + random.nextInt(Main.MAP_SIZE));
        this.map.put("key" + random.nextInt(Main.MAP_SIZE), UUID.randomUUID().toString());
        System.out.println(Thread.currentThread().getName() + ": " + i);
    }/*from  w w w.j a v a2  s  .co m*/
}

From source file:com.twosigma.beaker.chart.Graphics.java

public Graphics() {
    this.uid = UUID.randomUUID().toString();
}

From source file:io.pivotal.cla.security.GitHubAuthenticationEntryPoint.java

public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {

    String secretState = statePrefix() + UUID.randomUUID().toString();

    request.getSession().setAttribute("state", secretState);

    String callbackUrl = UrlBuilder.fromRequest(request).callbackUrl();
    String redirectUrl = UriComponentsBuilder.fromHttpUrl("https://github.com/login/oauth/authorize")
            .queryParam("client_id", config.getClientId()).queryParam("redirect_uri", callbackUrl)
            .queryParam("state", secretState).queryParam("scope", scope).build().toUriString();

    response.sendRedirect(redirectUrl);/*from w ww.java2  s . c  o m*/
}

From source file:org.jboss.aerogear.unifiedpush.utils.application.PushApplicationUtils.java

public static List<PushApplication> generate(int count) {
    List<PushApplication> pushApplications = new ArrayList<PushApplication>();

    for (int i = 0; i < count; i++) {
        String name = UUID.randomUUID().toString();
        String description = UUID.randomUUID().toString();
        String developer = "admin";

        PushApplication pushApplication = create(name, description, developer);

        pushApplications.add(pushApplication);
    }//w w w . j  a v  a 2s . c o m

    return pushApplications;
}