Example usage for org.springframework.util AntPathMatcher AntPathMatcher

List of usage examples for org.springframework.util AntPathMatcher AntPathMatcher

Introduction

In this page you can find the example usage for org.springframework.util AntPathMatcher AntPathMatcher.

Prototype

public AntPathMatcher() 

Source Link

Document

Create a new instance with the #DEFAULT_PATH_SEPARATOR .

Usage

From source file:de.itsvs.cwtrpc.core.pattern.AntPatternMatcher.java

public AntPatternMatcher(String pathSeparator) {
    this.pathSeparator = pathSeparator;
    this.pathMatcher = new AntPathMatcher();
    this.pathMatcher.setPathSeparator(pathSeparator);
}

From source file:springfox.documentation.builders.PathSelectors.java

/**
 * Predicate that evaluates the supplied ant pattern
 *
 * @param antPattern - ant Pattern//w w  w  . j  a v  a  2 s  .c  o m
 * @return predicate that matches a particular ant pattern
 */
public static Predicate<String> ant(final String antPattern) {
    return new Predicate<String>() {
        @Override
        public boolean apply(String input) {
            AntPathMatcher matcher = new AntPathMatcher();
            return matcher.match(antPattern, input);
        }
    };
}

From source file:org.bonitasoft.web.designer.controller.RequestMappingUtils.java

public String extractPathWithinPattern(HttpServletRequest request) {
    return new AntPathMatcher().extractPathWithinPattern(
            (String) request.getAttribute(BEST_MATCHING_PATTERN_ATTRIBUTE),
            (String) request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE));
}

From source file:org.italiangrid.storm.webdav.authz.util.HeaderRegexMatcher.java

public HeaderRegexMatcher(String headerName, String expression) {

    this.headerName = headerName;
    this.pattern = expression;
    this.matcher = new AntPathMatcher();
}

From source file:ch.rasc.wampspring.broker.DefaultSubscriptionRegistryTests.java

@Before
public void setup() {
    this.registry = new DefaultSubscriptionRegistry(new AntPathMatcher());
}

From source file:org.ng200.openolympus.controller.PartialsController.java

@RequestMapping("/partials/**")
String getMapping(final HttpServletRequest request) {
    final String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
    final String bestMatchPattern = (String) request
            .getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);

    final AntPathMatcher apm = new AntPathMatcher();
    final String finalPath = apm.extractPathWithinPattern(bestMatchPattern, path);

    return "partials/" + finalPath + "::content";

}

From source file:eu.supersede.gr.rest.ResourcesRest.java

@RequestMapping("/**")
public byte[] getResource(final HttpServletRequest request) {

    String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
    String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);

    AntPathMatcher apm = new AntPathMatcher();
    String finalPath = apm.extractPathWithinPattern(bestMatchPattern, path);

    //      System.out.println( "Serving page " + finalPath );

    Resource resource = resourceLoader.getResource("classpath:static/ahprp/" + finalPath);

    //      try {
    //         System.out.println( resource.getFile().getAbsolutePath() );
    //      } catch (IOException e1) {
    //         e1.printStackTrace();
    //      }/*www.j  av  a2 s.  c  o m*/
    //      Resource resource = resourceLoader.getResource("classpath:static/game.html");

    try {
        InputStream is = resource.getInputStream();

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        try {
            int read = is.read();
            while (read != -1) {
                byteArrayOutputStream.write(read);
                read = is.read();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        byte[] bytes = byteArrayOutputStream.toByteArray();
        return bytes;

    } catch (IOException e) {
        e.printStackTrace();
    }

    // Something went wrong
    return ("Failed to load resource '" + finalPath).getBytes();
}

From source file:com.ge.predix.uaa.token.lib.DefaultZoneConfiguration.java

@Required
public void setAllowedUriPatterns(final List<String> allowedUriPatterns) {
    AntPathMatcher matcher = new AntPathMatcher();

    for (String pattern : allowedUriPatterns) {
        if (!matcher.isPattern(pattern)) {
            throw new IllegalArgumentException("Invalid pattern: " + pattern);
        }//  w ww  .j  a v a  2 s.c  o m
    }
    this.allowedUriPatterns = allowedUriPatterns;
}

From source file:org.openflamingo.uploader.policy.AntPathPattern.java

@Override
public boolean accept(Path path) {
    String evaluated = jobContext.getValue(path.getName());
    boolean matched = new AntPathMatcher().match(pattern, evaluated);
    if (!matched) {
        logger.debug(/*from   w  w w  .ja v a  2 s  .  com*/
                "'{}' ?? Ant Path Pattern '{}' ?   .",
                evaluated, pattern);
    }
    return matched;
}