use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class PartDescriptorServiceTest method testGetByKey.
@Test
public void testGetByKey() throws Exception {
final DescriptorKey key = DescriptorKey.from("myapp1:mypart");
final PartDescriptor descriptor = this.service.getByKey(key);
assertNotNull(descriptor);
}
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 FlattenedPageIndexUpgraderTest method test.
private void test(final String dataFile, final String oldIndexDocumentFile, final String newIndexDocumentFile) throws Exception {
final JsonNode pageComponents = loadJson(dataFile);
final PropertyTree data = new JsonToPropertyTreeTranslator().translate(pageComponents);
final List<PropertySet> components = Lists.newArrayList(data.getSets("components"));
if (components.size() == 0) {
throw new RuntimeException("page components is empty");
}
final String descriptorKeyStr = data.getString(PropertyPath.from("components.page.descriptor"));
if (descriptorKeyStr == null) {
throw new RuntimeException("page descriptorKey is null");
}
final DescriptorKey descriptorKey = DescriptorKey.from(descriptorKeyStr);
final PatternIndexConfigDocument oldDocument = getIndexConfigDocument(oldIndexDocumentFile);
final PatternIndexConfigDocument newDocument = new FlattenedPageIndexUpgrader(descriptorKey, components).upgrade(oldDocument);
assertEquals(getIndexConfigDocument(newIndexDocumentFile), newDocument);
}
use of com.enonic.xp.page.DescriptorKey in project xp by enonic.
the class EditableScheduledJobTest method testChanged.
@Test
public void testChanged() {
final ScheduledJob source = ScheduledJob.create().name(ScheduledJobName.from("name")).descriptor(DescriptorKey.from("app:key")).calendar(mock(ScheduleCalendar.class)).creator(PrincipalKey.from("user:system:creator")).modifier(PrincipalKey.from("user:system:creator")).createdTime(Instant.parse("2016-11-02T10:36:00Z")).modifiedTime(Instant.parse("2016-11-02T10:36:00Z")).build();
final PrincipalKey user = PrincipalKey.ofUser(IdProviderKey.createDefault(), "user");
final DescriptorKey descriptor = DescriptorKey.from(ApplicationKey.BASE, "descriptor");
final PropertyTree config = new PropertyTree();
config.addString("property", "value");
final String description = "description";
final EditableScheduledJob editable = new EditableScheduledJob(source);
editable.config = config;
editable.user = user;
editable.descriptor = descriptor;
editable.description = description;
editable.calendar = mock(ScheduleCalendar.class);
editable.enabled = true;
final ScheduledJob target = editable.build();
assertEquals(source.getName(), target.getName());
assertEquals(config, target.getConfig());
assertEquals(user, target.getUser());
assertEquals(descriptor, target.getDescriptor());
assertEquals(description, target.getDescription());
assertTrue(target.isEnabled());
}
Aggregations