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.evolveum.midpoint.model.common.expression.evaluator.GenerateExpressionEvaluator.java

@Override
public PrismValueDeltaSetTriple<V> evaluate(ExpressionEvaluationContext params)
        throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {

    StringPolicyType stringPolicyType = null;

    //        if (elementStringPolicy == null) {
    // if the policy was changed, the most fresh copy is needed, therefore
    // it must be resolved all time the value is generated..if it was not
    // resolved each time, the cached policy would be used and so bad values
    // would be generated

    StringPolicyResolver stringPolicyResolver = params.getStringPolicyResolver();
    if (stringPolicyResolver != null) {
        stringPolicyType = stringPolicyResolver.resolve();
    }/*from ww w  .  ja  v  a  2 s.c o  m*/
    //        } else {
    //           stringPolicyType = elementStringPolicy;
    //        }
    //        
    String stringValue = null;
    GenerateExpressionEvaluatorModeType mode = generateEvaluatorType.getMode();
    if (mode == null || mode == GenerateExpressionEvaluatorModeType.POLICY) {

        // TODO: generate value based on stringPolicyType (if not null)
        if (stringPolicyType != null) {
            if (isNotEmptyMinLength(stringPolicyType)) {
                stringValue = ValuePolicyGenerator.generate(stringPolicyType, DEFAULT_LENGTH, true,
                        params.getResult());
            } else {
                stringValue = ValuePolicyGenerator.generate(stringPolicyType, DEFAULT_LENGTH, false,
                        params.getResult());
            }
            params.getResult().computeStatus();
            if (params.getResult().isError()) {
                throw new ExpressionEvaluationException("Failed to generate value according to policy: "
                        + stringPolicyType.getDescription() + ". " + params.getResult().getMessage());
            }
        }

        if (stringValue == null) {
            int length = DEFAULT_LENGTH;
            RandomString randomString = new RandomString(length);
            stringValue = randomString.nextString();
        }

    } else if (mode == GenerateExpressionEvaluatorModeType.UUID) {
        UUID randomUUID = UUID.randomUUID();
        stringValue = randomUUID.toString();

    } else {
        throw new ExpressionEvaluationException("Unknown mode for generate expression: " + mode);
    }

    Object value = ExpressionUtil.convertToOutputValue(stringValue, outputDefinition, protector);

    Item<V, D> output = outputDefinition.instantiate();
    if (output instanceof PrismProperty) {
        PrismPropertyValue<Object> pValue = new PrismPropertyValue<Object>(value);
        ((PrismProperty<Object>) output).add(pValue);
    } else {
        throw new UnsupportedOperationException(
                "Can only generate values of property, not " + output.getClass());
    }

    return ItemDelta.toDeltaSetTriple(output, null);
}

From source file:de.linzn.cubit.internal.blockEdit.normal.snapshot.WorldEditFunctions.java

public boolean isSnapshotDirectory(UUID uuid, String snapshotName) {
    String fullPath = this.snapshotsDirectory + "/" + uuid.toString() + "/" + snapshotName;
    File path = new File(fullPath);
    return path.exists();
}

From source file:net.daboross.bukkitdev.skywars.score.JSONScoreStorage.java

@Override
public void setScore(final UUID uuid, final int score) {
    JSONObject playerObj = uuidToStoredPlayer.optJSONObject(uuid.toString());
    if (playerObj == null) {
        playerObj = new JSONObject();
    }/*from ww  w .  j  a  v  a  2  s. c  o  m*/
    playerObj.put("score", score);
}

From source file:de.linzn.cubit.internal.blockEdit.normal.snapshot.WorldEditFunctions.java

public File getSnapshotDirectoryLocation(UUID uuid, String snapshotName) {
    String fullPath = this.snapshotsDirectory + "/" + uuid.toString() + "/" + snapshotName;
    File path = new File(fullPath);
    if (!path.exists())
        path.mkdirs();/*from  www. j  a va  2  s. co m*/
    return path;
}

From source file:net.daboross.bukkitdev.skywars.score.JSONScoreStorage.java

@Override
public void addScore(final UUID uuid, final int diff) {
    JSONObject playerObj = uuidToStoredPlayer.optJSONObject(uuid.toString());
    if (playerObj == null) {
        playerObj = new JSONObject();
        playerObj.put("score", diff); // assume the default score is 0
    } else {/*from w  w w .  j  a  v a  2  s  .c om*/
        playerObj.put("score", playerObj.getInt("score") + diff);
    }
}

From source file:com.gmail.ferusgrim.util.NameGrabber.java

@Override
public Map<UUID, String> call() throws Exception {
    Map<UUID, String> responseMap = new HashMap<UUID, String>();
    JSONParser parser = new JSONParser();

    for (UUID uuid : this.uuidsToLookup) {
        HttpURLConnection connection = (HttpURLConnection) new URL(
                "https://sessionserver.mojang.com/session/minecraft/profile/"
                        + uuid.toString().replace("-", "")).openConnection();
        JSONObject response = (JSONObject) parser.parse(new InputStreamReader(connection.getInputStream()));

        String name = (String) response.get("name");

        if (name == null) {
            continue;
        }/*from w ww . j av  a2 s.co  m*/

        String cause = (String) response.get("cause");
        String message = (String) response.get("errorMessage");

        if (cause != null && cause.length() > 0) {
            throw new IllegalStateException(message);
        }

        responseMap.put(uuid, name);
    }

    return responseMap;
}

From source file:org.trustedanalytics.servicebroker.hdfs.plans.provisioning.HdfsProvisioningClient.java

@Override
public void createEncryptedZone(UUID instanceId, UUID orgId) throws ServiceBrokerException {
    try {/*from   w  w  w .  j  a v  a  2s  .  c  o  m*/
        String path = HdfsPathTemplateUtils.fill(userspacePathTemplate, instanceId, orgId);
        superUserHdfsClient.createKeyAndEncryptedZone(instanceId.toString(), new Path(path));
    } catch (IOException e) {
        throw new ServiceBrokerException("Unable to provision encrypted directory for: " + instanceId, e);
    }
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindSecSessionSecProxyId.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindSecSessionSecProxyId.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }/*from  www.j  ava  2  s .co  m*/

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamSecSessionObj) {
        UUID secProxyId = ((ICFBamSecSessionObj) genDef).getOptionalSecProxyId();
        if (secProxyId == null) {
            ret = null;
        } else {
            ret = secProxyId.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamSecSessionObj");
    }

    return (ret);
}

From source file:org.ovirt.engine.sdk.decorators.ClusterGlusterVolumeGlusterBrickStatistics.java

/**
 * Fetches ClusterGlusterVolumeGlusterBrickStatistic object by id.
 *
 * @return/*from  ww w.  j a  v a2  s .c  om*/
 *     {@link ClusterGlusterVolumeGlusterBrickStatistic }
 *
 * @throws ClientProtocolException
 *             Signals that HTTP/S protocol error has occurred.
 * @throws ServerException
 *             Signals that an oVirt api error has occurred.
 * @throws IOException
 *             Signals that an I/O exception of some sort has occurred.
 */
@Override
public ClusterGlusterVolumeGlusterBrickStatistic get(UUID id)
        throws ClientProtocolException, ServerException, IOException {
    String url = this.parent.getHref() + SLASH + getName() + SLASH + id.toString();
    return getProxy().get(url, org.ovirt.engine.sdk.entities.Statistic.class,
            ClusterGlusterVolumeGlusterBrickStatistic.class);
}

From source file:net.sourceforge.msscodefactory.cfbam.v2_7.CFBamMssCF.CFBamMssCFBindUuidDefInitValue.java

public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindUuidDefInitValue.expandBody() ";

    if (genContext == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext");
    }/*from w ww . j  a  v a  2  s .co  m*/

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), "expandBody", 1,
                "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamUuidDefObj) {
        UUID initValue = ((ICFBamUuidDefObj) genDef).getOptionalInitValue();
        if (initValue == null) {
            ret = null;
        } else {
            ret = initValue.toString();
        }
    } else {
        throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "expandBody",
                "genContext.getGenDef()", genDef, "ICFBamUuidDefObj");
    }

    return (ret);
}