List of usage examples for org.eclipse.jgit.storage.file FileBasedConfig getSections
public Set<String> getSections()
From source file:org.ms123.common.git.GitServiceImpl.java
License:Open Source License
public List getRepositories(@PName("flags") @POptional List<String> flags, @PName("all") @PDefaultBool(false) @POptional Boolean all) throws RpcException { System.out.println("getRepositories;" + flags + "/" + all); try {//from ww w . j a v a 2s . c om String gitSpace = System.getProperty("git.repos"); File dir = new File(gitSpace); if (!dir.exists()) { throw new RpcException(ERROR_FROM_METHOD, 100, "GitService.gitSpace not exists"); } List<Map> resList = new ArrayList<Map>(); File[] chld = dir.listFiles(); FS fs = FS.detect(); for (int i = 0; i < chld.length; i++) { File file = chld[i]; String fileName = file.getName(); if (!all && hasStoreCfg(file) == false) { continue; } debug("\n---------------->" + fileName); Map map = new HashMap(); if (flags != null && flags.contains("updateAvailable")) { Git gitObject = Git.open(new File(gitSpace, fileName)); map.put("updateAvailable", updateAvailable(gitObject)); } if (flags != null && flags.contains("isModified")) { Git gitObject = Git.open(new File(gitSpace, fileName)); map.put("isModified", isModified(gitObject)); } debug(fileName); FileBasedConfig fbc = new FileBasedConfig(new File(gitSpace + "/" + fileName + "/.git/config"), fs); fbc.load(); debug("FBC:" + fbc); debug("FBC:" + fbc.getSections()); debug("FBC:" + fbc.toText()); String created = fbc.getString("sw", null, "created"); SimpleDateFormat sdf = new SimpleDateFormat(m_datePattern, Locale.GERMAN); map.put("name", fileName); if (created != null) { map.put("created", sdf.parse(created).getTime()); } resList.add(map); } return resList; } catch (Exception e) { if (e instanceof RpcException) throw (RpcException) e; throw new RpcException(ERROR_FROM_METHOD, INTERNAL_SERVER_ERROR, "GitService.getRepositories:", e); } finally { } }