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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations