Thursday, 25 September 2014

Start liferay tomcat in a debug mode

1) Open the "....\liferay-portal-6.1-.....\tomcat\bin\catalina.bat" file (for windows)

2) Search for "DEBUG_OPTS" and replaced whole line with below content
set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044

3) Start tomcat with "....\liferay-portal-6.1-.....\tomcat\bin\startup.bat"

4) Inside Liferay IDE/Eclipse go to "Run" -> "Debug Configurations..."

5) Go to "Remote Java Application" and double click on it

6) Give "Name" : "xyzportlet-debug"

7) Project : "Need to select via {Browse} option"

8) Inside "Connection Properties"
    "Host" : "localhost"
   "Port" : "1044" (which we have specified in "catalina.bat" file)

9) Attach source of the project via "Source" tab of a wizard

10) Click on "Apply" and "Debug"

11) Set the break point in your source code (Point where you want to break the execution and debug)

That is it. We are all set to debug our code. Now, access your code via "Browser" and enjoy debugging.

Cheers!
Henal Saraiya
(Senior Consultant)
CIGNEX Datamatics

Wednesday, 24 September 2014

How to check SQL Server Database size

1) Open "Microsoft SQL Server Management Studio Express"
2) Open "New Query" window
3) Fire below query to select database whose size we want to check
     use {database name};
4) Execute above command via pressing "f5"
5) So far, we have selected database whose size we want to check.
6) Fire below query to get size
            "    SELECT
              database_name = DB_NAME(database_id)
            , log_size_mb = CAST(SUM(CASE WHEN type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(8,2))
            , row_size_mb = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(8,2))
            , total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2))
            FROM sys.master_files WITH(NOWAIT)
            WHERE database_id = DB_ID() -- for current db
            GROUP BY database_id
"
6) You will see result in below format
    "database_name" : "log_size_mb" : "row_size_mb" : "total_size_mb"

Cheers!
Henal Saraiya

Steps to verify Liferay service via SOAP UI

1)    Download SOUP UI (http://softlayer-sng.dl.sourceforge.net/project/soapui/soapui/5.0.0/SoapUI-x32-5.0.0.exe)
2)    Get list of services exposed by Liferay
    -    Hit URL : http://<server>:<port>/api/secure/axis
3)    Open SOAP UI ("C:\Program Files (x86)\SmartBear\SoapUI-5.0.0\bin\SoapUI-5.0.0.exe")
    -    Click on File -> New SOAP Project
    -    Project Name : "Portal_PortalService"
    -    Initial WSDL : "http://localhost:8080/api/secure/axis/Portal_PortalService?wsdl"
    -    Click on "OK"
4)    Under "Projects" our project will get list down
5)    Explore project(click "+" sign) to see list of operations/methods
6)    Double click on "getBuildNumber" -> "Request1"
7)    That will open a new window where we can specify input parameters for the method
8)    Click on "Authorization" tab of "Request1" window
9)    In "Authorization:" dropdown select "Add New Authorization"
10)    Select "Type" : "Basic" (Inside "Add Authorization" popup)
11)    Click on "Ok"
12)    A new screen will appear under "Authorization" section
13)    Give "UserName" & "Password" (liferay's screenname & password)
14)    Let other options as it is i.e.(Default options)
    -    Domain : ""
    -    Pre-emptive auth: "Use Global Preference"
    -    Outgoing WSS : ""
    -    Incoming WSS : ""
15)    Click on green arrow under "Request 1" screen (Left top) (Its use to Submit request to specified endpoint URL)
16)    On the right section of "Request 1" section you will be able to see response in XML/Raw format

Cheers!
Henal Saraiya
(Senior Consultant)
CIGNEX Datamatics

Friday, 19 September 2014

Steps to migrate content from DataBase to AdvanceFileSystem

Steps to migrate liferay content from DataBase to AdvanceFileSystem and upload a content using "AdvancedFileSystemStore"

1)    Stop tomcat server
2)    Add below property in portal-ext.properties file
        #
        # FileSystemStore
        #
        dl.store.file.system.root.dir={Path of your drive}
3)    Start server
4)    Go to "Control Panel"
5)    Go to "Server" -> "Server Administration" -> "Data Migration"
6)    select dl.store.impl to "AdvanceFileSystemStore"
7)    Click on "Execute"
8)    Once migration task is completed, stop server
    [Note: You should see below message in tomcat log]
   
        12:11:31,141 INFO  [com.liferay.portal.plugin.PluginPackageUtil][PluginPackageUtil:1421] Checking for available updates
        12:11:31,143 INFO  [com.liferay.portal.plugin.PluginPackageUtil][PluginPackageUtil:1465] Finished checking for available updates in 1 ms
        12:12:25,676 DEBUG [http-bio-8080-exec-8][MaintenanceUtil:64] Executing com.liferay.portal.convert.ConvertDocumentLibrary
        12:12:25,692 INFO  [liferay/convert_process-1][ConvertProcess:41] Starting conversion for com.liferay.portal.convert.ConvertDocumentLibrary
        12:12:25,703 DEBUG [liferay/convert_process-1][MaintenanceUtil:64] Migrating 18 document library files
        12:12:26,743 DEBUG [liferay/convert_process-1][MaintenanceUtil:64] Migrating message boards attachments in 32 messages
        12:12:26,804 DEBUG [liferay/convert_process-1][MaintenanceUtil:64] Migrating wiki page attachments in 0 pages
        12:12:26,813 DEBUG [liferay/convert_process-1][MaintenanceUtil:64] Please set dl.store.impl in your portal-ext.properties to use com.liferay.portlet.documentlibrary.store.AdvancedF
        ileSystemStore
        12:12:26,814 INFO  [liferay/convert_process-1][ConvertProcess:47] Finished conversion for com.liferay.portal.convert.ConvertDocumentLibrary in 1122 ms

8)    Make sure that content is migrated and available in the folder specified in point#2 i.e. {Path of your drive}       
9)    Make below changes in portal-ext.properties
   
    ##### For Advance File System Store
    dl.store.impl=com.liferay.portlet.documentlibrary.store.AdvancedFileSystemStore
   
    #comment out below line which was added earlier
    #
    # Set the name of a class that implements
    # com.liferay.portlet.documentlibrary.store.Store. The
    # document library server will use this to persist documents.
    #
    #dl.store.impl=com.liferay.portlet.documentlibrary.store.JCRStore
    jcr.initialize.on.startup=false

10)    Start Server
11)    Upload a document / images using "Document and Media"
12)    Go to the location specified in point#2
13)    Make sure content is available in it

So far, we have migrated content from Database to "AdvanceFileSystemStore" and uploading content via "AdvanceFileSystemStore" is done.

Cheers!
Henal Saraiya
(Senior Consultant)
CIGNEX Datamatics

Thursday, 18 September 2014

Liferay + SQL Server / Steps for Installation of SQL Server 2005

Steps for Installation of SQL Server 2005

1)     Install SQL Server 2005 with below options
    >    Use sql authentication instead of windows authentication
    >    Give User Name & Password as "sa" and "sa"
2)    Configuration
    >    Open C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft SQL Server 2005\Configuration Tools\SQL Server Configuration Manager
    >    Navigate "SQL Server 2005 Network Configuration" > "Protocols for SQLEXPRESS"
    >     double click "TCP/IP"
    >    Go to "IP Address" tab
    >    Under "IP All" section give TCP Port "1433"
    >    "Apply" and "Ok"
    >    Navigate to "SQL Server 2005 Services"
    >    Restart Service of "SQL Server (SQLEXPRESS)" (available on right tab)
3)    Verify SQL Server's service is up and listening on port 1433   
    >    Go to command prompt
    >    type "telnet localhost 1433" and hit enter
4)    Create Database with "Microsoft SQL Server Management Studio Express"
    >    Right click on "Databases" -> "New Database"
    >    Give database name "test"
    >    Click on "Ok"
5)    Create a User and give permission to newly created DB
    >    Go to "Object Explorer"
    >    Click on "Security"
    >    Go to "Logins"
    >    Right click on it and select "New Login"
    >    Give "Login Name"
    >    select "SQL Server authentication"
    >    give "Password" & "Confirm password"
    >    Uncheck "Enforce password policy"
    >    From the "Default database" select DB (on which permission you want to grant)
    >    Click on the "Server Roles" (under "Select a page" on left column inside "Login-new" wizard)
    >    Check "sysadmin"
    >    Move to "User Mapping"
    >    Select the databases whose mapping you want to do with new user (in our case its "test")
    >    Click on "Status" section on left column
    >     Let the default settings as it is i.e.
        1)    Permission to connect to database engine : "Grant"
        2)    Login : "Enabled"
    > Click on "Ok"

So far we have done SQL Server setup, DB created and User is mapped to database with required permissions.

Cheers!
Henal Saraiya
(Senior Consultant)
CIGNEX Datamatics