Saturday 22 August 2015

Debug enabling on Servers

WEBLOGIC Server : folder path : /user_projects/domains/base_domain/bin/setDomainEnv.sh

JAVA_OPTIONS="${JAVA_OPTIONS} ${JAVA_PROPERTIES} -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=25801,server=y,suspend=n 
  .........." 

JBOSS Server : folder path : bin/standalone-conf.bat

"%JAVA%" -agentlib:jdwp=transport=dt_socket,address=25801,server=y,suspend=n %JAVA_OPTS% ^
"-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\boot.log" ^
"-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^
    -jar "%JBOSS_HOME%\jboss-modules.jar" ^
    -mp "%JBOSS_MODULEPATH%" ^
    -jaxpmodule "javax.xml.jaxp-provider" ^
     org.jboss.as.standalone ^
    -Djboss.home.dir="%JBOSS_HOME%" ^
     %*



TOMCAT Server : folder path : bin/catalina.bat

%_EXECJAVA% -agentlib:jdwp=transport=dt_socket,address=25801,server=y,suspend=n %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%

Liferay 6.x cstom plugin or out of box web services consumption via Java program

Required class path dependencies are :


  1. portal-client
  2. axis
  3. axis-jaxrpc
  4. commons-logging
  5. commons-discovery
  6. wsdl4j

Java code:

public class CompetencyRemoteAuth {

                static final Logger LOGGER = LoggerFactory
                                                .getLogger(CompetencyRemoteAuth.class);

                static final String LIFERAY_USER_NAME = "satya.kolliboina@gmail.com";
                static final String LIFERAY_USER_PASSWORD = "test1";

                static final String USER_SERVICE = "Portal_UserService";
                static final String COMPANY_SERVICE = "Portal_CompanyService";
                static final String Competency_AUTHENTICATION_SERVICE = "Plugin_Competency_CompetencyAuthenticationService";
                static final String Competency_REGISTRATION_SERVICE = "Plugin_Competency_RegistrationService";

                /**
                * @param args
                */
                public static void main(String[] args) {
                                try {
                                                System.out.println("UserEmail: " + args[0] + "...user pwd:"+args[1]);
                                                URL CompetencyAuthenticationServiceEndPoint = _getURL(args[0],args[1], Competency_AUTHENTICATION_SERVICE);
                                             
                                                System.out.println("Try lookup CompetencyAuthentication Service by End Point: "         + CompetencyAuthenticationServiceEndPoint + "...");
                                             
                                                URL companyServiceEndPoint = _getURL(args[0],args[1], COMPANY_SERVICE);
                                             
                                                System.out.println("Try lookup company Service by End Point: "               + CompetencyAuthenticationServiceEndPoint + "...");
                                             
                                                CompetencyAuthenticationServiceSoapServiceLocator CompetencyAuthenticationLocator = new CompetencyAuthenticationServiceSoapServiceLocator();
                                                CompetencyAuthenticationServiceSoap CompetencyAuthenticationService = CompetencyAuthenticationLocator.getPlugin_Competency_CompetencyAuthenticationService(CompetencyAuthenticationServiceEndPoint);
                                                                             
                                                ((Plugin_Competency_CompetencyAuthenticationServiceSoapBindingStub) competencyAuthenticationService)
                                                .setUsername(args[0]);
                                                ((Plugin_Competency_CompetencyAuthenticationServiceSoapBindingStub) competencyAuthenticationService)
                                                .setPassword(args[1]);
             
                                             
                                                CompanyServiceSoapServiceLocator locatorCompany = new CompanyServiceSoapServiceLocator();
                                                CompanyServiceSoap companyService = locatorCompany.getPortal_CompanyService(companyServiceEndPoint);
                                                CompanySoap companySoap = companyService.getCompanyByVirtualHost("localhost");

                                                System.out.println("Get UserID" + "...");
                                                long userId = 0;
                                             
                                             
                                                userId = CompetencyAuthenticationService.CompetencyAuthentication(args[0], args[1], args[2]);
                                                System.out.println("UserId for user named " + args[0]   + " is " + userId);

                                             

                                } catch (RemoteException re) {
                                                LOGGER.error(re.getClass().getCanonicalName()
                                                                                + re.getMessage());
                                } catch (ServiceException se) {
                                                LOGGER.error(se.getClass().getCanonicalName()
                                                                                + se.getMessage());
                                }
                }
             
                /**
                * Get the URL Liferay SOAP Service
                *
                 * @param remoteUser
                * @param password
                * @param serviceName
                * @return
                */
                private static URL _getURL(String remoteUser, String password, String serviceName) {
//http://localhost:9090/CompetencyAuthentication-portlet/api/axis/Plugin_Competency_CompetencyAuthenticationService?wsdl
                                final String LIFERAY_PROTOCOL = "http://";
                                final String LIFERAY_TCP_PORT = "9090";
                                final String LIFERAY_FQDN = "127.0.0.1";
                                String LIFERAY_AXIS_PATH = "";
                             
                                try {
                                                if(serviceName.split("_")[0].equalsIgnoreCase("Plugin")){
                                                                LIFERAY_AXIS_PATH = "/CompetencyMobility-portlet/api/secure/axis/";
                                                }else{
                                                                LIFERAY_AXIS_PATH = "/api/secure/axis/";
                                                }
                                                return new URL(LIFERAY_PROTOCOL
                                                                                + URLEncoder.encode(remoteUser, "UTF-8") + ":"
                                                                                + URLEncoder.encode(password, "UTF-8") + "@" + LIFERAY_FQDN
                                                                                + ":" + LIFERAY_TCP_PORT + LIFERAY_AXIS_PATH + serviceName);
                                } catch (Exception e) {
                                                LOGGER.error(e.getMessage());
                                                e.printStackTrace();
                                                return null;
                                }
                }
}

Tuesday 18 August 2015

Coding standards to develop artifact

1. If we get any errors, while performing add/update operations then return previous request & response (which contains user entered data). By using the snippet:

PortalUtil.copyRequestParameters(request, response);

2. If necessary we need to write custom validator, to validate custom entities.

3. While writing implementation to CRUD operations in Liferay's service builder xxxxLocalServiceImpl class, make sure that you are not re-writing available operations in xxxxLocalServiceBaseImpl.

xxxLocalServiceBaseImpl CRUD operations are available. We are extending it in our xxxxLocalServiceImpl. So, no need to write again those CRUD operations on xxxxLocalServiceImpl class.


Friday 31 July 2015

oracle schema and tablespace for liferay portal setup

prompt 'creating tablespace COMPETENCY_DATAand COMPETENCY_IDX'
 CREATE TABLESPACE "COMPETENCY_DATA" DATAFILE 
  'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\COMPETENCY_DATA01.DBF' SIZE 5242880
  AUTOEXTEND ON NEXT 1310720 MAXSIZE 32767M
  LOGGING ONLINE PERMANENT BLOCKSIZE 8192
  EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT NOCOMPRESS  SEGMENT SPACE MANAGEMENT AUTO;
  
  CREATE TABLESPACE "COMPETENCY_IDX" DATAFILE 
  'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\COMPETENCY_IDX01.DBF' SIZE 5242880
  AUTOEXTEND ON NEXT 1310720 MAXSIZE 32767M
  LOGGING ONLINE PERMANENT BLOCKSIZE 8192
  EXTENT MANAGEMENT LOCAL AUTOALLOCATE DEFAULT NOCOMPRESS  SEGMENT SPACE MANAGEMENT AUTO;

prompt 'creating LPORTAL schema'     
drop user lportal cascade;
accept l_portalpwd prompt "LPORTAL Password : "
create user lportal identified by &l_portalpwd;
prompt 'granting privileges to the LPORTAL schema'
grant resource, connect, dba to lportal;
MOVING TABLESPACE:

declare
l_sqltext varchar2(500);
begin
for i in (select owner, table_name, tablespace_name from dba_tables where owner in  ('LPORTAL') and tablespace_name ='USERS') loop
l_sqltext := 'ALTER TABLE '||i.OWNER||'.'|| i.TABLE_NAME|| ' MOVE TABLESPACE COMPETENCY_DATA';
execute immediate l_sqltext;
end loop;
end;
/


declare
l_sqltext varchar2(500);
begin
for i in (select owner, index_name from dba_indexes where TABLE_OWNER in ('LPORTAL') AND index_type = 'NORMAL'  AND TABLESPACE_NAME = 'USERS') loop
l_sqltext := 'ALTER INDEX '||i.OWNER||'.'|| i.INDEX_NAME|| ' REBUILD TABLESPACE COMPETENCY_IDX';
execute immediate l_sqltext;
end loop;
end;
/

Liferay default role associations via portal-ext.properties

system.roles=Moderator
system.role.Moderator.description=This is Moderator role.

Friday 24 July 2015

Dr. Manoj R Dudhgaonkar, Radha Madhavi, Ankit Pancholi, Dharithi Pancholi, Maruthi Prasad Anumula, Mahammad.s.ali and Siddharth Thomas with me

We (My spouse & myself) never forget the day (February 16, 2014), which day changed our life. We woke up as usual at 6:30 AM. I have changed my breakfast menu from Wheat Upma to Corn Flakes after toilet because I felt that I had so much heat inside of my body

Suddenly, I felt so much stomach pain at 7:00 AM. Swallowed normal stomach pain tablet & tried to sleep to get rid from that pain. I could not won from that pain.

To overcome that pain I had done many unknown Asanas with standinng, sitting & bending, and laid down in my balcony on the mat. I understood that my Asanas knowledge is vague that time. 

She unable to understand whats going on to her life partner, at the same time unable to control fear & sorrow. She controlled herself and offered butter milk. That butter milk I offered to bathroom as vomiting. 

To console her or to make her normal, I tried to hide that pain and behave as normal. I unable to do so.

I vomited water after had water with sugar to bring down my body temparature. 

Few friends are forever: I called one of my friend (Mr. Ankit) & boast out whats happened. He told home remedy to adjust stomach nerves. I called other friend (Mr. Maruthi) to enquired opened hospitals (sunday evening fews hospitals are opened at Hinjewadi in pune) at that time. Mean time, we (spouse & myself) started to hinjewadi area to get treatment from Maruthi enquired hospital. We admitted at Mulshi millenium hospital before Ankit's family has reached that hospital. 

Few doctors believes Service is primary, money is secondary : Around 4:00 PM, Dr. Manoj R Dudhgaonkar, injected medicine via syringe to my both buttocks to surpass that severe pain and injected saline to get energy. From morning, Spouse had not been taken anything. Still, she is normal because her focus to see me as normal. I became normal with these medicines and saline. To get rid from that pain. It took 45 mins after that two injections. Dr. Manoj, He has limited equipment but he has unlimited love on his duty/service. 

He took X-Ray and confirmed that leaking from the intestine and instructed that immediately join multi speciality hospital that day itself, do not do any travel now. We (Spouse, Ankit's family, Maruthi & Ali) are preparing to move to Aditya birla emergency department enquired by Dr. Manoj. One of manager (Mr. Siddharth from Cignex) came to meet me and he got to know that I got appendicitis. 

Dr. Gajanan Wagholikar, Radha Madhavi and her parents (Mr. Venkateswarlu & Suvarna Kumari), and her sister's family (Srinivasulu, Vani & Shanmukha teja) and her brother (Muralidhar), my parents (Ramanama) and my brother in law (Satyanarayana P) and my friend (Yesu ratnam), Ankit Pancholi & his parents, Dharithi Pancholi, Maruthi Prasad Anumula,with me.

Mr. Ankit drove to Aditya Birla Hospital, Emergency Department for admission. Due to that severe pain abdominal internal parts getting pain due to car jerks whenever car crossing speed brakers while driving on road. After joined into the emergency ward then doctor suggested Abdominal CT-Scan to diagnosis the problem. While preparing for the Abdominal CT scan, drinking water again started that stomach pain. But, I know that I need to complete 2 litres of water to get proper Abdominal CT Scan.

All are praying and hope for good entire night. 

On Feb 17, 2014, Doctor came and told that this is perforation (intenstine damaged/leaking). He instructed that one more Abdominal CT Scan to take decision lazer surgery or open surgery is required. Afternoon doctor confirms that we need to do open surgery. 

At 7:00 PM, Spouse & Friends, they dropped me at operation theatre with tears and wet hearts. spouse signed on the required documents for surgery declarations. Some other specialists came, explained and took my consent and sent me to the surgery room. I saw a light, heard some sounds and felt very hot on my stomach due to lamp. 

My brother in law (Mr. Murali) reached Pune at 2:00 PM. Father in law, mother in law and mother, they reached at 8:00 PM. 

Around at 11:30 PM, Doctor shown infected intestine piece to them. After that I shifted to ICU Room. The following morning I am in the surgical intensive care unit. I have a central line in my neck, an IV in my arm, a catheter in my penis, a tube down my nose, a drainage tube coming from my stomach. My stomach is held together by 18 stitches and I was wearing "medical mittens" so I cannot pull any of it out.

Dr. Wagholikar sir, visits every day and each time asks me how I am feeling. One the third day I told him I was feeling good; that I was not a perforation patient anymore. I was getting bad nightmares and daymares then my father in law told that chant Anjaneya slokams to get rid of them. I was shifted to general ward. But, I was unable to stay there, I was getting feel like my stomach flesh was burning, and lack of proper weather conditions and so much disturbance. Finally, we moved to other separate ward where we have proper weather conditions. Dr. Panda sir, observing hepatitis B due to my hepatitis B results are positive. Finally, we understood that due to Abdominal TB this perforation happened. Slowly, I started walking, drinking, eating and trying to improve my breath. I spend one week in the hospital. All were coming for visiting and staying at the hospital premises. One week later, Dr. Wagholikar & Dr. Panda, they confirmed that I can go home the next day. 


Wednesday 20 May 2015

PDF Generation from XML Structure and Java

PDF Generation from XML Structure and Java Programming language



Saturday 16 May 2015

integrating liferay with DB2

Integratinging Liferay with DB2


Install DB2

Import SQL file into DB2
db2 -td\; -vf create-db2.sql

Install JDBC drivers
Install jdbc driver files db2jcc.jar and db2jcc_license_cu.jar into directory $TOMCAT_HOME/lib/ext 

Edit tomcat/lib/portal-ext.properties file and add following lines.
***************************
hibernate.dialect=com.liferay.portal.dao.orm.hibernate.DB2Dialect
custom.sql.function.isnull=CAST(? AS VARCHAR(32672)) IS NULL
custom.sql.function.isnotnull=CAST(? AS VARCHAR(32672)) IS NOT NULL
jdbc.default.driverClassName=com.ibm.db2.jcc.DB2Driver
jdbc.default.url=jdbc:db2://127.0.0.1:50000/lportal
jdbc.default.username=
jdbc.default.password=



Saturday 2 May 2015

to setup s3 properties in portal-ext.properties file of liferay

##
## S3 properties
##
    dl.hook.s3.access.key=   
dl.hook.s3.secret.key=  
 dl.hook.s3.bucket.name=
    amazon.cloudfront.domain=

Friday 1 May 2015

vertical marque in java script

var delayb4scroll=1000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)) //if scroller hasn't reached the end of its height
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px" //move scroller upwards
else //else, reset to original position
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0
marqueeheight=document.getElementById("marqueecontainer").offsetHeight
actualheight=cross_marquee.offsetHeight //height of marquee content (much of which is hidden from view)
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee

Thursday 30 April 2015

clean undeployed portlet's preferences and permissions from database tables

Problem Description:
An undeloyed portlets from Liferay portal webapp context only removes the portlet of visibility in the “Add Application” so that permission users can’t add that portlet to a page. But portlets instance information was not removed from layout and its preferences (user and layout level) and permissions. Still there is a mapping existed in tables from liferay schema.
Proposed Solution: As Liferay provides cool feature of hooks which users can customize Liferay Portal source. We can use this hook to identify the undeployed portltes and clean the unwanted data.
Steps to reproduce the problem
Step: 1 - Download Liferay Instance
Step: 2 - Download photolibraryportlet (this only for example, you can deploy and underplay any custom portlet)
Step: 3 - Create 2 Liferay Pages and add calendar portlet,
Step: 4 - Configure Portlet Preferences
Step-5 - Setup Portlet Permissions

Page1


 
Page2

Page/Layout Level Porlet Related Data
SELECT * FROM portletpreferences WHERE portletId LIKE '%photolibraryportlet%';


SELECT * FROM resourcepermission WHERE NAME LIKE '%photolibraryportlet%';


Step-6: Undeploy the photolibraryportlet portlet
  1. Remove the removelibraryportlet webapp context from portal
cd %LIFE_HOME%\tomcat-7.0.42\webapps\market-photolibrary-portlet
rm –rf market-photolibrary-portlet
Step-7: Access Page1 and Page2 where you have render the portlet through admin
Admin can’t add the portlet from UI as it’s undeployed – working as expected



Validation: Even though portlet was undeployed still its information existed in liferay tables
SELECT * FROM portletpreferences WHERE portletId LIKE '%photolibraryportlet%';
SELECT * FROM resourcepermission WHERE NAME LIKE '%photolibraryportlet%';
Summary of API for this hook plugin:
  1. Get Group Layouts(public and private)
List<Layout> layouts= LayoutLocalServiceUtil.getLayouts(groupId, privateLayout)
  1. Iterate Layouts and identify the undeployed portlets
List<Portlet> allPortlets = layoutTypePortlet.getPortlets()
if(pagePortlet.isUndeployedPortlet())
  1. Remove Porlet from Layout and update Layout
layoutTypePortlet.removePortletId(userId, pagePortlet.getPortletId())

Steps to clean undeployed portlets entries from database tables.
  • Step2: click ‘server administration’ option

  • Step3: click ‘Execute’ button to clean Database tables entries of undeployed portlets. 

     
  • Step4: After successful execution we will get success message.

  • On the log file, you can find
    • 1. total number sites are available in the current instance
    • 2. total number of applied layouts are 4 for the respective site
    • 3. total number of added portlets for the respective page
    • 4. cleaned undeployed xxx-portlet portlet entries from database table

Final validations :
  • DB Validation (No Data related to page level)
    • SELECT * FROM portletpreferences WHERE portletId LIKE '%photolibraryportlet%';
    • SELECT * FROM resourcepermission WHERE NAME LIKE '%photolibraryportlet %';