List of usage examples for com.liferay.portal.kernel.util HttpUtil fixPath
public static String fixPath(String path)
From source file:com.liferay.sync.servlet.DownloadServlet.java
License:Open Source License
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try {//w ww. j a v a 2 s . c om HttpSession session = request.getSession(); if (PortalSessionThreadLocal.getHttpSession() == null) { PortalSessionThreadLocal.setHttpSession(session); } User user = PortalUtil.getUser(request); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user); PermissionThreadLocal.setPermissionChecker(permissionChecker); String path = HttpUtil.fixPath(request.getPathInfo()); String[] pathArray = StringUtil.split(path, CharPool.SLASH); if (pathArray[0].equals("image")) { long imageId = GetterUtil.getLong(pathArray[1]); sendImage(response, imageId); } else { long groupId = GetterUtil.getLong(pathArray[0]); String uuid = pathArray[1]; boolean patch = ParamUtil.getBoolean(request, "patch"); if (patch) { sendPatch(request, response, user, groupId, uuid); } else { sendFile(request, response, groupId, uuid); } } } catch (NoSuchFileEntryException nsfee) { PortalUtil.sendError(HttpServletResponse.SC_NOT_FOUND, nsfee, request, response); } catch (Exception e) { PortalUtil.sendError(e, request, response); } }