[shared-space] r25 committed - - Version 1.0.4-SNAPSHOT...

15 views
Skip to first unread message

shared...@googlecode.com

unread,
Dec 11, 2010, 9:24:05 AM12/11/10
to jira-extende...@googlegroups.com
Revision: 25
Author: TonHu2004
Date: Sat Dec 11 06:23:30 2010
Log: - Version 1.0.4-SNAPSHOT
- Added getLinkedInward
- Added getLinkedOutward
- Added updateUser donated by Matt Doar
- Updated pom to cater for changed repositories :-( (not cleaned up)
http://code.google.com/p/shared-space/source/detail?r=25

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 Thu Apr 15 15:54:39 2010
+++ /trunk/jira-extended-webservice/pom.xml Sat Dec 11 06:23:30 2010
@@ -1,84 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>com.atlassian.jira.plugins</groupId>
- <artifactId>jira-plugin-base</artifactId>
- <version>15</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.sharedSpace.jira</groupId>
- <artifactId>webservice-extension</artifactId>
- <version>1.0.3-SNAPSHOT</version>
-
- <name>Jira Webservice Extensions</name>
- <packaging>atlassian-plugin</packaging>
-
- <properties>
-
<atlassian.plugin.key>org.sharedSpace.jira.webservice.extension</atlassian.plugin.key>
-
- <!-- JIRA version -->
- <atlassian.product.version>4.0</atlassian.product.version>
- <!-- JIRA functional test library version -->
-
<atlassian.product.test-lib.version>4.0</atlassian.product.test-lib.version>
- <!-- JIRA data version -->
-
<atlassian.product.data.version>4.0</atlassian.product.data.version>
- </properties>
-
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>com.atlassian.jira.plugins</groupId>
+ <artifactId>jira-plugin-base</artifactId>
+ <version>15</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.sharedSpace.jira</groupId>
+ <artifactId>webservice-extension</artifactId>
+ <version>1.0.4-SNAPSHOT</version>
+ <name>Jira Webservice Extensions</name>
+ <packaging>atlassian-plugin</packaging>
+ <properties>
+
<atlassian.plugin.key>org.sharedSpace.jira.webservice.extension</atlassian.plugin.key>
+ <!-- JIRA version -->
+ <atlassian.product.version>4.0</atlassian.product.version>
+ <!-- JIRA functional test library version -->
+
<atlassian.product.test-lib.version>4.0</atlassian.product.test-lib.version>
+ <!-- JIRA data version -->
+ <atlassian.product.data.version>4.0</atlassian.product.data.version>
+ </properties>
<repositories>
- <repository>
- <id>central</id>
- <url>https://m2proxy.atlassian.com/repository/public</url>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>always</updatePolicy>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- </repository>
- <repository>
- <id>atlassian-m1-repository</id>
- <url>https://m2proxy.atlassian.com/repository/m1/</url>
- <releases>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
+ <repository>
+ <id>central</id>
+ <url>http://repository.atlassian.com/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>always</updatePolicy>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ </repository>
+ <repository>
+ <id>atlassian-public</id>
+ <url>http://maven.atlassian.com/repository/public/</url>
+ <releases>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>marvelution</id>
+
<url>http://repository.marvelution.com/content/repositories/atlassian/</url>
+ <releases>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>atlassian-contrib</id>
+ <url>http://maven.atlassian.com/contrib/</url>
+ <releases>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>atlassian-contrib-snapshot</id>
+ <url>http://maven.atlassian.com/contrib-snapshot/</url>
+ <releases>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>codehaus</id>
+ <url>http://repository.codehaus.org/</url>
+ <releases>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
</repositories>
- <pluginRepositories>
- <pluginRepository>
- <id>central</id>
- <url>https://m2proxy.atlassian.com/repository/public</url>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>fail</checksumPolicy>
- </releases>
- <snapshots>
- <checksumPolicy>fail</checksumPolicy>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
-
+ <pluginRepositories>
+ <pluginRepository>
+ <id>central</id>
+ <url>http://repository.atlassian.com/maven2/</url>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ </pluginRepository>
+ <pluginRepository>
+ <id>central-public</id>
+ <url>http://maven.atlassian.com/repository/public/</url>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ </pluginRepository>
+ <pluginRepository>
+ <id>marvelution</id>
+
<url>http://repository.marvelution.com/content/repositories/atlassian/</url>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ </pluginRepository>
+ <pluginRepository>
+ <id>atlassian-contrib</id>
+ <url>http://maven.atlassian.com/repository/contrib/</url>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>fail</checksumPolicy>
+ </releases>
+ <snapshots>
+ <checksumPolicy>fail</checksumPolicy>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
<build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
<!-- Workaround mangled paths issue in Windows with -Pplugin-debug -->
<!--
<plugin>
@@ -92,8 +155,8 @@
</dependency>
</dependencies>
</plugin>
- -->
- <!--
+ -->
+ <!--
<configuration>
<configuration>
<properties>
@@ -108,11 +171,9 @@
</properties>
</configuration>
</configuration>
- -->
-
- </plugins>
+ -->
+ </plugins>
</build>
-
<dependencies>
<dependency>
<groupId>javax.mail</groupId>
@@ -120,65 +181,66 @@
<version>1.4.2</version>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>com.atlassian.jira.plugins</groupId>
- <artifactId>atlassian-jira-rpc-plugin</artifactId>
- <version>4.0</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>com.atlassian.jira.plugins</groupId>
+ <artifactId>atlassian-jira-rpc-plugin</artifactId>
+ <version>4.0</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
-
- <!-- TODO: Add project description -->
- <description>
- Some extensions to the JIRA SOAP services: * link handling *
add/remove/updateComponent * create subTask-link. Access:
http(s)://your-jira-install/rpc/soap/sharedspace-s1v1?WSDL
- </description>
- <!--
+ <!-- TODO: Add project description -->
+ <description>Some extensions to the JIRA SOAP services: * link handling *
add/remove/updateComponent * create subTask-link. Access:
http(s)://your-jira-install/rpc/soap/sharedspace-s1v1?WSDL</description>
+ <!--
<url></url>
- -->
-
- <!-- TODO: Complete developer details -->
+ -->
+ <!-- TODO: Complete developer details -->
<developers>
<developer>
<name>Mario Ivankovits</name>
</developer>
</developers>
-
- <!-- TODO: Complete source control details -->
- <!--
+ <!-- TODO: Complete source control details -->
+ <!--
<scm>
<connection></connection>
<developerConnection></developerConnection>
<url></url>
</scm>
-->
-
- <!--You can define Ant tasks to be executed before and/or after
integration tests --><!--
+ <!--You can define Ant tasks to be executed before and/or after
integration tests -->
+ <!--
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
- <executions>
+
+<executions>
<execution>
<id>pre-integration-test-user-ant-tasks</id>
- <configuration>
+
+<configuration>
<tasks>
- <echo message="Ant task before integration
tests."/>
+ <echo message="Ant
+task before integration tests."/>
</tasks>
</configuration>
- </execution>
+
+</execution>

<execution>
<id>post-integration-test-user-ant-tasks</id>
- <configuration>
+
+<configuration>
<tasks>
- <echo message="Ant task _after_
integration tests."/>
+ <echo message="Ant
+task _after_ integration tests."/>
</tasks>
</configuration>
- </execution>
+
+</execution>
</executions>
</plugin>
</plugins>
- </build>-->
-
+ </build>
+ -->
</project>
=======================================
---
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtension.java
Thu Apr 15 15:54:39 2010
+++
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtension.java
Sat Dec 11 06:23:30 2010
@@ -36,29 +36,62 @@

/**
* 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
+ * @throws RemoteException
*/
public RemoteIssue[] getLinkedIssues(String token, Long issueIdFrom,
String linkType) throws RemoteException;

/**
- * link issue
+ * 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
+ * @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
+ * @throws RemoteException
+ */
+ public RemoteIssue[] getLinkedOutward(String token, Long issueIdFrom,
String linkType) throws RemoteException;
+
+ /**
+ * link issue.
*
- * @param unique if true fails if there is already a link with given type
- * @param replace if true all other links with given type will be removed
+ * @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;

/**
- * unlink issue
+ * 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
+ * @throws RemoteException
*/
public void unlinkIssue(String token, Long issueIdFrom, Long issueIdTo,
String linkType) throws RemoteException;

/**
- * get issue for specific worklog id
+ * get issue for specific worklog id.
*/
public RemoteIssue getIssueForWorklog(String token, Long worklogId)
throws RemoteException, SearchException;

/**
- * get custom field values for issue
+ * get custom field values for issue.
*/
public String[] getCustomFieldValues(String token, Long customFieldId,
Long issueId) throws RemoteException, SearchException;

@@ -81,4 +114,9 @@
* 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;
+}
=======================================
---
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtensionImpl.java
Thu Apr 15 15:54:39 2010
+++
/trunk/jira-extended-webservice/src/main/java/org/sharedSpace/jira/webservice/SoapExtensionImpl.java
Sat Dec 11 06:23:30 2010
@@ -66,33 +66,57 @@
import com.atlassian.jira.rpc.soap.util.SoapUtilsBean;
import com.atlassian.jira.util.JiraDurationUtils;
import com.atlassian.jira.web.bean.FieldVisibilityBean;
+import com.atlassian.core.user.UserUtils;
+import com.atlassian.jira.config.properties.APKeys;
+import com.opensymphony.util.TextUtils;
import com.opensymphony.user.User;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

-public class SoapExtensionImpl extends JiraSoapServiceImpl implements
SoapExtension
-{
+@SuppressWarnings("deprecation")
+public class SoapExtensionImpl extends JiraSoapServiceImpl implements
+ SoapExtension {
private final ProjectManager projectManager;
private final TokenManager tokenManager;
+ @SuppressWarnings("unused")
private final SearchProvider searchProvider;
private final CustomFieldManager customFieldManager;
private final SoapUtilsBean soapUtilsBean;
+ @SuppressWarnings("unused")
private final FieldVisibilityBean fieldVisibilityBean;
private final AttachmentManager attachmentManager;
+ @SuppressWarnings("unused")
private final OfBizDelegator ofBizDelegator;
private final WorklogManager worklogManager;
+ @SuppressWarnings("unused")
private final JiraDurationUtils jiraDurationUtils;
private final IssueManager issueManager;
+ @SuppressWarnings("unused")
private final SearchRequestService searchRequestService;
private final OptionsManager optionsManager;
private final ProjectComponentManager projectComponentManager;
private final SubTaskManager subTaskManager;

- public SoapExtensionImpl(OptionsManager optionsManager,
SearchRequestService searchRequestService, IssueManager issueManager,
JiraDurationUtils jiraDurationUtils, WorklogManager worklogManager,
OfBizDelegator ofBizDelegator, FieldVisibilityBean fieldVisibilityBean,
ProjectManager projectManager, AttachmentManager attachmentManager,
CustomFieldManager customFieldManager, SoapUtilsBean soapUtilsBean,
SearchProvider searchProvider, TokenManager tokenManager, ProjectService
projectService, IssueService issueService, UserService userService,
SchemeService schemeService, AdminService adminService, SearchService
searchService, ProjectRoleService projectRoleService, IssueConstantsService
issueConstantsService, ProjectComponentManager projectComponentManager,
SubTaskManager subTaskManager)
- {
- super(tokenManager, projectService, issueService, userService,
schemeService, adminService, searchService, projectRoleService,
issueConstantsService);
+ public SoapExtensionImpl(OptionsManager optionsManager,
+ SearchRequestService searchRequestService,
+ IssueManager issueManager, JiraDurationUtils jiraDurationUtils,
+ WorklogManager worklogManager, OfBizDelegator ofBizDelegator,
+ FieldVisibilityBean fieldVisibilityBean,
+ ProjectManager projectManager, AttachmentManager attachmentManager,
+ CustomFieldManager customFieldManager, SoapUtilsBean soapUtilsBean,
+ SearchProvider searchProvider, TokenManager tokenManager,
+ ProjectService projectService, IssueService issueService,
+ UserService userService, SchemeService schemeService,
+ AdminService adminService, SearchService searchService,
+ ProjectRoleService projectRoleService,
+ IssueConstantsService issueConstantsService,
+ ProjectComponentManager projectComponentManager,
+ SubTaskManager subTaskManager) {
+ super(tokenManager, projectService, issueService, userService,
+ schemeService, adminService, searchService, projectRoleService,
+ issueConstantsService);

this.ofBizDelegator = ofBizDelegator;
this.projectManager = projectManager;
@@ -111,47 +135,55 @@
this.subTaskManager = subTaskManager;
}

- public String ping()
- {
+ public String ping() {
return "pong";
}

/**
- * retrieve all issues of type <code>linkType</code> the issue
<code>issueIdFrom</code> points to.
+ * retrieve all issues of type <code>linkType</code> the issue
+ * <code>issueIdFrom</code> points to.
+ *
+ * @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 {
User user = tokenManager.retrieveUserNoPermissionCheck(token);

- 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);
+ 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();
+ IssueLinkManager ilm = ComponentManager.getInstance()
+ .getIssueLinkManager();
IssueLinkType contributeLinkType = null;
- if (!linkType.equals(""))
- {
+ if (!linkType.equals("")) {
contributeLinkType = getLinkType(linkType);
}

- // Collection<IssueLink> issueLinks = ilm.getIssueLinks(issueIdFrom);
List<IssueLink> issueInLinks = ilm.getInwardLinks(issueIdFrom);

List<RemoteIssue> ret = new ArrayList<RemoteIssue>();
- if (issueInLinks != null)
- {
- for (IssueLink issueLink : issueInLinks)
- {
- if (contributeLinkType == null ||
issueLink.getIssueLinkType().equals(contributeLinkType))
- {
+ if (issueInLinks != null) {
+ for (IssueLink issueLink : issueInLinks) {
+ if (contributeLinkType == null
+ || issueLink.getIssueLinkType().equals(
+ contributeLinkType)) {
Long issueIdTo = issueLink.getSourceId();

- if (issueIdTo != issueIdFrom)
- {
- RemoteIssue issueTo = is.getIssueById(user,
Long.toString(issueIdTo));
+ if (issueIdTo != issueIdFrom) {
+ RemoteIssue issueTo = is.getIssueById(user,
+ Long.toString(issueIdTo));

ret.add(issueTo);
}
@@ -161,17 +193,16 @@

List<IssueLink> issueOutLinks = ilm.getOutwardLinks(issueIdFrom);

- if (issueOutLinks != null)
- {
- for (IssueLink issueLink : issueOutLinks)
- {
- if (contributeLinkType == null ||
issueLink.getIssueLinkType().equals(contributeLinkType))
- {
+ if (issueOutLinks != null) {
+ for (IssueLink issueLink : issueOutLinks) {
+ if (contributeLinkType == null
+ || issueLink.getIssueLinkType().equals(
+ contributeLinkType)) {
Long issueIdTo = issueLink.getDestinationId();

- if (issueIdTo != issueIdFrom)
- {
- RemoteIssue issueTo = is.getIssueById(user,
Long.toString(issueIdTo));
+ if (issueIdTo != issueIdFrom) {
+ RemoteIssue issueTo = is.getIssueById(user,
+ Long.toString(issueIdTo));

ret.add(issueTo);
}
@@ -182,112 +213,179 @@
}

/**
- * remove the link with given info
+ * retrieve all Inward issues of type <code>linkType</code> the issue
+ * <code>issueIdFrom</code> points to.
+ *
+ * @param token
+ * user token from login
+ * @param issueIdFrom
+ * issue on which the inward links should be gotten
+ * @param linkType
+ * name of the link type to fetch, "" for all types
+ * @throws RemoteException
*/
- public void unlinkIssue(String token, Long issueIdFrom, Long issueIdTo,
String linkType) throws RemoteException
- {
+ public RemoteIssue[] getLinkedInward(String token, Long issueIdFrom,
+ String linkType) throws RemoteException {
User user = tokenManager.retrieveUserNoPermissionCheck(token);

- 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);
- }
- RemoteIssue issueTo = is.getIssueById(user, Long.toString(issueIdTo));
- if (issueTo == null)
- {
- throw new RemoteException("issue 'to' not found. id=" + issueIdTo);
+ 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);
}

- IssueLinkManager ilm =
ComponentManager.getInstance().getIssueLinkManager();
- IssueLinkType contributeLinkType;
- if (linkType.equals(""))
- {
- contributeLinkType = null;
- }
- else
- {
- contributeLinkType = getLinkType(linkType);
+ List<IssueLink> issueInLinks = ilm.getInwardLinks(issueIdFrom);
+
+ List<RemoteIssue> ret = new ArrayList<RemoteIssue>();
+ if (issueInLinks != null) {
+ for (IssueLink issueLink : issueInLinks) {
+ if (contributeLinkType == null
+ || issueLink.getIssueLinkType().equals(
+ contributeLinkType)) {
+ Long issueIdTo = issueLink.getSourceId();
+
+ if (issueIdTo != issueIdFrom) {
+ RemoteIssue issueTo = is.getIssueById(user,
+ Long.toString(issueIdTo));
+
+ ret.add(issueTo);
+ }
+ }
+ }
}

- IssueLink issueLink = ilm.getIssueLink(issueIdFrom, issueIdTo,
contributeLinkType.getId());
-
- if (issueLink == null)
- {
- // link does not exist
- return;
+ return ret.toArray(new RemoteIssue[ret.size()]);
+ }
+
+ /**
+ * retrieve all Outward issues of type <code>linkType</code> the issue
+ * <code>issueIdFrom</code> points to.
+ *
+ * @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[] getLinkedOutward(String token, Long issueIdFrom,
+ String linkType) throws RemoteException {
+ User user = tokenManager.retrieveUserNoPermissionCheck(token);
+
+ 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);
}

- try
- {
- ilm.removeIssueLink(issueLink, user);
- }
- catch (RemoveException e)
- {
- throw new RemoteException(e.getLocalizedMessage());
- }
+ IssueLinkManager ilm = ComponentManager.getInstance()
+ .getIssueLinkManager();
+ IssueLinkType contributeLinkType = null;
+ if (!linkType.equals("")) {
+ contributeLinkType = getLinkType(linkType);
+ }
+
+ List<RemoteIssue> ret = new ArrayList<RemoteIssue>();
+
+ List<IssueLink> issueOutLinks = ilm.getOutwardLinks(issueIdFrom);
+
+ if (issueOutLinks != null) {
+ for (IssueLink issueLink : issueOutLinks) {
+ if (contributeLinkType == null
+ || issueLink.getIssueLinkType().equals(
+ contributeLinkType)) {
+ Long issueIdTo = issueLink.getDestinationId();
+
+ if (issueIdTo != issueIdFrom) {
+ RemoteIssue issueTo = is.getIssueById(user,
+ Long.toString(issueIdTo));
+
+ ret.add(issueTo);
+ }
+ }
+ }
+ }
+ return ret.toArray(new RemoteIssue[ret.size()]);
}

/**
- * create a outward link from <code>issueIdFrom</code> to
<code>issueIdTo</code> of type <code>linkType</code>.
+ * create a outward link from <code>issueIdFrom</code> to
+ * <code>issueIdTo</code> of type <code>linkType</code>.
*
- * @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 {
User user = tokenManager.retrieveUserNoPermissionCheck(token);

- 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);
+ 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);
}
RemoteIssue issueTo = is.getIssueById(user, Long.toString(issueIdTo));
- if (issueTo == null)
- {
+ if (issueTo == null) {
throw new RemoteException("issue 'to' not found. id=" + issueIdTo);
}

- IssueLinkManager ilm =
ComponentManager.getInstance().getIssueLinkManager();
+ IssueLinkManager ilm = ComponentManager.getInstance()
+ .getIssueLinkManager();
IssueLinkType contributeLinkType = getLinkType(linkType);

- if (unique)
- {
- Collection<IssueLink> issueFromLinks = ilm.getIssueLinks(issueIdFrom);
- if (issueFromLinks != null)
- {
- for (IssueLink issueLink : issueFromLinks)
- {
- if (issueLink.getIssueLinkType().equals(contributeLinkType))
- {
- throw new RemoteException("link of type '" +
contributeLinkType.getName() + "' already exists");
+ if (unique) {
+ Collection<IssueLink> issueFromLinks = ilm
+ .getIssueLinks(issueIdFrom);
+ if (issueFromLinks != null) {
+ for (IssueLink issueLink : issueFromLinks) {
+ if (issueLink.getIssueLinkType().equals(contributeLinkType)) {
+ throw new RemoteException("link of type '"
+ + contributeLinkType.getName()
+ + "' already exists");
}
}
}
}
- if (replace)
- {
- Collection<IssueLink> issueFromLinks = ilm.getIssueLinks(issueIdFrom);
- if (issueFromLinks != null)
- {
- for (IssueLink issueLink : issueFromLinks)
- {
- if (issueLink.getIssueLinkType().equals(contributeLinkType))
- {
- try
- {
+ if (replace) {
+ Collection<IssueLink> issueFromLinks = ilm
+ .getIssueLinks(issueIdFrom);
+ if (issueFromLinks != null) {
+ for (IssueLink issueLink : issueFromLinks) {
+ if (issueLink.getIssueLinkType().equals(contributeLinkType)) {
+ try {
ilm.removeIssueLink(issueLink, user);
- }
- catch (RemoveException e)
- {
+ } catch (RemoveException e) {
throw new RemoteException(e.getLocalizedMessage());
}
}
@@ -295,132 +393,188 @@
}
}

- try
- {
- ilm.createIssueLink(issueIdFrom, issueIdTo, contributeLinkType.getId(),
null, user);
- }
- catch (CreateException e)
- {
+ try {
+ ilm.createIssueLink(issueIdFrom, issueIdTo,
+ contributeLinkType.getId(), null, user);
+ } catch (CreateException e) {
+ throw new RemoteException(e.getLocalizedMessage());
+ }
+ }
+
+ /**
+ * remove the link with given info
+ *
+ * @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
+ */
+ public void unlinkIssue(String token, Long issueIdFrom, Long issueIdTo,
+ String linkType) throws RemoteException {
+ User user = tokenManager.retrieveUserNoPermissionCheck(token);
+
+ 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);
+ }
+ RemoteIssue issueTo = is.getIssueById(user, Long.toString(issueIdTo));
+ if (issueTo == null) {
+ throw new RemoteException("issue 'to' not found. id=" + issueIdTo);
+ }
+
+ IssueLinkManager ilm = ComponentManager.getInstance()
+ .getIssueLinkManager();
+ IssueLinkType contributeLinkType;
+ if (linkType.equals("")) {
+ contributeLinkType = null;
+ } else {
+ contributeLinkType = getLinkType(linkType);
+ }
+
+ IssueLink issueLink = ilm.getIssueLink(issueIdFrom, issueIdTo,
+ contributeLinkType.getId());
+
+ if (issueLink == null) {
+ // link does not exist
+ return;
+ }
+
+ try {
+ ilm.removeIssueLink(issueLink, user);
+ } catch (RemoveException e) {
throw new RemoteException(e.getLocalizedMessage());
}
}

- private IssueLinkType getLinkType(String linkType)
- throws RemoteException
- {
- IssueLinkTypeManager iltm =
ComponentManager.getComponentInstanceOfType(IssueLinkTypeManager.class);
-
- Collection<IssueLinkType> contributeLinkTypes =
iltm.getIssueLinkTypesByName(linkType);
- if (contributeLinkTypes == null || contributeLinkTypes.size() < 1)
- {
- throw new RemoteException("no link type with name '" + linkType + "'
found.");
+ private IssueLinkType getLinkType(String linkType) throws RemoteException
{
+ IssueLinkTypeManager iltm = ComponentManager
+ .getComponentInstanceOfType(IssueLinkTypeManager.class);
+
+ Collection<IssueLinkType> contributeLinkTypes = iltm
+ .getIssueLinkTypesByName(linkType);
+ if (contributeLinkTypes == null || contributeLinkTypes.size() < 1) {
+ throw new RemoteException("no link type with name '" + linkType
+ + "' found.");
}

- IssueLinkType contributeLinkType = contributeLinkTypes.iterator().next();
+ IssueLinkType contributeLinkType = contributeLinkTypes.iterator()
+ .next();
return contributeLinkType;
}

- public RemoteIssue getIssueForWorklog(String token, Long worklogId)
throws RemoteException, SearchException
- {
+ public RemoteIssue getIssueForWorklog(String token, Long worklogId)
+ throws RemoteException, SearchException {
Worklog worklog = worklogManager.getById(worklogId);
- if (worklog == null)
- {
+ if (worklog == null) {
return null;
}

return convertIssueObjectToRemoteIssue(worklog.getIssue());
}

- private RemoteIssue convertIssueObjectToRemoteIssue(Issue issue) throws
RemoteException
- {
- return new RemoteIssue(issue, customFieldManager, attachmentManager,
soapUtilsBean);
+ private RemoteIssue convertIssueObjectToRemoteIssue(Issue issue)
+ throws RemoteException {
+ return new RemoteIssue(issue, customFieldManager, attachmentManager,
+ soapUtilsBean);
}

- private String formatTimeDuration(long timeSpentInSeconds)
- {
- return jiraDurationUtils.getFormattedDuration(new
Long(timeSpentInSeconds));
- }
-
- public String[] getCustomFieldValues(String token, Long customFieldId,
Long issueId) throws RemoteException, SearchException
- {
+ /*
+ * private String formatTimeDuration(long timeSpentInSeconds) { return
+ * jiraDurationUtils.getFormattedDuration(new Long(timeSpentInSeconds)); }
+ */
+
+ public String[] getCustomFieldValues(String token, Long customFieldId,
+ Long issueId) throws RemoteException, SearchException {
+ @SuppressWarnings("unused")
User user = tokenManager.retrieveUserNoPermissionCheck(token);

Issue issue = issueManager.getIssueObject(issueId);
- CustomField customField =
customFieldManager.getCustomFieldObject(customFieldId);
-
- Options options =
optionsManager.getOptions(customField.getRelevantConfig(issue));
+ CustomField customField = customFieldManager
+ .getCustomFieldObject(customFieldId);
+
+ Options options = optionsManager.getOptions(customField
+ .getRelevantConfig(issue));

String[] ret = new String[options.size()];
- for (int i = 0; i<options.size(); i++)
- {
+ for (int i = 0; i < options.size(); i++) {
ret[i] = ((Option) options.get(i)).getValue();
}

return ret;
}

- 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 {
+ @SuppressWarnings("unused")
User user = tokenManager.retrieveUserNoPermissionCheck(token);

Project project = projectManager.getProjectObjByKey(projectKey);
- if (project == null)
- {
- throw new RemoteException("project with key '" + projectKey + "' not
found.");
+ if (project == null) {
+ throw new RemoteException("project with key '" + projectKey
+ + "' not found.");
}

- ProjectComponent component = projectComponentManager.create(name,
description, lead, assigneeType, project.getId());
- if (component == null)
- {
- throw new RemoteException("problems creating component with name '" +
name + "' not found.");
+ ProjectComponent component = projectComponentManager.create(name,
+ description, lead, assigneeType, project.getId());
+ if (component == null) {
+ throw new RemoteException("problems creating component with name '"
+ + name + "' not found.");
}

return component.getId();
}

- public void removeComponent(String token, String projectKey, long
componentId) throws RemoteException, RemoteAuthenticationException
- {
+ public void removeComponent(String token, String projectKey,
+ long componentId) throws RemoteException,
+ RemoteAuthenticationException {
+ @SuppressWarnings("unused")
User user = tokenManager.retrieveUserNoPermissionCheck(token);

Project project = projectManager.getProjectObjByKey(projectKey);
- if (project == null)
- {
- throw new RemoteException("project with key '" + projectKey + "' not
found.");
+ if (project == null) {
+ throw new RemoteException("project with key '" + projectKey
+ + "' not found.");
}

- try
- {
+ try {
projectComponentManager.delete(componentId);
- }
- catch (EntityNotFoundException e)
- {
+ } catch (EntityNotFoundException e) {
throw new RemoteException(e.getLocalizedMessage());
}
}

- 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 {
+ @SuppressWarnings("unused")
User user = tokenManager.retrieveUserNoPermissionCheck(token);

Project project = projectManager.getProjectObjByKey(projectKey);
- if (project == null)
- {
- throw new RemoteException("project with key '" + projectKey + "' not
found.");
+ if (project == null) {
+ throw new RemoteException("project with key '" + projectKey
+ + "' not found.");
}

MutableProjectComponent mutableCmp;
- try
- {
+ try {
ProjectComponent cmp = projectComponentManager.find(componentId);
- if (!(cmp instanceof MutableProjectComponent))
- {
- throw new RemoteException("ProjectComponentManager did not return an
updateable component object");
+ if (!(cmp instanceof MutableProjectComponent)) {
+ throw new RemoteException(
+ "ProjectComponentManager did not return an updateable component
object");
}

mutableCmp = (MutableProjectComponent) cmp;
- }
- catch (EntityNotFoundException e)
- {
+ } catch (EntityNotFoundException e) {
throw new RemoteException(e.getLocalizedMessage());
}

@@ -429,50 +583,76 @@
mutableCmp.setLead(lead);
mutableCmp.setAssigneeType(assigneeType);

- try
- {
+ try {
projectComponentManager.update(mutableCmp);
- }
- catch (EntityNotFoundException e)
- {
+ } catch (EntityNotFoundException e) {
throw new RemoteException(e.getLocalizedMessage());
}
}

- public void createSubtaskLink(String token, long parentIssueId, long
subtaskIssueId, long issueTypeId) throws RemoteException
- {
+ /**
+ */
+ public void createSubtaskLink(String token, long parentIssueId,
+ long subtaskIssueId, long issueTypeId) throws RemoteException {
User user = tokenManager.retrieveUserNoPermissionCheck(token);

MutableIssue parentIssue = issueManager.getIssueObject(parentIssueId);
- if (parentIssue == null)
- {
- throw new RemoteException("parent issue not found. id=" +
parentIssueId);
+ if (parentIssue == null) {
+ throw new RemoteException("parent issue not found. id="
+ + parentIssueId);
}

MutableIssue subIssue = issueManager.getIssueObject(subtaskIssueId);
- if (subIssue == null)
- {
- throw new RemoteException("sub issue not found. id=" + subtaskIssueId);
- }
- if (subIssue.getParentId() != null)
- {
- throw new RemoteException("sub issue already linked. id=" +
subtaskIssueId + " parent=" + subIssue.getParentId());
+ if (subIssue == null) {
+ throw new RemoteException("sub issue not found. id="
+ + subtaskIssueId);
+ }
+ if (subIssue.getParentId() != null) {
+ throw new RemoteException("sub issue already linked. id="
+ + subtaskIssueId + " parent=" + subIssue.getParentId());
}

subIssue.setParentId(parentIssue.getId());
- try
- {
+ try {
subTaskManager.createSubTaskIssueLink(parentIssue, subIssue, user);
- }
- catch (CreateException e)
- {
+ } catch (CreateException e) {
throw new RemoteException(e.getLocalizedMessage());
}

// Update the IssueType field to the new SubtaskIssueType
RemoteFieldValue[] actionParams = new RemoteFieldValue[1];
- actionParams[0] = new RemoteFieldValue("issuetype", new String[] {"" +
issueTypeId });
+ actionParams[0] = new RemoteFieldValue("issuetype", new String[] { ""
+ + issueTypeId });
this.updateIssue(token, subIssue.getKey(), actionParams);

}
-}
+
+ public void updateUser(String token, String userid, String fullName,
+ String email) throws RemoteException {
+ @SuppressWarnings("unused")
+ User loggedInUser = tokenManager.retrieveUserNoPermissionCheck(token);
+
+ User user = null;
+ try {
+ user = UserUtils.getUser(userid);
+ } catch (com.opensymphony.user.EntityNotFoundException e) {
+ throw new RemoteException("Unable to find user " + userid);
+ }
+
+ if (false) { // TODO
+ //
getApplicationProperties().getOption(APKeys.JIRA_OPTION_USER_EXTERNALMGT))
+ throw new RemoteException("External user management is enabled");
+ }
+
+ if (!TextUtils.stringSet(TextUtils.noNull(fullName).trim())) {
+ throw new RemoteException("Full name is invalid");
+ }
+ if (!TextUtils.verifyEmail(TextUtils.noNull(email).trim())) {
+ throw new RemoteException("Email is invalid");
+ }
+
+ user.setFullName(fullName);
+ user.setEmail(email);
+ }
+
+}

Reply all
Reply to author
Forward
0 new messages