]> git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/runtime/org.argeo.slc.server/src/main/java/org/argeo/slc/web/ajaxplorer/svn/SvnLsAction.java
Restructure SLC
[gpl/argeo-slc.git] / legacy / runtime / org.argeo.slc.server / src / main / java / org / argeo / slc / web / ajaxplorer / svn / SvnLsAction.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.web.ajaxplorer.svn;
17
18 import java.io.File;
19 import java.io.FileFilter;
20 import java.util.List;
21 import java.util.Vector;
22
23 import org.argeo.slc.web.ajaxplorer.AjxpDriverException;
24 import org.argeo.slc.web.ajaxplorer.file.FileLsAction;
25 import org.tmatesoft.svn.core.SVNException;
26 import org.tmatesoft.svn.core.wc.SVNInfo;
27 import org.tmatesoft.svn.core.wc.SVNRevision;
28 import org.tmatesoft.svn.core.wc.SVNWCClient;
29
30 public class SvnLsAction extends FileLsAction<SvnDriver, SvnAjxpFile> {
31
32 @Override
33 protected List<SvnAjxpFile> listFiles(SvnDriver driver, final String path,
34 final boolean dirOnly) {
35 try {
36 File dir = driver.getFile(path);
37 SVNWCClient client = driver.getManager().getWCClient();
38
39 final List<SvnAjxpFile> res = new Vector<SvnAjxpFile>();
40 FileFilter filter = createFileFilter(dir);
41 File[] files = dir.listFiles(filter);
42 for (File file : files) {
43 //SVNStatus status = driver.getManager().getStatusClient().doStatus(file, false);
44
45 SVNInfo info = client.doInfo(file, SVNRevision.WORKING);
46 if (dirOnly) {
47 if (file.isDirectory())
48 res.add(new SvnAjxpFile(info, path));
49 } else {
50 res.add(new SvnAjxpFile(info, path));
51 }
52 }
53 return res;
54 } catch (SVNException e) {
55 throw new AjxpDriverException("Cannot list svn dir " + path, e);
56 }
57 }
58
59 @Override
60 protected FileFilter createFileFilter(File dir) {
61 return new FileFilter() {
62
63 public boolean accept(File pathname) {
64 if (pathname.getName().equals(".svn")) {
65 return false;
66 } else {
67 return true;
68 }
69 }
70
71 };
72 }
73
74 }