use of com.intellij.util.xmlb.XmlSerializationException in project intellij-community by JetBrains.
the class PluginManagerCore method loadDescriptorFromDir.
@Nullable
private static IdeaPluginDescriptorImpl loadDescriptorFromDir(@NotNull File file, @NotNull String fileName) {
File descriptorFile = new File(file, META_INF + File.separator + fileName);
if (descriptorFile.exists()) {
try {
IdeaPluginDescriptorImpl descriptor = new IdeaPluginDescriptorImpl(file);
descriptor.readExternal(descriptorFile.toURI().toURL());
return descriptor;
} catch (XmlSerializationException e) {
getLogger().info("Cannot load " + file, e);
prepareLoadingPluginsErrorMessage(Collections.singletonList("File '" + file.getName() + "' contains invalid plugin descriptor."));
} catch (Throwable e) {
getLogger().info("Cannot load " + file, e);
}
}
return null;
}
use of com.intellij.util.xmlb.XmlSerializationException in project intellij-community by JetBrains.
the class PluginManagerCore method loadDescriptorFromJar.
@Nullable
private static IdeaPluginDescriptorImpl loadDescriptorFromJar(@NotNull File file, @NotNull String fileName, @NotNull JDOMXIncluder.PathResolver pathResolver) {
try {
URL jarURL = URLUtil.getJarEntryURL(file, META_INF + '/' + fileName);
ZipFile zipFile = new ZipFile(file);
try {
ZipEntry entry = zipFile.getEntry(META_INF + '/' + fileName);
if (entry != null) {
Document document = JDOMUtil.loadDocument(zipFile.getInputStream(entry));
IdeaPluginDescriptorImpl descriptor = new IdeaPluginDescriptorImpl(file);
descriptor.readExternal(document, jarURL, pathResolver);
return descriptor;
}
} finally {
zipFile.close();
}
} catch (XmlSerializationException e) {
getLogger().info("Cannot load " + file, e);
prepareLoadingPluginsErrorMessage(Collections.singletonList("File '" + file.getName() + "' contains invalid plugin descriptor."));
} catch (Throwable e) {
getLogger().info("Cannot load " + file, e);
}
return null;
}
use of com.intellij.util.xmlb.XmlSerializationException in project intellij-community by JetBrains.
the class ShowSerializedXmlAction method generateAndShowXml.
private static void generateAndShowXml(final Module module, final String className) {
final List<URL> urls = new ArrayList<>();
final List<String> list = OrderEnumerator.orderEntries(module).recursively().runtimeOnly().getPathsList().getPathList();
for (String path : list) {
try {
urls.add(new File(FileUtil.toSystemIndependentName(path)).toURI().toURL());
} catch (MalformedURLException e1) {
LOG.info(e1);
}
}
final Project project = module.getProject();
UrlClassLoader loader = UrlClassLoader.build().urls(urls).parent(XmlSerializer.class.getClassLoader()).get();
final Class<?> aClass;
try {
aClass = Class.forName(className, true, loader);
} catch (ClassNotFoundException e) {
Messages.showErrorDialog(project, "Cannot find class '" + className + "'", CommonBundle.getErrorTitle());
LOG.info(e);
return;
}
final Object o;
try {
o = new SampleObjectGenerator().createValue(aClass, FList.<Type>emptyList());
} catch (Exception e) {
Messages.showErrorDialog(project, "Cannot generate class '" + className + "': " + e.getMessage(), CommonBundle.getErrorTitle());
LOG.info(e);
return;
}
final Element element;
try {
element = XmlSerializer.serialize(o);
} catch (XmlSerializationException e) {
LOG.info(e);
Throwable cause = e.getCause();
Messages.showErrorDialog(project, e.getMessage() + (cause != null ? ": " + cause.getMessage() : ""), CommonBundle.getErrorTitle());
return;
}
final String text = JDOMUtil.writeElement(element, "\n");
Messages.showIdeaMessageDialog(project, text, "Serialized XML for '" + className + "'", new String[] { CommonBundle.getOkButtonText() }, 0, Messages.getInformationIcon(), null);
}
Aggregations