How to write xsd file (Enrich mediator) and use it with eclipse IDE

In general, a schema is an abstract representation of an object's characteristics and relationship. XSD specifies how to formally describe the elements in an Extensible Markup Language (XML) document.
Here i will briefly describe how to write simple XSD and use it with eclipse ide.

first we will consider simple xml file

<enrich xmlns:p="http://ws.apache.org/ns/synapse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<p:source clone="false" type="custom" xpath="/default/xpath"/>
<p:target action="replace" type="custom" xpath="/default/xpath"/>
</p:enrich>

Here is the XSd file to describe that XML file. Save this file as enrich.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
           targetNamespace="http://ws.apache.org/ns/synapse"
           xmlns="http://ws.apache.org/ns/synapse">
<xs:element name="enrich">
    <xs:complexType>
        <xs:sequence>       
    <xs:element name="source">
        <xs:annotation>
            <xs:documentation source="description">
                Source Configuration
            </xs:documentation>
        </xs:annotation>
                <xs:complexType>         
                    <xs:attribute name="clone" minOccurs="1" maxOccurs="1">
                        <xs:annotation>
                        <xs:documentation>
                             Weather message can be cloned or use as a reference during the enriching
                         </xs:documentation>
                        </xs:annotation>
                        <xs:restriction base="xs:string">
                     <xs:enumeration value="true"/>
                    <xs:enumeration value="false"/>
                 </xs:restriction>
                         </xs:attribute>
             <xs:attribute name="type" minOccurs="1" maxOccurs="1">
                         <xs:annotation>
                         <xs:documentation>
                            Type that the mediator use from the original message to enrich the modified message that pass through the mediator
                         </xs:documentation>
                         </xs:annotation>
                 <xs:restriction base="xs:string">
             <xs:enumeration value="custom"/>
                         <xs:enumeration value="envelope"/>
                        <xs:enumeration value="body"/>
                 <xs:enumeration value="property"/>
                        <xs:enumeration value="inline"/>
                 </xs:restriction>
                         </xs:attribute>
            <xs:attribute name="xpath" type="xs:string" use="optional"/>
            <xs:attribute name="property" type="xs:string" use="optional"/>
         </xs:complexType>          
        </xs:element>      
    <xs:element name="target">
            <xs:annotation>
                <xs:documentation source="description">
                Target Configuration
                </xs:documentation>
            </xs:annotation>
            <xs:complexType>
        <xs:attribute name="action" minOccurs="1" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                            The relevant action can be applied to outgoing message.
                        </xs:documentation>                    </xs:annotation>
                <xs:restriction base="xs:string">
                        <xs:enumeration value="replace"/>
                       <xs:enumeration value="child"/>
                <xs:enumeration value="sibiling"/>
            </xs:restriction>
                </xs:attribute>
        <xs:attribute name="type" minOccurs="1" maxOccurs="1">
                    <xs:annotation>
                        <xs:documentation>
                           Type of enriching the outgoing message.
                        </xs:documentation>
                    </xs:annotation>
                <xs:restriction base="xs:string">
                        <xs:enumeration value="envelope"/>
                       <xs:enumeration value="body"/>
                <xs:enumeration value="property"/>
                       <xs:enumeration value="custom"/>
            </xs:restriction>
                </xs:attribute>
        <xs:attribute name="xpath" type="xs:string" use="optional"/>
        <xs:attribute name="property" type="xs:string" use="optional"/>
    </xs:complexType>
    </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>  
</xs:schema>
If you need to find more about enrich mediator you can visit
http://wso2.org/project/esb/java/3.0.1/docs/mediators/enrich.html


If you need more examples of xsd's written for various uses visit
https://svn.apache.org/repos/asf/synapse/trunk/java/repository/schema/mediators/filter/

Then we will see how we can use this with eclipse IDE
01.Open eclipse IDE
02.From window menu goto preferences
   Window>Preferences
   Then you will see image shown below



03.from the menu appearing you must select xml catalog as shown below


04.Then add xml catalog entry as shown in the figure shown in figure
05.browse your xsd file and save it
06.create new eclipse project and add new XML file
   from menu New > XML
07.Create new xml as shown in the below images.

   create xml from xml schema

select xml category and then point the xml



  Than you will get new xml file as shown below

Now you have created it successfully.

How to detect bundle starts faliure(WSO2 Carbon) and how to fix it simply

WSO2 Carbon is based on set of OSGI bundles. when server starts those bundles must starts. But in some cases those may not start due to some reason. In most of issues we ask people to check weather bundles started or not. here i will briefly describe how to detect bundle start  failure and how to fix it without having any previous knowledge about osgi(I'm also not expert in osgi)Most of cases bundles will not start automatically may be they depend on some other bundle that did not started successfully or they may not included in bundledef file.we will see how to detect it

01.start wso2server in diagnose mode with osgi console by typing following  command in the command line
 sh wso2server.sh -DosgiConsole

you can get all osgi bundles information by typing ss in command line so you will be able to view bundles infomation

check weather your bundles state in order to use it, it must be activated.In cases it installed only we can start them manually by typing start command


if you see dependency or not listed in bundles list you have to manually add them to bundleinfo file.

in this case you can see we cant start this bundle because it depend on some other bundle that not listed so we have to manually add them to bundleinfo file.
Now you can see where is the root of error and we can fix it now

you can see file inside this filder

wso2stratos-manager-1.1.0-SNAPSHOT/repository/components/configuration/org.eclipse.equinox.simpleconfigurator/bunldles.info
This file contains all bundles that should be started


org.wso2.carbon.tenant.reg.agent.client,1.1.0.SNAPSHOT,plugins/org.wso2.carbon.tenant.reg.agent.client-1.1.0.SNAPSHOT.jar,4,true
org.wso2.carbon.tenant.reg.agent.service,1.1.0.SNAPSHOT,plugins/org.wso2.carbon.tenant.reg.agent.service-1.1.0.SNAPSHOT.jar,4,true
org.wso2.carbon.tenant.register.stub,3.2.0.SNAPSHOT,plugins/org.wso2.carbon.tenant.register.stub-3.2.0.SNAPSHOT.jar,4,true


so we will add new bundle that need to start as follows and put corressponding jar file in to repositary/components/pluggings folder

then you can start server again and you can check weather bundles started or not

How to fix error in svn due to locking "error-folder is already under version control"

When i try to add folder to svn this gives following error
sanjeewa@sanjeewa-laptop:~/trunck/carbon/service-stubs$ svn add org.wso2.carbon.usage.meteringsummarygenerationds.stub/
svn: Working copy '.' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)

then tried to clean up. it also gives following error
sanjeewa@sanjeewa-laptop:~/trunck/carbon/service-stubs$ svn cleanup
svn: 'org.wso2.carbon.usage.meteringsummarygenerationds.stub' is not a working copy directory

then i removed that folder by deleting and add new folder and try to add it
sanjeewa@sanjeewa-laptop:~/trunck/carbon/service-stubs$ svn add org.wso2.carbon.usage.meteringsummarygenerationds.stub/
svn: warning: 'org.wso2.carbon.usage.meteringsummarygenerationds.stub' is already under version control

So finally i found the way to solve it
01.first copy that folder to some other location(remove all .svn files inside)
02.then type svn clenup
03.then type svn revert command
svn revert org.wso2.carbon.usage.meteringsummarygenerationds.stub/
04.Copy back that folder to the location that we need
05.then add to svn
svn add org.wso2.carbon.usage.meteringsummarygenerationds.stub/

Empowering the Future of API Management: Unveiling the Journey of WSO2 API Platform for Kubernetes (APK) Project and the Anticipated Alpha Release

  Introduction In the ever-evolving realm of API management, our journey embarked on the APK project eight months ago, and now, with great a...