コード例 #1
0
  private void validateCreateOrgData(
      String orgName,
      String password,
      String firstName,
      String lastName,
      String email,
      Boolean usePamAuth) {

    Map<String, String> values = new HashMap<String, String>();
    values.put("orgName", orgName);
    values.put("desiredPassword", password);
    values.put("desiredPasswordConfirm", password);
    values.put("firstNames", firstName);
    values.put("lastName", lastName);

    ValidatorResult result =
        RhnValidationHelper.validate(
            this.getClass(), values, new LinkedList<String>(values.keySet()), VALIDATION_XSD);

    if (!result.isEmpty()) {
      log.error("Validation errors:");
      for (ValidatorError error : result.getErrors()) {
        log.error("   " + error.getMessage());
      }
      // Multiple errors could return here, but we'll have to just throw an
      // exception for the first one and return that to the user.
      ValidatorError e = result.getErrors().get(0);
      throw new ValidationException(e.getMessage());
    }

    if (!usePamAuth && StringUtils.isEmpty(password)) {
      throw new FaultException(
          -501, "passwordRequiredOrUsePam", "Password is required if not using PAM authentication");
    }
  }
コード例 #2
0
  /**
   * Set an organizations entitlement allocation for a channel family.
   *
   * <p>If increasing the entitlement allocation, the default organization must have a sufficient
   * number of free entitlements.
   *
   * @param sessionKey User's session key.
   * @param orgId Organization ID to set allocation for.
   * @param channelFamilyLabel Channel family to set allocation for.
   * @param allocation New flex entitlement allocation.
   * @return 1 on success.
   * @xmlrpc.doc Set an organization's flex entitlement allocation for the given software
   *     entitlement.
   *     <p>If increasing the flex entitlement allocation, the default organization (i.e. orgId=1)
   *     must have a sufficient number of free flex entitlements.
   * @xmlrpc.param #param("string", "sessionKey")
   * @xmlrpc.param #param("int", "orgId")
   * @xmlrpc.param #param_desc("string", "label", "Software entitlement label.")
   * @xmlrpc.param #param("int", "allocation")
   * @xmlrpc.returntype #return_int_success()
   */
  public int setSoftwareFlexEntitlements(
      String sessionKey, Integer orgId, String channelFamilyLabel, Integer allocation) {

    getSatAdmin(sessionKey);
    Org org = verifyOrgExists(orgId);
    lookupChannelFamily(channelFamilyLabel);

    UpdateOrgSoftwareEntitlementsCommand cmd =
        new UpdateOrgSoftwareEntitlementsCommand(
            channelFamilyLabel, org, null, Long.valueOf(allocation));
    ValidatorError ve = cmd.store();
    if (ve != null) {
      throw new ValidationException(ve.getMessage());
    }

    return 1;
  }
コード例 #3
0
  /**
   * Set an organizations entitlement allocation for a channel family.
   *
   * <p>If increasing the entitlement allocation, the default organization (i.e. orgId=1) must have
   * a sufficient number of free entitlements.
   *
   * @param sessionKey User's session key.
   * @param orgId Organization ID to set allocation for.
   * @param systemEntitlementLabel System entitlement to set allocation for.
   * @param allocation New entitlement allocation.
   * @return 1 on success.
   * @xmlrpc.doc Set an organization's entitlement allocation for the given software entitlement.
   *     <p>If increasing the entitlement allocation, the default organization (i.e. orgId=1) must
   *     have a sufficient number of free entitlements.
   * @xmlrpc.param #param("string", "sessionKey")
   * @xmlrpc.param #param("int", "orgId")
   * @xmlrpc.param #param_desc("string", "label", "System entitlement label. Valid values include:")
   *     #options() #item("enterprise_entitled") #item("monitoring_entitled")
   *     #item("provisioning_entitled") #item("virtualization_host")
   *     #item("virtualization_host_platform") #options_end()
   * @xmlrpc.param #param("int", "allocation")
   * @xmlrpc.returntype #return_int_success()
   */
  public int setSystemEntitlements(
      String sessionKey, Integer orgId, String systemEntitlementLabel, Integer allocation) {

    getSatAdmin(sessionKey);

    Org org = verifyOrgExists(orgId);

    Entitlement ent = EntitlementManager.getByName(systemEntitlementLabel);
    if (ent == null
        || (!EntitlementManager.getAddonEntitlements().contains(ent)
            && !EntitlementManager.getBaseEntitlements().contains(ent))) {
      throw new InvalidEntitlementException();
    }

    UpdateOrgSystemEntitlementsCommand cmd =
        new UpdateOrgSystemEntitlementsCommand(ent, org, new Long(allocation));
    ValidatorError ve = cmd.store();
    if (ve != null) {
      throw new ValidationException(ve.getMessage());
    }

    return 1;
  }