Monday, 20 September 2021
HPE Accelerating Impact 2019 Highlights to Support Nonprofits
Sunday, 4 October 2020
Liferay Configuration API dependencies
I am using liferay 7.2.0 version.
Have not found:
compileOnly group: "com.liferay", name: "com.liferay.portal.configuration.metatype.api", version: "2.0.0"
Found:
compileOnly group: "com.liferay", name: "com.liferay.portal.configuration.metatype", version: "2.0.0"
Thursday, 3 September 2020
Liferay's success or failure messages for user feedback and custom aui validator
view.jsp:
<liferay-ui:success key="entity-updated-successfully" message="successfully-updated-entity-details"/>
<liferay-ui:error key="entity-updation-failed" message="failed-updation-entity-details"/>
Custom AUI Validator:
<aui:input name="title">
<aui:validator errorMessage="please-specify-file" name="custom" >
function (val, fieldNode, ruleVal){
return ((val!='') || A.one('#<portlet:namespace/>file').val() != '');
}
</aui:validator>
</aui:input>
Thursday, 23 July 2020
liferay headless delivery open APIs URL
localhost:8080/o/headless-delivery/v1.0/openapi.json
Liferay 7.x inclusion of CSS or JS files into the portlet or widget
Include the below entries under portlet component properties:
"com.liferay.portlet.header-portlet-javascript":"/js/main1.js"
"com.liferay.portlet.header-portlet-javascript":"/js/main2.js"
liferay 7.x questions and answers - for certification
1. When multiple implementations are available for osgi-api which are used to identify the particular implementation for that client?
Sol : Policies & filters
2. bnd tools generate _____ file by using build.gradle entries.
Sol : MANIFEST.MF
3. what is require-capability & provide capability?
4. provide-capability vs export in osgi?
5. why we are using blade CLI in liferay development?
Sol : Blade CLI provides module project templates are mvc-portlet, service, service-builder and so on.
Sol : Policies & filters
2. bnd tools generate _____ file by using build.gradle entries.
Sol : MANIFEST.MF
3. what is require-capability & provide capability?
4. provide-capability vs export in osgi?
5. why we are using blade CLI in liferay development?
Sol : Blade CLI provides module project templates are mvc-portlet, service, service-builder and so on.
portlet lifecycle phases
1. init phase
2. render phase
3. action phase
4. resource phase
5. event phase
6. destroy phase
2. render phase
3. action phase
4. resource phase
5. event phase
6. destroy phase
Liferay theme creation basic commands/tools to setup or configuration
Install
Node.js
1.
Find the node-[version]-[os] installer from node site.
2.
Run the
installer for your operating system and follow the instructions.
3.
Open a Command
Prompt/Terminal window.
4.
Run node -v in your command line to verify your
installation once you have installed node.js and npm.
o
The node version should be
8.x.x
5.
Run npm -version to double-check the appropriate version is
installed.
o
The npm version should be
6.x.x
Install
Yeoman and Gulp Dependencies
1.
Open the
command line.
2.
Type npm install -g yo gulp.
o Note:
Users on OSX or Linux will need administrative access to run this command. To
do this, they may need to run sudo before the command.
3.
Press Enter.
This
should have installed the Yeoman and gulp global dependencies. Now we can go
ahead and install the Liferay Theme Generator. If you are running Windows, you
should also install Windows Build Tools before Installing the Liferay Theme
Generator. Let's do this next.
Install
the Liferay Theme Generator
1.
Type npm install -g generator-liferay-theme in the Command
Prompt/Terminal.
o Note:
Like before, Users on OSX or Linux may need to run sudo before the command.
2.
Press Enter.
3.
Type yo in the command line to see that the generator
is installed.
4.
Press Enter.
5.
Type Y
or N if an initial prompt asks to collect data.
6.
Press Enter.
7.
Choose Get
me out of here!.
8.
Press Enter.
Liferay OSGi framework
1. OSGi Framework provides runtime environment (container) and development environment (annotations, dependency injection)
Note: @Reference works for concrete classes only. That means not work for interface and abstract classes (getting null as object value)
2. Component lifecycle - active, activated and deactivated
3. Component registered in OSGi Container and service registered in Service registry
4. invoke method (getTime()) from gogo shell - "osgi.command.function=getTime", "osgi.command.scope=custom"
5. We can determine multiple implementations for single interface by using 1. ranking, 2. target
6. Export-Package & Import-Package vs Provide-Capability & Require-Capability
7. Bundle lifecycle - 1. Installed, 2. Resolved, 3. Active, 4.
8. Spring beans generated by liferay service builder by which annotation can use/reference it ?
sol : @ServiceReference annotation.
Explanation : AssignmentServiceImpl is not OSGi component class. Hence, need to use @servicereference.
9. MVC Commands take care of the portlet life-cycle and interaction b/w UI & Back-end.
a. MVC Commands are wired to a certain portlet life-cycle (render, action & resource)
b. They respond to certain 'mvc.command.name' defined in component properties.
c. they register to a certain portlet with the 'javax.portlet.name' component property.
10. To make silence the generated API under any xxxxLocalServiceImpl classes, simply override that API by @override and define to throw UnsupportedOperationException
11. what is the bundle State when its working as expected after deployment of fragment module ?
Sol : Resolved
12. how many ways override JSPs and what are those ?
Sol : 2 ways and a. override that JSP by creating fragment module. b. update that JSP by creating render filter and customize the JSP output.
13. What is LifecycleAction and why will use it?
Sol : LifecycleAction allows us to customize liferay's application by using events. Events are 1. application.startup.events, 2. prelogin.events, 3. postlogin.events and etc.,
14. what is the use of servicewrapper?
Sol : By using Servicewrapper we can customize service methods either pre or post execution.
15. How we can override struts action?
Sol : Our custom component class should extends BaseStrutsAction and property is "path=/portal/logout"
Sample :
Sol : Our custom component class should extends BaseMVCActionCommand, and property is property = {
"javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY,
"javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY_ADMIN,
"javax.portlet.name=" + DLPortletKeys.MEDIA_GALLERY_DISPLAY,
"mvc.command.name=/document_library/edit_folder",
"service.ranking:Integer=100"
}
17. Model entity listener ?
Sol : Events we are able to listen for when an action on a Model Entity is executed in the persistence layer. There are a few use cases for Model Listeners such as an Audit Listener, Cache Clearing Listener, and Validation Listener. The use case we are implementing is the fourth use case, the Entity Update Listener.
Snippet : @Component(immediate = true, service = ModelListener.class)
public class UserPostUpdateModelListener extends BaseModelListener<User> {
}
18. message bus listener ?
2. Component lifecycle - active, activated and deactivated
3. Component registered in OSGi Container and service registered in Service registry
4. invoke method (getTime()) from gogo shell - "osgi.command.function=getTime", "osgi.command.scope=custom"
5. We can determine multiple implementations for single interface by using 1. ranking, 2. target
6. Export-Package & Import-Package vs Provide-Capability & Require-Capability
7. Bundle lifecycle - 1. Installed, 2. Resolved, 3. Active, 4.
8. Spring beans generated by liferay service builder by which annotation can use/reference it ?
sol : @ServiceReference annotation.
Explanation : AssignmentServiceImpl is not OSGi component class. Hence, need to use @servicereference.
9. MVC Commands take care of the portlet life-cycle and interaction b/w UI & Back-end.
a. MVC Commands are wired to a certain portlet life-cycle (render, action & resource)
b. They respond to certain 'mvc.command.name' defined in component properties.
c. they register to a certain portlet with the 'javax.portlet.name' component property.
10. To make silence the generated API under any xxxxLocalServiceImpl classes, simply override that API by @override and define to throw UnsupportedOperationException
11. what is the bundle State when its working as expected after deployment of fragment module ?
Sol : Resolved
12. how many ways override JSPs and what are those ?
Sol : 2 ways and a. override that JSP by creating fragment module. b. update that JSP by creating render filter and customize the JSP output.
13. What is LifecycleAction and why will use it?
Sol : LifecycleAction allows us to customize liferay's application by using events. Events are 1. application.startup.events, 2. prelogin.events, 3. postlogin.events and etc.,
14. what is the use of servicewrapper?
Sol : By using Servicewrapper we can customize service methods either pre or post execution.
15. How we can override struts action?
Sol : Our custom component class should extends BaseStrutsAction and property is "path=/portal/logout"
Sample :
1. Step 1 : @Component(
2. immediate = true,
3.property = {
4. "path=/portal/logout"
5.},
6.service = StrutsAction.class)
1.Step 2 : @Override
2. public String execute(
3. StrutsAction originalStrutsAction, HttpServletRequest request,
4. HttpServletResponse response)
5. throws Exception {
6.
7. System.out.println("Overriding the Portal Logout Action!");
8.
9. originalStrutsAction.execute(request, response);
10.
11. response.sendRedirect("https://university.liferay.com");
12.
13. return null;
14. }
16. How to override MVCActionCommand?Sol : Our custom component class should extends BaseMVCActionCommand, and property is property = {
"javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY,
"javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY_ADMIN,
"javax.portlet.name=" + DLPortletKeys.MEDIA_GALLERY_DISPLAY,
"mvc.command.name=/document_library/edit_folder",
"service.ranking:Integer=100"
}
17. Model entity listener ?
Sol : Events we are able to listen for when an action on a Model Entity is executed in the persistence layer. There are a few use cases for Model Listeners such as an Audit Listener, Cache Clearing Listener, and Validation Listener. The use case we are implementing is the fourth use case, the Entity Update Listener.
Snippet : @Component(immediate = true, service = ModelListener.class)
public class UserPostUpdateModelListener extends BaseModelListener<User> {
}
18. message bus listener ?
Monday, 29 July 2019
Gogo shel commands
Gogo shell is available inside of the OSGi Container.
Gogo shell commands :
1. lb (to see list of bundles)
2. start <<bundle-id>>
3. stop <<bundle-id>>
4. headers <<bundle-id>>
Gogo shell commands :
1. lb (to see list of bundles)
2. start <<bundle-id>>
3. stop <<bundle-id>>
4. headers <<bundle-id>>
OSGi Basics
OSGi is specification and set of standards to develop Java based modular applications.
1. OSGi Framework : It is runtime (OSGi Container) & development environment.
2. Bundle : Basic unit to deploy into the OSGi container. It is a JAR file which contains executable code and OSGi headers in its MANIFEST.MF file.
Bundle = MANIFEST.MF + Java classes + Resources.
a. Symantic versioning : Major . Minor . Micro - Qualifier (3.0.0-BETA).
Eg. [1.2, 3.0) (means version 1.2 onwards and upto 3.0 not included 3.0 version)
b. Bundle lifecycle managed by BundleActivator.
States are :
1. installed (after added into the container), 2. Resolved (all imported dependencies are resolved ), 3. Starting, 4. Active, 5. Stopping, 6. Unistalling.
3. Component : It is an object (java class) which has set of functionalities. It is managed by component framework.
Component Lifecycle : 1. active, 2. activated. 3. deactivated
4. Service : It is a component registered to OSGi Container 'service registry'.
Implements an interface and referenced by its interface in the OSGi Container.
1. OSGi Framework : It is runtime (OSGi Container) & development environment.
2. Bundle : Basic unit to deploy into the OSGi container. It is a JAR file which contains executable code and OSGi headers in its MANIFEST.MF file.
Bundle = MANIFEST.MF + Java classes + Resources.
a. Symantic versioning : Major . Minor . Micro - Qualifier (3.0.0-BETA).
Eg. [1.2, 3.0) (means version 1.2 onwards and upto 3.0 not included 3.0 version)
b. Bundle lifecycle managed by BundleActivator.
States are :
1. installed (after added into the container), 2. Resolved (all imported dependencies are resolved ), 3. Starting, 4. Active, 5. Stopping, 6. Unistalling.
3. Component : It is an object (java class) which has set of functionalities. It is managed by component framework.
Component Lifecycle : 1. active, 2. activated. 3. deactivated
4. Service : It is a component registered to OSGi Container 'service registry'.
Implements an interface and referenced by its interface in the OSGi Container.
Labels:
bundle,
component,
OSGi,
osgi framework,
service
Saturday, 1 December 2018
XML Processing via Java - JAXB
Unmarshal is a process reading from XML to Java
Marshal is a process writing into XML from Java
Wednesday, 4 July 2018
GenericDaoImpl
@Repository
@Transactional(readOnly = true)
@SuppressWarnings({ "unchecked", "serial" })
public abstract class GenericDaoImpl<E, ID extends Serializable> extends
HibernateTemplate implements GenericDao<E, ID> {
protected Class<E> entityClass;
public GenericDaoImpl() {
setEntityClass();
}
public E findById(ID id, boolean lock) {
return (E) super.get(entityClass, id);
}
public E findById(ID id) {
return findById(id, false);
}
public List<E> findAll() throws Exception {
return this.loadAll(entityClass);
}
public List<E> findByCriteria(DetachedCriteria criteria, int startIndex,
int maxResults) {
return (List<E>) super.findByCriteria(criteria, startIndex, maxResults);
}
@Autowired
@Qualifier("hibernateSessionFactory")
public void setSessionFactory(SessionFactory hibernateSessionFactory) {
super.setSessionFactory(hibernateSessionFactory);
}
protected void setEntityClass() {
entityClass = (Class<E>) ((ParameterizedType) getClass()
.getGenericSuperclass()).getActualTypeArguments()[0];
}
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public E makePersistent(E entity) {
this.checkWriteOperationAllowed(getSession());
this.saveOrUpdate(entity);
return entity;
}
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void deleteEntity(E entity) {
this.checkWriteOperationAllowed(getSession());
this.delete(entity);
}
@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public void deleteAllEntities(Collection<E> entities) {
for (E entity : entities) {
this.checkWriteOperationAllowed(getSession());
this.delete(entity);
}
}
@Override
public Session getSession() {
Session session = getSessionFactory().getCurrentSession();
session.setFlushMode(FlushMode.COMMIT);
return session;
}
}
Session factory configuration in spring
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/TEST" />
</bean>
<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="packagesToScan" value="com.test.model"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>
<prop key="hibernate.search.autoregister_listeners">false</prop>
<prop key="hibernate.connection.release_mode">after_transaction</prop>
<prop key="hibernate.transaction.auto_close_session">false</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="hibernateSessionFactory"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<property name="jndiName" value="jdbc/TEST" />
</bean>
<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="packagesToScan" value="com.test.model"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>
<prop key="hibernate.search.autoregister_listeners">false</prop>
<prop key="hibernate.connection.release_mode">after_transaction</prop>
<prop key="hibernate.transaction.auto_close_session">false</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="hibernateSessionFactory"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
Model listener
Model listeners were designed to perform lightweight actions in response to a create, remove, or update attempt on an entity’s database table or a mapping table
Model listeners are not called when fetching records from the database
Model listeners are not called when fetching records from the database
Monday, 3 July 2017
import data from file to mongodb collection
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 :
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;
}
}
}
- portal-client
- axis
- axis-jaxrpc
- commons-logging
- commons-discovery
- 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;
}
}
}
Labels:
Liferay,
remote methods,
web services
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.
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;
/
Subscribe to:
Posts (Atom)