wireframe-jira4r 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/jira4r.gemspec +63 -0
- data/lib/jira4r.rb +11 -0
- data/lib/jira4r/jira_tool.rb +234 -0
- data/lib/jira4r/server.rb +10 -0
- data/lib/jira4r/v2/jira_service.rb +882 -0
- data/lib/jira4r/v2/jira_service_mapping_registry.rb +1058 -0
- data/lib/jira4r/v2/jira_soap_service_driver.rb +1141 -0
- data/regen.sh +23 -0
- data/test/helper.rb +11 -0
- data/test/test_jira4r.rb +10 -0
- data/wireframe-jira4r.gemspec +65 -0
- data/wsdl/jirasoapservice-v2.wsdl +8535 -0
- metadata +116 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 James Stuart
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= jira4r
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 James Stuart. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "wireframe-jira4r"
|
8
|
+
gem.summary = %Q{JIRA Soap Interface Gem}
|
9
|
+
gem.description = %Q{JIRA Soap Interface Gem}
|
10
|
+
gem.email = "andrew@twitter.com"
|
11
|
+
gem.homepage = "http://github.com/aerickson/jira4r"
|
12
|
+
gem.authors = ["James Stuart", "Andrew Erickson", "Andrew Cantino", "Ryan Sonnek"]
|
13
|
+
gem.add_runtime_dependency "soap4r", ">= 0"
|
14
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "jira4r #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.1
|
data/jira4r.gemspec
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{jira4r}
|
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", "Andrew Erickson", "Andrew Cantino"]
|
12
|
+
s.date = %q{2010-05-28}
|
13
|
+
s.description = %q{JIRA Soap Interface Gem}
|
14
|
+
s.email = %q{andrew@twitter.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"jira4r.gemspec",
|
27
|
+
"lib/jira4r.rb",
|
28
|
+
"lib/jira4r/jira_tool.rb",
|
29
|
+
"lib/jira4r/server.rb",
|
30
|
+
"lib/jira4r/v2/jira_service.rb",
|
31
|
+
"lib/jira4r/v2/jira_service_mapping_registry.rb",
|
32
|
+
"lib/jira4r/v2/jira_soap_service_driver.rb",
|
33
|
+
"test/helper.rb",
|
34
|
+
"test/test_jira4r.rb",
|
35
|
+
"wsdl/jirasoapservice-v2.wsdl"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/aerickson/jira4r}
|
38
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.3.6}
|
41
|
+
s.summary = %q{JIRA Soap Interface Gem}
|
42
|
+
s.test_files = [
|
43
|
+
"test/helper.rb",
|
44
|
+
"test/test_jira4r.rb"
|
45
|
+
]
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_runtime_dependency(%q<soap4r>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<soap4r>, [">= 0"])
|
56
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
57
|
+
end
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<soap4r>, [">= 0"])
|
60
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
data/lib/jira4r.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'soap4r'
|
3
|
+
|
4
|
+
require "soap/rpc/driver"
|
5
|
+
require "soap/mapping"
|
6
|
+
require "logger"
|
7
|
+
require "jira4r/jira_tool"
|
8
|
+
require "jira4r/server"
|
9
|
+
require "jira4r/v2/jira_service"
|
10
|
+
require "jira4r/v2/jira_service_mapping_registry"
|
11
|
+
require "jira4r/v2/jira_soap_service_driver"
|
@@ -0,0 +1,234 @@
|
|
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
|
+
service_classname = "Jira4R::V#{@version}::JiraSoapService"
|
56
|
+
puts "Service: #{service_classname}"
|
57
|
+
service = eval(service_classname)
|
58
|
+
@driver = service.send(:new, @endpoint_url)
|
59
|
+
|
60
|
+
if not ( @http_realm.nil? or @http_username.nil? or @http_password.nil? )
|
61
|
+
@driver.options["protocol.http.basic_auth"] << [ @http_realm, @http_username, @http_password ]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
@driver
|
65
|
+
end
|
66
|
+
|
67
|
+
#Assign a wiredump file prefix to the driver.
|
68
|
+
def wiredump_file_base=(base)
|
69
|
+
driver().wiredump_file_base = base
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
#Login to the JIRA instance, storing the token for later calls.
|
74
|
+
#
|
75
|
+
#This is typically the first call that is made on the JiraTool.
|
76
|
+
def login(username, password)
|
77
|
+
@token = driver().login(username, password)
|
78
|
+
end
|
79
|
+
|
80
|
+
#Clients should avoid using the authentication token directly.
|
81
|
+
def token()
|
82
|
+
@token
|
83
|
+
end
|
84
|
+
|
85
|
+
#Call a method on the driver, adding in the authentication token previously determined using login()
|
86
|
+
def call_driver(method_name, *args)
|
87
|
+
@logger.debug("Finding method #{method_name}")
|
88
|
+
method = driver().method(method_name)
|
89
|
+
|
90
|
+
if args.length > 0
|
91
|
+
method.call(@token, *args)
|
92
|
+
else
|
93
|
+
method.call(@token)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
#Retrieve a project without the associated PermissionScheme.
|
98
|
+
#This will be significantly faster for larger Jira installations.
|
99
|
+
#See: JRA-10660
|
100
|
+
def getProjectNoScheme(key)
|
101
|
+
puts "getProjectNoScheme is deprecated. Please call getProjectNoSchemes."
|
102
|
+
getProjectNoSchemes(key)
|
103
|
+
end
|
104
|
+
|
105
|
+
def getProjectNoSchemes(key)
|
106
|
+
self.getProjectsNoSchemes().find { |project| project.key == key }
|
107
|
+
end
|
108
|
+
|
109
|
+
def getProject(key)
|
110
|
+
#Jira > 3.10 has been patched to support this method directly as getProjectByKey
|
111
|
+
puts "Using deprecated JIRA4R API call getProject(key); replace with getProjectByKey(key)"
|
112
|
+
return getProjectByKey(key)
|
113
|
+
end
|
114
|
+
|
115
|
+
def getProjectByKey( projectKey )
|
116
|
+
begin
|
117
|
+
return call_driver( "getProjectByKey", projectKey )
|
118
|
+
rescue SOAP::FaultError => soap_error
|
119
|
+
#XXX surely there is a better way to detect this kind of condition in the JIRA server
|
120
|
+
if soap_error.faultcode.to_s == "soapenv:Server.userException" and soap_error.faultstring.to_s == "com.atlassian.jira.rpc.exception.RemoteException: Project: #{projectKey} does not exist"
|
121
|
+
return nil
|
122
|
+
else
|
123
|
+
raise soap_error
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def getGroup( groupName )
|
129
|
+
begin
|
130
|
+
return call_driver( "getGroup", groupName )
|
131
|
+
rescue SOAP::FaultError => soap_error
|
132
|
+
#XXX surely there is a better way to detect this kind of condition in the JIRA server
|
133
|
+
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}"
|
134
|
+
return nil
|
135
|
+
else
|
136
|
+
raise soap_error
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def getProjectRoleByName( projectRoleName )
|
142
|
+
getProjectRoles.each{ |projectRole|
|
143
|
+
return projectRole if projectRole.name == projectRoleName
|
144
|
+
}
|
145
|
+
end
|
146
|
+
|
147
|
+
def getPermissionScheme( permissionSchemeName )
|
148
|
+
self.getPermissionSchemes().each { |permission_scheme|
|
149
|
+
return permission_scheme if permission_scheme.name == permissionSchemeName
|
150
|
+
}
|
151
|
+
return nil
|
152
|
+
end
|
153
|
+
|
154
|
+
def getNotificationScheme( notificationSchemeName )
|
155
|
+
self.getNotificationSchemes().each { |notification_scheme|
|
156
|
+
return notification_scheme if notification_scheme.name == notificationSchemeName
|
157
|
+
}
|
158
|
+
return nil
|
159
|
+
end
|
160
|
+
|
161
|
+
def getPermission( permissionName )
|
162
|
+
if not @permissions
|
163
|
+
@permissions = self.getAllPermissions()
|
164
|
+
end
|
165
|
+
|
166
|
+
@permissions.each { |permission|
|
167
|
+
return permission if permission.name.downcase == permissionName.downcase
|
168
|
+
}
|
169
|
+
|
170
|
+
@logger.warn("No permission #{permissionName} found")
|
171
|
+
return nil
|
172
|
+
end
|
173
|
+
|
174
|
+
def findPermission(allowedPermissions, permissionName)
|
175
|
+
allowedPermissions.each { |allowedPermission|
|
176
|
+
#puts "Checking #{allowedPermission.name} against #{permissionName} "
|
177
|
+
return allowedPermission if allowedPermission.name == permissionName
|
178
|
+
}
|
179
|
+
return nil
|
180
|
+
end
|
181
|
+
|
182
|
+
def findEntityInPermissionMapping(permissionMapping, entityName)
|
183
|
+
permissionMapping.remoteEntities.each { |entity|
|
184
|
+
return entity if entity.name == entityName
|
185
|
+
}
|
186
|
+
return nil
|
187
|
+
end
|
188
|
+
|
189
|
+
#Removes entity
|
190
|
+
def setPermissions( permissionScheme, allowedPermissions, entity)
|
191
|
+
allowedPermissions = [ allowedPermissions ].flatten.compact
|
192
|
+
#Remove permissions that are no longer allowed
|
193
|
+
permissionScheme.permissionMappings.each { |mapping|
|
194
|
+
next unless findEntityInPermissionMapping(mapping, entity.name)
|
195
|
+
|
196
|
+
allowedPermission = findPermission(allowedPermissions, mapping.permission.name)
|
197
|
+
if allowedPermission
|
198
|
+
puts "Already has #{allowedPermission.name} in #{permissionScheme.name} for #{entity.name}"
|
199
|
+
allowedPermissions.delete(allowedPermission)
|
200
|
+
next
|
201
|
+
end
|
202
|
+
|
203
|
+
puts "Deleting #{mapping.permission.name} from #{permissionScheme.name} for #{entity.name}"
|
204
|
+
deletePermissionFrom( permissionScheme, mapping.permission, entity)
|
205
|
+
}
|
206
|
+
|
207
|
+
puts allowedPermissions.inspect
|
208
|
+
allowedPermissions.each { |allowedPermission|
|
209
|
+
puts "Granting #{allowedPermission.name} to #{permissionScheme.name} for #{entity.name}"
|
210
|
+
addPermissionTo(permissionScheme, allowedPermission, entity)
|
211
|
+
}
|
212
|
+
end
|
213
|
+
|
214
|
+
private
|
215
|
+
def fix_args(args)
|
216
|
+
args.collect { |arg|
|
217
|
+
if arg == nil
|
218
|
+
SOAP::SOAPNil.new
|
219
|
+
else
|
220
|
+
arg
|
221
|
+
end
|
222
|
+
}
|
223
|
+
end
|
224
|
+
|
225
|
+
def method_missing(method_name, *args)
|
226
|
+
args = fix_args(args)
|
227
|
+
call_driver(method_name, *args)
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|