jira-integration: Allow to store a comma-separated list of labels instead of URL
This patch allows the user to store a URL or a comma-separated list of words to specify the possible labels for the JIRA connector. FEA: ItEr77S16JiraAndTimConnectorContributionIntegration
This commit is contained in:
parent
f5d8984c5b
commit
5d439b032a
3 changed files with 19 additions and 8 deletions
|
|
@ -21,11 +21,15 @@ package org.libreplan.importers;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.libreplan.business.advance.bootstrap.PredefinedAdvancedTypes;
|
||||
import org.libreplan.business.advance.entities.AdvanceMeasurement;
|
||||
|
|
@ -67,7 +71,14 @@ public class JiraOrderElementSynchronizer implements IJiraOrderElementSynchroniz
|
|||
String jiraLabelUrl = configurationDAO.getConfiguration()
|
||||
.getJiraConfiguration().getJiraLabelUrl();
|
||||
|
||||
return JiraRESTClient.getAllLables(jiraLabelUrl);
|
||||
String labels;
|
||||
try {
|
||||
new URL(jiraLabelUrl);
|
||||
labels = JiraRESTClient.getAllLables(jiraLabelUrl);
|
||||
} catch (MalformedURLException e) {
|
||||
labels = jiraLabelUrl;
|
||||
}
|
||||
return Arrays.asList(StringUtils.split(labels, ","));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
package org.libreplan.importers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -28,7 +27,6 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.cxf.jaxrs.client.WebClient;
|
||||
import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
|
||||
import org.codehaus.jackson.map.DeserializationConfig.Feature;
|
||||
|
|
@ -70,12 +68,11 @@ public class JiraRESTClient {
|
|||
*
|
||||
* @param url
|
||||
* the url from where to fetch data
|
||||
* @return List of labels
|
||||
* @return String with the list of labels sepparated by comma
|
||||
*/
|
||||
public static List<String> getAllLables(String url) {
|
||||
public static String getAllLables(String url) {
|
||||
WebClient client = WebClient.create(url).accept(mediaTypes);
|
||||
String labels = client.get(String.class);
|
||||
return Arrays.asList(StringUtils.split(labels, ","));
|
||||
return client.get(String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,11 +24,13 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
@ -57,8 +59,9 @@ public class JiraRESTClientTest {
|
|||
@Test
|
||||
@Ignore("Only working if you have a JIRA server configured")
|
||||
public void testGetAllLablesFromValidLabelUrl() {
|
||||
List<String> result = JiraRESTClient.getAllLables(properties
|
||||
String labels = JiraRESTClient.getAllLables(properties
|
||||
.getProperty("label_url"));
|
||||
List<String> result = Arrays.asList(StringUtils.split(labels, ","));
|
||||
assertTrue(result.size() > 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue