Posts

Viewing the lucene index files in liferay

Image
By default liferay will index the files. But by default we cannot view the index files . So if we want to view the index files flow the below steps. So the default position of the index are <tomcat-installation>\data\lucene . To view the files we need install the jar in the following location http://code.google.com/p/luke/downloads/detail?name=lukeall-4.0.0-ALPHA.jar file called " lukeall-4.0.0-ALPHA.jar ". After installation go the installation folder copy the path and open the command prompt and hit the following URL as following image. It will open the following Screen shot GUI as, In the Browse option select the location of the lucene and check the checkbox (Force unlock,if locked). In My local system location of the lucene index files are <tomcat-installation>\data\lucene\10154 . Click OK, then we can view the index files as below screen. So here we can view the index files, which were liferay is indexed. Also we choose another ...

Creating the scheduler dynamically in liferay

We can create the scheduler by defining the entries in the liferay-portlet.xml with specfying the only particular entries. what if scheduler what to change based on the user input. so here is the code, String cron = "0 0/1 * 1/1 * ? *"; Portlet portlet = PortletLocalServiceUtil.getPortletById("new_WAR_UserSearchportlet"); Trigger trigger = null; try { trigger = TriggerFactoryUtil.buildTrigger(TriggerType.CRON, Scheduler.class.getName(), Scheduler.class.getName(), new Date(), null, cron); } catch (SchedulerException e) { e.printStackTrace(); } Message message = new Message(); message.put(SchedulerEngine.CONTEXT_PATH, portlet.getContextPath()); message.put(SchedulerEngine.MESSAGE_LISTENER_CLASS_NAME, Scheduler.class.getName()); message.put(SchedulerEngine.PORTLET_ID, portlet.getPortletId()); try { SchedulerEngineUtil.schedule(trigger, StorageType.PERSISTED, "", "liferay/scheduler_dispatch", mes...

How to change the authentication type for login portlet in liferay

Image
We have 3 options to change the authentication type for login. 1. Go to the controlPanel , navigate to the portal section and click on the portal setting and click on the Authentication right handside as shown in below screen shot.  select the values from the selectbox of " How do users authenticate? " ans click on the save button to save the changes. 2.We can change the properties in the portal-ext.properties as, here i have changed to authenticate by screen name.     #     # The portal can authenticate users based on their email address, screen     # name, or user id.     #     #company.security.auth.type=emailAddress     company.security.auth.type=screenName     #company.security.auth.type=userId 3. Changing the settings of login portlet. Go to page where login portlet is reside and click on the setting icon as shown below. and click on the " configuration " which will nav...

Adding the results in the Cache

If we want our results to be in cache, Then we can follow the below procedure as Suppose we take an example, where users to be add in the cache. where name is "ListOfUsers" , key is "Users" and value is getting the all users - UserLocalServiceUtil.getAllUsers(-1,-1). First line is calling the cache called "ListOfUsers". Second line is getting the cache by key "Users". Then the preceding line is , if cache value is null the put the values in the cache. PortalCache cache = MultiVMPoolUtil.getCache("ListOfUsers"); List<user> userList = (List<user>) cache.get("Users"); if(Validator.isNull(userList)) { cache.put("Users",UserLocalServiceUtil.getAllUsers(-1,-1),100); } Here 100 refers to the no.of seconds the results to be in the cache. After 100 seconds cache will be cleared.

IPC which to be prefer : Public Render Parameters or Events

Internal Portlet Communication can be done in 2 ways, 1.Using Public Render Parameter 2.Using Events Public Render Parameter : Liferay The way tagcloud and Blog communicates. Using Public Render Parameter way we can pass only string Using Events we can transfer any serializable objects So using Events is the recommended way with jsr286.

Creating the User Group and assigning the roles for the user group

1.Creating the UserGroup: We can get the userId and companyId from themeDisplay.      UserGroup userGrp = UserGroupLocalServiceUtil.addUserGroup(userId, companyId, "Test User Group", "Test User Group Desc"); 2.Assiging the user to UserGroup: Here we can assign group of users but as of now we are assigning the only one user. UserLocalServiceUtil.addUserGroupUsers(userGrp.getUserGroupId(), new long []{userId}); 3.Assiging the roles to the usergroups:            Here we are getting the groupId of the UserGroup and also the role long groupId =userGrp.getGroup().getGroupId() Role roleId = RoleLocalServiceUtil.getRole(companyId, "Power User"); RoleLocalServiceUtil.addGroupRole(groupId, roleId);

Adding address for Organization

Image
1.Adding Address List<ListType> addressTypes = ListTypeServiceUtil.getListTypes(Organization.class.getName()+ ListTypeConstants.ADDRESS); Here retrieving the all the address for the organization. Below screen is the available address for the organization. ( 1.Billing, 2.Other, 3.P.O.Box, 4.Shipping ) .Hence " addressTypes " contains all these address As an example we will add address as "Billing" type. so we will iterate all for the listtypes to get Billing type. for (ListType addressType : addressTypes) { String addressTypeName = addressType.getName(); if(addressTypeName.equalsIgnoreCase("Billing")) { personalAddressTypeId = addressType.getListTypeId(); } } Then adding the adddress AddressLocalServiceUtil.addAddress(userId, Organization.class.getName(), organization.getOrganizationId(), street1, street2, street3, city, zip,regionId, countryId, personalAddressTypeId, true, true); Here we need to add the country and region also,...