James Moger
2011-10-23 fe326255202dcfac8b0991ca9d28e3cf4bcc4fe6
src/com/gitblit/client/GitblitClient.java
File was renamed from src/com/gitblit/client/GitblitModel.java
@@ -23,14 +23,23 @@
import java.util.Map;
import com.gitblit.GitBlitException.ForbiddenException;
import com.gitblit.IStoredSettings;
import com.gitblit.GitBlitException.UnauthorizedException;
import com.gitblit.Keys;
import com.gitblit.models.FederationModel;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.ServerSettings;
import com.gitblit.models.ServerStatus;
import com.gitblit.models.UserModel;
import com.gitblit.utils.RpcUtils;
public class GitblitModel implements Serializable {
/**
 * 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 {
   private static final long serialVersionUID = 1L;
@@ -39,10 +48,12 @@
   public final String account;
   private final char[] password;
   private volatile boolean allowManagement;
   private volatile boolean isAdmin;
   private volatile boolean allowAdministration;
   private volatile IStoredSettings settings;
   private volatile ServerSettings settings;
   private final List<RepositoryModel> allRepositories;
@@ -50,7 +61,9 @@
   private final List<FederationModel> federationRegistrations;
   public GitblitModel(String url, String account, char[] password) {
   private ServerStatus status;
   public GitblitClient(String url, String account, char[] password) {
      this.url = url;
      this.account = account;
      this.password = password;
@@ -64,26 +77,48 @@
      refreshRepositories();
      try {
         settings = RpcUtils.getSettings(url, account, password);
         refreshUsers();
         refreshFederationRegistrations();
         isAdmin = true;
         allowManagement = true;
      } catch (UnauthorizedException e) {
      } catch (ForbiddenException e) {
      } catch (IOException e) {
         System.err.println(e.getMessage());
      }
      try {
         settings = RpcUtils.getSettings(url, account, password);
         status = RpcUtils.getStatus(url, account, password);
         allowAdministration = true;
      } catch (UnauthorizedException e) {
      } catch (ForbiddenException e) {
      } catch (IOException e) {
         System.err.println(e.getMessage());
      }
   }
   public boolean allowAdmin() {
      return isAdmin;
   public boolean allowManagement() {
      return allowManagement;
   }
   public boolean allowAdministration() {
      return allowAdministration;
   }
   public boolean isOwner(RepositoryModel model) {
      return account.equalsIgnoreCase(model.owner);
      return account != null && account.equalsIgnoreCase(model.owner);
   }
   public IStoredSettings getSettings() {
   public ServerSettings getSettings() {
      return settings;
   }
   public ServerStatus getStatus() {
      return status;
   }
   public String getSettingDescription(String key) {
      return settings.get(key).description;
   }
   public List<RepositoryModel> refreshRepositories() throws IOException {
@@ -133,7 +168,7 @@
   }
   public List<String> getFederationSets() {
      return settings.getStrings(Keys.federation.sets);
      return settings.get(Keys.federation.sets).getStrings();
   }
   public List<RepositoryModel> getRepositories() {