On 04/17/09 16:52, giancarlo wrote:
_*Introduction to the problem:*_

- My extension is developed and deployed through NetBeans, OOo plugin and OOo java sdk 3, on GNU/Linux platform.

- The oxt package made contains an indispensable folder, called "repository", and correctly added to the oxt setting the following on build.xml:

   <target name="-post-uno-package">
       <zip update="true" destfile="${uno.package.name}">
<zipfileset dir="/root/repository" includes="*/*" casesensitive="yes" prefix="repository"/>
      </zip>
   </target>

- Running the extension, some stuff contained in the "repository" folder is processed.

- The path of "repository" is found by this code:

public MyExtension(XComponentContext context) {
       String m_implementationName = MyExtension.class.getName();
       m_xContext = context;
XPackageInformationProvider xPackageInformationProvider = PackageInformationProvider.get(m_xContext); reposPath = xPackageInformationProvider.getPackageLocation(m_implementationName);
       reposPath = reposPath.replaceFirst("file://", "");
       reposPath +="/repository";
      ...
      ...
}

- Running the extension on OOo for GNU/Linux, the "repository" path is right (I have to suppress "file://" at the start), and everything goes fine:

/root/.openoffice.org/3/user/uno_packages/cache/uno_packages/FhREz3_/MyExtension.oxt/repository/ (this is the right folder)


*_The problem:_*

- When I try out the extension on OOo for MS Windows (both XP and Vista) the path is wrong, I get things like this:

      \C:/ . . . /MyExtension.oxt/repository

You mean, the string returned by getPackageLocation is

   file://\C:/...

?  That is a bug; please file an issue; it should be

   file:///C:/...

instead.

note the backslash ( \ ) at the start, furthermore note the slashes ( / ) contained in the path: I did know that only backslashes were allowed on MS Windows paths
(but I can be wrong).

What getPackageLocation returns is a URL, not a filepath in system-specific notation, so it should always only contain forward slashes.

- When I try out the extension on my work pc (Windows XP), things get worse... the extension is installed under this lan folder (\\Domainserver1\...), and the REAL "repository" path is:

\\Domainserver1\User_Folder\username\AppData\Roaming\OpenOffice.org\3\user\uno_packages\cache\uno_packages\20.tmp_\MyExtension.oxt\repository

- But the path found by the extension is this:

Domainserver1/User_Folder/username/AppData/Roaming/OpenOffice.org/3/user/uno_packages/cache/uno_packages/20.tmp_/MyExtension.oxt/repository

note that there are no backslashes at the start and AGAIN I have slashes instead of backslashes.

Here, the URL returned by getPackageLocation is file://Domainserver1/..., placing the UNC path's server name in the URL's authority component.

In short, your approach of converting from a (file) URL to a system-specific filepath notation (by stripping leading "file://") is too naive. In Java, you can use functionality provided by java.net.URL, java.net.URI, java.net.File etc. to do the conversion correctly.

-Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to