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.formkiq.core.dao.QueueDaoImpl.java

@SuppressWarnings({ "unchecked", "resource" })
@Override//from   w w  w . j  av a2 s. com
public QueueListDTO findMessages(final String queue, final String token) {

    int offset = Strings.getOffset(token);
    int max = Strings.getMaxResults(token, DEFAULT_MAX_RESULTS);

    StringBuilder sql = new StringBuilder(
            "select u.queue_message_id as uuid " + ", u.message as message, u.status as status "
                    + " from queue_messages u " + " where queue_id=:queue ");

    sql.append(" OFFSET " + offset + " FETCH FIRST " + (max + 1) + " ROWS ONLY");

    Session session = getEntityManager().unwrap(Session.class);

    List<QueueDTO> list = session.createSQLQuery(sql.toString()).addScalar("uuid", StringType.INSTANCE)
            .addScalar("message", StringType.INSTANCE).addScalar("status", StringType.INSTANCE)
            .setParameter("queue", UUID.fromString(queue), PostgresUUIDType.INSTANCE)
            .setResultTransformer(new AliasToBeanResultTransformer(QueueDTO.class)).list();

    QueueListDTO dto = new QueueListDTO();

    List<QueueDTO> truncate = updatePagination(dto, offset, max, list);
    dto.setMessages(truncate);

    return dto;
}

From source file:com.github.helenusdriver.persistence.SetUUIDTokenizer.java

/**
 * {@inheritDoc}/* w w w  .j a v a2  s. com*/
 *
 * @author paouelle
 *
 * @see com.github.helenusdriver.persistence.Persister#decode(java.lang.Object)
 */
@Override
public Set<UUID> decode(String s) throws IOException {
    final String[] as = StringUtils.splitByWholeSeparator(s, separator);

    if (as == null) {
        return null;
    }
    final Set<UUID> set = new LinkedHashSet<>(as.length); // to maintain found order

    for (final String se : as) {
        try {
            set.add(UUID.fromString(se));
        } catch (IllegalArgumentException e) {
            throw new IOException("unable to decode UUID: " + se, e);
        }
    }
    return set;
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmXMsgRqstHandler.CFCrmXMsgRqstTSecGroupMemberDeleteByUserIdxHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from  w  ww . j  a  v  a  2s  .c  om*/
        // Common XML Attributes
        String attrId = null;
        String attrSecUserId = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstTSecGroupMemberDeleteByUserIdx");

        CFCrmXMsgRqstHandler xmsgRqstHandler = (CFCrmXMsgRqstHandler) getParser();
        if (xmsgRqstHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFCrmSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("SecUserId")) {
                if (attrSecUserId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrSecUserId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values$implRqstTableDeleteByHandlerCheckReqKeyAttrs$

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();
        // Convert string attributes to native Java types

        UUID natSecUserId;
        natSecUserId = UUID.fromString(attrSecUserId);

        // Delete the objects
        schemaObj.getTSecGroupMemberTableObj().deleteTSecGroupMemberByUserIdx(natSecUserId);
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgTSecGroupMemberMessageFormatter.formatTSecGroupMemberRspnDeleted() + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response);
    } catch (RuntimeException e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:net.portalblock.untamedchat.bungee.providers.RedisBungeeProvider.java

@EventHandler
public void onPubSubMessage(PubSubMessageEvent e) {
    if (e.getChannel().equals(UntamedChat.GBL_CHANNEL)) {
        Message message = Message.fromJSONObject(new JSONObject(e.getMessage()));
        switch (message.getTarget().getKind()) {
        case GLOBAL:
            String msg = UCConfig.compileMessage(UCConfig.GLOBAL_FORMAT, message.getMessage(),
                    message.getServer(), message.getSender(), null);
            for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers())
                p.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', msg)));
            break;
        case PLAYER:
            ProxiedPlayer t = ProxyServer.getInstance().getPlayer(message.getTarget().getTarget());
            if (t != null) {
                String trgtMsg = UCConfig.compileMessage(UCConfig.TARGET_FORMAT, message.getMessage(),
                        message.getServer(), message.getSender(), message.getTarget().getTarget());
                lastMessages.put(t.getName().toLowerCase(), message.getSender());
                t.sendMessage(//  ww w .jav  a2s .co  m
                        TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', trgtMsg)));

                String ssMsg = UCConfig.compileMessage(UCConfig.SOCIAL_SPY_FORMAT, message.getMessage(), "",
                        message.getSender(), message.getTarget().getTarget());
                for (Map.Entry<UUID, Boolean> entry : spying.entrySet()) {
                    if (entry.getValue()) {
                        ProxiedPlayer player1 = ProxyServer.getInstance().getPlayer(entry.getKey());

                        if (player1 != null)
                            player1.sendMessage(TextComponent
                                    .fromLegacyText(ChatColor.translateAlternateColorCodes('&', ssMsg)));
                    }
                }
            }
            break;
        }
    } else if (e.getChannel().equals(UntamedChat.TOG_CHANNEL)) {
        JSONObject msg = new JSONObject(e.getMessage());
        if (msg.getString("type").equals("chat"))
            globalChat.put(UUID.fromString(msg.getString("uuid")), msg.getBoolean("mode"));
        else if (msg.getString("type").equals("spy"))
            spying.put(UUID.fromString(msg.getString("uuid")), msg.getBoolean("mode"));
    }
}

From source file:com.noxpvp.mmo.MMOPlayer.java

public void load() {
    superLoad();// ww  w  .j a  v a 2 s  .  c om

    ConfigurationNode node = getPersistantData();
    setPrimaryClass(node.get(PRIMARY_CLASS_NODE, ""));
    setSecondaryClass(node.get(SECONDARY_CLASS_NODE, ""));

    /*
     * Seperate the scope Just in case we want to use the variables again.
     */
    {
        String uid = node.get(TARGET_NODE + ".uuid", String.class);
        World world = Bukkit.getWorld(node.get(TARGET_NODE + ".world", String.class));
        if (!LogicUtil.nullOrEmpty(uid) && world != null)
            setTarget(EntityUtil.getEntity(world, UUID.fromString(uid), LivingEntity.class));
    }
}

From source file:org.trustedanalytics.uploader.service.UploadService.java

private void doProcess(FileItemStream fileItemStream, UploadMetadata uploadMetadata,
        Function<Transfer, Transfer> mapper, List<Transfer> transfers) {
    try (InputStream input = streamDecoder.apply(fileItemStream.openStream())) {
        final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        Transfer transfer = new Transfer(uploadMetadata);
        streamConsumer.accept(input, transfer, UUID.fromString(uploadMetadata.getOrgUUID()));
        transfer = mapper.apply(transfer);
        dataAcquisitionClient.uploadCompleted(transfer, "bearer " + tokenExtractor.apply(auth));
        transfers.add(transfer);//w w  w . j  av a  2  s  .  c om

    } catch (AccessControlException ex) {
        throw new AccessDeniedException("Permission denied", ex);
    } catch (IOException | LoginException | InterruptedException ex) {
        throw new UploadException(transfers, ex);
    }
}

From source file:occi.infrastructure.Network.java

public Network(State state, int vlan, Set<Link> links, Set<String> attributes)
        throws URISyntaxException, SchemaViolationException {
    super(links, attributes);
    this.state = state;
    this.vlan = vlan;

    networkList.put(UUID.fromString(getId().toString()), this);
    generateActionNames();/*from  www.ja v a 2 s .  c om*/
    generateAttributeList();
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmXMsgRqstHandler.CFCrmXMsgRqstSecGroupMemberReadByUserIdxHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from w  ww  .java 2 s  .  c  om
        // Common XML Attributes
        String attrId = null;
        String attrSecUserId = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstSecGroupMemberReadByUserIdx");

        CFCrmXMsgRqstHandler xmsgRqstHandler = (CFCrmXMsgRqstHandler) getParser();
        if (xmsgRqstHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFCrmSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("SecUserId")) {
                if (attrSecUserId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrSecUserId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values$implRqstTableReadByHandlerCheckReqKeyAttrs$

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();
        // Convert string attributes to native Java types
        // and apply the converted attributes to the editBuff.

        UUID natSecUserId;
        natSecUserId = UUID.fromString(attrSecUserId);

        // Read the objects
        SortedMap<CFCrmSecGroupMemberPKey, ICFCrmSecGroupMemberObj> map = schemaObj.getSecGroupMemberTableObj()
                .readSecGroupMemberByUserIdx(natSecUserId);
        String responseOpening = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRspnListOpenTag();
        xmsgRqstHandler.appendResponse(responseOpening);
        Iterator<ICFCrmSecGroupMemberObj> iter = map.values().iterator();
        ICFCrmSecGroupMemberObj cur;
        String subxml;
        while (iter.hasNext()) {
            cur = iter.next();
            subxml = CFCrmXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRspnDerivedRec("\n\t\t",
                    cur.getSecGroupMemberBuff());
            xmsgRqstHandler.appendResponse(subxml);
        }
        String responseClosing = "\n" + "\t"
                + CFCrmXMsgSecGroupMemberMessageFormatter.formatSecGroupMemberRspnListCloseTag()
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        xmsgRqstHandler.appendResponse(responseClosing);
    } catch (RuntimeException e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:com.formkiq.core.dao.FolderDaoImpl.java

@SuppressWarnings("resource")
@Override/*  ww w.  j ava  2  s .  co m*/
public void deleteForm(final String folder, final String uuid, final boolean isparentuuid) {

    String sql = "update folder_forms set status=:status " + " where folder_id=:folder and uuid=:uuid";

    if (isparentuuid) {
        sql = "update folder_forms set status=:status " + " where folder_id=:folder and parent_uuid=:uuid";
    }

    Session session = getEntityManager().unwrap(Session.class);

    session.createSQLQuery(sql).setParameter("status", FolderFormStatus.DELETED.name())
            .setParameter("folder", UUID.fromString(folder), PostgresUUIDType.INSTANCE)
            .setParameter("uuid", UUID.fromString(uuid), PostgresUUIDType.INSTANCE).executeUpdate();
}

From source file:com.spectralogic.ds3client.helpers.RequestMatchers.java

public static GetObjectRequest getRequestHas(final String bucket, final String key, final UUID jobId,
        final long offset) {
    return argThat(new TypeSafeMatcher<GetObjectRequest>() {
        @Override//from   w  ww .  java  2s.c  o  m
        protected boolean matchesSafely(final GetObjectRequest item) {
            return item.getBucketName().equals(bucket) && item.getObjectName().equals(key)
                    && (item.getJob() == null ? jobId == null : UUID.fromString(item.getJob()).equals(jobId))
                    && item.getOffset() == offset;
        }

        @Override
        public void describeTo(final Description description) {
            describeTransferRequest(bucket, key, jobId, offset, description);
        }

        @Override
        protected void describeMismatchSafely(final GetObjectRequest item,
                final Description mismatchDescription) {
            describeTransferRequest(item.getBucketName(), item.getObjectName(), UUID.fromString(item.getJob()),
                    item.getOffset(), mismatchDescription);
        }
    });
}