Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Commit 44a8b2e

Browse files
author
Sander Postma
committed
Added functions getRootWeb() and getSubWebs()
1 parent 2b9884a commit 44a8b2e

File tree

4 files changed

+297
-129
lines changed

4 files changed

+297
-129
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
mavenArtifactId = sharepoint-services-java
2-
mavenVersion = 1.1.0-sphereon
2+
mavenVersion = 1.2.0-sphereon

sdk/sharepoint-services/src/main/java/com/microsoft/services/sharepoint/ListClient.java

+69
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public void onSuccess(JSONObject json) {
7373
result.set(list);
7474
} catch (JSONException e) {
7575
log(e);
76+
result.setException(e);
7677
}
7778
}
7879
});
@@ -135,6 +136,7 @@ public void onSuccess(JSONObject json) {
135136
result.set(SPListItem.listFromJson(json));
136137
} catch (JSONException e) {
137138
log(e);
139+
result.setException(e);
138140
}
139141
}
140142
});
@@ -197,6 +199,7 @@ public void onSuccess(JSONObject json) {
197199
result.set(SPListItem.listFromJson(json));
198200
} catch (JSONException e) {
199201
log(e);
202+
result.setException(e);
200203
}
201204
}
202205
});
@@ -230,6 +233,7 @@ public void onSuccess(JSONObject json) {
230233
result.set(SPListField.listFromJson(json));
231234
} catch (JSONException e) {
232235
log(e);
236+
result.setException(e);
233237
}
234238
}
235239
});
@@ -419,6 +423,71 @@ public void onSuccess(JSONObject json) {
419423
result.set(columnNames);
420424
} catch (JSONException e) {
421425
log(e);
426+
result.setException(e);
427+
}
428+
}
429+
});
430+
return result;
431+
}
432+
433+
434+
/**
435+
* Get a list of sub-webs for the current site collection
436+
* @return
437+
*/
438+
public ListenableFuture<List<SPWeb>> getSubWebs() {
439+
final SettableFuture<List<SPWeb>> result = SettableFuture.create();
440+
441+
String getListsUrl = getSiteUrl() + "_api/web/?$select=Webs&$expand=Webs";
442+
443+
ListenableFuture<JSONObject> request = executeRequestJson(getListsUrl, "GET");
444+
445+
Futures.addCallback(request, new FutureCallback<JSONObject>() {
446+
@Override
447+
public void onFailure(Throwable t) {
448+
result.setException(t);
449+
}
450+
451+
@Override
452+
public void onSuccess(JSONObject json) {
453+
try {
454+
List<SPWeb> list = SPWeb.listFromJson(json);
455+
result.set(list);
456+
} catch (JSONException e) {
457+
log(e);
458+
result.setException(e);
459+
}
460+
}
461+
});
462+
return result;
463+
}
464+
465+
466+
/**
467+
* Get root web for the current site collection
468+
* @return
469+
*/
470+
public ListenableFuture<SPWeb> getRootWeb() {
471+
final SettableFuture<SPWeb> result = SettableFuture.create();
472+
473+
String getListsUrl = getSiteUrl() + "_api/Site/RootWeb";
474+
475+
ListenableFuture<JSONObject> request = executeRequestJson(getListsUrl, "GET");
476+
477+
Futures.addCallback(request, new FutureCallback<JSONObject>() {
478+
@Override
479+
public void onFailure(Throwable t) {
480+
result.setException(t);
481+
}
482+
483+
@Override
484+
public void onSuccess(JSONObject json) {
485+
try {
486+
SPWeb rootWeb = SPWeb.createFromJson(json, SPWeb.class);
487+
result.set(rootWeb);
488+
} catch (JSONException e) {
489+
log(e);
490+
result.setException(e);
422491
}
423492
}
424493
});

0 commit comments

Comments
 (0)