18 Nisan 2016 Pazartesi

Android Right Side Navigation and Left Side Logo Toolbar (Appcompat 23.1.1)

For my personal project , I need a toolbar which has logo  on left side and navigation menu on the right side without setting RTL... (Why do I need this ,  because my designer made a mobile web design like this layout.)

I have used appcompat-v7 version 23.1.1  and tried to setup the layout (I have explained above) by giving gravity (start | end ) directive.

I didn't work!

For a weekend I was planning to go hometown and stay with my parents , it may an opportunity for diving to appcompat codes and change the layout .

After a 1 day confusion for building and understanding platform_framework_support project , in the end I have done the required changes.

You can download the dependency 23.1.inc.zip .


  • Download the file above.
  • Then change the dependency to ;

        compile 'com.android.support:appcompat-v7:23.1.inc@aar'

  • Then  unzip the package to the local repo.(In the gradle error output will give you from which path it is trying to retrieve package)
  • Change the navigationView gravity;
<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"

    android:layout_width="wrap_content"

    android:layout_height="match_parent"

    android:background="?attr/colorPrimary"

    app:itemTextColor="@color/cardPrimary"

    android:layout_gravity="end"

    android:fitsSystemWindows="true"

    app:headerLayout="@layout/nav_header_main"

    app:menu="@menu/activity_main_drawer" />

  • Change the drawer close and open functions.Otherwise you will have error.
drawer.closeDrawer(GravityCompat.END);




9 Mart 2016 Çarşamba

AWS S3 Maven Repository


In my project, I decided to use Amazon S3 as a maven repository. I will try to explain some hints to do that..


  • First you should create a "devops" group who has S3 full access and create a "devops" user within "devops" group. You can use "devops" user in build server and put more restrictions in future.  

  • Create Bucket. I faced many problems with region Franfurt so I recommend you to use Ireland region while creating bucket.

  • After creation of the user , apply the steps and use devops access key and secret.

I hope it will be useful for you..

2 Mart 2016 Çarşamba

JSON Validation over WSDL


Github : https://github.com/rernas35/JsonValidationOverWSDL

In our team,  we need a json validator for REST services. We have done some investigation and found out that mostly Swagger and WADL  is used for this purpose.

Our infrastructure is not adequate for Swagger or WADL that's why we have implemented a json validation library that use WSDL definitions for schema.

If you have services that is exposed in both SOAP and REST but you don't have swagger or wadl support, you can use this validation library,

Sample wsdl is a simple web service that is composed of login, logout, search and buy operations.

Output of validation library is JSON-Schema.Spec is here.

Json-Schema :

 
   "$schema":"http://json-schema.org/draft-04/schema#",
   "type":"object",
   "additionalProperties":false,
   "definitions": 
      "PurchaseStatusType_CT": 
         "type":"object",
         "additionalProperties":false,
         "id":"http://www.example.org/sample//PurchaseStatusType_CT",
         "properties": 
            "id": 
               "type":"string",
               "id":"http://www.example.org/sample//id"
            },
            "stockStatus": 
               "type":"string",
               "id":"http://www.example.org/sample//stockStatus"
            },
            "expectedDelivery": 
               "type":"string",
               "id":"http://www.example.org/sample//expectedDelivery"
            }
         },
         "required": 
            "id",
            "stockStatus",
            "expectedDelivery"
         ]
      },
      "ItemType_CT": 
         "type":"object",
         "additionalProperties":false,
         "id":"http://www.example.org/sample//ItemType_CT",
         "properties": 
            "id": 
               "type":"string",
               "id":"http://www.example.org/sample//id"
            },
            "description": 
               "type":"string",
               "id":"http://www.example.org/sample//description"
            },
            "price": 
               "type":"string",
               "id":"http://www.example.org/sample//price"
            }
         },
         "required": 
            "id",
            "description",
            "price"
         ]
      },
      "searchResponseembedded": 
         "type":"object",
         "additionalProperties":false,
         "id":"http://www.example.org/sample//searchResponseembedded",
         "properties": 
            "item": 
               "$ref":"#/definitions/ItemType_CT"
            }
         },
         "required": 
            "item"
         ]
      },
      "buyResponseembedded": 
         "type":"object",
         "additionalProperties":false,
         "id":"http://www.example.org/sample//buyResponseembedded",
         "properties": 
            "purchasestatus": 
               "$ref":"#/definitions/PurchaseStatusType_CT"
            }
         },
         "required": 
            "purchasestatus"
         ]
      }
   },
   "properties": 
      "username": 
         "type":"string",
         "id":"wsdl.namespace/username"
      },
      "password": 
         "type":"string",
         "id":"wsdl.namespace/password"
      },
      "sessionid": 
         "type":"string",
         "id":"wsdl.namespace/sessionid"
      },
      "sessioninfo": 
         "type":"string",
         "id":"wsdl.namespace/sessioninfo"
      },
      "searchstring": 
         "type":"string",
         "id":"wsdl.namespace/searchstring"
      },
      "searchResponse": 
         "$ref":"#/definitions/searchResponseembedded"
      },
      "buystring": 
         "type":"string",
         "id":"wsdl.namespace/buystring"
      },
      "buyResponse": 
         "$ref":"#/definitions/buyResponseembedded"
      }
   }
}

Test Class : 


package com.ingbank.esb.json.model;


import junit.framework.TestCase;


import org.everit.json.schema.Schema;

import org.everit.json.schema.ValidationException;
import org.json.JSONObject;

import com.devside.esb.json.model.JSONSchemaGenerator;

import com.devside.esb.json.model.TypeSchema;

public class SampleServiceTest extends TestCase {


Schema schema;

protected void setUp(){
schema = JSONSchemaGenerator.generate(TypeSchema.class.getClassLoader().getResource("sample-service.wsdl").getPath());
}

public void testEchoSuccess(){
schema.validate(new JSONObject("{\"username\":\"user01\",\"password\":\"pass01\"}"));
}

public void testEchoAdditionalField(){
try {
schema.validate(new JSONObject("{\"username\":\"user01\",\"password\":\"pass01\",\"falan\":\"filan\"}"));
assertTrue(false);
} catch (Exception e) {
assertTrue(e instanceof ValidationException);
}


}




}