List of usage examples for org.springframework.util StringUtils arrayToCommaDelimitedString
public static String arrayToCommaDelimitedString(@Nullable Object[] arr)
From source file:org.springframework.validation.DataBinder.java
/** * Register fields that are required for each binding process. * <p>If one of the specified fields is not contained in the list of * incoming property values, a corresponding "missing field" error * will be created, with error code "required" (by the default * binding error processor).// ww w . jav a 2 s . c o m * @param requiredFields array of field names * @see #setBindingErrorProcessor * @see DefaultBindingErrorProcessor#MISSING_FIELD_ERROR_CODE */ public void setRequiredFields(@Nullable String... requiredFields) { this.requiredFields = PropertyAccessorUtils.canonicalPropertyNames(requiredFields); if (logger.isDebugEnabled()) { logger.debug("DataBinder requires binding of required fields [" + StringUtils.arrayToCommaDelimitedString(requiredFields) + "]"); } }
From source file:org.springframework.web.socket.server.DefaultHandshakeHandler.java
protected void handleWebSocketVersionNotSupported(ServerHttpRequest request, ServerHttpResponse response) { logger.debug("WebSocket version not supported " + request.getHeaders().get("Sec-WebSocket-Version")); response.setStatusCode(HttpStatus.UPGRADE_REQUIRED); response.getHeaders()/*from w ww . j a va 2 s.c om*/ .setSecWebSocketVersion(StringUtils.arrayToCommaDelimitedString(getSupportedVerions())); }
From source file:org.springframework.web.socket.server.support.AbstractHandshakeHandler.java
protected void handleWebSocketVersionNotSupported(ServerHttpRequest request, ServerHttpResponse response) { if (logger.isErrorEnabled()) { String version = request.getHeaders().getFirst("Sec-WebSocket-Version"); logger.error("Handshake failed due to unsupported WebSocket version: " + version + ". Supported versions: " + Arrays.toString(getSupportedVersions())); }/*from w w w .j av a 2s .co m*/ response.setStatusCode(HttpStatus.UPGRADE_REQUIRED); response.getHeaders().set(WebSocketHttpHeaders.SEC_WEBSOCKET_VERSION, StringUtils.arrayToCommaDelimitedString(getSupportedVersions())); }
From source file:org.springframework.web.socket.server.support.DefaultHandshakeHandler.java
protected void handleWebSocketVersionNotSupported(ServerHttpRequest request, ServerHttpResponse response) { if (logger.isErrorEnabled()) { String version = request.getHeaders().getFirst("Sec-WebSocket-Version"); logger.error("Handshake failed due to unsupported WebSocket version: " + version + ". Supported versions: " + Arrays.toString(getSupportedVersions())); }/*www . j a va 2 s . c o m*/ response.setStatusCode(HttpStatus.UPGRADE_REQUIRED); response.getHeaders().put(WebSocketHttpHeaders.SEC_WEBSOCKET_VERSION, Arrays.asList(StringUtils.arrayToCommaDelimitedString(getSupportedVersions()))); }
From source file:org.springframework.ws.soap.saaj.SaajSoapMessageFactory.java
public SaajSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException { MimeHeaders mimeHeaders = parseMimeHeaders(inputStream); try {//from w w w.j a v a2 s. com inputStream = checkForUtf8ByteOrderMark(inputStream); SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); } catch (SOAPException ex) { // SAAJ 1.3 RI has a issue with handling multipart XOP content types which contain "startinfo" rather than // "start-info", so let's try and do something about it String contentType = StringUtils .arrayToCommaDelimitedString(mimeHeaders.getHeader(TransportConstants.HEADER_CONTENT_TYPE)); if (contentType.contains("startinfo")) { contentType = contentType.replace("startinfo", "start-info"); mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType); try { SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString); } catch (SOAPException e) { // fall-through } } throw new SoapMessageCreationException("Could not create message from InputStream: " + ex.getMessage(), ex); } catch (SaajSoapEnvelopeException ex) { SAXParseException parseException = getSAXParseException(ex); if (parseException != null) { throw new InvalidXmlException("Could not parse XML", parseException); } else { throw ex; } } }
From source file:org.springframework.xd.gemfire.LoggingCacheListener.java
public LoggingCacheListener(String level) { try {/* ww w . j a v a 2 s .c o m*/ this.level = Level.valueOf(level.toUpperCase()); } catch (IllegalArgumentException e) { throw new IllegalArgumentException( "Invalid log level '" + level + "'. The (case-insensitive) supported values are: " + StringUtils.arrayToCommaDelimitedString(Level.values())); } }
From source file:org.springframework.xd.module.options.FlattenedCompositeModuleOptionsMetadata.java
@Override public ModuleOptions interpolate(Map<String, String> raw) throws BindException { @SuppressWarnings("serial") Map<ModuleOptionsMetadata, Map<String, String>> distributed = new HashMap<ModuleOptionsMetadata, Map<String, String>>() { @Override// w w w . jav a2s . co m public Map<String, String> get(Object key) { Map<String, String> result = super.get(key); if (result == null) { result = new HashMap<String, String>(); this.put((ModuleOptionsMetadata) key, result); } return result; } }; Map<String, String> copy = new HashMap<String, String>(raw); // First, distribute raw input values to their corresponding MOM for (String key : raw.keySet()) { for (ModuleOptionsMetadata mom : momToSupportedOptions.keySet()) { Set<String> optionNames = momToSupportedOptions.get(mom); if (optionNames.contains(key)) { distributed.get(mom).put(key, copy.remove(key)); break; } } } if (copy.size() > 0) { // We're just interested in a container for errors BindingResult bindingResult = new MapBindingResult(new HashMap<String, Object>(), "flattened"); for (String pty : copy.keySet()) { bindingResult.addError( new FieldError("flattened", pty, String.format("option named '%s' is not supported", pty))); } throw new BindException(bindingResult); } // Then, interpolate per-MOM and remember which MOM is responsible for which exposed value // TODO: should be multimap, as several MOMs could expose the same value final Map<String, ModuleOptions> nameToOptions = new HashMap<String, ModuleOptions>(); for (ModuleOptionsMetadata mom : momToSupportedOptions.keySet()) { Map<String, String> rawValuesSubset = distributed.get(mom); ModuleOptions mo = mom.interpolate(rawValuesSubset); EnumerablePropertySource<?> propertySource = mo.asPropertySource(); for (String optionName : propertySource.getPropertyNames()) { /* * XD-1472: InputType treated as a special case. If the module defines a default value, do not replace * it with a null value (the global default) */ if (optionName.equals(INPUT_TYPE)) { if (propertySource.getProperty(optionName) != null) { nameToOptions.put(optionName, mo); } } else { nameToOptions.put(optionName, mo); } } } final Set<ModuleOptions> uniqueModuleOptions = new HashSet<ModuleOptions>(nameToOptions.values()); return new ModuleOptions() { @Override public EnumerablePropertySource<FlattenedCompositeModuleOptionsMetadata> asPropertySource() { String psName = String.format("flattened-%d", System.identityHashCode(FlattenedCompositeModuleOptionsMetadata.this)); return new EnumerablePropertySource<FlattenedCompositeModuleOptionsMetadata>(psName, FlattenedCompositeModuleOptionsMetadata.this) { @Override public String[] getPropertyNames() { String[] result = nameToOptions.keySet().toArray(new String[nameToOptions.keySet().size()]); FlattenedCompositeModuleOptionsMetadata.logger.debug(String.format( "returning propertyNames: %s", StringUtils.arrayToCommaDelimitedString(result))); return result; } @Override public Object getProperty(String name) { ModuleOptions moduleOptions = nameToOptions.get(name); return moduleOptions == null ? null : moduleOptions.asPropertySource().getProperty(name); } }; } @Override public String[] profilesToActivate() { List<String> result = new ArrayList<String>(); for (ModuleOptions delegate : uniqueModuleOptions) { result.addAll(Arrays.asList(delegate.profilesToActivate())); } return result.toArray(new String[result.size()]); } @Override public void validate() { for (ModuleOptions delegate : uniqueModuleOptions) { delegate.validate(); } } }; }
From source file:org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection.java
public void afterPropertiesSet() throws IOException { Assert.notEmpty(xsdResources, "'xsds' must not be empty"); schemaCollection.setSchemaResolver(uriResolver); Set<XmlSchema> processedIncludes = new HashSet<XmlSchema>(); Set<XmlSchema> processedImports = new HashSet<XmlSchema>(); for (Resource xsdResource : xsdResources) { Assert.isTrue(xsdResource.exists(), xsdResource + " does not exit"); try {/*from w w w. j av a2 s . c om*/ XmlSchema xmlSchema = schemaCollection.read(SaxUtils.createInputSource(xsdResource)); xmlSchemas.add(xmlSchema); if (inline) { inlineIncludes(xmlSchema, processedIncludes, processedImports); findImports(xmlSchema, processedImports, processedIncludes); } } catch (Exception ex) { throw new CommonsXsdSchemaException("Schema [" + xsdResource + "] could not be loaded", ex); } } if (logger.isInfoEnabled()) { logger.info("Loaded " + StringUtils.arrayToCommaDelimitedString(xsdResources)); } }
From source file:org.springframework.yarn.am.CommandLineAppmasterRunner.java
@Override protected ExitStatus handleBeanRun(YarnAppmaster bean, String[] parameters, Set<String> opts) { Properties properties = StringUtils.splitArrayElementsIntoProperties(parameters, "="); bean.setParameters(properties != null ? properties : new Properties()); bean.setEnvironment(System.getenv()); if (log.isDebugEnabled()) { log.debug("Starting YarnAppmaster bean: " + StringUtils.arrayToCommaDelimitedString(parameters)); }/* w w w .java 2s .com*/ bean.addAppmasterStateListener(new AppmasterStateListener() { @Override public void state(AppmasterState state) { if (state == AppmasterState.COMPLETED) { latch.countDown(); } } }); bean.submitApplication(); if (log.isDebugEnabled()) { log.debug("Waiting latch to receive appmaster complete state"); } try { latch.await(); } catch (InterruptedException e) { log.debug("Latch interrupted"); } log.info("Bean run completed"); return ExitStatus.COMPLETED; }
From source file:org.springframework.yarn.batch.partition.HdfsSplitBatchPartitionHandler.java
@Override protected Map<StepExecution, ContainerRequestHint> createResourceRequestData(Set<StepExecution> stepExecutions) throws Exception { Map<StepExecution, ContainerRequestHint> requests = new HashMap<StepExecution, ContainerRequestHint>(); for (StepExecution execution : stepExecutions) { String fileName = execution.getExecutionContext().getString("fileName"); long splitStart = execution.getExecutionContext().getLong("splitStart"); long splitLength = execution.getExecutionContext().getLong("splitLength"); log.debug("Creating request data for stepExecution=" + execution + " with fileName=" + fileName + " splitStart=" + splitStart + " splitLength=" + splitLength); FileSystem fs = FileSystem.get(configuration); Path path = new Path(execution.getExecutionContext().getString("fileName")); HashSet<String> hostsSet = new HashSet<String>(); BlockLocation[] fileBlockLocations = fs.getFileBlockLocations(path, splitStart, splitLength); for (BlockLocation blockLocation : fileBlockLocations) { for (String host : blockLocation.getHosts()) { hostsSet.add(host);/*from w ww .j a va 2 s . c om*/ } log.debug("block: " + blockLocation + " topologypaths=" + StringUtils.arrayToCommaDelimitedString(blockLocation.getTopologyPaths())); } String[] hosts = hostsSet.toArray(new String[0]); String[] racks = new String[0]; // hints only for hosts requests.put(execution, new ContainerRequestHint(execution, null, hosts, racks, null)); } return requests; }