Package com.google.gerrit.server.git

Examples of com.google.gerrit.server.git.MetaDataUpdate$User


      throw new ProjectCreationFailedException(msg, e);
    }
  }

  private void createProjectConfig() throws IOException, ConfigInvalidException {
    final MetaDataUpdate md =
        metaDataUpdateFactory.create(createProjectArgs.getProject());
    try {
      final ProjectConfig config = ProjectConfig.read(md);
      config.load(md);

      Project newProject = config.getProject();
      newProject.setDescription(createProjectArgs.projectDescription);
      newProject.setSubmitType(createProjectArgs.submitType);
      newProject
          .setUseContributorAgreements(createProjectArgs.contributorAgreements);
      newProject.setUseSignedOffBy(createProjectArgs.signedOffBy);
      newProject.setUseContentMerge(createProjectArgs.contentMerge);
      newProject.setRequireChangeID(createProjectArgs.changeIdRequired);
      if (createProjectArgs.newParent != null) {
        newProject.setParentName(createProjectArgs.newParent.getProject()
            .getNameKey());
      }

      if (!createProjectArgs.ownerIds.isEmpty()) {
        final AccessSection all =
            config.getAccessSection(AccessSection.ALL, true);
        for (AccountGroup.UUID ownerId : createProjectArgs.ownerIds) {
          GroupDescription.Basic g = groupBackend.get(ownerId);
          if (g != null) {
            GroupReference group = config.resolve(GroupReference.forGroup(g));
            all.getPermission(Permission.OWNER, true).add(
                new PermissionRule(group));
          }
        }
      }

      md.setMessage("Created project\n");
      config.commit(md);
    } finally {
      md.close();
    }
    projectCache.onCreateProject(createProjectArgs.getProject());
    repoManager.setProjectDescription(createProjectArgs.getProject(),
        createProjectArgs.projectDescription);
    referenceUpdated.fire(createProjectArgs.getProject(),
View Full Code Here


    // Load the current configuration from the repository, ensuring its the most
    // recent version available. If it differs from what was in the project
    // state, force a cache flush now.
    //
    ProjectConfig config;
    MetaDataUpdate md = metaDataUpdateFactory.create(projectName);
    try {
      config = ProjectConfig.read(md);

      if (config.updateGroupNames(groupBackend)) {
        md.setMessage("Update group names\n");
        config.commit(md);
        projectCache.evict(config.getProject());
        pc = open();
      } else if (config.getRevision() != null
          && !config.getRevision().equals(
              pc.getProjectState().getConfig().getRevision())) {
        projectCache.evict(config.getProject());
        pc = open();
      }
    } finally {
      md.close();
    }

    final RefControl metaConfigControl = pc.controlForRef(GitRepositoryManager.REF_CONFIG);
    List<AccessSection> local = new ArrayList<AccessSection>();
    Set<String> ownerOf = new HashSet<String>();
View Full Code Here

      ConfigInvalidException, InvalidNameException, NoSuchGroupException,
      OrmException {
    final ProjectControl projectControl =
        projectControlFactory.controlFor(projectName);

    final MetaDataUpdate md;
    try {
      md = metaDataUpdateFactory.create(projectName);
    } catch (RepositoryNotFoundException notFound) {
      throw new NoSuchProjectException(projectName);
    }
    try {
      ProjectConfig config = ProjectConfig.read(md, base);
      Set<String> toDelete = scanSectionNames(config);

      for (AccessSection section : mergeSections(sectionList)) {
        String name = section.getName();

        if (AccessSection.GLOBAL_CAPABILITIES.equals(name)) {
          if (checkIfOwner && !projectControl.isOwner()) {
            continue;
          }
          replace(config, toDelete, section);

        } else if (AccessSection.isValid(name)) {
          if (checkIfOwner && !projectControl.controlForRef(name).isOwner()) {
            continue;
          }

          RefControl.validateRefPattern(name);

          replace(config, toDelete, section);
        }
      }

      for (String name : toDelete) {
        if (AccessSection.GLOBAL_CAPABILITIES.equals(name)) {
          if (!checkIfOwner || projectControl.isOwner()) {
            config.remove(config.getAccessSection(name));
          }

        } else if (!checkIfOwner ||  projectControl.controlForRef(name).isOwner()) {
          config.remove(config.getAccessSection(name));
        }
      }

      if (message != null && !message.isEmpty()) {
        if (!message.endsWith("\n")) {
          message += "\n";
        }
        md.setMessage(message);
      } else {
        md.setMessage("Modify access rules\n");
      }

      return updateProjectConfig(config, md);
    } finally {
      md.close();
    }
  }
View Full Code Here

      } catch (IOException e) {
        throw new OrmException(e);
      }

      try {
        MetaDataUpdate md =
            new MetaDataUpdate(GitReferenceUpdated.DISABLED, name, git);
        md.getCommitBuilder().setAuthor(serverUser);
        md.getCommitBuilder().setCommitter(serverUser);

        ProjectConfig config = ProjectConfig.read(md);

        // Update the existing refences to the new reference.
        boolean updated = false;
        for (Map.Entry<AccountGroup.UUID, GroupReference> entry: ldapUUIDMap.entrySet()) {
          GroupReference ref = config.getGroup(entry.getKey());
          if (ref != null) {
            updated = true;
            ref.setName(entry.getValue().getName());
            ref.setUUID(entry.getValue().getUUID());
            config.resolve(ref);
          }
        }

        // Determine if a toResolve group is used and should be made INTERNAL.
        Iterator<AccountGroup.UUID> iter = toResolve.iterator();
        while (iter.hasNext()) {
          AccountGroup.UUID uuid = iter.next();
          if (config.getGroup(uuid) != null) {
            resolveToUpdate.add(uuid);
            iter.remove();
          }
        }

        if (!updated) {
          continue;
        }

        md.setMessage("Switch LDAP group UUIDs to DNs\n");
        config.commit(md);
      } catch (IOException e) {
        throw new OrmException(e);
      } catch (ConfigInvalidException e) {
        throw new OrmException(e);
View Full Code Here

            + "'\n");
        continue;
      }

      try {
        MetaDataUpdate md = metaDataUpdateFactory.create(nameKey);
        try {
          ProjectConfig config = ProjectConfig.read(md);
          config.getProject().setParentName(newParentKey);
          md.setMessage("Inherit access from "
              + (newParentKey != null ? newParentKey.get() : allProjectsName.get()) + "\n");
          config.commit(md);
        } finally {
          md.close();
        }
      } catch (RepositoryNotFoundException notFound) {
        err.append("error: Project " + name + " not found\n");
      } catch (IOException e) {
        final String msg = "Cannot update project " + name;
View Full Code Here

    Project.NameKey nameKey = ctlProject.getNameKey();
    String name = ctlProject.getName();
    final StringBuilder err = new StringBuilder();

    try {
      MetaDataUpdate md = metaDataUpdateFactory.create(nameKey);
      try {
        ProjectConfig config = ProjectConfig.read(md);
        Project project = config.getProject();

        project.setRequireChangeID(requireChangeID != null ? requireChangeID
            : project.isRequireChangeID());

        project.setRequireChangeID(noRequireChangeID != null
            ? !noRequireChangeID : project.isRequireChangeID());

        project.setSubmitType(submitType != null ? submitType : project
            .getSubmitType());

        project.setUseContentMerge(contentMerge != null ? contentMerge
            : project.isUseContentMerge());

        project.setUseContentMerge(noContentMerge != null ? !noContentMerge
            : project.isUseContentMerge());

        project.setUseContributorAgreements(contributorAgreements != null
            ? contributorAgreements : project.isUseContributorAgreements());

        project.setUseContributorAgreements(noContributorAgreements != null
            ? !noContributorAgreements : project.isUseContributorAgreements());

        project.setUseSignedOffBy(signedOffBy != null ? signedOffBy : project
            .isUseSignedOffBy());

        project.setUseContentMerge(noSignedOffBy != null ? !noSignedOffBy
            : project.isUseContentMerge());

        project.setDescription(projectDescription != null ? projectDescription
            : project.getDescription());

        project.setState(state != null ? state : project.getState());

        md.setMessage("Project settings updated");
        config.commit(md);
      } finally {
        md.close();
      }
    } catch (RepositoryNotFoundException notFound) {
      err.append("error: Project " + name + " not found\n");
    } catch (IOException e) {
      final String msg = "Cannot update project " + name;
View Full Code Here

            Form<User> userForm = Form.form(User.class).bind(ImmutableMap.of("email", "e"));
            //#handle-errors
            if (userForm.hasErrors()) {
                return badRequest(views.html.form.render(userForm));
            } else {
                User user = userForm.get();
                return ok("Got user " + user);
            }
            //#handle-errors
        }
View Full Code Here

        //#bind
        Map<String,String> anyData = new HashMap();
        anyData.put("email", "bob@gmail.com");
        anyData.put("password", "secret");

        User user = userForm.bind(anyData).get();
        //#bind

        assertThat(user.email, equalTo("bob@gmail.com"));
        assertThat(user.password, equalTo("secret"));
    }
View Full Code Here

                this.password = password;
            }
        }
        Form<javaguide.forms.u1.User> userForm = Form.form(javaguide.forms.u1.User.class);
        //#fill
        userForm = userForm.fill(new User("bob@gmail.com", "secret"));
        //#fill
        assertThat(userForm.field("email").value(), equalTo("bob@gmail.com"));
        assertThat(userForm.field("password").value(), equalTo("secret"));
    }
View Full Code Here

    public static class Controller1 extends MockJavaAction {
        public Result index() {
            Form<User> userForm = Form.form(User.class);
            //#bind-from-request
            User user = userForm.bindFromRequest().get();
            //#bind-from-request

            return ok(user.email);
        }
View Full Code Here

TOP

Related Classes of com.google.gerrit.server.git.MetaDataUpdate$User

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.