List of usage examples for org.apache.commons.lang StringUtils repeat
public static String repeat(String str, int repeat)
Repeat a String repeat
times to form a new String.
From source file:nl.cyso.vcloud.client.Formatter.java
private static void printBordered(Object msg, boolean error) { String[] lines = msg.toString().split("\n"); int longest = 0; for (String line : lines) { if (line.length() > longest) { longest = line.length();/*w ww .ja va 2s . co m*/ } } if (error) { Formatter.printErrorLine(StringUtils.repeat("-", longest)); Formatter.printError(msg); Formatter.printErrorLine(StringUtils.repeat("-", longest)); } else { Formatter.printInfoLine(StringUtils.repeat("-", longest)); Formatter.printInfo(msg); Formatter.printInfoLine(StringUtils.repeat("-", longest)); } }
From source file:nl.cyso.vsphere.client.docs.Readme.java
private String getNameSection() { StringBuilder section = new StringBuilder(); String header = String.format("%s - a tool to manage vSphere datacenter objects\n", Version.getVersion().getProjectName()); section.append(header);// w ww .jav a 2s .c o m section.append(StringUtils.repeat("-", header.length()) + "\n\n"); return section.toString(); }
From source file:nl.nn.adapterframework.extensions.esb.EsbUtils.java
private static PoolingConnectionFactory setupJmsConnectionFactory(String url, String userName, String password) {//from w w w . j a v a 2 s . co m String serverUrl = StringUtils.replace(url, "tibjmsnaming:", "tcp:"); log.debug("setting up JmsConnectionFactory url [" + serverUrl + "] username [" + userName + "] password [" + StringUtils.repeat("*", password.length()) + "]"); PoolingConnectionFactory jmsConnectionFactory = new PoolingConnectionFactory(); jmsConnectionFactory.setClassName("com.tibco.tibjms.TibjmsXAConnectionFactory"); jmsConnectionFactory.setUniqueName("tibcojms"); jmsConnectionFactory.setMaxPoolSize(5); jmsConnectionFactory.setAllowLocalTransactions(true); jmsConnectionFactory.setUser(userName); jmsConnectionFactory.setPassword(password); jmsConnectionFactory.getDriverProperties().setProperty("serverUrl", serverUrl); jmsConnectionFactory.init(); return jmsConnectionFactory; }
From source file:nl.nn.adapterframework.extensions.esb.EsbUtils.java
private static PoolingDataSource setupJdbcDataSource(String url, String userName, String password) { log.debug("setting up JdbcDataSource url [" + url + "] username [" + userName + "] password [" + StringUtils.repeat("*", password.length()) + "]"); PoolingDataSource jdbcDataSource = new PoolingDataSource(); jdbcDataSource.setClassName("oracle.jdbc.xa.client.OracleXADataSource"); jdbcDataSource.setUniqueName("oracle"); jdbcDataSource.setMaxPoolSize(5);/*w ww. j av a 2 s. c om*/ jdbcDataSource.setAllowLocalTransactions(true); // jdbcDataSource.setTestQuery("SELECT 1 FROM DUAL"); jdbcDataSource.getDriverProperties().setProperty("user", userName); jdbcDataSource.getDriverProperties().setProperty("password", password); jdbcDataSource.getDriverProperties().setProperty("URL", url); jdbcDataSource.init(); return jdbcDataSource; }
From source file:nl.nn.adapterframework.pipes.CreateRestViewPipe.java
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException { HttpServletRequest httpServletRequest = (HttpServletRequest) session.get("restListenerServletRequest"); String requestURL = httpServletRequest.getRequestURL().toString(); String servletPath = httpServletRequest.getServletPath(); String uri = StringUtils.substringAfter(requestURL, servletPath); int countSrcPrefix = StringUtils.countMatches(uri, "/"); String srcPrefix = StringUtils.repeat("../", countSrcPrefix); session.put(SRCPREFIX, srcPrefix);//from w ww. j a v a2s . co m log.debug(getLogPrefix(session) + "stored [" + srcPrefix + "] in pipeLineSession under key [" + SRCPREFIX + "]"); PipeRunResult prr = super.doPipe(input, session); String result = (String) prr.getResult(); log.debug("transforming page [" + result + "] to view"); String newResult = null; ServletContext servletContext = (ServletContext) session.get("restListenerServletContext"); try { Map parameters = retrieveParameters(httpServletRequest, servletContext, srcPrefix); newResult = XmlUtils.getAdapterSite(result, parameters); } catch (Exception e) { throw new PipeRunException(this, getLogPrefix(session) + " Exception on transforming page to view", e); } session.put(CONTENTTYPE, getContentType()); log.debug(getLogPrefix(session) + "stored [" + getContentType() + "] in pipeLineSession under key [" + CONTENTTYPE + "]"); return new PipeRunResult(getForward(), newResult); }
From source file:nl.nn.adapterframework.util.Misc.java
public static String hide(String string) { return StringUtils.repeat("*", string.length()); }
From source file:nl.nn.adapterframework.util.Misc.java
public static String hideAll(String inputString, String regex, int mode) { StringBuilder result = new StringBuilder(); Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(inputString); int previous = 0; while (matcher.find()) { result.append(inputString.substring(previous, matcher.start())); int len = matcher.end() - matcher.start(); if (mode == 1) { int lenFirstHalf = (int) Math.ceil((double) len / 2); result.append(StringUtils.repeat("*", lenFirstHalf)); result.append(inputString.substring(matcher.start() + lenFirstHalf, matcher.start() + len)); } else {/*w w w.j a v a 2s . com*/ result.append(StringUtils.repeat("*", len)); } previous = matcher.end(); } result.append(inputString.substring(previous, inputString.length())); return result.toString(); }
From source file:nl.nn.adapterframework.webcontrol.action.ShowSecurityItems.java
private void addAuthEntries(XmlBuilder securityItems) { XmlBuilder aes = new XmlBuilder("authEntries"); securityItems.addSubElement(aes);//w ww . j a v a 2s . co m List entries = new ArrayList(); try { URL url = ClassUtils.getResourceURL(this, AUTHALIAS_XSLT); if (url != null) { for (Configuration configuration : ibisManager.getConfigurations()) { Transformer t = XmlUtils.createTransformer(url, true); String configString = configuration.getLoadedConfiguration(); String authEntries = XmlUtils.transformXml(t, configString); log.debug("authentication aliases for configuration [" + configuration.getName() + "] found [" + authEntries.trim() + "]"); Collection<String> c = XmlUtils.evaluateXPathNodeSet(authEntries, "authEntries/entry/@alias"); if (c != null && c.size() > 0) { for (Iterator<String> cit = c.iterator(); cit.hasNext();) { String entry = cit.next(); if (!entries.contains(entry)) { entries.add(entry); } } } } } } catch (Exception e) { XmlBuilder ae = new XmlBuilder("entry"); aes.addSubElement(ae); ae.addAttribute("alias", "*** ERROR ***"); } if (entries != null) { Collections.sort(entries); Iterator iter = entries.iterator(); while (iter.hasNext()) { String alias = (String) iter.next(); CredentialFactory cf = new CredentialFactory(alias, null, null); XmlBuilder ae = new XmlBuilder("entry"); aes.addSubElement(ae); ae.addAttribute("alias", alias); String userName; String passWord; try { userName = cf.getUsername(); passWord = StringUtils.repeat("*", cf.getPassword().length()); } catch (Exception e) { userName = "*** ERROR ***"; passWord = "*** ERROR ***"; } ae.addAttribute("userName", userName); ae.addAttribute("passWord", passWord); } } }
From source file:nl.nn.adapterframework.webcontrol.api.ShowSecurityItems.java
private ArrayList<Object> addAuthEntries() { ArrayList<Object> authEntries = new ArrayList<Object>(); Collection<Node> entries = null; try {//ww w . ja v a 2 s . co m URL url = ClassUtils.getResourceURL(this, AUTHALIAS_XSLT); if (url != null) { for (Configuration configuration : ibisManager.getConfigurations()) { Transformer t = XmlUtils.createTransformer(url, true); String configString = configuration.getOriginalConfiguration(); configString = StringResolver.substVars(configString, AppConstants.getInstance()); configString = ConfigurationUtils.getActivatedConfiguration(configuration, configString); String ae = XmlUtils.transformXml(t, configString); Element authEntriesElement = XmlUtils.buildElement(ae); if (entries == null) { entries = XmlUtils.getChildTags(authEntriesElement, "entry"); } else { entries.addAll(XmlUtils.getChildTags(authEntriesElement, "entry")); } } } } catch (Exception e) { authEntries.add("*** ERROR ***"); } if (entries != null) { Iterator<Node> iter = entries.iterator(); while (iter.hasNext()) { Map<String, Object> ae = new HashMap<String, Object>(); Element itemElement = (Element) iter.next(); String alias = itemElement.getAttribute("alias"); ae.put("alias", alias); CredentialFactory cf = new CredentialFactory(alias, null, null); String userName; String passWord; try { userName = cf.getUsername(); passWord = StringUtils.repeat("*", cf.getPassword().length()); } catch (Exception e) { userName = "*** ERROR ***"; passWord = "*** ERROR ***"; } ae.put("username", userName); ae.put("password", passWord); authEntries.add(ae); } } return authEntries; }
From source file:nl.strohalm.cyclos.entities.accounts.external.filemapping.FileMappingWithFields.java
/** * Returns a converter for amount/*w w w. j a v a2 s . com*/ */ public Converter<BigDecimal> getNumberConverter() { if (numberFormat == NumberFormat.FIXED_POSITION) { return new FixedLengthNumberConverter<BigDecimal>(BigDecimal.class, decimalPlaces); } else { final DecimalFormatSymbols symbols = new DecimalFormatSymbols(); symbols.setDecimalSeparator(decimalSeparator); symbols.setGroupingSeparator('!'); final DecimalFormat format = new DecimalFormat("0." + StringUtils.repeat("0", decimalPlaces), symbols); format.setGroupingUsed(false); return new NumberConverter<BigDecimal>(BigDecimal.class, format); } }