| | |
| | |
|
| | | import java.io.Serializable;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collection;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | // field names are reflectively mapped in EditRepository page
|
| | | public String name;
|
| | | public String description;
|
| | | public String owner;
|
| | | public List<String> owners;
|
| | | public Date lastChange;
|
| | | public boolean hasCommits;
|
| | | public boolean showRemoteBranches;
|
| | |
| | | public RepositoryModel(String name, String description, String owner, Date lastchange) {
|
| | | this.name = name;
|
| | | this.description = description;
|
| | | this.owner = owner;
|
| | | this.lastChange = lastchange;
|
| | | this.accessRestriction = AccessRestrictionType.NONE;
|
| | | this.authorizationControl = AuthorizationControl.NAMED;
|
| | | this.federationSets = new ArrayList<String>();
|
| | | this.federationStrategy = FederationStrategy.FEDERATE_THIS;
|
| | | this.projectPath = StringUtils.getFirstPathElement(name);
|
| | | this.owners = new ArrayList<String>();
|
| | | |
| | | addOwner(owner);
|
| | | }
|
| | |
|
| | | public List<String> getLocalBranches() {
|
| | |
| | | }
|
| | |
|
| | | public boolean isOwner(String username) {
|
| | | return owner != null && username != null && owner.equalsIgnoreCase(username);
|
| | | if (StringUtils.isEmpty(username) || ArrayUtils.isEmpty(owners)) {
|
| | | return false;
|
| | | }
|
| | | return owners.contains(username.toLowerCase());
|
| | | }
|
| | |
|
| | | public boolean isPersonalRepository() {
|
| | |
| | | clone.sparkleshareId = sparkleshareId;
|
| | | return clone;
|
| | | }
|
| | | } |
| | |
|
| | | public void addOwner(String username) {
|
| | | if (!StringUtils.isEmpty(username)) {
|
| | | String name = username.toLowerCase();
|
| | | // a set would be more efficient, but this complicates JSON
|
| | | // deserialization so we enforce uniqueness with an arraylist
|
| | | if (!owners.contains(name)) {
|
| | | owners.add(name);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void removeOwner(String username) {
|
| | | if (!StringUtils.isEmpty(username)) {
|
| | | owners.remove(username.toLowerCase());
|
| | | }
|
| | | }
|
| | |
|
| | | public void addOwners(Collection<String> usernames) {
|
| | | if (!ArrayUtils.isEmpty(usernames)) {
|
| | | for (String username : usernames) {
|
| | | addOwner(username);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void removeOwners(Collection<String> usernames) {
|
| | | if (!ArrayUtils.isEmpty(owners)) {
|
| | | for (String username : usernames) {
|
| | | removeOwner(username);
|
| | | }
|
| | | }
|
| | | }
|
| | | } |