private String calcEtag(Username username, List<GoDashboardPipelineGroup> pipelineGroups, List<GoDashboardEnvironment> environments) { final String pipelineSegment = pipelineGroups.stream(). map(GoDashboardPipelineGroup::etag).collect(Collectors.joining(SEP_CHAR)); final String environmentSegment = environments.stream(). map(GoDashboardEnvironment::etag).collect(Collectors.joining(SEP_CHAR)); return DigestUtils.md5Hex(StringUtils.joinWith(SEP_CHAR, username.getUsername(), pipelineSegment, environmentSegment)); }
private String calcEtag(Username username, List<GoDashboardPipelineGroup> pipelineGroups, List<GoDashboardEnvironment> environments) { final String pipelineSegment = pipelineGroups.stream(). map(GoDashboardPipelineGroup::etag).collect(Collectors.joining(SEP_CHAR)); final String environmentSegment = environments.stream(). map(GoDashboardEnvironment::etag).collect(Collectors.joining(SEP_CHAR)); return DigestUtils.md5Hex(StringUtils.joinWith(SEP_CHAR, username.getUsername(), pipelineSegment, environmentSegment)); }
private String calcPipelinesDataEtag(Username username, List<PipelineConfigs> pipelineConfigs) { final HashMap<String, List<CaseInsensitiveString>> pipelinesDataSegment = new HashMap<>(); for (PipelineConfigs group : pipelineConfigs) { final List<PipelineConfig> pipelines = group.getPipelines(); if (!pipelines.isEmpty()) { List<CaseInsensitiveString> pipelineNames = pipelines.stream().map(PipelineConfig::name).collect(Collectors.toList()); pipelinesDataSegment.put(group.getGroup(), pipelineNames); } } return DigestUtils.md5Hex(StringUtils.joinWith("/", username.getUsername(), pipelinesDataSegment)); } }
public static String getSparkEnvAppId() { // Do not use "org.apache.spark.SparkEnv" directly because the maven shade plugin will convert // the class name to ja_shaded.org.apache.spark.SparkEnv due to relocation. String className = org.apache.commons.lang3.StringUtils.joinWith( ".", "org", "apache", "spark", "SparkEnv"); try { Object result = ReflectionUtils.executeStaticMethods( className, "get.conf.getSparkEnvAppId"); if (result == null) { return null; } return result.toString(); } catch (Throwable e) { return null; } }
@Test(expected = IllegalArgumentException.class) public void testJoinWithThrowsException() { StringUtils.joinWith(",", (Object[]) null); }
@Test public void testJoinWith() { assertEquals("", StringUtils.joinWith(",")); // empty array assertEquals("", StringUtils.joinWith(",", (Object[]) NULL_ARRAY_LIST)); assertEquals("null", StringUtils.joinWith(",", NULL_TO_STRING_LIST)); //toString method prints 'null' assertEquals("a,b,c", StringUtils.joinWith(",", "a", "b", "c")); assertEquals(",a,", StringUtils.joinWith(",", null, "a", "")); assertEquals("ab", StringUtils.joinWith(null, "a", "b")); }
private static String getMessage(Collection<String> displayMessageList) { if (CollectionUtil.isEmpty(displayMessageList)) { return ""; } return StringUtils.joinWith("\n", displayMessageList.toArray()); }
private static String getMessage(List<String> displayMessageList) { if (CollectionUtil.isEmpty(displayMessageList)) { return ""; } return StringUtils.joinWith("\n", displayMessageList.toArray()); }
@Override protected String getSourcePath() { return StringUtils.joinWith(File.pathSeparator, StringUtils.join(this.project.getCompileSourceRoots(), File.pathSeparatorChar), StringUtils.join(this.project.getTestCompileSourceRoots(), File.pathSeparatorChar) ); }
@Override protected String getSourcePath() { return StringUtils.joinWith(File.pathSeparator, StringUtils.join(this.project.getCompileSourceRoots(), File.pathSeparatorChar), StringUtils.join(this.project.getTestCompileSourceRoots(), File.pathSeparatorChar) ); }
private void adapt() { List<String> wk = new ArrayList<>(); JSONObject ret = new JSONObject(); JSONObject fbData = JSON.parseObject(value); for(String key : fbData.keySet()) { if(fbData.get(key) instanceof JSONObject) { JSONObject subJbValue = ((JSONObject) fbData.get(key)); for(String jbKey : subJbValue.keySet()) { ret.put(StringUtils.joinWith(".", key, jbKey), subJbValue.get(jbKey)); } } else { ret.put(key, fbData.get(key)); } } wk.add(ret.toJSONString()); it = wk.iterator(); }
private static void injectSourcePropertiesAsInputs(PaaSNodeTemplate source, Map<String, Interface> interfaces) { // input name: SOURCE_<propertyName> injectPropertiesAsInputs(ToscaFunctionConstants.SOURCE, null, source.getTemplate().getProperties(), interfaces, baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.SOURCE, baseName)); }
private static void injectCapabilitiesProperties(NodeTemplate template, Map<String, Interface> interfaces) { if (template.getCapabilities() == null) { return; } template.getCapabilities().forEach((capabilityName, capability) -> { // input name: CAPABILITIES_<capabilityName>_<propertyName> injectPropertiesAsInputs(ToscaFunctionConstants.SELF, capabilityName, capability.getProperties(), interfaces, baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.SELF, CAPABILITIES, capabilityName, baseName)); }); }
private static void injectTargetPropertiesAsInputs(PaaSNodeTemplate target, Map<String, Interface> interfaces) { // input name: TARGET_<propertyName> injectPropertiesAsInputs(ToscaFunctionConstants.TARGET, null, target.getTemplate().getProperties(), interfaces, baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.TARGET, baseName)); }
private static void injectTargetedCapabilityProperties(PaaSNodeTemplate target, String capabilityName, Map<String, Interface> interfaces) { if (target.getTemplate().getCapabilities() != null && target.getTemplate().getCapabilities().containsKey(capabilityName)) { Capability capability = target.getTemplate().getCapabilities().get(capabilityName); // input name: TARGET_CAPABILITIES_<capabilityName>_<propertyName> injectPropertiesAsInputs(ToscaFunctionConstants.TARGET, capabilityName, capability.getProperties(), interfaces, baseName -> StringUtils .joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.TARGET, CAPABILITIES, capabilityName, baseName)); } }
baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.SELF, baseName));
/** * Inject node template and capabilities properties as input parameters for all its interfaces operations <br> * The injected input names are uppercased and is in form: * <ul> * <li>{@code SELF_<PROPERTY_NAME>} for node property * <li>{@code SELF_CAPABILITIES_<CAPABILITY_NAME>_<PROPERTY_NAME>} for capability property * </ul> * In case of name conflict, the overriding order is: (--> = overrides) * * <pre> * declared input --> node property input --> capability property input * </pre> * * @param paaSTemplate The {@link PaaSNodeTemplate} to process */ public static void processNodeTemplateProperties(PaaSNodeTemplate paaSTemplate) { NodeTemplate template = paaSTemplate.getTemplate(); // inject nodetemplate properties if (MapUtils.isNotEmpty(template.getProperties())) { injectPropertiesAsInputs(ToscaFunctionConstants.SELF, null, template.getProperties(), paaSTemplate.getInterfaces(), baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.SELF, baseName)); } // inject capabilities properties injectCapabilitiesProperties(template, paaSTemplate.getInterfaces()); }