mirror of
https://github.com/greenshot/greenshot
synced 2025-07-31 04:00:13 -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 {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
|
||||
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 DateTime loggedInTime = DateTime.Now;
|
||||
private bool loggedIn = false;
|
||||
|
@ -105,13 +106,17 @@ namespace Confluence {
|
|||
private Cache<string, RemotePage> pageCache = new Cache<string, RemotePage>(60 * config.Timeout);
|
||||
|
||||
public ConfluenceConnector(string url, int timeout) {
|
||||
this.url = url;
|
||||
this.timeout = timeout;
|
||||
confluence = new ConfluenceSoapServiceService();
|
||||
confluence.Url = url;
|
||||
confluence.Proxy = NetworkHelper.CreateProxy(new Uri(url));
|
||||
init(url);
|
||||
}
|
||||
|
||||
private void init(string url) {
|
||||
this.url = url;
|
||||
confluence = new ConfluenceSoapServiceService();
|
||||
confluence.Url = url;
|
||||
confluence.Proxy = NetworkHelper.CreateProxy(new Uri(url));
|
||||
}
|
||||
|
||||
~ConfluenceConnector() {
|
||||
logout();
|
||||
}
|
||||
|
@ -126,6 +131,11 @@ namespace Confluence {
|
|||
this.loggedInTime = DateTime.Now;
|
||||
this.loggedIn = true;
|
||||
} 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
|
||||
if (e.Message.Contains(AUTH_FAILED_EXCEPTION_NAME)) {
|
||||
return false;
|
||||
|
@ -144,8 +154,9 @@ namespace Confluence {
|
|||
logout();
|
||||
try {
|
||||
// Get the system name, so the user knows where to login to
|
||||
string systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX,"");
|
||||
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
||||
string systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX1,"");
|
||||
systemName = url.Replace(ConfluenceConfiguration.DEFAULT_POSTFIX2, "");
|
||||
CredentialsDialog dialog = new CredentialsDialog(systemName);
|
||||
dialog.Name = null;
|
||||
while (dialog.Show(dialog.Name) == DialogResult.OK) {
|
||||
if (doLogin(dialog.Name, dialog.Password)) {
|
||||
|
|
|
@ -29,8 +29,9 @@ namespace GreenshotConfluencePlugin {
|
|||
[Serializable]
|
||||
[IniSection("Confluence", Description="Greenshot Confluence Plugin configuration")]
|
||||
public class ConfluenceConfiguration : IniSection {
|
||||
public const string DEFAULT_POSTFIX = "/rpc/soap-axis/confluenceservice-v1?wsdl";
|
||||
public const string DEFAULT_PREFIX = "http://";
|
||||
public const string DEFAULT_POSTFIX1 = "/rpc/soap-axis/confluenceservice-v1?wsdl";
|
||||
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";
|
||||
|
||||
[IniProperty("Url", Description="Url to Confluence system, including wsdl.", DefaultValue=DEFAULT_URL)]
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace GreenshotConfluencePlugin {
|
|||
if (config.Url.Contains("soap-axis")) {
|
||||
confluenceConnector = new ConfluenceConnector(config.Url, config.Timeout);
|
||||
} 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>();
|
||||
Regex pageIdRegex = new Regex(@"pageId=(\d+)");
|
||||
Regex spacePageRegex = new Regex(@"\/display\/([^\/]+)\/([^#]+)");
|
||||
foreach(string browserurl in GetBrowserUrls()) {
|
||||
foreach(string browserurl in GetBrowserUrls()) {
|
||||
string url = null;
|
||||
try {
|
||||
url = Uri.UnescapeDataString(browserurl).Replace("+", " ");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue