1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*******************************************************************************
* Copyright (c) 2006 - 2006 Mylar eclipse.org project and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Mylar project committers - initial API and implementation
*******************************************************************************/
package org.eclipse.mylar.internal.trac.core;
import java.net.URL;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylar.internal.trac.model.TracComponent;
import org.eclipse.mylar.internal.trac.model.TracMilestone;
import org.eclipse.mylar.internal.trac.model.TracPriority;
import org.eclipse.mylar.internal.trac.model.TracSeverity;
import org.eclipse.mylar.internal.trac.model.TracTicketResolution;
import org.eclipse.mylar.internal.trac.model.TracTicketStatus;
import org.eclipse.mylar.internal.trac.model.TracTicketType;
import org.eclipse.mylar.internal.trac.model.TracVersion;
/**
* @author Steffen Pingel
*/
public abstract class AbstractTracClient implements ITracClient {
protected String username;
protected String password;
protected URL repositoryUrl;
protected Version version;
protected TracClientData data;
public AbstractTracClient(URL repositoryUrl, Version version, String username, String password) {
this.repositoryUrl = repositoryUrl;
this.version = version;
this.username = username;
this.password = password;
this.data = new TracClientData();
}
public Version getVersion() {
return version;
}
protected boolean hasAuthenticationCredentials() {
return username != null && username.length() > 0;
}
public TracComponent[] getComponents() {
return (data.components != null) ? data.components.toArray(new TracComponent[0]) : null;
}
public TracMilestone[] getMilestones() {
return (data.milestones != null) ? data.milestones.toArray(new TracMilestone[0]) : null;
}
public TracPriority[] getPriorities() {
return (data.priorities != null) ? data.priorities.toArray(new TracPriority[0]) : null;
}
public TracSeverity[] getSeverities() {
return (data.severities != null) ? data.severities.toArray(new TracSeverity[0]) : null;
}
public TracTicketResolution[] getTicketResolutions() {
return (data.ticketResolutions != null) ? data.ticketResolutions.toArray(new TracTicketResolution[0]) : null;
}
public TracTicketStatus[] getTicketStatus() {
return (data.ticketStatus != null) ? data.ticketStatus.toArray(new TracTicketStatus[0]) : null;
}
public TracTicketType[] getTicketTypes() {
return (data.ticketTypes != null) ? data.ticketTypes.toArray(new TracTicketType[0]) : null;
}
public TracVersion[] getVersions() {
return (data.versions != null) ? data.versions.toArray(new TracVersion[0]) : null;
}
public void updateAttributes(IProgressMonitor monitor, boolean force) throws TracException {
if (data.lastUpdate == 0 || force) {
updateAttributes(monitor);
data.lastUpdate = System.currentTimeMillis();
}
}
public abstract void updateAttributes(IProgressMonitor monitor) throws TracException;
public void setData(TracClientData data) {
this.data = data;
}
public String[] getDefaultTicketResolutions() {
return new String[] { "fixed", "invalid", "wontfix", "duplicate", "worksforme" };
}
public String[] getDefaultTicketActions(String status) {
if ("new".equals(status)) {
return new String[] { "leave", "resolve", "reassign", "accept" };
} else if ("assigned".equals(status)) {
return new String[] { "leave", "resolve", "reassign" };
} else if ("reopened".equals(status)) {
return new String[] { "leave", "resolve", "reassign" };
} else if ("closed".equals(status)) {
return new String[] { "leave", "reopen" };
}
return null;
}
}
|