Search in sources :

Example 1 with ContentStoreService

use of org.craftercms.core.service.ContentStoreService in project engine by craftercms.

the class ConfigurationScriptJobResolver method getJobsUnderFolder.

protected List<JobContext> getJobsUnderFolder(SiteContext siteContext, HierarchicalConfiguration jobFolderConfig) {
    List<JobContext> jobContexts = null;
    String folderPath = jobFolderConfig.getString(PATH_KEY);
    String cronExpression = jobFolderConfig.getString(CRON_EXPRESSION_KEY);
    ContentStoreService storeService = siteContext.getStoreService();
    Context context = siteContext.getContext();
    if (StringUtils.isNotEmpty(folderPath) && StringUtils.isNotEmpty(cronExpression)) {
        List<String> scriptPaths = ContentStoreUtils.findChildrenUrl(storeService, context, folderPath);
        if (CollectionUtils.isNotEmpty(scriptPaths)) {
            for (String scriptPath : scriptPaths) {
                if (scriptPath.endsWith(scriptSuffix)) {
                    if (jobContexts == null) {
                        jobContexts = new ArrayList<>();
                    }
                    jobContexts.add(SchedulingUtils.createJobContext(siteContext, scriptPath, cronExpression, servletContext));
                }
            }
        }
    }
    return jobContexts;
}
Also used : SiteContext(org.craftercms.engine.service.context.SiteContext) Context(org.craftercms.core.service.Context) JobContext(org.craftercms.engine.util.quartz.JobContext) ServletContext(javax.servlet.ServletContext) ContentStoreService(org.craftercms.core.service.ContentStoreService) JobContext(org.craftercms.engine.util.quartz.JobContext)

Example 2 with ContentStoreService

use of org.craftercms.core.service.ContentStoreService in project engine by craftercms.

the class Dom4jExtensionTest method createContentStoreService.

private ContentStoreService createContentStoreService() {
    ContentStoreService storeService = mock(ContentStoreService.class);
    ContentStoreServiceMockUtils.setUpGetContentFromClassPath(storeService);
    return storeService;
}
Also used : ContentStoreService(org.craftercms.core.service.ContentStoreService)

Example 3 with ContentStoreService

use of org.craftercms.core.service.ContentStoreService in project engine by craftercms.

the class FolderToIndexItemProcessorTest method createContentStoreService.

private ContentStoreService createContentStoreService() {
    Document dom = mock(Document.class);
    when(dom.asXML()).thenReturn(XML);
    Item item = new Item();
    item.setDescriptorUrl(INDEX_EN_URL);
    item.setDescriptorDom(dom);
    item.setKey(INDEX_EN_URL);
    ContentStoreService storeService = mock(ContentStoreService.class);
    when(storeService.findItem(null, null, INDEX_EN_URL, null)).thenReturn(item);
    return storeService;
}
Also used : Item(org.craftercms.core.service.Item) ContentStoreService(org.craftercms.core.service.ContentStoreService) Document(org.dom4j.Document)

Example 4 with ContentStoreService

use of org.craftercms.core.service.ContentStoreService in project engine by craftercms.

the class ToCurrentTargetedVersionItemProcessorTest method createContentStoreService.

private ContentStoreService createContentStoreService() {
    Item item = new Item();
    item.setUrl(INDEX_EN_URL);
    ContentStoreService storeService = mock(ContentStoreService.class);
    when(storeService.findItem(null, null, INDEX_EN_US_URL, null)).thenReturn(item);
    return storeService;
}
Also used : Item(org.craftercms.core.service.Item) ContentStoreService(org.craftercms.core.service.ContentStoreService)

Example 5 with ContentStoreService

use of org.craftercms.core.service.ContentStoreService in project engine by craftercms.

the class RestScriptsController method parseScriptUrlForVariables.

protected String parseScriptUrlForVariables(SiteContext siteContext, String scriptUrl, Map<String, Object> variables) {
    ContentStoreService storeService = siteContext.getStoreService();
    if (!storeService.exists(siteContext.getContext(), scriptUrl) && urlTemplateScanner != null) {
        List<UriTemplate> urlTemplates = urlTemplateScanner.scan(siteContext);
        if (CollectionUtils.isNotEmpty(urlTemplates)) {
            for (UriTemplate template : urlTemplates) {
                if (template.matches(scriptUrl)) {
                    Map<String, String> pathVars = template.match(scriptUrl);
                    String actualScriptUrl = template.toString();
                    variables.put(GroovyScriptUtils.VARIABLE_PATH_VARS, pathVars);
                    return actualScriptUrl;
                }
            }
        }
    }
    return scriptUrl;
}
Also used : ContentStoreService(org.craftercms.core.service.ContentStoreService) UriTemplate(org.springframework.web.util.UriTemplate)

Aggregations

ContentStoreService (org.craftercms.core.service.ContentStoreService)10 SiteContext (org.craftercms.engine.service.context.SiteContext)4 Context (org.craftercms.core.service.Context)3 ArrayList (java.util.ArrayList)2 Item (org.craftercms.core.service.Item)2 ScriptFactory (org.craftercms.engine.scripting.ScriptFactory)2 UriTemplate (org.springframework.web.util.UriTemplate)2 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 ServletContext (javax.servlet.ServletContext)1 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)1 RequestContext (org.craftercms.commons.http.RequestContext)1 Callback (org.craftercms.commons.lang.Callback)1 CrafterException (org.craftercms.core.exception.CrafterException)1 CachingAwareList (org.craftercms.core.util.cache.impl.CachingAwareList)1 ConfigurationException (org.craftercms.engine.exception.ConfigurationException)1 JobContext (org.craftercms.engine.util.quartz.JobContext)1 Document (org.dom4j.Document)1