List of usage examples for org.springframework.util StringUtils arrayToCommaDelimitedString
public static String arrayToCommaDelimitedString(@Nullable Object[] arr)
From source file:ch.nydi.spring.context.support.PrimaryResolverListableBeanFactory.java
@Override public <T> T getBean(Class<T> requiredType) throws BeansException { Assert.notNull(requiredType, "Required type must not be null"); String[] beanNames = getBeanNamesForType(requiredType); String primaryCandidate = null; if (beanNames.length > 1) { final ArrayList<String> autowireCandidates = new ArrayList<String>(); for (final String beanName : beanNames) { final BeanDefinition beanDefinition = getBeanDefinition(beanName); if (beanDefinition.isAutowireCandidate()) { autowireCandidates.add(beanName); if (beanDefinition.isPrimary()) { primaryCandidate = beanName; }/*from w w w . j av a 2 s . c om*/ } } if (autowireCandidates.size() > 0) { beanNames = autowireCandidates.toArray(new String[autowireCandidates.size()]); } } if (beanNames.length == 1) { return getBean(beanNames[0], requiredType); } else if (beanNames.length > 1) { // more than one bean defined, lookup primary candidate if (primaryCandidate != null) { return getBean(primaryCandidate, requiredType); } throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found " + beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames)); } else if (beanNames.length == 0 && getParentBeanFactory() != null) { return getParentBeanFactory().getBean(requiredType); } else { throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found " + beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames)); } }
From source file:net.easysmarthouse.service.context.ProxiedResolverGenericXmlApplicationContext.java
@Override public <T extends Object> T getBean(Class<T> requiredType) throws BeansException { Assert.notNull(requiredType, "Required type must not be null"); String[] beanNames = getBeanNamesForType(requiredType); String primaryCandidate = null; if (beanNames.length > 1) { ArrayList<String> autowireCandidates = new ArrayList<String>(); for (String beanName : beanNames) { BeanDefinition beanDefinition = getBeanDefinition(beanName); if (beanDefinition.isAutowireCandidate()) { autowireCandidates.add(beanName); if (beanDefinition.isPrimary()) { primaryCandidate = beanName; }//from w ww .j av a 2 s . c om } } for (String autowireCandidate : autowireCandidates) { if (autowireCandidates.contains(autowireCandidate + "Proxied")) { primaryCandidate = autowireCandidate; } } if (autowireCandidates.size() > 0) { beanNames = autowireCandidates.toArray(new String[autowireCandidates.size()]); } } if (beanNames.length == 1) { return getBean(beanNames[0], requiredType); } else if (beanNames.length > 1) { // more than one bean defined, lookup primary candidate if (primaryCandidate != null) { return getBean(primaryCandidate, requiredType); } throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found " + beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames)); } else if (beanNames.length == 0 && getParentBeanFactory() != null) { return getParentBeanFactory().getBean(requiredType); } else { throw new NoSuchBeanDefinitionException(requiredType, "expected single bean but found " + beanNames.length + ": " + StringUtils.arrayToCommaDelimitedString(beanNames)); } }
From source file:eu.europeana.uim.sugarcrmclient.internal.ExtendedSaajSoapMessageFactory.java
public SaajSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException { MimeHeaders mimeHeaders = parseMimeHeaders(inputStream); try {/*from ww w . jav a 2 s . c o m*/ inputStream = checkForUtf8ByteOrderMark(inputStream); inputStream = decompressStream((PushbackInputStream) inputStream); return new SaajSoapMessage(getMessageFactory().createMessage(mimeHeaders, inputStream)); } 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.indexOf("startinfo") != -1) { contentType = contentType.replace("startinfo", "start-info"); mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType); try { return new SaajSoapMessage(getMessageFactory().createMessage(mimeHeaders, inputStream), true); } catch (SOAPException e) { // fall-through } } throw new SoapMessageCreationException("Could not create message from InputStream: " + ex.getMessage(), ex); } }
From source file:com.consol.citrus.simulator.servlet.SimulatorStatusServlet.java
@Override public void onTestFinish(TestCase test) { runningTests.remove(StringUtils.arrayToCommaDelimitedString(test.getParameters())); }
From source file:org.springmodules.validation.commons.DefaultValidatorFactory.java
/** * Sets the locations of the validation configuration files from which to load validation rules. Creates an instance * of <code>ValidatorResources</code> from the specified configuration files. * * @see org.springframework.core.io.Resource * @see ValidatorResources/*from ww w .j av a 2 s .com*/ */ public void setValidationConfigLocations(Resource[] validationConfigLocations) { if (DefaultValidatorFactory.log.isInfoEnabled()) { DefaultValidatorFactory.log.info("Loading validation configurations from [" + StringUtils.arrayToCommaDelimitedString(validationConfigLocations) + "]"); } try { InputStream[] inputStreams = new InputStream[validationConfigLocations.length]; for (int i = 0; i < inputStreams.length; i++) { inputStreams[i] = validationConfigLocations[i].getInputStream(); } this.validatorResources = new ValidatorResources(inputStreams); } catch (IOException e) { throw new FatalBeanException("Unable to read validation configuration due to IOException.", e); } catch (SAXException e) { throw new FatalBeanException("Unable to parse validation configuration XML", e); } }
From source file:com.mum.controller.ProductController.java
@RequestMapping(value = "products/add", method = RequestMethod.POST) public String processAddNewProductForm(@ModelAttribute("newProduct") Product product, BindingResult result, HttpServletRequest request, HttpServletResponse response) { MultipartFile productImage = product.getProductImage(); String rootDirectory = request.getSession().getServletContext().getRealPath("/../../../"); if (productImage != null && !productImage.isEmpty()) { try {/*from w w w . ja v a2 s . c om*/ productImage.transferTo( new File(rootDirectory + "\\images\\" + productImage.getOriginalFilename() + ".png")); } catch (Exception e) { throw new RuntimeException("Product Image saving failed", e); } } String[] suppressedFields = result.getSuppressedFields(); if (suppressedFields.length > 0) { throw new RuntimeException("Attempting to bind disallowed fields:" + StringUtils.arrayToCommaDelimitedString(suppressedFields)); } productService.addProduct(product); //return "redirect:/products/add"; //return "redirect:/products"; return ""; }
From source file:com.artivisi.belajar.restful.ui.controller.HomepageController.java
@RequestMapping("/homepage/appinfo") @ResponseBody/*from w w w . j av a 2 s . c om*/ public Map<String, String> appInfo(HttpServletRequest request) { ApplicationContext ctx = WebApplicationContextUtils .getWebApplicationContext(request.getSession().getServletContext()); Map<String, String> hasil = new HashMap<String, String>(); hasil.put("profileDefault", StringUtils.arrayToCommaDelimitedString(ctx.getEnvironment().getDefaultProfiles())); hasil.put("profileActive", StringUtils.arrayToCommaDelimitedString(ctx.getEnvironment().getActiveProfiles())); hasil.put("namaAplikasi", messageSource.getMessage("app.name", null, "undefined", null)); hasil.put("versiAplikasi", messageSource.getMessage("app.version", null, "x.x.x", null)); return hasil; }
From source file:ro.raisercostin.web.DebuggingFilter.java
public String debug(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, DebuggingPrinter debuggingPrinter, boolean debugAll, boolean debugRequest) { final JspFactory jspFactory = JspFactory.getDefaultFactory(); HttpSession session = request.getSession(); debuggingPrinter.addHeader();//from w w w . j a v a 2 s. co m debuggingPrinter.addSection("Request Parameters"); for (Iterator iterator = request.getParameterMap().entrySet().iterator(); iterator.hasNext();) { Map.Entry<String, Object> parameter = (Map.Entry<String, Object>) iterator.next(); addRow(debuggingPrinter, parameter.getKey(), StringUtils.arrayToCommaDelimitedString((Object[]) parameter.getValue())); } debuggingPrinter.endSection(); if (debugRequest) { debuggingPrinter.addSection("Request Header"); for (Enumeration e = request.getHeaderNames(); e.hasMoreElements();) { String parameterName = (String) e.nextElement(); addRow(debuggingPrinter, parameterName, debuggingPrinter.transform(request.getHeader(parameterName))); } debuggingPrinter.endSection(); debuggingPrinter.addSection("Request Attributes"); java.util.Enumeration en = request.getAttributeNames(); while (en.hasMoreElements()) { String attrName = (String) en.nextElement(); try { addRow(debuggingPrinter, split(attrName, 50), toString2(request.getAttribute(attrName), 120)); } catch (Exception e) { addRow(debuggingPrinter, split(attrName, 50), toString(e, 120)); } } debuggingPrinter.endSection(); debuggingPrinter.addSection("Session Attributes"); en = session.getAttributeNames(); while (en.hasMoreElements()) { String attrName = (String) en.nextElement(); try { addRow(debuggingPrinter, split(attrName, 50), toString2(session.getAttribute(attrName), 120)); } catch (Exception e) { addRow(debuggingPrinter, split(attrName, 50), toString(e, 120)); } } debuggingPrinter.endSection(); debuggingPrinter.addSection("Request Info"); addRow(debuggingPrinter, "AuthType", request.getAuthType()); addRow(debuggingPrinter, "ContextPath", request.getContextPath()); addRow(debuggingPrinter, "Method", request.getMethod()); addRow(debuggingPrinter, "PathInfo", request.getPathInfo()); addRow(debuggingPrinter, "PathTranslated", request.getPathTranslated()); addRow(debuggingPrinter, "Protocol", request.getProtocol()); addRow(debuggingPrinter, "QueryString", request.getQueryString()); addRow(debuggingPrinter, "RemoteAddr", request.getRemoteAddr()); addRow(debuggingPrinter, "RemoteUser", request.getRemoteUser()); addRow(debuggingPrinter, "RequestedSessionId", request.getRequestedSessionId()); addRow(debuggingPrinter, "RequestURI", request.getRequestURI()); addRow(debuggingPrinter, "RequestURL", request.getRequestURL().toString()); addRow(debuggingPrinter, "ServletPath", request.getServletPath()); addRow(debuggingPrinter, "Scheme", request.getScheme()); addRow(debuggingPrinter, "ServletPath", request.getServletPath()); } if (debugAll) { debuggingPrinter.addSection("Server"); addRow(debuggingPrinter, "Server Info", servletContext.getServerInfo()); addRow(debuggingPrinter, "Servlet Engine Version", servletContext.getMajorVersion() + "." + servletContext.getMinorVersion()); addRow(debuggingPrinter, "JSP Version", jspFactory.getEngineInfo().getSpecificationVersion()); debuggingPrinter.endSection(); debuggingPrinter.addSection("JVM Properties"); for (Enumeration e = System.getProperties().propertyNames(); e.hasMoreElements();) { String parameterName = (String) e.nextElement(); addRow(debuggingPrinter, parameterName, debuggingPrinter.transform(System.getProperty(parameterName))); } debuggingPrinter.endSection(); debuggingPrinter.addSection("Environment"); for (Map.Entry<String, String> property : System.getenv().entrySet()) { addRow(debuggingPrinter, property.getKey(), debuggingPrinter.transform(property.getValue())); } debuggingPrinter.endSection(); debuggingPrinter.addSection("Debugger Provided by"); addRow(debuggingPrinter, "provided by", "raisercostin"); debuggingPrinter.addRow("source", "<a target='_blank' href='http://code.google.com/p/raisercostin/wiki/DebuggingFilter'>http://code.google.com/p/raisercostin/wiki/DebuggingFilter</a>"); addRow(debuggingPrinter, "version", "1.0"); addRow(debuggingPrinter, "timestamp", "2008.June.14"); addRow(debuggingPrinter, "license", "<a target='_blank' href='http://www.apache.org/licenses/LICENSE-2.0.html'>Apache License 2.0</a>"); debuggingPrinter.endSection(); } debuggingPrinter.addFooter(); return debuggingPrinter.getString(); }
From source file:com.consol.citrus.simulator.servlet.SimulatorStatusServlet.java
@Override public void onTestActionStart(TestCase testCase, TestAction testAction) { if (!testAction.getClass().equals(SleepAction.class)) { LOG.debug(testCase.getName() + "(" + StringUtils.arrayToCommaDelimitedString(testCase.getParameters()) + ") - " + testAction.getName() + ": " + (StringUtils.hasText(testAction.getDescription()) ? testAction.getDescription() : "")); }// w w w . j a v a 2 s .c o m }
From source file:org.appverse.web.framework.backend.frontfacade.mvc.swagger.controller.SwaggerOAuth2Controller.java
private Map<String, String> convertParameters(Map<String, String[]> map) { Map<String, String> data = new HashMap<String, String>(); if (map != null) { for (Map.Entry<String, String[]> entry : map.entrySet()) { data.put(entry.getKey(), StringUtils.arrayToCommaDelimitedString(entry.getValue())); }//from w w w .j av a 2 s . com } return data; }