//_driver = new InfiniteDriver("http://localhost:8184/");
//_driver = new InfiniteDriver("http://URL/api/", "APIKEY");
_driver.useExistingCookie(_cookie);
ResponseObject response = new ResponseObject();
PersonPojo me = _driver.getPerson(null, response);
if (!response.isSuccess() || (null == me)) {
return returnError("Cookie Lookup", "Cookie session expired or never existed, please login first or use valid key or user/pass");
}
// OK some basic access controls:
// 1] if it's an admin command then must be nodes:
if (null == _indexCommand) { // 1]
if (!_indexOrAdminCommand.equals("_nodes")) {
return returnError("Record", "Admin command error - " + _proxyUrl);
}
}//TESTED (1)
else { // Indexes specified, need to check vs person's communities (2-5)
// Mode: stashed/live (/neither)
String mode = this._queryOptions.get("mode");
if (null != mode) {
if (!mode.equalsIgnoreCase("live") && !mode.equalsIgnoreCase("stashed")) { // only allowed values
mode = null;
}
}
// Do we have a community override set?
String commIdStrList = this._queryOptions.get("cids");
HashSet<String> commIdOverrideSet = null;
HashSet<String> dashboardOnly_fullCommunitySet = null;
if (null != commIdStrList) {
String[] commIdStrArray = commIdStrList.split("\\s*,\\s*");
if ((commIdStrArray.length > 1) || !commIdStrArray[0].isEmpty()) {
commIdOverrideSet = new HashSet<String>(Arrays.asList(commIdStrArray));
if (commIdOverrideSet.isEmpty()) { // not specified - all communities
commIdOverrideSet = null;
}
}
}
// Complication: for viewing dashboards, not allowed to ignore while adding new dashboard
// (for any other type, the CIDs aren't present)
boolean isDashboard = _indexOrAdminCommand.equals("kibana-int") && (null != mode);
if (!isDashboard) { // dashboard specific processing
if (null != commIdOverrideSet) {
String applyCommFilter = this._queryOptions.get("commFilter");
if ((null != applyCommFilter) && (applyCommFilter.equals("0") || applyCommFilter.equalsIgnoreCase("false"))) {
commIdOverrideSet = null;
}
}
}//TESTED (by hand)
else if (null != commIdOverrideSet) { // dashboard-specific processing
String applyCommFilter = this._queryOptions.get("commFilter");
if ((null != applyCommFilter) && (applyCommFilter.equals("0") || applyCommFilter.equalsIgnoreCase("false"))) {
dashboardOnly_fullCommunitySet = new HashSet<String>();
}
}//TESTED (by hand)
// Which stores are we examining
boolean showRecords = true;
boolean showCustom = false;
boolean showDocs = false; // (this one is a bit more complex)
String showRecordsVal = this._queryOptions.get("records");
if ((null != showRecordsVal) && (showRecordsVal.equals("0") || showRecordsVal.equalsIgnoreCase("false"))) {
showRecords = false;
}
String showCustomVal = this._queryOptions.get("custom");
if ((null != showCustomVal) && (showCustomVal.equals("1") || showCustomVal.equalsIgnoreCase("true"))) {
showCustom = true;
}
String showDocsVal = this._queryOptions.get("docs");
if ((null != showDocsVal) && (showDocsVal.equals("1") || showDocsVal.equalsIgnoreCase("true"))) {
showDocs = true;
}
if (!showRecords && !showCustom && !showDocs) {
return returnError("Record", "Command error - must show at least one of records, custom, docs");
}
//(TESTED: records, custom)
communityIds = new HashSet<String>();
for (PersonCommunityPojo myComm: me.getCommunities()) {
String commIdStr = myComm.get_id().toString();
if (null != commIdOverrideSet) {
if (commIdOverrideSet.contains(commIdStr)) { // community override but included
communityIds.add(commIdStr);
}