List of usage examples for java.util UUID toString
public String toString()
From source file:org.ng200.openolympus.controller.task.TaskCreationController.java
@RequestMapping(method = RequestMethod.POST) public String createTask(final Model model, final HttpServletRequest request, @Valid final TaskDto taskDto, final BindingResult bindingResult) throws IllegalStateException, IOException, ArchiveException { this.taskDtoValidator.validate(taskDto, bindingResult, null); if (bindingResult.hasErrors()) { model.addAttribute("submitURL", "/archive/add"); model.addAttribute("mode", "add"); return "tasks/add"; }//from w w w .ja v a 2 s .c o m final UUID uuid = UUID.randomUUID(); Task task = new Task(taskDto.getName(), uuid.toString(), uuid.toString(), Date.from(Instant.now())); this.uploadTaskData(task, taskDto); task = this.taskRepository.save(task); return "redirect:/task/" + task.getId(); }
From source file:org.service.ApiRest.java
/** * Envia la imagen codificada al servidor * * @param String encodedImage Imagen codificada con Base64 * @throws IOException//from ww w . j a va 2 s . c o m * @throws ClientProtocolException * @throws JSONException * */ public Boolean uploadPhoto(String encodedImage, EditText name, EditText nameFloor, EditText numberFloor) throws ClientProtocolException, IOException, JSONException { HttpClient httpclient = new DefaultHttpClient(); //url y tipo de contenido HttpPost httppost = new HttpPost(HTTP_EVENT); httppost.addHeader("Content-Type", "application/json"); //forma el JSON y tipo de contenido JSONObject jsonObject = new JSONObject(); UUID uuid = UUID.randomUUID(); String randomUUIDString = uuid.toString(); jsonObject.put("idEdifice", randomUUIDString); jsonObject.put("NameEdifice", name.getText().toString()); jsonObject.put("photo", encodedImage); jsonObject.put("idFloor", UUID.randomUUID().toString()); jsonObject.put("NameFloor", nameFloor.getText().toString()); jsonObject.put("NumberFloor", numberFloor.getText().toString()); // StringEntity stringEntity = new StringEntity(jsonObject.toString()); // stringEntity.setContentType((Header) new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); httppost.setEntity(stringEntity); //ejecuta HttpResponse response = httpclient.execute(httppost); //obtiene la respuesta y transorma a objeto JSON String jsonResult = inputStreamToString(response.getEntity().getContent()).toString(); JSONObject object = new JSONObject(jsonResult); if (object.getString("status").equals("200")) { return true; } return false; }
From source file:org.noorganization.instalist.comm.message.ListInfo.java
public void setCategoryUUID(UUID categoryUUID) { mCategoryUUID = categoryUUID.toString(); }
From source file:me.heyimblake.HiveMCRank.Utils.WebConnector.java
/** * Returns the Hive Name of the rank of a supplied UUID. Regular Member is returned if null. * * @param uuid the UUID of the player//from w w w .j ava 2s.com * @return Hive Name of the rank of the UUID * @throws Exception thrown if the UUID has never been on TheHive or TheHive's API is not available. Default Rank is returned. */ public String getHiveRank(final UUID uuid) throws Exception { String rankfromapi; final String uuidNoDash = uuid.toString().replace("-", ""); try { final String API_URL = "http://api.hivemc.com/v1/player/"; final URLConnection connection = new URL(API_URL + uuidNoDash).openConnection(); Bukkit.getServer().getLogger().log(Level.INFO, "Connection opened to " + API_URL + uuidNoDash); connection.addRequestProperty("User-Agent", "Mozilla/5.0"); final JSONTokener tokener = new JSONTokener(connection.getInputStream()); final JSONObject root = new JSONObject(tokener); if (root.getString("rankName") == null) { rankfromapi = "Regular Member"; } else { rankfromapi = root.getString("rankName"); } } catch (Exception e) { Bukkit.getServer().getLogger().log(Level.SEVERE, "Exception occurred while trying to get the HiveMC rank of " + uuid); Bukkit.getServer().getLogger().log(Level.SEVERE, "Chances are that the user has never logged onto TheHive before. Their rank has been set to regular for now."); rankfromapi = "Regular Member"; } return rankfromapi; }
From source file:microsoft.exchange.webservices.data.misc.IFunctionsTest.java
@Test public void testToUUID() { final IFunctions.ToUUID f = IFunctions.ToUUID.INSTANCE; try {//ww w. j a v a2s. com Assert.assertNull(f.func(null)); } catch (final Throwable ex) { final UUID uuid = UUID.randomUUID(); Assert.assertEquals(uuid, f.func(uuid.toString())); } }
From source file:me.gamingtest.de.Util.NameFetcher.java
@Override public Map<UUID, String> call() throws Exception { Map<UUID, String> uuidStringMap = new HashMap<UUID, String>(); for (UUID uuid : uuids) { HttpURLConnection connection = (HttpURLConnection) new URL( PROFILE_URL + uuid.toString().replace("-", "")).openConnection(); JSONObject response = (JSONObject) jsonParser.parse(new InputStreamReader(connection.getInputStream())); String name = (String) response.get("name"); if (name == null) { continue; }/* w w w. j av a 2s .c o m*/ String cause = (String) response.get("cause"); String errorMessage = (String) response.get("errorMessage"); if (cause != null && cause.length() > 0) { throw new IllegalStateException(errorMessage); } uuidStringMap.put(uuid, name); } return uuidStringMap; }
From source file:org.noorganization.instalist.comm.message.TaggedProductInfo.java
public void setTagUUID(UUID _tagUUID) { mTagUUID = _tagUUID != null ? _tagUUID.toString() : null; }
From source file:com.facebook.presto.rakam.S3BackupStore.java
@Override public boolean shardExists(java.util.UUID uuid) { try {//from www .ja v a 2 s . co m s3Client.getObjectMetadata(config.getS3Bucket(), uuid.toString()); return true; } catch (AmazonS3Exception e) { if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) { return false; } else { throw e; } } }
From source file:com.azaptree.services.security.commands.subjectRepository.DeleteSubject.java
@Transactional @Override/*from w w w . j av a 2 s. com*/ protected boolean executeCommand(final Context ctx) { final UUID subjectId = get(ctx, SUBJECT_ID); if (!subjectDAO.delete(subjectId)) { throw new UnknownSubjectException(subjectId.toString()); } return CONTINUE_PROCESSING; }
From source file:org.trustedanalytics.serviceexposer.RedisCredentialsStoreTest.java
@Test public void testGetCredentialsInJSON() { String serviceName = "tested"; UUID guid = UUID.randomUUID(); String randomServiceGuid = guid.toString(); UUID randomSpaceGuid = UUID.randomUUID(); UUID randomSpaceGuid2 = UUID.randomUUID(); Map<String, String> testEntry = ImmutableMap.of("guid", randomServiceGuid, "hostname", serviceName + "-" + randomServiceGuid, "login", "", "password", ""); when(mockCredentialsProperties.retriveMapForm()).thenReturn(testEntry); when(mockCredentialsProperties.getSpaceGuid()).thenReturn(randomSpaceGuid.toString()); CredentialProperties existingEntry = new CredentialProperties(true, "", randomServiceGuid, randomSpaceGuid.toString(), serviceName, "", "", "", "", ""); List<Object> serviceEntries = ImmutableList.of(existingEntry); when(mockHashOps.get(SERVICE_TYPE, guid.toString())).thenReturn(existingEntry); CredentialProperties entry = sut.get(SERVICE_TYPE, guid); Map ref = ImmutableMap.of(serviceName, testEntry); Map actual = ImmutableMap.of(entry.getName(), entry.retriveMapForm()); assertEquals(ref, actual);// w w w. ja v a 2s.co m }