1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2011, 2013, 2014, 2016 Synacor, Inc. 5 * 6 * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at: https://www.zimbra.com/license 9 * The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 10 * have been added to cover use of software over a computer network and provide for limited attribution 11 * for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B. 12 * 13 * Software distributed under the License is distributed on an "AS IS" basis, 14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. 15 * See the License for the specific language governing rights and limitations under the License. 16 * The Original Code is Zimbra Open Source Web Client. 17 * The Initial Developer of the Original Code is Zimbra, Inc. All rights to the Original Code were 18 * transferred by Zimbra, Inc. to Synacor, Inc. on September 14, 2015. 19 * 20 * All portions of the code are Copyright (C) 2011, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * @overview 26 * 27 * This file accesses the set of system retention policies 28 * 29 */ 30 31 ZmSystemRetentionPolicy = function() { 32 }; 33 34 ZmSystemRetentionPolicy.prototype.constructor = ZmSystemRetentionPolicy; 35 36 ZmSystemRetentionPolicy.prototype.toString = 37 function() { 38 return "ZmSystemRetentionPolicy"; 39 }; 40 41 ZmSystemRetentionPolicy.prototype.getKeepPolicies = 42 function() { 43 return this._keepPolicies; 44 }; 45 46 ZmSystemRetentionPolicy.prototype.getPurgePolicies = 47 function() { 48 return this._purgePolicies; 49 }; 50 51 52 // Read the system retention policies from the server 53 ZmSystemRetentionPolicy.prototype.getPolicies = 54 function(callback, batchCmd) { 55 this._keepPolicies = new Array(); 56 this._purgePolicies = new Array(); 57 58 var jsonObj = {GetSystemRetentionPolicyRequest:{_jsns:"urn:zimbraMail"}}; 59 var request = jsonObj.GetSystemRetentionPolicyRequest; 60 var respCallback = this._handleResponseGetPolicies.bind(this, callback); 61 if (batchCmd) { 62 batchCmd.addRequestParams(jsonObj, respCallback); 63 } else { 64 appCtxt.getRequestMgr().sendRequest({jsonObj:jsonObj, asyncMode:true, callback:respCallback}); 65 } 66 }; 67 68 69 70 ZmSystemRetentionPolicy.prototype._handleResponseGetPolicies = 71 function(callback, result) { 72 var resp = result.getResponse().GetSystemRetentionPolicyResponse; 73 if (resp.retentionPolicy) { 74 if (resp.retentionPolicy[0].keep && resp.retentionPolicy[0].keep[0] && 75 resp.retentionPolicy[0].keep[0].policy) { 76 this._keepPolicies = resp.retentionPolicy[0].keep[0].policy; 77 } 78 if (resp.retentionPolicy[0].purge && resp.retentionPolicy[0].purge[0] && 79 resp.retentionPolicy[0].purge[0].policy) { 80 this._purgePolicies = resp.retentionPolicy[0].purge[0].policy; 81 } 82 } 83 if (callback) { 84 callback.run(this._keepPolicies, this._purgePolicies); 85 } 86 }; 87