1 package org.apache.maven.plugins.patchtracker.tracking.jira;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.axis.encoding.Base64;
23 import org.apache.maven.plugins.patchtracker.tracking.jira.soap.JiraSoapService;
24 import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteAuthenticationException;
25 import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteComment;
26 import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteComponent;
27 import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteException;
28 import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteIssue;
29 import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemotePermissionException;
30 import org.apache.maven.plugins.patchtracker.tracking.jira.soap.RemoteValidationException;
31
32 import java.util.Arrays;
33 import java.util.Collections;
34 import java.util.List;
35
36
37
38
39 public class JiraSession
40 {
41 private final JiraSoapService service;
42
43
44
45
46 private final String token;
47
48 private final String projectKey;
49
50 public JiraSession( JiraSoapService service, String token, String projectKey )
51 {
52 this.service = service;
53 this.token = token;
54 this.projectKey = projectKey;
55 }
56
57 public RemoteIssue createIssue( RemoteIssue remoteIssue )
58 throws RemotePermissionException, RemoteValidationException, RemoteAuthenticationException, RemoteException,
59 java.rmi.RemoteException
60 {
61 return service.createIssue( token, remoteIssue );
62 }
63
64 public boolean addBase64EncodedAttachmentsToIssue( String issueKey, String fileName, String attachmentContent )
65 throws RemotePermissionException, RemoteValidationException, RemoteAuthenticationException, RemoteException,
66 java.rmi.RemoteException
67 {
68
69 return service.addBase64EncodedAttachmentsToIssue( token, issueKey, new String[]{ fileName + ".patch" },
70 new String[]{
71 Base64.encode( attachmentContent.getBytes() ) } );
72 }
73
74 public RemoteIssue findRemoteIssue( String issueKey )
75 throws RemotePermissionException, RemoteValidationException, RemoteAuthenticationException, RemoteException,
76 java.rmi.RemoteException
77 {
78 return service.getIssue( token, issueKey );
79 }
80
81 public void addCommentToIssue( String issueKey, String comment )
82 throws RemotePermissionException, RemoteValidationException, RemoteAuthenticationException, RemoteException,
83 java.rmi.RemoteException
84 {
85 RemoteComment remoteComment = new RemoteComment();
86 remoteComment.setBody( comment );
87 service.addComment( token, issueKey, remoteComment );
88 }
89
90 public List<RemoteComponent> getRemoteComponents()
91 throws RemotePermissionException, RemoteValidationException, RemoteAuthenticationException, RemoteException,
92 java.rmi.RemoteException
93 {
94 RemoteComponent[] remoteComponents = service.getComponents( token, projectKey );
95 return remoteComponents == null ? Collections.<RemoteComponent>emptyList() : Arrays.asList( remoteComponents );
96 }
97 }