1 6 package net.sourceforge.cvsgrab; 7 8 import java.util.Iterator ; 9 import java.util.Vector ; 10 11 18 19 public class RemoteRepository { 20 21 private Vector _remoteDirectories = new Vector (); 22 private Vector _directoriesToProcess = new Vector (); 23 24 private String _rootUrl; 25 private LocalRepository _localRepository; 26 private CvsWebInterface _webInterface; 27 28 34 public RemoteRepository(String rootUrl, LocalRepository localRepository) { 35 this._rootUrl = rootUrl; 36 this._localRepository = localRepository; 37 } 38 39 44 public String getRootUrl() { 45 return _rootUrl; 46 } 47 48 53 public LocalRepository getLocalRepository() { 54 return _localRepository; 55 } 56 57 63 public RemoteDirectory getRemoteDirectory(String dirPath) { 64 for (Iterator i = _remoteDirectories.iterator(); i.hasNext(); ) { 65 RemoteDirectory remoteDir = (RemoteDirectory) i.next(); 66 if (remoteDir.getDirectoryPath().equals(dirPath)) { 67 return remoteDir; 68 } 69 } 70 return null; 71 } 72 73 76 public CvsWebInterface getWebInterface() { 77 return _webInterface; 78 } 79 80 85 public void setWebInterface(CvsWebInterface webInterface) { 86 _webInterface = webInterface; 87 } 88 89 94 public void registerDirectoryToProcess(RemoteDirectory remoteDir) { 95 if (getRemoteDirectory(remoteDir.getDirectoryPath()) != null) { 96 return; 97 } 98 _remoteDirectories.add(remoteDir); 99 _directoriesToProcess.add(remoteDir); 100 _localRepository.add(remoteDir); 101 } 102 103 106 public boolean hasDirectoryToProcess() { 107 return (_directoriesToProcess.size() > 0); 108 } 109 110 113 public RemoteDirectory nextDirectoryToProcess() { 114 if (!_directoriesToProcess.isEmpty()) { 115 RemoteDirectory rDir = (RemoteDirectory) _directoriesToProcess.get(0); 116 _directoriesToProcess.remove(0); 117 return rDir; 118 } 119 return null; 120 } 121 122 126 public String getDirectoryUrl(String directoryName) { 127 String url = _webInterface.getDirectoryUrl(getRootUrl(), directoryName); 128 return url; 129 } 130 131 135 public String getDownloadUrl(RemoteFile file) { 136 String url = _webInterface.getDownloadUrl(file); 137 return url; 138 } 139 140 } 141 | Popular Tags |