Posts

Showing posts with the label delete

UnderStanding the Resource Permission

This article explains about the basic flow of the resources, how they are applied. 1. Create the Portlet with the Name as "TestPermission" 2. Create service.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd"> <service-builder package-path="com.service"> <author>Test</author> <namespace>Test</namespace> <entity name="Bus" local-service="true">         <column name="id" type="long" primary="true"></column>         <column name="registration" type="String"></column>         <column name="wheels" type="String"></column>     </entity> </service-builder> Build the services, automatically classes w...

Deleting the cookies

Sometimes it is required to delete the cookies, where we need to set the MaxAge to 0. Here we are retrieving the cookies from the request, and setting the maxAge to "0" to the response , so that it will expire the cookies. Cookie[] cookies = request.getCookies(); for(Cookie cookie : cookies){ System.out.println("cookie Name is "+cookie.getName()); cookie.setMaxAge(0); response.addProperty(cookie); }

File Utility methods in liferay

Liferay has many utility method to handle the file like copyDirectory , copyFile , unZip , delete , createTmpfile etc.. In real scenerio to unzip the file we need to write pure java code but liferay has utility method to unzip the file Have a look into the fileUtil class and look into the method unzip(File source, File destination) public static void unzip(File source, File destination) { PortalFilePermission.checkCopy(_getPath(source), _getPath(destination)); getFile().unzip(source, destination); } Also internally if we look into the how liferay is unzip, look into the ExpandTask class and look into the method as public static void expand(File source, File destination) { Expand expand = new Expand(); expand.setDest(destination); expand.setProject(AntUtil.getProject()); expand.setSrc(source); expand.execute(); } Their it is using the Expand class(org.apache.too...