public EnumerationValidator(String expr) { values = new HashSet<String>(); String[] vals = StringUtils.split(expr, ',', true); for (String v : vals) { values.add(v); } }
protected static String escapeEntryPath(String path) { String zipEntryEncoding = Framework.getProperty(ZIP_ENTRY_ENCODING_PROPERTY); if (zipEntryEncoding != null && zipEntryEncoding.equals(ZIP_ENTRY_ENCODING_OPTIONS.ascii.toString())) { return StringUtils.toAscii(path, true); } return path; }
protected static String getEnvProperty(String key, Map<String, Object> hostEnv, Properties sysprops, boolean addToSystemProperties) { String v = (String) hostEnv.get(key); if (v == null) { v = System.getProperty(key); } if (v != null) { v = StringUtils.expandVars(v, sysprops); if (addToSystemProperties) { sysprops.setProperty(key, v); } } return v; }
@Override public Object getAdaptedValue(OperationContext ctx, Object objectToAdapt) throws TypeAdaptException { String content = (String) objectToAdapt; List<String> li = StringUtils.split(content, ',', '\\', true); return new StringList(li); }
/** * Replaces accented characters from a non-null String by their ascii equivalent. */ public static String toAscii(String s) { return toAscii(s, false); }
@Override protected String getContentToCopy(File fileToCopy, Map<String, String> prefs) throws PackageException { try { String content = FileUtils.readFileToString(fileToCopy, UTF_8); return StringUtils.expandVars(content, prefs); } catch (IOException e) { throw new PackageException("Failed to run parameterized copy for: " + fileToCopy.getName(), e); } }
@XNode("filters/lifeCycle") protected void setLifeCycleExpr(String lifeCycles) { lifeCycle = StringUtils.split(lifeCycles, ',', true); }
protected String escapeEntryPath(String path) { String zipEntryEncoding = Framework.getProperty(ZIP_ENTRY_ENCODING_PROPERTY); if (zipEntryEncoding != null && zipEntryEncoding.equals(ZIP_ENTRY_ENCODING_OPTIONS.ascii.toString())) { return StringUtils.toAscii(path, true); } return path; }
protected String loadParametrizedFile(File file, Map<String, String> params) throws IOException { String content = FileUtils.readFileToString(file, UTF_8); // replace variables. return StringUtils.expandVars(content, createContextMap(params)); }
protected Map<String, String> parseAttrs(String expr) { Map<String, String> map = new HashMap<>(); String[] ar = StringUtils.split(expr, ';', true); for (String a : ar) { int i = a.indexOf('='); if (i == -1) { map.put(a, null); } else { String key = a.substring(0, i).trim(); String val = a.substring(i + 1).trim(); if (key.endsWith(":")) { key = key.substring(0, key.length() - 1).trim(); } map.put(key, val); } } return map; }
s = StringUtils.toAscii(s); s = s.trim(); if (lower) {
protected static void loadSystemProperties() { File file = new File(home, "system.properties"); if (!file.isFile()) { return; } FileInputStream in = null; try { in = new FileInputStream(file); Properties p = new Properties(); p.load(in); for (Map.Entry<Object, Object> entry : p.entrySet()) { String v = (String) entry.getValue(); v = StringUtils.expandVars(v, System.getProperties()); System.setProperty((String) entry.getKey(), v); } } catch (IOException e) { throw new RuntimeException("Failed to load system properties", e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { log.error(e); } } } }
@Override public Collection<BundleFile> getNestedBundles(File tmpDir) throws IOException { Attributes attrs = mf.getMainAttributes(); String cp = attrs.getValue(Constants.BUNDLE_CLASSPATH); if (cp == null) { cp = attrs.getValue("Class-Path"); } if (cp == null) { return null; } String[] paths = StringUtils.split(cp, ',', true); List<BundleFile> nested = new ArrayList<>(); for (String path : paths) { File nestedBundle = new File(file, path); if (nestedBundle.isDirectory()) { nested.add(new DirectoryBundleFile(nestedBundle)); } else { nested.add(new JarBundleFile(nestedBundle)); } } return nested; }
filename = URLDecoder.decode(filename, "UTF-8"); } catch (UnsupportedEncodingException e) { filename = StringUtils.toAscii(filename);
return null; String[] paths = StringUtils.split(cp, ',', true); URL base = new URL("jar:" + new File(jarFile.getName()).toURI().toURL().toExternalForm() + "!/"); String fileName = getFileName();
public List<Map<String, Object>> buildTree(T root, String path) { if (path == null || path.length() == 0 || "/".equals(path)) { return buildChildren(root); } String[] ar = StringUtils.split(path, '/', false); if (ar.length > 1) { String name = getName(root); if (name.equals(ar[0])) { return buildChildren(root, ar, 1); } } return buildChildren(root); }
@SuppressWarnings("deprecation") private Set<String> getSplittedParameterValues(char separator, String category, String... subCategories) { if (category == null) { return Collections.emptySet(); } StringBuilder sb = new StringBuilder(category); for (String subCategory : subCategories) { sb.append(separator + subCategory); } String paramKey = sb.toString().toLowerCase(); List<Object> dirty = getParameters(paramKey); dirty.addAll(getParameters(HEADER_PREFIX + paramKey)); // Deprecated on server since 5.8, but the code on client wasn't - keep this part of code as Nuxeo Automation // Client is deprecated since 8.10 and Nuxeo Java Client handle this properly // backward compatibility, supports X-NXDocumentProperties and X-NXContext-Category if (EMBED_PROPERTIES.equalsIgnoreCase(paramKey)) { dirty.addAll(getParameters("X-NXDocumentProperties")); } else if ((EMBED_ENRICHERS + separator + ENTITY_TYPE).equalsIgnoreCase(paramKey)) { dirty.addAll(getParameters("X-NXContext-Category")); } Set<String> result = new TreeSet<>(); for (Object value : dirty) { if (value instanceof String) { result.addAll(Arrays.asList(org.nuxeo.common.utils.StringUtils.split((String) value, ',', true))); } } return result; }
if (v.length() > 0) { types = new HashSet<String>(); for (String t : StringUtils.split(v, ',', true)) { types.add(t);
@Override public Object getAdaptedValue(OperationContext ctx, Object objectToAdapt) throws TypeAdaptException { String value = (String) objectToAdapt; String[] array = StringUtils.split(value, ',', true); DocumentModelList result = new DocumentModelListImpl(array.length); for (String val : array) { result.add(TypeAdapterHelper.createDocumentModel(ctx, val)); } return result; } }
@Override public BlobList getInput(String content) { String[] array = StringUtils.split(content, ',', true); BlobList list = new BlobList(array.length); for (String key : array) { list.add(BlobInputResolver.blobFromKey(key)); } return list; } }