Search in sources :

Example 21 with DescriptorKey

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);
}
Also used : PartDescriptor(com.enonic.xp.region.PartDescriptor) DescriptorKey(com.enonic.xp.page.DescriptorKey) Test(org.junit.jupiter.api.Test) AbstractDescriptorServiceTest(com.enonic.xp.core.impl.content.page.AbstractDescriptorServiceTest)

Example 22 with DescriptorKey

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);
}
Also used : PropertySet(com.enonic.xp.data.PropertySet) DescriptorKey(com.enonic.xp.page.DescriptorKey) FlattenedPageIndexUpgrader(com.enonic.xp.repo.impl.dump.upgrade.flattenedpage.FlattenedPageIndexUpgrader)

Example 23 with DescriptorKey

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());
                    }
                }
            }
        });
    }
}
Also used : Matcher(java.util.regex.Matcher) DescriptorKey(com.enonic.xp.page.DescriptorKey)

Example 24 with DescriptorKey

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);
}
Also used : JsonToPropertyTreeTranslator(com.enonic.xp.json.JsonToPropertyTreeTranslator) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) DescriptorKey(com.enonic.xp.page.DescriptorKey) JsonNode(com.fasterxml.jackson.databind.JsonNode) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) FlattenedPageIndexUpgrader(com.enonic.xp.repo.impl.dump.upgrade.flattenedpage.FlattenedPageIndexUpgrader)

Example 25 with DescriptorKey

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());
}
Also used : ScheduledJob(com.enonic.xp.scheduler.ScheduledJob) EditableScheduledJob(com.enonic.xp.scheduler.EditableScheduledJob) PropertyTree(com.enonic.xp.data.PropertyTree) DescriptorKey(com.enonic.xp.page.DescriptorKey) ScheduleCalendar(com.enonic.xp.scheduler.ScheduleCalendar) PrincipalKey(com.enonic.xp.security.PrincipalKey) EditableScheduledJob(com.enonic.xp.scheduler.EditableScheduledJob) Test(org.junit.jupiter.api.Test)

Aggregations

DescriptorKey (com.enonic.xp.page.DescriptorKey)73 Test (org.junit.jupiter.api.Test)45 PropertyTree (com.enonic.xp.data.PropertyTree)25 PrincipalKey (com.enonic.xp.security.PrincipalKey)11 ScheduledJob (com.enonic.xp.scheduler.ScheduledJob)10 TaskId (com.enonic.xp.task.TaskId)10 Page (com.enonic.xp.page.Page)7 ScheduledJobName (com.enonic.xp.scheduler.ScheduledJobName)7 TaskDescriptor (com.enonic.xp.task.TaskDescriptor)7 Instant (java.time.Instant)7 PropertySet (com.enonic.xp.data.PropertySet)6 ServiceDescriptor (com.enonic.xp.service.ServiceDescriptor)6 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)5 CronCalendar (com.enonic.xp.scheduler.CronCalendar)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 ApplicationKey (com.enonic.xp.app.ApplicationKey)4 AbstractDescriptorServiceTest (com.enonic.xp.core.impl.content.page.AbstractDescriptorServiceTest)4 DescribedTask (com.enonic.xp.impl.task.distributed.DescribedTask)4 PortalRequest (com.enonic.xp.portal.PortalRequest)4 PortalResponse (com.enonic.xp.portal.PortalResponse)4