showReadme = false\r
federationStrategy = FEDERATE_THIS\r
isFederated = false\r
+ skipSizeCalculation = false\r
federationSets = \r
\r
#### Repository Names\r
<tr><td>LIST_FEDERATION_RESULTS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List<FederationModel></td></tr>\r
<tr><td>LIST_FEDERATION_PROPOSALS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List<FederationProposal></td></tr>\r
<tr><td>LIST_FEDERATION_SETS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List<FederationSet></td></tr>\r
-<tr><td>LIST_SETTINGS</td><td>-</td><td><em>admin</em></td><td>-</td><td>Map<String, SettingModel></td></tr>\r
+<tr><td>LIST_SETTINGS</td><td>-</td><td><em>admin</em></td><td>-</td><td>ServerSettings (see example below)</td></tr>\r
+<tr><td>LIST_STATUS</td><td>-</td><td><em>admin</em></td><td>-</td><td>ServerStatus (see example below)</td></tr>\r
</table>\r
\r
### RPC/HTTP Response Codes\r
\r
This particular project should not be difficult as the only external dependency for `com.gitblit.utils.RpcUtils` is [google-gson](http://google-gson.googlecode.com) which is already a dependency of the EGit/GitHub Mylyn feature.\r
\r
+One proposal from the EGit team is to define a common JSON RPC method for enumeration of repositories which can be implemented by Git hosts. The EGit team would then implement the UI and the client-side enumeration code. This idea was raised as part of this [feature request for EGit](https://bugs.eclipse.org/bugs/show_bug.cgi?id=361251).\r
+\r
Currently this project is in the planning stage.\r
\r
### Example: LIST_REPOSITORIES\r
"libraries"\r
],\r
"isFederated": false,\r
+ "skipSizeCalculation": false,\r
"size": "102 KB"\r
},\r
"https://localhost/git/libraries/smack.git": {\r
"federationStrategy": "FEDERATE_THIS",\r
"federationSets": [],\r
"isFederated": false,\r
+ "skipSizeCalculation": false,\r
"size": "4.8 MB"\r
}\r
}\r
\r
### Example: LIST_SETTINGS\r
**url**: https://localhost/rpc?req=LIST_SETTINGS \r
-**response body**: Map<String, SettingModel>\r
+**response body**: ServerSettings\r
<pre>\r
{\r
- "web.siteName": {\r
- "name": "web.siteName",\r
- "currentValue": "",\r
- "defaultValue": "",\r
- "description": "Gitblit Web Settings\nIf blank Gitblit is displayed.",\r
- "since": "0.5.0",\r
- "caseSensitive": false,\r
- "restartRequired": false,\r
- "spaceDelimited": false\r
- },\r
- "web.summaryCommitCount": {\r
- "name": "web.summaryCommitCount",\r
- "currentValue": "16",\r
- "defaultValue": "16",\r
- "description": "The number of commits to display on the summary page\nValue must exceed 0 else default of 16 is used",\r
- "since": "0.5.0",\r
- "caseSensitive": false,\r
- "restartRequired": false,\r
- "spaceDelimited": false\r
+ "settings": {\r
+ "web.siteName": {\r
+ "name": "web.siteName",\r
+ "currentValue": "",\r
+ "defaultValue": "",\r
+ "description": "Gitblit Web Settings\nIf blank Gitblit is displayed.",\r
+ "since": "0.5.0",\r
+ "caseSensitive": false,\r
+ "restartRequired": false,\r
+ "spaceDelimited": false\r
+ },\r
+ "web.summaryCommitCount": {\r
+ "name": "web.summaryCommitCount",\r
+ "currentValue": "16",\r
+ "defaultValue": "16",\r
+ "description": "The number of commits to display on the summary page\nValue must exceed 0 else default of 16 is used",\r
+ "since": "0.5.0",\r
+ "caseSensitive": false,\r
+ "restartRequired": false,\r
+ "spaceDelimited": false\r
+ }\r
}\r
}\r
+</pre>\r
+\r
+### Example: LIST_STATUS\r
+**url**: https://localhost/rpc?req=LIST_STATUS \r
+**response body**: ServerStatus\r
+<pre>\r
+{\r
+ "bootDate": "2011-10-22T12:13:00Z",\r
+ "systemProperties": {\r
+ "file.encoding": "Cp1252",\r
+ "java.home": "C:\\Program Files\\Java\\jdk1.6.0_26\\jre",\r
+ "java.io.tmpdir": "C:\\Users\\JAMESM~1\\AppData\\Local\\Temp\\",\r
+ "java.runtime.name": "Java(TM) SE Runtime Environment",\r
+ "java.runtime.version": "1.6.0_26-b03",\r
+ "java.vendor": "Sun Microsystems Inc.",\r
+ "java.version": "1.6.0_26",\r
+ "java.vm.info": "mixed mode",\r
+ "java.vm.name": "Java HotSpot(TM) 64-Bit Server VM",\r
+ "java.vm.vendor": "Sun Microsystems Inc.",\r
+ "java.vm.version": "20.1-b02",\r
+ "os.arch": "amd64",\r
+ "os.name": "Windows 7",\r
+ "os.version": "6.1"\r
+ },\r
+ "heapAllocated": 128057344,\r
+ "heapFree": 120399168,\r
+ "heapSize": 1899560960\r
+}\r
</pre>
\ No newline at end of file
LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER, LIST_REPOSITORY_MEMBERS,\r
SET_REPOSITORY_MEMBERS, LIST_FEDERATION_REGISTRATIONS, LIST_FEDERATION_RESULTS,\r
LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS, LIST_SETTINGS,\r
- LIST_SERVER_STATUS;\r
+ LIST_STATUS;\r
\r
public static RpcRequest fromName(String name) {\r
for (RpcRequest type : values()) {\r
import java.util.List;\r
import java.util.Map;\r
import java.util.Map.Entry;\r
-import java.util.TreeMap;\r
import java.util.concurrent.ConcurrentHashMap;\r
import java.util.concurrent.Executors;\r
import java.util.concurrent.ScheduledExecutorService;\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.ServerStatus;\r
import com.gitblit.models.SettingModel;\r
+import com.gitblit.models.ServerSettings;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.utils.ByteFormat;\r
import com.gitblit.utils.FederationUtils;\r
\r
private IStoredSettings settings;\r
\r
- private Map<String, SettingModel> settingModels;\r
+ private ServerSettings settingsModel;\r
\r
private ServerStatus serverStatus;\r
\r
/**\r
* Returns the descriptions/comments of the Gitblit config settings.\r
* \r
- * @return Map<String, SettingModel>\r
+ * @return SettingsModel\r
*/\r
- public Map<String, SettingModel> getSettingModels() {\r
+ public ServerSettings getSettingsModel() {\r
// ensure that the current values are updated in the setting models\r
- for (String key : settings.getAllKeys(null)) {\r
- if (settingModels.containsKey(key)) {\r
- settingModels.get(key).currentValue = settings.getString(key, "");\r
- }\r
- }\r
- return settingModels;\r
+ settingsModel.updateCurrentValues(settings);\r
+ return settingsModel;\r
}\r
\r
/**\r
* \r
* @return Map<String, SettingModel>\r
*/\r
- private Map<String, SettingModel> loadSettingModels() {\r
- Map<String, SettingModel> map = new TreeMap<String, SettingModel>();\r
+ private ServerSettings loadSettingModels() {\r
+ ServerSettings settingsModel = new ServerSettings();\r
try {\r
// Read bundled Gitblit properties to extract setting descriptions.\r
// This copy is pristine and only used for populating the setting\r
setting.defaultValue = kvp[1].trim();\r
setting.currentValue = setting.defaultValue;\r
setting.description = description.toString().trim();\r
- map.put(key, setting);\r
+ settingsModel.add(setting);\r
description.setLength(0);\r
setting = new SettingModel();\r
}\r
} catch (IOException e) {\r
logger.error("Failed to load resource copy of gitblit.properties");\r
}\r
- return map;\r
+ return settingsModel;\r
}\r
\r
/**\r
@Override\r
public void contextInitialized(ServletContextEvent contextEvent) {\r
servletContext = contextEvent.getServletContext();\r
- settingModels = loadSettingModels();\r
+ settingsModel = loadSettingModels();\r
if (settings == null) {\r
// Gitblit WAR is running in a servlet container\r
WebXmlSettings webxmlSettings = new WebXmlSettings(contextEvent.getServletContext());\r
}\r
} else if (RpcRequest.LIST_SETTINGS.equals(reqType)) {\r
// return the server's settings\r
- result = GitBlit.self().getSettingModels();\r
- } else if (RpcRequest.LIST_SERVER_STATUS.equals(reqType)) {\r
+ result = GitBlit.self().getSettingsModel();\r
+ } else if (RpcRequest.LIST_STATUS.equals(reqType)) {\r
// return the server's status information\r
result = GitBlit.self().getStatus();\r
}\r
import java.util.Arrays;\r
import java.util.HashSet;\r
import java.util.List;\r
-import java.util.Map;\r
import java.util.Set;\r
\r
import javax.swing.ImageIcon;\r
import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.Keys;\r
import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.models.SettingModel;\r
+import com.gitblit.models.ServerSettings;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.utils.StringUtils;\r
\r
\r
private final UserModel user;\r
\r
- private final Map<String, SettingModel> settings;\r
+ private final ServerSettings settings;\r
\r
private boolean isCreate;\r
- \r
+\r
private boolean canceled = true;\r
\r
private JTextField usernameField;\r
\r
private Set<String> usernames;\r
\r
- public EditUserDialog(Map<String, SettingModel> settings) {\r
+ public EditUserDialog(ServerSettings settings) {\r
this(new UserModel(""), settings);\r
this.isCreate = true;\r
- setTitle(Translation.get("gb.newUser")); \r
+ setTitle(Translation.get("gb.newUser"));\r
}\r
\r
- public EditUserDialog(UserModel anUser, Map<String, SettingModel> settings) {\r
+ public EditUserDialog(UserModel anUser, ServerSettings settings) {\r
super();\r
this.user = new UserModel("");\r
this.settings = settings;\r
setTitle(Translation.get("gb.edit") + ": " + anUser.username);\r
setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());\r
}\r
- \r
+\r
@Override\r
protected JRootPane createRootPane() {\r
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);\r
}\r
char[] pw = passwordField.getPassword();\r
if (pw == null || pw.length < minLength) {\r
- error(MessageFormat.format(\r
- "Password is too short. Minimum length is {0} characters.", minLength));\r
+ error(MessageFormat.format("Password is too short. Minimum length is {0} characters.",\r
+ minLength));\r
return false;\r
}\r
char[] cpw = confirmPasswordField.getPassword();\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.client;\r
+\r
+import java.io.IOException;\r
+import java.io.Serializable;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import com.gitblit.GitBlitException.ForbiddenException;\r
+import com.gitblit.GitBlitException.UnauthorizedException;\r
+import com.gitblit.Keys;\r
+import com.gitblit.models.FederationModel;\r
+import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.ServerSettings;\r
+import com.gitblit.models.ServerStatus;\r
+import com.gitblit.models.UserModel;\r
+import com.gitblit.utils.RpcUtils;\r
+\r
+/**\r
+ * GitblitClient is a object that retrieves data from a Gitblit server, caches\r
+ * it for local operations, and allows updating or creating Gitblit objects.\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class GitblitClient implements Serializable {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ public final String url;\r
+\r
+ public final String account;\r
+\r
+ private final char[] password;\r
+\r
+ private volatile boolean isAdmin;\r
+\r
+ private volatile ServerSettings settings;\r
+\r
+ private final List<RepositoryModel> allRepositories;\r
+\r
+ private final List<UserModel> allUsers;\r
+\r
+ private final List<FederationModel> federationRegistrations;\r
+\r
+ private ServerStatus status;\r
+\r
+ public GitblitClient(String url, String account, char[] password) {\r
+ this.url = url;\r
+ this.account = account;\r
+ this.password = password;\r
+\r
+ this.allUsers = new ArrayList<UserModel>();\r
+ this.allRepositories = new ArrayList<RepositoryModel>();\r
+ this.federationRegistrations = new ArrayList<FederationModel>();\r
+ }\r
+\r
+ public void login() throws IOException {\r
+ refreshRepositories();\r
+\r
+ try {\r
+ settings = RpcUtils.getSettings(url, account, password);\r
+ status = RpcUtils.getStatus(url, account, password);\r
+ refreshUsers();\r
+ isAdmin = true;\r
+ } catch (UnauthorizedException e) {\r
+ } catch (ForbiddenException e) {\r
+ } catch (IOException e) {\r
+ System.err.println(e.getMessage());\r
+ }\r
+ }\r
+\r
+ public boolean allowAdmin() {\r
+ return isAdmin;\r
+ }\r
+\r
+ public boolean isOwner(RepositoryModel model) {\r
+ return account != null && account.equalsIgnoreCase(model.owner);\r
+ }\r
+\r
+ public ServerSettings getSettings() {\r
+ return settings;\r
+ }\r
+\r
+ public ServerStatus getStatus() {\r
+ return status;\r
+ }\r
+\r
+ public String getSettingDescription(String key) {\r
+ return settings.get(key).description;\r
+ }\r
+\r
+ public List<RepositoryModel> refreshRepositories() throws IOException {\r
+ Map<String, RepositoryModel> repositories = RpcUtils\r
+ .getRepositories(url, account, password);\r
+ allRepositories.clear();\r
+ allRepositories.addAll(repositories.values());\r
+ Collections.sort(allRepositories);\r
+ return allRepositories;\r
+ }\r
+\r
+ public List<UserModel> refreshUsers() throws IOException {\r
+ List<UserModel> users = RpcUtils.getUsers(url, account, password);\r
+ allUsers.clear();\r
+ allUsers.addAll(users);\r
+ return allUsers;\r
+ }\r
+\r
+ public List<FederationModel> refreshFederationRegistrations() throws IOException {\r
+ List<FederationModel> list = RpcUtils.getFederationRegistrations(url, account, password);\r
+ federationRegistrations.clear();\r
+ federationRegistrations.addAll(list);\r
+ return federationRegistrations;\r
+ }\r
+\r
+ public List<UserModel> getUsers() {\r
+ return allUsers;\r
+ }\r
+\r
+ public List<String> getUsernames() {\r
+ List<String> usernames = new ArrayList<String>();\r
+ for (UserModel user : this.allUsers) {\r
+ usernames.add(user.username);\r
+ }\r
+ Collections.sort(usernames);\r
+ return usernames;\r
+ }\r
+\r
+ public List<String> getPermittedUsernames(RepositoryModel repository) {\r
+ List<String> usernames = new ArrayList<String>();\r
+ for (UserModel user : this.allUsers) {\r
+ if (user.repositories.contains(repository.name)) {\r
+ usernames.add(user.username);\r
+ }\r
+ }\r
+ return usernames;\r
+ }\r
+\r
+ public List<String> getFederationSets() {\r
+ return settings.get(Keys.federation.sets).getStrings();\r
+ }\r
+\r
+ public List<RepositoryModel> getRepositories() {\r
+ return allRepositories;\r
+ }\r
+\r
+ public boolean createRepository(RepositoryModel repository, List<String> permittedUsers)\r
+ throws IOException {\r
+ boolean success = true;\r
+ success &= RpcUtils.createRepository(repository, url, account, password);\r
+ if (permittedUsers.size() > 0) {\r
+ // if new repository has named members, set them\r
+ success &= RpcUtils.setRepositoryMembers(repository, permittedUsers, url, account,\r
+ password);\r
+ }\r
+ return success;\r
+ }\r
+\r
+ public boolean updateRepository(String name, RepositoryModel repository,\r
+ List<String> permittedUsers) throws IOException {\r
+ boolean success = true;\r
+ success &= RpcUtils.updateRepository(name, repository, url, account, password);\r
+ // always set the repository members\r
+ success &= RpcUtils\r
+ .setRepositoryMembers(repository, permittedUsers, url, account, password);\r
+ return success;\r
+ }\r
+\r
+ public boolean deleteRepository(RepositoryModel repository) throws IOException {\r
+ return RpcUtils.deleteRepository(repository, url, account, password);\r
+ }\r
+\r
+ public boolean createUser(UserModel user) throws IOException {\r
+ return RpcUtils.createUser(user, url, account, password);\r
+ }\r
+\r
+ public boolean updateUser(String name, UserModel user) throws IOException {\r
+ return RpcUtils.updateUser(name, user, url, account, password);\r
+ }\r
+\r
+ public boolean deleteUser(UserModel user) throws IOException {\r
+ return RpcUtils.deleteUser(user, url, account, password);\r
+ }\r
+}\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.client;\r
-\r
-import java.io.IOException;\r
-import java.io.Serializable;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import com.gitblit.GitBlitException.ForbiddenException;\r
-import com.gitblit.GitBlitException.UnauthorizedException;\r
-import com.gitblit.Keys;\r
-import com.gitblit.models.FederationModel;\r
-import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.models.ServerStatus;\r
-import com.gitblit.models.SettingModel;\r
-import com.gitblit.models.UserModel;\r
-import com.gitblit.utils.RpcUtils;\r
-\r
-public class GitblitModel implements Serializable {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- public final String url;\r
-\r
- public final String account;\r
-\r
- private final char[] password;\r
-\r
- private volatile boolean isAdmin;\r
-\r
- private volatile Map<String, SettingModel> settings;\r
-\r
- private final List<RepositoryModel> allRepositories;\r
-\r
- private final List<UserModel> allUsers;\r
-\r
- private final List<FederationModel> federationRegistrations;\r
-\r
- private ServerStatus status;\r
-\r
- public GitblitModel(String url, String account, char[] password) {\r
- this.url = url;\r
- this.account = account;\r
- this.password = password;\r
-\r
- this.allUsers = new ArrayList<UserModel>();\r
- this.allRepositories = new ArrayList<RepositoryModel>();\r
- this.federationRegistrations = new ArrayList<FederationModel>();\r
- }\r
-\r
- public void login() throws IOException {\r
- refreshRepositories();\r
-\r
- try {\r
- settings = RpcUtils.getSettings(url, account, password);\r
- status = RpcUtils.getStatus(url, account, password);\r
- refreshUsers();\r
- isAdmin = true;\r
- } catch (UnauthorizedException e) {\r
- } catch (ForbiddenException e) {\r
- } catch (IOException e) {\r
- System.err.println(e.getMessage());\r
- }\r
- }\r
-\r
- public boolean allowAdmin() {\r
- return isAdmin;\r
- }\r
-\r
- public boolean isOwner(RepositoryModel model) {\r
- return account != null && account.equalsIgnoreCase(model.owner);\r
- }\r
-\r
- public Map<String, SettingModel> getSettings() {\r
- return settings;\r
- }\r
-\r
- public String getSettingDescription(String key) {\r
- return settings.get(key).description;\r
- }\r
-\r
- public List<RepositoryModel> refreshRepositories() throws IOException {\r
- Map<String, RepositoryModel> repositories = RpcUtils\r
- .getRepositories(url, account, password);\r
- allRepositories.clear();\r
- allRepositories.addAll(repositories.values());\r
- Collections.sort(allRepositories);\r
- return allRepositories;\r
- }\r
-\r
- public List<UserModel> refreshUsers() throws IOException {\r
- List<UserModel> users = RpcUtils.getUsers(url, account, password);\r
- allUsers.clear();\r
- allUsers.addAll(users);\r
- return allUsers;\r
- }\r
-\r
- public List<FederationModel> refreshFederationRegistrations() throws IOException {\r
- List<FederationModel> list = RpcUtils.getFederationRegistrations(url, account, password);\r
- federationRegistrations.clear();\r
- federationRegistrations.addAll(list);\r
- return federationRegistrations;\r
- }\r
-\r
- public List<UserModel> getUsers() {\r
- return allUsers;\r
- }\r
-\r
- public List<String> getUsernames() {\r
- List<String> usernames = new ArrayList<String>();\r
- for (UserModel user : this.allUsers) {\r
- usernames.add(user.username);\r
- }\r
- Collections.sort(usernames);\r
- return usernames;\r
- }\r
-\r
- public List<String> getPermittedUsernames(RepositoryModel repository) {\r
- List<String> usernames = new ArrayList<String>();\r
- for (UserModel user : this.allUsers) {\r
- if (user.repositories.contains(repository.name)) {\r
- usernames.add(user.username);\r
- }\r
- }\r
- return usernames;\r
- }\r
-\r
- public List<String> getFederationSets() {\r
- return settings.get(Keys.federation.sets).getStrings();\r
- }\r
-\r
- public List<RepositoryModel> getRepositories() {\r
- return allRepositories;\r
- }\r
-\r
- public boolean createRepository(RepositoryModel repository, List<String> permittedUsers)\r
- throws IOException {\r
- boolean success = true;\r
- success &= RpcUtils.createRepository(repository, url, account, password);\r
- if (permittedUsers.size() > 0) {\r
- // if new repository has named members, set them\r
- success &= RpcUtils.setRepositoryMembers(repository, permittedUsers, url, account,\r
- password);\r
- }\r
- return success;\r
- }\r
-\r
- public boolean updateRepository(String name, RepositoryModel repository,\r
- List<String> permittedUsers) throws IOException {\r
- boolean success = true;\r
- success &= RpcUtils.updateRepository(name, repository, url, account, password);\r
- // always set the repository members\r
- success &= RpcUtils\r
- .setRepositoryMembers(repository, permittedUsers, url, account, password);\r
- return success;\r
- }\r
-\r
- public boolean deleteRepository(RepositoryModel repository) throws IOException {\r
- return RpcUtils.deleteRepository(repository, url, account, password);\r
- }\r
-\r
- public boolean createUser(UserModel user) throws IOException {\r
- return RpcUtils.createUser(user, url, account, password);\r
- }\r
-\r
- public boolean updateUser(String name, UserModel user) throws IOException {\r
- return RpcUtils.updateUser(name, user, url, account, password);\r
- }\r
-\r
- public boolean deleteUser(UserModel user) throws IOException {\r
- return RpcUtils.deleteUser(user, url, account, password);\r
- }\r
-}\r
\r
private final Insets insets = new Insets(margin, margin, margin, margin);\r
\r
- private GitblitModel gitblit;\r
+ private GitblitClient gitblit;\r
\r
private JTabbedPane tabs;\r
\r
private JTable repositoriesTable;\r
\r
- private RepositoriesModel repositoriesModel;\r
+ private RepositoriesTableModel repositoriesModel;\r
\r
private JTable usersTable;\r
\r
- private UsersModel usersModel;\r
+ private UsersTableModel usersModel;\r
\r
private JTable settingsTable;\r
\r
- private SettingsModel settingsModel;\r
+ private SettingsTableModel settingsModel;\r
\r
private JButton createRepository;\r
\r
\r
private DefaultTableCellRenderer sizeRenderer;\r
\r
- private TableRowSorter<RepositoriesModel> defaultRepositoriesSorter;\r
+ private TableRowSorter<RepositoriesTableModel> defaultRepositoriesSorter;\r
\r
- private TableRowSorter<UsersModel> defaultUsersSorter;\r
+ private TableRowSorter<UsersTableModel> defaultUsersSorter;\r
\r
- private TableRowSorter<SettingsModel> defaultSettingsSorter;\r
+ private TableRowSorter<SettingsTableModel> defaultSettingsSorter;\r
\r
private JButton editRepository;\r
\r
}\r
\r
public GitblitPanel(String url, String account, char[] password) {\r
- this.gitblit = new GitblitModel(url, account, password);\r
+ this.gitblit = new GitblitClient(url, account, password);\r
\r
tabs = new JTabbedPane(JTabbedPane.BOTTOM);\r
tabs.addTab(Translation.get("gb.repositories"), createRepositoriesPanel());\r
ownerRenderer.setForeground(Color.gray);\r
ownerRenderer.setHorizontalAlignment(SwingConstants.CENTER);\r
\r
- repositoriesModel = new RepositoriesModel();\r
- defaultRepositoriesSorter = new TableRowSorter<RepositoriesModel>(repositoriesModel);\r
+ repositoriesModel = new RepositoriesTableModel();\r
+ defaultRepositoriesSorter = new TableRowSorter<RepositoriesTableModel>(repositoriesModel);\r
repositoriesTable = Utils.newTable(repositoriesModel);\r
repositoriesTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
repositoriesTable.setRowSorter(defaultRepositoriesSorter);\r
- repositoriesTable.getRowSorter().toggleSortOrder(RepositoriesModel.Columns.Name.ordinal());\r
+ repositoriesTable.getRowSorter().toggleSortOrder(RepositoriesTableModel.Columns.Name.ordinal());\r
\r
- setRepositoryRenderer(RepositoriesModel.Columns.Name, nameRenderer, -1);\r
- setRepositoryRenderer(RepositoriesModel.Columns.Indicators, typeRenderer, 100);\r
- setRepositoryRenderer(RepositoriesModel.Columns.Owner, ownerRenderer, -1);\r
- setRepositoryRenderer(RepositoriesModel.Columns.Size, sizeRenderer, 60);\r
+ setRepositoryRenderer(RepositoriesTableModel.Columns.Name, nameRenderer, -1);\r
+ setRepositoryRenderer(RepositoriesTableModel.Columns.Indicators, typeRenderer, 100);\r
+ setRepositoryRenderer(RepositoriesTableModel.Columns.Owner, ownerRenderer, -1);\r
+ setRepositoryRenderer(RepositoriesTableModel.Columns.Size, sizeRenderer, 60);\r
\r
repositoriesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {\r
@Override\r
if (selected) {\r
int viewRow = repositoriesTable.getSelectedRow();\r
int modelRow = repositoriesTable.convertRowIndexToModel(viewRow);\r
- RepositoryModel model = ((RepositoriesModel) repositoriesTable.getModel()).list\r
+ RepositoryModel model = ((RepositoriesTableModel) repositoriesTable.getModel()).list\r
.get(modelRow);\r
editRepository.setEnabled(singleSelection\r
&& (gitblit.allowAdmin() || gitblit.isOwner(model)));\r
return repositoriesPanel;\r
}\r
\r
- private void setRepositoryRenderer(RepositoriesModel.Columns col, TableCellRenderer renderer,\r
+ private void setRepositoryRenderer(RepositoriesTableModel.Columns col, TableCellRenderer renderer,\r
int maxWidth) {\r
String name = repositoriesTable.getColumnName(col.ordinal());\r
repositoriesTable.getColumn(name).setCellRenderer(renderer);\r
}\r
});\r
\r
- usersModel = new UsersModel();\r
- defaultUsersSorter = new TableRowSorter<UsersModel>(usersModel);\r
+ usersModel = new UsersTableModel();\r
+ defaultUsersSorter = new TableRowSorter<UsersTableModel>(usersModel);\r
usersTable = Utils.newTable(usersModel);\r
- String name = usersTable.getColumnName(UsersModel.Columns.Name.ordinal());\r
+ String name = usersTable.getColumnName(UsersTableModel.Columns.Name.ordinal());\r
usersTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
usersTable.getColumn(name).setCellRenderer(nameRenderer);\r
usersTable.setRowSorter(defaultUsersSorter);\r
- usersTable.getRowSorter().toggleSortOrder(UsersModel.Columns.Name.ordinal());\r
+ usersTable.getRowSorter().toggleSortOrder(UsersTableModel.Columns.Name.ordinal());\r
usersTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {\r
\r
@Override\r
\r
private JPanel createSettingsPanel() {\r
final SettingPanel settingPanel = new SettingPanel();\r
- settingsModel = new SettingsModel();\r
- defaultSettingsSorter = new TableRowSorter<SettingsModel>(settingsModel);\r
+ settingsModel = new SettingsTableModel();\r
+ defaultSettingsSorter = new TableRowSorter<SettingsTableModel>(settingsModel);\r
settingsTable = Utils.newTable(settingsModel);\r
settingsTable.setDefaultRenderer(SettingModel.class, new SettingCellRenderer());\r
- String name = settingsTable.getColumnName(UsersModel.Columns.Name.ordinal());\r
+ String name = settingsTable.getColumnName(UsersTableModel.Columns.Name.ordinal());\r
settingsTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
settingsTable.getColumn(name).setCellRenderer(nameRenderer);\r
settingsTable.setRowSorter(defaultSettingsSorter);\r
- settingsTable.getRowSorter().toggleSortOrder(SettingsModel.Columns.Name.ordinal());\r
+ settingsTable.getRowSorter().toggleSortOrder(SettingsTableModel.Columns.Name.ordinal());\r
settingsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {\r
\r
@Override\r
repositoriesTable.setRowSorter(defaultRepositoriesSorter);\r
return;\r
}\r
- RowFilter<RepositoriesModel, Object> containsFilter = new RowFilter<RepositoriesModel, Object>() {\r
- public boolean include(Entry<? extends RepositoriesModel, ? extends Object> entry) {\r
+ RowFilter<RepositoriesTableModel, Object> containsFilter = new RowFilter<RepositoriesTableModel, Object>() {\r
+ public boolean include(Entry<? extends RepositoriesTableModel, ? extends Object> entry) {\r
for (int i = entry.getValueCount() - 1; i >= 0; i--) {\r
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {\r
return true;\r
return false;\r
}\r
};\r
- TableRowSorter<RepositoriesModel> sorter = new TableRowSorter<RepositoriesModel>(\r
+ TableRowSorter<RepositoriesTableModel> sorter = new TableRowSorter<RepositoriesTableModel>(\r
repositoriesModel);\r
sorter.setRowFilter(containsFilter);\r
repositoriesTable.setRowSorter(sorter);\r
usersTable.setRowSorter(defaultUsersSorter);\r
return;\r
}\r
- RowFilter<UsersModel, Object> containsFilter = new RowFilter<UsersModel, Object>() {\r
- public boolean include(Entry<? extends UsersModel, ? extends Object> entry) {\r
+ RowFilter<UsersTableModel, Object> containsFilter = new RowFilter<UsersTableModel, Object>() {\r
+ public boolean include(Entry<? extends UsersTableModel, ? extends Object> entry) {\r
for (int i = entry.getValueCount() - 1; i >= 0; i--) {\r
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {\r
return true;\r
return false;\r
}\r
};\r
- TableRowSorter<UsersModel> sorter = new TableRowSorter<UsersModel>(usersModel);\r
+ TableRowSorter<UsersTableModel> sorter = new TableRowSorter<UsersTableModel>(usersModel);\r
sorter.setRowFilter(containsFilter);\r
usersTable.setRowSorter(sorter);\r
}\r
settingsTable.setRowSorter(defaultSettingsSorter);\r
return;\r
}\r
- RowFilter<SettingsModel, Object> containsFilter = new RowFilter<SettingsModel, Object>() {\r
- public boolean include(Entry<? extends SettingsModel, ? extends Object> entry) {\r
+ RowFilter<SettingsTableModel, Object> containsFilter = new RowFilter<SettingsTableModel, Object>() {\r
+ public boolean include(Entry<? extends SettingsTableModel, ? extends Object> entry) {\r
for (int i = entry.getValueCount() - 1; i >= 0; i--) {\r
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {\r
return true;\r
return false;\r
}\r
};\r
- TableRowSorter<SettingsModel> sorter = new TableRowSorter<SettingsModel>(settingsModel);\r
+ TableRowSorter<SettingsTableModel> sorter = new TableRowSorter<SettingsTableModel>(settingsModel);\r
sorter.setRowFilter(containsFilter);\r
settingsTable.setRowSorter(sorter);\r
}\r
\r
private JTable registrationsTable;\r
\r
- private RegistrationsModel model;\r
+ private RegistrationsTableModel model;\r
\r
public RegistrationsDialog(List<GitblitRegistration> registrations,\r
RegistrationListener listener) {\r
\r
private void initialize() {\r
NameRenderer nameRenderer = new NameRenderer();\r
- model = new RegistrationsModel(registrations);\r
+ model = new RegistrationsTableModel(registrations);\r
registrationsTable = Utils.newTable(model);\r
registrationsTable.setRowHeight(nameRenderer.getFont().getSize() + 8);\r
\r
- String id = registrationsTable.getColumnName(RegistrationsModel.Columns.Name.ordinal());\r
+ String id = registrationsTable.getColumnName(RegistrationsTableModel.Columns.Name.ordinal());\r
registrationsTable.getColumn(id).setCellRenderer(nameRenderer);\r
registrationsTable.addMouseListener(new MouseAdapter() {\r
public void mouseClicked(MouseEvent e) {\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.client;\r
-\r
-import java.util.Collections;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import javax.swing.table.AbstractTableModel;\r
-\r
-/**\r
- * Table model of a list of Gitblit server registrations.\r
- * \r
- * @author James Moger\r
- * \r
- */\r
-public class RegistrationsModel extends AbstractTableModel {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- List<GitblitRegistration> list;\r
-\r
- enum Columns {\r
- Name, URL, Last_Login;\r
-\r
- @Override\r
- public String toString() {\r
- return name().replace('_', ' ');\r
- }\r
- }\r
-\r
- public RegistrationsModel(List<GitblitRegistration> list) {\r
- this.list = list;\r
- Collections.sort(this.list);\r
- }\r
-\r
- @Override\r
- public int getRowCount() {\r
- return list.size();\r
- }\r
-\r
- @Override\r
- public int getColumnCount() {\r
- return Columns.values().length;\r
- }\r
-\r
- @Override\r
- public String getColumnName(int column) {\r
- Columns col = Columns.values()[column];\r
- switch (col) {\r
- case Name:\r
- return Translation.get("gb.name");\r
- case URL:\r
- return Translation.get("gb.url");\r
- case Last_Login:\r
- return Translation.get("gb.lastLogin");\r
- }\r
- return "";\r
- }\r
-\r
- /**\r
- * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
- * \r
- * @param columnIndex\r
- * the column being queried\r
- * @return the Object.class\r
- */\r
- public Class<?> getColumnClass(int columnIndex) {\r
- if (columnIndex == Columns.Last_Login.ordinal()) {\r
- return Date.class;\r
- }\r
- return String.class;\r
- }\r
-\r
- @Override\r
- public Object getValueAt(int rowIndex, int columnIndex) {\r
- GitblitRegistration model = list.get(rowIndex);\r
- Columns col = Columns.values()[columnIndex];\r
- switch (col) {\r
- case Name:\r
- return model.name;\r
- case URL:\r
- return model.url;\r
- case Last_Login:\r
- return model.lastLogin;\r
- }\r
- return null;\r
- }\r
-}\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.client;\r
+\r
+import java.util.Collections;\r
+import java.util.Date;\r
+import java.util.List;\r
+\r
+import javax.swing.table.AbstractTableModel;\r
+\r
+/**\r
+ * Table model of a list of Gitblit server registrations.\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class RegistrationsTableModel extends AbstractTableModel {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ List<GitblitRegistration> list;\r
+\r
+ enum Columns {\r
+ Name, URL, Last_Login;\r
+\r
+ @Override\r
+ public String toString() {\r
+ return name().replace('_', ' ');\r
+ }\r
+ }\r
+\r
+ public RegistrationsTableModel(List<GitblitRegistration> list) {\r
+ this.list = list;\r
+ Collections.sort(this.list);\r
+ }\r
+\r
+ @Override\r
+ public int getRowCount() {\r
+ return list.size();\r
+ }\r
+\r
+ @Override\r
+ public int getColumnCount() {\r
+ return Columns.values().length;\r
+ }\r
+\r
+ @Override\r
+ public String getColumnName(int column) {\r
+ Columns col = Columns.values()[column];\r
+ switch (col) {\r
+ case Name:\r
+ return Translation.get("gb.name");\r
+ case URL:\r
+ return Translation.get("gb.url");\r
+ case Last_Login:\r
+ return Translation.get("gb.lastLogin");\r
+ }\r
+ return "";\r
+ }\r
+\r
+ /**\r
+ * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
+ * \r
+ * @param columnIndex\r
+ * the column being queried\r
+ * @return the Object.class\r
+ */\r
+ public Class<?> getColumnClass(int columnIndex) {\r
+ if (columnIndex == Columns.Last_Login.ordinal()) {\r
+ return Date.class;\r
+ }\r
+ return String.class;\r
+ }\r
+\r
+ @Override\r
+ public Object getValueAt(int rowIndex, int columnIndex) {\r
+ GitblitRegistration model = list.get(rowIndex);\r
+ Columns col = Columns.values()[columnIndex];\r
+ switch (col) {\r
+ case Name:\r
+ return model.name;\r
+ case URL:\r
+ return model.url;\r
+ case Last_Login:\r
+ return model.lastLogin;\r
+ }\r
+ return null;\r
+ }\r
+}\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.client;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import javax.swing.table.AbstractTableModel;\r
-\r
-import com.gitblit.models.RepositoryModel;\r
-\r
-/**\r
- * Table model of a list of repositories.\r
- * \r
- * @author James Moger\r
- * \r
- */\r
-public class RepositoriesModel extends AbstractTableModel {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- List<RepositoryModel> list;\r
-\r
- enum Columns {\r
- Name, Description, Owner, Indicators, Last_Change, Size;\r
-\r
- @Override\r
- public String toString() {\r
- return name().replace('_', ' ');\r
- }\r
- }\r
-\r
- public RepositoriesModel() {\r
- this(new ArrayList<RepositoryModel>());\r
- }\r
-\r
- public RepositoriesModel(List<RepositoryModel> repositories) {\r
- this.list = repositories;\r
- Collections.sort(this.list);\r
- }\r
-\r
- @Override\r
- public int getRowCount() {\r
- return list.size();\r
- }\r
-\r
- @Override\r
- public int getColumnCount() {\r
- return Columns.values().length;\r
- }\r
-\r
- @Override\r
- public String getColumnName(int column) {\r
- Columns col = Columns.values()[column];\r
- switch (col) {\r
- case Name:\r
- return Translation.get("gb.name");\r
- case Description:\r
- return Translation.get("gb.description");\r
- case Owner:\r
- return Translation.get("gb.owner");\r
- case Last_Change:\r
- return Translation.get("gb.lastChange");\r
- case Size:\r
- return Translation.get("gb.size");\r
- }\r
- return "";\r
- }\r
-\r
- /**\r
- * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
- * \r
- * @param columnIndex\r
- * the column being queried\r
- * @return the Object.class\r
- */\r
- public Class<?> getColumnClass(int columnIndex) {\r
- Columns col = Columns.values()[columnIndex];\r
- switch (col) {\r
- case Name:\r
- case Indicators:\r
- return RepositoryModel.class;\r
- case Last_Change:\r
- return Date.class;\r
- }\r
- return String.class;\r
- }\r
-\r
- @Override\r
- public Object getValueAt(int rowIndex, int columnIndex) {\r
- RepositoryModel model = list.get(rowIndex);\r
- Columns col = Columns.values()[columnIndex];\r
- switch (col) {\r
- case Name:\r
- return model;\r
- case Description:\r
- return model.description;\r
- case Owner:\r
- return model.owner;\r
- case Indicators:\r
- return model;\r
- case Last_Change:\r
- return model.lastChange;\r
- case Size:\r
- return model.size;\r
- }\r
- return null;\r
- }\r
-}\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.client;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.Date;\r
+import java.util.List;\r
+\r
+import javax.swing.table.AbstractTableModel;\r
+\r
+import com.gitblit.models.RepositoryModel;\r
+\r
+/**\r
+ * Table model of a list of repositories.\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class RepositoriesTableModel extends AbstractTableModel {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ List<RepositoryModel> list;\r
+\r
+ enum Columns {\r
+ Name, Description, Owner, Indicators, Last_Change, Size;\r
+\r
+ @Override\r
+ public String toString() {\r
+ return name().replace('_', ' ');\r
+ }\r
+ }\r
+\r
+ public RepositoriesTableModel() {\r
+ this(new ArrayList<RepositoryModel>());\r
+ }\r
+\r
+ public RepositoriesTableModel(List<RepositoryModel> repositories) {\r
+ this.list = repositories;\r
+ Collections.sort(this.list);\r
+ }\r
+\r
+ @Override\r
+ public int getRowCount() {\r
+ return list.size();\r
+ }\r
+\r
+ @Override\r
+ public int getColumnCount() {\r
+ return Columns.values().length;\r
+ }\r
+\r
+ @Override\r
+ public String getColumnName(int column) {\r
+ Columns col = Columns.values()[column];\r
+ switch (col) {\r
+ case Name:\r
+ return Translation.get("gb.name");\r
+ case Description:\r
+ return Translation.get("gb.description");\r
+ case Owner:\r
+ return Translation.get("gb.owner");\r
+ case Last_Change:\r
+ return Translation.get("gb.lastChange");\r
+ case Size:\r
+ return Translation.get("gb.size");\r
+ }\r
+ return "";\r
+ }\r
+\r
+ /**\r
+ * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
+ * \r
+ * @param columnIndex\r
+ * the column being queried\r
+ * @return the Object.class\r
+ */\r
+ public Class<?> getColumnClass(int columnIndex) {\r
+ Columns col = Columns.values()[columnIndex];\r
+ switch (col) {\r
+ case Name:\r
+ case Indicators:\r
+ return RepositoryModel.class;\r
+ case Last_Change:\r
+ return Date.class;\r
+ }\r
+ return String.class;\r
+ }\r
+\r
+ @Override\r
+ public Object getValueAt(int rowIndex, int columnIndex) {\r
+ RepositoryModel model = list.get(rowIndex);\r
+ Columns col = Columns.values()[columnIndex];\r
+ switch (col) {\r
+ case Name:\r
+ return model;\r
+ case Description:\r
+ return model.description;\r
+ case Owner:\r
+ return model.owner;\r
+ case Indicators:\r
+ return model;\r
+ case Last_Change:\r
+ return model.lastChange;\r
+ case Size:\r
+ return model.size;\r
+ }\r
+ return null;\r
+ }\r
+}\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.client;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import javax.swing.table.AbstractTableModel;\r
-\r
-import com.gitblit.models.SettingModel;\r
-\r
-/**\r
- * Table model of Map<String, SettingModel>.\r
- * \r
- * @author James Moger\r
- * \r
- */\r
-public class SettingsModel extends AbstractTableModel {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- Map<String, SettingModel> settings;\r
-\r
- List<String> keys;\r
-\r
- enum Columns {\r
- Name, Value;\r
-\r
- @Override\r
- public String toString() {\r
- return name().replace('_', ' ');\r
- }\r
- }\r
-\r
- public SettingsModel() {\r
- this(null);\r
- }\r
-\r
- public SettingsModel(Map<String, SettingModel> settings) {\r
- setSettings(settings);\r
- }\r
-\r
- public void setSettings(Map<String, SettingModel> settings) {\r
- this.settings = settings;\r
- if (settings == null) {\r
- keys = new ArrayList<String>();\r
- } else {\r
- keys = new ArrayList<String>(settings.keySet());\r
- Collections.sort(keys);\r
- }\r
- }\r
-\r
- @Override\r
- public int getRowCount() {\r
- return keys.size();\r
- }\r
-\r
- @Override\r
- public int getColumnCount() {\r
- return Columns.values().length;\r
- }\r
-\r
- @Override\r
- public String getColumnName(int column) {\r
- Columns col = Columns.values()[column];\r
- switch (col) {\r
- case Name:\r
- return Translation.get("gb.name");\r
- }\r
- return "";\r
- }\r
-\r
- /**\r
- * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
- * \r
- * @param columnIndex\r
- * the column being queried\r
- * @return the Object.class\r
- */\r
- public Class<?> getColumnClass(int columnIndex) {\r
- if (Columns.Value.ordinal() == columnIndex) {\r
- return SettingModel.class;\r
- }\r
- return String.class;\r
- }\r
-\r
- @Override\r
- public Object getValueAt(int rowIndex, int columnIndex) {\r
- String key = keys.get(rowIndex);\r
- SettingModel setting = settings.get(key);\r
- Columns col = Columns.values()[columnIndex];\r
- switch (col) {\r
- case Name:\r
- return key;\r
- case Value:\r
- return setting;\r
- }\r
- return null;\r
- }\r
-\r
- public SettingModel get(int modelRow) {\r
- String key = keys.get(modelRow);\r
- return settings.get(key);\r
- }\r
-}\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.client;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import javax.swing.table.AbstractTableModel;\r
+\r
+import com.gitblit.models.ServerSettings;\r
+import com.gitblit.models.SettingModel;\r
+\r
+/**\r
+ * Table model of Map<String, SettingModel>.\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class SettingsTableModel extends AbstractTableModel {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ ServerSettings settings;\r
+\r
+ List<String> keys;\r
+\r
+ enum Columns {\r
+ Name, Value;\r
+\r
+ @Override\r
+ public String toString() {\r
+ return name().replace('_', ' ');\r
+ }\r
+ }\r
+\r
+ public SettingsTableModel() {\r
+ this(null);\r
+ }\r
+\r
+ public SettingsTableModel(ServerSettings settings) {\r
+ setSettings(settings);\r
+ }\r
+\r
+ public void setSettings(ServerSettings settings) {\r
+ this.settings = settings;\r
+ if (settings == null) {\r
+ keys = new ArrayList<String>();\r
+ } else {\r
+ keys = new ArrayList<String>(settings.getKeys());\r
+ Collections.sort(keys);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public int getRowCount() {\r
+ return keys.size();\r
+ }\r
+\r
+ @Override\r
+ public int getColumnCount() {\r
+ return Columns.values().length;\r
+ }\r
+\r
+ @Override\r
+ public String getColumnName(int column) {\r
+ Columns col = Columns.values()[column];\r
+ switch (col) {\r
+ case Name:\r
+ return Translation.get("gb.name");\r
+ }\r
+ return "";\r
+ }\r
+\r
+ /**\r
+ * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
+ * \r
+ * @param columnIndex\r
+ * the column being queried\r
+ * @return the Object.class\r
+ */\r
+ public Class<?> getColumnClass(int columnIndex) {\r
+ if (Columns.Value.ordinal() == columnIndex) {\r
+ return SettingModel.class;\r
+ }\r
+ return String.class;\r
+ }\r
+\r
+ @Override\r
+ public Object getValueAt(int rowIndex, int columnIndex) {\r
+ String key = keys.get(rowIndex);\r
+ SettingModel setting = settings.get(key);\r
+ Columns col = Columns.values()[columnIndex];\r
+ switch (col) {\r
+ case Name:\r
+ return key;\r
+ case Value:\r
+ return setting;\r
+ }\r
+ return null;\r
+ }\r
+\r
+ public SettingModel get(int modelRow) {\r
+ String key = keys.get(modelRow);\r
+ return settings.get(key);\r
+ }\r
+}\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.client;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import javax.swing.table.AbstractTableModel;\r
-\r
-import com.gitblit.models.UserModel;\r
-\r
-/**\r
- * Table model of a list of users.\r
- * \r
- * @author James Moger\r
- * \r
- */\r
-public class UsersModel extends AbstractTableModel {\r
-\r
- private static final long serialVersionUID = 1L;\r
-\r
- List<UserModel> list;\r
-\r
- enum Columns {\r
- Name;\r
-\r
- @Override\r
- public String toString() {\r
- return name().replace('_', ' ');\r
- }\r
- }\r
-\r
- public UsersModel() {\r
- this(new ArrayList<UserModel>());\r
- }\r
-\r
- public UsersModel(List<UserModel> users) {\r
- this.list = users;\r
- Collections.sort(this.list);\r
- }\r
-\r
- @Override\r
- public int getRowCount() {\r
- return list.size();\r
- }\r
-\r
- @Override\r
- public int getColumnCount() {\r
- return Columns.values().length;\r
- }\r
-\r
- @Override\r
- public String getColumnName(int column) {\r
- Columns col = Columns.values()[column];\r
- switch (col) {\r
- case Name:\r
- return Translation.get("gb.name");\r
- }\r
- return "";\r
- }\r
-\r
- /**\r
- * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
- * \r
- * @param columnIndex\r
- * the column being queried\r
- * @return the Object.class\r
- */\r
- public Class<?> getColumnClass(int columnIndex) {\r
- return String.class;\r
- }\r
-\r
- @Override\r
- public Object getValueAt(int rowIndex, int columnIndex) {\r
- UserModel model = list.get(rowIndex);\r
- Columns col = Columns.values()[columnIndex];\r
- switch (col) {\r
- case Name:\r
- return model.username;\r
- }\r
- return null;\r
- }\r
-}\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.client;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+import javax.swing.table.AbstractTableModel;\r
+\r
+import com.gitblit.models.UserModel;\r
+\r
+/**\r
+ * Table model of a list of users.\r
+ * \r
+ * @author James Moger\r
+ * \r
+ */\r
+public class UsersTableModel extends AbstractTableModel {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ List<UserModel> list;\r
+\r
+ enum Columns {\r
+ Name;\r
+\r
+ @Override\r
+ public String toString() {\r
+ return name().replace('_', ' ');\r
+ }\r
+ }\r
+\r
+ public UsersTableModel() {\r
+ this(new ArrayList<UserModel>());\r
+ }\r
+\r
+ public UsersTableModel(List<UserModel> users) {\r
+ this.list = users;\r
+ Collections.sort(this.list);\r
+ }\r
+\r
+ @Override\r
+ public int getRowCount() {\r
+ return list.size();\r
+ }\r
+\r
+ @Override\r
+ public int getColumnCount() {\r
+ return Columns.values().length;\r
+ }\r
+\r
+ @Override\r
+ public String getColumnName(int column) {\r
+ Columns col = Columns.values()[column];\r
+ switch (col) {\r
+ case Name:\r
+ return Translation.get("gb.name");\r
+ }\r
+ return "";\r
+ }\r
+\r
+ /**\r
+ * Returns <code>Object.class</code> regardless of <code>columnIndex</code>.\r
+ * \r
+ * @param columnIndex\r
+ * the column being queried\r
+ * @return the Object.class\r
+ */\r
+ public Class<?> getColumnClass(int columnIndex) {\r
+ return String.class;\r
+ }\r
+\r
+ @Override\r
+ public Object getValueAt(int rowIndex, int columnIndex) {\r
+ UserModel model = list.get(rowIndex);\r
+ Columns col = Columns.values()[columnIndex];\r
+ switch (col) {\r
+ case Name:\r
+ return model.username;\r
+ }\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2011 gitblit.com.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package com.gitblit.models;\r
+\r
+import java.io.Serializable;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+import com.gitblit.IStoredSettings;\r
+\r
+/**\r
+ * Server settings represents the settings of the Gitblit server including all\r
+ * setting metadata such as name, current value, default value, description, and\r
+ * directives. It is a model class for serialization and presentation, but not\r
+ * for persistence.\r
+ * \r
+ * @author James Moger\r
+ */\r
+public class ServerSettings implements Serializable {\r
+\r
+ private final Map<String, SettingModel> settings;\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ public ServerSettings() {\r
+ settings = new TreeMap<String, SettingModel>();\r
+ }\r
+ \r
+ public List<String> getKeys() {\r
+ return new ArrayList<String>(settings.keySet());\r
+ }\r
+\r
+ public void add(SettingModel setting) {\r
+ settings.put(setting.name, setting);\r
+ }\r
+\r
+ public SettingModel get(String key) {\r
+ return settings.get(key);\r
+ }\r
+\r
+ public void updateCurrentValues(IStoredSettings storedSettings) {\r
+ for (String key : storedSettings.getAllKeys(null)) {\r
+ if (settings.containsKey(key)) {\r
+ settings.get(key).currentValue = storedSettings.getString(key, "");\r
+ }\r
+ }\r
+ }\r
+}\r
\r
import java.io.Serializable;\r
import java.util.Date;\r
-import java.util.HashMap;\r
import java.util.Map;\r
+import java.util.TreeMap;\r
\r
/**\r
* ServerStatus encapsulates runtime status information about the server\r
- * including the system environment.\r
+ * including some information about the system environment.\r
* \r
* @author James Moger\r
* \r
\r
public final Date bootDate;\r
\r
+ public final Map<String, String> systemProperties;\r
+\r
public final long heapSize;\r
\r
- public final Map<String, String> systemProperties;\r
- \r
public volatile long heapAllocated;\r
\r
public volatile long heapFree;\r
\r
heapSize = Runtime.getRuntime().maxMemory();\r
\r
- systemProperties = new HashMap<String, String>();\r
+ systemProperties = new TreeMap<String, String>();\r
put("file.encoding");\r
put("java.home");\r
put("java.io.tmpdir");\r
import com.gitblit.models.FederationSet;\r
import com.gitblit.models.RepositoryModel;\r
import com.gitblit.models.ServerStatus;\r
-import com.gitblit.models.SettingModel;\r
+import com.gitblit.models.ServerSettings;\r
import com.gitblit.models.UserModel;\r
import com.google.gson.reflect.TypeToken;\r
\r
private static final Type SETS_TYPE = new TypeToken<Collection<FederationSet>>() {\r
}.getType();\r
\r
- private static final Type SETTINGS_TYPE = new TypeToken<Map<String, SettingModel>>() {\r
- }.getType();\r
-\r
/**\r
* \r
* @param remoteURL\r
* @param serverUrl\r
* @param account\r
* @param password\r
- * @return an Map<String, SettingModel> object\r
+ * @return an Settings object\r
* @throws IOException\r
*/\r
- public static Map<String, SettingModel> getSettings(String serverUrl, String account,\r
- char[] password) throws IOException {\r
+ public static ServerSettings getSettings(String serverUrl, String account, char[] password)\r
+ throws IOException {\r
String url = asLink(serverUrl, RpcRequest.LIST_SETTINGS);\r
- Map<String, SettingModel> settings = JsonUtils.retrieveJson(url, SETTINGS_TYPE, account,\r
- password);\r
+ ServerSettings settings = JsonUtils.retrieveJson(url, ServerSettings.class, account, password);\r
return settings;\r
}\r
\r
*/\r
public static ServerStatus getStatus(String serverUrl, String account, char[] password)\r
throws IOException {\r
- String url = asLink(serverUrl, RpcRequest.LIST_SERVER_STATUS);\r
+ String url = asLink(serverUrl, RpcRequest.LIST_STATUS);\r
ServerStatus status = JsonUtils.retrieveJson(url, ServerStatus.class, account, password);\r
return status;\r
}\r
import com.gitblit.models.FederationProposal;\r
import com.gitblit.models.FederationSet;\r
import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.ServerSettings;\r
import com.gitblit.models.ServerStatus;\r
-import com.gitblit.models.SettingModel;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.utils.RpcUtils;\r
\r
}\r
\r
public void testSettings() throws Exception {\r
- Map<String, SettingModel> settings = RpcUtils.getSettings(url, account, password.toCharArray());\r
+ ServerSettings settings = RpcUtils.getSettings(url, account, password.toCharArray());\r
assertTrue("No settings were retrieved!", settings != null);\r
}\r
\r