| | |
| | | import java.util.Collection; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import java.util.Map; |
| | | import java.util.TimeZone; |
| | | |
| | |
| | | import org.eclipse.jgit.transport.RefSpec; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import ro.fortsoft.pf4j.PluginState; |
| | | import ro.fortsoft.pf4j.PluginWrapper; |
| | | import ro.fortsoft.pf4j.Version; |
| | | |
| | | import com.gitblit.Constants; |
| | | import com.gitblit.Constants.AccessPermission; |
| | |
| | | import com.gitblit.models.GitClientApplication; |
| | | import com.gitblit.models.Mailing; |
| | | import com.gitblit.models.Metric; |
| | | import com.gitblit.models.PluginRegistry.InstallState; |
| | | import com.gitblit.models.PluginRegistry.PluginRegistration; |
| | | import com.gitblit.models.PluginRegistry.PluginRelease; |
| | | import com.gitblit.models.ProjectModel; |
| | | import com.gitblit.models.RegistrantAccessPermission; |
| | | import com.gitblit.models.RepositoryModel; |
| | |
| | | import com.gitblit.models.TeamModel; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.tickets.ITicketService; |
| | | import com.gitblit.transport.ssh.SshSession; |
| | | import com.gitblit.transport.ssh.IPublicKeyManager; |
| | | import com.gitblit.transport.ssh.SshKey; |
| | | import com.gitblit.utils.ArrayUtils; |
| | | import com.gitblit.utils.XssFilter; |
| | | import com.gitblit.utils.HttpUtils; |
| | | import com.gitblit.utils.JsonUtils; |
| | | import com.gitblit.utils.ObjectCache; |
| | |
| | | |
| | | protected final IRuntimeManager runtimeManager; |
| | | |
| | | protected final IPluginManager pluginManager; |
| | | |
| | | protected final INotificationManager notificationManager; |
| | | |
| | | protected final IUserManager userManager; |
| | | |
| | | protected final IAuthenticationManager authenticationManager; |
| | | |
| | | protected final IPublicKeyManager publicKeyManager; |
| | | |
| | | protected final IRepositoryManager repositoryManager; |
| | | |
| | |
| | | |
| | | public GitblitManager( |
| | | IRuntimeManager runtimeManager, |
| | | IPluginManager pluginManager, |
| | | INotificationManager notificationManager, |
| | | IUserManager userManager, |
| | | IAuthenticationManager authenticationManager, |
| | | IPublicKeyManager publicKeyManager, |
| | | IRepositoryManager repositoryManager, |
| | | IProjectManager projectManager, |
| | | IFederationManager federationManager) { |
| | | |
| | | this.settings = runtimeManager.getSettings(); |
| | | this.runtimeManager = runtimeManager; |
| | | this.pluginManager = pluginManager; |
| | | this.notificationManager = notificationManager; |
| | | this.userManager = userManager; |
| | | this.authenticationManager = authenticationManager; |
| | | this.publicKeyManager = publicKeyManager; |
| | | this.repositoryManager = repositoryManager; |
| | | this.projectManager = projectManager; |
| | | this.federationManager = federationManager; |
| | |
| | | RepositoryModel cloneModel = repository.cloneAs(cloneName); |
| | | // owner has REWIND/RW+ permissions |
| | | cloneModel.addOwner(user.username); |
| | | |
| | | // ensure initial access restriction of the fork |
| | | // is not lower than the source repository (issue-495/ticket-167) |
| | | if (repository.accessRestriction.exceeds(cloneModel.accessRestriction)) { |
| | | cloneModel.accessRestriction = repository.accessRestriction; |
| | | } |
| | | |
| | | repositoryManager.updateRepositoryModel(cloneName, cloneModel, false); |
| | | |
| | | // add the owner of the source repository to the clone's access list |
| | |
| | | repositoryManager.updateRepositoryModel(model.name, model, false); |
| | | } |
| | | } |
| | | |
| | | // rename the user's ssh public keystore |
| | | getPublicKeyManager().renameUser(username, user.username); |
| | | } |
| | | if (!userManager.updateUserModel(username, user)) { |
| | | throw new GitBlitException("Failed to update user!"); |
| | |
| | | // no user definitions, use system definitions |
| | | if (!clientApplications.hasCurrent("system", new Date(0))) { |
| | | try { |
| | | InputStream is = getClass().getResourceAsStream("/clientapps.json"); |
| | | InputStream is = GitblitManager.class.getResourceAsStream("/clientapps.json"); |
| | | Collection<GitClientApplication> clients = readClientApplications(is); |
| | | is.close(); |
| | | if (clients != null) { |
| | |
| | | // Read bundled Gitblit properties to extract setting descriptions. |
| | | // This copy is pristine and only used for populating the setting |
| | | // models map. |
| | | InputStream is = getClass().getResourceAsStream("/reference.properties"); |
| | | InputStream is = GitblitManager.class.getResourceAsStream("/reference.properties"); |
| | | BufferedReader propertiesReader = new BufferedReader(new InputStreamReader(is)); |
| | | StringBuilder description = new StringBuilder(); |
| | | SettingModel setting = new SettingModel(); |
| | |
| | | throw new RuntimeException("This class does not have a ticket service!"); |
| | | } |
| | | |
| | | @Override |
| | | public IPublicKeyManager getPublicKeyManager() { |
| | | return publicKeyManager; |
| | | } |
| | | |
| | | /* |
| | | * ISTOREDSETTINGS |
| | | * |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean isServingHTTP() { |
| | | return runtimeManager.isServingHTTP(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isServingGIT() { |
| | | return runtimeManager.isServingGIT(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isServingSSH() { |
| | | return runtimeManager.isServingSSH(); |
| | | } |
| | | |
| | | @Override |
| | | public TimeZone getTimezone() { |
| | | return runtimeManager.getTimezone(); |
| | | } |
| | | |
| | | @Override |
| | | public Locale getLocale() { |
| | | return runtimeManager.getLocale(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return runtimeManager.getStatus(); |
| | | } |
| | | |
| | | @Override |
| | | public XssFilter getXssFilter() { |
| | | return runtimeManager.getXssFilter(); |
| | | } |
| | | |
| | | /* |
| | | * NOTIFICATION MANAGER |
| | | */ |
| | | |
| | | @Override |
| | | public boolean isSendingMail() { |
| | | return notificationManager.isSendingMail(); |
| | | } |
| | | |
| | | @Override |
| | | public void sendMailToAdministrators(String subject, String message) { |
| | |
| | | } |
| | | return user; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public UserModel authenticate(SshSession sshSession) { |
| | | return authenticationManager.authenticate(sshSession); |
| | | public UserModel authenticate(String username, SshKey key) { |
| | | return authenticationManager.authenticate(username, key); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public UserModel authenticate(HttpServletRequest httpRequest, boolean requiresCertificate) { |
| | | UserModel user = authenticationManager.authenticate(httpRequest, requiresCertificate); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void resetRepositoryCache(String repositoryName) { |
| | | repositoryManager.resetRepositoryCache(repositoryName); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getRepositoryList() { |
| | | return repositoryManager.getRepositoryList(); |
| | | } |
| | |
| | | @Override |
| | | public void updateConfiguration(Repository r, RepositoryModel repository) { |
| | | repositoryManager.updateConfiguration(r, repository); |
| | | } |
| | | |
| | | @Override |
| | | public boolean canDelete(RepositoryModel model) { |
| | | return repositoryManager.canDelete(model); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public boolean isIdle(Repository repository) { |
| | | return repositoryManager.isIdle(repository); |
| | | } |
| | | |
| | | /* |
| | | * PLUGIN MANAGER |
| | | */ |
| | | |
| | | @Override |
| | | public Version getSystemVersion() { |
| | | return pluginManager.getSystemVersion(); |
| | | } |
| | | |
| | | @Override |
| | | public void startPlugins() { |
| | | pluginManager.startPlugins(); |
| | | } |
| | | |
| | | @Override |
| | | public void stopPlugins() { |
| | | pluginManager.stopPlugins(); |
| | | } |
| | | |
| | | @Override |
| | | public List<PluginWrapper> getPlugins() { |
| | | return pluginManager.getPlugins(); |
| | | } |
| | | |
| | | @Override |
| | | public PluginWrapper getPlugin(String pluginId) { |
| | | return pluginManager.getPlugin(pluginId); |
| | | } |
| | | |
| | | @Override |
| | | public List<Class<?>> getExtensionClasses(String pluginId) { |
| | | return pluginManager.getExtensionClasses(pluginId); |
| | | } |
| | | |
| | | @Override |
| | | public <T> List<T> getExtensions(Class<T> clazz) { |
| | | return pluginManager.getExtensions(clazz); |
| | | } |
| | | |
| | | @Override |
| | | public PluginWrapper whichPlugin(Class<?> clazz) { |
| | | return pluginManager.whichPlugin(clazz); |
| | | } |
| | | |
| | | @Override |
| | | public PluginState startPlugin(String pluginId) { |
| | | return pluginManager.startPlugin(pluginId); |
| | | } |
| | | |
| | | @Override |
| | | public PluginState stopPlugin(String pluginId) { |
| | | return pluginManager.stopPlugin(pluginId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean disablePlugin(String pluginId) { |
| | | return pluginManager.disablePlugin(pluginId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean enablePlugin(String pluginId) { |
| | | return pluginManager.enablePlugin(pluginId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean uninstallPlugin(String pluginId) { |
| | | return pluginManager.uninstallPlugin(pluginId); |
| | | } |
| | | |
| | | @Override |
| | | public boolean refreshRegistry(boolean verifyChecksum) { |
| | | return pluginManager.refreshRegistry(verifyChecksum); |
| | | } |
| | | |
| | | @Override |
| | | public boolean installPlugin(String url, boolean verifyChecksum) throws IOException { |
| | | return pluginManager.installPlugin(url, verifyChecksum); |
| | | } |
| | | |
| | | @Override |
| | | public boolean upgradePlugin(String pluginId, String url, boolean verifyChecksum) throws IOException { |
| | | return pluginManager.upgradePlugin(pluginId, url, verifyChecksum); |
| | | } |
| | | |
| | | @Override |
| | | public List<PluginRegistration> getRegisteredPlugins() { |
| | | return pluginManager.getRegisteredPlugins(); |
| | | } |
| | | |
| | | @Override |
| | | public List<PluginRegistration> getRegisteredPlugins(InstallState state) { |
| | | return pluginManager.getRegisteredPlugins(state); |
| | | } |
| | | |
| | | @Override |
| | | public PluginRegistration lookupPlugin(String pluginId) { |
| | | return pluginManager.lookupPlugin(pluginId); |
| | | } |
| | | |
| | | @Override |
| | | public PluginRelease lookupRelease(String pluginId, String version) { |
| | | return pluginManager.lookupRelease(pluginId, version); |
| | | } |
| | | } |