Monday, January 9, 2017

How to get rid of no-reply@liferay.com in Liferay Kaleo workflow

When ever we work with Kaleo workflow in liferay, we will have a mail configuration in that. In Kaleo workflow it adds automatically 'no-reply@liferay.com' as the sender the email.If you want to change that, you can't... at least not directly through the UI of control panel.

The only way to change that email is modifying the XML file, you have to go to the workflow XML and change some things there. In the actions element, and above the notification element add a new action element like this:

<action>
    <name>setNotificationStuff onEntry</name>
    <script>

workflowContext.put(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_ADDRESS,"inthiyaz@liferay.com");  

workflowContext.put(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME,"IMTHU");

    </script>
    <script-language>javascript</script-language>
    <execution-type>onEntry</execution-type>
</action>

Thursday, January 5, 2017

Category checking to particular DLFile in liferay

This blog will help you to check the particular categorie assigned to DLFile or not, and also helps to fectch all the categories from database,

import com.liferay.portlet.asset.model.AssetCategory;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;

 List categoryList = null;
//Using dynamic query to fetch all the categories with the name "IMTHIYAZ"
DynamicQuery query = DynamicQueryFactoryUtil.forClass(AssetCategory.class).add(PropertyFactoryUtil.forName("name").eq("IMTHIYAZ"));
               categoryList = AssetCategoryLocalServiceUtil.dynamicQuery(query, 0,1);
//Result list contains all the list of AssetCategory Objects with the Name "IMTHIYAZ"

import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.asset.model.AssetEntry;

AssetEntry assetentry = null;
DLFileEntry fileEntryObj ; Assuming this object conatins file
//getting assetentry of particular file
 assetentry = AssetEntryLocalServiceUtil.getEntry( DLFileEntry.class.getName(), fileEntryObj.getPrimaryKey());
//fetching all categories of particular assetentry
long assetCategoryId[] = assetentry.getCategoryIds();
List assetCategories = assetentry.getCategories();
 if(assetCategories.contains(categoryList.get(0))){
//This file contains IMTHIYAZ category
}

Tuesday, January 3, 2017

How to use orderbycomparator in liferay

Liferay provides one of the beautiful API is "orderbycomparator ", this api will work as "Order By" keyword in database, let see the example how to utilize this API.

import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.OrderByComparatorFactoryUtil;

//Fetching the DLFiles order by create date
OrderByComparator comparator = OrderByComparatorFactoryUtil.create("DLFileEntry", "createDate/modifiedDate", true/false);

Note :- createDate / modifiedDate should be your column name of your table.

 Long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
DLFileEntryLocalServiceUtil.getFileEntries(themeDisplay.getScopeGroupId(),parentFolderId,-1, -1, comparator);

//Fetching the custom table vlaues order by title
OrderByComparator comparator = OrderByComparatorFactoryUtil.create(customModelImpl.TABLE_NAME, "title", true);


Liferay DXP JNDI Data Source Cofiguration

 This Blog will help us to learn about the JNDI Data Source Configuration in Liferay DXP. We have tested this with Liferay 7.3 with Tomcat. ...