Search in sources :

Example 31 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class TaskServiceImplTest method submitTask_DescriptorKey_offload_to_clustered_wait_fail.

@Test
void submitTask_DescriptorKey_offload_to_clustered_wait_fail() {
    final DescriptorKey descriptorKey = DescriptorKey.from("module:my-admin-tool");
    when(taskConfig.distributable_acceptInbound()).thenReturn(false);
    taskService.activate(taskConfig);
    assertThrows(RuntimeException.class, () -> {
        taskService.submitTask(SubmitTaskParams.create().descriptorKey(descriptorKey).build());
    });
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey) Test(org.junit.jupiter.api.Test)

Example 32 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class AdminToolPortalHandler method createPortalRequest.

@Override
protected PortalRequest createPortalRequest(final WebRequest webRequest, final WebResponse webResponse) {
    final PortalRequest portalRequest = new PortalRequest(webRequest);
    final DescriptorKey descriptorKey = getDescriptorKey(webRequest);
    if (descriptorKey == null) {
        portalRequest.setBaseUri(ADMIN_TOOL_START);
        portalRequest.setApplicationKey(DEFAULT_DESCRIPTOR_KEY.getApplicationKey());
    } else {
        portalRequest.setBaseUri(ADMIN_TOOL_PREFIX + descriptorKey.getApplicationKey() + "/" + descriptorKey.getName());
        portalRequest.setApplicationKey(descriptorKey.getApplicationKey());
    }
    portalRequest.setMode(RenderMode.ADMIN);
    return portalRequest;
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey) PortalRequest(com.enonic.xp.portal.PortalRequest)

Example 33 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class LayoutComponentDataSerializer method fromData.

public LayoutComponent fromData(final PropertySet layoutData, final List<PropertySet> componentsAsData) {
    final LayoutComponent.Builder layoutComponent = LayoutComponent.create();
    final LayoutRegions.Builder layoutRegionsBuilder = LayoutRegions.create();
    final PropertySet specialBlockSet = layoutData.getSet(LayoutComponentType.INSTANCE.toString());
    if (specialBlockSet != null && specialBlockSet.isNotNull(DESCRIPTOR)) {
        final DescriptorKey descriptorKey = DescriptorKey.from(specialBlockSet.getString(DESCRIPTOR));
        layoutComponent.descriptor(descriptorKey);
        layoutComponent.config(getConfigFromData(specialBlockSet, descriptorKey));
        final LayoutDescriptor layoutDescriptor = layoutDescriptorService.getByKey(descriptorKey);
        final String layoutPath = layoutData.getString(PATH);
        if (layoutDescriptor.getRegions() != null && layoutDescriptor.getRegions().numberOfRegions() > 0) {
            layoutDescriptor.getRegions().forEach(regionDescriptor -> {
                layoutRegionsBuilder.add(regionDataSerializer.fromData(regionDescriptor, layoutPath, componentsAsData));
            });
        }
    }
    layoutComponent.regions(layoutRegionsBuilder.build());
    return layoutComponent.build();
}
Also used : LayoutDescriptor(com.enonic.xp.region.LayoutDescriptor) PropertySet(com.enonic.xp.data.PropertySet) DescriptorKey(com.enonic.xp.page.DescriptorKey) LayoutComponent(com.enonic.xp.region.LayoutComponent) LayoutRegions(com.enonic.xp.region.LayoutRegions)

Example 34 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class TaskDescriptorLoaderTest method testCreateDefault.

@Test
public void testCreateDefault() {
    final DescriptorKey key = DescriptorKey.from("myapp1:task1");
    final TaskDescriptor descriptor = this.loader.createDefault(key);
    assertEquals(key, descriptor.getKey());
    assertEquals("task1", descriptor.getName());
}
Also used : TaskDescriptor(com.enonic.xp.task.TaskDescriptor) DescriptorKey(com.enonic.xp.page.DescriptorKey) Test(org.junit.jupiter.api.Test)

Example 35 with DescriptorKey

use of com.enonic.xp.page.DescriptorKey in project xp by enonic.

the class ServiceDescriptorServiceImplTest method testGetByKey_default.

@Test
public void testGetByKey_default() throws Exception {
    final DescriptorKey key = DescriptorKey.from("myapp1:unknown");
    final ServiceDescriptor descriptor = this.service.getByKey(key);
    assertNotNull(descriptor);
}
Also used : ServiceDescriptor(com.enonic.xp.service.ServiceDescriptor) DescriptorKey(com.enonic.xp.page.DescriptorKey) Test(org.junit.jupiter.api.Test) AbstractDescriptorServiceTest(com.enonic.xp.core.impl.content.page.AbstractDescriptorServiceTest)

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