Showing posts with label App Manager. Show all posts
Showing posts with label App Manager. Show all posts

Tuesday, November 22, 2016

[WSO2 App Manager] How to Customize Webapp Overview Page

I posted several posts on how to add different custom input fields to Publisher. In this post, let's see how to customize Publisher overview page.

By default, webapp overview page is like below.




If you want to preview custom fields in the overview page, you need to modify <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/helpers/splitter.js.

Suppose you added a custom field called "Price" like in this post. Then you have to add below condition inside splitData function of above file.
   
   else if (dataPart[i].name == "overview_price") {  
     overview_main.push(dataPart[i]);  
   }  
   

Then,  the webapp overview page with custom feild will look like below.

Thursday, November 10, 2016

Google Analytics Tracking for WSO2 App Manager

Google Analytics is a free Web analytics service that provides statistics and basic analytical tools. We can configure WSO2 App Manager to track web application and sites invocation statistics through Google Analytics.

First, let's see how to setup a google Analytic account.

1. Go to http://www.google.com/analytics/ and Click on Analytic tab.
2. Then, click on "Admin" tab and create a New Account.
3. Click on "Website" and give account information like in below. Here, you have to fill the information which you want to track.
4. Click on 'Get Tracking Id'. Then you will redirect to a page like below. From there you can get the Tracking Id.
5.  Configure WSO2 App Manager with received Tracking code. Enable google analytics and add TrackingID of <APPM_HOME>/repository/conf/app-manager.xml as shown below.
   
  <GoogleAnalyticsTracking>  
 <!--Enable/Disable Google Analytics Tracking-->  
      <Enabled>true</Enabled>  
      <!--Google Analytics Tracking ID-->  
      <TrackingID>UA-86711225-1</TrackingID>  
 </GoogleAnalyticsTracking>  
   
6. Restart server.
7. Place the below JavaScript code snippet into the pages that you need to track with your Google Analytics account.
   
 <script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript">  
   function invokeStatistics(){      
   var tracking_code = ["<TRACKING_CODE>"];      
   var request = $.ajax({      
     url: "http://<AM_GATEWAY_URL>:8280/statistics/",      
     type: "GET",      
     headers: {        
       "trackingCode":tracking_code,      
       }         
     }  
   );    
 }  
 </script>  
   

Now we have successfully integrated WSO2 App Manager with Google Analytics. Let's see how we can see the statistics.

Real-time statistics


Then go to Google Analytics [http://www.google.com/analytics/] and select the created account above.

The following image shows an invocation of a specific Web application. The Google Analytics graphs and statistics are displayed at runtime in its Real-Time view. In below graphs, you will able to see a hit on "PageViews" per second and active users.


Reporting statistics

Google Analytics reporting statistics will take more than 24 hours from the time of invocation.

A sample dashboard with populated statistics is shown in below.


Monday, November 7, 2016

[WSO2 App Manager] How to Add a Custom Dropdown Field to a Webapp

In WSO2 App Manager, when you create a new web app, you have to fill a set of predefined values. If you want to add any custom fields to an app, you can easily do it.

Suppose you want to add a custom dropdown field to webapp create page. Say the custom dropdown field name is "App Network Type". 

First, Let's see how to add a custom field to UI (Jaggery APIs).
  1. Modify <APPM_HOME>/repository/resources/rxt/webapp.rxt.
  2.    
       <field type = "text">  
           <name label = "App Network Type">App Network Type</name>  
       </field>  
       
    
  3. Login to Management console and navigate to Home > Extensions > Configure > Artifact Types and delete "webapp.rxt"
  4. Add below code snippet to the required place of <APPM_HOME>repository/deployment/server/jageeryapps/publisher/themes/appm/partials/add-asset.hbs
  5.    
     <div class="form-group">  
       <label class = "control-label col-sm-2">App Network Type : </label>  
       <div class = "col-sm-10">  
         <select id = "appNetworkType" class = "col-lg-6 col-sm-12 col-xs-12">  
           <option value = "None">None</option>  
           <option value = "Online">Online</option>  
           <option value = "Offline">Offline</option>  
         </select>  
       </div>  
       <input type = "hidden" required = "" class = "col-lg-6 col-sm-12 col-xs-12" name = "overview_appNetworkType"  
           id = "overview_appNetworkType">  
     </div>  
       
    
  6. Add below code snippet to <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/partials/edit-asset.hbs.
  7.    
     <div class = "form-group">  
       <label class = "control-label col-sm-2">App Network Type : </label>  
       <div class = "col-sm-10">  
         <select id = "appNetworkType" class = "col-lg-6 col-sm-12 col-xs-12">  
           <option value = "None">None</option>  
           <option value = "Online">Online</option>  
           <option value = "Offline">Offline</option>  
         </select>  
       </div>  
       
       <input type='hidden' value="{{{snoop "fields(name=overview_appNetworkType).value" data}}}"  
       name="overview_appNetworkType" id="overview_appNetworkType"/>  
     </div>  
       
    
  8. To save selected value in registry, you need to add below function inside $(document ).ready(function() {} of <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/js/resource-add.js
  9.    
     $("#appNetworkType").change(function() {  
       var selectedNetworkType = $('#appNetworkType').find(":selected").text();  
       $('#overview_appNetworkType').val(selectedNetworkType);  
     });  
       
    
  10. To preview the selected dropdown field value in app edit page, add below code snippet inside $(document ).ready(function() {} of  <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/js/resource-edit.js.
  11.    
     var selectedNetworkType = $('#overview_appNetworkType').val();  
     $( "#appNetworkType" ).each(function( index ) {  
       $(this).val(selectedNetworkType);  
     });  
       
     $("#appNetworkType").change(function() {  
       var selectedNetworkType = $('#appNetworkType').find(":selected").text();  
       $('#overview_appNetworkType').val(selectedNetworkType);  
     });  
       
    
  12. When you create a new version of an existing webapp, to copy the selected dropdown value to the new version, add below line to
    <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/partials/copy-app.hbs
  13.    
     <input type='text' value= "{{{snoop "fields(name=overview_appNetworkType).value" data}}}" name = "overview_appNetworkType" id = "overview_appNetworkType"/>   
       
    

    Now, Let's see how to add customized fields to the REST APIs.
  14. Go to Main -> Browse -> in Management console and navigate to   /_system/governance/appmgt/applicationdata/custom-property-definitions/webapp.json and click on "Edit As Text". Add the custom fields which you want to add.
  15.    
     {   
        "customPropertyDefinitions":   
         [   
          {"name" : "overview_appNetworkType"}   
         ]   
      }   
       
    
  16. Restart App Manager.
  17. Web app create page with the newly added dropdown field will be shown as below. 

Wednesday, November 2, 2016

[WSO2 App Manager] How to Disable App Types

WSO2 App Manager facilitates creating, publishing, and managing Webapps, Sites, mobile applications.  By default, these three app types are enabled in WSO2 App Manager. Enabled app types has mentioned under <EnabledAssetTypeList> in <AppM_Home>/repository/conf/app-manager.xml
   
   <EnabledAssetTypeList>  
     <Type>webapp</Type>  
     <Type>mobileapp</Type>  
     <Type>site</Type>  
   </EnabledAssetTypeList>  
   

If you want to disable any app type from App Manager, you can easily do it. You just have to remove unwanted app types from above configuration and restart the server.

If you disable mobileapp from App Manager, Publisher shows as below.

Store will show like below.



If you want remove "Site" from App Manager, you have to do two additional steps. Because Webapps and Sites are using same creating and editing pages in Publisher.
You have not to allow users to create "Sites" from Publisher. For that, you have to remove the relevant div(as shown in below image) from Publisher UI.




Comment below code block of
<AppM_Home>/deployment/server/jaggeryapps/publisher/themes/appm/partialspublisher/themes/appm/partials/add-asset.hbs

   
   <div class = "form-group" type = 'hidden'>  
     <label class = "control-label col-sm-2">Treat as a Site: </label>  
     <div class = "col-sm-10 checkbox-div">  
       <input type = "checkbox" class = "treatAsASite_checkbox">  
      </div>  
   </div>  
   
   
Comment below code block of
<AppM_Home>/deployment/server/jaggeryapps/publisher/themes/appm/partialspublisher/themes/appm/partials/edit-asset.hbs

   
   <div class = "form-group" type = "hidden">  
     <label class = "control-label col-sm-2">Treat as a Site: </label>  
     <div class = "col-sm-10 checkbox-div">  
      <label>  
        <input type = "checkbox" class = "treatAsASite_checkbox"  
          value = "{{{snoop "fields(name=overview_treatAsASite).value" data}}}">  
       </label>  
     </div>  
   




Monday, September 5, 2016

[WSO2 App Manager] How to Add a Custom Radio Button Field to a Webapp

In WSO2 App Manager, when you create a new web app, you have to fill a set of predefined values. If you want to add any custom fields to an app, you can easily do it.

Suppose you want to add custom radio button field to webapp create page. Say the custom radio button field name is "App Category".

First, Let's see how to add a custom field to UI (Jaggery APIs).
  1. Modify <APPM_HOME>/repository/resources/rxt/webapp.rxt.
  2.    
       <field type="text" required="true">  
         <name>App Category</name>  
       </field>  
       
    
    Note : If you don't want add the custom field as mandatory, required="true" part is not necessary.
  3. Login to Management console and navigate to Home > Extensions > Configure > Artifact Types and delete "webapp.rxt"
  4. Add below code snippet to the required place of <APPM_HOME>repository/deployment/server/jageeryapps/publisher/themes/appm/partials/add-asset.hbs
  5.    
       <div class="form-group">  
         <label class="control-label col-sm-2">App Category: </label>  
         <div class="col-sm-10">  
           <div class="radio">  
             <label>  
               <input type="radio" data-value="free" class="appCategoryRadio" name="appCategoryRadio">  
               Free  
             </label>  
           </div>  
           <div class="radio">  
             <label>  
               <input type="radio" data-value="premium" class="appCategoryRadio" name="appCategoryRadio">  
                 Premium  
              </label>  
            </div>  
          </div>  
       </div>  
       
       <input type="hidden" class="col-lg-6 col-sm-12 col-xs-12" name="overview_appCategory"  
               id="overview_appCategory">  
       
    
  6. Add below code snippet to <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/partials/edit-asset.hbs.
  7.    
       <div class="form-group">  
         <label class="control-label col-sm-2">App Category: </label>  
         <div class="col-sm-10">  
           <div class="radio">  
             <label>  
               <input type="radio" data-value="free" class="appCategoryRadio" name="appCategoryRadio">  
                 Free  
             </label>  
           </div>  
           <div class="radio">  
             <label>  
               <input type="radio" data-value="premium" class="appCategoryRadio" name="appCategoryRadio">  
                 Premium  
             </label>  
           </div>  
         </div>  
       </div>  
        
       <input type="hidden"  
             value="{{{snoop "fields(name=overview_appCategory).value" data}}}"  
             class="col-lg-6 col-sm-12 col-xs-12" name="overview_appCategory"  
             id="overview_appCategory">  
       
    
  8. To save selected radio button value in registry, you need to add below function inside $(document ).ready(function() {} of <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/js/resource-add.js
  9.    
       $(".appCategoryRadio").click(function(){  
         var output = [];  
         $( ".appCategoryRadio" ).each(function( index ) {  
           var categoryValue = $(this).data('value');  
           if( $(this).is(':checked')){  
             output.push(categoryValue);  
           }  
         });  
         $('#overview_appCategory').val(output);  
       });  
       
    
  10. To preview the selected radio button value in app edit page, add below code snippet inside $(document ).ready(function() {} of  <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/js/resource-edit.js.
  11.    
       $(".appCategoryRadio").click(function(){  
         var output = [];  
         $( ".appCategoryRadio" ).each(function( index ) {  
           var categoryValue = $(this).data('value');  
           if( $(this).is(':checked')){  
             output.push(categoryValue);  
           }  
         });  
         $('#overview_appCategory').val(output);  
       
       
       });  
       
       var appCategoryValue = $('#overview_appCategory').val().split(',');  
       $( ".appCategoryRadio" ).each(function( index ) {  
         var value = $(this).data('value');  
         if($.inArray(value, appCategoryValue) >= 0){  
           $(this).prop('checked', true);  
         }  
       });  
       
    
  12. When you create a new version of an existing webapp, to copy the selected radio button value to the new version, add below line to
    <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/partials/copy-app.hbs
  13.    
       <input type='text' value="{{{snoop "fields(name=overview_appCategory).value" data}}}" name="overview_appCategory" id="overview_appCategory"/>  
       
    
    Now, Let's see how to add customized fields to the REST APIs.
  14. Go to Main -> Browse -> in Management console and navigate to   /_system/governance/appmgt/applicationdata/custom-property-definitions/webapp.json and click on "Edit As Text". Add the custom fields which you want to add.
  15.    
       {  
         "customPropertyDefinitions":  
           [  
             {"name":"overview_appCategory"}  
           ]  
       }  
       
    
  16. Restart App Manager.
  17. Web app create page with the newly added radio button will be shown as below. save image

[WSO2 App Manager] How to Add a Custom Checkbox to a Webapp

WSO2 App Manager supports users to customize the server as they need. Here, I'm going to talk about how to add a custom checkbox to webapp create page.

First, Let's see how to add a custom checkbox field to UI (Jaggery APIs).

For example,  let's 
take the checkbox attribute name as “Free App”.
  1. Modify <APPM_HOME>/repository/resources/rxt/webapp.rxt.
  2.    
       <field type="text">  
         <name label="Free App">Free App</name>  
       </field>  
       
    
  3. Login to Management console and navigate to Home > Extensions > Configure > Artifact Types and delete "webapp.rxt"
  4. Add below code snippet to the required place of <APPM_HOME>repository/deployment/server/jageeryapps/publisher/themes/appm/partials/add-asset.hbs
  5.    
       <div class="form-group">  
         <label class="control-label col-sm-2">Free App: </label>  
           <div class="col-sm-10 checkbox-div">  
             <input type="checkbox" class="freeApp_checkbox">  
           </div>  
       </div>  
       
       <input type="hidden" required="" value="FALSE" class="col-lg-6 col-sm-12 col-xs-12" name="overview_freeApp" id="overview_freeApp">  
       
    
  6. Add below code snippet to <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/partials/edit-asset.hbs as well.
  7.    
       <div class="form-group">  
         <label class="control-label col-sm-2">Free App: </label>  
         <div class="col-sm-10 checkbox-div">  
           <input type="checkbox" class="freeApp_checkbox" value="{{{snoop "fields(name=overview_freeApp).value" data}}}">  
         </div>  
       </div>  
       
       <input type="hidden" required="" value="{{{snoop "fields(name=overview_freeApp).value" data}}}"  
        class="col-lg-6 col-sm-12 col-xs-12" name="overview_freeApp" id="overview_freeApp">  
       
    
  8. To save newly added value in registry, add below function inside   $(document).ready(function(){} of <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/js/resource-add.js
  9.    
       $(".freeApp_checkbox").click(function(){  
         var output = [];  
         $( ".freeApp_checkbox" ).each(function( index ) {  
           if( $(this).is(':checked')){  
             output.push("TRUE");  
           } else {  
             output.push("FALSE");  
          }  
         });  
         $('#overview_freeApp').val(output);  
       });  
       
    
  10. To preview check box value in app edit page, add below code snippet inside $( document ).ready(function() {} of  <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/js/resource-edit.js.
  11.    
       var freeAppValue = $('#overview_freeApp').val();  
       $(".freeApp_checkbox").each(function (index) {  
         if (freeAppValue == "TRUE") {  
           $(this).prop('checked', true);  
         } else {  
           $(this).prop('checked', false);  
         }  
       });  
       
       $(".freeApp_checkbox").click(function(){  
         var output = [];  
         $( ".freeApp_checkbox" ).each(function( index ) {  
           if( $(this).is(':checked')){  
             output.push("TRUE");  
           } else {  
             output.push("FALSE");  
           }  
         });  
         
         $('#overview_freeApp').val(output);  
       });  
       
    
  12.  When you create a new version of an existing webapp, to copy the checkbox value to the new version, add below line to
    <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/partials/copy-app.hbs
  13.    
       <input type='text' value="{{{snoop "fields(name=overview_freeApp).value" data}}}" name="overview_freeApp" id="overview_freeApp"/>  
       
    
    Now, Let's see how to add customized fields to the REST APIs.
  14. Go to Main -> Browse -> in Management console and navigate to   /_system/governance/appmgt/applicationdata/custom-property-definitions/webapp.json and click on "Edit As Text". Add the custom fields which you want to add.
  15.    
       {  
          "customPropertyDefinitions":  
           [  
             {"name":"overview_freeApp"}  
           ]  
       }  
       
    
  16. Restart App Manager.
  17. Web app create page with the newly added checkbox will be shown as below.save image

Tuesday, August 30, 2016

[WSO2 App Manager] How to Publish Webapp to Multiple Tenant Stores.

In WSO2 App Manager, by default webapps are published to their own app store. But you can configure it to publish apps to external stores as well. 
In this post, we are talking about how to do that.
  1. Log in to Management Console.
  2. Go to Main -> Browse -> and navigate to   /_system/governance/appmgt/applicationdata/external-app-stores.xml, and click on "Edit As Text". Add each external app store which you want to publish apps, inside <ExternalAPPStores> element .
  3.    
     <ExternalAPPStores>  
       <StoreURL>http://localhost:9763/store</StoreURL>  
       <ExternalAPPStore id="Store1" type="wso2" className="org.wso2.carbon.appmgt.impl.publishers.WSO2ExternalAppStorePublisher">  
         <DisplayName>Engineering</DisplayName>  
         <Endpoint>http://localhost:9763/publisher</Endpoint>  
         <Username>admin@eng.com</Username>  
         <Password>xxxxx</Password>  
       </ExternalAPPStore>  
        
       <ExternalAPPStore id="Store2" type="wso2" className="org.wso2.carbon.appmgt.impl.publishers.WSO2ExternalAppStorePublisher">  
         <DisplayName>Finance</DisplayName>  
         <Endpoint>http://localhost:9763/publisher</Endpoint>  
         <Username>admin@finance.com</Username>  
         <Password>xxxx</Password>  
       </ExternalAPPStore>   
     </ExternalAPPStores>  
       
    
  4. Create a webapp and publish it.  Then go to webapp overview page. All the external app stores added in step 2, are previewed on "External Stores" tab.
  5. Select the stores and click on Save to publish the webapp to selected stores.  
  6. From WSO2 App Manager 1.2.1, if you want to publish web apps to external store, you need to follow this step too. Go to Main -> Browse -> in Management Console and navigate to   /_system/config/store/configs/store.json and click on "Edit As Text". Set "publicVisibility"  to true.
  7. Then, go to the relevant external store. You will see the app there with  an "Ad" label. Here Ad stands for "Advertised" 
  8. This apps life cycle status can be changed by any publisher but it can be edited by the original publisher.

Monday, August 22, 2016

[WSO2 App Manager] How to Add Custom Image Field to a Webapp

In default publisher UI, two images can be uploaded when creating a webapp. They are image banner and image thumbnail. Suppose you want to add the another image input too for apps, and let’s see how to do that.

First, Let's see how to add a custom image field to UI (Jaggery APIs).

For example,  let's take "Logo" as the custom field.

1. Modify <APPM_HOME>/repository/resources/rxt/webapp.rxt by adding below code under <table name="Images">.
   
   <field type="text">  
      <name>Logo</name>  
   </field>  
   
2. Login to Management console and navigate to Home > Extensions > Configure > Artifact Types and delete "webapp.rxt"

3. Add following block under "fields" of <APPM_HOME>/repository/deployment/server/jageeryapps/publisher/config/ext/webapp.json
   
   {  
      "name": "logo",  
      "table": "images",  
      "type": "imageFile"  
   }  
   
4. Add following line under "storeFields" of <APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/config/storage.json
   
   "images_logo"  
   
5. Add below line to both <APPM_HOME>repository/deployment/server/jageeryapps/publisher/themes/appm/partials/add-asset.hbs
and
<APPM_HOME>repository/deployment/server/jageeryapps/publisher/themes/appm/partials/edit-asset.hbs
files.
   
   {{{ form_render "images_logo" data.fields }}}  
   
6. When you create a new version of an existing webapp, to copy the image field value to the new version, you need to add below line to
<APPM_HOME>/repository/deployment/server/jaggeryapps/publisher/themes/appm/partials/copy-app.hbs
   
   <input type='text' value="{{{snoop "fields(name=images_logo).value" data}}}" name="images_logo" id="images_logo"/>  
   
   

Now, Let's see how to add customized image field to the REST APIs.

7. Go to Main -> Browse -> in Management console and navigate to   /_system/governance/appmgt/applicationdata/custom-property-definitions/webapp.json and click on "Edit As Text". Add the custom fields inside customPropertyDefinitions section.
   
   {  
     "customPropertyDefinitions":  
     [  
       {"name":"images_logo"}  
     ]  
   }  
   
8. Restart App Manager.

9. Sample curl command with custom image property to create a web app is shown in below.
   
 curl -X POST -H "Authorization: Bearer c4cdc394-931f-3e3f-9a91-f2be09fab1de" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"name":"sampleApp","version":"1.0.0","banner":"36d35be6-1847-4d22-b885-16c653486a77/241eb51a2fdb683b.jpg","thumbnailUrl":"85229347-fcdf-4548-993e-1509dd4242df/dd24c0d2ea4a5697.png","displayName":"sampleApp","description":   
  "description","isSite":"false","context":"sampleContext","appUrL":"http://wso2.com",   
  "transport":"http", "customProperties":[   
   {   
    "name":"images_logo",   
    "value":"1b3bfd53-ff9a-4dd3-85f0-5e75e6bfa215/R9GxtyGTG7gN5hQ.jpg"   
   }   
  ]}' "http://localhost:9763/api/appm/publisher/v1.1/apps/webapp"   
   
Note : Refer this to upload a image to the system. Then, you can use that uploaded image  to create web app from REST APIs.

8. Web app create page with the newly added image field(i.e. Logo) will be shown as below.

save image

Friday, August 5, 2016

How to Share Userstore Between Two WSO2 Servers

We can share user store between WSO2 carbon servers. Here I'm going to explain using WSO2 App Manager and WSO2 Identity Server.
  1. Create new database called APPM_UM_DB in MYSQL server. 
  2. Create tables inside the created database by executing the script in <APPM_HOME>/dbscripts/mysql.sql
  3. If App Manager and Identity Server are running on the same machine, follow this step.
  4. Set Offset value to 1 in /repository/conf/carbon.xml.
       
       <Offset>1</Offset>  
       
  5. Specify the datasource definition like below in the <APPM_HOME>/repository/conf/datasources/master-datasources.xml to connect early created APPM_UM_DB database to share user store.
       
       <datasource>  
          <name>WSO2UM_DB</name>  
          <description>The datasource used for user manager database</description>  
          <jndiConfig>  
            <name>jdbc/WSO2UM_DB</name>  
          </jndiConfig>  
           <definition type="RDBMS">  
             <configuration>  
               <url>jdbc:mysql://localhost:3306/APPM_UM_DB</url>  
                <username>username</username>  
                <password>password</password>  
                <driverClassName>com.mysql.jdbc.Driver</driverClassName>  
                <maxActive>50</maxActive>  
                <maxWait>60000</maxWait>  
                <testOnBorrow>true</testOnBorrow>  
                <validationQuery>SELECT 1</validationQuery>  
                <validationInterval>30000</validationInterval>  
             </configuration>  
         </definition>  
       </datasource>  
          
    
  6. Add the same data source configuration to <IS_HOME>/repository/conf/datasources/master-datasources.xml.
  7. Copy the database driver to both <IS_HOME>/repository/components/lib and <AppM_HOME>/repository/components/lib directories.
  8. Update the <APPM_HOME>/repository/conf/user-mgt.xml with jndiConfig name added in step 4 (i.e. jdbc/WSO2UM_DB) as below.
       
       <configuration>   
         ...  
         <Property name="dataSource">jdbc/WSO2UM_DB</Property>  
       </configuration>  
       
  9. Repeat step 7 to <IS_HOME>/repository/conf/user-mgt.xml.
  10. The Identity Server has an embedded LDAP user store and App manager has a JDBC user store by default. You can use either JDBC or LDAP user store in both servers(Both should be the same.) Here I'm using JDBC user store. Copy following configuration from <APPM_HOME>/repository/conf/user-mgt.xml to <IS_HOME>/repository/conf/user-mgt.xml. Remember to remove LDAP user store from Identity server user-mgt.xml.
       
       <UserStoreManager class="org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager">  
           <Property name="TenantManager">org.wso2.carbon.user.core.tenant.JDBCTenantManager</Property>  
             <Property name="ReadOnly">false</Property>  
           <Property name="MaxUserNameListLength">100</Property>  
           <Property name="IsEmailUserName">false</Property>  
           <Property name="DomainCalculation">default</Property>  
           <Property name="PasswordDigest">SHA-256</Property>  
           <Property name="StoreSaltedPassword">true</Property>  
           <Property name="ReadGroups">true</Property>  
            <Property name="WriteGroups">true</Property>  
           <Property name="UserNameUniqueAcrossTenants">false</Property>  
           <Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>  
           <Property name="PasswordJavaScriptRegEx">^[\S]{5,30}$</Property>  
            <Property name="UsernameJavaRegEx">^[^~!#$;%^*+={}\\|\\\\&lt;&gt;,\'\"]{3,30}$</Property>  
            <Property name="UsernameJavaScriptRegEx">^[\S]{3,30}$</Property>  
            <Property name="RolenameJavaRegEx">^[^~!#$;%^*+={}\\|\\\\&lt;&gt;,\'\"]{3,30}$</Property>  
            <Property name="RolenameJavaScriptRegEx">^[\S]{3,30}$</Property>  
           <Property name="UserRolesCacheEnabled">false</Property>  
           <Property name="MaxRoleNameListLength">100</Property>  
           <Property name="MaxUserNameListLength">100</Property>  
            <Property name="SharedGroupEnabled">false</Property>  
           <Property name="SCIMEnabled">false</Property>  
         </UserStoreManager>  
       
    
  11. Restart both servers.
That's all. Now if you create a user or a role from one server, it will be shown in both servers.

Friday, July 29, 2016

How to Change WSO2 App Manager Store and Webapp Favicons

If you want to use WSO2 App Manager as the app store of your organization, it is very important to know how to replace default favicon of WSO2 App Manager by your organization logo. Here are the steps to do it.

How to Change Store Favicon


If you want to change the Store favicon, replace favicon.png in <APPM_HOME>/repository/deployment/server/jaggeryapps/store/themes/store/libs/theme-wso2_1.0/images by the logo you want to have.

Then, Store will be like below. You will see the new favicon.



How to Change Webapp Favicons


If you want to change the favicon of all webapps, you need to do some code changes. Here's how to do it.

1. Clone wso2 carbon-mediation code from here. Make you sure to use correct branch as per your App Manager version. For example, you need to get release-4.6.1 version for App Manager 1.2.0.

2. Go to carbon-mediation/components/mediation-initializer/org.wso2.carbon.mediation.transport.handlers directory.

3. Change the icon location of favicon icon in here like this.
   
   response.addHeader("Location", "http://wso2.org/favicon.ico");  
   
4. Build org.wso2.carbon.mediation.transport.handlers component. Then there will be org.wso2.carbon.mediation.transport.handlers-4.6.1.jar in the target folder.

5. Add org.wso2.carbon.mediation.transport.handlers-4.6.1.jar as a patch to App Manager server. For that, create a directory "patch0900" inside <APPM_HOME>/repository/component/patches/ and copy the jar into it.

6. Restart the server.

Favicon of Gateway response will be displayed as below.


Thursday, July 28, 2016

Start Multiple WSO2 App Manager Instances on the Same Computer

If you want to run multiple WSO2 App Manager servers on the same machine, you have to change the default ports with an offset value to avoid port conflicts. The default HTTP and HTTPS ports (without offset) of a WSO2 product are 9763 and 9443 respectively.

Here are the steps to offset ports. Let's assume you want to increase all ports by 1.

1.  Set Offset value to 1 in <APPM_HOME>/repository/conf/carbon.xml
   
   <Offset>1</Offset>  
   
2.  Change ports in AssertionConsumerServiceURL of each ServiceProvider  in <APPM_HOME>/repository/conf/identity/sso-idp-config.xml.
   
   https://localhost:9444/store/acs  
   https://localhost:9444/publisher/acs  
   https://localhost:9444/social/acs  
   
3. Change the port of address uri in <APPM_HOME>/repository/deployment/server/synapse-configs/default/proxy-services/WorkflowCallbackService.xml.
   
 <address uri="https://localhost:9444/store/site/blocks/workflow/workflow-listener/ajax/workflow-listener.jag" format="rest"/>  
   
4. Change the port of endpoint address in <APPM_HOME>/repository/deployment/server/synapse-configs/default/api/_AuthorizeAPI_.xml
   
   <address uri="https://localhost:9444/oauth2/authorize"/>   
   
5. Change  the port of endpoint address in <APPM_HOME>/repository/deployment/server/synapse-configs/default/api/_RevokeAPI_.xml
   
   <address uri="https://localhost:9444/oauth2/revoke"/>   
   
6. Change  the port of endpoint address in <APPM_HOME>/repository/deployment/server/synapse-configs/default/api/_TokenAPI_.xml
   
   <address uri="https://localhost:9444/appmoauth2/token"/>   
   
7. Start the server.

Sunday, July 24, 2016

[WSO2 App Manager] How to add a custom field to a web app

In WSO2 App Manager, when you create a new web app, you have to fill a set of predefined values (eg: Name, Version, Context etc.). If you want to add any custom fields to an app, you can easily do it.

First, Let's see how to add a custom field to UI (Jaggery APIs).

For example,  let's take "Price" as the custom field.

1. Modify <APPM_HOME>/repository/resources/rxt/webapp.rxt. If you want to add "Price" as a mandatory field, add below code to the overview section of rxt file.

   
   <field type="text" required="true">  
     <name>Price</name>  
   </field>  
   

Note : If you don't want add the custom field as mandatory, required="true" part is not necessary.

2. Login to Management console and navigate to Home > Extensions > Configure > Artifact Types and delete "webapp.rxt"

3. Add following block under "fieldProperties" of <APPM_HOME>/repository/deployment/server/jageeryapps/publisher/config/ext/webapp.json

   
   {  
       "field": "overview.price",  
       "name": "editable",  
       "value": true  
   }  
   


4. Add below line to both <APPM_HOME>repository/deployment/server/jageeryapps/publisher/themes/appm/partials/add-asset.hbs
and
<APPM_HOME>repository/deployment/server/jageeryapps/publisher/themes/appm/partials/edit-asset.hbs
files.

   
   {{{ form_render "overview_price" data.fields }}}  
   


Now, Let's see how to add customized fields to the REST APIs.

5. Go to Main -> Browse -> in Management console and navigate to   /_system/governance/appmgt/applicationdata/custom-property-definitions/webapp.json and click on "Edit As Text". Add the custom fields which you want to add.

   
   {  
    "customPropertyDefinitions":  
    [  
     {"name":"overview_price"}  
    ]  
   }  
   

6. Restart App Manager.

7. Sample curl command with custom properties to create a web app is shown in below.

   
 curl -X POST -H "Authorization: Bearer c4cdc394-931f-3e3f-9a91-f2be09fab1de" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{"name":"sampleApp","version":"1.0.0","banner":"36d35be6-1847-4d22-b885-16c653486a77/241eb51a2fdb683b.jpg","thumbnailUrl":"85229347-fcdf-4548-993e-1509dd4242df/dd24c0d2ea4a5697.png","displayName":"sampleApp","description":  
 "description","isSite":"false","context":"sampleContext","appUrL":"http://wso2.com",  
 "transport":"http", "customProperties":[  
   {  
     "name":"overview_price",  
     "value":"10"  
   }  
 ]}' "http://localhost:9763/api/appm/publisher/v1.1/apps/webapp"  
   

8. Web app create page with the newly added custom field(i.e. Price) will be shown as below.