List of usage examples for java.util UUID fromString
public static UUID fromString(String name)
From source file:com.kolich.pusachat.spring.beans.ChatRooms.java
public synchronized ChatRoom getRoom(final String roomId) { try {/*from w w w. j ava2 s . c om*/ return getRoom(UUID.fromString(roomId)); } catch (IllegalArgumentException e) { throw new RoomNotFoundException("Malformed chat room UUID: " + roomId, e); } }
From source file:occi.infrastructure.Network.java
public Network(State state, String label, Set<Link> links, Set<String> attributes) throws URISyntaxException, SchemaViolationException { super(links, attributes); this.state = state; this.label = label; networkList.put(UUID.fromString(getId().toString()), this); generateActionNames();/*from w ww .j a v a 2 s .co m*/ generateAttributeList(); }
From source file:org.acoustid.server.util.ParameterMap.java
public String getUUIDString(String name) throws MissingParameterException, ParameterFormatException { String value = getString(name); try {//w w w . ja v a 2s . c o m UUID.fromString(value); } catch (IllegalArgumentException ex) { throw new ParameterFormatException("Parameter '" + name + "' is not a valid UUID", ex); } return value; }
From source file:com.jim.im.login.rest.LoginRestService.java
/** * sessionIDuserIDsessionInfo/*from w ww . j a va 2s . c om*/ * * @param sessionID * @param userID * @return * @throws ImParamException */ private Map<String, String> getUserStatus(String sessionID, int userID) throws ImParamException { Map<String, String> map = null; try { // ???userinfo dictionaryobj[] paras = new dictionaryobj[1]; paras[0] = new dictionaryobj(); paras[0].Itemcode = "usernumbers"; paras[0].Itemname = String.valueOf(userID); rowobj[] rowobjs = entSystemManagerService.getuserstatus(UUID.fromString(sessionID), userID, paras); if (rowobjs != null && rowobjs.length != 0) { map = new HashMap<String, String>(); dictionaryobj[] objs = rowobjs[0].Values; for (dictionaryobj retobj : objs) { String key = retobj.Itemcode; String value = retobj.Itemname; if (value == null) { value = ""; } if (GatewayUserstatusEnum.clienttypeno.name().equals(key) || GatewayUserstatusEnum.clienttypename.name().equals(key) || GatewayUserstatusEnum.clienttypeno.name().equals(key) || GatewayUserstatusEnum.clientversionno.name().equals(key) || GatewayUserstatusEnum.devicetoken.name().equals(key) || GatewayUserstatusEnum.versionname.name().equals(key)) { map.put(key, value); } } } } catch (Exception e) { e.printStackTrace(); throw new ImParamException( "get geteway userinfoobj fail by sessionID:" + sessionID + ",userID:" + userID, e); } return map; }
From source file:de.kaiserpfalzEdv.office.core.license.impl.LicenseBuilder.java
private UUID getUuidFromLicense(final License license, final String feature) { return UUID.fromString(license.getFeature(feature)); }
From source file:com.haulmont.cuba.core.controllers.FileDownloadController.java
protected UserSession getSession(HttpServletRequest request, HttpServletResponse response) throws IOException { UUID sessionId;/* w ww . j ava 2 s.c o m*/ try { sessionId = UUID.fromString(request.getParameter("s")); } catch (Exception e) { log.error("Error parsing sessionId from URL param", e); response.sendError(HttpServletResponse.SC_BAD_REQUEST); return null; } UserSession session = userSessions.getAndRefresh(sessionId); if (session == null) response.sendError(HttpServletResponse.SC_FORBIDDEN); return session; }
From source file:info.mallmc.framework.util.ProfileLoader.java
private UUID parseUUID(String uuidStr) { // Split uuid in to 5 components String[] uuidComponents = new String[] { uuidStr.substring(0, 8), uuidStr.substring(8, 12), uuidStr.substring(12, 16), uuidStr.substring(16, 20), uuidStr.substring(20, uuidStr.length()) }; // Combine components with a dash StringBuilder builder = new StringBuilder(); for (String component : uuidComponents) { builder.append(component).append('-'); }//from w w w . j a v a2 s . c om // Correct uuid length, remove last dash builder.setLength(builder.length() - 1); return UUID.fromString(builder.toString()); }
From source file:org.stockwatcher.web.WatchListController.java
@ResponseBody @RequestMapping(value = "/delete", method = RequestMethod.POST) public void deleteWatchList(Model model, HttpServletRequest request, HttpServletResponse response) throws IOException { String id = getRequestParameter(request, "watchListId"); UUID watchListId = UUID.fromString(id); WatchList watchList = watchListDAO.getWatchList(watchListId); User user = (User) request.getSession().getAttribute("user"); if (watchList.getUserId().equals(user.getId())) { // Notice we are using the Cassandra-specific DAO method watchListDAO.deleteWatchList(DELETE_WATCHLIST_QUERYOPTIONS, watchListId); LOGGER.info("Deleted watchList {}", watchListId); }//from ww w . j av a2 s .c o m }
From source file:org.trustedanalytics.user.orgs.SpacesIT.java
@Test public void getSpacesForSpecificOrg_shouldAskCloudfoundryForSpaces() { final String ORG = "6b436ee1-de3c-4996-b312-bacd54ef301a"; Map<String, Object> pathVars = new HashMap<>(); pathVars.put("org", ORG); Page<CcSpace> SPACES_FROM_CF = new Page<>(); SPACES_FROM_CF.setResources(SpacesTestsResources.getSpacesReturnedByCf().getSpaces()); final String EXPECTED_SPACES = SpacesTestsResources.getSpacesExpectedToBeReturnedBySc(); Observable<CcSpace> toReturn = Observable.from(SpacesTestsResources.getSpacesReturnedByCf().getSpaces()); when(ccClient.getSpaces(UUID.fromString(ORG))).thenReturn(toReturn); TestRestTemplate testRestTemplate = new TestRestTemplate(); ResponseEntity<String> response = RestOperationsHelpers.getForEntityWithToken(testRestTemplate, TOKEN, BASE_URL + SpacesController.GET_SPACES_OF_ORG_URL, pathVars); assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); assertThat(response.getBody(), equalTo(EXPECTED_SPACES)); }
From source file:me.ryanhamshire.griefprevention.migrator.RedProtectMigrator.java
public static void migrate(World world, Path redProtectFilePath, Path gpClaimDataPath) throws FileNotFoundException, ClassNotFoundException { if (!GriefPreventionPlugin.getGlobalConfig().getConfig().migrator.redProtectMigrator) { return;/* w ww. java 2 s. c o m*/ } int count = 0; try { GriefPreventionPlugin.instance.getLogger().info("Starting RedProtect region data migration for world " + world.getProperties().getWorldName() + "..."); ConfigurationLoader<CommentedConfigurationNode> regionManager = HoconConfigurationLoader.builder() .setPath(redProtectFilePath).build(); CommentedConfigurationNode region = regionManager.load(); GriefPreventionPlugin.instance.getLogger() .info("Scanning RedProtect regions in world data file '" + redProtectFilePath + "'..."); for (Object key : region.getChildrenMap().keySet()) { String rname = key.toString(); if (!region.getNode(rname).hasMapChildren()) { continue; } int maxX = region.getNode(rname, "maxX").getInt(); int maxY = region.getNode(rname, "maxY").getInt(255); int maxZ = region.getNode(rname, "maxZ").getInt(); int minX = region.getNode(rname, "minX").getInt(); int minY = region.getNode(rname, "minY").getInt(0); int minZ = region.getNode(rname, "minZ").getInt(); List<String> owners = new ArrayList<String>(); owners.addAll(region.getNode(rname, "owners").getList(TypeToken.of(String.class))); List<String> members = new ArrayList<String>(); members.addAll(region.getNode(rname, "members").getList(TypeToken.of(String.class))); String creator = region.getNode(rname, "creator").getString(); String welcome = region.getNode(rname, "welcome").getString(); // create GP claim data file GriefPreventionPlugin.instance.getLogger() .info("Migrating RedProtect region data '" + rname + "'..."); UUID ownerUniqueId = null; if (validate(creator)) { try { // check cache first ownerUniqueId = PlayerUtils.getUUIDByName(creator); if (ownerUniqueId == null) { ownerUniqueId = UUID.fromString(getUUID(creator)); } } catch (Throwable e) { // assume admin claim } } UUID claimUniqueId = UUID.randomUUID(); Location<World> lesserBoundaryCorner = new Location<>(world, minX, minY, minZ); Location<World> greaterBoundaryCorner = new Location<>(world, maxX, maxY, maxZ); Path claimFilePath = gpClaimDataPath.resolve(claimUniqueId.toString()); if (!Files.exists(claimFilePath)) { Files.createFile(claimFilePath); } ClaimStorageData claimStorage = new ClaimStorageData(claimFilePath); ClaimDataConfig claimDataConfig = claimStorage.getConfig(); claimDataConfig.setName(Text.of(rname)); claimDataConfig.setWorldUniqueId(world.getUniqueId()); claimDataConfig.setOwnerUniqueId(ownerUniqueId); claimDataConfig.setLesserBoundaryCorner(BlockUtils.positionToString(lesserBoundaryCorner)); claimDataConfig.setGreaterBoundaryCorner(BlockUtils.positionToString(greaterBoundaryCorner)); claimDataConfig.setDateLastActive(Instant.now()); claimDataConfig.setType(ownerUniqueId == null ? ClaimType.ADMIN : ClaimType.BASIC); if (!welcome.equals("")) { claimDataConfig.setGreeting(Text.of(welcome)); } List<String> rpUsers = new ArrayList<>(owners); rpUsers.addAll(members); List<UUID> builders = claimDataConfig.getBuilders(); for (String builder : rpUsers) { if (!validate(builder)) { continue; } UUID builderUniqueId = null; try { builderUniqueId = PlayerUtils.getUUIDByName(builder); if (builderUniqueId == null) { builderUniqueId = UUID.fromString(getUUID(builder)); } } catch (Throwable e) { GriefPreventionPlugin.instance.getLogger().error("Could not locate a valid UUID for user '" + builder + "' in region '" + rname + "'. Skipping..."); continue; } if (!builders.contains(builderUniqueId) && ownerUniqueId != null && !builderUniqueId.equals(ownerUniqueId)) { builders.add(builderUniqueId); } } claimDataConfig.setRequiresSave(true); claimStorage.save(); GriefPreventionPlugin.instance.getLogger().info( "Successfully migrated RedProtect region data '" + rname + "' to '" + claimFilePath + "'"); count++; } GriefPreventionPlugin.instance.getLogger().info("Finished RedProtect region data migration for world '" + world.getProperties().getWorldName() + "'." + " Migrated a total of " + count + " regions."); } catch (IOException e) { e.printStackTrace(); } catch (ObjectMappingException e) { e.printStackTrace(); } }