Modified:
/trunk/jira-extended-webservice/pom.xml
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtension.java
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtensionImpl.java
=======================================
--- /trunk/jira-extended-webservice/pom.xml Sat Dec 11 06:23:30 2010
+++ /trunk/jira-extended-webservice/pom.xml Sat Dec 18 07:10:14 2010
@@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.sharedSpace.jira</groupId>
<artifactId>webservice-extension</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.0.5-SNAPSHOT</version>
<name>Jira Webservice Extensions</name>
<packaging>atlassian-plugin</packaging>
<properties>
=======================================
---
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtension.java
Sat Dec 11 06:23:30 2010
+++
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtension.java
Sat Dec 18 07:10:14 2010
@@ -26,97 +26,187 @@
import com.atlassian.jira.rpc.soap.JiraSoapService;
import com.atlassian.jira.rpc.soap.beans.RemoteIssue;
-public interface SoapExtension extends JiraSoapService
-{
+public interface SoapExtension extends JiraSoapService {
/**
- * Used to check if the webservice is active.
- * Calling this method returns a constant string.
+ * Used to check if the webservice is active. Calling this method returns
a
+ * constant string.
*/
public String ping();
/**
* Get linked issues with specific link type.
- * @param token user token from login
- * @param issueIdFrom issue on which the inward and outward links should
be gotten
- * @param linkType name of the link type to fetch, "" for all types
+ *
+ * @param token
+ * user token from login
+ * @param issueIdFrom
+ * issue on which the inward and outward links should be gotten
+ * @param linkType
+ * name of the link type to fetch, "" for all types
* @throws RemoteException
*/
- public RemoteIssue[] getLinkedIssues(String token, Long issueIdFrom,
String linkType) throws RemoteException;
+ public RemoteIssue[] getLinkedIssues(String token, Long issueIdFrom,
+ String linkType) throws RemoteException;
+
+ /**
+ * Retrieve link and link-type info of type <code>linkType</code> (or all
if
+ * null) that issueId <code>issueIdFrom</code> links to.
+ *
+ * @param token
+ * user token from login
+ * @param issueIdFrom
+ * issue on which the link info should be gotten
+ * @param linkType
+ * name of the link type to fetch, "" for all types
+ * @param separator
+ * a separator string to be used between the info items,
defaults
+ * to "|" if null or empty
+ * @return An array of strings with the following format, separated by
+ * parameter <code>separator</code> or "|" if null or empty:</br>
+ * (Any information already known is left out, like the
+ * source-issueKey. Field-comments in round brackets.)
+ *
+ * <pre>
+ * link.issueKey |
+ * link.issueId |
+ * link.id |
+ * link.isSystemLink ("Y" or "N") |
+ * linkTypeMnemonic ("I" or "O") |
+ * linkType.Id |
+ * linkType.Name |
+ * linkType.Inward (description) |
+ * linkType.Outward (description) |
+ * linkType.Style |
+ * linkType.isSubTaskLinkType ("Y" or "N") |
+ * </pre>
+ *
+ * The string is always ended with a separator so it can be
+ * externally 'recognized' if required.</br> Example result
+ * (2-string array) (requested issueIdFrom = ATH-1.getId()):
+ *
+ * <pre>
+ * ATH-3|10010|10020|N|I|10011|Related|relates also to|related to||N|
+ * ATH-2|10001|10060|Y|O|10000|jira_subtask_link|jira_subtask_inward|
jira_subtask_outward|jira_subtask|Y|
+ * </pre>
+ *
+ * The first one is a standard 'Related' inward link from
+ * ATH-3.</br> The second one is a SubTask link from ATH-1 to
ATH-2,
+ * where ATH-2 is the SubTask. The SubTask is both a SystemLink
and
+ * a SubTaskLinkType.
+ * @throws RemoteException
+ */
+ public String[] getLinkedInfo(String token, Long issueIdFrom,
+ String linkType, String separator) throws RemoteException;
/**
* Get Inward linked issues with specific link type.
- * @param token user token from login
- * @param issueIdFrom issue on which the outward links should be gotten
- * @param linkType name of the link type to fetch, "" for all types
+ *
+ * @param token
+ * user token from login
+ * @param issueIdFrom
+ * issue on which the outward links should be gotten
+ * @param linkType
+ * name of the link type to fetch, "" for all types
* @throws RemoteException
*/
- public RemoteIssue[] getLinkedInward(String token, Long issueIdFrom,
String linkType) throws RemoteException;
+ public RemoteIssue[] getLinkedInward(String token, Long issueIdFrom,
+ String linkType) throws RemoteException;
/**
* Get Outward linked issues with specific link type.
- * @param token user token from login
- * @param issueIdFrom issue on which the outward link should be created
- * @param linkType name of the link type to remove
+ *
+ * @param token
+ * user token from login
+ * @param issueIdFrom
+ * issue on which the outward link should be created
+ * @param linkType
+ * name of the link type to remove
* @throws RemoteException
*/
- public RemoteIssue[] getLinkedOutward(String token, Long issueIdFrom,
String linkType) throws RemoteException;
+ public RemoteIssue[] getLinkedOutward(String token, Long issueIdFrom,
+ String linkType) throws RemoteException;
/**
* link issue.
*
- * @param token user token from login
- * @param issueIdFrom issue on which the outward link should be created
- * @param issueIdTo issue which should receive the inward link
- * @param linkType name of the link type to create
- * @param unique failure if an outward link of type
<code>linkType</code> already exists
- * @param replace replace all links of type <code>linkType</code> from
the "from issue".
+ * @param token
+ * user token from login
+ * @param issueIdFrom
+ * issue on which the outward link should be created
+ * @param issueIdTo
+ * issue which should receive the inward link
+ * @param linkType
+ * name of the link type to create
+ * @param unique
+ * failure if an outward link of type <code>linkType</code>
+ * already exists
+ * @param replace
+ * replace all links of type <code>linkType</code> from the
+ * "from issue".
* @throws RemoteException
*/
- public void linkIssue(String token, Long issueIdFrom, Long issueIdTo,
String linkType, boolean unique, boolean replace) throws RemoteException;
+ public void linkIssue(String token, Long issueIdFrom, Long issueIdTo,
+ String linkType, boolean unique, boolean replace)
+ throws RemoteException;
/**
* unlink issue.
*
- * @param token user token from login
- * @param issueIdFrom issue on which the outward link should be created
- * @param issueIdTo issue which should receive the inward link
- * @param linkType name of the link type to remove
+ * @param token
+ * user token from login
+ * @param issueIdFrom
+ * issue on which the outward link should be created
+ * @param issueIdTo
+ * issue which should receive the inward link
+ * @param linkType
+ * name of the link type to remove
* @throws RemoteException
*/
- public void unlinkIssue(String token, Long issueIdFrom, Long issueIdTo,
String linkType) throws RemoteException;
+ public void unlinkIssue(String token, Long issueIdFrom, Long issueIdTo,
+ String linkType) throws RemoteException;
/**
* get issue for specific worklog id.
*/
- public RemoteIssue getIssueForWorklog(String token, Long worklogId)
throws RemoteException, SearchException;
+ public RemoteIssue getIssueForWorklog(String token, Long worklogId)
+ throws RemoteException, SearchException;
/**
* get custom field values for issue.
*/
- public String[] getCustomFieldValues(String token, Long customFieldId,
Long issueId) throws RemoteException, SearchException;
+ public String[] getCustomFieldValues(String token, Long customFieldId,
+ Long issueId) throws RemoteException, SearchException;
/**
* add a component to the project
*/
- public long addComponent(String token, String projectKey, String name,
String description, String lead, long assigneeType) throws RemoteException,
RemoteAuthenticationException;
+ public long addComponent(String token, String projectKey, String name,
+ String description, String lead, long assigneeType)
+ throws RemoteException, RemoteAuthenticationException;
/**
* remove a component
*/
- public void removeComponent(String token, String projectKey, long
componentId) throws RemoteException, RemoteAuthenticationException;
+ public void removeComponent(String token, String projectKey,
+ long componentId) throws RemoteException,
+ RemoteAuthenticationException;
/**
* update the name of a component
*/
- public void updateComponent(String token, String projectKey, long
componentId, String name, String description, String lead, long
assigneeType) throws RemoteException, RemoteAuthenticationException;
+ public void updateComponent(String token, String projectKey,
+ long componentId, String name, String description, String lead,
+ long assigneeType) throws RemoteException,
+ RemoteAuthenticationException;
/**
* link an issue to another issue as subtask
*/
- public void createSubtaskLink(String token, long parentIssueId, long
subtaskIssueId, long issueTypeId) throws RemoteException;
-
- /**
- * Update the full name and email of a user
- */
- public void updateUser(String token, String userid, String fullName,
String email) throws RemoteException;
-}
+ public void createSubtaskLink(String token, long parentIssueId,
+ long subtaskIssueId, long issueTypeId) throws RemoteException;
+
+ /**
+ * Update the full name and email of a user
+ */
+ public void updateUser(String token, String userid, String fullName,
+ String email) throws RemoteException;
+}
=======================================
---
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtensionImpl.java
Sat Dec 11 06:23:30 2010
+++
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtensionImpl.java
Sat Dec 18 07:10:14 2010
@@ -99,6 +99,10 @@
private final ProjectComponentManager projectComponentManager;
private final SubTaskManager subTaskManager;
+ private static final String INFORET_SEPARATOR_DEFAULT = "|";
+ private static final String INFORET_LINK_INWARD_MNEM = "I";
+ private static final String INFORET_LINK_OUTWARD_MNEM = "O";
+
public SoapExtensionImpl(OptionsManager optionsManager,
SearchRequestService searchRequestService,
IssueManager issueManager, JiraDurationUtils jiraDurationUtils,
@@ -211,6 +215,163 @@
}
return ret.toArray(new RemoteIssue[ret.size()]);
}
+
+ /**
+ * Retrieve link and link-type info of type <code>linkType</code> (or all
if
+ * null) that issueId <code>issueIdFrom</code> links to.
+ *
+ * @param token
+ * user token from login
+ * @param issueIdFrom
+ * issue on which the link info should be gotten
+ * @param linkType
+ * name of the link type to fetch, "" for all types
+ * @param separator
+ * a separator string to be used between the info items,
defaults
+ * to "|" if null or empty
+ * @return An array of strings with the following format, separated by
+ * parameter <code>separator</code> or "|" if null or empty:</br>
+ * (Any information already known is left out, like the
+ * source-issueKey. Field-comments in round brackets.)
+ *
+ * <pre>
+ * link.issueKey |
+ * link.issueId |
+ * link.id |
+ * link.isSystemLink ("Y" or "N") |
+ * linkTypeMnemonic ("I" or "O") |
+ * linkType.Id |
+ * linkType.Name |
+ * linkType.Inward (description) |
+ * linkType.Outward (description) |
+ * linkType.Style |
+ * linkType.isSubTaskLinkType ("Y" or "N") |
+ * </pre>
+ *
+ * The string is always ended with a separator so it can be
+ * externally 'recognized' if required.</br> Example result
+ * (2-string array) (requested issueIdFrom = ATH-1.getId()):
+ *
+ * <pre>
+ * ATH-3|10010|10020|N|I|10011|Related|relates also to|related to||N|
+ * ATH-2|10001|10060|Y|O|10000|jira_subtask_link|jira_subtask_inward|
jira_subtask_outward|jira_subtask|Y|
+ * </pre>
+ *
+ * The first one is a standard 'Related' inward link from
+ * ATH-3.</br> The second one is a SubTask link from ATH-1 to
ATH-2,
+ * where ATH-2 is the SubTask. The SubTask is both a SystemLink
and
+ * a SubTaskLinkType.
+ * @throws RemoteException
+ */
+ public String[] getLinkedInfo(String token, Long issueIdFrom,
+ String linkType, String separator) throws RemoteException {
+ User user = tokenManager.retrieveUserNoPermissionCheck(token);
+
+ if (separator == null || separator.equals("")) {
+ separator = INFORET_SEPARATOR_DEFAULT;
+ }
+ IssueService is = ComponentManager
+ .getComponentInstanceOfType(IssueService.class);
+ RemoteIssue issueFrom = is.getIssueById(user,
+ Long.toString(issueIdFrom));
+ if (issueFrom == null) {
+ throw new RemoteException("issue 'from' not found. id="
+ + issueIdFrom);
+ }
+
+ IssueLinkManager ilm = ComponentManager.getInstance()
+ .getIssueLinkManager();
+ IssueLinkType contributeLinkType = null;
+ if (!linkType.equals("")) {
+ contributeLinkType = getLinkType(linkType);
+ }
+
+ List<IssueLink> issueInLinks = ilm.getInwardLinks(issueIdFrom);
+
+ String linkTypeMnemonic = INFORET_LINK_INWARD_MNEM;
+ List<String> ret = new ArrayList<String>();
+ if (issueInLinks != null) {
+ for (IssueLink issueLink : issueInLinks) {
+ if (contributeLinkType == null
+ || issueLink.getIssueLinkType().equals(
+ contributeLinkType)) {
+ Long issueIdTo = issueLink.getSourceId();
+ IssueLinkType ilt = issueLink.getIssueLinkType();
+
+ if (issueIdTo != issueIdFrom) {
+ RemoteIssue issueTo = is.getIssueById(user,
+ Long.toString(issueIdTo));
+ String ld = issueTo.getKey()
+ + separator
+ + issueTo.getId()
+ + separator
+ + issueLink.getId()
+ + separator
+ + (issueLink.isSystemLink() ? "Y" : "N")
+ + separator
+ + linkTypeMnemonic
+ + separator
+ + ilt.getId()
+ + separator
+ + ilt.getName()
+ + separator
+ + ilt.getInward()
+ + separator
+ + ilt.getOutward()
+ + separator
+ + (ilt.getStyle() == null ? "" : ilt.getStyle())
+ + separator
+ + (ilt.isSubTaskLinkType() ? "Y" : "N")
+ + separator;
+ ret.add(ld);
+ }
+ }
+ }
+ }
+
+ List<IssueLink> issueOutLinks = ilm.getOutwardLinks(issueIdFrom);
+
+ linkTypeMnemonic = INFORET_LINK_OUTWARD_MNEM;
+ if (issueOutLinks != null) {
+ for (IssueLink issueLink : issueOutLinks) {
+ if (contributeLinkType == null
+ || issueLink.getIssueLinkType().equals(
+ contributeLinkType)) {
+ Long issueIdTo = issueLink.getDestinationId();
+ IssueLinkType ilt = issueLink.getIssueLinkType();
+
+ if (issueIdTo != issueIdFrom) {
+ RemoteIssue issueTo = is.getIssueById(user,
+ Long.toString(issueIdTo));
+ String ld = issueTo.getKey()
+ + separator
+ + issueTo.getId()
+ + separator
+ + issueLink.getId()
+ + separator
+ + (issueLink.isSystemLink() ? "Y" : "N")
+ + separator
+ + linkTypeMnemonic
+ + separator
+ + ilt.getId()
+ + separator
+ + ilt.getName()
+ + separator
+ + ilt.getInward()
+ + separator
+ + ilt.getOutward()
+ + separator
+ + (ilt.getStyle() == null ? "" : ilt.getStyle())
+ + separator
+ + (ilt.isSubTaskLinkType() ? "Y" : "N")
+ + separator;
+ ret.add(ld);
+ }
+ }
+ }
+ }
+ return ret.toArray(new String[ret.size()]);
+ }
/**
* retrieve all Inward issues of type <code>linkType</code> the issue