diff --git a/Common/TDSQASystemAPI/BL/XmlRepository.cs b/Common/TDSQASystemAPI/BL/XmlRepository.cs index def32ac..1096ab2 100644 --- a/Common/TDSQASystemAPI/BL/XmlRepository.cs +++ b/Common/TDSQASystemAPI/BL/XmlRepository.cs @@ -107,6 +107,11 @@ public XmlDocument GetXmlContent(long fileId) return xmlRepositoryDAL.GetXmlContent(fileId); } + public XmlDocument GetDestinationXmlContent(long fileId) + { + return xmlRepositoryDAL.GetDestinationXmlContent(fileId); + } + public XmlDocument ProcessXmlFile(long fileId) { return xmlRepositoryDAL.ProcessXmlFile(fileId); diff --git a/Common/TDSQASystemAPI/DAL/XmlRepository.cs b/Common/TDSQASystemAPI/DAL/XmlRepository.cs index f63e0fb..3d8dafe 100644 --- a/Common/TDSQASystemAPI/DAL/XmlRepository.cs +++ b/Common/TDSQASystemAPI/DAL/XmlRepository.cs @@ -126,6 +126,30 @@ public XmlDocument GetXmlContent(long fileId) return doc; } + public XmlDocument GetDestinationXmlContent(long fileId) + { + XmlDocument doc = null; + using (DbCommand cmd = _db.GetStoredProcCommand("GetDestinationXmlContentByFileID")) + { + if (dbCommandTimeout != null) + cmd.CommandTimeout = dbCommandTimeout.Value; + _db.AddInParameter(cmd, "@FileID", DbType.Int64, fileId); + using (SqlDataReader rdr = (SqlDataReader)_db.ExecuteReader(cmd)) + { + if (rdr.Read()) + { + if (!rdr.IsDBNull(0)) + { + doc = new XmlDocument(); + doc.Load(rdr.GetSqlXml(0).CreateReader()); + } + } + } + } + + return doc; + } + public XmlDocument ProcessXmlFile(long fileId) { XmlDocument doc = null; diff --git a/TDSQAService/OSS.TIS/DAL/ARTDAL.cs b/TDSQAService/OSS.TIS/DAL/ARTDAL.cs index 7e5c811..14a7e19 100644 --- a/TDSQAService/OSS.TIS/DAL/ARTDAL.cs +++ b/TDSQAService/OSS.TIS/DAL/ARTDAL.cs @@ -52,7 +52,7 @@ public XmlDocument GetStudentPackageXML(string ssid, string stateAbbrviation, bo HttpResponseMessage response = Get(ssid, stateAbbrviation, oauthToken, useAlternateStudentId); - if ((response.StatusCode == HttpStatusCode.Unauthorized || response.StatusCode == HttpStatusCode.Forbidden) && authTokenFoundInCache) + if ((response.StatusCode == HttpStatusCode.Unauthorized || response.StatusCode == HttpStatusCode.Forbidden || response.StatusCode == HttpStatusCode.BadRequest) && authTokenFoundInCache) { // try again with a fresh token; may have expired OAuth.RemoveFromCache(artService.Authorization, oauthToken); diff --git a/TDSQAService/OSS.TIS/SQL/TISDB/1_Create_Objects.sql b/TDSQAService/OSS.TIS/SQL/TISDB/1_Create_Objects.sql index 5772912..903ed46 100644 Binary files a/TDSQAService/OSS.TIS/SQL/TISDB/1_Create_Objects.sql and b/TDSQAService/OSS.TIS/SQL/TISDB/1_Create_Objects.sql differ diff --git a/TISServices/TISServices/Authorization/AuthorizeOpenAMAttribute.cs b/TISServices/TISServices/Authorization/AuthorizeOpenAMAttribute.cs index 3ebd716..ce80cfb 100644 --- a/TISServices/TISServices/Authorization/AuthorizeOpenAMAttribute.cs +++ b/TISServices/TISServices/Authorization/AuthorizeOpenAMAttribute.cs @@ -56,7 +56,7 @@ public override void OnAuthorization(HttpActionContext actionContext) { using (HttpClient client = new HttpClient()) { - response = client.GetAsync(String.Format("{0}?access_token={1}", OpenAMUrl, authKey)).Result; + response = client.GetAsync(String.Format("{0}?access_token={1}&realm=/sbac", OpenAMUrl, authKey)).Result; if (response.IsSuccessStatusCode) { // appears to be a successful authentication. diff --git a/TISServices/TISServices/Services/TestResultController.cs b/TISServices/TISServices/Services/TestResultController.cs index 1b30f38..d66048c 100644 --- a/TISServices/TISServices/Services/TestResultController.cs +++ b/TISServices/TISServices/Services/TestResultController.cs @@ -19,9 +19,10 @@ using TISServices.Utilities; using OSS.TIS; using TISServices.Authorization; +using System.Text; namespace TISServices.Services -{ +{ [AuthorizeOpenAM] public class TestResultController : ApiController { @@ -100,16 +101,29 @@ public HttpResponseMessage Submit(string statusCallback) try { - new XmlRepository().InsertXml(XmlRepository.Location.source, doc, callBackUrl.AbsoluteUri, new TestResultSerializerFactory()); + long fileId = new XmlRepository().InsertXml(XmlRepository.Location.source, doc, callBackUrl.AbsoluteUri, new TestResultSerializerFactory()); Statistics.AddToInsertedRequestCount(); + return Request.CreateResponse(HttpStatusCode.OK, fileId); } catch (Exception ex) { TISServicesLogger.Log(ex); return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Could not persist the request."); } + } + + [HttpGet] + public HttpResponseMessage Get(long fileId) + { + XmlDocument doc = new XmlRepository().GetDestinationXmlContent(fileId); - return Request.CreateResponse(HttpStatusCode.OK); + if (doc == null) + return new HttpResponseMessage(HttpStatusCode.NotFound); + + return new HttpResponseMessage() + { + Content = new StringContent(doc.OuterXml, Encoding.UTF8, "application/xml") + }; } } } \ No newline at end of file