Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The idea of this sample is to demonstrate how to use media type handlers. The sample application is to process project proposals, so we'll be using a component that intercepts Registry put() requests with a particular proposal media-type. The Handler will read the proposal and mark it as valid or not. In order to be a valid proposal there should be a number of fields - if all of them are there then the handler will mark the proposal as valid. If one or more fields are missing then the proposal would be invalid.

Instructions

1. Copy the  Copy the <G-REG_HOME>/samples/handler/bin/org.wso2.carbon.registry.samples.handler-34.25.0.jar file into GREG_HOMEthe <G-REG_HOME>/repository/components/dropins/ directory.

2. You also can upload handlers through the administration console by visiting the "Add" in "Extensions."

...

3. Edit the registry.xml file which is in GREG_HOME/repository/conf folder with and add the following XML snippet.

Code Block
languagehtml/xml
<handler class="org.wso2.carbon.registry.samples.handler.ProjectProposalMediaTypeHandler" methods="PUT">
    <filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
        <property name="mediaType">pp</property>
    </filter>
</handler>

Image RemovedImage Added

4. You also can add the handler configuration through the administration console.

4.1. Enter the "ExtensinsExtensions" menu.

4.2. Open the "Handlers" configuration menu.

...

6. Browse the resources tree by visiting "Browse" menu in "Resources."

Image RemovedImage Added

7. Add a new resource. See Adding a Resource.

...

Info
titleNote

Sample project proposals are available in GREG_HOME/samples/handler/src/resources folder.

Image Removed

Image RemovedImage Added

10. You should see a confirmation like this:

...

11. Browse to the added project proposal. You could see the "Properties" and the "Tag" have been added to the resource.

Excerpt
hiddentrue

Instructions on how to use media type handlers.