use of com.enonic.xp.xml.parser.XmlApplicationParser in project xp by enonic.
the class ApplicationDescriptorBuilder method build.
public ApplicationDescriptor build() {
final URL url = bundle.getResource(APP_DESCRIPTOR_FILENAME);
final String xml = parseAppXml(url);
ApplicationDescriptor.Builder appDescriptorBuilder = ApplicationDescriptor.create();
final XmlApplicationParser parser = new XmlApplicationParser().currentApplication(ApplicationKey.from(bundle)).appDescriptorBuilder(appDescriptorBuilder).source(xml);
parser.parse();
if (hasAppIcon(bundle)) {
final URL iconUrl = bundle.getResource(APP_ICON_FILENAME);
try (InputStream stream = iconUrl.openStream()) {
final byte[] iconData = stream.readAllBytes();
final Icon icon = Icon.from(iconData, "image/svg+xml", Instant.ofEpochMilli(this.bundle.getLastModified()));
appDescriptorBuilder.icon(icon);
} catch (IOException e) {
throw new RuntimeException("Unable to load application icon for " + bundle.getSymbolicName(), e);
}
}
return appDescriptorBuilder.build();
}
Aggregations