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.boxedfolder.domain.AnalyticsLogRepositoryTests.java

@Before
public void setup() {
    // Setup test data
    app = new App();
    app.setDateCreated(new DateTime());
    app.setDateUpdated(new DateTime());
    app.setName("Testapp");
    app.setApplicationKey(UUID.fromString("550e8400-e29b-11d4-a716-446655440001"));
    entityManager.persist(app);/*from  w  ww  .  j  a v a  2s  .  c  om*/

    App secondApp = new App();
    secondApp.setDateCreated(new DateTime());
    secondApp.setName("Testapp 2");
    secondApp.setApplicationKey(UUID.fromString("550e8400-e29b-11d4-a716-446655440000"));
    entityManager.persist(secondApp);

    beacon = new Beacon();
    beacon.setDateCreated(new DateTime());
    beacon.setDateUpdated(new DateTime());
    beacon.setName("Testbeacon");
    beacon.setUuid(UUID.fromString("550e8400-e29b-11d4-a716-446655440002"));
    beacon.setMajor(1);
    beacon.setMinor(2);
    entityManager.persist(beacon);

    event = new NotificationEvent();
    event.setDateCreated(new DateTime());
    event.setDateUpdated(new DateTime());
    event.setName("Testevent");
    event.setMessage("test");
    event.setTitle("testtitle");
    event.getApps().add(app);
    event.getBeacons().add(beacon);
    entityManager.persist(event);

    TextEvent secondEvent = new TextEvent();
    secondEvent.setDateCreated(new DateTime());
    secondEvent.setDateUpdated(new DateTime());
    secondEvent.setName("Testevent 2");
    secondEvent.setText("test");
    secondEvent.getApps().add(app);
    secondEvent.getBeacons().add(beacon);
    entityManager.persist(secondEvent);

    AnalyticsLog log = new AnalyticsLog();
    log.setDateCreated(new DateTime());
    log.setDateUpdated(new DateTime());
    log.setBeacon(beacon);
    log.setOccuredEvent(event);
    entityManager.persist(log);

    AnalyticsLog secondLog = new AnalyticsLog();
    secondLog.setDateCreated(new DateTime());
    secondLog.setDateUpdated(new DateTime());
    secondLog.setBeacon(beacon);
    secondLog.setOccuredEvent(secondEvent);
    entityManager.persist(secondLog);
    entityManager.flush();

    analyticsRepository = new AnalyticsLogRepositoryImpl();
    analyticsRepository.setEntityManager(entityManager);
}

From source file:com.seitenbau.jenkins.plugins.dynamicparameter.BaseParameterDefinition.java

/**
 * Constructor./*w w  w.  ja  v  a2  s .  c o  m*/
 * @param name parameter name
 * @param description parameter description
 * @param uuid UUID of the parameter definition
 * @param remote flag showing if the script should be executed remotely
 */
protected BaseParameterDefinition(String name, String description, String uuid, Boolean remote) {
    super(name, description);
    _remote = remote;

    if (StringUtils.length(uuid) == 0) {
        _uuid = UUID.randomUUID();
    } else {
        _uuid = UUID.fromString(uuid);
    }
}

From source file:com.spectralogic.ds3cli.command.RecoverGetBulk.java

@Override
public CliCommand init(final Arguments args) throws Exception {
    processCommandOptions(requiredArgs, optionalArgs, args);
    this.jobId = UUID.fromString(args.getId());
    this.bucketName = args.getBucket();
    this.numberOfThreads = args.getNumberOfThreads();

    this.directory = args.getDirectory();
    if (Guard.isStringNullOrEmpty(this.directory) || directory.equals(".")) {
        this.outputPath = FileSystems.getDefault().getPath(".");
    } else {/* w  w  w  .  ja v a  2 s.  co  m*/
        final Path dirPath = FileSystems.getDefault().getPath(directory);
        this.outputPath = FileSystems.getDefault().getPath(".").resolve(dirPath);
    }
    LOG.info("Output Path = {}", this.outputPath);

    final String[] prefix = args.getOptionValues(PREFIXES.getOpt());
    if (prefix != null && prefix.length > 0) {
        this.prefixes = ImmutableList.copyOf(prefix);
    }
    return this;
}

From source file:dbsimulator.dal.mysql.MySqlSimDal.java

@Override
public List<SessionTest> loadSessionTests() {

    List<SessionTest> sessionTests = new ArrayList<>();

    try (SQLConnection connection = getSQLConnection()) {
        UUID session = UUID.fromString(getSessionKey());
        SingleDataResultSet rs = _simdll.SIM_GetSessionTests2_SP(connection, session);
        Iterator<DbResultRecord> iterator = rs.getRecords();
        while (iterator.hasNext()) {
            DbResultRecord rec = iterator.next();
            String testkey = rec.<String>get("testkey");
            String testid = rec.<String>get("testid");
            Integer iterations = rec.<Integer>get("iterations");
            Integer opportunities = rec.<Integer>get("opportunities");
            Integer simulations = rec.<Integer>get("simulations");
            SessionTest sessionTest = new SessionTest(testid, testkey, iterations, opportunities, simulations);
            sessionTests.add(sessionTest);
        }/*  w ww. j a  v  a2s .  c  o m*/
    } catch (SQLException se) {
        _logger.error(se.getMessage());
    } catch (ReturnStatusException re) {
        _logger.error(re.getMessage());
    }

    return sessionTests;
}

From source file:com.blueserial.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ActivityHelper.initialize(this);

    Intent intent = getIntent();//from  w  w  w. ja  v a2 s  .c  o m
    Bundle b = intent.getExtras();
    mDevice = b.getParcelable(Homescreen.DEVICE_EXTRA);
    mDeviceUUID = UUID.fromString(b.getString(Homescreen.DEVICE_UUID));
    mMaxChars = b.getInt(Homescreen.BUFFER_SIZE);

    jsonParser = new JSONParser();
    url = "http://172.16.152.129/my_projects/android_database/add_sonar_data.php";

    Log.d(TAG, "Ready");

    mBtnDisconnect = (Button) findViewById(R.id.btnDisconnect);
    mBtnSend = (Button) findViewById(R.id.btnSend);
    mBtnClear = (Button) findViewById(R.id.btnClear);
    mTxtReceive = (TextView) findViewById(R.id.txtReceive);
    mEditSend = (EditText) findViewById(R.id.editSend);
    scrollView = (ScrollView) findViewById(R.id.viewScroll);
    chkScroll = (CheckBox) findViewById(R.id.chkScroll);
    chkReceiveText = (CheckBox) findViewById(R.id.chkReceiveText);
    mBtnClearInput = (Button) findViewById(R.id.btnClearInput);

    mTxtReceive.setMovementMethod(new ScrollingMovementMethod());

    mBtnDisconnect.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mIsUserInitiatedDisconnect = true;
            new DisConnectBT().execute();
        }
    });

    mBtnSend.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            try {
                mBTSocket.getOutputStream().write(mEditSend.getText().toString().getBytes());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    mBtnClear.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            mEditSend.setText("");
        }
    });

    mBtnClearInput.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            mTxtReceive.setText("");
        }
    });

}

From source file:com.formkiq.core.domain.type.FolderDTO.java

/**
 * @param id {@link String}/*from www.  j  a  v a2s.c o  m*/
 */
@Deprecated
public void setFolder(final String id) {
    this.folder = id;
    setUUID(UUID.fromString(id));
}

From source file:org.keycloak.secretstore.boundary.QRCodeServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String tokenIdAsString = req.getParameter("tokenId");
    String sizeAsString = req.getParameter("size");
    Principal principal = req.getUserPrincipal();

    int size = 250;

    if (null != sizeAsString && !sizeAsString.isEmpty()) {
        try {//from w  w  w. ja  v  a 2s.co  m
            size = Integer.parseInt(req.getParameter("size"));
        } catch (Throwable t) {
            resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Size is invalid.");
            return;
        }
    }

    if (null == tokenIdAsString || tokenIdAsString.isEmpty()) {
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Token key is missing.");
        return;
    }

    UUID tokenId;
    try {
        tokenId = UUID.fromString(tokenIdAsString);
    } catch (Throwable t) {
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Token key is invalid.");
        return;
    }

    Token token = tokenService.getByIdForDistribution(tokenId);
    if (null == token) {
        resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Token could not be found.");
        return;
    }

    if (!principal.getName().equals(token.getPrincipal())) {
        resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Token could not be found for principal.");
        return;
    }

    String response = token.getId().toString() + "," + token.getSecret();

    if (null != token.getExpiresAt()) {
        response += "," + token.getExpiresAt().toString();
    }

    BitMatrix bitMatrix;
    try {
        QRCodeWriter writer = new QRCodeWriter();
        bitMatrix = writer.encode(response, BarcodeFormat.QR_CODE, size, size);
    } catch (WriterException e) {
        resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while generating the QR Code.");
        return;
    }

    ByteArrayOutputStream pngOut = new ByteArrayOutputStream();
    MatrixToImageWriter.writeToStream(bitMatrix, "PNG", pngOut);
    byte[] pngData = pngOut.toByteArray();

    resp.setStatus(HttpServletResponse.SC_OK);
    resp.setContentType("image/png");
    resp.getOutputStream().write(pngData);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAst.CFAstSecDevicePKey.java

public CFAstSecDevicePKey() {
    requiredSecUserId = UUID.fromString(CFAstSecDeviceBuff.SECUSERID_INIT_VALUE.toString());
    requiredDevName = new String(CFAstSecDeviceBuff.DEVNAME_INIT_VALUE);
}

From source file:com.delphix.session.service.ServiceUUID.java

@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal(in);

    uuid = UUID.fromString(in.readUTF());

    if (in.readBoolean()) {
        alias = in.readUTF();//from   w ww .j a  v a 2s.  c om
    }

    ephemeral = in.readBoolean();
}

From source file:org.trustedanalytics.modelcatalog.ModelCatalogIT.java

@Test
public void modelController_getModels() throws ExecutionException {

    assertEquals(0, h2oInstanceCache.size());

    h2oInstancesOperations.getAnalyticsToolInstances(UUID.fromString("ee1c60ab-1d4f-4bbb-aeba-60ea8c67bbbb"));

    H2oInstanceCredentials h2oInstanceCredentials = new H2oInstanceCredentials();
    h2oInstanceCredentials.setGuid("test-guid");

    H2oInstanceCredentials h2oInstanceCredentialsNonexistent = new H2oInstanceCredentials();
    h2oInstanceCredentialsNonexistent.setGuid("nonexistent-guid");

    assertEquals(1, h2oInstanceCache.size());
    assertEquals(null, h2oInstanceCache.getIfPresent(h2oInstanceCredentialsNonexistent));
    assertEquals(2, h2oInstanceCache.get(h2oInstanceCredentials).getH2oModels().size());
}