Re: Beagle,Querying extended properties



Hi,

Sorry for the delay, I'm digging myself out from a mountain of
neglected email. :(

On 6/19/07, Daniel Labella de la Cruz <dani labella gmail com> wrote:
Hello!!, I have a problem, I'm trying to put the code on
FIleSystemQueryable.cs but I don't know if I'm doing somethig wrong or it
just don't work....
I added this code on ExtendedAttribute.cs inside Util directory for listing
extended properties...

        public static ArrayList List (string path)
        {
            string[] XPropertiesNames;
            ArrayList XPropertiesList=new ArrayList();
            if(! FileSystem.Exists(path))
                throw new IOException (path);
            Syscall.listxattr (path,out XPropertiesNames);
            for (int i=0 ; i<XPropertiesNames.Length ; i++)
            {
                XPropertiesList.Add (XPropertiesNames[i]);
            }
            return XPropertiesList;
        }

I don't see anything wrong with this function, but I would probably
change it to just return string[], since you wouldn't ever need to
change the return value.

and then added the following method to FileSystemQueryable.cs

       public static void AddExtendedProperties (Indexable      indexable,

string         path)
        {
            ArrayList XPropertyList=new ArrayList();
            string XPropertyValue;
            string[] PropertyName;
            XPropertyList=Util.ExtendedAttribute.List(path);
            foreach (string XPropertyName in XPropertyList)
            {

XPropertyValue=Util.ExtendedAttribute.Get(path,XPropertyName);
                PropertyName=XPropertyName.Split('.');
                indexable.AddProperty(Beagle.Property.New
("xattr:"+XPropertyValue,

PropertyName[PropertyName.Length-1]));

            }
        }

I'm not really sure what you're trying to use for key-value here.
You're taking the value of the xattr and using it as part of the
property key.  If I have an xattr "user.testing.key" = "value", your
Beagle property will be "xattr:value" = "key", and I'm pretty sure
that's not what you want.

and then I make a call to this method on AddFile method
         .
         .
         .
          if (indexable != null) {
                Scheduler.Task task;
                //a call to add extended properties
                AddExtendedProperties (indexable,path);
                //
                task = NewAddTask (indexable);
                task.Priority = Scheduler.Priority.Immediate;
                ThisScheduler.Add (task);
            }
            .
            .
            .
after this, it compile ok, but I don't know if I'm doing somethig wrong
querying the extended attributes (maybe I'm querying with wrong syntax) or
simply the code I put doesn't work...

I think the item I mentioned above is why searches aren't working for
you.  You might want to search for other things you know will match
(like the file name, or a unique word contained inside the document)
and use beagle-query --verbose.  That will give you the list of all
the properties on the document.

Joe



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]