You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
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
@Override
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("=========================");
System.out.println("DEBUG REQUEST");
System.out.println("DOKID:" + dokid);
System.out.println("CONFLUENCE USER:" + confUser);
System.out.println("GUID:" + guid);
System.out.println("=========================");
String url = "https://edm-files-documents-service-api.dev.cloud.ebmpapst.com/api/confluence/document-link/"
+ dokid + "/" + confUser + "/" + guid + "/";
// Mit der Url verbinden
HttpResponse<JsonNode> jsonResponse = Unirest.post(url).header("accept", "application/json").asJson();
System.out.println(jsonResponse.getBody());
System.out.println(jsonResponse.toString());
JSONObject res = new JSONObject(jsonResponse.getBody());
JSONObject resItem = new JSONObject(res.getString("array").replaceAll("\\[", "").replaceAll("\\]", ""));
System.out.println(resItem);
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("===============================");
System.out.println("DEBUG RESPONSE");
System.out.println(resItem);
System.out.println("DEBUG RESPONSE Type");
System.out.println(resType);
System.out.println("DEBUG RESPONSE X Type");
System.out.println(resTypeX);
System.out.println("DEBUG RESPONSE Y Type");
System.out.println(resTypeY);
System.out.println("===============================");
// 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;
}
}
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...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events