List of usage examples for org.apache.commons.lang3 StringUtils substringAfter
public static String substringAfter(final String str, final String separator)
Gets the substring after the first occurrence of a separator.
From source file:com.yqboots.security.access.RoleHierarchyImpl.java
/** * Retrieves the hierarchy roles./*w w w. j ava2s . c om*/ * * @param role the granted authority * @return the roles from hierarchy */ protected Collection<? extends GrantedAuthority> retrieveHierarchyRoles(GrantedAuthority role) { final Set<GrantedAuthority> results = new HashSet<>(); // /R001/R002/R003 ... String roleStr = role.getAuthority(); if (StringUtils.startsWith(roleStr, "ROLE_") && StringUtils.contains(roleStr, "/")) { roleStr = StringUtils.substringAfter(roleStr, "ROLE_"); } while (StringUtils.isNotBlank(roleStr)) { results.add(new SimpleGrantedAuthority(roleStr)); if (!StringUtils.contains(roleStr, "/")) { break; } roleStr = StringUtils.substringBeforeLast(roleStr, "/"); } return results; }
From source file:com.muk.security.AuthEventListener.java
@Override public void onApplicationEvent(AuthorizedEvent event) { final Exchange exchange = (Exchange) event.getSource(); if (!RestConstants.Rest.anonymousToken.equals(event.getAuthentication().getName()) && exchange.getIn().getHeader(HttpHeaders.AUTHORIZATION, String.class) != null) { final Authentication currentAuthentication = event.getAuthentication(); final String currentTokenRepresentation = (String) currentAuthentication.getCredentials(); final String incomingTokenRepresentation = StringUtils .substringAfter(exchange.getIn().getHeader(HttpHeaders.AUTHORIZATION, String.class), "Bearer "); if (!currentTokenRepresentation.equals(incomingTokenRepresentation)) { exchange.getOut().getHeaders().put(RestConstants.Headers.refreshToken, currentTokenRepresentation); }// w ww . j a va 2s . c o m } }
From source file:io.wcm.handler.richtext.impl.DataPropertyUtil.java
/** * Converts a HTML5 data attribute name including "data-" prefix to a headless camel case name. * @param html5DataName Html5 data attribute name * @return Headless camel case name//from ww w. j av a 2 s . c o m * @throws IllegalArgumentException If parameter name is not valid */ public static String toHeadlessCamelCaseName(String html5DataName) { if (StringUtils.isEmpty(html5DataName)) { throw new IllegalArgumentException("Property name is empty."); } if (!isHtml5DataName(html5DataName)) { throw new IllegalArgumentException("This is not a valid HTML5 data property name: " + html5DataName); } String html5DataNameWithoutSuffix = StringUtils.substringAfter(html5DataName, HTML5_DATA_PREFIX); StringBuilder headlessCamelCaseName = new StringBuilder(); boolean upperCaseNext = false; for (int i = 0; i < html5DataNameWithoutSuffix.length(); i++) { char c = html5DataNameWithoutSuffix.charAt(i); if (c == '-') { upperCaseNext = true; } else if (upperCaseNext) { headlessCamelCaseName.append(Character.toUpperCase(c)); upperCaseNext = false; } else { headlessCamelCaseName.append(c); } } return headlessCamelCaseName.toString(); }
From source file:io.wcm.devops.conga.model.util.MapExpander.java
private static Map.Entry<String, Object> expandEntry(Map.Entry<String, Object> entry) { if (!StringUtils.contains(entry.getKey(), ".")) { return new MapEntry<String, Object>(entry.getKey(), expandDeep(entry.getValue())); }//from w w w . j a v a 2 s.c o m String key = StringUtils.substringBefore(entry.getKey(), "."); String remaining = StringUtils.substringAfter(entry.getKey(), "."); Map<String, Object> map = new HashMap<>(); map.put(remaining, expandDeep(entry.getValue())); Map<String, Object> expandedMap = expand(map); return new MapEntry<String, Object>(key, expandedMap); }
From source file:com.cognifide.qa.bb.aem.touch.pageobjects.touchui.Component.java
/** * @return data path of the component./*from ww w .j av a 2 s. c om*/ */ public String getDataPath() { String rawValue = conditions.staleSafe(currentScope, checked -> checked.getAttribute(HtmlTags.Attributes.DATA_PATH)); return StringUtils.substringAfter(rawValue, JCR_CONTENT); }
From source file:com.u2apple.rt.util.AndroidDeviceUtils.java
public static String getProductId(String brand, String model) { String productId = null;//from ww w .ja v a 2 s.com if (StringUtils.isNotBlank(brand) && StringUtils.isNotBlank(model)) { brand = brand.toLowerCase(); model = model.toLowerCase(); String modelWithoutBrand; if (StringUtils.containsIgnoreCase(model, brand)) { modelWithoutBrand = StringUtils.substringAfter(model, brand); } else { modelWithoutBrand = model; } //?model. if ("samsung".equalsIgnoreCase(brand) && modelWithoutBrand.contains("-")) { int index = modelWithoutBrand.indexOf("-"); //When "-" is the last char. if (index < modelWithoutBrand.length() - 1) { modelWithoutBrand = modelWithoutBrand.substring(index + 1); } } String formattedModel = formatModel(modelWithoutBrand); //?? if ("vivo".equalsIgnoreCase(brand)) { productId = "bbk-vivo" + formattedModel; } else { productId = brand + "-" + formattedModel; } } return productId; }
From source file:com.liveneo.plat.web.action.DownloadAction.java
public String getDownloadFileName() { String fileName = this.getRequest().getParameter("fileName"); String filewav = this.getRequest().getParameter("filewav"); String downFileName = ""; if (StringUtils.equalsIgnoreCase(loadflag, "restore")) { downFileName = fileName + ".zip"; }/* ww w . j av a 2s. c om*/ if (StringUtils.equalsIgnoreCase(loadflag, "excel")) { downFileName = fileName; } if (StringUtils.equalsIgnoreCase(loadflag, "recording")) { if (StringUtils.isNotEmpty(fileName)) { downFileName = StringUtils.substringAfter(fileName, "/noneccrecord/ivrvoice/"); } else { downFileName = "empty.wav"; } } if (StringUtils.equalsIgnoreCase(loadflag, "license")) { downFileName = filewav; } if (StringUtils.equalsIgnoreCase(loadflag, "wo")) { downFileName = fileName; } if (StringUtils.equalsIgnoreCase(loadflag, "report")) { downFileName = fileName; } if (StringUtils.equalsIgnoreCase(loadflag, "commonexcel")) { downFileName = fileName; } try { downFileName = new String(downFileName.getBytes(), "ISO8859-1"); } catch (Exception e) { e.printStackTrace(); } return downFileName; }
From source file:info.magnolia.photoreview.app.container.RecursiveBeanItem.java
@Override public Property<?> getItemProperty(Object id) { if (id instanceof String && ((String) id).contains(SEPARATOR)) { String thisKey = StringUtils.substringBefore((String) id, SEPARATOR); String nextKey = StringUtils.substringAfter((String) id, SEPARATOR); Property<?> property = super.getItemProperty(thisKey); Object subBean = property.getValue(); if (subBean != null) { return new RecursiveBeanItem(subBean).getItemProperty(nextKey); } else {// w w w .jav a 2 s. c o m return null; } } return super.getItemProperty(id); }
From source file:de.tudarmstadt.ukp.dkpro.core.ixa.internal.IxaLemmatizerTagsetDescriptionProvider.java
@Override public Set<String> listTags(String aLayer, String aTagsetName) { try {//from w w w . java2s .c om AbstractModel innerModel = (AbstractModel) FieldUtils.readField(model, "model", true); HashMap<String, Integer> pmap = (HashMap<String, Integer>) FieldUtils.readField(innerModel, "pmap", true); Set<String> tagSet = new TreeSet<String>(); String prefix = feature + separator; for (Object key : pmap.keySet()) { if (key instanceof String && ((String) key).startsWith(prefix)) { tagSet.add(StringUtils.substringAfter(((String) key), separator)); } } return tagSet; } catch (IllegalAccessException e) { throw new IllegalStateException(e); } }
From source file:com.iorga.iraj.security.HttpClientRequestToSign.java
@Override public String getResource() { try {/* ww w . j a v a2 s . co m*/ return StringUtils.substringAfter(clientRequest.getUri(), webApplicationPathPrefix); } catch (final Exception e) { throw new RuntimeException(e); } }