예제 #1
0
        public static void copy(DSObject jobject, String mount_point)
        {
            DSObject new_jobject = jobject.Clone();
            new_jobject.Metadata.setItem("mountpoint",mount_point);

            if (jobject.Metadata.HasKey("title")) {
                String filename = jobject.Metadata.getItem("title").ToString();

                if (jobject.Metadata.HasKey("mime_type")) {
                    object mime_type = jobject.Metadata.getItem("mime_type");
            //					extension = mime.get_primary_extension(mime_type);
            //					if extension:
            //						filename += '.' + extension
                }

                    new_jobject.Metadata.setItem("suggested_filename",filename);
            }

            // this will cause the file be retrieved from the DS
            new_jobject.FilePath = jobject.FilePath;

            write(new_jobject);
        }
예제 #2
0
        private static void _write(DSObject ds_object, bool update_mtime, bool transfer_ownership, Object reply_handler, Object error_handler, int timeout)
        {
            //			Logging.debug("datastore.write");
            String file_path;

            //			Dictionary<String,object> properties = (Dictionary<String,object>)ds_object.Metadata.GetDictionary().Clone();
            Dictionary<String,object> properties = (Dictionary<String,object>)ds_object.Metadata.GetDictionary();

            if (update_mtime) {
                properties["mtime"] = DateTime.Now.ToString("s");
                properties["timestamp"] = DateTime.Now.Ticks;
            }

            if (ds_object.FilePath==null) {
                file_path = "";
            } else {
                file_path = ds_object.FilePath;
            }

            // FIXME in Python source code: this func will be sync for creates regardless of the handlers
            // supplied. This is very bad API, need to decide what to do here.
            if (ds_object.object_id!=null) {

                // Note: the reply_handler, error_handler and timeout is not handled by DBus interface. We need to implement in other manner
            //				dbus_helpers.update(ds_object.object_id, properties, file_path, transfer_ownership, reply_handler=reply_handler,  error_handler=error_handler, timeout=timeout);
                dbus_helpers.update(ds_object.object_id.ToString(), properties, file_path, transfer_ownership);

            } else {
                if (reply_handler!=null || error_handler != null) {
            //					Logging.warning("Datastore.write() cannot currently be called' async for creates, see ticket 3071");
                } else {
            //					ds_object.object_id = dbus_helpers.create(properties, file_path, transfer_ownership);
                    ds_object.object_id = dbus_helpers.create(properties, file_path, transfer_ownership);
                }
            }

            // TODO in Python source code: register the object for updates
            //			Logging.debug("Written object %s to the datastore.", ds_object.object_id);
        }
예제 #3
0
 public static void write(DSObject ds_object,bool update_mtime, bool transfer_ownership, Object reply_handler, Object error_handler, int timeout)
 {
     _write(ds_object, update_mtime, transfer_ownership, reply_handler, error_handler, timeout);
 }
예제 #4
0
        private static ArrayList _find(Dictionary<String,object> query, Object sorting, object limit, object offset, String[] properties)
        {
            //		    query = query.copy()

              			if (properties==null) {
                properties = new String[0];
            }

            if (sorting!=null) {
                query["order_by"] = sorting;
            }
            if (limit!=null) {
                query["limit"] = limit;
            }
            if (offset!=null) {
                query["offset"] = offset;
            }

            findResult result= dbus_helpers.find(query, properties);

            // Note: the reply_handler, error_handler and timeout is not handled by DBus interface. We need to implement in other manner
            //			props_list, total_count = dbus_helpers.find(query, properties, reply_handler, error_handler)

            ArrayList objects=new ArrayList();
            int i=0;
            foreach (Dictionary<string,object> props in result.results) {
                object object_id=props["uid"];
            //			        del props['uid']

                DSObject ds_object=new DSObject(object_id, new DSMetadata(props));
                objects.Add(ds_object);
                ++i;
            }

            return objects;
        }
예제 #5
0
 public static void write(DSObject ds_object,bool update_mtime, bool transfer_ownership, Object reply_handler)
 {
     _write(ds_object, update_mtime, transfer_ownership, reply_handler, null, -1);
 }
예제 #6
0
 public static void write(DSObject ds_object,bool update_mtime, bool transfer_ownership)
 {
     _write(ds_object, update_mtime, transfer_ownership, null, null, -1);
 }
예제 #7
0
 public static void write(DSObject ds_object,bool update_mtime)
 {
     _write(ds_object, update_mtime, false, null, null, -1);
 }
예제 #8
0
 public static void write(DSObject ds_object)
 {
     _write(ds_object, true, false, null, null, -1);
 }
예제 #9
0
        public static DSObject get(Object object_id)
        {
            //			Loggin.debug("Datastore.get");
            Dictionary<String,object> metadata=(Dictionary<String,object>)dbus_helpers.get_properties(object_id.ToString());

            DSObject ds_object = new DSObject(object_id, new DSMetadata(metadata), null);

            // TODO in Python source code: register the object for updates
            return ds_object;
        }