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:com.spectralogic.ds3cli.helpers.ABMTestHelper.java

/**
 * Creates a data policy acl for group to link the specified data policy and group,
 * if said rule does not already exist./*from w w w  .  j a  va  2  s .  co m*/
 */
public static PutDataPolicyAclForGroupSpectraS3Response createDataPolicyAclForGroup(final UUID dataPolicyId,
        final UUID groupId, final Ds3Client client) throws IOException {
    //Check if data policy Acl for group already exists
    final GetDataPolicyAclsSpectraS3Response response = client
            .getDataPolicyAclsSpectraS3(new GetDataPolicyAclsSpectraS3Request()
                    .withDataPolicyId(dataPolicyId.toString()).withGroupId(groupId.toString()));
    assertThat(response.getDataPolicyAclListResult().getDataPolicyAcls().size(), is(0));

    //Create the data policy Acl
    return client.putDataPolicyAclForGroupSpectraS3(
            new PutDataPolicyAclForGroupSpectraS3Request(dataPolicyId.toString(), groupId.toString()));
}

From source file:org.apache.taverna.databundle.DataBundles.java

public static Path getIntermediate(Bundle dataBundle, UUID uuid) throws IOException {
    String fileName = uuid.toString();
    Path intermediates = getIntermediates(dataBundle);
    // Folder is named after first 2 characters of UUID
    Path folder = intermediates.resolve(fileName.substring(0, 2));
    createDirectories(folder);// w  ww.j a v a 2  s  .c om
    return anyExtension(folder, fileName);
}

From source file:com.spectralogic.ds3cli.helpers.ABMTestHelper.java

/**
 * Creates a data persistence rule to link the specified data policy and storage domain,
 * if said rule does not already exist./*from www  . j  a v  a  2  s. co  m*/
 */
public static PutDataPersistenceRuleSpectraS3Response createDataPersistenceRule(final UUID dataPolicyId,
        final UUID storageDomainId, final Ds3Client client) throws IOException {
    //Check if data persistence rule already exists
    final GetDataPersistenceRulesSpectraS3Response response = client
            .getDataPersistenceRulesSpectraS3(new GetDataPersistenceRulesSpectraS3Request()
                    .withDataPolicyId(dataPolicyId.toString()).withStorageDomainId(storageDomainId.toString()));
    assertThat(response.getDataPersistenceRuleListResult().getDataPersistenceRules().size(), is(0));

    //Create the data persistence rule
    return client.putDataPersistenceRuleSpectraS3(
            new PutDataPersistenceRuleSpectraS3Request(dataPolicyId.toString(), DataIsolationLevel.STANDARD,
                    storageDomainId.toString(), DataPersistenceRuleType.PERMANENT));
}

From source file:com.spectralogic.ds3cli.helpers.ABMTestHelper.java

/**
 * Creates a storage domain member if one does not already exist between the specified
 * storage domain and pool partition. If a storage domain member already exists,an
 * error is thrown.//from www.java 2  s .co  m
 */
public static PutPoolStorageDomainMemberSpectraS3Response createPoolStorageDomainMember(
        final UUID storageDomainId, final UUID poolPartitionId, final Ds3Client client) throws IOException {
    //Check if storage domain member already exists between specified storage domain and pool partition
    try {
        final GetStorageDomainMembersSpectraS3Response getMembers = client.getStorageDomainMembersSpectraS3(
                new GetStorageDomainMembersSpectraS3Request().withPoolPartitionId(poolPartitionId.toString())
                        .withStorageDomainId(storageDomainId.toString()));
        assertThat(getMembers.getStorageDomainMemberListResult().getStorageDomainMembers().size(), is(0));
    } catch (final IOException e) {
        //Pass: expected storage domain member to not exist
    }

    //Create the storage domain
    return client.putPoolStorageDomainMemberSpectraS3(new PutPoolStorageDomainMemberSpectraS3Request(
            poolPartitionId.toString(), storageDomainId.toString()));
}

From source file:com.spectralogic.ds3client.integration.test.helpers.ABMTestHelper.java

/**
 * Deletes a data policy Acl for group with the specified ID, and verifies that said
 * acl was deleted. If the acl was not properly deleted, then an error is logged.
 *///from w ww .jav  a  2s .  co m
public static void deleteDataPolicyAclForGroup(final UUID aclId, final Ds3Client client) {
    if (aclId == null) {
        //This might not be an error if this function is called as part of cleanup code
        LOG.debug("Data policy Acl was null");
        return;
    }
    //Delete the acl
    try {
        client.deleteDataPolicyAclSpectraS3(new DeleteDataPolicyAclSpectraS3Request(aclId.toString()));
    } catch (final IOException | AssertionError e) {
        LOG.error("Data policy Acl was not deleted as expected: " + aclId.toString());
    }

    //Verify that the Acl was deleted
    try {
        client.getDataPolicyAclSpectraS3(new GetDataPolicyAclSpectraS3Request(aclId.toString()));
        LOG.error("Data policy Acl still exists despite deletion attempt: " + aclId.toString());
    } catch (final IOException e) {
        //Pass: expected data policy acl to not exist
    }
}

From source file:net.lldp.checksims.ChecksimsCommandLine.java

private static File recursiveTurninExtraction(File turninZip) throws ZipException, ChecksimsException {
    UUID ran = UUID.randomUUID(); // /tmp/uuid
    String tmpPath = System.getProperty("java.io.tmpdir");

    File unzipLocation = new File(tmpPath, ran.toString());
    if (unzipLocation.mkdir()) {
        ZipFile zip = new ZipFile(turninZip);
        if (zip.isEncrypted()) {
            throw new ChecksimsException("zipfile: " + turninZip.getPath() + " is encrypted");
        }//  w w  w  .  j a va  2s  .  c  o  m
        @SuppressWarnings("unchecked")
        List<FileHeader> fileHeaders = zip.getFileHeaders();

        File studentsDir = new File(unzipLocation, "students");
        File groupsDir = new File(unzipLocation, "groups");
        studentsDir.mkdirs();
        groupsDir.mkdirs();
        for (FileHeader header : fileHeaders) {
            if (header.getFileName().startsWith("students") || header.getFileName().startsWith("groups")) {
                zip.extractFile(header, unzipLocation.getPath());
            }
        }

        for (File submissionDir : studentsDir.listFiles()) {
            if (submissionDir.isFile()) {
                throw new ChecksimsException(
                        "invalid file in turnin directory. might this be an invalid, hand crafted zip file?");
            }

            for (File submission : submissionDir.listFiles()) {
                if (submission.getAbsolutePath().endsWith(".zip")) {
                    ZipFile submissionZip = new ZipFile(submission);
                    submissionZip.extractAll(submissionDir.getAbsolutePath());
                    submission.delete(); // remove zip file!
                }
                if (submission.getAbsolutePath().endsWith(".tar")) {
                    throw new RuntimeException(".tar submissions not accepted yet!");
                }
                // TODO: more archive handling,
                // tar.bz2, tar.gz, .tar, .7z, for starters
            }
        }
        addTempFile(unzipLocation);
        return unzipLocation;
    } else {
        throw new ChecksimsException("canno create " + unzipLocation.getPath());
    }
}

From source file:gobblin.instrumented.Instrumented.java

/**
 * Generates a new {@link gobblin.metrics.MetricContext} with the parent and tags taken from the reference context.
 * Allows replacing {@link gobblin.metrics.Tag} with new input tags.
 * This method will not copy any {@link gobblin.metrics.Metric} contained in the reference {@link gobblin.metrics.MetricContext}.
 *
 * @param context Reference {@link gobblin.metrics.MetricContext}.
 * @param newTags New {@link gobblin.metrics.Tag} to apply to context. Repeated keys will override old tags.
 * @param name Name of the new {@link gobblin.metrics.MetricContext}.
 *             If absent or empty, will modify old name by adding a random integer at the end.
 * @return Generated {@link gobblin.metrics.MetricContext}.
 *//*from   w ww. j av  a 2  s .  c o  m*/
public static MetricContext newContextFromReferenceContext(MetricContext context, List<Tag<?>> newTags,
        Optional<String> name) {

    String newName = name.orNull();

    if (Strings.isNullOrEmpty(newName)) {
        UUID uuid = UUID.randomUUID();
        String randomIdPrefix = "uuid:";

        String oldName = context.getName();
        List<String> splitName = Strings.isNullOrEmpty(oldName) ? Lists.<String>newArrayList()
                : Lists.newArrayList(Splitter.on(".").splitToList(oldName));
        if (splitName.size() > 0 && StringUtils.startsWith(Iterables.getLast(splitName), randomIdPrefix)) {
            splitName.set(splitName.size() - 1, String.format("%s%s", randomIdPrefix, uuid.toString()));
        } else {
            splitName.add(String.format("%s%s", randomIdPrefix, uuid.toString()));
        }
        newName = Joiner.on(".").join(splitName);
    }

    MetricContext.Builder builder = context.getParent().isPresent()
            ? context.getParent().get().childBuilder(newName)
            : MetricContext.builder(newName);
    return builder.addTags(context.getTags()).addTags(newTags).build();
}

From source file:com.spectralogic.ds3cli.helpers.ABMTestHelper.java

/**
 * Deletes a data policy Acl for group with the specified ID, and verifies that said
 * acl was deleted. If the acl was not properly deleted, then an error is logged.
 *///from w  ww  .  j a  v  a2s .c  o  m
public static void deleteDataPolicyAclForGroup(final UUID aclId, final Ds3Client client) {
    if (aclId == null) {
        //This might not be an error if this function is called as part of cleanup code
        LOG.debug("Data policy Acl was null");
        return;
    }
    //Delete the acl
    try {
        final DeleteDataPolicyAclSpectraS3Response deleteAcl = client
                .deleteDataPolicyAclSpectraS3(new DeleteDataPolicyAclSpectraS3Request(aclId.toString()));
    } catch (final IOException | AssertionError e) {
        LOG.error("Data policy Acl was not deleted as expected: {}", aclId.toString());
    }

    //Verify that the Acl was deleted
    try {
        client.getDataPolicyAclSpectraS3(new GetDataPolicyAclSpectraS3Request(aclId.toString()));
        LOG.error("Data policy Acl still exists despite deletion attempt: {}", aclId.toString());
    } catch (final IOException e) {
        //Pass: expected data policy acl to not exist
    }
}

From source file:net.ftb.util.OSUtils.java

public static void setClientToken(UUID u) {
    File tokenFile = new File(getCacheStorageLocation() + File.separator + "clientToken");
    try {/* w w w .  ja  va 2  s. co m*/
        FileUtils.writeStringToFile(tokenFile, u.toString());
    } catch (IOException e) {
        Logger.logError("Client token write failed", e);
    }
}

From source file:com.github.rnewson.couchdb.lucene.DatabaseIndexer.java

public static File uuidDir(final File root, final UUID uuid) {
    return new File(root, uuid.toString());
}