Open ESB : NetBeans BPEL Documentation Plug-in Upload Functionality
By The Old Toxophilist on Oct 15, 2009
Read the original article at The Crooked Stick
As mentioned in my previous entry "Extending
the Template Based BPEL Document Generator" I would be looking at
linking into Adjoovo Spaces as a
source for extended BPEL annotation. Whilst looking into this option I
decided that what I also needed was the ability to upload BPEL
information to the various repositories I was working with and on
further investingation decided to extend the NetBeans Module associated
within the Documentation Generator (NetBeans
Module for BPEL Documentation Generation) to include this
Because I have done more JDBC and LDAP programming than REST Web
Services I decided that I would build the Adjoovo Spaces Upload Action
first and this blog entry covers the additional functionality I created
and how I accessed the Spaces using the REST API.
- NetBeans 6.1 BPEL Documentaion Module.
- NetBeans 6.5 BPEL Documentaion Module.
- NetBeans 6.7.1 BPEL Documentaion Module.
- NetBeans 6.5 / 6.7.1 Adjoovo Upload Module.
Building the REST Java API
As mentioned I have not done much REST API programming so this was
as much a learning experience for me as a simple extension to the
documentation functionality. I will not cover the building of the
NetBeans Action in detail but will describe how a created the
AdjoovoUploader and how I extended the layer.xml to include the action
for all the specified file types. The layer.xml file was edited
directly because simply created a single AdjoovoUploadAction that
executes the same functionality for all file type and leave the parsing
of the contents to the Adjoovo Spaces instance. Hence all functionality
required to upload the file is contained within a single class; the
As mentioned the AdjoovoUploader.java is the core component and the
contents of it can be seen below. The key functionality within the java
file can be seen between lines 53 and 85.
Following the Adjoovo Documentation the REST Web Service used to
upload a file to Spaces is:
curl -F "contents=@<yourFilename>" -X POST http://localhost:8080/spaces/rest/store/space/<yourSpaceName>/artifact
To reproduce this using the Jersey Java API we need to create a
FormDataMultiPart (line 69) because this is being POSTed to the URL. To
compose this message we then need to provided a
FormDataContentDisposition (line 70) to define the content specifying
the filename. Finally we will need to provided the contents of the file
as the body to the POST. This is done by creating a FormDataBodyPart
(line 71) that will contain the file contents as an InputStream and
defined as an Octal Stream Type.
The BodyPart is added to the MultiPart (line 72) and the simply sent
to the web resource (url) specifying that the contents is MultPart Data
(line 74). Once the post has occurred the response can be check to see
if it was successful (200) and this result returned to the Action.
The Layer.xml will specify how the AdjoovoUploadAction is linked to the various file types in NetBeans and looking at the file below you can see all the appropriate file type.
The following screen cast show the installation of the Upload NetBeans modules. Once this has been done the options are configured and then a number of artifacts are uploaded to the local Adjoov Spaces instance.