| | |
| | | import com.gitblit.manager.IGitblit; |
| | | import com.gitblit.models.RegistrantAccessPermission; |
| | | import com.gitblit.models.RepositoryModel; |
| | | import com.gitblit.models.TeamModel; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.ssh.SshKey; |
| | | import com.gitblit.transport.ssh.commands.CommandMetaData; |
| | |
| | | UserModel u = getUser(true); |
| | | |
| | | // fields |
| | | String [] fheaders = new String [] { "Field", "Value" }; |
| | | Object [][] fdata = new Object[5][]; |
| | | fdata[0] = new Object [] { "Email", u.emailAddress }; |
| | | fdata[1] = new Object [] { "Type", u.accountType }; |
| | | fdata[2] = new Object [] { "Can Admin", u.canAdmin() ? "Y":"" }; |
| | | fdata[3] = new Object [] { "Can Fork", u.canFork() ? "Y":"" }; |
| | | fdata[4] = new Object [] { "Can Create", u.canCreate() ? "Y":"" }; |
| | | String fields = FlipTable.of(fheaders, fdata, Borders.COLS); |
| | | StringBuilder fb = new StringBuilder(); |
| | | fb.append("Email : ").append(u.emailAddress == null ? "": u.emailAddress).append('\n'); |
| | | fb.append("Type : ").append(u.accountType).append('\n'); |
| | | fb.append("Can Admin : ").append(u.canAdmin() ? "Y":"").append('\n'); |
| | | fb.append("Can Fork : ").append(u.canFork() ? "Y":"").append('\n'); |
| | | fb.append("Can Create : ").append(u.canCreate() ? "Y":"").append('\n'); |
| | | String fields = fb.toString(); |
| | | |
| | | // teams |
| | | String teams; |
| | | if (u.teams.size() == 0) { |
| | | teams = FlipTable.EMPTY; |
| | | } else { |
| | | String [] theaders = new String [] { "Team", "Type" }; |
| | | Object [][] tdata = new Object[u.teams.size()][]; |
| | | int i = 0; |
| | | for (TeamModel t : u.teams) { |
| | | tdata[i] = new Object [] { t.name, t.accountType }; |
| | | i++; |
| | | } |
| | | teams = FlipTable.of(theaders, tdata, Borders.COLS); |
| | | teams = Joiner.on(", ").join(u.teams); |
| | | } |
| | | |
| | | // owned repositories |
| | |
| | | protected void asTable(List<UserModel> list) { |
| | | String[] headers; |
| | | if (verbose) { |
| | | String[] h = { "Name", "Display name", "Type", "Email", "Create?", "Fork?"}; |
| | | String[] h = { "Name", "Display name", "Email", "Type", "Teams", "Create?", "Fork?"}; |
| | | headers = h; |
| | | } else { |
| | | String[] h = { "Name", "Display name", "Type", "Email"}; |
| | | String[] h = { "Name", "Display name", "Email", "Type"}; |
| | | headers = h; |
| | | } |
| | | |
| | |
| | | |
| | | String name = (u.disabled ? "-" : ((u.canAdmin() ? "*" : " "))) + u.username; |
| | | if (verbose) { |
| | | data[i] = new Object[] { name, u.displayName, u.accountType, |
| | | data[i] = new Object[] { |
| | | name, |
| | | u.displayName, |
| | | u.emailAddress, |
| | | u.accountType + (u.canAdmin() ? ",admin":""), |
| | | u.teams.isEmpty() ? "" : u.teams.size(), |
| | | (u.canAdmin() || u.canCreate()) ? "Y":"", |
| | | (u.canAdmin() || u.canFork()) ? "Y" : ""}; |
| | | } else { |
| | | data[i] = new Object[] { name, u.displayName, u.accountType, |
| | | u.emailAddress }; |
| | | data[i] = new Object[] { |
| | | name, |
| | | u.displayName, |
| | | u.emailAddress, |
| | | u.accountType + (u.canAdmin() ? ",admin":"")}; |
| | | } |
| | | } |
| | | stdout.print(FlipTable.of(headers, data, Borders.BODY_HCOLS)); |
| | |
| | | protected void asTabbed(List<UserModel> users) { |
| | | if (verbose) { |
| | | for (UserModel u : users) { |
| | | outTabbed(u.disabled ? "-" : ((u.canAdmin() ? "*" : " ")) + u.username, |
| | | outTabbed( |
| | | u.disabled ? "-" : ((u.canAdmin() ? "*" : " ")) + u.username, |
| | | u.getDisplayName(), |
| | | u.accountType, |
| | | u.emailAddress == null ? "" : u.emailAddress, |
| | | u.accountType + (u.canAdmin() ? ",admin":""), |
| | | u.teams.isEmpty() ? "" : u.teams.size(), |
| | | (u.canAdmin() || u.canCreate()) ? "Y":"", |
| | | (u.canAdmin() || u.canFork()) ? "Y" : ""); |
| | | } |