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:org.sventon.export.DefaultExportExecutorTest.java

@Test
public void testExportTask() throws Exception {
    final List<PathRevision> entries = new ArrayList<PathRevision>();

    final ConfigDirectory configDirectoryMock = createMock(ConfigDirectory.class);
    final ExportDirectory exportDirectoryMock = createMock(ExportDirectory.class);
    final RepositoryService repositoryServiceMock = createMock(RepositoryService.class);
    final SVNConnection connection = createMock(SVNConnection.class);
    final File exportDir = new File(TestUtils.TEMP_DIR);

    expect(configDirectoryMock.getExportDirectory()).andStubReturn(exportDir);
    expect(configDirectoryMock.getExportDirectory()).andStubReturn(exportDir);
    expect(exportDirectoryMock.getDirectory()).andReturn(new File("."));
    expect(exportDirectoryMock.getUUID()).andStubReturn(UUID.fromString(UUID_STRING));
    expect(exportDirectoryMock.mkdirs()).andStubReturn(true);
    repositoryServiceMock.export(connection, entries, 123, exportDir);
    exportDirectoryMock.delete();//from ww  w.j  a v a 2 s .co  m
    expect(exportDirectoryMock.compress()).andStubReturn(exportDir);

    replay(configDirectoryMock);
    replay(exportDirectoryMock);
    replay(connection);

    final DefaultExportExecutor exportExecutor = new DefaultExportExecutor(configDirectoryMock);

    exportExecutor.setRepositoryService(repositoryServiceMock);

    final DefaultExportExecutor.ExportTask exportTask = exportExecutor.new ExportTask(exportDirectoryMock,
            connection, entries, 123);

    exportTask.call();

    verify(configDirectoryMock);
    verify(exportDirectoryMock);
    verify(connection);
}

From source file:managers.nodes.SlotManager.java

@Override
protected Promise<Boolean> disconnect(JsonNode slot, JsonNode partOrRule, String location) {
    if (partOrRule.has("name")) {
        Rule rule = new Rule(partOrRule.get("name").asText());
        return disconnect(slot, rule, location);
    }/*from  w  w w  .  jav a2 s .  c  o m*/
    String uuid = partOrRule.get("uuid").asText();
    Part part = new Part(UUID.fromString(uuid));
    return disconnect(slot, part, location);
}

From source file:nl.esciencecenter.octopus.webservice.job.JobsPollerTest.java

@Test
public void run_RunningState_StateUnchangedIterationIncreased()
        throws URISyntaxException, UnsupportedEncodingException, ClientProtocolException, IOException {
    Map<String, SandboxedJob> jobs = new HashMap<String, SandboxedJob>();
    String identifier = "11111111-1111-1111-1111-111111111111";
    UUID uuid = UUID.fromString(identifier);
    Job job = new JobImplementation(mock(JobDescription.class), mock(Scheduler.class), uuid, identifier, false,
            false);/* ww w  . j av  a 2  s. c om*/
    JobStatus jobstatus = new JobStatusImplementation(job, "RUNNING", 0, null, true, false, null);
    SandboxedJob sjob = new SandboxedJob(null, job, null, null, jobstatus, 5);
    jobs.put(identifier, sjob);
    PollConfiguration pollConf = new PollConfiguration();
    Octopus octopus = mock(Octopus.class);
    Jobs jobsEngine = mock(Jobs.class);
    when(octopus.jobs()).thenReturn(jobsEngine);
    JobStatus[] statuses = { jobstatus };
    // use `doReturn` instead of `when` as argument matching fails
    doReturn(statuses).when(jobsEngine).getJobStatuses((Job[]) any());
    JobsPoller poller = new JobsPoller(jobs, pollConf, octopus);

    poller.run();

    assertThat(sjob.getStatus()).isEqualTo(jobstatus);
    assertThat(sjob.getPollIterations()).isEqualTo(6);
}

From source file:com.chiralbehaviors.CoRE.access.resource.CollectionResource.java

@GET
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)/*from  ww w  . j a  v  a  2s.c o  m*/
public List<Product> get(@PathParam("id") String id, @QueryParam("relId") List<String> relIds)
        throws JsonProcessingException {

    Product p = new Product();
    p.setId(UUID.fromString(id));
    List<Ruleform> nodes = new LinkedList<>();
    nodes.add(p);
    List<Relationship> rels = new LinkedList<>();
    for (String rid : relIds) {
        Relationship r = readOnlyModel.getEntityManager().find(Relationship.class, rid);
        rels.add(r);
    }
    return readOnlyModel.getProductModel().getChildren(p, rels.get(0));

}

From source file:occi.infrastructure.Network.java

/**
 * Minimal constructor./*from w w  w. j a  v  a 2  s.co  m*/
 * 
 * @param links
 * @param attributes
 * @throws URISyntaxException
 * @throws SchemaViolationException
 */
public Network(State state, Set<Link> links, Set<String> attributes)
        throws URISyntaxException, SchemaViolationException {
    super(links, attributes);
    this.state = state;

    setKind(new Kind(actionSet, null, null, null, "network", "network",
            OcciConfig.getInstance().config.getString("occi.scheme") + "/infrastructure#", attributes));

    networkList.put(UUID.fromString(getId().toString()), this);
    generateActionNames();
    generateActionNames();
    generateAttributeList();
}

From source file:org.springframework.cloud.aws.messaging.support.converter.NotificationRequestConverter.java

private static Map<String, Object> getMessageAttributesAsMessageHeaders(JsonNode message) {
    Map<String, Object> messageHeaders = new HashMap<>();
    Iterator<String> fieldNames = message.fieldNames();
    while (fieldNames.hasNext()) {
        String attributeName = fieldNames.next();
        String attributeValue = message.get(attributeName).get("Value").asText();
        String attributeType = message.get(attributeName).get("Type").asText();
        if (MessageHeaders.CONTENT_TYPE.equals(attributeName)) {
            messageHeaders.put(MessageHeaders.CONTENT_TYPE, MimeType.valueOf(attributeValue));
        } else if (MessageHeaders.ID.equals(attributeName)) {
            messageHeaders.put(MessageHeaders.ID, UUID.fromString(attributeValue));
        } else {/*from  w  w  w .  j  a  va 2s.  co  m*/
            if (MessageAttributeDataTypes.STRING.equals(attributeType)) {
                messageHeaders.put(attributeName, attributeValue);
            } else if (attributeType.startsWith(MessageAttributeDataTypes.NUMBER)) {
                Object numberValue = getNumberValue(attributeType, attributeValue);
                if (numberValue != null) {
                    messageHeaders.put(attributeName, numberValue);
                }
            } else if (MessageAttributeDataTypes.BINARY.equals(attributeName)) {
                messageHeaders.put(attributeName, ByteBuffer.wrap(attributeType.getBytes()));
            }
        }
    }

    return messageHeaders;
}

From source file:com.turt2live.hurtle.uuid.UUIDServiceProvider.java

/**
 * Gets the UUID of a player name./*from  w w w .j av a  2 s  .c  o m*/
 *
 * @param name the name, cannot be null
 *
 * @return the UUID for the player, or null if not found or for invalid input
 */
public static UUID getUUID(String name) {
    if (name == null)
        return null;
    try {
        URL url = new URL("http://uuid.turt2live.com/uuid/" + name);
        BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
        String parsed = "";
        String line;
        while ((line = reader.readLine()) != null)
            parsed += line;
        reader.close();

        Object o = JSONValue.parse(parsed);
        if (o instanceof JSONObject) {
            JSONObject jsonObject = (JSONObject) o;
            o = jsonObject.get("uuid");
            if (o instanceof String) {
                String s = (String) o;
                if (!s.equalsIgnoreCase("unknown")) {
                    return UUID.fromString(insertDashes(s));
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:de.Keyle.MyPet.util.player.UUIDFetcher.java

private static UUID getUUID(String id) {
    if (id.contains("-")) {
        return UUID.fromString(id);
    }//from  w  w w .  j  ava  2s.  co  m
    return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-"
            + id.substring(16, 20) + "-" + id.substring(20, 32));
}

From source file:com.oneops.inductor.AbstractOrderExecutor.java

/**
 * boolean check for uuid//  w  w w  .  ja  v  a  2 s.c o  m
 *
 * @param uuid string
 */
public static boolean isUUID(String uuid) {
    if (uuid == null)
        return false;
    try {
        // we have to convert to object and back to string because the built
        // in fromString does not have
        // good validation logic.
        UUID fromStringUUID = UUID.fromString(uuid);
        String toStringUUID = fromStringUUID.toString();
        return toStringUUID.equalsIgnoreCase(uuid);
    } catch (IllegalArgumentException e) {
        return false;
    }
}

From source file:gemlite.core.internal.domain.utilClass.DBDataSource.java

@Override
public UUID getUUID(String name) {
    String str = "";
    try {// w w  w.  j a v  a2 s  .  co m
        str = StringUtils.trim(rs.getString(name));
    } catch (SQLException e) {
        LogUtil.getCoreLog().error(name, e);
    }
    return UUID.fromString(str);
}