Skip to content
Jens Reimann edited this page Oct 26, 2015 · 5 revisions

This is a short introduction to the "Unzip Adapter".

Also see the more detailed documentation at http://doc.packagedrone.org/book/unzip_adapter.xhtml

In short it allows one to access files from inside an artifact which is a ZIP file. The URL is constructed in a way, so that it is transparent for the caller that this file actually is inside a ZIP file.

URL

The entry point to the Unzip Plugin is: http://yourserver/unzip

Please note: http://yourserver is the URL to your server. When running locally this would be http://localhost:8080, when you put an Apache in front of Jetty, and use an external DNS name, this could also be http://thedrone.packagedrone.org/unzip.

The Unzip Adapter of course needs to known which artifact you are referring to. Currently this can be done in three different ways:

  • By artifact ID (artifact)
  • The newest artifact in a channel (newest)
  • The newest ZIP artifact in a channel (newestZip)
  • The newest artifact in a channel with a specific name (newestByName)

Each time the URL is constructed a bit differently, since different parameters are required. However every thing is encoded in the path of the URL. No query parameters are used.

The common part of the URL is http://yourserver/unzip/<type>, where <type> is one of the types from the list above (artifact, newest, …).

By artifact ID

This is the most straight forward type. You specific a specific artifact, by ID, and it will always reference the same artifact. Since the content of an artifact cannot change, it will always deliver the same content.

Please note: Artifact IDs are case sensitive!

Assuming your artifact has the ID 8e196cf8-35a5-431d-b0df-85c3e65d1fa0, and that it is a ZIP file. Then you could access the file META-INF/MANIFEST.MF directly using the following URL:

http://yourserver/unzip/artifact/8e196cf8-35a5-431d-b0df-85c3e65d1fa0/META-INF/MANIFEST.MF

With Package Drone 0.11.0 the URL for the artifact access will change since artifacts IDs are no longer globally unique. Therefore the channel ID has to be added to the URL:

http://yourserver/unzip/artifact/channel1/8e196cf8-35a5-431d-b0df-85c3e65d1fa0/META-INF/MANIFEST.MF

Newest

This searches the provided channel and looks for the newest (last uploaded) artifact and tries to locate the file in this.

However this method does not check if the latest artifact is indeed a ZIP file. If it is not, the lookup will fail.

Assuming that the name of the channel is channel1 the URL for the same file (META-INF/MANIFEST.MF) would be:

http://yourserver/unzip/newest/channel1/META-INF/MANIFEST.MF

Newest ZIP

This works like newest but only considers artifacts which appear to be a ZIP file. This is either the extension .zip on the arifact name, or the mime type application/zip detected by the Mime Channel Aspect. The type name is newestZip.

Newest by name

This searches a channel for all artifacts with a specific name. Since the artifact name is not necessarily unique in a Package Drone channel, this can lead to multiple versions. This method picks the most recent upload.

Assuming that the name of the channel is channel1 and the name of the artifact test.jar the URL for the same file (META-INF/MANIFEST.MF) would be:

http://yourserver/unzip/newestByName/channel1/test.jar/META-INF/MANIFEST.MF

Use cases

There are many scenarios where this deep linking can be used. Beside Package Drone using it for itself, in order to provide links to embedded about.html files for Eclipse Feature license URLs, there are a few more.

Uploading a complete P2 repository

With the Unzip Adapter it is possible to reproduce the same scenario as with the Tycho Nexus Unzip Plugin.

Normally Package Drone would take individually uploaded OSGi bundles and Eclipse features. However it is of course also possible to upload a complete P2 repository ZIP. Package Drone will currently handle it as a plain BLOB and will not further process any OSGi meta data.

However, using deep linking it is possible to directly access the content of the P2 repository ZIP, as if it would be unzipped on the server and feed the P2 system with this repository.

Assuming the channel name is repo1 and the P2 ZIP file is named repo.zip, then you could use the method newestByName with the following URL:

http://yourserver/unzip/newestByName/repo1/repo.zip

Directly referencing this URL with P2, either from Eclipse PDE or Maven Tycho, would give you access to the uploaded P2 repository, without unzipping.

Clone this wiki locally