Search in sources :

Example 51 with DescriptorKey

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

the class LayoutDescriptorServiceTest method testGetByKey.

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

Example 52 with DescriptorKey

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

the class AbstractDataSerializerTest method createPartComponent.

protected PartComponent createPartComponent(final String partName, final String descriptorKey, final PropertyTree partConfig) {
    final DescriptorKey descriptor = DescriptorKey.from(descriptorKey);
    Mockito.when(partDescriptorService.getByKey(descriptor)).thenReturn(PartDescriptor.create().key(descriptor).displayName(partName).config(Form.create().build()).build());
    return PartComponent.create().descriptor(descriptor).config(partConfig).build();
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey)

Example 53 with DescriptorKey

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

the class FlattenedPageRegionsIndexUpgrader method upgradeDescriptorBasedComponent.

private void upgradeDescriptorBasedComponent(PropertySet componentSet, final String componentType) {
    final String descriptorKeyStr = componentSet.getString(TGT_DESCRIPTOR_KEY);
    if (descriptorKeyStr != null) {
        final DescriptorKey descriptorKey = DescriptorKey.from(descriptorKeyStr);
        result.add(String.join(ELEMENT_DIVIDER, TGT_COMPONENTS_KEY, componentType, TGT_CONFIG_KEY, getSanitizedAppName(descriptorKey), getSanitizedComponentName(descriptorKey), "*"), IndexConfig.BY_TYPE);
    }
}
Also used : DescriptorKey(com.enonic.xp.page.DescriptorKey)

Example 54 with DescriptorKey

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

the class SchedulableTaskImpl method run.

@Override
public void run() {
    try {
        final TaskId taskId = taskContext().callWith(() -> OsgiSupport.withService(TaskService.class, taskService -> taskService.submitTask(SubmitTaskParams.create().descriptorKey(job.getDescriptor()).data(job.getConfig()).build())));
        adminContext().runWith(() -> OsgiSupport.withService(NodeService.class, nodeService -> UpdateLastRunCommand.create().nodeService(nodeService).name(job.getName()).lastRun(Instant.now()).lastTaskId(taskId).build().execute()));
    } catch (Exception e) {
        LOG.warn("Error while running job [{}]", this.job.getName(), e);
    } catch (Throwable t) {
        LOG.error("Error while running job [{}], no further attempts will be made", this.job.getName(), t);
        throw t;
    }
}
Also used : SubmitTaskParams(com.enonic.xp.task.SubmitTaskParams) LoggerFactory(org.slf4j.LoggerFactory) UpdateLastRunCommand(com.enonic.xp.impl.scheduler.UpdateLastRunCommand) ScheduledJob(com.enonic.xp.scheduler.ScheduledJob) ContextAccessor(com.enonic.xp.context.ContextAccessor) NodeService(com.enonic.xp.node.NodeService) TaskService(com.enonic.xp.task.TaskService) ContextBuilder(com.enonic.xp.context.ContextBuilder) VerifiedUsernameAuthToken(com.enonic.xp.security.auth.VerifiedUsernameAuthToken) SecurityService(com.enonic.xp.security.SecurityService) PropertyTree(com.enonic.xp.data.PropertyTree) User(com.enonic.xp.security.User) Logger(org.slf4j.Logger) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) Instant(java.time.Instant) OsgiSupport(com.enonic.xp.core.internal.osgi.OsgiSupport) Serializable(java.io.Serializable) TaskId(com.enonic.xp.task.TaskId) PrincipalKey(com.enonic.xp.security.PrincipalKey) DescriptorKey(com.enonic.xp.page.DescriptorKey) ScheduledJobName(com.enonic.xp.scheduler.ScheduledJobName) RoleKeys(com.enonic.xp.security.RoleKeys) Preconditions(com.google.common.base.Preconditions) Context(com.enonic.xp.context.Context) ScheduleCalendar(com.enonic.xp.scheduler.ScheduleCalendar) TaskId(com.enonic.xp.task.TaskId) TaskService(com.enonic.xp.task.TaskService) NodeService(com.enonic.xp.node.NodeService)

Example 55 with DescriptorKey

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

the class ServiceDescriptorServiceImpl method getByKey.

@Override
public ServiceDescriptor getByKey(final DescriptorKey descriptorKey) {
    final ResourceProcessor<DescriptorKey, ServiceDescriptor> processor = newRootProcessor(descriptorKey);
    final ServiceDescriptor descriptor = this.resourceService.processResource(processor);
    if (descriptor != null) {
        return descriptor;
    }
    return createDefaultDescriptor(descriptorKey);
}
Also used : ServiceDescriptor(com.enonic.xp.service.ServiceDescriptor) DescriptorKey(com.enonic.xp.page.DescriptorKey)

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