Example usage for java.util UUID fromString

List of usage examples for java.util UUID fromString

Introduction

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

Prototype

public static UUID fromString(String name) 

Source Link

Document

Creates a UUID from the string standard representation as described in the #toString method.

Usage

From source file:com.haulmont.cuba.core.controllers.LogDownloadController.java

protected UserSession getSession(String sessionId, HttpServletResponse response) throws IOException {
    UUID sessionUUID;//from   ww  w . j a va 2  s.c  o m
    try {
        sessionUUID = UUID.fromString(sessionId);
    } catch (Exception e) {
        log.error("Error parsing sessionId from URL param", e);
        response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        return null;
    }

    UserSession session = userSessions.getAndRefresh(sessionUUID);
    if (session == null)
        response.sendError(HttpServletResponse.SC_FORBIDDEN);

    return session;
}

From source file:com.haulmont.cuba.core.QueryResultTest.java

@Test
public void test() {
    Transaction tx;/*from w ww  .  j  a va2  s. co  m*/
    javax.persistence.EntityManager emDelegate;
    EntityManager em;
    Query query;

    UUID sessionId = UUID.randomUUID();
    int queryKey = 1;

    tx = cont.persistence().createTransaction();
    try {
        emDelegate = cont.persistence().getEntityManager().getDelegate();

        QueryResult queryResult = new QueryResult();
        queryResult.setSessionId(sessionId);
        queryResult.setQueryKey(queryKey);
        queryResult.setEntityId(UUID.fromString("60885987-1b61-4247-94c7-dff348347f93"));

        emDelegate.persist(queryResult);

        tx.commitRetaining();

        em = cont.persistence().getEntityManager();
        query = em.createQuery("select u from sec$User u, sys$QueryResult qr "
                + "where qr.entityId = u.id and qr.sessionId = ?1 and qr.queryKey = ?2");
        query.setParameter(1, sessionId);
        query.setParameter(2, queryKey);
        query.setView(new View(User.class).addProperty("login").addProperty("name").addProperty("group",
                new View(Group.class).addProperty("name")));

        //            OpenJPAQuery openJPAQuery = (OpenJPAQuery) query.getDelegate();
        //            Map params = new HashMap();
        //            params.put(1, sessionId);
        //            params.put(2, queryKey);
        //            String[] dataStoreActions = openJPAQuery.getDataStoreActions(params);
        //
        //            System.out.println(dataStoreActions);

        List<User> list = query.getResultList();
        assertEquals(1, list.size());
        User user = list.get(0);
        assertEquals("admin", user.getLogin());

        tx.commit();
    } finally {
        tx.end();
    }
}

From source file:eu.dasish.annotation.backend.Helpers.java

public static UUID generateUUID() {
    UUID result = UUID.randomUUID();
    char[] chars = result.toString().toCharArray();
    if (chars[0] >= 'a' && chars[0] <= 'z') {
        return result;
    } else {//w ww .j a va  2  s . co  m
        Random r = new Random();
        chars[0] = hexa.charAt(r.nextInt(hexan));
        result = UUID.fromString(new String(chars));
        return result;
    }
}

From source file:org.trustedanalytics.user.orgs.OrgsController.java

@ApiOperation(value = "Renames organization name", notes = "Privilege level: Consumer of this endpoint must be a member of specified organization  "
        + "with OrgManager role, based on valid access token")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"),
        @ApiResponse(code = 400, message = "The organization name is already taken"),
        @ApiResponse(code = 500, message = "Internal server error, e.g. error connecting to CloudController") })
@RequestMapping(value = GENERAL_ORGS_URL + "/{org}/name", method = PUT, consumes = APPLICATION_JSON_VALUE)
public void renameOrg(@RequestBody OrgNameRequest request, @PathVariable String org) {
    ccClient.renameOrg(UUID.fromString(org), request.getName());
}

From source file:com.haulmont.cuba.core.DataManagerTest.java

@Test
public void testAssociatedResult() throws Exception {
    LoadContext<Group> loadContext = LoadContext.create(Group.class);
    loadContext.setQueryString("select u.group from sec$User u where u.id = :userId").setParameter("userId",
            UUID.fromString("60885987-1b61-4247-94c7-dff348347f93"));

    List<Group> groups = dataManager.loadList(loadContext);
    assertEquals(1, groups.size());/*from  ww  w .j av  a  2 s  .co  m*/
}

From source file:com.strategicgains.docussandra.ParseUtils.java

/**
 * Parses a String as a UUID.//w ww .j av  a 2  s .c o m
 *
 * @param in String to parse as an UUID.
 * @return A UUID that is based on the passed in String.
 * @throws IndexParseFieldException if the String cannot be parsed as an
 * UUID.
 */
public static UUID parseStringAsUUID(String in) throws IndexParseFieldException {
    try {
        return UUID.fromString(in);
    } catch (IllegalArgumentException e) {
        throw new IndexParseFieldException(in, e);
    }
}

From source file:com.relicum.ipsum.Configuration.PlayerHandler.java

public void addGamerData(GamerData data) {
    Validate.notNull(data);

    players.putIfAbsent(UUID.fromString(data.getUniqueId()), data);

}

From source file:org.energyos.espi.common.service.impl.UsagePointServiceImpl.java

@Override
public UsagePoint findByHashedId(String usagePointHashedId) {
    return findByUUID(UUID.fromString(usagePointHashedId));
}

From source file:com.haulmont.restapi.service.filter.RestFilterParserTest.java

@Test
public void testEntityCondition() throws Exception {
    new StrictExpectations() {
        {//  w  w w.  j  av  a2s . c o m
            RandomStringUtils.randomAlphabetic(anyInt);
            result = "paramName1";
        }
    };

    String data = readDataFromFile("data/restFilter2.json");
    MetaClass metaClass = metadata.getClass("test$TestEntity");
    RestFilterParseResult parseResult = restFilterParser.parse(data, metaClass);

    String expectedJpqlWhere = "({E}.linkedTestEntity.id = :paramName1)";
    assertEquals(expectedJpqlWhere, parseResult.getJpqlWhere());

    Map<String, Object> queryParameters = parseResult.getQueryParameters();
    assertEquals(UUID.fromString("2de6a78f-7bef-89a7-eb5e-b725582f23af"), queryParameters.get("paramName1"));
}

From source file:edu.purdue.cybercenter.dm.service.VocabularyService.java

private boolean isDefinitionChanged(Vocabulary vocabulary) {
    edu.purdue.cybercenter.dm.domain.Vocabulary dbVocabulary = findLatestByUuid(
            UUID.fromString(vocabulary.getUuid()));
    if (dbVocabulary != null) {
        // an existing vocabulary
        Vocabulary latestVocabulary = dbVocabularyToVocabulary(dbVocabulary);
        return !VocabularyUtils.isSame(latestVocabulary, vocabulary);
    } else {// w  ww  . jav a2s  .com
        // a new vocabulary
        return true;
    }
}