Example usage for java.util UUID toString

List of usage examples for java.util UUID toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this UUID .

Usage

From source file:org.noorganization.instalist.comm.message.IngredientInfo.java

public void setUUID(UUID uuid) {
    mUUID = uuid != null ? uuid.toString() : null;
}

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

public void save(UUID uuid) throws IOException {

    String fold = uuid.toString().substring(0, 2);

    GsonIO.writeToFile(Paths.get(folder + File.separator + uuid.toString() + ".json"), getPlayer(uuid),
            GamerData.class);

}

From source file:edu.unc.lib.dl.cdr.sword.server.deposit.DSPACEMETSDepositHandler.java

@Override
public DepositReceipt doDeposit(PID destination, Deposit deposit, PackagingType type, SwordConfiguration config,
        String depositor, String owner) throws SwordError {
    if (log.isDebugEnabled()) {
        log.debug("Preparing to perform a DSPACE METS deposit to " + destination.getPid());
        log.debug("Working with temporary file: " + deposit.getFile().getAbsolutePath());
    }//www  .  j a  v a2 s  . co m

    // extract info from METS header
    MetsHeaderScanner scanner = new MetsHeaderScanner();
    try {
        scanner.scan(deposit.getFile(), deposit.getFilename());
    } catch (Exception e1) {
        throw new SwordError(ErrorURIRegistry.INGEST_EXCEPTION, 400,
                "Unable to parse your METS file: " + deposit.getFilename(), e1);
    }

    UUID depositUUID = UUID.randomUUID();
    PID depositPID = new PID("uuid:" + depositUUID.toString());
    File dir = makeNewDepositDirectory(depositPID.getUUID());

    // drop upload in data directory
    try {
        File data = new File(dir, "data");
        data.mkdir();
        FileUtils.moveFile(deposit.getFile(), new File(data, deposit.getFilename()));
    } catch (IOException e) {
        throw new SwordError(ErrorURIRegistry.INGEST_EXCEPTION, 500,
                "Unable to create your deposit bag: " + depositPID.getPid(), e);
    }

    // METS specific fields
    Map<String, String> status = new HashMap<String, String>();
    status.put(DepositField.metsProfile.name(), scanner.getProfile());
    status.put(DepositField.metsType.name(), scanner.getType());
    status.put(DepositField.createTime.name(), scanner.getCreateDate());
    status.put(DepositField.intSenderDescription.name(), StringUtils.join(scanner.getNames(), ','));

    registerDeposit(depositPID, destination, deposit, type, depositor, owner, status);
    return buildReceipt(depositPID, config);
}

From source file:fr.syncarnet.tasks.DeletedTasks.java

public String jsonify() {
    JSONObject jsonDT = new JSONObject();
    JSONArray jsonUUIDs = new JSONArray();
    JSONArray jsonTimestamps = new JSONArray();
    JSONObject jsonTTemp;/*  w  w w.j a v a  2  s.c o m*/
    try {
        for (int i = 0; i < this.size(); i++)
            jsonUUIDs.put(this.get(i).toString());
        jsonDT.put("uuids", jsonUUIDs.toString());
        Log.d(TAG, "Added uuids to json");

        for (Map.Entry<UUID, Long> entry : timestamps.entrySet()) {
            jsonTTemp = new JSONObject();
            UUID key = entry.getKey();
            jsonTTemp.put("uuid", key.toString());
            Long value = entry.getValue();
            jsonTTemp.put("timestamp", value);
            jsonTimestamps.put(jsonTTemp.toString());
        }
        jsonDT.put("timestamps", jsonTimestamps.toString());
        Log.d(TAG, "Added timestamps to json");

        return jsonDT.toString();
    } catch (JSONException e) {
        Log.e(TAG, "Exception while jsonifying");
        return "";
    }
}

From source file:com.facebook.presto.rakam.S3BackupStore.java

@Override
public void backupShard(java.util.UUID uuid, java.io.File source) {
    try {//from w  ww . j a v  a  2  s  . c o m
        s3Client.putObject(config.getS3Bucket(), uuid.toString(), source);
    } catch (Exception e) {
        throw new PrestoException(RAPTOR_BACKUP_ERROR, "Failed to create backup shard file on S3", e);
    }
}

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

@Override
public Map<UUID, String> call() throws Exception {
    Map<UUID, String> uuidStringMap = new HashMap<UUID, String>();
    for (UUID uuid : uuids) {
        HttpURLConnection connection = (HttpURLConnection) new URL(
                PROFILE_URL + uuid.toString().replace("-", "")).openConnection();
        JSONObject response = (JSONObject) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
        String name = (String) response.get("name");
        if (name == null) {
            continue;
        }//from   w  ww  .  j  a v a 2  s .  com
        String cause = (String) response.get("cause");
        String errorMessage = (String) response.get("errorMessage");
        if (cause != null && !cause.isEmpty()) {
            throw new IllegalStateException(errorMessage);
        }
        uuidStringMap.put(uuid, name);
    }
    return uuidStringMap;
}

From source file:edu.unc.lib.dl.cdr.sword.server.deposit.CDRMETSDepositHandler.java

@Override
public DepositReceipt doDeposit(PID destination, Deposit deposit, PackagingType type, SwordConfiguration config,
        String depositor, String owner) throws SwordError {
    if (log.isDebugEnabled()) {
        log.debug("Preparing to perform a CDR METS deposit to " + destination.getPid());
        log.debug("Working with temporary file: " + deposit.getFile().getAbsolutePath());
    }//ww  w .ja v a  2s  .  c  o  m

    // extract info from METS header
    MetsHeaderScanner scanner = new MetsHeaderScanner();
    try {
        scanner.scan(deposit.getFile(), deposit.getFilename());
    } catch (Exception e1) {
        throw new SwordError(ErrorURIRegistry.INGEST_EXCEPTION, 400,
                "Unable to parse your METS file: " + deposit.getFilename(), e1);
    }

    PID depositPID = scanner.getObjID();
    if (depositPID == null) {
        UUID depositUUID = UUID.randomUUID();
        depositPID = new PID("uuid:" + depositUUID.toString());
    }
    File dir = makeNewDepositDirectory(depositPID.getUUID());

    // drop upload in data directory
    try {
        File data = new File(dir, "data");
        data.mkdir();
        FileUtils.moveFile(deposit.getFile(), new File(data, deposit.getFilename()));
    } catch (IOException e) {
        throw new SwordError(ErrorURIRegistry.INGEST_EXCEPTION, 500,
                "Unable to create your deposit bag: " + depositPID.getPid(), e);
    }

    // METS specific fields
    Map<String, String> status = new HashMap<String, String>();
    status.put(DepositField.metsProfile.name(), scanner.getProfile());
    status.put(DepositField.metsType.name(), scanner.getType());
    status.put(DepositField.createTime.name(), scanner.getCreateDate());
    status.put(DepositField.intSenderDescription.name(), StringUtils.join(scanner.getNames(), ','));

    registerDeposit(depositPID, destination, deposit, type, depositor, owner, status);
    return buildReceipt(depositPID, config);
}

From source file:gr.upatras.ece.nam.baker.InstalledServiceTest.java

private InstalledBun installedServiceInit() {
    UUID uuid = UUID.randomUUID();
    String repoUrl = "repourl";
    InstalledBun is = new InstalledBun(uuid.toString(), repoUrl);
    is.setInstalledVersion("1.1v");
    return is;/*from  w  w  w  .java2s.co m*/
}

From source file:org.noorganization.instalist.comm.message.TaggedProductInfo.java

public void setProductUUID(UUID _productUUID) {
    mProductUUID = _productUUID != null ? _productUUID.toString() : null;
}

From source file:com.haulmont.cuba.restapi.CommitRequest.java

private String generateId(String entityName) {
    Metadata metadata = AppBeans.get(Metadata.NAME);
    MetaClass metaClass = metadata.getSession().getClass(entityName);

    MetaProperty primaryKeyProp = metadata.getTools().getPrimaryKeyProperty(metaClass);
    if (primaryKeyProp == null)
        throw new UnsupportedOperationException("Cannot generate ID for " + entityName);

    if (primaryKeyProp.getJavaType().equals(UUID.class)) {
        UuidSource uuidSource = AppBeans.get(UuidSource.NAME);
        UUID uuid = uuidSource.createUuid();
        return uuid.toString();
    } else if (primaryKeyProp.getJavaType().equals(Long.class)) {
        NumberIdSource numberIdSource = AppBeans.get(NumberIdSource.NAME);
        Long longId = numberIdSource.createLongId(entityName);
        return longId.toString();
    } else if (primaryKeyProp.getJavaType().equals(Integer.class)) {
        NumberIdSource numberIdSource = AppBeans.get(NumberIdSource.NAME);
        Integer intId = numberIdSource.createIntegerId(entityName);
        return intId.toString();
    } else {//from ww  w .j  a  v a 2 s  . c om
        throw new UnsupportedOperationException("Cannot generate ID for " + entityName);
    }
}