Using ArrayUtils.isEmpty to test arrays and collections
| | |
| | |
|
| | | import com.gitblit.models.TeamModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.DeepCopier;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | |
| | | // repository memberships
|
| | | // null check on "final" repositories because JSON-sourced UserModel
|
| | | // can have a null repositories object
|
| | | if (model.repositories != null) {
|
| | | if (!ArrayUtils.isEmpty(model.repositories)) {
|
| | | config.setStringList(USER, model.username, REPOSITORY, new ArrayList<String>(
|
| | | model.repositories));
|
| | | }
|
| | |
| | | for (TeamModel model : teams.values()) {
|
| | | // null check on "final" repositories because JSON-sourced TeamModel
|
| | | // can have a null repositories object
|
| | | if (model.repositories != null) {
|
| | | if (!ArrayUtils.isEmpty(model.repositories)) {
|
| | | config.setStringList(TEAM, model.name, REPOSITORY, new ArrayList<String>(
|
| | | model.repositories));
|
| | | }
|
| | |
|
| | | // null check on "final" users because JSON-sourced TeamModel
|
| | | // can have a null users object
|
| | | if (model.users != null) {
|
| | | if (!ArrayUtils.isEmpty(model.users)) {
|
| | | config.setStringList(TEAM, model.name, USER, new ArrayList<String>(model.users));
|
| | | }
|
| | |
|
| | | // null check on "final" mailing lists because JSON-sourced
|
| | | // TeamModel can have a null users object
|
| | | if (model.mailingLists != null) {
|
| | | if (!ArrayUtils.isEmpty(model.mailingLists)) {
|
| | | config.setStringList(TEAM, model.name, MAILINGLIST, new ArrayList<String>(
|
| | | model.mailingLists));
|
| | | }
|
| | |
|
| | | // null check on "final" preReceiveScripts because JSON-sourced
|
| | | // TeamModel can have a null preReceiveScripts object
|
| | | if (model.preReceiveScripts != null) {
|
| | | if (!ArrayUtils.isEmpty(model.preReceiveScripts)) {
|
| | | config.setStringList(TEAM, model.name, PRERECEIVE, model.preReceiveScripts);
|
| | | }
|
| | |
|
| | | // null check on "final" postReceiveScripts because JSON-sourced
|
| | | // TeamModel can have a null postReceiveScripts object
|
| | | if (model.postReceiveScripts != null) {
|
| | | if (!ArrayUtils.isEmpty(model.postReceiveScripts)) {
|
| | | config.setStringList(TEAM, model.name, POSTRECEIVE, model.postReceiveScripts);
|
| | | }
|
| | | }
|
| | |
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.TeamModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.FederationUtils;
|
| | | import com.gitblit.utils.FileUtils;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | |
| | |
|
| | | // update team repositories
|
| | | TeamModel remoteTeam = user.getTeam(teamname);
|
| | | if (remoteTeam != null && remoteTeam.repositories != null) {
|
| | | if (remoteTeam != null && !ArrayUtils.isEmpty(remoteTeam.repositories)) {
|
| | | int before = team.repositories.size();
|
| | | team.addRepositories(remoteTeam.repositories);
|
| | | int after = team.repositories.size();
|
| | |
| | | if (scriptName.endsWith(".groovy")) {
|
| | | scriptName = scriptName.substring(0, scriptName.indexOf(".groovy"));
|
| | | }
|
| | | File file = new File(registrationFolderFile, registration.name + "_" + scriptName + ".groovy");
|
| | | File file = new File(registrationFolderFile, registration.name + "_"
|
| | | + scriptName + ".groovy");
|
| | | FileUtils.writeContent(file, script.getValue());
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import com.gitblit.models.TeamModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.DeepCopier;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | |
| | |
|
| | | private void updateTeamCache(Properties allUsers, String teamname, TeamModel model) {
|
| | | StringBuilder sb = new StringBuilder();
|
| | | if (!ArrayUtils.isEmpty(model.repositories)) {
|
| | | for (String repository : model.repositories) {
|
| | | sb.append(repository);
|
| | | sb.append(',');
|
| | | }
|
| | | }
|
| | | if (!ArrayUtils.isEmpty(model.users)) {
|
| | | for (String user : model.users) {
|
| | | sb.append('!');
|
| | | sb.append(user);
|
| | | sb.append(',');
|
| | | }
|
| | | }
|
| | | if (!ArrayUtils.isEmpty(model.mailingLists)) {
|
| | | for (String address : model.mailingLists) {
|
| | | sb.append('&');
|
| | | sb.append(address);
|
| | | sb.append(',');
|
| | | }
|
| | | }
|
| | | if (!ArrayUtils.isEmpty(model.preReceiveScripts)) {
|
| | | for (String script : model.preReceiveScripts) {
|
| | | sb.append('^');
|
| | | sb.append(script);
|
| | | sb.append(',');
|
| | | }
|
| | | }
|
| | | if (!ArrayUtils.isEmpty(model.postReceiveScripts)) {
|
| | | for (String script : model.postReceiveScripts) {
|
| | | sb.append('%');
|
| | | sb.append(script);
|
| | | sb.append(',');
|
| | | }
|
| | | }
|
| | | // trim trailing comma
|
| | | sb.setLength(sb.length() - 1);
|
| | | allUsers.remove("@" + teamname);
|
| | |
| | | import com.gitblit.models.SettingModel;
|
| | | import com.gitblit.models.TeamModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.ByteFormat;
|
| | | import com.gitblit.utils.FederationUtils;
|
| | | import com.gitblit.utils.JGitUtils;
|
| | |
| | | config.setString("gitblit", null, "federationStrategy",
|
| | | repository.federationStrategy.name());
|
| | | config.setBoolean("gitblit", null, "isFederated", repository.isFederated);
|
| | | if (repository.preReceiveScripts != null) {
|
| | | if (!ArrayUtils.isEmpty(repository.preReceiveScripts)) {
|
| | | config.setStringList("gitblit", null, "preReceiveScript", repository.preReceiveScripts);
|
| | | }
|
| | | if (repository.postReceiveScripts != null) {
|
| | | if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {
|
| | | config.setStringList("gitblit", null, "postReceiveScript",
|
| | | repository.postReceiveScripts);
|
| | | }
|
| | | if (repository.mailingLists != null) {
|
| | | if (!ArrayUtils.isEmpty(repository.mailingLists)) {
|
| | | config.setStringList("gitblit", null, "mailingList", repository.mailingLists);
|
| | | }
|
| | | try {
|
| | |
| | | import com.gitblit.Constants.AccessRestrictionType;
|
| | | import com.gitblit.Constants.FederationStrategy;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | | /**
|
| | |
| | | anRepository.skipSummaryMetrics);
|
| | | isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen);
|
| | |
|
| | | mailingListsField = new JTextField(anRepository.mailingLists == null ? ""
|
| | | mailingListsField = new JTextField(ArrayUtils.isEmpty(anRepository.mailingLists) ? ""
|
| | | : StringUtils.flattenStrings(anRepository.mailingLists, " "), 50);
|
| | |
|
| | | accessRestriction = new JComboBox(AccessRestrictionType.values());
|
| | |
| | | import com.gitblit.models.ServerStatus;
|
| | | import com.gitblit.models.TeamModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.RpcUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.utils.SyndicationUtils;
|
| | |
| | | if (repository != null) {
|
| | | for (String teamname : getPermittedTeamnames(repository)) {
|
| | | TeamModel team = getTeamModel(teamname);
|
| | | if (!ArrayUtils.isEmpty(team.preReceiveScripts)) {
|
| | | scripts.addAll(team.preReceiveScripts);
|
| | | }
|
| | | }
|
| | | }
|
| | | return new ArrayList<String>(scripts);
|
| | |
| | | if (repository != null) {
|
| | | for (String teamname : getPermittedTeamnames(repository)) {
|
| | | TeamModel team = getTeamModel(teamname);
|
| | | if (!ArrayUtils.isEmpty(team.postReceiveScripts)) {
|
| | | scripts.addAll(team.postReceiveScripts);
|
| | | }
|
| | | }
|
| | | }
|
| | | return new ArrayList<String>(scripts);
|
| | |
| | |
|
| | | // create list of available scripts by excluding inherited scripts
|
| | | List<String> scripts = new ArrayList<String>();
|
| | | if (!ArrayUtils.isEmpty(settings.pushScripts)) { |
| | | for (String script : settings.pushScripts) {
|
| | | if (!inherited.contains(script)) {
|
| | | scripts.add(script);
|
| | | }
|
| | | }
|
| | | }
|
| | | return scripts;
|
| | | }
|
| | |
|
| | |
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.ArrayUtils;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | |
| | | new ChoiceRenderer<String>("", ""), 5, false);
|
| | |
|
| | | // pre-receive palette
|
| | | if (repositoryModel.preReceiveScripts != null) {
|
| | | if (!ArrayUtils.isEmpty(repositoryModel.preReceiveScripts)) {
|
| | | preReceiveScripts.addAll(repositoryModel.preReceiveScripts);
|
| | | }
|
| | | final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",
|
| | |
| | | new ChoiceRenderer<String>("", ""), 12, true);
|
| | |
|
| | | // post-receive palette
|
| | | if (repositoryModel.postReceiveScripts != null) {
|
| | | if (!ArrayUtils.isEmpty(repositoryModel.postReceiveScripts)) {
|
| | | postReceiveScripts.addAll(repositoryModel.postReceiveScripts);
|
| | | }
|
| | | final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",
|
| | |
| | | form.add(new CheckBox("showReadme"));
|
| | | form.add(new CheckBox("skipSizeCalculation"));
|
| | | form.add(new CheckBox("skipSummaryMetrics"));
|
| | | mailingLists = new Model<String>(repositoryModel.mailingLists == null ? ""
|
| | | mailingLists = new Model<String>(ArrayUtils.isEmpty(repositoryModel.mailingLists) ? ""
|
| | | : StringUtils.flattenStrings(repositoryModel.mailingLists, " "));
|
| | | form.add(new TextField<String>("mailingLists", mailingLists));
|
| | | form.add(usersPalette);
|