作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何捕获 CMC(中央管理控制台)或 WEBI 工具中可用的所有报告的 CUID 并将其粘贴到 Excel 中?
我可以通过查看每个报告属性来手动进行检查,但如果我希望通过编码捕获所有 CUID,这可能吗?
这可以用Java语言完成吗?
最佳答案
不是我的,但希望它可以帮助你:
以下是将 Web Intelligence 文档导出为 CSV 格式的示例 Java 代码。
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
public class Document {
public static void main(String[] args) {
try {
URL url = new URL(
“http://localhost:6405/biprws/raylight/v1/documents/7485/dataproviders/DP0/flows/0“);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(“GET”);
conn.setRequestProperty(“Accept”, “text/plain”);//change to text/plain if you want in CSV format
String logonToken = “\”” + getLogonToken() + “\””;
conn.setRequestProperty(“X-SAP-LogonToken”, logonToken);
conn.setDoOutput(true);
conn.setDoInput(true);
conn.connect();
if (conn.getResponseCode() != 200) {
throw new RuntimeException(“Failed : HTTP error code : “
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
String output;
// Exported CSV file will be generated at “C://rest.csv”, location could be changed as required.
File f1 = new File(“C://rest.csv”);
f1.createNewFile();
FileWriter fw = new FileWriter(f1);//change extension to .csv for csv format
BufferedWriter bw = new BufferedWriter(fw);
while ((output = br.readLine()) != null) {
bw.write(output);
bw.write(“\n”);
}
bw.close();
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
}
public static String getLogonToken() throws ParseException, IOException {
String logontoken = null;
URL url = new URL(“http://localhost:6405/biprws/logon/long/“);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(“POST”);
conn.setRequestProperty(“Accept”, “application/json”);
conn.setRequestProperty(“Content-Type”,
“application/xml; charset=utf-8”);
conn.setDoInput(true);
conn.setDoOutput(true);
String body = “<attrs xmlns=\”http://www.sap.com/rws/bip\“>”
+ “<attr name=\”userName\” type=\”string\”>Administrator</attr>”
+ “<attr name=\”password\” type=\”string\”>Password</attr>”
+ “<attr name=\”auth\” type=\”string\” possibilities=\”secEnterprise,secLDAP,secWinAD\”>secEnterprise</attr>”
+ “</attrs>”;
int len = body.length();
conn.setRequestProperty(“Content-Length”, Integer.toString(len));
conn.connect();
OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
out.write(body, 0, len);
out.flush();
if (conn.getResponseCode() != 200) {
throw new RuntimeException(“Failed : HTTP error code : “
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
String jsontxt = br.readLine();
JSONParser parser = new JSONParser();
JSONObject json = (JSONObject) parser.parse(jsontxt);
logontoken = (String) json.get(“logonToken”);
conn.disconnect();
return logontoken;
}
}
您也可以检查一下:
https://blogs.sap.com/2013/09/13/export-webi-report-using-the-restful-sdk/
关于java - 获取所有报告的 CUID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62299244/
如何捕获 CMC(中央管理控制台)或 WEBI 工具中可用的所有报告的 CUID 并将其粘贴到 Excel 中? 我可以通过查看每个报告属性来手动进行检查,但如果我希望通过编码捕获所有 CUID,这可
我正在考虑使用 cuid ( https://www.npmjs.com/package/cuid ) 来替换 mongoose 自然生成的 objectid,这样我的模型中的 _id 将获得 cui
我是一名优秀的程序员,十分优秀!