private ObjectNode getMetaDataFromPath(int revision, String path) throws SVNException, IOException { org.tmatesoft.svn.core.io.SVNRepository repository = getSVNRepository(); SVNNodeKind nodeKind = repository.checkPath(path, revision); if (nodeKind == SVNNodeKind.DIR) { ObjectNode result = Json.newObject(); ObjectNode listData = Json.newObject(); SVNProperties prop = new SVNProperties(); Collection<SVNDirEntry> entries = repository.getDir(path, -1, prop, SVNDirEntry.DIRENT_ALL, (Collection) null); result.put("type", "folder"); for (SVNDirEntry entry : entries) { ObjectNode data = Json.newObject(); String author = entry.getAuthor(); User user = User.findByLoginId(author); Long commitTime = entry.getDate().getTime(); data.put("type", entry.getKind() == SVNNodeKind.DIR ? "folder" : "file"); data.put("msg", entry.getCommitMessage()); data.put("author", author); data.put("avatar", getAvatar(user)); data.put("userName", user.name); data.put("userLoginId", user.loginId); data.put("createdDate", commitTime); data.put("commitMessage", entry.getCommitMessage()); data.put("commiter", author); data.put("commitDate", commitTime); data.put("commitId", entry.getRevision()); data.put( "commitUrl", routes.CodeHistoryApp.show(ownerName, projectName, String.valueOf(entry.getRevision())) .url()); data.put("size", entry.getSize()); listData.put(entry.getName(), data); } result.put("data", listData); return result; } else if (nodeKind == SVNNodeKind.FILE) { return fileAsJson(path, repository); } else { return null; } }
@Override public ObjectNode findFileInfo(String path) throws SVNException { org.tmatesoft.svn.core.io.SVNRepository repository = getSVNRepository(); SVNNodeKind nodeKind = repository.checkPath(path, -1); if (nodeKind == SVNNodeKind.DIR) { // 폴더 내용 출력 ObjectNode result = Json.newObject(); result.put("type", "folder"); ObjectNode listData = Json.newObject(); SVNProperties prop = new SVNProperties(); Collection<SVNDirEntry> entries = repository.getDir(path, -1, prop, SVNDirEntry.DIRENT_ALL, (Collection) null); Iterator<SVNDirEntry> iterator = entries.iterator(); while (iterator.hasNext()) { SVNDirEntry entry = iterator.next(); ObjectNode data = Json.newObject(); String author = entry.getAuthor(); User user = User.findByLoginId(author); data.put("type", entry.getKind() == SVNNodeKind.DIR ? "folder" : "file"); data.put("msg", entry.getCommitMessage()); data.put("author", author); data.put("avatar", getAvatar(user)); data.put("userName", user.name); data.put("userLoginId", user.loginId); data.put("createdDate", entry.getDate().getTime()); listData.put(entry.getName(), data); } result.put("data", listData); return result; } else if (nodeKind == SVNNodeKind.FILE) { // 파일 내용 출력 return fileAsJson(path, repository); } else { return null; } }