def doAdminActions(self, task): """Execute Admin Objects Actions""" response = self.empty_response(task) # Load Object Class ws_object = Framework.getObject(task["params"]['type']) # READING OF OBJECT DESCRIPTION if task['name'] == const.__SPL_F_DESC__: if ws_object: response['data'] = ws_object.description() response['result'] = bool(response['data'].__len__()) # READING OF OBJECT FIELDS if task['name'] == const.__SPL_F_FIELDS__: if ws_object: response['data'] = ws_object.fields() response['result'] = bool(response['data'].__len__()) # READING OF OBJECTS LIST if task['name'] == const.__SPL_F_LIST__: try: filters = task["params"]["filters"] except: filters = None try: parameters = task["params"]["params"] except: parameters = None if ws_object: response['data'] = ws_object.objectsList(filters, parameters) response['result'] = bool(response['data'].__len__()) return response
def get_file(self, path, md5): # Walk for File on All Registered Objects for object_type in Framework.getObjects(): object_class = Framework.getObject(object_type) file = object_class.getFile(path, md5) # Verify File was Found if file is None or not isinstance(file, dict): continue # Verify File Md5 if file['md5'] != md5: continue return file Framework.log().error("File Not Found") return None
def doSyncActions(self, task): """Execute Admin Objects Actions""" from splashpy.componants.validator import Validator response = self.empty_response(task) # Load Object Class ws_object = Framework.getObject(task["params"]['type']) ws_object_id = task["params"]['id'] # Verify Object Id if not Validator.isValidObjectId(ws_object_id): return response # READING OF OBJECT DATA if task['name'] == const.__SPL_F_GET__: ws_fields = task["params"]['fields'] if ws_object and Validator.isValidObjectFieldsList(ws_fields): response['data'] = ws_object.get(ws_object_id, ws_fields) response['result'] = (response['data'] != False) # WRITING OF OBJECT DATA if task['name'] == const.__SPL_F_SET__: ws_fields = task["params"]['fields'] if ws_object and Validator.isValidObjectFieldsList(ws_fields): # Take Lock for this object => No Commit Allowed for this Object ws_object.lock(ws_object_id) # Write Data on local system response['data'] = ws_object.set(ws_object_id, ws_fields) # Release Lock for this object ws_object.unlock(ws_object_id) response['result'] = (response['data'] != False) # DELETE OBJECT if task['name'] == const.__SPL_F_DEL__: if ws_object: # Take Lock for this object => No Commit Allowed for this Object ws_object.lock(ws_object_id) response['data'] = ws_object.delete(ws_object_id) response['result'] = response['data'] return response