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:io.pivotal.spring.xd.jdbcgpfdist.support.DefaultLoadService.java

@Override
public void load(LoadConfiguration loadConfiguration, RuntimeContext context) {
    String prefix = UUID.randomUUID().toString().replaceAll("-", "_");

    // setup jdbc operations
    JdbcCommands operations = new JdbcCommands(jdbcTemplate);

    String sqlCreateTable = SqlUtils.createExternalReadableTable(loadConfiguration, prefix,
            context != null ? context.getLocations() : null);
    String sqlDropTable = SqlUtils.dropExternalReadableTable(loadConfiguration, prefix);
    String sqlInsert = SqlUtils.load(loadConfiguration, prefix);

    operations.setPrepareSql(sqlCreateTable);
    operations.setCleanSql(sqlDropTable);
    operations.setRunSql(sqlInsert);//from   w ww.j a v a 2 s .  co m

    operations.setBeforeSqls(loadConfiguration.getSqlBefore());
    operations.setAfterSqls(loadConfiguration.getSqlAfter());

    if (!operations.execute() && operations.getLastException() != null) {
        throw operations.getLastException();
    }
}

From source file:edu.harvard.i2b2.basex.XQueryUtil.java

/**
 * Runs the example code./* w w  w  .ja  v  a 2  s .c o  m*/
 * 
 * @param args
 *            (ignored) command-line arguments
 * @throws XQueryUtilException
 * @throws BaseXException
 *             if a database command fails
 */

public static ArrayList<String> getStringSequence(String query, String input) throws XQueryUtilException {
    ArrayList<String> resList = new ArrayList<String>();
    // Database context.
    Context context = new Context();

    // Create a database from a remote XML document
    // System.out.println("\n* Create a database from a file via http.");

    // Use internal parser to skip DTD parsing
    try {
        new Set("intparse", true).execute(context);
        String dbName = UUID.randomUUID().toString();
        new org.basex.core.cmd.CreateDB(dbName, input).execute(context);

        try (QueryProcessor proc = new QueryProcessor(query, context)) {
            // Store the pointer to the result in an iterator:
            Iter iter = proc.iter();

            // Iterate through all items and serialize
            int count = 0;
            for (Item item; (item = iter.next()) != null;) {
                String r = item.serialize().toString();
                resList.add(r);
            }
        } catch (QueryException | QueryIOException e) {
            //e.printStackTrace();
            logger.error(e.getMessage(), e);
            throw new XQueryUtilException(e);
        }

        // System.out.println("\n* Drop the database.");

        new DropIndex("text").execute(context);
        new DropIndex("attribute").execute(context);
        new DropIndex("fulltext").execute(context);

        new DropDB(dbName).execute(context);
    } catch (BaseXException e1) {
        //e1.printStackTrace();
        logger.error("", e1);
        throw new XQueryUtilException(e1);
    }
    context.close();
    return resList;
}

From source file:com.bbytes.zorba.domain.testing.ZorbaBaseTesting.java

/**
 * Returns a mock object for {@link SendMailJob}
 * /* ww w. j  a  v  a2  s.co m*/
 * @return
 */
public static ZorbaRequest createZorbaRequestForSendMailJob() {
    ZorbaRequest mock = new ZorbaRequest();
    mock.setJobName("Send-Mail-Job");
    mock.setPriority(Priority.CRITICAL);
    mock.setId(UUID.randomUUID().toString());
    ZorbaData<String, Serializable> data = new ZorbaData<String, Serializable>();
    data.put("from", "dhanush@beyondbytes.co.in");
    data.put("to", "dhanush@beyondbytes.co.in");
    data.put("subject", "Unit Test Mail");
    data.put("body", "Unit Test Mail");
    mock.setData(data);
    return mock;
}

From source file:org.springdata.ehcache.config.java.JavaConfigTest.java

@Test
public void test() {

    String key = UUID.randomUUID().toString();

    byte[] value = "someValue".getBytes();

    key = new String(key);

    Assert.assertNull(service.get(key));

    key = new String(key);

    service.put(key, value);//from   ww  w  . j a  v  a 2s .c  o m

    key = new String(key);

    Assert.assertEquals(value, service.get(key));

}

From source file:com.ibm.rpe.web.template.ui.servlet.SaveTemplateLayout.java

@GET
@Path("/savelayout")
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public Response saveTemplateLayout(@Context HttpServletRequest request,
        @QueryParam("layoutjson") String savedJson, @QueryParam("title") String title) {
    try {/*from ww w  .j  a  va 2s.c  om*/
        if (title == null) {
            title = UUID.randomUUID().toString() + ".json";
        } else {
            title += ".json";
        }
        return Utils.downloadResponse(IOUtils.toInputStream(savedJson, "UTF-8"), title);
    } catch (IOException e) {
        e.printStackTrace();
        Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getLocalizedMessage()).build();
    }
    return null;
}

From source file:org.opensafety.hishare.managers.implementation.remoting.UserManagerImpl.java

public String renewUserAuthentication(String username) {
    User authenticatee = userDao.getByName(username);
    authenticatee.setAuthenticationId(UUID.randomUUID().toString());
    userDao.updateUser(authenticatee);/*from w w  w  . j  av a  2s. co  m*/
    return authenticatee.getAuthenticationId();
}

From source file:AIR.Common.DB.DataBaseTable.java

public DataBaseTable(String name, DATABASE_TYPE dbType) {
    // create unique table name. Dashes are not allowed in tbl names.
    _tableName = String.format("%s%s", name, UUID.randomUUID().toString().replace('-', 'z'));
    this._IsOnDisk = true;
    this._dbType = dbType;
}

From source file:se.nackademin.selenide.rest.test.AuthorOperations.java

public String prepareNewAuthorSpec() {
    setId((Integer) new Random().nextInt(7000));
    firstName = UUID.randomUUID().toString();
    lastName = UUID.randomUUID().toString();
    country = UUID.randomUUID().toString();
    bio = UUID.randomUUID().toString();
    String postBodyTemplate = "" + "\"author\":\n" + "   {\n" + "  \"bio\":\"%s\",\n"
            + "  \"country\":\"%s\",\n" + "  \"firstName\":\"%s\",\n" + "  \"lastName\":\"%s\",\n" + "  }\n"
            + "  }";

    String postBody = String.format(postBodyTemplate, firstName, "" + id, "" + lastName, "" + country,
            "" + bio);
    return postBody;
}

From source file:net.swigg.talo.admin.TestControllerImpl.java

@Override
public String test() {
    return UUID.randomUUID().toString();
}

From source file:org.LexGrid.LexBIG.caCore.applicationservice.resource.RemoteResourceManager.java

public Object replaceWithShell(Object result) {
    if (enableRemoteShell && !(result instanceof RemoteShell)
            && LexEVSCaCoreUtils.isLexBigClass(result.getClass())
            && !result.getClass().isAnnotationPresent(LgClientSideSafe.class)
            && !doMethodsContainClientSideSafeAnnotation(result.getClass())) {
        Class<?>[] classes = ClassUtils.getAllInterfaces(result);
        if (classes.length > 0) {
            String resourceUuid = UUID.randomUUID().toString();

            resourceMap.put(resourceUuid, result);
            RemoteShell shell = new RemoteShell(classes, result.getClass(), resourceUuid);

            result = shell;//from  ww w .j  av a 2 s. c  o  m
        }
    }
    return result;
}