List of usage examples for org.apache.commons.io FilenameUtils wildcardMatch
public static boolean wildcardMatch(String filename, String wildcardMatcher)
From source file:org.jahia.utils.zip.ExclusionWildcardFilter.java
public boolean accept(String path) { if (excludedResources == null || excludedResources.length == 0) { return true; }/* ww w.j a va2 s .c o m*/ boolean accept = true; for (String excludePattern : excludedResources) { if (FilenameUtils.wildcardMatch(path, excludePattern)) { accept = false; break; } } return accept; }
From source file:org.kalypso.kalypsomodel1d2d.sim.ResultManager.java
private FileObject[] find2dFiles(final FileObject remoteWorking) throws IOException { final List<FileObject> resultList = new ArrayList<>(); if (remoteWorking == null) return null; final FileObject[] children = remoteWorking.getChildren(); for (final FileObject child : children) { final FileName childName = child.getName(); final String baseName = childName.getBaseName(); if (FilenameUtils.wildcardMatch(baseName, "*.2d") || FilenameUtils.wildcardMatch(baseName, "*.2d.zip")) //$NON-NLS-1$ //$NON-NLS-2$ {//from w ww .j a va 2 s . co m resultList.add(child); } } return resultList.toArray(new FileObject[resultList.size()]); }
From source file:org.kalypso.kalypsomodel1d2d.sim.ResultManager.java
private FileObject findTelemacResultFile(final FileObject resultDir) { if (resultDir == null) return null; FileObject[] children = null; try {//from w ww . j a v a 2s. c o m children = resultDir.getChildren(); } catch (FileSystemException e) { e.printStackTrace(); } for (final FileObject child : children) { final FileName childName = child.getName(); final String baseName = childName.getBaseName(); if (FilenameUtils.wildcardMatch(baseName, "*res*.slf*")) //$NON-NLS-1$ { return child; } } final IPath path = ResultMeta1d2dHelper.getSavedPathFromResultData(m_calcUnitMeta, ResultMeta1d2dHelper.TELEMAC_RAW_DATA_META_NAME); if (path != null) { try { return resultDir.getParent().resolveFile(path.toOSString()); } catch (final Exception e) { m_geoLog.formatLog(IStatus.INFO, CODE_RUNNING_FINE, Messages.getString("org.kalypso.kalypsomodel1d2d.sim.ResultManager.15"), //$NON-NLS-1$ resultDir.getName().getBaseName()); return null; } } return null; }
From source file:org.paxml.core.ResourceLocator.java
/** * Find a set of resources filtered with the given name pattern. The scope * of the find are the added resources./* www . j a v a 2 s . c o m*/ * * @param pattern * the pattern on resource name, not on path. * @return the set, never null */ public Set<PaxmlResource> filterResources(String pattern) { Set<PaxmlResource> set = new LinkedHashSet<PaxmlResource>(0); for (Map.Entry<String, PaxmlResource> entry : resources.entrySet()) { if (FilenameUtils.wildcardMatch(entry.getKey(), pattern)) { set.add(entry.getValue()); } } return set; }
From source file:org.paxml.launch.Matcher.java
/** * Match path with wildcard pattern./*from w ww . ja v a2 s . c o m*/ * * @param str * the path or name * @return true if matches, false if not */ public boolean match(String str) { return FilenameUtils.wildcardMatch(str, pattern); }
From source file:org.pepstock.jem.node.security.SecurityUtils.java
/** * Checks if the file name must be checked, ignored or rejected * //from ww w.ja va2 s . co m * @param fileName to check! * @return if authorized or must be checked */ public int checkReadFileName(String fileName) { // checks if filename is located on a data paths String dataPath = DataPathsContainer.getInstance().getAbsoluteDataPath(fileName); // if yes (not null!) the permission must be checked if (dataPath != null) { return TO_BE_CHECKED; } // gets the boolean if is going to source or output folders boolean textFolder = fileName.startsWith(OUTPUT_PATH) || fileName.startsWith(SOURCE_PATH); // gets the boolean if is going to binary or library or class folders boolean binaryFolder = fileName.startsWith(LIBRARY_PATH) || fileName.startsWith(BINARY_PATH) || fileName.startsWith(CLASS_PATH); // if is going on the previous checked folder, DOESN'T // perform any permission check if (textFolder || binaryFolder) { return TO_BE_IGNORED; } // if you're going on the persistence path, a Security exception will be thrown // because it's not allowed to read anything on persistence folder if (fileName.startsWith(PERSISTENCE_PATH)) { return TO_BE_REJECTED; } // if you're reading classes, jar or zip, DOESN'T // perform any permission check // this is done when JAVA programs are executed String ext = FilenameUtils.getExtension(fileName); if ("class".equalsIgnoreCase(ext) || "jar".equalsIgnoreCase(ext) || "zip".equalsIgnoreCase(ext)) { return TO_BE_IGNORED; } // any access to the JEM home to read configuration files are not allowed. // Security exception will be thrown if (fileName.startsWith(HOME) && FilenameUtils.wildcardMatch(fileName, HOME + File.separator + "*" + File.separator + "config*")) { return TO_BE_REJECTED; } // if you are here, DOESN'T // perform any permission check return TO_BE_IGNORED; }
From source file:org.polymap.model2.query.grammar.PropertyMatches.java
@Override public boolean evaluate(Composite target) { Object propValue = propValue(target, prop); return propValue != null ? FilenameUtils.wildcardMatch(propValue.toString(), value.toString()) : false; }
From source file:org.polymap.rhei.batik.engine.BatikFactory.java
public IAppDesign createAppDesign() { try {/*www.ja v a2s.c om*/ IConfigurationElement[] elms = Platform.getExtensionRegistry() .getConfigurationElementsFor(BatikPlugin.PLUGIN_ID, APP_DESIGN_EXTENSION_POINT); String path = RWT.getRequest().getServletPath(); IConfigurationElement bestMatch = null; String bestMatcher = null; for (IConfigurationElement elm : elms) { String matcher = elm.getAttribute("servletNameMatcher"); if (FilenameUtils.wildcardMatch(path, matcher)) { if (bestMatcher == null || bestMatcher.length() < matcher.length()) { bestMatch = elm; bestMatcher = matcher; } } } return (IAppDesign) bestMatch.createExecutableExtension("class"); } catch (CoreException e) { throw new RuntimeException(e); } }
From source file:org.polymap.rhei.batik.engine.BatikFactory.java
public IPanelFilter allPanelFilters() { try {/* ww w . ja v a2 s . co m*/ IConfigurationElement[] elms = Platform.getExtensionRegistry() .getConfigurationElementsFor(BatikPlugin.PLUGIN_ID, PANEL_FILTERS_EXTENSION_POINT); String path = RWT.getRequest().getServletPath(); List<IPanelFilter> filters = new ArrayList(); for (IConfigurationElement elm : elms) { String matcher = elm.getAttribute("servletNameMatcher"); if (FilenameUtils.wildcardMatch(path, matcher)) { filters.add((IPanelFilter) elm.createExecutableExtension("class")); } } return new IPanelFilter() { @Override public boolean apply(IPanel panel) { for (IPanelFilter filter : filters) { if (!filter.apply(panel)) { return false; } } return true; } }; } catch (CoreException e) { throw new RuntimeException(e); } }
From source file:org.simbasecurity.core.domain.ExcludedResourceEntity.java
@Override public boolean matches(String resource) { return FilenameUtils.wildcardMatch(resource, pattern); }