List of usage examples for java.util UUID toString
public String toString()
From source file:org.ovirt.engine.sdk.decorators.DataCenterStorageDomainDiskStatistics.java
/** * Fetches DataCenterStorageDomainDiskStatistic object by id. * * @return//w w w. j a va 2s.co m * {@link DataCenterStorageDomainDiskStatistic } * * @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 DataCenterStorageDomainDiskStatistic 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, DataCenterStorageDomainDiskStatistic.class); }
From source file:org.ng200.openolympus.services.StorageService.java
public Path createSolutionDirectory() throws IOException { final UUID uuid = UUID.randomUUID(); final Path dir = FileSystems.getDefault().getPath(this.storagePath, "solutions", uuid.toString() + "_" + System.currentTimeMillis()); FileAccess.createDirectories(dir);/*from w w w.ja v a 2s.co m*/ return dir; }
From source file:org.ovirt.engine.sdk.decorators.DataCenterClusterGlusterVolumeGlusterBrickStatistics.java
/** * Fetches DataCenterClusterGlusterVolumeGlusterBrickStatistic object by id. * * @return/*www . ja va2 s .c o m*/ * {@link DataCenterClusterGlusterVolumeGlusterBrickStatistic } * * @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 DataCenterClusterGlusterVolumeGlusterBrickStatistic 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, DataCenterClusterGlusterVolumeGlusterBrickStatistic.class); }
From source file:org.ohmage.query.impl.SurveyResponseImageQueries.java
public List<UUID> getImageIdsFromSurveyResponse(UUID surveyResponseId) throws DataAccessException { try {//from w ww . j ava 2s. c o m return getJdbcTemplate().query(SQL_GET_IMAGE_IDS_FROM_SURVEY_RESPONSE, new Object[] { surveyResponseId.toString() }, new RowMapper<UUID>() { @Override public UUID mapRow(ResultSet rs, int rowNum) throws SQLException { String response = rs.getString("response"); try { return UUID.fromString(response); } catch (IllegalArgumentException notUuid) { try { NoResponse.valueOf(response.toUpperCase()); return null; } catch (IllegalArgumentException notNoResponse) { throw new SQLException("The response value is not a valid UUID.", notNoResponse); } } } }); } catch (org.springframework.dao.DataAccessException e) { throw new DataAccessException("Error executing SQL '" + SQL_GET_IMAGE_IDS_FROM_SURVEY_RESPONSE + "' with parameter: " + surveyResponseId, e); } }
From source file:com.azaptree.services.security.commands.subjectRepository.DeleteSubjectCredential.java
public DeleteSubjectCredential() { setValidator(new CommandContextValidatorSupport() { @Override/*from ww w . ja v a 2s . c o m*/ protected void checkInput(final Command command, final Context ctx) { final UUID subjectId = get(ctx, SUBJECT_ID); if (!subjectDAO.exists(subjectId)) { throw new UnknownSubjectException(subjectId.toString()); } final UUID updatedBySubjectId = get(ctx, UPDATED_BY_SUBJECT_ID); if (updatedBySubjectId != null) { Assert.isTrue(!subjectId.equals(updatedBySubjectId), String.format( "The updatedBy subject (%s) cannot be the same as the subject (%s) which we are adding the credential to", subjectId, updatedBySubjectId)); if (!subjectDAO.exists(updatedBySubjectId)) { throw new UnknownSubjectException( String.format("Subject for updatedBy does not exist: %s", updatedBySubjectId)); } } } @Override protected void checkOutput(final Command command, final Context ctx) { // none required } }); setInputKeys(SUBJECT_ID, CREDENTIAL_NAME, UPDATED_BY_SUBJECT_ID); }
From source file:adminpackage.adminview.ProductAddition.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, Exception { response.setContentType("text/plain;charset=UTF-8"); DiskFileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); AdminViewProduct product = new AdminViewProduct(); List<FileItem> items = upload.parseRequest(request); Iterator itr = items.iterator(); String value = "defa"; String url = ""; while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); if (item.isFormField()) { String name = item.getFieldName(); value = item.getString();/*from w ww. ja v a 2s . co m*/ switch (name) { case "pname": product.setName(value); break; case "quantity": product.setQuantity(Integer.parseInt(value)); break; case "author": product.setAuthor(value); break; case "isbn": product.setISBN(Long.parseLong(value)); break; case "description": product.setDescription(value); break; case "category": product.setCategory(value); break; case "price": product.setPrice(Integer.parseInt(value)); break; } } else { //System.out.println(context.getRealPath("/pages/images/").replaceAll("\\\\target\\\\MavenOnlineShoping-1.0-SNAPSHOT", "\\\\src\\\\main\\\\webapp") + item.getName()); //url = context.getRealPath("/pages/images/").replaceAll("\\\\target\\\\MavenOnlineShoping-1.0-SNAPSHOT", "\\\\src\\\\main\\\\webapp") + item.getName(); UUID idOne = UUID.randomUUID(); product.setImage(idOne.toString() + item.getName().substring(item.getName().length() - 4)); item.write(new File(context.getRealPath("/pages/images/") .replaceAll("\\\\target\\\\MavenOnlineShoping-1.0-SNAPSHOT", "\\\\src\\\\main\\\\webapp") + idOne.toString() + item.getName().substring(item.getName().length() - 4))); } } PrintWriter out = response.getWriter(); if (adminFacadeHandler.addBook(product)) { out.print("true"); } else { //out.println("false"); out.print("false"); } }
From source file:annis.administration.BinaryImportHelper.java
public BinaryImportHelper(File f, File dataDir, String toplevelCorpusName, long corpusRef, Map<String, String> mimeTypeMapping) { this.fileSource = f; // create a file-name in the form of "filename_toplevelcorpus_UUID.ending", thus we // need to split the file name into its components String baseName = FilenameUtils.getBaseName(fileSource.getName()); String extension = FilenameUtils.getExtension(fileSource.getName()); UUID uuid = UUID.randomUUID(); String outputName = ""; if (toplevelCorpusName == null) { outputName = baseName + "_" + uuid.toString() + (extension.isEmpty() ? "" : "." + extension); } else {//from w w w. j ava 2 s . c o m outputName = baseName + "_" + CommonHelper.getSafeFileName(toplevelCorpusName) + "_" + uuid.toString() + (extension.isEmpty() ? "" : "." + extension); } fileDestination = new File(dataDir, outputName); String fileEnding = FilenameUtils.getExtension(f.getName()); if (mimeTypeMapping.containsKey(fileEnding)) { this.mimeType = mimeTypeMapping.get(fileEnding); } else { this.mimeType = new MimetypesFileTypeMap().getContentType(fileSource); } this.corpusRef = corpusRef; }
From source file:net.bemacized.enderauth.discordbot.mccache.NameFetcher.java
@Override public Map<UUID, Lookup<NameHistory>> call() { Map<UUID, Lookup<NameHistory>> uuidNameHistory = new HashMap<>(); for (UUID uuid : uuids) { try {/*from ww w . j a va 2s . c om*/ URLConnection connection = new URL(String.format(PROFILE_URL, uuid.toString().replace("-", ""))) .openConnection(); JSONArray response = new JSONArray(IOUtils.toString(connection.getInputStream())); NameHistory history = new NameHistory(); for (Object obj : response) { JSONObject object = (JSONObject) obj; String name = (String) object.get("name"); Date changedToAt = object.has("changedToAt") ? new Date(object.getLong("changedToAt")) : null; history.getHistory().add(new NameHistoryEntry(name, changedToAt)); } history.sort(); uuidNameHistory.put(uuid, new Lookup<>(history, null)); } catch (Exception e) { uuidNameHistory.put(uuid, new Lookup<>(null, e)); } } return uuidNameHistory; }
From source file:ccc.cli.NewDBQueries.java
/** * Change migration user password.//from ww w . ja va 2 s. c o m * * @param muid UUID of the migration user; */ public void changeMigrationUserPw(final UUID muid) { final UUID pwId = UUID.randomUUID(); final byte[] hash = Encryption.hash("" + new Date().getTime(), pwId.toString()); PreparedStatement ps = null; try { // update password ps = _connection.prepareStatement("UPDATE users SET hash=?, vn=1 WHERE user_id = ?"); ps.setBytes(1, hash); ps.setString(2, muid.toString()); ps.executeUpdate(); _connection.commit(); } catch (final SQLException e) { throw new RuntimeException(e); } finally { DbUtils.closeQuietly(ps); } }
From source file:org.ovirt.engine.sdk.decorators.InstanceTypeNICs.java
/** * Fetches InstanceTypeNIC object by id. * * @return/*from ww w. j a va2 s. c o m*/ * {@link InstanceTypeNIC } * * @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 InstanceTypeNIC 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.NIC.class, InstanceTypeNIC.class); }