* The access permissions available for a repository. \r
*/\r
public static enum AccessPermission {\r
- NONE("N"), EXCLUDE("X"), VIEW("V"), CLONE("R"), PUSH("RW"), CREATE("RWC"), DELETE("RWD"), REWIND("RW+");\r
+ NONE("N"), EXCLUDE("X"), VIEW("V"), CLONE("R"), PUSH("RW"), CREATE("RWC"), DELETE("RWD"), REWIND("RW+"), OWNER("RW+");\r
\r
public static final AccessPermission [] NEWPERMISSIONS = { EXCLUDE, VIEW, CLONE, PUSH, CREATE, DELETE, REWIND };\r
\r
}\r
\r
public static enum PermissionType {\r
- EXPLICIT, OWNER, ADMINISTRATOR, TEAM, REGEX;\r
+ MISSING, EXPLICIT, TEAM, REGEX, OWNER, ADMINISTRATOR;\r
}\r
\r
public static enum GCStatus {\r
import com.gitblit.Constants.FederationRequest;\r
import com.gitblit.Constants.FederationStrategy;\r
import com.gitblit.Constants.FederationToken;\r
-import com.gitblit.Constants.PermissionType;\r
import com.gitblit.models.FederationModel;\r
import com.gitblit.models.FederationProposal;\r
import com.gitblit.models.FederationSet;\r
case PULL_SETTINGS:\r
case PULL_SCRIPTS:\r
return token.equals(all);\r
+ default:\r
+ break;\r
}\r
return false;\r
}\r
url = model.origin;\r
}\r
break;\r
+ default:\r
+ break;\r
}\r
\r
if (federationSets.containsKey(token)) {\r
import java.text.MessageFormat;\r
import java.util.ArrayList;\r
import java.util.Collections;\r
+import java.util.HashMap;\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
\r
import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.Constants.AuthorizationControl;\r
+import com.gitblit.Constants.PermissionType;\r
import com.gitblit.Constants.RegistrantType;\r
import com.gitblit.Keys;\r
import com.gitblit.models.RegistrantAccessPermission;\r
}\r
\r
public void setRepositories(List<RepositoryModel> repositories, List<RegistrantAccessPermission> permissions) {\r
+ Map<String, RepositoryModel> repoMap = new HashMap<String, RepositoryModel>();\r
List<String> restricted = new ArrayList<String>();\r
for (RepositoryModel repo : repositories) {\r
// exclude Owner or personal repositories\r
restricted.add(repo.name);\r
} \r
}\r
+ repoMap.put(repo.name.toLowerCase(), repo);\r
}\r
StringUtils.sortRepositorynames(restricted);\r
\r
list.remove(rp.registrant.toLowerCase());\r
}\r
}\r
+ \r
+ // update owner and missing permissions for editing\r
+ for (RegistrantAccessPermission permission : permissions) {\r
+ if (permission.mutable && PermissionType.EXPLICIT.equals(permission.permissionType)) {\r
+ // Ensure this is NOT an owner permission - which is non-editable\r
+ // We don't know this from within the usermodel, ownership is a\r
+ // property of a repository.\r
+ RepositoryModel rm = repoMap.get(permission.registrant.toLowerCase());\r
+ if (rm == null) {\r
+ permission.permissionType = PermissionType.MISSING;\r
+ permission.mutable = false;\r
+ continue;\r
+ }\r
+ boolean isOwner = rm.isOwner(username);\r
+ if (isOwner) {\r
+ permission.permissionType = PermissionType.OWNER;\r
+ permission.mutable = false;\r
+ }\r
+ }\r
+ }\r
+\r
repositoryPalette.setObjects(list, permissions);\r
}\r
\r
setToolTipText(MessageFormat.format(Translation.get("gb.regexPermission"), ap.source));\r
break;\r
default:\r
- setText("");\r
- setToolTipText(null);\r
+ if (ap.isMissing()) {\r
+ setText(Translation.get("gb.missing"));\r
+ setToolTipText(Translation.get("gb.missingPermission"));\r
+ } else {\r
+ setText("");\r
+ setToolTipText(null);\r
+ }\r
break;\r
}\r
}\r
import java.awt.event.MouseAdapter;\r
import java.awt.event.MouseEvent;\r
import java.io.IOException;\r
-import java.text.MessageFormat;\r
import java.util.ArrayList;\r
import java.util.List;\r
\r
import javax.swing.event.ListSelectionListener;\r
import javax.swing.table.TableRowSorter;\r
\r
+import com.gitblit.Constants.AccessPermission;\r
import com.gitblit.Constants.PermissionType;\r
import com.gitblit.Constants.RpcRequest;\r
import com.gitblit.models.RegistrantAccessPermission;\r
gitblit.getSettings());\r
dialog.setLocationRelativeTo(UsersPanel.this);\r
dialog.setUsers(gitblit.getUsers());\r
- \r
- List<RegistrantAccessPermission> permissions = user.getRepositoryPermissions();\r
- for (RegistrantAccessPermission permission : permissions) {\r
- if (permission.mutable && PermissionType.EXPLICIT.equals(permission.permissionType)) {\r
- // Ensure this is NOT an owner permission - which is non-editable\r
- // We don't know this from within the usermodel, ownership is a\r
- // property of a repository.\r
- RepositoryModel rm = gitblit.getRepository(permission.registrant);\r
- if (rm == null) {\r
- System.out.println(MessageFormat.format("{0}: failed to find registrant repository {1}",\r
- getClass().getSimpleName(), permission.registrant));\r
- continue;\r
- }\r
- boolean isOwner = rm.isOwner(user.username);\r
- if (isOwner) {\r
- permission.permissionType = PermissionType.OWNER;\r
- permission.mutable = false;\r
- }\r
- }\r
- }\r
- \r
dialog.setRepositories(gitblit.getRepositories(), user.getRepositoryPermissions());\r
dialog.setTeams(gitblit.getTeams(), user.teams == null ? null : new ArrayList<TeamModel>(\r
user.teams));\r
return PermissionType.OWNER.equals(permissionType);
}
+ public boolean isMissing() {
+ return PermissionType.MISSING.equals(permissionType);
+ }
+
@Override
public int compareTo(RegistrantAccessPermission p) {
switch (registrantType) {
pType = PermissionType.REGEX;\r
source = registrant;\r
}\r
- if (AccessPermission.MISSING.equals(entry.getValue())) {\r
- // repository can not be found, permission is not editable\r
- editable = false;\r
- }\r
list.add(new RegistrantAccessPermission(registrant, entry.getValue(), pType, RegistrantType.REPOSITORY, source, editable));\r
}\r
Collections.sort(list);\r
gb.administrator = admin\r
gb.administratorPermission = Gitblit administrator\r
gb.team = team\r
-gb.teamPermission = permission set by \"{0}\" team membership
\ No newline at end of file
+gb.teamPermission = permission set by \"{0}\" team membership\r
+gb.missing = missing!\r
+gb.missingPermission = the repository for this permission is missing!
\ No newline at end of file
import org.apache.wicket.model.Model;\r
import org.apache.wicket.model.util.CollectionModel;\r
import org.apache.wicket.model.util.ListModel;\r
-import org.slf4j.LoggerFactory;\r
\r
import com.gitblit.Constants.PermissionType;\r
import com.gitblit.Constants.RegistrantType;\r
// property of a repository.\r
RepositoryModel rm = GitBlit.self().getRepositoryModel(permission.registrant);\r
if (rm == null) {\r
- LoggerFactory.getLogger(getClass()).error("Missing repository " + permission.registrant);\r
+ permission.permissionType = PermissionType.MISSING;\r
+ permission.mutable = false;\r
continue;\r
}\r
boolean isOwner = rm.isOwner(oldName);\r
final RegistrantAccessPermission entry = item.getModelObject();
if (RegistrantType.REPOSITORY.equals(entry.registrantType)) {
String repoName = StringUtils.stripDotGit(entry.registrant);
- if (StringUtils.findInvalidCharacter(repoName) == null) {
+ if (!entry.isMissing() && StringUtils.findInvalidCharacter(repoName) == null) {
// repository, strip .git and show swatch
Label registrant = new Label("registrant", repoName);
WicketUtils.setCssClass(registrant, "repositorySwatch");
WicketUtils.setCssBackground(registrant, repoName);
item.add(registrant);
} else {
- // likely a regex
+ // regex or missing
Label label = new Label("registrant", entry.registrant);
WicketUtils.setCssStyle(label, "font-weight: bold;");
item.add(label);
item.add(regex);
break;
default:
- item.add(new Label("pType", "").setVisible(false));
+ if (entry.isMissing()) {
+ // repository is missing, this permission will be removed on save
+ Label missing = new Label("pType", getString("gb.missing"));
+ WicketUtils.setCssClass(missing, "label label-important");
+ WicketUtils.setHtmlTooltip(missing, getString("gb.missingPermission"));
+ item.add(missing);
+ } else {
+ // standard permission
+ item.add(new Label("pType", "").setVisible(false));
+ }
break;
}