I have another question:

How can I use the DataFileProvider to obtain a java.io.File object that is a Directory (isDirectory() returns true)?

This would help a lot for the Ontonet offline mode.

Thanks

Alessandro


On 7/13/11 6:32 PM, Alessandro Adamou wrote:
Hi Rupert,

I'm not getting this to work on my new module (in the sandbox).

so I have my explanation bundle
and its pom.xml has the instruction

<Data-Files>
                            schemas,
                            schemas/registry
</Data-Files>

these directories exist in the explanation src/main/resources dir
and there is a file schemas/test.owl

Then I have a class in the same bundle. It references the datafile provider like this

    @Reference
    private DataFileProvider dataFileProvider;

Then in that class I do

Map<String,String> modelProperties = new HashMap<String,String>();
            modelProperties.put("Description", "Test ontology");
InputStream is = dataFileProvider.getInputStream(null, "test.owl",
                modelProperties);

and I'm getting IOExceptions and these log entries in a row

13.07.2011 18:30:12.569 *INFO* [FelixStartLevel] org.apache.stanbol.commons.stanboltools.datafileprovider.bundle.impl.BundleDataFileProvider Resource NOT found: test.owl 13.07.2011 18:30:12.569 *INFO* [FelixStartLevel] org.apache.stanbol.commons.stanboltools.datafileprovider.bundle.impl.BundleDataFileProvider Resource NOT found: test.owl 13.07.2011 18:30:12.569 *INFO* [FelixStartLevel] org.apache.stanbol.commons.stanboltools.datafileprovider.bundle.impl.BundleDataFileProvider Resource NOT found: test.owl

Why?

Alessandro


On 7/8/11 3:39 PM, Rupert Westenthaler wrote:
Hi

You can not retrieve URLs directly because the DataFileProvider
expects to load files.

The method used to lookup Resources is

     InputStream getInputStream(
             String bundleSymbolicName,
             String filename,
             Map<String, String>  comments) throws IOException;

for the 'bundleSymbolicName' you can parse null. It can be used to
ensure that the DataFile can only be loaded from the
MainDataFileProvider or from a DataFileProvider of the parsed
bundleSymbolicName.

This is the name of the file. You need to choose a way how to encode
the URL of an ontology to a fileName. I would not recommend you to
used paths, because users will not want to create sub-directories in
the /datafile directory. If a single configuration consists of several
files (e.g. a SolrIndex) than you should consider to use an archive
(ZIP, GZ ...).

The comments are currently used to provide additional information
about the requested file to the User. In future we might bind specific
functionality to some keys (e.g. A Button to download a required
resource if the "Download-Location" key is present and the value is an
valid URL)

The easiest way provide required datafiles to Stanbol is to include
those in a Bundle and to add the

<Data-Files>
         {path}
</Data-Files>

to the<instructions>  of the 'maven-bundle-plugin'.

     {path} it the path within the bundle to the folder containing the
DataFiles that need to be loaded. Multiple paths can be separated by
','

For a example you can have a look at the
"org.apache.stanbol.defaultdata" bundle.

best
Rupert Westenthaler

--
M.Sc. Alessandro Adamou

Alma Mater Studiorum - Università di Bologna
Department of Computer Science
Mura Anteo Zamboni 7, Bologna - Italy

Semantic Technology Laboratory (STLab)
Institute for Cognitive Science and Technology (ISTC)
National Research Council (CNR)
Via Nomentana 56, 00161 Rome - Italy


"As for the charges against me, I am unconcerned. I am beyond their timid, lying 
morality, and so I am beyond caring."
(Col. Walter E. Kurtz)

Reply via email to