public static StringBuilder buildMysqlUpdateSql(final String joins, final Collection<Ternary<Attribute, Boolean, Object>> setters) { if (setters.size() == 0) { return null; } final StringBuilder sql = new StringBuilder("UPDATE "); sql.append(joins); sql.append(" SET "); for (final Ternary<Attribute, Boolean, Object> setter : setters) { final Attribute attr = setter.first(); sql.append(attr.table).append(".").append(attr.columnName).append("="); if (setter.second() != null) { sql.append(attr.table).append(".").append(attr.columnName).append(setter.second() ? "+" : "-"); } sql.append("?, "); } sql.delete(sql.length() - 2, sql.length()); sql.append(" WHERE "); return sql; }
public static byte[] buildAndSaveKeystore(final List<Ternary<String, String, String>> certs, final String storePassword) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, InvalidKeySpecException { final KeyStore ks = KeyStore.getInstance("JKS"); ks.load(null, storePassword != null ? storePassword.toCharArray() : null); //name,cert,key for (final Ternary<String, String, String> cert : certs) { if (cert.third() == null) { final Certificate c = buildCertificate(cert.second()); ks.setCertificateEntry(cert.first(), c); } else { final Certificate[] c = new Certificate[certs.size()]; int i = certs.size(); for (final Ternary<String, String, String> ct : certs) { c[i - 1] = buildCertificate(ct.second()); i--; } ks.setKeyEntry(cert.first(), buildPrivateKey(cert.third()), storePassword != null ? storePassword.toCharArray() : null, c); } } final ByteArrayOutputStream os = new ByteArrayOutputStream(); ks.store(os, storePassword != null ? storePassword.toCharArray() : null); os.close(); return os.toByteArray(); }
_mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal(), this.getKeyword()); result = hostsForMigration.first(); final List<? extends Host> hostsWithCapacity = hostsForMigration.second(); hostsRequiringStorageMotion = hostsForMigration.third();
@Override public void execute() { ListResponse<HostResponse> response = null; if (getVirtualMachineId() == null) { response = _queryService.searchForServers(this); } else { final Pair<List<? extends Host>, Integer> result; final Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Host, Boolean>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(), getStartIndex(), getPageSizeVal(), null); result = hostsForMigration.first(); final List<? extends Host> hostsWithCapacity = hostsForMigration.second(); response = new ListResponse<>(); final List<HostResponse> hostResponses = new ArrayList<>(); for (final Host host : result.first()) { final HostResponse hostResponse = _responseGenerator.createHostResponse(host, getDetails()); Boolean suitableForMigration = false; if (hostsWithCapacity.contains(host)) { suitableForMigration = true; } hostResponse.setSuitableForMigration(suitableForMigration); hostResponse.setObjectName("host"); hostResponses.add(hostResponse); } response.setResponses(hostResponses, result.second()); } response.setResponseName(getCommandName()); setResponseObject(response); }