use of net.nemerosa.ontrack.extension.jira.client.JIRAClient in project ontrack by nemerosa.
the class JIRAServiceExtension method followLinks.
/**
* Given an issue seed, and a list of link names, follows the given links recursively and
* puts the associated issues into the {@code collectedIssues} map.
*
* @param configuration JIRA configuration to use to load the issues
* @param seed Issue to start from.
* @param linkNames Links to follow
* @param collectedIssues Collected issues, indexed by their key
*/
public void followLinks(JIRAConfiguration configuration, JIRAIssue seed, Set<String> linkNames, Map<String, JIRAIssue> collectedIssues) {
try (Transaction tx = transactionService.start()) {
JIRASession session = getJIRASession(tx, configuration);
// Gets the client from the current session
JIRAClient client = session.getClient();
// Puts the seed into the list
collectedIssues.put(seed.getKey(), seed);
// Gets the linked issue keys
seed.getLinks().stream().filter(linkedIssue -> linkNames.contains(linkedIssue.getLinkName())).filter(linkedIssue -> !collectedIssues.containsKey(linkedIssue.getKey())).map(linkedIssue -> client.getIssue(linkedIssue.getKey(), configuration)).forEach(linkedIssue -> followLinks(configuration, linkedIssue, linkNames, collectedIssues));
}
}
use of net.nemerosa.ontrack.extension.jira.client.JIRAClient in project ontrack by nemerosa.
the class JIRASessionFactoryImpl method create.
@Override
public JIRASession create(JIRAConfiguration configuration) {
// Creates a HTTP JSON client
JsonClient jsonClient = clientFactory.getJsonClient(new ClientConnection(configuration.getUrl(), configuration.getUser(), configuration.getPassword()));
// Creates the client
JIRAClient client = new JIRAClientImpl(jsonClient);
// Creates the session
return new JIRASession() {
@Override
public JIRAClient getClient() {
return client;
}
@Override
public void close() {
client.close();
}
};
}
Aggregations