@Override
  public Set<Resource> getResources(Request request, Predicate predicate)
    throws SystemException, UnsupportedPropertyException,
    NoSuchResourceException, NoSuchParentResourceException {

    Set<Resource> results = new LinkedHashSet<>();
    Long mpackId = null;
    //Fetch all mpacks
    if (predicate == null) {
      // Fetch all mpacks
      Set<MpackResponse> responses = getManagementController().getMpacks();
      if (null == responses) {
        responses = Collections.emptySet();
      }

      for (MpackResponse response : responses) {
        Resource resource = setResources(response);
        Set<String> requestIds = getRequestPropertyIds(request, predicate);
        if (requestIds.contains(MODULES)) {
          List<Module> modules = getManagementController().getModules(response.getId());
          resource.setProperty(MODULES, modules);
        }
        results.add(resource);
      }
    } else {
      // Fetch a particular mpack based on id
      Map<String, Object> propertyMap = new HashMap<>(PredicateHelper.getProperties(predicate));
      if (propertyMap.containsKey(MPACK_RESOURCE_ID)) {
        Object objMpackId = propertyMap.get(MPACK_RESOURCE_ID);
        if (objMpackId != null) {
          mpackId = Long.valueOf((String) objMpackId);
        }
        MpackResponse response = getManagementController().getMpack(mpackId);

        if (null != response) {
          Resource resource = setResources(response);
          List<Module> modules = getManagementController().getModules(response.getId());
          resource.setProperty(MODULES, modules);
          results.add(resource);
        }
      } //Fetch an mpack based on a stackVersion query
      else if (propertyMap.containsKey(STACK_NAME_PROPERTY_ID)
              && propertyMap.containsKey(STACK_VERSION_PROPERTY_ID)) {
        String stackName = (String) propertyMap.get(STACK_NAME_PROPERTY_ID);
        String stackVersion = (String) propertyMap.get(STACK_VERSION_PROPERTY_ID);
        StackEntity stackEntity = stackDAO.find(stackName, stackVersion);
        mpackId = stackEntity.getMpackId();
        MpackResponse response = getManagementController().getMpack(mpackId);

        if (null != response) {
          Resource resource = setResources(response);
          resource.setProperty(STACK_NAME_PROPERTY_ID, stackName);
          resource.setProperty(STACK_VERSION_PROPERTY_ID, stackVersion);
          results.add(resource);
        }
      }
      if (null == mpackId) {
        throw new IllegalArgumentException(
                "Either the management pack ID or the stack name and version are required when searching");
      }

      if (results.isEmpty()) {
        throw new NoSuchResourceException("The requested resource doesn't exist: " + predicate);
      }
    }
    return results;
  }
Validates the request body for the required properties in order to create an Mpack resource.

@param mpackRequest
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java