public function GetClassDefinition($resId, $schemaName, $className, $format)
 {
     //Check for unsupported representations
     $fmt = $this->ValidateRepresentation($format, array("xml", "json"));
     $sessionId = "";
     if ($resId->GetRepositoryType() == MgRepositoryType::Session) {
         $sessionId = $resId->GetRepositoryName();
     }
     $resIdStr = $resId->ToString();
     $mimeType = $this->GetMimeTypeForFormat($fmt);
     $this->EnsureAuthenticationForSite($sessionId, false, $mimeType);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     $site = $siteConn->GetSite();
     $this->VerifyWhitelist($resIdStr, $mimeType, "GETCLASSDEFINITION", $fmt, $site, $this->userName);
     if ($fmt == "json") {
         //For JSON, we are defining a completely new response format. No point trying to transform the XML version, which is just a plain
         //XML schema. Do we really want to serve a JSON-ified version of that?
         $this->EnsureAuthenticationForSite($sessionId);
         $siteConn = new MgSiteConnection();
         $siteConn->Open($this->userInfo);
         $featSvc = $siteConn->CreateService(MgServiceType::FeatureService);
         $clsDef = $featSvc->GetClassDefinition($resId, $schemaName, $className);
         $this->app->response->header("Content-Type", MgMimeType::Json);
         $this->app->response->setBody(MgUtils::ClassDefinitionToJson($clsDef));
     } else {
         $that = $this;
         $this->EnsureAuthenticationForHttp(function ($req, $param) use($that, $fmt, $schemaName, $className, $resIdStr) {
             $param->AddParameter("OPERATION", "DESCRIBEFEATURESCHEMA");
             $param->AddParameter("VERSION", "1.0.0");
             if ($fmt === "json") {
                 $param->AddParameter("FORMAT", MgMimeType::Json);
             } else {
                 $param->AddParameter("FORMAT", MgMimeType::Xml);
             }
             $param->AddParameter("RESOURCEID", $resIdStr);
             $param->AddParameter("SCHEMA", $schemaName);
             $param->AddParameter("CLASSNAMES", $className);
             $that->ExecuteHttpRequest($req);
         }, false, "", $sessionId, $mimeType);
     }
 }