use of org.dom4j.io.SAXReader in project Spark by igniterealtime.
the class PluginViewer method getPluginList.
public Collection<PublicPlugin> getPluginList(InputStream response) {
final List<PublicPlugin> pluginList = new ArrayList<>();
SAXReader saxReader = new SAXReader();
Document pluginXML = null;
try {
pluginXML = saxReader.read(response);
} catch (DocumentException e) {
Log.error(e);
}
List<? extends Node> plugins = pluginXML.selectNodes("/plugins/plugin");
for (Node plugin1 : plugins) {
PublicPlugin publicPlugin = new PublicPlugin();
String clazz;
String name = null;
try {
Element plugin = (Element) plugin1;
try {
String version = plugin.selectSingleNode("minSparkVersion").getText();
if (!isGreaterOrEqual(JiveInfo.getVersion(), version)) {
Log.error("Unable to load plugin " + name + " due to min version incompatibility.");
continue;
}
} catch (Exception e) {
Log.error("Unable to load plugin " + name + " due to no minSparkVersion.");
continue;
}
name = plugin.selectSingleNode("name").getText();
clazz = plugin.selectSingleNode("class").getText();
publicPlugin.setPluginClass(clazz);
publicPlugin.setName(name);
try {
String version = plugin.selectSingleNode("version").getText();
publicPlugin.setVersion(version);
String author = plugin.selectSingleNode("author").getText();
publicPlugin.setAuthor(author);
Node emailNode = plugin.selectSingleNode("email");
if (emailNode != null) {
publicPlugin.setEmail(emailNode.getText());
}
Node descriptionNode = plugin.selectSingleNode("description");
if (descriptionNode != null) {
publicPlugin.setDescription(descriptionNode.getText());
}
Node homePageNode = plugin.selectSingleNode("homePage");
if (homePageNode != null) {
publicPlugin.setHomePage(homePageNode.getText());
}
Node downloadNode = plugin.selectSingleNode("downloadURL");
if (downloadNode != null) {
String downloadURL = downloadNode.getText();
publicPlugin.setDownloadURL(downloadURL);
}
Node changeLogNode = plugin.selectSingleNode("changeLog");
if (changeLogNode != null) {
publicPlugin.setChangeLogURL(changeLogNode.getText());
}
Node readMeNode = plugin.selectSingleNode("readme");
if (readMeNode != null) {
publicPlugin.setReadMeURL(readMeNode.getText());
}
Node smallIcon = plugin.selectSingleNode("smallIcon");
if (smallIcon != null) {
publicPlugin.setSmallIconAvailable(true);
}
Node largeIcon = plugin.selectSingleNode("largeIcon");
if (largeIcon != null) {
publicPlugin.setLargeIconAvailable(true);
}
} catch (Exception e) {
Log.error("Error retrieving PluginInformation from xml.", e);
}
pluginList.add(publicPlugin);
} catch (Exception ex) {
ex.printStackTrace();
}
}
return pluginList;
}
use of org.dom4j.io.SAXReader in project Spark by igniterealtime.
the class PluginManager method loadInternalPlugins.
/**
* Loads an internal plugin.
*
* @param reader the inputstreamreader for an internal plugin.
*/
private void loadInternalPlugins(InputStreamReader reader) {
SAXReader saxReader = new SAXReader();
Document pluginXML = null;
try {
pluginXML = saxReader.read(reader);
} catch (DocumentException e) {
Log.error(e);
}
List<Element> plugins = pluginXML.selectNodes("/plugins/plugin");
for (final Element plugin : plugins) {
EventQueue.invokeLater(() -> {
String clazz = null;
String name;
try {
name = plugin.selectSingleNode("name").getText();
clazz = plugin.selectSingleNode("class").getText();
Plugin pluginClass1 = (Plugin) Class.forName(clazz).newInstance();
Log.debug(name + " has been loaded. Internal plugin.");
registerPlugin(pluginClass1);
} catch (Throwable ex) {
Log.error("Unable to load plugin " + clazz + ".", ex);
}
});
}
}
use of org.dom4j.io.SAXReader in project Spark by igniterealtime.
the class PluginManager method hasDependencies.
private boolean hasDependencies(File pluginFile) {
SAXReader saxReader = new SAXReader();
try {
final Document pluginXML = saxReader.read(pluginFile);
final List dependencies = pluginXML.selectNodes("plugin/depends/plugin");
return dependencies != null && dependencies.size() > 0;
} catch (DocumentException e) {
Log.error("Unable to read plugin dependencies from " + pluginFile, e);
return false;
}
}
use of org.dom4j.io.SAXReader in project sic by belluccifranco.
the class AfipServiceImpl method getFEAuth.
@Override
public FEAuthRequest getFEAuth(String afipNombreServicio, Empresa empresa) {
FEAuthRequest feAuthRequest = new FEAuthRequest();
String loginTicketResponse = "";
byte[] p12file = configuracionDelSistemaService.getConfiguracionDelSistemaPorEmpresa(empresa).getCertificadoAfip();
if (p12file.length == 0) {
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_cds_certificado_vacio"));
}
String p12signer = configuracionDelSistemaService.getConfiguracionDelSistemaPorEmpresa(empresa).getFirmanteCertificadoAfip();
String p12pass = configuracionDelSistemaService.getConfiguracionDelSistemaPorEmpresa(empresa).getPasswordCertificadoAfip();
// siempre devuelve por 12hs
long ticketTime = 3600000L;
byte[] loginTicketRequest_xml_cms = afipWebServiceSOAPClient.crearCMS(p12file, p12pass, p12signer, afipNombreServicio, ticketTime);
LoginCms loginCms = new LoginCms();
loginCms.setIn0(Base64.getEncoder().encodeToString(loginTicketRequest_xml_cms));
try {
loginTicketResponse = afipWebServiceSOAPClient.loginCMS(loginCms);
} catch (WebServiceClientException ex) {
LOGGER.error(ex.getMessage());
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_token_wsaa_error"));
}
try {
Reader tokenReader = new StringReader(loginTicketResponse);
Document tokenDoc = new SAXReader(false).read(tokenReader);
feAuthRequest.setToken(tokenDoc.valueOf("/loginTicketResponse/credentials/token"));
feAuthRequest.setSign(tokenDoc.valueOf("/loginTicketResponse/credentials/sign"));
feAuthRequest.setCuit(empresa.getCuip());
} catch (DocumentException ex) {
LOGGER.error(ex.getMessage());
throw new BusinessServiceException(ResourceBundle.getBundle("Mensajes").getString("mensaje_error_procesando_xml"));
}
return feAuthRequest;
}
use of org.dom4j.io.SAXReader in project eclipse-cs by checkstyle.
the class ProjectConfigurationFactory method getProjectConfiguration.
private static IProjectConfiguration getProjectConfiguration(InputStream in, IProject project) throws DocumentException, CheckstylePluginException {
SAXReader reader = new SAXReader();
Document document = reader.read(in);
Element root = document.getRootElement();
String version = root.attributeValue(XMLTags.FORMAT_VERSION_TAG);
if (!SUPPORTED_VERSIONS.contains(version)) {
throw new CheckstylePluginException(NLS.bind(Messages.errorUnknownFileFormat, version));
}
boolean useSimpleConfig = Boolean.valueOf(root.attributeValue(XMLTags.SIMPLE_CONFIG_TAG)).booleanValue();
boolean syncFormatter = Boolean.valueOf(root.attributeValue(XMLTags.SYNC_FORMATTER_TAG)).booleanValue();
List<ICheckConfiguration> checkConfigs = getLocalCheckConfigs(root, project);
List<FileSet> fileSets = getFileSets(root, checkConfigs);
List<IFilter> filters = getFilters(root);
return new ProjectConfiguration(project, checkConfigs, fileSets, filters, useSimpleConfig, syncFormatter);
}
Aggregations