public static String getVirtualPath(File file, User user) { String path = file.getName(); Links links = user.getLinks(); IVResource rootDir = user.getWorkspace(); File parent = file.getParentFile(); while (!parent.equals(rootDir)) { Link link = links.isLinkTarget(parent.getPath()); if (link != null) { path = link.path + "/" + path; break; } path = parent.getName() + "/" + path; parent = parent.getParentFile(); } return path; }
public static void directoryListJSON( IVResource dir, String path, User user, JSONWriter jsonWriter) { if (dir.exists()) { IVResource[] listFiles = dir.listFiles(); for (int j = 0; j < listFiles.length; j++) { IVResource member = listFiles[j]; if (Resource.isHidden(member)) continue; jsonWriter .startObject() .addField("name", member.getName()) .addField("isDir", member.isDirectory()) .endObject(); } List links = user.getLinks().findLinks(path); for (Iterator iterator = links.iterator(); iterator.hasNext(); ) { Link link = (Link) iterator.next(); jsonWriter .startObject() .addField("name", link.name) .addField("isDir", true) .addField("link", link.location) .endObject(); } } /* if (path.equals(".") || path.length()==0 || jsonWriter.isEmpty()) { ServerManager.getServerManger().getLibraryManager().listFiles(path,jsonWriter); } */ }
@Override public void handleCommand(HttpServletRequest req, HttpServletResponse resp, User user) throws IOException { String pathStr = req.getParameter("path"); String inFolder = req.getParameter("inFolder"); boolean ignoreCase = "true".equals(req.getParameter("ignoreCase")); boolean workspaceOnly = Boolean.parseBoolean(req.getParameter("workspaceOnly")); IVResource[] foundFiles = null; if (inFolder != null) { foundFiles = user.findFiles(pathStr, inFolder, ignoreCase, workspaceOnly); } else { foundFiles = user.findFiles(pathStr, ignoreCase, workspaceOnly); } this.responseString = Resource.foundVRsourcesToJson(foundFiles, user); }