Examples of ProjectCreationFailedException


Examples of com.google.gerrit.common.errors.ProjectCreationFailedException

        }
      } finally {
        repo.close();
      }
    } catch (RepositoryCaseMismatchException e) {
      throw new ProjectCreationFailedException("Cannot create " + nameKey.get()
          + " because the name is already occupied by another project."
          + " The other project has the same name, only spelled in a"
          + " different case.", e);
    } catch (RepositoryNotFoundException badName) {
      throw new ProjectCreationFailedException("Cannot create " + nameKey, badName);
    } catch (IllegalStateException err) {
      try {
        final Repository repo = repoManager.openRepository(nameKey);
        try {
          if (repo.getObjectDatabase().exists()) {
            throw new ProjectCreationFailedException("project \"" + nameKey + "\" exists");
          }
        } finally {
          repo.close();
        }
      } catch (IOException ioErr) {
        final String msg = "Cannot create " + nameKey;
        log.error(msg, err);
        throw new ProjectCreationFailedException(msg, ioErr);
      }
    } catch (Exception e) {
      final String msg = "Cannot create " + nameKey;
      log.error(msg, e);
      throw new ProjectCreationFailedException(msg, e);
    }
  }
View Full Code Here

Examples of com.google.gerrit.common.errors.ProjectCreationFailedException

  }

  private void validateParameters() throws ProjectCreationFailedException {
    if (createProjectArgs.getProjectName() == null
        || createProjectArgs.getProjectName().isEmpty()) {
      throw new ProjectCreationFailedException("Project name is required");
    }

    if (createProjectArgs.getProjectName().endsWith(Constants.DOT_GIT_EXT)) {
      createProjectArgs.setProjectName(createProjectArgs.getProjectName()
          .substring(
              0,
              createProjectArgs.getProjectName().length()
                  - Constants.DOT_GIT_EXT.length()));
    }

    if (!currentUser.getCapabilities().canCreateProject()) {
      throw new ProjectCreationFailedException(String.format(
          "%s does not have \"Create Project\" capability.",
          currentUser.getUserName()));
    }

    if (createProjectArgs.ownerIds == null
        || createProjectArgs.ownerIds.isEmpty()) {
      createProjectArgs.ownerIds =
          new ArrayList<AccountGroup.UUID>(projectOwnerGroups);
    }

    List<String> transformedBranches = new ArrayList<String>();
    if (createProjectArgs.branch == null ||
        createProjectArgs.branch.isEmpty()) {
      createProjectArgs.branch = Collections.singletonList(Constants.MASTER);
    }
    for (String branch : createProjectArgs.branch) {
      while (branch.startsWith("/")) {
        branch = branch.substring(1);
      }
      if (!branch.startsWith(Constants.R_HEADS)) {
        branch = Constants.R_HEADS + branch;
      }
      if (!Repository.isValidRefName(branch)) {
        throw new ProjectCreationFailedException(String.format(
            "Branch \"%s\" is not a valid name.", branch));
      }
      if (!transformedBranches.contains(branch)) {
        transformedBranches.add(branch);
      }
View Full Code Here

Examples of com.google.gerrit.common.errors.ProjectCreationFailedException

    if (!parentName.equals("")) {
      final Project.NameKey nameKey = new Project.NameKey(parentName);
      try {
        args.newParent = projectControlFactory.validateFor(nameKey);
      } catch (NoSuchProjectException e) {
        throw new ProjectCreationFailedException("Parent project \""
            + parentName + "\" does not exist.", e);
      }
    }
    args.projectDescription = "";
    args.submitType = SubmitType.MERGE_IF_NECESSARY;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.