Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

while trying to run the code getting UnirestHandshakeException

package com.ebmpapst.confluence.plugin;

import com.atlassian.confluence.util.HtmlUtil;
import com.atlassian.json.jsonorg.JSONObject;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.opensymphony.webwork.ServletActionContext;
import com.opensymphony.xwork.Action;
import javax.servlet.http.HttpServletRequest;
import java.sql.ResultSet;

//Extends Action Support um an ein paar wichtige Klassen ranzukommen
public class RemLink extends
com.atlassian.confluence.core.ConfluenceActionSupport {
//Globale Variablen f�r Template
String pageUrlOp;
String guidOp;
String doknameop;
String guidDb;
String actionurlop;
String originurlop;
ResultSet rs = null;
private static final long serialVersionUID = 1L;

//"Main" Methode
public String execute() throws Exception {
// Die Start Methode
// Die Grundurl der Website
String pageBaseUrl = settingsManager.getGlobalSettings().getBaseUrl();
// Die Request
HttpServletRequest request = ServletActionContext.getRequest();
// Die Parameter aus der request auslesen und in Variablen schreiben
String dokid = request.getParameter("dokid");
String pageurl = request.getParameter("originurl");
String pageUrldeco = HtmlUtil.urlDecode(pageurl);
String confUser = request.getParameter("confuser").toUpperCase();
String guid = request.getParameter("guid");
// Einige Variablen global setzen so dass sie sp�ter von den Templates
// verwendet werden k�nnen
this.originurlop = pageurl;
this.pageUrlOp = pageUrldeco;
this.actionurlop = pageBaseUrl + "/plugins/remdok/remlink.action?";
// Die Anfrage an den Webservice
boolean ret = sendGet(dokid, guid, confUser);
if (ret) {
// Falls sie erfolgreich ist
return Action.SUCCESS;
} else {
// andernfalls
return Action.ERROR;

// Die Anfrage an den Webservice
private boolean sendGet(String dokid, String guid, String confUser)
throws Exception {
// die Url and der die Parameter angehangen werden
System.out.println("DEBUG REQUEST");
System.out.println("DOKID:" + dokid);
System.out.println("CONFLUENCE USER:" + confUser);
System.out.println("GUID:" + guid);
String url = ""
+ dokid + "/" + confUser + "/" + guid + "/";

// Mit der Url verbinden
HttpResponse<JsonNode> jsonResponse ="accept", "application/json").asJson();
JSONObject res = new JSONObject(jsonResponse.getBody());
JSONObject resItem = new JSONObject(res.getString("array").replaceAll("\\[", "").replaceAll("\\]", ""));
String resType = resItem.getString("result");
String resTypeC = resType.replaceAll("\\[", "").replaceAll("\\]", "");
JSONObject resTypeX = new JSONObject(resTypeC);
// ... Bis man zum Ergebnis kommt
String resTypeY = resTypeX.getString("Type");
// In der Konsole sieht man noch einmal die Schritte der Aufdröselung
// Dröseling auf JSON since 2016
System.out.println("DEBUG RESPONSE");
System.out.println("DEBUG RESPONSE Type");
System.out.println("DEBUG RESPONSE X Type");
System.out.println("DEBUG RESPONSE Y Type");
// Falls die Anfrage erfolgreich war
// ... Und die Aufdr�selung richtig war
// andernfalls
return resTypeY.equals("Success");

// Methoden so dass das Makro an die Variablen rankommt, die es braucht.
public String getpageurl() {
return pageUrlOp;

public String getdokname() {
return doknameop;

public String getactionurl() {
return actionurlop;

public String getoriginurl() {
return originurlop;


0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

59 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you