@Override
    public void process(Request request, TreeNode<Resource> resultNode, String href) {
      if (href.contains("/stacks/")) {
        ResourceImpl mpack = (ResourceImpl) resultNode.getObject();
        Map<String, Map<String, Object>> mapInfo = mpack.getPropertiesMap();
        Map<String, Object> mpackInfo = mapInfo.get("MpackInfo");

        int idx = href.indexOf("stacks/");
        Long mpackId = (Long)mpackInfo.get("id");
        href = href.substring(0, idx) + "mpacks/" + mpackId;
        resultNode.setProperty("href", href);
      } else {
        super.process(request, resultNode, href);
      }
    }
Post Processing the mpack href when the call comes from stack endpoint to ensure that the
href is a backreference to the mpacks end point
ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java