/** * Returns a String containing the string representation of all elements from * the given collection, separated by the separator string. * * @param collection The collection * @param sep The separator string * @return A string: elem(0) + sep + ... + elem(N) */ public static String mkString(Collection<?> collection, String sep) { return mkString(collection, "", sep, ""); }
public String getZooKeepersConnectionSpec() { return CollectionUtil.mkString(getZooKeepers(), ","); }
/** * @param xmlLines XML with " replaced with ' */ public static Element parse(String... xmlLines) { List<String> lines = new ArrayList<>(); lines.add("<?xml version='1.0' encoding='utf-8' ?>"); lines.addAll(Arrays.asList(xmlLines)); try { return XmlHelper.getDocumentBuilder().parse( inputSource((CollectionUtil.mkString(lines, "\n").replace("'", "\"")))) .getDocumentElement(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void validate(VespaModel model, DeployState deployState) { if (! deployState.isHosted()) return; if (! deployState.zone().environment().isProduction()) return; if (model.getAdmin().getApplicationType() != ApplicationType.DEFAULT) return; List<String> offendingClusters = new ArrayList<>(); for (ContainerCluster cluster : model.getContainerClusters().values()) { if (cluster.getHttp() == null || ! cluster.getHttp().getAccessControl().isPresent() || ! cluster.getHttp().getAccessControl().get().writeEnabled) if (hasHandlerThatNeedsProtection(cluster) || ! cluster.getAllServlets().isEmpty()) offendingClusters.add(cluster.getName()); } if (! offendingClusters.isEmpty()) throw new IllegalArgumentException( "Access-control must be enabled for write operations to container clusters in production zones: " + mkString(offendingClusters, "[", ", ", "].")); }