jira4r-jh 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +14 -0
- data/NOTICE +3 -0
- data/README.textile +3 -0
- data/README.txt +3 -0
- data/Rakefile +187 -0
- data/VERSION +1 -0
- data/jira4r-jh.gemspec +88 -0
- data/lib/jira4r/.DS_Store +0 -0
- data/lib/jira4r/jira4r.rb +19 -0
- data/lib/jira4r/jira_tool.rb +239 -0
- data/lib/jira4r/v2/.DS_Store +0 -0
- data/lib/jira4r/v2/JiraSoapServiceDriver.rb +1140 -0
- data/lib/jira4r/v2/jiraService.rb +922 -0
- data/lib/jira4r/v2/jiraServiceMappingRegistry.rb +1096 -0
- data/lib/jiraService.rb +21 -0
- data/lib/jiraServiceMappingRegistry.rb +21 -0
- data/spec/.gitignore +1 -0
- data/spec/jira4r_spec.rb +11 -0
- data/spec/spec_helper.rb +10 -0
- data/wsdl/jirasoapservice-v2.wsdl +8551 -0
- metadata +211 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
httpclient (2.1.6)
|
6
|
+
jeweler (1.5.2)
|
7
|
+
bundler (~> 1.0.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
rake (0.8.7)
|
11
|
+
rspec (1.3.0)
|
12
|
+
soap4r (1.5.8)
|
13
|
+
httpclient (>= 2.1.1)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
x86-mingw32
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
bundler (~> 1.0.0)
|
20
|
+
jeweler (~> 1.5.2)
|
21
|
+
rspec (< 2.0.0)
|
22
|
+
soap4r
|
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
Copyright 2006-2009 Codehaus Foundation
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
you may not use this file except in compliance with the License.
|
6
|
+
You may obtain a copy of the License at
|
7
|
+
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
See the License for the specific language governing permissions and
|
14
|
+
limitations under the License.
|
data/NOTICE
ADDED
data/README.textile
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
h1. jira4r
|
2
|
+
|
3
|
+
The current gem version of jira4r (0.3.0) is ancient. There is a more up to date version here http://xircles.rubyhaus.org/projects/jira4r so I have just cloned it so I can create my own gem of the source (jira4r-jh). Once a more up to date version of jira4r get's released I will remove this one.
|
data/README.txt
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
h1. jira4r
|
2
|
+
|
3
|
+
The current gem version of jira4r (0.3.0) is ancient. There is a more up to date version here http://xircles.rubyhaus.org/projects/jira4r so I have just cloned it so I can create my own gem of the source (jira4r-jh). Once a more up to date version of jira4r get's released I will remove this one.
|
data/Rakefile
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
require 'bundler'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
rescue Exception
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
Bundler.setup(:default, :development)
|
16
|
+
rescue Bundler::BundlerError => e
|
17
|
+
$stderr.puts e.message
|
18
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
19
|
+
exit e.status_code
|
20
|
+
end
|
21
|
+
require 'rake'
|
22
|
+
require 'jeweler'
|
23
|
+
|
24
|
+
Jeweler::Tasks.new do |gem|
|
25
|
+
gem.name = "jira4r-jh"
|
26
|
+
gem.homepage = "http://xircles.rubyhaus.org/projects/jira4r"
|
27
|
+
gem.license = "Apache"
|
28
|
+
gem.summary = %Q{Clone of latest source from http://xircles.rubyhaus.org/projects/jira4r }
|
29
|
+
gem.description = %Q{the current version of jira4r is quite old. there is a newer version but there isn't a new gem for it so I am just releasing it}
|
30
|
+
gem.email = "jamiehollingworth@gmail.com"
|
31
|
+
gem.authors = ["James Stuart", "James Hollingworth"]
|
32
|
+
|
33
|
+
gem.add_runtime_dependency 'soap4r'
|
34
|
+
gem.add_development_dependency 'rspec', '> 1.2.3'
|
35
|
+
gem.add_development_dependency 'jeweler'
|
36
|
+
gem.add_development_dependency 'bundler'
|
37
|
+
end
|
38
|
+
Jeweler::RubygemsDotOrgTasks.new
|
39
|
+
|
40
|
+
|
41
|
+
gem 'soap4r'
|
42
|
+
|
43
|
+
require 'wsdl/soap/wsdl2ruby'
|
44
|
+
|
45
|
+
logger = Logger.new(STDERR)
|
46
|
+
logger.level = Logger::INFO
|
47
|
+
|
48
|
+
|
49
|
+
desc "gets the wsdl and generates the classes"
|
50
|
+
task :default => [:generate]
|
51
|
+
|
52
|
+
|
53
|
+
desc "gets the wsdl files for JIRA services"
|
54
|
+
task :getwsdl do
|
55
|
+
versions().each { |version|
|
56
|
+
save(getWsdlFileName(version), get_file("jira.codehaus.org", "/rpc/soap/jirasoapservice-v#{version}?wsdl"))
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
task :clean do
|
61
|
+
def unl(file)
|
62
|
+
File.unlink(file) if File.exist?(file)
|
63
|
+
end
|
64
|
+
unl("wsdl/jirasoapservice-v2.wsdl")
|
65
|
+
unl("lib/jira4r/v2/jiraService.rb")
|
66
|
+
unl("lib/jira4r/v2/jiraServiceDriver.rb")
|
67
|
+
unl("lib/jira4r/v2/jiraServiceMappingRegistry.rb")
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "generate the wsdl"
|
71
|
+
task :generate do
|
72
|
+
versions().each { |version|
|
73
|
+
wsdl = getWsdlFileName(version)
|
74
|
+
basedir = "lib/jira4r/v#{version}"
|
75
|
+
mkdir_p basedir
|
76
|
+
|
77
|
+
if not File.exist?(wsdl)
|
78
|
+
raise "WSDL does not exist: #{wsdl}"
|
79
|
+
end
|
80
|
+
wsdl_url = "file://#{File.expand_path(wsdl)}"
|
81
|
+
|
82
|
+
# Create the server
|
83
|
+
worker = WSDL::SOAP::WSDL2Ruby.new
|
84
|
+
worker.logger = logger
|
85
|
+
worker.location = wsdl_url
|
86
|
+
worker.basedir = basedir
|
87
|
+
worker.opt['force'] = true
|
88
|
+
worker.opt['classdef'] = "jiraService"
|
89
|
+
worker.opt['module_path'] ="Jira4R::V#{version}"
|
90
|
+
|
91
|
+
worker.opt['mapping_registry'] = true
|
92
|
+
#worker.run
|
93
|
+
|
94
|
+
#Create the driver
|
95
|
+
#worker = WSDL::SOAP::WSDL2Ruby.new
|
96
|
+
#worker.logger = logger
|
97
|
+
#worker.location = wsdl_url
|
98
|
+
#worker.basedir = basedir
|
99
|
+
#worker.opt['force'] = true
|
100
|
+
#worker.opt['module_path'] = "Jira4R::V#{version}"
|
101
|
+
|
102
|
+
worker.opt['driver'] = "JiraSoapService"
|
103
|
+
worker.run
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
def versions
|
108
|
+
[ 2 ]
|
109
|
+
end
|
110
|
+
|
111
|
+
def get_file(host, path)
|
112
|
+
puts "getting http://#{host}#{path}"
|
113
|
+
http = Net::HTTP.new(host)
|
114
|
+
http.start { |w| w.get2(path).body }
|
115
|
+
end
|
116
|
+
|
117
|
+
def getWsdlFileName(vName)
|
118
|
+
"wsdl/jirasoapservice-v#{vName}.wsdl"
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
# Saves this document to the specified @var path.
|
123
|
+
# doesn't create the file if contains markup for 404 page
|
124
|
+
def save( path, content )
|
125
|
+
File::open(path, 'w') { | f |
|
126
|
+
f.write( content )
|
127
|
+
}
|
128
|
+
end
|
129
|
+
|
130
|
+
def fix_soap_files(version)
|
131
|
+
fix_require("lib/jira4r/v#{version}/jiraServiceMappingRegistry.rb")
|
132
|
+
fix_require("lib/jira4r/v#{version}/JiraSoapServiceDriver.rb")
|
133
|
+
end
|
134
|
+
|
135
|
+
def fix_require(filename)
|
136
|
+
content = ""
|
137
|
+
File.open(filename) { |io|
|
138
|
+
content = io.read()
|
139
|
+
|
140
|
+
content = fix_content(content, 'jiraService')
|
141
|
+
content = fix_content(content, 'jiraServiceMappingRegistry')
|
142
|
+
}
|
143
|
+
|
144
|
+
File.open(filename, "w") { |io|
|
145
|
+
io.write(content)
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
def fix_content(content, name)
|
150
|
+
return content.gsub("require '#{name}.rb'", "require File.dirname(__FILE__) + '/#{name}.rb'")
|
151
|
+
end
|
152
|
+
|
153
|
+
SPEC_DIR = File.join(File.dirname(__FILE__), 'spec')
|
154
|
+
FIXTURE_DIR = File.join(SPEC_DIR, 'fixtures')
|
155
|
+
SPECS = "#{SPEC_DIR}/*_spec.rb"
|
156
|
+
|
157
|
+
begin
|
158
|
+
require 'spec/rake/spectask'
|
159
|
+
|
160
|
+
begin
|
161
|
+
require 'rcov/rcovtask'
|
162
|
+
|
163
|
+
Spec::Rake::SpecTask.new do |t|
|
164
|
+
t.libs << SPEC_DIR
|
165
|
+
t.pattern = SPECS
|
166
|
+
t.rcov = true
|
167
|
+
t.rcov_dir = "#{SPEC_DIR}/coverage"
|
168
|
+
t.verbose = true
|
169
|
+
end
|
170
|
+
|
171
|
+
desc "Generate and open coverage reports"
|
172
|
+
task :rcov do
|
173
|
+
system "open #{SPEC_DIR}/coverage/index.html"
|
174
|
+
end
|
175
|
+
task :rcov => :spec
|
176
|
+
rescue LoadError
|
177
|
+
### Enabling these warnings makes every run of rake whiny unless you have these gems.
|
178
|
+
# warn ">>> You don't seem to have the rcov gem installed; not adding coverage tasks"
|
179
|
+
Spec::Rake::SpecTask.new do |t|
|
180
|
+
t.libs << SPEC_DIR
|
181
|
+
t.pattern = SPECS
|
182
|
+
t.verbose = true
|
183
|
+
end
|
184
|
+
end
|
185
|
+
rescue LoadError
|
186
|
+
# warn ">>> You don't seem to have the rspec gem installed; not adding rspec tasks"
|
187
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.0
|
data/jira4r-jh.gemspec
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{jira4r-jh}
|
8
|
+
s.version = "0.4.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["James Stuart", "James Hollingworth"]
|
12
|
+
s.date = %q{2011-01-01}
|
13
|
+
s.description = %q{the current version of jira4r is quite old. there is a newer version but there isn't a new gem for it so I am just releasing it}
|
14
|
+
s.email = %q{jamiehollingworth@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.textile",
|
18
|
+
"README.txt"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE",
|
24
|
+
"NOTICE",
|
25
|
+
"README.textile",
|
26
|
+
"README.txt",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"jira4r-jh.gemspec",
|
30
|
+
"lib/jira4r/.DS_Store",
|
31
|
+
"lib/jira4r/jira4r.rb",
|
32
|
+
"lib/jira4r/jira_tool.rb",
|
33
|
+
"lib/jira4r/v2/.DS_Store",
|
34
|
+
"lib/jira4r/v2/JiraSoapServiceDriver.rb",
|
35
|
+
"lib/jira4r/v2/jiraService.rb",
|
36
|
+
"lib/jira4r/v2/jiraServiceMappingRegistry.rb",
|
37
|
+
"lib/jiraService.rb",
|
38
|
+
"lib/jiraServiceMappingRegistry.rb",
|
39
|
+
"spec/.gitignore",
|
40
|
+
"spec/jira4r_spec.rb",
|
41
|
+
"spec/spec_helper.rb",
|
42
|
+
"wsdl/jirasoapservice-v2.wsdl"
|
43
|
+
]
|
44
|
+
s.homepage = %q{http://xircles.rubyhaus.org/projects/jira4r}
|
45
|
+
s.licenses = ["Apache"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = %q{1.3.7}
|
48
|
+
s.summary = %q{Clone of latest source from http://xircles.rubyhaus.org/projects/jira4r}
|
49
|
+
s.test_files = [
|
50
|
+
"spec/jira4r_spec.rb",
|
51
|
+
"spec/spec_helper.rb"
|
52
|
+
]
|
53
|
+
|
54
|
+
if s.respond_to? :specification_version then
|
55
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
56
|
+
s.specification_version = 3
|
57
|
+
|
58
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
|
+
s.add_runtime_dependency(%q<soap4r>, [">= 0"])
|
60
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
61
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
62
|
+
s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
|
63
|
+
s.add_runtime_dependency(%q<soap4r>, [">= 0"])
|
64
|
+
s.add_development_dependency(%q<rspec>, ["> 1.2.3"])
|
65
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<soap4r>, [">= 0"])
|
69
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
70
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
71
|
+
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
72
|
+
s.add_dependency(%q<soap4r>, [">= 0"])
|
73
|
+
s.add_dependency(%q<rspec>, ["> 1.2.3"])
|
74
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
75
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
76
|
+
end
|
77
|
+
else
|
78
|
+
s.add_dependency(%q<soap4r>, [">= 0"])
|
79
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
80
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
81
|
+
s.add_dependency(%q<rspec>, ["< 2.0.0"])
|
82
|
+
s.add_dependency(%q<soap4r>, [">= 0"])
|
83
|
+
s.add_dependency(%q<rspec>, ["> 1.2.3"])
|
84
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
85
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright 2007 Codehaus Foundation #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); #
|
5
|
+
# you may not use this file except in compliance with the License. #
|
6
|
+
# You may obtain a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
################################################################################
|
16
|
+
|
17
|
+
#Oh how I hate thee...
|
18
|
+
$: << File.dirname(__FILE__) + '/..'
|
19
|
+
require 'jira4r/jira_tool.rb'
|
@@ -0,0 +1,239 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright 2006-2009 Codehaus Foundation
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
################################################################################
|
16
|
+
require 'logger'
|
17
|
+
|
18
|
+
#It is the responsibility of the caller to ensure SOAP4R is installed and working correctly
|
19
|
+
#require 'rubygems'
|
20
|
+
#gem 'soap4r'
|
21
|
+
|
22
|
+
module Jira4R
|
23
|
+
|
24
|
+
class JiraTool
|
25
|
+
attr_accessor :enhanced
|
26
|
+
|
27
|
+
# Create a new JiraTool
|
28
|
+
#
|
29
|
+
# where:
|
30
|
+
# version ... the version of the SOAP API you wish to use - currently supported versions [ 2 ]
|
31
|
+
# base_url ... the base URL of the JIRA instance - eg. http://confluence.atlassian.com
|
32
|
+
def initialize(version, base_url)
|
33
|
+
@version = version
|
34
|
+
@base_url = base_url
|
35
|
+
@logger = Logger.new(STDERR)
|
36
|
+
@endpoint_url = "#{@base_url}/rpc/soap/jirasoapservice-v#{version}"
|
37
|
+
end
|
38
|
+
|
39
|
+
#Assign a new logger to the tool. By default a STDERR logger is used.
|
40
|
+
def logger=(logger)
|
41
|
+
@logger = logger
|
42
|
+
end
|
43
|
+
|
44
|
+
def http_auth(http_username, http_password, http_realm)
|
45
|
+
@http_username = http_username
|
46
|
+
@http_password = http_password
|
47
|
+
@http_realm = http_realm
|
48
|
+
end
|
49
|
+
|
50
|
+
#Retrieve the driver, creating as required.
|
51
|
+
def driver()
|
52
|
+
if not @driver
|
53
|
+
@logger.info( "Connecting driver to #{@endpoint_url}" )
|
54
|
+
|
55
|
+
require "jira4r/v#{@version}/jiraService.rb"
|
56
|
+
require "jira4r/v#{@version}/JiraSoapServiceDriver.rb"
|
57
|
+
require "jira4r/v#{@version}/jiraServiceMappingRegistry.rb"
|
58
|
+
|
59
|
+
service_classname = "Jira4R::V#{@version}::JiraSoapService"
|
60
|
+
puts "Service: #{service_classname}"
|
61
|
+
service = eval(service_classname)
|
62
|
+
@driver = service.send(:new, @endpoint_url)
|
63
|
+
|
64
|
+
if not ( @http_realm.nil? or @http_username.nil? or @http_password.nil? )
|
65
|
+
@driver.options["protocol.http.basic_auth"] << [ @http_realm, @http_username, @http_password ]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
@driver
|
69
|
+
end
|
70
|
+
|
71
|
+
#Assign a wiredump file prefix to the driver.
|
72
|
+
def wiredump_file_base=(base)
|
73
|
+
driver().wiredump_file_base = base
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
#Login to the JIRA instance, storing the token for later calls.
|
78
|
+
#
|
79
|
+
#This is typically the first call that is made on the JiraTool.
|
80
|
+
def login(username, password)
|
81
|
+
@token = driver().login(username, password)
|
82
|
+
end
|
83
|
+
|
84
|
+
#Clients should avoid using the authentication token directly.
|
85
|
+
def token()
|
86
|
+
@token
|
87
|
+
end
|
88
|
+
|
89
|
+
#Call a method on the driver, adding in the authentication token previously determined using login()
|
90
|
+
def call_driver(method_name, *args)
|
91
|
+
@logger.debug("Finding method #{method_name}")
|
92
|
+
method = driver().method(method_name)
|
93
|
+
|
94
|
+
if args.length > 0
|
95
|
+
method.call(@token, *args)
|
96
|
+
else
|
97
|
+
method.call(@token)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
#Retrieve a project without the associated PermissionScheme.
|
102
|
+
#This will be significantly faster for larger Jira installations.
|
103
|
+
#See: JRA-10660
|
104
|
+
def getProjectNoScheme(key)
|
105
|
+
puts "getProjectNoScheme is deprecated. Please call getProjectNoSchemes."
|
106
|
+
getProjectNoSchemes(key)
|
107
|
+
end
|
108
|
+
|
109
|
+
def getProjectNoSchemes(key)
|
110
|
+
self.getProjectsNoSchemes().find { |project| project.key == key }
|
111
|
+
end
|
112
|
+
|
113
|
+
def getProject(key)
|
114
|
+
#Jira > 3.10 has been patched to support this method directly as getProjectByKey
|
115
|
+
puts "Using deprecated JIRA4R API call getProject(key); replace with getProjectByKey(key)"
|
116
|
+
return getProjectByKey(key)
|
117
|
+
end
|
118
|
+
|
119
|
+
def getProjectByKey( projectKey )
|
120
|
+
begin
|
121
|
+
return call_driver( "getProjectByKey", projectKey )
|
122
|
+
rescue SOAP::FaultError => soap_error
|
123
|
+
#XXX surely there is a better way to detect this kind of condition in the JIRA server
|
124
|
+
if (soap_error.faultcode.to_s == "soapenv:Server.userException") and
|
125
|
+
(soap_error.faultstring.to_s =~ /No project could be found with key '#{projectKey}'/)
|
126
|
+
return nil
|
127
|
+
else
|
128
|
+
raise soap_error
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def getGroup( groupName )
|
134
|
+
begin
|
135
|
+
return call_driver( "getGroup", groupName )
|
136
|
+
rescue SOAP::FaultError => soap_error
|
137
|
+
#XXX surely there is a better way to detect this kind of condition in the JIRA server
|
138
|
+
if soap_error.faultcode.to_s == "soapenv:Server.userException" and soap_error.faultstring.to_s == "com.atlassian.jira.rpc.exception.RemoteValidationException: no group found for that groupName: #{groupName}"
|
139
|
+
return nil
|
140
|
+
else
|
141
|
+
raise soap_error
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def getProjectRoleByName( projectRoleName )
|
147
|
+
getProjectRoles.each{ |projectRole|
|
148
|
+
return projectRole if projectRole.name == projectRoleName
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
152
|
+
def getPermissionScheme( permissionSchemeName )
|
153
|
+
self.getPermissionSchemes().each { |permission_scheme|
|
154
|
+
return permission_scheme if permission_scheme.name == permissionSchemeName
|
155
|
+
}
|
156
|
+
return nil
|
157
|
+
end
|
158
|
+
|
159
|
+
def getNotificationScheme( notificationSchemeName )
|
160
|
+
self.getNotificationSchemes().each { |notification_scheme|
|
161
|
+
return notification_scheme if notification_scheme.name == notificationSchemeName
|
162
|
+
}
|
163
|
+
return nil
|
164
|
+
end
|
165
|
+
|
166
|
+
def getPermission( permissionName )
|
167
|
+
if not @permissions
|
168
|
+
@permissions = self.getAllPermissions()
|
169
|
+
end
|
170
|
+
|
171
|
+
@permissions.each { |permission|
|
172
|
+
return permission if permission.name.downcase == permissionName.downcase
|
173
|
+
}
|
174
|
+
|
175
|
+
@logger.warn("No permission #{permissionName} found")
|
176
|
+
return nil
|
177
|
+
end
|
178
|
+
|
179
|
+
def findPermission(allowedPermissions, permissionName)
|
180
|
+
allowedPermissions.each { |allowedPermission|
|
181
|
+
#puts "Checking #{allowedPermission.name} against #{permissionName} "
|
182
|
+
return allowedPermission if allowedPermission.name == permissionName
|
183
|
+
}
|
184
|
+
return nil
|
185
|
+
end
|
186
|
+
|
187
|
+
def findEntityInPermissionMapping(permissionMapping, entityName)
|
188
|
+
permissionMapping.remoteEntities.each { |entity|
|
189
|
+
return entity if entity.name == entityName
|
190
|
+
}
|
191
|
+
return nil
|
192
|
+
end
|
193
|
+
|
194
|
+
#Removes entity
|
195
|
+
def setPermissions( permissionScheme, allowedPermissions, entity)
|
196
|
+
allowedPermissions = [ allowedPermissions ].flatten.compact
|
197
|
+
#Remove permissions that are no longer allowed
|
198
|
+
permissionScheme.permissionMappings.each { |mapping|
|
199
|
+
next unless findEntityInPermissionMapping(mapping, entity.name)
|
200
|
+
|
201
|
+
allowedPermission = findPermission(allowedPermissions, mapping.permission.name)
|
202
|
+
if allowedPermission
|
203
|
+
puts "Already has #{allowedPermission.name} in #{permissionScheme.name} for #{entity.name}"
|
204
|
+
allowedPermissions.delete(allowedPermission)
|
205
|
+
next
|
206
|
+
end
|
207
|
+
|
208
|
+
puts "Deleting #{mapping.permission.name} from #{permissionScheme.name} for #{entity.name}"
|
209
|
+
deletePermissionFrom( permissionScheme, mapping.permission, entity)
|
210
|
+
}
|
211
|
+
|
212
|
+
puts allowedPermissions.inspect
|
213
|
+
allowedPermissions.each { |allowedPermission|
|
214
|
+
puts "Granting #{allowedPermission.name} to #{permissionScheme.name} for #{entity.name}"
|
215
|
+
addPermissionTo(permissionScheme, allowedPermission, entity)
|
216
|
+
}
|
217
|
+
end
|
218
|
+
|
219
|
+
private
|
220
|
+
def fix_args(args)
|
221
|
+
args.collect { |arg|
|
222
|
+
if arg == nil
|
223
|
+
SOAP::SOAPNil.new
|
224
|
+
else
|
225
|
+
arg
|
226
|
+
end
|
227
|
+
}
|
228
|
+
end
|
229
|
+
|
230
|
+
def method_missing(method_name, *args)
|
231
|
+
args = fix_args(args)
|
232
|
+
call_driver(method_name, *args)
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|