mirror of
https://github.com/greenshot/greenshot
synced 2025-07-30 03:30:02 -07:00
Added Confluence V2 support, preferring this and using fall back to V1 if this doesn't work at the login.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1944 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
d28bea64a7
commit
5c038ed1da
4 changed files with 23 additions and 11 deletions
|
@ -95,7 +95,8 @@ namespace Confluence {
|
||||||
public class ConfluenceConnector {
|
public class ConfluenceConnector {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
|
||||||
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.confluence.rpc.AuthenticationFailedException";
|
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.confluence.rpc.AuthenticationFailedException";
|
||||||
private static ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
private const string V2_FAILED = "AXIS";
|
||||||
|
private static ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
|
||||||
private string credentials = null;
|
private string credentials = null;
|
||||||
private DateTime loggedInTime = DateTime.Now;
|
private DateTime loggedInTime = DateTime.Now;
|
||||||
private bool loggedIn = false;
|
private bool loggedIn = false;
|
||||||
|
@ -105,13 +106,17 @@ namespace Confluence {
|
||||||
private Cache<string, RemotePage> pageCache = new Cache<string, RemotePage>(60 * config.Timeout);
|
private Cache<string, RemotePage> pageCache = new Cache<string, RemotePage>(60 * config.Timeout);
|
||||||
|
|
||||||
public ConfluenceConnector(string url, int timeout) {
|
public ConfluenceConnector(string url, int timeout) {
|
||||||
this.url = url;
|
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
confluence = new ConfluenceSoapServiceService();
|
init(url);
|
||||||
confluence.Url = url;
|
|
||||||
confluence.Proxy = NetworkHelper.CreateProxy(new Uri(url));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init(string url) {
|
||||||
|
this.url = url;
|
||||||
|
confluence = new ConfluenceSoapServiceService();
|
||||||
|
confluence.Url = url;
|
||||||
|
confluence.Proxy = NetworkHelper.CreateProxy(new Uri(url));
|
||||||
|
}
|
||||||
|
|
||||||
~ConfluenceConnector() {
|
~ConfluenceConnector() {
|
||||||
logout();
|
logout();
|
||||||
}
|
}
|
||||||
|
@ -126,6 +131,11 @@ namespace Confluence {
|
||||||
this.loggedInTime = DateTime.Now;
|
this.loggedInTime = DateTime.Now;
|
||||||
this.loggedIn = true;
|
this.loggedIn = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
// Check if confluence-v2 caused an error, use v1 instead
|
||||||
|
if (e.Message.Contains(V2_FAILED) && url.Contains("v2")) {
|
||||||
|
init(url.Replace("v2", "v1"));
|
||||||
|
return doLogin(user, password);
|
||||||
|
}
|
||||||
// check if auth failed
|
// check if auth failed
|
||||||
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -144,8 +154,9 @@ namespace Confluence {
|
||||||
logout();
|
logout();
|
||||||
try {
|
try {
|
||||||
// Get the system name, so the user knows where to login to
|
// Get the system name, so the user knows where to login to
|
||||||
string systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX,"");
|
string systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX1,"");
|
||||||
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX2, "");
|
||||||
|
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
||||||
dialog.Name = null;
|
dialog.Name = null;
|
||||||
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||||
if (doLogin(dialog.Name, dialog.Password)) {
|
if (doLogin(dialog.Name, dialog.Password)) {
|
||||||
|
|
|
@ -29,8 +29,9 @@ namespace GreenshotConfluencePlugin {
|
||||||
[Serializable]
|
[Serializable]
|
||||||
[IniSection("Confluence", Description="Greenshot Confluence Plugin configuration")]
|
[IniSection("Confluence", Description="Greenshot Confluence Plugin configuration")]
|
||||||
public class ConfluenceConfiguration : IniSection {
|
public class ConfluenceConfiguration : IniSection {
|
||||||
public const string DEFAULT_POSTFIX = "/rpc/soap-axis/confluenceservice-v1?wsdl";
|
public const string DEFAULT_POSTFIX1 = "/rpc/soap-axis/confluenceservice-v1?wsdl";
|
||||||
public const string DEFAULT_PREFIX = "http://";
|
public const string DEFAULT_POSTFIX2 = "/rpc/soap-axis/confluenceservice-v2?wsdl";
|
||||||
|
public const string DEFAULT_PREFIX = "http://";
|
||||||
private const string DEFAULT_URL = DEFAULT_PREFIX + "confluence";
|
private const string DEFAULT_URL = DEFAULT_PREFIX + "confluence";
|
||||||
|
|
||||||
[IniProperty("Url", Description="Url to Confluence system, including wsdl.", DefaultValue=DEFAULT_URL)]
|
[IniProperty("Url", Description="Url to Confluence system, including wsdl.", DefaultValue=DEFAULT_URL)]
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
if (config.Url.Contains("soap-axis")) {
|
if (config.Url.Contains("soap-axis")) {
|
||||||
confluenceConnector = new ConfluenceConnector(config.Url, config.Timeout);
|
confluenceConnector = new ConfluenceConnector(config.Url, config.Timeout);
|
||||||
} else {
|
} else {
|
||||||
confluenceConnector = new ConfluenceConnector(config.Url + ConfluenceConfiguration.DEFAULT_POSTFIX, config.Timeout);
|
confluenceConnector = new ConfluenceConnector(config.Url + ConfluenceConfiguration.DEFAULT_POSTFIX2, config.Timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
List<Confluence.Page> pages = new List<Confluence.Page>();
|
List<Confluence.Page> pages = new List<Confluence.Page>();
|
||||||
Regex pageIdRegex = new Regex(@"pageId=(\d+)");
|
Regex pageIdRegex = new Regex(@"pageId=(\d+)");
|
||||||
Regex spacePageRegex = new Regex(@"\/display\/([^\/]+)\/([^#]+)");
|
Regex spacePageRegex = new Regex(@"\/display\/([^\/]+)\/([^#]+)");
|
||||||
foreach(string browserurl in GetBrowserUrls()) {
|
foreach(string browserurl in GetBrowserUrls()) {
|
||||||
string url = null;
|
string url = null;
|
||||||
try {
|
try {
|
||||||
url = Uri.UnescapeDataString(browserurl).Replace("+", " ");
|
url = Uri.UnescapeDataString(browserurl).Replace("+", " ");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue