Package com.gitblit

Examples of com.gitblit.GitBlitException$ForbiddenException


      fetch.setRefSpecs(new RefSpec("+refs/tags/*:refs/tags/*"));
      fetch.call();

      git.getRepository().close();
    } catch (Exception e) {
      throw new GitBlitException(e);
    }

    // create a Gitblit repository model for the clone
    RepositoryModel cloneModel = repository.cloneAs(cloneName);
    // owner has REWIND/RW+ permissions
View Full Code Here


   * @param team
   */
  @Override
  public void addTeam(TeamModel team) throws GitBlitException {
    if (!userManager.updateTeamModel(team)) {
      throw new GitBlitException("Failed to add team!");
    }
  }
View Full Code Here

   */
  @Override
  public void reviseTeam(String teamname, TeamModel team) throws GitBlitException {
    if (!teamname.equalsIgnoreCase(team.name)) {
      if (userManager.getTeamModel(team.name) != null) {
        throw new GitBlitException(MessageFormat.format(
            "Failed to rename ''{0}'' because ''{1}'' already exists.", teamname,
            team.name));
      }
    }
    if (!userManager.updateTeamModel(teamname, team)) {
      throw new GitBlitException("Failed to update team!");
    }
  }
View Full Code Here

   * @throws GitBlitException
   */
  @Override
  public void addUser(UserModel user) throws GitBlitException {
    if (!userManager.updateUserModel(user)) {
      throw new GitBlitException("Failed to add user!");
    }
  }
View Full Code Here

   */
  @Override
  public void reviseUser(String username, UserModel user) throws GitBlitException {
    if (!username.equalsIgnoreCase(user.username)) {
      if (userManager.getUserModel(user.username) != null) {
        throw new GitBlitException(MessageFormat.format(
            "Failed to rename ''{0}'' because ''{1}'' already exists.", username,
            user.username));
      }

      // rename repositories and owner fields for all repositories
      for (RepositoryModel model : repositoryManager.getRepositoryModels(user)) {
        if (model.isUsersPersonalRepository(username)) {
          // personal repository
          model.addOwner(user.username);
          String oldRepositoryName = model.name;
          model.name = user.getPersonalPath() + model.name.substring(model.projectPath.length());
          model.projectPath = user.getPersonalPath();
          repositoryManager.updateRepositoryModel(oldRepositoryName, model, false);
        } else if (model.isOwner(username)) {
          // common/shared repo
          model.addOwner(user.username);
          repositoryManager.updateRepositoryModel(model.name, model, false);
        }
      }

      // rename the user's ssh public keystore
      getPublicKeyManager().renameUser(username, user.username);
    }
    if (!userManager.updateUserModel(username, user)) {
      throw new GitBlitException("Failed to update user!");
    }
  }
View Full Code Here

   */
  @Override
  public void updateRepositoryModel(String repositoryName, RepositoryModel repository,
      boolean isCreate) throws GitBlitException {
    if (gcExecutor.isCollectingGarbage(repositoryName)) {
      throw new GitBlitException(MessageFormat.format("sorry, Gitblit is busy collecting garbage in {0}",
          repositoryName));
    }
    Repository r = null;
    String projectPath = StringUtils.getFirstPathElement(repository.name);
    if (!StringUtils.isEmpty(projectPath)) {
      if (projectPath.equalsIgnoreCase(settings.getString(Keys.web.repositoryRootGroupName, "main"))) {
        // strip leading group name
        repository.name = repository.name.substring(projectPath.length() + 1);
      }
    }
    if (isCreate) {
      // ensure created repository name ends with .git
      if (!repository.name.toLowerCase().endsWith(org.eclipse.jgit.lib.Constants.DOT_GIT_EXT)) {
        repository.name += org.eclipse.jgit.lib.Constants.DOT_GIT_EXT;
      }
      if (hasRepository(repository.name)) {
        throw new GitBlitException(MessageFormat.format(
            "Can not create repository ''{0}'' because it already exists.",
            repository.name));
      }
      // create repository
      logger.info("create repository " + repository.name);
      String shared = settings.getString(Keys.git.createRepositoriesShared, "FALSE");
      r = JGitUtils.createRepository(repositoriesFolder, repository.name, shared);
    } else {
      // rename repository
      if (!repositoryName.equalsIgnoreCase(repository.name)) {
        if (!repository.name.toLowerCase().endsWith(
            org.eclipse.jgit.lib.Constants.DOT_GIT_EXT)) {
          repository.name += org.eclipse.jgit.lib.Constants.DOT_GIT_EXT;
        }
        if (new File(repositoriesFolder, repository.name).exists()) {
          throw new GitBlitException(MessageFormat.format(
              "Failed to rename ''{0}'' because ''{1}'' already exists.",
              repositoryName, repository.name));
        }
        close(repositoryName);
        File folder = new File(repositoriesFolder, repositoryName);
        File destFolder = new File(repositoriesFolder, repository.name);
        if (destFolder.exists()) {
          throw new GitBlitException(
              MessageFormat
                  .format("Can not rename repository ''{0}'' to ''{1}'' because ''{1}'' already exists.",
                      repositoryName, repository.name));
        }
        File parentFile = destFolder.getParentFile();
        if (!parentFile.exists() && !parentFile.mkdirs()) {
          throw new GitBlitException(MessageFormat.format(
              "Failed to create folder ''{0}''", parentFile.getAbsolutePath()));
        }
        if (!folder.renameTo(destFolder)) {
          throw new GitBlitException(MessageFormat.format(
              "Failed to rename repository ''{0}'' to ''{1}''.", repositoryName,
              repository.name));
        }
        // rename the roles
        if (!userManager.renameRepositoryRole(repositoryName, repository.name)) {
          throw new GitBlitException(MessageFormat.format(
              "Failed to rename repository permissions ''{0}'' to ''{1}''.",
              repositoryName, repository.name));
        }

        // rename fork origins in their configs
View Full Code Here

          switch (rc) {
          case FAST_FORWARD:
            // successful, clean merge
            break;
          default:
            throw new GitBlitException(MessageFormat.format("Unexpected result \"{0}\" when merging commit {1} into {2} in {3}",
                rc.name(), srcTip.getName(), branchTip.getName(), repository.getDirectory()));
          }

          // return the merge commit id
          return new MergeResult(MergeStatus.MERGED, mergeCommitId.getName());
View Full Code Here

    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = null;
    try {
      feed = input.build(new XmlReader(is));
    } catch (FeedException f) {
      throw new GitBlitException(f);
    }
    is.close();
    List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();
    for (Object o : feed.getEntries()) {
      SyndEntryImpl entry = (SyndEntryImpl) o;
View Full Code Here

      fetch.setRefSpecs(new RefSpec("+refs/tags/*:refs/tags/*"));
      fetch.call();

      git.getRepository().close();
    } catch (Exception e) {
      throw new GitBlitException(e);
    }

    // create a Gitblit repository model for the clone
    RepositoryModel cloneModel = repository.cloneAs(cloneName);
    // owner has REWIND/RW+ permissions
View Full Code Here

   * @param team
   */
  @Override
  public void addTeam(TeamModel team) throws GitBlitException {
    if (!userManager.updateTeamModel(team)) {
      throw new GitBlitException("Failed to add team!");
    }
  }
View Full Code Here

TOP

Related Classes of com.gitblit.GitBlitException$ForbiddenException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.