From 831469ba89ea8bca3bfbd1d662dbdd2c9f233798 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 12 Sep 2011 15:37:55 -0400
Subject: [PATCH] Largely completed, uber-cool federation feature.

---
 src/com/gitblit/FileUserService.java |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/com/gitblit/FileUserService.java b/src/com/gitblit/FileUserService.java
index 12164ce..9dc8008 100644
--- a/src/com/gitblit/FileUserService.java
+++ b/src/com/gitblit/FileUserService.java
@@ -149,6 +149,8 @@
 				// Permissions
 				if (role.equalsIgnoreCase(Constants.ADMIN_ROLE)) {
 					model.canAdmin = true;
+				} else if (role.equalsIgnoreCase(Constants.NOT_FEDERATED_ROLE)) {
+					model.excludeFromFederation = true;
 				}
 				break;
 			default:
@@ -188,6 +190,9 @@
 			// Permissions
 			if (model.canAdmin) {
 				roles.add(Constants.ADMIN_ROLE);
+			}
+			if (model.excludeFromFederation) {
+				roles.add(Constants.NOT_FEDERATED_ROLE);
 			}
 
 			StringBuilder sb = new StringBuilder();
@@ -499,14 +504,15 @@
 		// If the write is successful, delete the current file and rename
 		// the temporary copy to the original filename.
 		if (realmFileCopy.exists() && realmFileCopy.length() > 0) {
-			if (propertiesFile.delete()) {
-				if (!realmFileCopy.renameTo(propertiesFile)) {
-					throw new IOException(MessageFormat.format("Failed to rename {0} to {1}!",
-							realmFileCopy.getAbsolutePath(), propertiesFile.getAbsolutePath()));
+			if (propertiesFile.exists()) {
+				if (!propertiesFile.delete()) {
+					throw new IOException(MessageFormat.format("Failed to delete {0}!",
+							propertiesFile.getAbsolutePath()));
 				}
-			} else {
-				throw new IOException(MessageFormat.format("Failed to delete (0)!",
-						propertiesFile.getAbsolutePath()));
+			}
+			if (!realmFileCopy.renameTo(propertiesFile)) {
+				throw new IOException(MessageFormat.format("Failed to rename {0} to {1}!",
+						realmFileCopy.getAbsolutePath(), propertiesFile.getAbsolutePath()));
 			}
 		} else {
 			throw new IOException(MessageFormat.format("Failed to save {0}!",

--
Gitblit v1.9.1