use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class IndexConfigUpgrader method upgradePageIndexConfig.
private PatternIndexConfigDocument upgradePageIndexConfig(final PatternIndexConfigDocument sourceDocument, final NodeVersion nodeVersion) {
final List<PropertySet> components = Lists.newArrayList(nodeVersion.getData().getSets("components"));
final String descriptorKeyStr = nodeVersion.getData().getString(PropertyPath.from("components.page.descriptor"));
final DescriptorKey pageDescriptorKey = descriptorKeyStr != null ? DescriptorKey.from(descriptorKeyStr) : null;
final FlattenedPageIndexUpgrader pageIndexUpgrader = new FlattenedPageIndexUpgrader(pageDescriptorKey, components);
return pageIndexUpgrader.upgrade(sourceDocument);
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class FlattenedPageRegionsIndexUpgrader method upgradeHtmlAreas.
private void upgradeHtmlAreas(final PathIndexConfig pathIndexConfig) {
final Matcher matcher = HTML_AREA_CONFIG_PATH_PATTERN.matcher(pathIndexConfig.getPath().toString());
if (matcher.find()) {
this.components.forEach(componentSet -> {
final String componentNewType = FlattenedPageDataUpgrader.getTargetType(matcher.group(2));
if (componentNewType != null) {
final String descriptorKeyStr = componentSet.getString(String.join(ELEMENT_DIVIDER, componentNewType, TGT_DESCRIPTOR_KEY));
if (descriptorKeyStr != null) {
final DescriptorKey descriptorKey = DescriptorKey.from(descriptorKeyStr);
final String property = componentSet.getString(String.join(ELEMENT_DIVIDER, componentNewType, TGT_CONFIG_KEY, getSanitizedAppName(descriptorKey), getSanitizedComponentName(descriptorKey), matcher.group(3)));
if (property != null) {
String newHtmlAreaPath = String.join(ELEMENT_DIVIDER, TGT_COMPONENTS_KEY, FlattenedPageDataUpgrader.getTargetType(matcher.group(2)), TGT_CONFIG_KEY, getSanitizedAppName(descriptorKey), getSanitizedComponentName(descriptorKey), matcher.group(3));
result.add(newHtmlAreaPath, pathIndexConfig.getIndexConfig());
}
}
}
});
}
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class SchedulerServiceImplTest method createOneTimeJob.
@Test
void createOneTimeJob() throws Exception {
final ScheduledJobName name = ScheduledJobName.from("test");
final DescriptorKey descriptor = DescriptorKey.from(ApplicationKey.from("com.enonic.app.features"), "landing");
final ScheduleCalendar calendar = calendarService.oneTime(Instant.parse("2021-02-25T10:44:33.170079900Z"));
final PropertyTree config = new PropertyTree();
config.addString("string", "value");
final PrincipalKey user = PrincipalKey.from("user:system:user");
final CreateScheduledJobParams params = CreateScheduledJobParams.create().name(name).descriptor(descriptor).calendar(calendar).config(config).description("description").enabled(true).user(user).build();
final Instant now = Instant.now();
Thread.sleep(100);
final ScheduledJob scheduledJob = adminContext().callWith(() -> schedulerService.create(params));
assertEquals("2021-02-25T10:44:33.170079900Z", ((OneTimeCalendar) scheduledJob.getCalendar()).getValue().toString());
assertEquals(ScheduleCalendarType.ONE_TIME, scheduledJob.getCalendar().getType());
assertEquals("user:system:repo-test-user", scheduledJob.getCreator().toString());
assertEquals("user:system:repo-test-user", scheduledJob.getModifier().toString());
assertTrue(now.isBefore(scheduledJob.getModifiedTime()));
assertTrue(now.isBefore(scheduledJob.getCreatedTime()));
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class SchedulerServiceImplTest method listWithoutAccess.
@Test
void listWithoutAccess() {
assertEquals(0, schedulerService.list().size());
final ScheduledJobName name = ScheduledJobName.from("test");
final DescriptorKey descriptor = DescriptorKey.from(ApplicationKey.from("com.enonic.app.features"), "landing");
final CronCalendar calendar = calendarService.cron("* * * * *", TimeZone.getDefault());
final PropertyTree config = new PropertyTree();
config.addString("string", "value");
adminContext().callWith(() -> schedulerService.create(CreateScheduledJobParams.create().name(name).descriptor(descriptor).calendar(calendar).config(config).description("description").build()));
assertEquals(0, schedulerService.list().size());
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class SchedulerServiceImplTest method get.
@Test
void get() {
final ScheduledJobName name = ScheduledJobName.from("test");
final DescriptorKey descriptor = DescriptorKey.from(ApplicationKey.from("com.enonic.app.features"), "landing");
final CronCalendar calendar = calendarService.cron("* * * * *", TimeZone.getDefault());
final PropertyTree config = new PropertyTree();
config.addString("string", "value");
adminContext().callWith(() -> schedulerService.create(CreateScheduledJobParams.create().name(name).descriptor(descriptor).calendar(calendar).config(config).description("description").build()));
final ScheduledJob scheduledJob = adminContext().callWith(() -> schedulerService.get(name));
assertEquals(name, scheduledJob.getName());
assertEquals(descriptor, scheduledJob.getDescriptor());
assertEquals(calendar.getCronValue(), ((CronCalendar) scheduledJob.getCalendar()).getCronValue());
assertEquals(calendar.getTimeZone(), ((CronCalendar) scheduledJob.getCalendar()).getTimeZone());
assertEquals(config, scheduledJob.getConfig());
assertEquals("description", scheduledJob.getDescription());
}
Aggregations