Open ESB : NetBeans BPEL Documentation Plug-in Upload Functionality

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 functionality.

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.

Resources


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 AdjoovoUploader.java.

AdjoovoUploader.java

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.


Layer.xml

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.


Screencast

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.



Comments:

Andrew, some comments....

1. Setting the URL & Space name in the NB options seems a bit too strict, I can accept URL but in all likelihood you may have several spaces that NB artefacts could be uploaded to... how about providing a comma separated list in the options and then the "Upload to Adjoovo Spaces" allows you to choose between.
2. Can you extend it to a CA - I can already provide a deployable zip of a CA to Spaces, I'd like to just click at the CA project level and upload this.
3. The million-dollar question... a NB plug-in to browse the space ;)

Posted by Mark on October 16, 2009 at 02:08 AM GMT #

Mark,

I have updated the interface, not quite as requested in 1, but you now have two menu options:

1. Upload to Default Adjoovo Spaces - Uses the Options information
2. Upload to Adjoovo Spaces - Causes a Dialog to appear allowing the user to select the Spaces URL / enter on and then Select / enter the space name. The list of Space names is retrieved from the Spaces URL specified.

Posted by guest on October 16, 2009 at 07:46 AM GMT #

Post a Comment:
Comments are closed for this entry.
About

As a member of the Oracle A-Team we specialise in enabling and supporting the Oracle Fusion Middleware communities.

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today