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:com.mingo.domain.util.DomainTestBuilder.java

public static Comment createComment(int prefix) {
    Comment comment = new Comment();
    comment.setModerationStatus(ModerationStatus.values()[random(0, ModerationStatus.values().length - 1)]);
    comment.setId(UUID.randomUUID().toString());
    comment.setAuthor(createAuthor(prefix));
    comment.setCreated(createDateAndAddYear(prefix));
    comment.setCommentBody(MessageFormatter.format(COMMENT_BODY, prefix).getMessage());
    return comment;
}

From source file:org.openmrs.module.pihmalawi.reporting.UuidGeneratorTest.java

@Test
public void generateUuid() {
    System.out.println(UUID.randomUUID().toString());
    System.out.println(UUID.randomUUID().toString());
}

From source file:de.zib.gndms.gndmc.utils.DownloadResponseExtractor.java

@Override
public void extractData(final String url, final ClientHttpResponse response) throws IOException {
    String downloadID = UUID.randomUUID().toString();

    logger.debug("Downloading " + url + " to file " + getOutputFile());

    super.extractData(url, response);

    InputStream in = getBody();//from ww w . j  av a 2 s . c o  m
    OutputStream out = new FileOutputStream(outputFile);
    StreamCopyNIO.copyStream(in, out);

    logger.debug("Done.");
}

From source file:io.pivotal.cla.config.GenerateAccessTokenConfig.java

@Override
public void afterSingletonsInstantiated() {
    AccessToken accessToken = accessTokens.findOne(AccessToken.CLA_ACCESS_TOKEN_ID);
    if (accessToken != null) {
        return;/*from ww  w  .j av a 2  s  .c  o m*/
    }
    String token = UUID.randomUUID().toString();
    accessToken = new AccessToken(AccessToken.CLA_ACCESS_TOKEN_ID, token);
    accessTokens.save(accessToken);
}

From source file:net.radai.garbanzo.GarbanzoTest.java

@Test
public void testRoundTrip() throws Exception {
    long seed = System.currentTimeMillis();
    Random random = new Random(seed);
    BeanClass original = new BeanClass();
    original.f1 = "";
    original.f2 = RandomStringUtils.randomAscii(10);
    original.f3 = random.nextDouble();//from   w ww. j  a v  a  2 s . c o  m
    original.f4 = null;
    original.f5 = UUID.randomUUID();
    original.f6 = new byte[1 + random.nextInt(10)];
    random.nextBytes(original.f6);
    original.f7 = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        original.f7.add((long) random.nextInt(10));
    }
    original.f8 = new HashMap<>();
    original.f8.put(Enum1.V1, (short) 7);
    original.f8.put(Enum1.V2, null);
    original.f9 = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        InnerBeanClass inner = new InnerBeanClass();
        inner.f1 = "bob " + i;
        original.f9.add(inner);
    }
    original.f9.add(null);

    String serialized = Garbanzo.marshal(original);

    BeanClass deserialized = Garbanzo.unmarshall(BeanClass.class, serialized);

    Assert.assertEquals(original, deserialized);
}

From source file:com.stratio.decision.configuration.StreamingSiddhiConfiguration.java

@Bean(destroyMethod = "shutdown")
public SiddhiManager siddhiManager() {
    SiddhiConfiguration conf = new SiddhiConfiguration();
    conf.setInstanceIdentifier("StratioStreamingCEP-Instance-" + UUID.randomUUID().toString());
    conf.setQueryPlanIdentifier(QUERY_PLAN_IDENTIFIER);
    conf.setDistributedProcessing(false);

    @SuppressWarnings("rawtypes")
    List<Class> extensions = new ArrayList<>();
    extensions.add(DistinctWindowExtension.class);
    conf.setSiddhiExtensions(extensions);

    // Create Siddhi Manager
    SiddhiManager siddhiManager = new SiddhiManager(conf);

    return siddhiManager;
}

From source file:org.khmeracademy.btb.auc.pojo.service.impl.User_servicesimpl.java

@Override
public boolean save_user(User user) {
    String verifyKey = "" + UUID.randomUUID();
    user.setVerifyKey(verifyKey);//w  ww .  ja  va  2  s  . co m
    try {
        verifycode.sendComfirmation(user);
    } catch (MailException ex) {
        Logger.getLogger(User_servicesimpl.class.getName()).log(Level.SEVERE, null, ex);
    } catch (MessagingException ex) {
        Logger.getLogger(User_servicesimpl.class.getName()).log(Level.SEVERE, null, ex);
    }
    return usr_repo.add_user(user);
}

From source file:co.mafiagame.test.persistence.api.TestPersistenceApi.java

@Override
public Account saveAccount(String userName, String firstName, String lastName, InterfaceType interfaceType,
        String userId) {//w  w  w  .  j  a  v a  2s .  c  o  m
    Account account = new Account();
    account.setId(UUID.randomUUID());
    account.setUsername(userName);
    account.setFirstName(firstName);
    account.setLastName(lastName);
    account.setType(interfaceType);
    account.setUserInterfaceId(userId);
    return account;
}

From source file:org.opensafety.hishare.model.factories.ParcelFactory.java

private String createPayloadLocation() {
    return UUID.randomUUID().toString();
}

From source file:com.viseur.control.UploadImageServlet.java

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request//from   w w  w  . j a  va 2s  . c om
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    Part imgPart = request.getPart("imageupload");
    String extension = request.getParameter("extension");
    int maxMB = Integer.valueOf(request.getParameter("maxsize"));

    //   String contextPath = request.getServletContext().getRealPath(""); //Files will be stored inside BUILD folder
    String imgName = UUID.randomUUID().toString();
    String filePath = "/temp/" + imgName + extension;
    String destination = VHost.UPLOAD + filePath;
    FileUpload imgUpload = new FileUpload(extension, maxMB, destination);
    boolean success = imgUpload.NewFileUpload(imgPart);

    JSONObject json = new JSONObject();
    json.put("success", success);
    if (success) {
        json.put("img", imgName);
        json.put("imgUrl", filePath);
    } else {
        json.put("error", imgUpload.error.mMessage);
    }

    try (PrintWriter out = response.getWriter()) {
        out.print(json);
        out.flush();
    }

}