public Map<String, String> createAccessControlEnablePolicyPostData( Integer[] policyEnable, Integer[] policyDisable) { Map<String, String> postData = this.getRouterParsing().advanced_accesscontrol.postPolicy; String enabledReplace = "%enable%"; String disableReplace = "%disable%"; for (Entry<String, String> entry : postData.entrySet()) { if (entry.getValue().contains(enabledReplace)) postData.put( entry.getKey(), entry.getValue().replace(enabledReplace, Utils.implode(policyEnable, ","))); if (entry.getValue().contains(disableReplace)) postData.put( entry.getKey(), entry.getValue().replace(disableReplace, Utils.implode(policyDisable, ","))); } return postData; }
public void doAccessControlEnabled(boolean enabled) throws Exception { Log.d(TAG, "DoAccessControlEnabled: " + enabled); // Create post data Map<String, String> postData = createAccessControlEnabledPostData(enabled); Log.d(TAG, "Post Data:\n" + Utils.mapToString(postData)); // Post access control data RestClient restClient = createRestClient(getRouterPage(this.getRouterParsing().advanced_accesscontrol.page)); restClient.addData(postData); Response response = restClient.execute(RequestMethod.POST); // Is logged in if (isNotLoggedIn(response)) throw new NotLoggedinException(); }
public void doAccessControlPolicy(boolean enabled, int policyId) throws Exception { Log.d(TAG, "doAccessControlPolicyEnabled: " + enabled + ", " + policyId); // Create post data Integer[] policyIds = {policyId}; Map<String, String> postData = createAccessControlEnablePolicyPostData( enabled ? policyIds : null, !enabled ? policyIds : null); Log.d(TAG, "Post Data:\n" + Utils.mapToString(postData)); // Post access control data RestClient restClient = createRestClient(getRouterPage(this.getRouterParsing().advanced_accesscontrol.page)); restClient.addData(postData); Response response = restClient.execute(RequestMethod.POST); // Is logged in if (isNotLoggedIn(response)) throw new NotLoggedinException(); }