Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

1.2.62 & adjusted to the metadata changes in R83

  • Loading branch information...
commit 15a6dca5cf8bb3439cfeb8bbe740ed411c09a6f2 1 parent b67779a
@zsvoboda zsvoboda authored
View
2  backend/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
</parent>
<artifactId>gooddata-cl-backend</artifactId>
View
165 backend/src/main/java/com/gooddata/integration/rest/GdcRESTApiWrapper.java
@@ -768,83 +768,6 @@ public JSONObject getAttribute(String attrUri) {
return list;
}
- /**
- * Gets a report definition from the report uri (/gdc/obj...)
- *
- * @param reportUri report uri (/gdc/obj...)
- * @return report definition
- */
- public String getReportDefinition(String reportUri) {
- l.debug( "Getting report definition for report uri=" + reportUri );
- String qUri = getServerUrl() + reportUri;
- HttpMethod qGet = createGetMethod( qUri );
- try {
- String qr = executeMethodOk( qGet );
- JSONObject q = JSONObject.fromObject( qr );
- if (q.isNullObject()) {
- l.debug("Error getting report definition for report uri=" + reportUri);
- throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri);
- }
- JSONObject report = q.getJSONObject("report");
- if (report.isNullObject()) {
- l.debug("Error getting report definition for report uri=" + reportUri);
- throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri);
- }
- JSONObject content = report.getJSONObject("content");
- if (content.isNullObject()) {
- l.debug("Error getting report definition for report uri=" + reportUri);
- throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri);
- }
- JSONArray results = content.getJSONArray("results");
- if (results == null) {
- l.debug("Error getting report definition for report uri=" + reportUri);
- throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri);
- }
- if (results.size() > 0) {
- String lastResultUri = results.getString(results.size() - 1);
- qUri = getServerUrl() + lastResultUri;
- qGet = createGetMethod(qUri);
- GetMethod qGet2 = createGetMethod( qUri );
- try
- {
- qr = executeMethodOk( qGet2 );
- q = JSONObject.fromObject(qr);
- if (q.isNullObject()) {
- l.debug("Error getting report definition for result uri=" + lastResultUri);
- throw new GdcProjectAccessException("Error getting report definition for result uri=" + lastResultUri);
- }
- JSONObject result = q.getJSONObject("reportResult2");
- if (result.isNullObject()) {
- l.debug("Error getting report definition for result uri=" + lastResultUri);
- throw new GdcProjectAccessException("Error getting report definition for result uri=" + lastResultUri);
- }
- content = result.getJSONObject("content");
- if (result.isNullObject()) {
- l.debug("Error getting report definition for result uri=" + lastResultUri);
- throw new GdcProjectAccessException("Error getting report definition for result uri=" + lastResultUri);
- }
- return content.getString("reportDefinition");
- }
- finally
- {
- qGet2.releaseConnection();
- }
- }
- // Here we haven't found any results. Let's try the defaultReportDefinition
- if (content.containsKey("defaultReportDefinition")) {
- String defaultRepDef = content.getString("defaultReportDefinition");
- if (defaultRepDef != null && defaultRepDef.length() > 0)
- return defaultRepDef;
- }
- l.debug("Error getting report definition for report uri=" + reportUri + " . No report results!");
- throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri +
- " . No report results!");
- } finally {
- if (qGet != null)
- qGet.releaseConnection();
- }
- }
-
private String getProjectIdFromObjectUri(String uri) {
Pattern regexp = Pattern.compile("gdc/md/.*?/");
Matcher m = regexp.matcher(uri);
@@ -951,12 +874,11 @@ public double computeMetric(String metricUri) {
public String computeReport(String reportUri) {
l.debug("Computing report uri=" + reportUri);
String retVal = "";
- String reportDefUri = getReportDefinition(reportUri);
int retryCnt = 1000;
boolean hasFinished = false;
while (retryCnt-- > 0 && !hasFinished) {
try {
- String dataResultUri = executeReportDefinition(reportDefUri);
+ String dataResultUri = executeReport(reportUri);
JSONObject result = getObjectByUri(dataResultUri);
hasFinished = true;
if (result != null && !result.isEmpty() && !result.isNullObject()) {
@@ -1075,7 +997,6 @@ public String executeReportDefinition(String reportDefUri) {
exec.put("report_req", execDef);
InputStreamRequestEntity request = new InputStreamRequestEntity(new ByteArrayInputStream(exec.toString().getBytes()));
execPost.setRequestEntity(request);
- String taskLink = null;
try {
String task = executeMethodOk(execPost);
if (task != null && task.length() > 0) {
@@ -1085,19 +1006,19 @@ public String executeReportDefinition(String reportDefUri) {
throw new GdcRestApiException("Executing report definition uri=" + reportDefUri + " failed. " +
"Returned invalid result result=" + tr);
}
- JSONObject reportResult = tr.getJSONObject("reportResult2");
+ JSONObject reportResult = tr.getJSONObject("execResult");
if (reportResult.isNullObject()) {
l.debug("Executing report definition uri=" + reportDefUri + " failed. Returned invalid result result=" + tr);
throw new GdcRestApiException("Executing report definition uri=" + reportDefUri + " failed. " +
"Returned invalid result result=" + tr);
}
- JSONObject content = reportResult.getJSONObject("content");
- if (content.isNullObject()) {
+ String dataResult = reportResult.getString("dataResult");
+ if (dataResult == null || dataResult.length()<=0) {
l.debug("Executing report definition uri=" + reportDefUri + " failed. Returned invalid result result=" + tr);
throw new GdcRestApiException("Executing report definition uri=" + reportDefUri + " failed. " +
"Returned invalid result result=" + tr);
}
- return content.getString("dataResult");
+ return dataResult;
} else {
l.debug("Executing report definition uri=" + reportDefUri + " failed. Returned invalid task link uri=" + task);
throw new GdcRestApiException("Executing report definition uri=" + reportDefUri +
@@ -1135,19 +1056,19 @@ public String executeReport(String reportUri) {
throw new GdcRestApiException("Executing report uri=" + reportUri + " failed. " +
"Returned invalid result result=" + tr);
}
- JSONObject reportResult = tr.getJSONObject("reportResult2");
+ JSONObject reportResult = tr.getJSONObject("execResult");
if (reportResult.isNullObject()) {
l.debug("Executing report uri=" + reportUri + " failed. Returned invalid result=" + tr);
throw new GdcRestApiException("Executing report uri=" + reportUri + " failed. " +
"Returned invalid result result=" + tr);
}
- JSONObject meta = reportResult.getJSONObject("meta");
- if (meta.isNullObject()) {
- l.debug("Executing report uri=" + reportUri + " failed. Returned invalid result=" + tr);
+ String dataResult = reportResult.getString("dataResult");
+ if (dataResult == null || dataResult.length()<=0) {
+ l.debug("Executing report uri=" + reportUri + " failed. Returned invalid dataResult=" + tr);
throw new GdcRestApiException("Executing report uri=" + reportUri + " failed. " +
- "Returned invalid result=" + tr);
+ "Returned invalid dataResult=" + tr);
}
- return meta.getString("uri");
+ return dataResult;
} else {
l.debug("Executing report uri=" + reportUri + " failed. Returned invalid task link uri=" + task);
throw new GdcRestApiException("Executing report uri=" + reportUri +
@@ -2739,16 +2660,6 @@ public JSONObject getObjectByUri(String objectUri) {
public MetadataObject getMetadataObject(String objectUri) {
l.debug("Executing getMetadataObject uri=" + objectUri);
MetadataObject o = new MetadataObject(getObjectByUri(objectUri));
- String tp = o.getType();
- if (tp.equalsIgnoreCase("report")) {
- try {
- String rdf = getReportDefinition(objectUri);
- JSONObject c = o.getContent();
- c.put("defaultReportDefinition", rdf);
- } catch (GdcProjectAccessException e) {
- l.debug("Can't extract the default report definition.");
- }
- }
return o;
}
@@ -3101,7 +3012,7 @@ private static DeleteMethod createDeleteMethod(String path) {
request.setRequestHeader("Content-Type", "application/json; charset=utf-8");
request.setRequestHeader("Accept", "application/json");
request.setRequestHeader("Accept-Charset", "utf-u");
- request.setRequestHeader("User-Agent", "GoodData CL/1.2.61");
+ request.setRequestHeader("User-Agent", "GoodData CL/1.2.62");
return request;
}
@@ -3412,4 +3323,56 @@ public String createProject(String name, String desc, String templateUri)
l.debug("Found projects " + list);
return list;
}
+
+ /**
+ * Gets a report definition from the report uri (/gdc/obj...)
+ *
+ * @param reportUri report uri (/gdc/obj...)
+ * @return report definition
+ */
+ @Deprecated
+ public String getReportDefinition(String reportUri) {
+ l.debug( "Getting report definition for report uri=" + reportUri );
+ String qUri = getServerUrl() + reportUri;
+ HttpMethod qGet = createGetMethod( qUri );
+ try {
+ String qr = executeMethodOk( qGet );
+ JSONObject q = JSONObject.fromObject( qr );
+ if (q.isNullObject()) {
+ l.debug("Error getting report definition for report uri=" + reportUri);
+ throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri);
+ }
+ JSONObject report = q.getJSONObject("report");
+ if (report.isNullObject()) {
+ l.debug("Error getting report definition for report uri=" + reportUri);
+ throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri);
+ }
+ JSONObject content = report.getJSONObject("content");
+ if (content.isNullObject()) {
+ l.debug("Error getting report definition for report uri=" + reportUri);
+ throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri);
+ }
+ JSONArray definitions = content.getJSONArray("definitions");
+ if (definitions == null) {
+ l.debug("Error getting report definition for report uri=" + reportUri);
+ throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri);
+ }
+ if (definitions.size() > 0) {
+ String lastDefUri = definitions.getString(definitions.size() - 1);
+ qUri = getServerUrl() + lastDefUri;
+ return lastDefUri;
+ }
+ else {
+ l.debug("Error getting report definition for report uri=" + reportUri);
+ throw new GdcProjectAccessException("Error getting report definition for report uri=" + reportUri);
+ }
+ } finally {
+ if (qGet != null)
+ qGet.releaseConnection();
+ }
+ }
+
+
}
+
+
View
88 backend/src/test/java/com/gooddata/integration/rest/TestGdcRestApiWrapper.java
@@ -40,37 +40,60 @@
private static Logger l = Logger.getLogger(TestGdcRestApiWrapper.class);
- NamePasswordConfiguration config = null;
+ //NamePasswordConfiguration config = null;
- //NamePasswordConfiguration config = new NamePasswordConfiguration("https","secure.gooddata.com","zd@gooddata.com","xxx");
+ NamePasswordConfiguration config = new NamePasswordConfiguration("https","js-rrrrd-devel.getgooddata.com","bear@gooddata.com","jindrisska");
String[] checkUrls = {
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/4170",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/12238",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/5479",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/13344",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/7261",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/12218",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/1788",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/13928",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/4148",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/8067",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/16843",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/3392",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/4192",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/4499",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/13772",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/18799",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/10730",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/6833",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/12467",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/7456",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/13785",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/4228",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/13876",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/3329",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/6826",
- "/gdc/md/bd410owmaf3lks1qxtecwjpls340ckg5/obj/5138"
+ "/gdc/md/FoodMartDemo/obj/130003800",
+ "/gdc/md/FoodMartDemo/obj/130001937",
+ "/gdc/md/FoodMartDemo/obj/130002154",
+ "/gdc/md/FoodMartDemo/obj/130002361",
+ "/gdc/md/FoodMartDemo/obj/130002376",
+ "/gdc/md/FoodMartDemo/obj/130002297",
+ "/gdc/md/FoodMartDemo/obj/130002162",
+ "/gdc/md/FoodMartDemo/obj/130002654",
+ "/gdc/md/FoodMartDemo/obj/130002587",
+ "/gdc/md/FoodMartDemo/obj/130002121",
+ "/gdc/md/FoodMartDemo/obj/130002004",
+ "/gdc/md/FoodMartDemo/obj/130002614",
+ "/gdc/md/FoodMartDemo/obj/130002675",
+ "/gdc/md/FoodMartDemo/obj/130002632",
+ "/gdc/md/FoodMartDemo/obj/130002292",
+ "/gdc/md/FoodMartDemo/obj/130002187",
+ "/gdc/md/FoodMartDemo/obj/130002355",
+ "/gdc/md/FoodMartDemo/obj/130001832",
+ "/gdc/md/FoodMartDemo/obj/130002891",
+ "/gdc/md/FoodMartDemo/obj/130002151",
+ "/gdc/md/FoodMartDemo/obj/130002449",
+ "/gdc/md/FoodMartDemo/obj/130001911",
+ "/gdc/md/FoodMartDemo/obj/130001982",
+ "/gdc/md/FoodMartDemo/obj/130002111",
+ "/gdc/md/FoodMartDemo/obj/130002371",
+ "/gdc/md/FoodMartDemo/obj/130002310",
+ "/gdc/md/FoodMartDemo/obj/130002317",
+ "/gdc/md/FoodMartDemo/obj/130002188",
+ "/gdc/md/FoodMartDemo/obj/130002303",
+ "/gdc/md/FoodMartDemo/obj/130002024",
+ "/gdc/md/FoodMartDemo/obj/130002469",
+ "/gdc/md/FoodMartDemo/obj/130001892",
+ "/gdc/md/FoodMartDemo/obj/130002087",
+ "/gdc/md/FoodMartDemo/obj/130002505",
+ "/gdc/md/FoodMartDemo/obj/130001874",
+ "/gdc/md/FoodMartDemo/obj/130001844",
+ "/gdc/md/FoodMartDemo/obj/130002356",
+ "/gdc/md/FoodMartDemo/obj/130001858",
+ "/gdc/md/FoodMartDemo/obj/130002366",
+ "/gdc/md/FoodMartDemo/obj/130001967",
+ "/gdc/md/FoodMartDemo/obj/130002225",
+ "/gdc/md/FoodMartDemo/obj/130002209",
+ "/gdc/md/FoodMartDemo/obj/130002431",
+ "/gdc/md/FoodMartDemo/obj/130001900",
+ "/gdc/md/FoodMartDemo/obj/130002324",
+ "/gdc/md/FoodMartDemo/obj/130002567",
+ "/gdc/md/FoodMartDemo/obj/130002868",
+ "/gdc/md/FoodMartDemo/obj/130002036",
+ "/gdc/md/FoodMartDemo/obj/130002195"
};
public void testComputeMetric() throws Exception {
@@ -79,13 +102,8 @@ public void testComputeMetric() throws Exception {
GdcRESTApiWrapper rest = new GdcRESTApiWrapper(config);
rest.login();
for (String url : checkUrls) {
- List<JSONObject> deps = rest.usedBy(url);
- for (JSONObject d : deps) {
- if ("report".equalsIgnoreCase(d.getString("category"))) {
- System.out.println(d.getString("link") + " : " + d.getString("title"));
- }
- }
-
+ String value = rest.getReportDefinition(url);
+ System.out.println("Result "+value);
}
rest.logout();
}
View
2  cli-distro/pom.xml
@@ -29,7 +29,7 @@
<parent>
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
</parent>
<artifactId>gooddata-cli</artifactId>
View
2  cli/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
</parent>
<artifactId>gooddata-cl-cli</artifactId>
View
2  cli/src/main/java/com/gooddata/processor/CreateZendeskV3Projects.java
@@ -267,7 +267,7 @@ protected CliParams parse(CommandLine ln) throws InvalidArgumentException {
CliParams cp = new CliParams();
if (cp.containsKey(CLI_PARAM_VERSION[0])) {
- l.info("GoodData CL version 1.2.61");
+ l.info("GoodData CL version 1.2.62");
System.exit(0);
}
View
11 cli/src/main/java/com/gooddata/processor/GdcDI.java
@@ -384,7 +384,7 @@ protected CliParams parse(CommandLine ln, Properties defaults) throws InvalidArg
if (cp.containsKey(CLI_PARAM_VERSION[0])) {
- l.info("GoodData CL version 1.2.61" +
+ l.info("GoodData CL version 1.2.62" +
((BUILD_NUMBER.length() > 0) ? ", build " + BUILD_NUMBER : "."));
System.exit(0);
@@ -1382,12 +1382,11 @@ private void executeReports(Command c, CliParams p, ProcessingContext ctx) throw
String[] uris = result.split("\n");
for (String uri : uris) {
try {
- String defUri = ctx.getRestApi(p).getReportDefinition(uri.trim());
- l.info("Executing report uri=" + defUri);
- String task = ctx.getRestApi(p).executeReportDefinition(defUri.trim());
- l.info("Report " + defUri + " execution finished: " + task);
+ l.info("Executing report uri=" + uri);
+ String task = ctx.getRestApi(p).executeReport(uri.trim());
+ l.info("Report " + uri + " execution finished: " + task);
} catch (GdcRestApiException e) {
- l.debug("The report uri=" + uri + " can't be computed!");
+ l.debug("The report uri=" + uri + " can't be computed!",e);
l.info("The report uri=" + uri + " can't be computed!");
}
}
View
2  common/pom.xml
@@ -29,7 +29,7 @@
<parent>
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
</parent>
<artifactId>gooddata-cl-common</artifactId>
View
2  connector/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
</parent>
<artifactId>gooddata-cl-connector</artifactId>
View
2  connector/src/main/java/com/gooddata/chargify/ChargifyWrapper.java
@@ -241,7 +241,7 @@ private static DeleteMethod createDeleteMethod(String path) {
private static <T extends HttpMethod> T configureHttpMethod(T request) {
request.setRequestHeader("Content-Type", "text/xml");
request.setRequestHeader("Accept", "text/xml");
- request.setRequestHeader("User-Agent", "GoodData CL/1.2.61");
+ request.setRequestHeader("User-Agent", "GoodData CL/1.2.62");
return request;
}
View
2  notification-distro/pom.xml
@@ -29,7 +29,7 @@
<parent>
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
</parent>
<artifactId>gooddata-alert</artifactId>
View
2  notification/pom.xml
@@ -29,7 +29,7 @@
<parent>
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
</parent>
<artifactId>gooddata-notification</artifactId>
View
2  notification/src/main/java/com/gooddata/processor/GdcNotification.java
@@ -371,7 +371,7 @@ else if (defaults.getProperty(name) != null) {
}
if (cp.containsKey(CLI_PARAM_VERSION[0])) {
- l.info("GoodData Notification Tool version 1.2.61" +
+ l.info("GoodData Notification Tool version 1.2.62" +
((BUILD_NUMBER.length() > 0) ? ", build " + BUILD_NUMBER : "."));
System.exit(0);
View
2  pom.xml
@@ -28,7 +28,7 @@
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
<name>gooddata-cl</name>
<description>GoodData CL command line tool and Java API framework.</description>
<url>http://developer.gooddata.com</url>
View
2  sfdc/pom.xml
@@ -29,7 +29,7 @@
<parent>
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
</parent>
<artifactId>gooddata-sfdc-lib</artifactId>
View
2  web/pom.xml
@@ -29,7 +29,7 @@
<parent>
<groupId>com.gooddata.cl</groupId>
<artifactId>gooddata-cl</artifactId>
- <version>1.2.61</version>
+ <version>1.2.62</version>
</parent>
<artifactId>gooddata-cl-web</artifactId>
Please sign in to comment.
Something went wrong with that request. Please try again.