From a502d96a860456ec5e8c96761db70f7cabb74751 Mon Sep 17 00:00:00 2001 From: Paul Martin <paul@paulsputer.com> Date: Sat, 30 Apr 2016 04:19:14 -0400 Subject: [PATCH] Merge pull request #1073 from gitblit/1062-DocEditorUpdates --- src/main/java/com/gitblit/client/GitblitClient.java | 81 ++++++++++++++++------------------------ 1 files changed, 32 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/gitblit/client/GitblitClient.java b/src/main/java/com/gitblit/client/GitblitClient.java index 427f45b..aecf81f 100644 --- a/src/main/java/com/gitblit/client/GitblitClient.java +++ b/src/main/java/com/gitblit/client/GitblitClient.java @@ -33,10 +33,6 @@ import com.gitblit.Constants.AuthorizationControl; import com.gitblit.Constants.PermissionType; import com.gitblit.Constants.RegistrantType; -import com.gitblit.GitBlitException.ForbiddenException; -import com.gitblit.GitBlitException.NotAllowedException; -import com.gitblit.GitBlitException.UnauthorizedException; -import com.gitblit.GitBlitException.UnknownRequestException; import com.gitblit.Keys; import com.gitblit.models.FederationModel; import com.gitblit.models.FeedEntryModel; @@ -55,9 +51,9 @@ /** * GitblitClient is a object that retrieves data from a Gitblit server, caches * it for local operations, and allows updating or creating Gitblit objects. - * + * * @author James Moger - * + * */ public class GitblitClient implements Serializable { @@ -119,34 +115,19 @@ refreshRepositories(); refreshSubscribedFeeds(0); - try { - // credentials may not have administrator access - // or server may have disabled rpc management - refreshUsers(); - if (protocolVersion > 1) { - refreshTeams(); - } - allowManagement = true; - } catch (UnauthorizedException e) { - } catch (ForbiddenException e) { - } catch (NotAllowedException e) { - } catch (UnknownRequestException e) { - } catch (IOException e) { - e.printStackTrace(); + // credentials may not have administrator access + // or server may have disabled rpc management + refreshUsers(); + if (protocolVersion > 1) { + refreshTeams(); } + allowManagement = true; - try { - // credentials may not have administrator access - // or server may have disabled rpc administration - refreshStatus(); - allowAdministration = true; - } catch (UnauthorizedException e) { - } catch (ForbiddenException e) { - } catch (NotAllowedException e) { - } catch (UnknownRequestException e) { - } catch (IOException e) { - e.printStackTrace(); - } + // credentials may not have administrator access + // or server may have disabled rpc administration + refreshStatus(); + allowAdministration = true; + } public int getProtocolVersion() { @@ -191,7 +172,7 @@ return sb.toString(); } } - + public AccessRestrictionType getDefaultAccessRestriction() { String restriction = "PUSH"; if (settings.hasKey(Keys.git.defaultAccessRestriction)) { @@ -211,7 +192,7 @@ /** * Returns the list of pre-receive scripts the repository inherited from the * global settings and team affiliations. - * + * * @param repository * if null only the globally specified scripts are returned * @return a list of scripts @@ -243,7 +224,7 @@ * Returns the list of all available Groovy pre-receive push hook scripts * that are not already inherited by the repository. Script files must have * .groovy extension - * + * * @param repository * optional parameter * @return list of available hook scripts @@ -253,9 +234,11 @@ // create list of available scripts by excluding inherited scripts List<String> scripts = new ArrayList<String>(); - for (String script : settings.pushScripts) { - if (!inherited.contains(script)) { - scripts.add(script); + if (!ArrayUtils.isEmpty(settings.pushScripts)) { + for (String script : settings.pushScripts) { + if (!inherited.contains(script)) { + scripts.add(script); + } } } return scripts; @@ -264,7 +247,7 @@ /** * Returns the list of post-receive scripts the repository inherited from * the global settings and team affiliations. - * + * * @param repository * if null only the globally specified scripts are returned * @return a list of scripts @@ -295,7 +278,7 @@ * Returns the list of unused Groovy post-receive push hook scripts that are * not already inherited by the repository. Script files must have .groovy * extension - * + * * @param repository * optional parameter * @return list of available hook scripts @@ -305,7 +288,7 @@ // create list of available scripts by excluding inherited scripts List<String> scripts = new ArrayList<String>(); - if (!ArrayUtils.isEmpty(settings.pushScripts)) { + if (!ArrayUtils.isEmpty(settings.pushScripts)) { for (String script : settings.pushScripts) { if (!inherited.contains(script)) { scripts.add(script); @@ -478,7 +461,7 @@ public List<UserModel> getUsers() { return allUsers; } - + public UserModel getUser(String username) { for (UserModel user : getUsers()) { if (user.username.equalsIgnoreCase(username)) { @@ -506,11 +489,11 @@ } return usernames; } - + /** * Returns the effective list of permissions for this user, taking into account * team memberships, ownerships. - * + * * @param user * @return the effective list of permissions for the user */ @@ -541,12 +524,12 @@ set.add(rp); } } - + List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>(set); Collections.sort(list); return list; } - + public List<RegistrantAccessPermission> getUserAccessPermissions(RepositoryModel repository) { List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>(); if (AccessRestrictionType.NONE.equals(repository.accessRestriction)) { @@ -593,7 +576,7 @@ } return teamnames; } - + public List<RegistrantAccessPermission> getTeamAccessPermissions(RepositoryModel repository) { List<RegistrantAccessPermission> list = new ArrayList<RegistrantAccessPermission>(); for (TeamModel team : allTeams) { @@ -626,7 +609,7 @@ public List<RepositoryModel> getRepositories() { return allRepositories; } - + public RepositoryModel getRepository(String name) { for (RepositoryModel repository : allRepositories) { if (repository.name.equalsIgnoreCase(name)) { @@ -682,7 +665,7 @@ public boolean deleteRepository(RepositoryModel repository) throws IOException { return RpcUtils.deleteRepository(repository, url, account, password); } - + public boolean clearRepositoryCache() throws IOException { return RpcUtils.clearRepositoryCache(url, account, password); } -- Gitblit v1.9.1