<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Jaggery - Delicious Javascript</title>
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le styles -->
    <link href="../css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding-top: 60px;
        }
    </style>
    <link href="../css/prettify.css" rel="stylesheet">
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon" href="../images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72"
          href="../images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114"
          href="../images/apple-touch-icon-114x114.png">
</head>

<body>

<%
include('/includes/topnavi.jag');
%>

<div class="container-fluid" style="width: 960px; margin: auto;">
    <div class="row">
        <div class="span16">
            <div class="page-header">
                <h1>
                    Documentation
                    <small>API documentation for Jaggery.js</small>
                </h1>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="span4">
            <div class="well">
                <%
                include('/includes/navi.jag');
                %>

            </div>

        </div>
        <div class="span12">
            <div class="content" id="email" name="email">
                <h3>MetadataStore</h3>
        <pre class="prettyprint linenums">
&lt%
     var dataStore = new MetadataStore("admin", "admin");
     var resource = dataStore.newResource();
     resource.content = "&lt;a&gt;Hello Jaggery&lt/a&gt;";
     resource.addProperty("url", "http://wso2.com");
     resource.addProperty("company", "WSO2 Inc.");
     dataStore.put("wso2products.xml", resource);

     //now we read the resource again
     var res = dataStore.get("wso2products.xml");

     //html to show the result
     var resource = {};
     resource.content = res.content.toXMLString();
     resource.props = {};
     resource.props.url = res.getProperty("url");
     resource.props.company = res.getProperty("company");

     print(resource);

%&gt
</pre>
                <%
                var regCode = '&lt%'
                + '\n var dataStore = new MetadataStore("admin", "admin");'
                + '\n var resource = dataStore.newResource();'
                + '\n resource.content = "&lt;a&gt;Hello Jaggery&lt;/a&gt;";'
                + '\n resource.addProperty("url", "http://wso2.com");'
                + '\n resource.addProperty("company", "WSO2 Inc.");'
                + '\n dataStore.put("wso2products.xml", resource);'
                + '\n '
                + '\n //now we read the resource again'
                + '\n var res = dataStore.get("wso2products.xml");'
                + '\n'
                + '\n //html to show the result'
                + '\n var resource = {};'
                + '\n resource.content = res.content.toXMLString();'
                + '\n resource.props = {};'
                + '\n resource.props.url = res.getProperty("url");'
                + '\n resource.props.company = res.getProperty("company");'
                + '\n'
                + '\n print(resource);'
                + '\n %&gt';

                var codeSnip = encodeURIComponent(regCode);
                var urlString = '../tryitframe.jag?code='+codeSnip;

                include('/includes/tryit_but.jag');
                %>
<div id="pageLinks">
<a class="navilink" href="#overview">Overview</a>
<a class="navilink" href="#members">Members</a>
<a class="navilink" href="#operations">Operations</a>
</div>
 <section id="overview">


<h4>Overview</h4>
<p class="description">This enables data manipulation through registry (metadata store) resources. </p>

</section>

                <section id="operations">
                    <h4>Operations</h4>

                    <table class="clsStd operations-table">
                        <tbody>
                        <tr>
                            <th>Operation</th>
                            <th>Returns</th>
                            <th>Description</th>
                        </tr>
                        <tr>

                        <td><code>MetadataStore("username", "password")</code></td>
                        <td>MetadataStore</td>
                        <td>
<pre class="prettyprint">
var dataStore = new MetadataStore("username", "password");
</pre>
Returns a new metadata store
                        </td>

                    </tr>
                        <tr>

                        <td><code>resourceExists(String path);</code></td>
                        <td>Boolean</td>
                        <td>
<pre class="prettyprint">
var dataStore = new MetadataStore("username", "password");
boolean existance = dataStore.resourceExists("middleware/wso2/products");
</pre>
                            This method returns true or false depending on the existence of either a Resource or a
                            Collection in the specified path.<br><br>

                            Above code returns true if a resource exists in the path
                            /_system/governance/middleware/wso2/products.
                        </td>

                    </tr>
                    <tr>
                        <td>
                            <code>get(String path, [Number start, Number pageSize]);</code>
                        </td>
                        <td>Object</td>
                        <td>This method returns the resource in the specified path. If
                            the resource in the path is a collection, then a Collection object is
                            returned. Else, it returns a Resource object. If it is a collection,
                            then you can specfify optional start and pageSize parameters to filter
                            your results.<br><br>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <code>remove(String path);</code>
                        </td>
                        <td>None</td>
                        <td>This method removes the resource in the specified path from
                            the Metadata store.
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <code>put(String suggestedPath, Resource|Collection resource);</code>
                        </td>
                        <td>String</td>
                        <td>This method adds either a Resource or a Collection into the
                            specified path in the Metadata store.
                        </td>
                    </tr>
                        <tr>
                            <td>
                                <code>createLink(String path, String target);</code>
                            </td>
                            <td>String</td>
                            <td>Creates a link to a existing resource.
                            </td>
                        </tr>
                    <tr>
                        <td>
                            <code>newResource();</code>
                        </td>
                        <td>Resource</td>
                        <td>Where you insert a new Resource into the Metadata store, then you
                            should use this method to create the initial Resource object.<br><br>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <code>newCollection();</code>
                        </td>
                        <td>Collection</td>
                        <td>Where you insert a new Resource into the Metadata store, then you
                            should use this method to create the initial Resource object.
                        </td>
                    </tr>
                        </tbody>
                    </table>
                </section>

            </div>
            <br>
            <br>
        </div>

    </div>
    <%
    include('/includes/footer.jag');
    %>

</div>

<!-- /container -->
<%
include('/includes/scripts.jag')
%>
	<script>	
		
		$(document).ready(function(){
        $('#reg').toggleClass('active')
		$('#docs').addClass('active')
        })
	</script>
</body>
</html>