Friday, October 7, 2011

RabbitVCS icon is missing in contex menu

In my last post try to explain how to install  RabbitVCS in ubuntu. i later when i start to use Ubutu10.10 found that all the steps are fine for Ubutu10.4 and i need a fix for it. after spending a lot I found that Gnome in  10.10 is different. see that it's a bug in the extension code, but you might be able to work  around it if you disable "show attributes" in the settings

try this command to enable:

gconftool-2 --type boolean --set /desktop/gnome/interface/menus_have_icons  true

i hope this time RabbiVcs will appear in you Context Menu.

Tuesday, April 5, 2011

New jQuery version into Liferay Portal

Copy the file "top_head.jsp" located in folder "liferay-portal-src-[version]\portal-web\docroot\html\common\themes\" into the EXT-folder 'liferay-portal-ext\ext-web\docroot\html\common\themes\'

>Open the copied file in your EXT
>Add the following lines:
<script  src="/html/js/jQuery1.3.2/jquery1.3.2.js" type="text/javascript"></script>
<script  src="/html/js/jQuery1.3.2/ui.jquery1.7.js" type="text/javascript"></script>
<script >="" src="/html/js/jQuery1.3.2/ui.stars.js" type="text/javascript"></script>

<script type="text/javascript">
var $132 = jQuery.noConflict(true);
 </script>
> Now you can access jQuery 1.3.2'.

Saturday, December 25, 2010

how to use ZTE Modem in linux


To intall Citycell ZTE Modem in linux you should follow following steps

  1. Plug Modem to PC
  2. open terminal and use lsusb command which will show usb device plugged at the time in my case I get following out put
#lsusb
    Bus 007 Device 002: ID 0a5c:2101 Broadcom Corp. Bluetooth Controller
    Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 006 Device 002: ID 15d9:0a4c Trust International B.V.
    Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 005 Device 003: ID 19d2:fff1 ONDA Communication S.p.A.
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 001 Device 002: ID 064e:a101 Suyin Corp. Acer CrystalEye Webcam
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
bold line is my ZTE Modem from that output I get vendor is 19d2 and product id fff1

  1. now load driver using modprobe command
    # sudo modprobe usbserial vendor=0x19d2 product=0xfff
  2. now edit wvdial config
    #sudo gedit /etc/wvdial.conf
    insert followin lines
    [Dialer Defaults]
    Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
    Modem Type = Analog Modem
    ISDN = 0
    Init1 = ATZ
    Modem = /dev/ttyUSB0
    Baud = 9600
    [Modem0]
    Init1 = ATZ
    SetVolume = 0
    Modem = /dev/ttyUSB0
    Baud = 230400
    FlowControl = Hardware (CRTSCTS)
    Dial Command = ATDT
    [Dialer citycell]
    Stupid Mode = 1
    Inherits = Modem0
    Password = waps
    Username = waps
    Phone = #777
  3. now dial you moden using following command
    #sudo wvdial citycell
If you do not have wvdial installed in you pc then install follwing:
  1. wvdial_1.60.1
  2. libxplc0.3.13_0.3.13-1
  3. libwvstreams4.4-base
  4. libwvstreams
  5. libuniconf

Thursday, December 23, 2010

Ubuntu USB file transfer is slow

Some time you might experence Ubuntu USB file transfer is slow then you can try following solution
$ sudo gedit /etc/default/grub

edit as following
#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=noacpi pci=routeirq"

then reload
$ sudo grub-mkconfig -o /boot/grub/grub.cfg


This fix might not work for every one.

RabbitVCS an alternative to TortoiseSVN

TortoiseSVN is not avail able for linux but we can use rabbitVCS as an alternative to Tortoise. Check following to install rabbitVCS in ubuntu.

Add repository source
$ sudo add-apt-repository ppa:rabbitvcs/ppa

update source list
$ sudo apt-get update

install rabbitvcs core
$ sudo apt-get install rabbitvcs-core

Install nautilus,thunar,gedit and command line plugins
$ sudo apt-get install rabbitvcs-nautilus rabbitvcs-thunar rabbitvcs-gedit rabbitvcs-cli


rabbitVCS installed in your ubutu system. Enjoy it.

If you can't see rebbitVCS in you context menu check this link

Wednesday, September 8, 2010

Hibernate Basics


Hibernate is an open source object relational mapping library. Hibernate provides a solution to map database tables to a class. It copies one row of the database data to a class. In the other direction it supports to save objects to the database. Objects are transformed to one or more tables.


Hibernate solves Object-Relational impedance mismatch problems by replacing direct persistence-related database accesses with high-level object handling functions.


Basic classes used while working with Hibernate are:
§         SessionFactory
§         Session
§         Transaction

SessionFactory
A thread safe, immutable cache of compiled mappings for a database. The SessionFactory is created from a Configuration object.

The SessionFactory is an expensive object to create. It like is usually created during application start up. However, unlike the Configuration object, it should be created once and kept for later use. The SessionFactory object is used by all the threads of an application.

SessionFactory object is created per database. Multiple SessionFactory objects (each requiring a separate Configuration) are created when connecting to multiple databases.

Session
A single-threaded, short-lived object representing a conversation between the application and the persistent store.  
Session objects are not thread safe. Therefore, session objects should not be kept open for a long time. Applications create and destroy these as needed.  Typically, they should be created to complete a single unit of work, but may span many units.


Transaction

Transaction object created from Session. Single-threaded, short-lived object used by the application. A Transaction represents a unit of work with the database (and potentially other systems). Transactions in Hibernate are handled by an underlying transaction manager and transaction.

Instance states

An instance of persistent classes may be in one of three different states

Transient:
The instance is not, and has never been associated with any persistence context (A persistence context is a set of entity instances in which any persistent entity identity is unique). It has no persistent identity.

Persistent:
The instance is currently associated with a persistence context. It has a persistent identity (primary key value) and, perhaps, a corresponding row in the database.

Detached
The instance was once associated with persistence context, a detached instance is an has been persistent, but its Session has been closed. The reference to the object is still valid, and the detached instance might even be modified in this state.  detached instance can be reattached to a new Session at a later point in time, making it (and all the modifications) persistent again. Can be reattachment of detached instances using the session.update() or Session.merge()  methods

Session and transaction scopes

Session-per-operation: open and close a Session for every simple database call in a single thread

Session-per-request: The most common pattern in a multi-user client/server application. In this model, a request from the client is send to the server (where the Hibernate persistence layer runs), a new Hibernate Session is opened, and all database operations are executed in this unit of work. Once the work has been completed (and the response for the client has been prepared), the session is flushed and closed. 

Open Session in View: scope of a Session and database transaction until the "view has been rendered"

Session-per-conversation: The Hibernate Session may be disconnected from the underlying JDBC connection after the database transaction has been committed, and reconnected when a new client request occurs.

 


Locking:
There are two common strategies when dealing with updates to database records, pessimistic locking and optimistic locking.

Optimistic locking is a strategy where you read a record, take note of a version number and check that the version hasn't changed before you write the record back. Optimistic assumes that nothing's going to change while you're reading it.

Pessimistic Lock is where you lock the record/data for your exclusive use until you have finished with it so that no one can access it in between.

 


Hibernate Automatic Dirty Check:


Hibernate automatically detects object state changes in order to synchronize the updated state with the database, this is called dirty checking. An important note here is, Hibernate will compare objects by value, except for Collections, which are compared by identity. For this reason you should return exactly the same collection instance as Hibernate passed to the setter method to prevent unnecessary database updates.

Hibernate can perform dirty checks only when the objects are loaded and changed in the scope of a single Session

Friday, August 27, 2010

Unit Testing Jersey REST service

In my last post i show how to create Rest service with Jersey api. I also try to give some idea about the basic concept of REST in this link. Now we should start testing before start to do anything else. I write one test case using Jersey Test Framework also create one client using Jersey client tool.

The Jersey Test Framework currently allows you to run your tests on any of the following three light weight containers:
• Embedded GlassFish
• Grizzly Web Server
• Lightweight HTTP Server
The framework is built over JUnit 4.x using Maven.
For details information on Jersey Test Framework check this post


Test case for ProductResource
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
import java.io.UnsupportedEncodingException;
import org.junit.Test;
import static org.junit.Assert.*;
import com.sun.jersey.test.framework.WebAppDescriptor;
import com.sun.jersey.test.framework.spi.container.http.HTTPContainerFactory;
import java.math.BigDecimal;
import org.model.Product;
import javax.ws.rs.core.MediaType;

/** *
* @author Kamal Hossain
*/
public class ProductServiceTest extends JerseyTest {

public static final String PACKAGE_NAME = "org.resources";
private WebResource ws;

public ProductServiceTest() {
super(new WebAppDescriptor.Builder(PACKAGE_NAME).build());
}

@Override
protected TestContainerFactory getTestContainerFactory() {
return new HTTPContainerFactory();

}

@Test
public void testProductResponse() throws UnsupportedEncodingException {
ws = resource().path("product/kamal");
ClientResponse response = ws.accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
assertEquals(200, response.getStatus());
System.out.println(response.getStatus());


}

@Test
public void testProductPrice() throws UnsupportedEncodingException {
ws = resource().path("product/kamal");
Product prod = ws.accept(MediaType.APPLICATION_XML).get(Product.class);
assertEquals(BigDecimal.valueOf(120), prod.getPrice());


}
}

Test case for ProductsResource
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
import java.io.UnsupportedEncodingException;
import org.junit.Test;
import static org.junit.Assert.*;
import com.sun.jersey.test.framework.WebAppDescriptor;
import com.sun.jersey.test.framework.spi.container.http.HTTPContainerFactory;
import org.model.Product;
import java.util.Collection;
import java.util.List;
import javax.ws.rs.core.MediaType;

/** *
* @author kamal hossain
*/
public class ProductsServiceTest extends JerseyTest {
public static final String PACKAGE_NAME = 'org.resources';
private WebResource ws;

public ProductsServiceTest() {
super(new WebAppDescriptor.Builder(PACKAGE_NAME).build());
}

@Override
protected TestContainerFactory getTestContainerFactory() {
return new HTTPContainerFactory();

}

@Test
public void testProductResponse() throws UnsupportedEncodingException {
ws = resource().path("product/kamal");
ClientResponse response = ws.accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
assertEquals(200, response.getStatus());
System.out.println(response.getStatus());


}

@Test
public void testProductList() throws UnsupportedEncodingException {
ws = resource().path("products");
GenericType<Collection<Product>> genericType = new GenericType<Collection<Product>>(){};
List<Product> wsResult = (List<Product>) ws.accept(MediaType.APPLICATION_XML).get(genericType);
assertEquals(2, wsResult.size());

}    

}




You can also install firefox addon Poster to test services.

AWS Services

      1.         Identity Access Management (IAM): Used to control Identity (who) Access (what AWS resources).                   1....