summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/01_setup.mkd1
-rw-r--r--docs/02_rpc.mkd77
-rw-r--r--src/com/gitblit/Constants.java2
-rw-r--r--src/com/gitblit/GitBlit.java26
-rw-r--r--src/com/gitblit/RpcServlet.java4
-rw-r--r--src/com/gitblit/client/EditUserDialog.java19
-rw-r--r--src/com/gitblit/client/GitblitClient.java (renamed from src/com/gitblit/client/GitblitModel.java)21
-rw-r--r--src/com/gitblit/client/GitblitPanel.java68
-rw-r--r--src/com/gitblit/client/RegistrationsDialog.java6
-rw-r--r--src/com/gitblit/client/RegistrationsTableModel.java (renamed from src/com/gitblit/client/RegistrationsModel.java)4
-rw-r--r--src/com/gitblit/client/RepositoriesTableModel.java (renamed from src/com/gitblit/client/RepositoriesModel.java)6
-rw-r--r--src/com/gitblit/client/SettingsTableModel.java (renamed from src/com/gitblit/client/SettingsModel.java)14
-rw-r--r--src/com/gitblit/client/UsersTableModel.java (renamed from src/com/gitblit/client/UsersModel.java)6
-rw-r--r--src/com/gitblit/models/ServerSettings.java63
-rw-r--r--src/com/gitblit/models/ServerStatus.java10
-rw-r--r--src/com/gitblit/utils/RpcUtils.java16
-rw-r--r--tests/com/gitblit/tests/RpcTests.java4
17 files changed, 224 insertions, 123 deletions
diff --git a/docs/01_setup.mkd b/docs/01_setup.mkd
index c7a8ff61..b2c5b2f8 100644
--- a/docs/01_setup.mkd
+++ b/docs/01_setup.mkd
@@ -134,6 +134,7 @@ All repository settings are stored within the repository `.git/config` file unde
showReadme = false
federationStrategy = FEDERATE_THIS
isFederated = false
+ skipSizeCalculation = false
federationSets =
#### Repository Names
diff --git a/docs/02_rpc.mkd b/docs/02_rpc.mkd
index b01eb679..94739ca3 100644
--- a/docs/02_rpc.mkd
+++ b/docs/02_rpc.mkd
@@ -30,7 +30,8 @@ The Gitblit RPC mechanism, like the Gitblit JGit servlet, syndication/feed servl
<tr><td>LIST_FEDERATION_RESULTS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List&lt;FederationModel&gt;</td></tr>
<tr><td>LIST_FEDERATION_PROPOSALS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List&lt;FederationProposal&gt;</td></tr>
<tr><td>LIST_FEDERATION_SETS</td><td>-</td><td><em>admin</em></td><td>-</td><td>List&lt;FederationSet&gt;</td></tr>
-<tr><td>LIST_SETTINGS</td><td>-</td><td><em>admin</em></td><td>-</td><td>Map&lt;String, SettingModel&gt;</td></tr>
+<tr><td>LIST_SETTINGS</td><td>-</td><td><em>admin</em></td><td>-</td><td>ServerSettings (see example below)</td></tr>
+<tr><td>LIST_STATUS</td><td>-</td><td><em>admin</em></td><td>-</td><td>ServerStatus (see example below)</td></tr>
</table>
### RPC/HTTP Response Codes
@@ -55,6 +56,8 @@ One obvious goal of a Gitblit RPC mechanism would be to have an EGit Feature tha
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.
+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).
+
Currently this project is in the planning stage.
### Example: LIST_REPOSITORIES
@@ -80,6 +83,7 @@ Currently this project is in the planning stage.
"libraries"
],
"isFederated": false,
+ "skipSizeCalculation": false,
"size": "102 KB"
},
"https://localhost/git/libraries/smack.git": {
@@ -97,6 +101,7 @@ Currently this project is in the planning stage.
"federationStrategy": "FEDERATE_THIS",
"federationSets": [],
"isFederated": false,
+ "skipSizeCalculation": false,
"size": "4.8 MB"
}
}
@@ -157,28 +162,58 @@ The original repository name is specified in the *name* url parameter. The new
### Example: LIST_SETTINGS
**url**: https://localhost/rpc?req=LIST_SETTINGS
-**response body**: Map&lt;String, SettingModel&gt;
+**response body**: ServerSettings
<pre>
{
- "web.siteName": {
- "name": "web.siteName",
- "currentValue": "",
- "defaultValue": "",
- "description": "Gitblit Web Settings\nIf blank Gitblit is displayed.",
- "since": "0.5.0",
- "caseSensitive": false,
- "restartRequired": false,
- "spaceDelimited": false
- },
- "web.summaryCommitCount": {
- "name": "web.summaryCommitCount",
- "currentValue": "16",
- "defaultValue": "16",
- "description": "The number of commits to display on the summary page\nValue must exceed 0 else default of 16 is used",
- "since": "0.5.0",
- "caseSensitive": false,
- "restartRequired": false,
- "spaceDelimited": false
+ "settings": {
+ "web.siteName": {
+ "name": "web.siteName",
+ "currentValue": "",
+ "defaultValue": "",
+ "description": "Gitblit Web Settings\nIf blank Gitblit is displayed.",
+ "since": "0.5.0",
+ "caseSensitive": false,
+ "restartRequired": false,
+ "spaceDelimited": false
+ },
+ "web.summaryCommitCount": {
+ "name": "web.summaryCommitCount",
+ "currentValue": "16",
+ "defaultValue": "16",
+ "description": "The number of commits to display on the summary page\nValue must exceed 0 else default of 16 is used",
+ "since": "0.5.0",
+ "caseSensitive": false,
+ "restartRequired": false,
+ "spaceDelimited": false
+ }
}
}
+</pre>
+
+### Example: LIST_STATUS
+**url**: https://localhost/rpc?req=LIST_STATUS
+**response body**: ServerStatus
+<pre>
+{
+ "bootDate": "2011-10-22T12:13:00Z",
+ "systemProperties": {
+ "file.encoding": "Cp1252",
+ "java.home": "C:\\Program Files\\Java\\jdk1.6.0_26\\jre",
+ "java.io.tmpdir": "C:\\Users\\JAMESM~1\\AppData\\Local\\Temp\\",
+ "java.runtime.name": "Java(TM) SE Runtime Environment",
+ "java.runtime.version": "1.6.0_26-b03",
+ "java.vendor": "Sun Microsystems Inc.",
+ "java.version": "1.6.0_26",
+ "java.vm.info": "mixed mode",
+ "java.vm.name": "Java HotSpot(TM) 64-Bit Server VM",
+ "java.vm.vendor": "Sun Microsystems Inc.",
+ "java.vm.version": "20.1-b02",
+ "os.arch": "amd64",
+ "os.name": "Windows 7",
+ "os.version": "6.1"
+ },
+ "heapAllocated": 128057344,
+ "heapFree": 120399168,
+ "heapSize": 1899560960
+}
</pre> \ No newline at end of file
diff --git a/src/com/gitblit/Constants.java b/src/com/gitblit/Constants.java
index f3ff6c44..79dfaf6a 100644
--- a/src/com/gitblit/Constants.java
+++ b/src/com/gitblit/Constants.java
@@ -205,7 +205,7 @@ public class Constants {
LIST_USERS, CREATE_USER, EDIT_USER, DELETE_USER, LIST_REPOSITORY_MEMBERS,
SET_REPOSITORY_MEMBERS, LIST_FEDERATION_REGISTRATIONS, LIST_FEDERATION_RESULTS,
LIST_FEDERATION_PROPOSALS, LIST_FEDERATION_SETS, LIST_SETTINGS,
- LIST_SERVER_STATUS;
+ LIST_STATUS;
public static RpcRequest fromName(String name) {
for (RpcRequest type : values()) {
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 238c01f7..eaf6a957 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -30,7 +30,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -70,6 +69,7 @@ import com.gitblit.models.ObjectCache;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.ServerStatus;
import com.gitblit.models.SettingModel;
+import com.gitblit.models.ServerSettings;
import com.gitblit.models.UserModel;
import com.gitblit.utils.ByteFormat;
import com.gitblit.utils.FederationUtils;
@@ -123,7 +123,7 @@ public class GitBlit implements ServletContextListener {
private IStoredSettings settings;
- private Map<String, SettingModel> settingModels;
+ private ServerSettings settingsModel;
private ServerStatus serverStatus;
@@ -1275,16 +1275,12 @@ public class GitBlit implements ServletContextListener {
/**
* Returns the descriptions/comments of the Gitblit config settings.
*
- * @return Map<String, SettingModel>
+ * @return SettingsModel
*/
- public Map<String, SettingModel> getSettingModels() {
+ public ServerSettings getSettingsModel() {
// ensure that the current values are updated in the setting models
- for (String key : settings.getAllKeys(null)) {
- if (settingModels.containsKey(key)) {
- settingModels.get(key).currentValue = settings.getString(key, "");
- }
- }
- return settingModels;
+ settingsModel.updateCurrentValues(settings);
+ return settingsModel;
}
/**
@@ -1294,8 +1290,8 @@ public class GitBlit implements ServletContextListener {
*
* @return Map<String, SettingModel>
*/
- private Map<String, SettingModel> loadSettingModels() {
- Map<String, SettingModel> map = new TreeMap<String, SettingModel>();
+ private ServerSettings loadSettingModels() {
+ ServerSettings settingsModel = new ServerSettings();
try {
// Read bundled Gitblit properties to extract setting descriptions.
// This copy is pristine and only used for populating the setting
@@ -1337,7 +1333,7 @@ public class GitBlit implements ServletContextListener {
setting.defaultValue = kvp[1].trim();
setting.currentValue = setting.defaultValue;
setting.description = description.toString().trim();
- map.put(key, setting);
+ settingsModel.add(setting);
description.setLength(0);
setting = new SettingModel();
}
@@ -1349,7 +1345,7 @@ public class GitBlit implements ServletContextListener {
} catch (IOException e) {
logger.error("Failed to load resource copy of gitblit.properties");
}
- return map;
+ return settingsModel;
}
/**
@@ -1409,7 +1405,7 @@ public class GitBlit implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent contextEvent) {
servletContext = contextEvent.getServletContext();
- settingModels = loadSettingModels();
+ settingsModel = loadSettingModels();
if (settings == null) {
// Gitblit WAR is running in a servlet container
WebXmlSettings webxmlSettings = new WebXmlSettings(contextEvent.getServletContext());
diff --git a/src/com/gitblit/RpcServlet.java b/src/com/gitblit/RpcServlet.java
index 6a8c2c59..ceed35e1 100644
--- a/src/com/gitblit/RpcServlet.java
+++ b/src/com/gitblit/RpcServlet.java
@@ -182,8 +182,8 @@ public class RpcServlet extends JsonServlet {
}
} else if (RpcRequest.LIST_SETTINGS.equals(reqType)) {
// return the server's settings
- result = GitBlit.self().getSettingModels();
- } else if (RpcRequest.LIST_SERVER_STATUS.equals(reqType)) {
+ result = GitBlit.self().getSettingsModel();
+ } else if (RpcRequest.LIST_STATUS.equals(reqType)) {
// return the server's status information
result = GitBlit.self().getStatus();
}
diff --git a/src/com/gitblit/client/EditUserDialog.java b/src/com/gitblit/client/EditUserDialog.java
index 0a1ddd93..988f8fb0 100644
--- a/src/com/gitblit/client/EditUserDialog.java
+++ b/src/com/gitblit/client/EditUserDialog.java
@@ -29,7 +29,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.swing.ImageIcon;
@@ -48,7 +47,7 @@ import javax.swing.KeyStroke;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.Keys;
import com.gitblit.models.RepositoryModel;
-import com.gitblit.models.SettingModel;
+import com.gitblit.models.ServerSettings;
import com.gitblit.models.UserModel;
import com.gitblit.utils.StringUtils;
@@ -58,10 +57,10 @@ public class EditUserDialog extends JDialog {
private final UserModel user;
- private final Map<String, SettingModel> settings;
+ private final ServerSettings settings;
private boolean isCreate;
-
+
private boolean canceled = true;
private JTextField usernameField;
@@ -78,13 +77,13 @@ public class EditUserDialog extends JDialog {
private Set<String> usernames;
- public EditUserDialog(Map<String, SettingModel> settings) {
+ public EditUserDialog(ServerSettings settings) {
this(new UserModel(""), settings);
this.isCreate = true;
- setTitle(Translation.get("gb.newUser"));
+ setTitle(Translation.get("gb.newUser"));
}
- public EditUserDialog(UserModel anUser, Map<String, SettingModel> settings) {
+ public EditUserDialog(UserModel anUser, ServerSettings settings) {
super();
this.user = new UserModel("");
this.settings = settings;
@@ -95,7 +94,7 @@ public class EditUserDialog extends JDialog {
setTitle(Translation.get("gb.edit") + ": " + anUser.username);
setIconImage(new ImageIcon(getClass().getResource("/gitblt-favicon.png")).getImage());
}
-
+
@Override
protected JRootPane createRootPane() {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
@@ -203,8 +202,8 @@ public class EditUserDialog extends JDialog {
}
char[] pw = passwordField.getPassword();
if (pw == null || pw.length < minLength) {
- error(MessageFormat.format(
- "Password is too short. Minimum length is {0} characters.", minLength));
+ error(MessageFormat.format("Password is too short. Minimum length is {0} characters.",
+ minLength));
return false;
}
char[] cpw = confirmPasswordField.getPassword();
diff --git a/src/com/gitblit/client/GitblitModel.java b/src/com/gitblit/client/GitblitClient.java
index 55e74b9c..76a67316 100644
--- a/src/com/gitblit/client/GitblitModel.java
+++ b/src/com/gitblit/client/GitblitClient.java
@@ -27,12 +27,19 @@ 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.SettingModel;
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;
@@ -44,7 +51,7 @@ public class GitblitModel implements Serializable {
private volatile boolean isAdmin;
- private volatile Map<String, SettingModel> settings;
+ private volatile ServerSettings settings;
private final List<RepositoryModel> allRepositories;
@@ -54,7 +61,7 @@ public class GitblitModel implements Serializable {
private ServerStatus status;
- public GitblitModel(String url, String account, char[] password) {
+ public GitblitClient(String url, String account, char[] password) {
this.url = url;
this.account = account;
this.password = password;
@@ -87,10 +94,14 @@ public class GitblitModel implements Serializable {
return account != null && account.equalsIgnoreCase(model.owner);
}
- public Map<String, SettingModel> getSettings() {
+ public ServerSettings getSettings() {
return settings;
}
+ public ServerStatus getStatus() {
+ return status;
+ }
+
public String getSettingDescription(String key) {
return settings.get(key).description;
}
diff --git a/src/com/gitblit/client/GitblitPanel.java b/src/com/gitblit/client/GitblitPanel.java
index 8635b006..e4c6e76c 100644
--- a/src/com/gitblit/client/GitblitPanel.java
+++ b/src/com/gitblit/client/GitblitPanel.java
@@ -71,21 +71,21 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
private final Insets insets = new Insets(margin, margin, margin, margin);
- private GitblitModel gitblit;
+ private GitblitClient gitblit;
private JTabbedPane tabs;
private JTable repositoriesTable;
- private RepositoriesModel repositoriesModel;
+ private RepositoriesTableModel repositoriesModel;
private JTable usersTable;
- private UsersModel usersModel;
+ private UsersTableModel usersModel;
private JTable settingsTable;
- private SettingsModel settingsModel;
+ private SettingsTableModel settingsModel;
private JButton createRepository;
@@ -99,11 +99,11 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
private DefaultTableCellRenderer sizeRenderer;
- private TableRowSorter<RepositoriesModel> defaultRepositoriesSorter;
+ private TableRowSorter<RepositoriesTableModel> defaultRepositoriesSorter;
- private TableRowSorter<UsersModel> defaultUsersSorter;
+ private TableRowSorter<UsersTableModel> defaultUsersSorter;
- private TableRowSorter<SettingsModel> defaultSettingsSorter;
+ private TableRowSorter<SettingsTableModel> defaultSettingsSorter;
private JButton editRepository;
@@ -112,7 +112,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
}
public GitblitPanel(String url, String account, char[] password) {
- this.gitblit = new GitblitModel(url, account, password);
+ this.gitblit = new GitblitClient(url, account, password);
tabs = new JTabbedPane(JTabbedPane.BOTTOM);
tabs.addTab(Translation.get("gb.repositories"), createRepositoriesPanel());
@@ -180,17 +180,17 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
ownerRenderer.setForeground(Color.gray);
ownerRenderer.setHorizontalAlignment(SwingConstants.CENTER);
- repositoriesModel = new RepositoriesModel();
- defaultRepositoriesSorter = new TableRowSorter<RepositoriesModel>(repositoriesModel);
+ repositoriesModel = new RepositoriesTableModel();
+ defaultRepositoriesSorter = new TableRowSorter<RepositoriesTableModel>(repositoriesModel);
repositoriesTable = Utils.newTable(repositoriesModel);
repositoriesTable.setRowHeight(nameRenderer.getFont().getSize() + 8);
repositoriesTable.setRowSorter(defaultRepositoriesSorter);
- repositoriesTable.getRowSorter().toggleSortOrder(RepositoriesModel.Columns.Name.ordinal());
+ repositoriesTable.getRowSorter().toggleSortOrder(RepositoriesTableModel.Columns.Name.ordinal());
- setRepositoryRenderer(RepositoriesModel.Columns.Name, nameRenderer, -1);
- setRepositoryRenderer(RepositoriesModel.Columns.Indicators, typeRenderer, 100);
- setRepositoryRenderer(RepositoriesModel.Columns.Owner, ownerRenderer, -1);
- setRepositoryRenderer(RepositoriesModel.Columns.Size, sizeRenderer, 60);
+ setRepositoryRenderer(RepositoriesTableModel.Columns.Name, nameRenderer, -1);
+ setRepositoryRenderer(RepositoriesTableModel.Columns.Indicators, typeRenderer, 100);
+ setRepositoryRenderer(RepositoriesTableModel.Columns.Owner, ownerRenderer, -1);
+ setRepositoryRenderer(RepositoriesTableModel.Columns.Size, sizeRenderer, 60);
repositoriesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
@@ -205,7 +205,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
if (selected) {
int viewRow = repositoriesTable.getSelectedRow();
int modelRow = repositoriesTable.convertRowIndexToModel(viewRow);
- RepositoryModel model = ((RepositoriesModel) repositoriesTable.getModel()).list
+ RepositoryModel model = ((RepositoriesTableModel) repositoriesTable.getModel()).list
.get(modelRow);
editRepository.setEnabled(singleSelection
&& (gitblit.allowAdmin() || gitblit.isOwner(model)));
@@ -266,7 +266,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
return repositoriesPanel;
}
- private void setRepositoryRenderer(RepositoriesModel.Columns col, TableCellRenderer renderer,
+ private void setRepositoryRenderer(RepositoriesTableModel.Columns col, TableCellRenderer renderer,
int maxWidth) {
String name = repositoriesTable.getColumnName(col.ordinal());
repositoriesTable.getColumn(name).setCellRenderer(renderer);
@@ -307,14 +307,14 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
}
});
- usersModel = new UsersModel();
- defaultUsersSorter = new TableRowSorter<UsersModel>(usersModel);
+ usersModel = new UsersTableModel();
+ defaultUsersSorter = new TableRowSorter<UsersTableModel>(usersModel);
usersTable = Utils.newTable(usersModel);
- String name = usersTable.getColumnName(UsersModel.Columns.Name.ordinal());
+ String name = usersTable.getColumnName(UsersTableModel.Columns.Name.ordinal());
usersTable.setRowHeight(nameRenderer.getFont().getSize() + 8);
usersTable.getColumn(name).setCellRenderer(nameRenderer);
usersTable.setRowSorter(defaultUsersSorter);
- usersTable.getRowSorter().toggleSortOrder(UsersModel.Columns.Name.ordinal());
+ usersTable.getRowSorter().toggleSortOrder(UsersTableModel.Columns.Name.ordinal());
usersTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
@@ -381,15 +381,15 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
private JPanel createSettingsPanel() {
final SettingPanel settingPanel = new SettingPanel();
- settingsModel = new SettingsModel();
- defaultSettingsSorter = new TableRowSorter<SettingsModel>(settingsModel);
+ settingsModel = new SettingsTableModel();
+ defaultSettingsSorter = new TableRowSorter<SettingsTableModel>(settingsModel);
settingsTable = Utils.newTable(settingsModel);
settingsTable.setDefaultRenderer(SettingModel.class, new SettingCellRenderer());
- String name = settingsTable.getColumnName(UsersModel.Columns.Name.ordinal());
+ String name = settingsTable.getColumnName(UsersTableModel.Columns.Name.ordinal());
settingsTable.setRowHeight(nameRenderer.getFont().getSize() + 8);
settingsTable.getColumn(name).setCellRenderer(nameRenderer);
settingsTable.setRowSorter(defaultSettingsSorter);
- settingsTable.getRowSorter().toggleSortOrder(SettingsModel.Columns.Name.ordinal());
+ settingsTable.getRowSorter().toggleSortOrder(SettingsTableModel.Columns.Name.ordinal());
settingsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
@@ -496,8 +496,8 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
repositoriesTable.setRowSorter(defaultRepositoriesSorter);
return;
}
- RowFilter<RepositoriesModel, Object> containsFilter = new RowFilter<RepositoriesModel, Object>() {
- public boolean include(Entry<? extends RepositoriesModel, ? extends Object> entry) {
+ RowFilter<RepositoriesTableModel, Object> containsFilter = new RowFilter<RepositoriesTableModel, Object>() {
+ public boolean include(Entry<? extends RepositoriesTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
return true;
@@ -506,7 +506,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
return false;
}
};
- TableRowSorter<RepositoriesModel> sorter = new TableRowSorter<RepositoriesModel>(
+ TableRowSorter<RepositoriesTableModel> sorter = new TableRowSorter<RepositoriesTableModel>(
repositoriesModel);
sorter.setRowFilter(containsFilter);
repositoriesTable.setRowSorter(sorter);
@@ -517,8 +517,8 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
usersTable.setRowSorter(defaultUsersSorter);
return;
}
- RowFilter<UsersModel, Object> containsFilter = new RowFilter<UsersModel, Object>() {
- public boolean include(Entry<? extends UsersModel, ? extends Object> entry) {
+ RowFilter<UsersTableModel, Object> containsFilter = new RowFilter<UsersTableModel, Object>() {
+ public boolean include(Entry<? extends UsersTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
return true;
@@ -527,7 +527,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
return false;
}
};
- TableRowSorter<UsersModel> sorter = new TableRowSorter<UsersModel>(usersModel);
+ TableRowSorter<UsersTableModel> sorter = new TableRowSorter<UsersTableModel>(usersModel);
sorter.setRowFilter(containsFilter);
usersTable.setRowSorter(sorter);
}
@@ -537,8 +537,8 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
settingsTable.setRowSorter(defaultSettingsSorter);
return;
}
- RowFilter<SettingsModel, Object> containsFilter = new RowFilter<SettingsModel, Object>() {
- public boolean include(Entry<? extends SettingsModel, ? extends Object> entry) {
+ RowFilter<SettingsTableModel, Object> containsFilter = new RowFilter<SettingsTableModel, Object>() {
+ public boolean include(Entry<? extends SettingsTableModel, ? extends Object> entry) {
for (int i = entry.getValueCount() - 1; i >= 0; i--) {
if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
return true;
@@ -547,7 +547,7 @@ public class GitblitPanel extends JPanel implements CloseTabListener {
return false;
}
};
- TableRowSorter<SettingsModel> sorter = new TableRowSorter<SettingsModel>(settingsModel);
+ TableRowSorter<SettingsTableModel> sorter = new TableRowSorter<SettingsTableModel>(settingsModel);
sorter.setRowFilter(containsFilter);
settingsTable.setRowSorter(sorter);
}
diff --git a/src/com/gitblit/client/RegistrationsDialog.java b/src/com/gitblit/client/RegistrationsDialog.java
index ae53d5fa..71178f30 100644
--- a/src/com/gitblit/client/RegistrationsDialog.java
+++ b/src/com/gitblit/client/RegistrationsDialog.java
@@ -56,7 +56,7 @@ public class RegistrationsDialog extends JDialog {
private JTable registrationsTable;
- private RegistrationsModel model;
+ private RegistrationsTableModel model;
public RegistrationsDialog(List<GitblitRegistration> registrations,
RegistrationListener listener) {
@@ -83,11 +83,11 @@ public class RegistrationsDialog extends JDialog {
private void initialize() {
NameRenderer nameRenderer = new NameRenderer();
- model = new RegistrationsModel(registrations);
+ model = new RegistrationsTableModel(registrations);
registrationsTable = Utils.newTable(model);
registrationsTable.setRowHeight(nameRenderer.getFont().getSize() + 8);
- String id = registrationsTable.getColumnName(RegistrationsModel.Columns.Name.ordinal());
+ String id = registrationsTable.getColumnName(RegistrationsTableModel.Columns.Name.ordinal());
registrationsTable.getColumn(id).setCellRenderer(nameRenderer);
registrationsTable.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
diff --git a/src/com/gitblit/client/RegistrationsModel.java b/src/com/gitblit/client/RegistrationsTableModel.java
index 8b4966ca..8c6b34ff 100644
--- a/src/com/gitblit/client/RegistrationsModel.java
+++ b/src/com/gitblit/client/RegistrationsTableModel.java
@@ -27,7 +27,7 @@ import javax.swing.table.AbstractTableModel;
* @author James Moger
*
*/
-public class RegistrationsModel extends AbstractTableModel {
+public class RegistrationsTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
@@ -42,7 +42,7 @@ public class RegistrationsModel extends AbstractTableModel {
}
}
- public RegistrationsModel(List<GitblitRegistration> list) {
+ public RegistrationsTableModel(List<GitblitRegistration> list) {
this.list = list;
Collections.sort(this.list);
}
diff --git a/src/com/gitblit/client/RepositoriesModel.java b/src/com/gitblit/client/RepositoriesTableModel.java
index c1fead91..9dd1a998 100644
--- a/src/com/gitblit/client/RepositoriesModel.java
+++ b/src/com/gitblit/client/RepositoriesTableModel.java
@@ -30,7 +30,7 @@ import com.gitblit.models.RepositoryModel;
* @author James Moger
*
*/
-public class RepositoriesModel extends AbstractTableModel {
+public class RepositoriesTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
@@ -45,11 +45,11 @@ public class RepositoriesModel extends AbstractTableModel {
}
}
- public RepositoriesModel() {
+ public RepositoriesTableModel() {
this(new ArrayList<RepositoryModel>());
}
- public RepositoriesModel(List<RepositoryModel> repositories) {
+ public RepositoriesTableModel(List<RepositoryModel> repositories) {
this.list = repositories;
Collections.sort(this.list);
}
diff --git a/src/com/gitblit/client/SettingsModel.java b/src/com/gitblit/client/SettingsTableModel.java
index af3c1b60..e6d23135 100644
--- a/src/com/gitblit/client/SettingsModel.java
+++ b/src/com/gitblit/client/SettingsTableModel.java
@@ -18,10 +18,10 @@ package com.gitblit.client;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
import javax.swing.table.AbstractTableModel;
+import com.gitblit.models.ServerSettings;
import com.gitblit.models.SettingModel;
/**
@@ -30,11 +30,11 @@ import com.gitblit.models.SettingModel;
* @author James Moger
*
*/
-public class SettingsModel extends AbstractTableModel {
+public class SettingsTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
- Map<String, SettingModel> settings;
+ ServerSettings settings;
List<String> keys;
@@ -47,20 +47,20 @@ public class SettingsModel extends AbstractTableModel {
}
}
- public SettingsModel() {
+ public SettingsTableModel() {
this(null);
}
- public SettingsModel(Map<String, SettingModel> settings) {
+ public SettingsTableModel(ServerSettings settings) {
setSettings(settings);
}
- public void setSettings(Map<String, SettingModel> settings) {
+ public void setSettings(ServerSettings settings) {
this.settings = settings;
if (settings == null) {
keys = new ArrayList<String>();
} else {
- keys = new ArrayList<String>(settings.keySet());
+ keys = new ArrayList<String>(settings.getKeys());
Collections.sort(keys);
}
}
diff --git a/src/com/gitblit/client/UsersModel.java b/src/com/gitblit/client/UsersTableModel.java
index 2b3c6443..57536adc 100644
--- a/src/com/gitblit/client/UsersModel.java
+++ b/src/com/gitblit/client/UsersTableModel.java
@@ -29,7 +29,7 @@ import com.gitblit.models.UserModel;
* @author James Moger
*
*/
-public class UsersModel extends AbstractTableModel {
+public class UsersTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
@@ -44,11 +44,11 @@ public class UsersModel extends AbstractTableModel {
}
}
- public UsersModel() {
+ public UsersTableModel() {
this(new ArrayList<UserModel>());
}
- public UsersModel(List<UserModel> users) {
+ public UsersTableModel(List<UserModel> users) {
this.list = users;
Collections.sort(this.list);
}
diff --git a/src/com/gitblit/models/ServerSettings.java b/src/com/gitblit/models/ServerSettings.java
new file mode 100644
index 00000000..47148d32
--- /dev/null
+++ b/src/com/gitblit/models/ServerSettings.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2011 gitblit.com.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gitblit.models;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import com.gitblit.IStoredSettings;
+
+/**
+ * Server settings represents the settings of the Gitblit server including all
+ * setting metadata such as name, current value, default value, description, and
+ * directives. It is a model class for serialization and presentation, but not
+ * for persistence.
+ *
+ * @author James Moger
+ */
+public class ServerSettings implements Serializable {
+
+ private final Map<String, SettingModel> settings;
+
+ private static final long serialVersionUID = 1L;
+
+ public ServerSettings() {
+ settings = new TreeMap<String, SettingModel>();
+ }
+
+ public List<String> getKeys() {
+ return new ArrayList<String>(settings.keySet());
+ }
+
+ public void add(SettingModel setting) {
+ settings.put(setting.name, setting);
+ }
+
+ public SettingModel get(String key) {
+ return settings.get(key);
+ }
+
+ public void updateCurrentValues(IStoredSettings storedSettings) {
+ for (String key : storedSettings.getAllKeys(null)) {
+ if (settings.containsKey(key)) {
+ settings.get(key).currentValue = storedSettings.getString(key, "");
+ }
+ }
+ }
+}
diff --git a/src/com/gitblit/models/ServerStatus.java b/src/com/gitblit/models/ServerStatus.java
index b1dc52dd..8dfc0fbc 100644
--- a/src/com/gitblit/models/ServerStatus.java
+++ b/src/com/gitblit/models/ServerStatus.java
@@ -17,12 +17,12 @@ package com.gitblit.models;
import java.io.Serializable;
import java.util.Date;
-import java.util.HashMap;
import java.util.Map;
+import java.util.TreeMap;
/**
* ServerStatus encapsulates runtime status information about the server
- * including the system environment.
+ * including some information about the system environment.
*
* @author James Moger
*
@@ -33,10 +33,10 @@ public class ServerStatus implements Serializable {
public final Date bootDate;
+ public final Map<String, String> systemProperties;
+
public final long heapSize;
- public final Map<String, String> systemProperties;
-
public volatile long heapAllocated;
public volatile long heapFree;
@@ -46,7 +46,7 @@ public class ServerStatus implements Serializable {
heapSize = Runtime.getRuntime().maxMemory();
- systemProperties = new HashMap<String, String>();
+ systemProperties = new TreeMap<String, String>();
put("file.encoding");
put("java.home");
put("java.io.tmpdir");
diff --git a/src/com/gitblit/utils/RpcUtils.java b/src/com/gitblit/utils/RpcUtils.java
index 440dabdb..2d409a0a 100644
--- a/src/com/gitblit/utils/RpcUtils.java
+++ b/src/com/gitblit/utils/RpcUtils.java
@@ -29,7 +29,7 @@ import com.gitblit.models.FederationProposal;
import com.gitblit.models.FederationSet;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.ServerStatus;
-import com.gitblit.models.SettingModel;
+import com.gitblit.models.ServerSettings;
import com.gitblit.models.UserModel;
import com.google.gson.reflect.TypeToken;
@@ -59,9 +59,6 @@ public class RpcUtils {
private static final Type SETS_TYPE = new TypeToken<Collection<FederationSet>>() {
}.getType();
- private static final Type SETTINGS_TYPE = new TypeToken<Map<String, SettingModel>>() {
- }.getType();
-
/**
*
* @param remoteURL
@@ -341,14 +338,13 @@ public class RpcUtils {
* @param serverUrl
* @param account
* @param password
- * @return an Map<String, SettingModel> object
+ * @return an Settings object
* @throws IOException
*/
- public static Map<String, SettingModel> getSettings(String serverUrl, String account,
- char[] password) throws IOException {
+ public static ServerSettings getSettings(String serverUrl, String account, char[] password)
+ throws IOException {
String url = asLink(serverUrl, RpcRequest.LIST_SETTINGS);
- Map<String, SettingModel> settings = JsonUtils.retrieveJson(url, SETTINGS_TYPE, account,
- password);
+ ServerSettings settings = JsonUtils.retrieveJson(url, ServerSettings.class, account, password);
return settings;
}
@@ -363,7 +359,7 @@ public class RpcUtils {
*/
public static ServerStatus getStatus(String serverUrl, String account, char[] password)
throws IOException {
- String url = asLink(serverUrl, RpcRequest.LIST_SERVER_STATUS);
+ String url = asLink(serverUrl, RpcRequest.LIST_STATUS);
ServerStatus status = JsonUtils.retrieveJson(url, ServerStatus.class, account, password);
return status;
}
diff --git a/tests/com/gitblit/tests/RpcTests.java b/tests/com/gitblit/tests/RpcTests.java
index 3c2f61f9..11a340a9 100644
--- a/tests/com/gitblit/tests/RpcTests.java
+++ b/tests/com/gitblit/tests/RpcTests.java
@@ -27,8 +27,8 @@ import com.gitblit.models.FederationModel;
import com.gitblit.models.FederationProposal;
import com.gitblit.models.FederationSet;
import com.gitblit.models.RepositoryModel;
+import com.gitblit.models.ServerSettings;
import com.gitblit.models.ServerStatus;
-import com.gitblit.models.SettingModel;
import com.gitblit.models.UserModel;
import com.gitblit.utils.RpcUtils;
@@ -207,7 +207,7 @@ public class RpcTests extends TestCase {
}
public void testSettings() throws Exception {
- Map<String, SettingModel> settings = RpcUtils.getSettings(url, account, password.toCharArray());
+ ServerSettings settings = RpcUtils.getSettings(url, account, password.toCharArray());
assertTrue("No settings were retrieved!", settings != null);
}