import javax.servlet.http.Cookie;\r
\r
import org.apache.wicket.protocol.http.WebResponse;\r
-import org.eclipse.jgit.errors.RepositoryNotFoundException;\r
import org.eclipse.jgit.lib.Repository;\r
+import org.eclipse.jgit.lib.RepositoryCache;\r
import org.eclipse.jgit.lib.RepositoryCache.FileKey;\r
import org.eclipse.jgit.lib.StoredConfig;\r
import org.eclipse.jgit.storage.file.FileBasedConfig;\r
import org.eclipse.jgit.storage.file.WindowCache;\r
import org.eclipse.jgit.storage.file.WindowCacheConfig;\r
-import org.eclipse.jgit.transport.ServiceMayNotContinueException;\r
-import org.eclipse.jgit.transport.resolver.FileResolver;\r
-import org.eclipse.jgit.transport.resolver.RepositoryResolver;\r
-import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;\r
-import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;\r
import org.eclipse.jgit.util.FS;\r
import org.eclipse.jgit.util.FileUtils;\r
import org.slf4j.Logger;\r
\r
private final AtomicReference<String> repositoryListSettingsChecksum = new AtomicReference<String>("");\r
\r
- private RepositoryResolver<Void> repositoryResolver;\r
-\r
private ServletContext servletContext;\r
\r
private File repositoriesFolder;\r
* @return repository or null\r
*/\r
public Repository getRepository(String repositoryName, boolean logError) {\r
+ File dir = FileKey.resolve(new File(repositoriesFolder, repositoryName), FS.DETECTED);\r
+ if (dir == null)\r
+ return null;\r
+\r
Repository r = null;\r
try {\r
- r = repositoryResolver.open(null, repositoryName);\r
- } catch (RepositoryNotFoundException e) {\r
- r = null;\r
+ FileKey key = FileKey.exact(dir, FS.DETECTED);\r
+ r = RepositoryCache.open(key, true);\r
+ } catch (IOException e) {\r
if (logError) {\r
logger.error("GitBlit.getRepository(String) failed to find "\r
+ new File(repositoriesFolder, repositoryName).getAbsolutePath());\r
}\r
- } catch (ServiceNotAuthorizedException e) {\r
- r = null;\r
- if (logError) {\r
- logger.error("GitBlit.getRepository(String) failed to find "\r
- + new File(repositoriesFolder, repositoryName).getAbsolutePath(), e);\r
- }\r
- } catch (ServiceNotEnabledException e) {\r
- r = null;\r
- if (logError) {\r
- logger.error("GitBlit.getRepository(String) failed to find "\r
- + new File(repositoriesFolder, repositoryName).getAbsolutePath(), e);\r
- }\r
- } catch (ServiceMayNotContinueException e) {\r
- r = null;\r
- if (logError) {\r
- logger.error("GitBlit.getRepository(String) failed to find "\r
- + new File(repositoriesFolder, repositoryName).getAbsolutePath(), e);\r
- }\r
}\r
return r;\r
}\r
*/\r
private void closeRepository(String repositoryName) {\r
Repository repository = getRepository(repositoryName);\r
+ RepositoryCache.close(repository);\r
+\r
// assume 2 uses in case reflection fails\r
int uses = 2;\r
try {\r
\r
// load repository\r
logger.info("edit repository " + repository.name);\r
- try {\r
- r = repositoryResolver.open(null, repository.name);\r
- } catch (RepositoryNotFoundException e) {\r
- logger.error("Repository not found", e);\r
- } catch (ServiceNotAuthorizedException e) {\r
- logger.error("Service not authorized", e);\r
- } catch (ServiceNotEnabledException e) {\r
- logger.error("Service not enabled", e);\r
- } catch (ServiceMayNotContinueException e) {\r
- logger.error("Service may not continue", e);\r
- }\r
+ r = getRepository(repository.name);\r
}\r
\r
// update settings\r
this.settings = settings;\r
repositoriesFolder = getRepositoriesFolder();\r
logger.info("Git repositories folder " + repositoriesFolder.getAbsolutePath());\r
- repositoryResolver = new FileResolver<Void>(repositoriesFolder, true);\r
\r
// calculate repository list settings checksum for future config changes\r
repositoryListSettingsChecksum.set(getRepositoryListSettingsChecksum());\r