Search in sources :

Example 11 with UriTemplate

use of org.springframework.web.util.UriTemplate in project engine by craftercms.

the class ScriptUrlTemplateScannerImpl method scan.

@Override
public List<UriTemplate> scan(SiteContext siteContext) {
    Context context = siteContext.getContext();
    ContentStoreService storeService = siteContext.getStoreService();
    ScriptFactory scriptFactory = siteContext.getScriptFactory();
    List<String> scriptUrls = new ArrayList<>();
    List<UriTemplate> urlTemplates = new ArrayList<>();
    findScripts(context, storeService, scriptFactory, scriptsFolder, scriptUrls);
    if (CollectionUtils.isNotEmpty(scriptUrls)) {
        for (String scriptUrl : scriptUrls) {
            Matcher matcher = urlVariablePlaceholderPattern.matcher(scriptUrl);
            if (matcher.find()) {
                urlTemplates.add(new UriTemplate(scriptUrl));
            }
        }
    }
    return urlTemplates;
}
Also used : SiteContext(org.craftercms.engine.service.context.SiteContext) Context(org.craftercms.core.service.Context) ContentStoreService(org.craftercms.core.service.ContentStoreService) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) UriTemplate(org.springframework.web.util.UriTemplate) ScriptFactory(org.craftercms.engine.scripting.ScriptFactory)

Aggregations

UriTemplate (org.springframework.web.util.UriTemplate)11 URI (java.net.URI)4 ContentStoreService (org.craftercms.core.service.ContentStoreService)2 Test (org.junit.Test)2 Statement (org.junit.runners.model.Statement)2 RestClientException (org.springframework.web.client.RestClientException)2 RestTemplate (org.springframework.web.client.RestTemplate)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1 Link (org.apache.geode.management.internal.web.domain.Link)1 Context (org.craftercms.core.service.Context)1 ScriptFactory (org.craftercms.engine.scripting.ScriptFactory)1 SiteContext (org.craftercms.engine.service.context.SiteContext)1 DefaultOAuth2AccessToken (org.springframework.security.oauth2.common.DefaultOAuth2AccessToken)1 OAuth2AccessToken (org.springframework.security.oauth2.common.OAuth2AccessToken)1 RestOperations (org.springframework.web.client.RestOperations)1