List of usage examples for java.util UUID fromString
public static UUID fromString(String name)
From source file:com.haulmont.cuba.web.controllers.FileDownloadController.java
protected UserSession getSession(HttpServletRequest request, HttpServletResponse response) throws IOException { UUID sessionId;/* w ww . jav a 2 s . c o m*/ try { sessionId = UUID.fromString(request.getParameter("s")); } catch (Exception e) { return null; } AppContext.setSecurityContext(new SecurityContext(sessionId)); try { UserSession userSession = userSessionService.getUserSession(sessionId); return userSession; } catch (NoUserSessionException e) { return null; } finally { AppContext.setSecurityContext(null); } }
From source file:com.seventh_root.ld33.common.player.Player.java
public static Player getByUUID(Connection databaseConnection, UUID uuid) throws SQLException { if (playersByUUID.containsKey(uuid.toString())) return playersByUUID.get(uuid.toString()); if (databaseConnection != null) { PreparedStatement statement = databaseConnection.prepareStatement( "SELECT uuid, name, password_hash, password_salt, resources FROM player WHERE uuid = ? LIMIT 1"); statement.setString(1, uuid.toString()); ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { Player player = new Player(databaseConnection, UUID.fromString(resultSet.getString("uuid")), resultSet.getString("name"), resultSet.getString("password_hash"), resultSet.getString("password_salt"), resultSet.getInt("resources")); cachePlayer(player);/*from ww w. j a v a 2 s .c om*/ return player; } } return null; }
From source file:jenkins.scm.impl.subversion.SubversionSampleRepoRule.java
public void notifyCommit(JenkinsRule r, String path) throws Exception { synchronousPolling(r);// w ww . j a v a 2s. c o m // Mocking the web POST, with crumb, is way too hard, and get an IllegalStateException: STREAMED from doNotifyCommits getReader anyway. for (SubversionRepositoryStatus.Listener listener : ExtensionList .lookup(SubversionRepositoryStatus.Listener.class)) { listener.onNotify(UUID.fromString(uuid(rootUrl())), -1, Collections.singleton(path)); } r.waitUntilNoActivity(); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmXMsgRqstHandler.CFCrmXMsgRqstSecDeviceReadByUserIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/*w ww . j a v a2s. com*/ // 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("RqstSecDeviceReadByUserIdx"); 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 if ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "SecUserId"); } // 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 List<ICFCrmSecDeviceObj> list = schemaObj.getSecDeviceTableObj().readSecDeviceByUserIdx(natSecUserId); String responseOpening = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFCrmXMsgSecDeviceMessageFormatter.formatSecDeviceRspnListOpenTag(); xmsgRqstHandler.appendResponse(responseOpening); Iterator<ICFCrmSecDeviceObj> iter = list.iterator(); ICFCrmSecDeviceObj cur; String subxml; while (iter.hasNext()) { cur = iter.next(); subxml = CFCrmXMsgSecDeviceMessageFormatter.formatSecDeviceRspnDerivedRec("\n\t\t", cur.getSecDeviceBuff()); xmsgRqstHandler.appendResponse(subxml); } String responseClosing = "\n" + "\t" + CFCrmXMsgSecDeviceMessageFormatter.formatSecDeviceRspnListCloseTag() + 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.nesscomputing.jms.activemq.ServiceDiscoveryTransportFactory.java
/** * Find and validate the discoveryId given in a connection string *//*from ww w .j a v a 2 s.c o m*/ private UUID getDiscoveryId(final Map<String, String> params) throws IOException { final String discoveryId = params.get("discoveryId"); if (discoveryId == null) { throw new IOException("srvc transport did not get a discoveryId parameter. Refusing to create."); } return UUID.fromString(discoveryId); }
From source file:com.esri.geoportal.harvester.beans.HistoryManagerBean.java
@Override public History.Event read(UUID id) throws CrudlException { try (Connection connection = dataSource.getConnection(); PreparedStatement st = connection .prepareStatement("SELECT taskid,started,completed,report,id FROM EVENTS WHERE ID = ?");) { st.setString(1, id.toString());/*from www . j a va 2 s .c o m*/ ResultSet rs = st.executeQuery(); if (rs.next()) { try (Reader reportReader = rs.getClob(4).getCharacterStream();) { History.Event event = new History.Event(); event.setTaskId(UUID.fromString(rs.getString(1))); event.setStartTimestamp(new Date(rs.getTimestamp(2).getTime())); event.setEndTimestamp(new Date(rs.getTimestamp(3).getTime())); event.setReport(deserialize(reportReader, History.Report.class)); event.setUuid(UUID.fromString(rs.getString(5))); return event; } } } catch (IOException | SQLException ex) { throw new CrudlException("Error reading history event", ex); } return null; }
From source file:com.orange.clara.cloud.servicedbdumper.fake.cloudfoundry.CloudFoundryClientFake.java
@Override public CloudServiceKey createServiceKey(String guid, String name) { if (databaseUri == null) { return null; }// ww w . j av a2s .c om Map<String, Object> credentials = Maps.newHashMap(); credentials.put("uri", this.databaseUri); CloudServiceKey cloudServiceKey = new CloudServiceKey( new CloudEntity.Meta(UUID.randomUUID(), new Date(), new Date()), name); cloudServiceKey.setCredentials(credentials); cloudServiceKey.setService( new CloudService(new CloudEntity.Meta(UUID.fromString(guid), new Date(), new Date()), guid)); return cloudServiceKey; }
From source file:com.esri.geoportal.harvester.beans.TriggerManagerBean.java
@Override public Collection<Map.Entry<UUID, TaskUuidTriggerDefinitionPair>> list() throws CrudlException { HashMap<UUID, TaskUuidTriggerDefinitionPair> map = new HashMap<>(); try (Connection connection = dataSource.getConnection(); PreparedStatement st = connection.prepareStatement("SELECT * FROM TRIGGERS");) { ResultSet rs = st.executeQuery(); while (rs.next()) { try { UUID id = UUID.fromString(rs.getString("id")); TaskUuidTriggerDefinitionPair td = deserialize(rs.getString("definition"), TaskUuidTriggerDefinitionPair.class); map.put(id, td);// w w w . j a v a 2s . c om } catch (IOException | SQLException ex) { LOG.warn("Error reading broker definition", ex); } } } catch (SQLException ex) { throw new CrudlException("Error selecting broker definition", ex); } return map.entrySet(); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgRqstHandler.CFAsteriskXMsgRqstSecSessionDeleteBySecProxyIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFAsteriskXMsgSchemaMessageFormatter schemaFormatter = null; try {/*from www.j a va 2 s. co m*/ // Common XML Attributes String attrId = null; String attrSecProxyId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstSecSessionDeleteBySecProxyIdx"); CFAsteriskXMsgRqstHandler xmsgRqstHandler = (CFAsteriskXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFAsteriskSchemaObj 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("SecProxyId")) { if (attrSecProxyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecProxyId = 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 // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types UUID natSecProxyId; natSecProxyId = UUID.fromString(attrSecProxyId); // Delete the objects schemaObj.getSecSessionTableObj().deleteSecSessionBySecProxyIdx(natSecProxyId); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSecSessionMessageFormatter.formatSecSessionRspnDeleted() + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFAsteriskXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { CFAsteriskXMsgRqstHandler xmsgRqstHandler = ((CFAsteriskXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFAsteriskXMsgRqstHandler xmsgRqstHandler = ((CFAsteriskXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_4.CFFreeSwitchXMsgRqstHandler.CFFreeSwitchXMsgRqstSecSessionDeleteBySecProxyIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFFreeSwitchXMsgSchemaMessageFormatter schemaFormatter = null; try {// w ww .ja v a 2 s . co m // Common XML Attributes String attrId = null; String attrSecProxyId = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstSecSessionDeleteBySecProxyIdx"); CFFreeSwitchXMsgRqstHandler xmsgRqstHandler = (CFFreeSwitchXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFFreeSwitchSchemaObj 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("SecProxyId")) { if (attrSecProxyId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrSecProxyId = 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 // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types UUID natSecProxyId; natSecProxyId = UUID.fromString(attrSecProxyId); // Delete the objects schemaObj.getSecSessionTableObj().deleteSecSessionBySecProxyIdx(natSecProxyId); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFreeSwitchXMsgSecSessionMessageFormatter.formatSecSessionRspnDeleted() + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFFreeSwitchXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { CFFreeSwitchXMsgRqstHandler xmsgRqstHandler = ((CFFreeSwitchXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFreeSwitchXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFFreeSwitchXMsgRqstHandler xmsgRqstHandler = ((CFFreeSwitchXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFreeSwitchXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }