use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ContentMappingConstraint method getXData.
private PropertyTree getXData(final ExtraDatas xDatas, final String appPrefix, final String name) {
if (xDatas == null) {
return null;
}
try {
final ApplicationKey app = ExtraData.fromApplicationPrefix(appPrefix);
final XDataName xDataName = XDataName.from(app, name);
final ExtraData extraData = xDatas.getMetadata(xDataName);
if (extraData == null) {
return null;
}
return extraData.getData();
} catch (Exception e) {
return null;
}
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class AdminToolPortalHandler method getDescriptorKey.
public static DescriptorKey getDescriptorKey(final WebRequest webRequest) {
final String path = webRequest.getRawPath();
if (path.startsWith(ADMIN_TOOL_PREFIX)) {
final String subPath = path.substring(ADMIN_TOOL_PREFIX.length());
final Matcher matcher = PATTERN.matcher(subPath);
if (matcher.find()) {
final ApplicationKey applicationKey = ApplicationKey.from(matcher.group(1));
final String adminToolName = matcher.group(2);
return DescriptorKey.from(applicationKey, adminToolName);
}
}
return null;
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class XmlApplicationParserTest method testSiteXmlDeserialization.
@Test
public void testSiteXmlDeserialization() {
final String xml = loadTestXml("serialized-application.xml");
final ApplicationDescriptor.Builder appDescriptorBuilder = ApplicationDescriptor.create();
ApplicationKey applicationKey = ApplicationKey.from("myapplication");
this.parser.source(xml).currentApplication(applicationKey).appDescriptorBuilder(appDescriptorBuilder).parse();
ApplicationDescriptor applicationDescriptor = appDescriptorBuilder.build();
assertEquals("My app description", applicationDescriptor.getDescription());
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class XmlSiteParserTest method testSiteXmlDeserializationWithMappingFilters.
@Test
public void testSiteXmlDeserializationWithMappingFilters() {
final String xml = loadTestXml("serialized-site-with-mapping-filters.xml");
final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
ApplicationKey applicationKey = ApplicationKey.from("myapplication");
this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
assertEquals(2, siteDescriptor.getMappingDescriptors().getSize());
final ControllerMappingDescriptor mapping1 = siteDescriptor.getMappingDescriptors().get(0);
final ControllerMappingDescriptor mapping2 = siteDescriptor.getMappingDescriptors().get(1);
assertEquals("myapplication:/filter1.js", mapping1.getFilter().toString());
assertEquals("_path:'/*/fisk'", mapping1.getContentConstraint().toString());
assertEquals("/.*", mapping1.getPattern().toString());
assertEquals(50, mapping1.getOrder());
assertEquals("myapplication:/filter2.js", mapping2.getFilter().toString());
assertEquals("type:'portal:fragment'", mapping2.getContentConstraint().toString());
assertEquals("/.*", mapping2.getPattern().toString());
assertEquals(5, mapping2.getOrder());
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class XmlSiteParserTest method testEmptySiteXmlDeserialization.
@Test
public void testEmptySiteXmlDeserialization() {
final String xml = loadTestXml("empty-site.xml");
final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
ApplicationKey applicationKey = ApplicationKey.from("myapplication");
this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
assertEquals(0, siteDescriptor.getForm().getFormItems().size());
assertEquals(0, siteDescriptor.getXDataMappings().getSize());
assertEquals(0, siteDescriptor.getResponseProcessors().getSize());
assertEquals(0, siteDescriptor.getMappingDescriptors().getSize());
}
Aggregations