Saturday, September 3, 2016

How to setup a local SVN server

Following commands guide to set a local SVN server, this is helpful when you want to use a temporary SVN sever (eg: testing a cluster setup)

Creating the repository

(go to the desired path where you want to setup the repository)
svnadmin create <repository-name>

Setting up username and password

uncomment the following in <repository-name>/conf/svnserve.conf
  • anon-access = none
  • auth-access = write
  • password-db = passwd 
add the users in the <repository-name>/conf/passwd in the following format 
username = password 

Starting the SVN server 

svnserve -d -r <repository-name>

svn server will start on the default port 3690

Checking out the repository 

svn co svn://localhost/

Committing a file 

svn ci -m "adding hello file" hello.txt --username username --password password

Stopping the svn server

ps -ef | grep [s]vnserve | awk '{print $2}' | xargs kill -9

Sunday, February 21, 2016

WSO2 ESB Iterate mediator sample

Following is a small API using WSO2 ESB iterate mediator.

<api xmlns="http://ws.apache.org/ns/synapse" name="simpleIterator" context="/simpleIterator">
   <resource methods="POST">
      <inSequence>
         <property name="root_element">
            <responses/>
         </property>
         <iterate expression="//symbols/symbol" sequential="true">
            <target>
               <sequence>
                  <property name="messageType" value="application/xml" scope="axis2"/>
                  <send>
                     <endpoint>
                        <http method="POST" uri-template="http://localhost:8080/sample-responses/simpleQuote"/>
                     </endpoint>
                  </send>
               </sequence>
            </target>
         </iterate>
      </inSequence>
      <outSequence>
         <aggregate>
            <completeCondition>
               <messageCount min="-1" max="-1"/>
            </completeCondition>
            <onComplete expression="//response" enclosingElementProperty="root_element">
               <log level="full"/>
               <respond/>
            </onComplete>
         </aggregate>
      </outSequence>
   </resource>
</api>
                        

sample (curl) request :

curl -d @symbols.xml -H "Content-Type: application/xml"  http://localhost:8280/simpleIterator -v 

symbols.xml
<symbols>
   <symbol>WSO2</symbol>
   <symbol>MSFT</symbol>
   <symbol>IBM</symbol>
   <symbol>ADBE</symbol>
   <symbol>AAPL</symbol>
   <symbol>ORCL</symbol>
   <symbol>RHT</symbol>
   <symbol>FB</symbol>
   <symbol>TWTR</symbol>
   <symbol>LNKD</symbol>
</symbols>

Sample backend can be found here.