use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class SchemaLoader method loadIcon.
private Icon loadIcon(final N name, final String mimeType, final String ext) {
final ResourceKey resourceKey = toResourceKey(name, ext);
final Resource resource = this.resourceService.getResource(resourceKey);
return SchemaHelper.loadIcon(resource, mimeType);
}
use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class TaskDescriptorLoaderTest method testLoad.
@Test
public void testLoad() {
final DescriptorKey descriptorKey = DescriptorKey.from("myapp1:task1");
final ResourceKey resourceKey = this.loader.toResource(descriptorKey);
assertEquals("myapp1:/tasks/task1/task1.xml", resourceKey.toString());
final Resource resource = this.resourceService.getResource(resourceKey);
final TaskDescriptor descriptor = this.loader.load(descriptorKey, resource);
assertEquals("MyTask", descriptor.getDescription());
FormItem formItem = descriptor.getConfig().getFormItem("param1");
assertEquals(" something ", formItem.toInput().getDefaultValue().getRootValue());
}
use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class NamedTaskScriptFactoryImpl method doCreate.
private NamedTaskScript doCreate(final TaskDescriptor descriptor, final PropertyTree data) {
final ResourceKey scriptResourceKey = ResourceKey.from(descriptor.getApplicationKey(), TASKS_PATH_PREFIX + descriptor.getName() + "/" + descriptor.getName() + ".js");
final ScriptExports exports;
try {
exports = this.scriptService.execute(scriptResourceKey);
} catch (ResourceNotFoundException e) {
throw new TaskNotFoundException(descriptor.getKey(), "Missing task script");
}
final boolean exists = exports.hasMethod(NamedTaskScript.SCRIPT_METHOD_NAME);
if (!exists) {
throw new TaskNotFoundException(descriptor.getKey(), "Missing exported function '" + NamedTaskScript.SCRIPT_METHOD_NAME + "' in task script");
}
return new NamedTaskScript(exports, descriptor, data);
}
use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class WidgetDescriptorLoaderTest method testLoadMax.
@Test
public void testLoadMax() {
final DescriptorKey descriptorKey = DescriptorKey.from("myapp1:widget1");
final ResourceKey resourceKey = this.loader.toResource(descriptorKey);
assertEquals("myapp1:/admin/widgets/widget1/widget1.xml", resourceKey.toString());
final Resource resource = this.resourceService.getResource(resourceKey);
final WidgetDescriptor descriptor = this.loader.load(descriptorKey, resource);
assertEquals("MyWidget", descriptor.getDisplayName());
assertEquals(1, descriptor.getInterfaces().size());
assertTrue(descriptor.getInterfaces().contains("com.enonic.xp.my-interface"));
assertEquals(1, descriptor.getAllowedPrincipals().getSize());
assertTrue(descriptor.getAllowedPrincipals().contains(PrincipalKey.from("role:system.user.admin")));
}
use of com.enonic.xp.resource.ResourceKey in project xp by enonic.
the class StyleDescriptorTest method testToResourceKey.
@Test
public void testToResourceKey() {
final ResourceKey resourceKey = StyleDescriptor.toResourceKey(ApplicationKey.from("myapp"));
assertEquals("myapp:/site/styles.xml", resourceKey.toString());
}
Aggregations