Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-28977

Temp file not being deleted after LAR import through hook

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: 6.0.6 GA, 6.0.12 EE, 6.1.1 CE GA2, 6.1.20 EE GA2
    • Component/s: Staging
    • Labels:
    • Environment:
      LIFERAY VERSION: 6.0 SP 1
      OPERATING SYSTEM: Red Hat
      APPLICATION SERVER: Tomcat 6.x
      JAVA VIRTUAL MACHINE: Java 6
      DATABASE: Oracle 10g

      Description

      LARs are not being cleared from temp folder when adding a lar through a hook. Fix involves changing LayoutLocalServiceImpl.java:

      public void importLayouts(
      			long userId, long groupId, boolean privateLayout,
      			Map<String, String[]> parameterMap, InputStream is)
      		throws PortalException, SystemException {
      
      		File file = null;
      
      		try {
      			file = FileUtil.createTempFile("lar");
      
      			FileUtil.write(file, is);
      
      			importLayouts(userId, groupId, privateLayout, parameterMap, file);
      		}
      		catch (IOException e) {
      			throw new SystemException(e);
      		}
      		finally {
      			FileUtil.delete(file);
      		}
      	}
      

      Which allows this to work:

      InputStream is = null;
      		File file = null;
      
      		try {
      			is = this.getClass().getResourceAsStream("test.lar");
      
      			file = FileUtil.createTempFile("lar");
      			System.out.println(file.getPath());
      
      			FileUtil.write(file, is);
      
      			LayoutLocalServiceUtil.importLayouts(user.getUserId(), user.getGroup().getGroupId(), true, parameterMap, is);
      		}
      		catch (IOException e) {
      			throw new SystemException(e);
      		}
      		finally {
      			StreamUtil.cleanUp(is);
      			FileUtil.delete(file);
      		}
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  7 years, 8 weeks ago

                  Packages

                  Version Package
                  6.0.X EE
                  6.1.2 CE GA3
                  6.1.30 EE GA3
                  --Sprint 11/12
                  6.2.0 CE M2