public static String toCSVList(final List<String> csvList) { return join(csvList, ","); } }
public boolean isAnnotated() { return StringUtils.isNotBlank(annotation); } }
public static String cleanPassword(String logString) { String cleanLogString = null; if (logString != null) { cleanLogString = logString; String[] temp = logString.split(","); int i = 0; if (temp != null) { while (i < temp.length) { temp[i] = StringUtils.cleanString(temp[i]); i++; } List<String> stringList = new ArrayList<String>(); Collections.addAll(stringList, temp); cleanLogString = StringUtils.join(stringList, ","); } } return cleanLogString; }
@Test public void testGetPreferredCharset() { final boolean ifUtf8Supported = StringUtils.isUtf8Supported(); if (ifUtf8Supported) { assertEquals(StringUtils.getPreferredCharset(), Charset.forName("UTF-8")); } else { assertNotEquals(StringUtils.getPreferredCharset(), Charset.forName("UTF-8")); } }
vmData.add(new String[]{USERDATA_DIR, USERDATA_FILE, userData}); vmData.add(new String[]{METATDATA_DIR, SERVICE_OFFERING_FILE, StringUtils.unicodeEscape(serviceOffering)}); vmData.add(new String[]{METATDATA_DIR, AVAILABILITY_ZONE_FILE, StringUtils.unicodeEscape(zoneName)}); vmData.add(new String[]{METATDATA_DIR, LOCAL_HOSTNAME_FILE, StringUtils.unicodeEscape(vmHostName)}); vmData.add(new String[]{METATDATA_DIR, LOCAL_IPV4_FILE, guestIpAddress}); String publicHostName = StringUtils.unicodeEscape(vmHostName); md5.update(password.getBytes(StringUtils.getPreferredCharset())); byte[] digest = md5.digest(); BigInteger bigInt = new BigInteger(1, digest);
@SuppressWarnings("unchecked") @DB public long submitAsyncJob(AsyncJob job, boolean scheduleJobExecutionInContext) { @SuppressWarnings("rawtypes") GenericDao dao = GenericDaoBase.getDao(job.getClass()); job.setInitMsid(getMsid()); job.setSyncSource(null); // no sync source originally dao.persist(job); publishOnEventBus(job, "submit"); scheduleExecution(job, scheduleJobExecutionInContext); if (s_logger.isDebugEnabled()) { s_logger.debug("submit async job-" + job.getId() + ", details: " + StringUtils.cleanString(job.toString())); } return job.getId(); }
return "checksum algorithm not recognised: " + oldValue.getAlgorithm(); if(StringUtils.isNotBlank(dnld.getChecksum()) && ! oldValue.equals(newValue)) { return "checksum \"" + newValue +"\" didn't match the given value, \"" + oldValue + "\""; templateName = jobs.get(jobId).getTmpltName().trim().replace(" ", "_"); } else { templateName = java.util.UUID.nameUUIDFromBytes((jobs.get(jobId).getTmpltName() + System.currentTimeMillis()).getBytes(StringUtils.getPreferredCharset())).toString();
public static String encodePassword(String originalPassword) { byte[] passwordBytes = originalPassword.getBytes(StringUtils.getPreferredCharset()); byte[] encodedPasswordBytes = Base64.encodeBase64(passwordBytes); return new String(encodedPasswordBytes, StringUtils.getPreferredCharset()); }
@Override public String getHostTags(final long hostId) { final List<String> hostTags = _hostTagsDao.gethostTags(hostId); if (hostTags == null) { return null; } else { return StringUtils.listToCsvTags(hostTags); } }
private void checkDestinationForTags(StoragePool destPool, VMInstanceVO vm) { List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId()); // OfflineVmwareMigration: iterate over volumes // OfflineVmwareMigration: get disk offering List<String> storageTags = storageMgr.getStoragePoolTagList(destPool.getId()); for(Volume vol : vols) { DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId()); List<String> volumeTags = StringUtils.csvTagsToList(diskOffering.getTags()); if(! matches(volumeTags, storageTags)) { String msg = String.format("destination pool '%s' with tags '%s', does not support the volume diskoffering for volume '%s' (tags: '%s') ", destPool.getName(), StringUtils.listToCsvTags(storageTags), vol.getName(), StringUtils.listToCsvTags(volumeTags) ); throw new CloudRuntimeException(msg); } } }
private void processManagementServerList(final List<String> msList, final String lbAlgorithm, final Long lbCheckInterval) { if (CollectionUtils.isNotEmpty(msList) && !Strings.isNullOrEmpty(lbAlgorithm)) { try { final String newMSHosts = String.format("%s%s%s", StringUtils.toCSVList(msList), IAgentShell.hostLbAlgorithmSeparator, lbAlgorithm); _shell.setPersistentProperty(null, "host", newMSHosts); _shell.setHosts(newMSHosts); _shell.resetHostCounter(); s_logger.info("Processed new management server list: " + newMSHosts); } catch (final Exception e) { throw new CloudRuntimeException("Could not persist received management servers list", e); } } if ("shuffle".equals(lbAlgorithm)) { scheduleHostLBCheckerTask(0); } else { scheduleHostLBCheckerTask(_shell.getLbCheckerInterval(lbCheckInterval)); } }
@Test public void testCleanPasswordFromJsonObjectInMiddle() { final String input = "{\"foo\":\"bar\",\"password\":\"test\",\"test\":\"blah\"}"; final String expected = "{\"foo\":\"bar\",\"test\":\"blah\"}"; final String result = StringUtils.cleanString(input); assertEquals(result, expected); }
public static String decodePassword(String encodedPassword) { byte[] encodedPasswordBytes = encodedPassword.getBytes(StringUtils.getPreferredCharset()); byte[] passwordBytes = Base64.decodeBase64(encodedPasswordBytes); return new String(passwordBytes, StringUtils.getPreferredCharset()); }
@Test public void testGetPreferredCharset() { final boolean ifUtf8Supported = StringUtils.isUtf8Supported(); if (ifUtf8Supported) { assertEquals(StringUtils.getPreferredCharset(), Charset.forName("UTF-8")); } else { assertNotEquals(StringUtils.getPreferredCharset(), Charset.forName("UTF-8")); } }
@Override public String getStoragePoolTags(long poolId) { return StringUtils.listToCsvTags(getStoragePoolTagList(poolId)); }
@Test public void testToCSVList() { String input = "one,two,three,four,five,six,seven,eight,nine,ten"; String output = StringUtils.toCSVList(Arrays.asList(input.split(","))); assertTrue(input.equals(output)); } }
protected String determineS3TemplateDirectory(final Long accountId, final Long templateId, final String templateUniqueName) { return join(asList(TEMPLATE_ROOT_DIR, accountId, templateId, templateUniqueName), S3Utils.SEPARATOR); }
public IsolationMethod(String prfx, String prvdr) { methodPrefix = prfx; provider = StringUtils.isNotBlank(prvdr)? prvdr : UNKNOWN_PROVIDER; registeredIsolationMethods.add(this); }
public static String cleanPassword(String logString) { String cleanLogString = null; if (logString != null) { cleanLogString = logString; String[] temp = logString.split(","); int i = 0; if (temp != null) { while (i < temp.length) { temp[i] = StringUtils.cleanString(temp[i]); i++; } List<String> stringList = new ArrayList<String>(); Collections.addAll(stringList, temp); cleanLogString = StringUtils.join(stringList, ","); } } return cleanLogString; } public static HttpClient getHttpClient() {
@Test public void testCleanPasswordFromJsonObjectWithMultiplePasswords() { final String input = "{\"description\":\"foo\"}],\"password\":\"bar\",\"nic\":[{\"password\":\"bar2\",\"id\":\"1\"}]}"; final String expected = "{\"description\":\"foo\"}],\"nic\":[{\"id\":\"1\"}]}"; final String result = StringUtils.cleanString(input); assertEquals(result, expected); }