Hello,
I'm trying from a JIRA addon communicate with Confluence and realize several actions like: create a page, attach files, etc.
I'm using the following code to do the above actions:
final ApplicationLink conflLink = applicationLinkService.getPrimaryApplicationLink(ConfluenceApplicationType.class);
ApplicationLinkRequestFactory authenticatedRequestFactory = conflLink.createImpersonatingAuthenticatedRequestFactory();
....
public HashMap<String, String> createPage(ApplicationLinkRequestFactory authenticatedRequestFactory, Issue issue, JSONObject newPage) throws CredentialsRequiredException, ResponseException {
final HashMap<String, String> datosPage = new HashMap<String, String>();
final Issue issueFinal = issue;
authenticatedRequestFactory
.createRequest(Request.MethodType.POST, REQUEST_URL)
.addHeader("Content-Type", "application/json")
.setRequestBody(newPage.toString())
.execute(new ResponseHandler<Response>() {
@Override
public void handle(Response response) throws ResponseException {
if(response.getStatusCode() != HttpURLConnection.HTTP_OK) {
try {
throw new Exception(response.getResponseBodyAsString());
} catch (Exception e) {
log.error(e.getMessage());
String commentBody = i18nResolver.getText("val.error.create.page") + e.getMessage();
createComment(issueFinal, commentBody);
}
}
else {
HashMap<String, Object> responsePage = jsonToMap(response.getResponseBodyAsString());
datosPage.put("id",(String) responsePage.get("id"));
datosPage.put("title", (String) responsePage.get("title"));
HashMap<String, Object> dataLinks = stringMapToHashMap((StringMap) responsePage.get("_links"));
String url = dataLinks.get("base") + (String) dataLinks.get("webui");
datosPage.put("url", url);
}
}
});
return datosPage;
} And this code worked well but sometimes I get the exception:
ResponseException - java.net.SocketTimeoutException: Read timed out
I tried to increase the Socket timeout in Confluence but still happen.
There is another way to make communication between JIRA and Confluence?
How I can resolve that exception problem?
Thanks in advance!