Lines 27-32
Link Here
|
27 |
import org.eclipse.mylyn.internal.jira.core.model.SecurityLevel; |
27 |
import org.eclipse.mylyn.internal.jira.core.model.SecurityLevel; |
28 |
import org.eclipse.mylyn.internal.jira.core.model.ServerInfo; |
28 |
import org.eclipse.mylyn.internal.jira.core.model.ServerInfo; |
29 |
import org.eclipse.mylyn.internal.jira.core.model.User; |
29 |
import org.eclipse.mylyn.internal.jira.core.model.User; |
|
|
30 |
import org.eclipse.osgi.util.NLS; |
30 |
|
31 |
|
31 |
/** |
32 |
/** |
32 |
* @author Steffen Pingel |
33 |
* @author Steffen Pingel |
Lines 64-83
Link Here
|
64 |
} |
65 |
} |
65 |
|
66 |
|
66 |
private void initializeProjects(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
67 |
private void initializeProjects(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
67 |
String version = data.serverInfo.getVersion(); |
68 |
monitor = Policy.monitorFor(monitor); |
68 |
|
69 |
|
69 |
data.projects = jiraClient.getProjects(monitor); |
70 |
data.projects = jiraClient.getProjects(monitor); |
70 |
|
71 |
|
71 |
data.projectsById = new HashMap<String, Project>(data.projects.length); |
72 |
try { |
72 |
data.projectsByKey = new HashMap<String, Project>(data.projects.length); |
73 |
monitor.beginTask(Messages.JiraClientCache_getting_project_details, data.projects.length); |
|
|
74 |
|
75 |
data.projectsById = new HashMap<String, Project>(data.projects.length); |
76 |
data.projectsByKey = new HashMap<String, Project>(data.projects.length); |
77 |
|
78 |
for (Project project : data.projects) { |
79 |
initializeProject(project, monitor); |
80 |
|
81 |
data.projectsById.put(project.getId(), project); |
82 |
data.projectsByKey.put(project.getKey(), project); |
83 |
Policy.advance(monitor, 1); |
84 |
} |
85 |
} finally { |
86 |
monitor.done(); |
87 |
} |
88 |
} |
89 |
|
90 |
private void initializeProject(Project project, IProgressMonitor monitor) throws JiraException { |
91 |
synchronized (project) { |
92 |
monitor.subTask(NLS.bind(Messages.JiraClientCache_project_details_for, project.getKey())); |
93 |
|
94 |
final String version = data.serverInfo.getVersion(); |
73 |
|
95 |
|
74 |
for (Project project : data.projects) { |
96 |
project.setComponents(jiraClient.getComponents(project.getKey(), Policy.subMonitorFor(monitor, 0))); |
75 |
project.setComponents(jiraClient.getComponents(project.getKey(), monitor)); |
97 |
project.setVersions(jiraClient.getVersions(project.getKey(), Policy.subMonitorFor(monitor, 0))); |
76 |
project.setVersions(jiraClient.getVersions(project.getKey(), monitor)); |
|
|
77 |
|
98 |
|
78 |
if (supportsPerProjectIssueTypes(version) >= 0) { |
99 |
if (supportsPerProjectIssueTypes(version) >= 0) { |
79 |
IssueType[] issueTypes = jiraClient.getIssueTypes(project.getId(), monitor); |
100 |
IssueType[] issueTypes = jiraClient.getIssueTypes(project.getId(), Policy.subMonitorFor(monitor, 0)); |
80 |
IssueType[] subTaskIssueTypes = jiraClient.getSubTaskIssueTypes(project.getId(), monitor); |
101 |
IssueType[] subTaskIssueTypes = jiraClient.getSubTaskIssueTypes(project.getId(), Policy.subMonitorFor( |
|
|
102 |
monitor, 1)); |
81 |
for (IssueType issueType : subTaskIssueTypes) { |
103 |
for (IssueType issueType : subTaskIssueTypes) { |
82 |
issueType.setSubTaskType(true); |
104 |
issueType.setSubTaskType(true); |
83 |
} |
105 |
} |
Lines 90-96
Link Here
|
90 |
} |
112 |
} |
91 |
if (new JiraVersion(version).compareTo(JiraVersion.JIRA_3_13) >= 0) { |
113 |
if (new JiraVersion(version).compareTo(JiraVersion.JIRA_3_13) >= 0) { |
92 |
try { |
114 |
try { |
93 |
SecurityLevel[] securityLevels = jiraClient.getAvailableSecurityLevels(project.getKey(), monitor); |
115 |
SecurityLevel[] securityLevels = jiraClient.getAvailableSecurityLevels(project.getKey(), |
|
|
116 |
Policy.subMonitorFor(monitor, 0)); |
94 |
if (securityLevels.length > 0) { |
117 |
if (securityLevels.length > 0) { |
95 |
SecurityLevel[] projectSecurityLevels = new SecurityLevel[securityLevels.length + 1]; |
118 |
SecurityLevel[] projectSecurityLevels = new SecurityLevel[securityLevels.length + 1]; |
96 |
projectSecurityLevels[0] = SecurityLevel.NONE; |
119 |
projectSecurityLevels[0] = SecurityLevel.NONE; |
Lines 102-110
Link Here
|
102 |
project.setSecurityLevels(null); |
125 |
project.setSecurityLevels(null); |
103 |
} |
126 |
} |
104 |
} |
127 |
} |
105 |
|
|
|
106 |
data.projectsById.put(project.getId(), project); |
107 |
data.projectsByKey.put(project.getKey(), project); |
108 |
} |
128 |
} |
109 |
} |
129 |
} |
110 |
|
130 |
|
Lines 121-130
Link Here
|
121 |
} |
141 |
} |
122 |
|
142 |
|
123 |
private void initializePriorities(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
143 |
private void initializePriorities(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
124 |
data.priorities = jiraClient.getPriorities(monitor); |
144 |
monitor = Policy.monitorFor(monitor); |
125 |
data.prioritiesById = new HashMap<String, Priority>(data.priorities.length); |
145 |
try { |
126 |
for (Priority priority : data.priorities) { |
146 |
monitor.beginTask(Messages.JiraClientCache_getting_priorities, 1); |
127 |
data.prioritiesById.put(priority.getId(), priority); |
147 |
data.priorities = jiraClient.getPriorities(monitor); |
|
|
148 |
data.prioritiesById = new HashMap<String, Priority>(data.priorities.length); |
149 |
for (Priority priority : data.priorities) { |
150 |
data.prioritiesById.put(priority.getId(), priority); |
151 |
} |
152 |
} finally { |
153 |
monitor.done(); |
128 |
} |
154 |
} |
129 |
} |
155 |
} |
130 |
|
156 |
|
Lines 137-198
Link Here
|
137 |
} |
163 |
} |
138 |
|
164 |
|
139 |
private void initializeIssueTypes(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
165 |
private void initializeIssueTypes(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
140 |
String version = data.serverInfo.getVersion(); |
166 |
monitor = Policy.monitorFor(monitor); |
141 |
if (supportsPerProjectIssueTypes(version) >= 0) { |
167 |
try { |
142 |
// collect issue types from all projects to avoid additional SOAP request |
168 |
monitor.beginTask(Messages.JiraClientCache_getting_issue_types, 2); |
143 |
Set<IssueType> issueTypes = new HashSet<IssueType>(); |
169 |
|
144 |
for (Project project : data.projects) { |
170 |
String version = data.serverInfo.getVersion(); |
145 |
IssueType[] projectIssueTypes = project.getIssueTypes(); |
171 |
if (supportsPerProjectIssueTypes(version) >= 0) { |
146 |
if (projectIssueTypes != null) { |
172 |
// collect issue types from all projects to avoid additional SOAP request |
147 |
issueTypes.addAll(Arrays.asList(projectIssueTypes)); |
173 |
Set<IssueType> issueTypes = new HashSet<IssueType>(); |
|
|
174 |
for (Project project : data.projects) { |
175 |
IssueType[] projectIssueTypes = project.getIssueTypes(); |
176 |
if (projectIssueTypes != null) { |
177 |
issueTypes.addAll(Arrays.asList(projectIssueTypes)); |
178 |
} |
148 |
} |
179 |
} |
149 |
} |
|
|
150 |
|
180 |
|
151 |
data.issueTypes = issueTypes.toArray(new IssueType[0]); |
181 |
data.issueTypes = issueTypes.toArray(new IssueType[0]); |
152 |
data.issueTypesById = new HashMap<String, IssueType>(data.issueTypes.length); |
182 |
data.issueTypesById = new HashMap<String, IssueType>(data.issueTypes.length); |
153 |
for (IssueType issueType : data.issueTypes) { |
183 |
for (IssueType issueType : data.issueTypes) { |
154 |
data.issueTypesById.put(issueType.getId(), issueType); |
184 |
data.issueTypesById.put(issueType.getId(), issueType); |
155 |
} |
185 |
} |
156 |
} else { |
|
|
157 |
IssueType[] issueTypes = jiraClient.getIssueTypes(monitor); |
158 |
IssueType[] subTaskIssueTypes; |
159 |
if (new JiraVersion(version).compareTo(JiraVersion.JIRA_3_3) >= 0) { |
160 |
subTaskIssueTypes = jiraClient.getSubTaskIssueTypes(monitor); |
161 |
} else { |
186 |
} else { |
162 |
subTaskIssueTypes = new IssueType[0]; |
187 |
IssueType[] issueTypes = jiraClient.getIssueTypes(Policy.subMonitorFor(monitor, 1)); |
163 |
} |
188 |
IssueType[] subTaskIssueTypes; |
|
|
189 |
if (new JiraVersion(version).compareTo(JiraVersion.JIRA_3_3) >= 0) { |
190 |
subTaskIssueTypes = jiraClient.getSubTaskIssueTypes(Policy.subMonitorFor(monitor, 1)); |
191 |
} else { |
192 |
subTaskIssueTypes = new IssueType[0]; |
193 |
} |
164 |
|
194 |
|
165 |
data.issueTypesById = new HashMap<String, IssueType>(issueTypes.length + subTaskIssueTypes.length); |
195 |
data.issueTypesById = new HashMap<String, IssueType>(issueTypes.length + subTaskIssueTypes.length); |
166 |
|
196 |
|
167 |
for (IssueType issueType : issueTypes) { |
197 |
for (IssueType issueType : issueTypes) { |
168 |
data.issueTypesById.put(issueType.getId(), issueType); |
198 |
data.issueTypesById.put(issueType.getId(), issueType); |
169 |
} |
199 |
} |
170 |
|
200 |
|
171 |
for (IssueType issueType : subTaskIssueTypes) { |
201 |
for (IssueType issueType : subTaskIssueTypes) { |
172 |
issueType.setSubTaskType(true); |
202 |
issueType.setSubTaskType(true); |
173 |
data.issueTypesById.put(issueType.getId(), issueType); |
203 |
data.issueTypesById.put(issueType.getId(), issueType); |
174 |
} |
204 |
} |
175 |
|
205 |
|
176 |
data.issueTypes = new IssueType[issueTypes.length + subTaskIssueTypes.length]; |
206 |
data.issueTypes = new IssueType[issueTypes.length + subTaskIssueTypes.length]; |
177 |
System.arraycopy(issueTypes, 0, data.issueTypes, 0, issueTypes.length); |
207 |
System.arraycopy(issueTypes, 0, data.issueTypes, 0, issueTypes.length); |
178 |
System.arraycopy(subTaskIssueTypes, 0, data.issueTypes, issueTypes.length, subTaskIssueTypes.length); |
208 |
System.arraycopy(subTaskIssueTypes, 0, data.issueTypes, issueTypes.length, subTaskIssueTypes.length); |
|
|
209 |
} |
210 |
} finally { |
211 |
monitor.done(); |
179 |
} |
212 |
} |
180 |
} |
213 |
} |
181 |
|
214 |
|
182 |
private void initializeStatuses(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
215 |
private void initializeStatuses(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
183 |
data.statuses = jiraClient.getStatuses(monitor); |
216 |
monitor = Policy.monitorFor(monitor); |
184 |
data.statusesById = new HashMap<String, JiraStatus>(data.statuses.length); |
217 |
try { |
185 |
for (JiraStatus status : data.statuses) { |
218 |
monitor.beginTask(Messages.JiraClientCache_getting_statuses, 1); |
186 |
data.statusesById.put(status.getId(), status); |
219 |
|
|
|
220 |
data.statuses = jiraClient.getStatuses(Policy.subMonitorFor(monitor, 1)); |
221 |
data.statusesById = new HashMap<String, JiraStatus>(data.statuses.length); |
222 |
for (JiraStatus status : data.statuses) { |
223 |
data.statusesById.put(status.getId(), status); |
224 |
} |
225 |
} finally { |
226 |
monitor.done(); |
187 |
} |
227 |
} |
188 |
} |
228 |
} |
189 |
|
229 |
|
190 |
private void initializeResolutions(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
230 |
private void initializeResolutions(JiraClientData data, IProgressMonitor monitor) throws JiraException { |
191 |
data.resolutions = jiraClient.getResolutions(monitor); |
231 |
monitor = Policy.monitorFor(monitor); |
192 |
data.resolutionsById = new HashMap<String, Resolution>(data.resolutions.length); |
232 |
try { |
193 |
for (Resolution resolution : data.resolutions) { |
233 |
monitor.beginTask(Messages.JiraClientCache_getting_resolutions, 1); |
194 |
data.resolutionsById.put(resolution.getId(), resolution); |
234 |
data.resolutions = jiraClient.getResolutions(monitor); |
|
|
235 |
data.resolutionsById = new HashMap<String, Resolution>(data.resolutions.length); |
236 |
for (Resolution resolution : data.resolutions) { |
237 |
data.resolutionsById.put(resolution.getId(), resolution); |
238 |
} |
239 |
} finally { |
240 |
monitor.done(); |
195 |
} |
241 |
} |
|
|
242 |
|
196 |
} |
243 |
} |
197 |
|
244 |
|
198 |
public Resolution getResolutionById(String id) { |
245 |
public Resolution getResolutionById(String id) { |
Lines 211-239
Link Here
|
211 |
return data; |
258 |
return data; |
212 |
} |
259 |
} |
213 |
|
260 |
|
|
|
261 |
public synchronized void refreshProjectDetails(String projectId, IProgressMonitor monitor) throws JiraException { |
262 |
Project project = getProjectById(projectId); |
263 |
if (project != null) { |
264 |
try { |
265 |
monitor.beginTask(Messages.JiraClientCache_getting_project_details, 100); |
266 |
initializeProject(project, monitor); |
267 |
} finally { |
268 |
monitor.done(); |
269 |
} |
270 |
} else { |
271 |
refreshDetails(monitor); |
272 |
} |
273 |
} |
274 |
|
214 |
public synchronized void refreshDetails(IProgressMonitor monitor) throws JiraException { |
275 |
public synchronized void refreshDetails(IProgressMonitor monitor) throws JiraException { |
215 |
try { |
276 |
try { |
216 |
monitor = Policy.monitorFor(monitor); |
277 |
monitor = Policy.monitorFor(monitor); |
|
|
278 |
monitor.beginTask(Messages.JiraClientCache_Updating_repository_configuration, 1500); |
279 |
|
280 |
final JiraClientData newData = new JiraClientData(); |
281 |
|
282 |
monitor.subTask(Messages.JiraClientCache_getting_server_info); |
283 |
IProgressMonitor submonitor = Policy.subMonitorFor(monitor, 100); |
284 |
try { |
285 |
submonitor.beginTask(Messages.JiraClientCache_getting_server_info, 1); |
286 |
data.serverInfo = newData.serverInfo = jiraClient.getServerInfo(submonitor); |
287 |
} finally { |
288 |
submonitor.done(); |
289 |
} |
290 |
|
291 |
monitor.subTask(Messages.JiraClientCache_getting_project_details); |
292 |
submonitor = Policy.subMonitorFor(monitor, 1000); |
293 |
try { |
294 |
initializeProjects(newData, submonitor); |
295 |
} finally { |
296 |
submonitor.done(); |
297 |
} |
298 |
|
299 |
monitor.subTask(Messages.JiraClientCache_getting_priorities); |
300 |
submonitor = Policy.subMonitorFor(monitor, 100); |
301 |
try { |
302 |
initializePriorities(newData, submonitor); |
303 |
} finally { |
304 |
submonitor.done(); |
305 |
} |
306 |
|
307 |
monitor.subTask(Messages.JiraClientCache_getting_issue_types); |
308 |
submonitor = Policy.subMonitorFor(monitor, 100); |
309 |
try { |
310 |
initializeIssueTypes(newData, submonitor); |
311 |
} finally { |
312 |
submonitor.done(); |
313 |
} |
314 |
|
315 |
monitor.subTask(Messages.JiraClientCache_getting_resolutions); |
316 |
submonitor = Policy.subMonitorFor(monitor, 100); |
317 |
try { |
318 |
initializeResolutions(newData, submonitor); |
319 |
} finally { |
320 |
submonitor.done(); |
321 |
} |
217 |
|
322 |
|
218 |
// use UNKNOWN since some of the update operations block for a long time |
323 |
monitor.subTask(Messages.JiraClientCache_getting_statuses); |
219 |
// TODO use InfiniteSubProgressMonitor |
324 |
submonitor = Policy.subMonitorFor(monitor, 100); |
220 |
monitor.beginTask(Messages.JiraClientCache_Updating_repository_configuration, IProgressMonitor.UNKNOWN); |
325 |
try { |
221 |
|
326 |
initializeStatuses(newData, submonitor); |
222 |
JiraClientData newData = new JiraClientData(); |
327 |
} finally { |
223 |
|
328 |
submonitor.done(); |
224 |
data.serverInfo = newData.serverInfo = jiraClient.getServerInfo(monitor); |
329 |
} |
225 |
|
|
|
226 |
Policy.advance(monitor, 1); |
227 |
initializeProjects(newData, monitor); |
228 |
Policy.advance(monitor, 1); |
229 |
initializePriorities(newData, monitor); |
230 |
Policy.advance(monitor, 1); |
231 |
initializeIssueTypes(newData, monitor); |
232 |
Policy.advance(monitor, 1); |
233 |
initializeResolutions(newData, monitor); |
234 |
Policy.advance(monitor, 1); |
235 |
initializeStatuses(newData, monitor); |
236 |
Policy.advance(monitor, 1); |
237 |
|
330 |
|
238 |
newData.lastUpdate = System.currentTimeMillis(); |
331 |
newData.lastUpdate = System.currentTimeMillis(); |
239 |
this.data = newData; |
332 |
this.data = newData; |