Merge branch 'master' of https://github.com/jamesagnew/hapi-fhir into jaxrs-sever-evolution

This commit is contained in:
Sebastien Riviere 2017-08-28 14:32:54 +02:00
commit 6a70453294
14 changed files with 138 additions and 73 deletions

View File

@ -38,19 +38,7 @@ function updateHighlightedLineTo(theNewHash) {
selectedLine = line; selectedLine = line;
} }
function updateHyperlinksAndStyles() {
(function() {
'use strict';
updateHighlightedLine();
window.onhashchange = updateHighlightedLine;
/* bail out if user is testing a version of this script via Greasemonkey or Tampermonkey */
if (window.HAPI_ResponseHighlighter_userscript) {
console.log("HAPI ResponseHighlighter: userscript detected - not executing embedded script");
return;
}
/* adds hyperlinks and CSS styles to dates and UUIDs (e.g. to enable user-select: all) */ /* adds hyperlinks and CSS styles to dates and UUIDs (e.g. to enable user-select: all) */
const logicalReferenceRegex = /^[A-Z][A-Za-z]+\/[0-9]+$/; const logicalReferenceRegex = /^[A-Z][A-Za-z]+\/[0-9]+$/;
const dateTimeRegex = /^-?[0-9]{4}(-(0[1-9]|1[0-2])(-(0[0-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?$/; // from the spec - https://www.hl7.org/fhir/datatypes.html#datetime const dateTimeRegex = /^-?[0-9]{4}(-(0[1-9]|1[0-2])(-(0[0-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?$/; // from the spec - https://www.hl7.org/fhir/datatypes.html#datetime
@ -85,4 +73,31 @@ function updateHighlightedLineTo(theNewHash) {
quote.appendChild(document.createTextNode('"')); quote.appendChild(document.createTextNode('"'));
} }
} }
}
(function() {
'use strict';
/* bail out if user is testing a version of this script via Greasemonkey or Tampermonkey */
if (window.HAPI_ResponseHighlighter_userscript) {
console.log("HAPI ResponseHighlighter: userscript detected - not executing embedded script");
return;
}
console.time("updateHighlightedLine");
updateHighlightedLine();
console.timeEnd("updateHighlightedLine");
window.onhashchange = updateHighlightedLine;
console.time("updateHyperlinksAndStyles");
updateHyperlinksAndStyles();
console.timeEnd("updateHyperlinksAndStyles");
window.addEventListener("load", function(event) {
// https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API
var now = new Date().getTime();
var page_load_time = now - performance.timing.navigationStart;
console.log("User-perceived page loading time: " + page_load_time + "ms");
});
})(); })();

View File

@ -53,9 +53,9 @@ public class DaoConfig {
"http://hl7.org/fhir/StructureDefinition/*"))); "http://hl7.org/fhir/StructureDefinition/*")));
/** /**
* Default value for {@link #setMaximumSearchResultCountInTransaction(int)} * Default value for {@link #setMaximumSearchResultCountInTransaction(Integer)}
* *
* @see #setMaximumSearchResultCountInTransaction(int) * @see #setMaximumSearchResultCountInTransaction(Integer)
*/ */
private static final Integer DEFAULT_MAXIMUM_SEARCH_RESULT_COUNT_IN_TRANSACTION = null; private static final Integer DEFAULT_MAXIMUM_SEARCH_RESULT_COUNT_IN_TRANSACTION = null;
@ -220,7 +220,7 @@ public class DaoConfig {
*/ */
public List<IServerInterceptor> getInterceptors() { public List<IServerInterceptor> getInterceptors() {
if (myInterceptors == null) { if (myInterceptors == null) {
myInterceptors = new ArrayList<IServerInterceptor>(); myInterceptors = new ArrayList<>();
} }
return myInterceptors; return myInterceptors;
} }

View File

@ -35,7 +35,7 @@ public interface ITermConceptParentChildLinkDao extends JpaRepository<TermConcep
@Modifying @Modifying
void deleteByCodeSystemVersion(@Param("cs_pid") Long thePid); void deleteByCodeSystemVersion(@Param("cs_pid") Long thePid);
@Query("SELECT t FROM TermConceptParentChildLink t WHERE t.myChildPid = :child_pid") @Query("SELECT t.myParentPid FROM TermConceptParentChildLink t WHERE t.myChildPid = :child_pid")
Collection<TermConceptParentChildLink> findAllWithChild(@Param("child_pid") Long theConceptPid); Collection<Long> findAllWithChild(@Param("child_pid") Long theConceptPid);
} }

View File

@ -357,14 +357,17 @@ public abstract class BaseHapiTerminologySvc implements IHapiTerminologySvc {
if (parents.contains(-1L)) { if (parents.contains(-1L)) {
return; return;
} else if (parents.isEmpty()) { } else if (parents.isEmpty()) {
Collection<TermConceptParentChildLink> parentLinks = myConceptParentChildLinkDao.findAllWithChild(theConceptPid); Collection<Long> parentLinks = myConceptParentChildLinkDao.findAllWithChild(theConceptPid);
if (parentLinks.isEmpty()) { if (parentLinks.isEmpty()) {
myChildToParentPidCache.put(theConceptPid, -1L); myChildToParentPidCache.put(theConceptPid, -1L);
ourLog.info("Found {} parent concepts of concept {} (cache has {})", 0, theConceptPid, myChildToParentPidCache.size());
return; return;
} else { } else {
for (TermConceptParentChildLink next : parentLinks) { for (Long next : parentLinks) {
myChildToParentPidCache.put(theConceptPid, next.getParentPid()); myChildToParentPidCache.put(theConceptPid, next);
} }
int parentCount = myChildToParentPidCache.get(theConceptPid).size();
ourLog.info("Found {} parent concepts of concept {} (cache has {})", parentCount, theConceptPid, myChildToParentPidCache.size());
} }
} }
@ -375,6 +378,7 @@ public abstract class BaseHapiTerminologySvc implements IHapiTerminologySvc {
theParentsBuilder.append(nextParent); theParentsBuilder.append(nextParent);
createParentsString(theParentsBuilder, nextParent); createParentsString(theParentsBuilder, nextParent);
} }
} }
@Override @Override
@ -382,8 +386,11 @@ public abstract class BaseHapiTerminologySvc implements IHapiTerminologySvc {
int maxResult = 1000; int maxResult = 1000;
Page<TermConcept> concepts = myConceptDao.findResourcesRequiringReindexing(new PageRequest(0, maxResult)); Page<TermConcept> concepts = myConceptDao.findResourcesRequiringReindexing(new PageRequest(0, maxResult));
if (concepts.hasContent() == false) { if (concepts.hasContent() == false) {
if (myChildToParentPidCache != null) {
ourLog.info("Clearing parent concept cache");
myNextReindexPass = System.currentTimeMillis() + DateUtils.MILLIS_PER_MINUTE; myNextReindexPass = System.currentTimeMillis() + DateUtils.MILLIS_PER_MINUTE;
myChildToParentPidCache = null; myChildToParentPidCache = null;
}
return; return;
} }

View File

@ -154,10 +154,15 @@ public class FhirResourceDaoR4SearchPageExpiryTest extends BaseJpaR4Test {
newTxTemplate().execute(new TransactionCallbackWithoutResult() { newTxTemplate().execute(new TransactionCallbackWithoutResult() {
@Override @Override
protected void doInTransactionWithoutResult(TransactionStatus theArg0) { protected void doInTransactionWithoutResult(TransactionStatus theArg0) {
assertNull(mySearchEntityDao.findByUuid(searchUuid1));
assertNotNull(mySearchEntityDao.findByUuid(searchUuid3)); assertNotNull(mySearchEntityDao.findByUuid(searchUuid3));
} }
}); });
newTxTemplate().execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus theArg0) {
assertNull(mySearchEntityDao.findByUuid(searchUuid1));
}
});
Thread.sleep(300); Thread.sleep(300);

View File

@ -79,6 +79,7 @@ public class ResourceProviderInterceptorDstu3Test extends BaseResourceProviderDs
private void resetServerInterceptor() throws ServletException, IOException { private void resetServerInterceptor() throws ServletException, IOException {
reset(myServerInterceptor); reset(myServerInterceptor);
reset(myDaoInterceptor);
when(myServerInterceptor.handleException(any(RequestDetails.class), any(BaseServerResponseException.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true); when(myServerInterceptor.handleException(any(RequestDetails.class), any(BaseServerResponseException.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myServerInterceptor.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true); when(myServerInterceptor.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myServerInterceptor.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true); when(myServerInterceptor.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
@ -87,14 +88,14 @@ public class ResourceProviderInterceptorDstu3Test extends BaseResourceProviderDs
} }
@Test @Test
public void testCreateResource() throws IOException { public void testCreateResource() throws IOException, ServletException {
String methodName = "testCreateResource"; String methodName = "testCreateResource";
Patient pt = new Patient(); Patient pt = new Patient();
pt.addName().setFamily(methodName); pt.addName().setFamily(methodName);
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt); String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
verify(myServerInterceptor, never()).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class)); resetServerInterceptor();
HttpPost post = new HttpPost(ourServerBase + "/Patient"); HttpPost post = new HttpPost(ourServerBase + "/Patient");
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
@ -125,7 +126,7 @@ public class ResourceProviderInterceptorDstu3Test extends BaseResourceProviderDs
} }
@Test @Test
public void testCreateResourceInTransaction() throws IOException { public void testCreateResourceInTransaction() throws IOException, ServletException {
String methodName = "testCreateResourceInTransaction"; String methodName = "testCreateResourceInTransaction";
Patient pt = new Patient(); Patient pt = new Patient();
@ -141,7 +142,7 @@ public class ResourceProviderInterceptorDstu3Test extends BaseResourceProviderDs
String resource = myFhirCtx.newXmlParser().encodeResourceToString(bundle); String resource = myFhirCtx.newXmlParser().encodeResourceToString(bundle);
verify(myServerInterceptor, never()).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class)); resetServerInterceptor();
HttpPost post = new HttpPost(ourServerBase + "/"); HttpPost post = new HttpPost(ourServerBase + "/");
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8"))); post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));

View File

@ -3,6 +3,8 @@ package ca.uhn.fhir.jpa.demo;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletException; import javax.servlet.ServletException;

View File

@ -11,6 +11,7 @@ curl -H "Authorization: Bearer " "http://fhirtest.uhn.ca/baseDstu3/\$mark-all-re
# Delete all errored resources # Delete all errored resources
update hfj_res_ver set forced_id_pid = null where res_id in (select res_id from hfj_resource where sp_index_status = 2); update hfj_res_ver set forced_id_pid = null where res_id in (select res_id from hfj_resource where sp_index_status = 2);
update hfj_resource set forced_id_pid = null where res_id in (select res_id from hfj_resource where sp_index_status = 2); update hfj_resource set forced_id_pid = null where res_id in (select res_id from hfj_resource where sp_index_status = 2);
delete from hfj_history_tag where res_id in (select res_id from hfj_resource where sp_index_status = 2);
delete from hfj_res_ver where res_id in (select res_id from hfj_resource where sp_index_status = 2); delete from hfj_res_ver where res_id in (select res_id from hfj_resource where sp_index_status = 2);
delete from hfj_forced_id where resource_pid in (select res_id from hfj_resource where sp_index_status = 2); delete from hfj_forced_id where resource_pid in (select res_id from hfj_resource where sp_index_status = 2);
delete from hfj_res_link where src_resource_id in (select res_id from hfj_resource where sp_index_status = 2); delete from hfj_res_link where src_resource_id in (select res_id from hfj_resource where sp_index_status = 2);
@ -27,3 +28,27 @@ delete from hfj_search_result where resource_pid in (select res_id from hfj_reso
delete from hfj_resource where res_id in (select res_id from hfj_resource where sp_index_status = 2); delete from hfj_resource where res_id in (select res_id from hfj_resource where sp_index_status = 2);
# Delete resource by id
delete from hfj_res_link where src_resource_id = 16940 or target_resource_id = 16940;
delete from hfj_spidx_date where res_id = 16940;
delete from hfj_spidx_string where res_id = 16940;
delete from hfj_spidx_token where res_id = 16940;
delete from hfj_spidx_uri where res_id = 16940;
delete from hfj_spidx_quantity where res_id = 16940;
delete from hfj_search_result where resource_pid = 16940;
delete from hfj_res_ver where res_id = 16940;
delete from hfj_res_param_present where res_id = 16940;
update hfj_resource set forced_id_pid = null where res_id = 16940;
delete from hfj_forced_id where resource_pid = 16940;
delete from hfj_resource where res_id = 16940;
delete from hfj_res_link where src_resource_id in ( 156618, 1092 , 1114 , 1139 , 1140 , 1141, 1142 , 1143 , 1144 , 1146 , 1147, 1148, 1062912, 1062916, 1062918, 1062919, 1062922, 1062929, 1062930, 1062934, 1062939, 1062940, 1062944, 1062949, 1062955, 1062957, 1062958, 1062959, 1062966, 1062969, 1062975, 1062976, 1062979, 1062981, 1062985, 1062987, 1062992, 1063002, 1063005, 1063007, 1063013, 1063016, 1063018, 1063020, 1063022, 1063062, 1063068, 1063075, 1063078, 1063080, 1063083, 1063084, 1063091, 1063095, 1063096, 1063098, 1107579, 1107591, 1107598, 1107761, 1107705, 1107748, 1109361, 1109388, 1109378, 1109399, 1109400, 1109401, 1109403, 1109404, 1109406, 1109409, 1109411, 1109414, 1109417, 1109418, 1109421, 1109427, 1109428, 1109429, 1109431, 1109432, 1109433, 1109891, 1109893, 1109947, 1179553, 1182781, 1182788, 1182791, 1182792, 1182795, 1182798, 1182801, 1182806, 1182811, 1182815) or target_resource_id in ( 156618, 1092 , 1114 , 1139 , 1140 , 1141, 1142 , 1143 , 1144 , 1146 , 1147, 1148, 1062912, 1062916, 1062918, 1062919, 1062922, 1062929, 1062930, 1062934, 1062939, 1062940, 1062944, 1062949, 1062955, 1062957, 1062958, 1062959, 1062966, 1062969, 1062975, 1062976, 1062979, 1062981, 1062985, 1062987, 1062992, 1063002, 1063005, 1063007, 1063013, 1063016, 1063018, 1063020, 1063022, 1063062, 1063068, 1063075, 1063078, 1063080, 1063083, 1063084, 1063091, 1063095, 1063096, 1063098, 1107579, 1107591, 1107598, 1107761, 1107705, 1107748, 1109361, 1109388, 1109378, 1109399, 1109400, 1109401, 1109403, 1109404, 1109406, 1109409, 1109411, 1109414, 1109417, 1109418, 1109421, 1109427, 1109428, 1109429, 1109431, 1109432, 1109433, 1109891, 1109893, 1109947, 1179553, 1182781, 1182788, 1182791, 1182792, 1182795, 1182798, 1182801, 1182806, 1182811, 1182815);
delete from hfj_spidx_date where res_id in ( 156618, 1092 , 1114 , 1139 , 1140 , 1141, 1142 , 1143 , 1144 , 1146 , 1147, 1148, 1062912, 1062916, 1062918, 1062919, 1062922, 1062929, 1062930, 1062934, 1062939, 1062940, 1062944, 1062949, 1062955, 1062957, 1062958, 1062959, 1062966, 1062969, 1062975, 1062976, 1062979, 1062981, 1062985, 1062987, 1062992, 1063002, 1063005, 1063007, 1063013, 1063016, 1063018, 1063020, 1063022, 1063062, 1063068, 1063075, 1063078, 1063080, 1063083, 1063084, 1063091, 1063095, 1063096, 1063098, 1107579, 1107591, 1107598, 1107761, 1107705, 1107748, 1109361, 1109388, 1109378, 1109399, 1109400, 1109401, 1109403, 1109404, 1109406, 1109409, 1109411, 1109414, 1109417, 1109418, 1109421, 1109427, 1109428, 1109429, 1109431, 1109432, 1109433, 1109891, 1109893, 1109947, 1179553, 1182781, 1182788, 1182791, 1182792, 1182795, 1182798, 1182801, 1182806, 1182811, 1182815);
delete from hfj_spidx_string where res_id in ( 156618, 1092 , 1114 , 1139 , 1140 , 1141, 1142 , 1143 , 1144 , 1146 , 1147, 1148, 1062912, 1062916, 1062918, 1062919, 1062922, 1062929, 1062930, 1062934, 1062939, 1062940, 1062944, 1062949, 1062955, 1062957, 1062958, 1062959, 1062966, 1062969, 1062975, 1062976, 1062979, 1062981, 1062985, 1062987, 1062992, 1063002, 1063005, 1063007, 1063013, 1063016, 1063018, 1063020, 1063022, 1063062, 1063068, 1063075, 1063078, 1063080, 1063083, 1063084, 1063091, 1063095, 1063096, 1063098, 1107579, 1107591, 1107598, 1107761, 1107705, 1107748, 1109361, 1109388, 1109378, 1109399, 1109400, 1109401, 1109403, 1109404, 1109406, 1109409, 1109411, 1109414, 1109417, 1109418, 1109421, 1109427, 1109428, 1109429, 1109431, 1109432, 1109433, 1109891, 1109893, 1109947, 1179553, 1182781, 1182788, 1182791, 1182792, 1182795, 1182798, 1182801, 1182806, 1182811, 1182815);
delete from hfj_spidx_token where res_id in ( 156618, 1092 , 1114 , 1139 , 1140 , 1141, 1142 , 1143 , 1144 , 1146 , 1147, 1148, 1062912, 1062916, 1062918, 1062919, 1062922, 1062929, 1062930, 1062934, 1062939, 1062940, 1062944, 1062949, 1062955, 1062957, 1062958, 1062959, 1062966, 1062969, 1062975, 1062976, 1062979, 1062981, 1062985, 1062987, 1062992, 1063002, 1063005, 1063007, 1063013, 1063016, 1063018, 1063020, 1063022, 1063062, 1063068, 1063075, 1063078, 1063080, 1063083, 1063084, 1063091, 1063095, 1063096, 1063098, 1107579, 1107591, 1107598, 1107761, 1107705, 1107748, 1109361, 1109388, 1109378, 1109399, 1109400, 1109401, 1109403, 1109404, 1109406, 1109409, 1109411, 1109414, 1109417, 1109418, 1109421, 1109427, 1109428, 1109429, 1109431, 1109432, 1109433, 1109891, 1109893, 1109947, 1179553, 1182781, 1182788, 1182791, 1182792, 1182795, 1182798, 1182801, 1182806, 1182811, 1182815);
delete from hfj_search_result where resource_pid in ( 156618, 1092 , 1114 , 1139 , 1140 , 1141, 1142 , 1143 , 1144 , 1146 , 1147, 1148, 1062912, 1062916, 1062918, 1062919, 1062922, 1062929, 1062930, 1062934, 1062939, 1062940, 1062944, 1062949, 1062955, 1062957, 1062958, 1062959, 1062966, 1062969, 1062975, 1062976, 1062979, 1062981, 1062985, 1062987, 1062992, 1063002, 1063005, 1063007, 1063013, 1063016, 1063018, 1063020, 1063022, 1063062, 1063068, 1063075, 1063078, 1063080, 1063083, 1063084, 1063091, 1063095, 1063096, 1063098, 1107579, 1107591, 1107598, 1107761, 1107705, 1107748, 1109361, 1109388, 1109378, 1109399, 1109400, 1109401, 1109403, 1109404, 1109406, 1109409, 1109411, 1109414, 1109417, 1109418, 1109421, 1109427, 1109428, 1109429, 1109431, 1109432, 1109433, 1109891, 1109893, 1109947, 1179553, 1182781, 1182788, 1182791, 1182792, 1182795, 1182798, 1182801, 1182806, 1182811, 1182815);
delete from hfj_resource where res_id in ( 156618, 1092 , 1114 , 1139 , 1140 , 1141, 1142 , 1143 , 1144 , 1146 , 1147, 1148, 1062912, 1062916, 1062918, 1062919, 1062922, 1062929, 1062930, 1062934, 1062939, 1062940, 1062944, 1062949, 1062955, 1062957, 1062958, 1062959, 1062966, 1062969, 1062975, 1062976, 1062979, 1062981, 1062985, 1062987, 1062992, 1063002, 1063005, 1063007, 1063013, 1063016, 1063018, 1063020, 1063022, 1063062, 1063068, 1063075, 1063078, 1063080, 1063083, 1063084, 1063091, 1063095, 1063096, 1063098, 1107579, 1107591, 1107598, 1107761, 1107705, 1107748, 1109361, 1109388, 1109378, 1109399, 1109400, 1109401, 1109403, 1109404, 1109406, 1109409, 1109411, 1109414, 1109417, 1109418, 1109421, 1109427, 1109428, 1109429, 1109431, 1109432, 1109433, 1109891, 1109893, 1109947, 1179553, 1182781, 1182788, 1182791, 1182792, 1182795, 1182798, 1182801, 1182806, 1182811, 1182815);

View File

@ -126,8 +126,6 @@ public interface IServerInterceptor {
* will be aborted with an appropriate error returned to the client. * will be aborted with an appropriate error returned to the client.
* </p> * </p>
* *
* @param theServletRequest
* The incoming servlet request as provided by the servlet container
* @param theOperation * @param theOperation
* The type of operation that the FHIR server has determined that the client is trying to invoke * The type of operation that the FHIR server has determined that the client is trying to invoke
* @param theProcessedRequest * @param theProcessedRequest

View File

@ -351,6 +351,7 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter {
* *
* @return Returns a reference to this for easy method chaining * @return Returns a reference to this for easy method chaining
*/ */
@SuppressWarnings("UnusedReturnValue")
public ResponseHighlighterInterceptor setShowRequestHeaders(boolean theShowRequestHeaders) { public ResponseHighlighterInterceptor setShowRequestHeaders(boolean theShowRequestHeaders) {
myShowRequestHeaders = theShowRequestHeaders; myShowRequestHeaders = theShowRequestHeaders;
return this; return this;
@ -362,6 +363,7 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter {
* *
* @return Returns a reference to this for easy method chaining * @return Returns a reference to this for easy method chaining
*/ */
@SuppressWarnings("UnusedReturnValue")
public ResponseHighlighterInterceptor setShowResponseHeaders(boolean theShowResponseHeaders) { public ResponseHighlighterInterceptor setShowResponseHeaders(boolean theShowResponseHeaders) {
myShowResponseHeaders = theShowResponseHeaders; myShowResponseHeaders = theShowResponseHeaders;
return this; return this;
@ -415,7 +417,7 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter {
} }
} }
if (prettyPrintResponse) { if (prettyPrintResponse) {
p.setPrettyPrint(prettyPrintResponse); p.setPrettyPrint(true);
} }
EncodingEnum encoding = p.getEncoding(); EncodingEnum encoding = p.getEncoding();
@ -558,7 +560,6 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter {
b.append("\n"); b.append("\n");
b.append("\n"); b.append("\n");
if (true) {
try { try {
if (isShowRequestHeaders()) { if (isShowRequestHeaders()) {
streamRequestHeaders(theServletRequest, b); streamRequestHeaders(theServletRequest, b);
@ -569,7 +570,6 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter {
} catch (Throwable t) { } catch (Throwable t) {
// ignore (this will hit if we're running in a servlet 2.5 environment) // ignore (this will hit if we're running in a servlet 2.5 environment)
} }
}
StringBuilder target = new StringBuilder(); StringBuilder target = new StringBuilder();
int linesCount = format(encoded, target, encoding); int linesCount = format(encoded, target, encoding);

View File

@ -761,6 +761,7 @@ public class ResponseHighlightingInterceptorTest {
@BeforeClass @BeforeClass
public static void beforeClass() throws Exception { public static void beforeClass() throws Exception {
ourPort = PortUtil.findFreePort(); ourPort = PortUtil.findFreePort();
ourLog.info("Using port: {}", ourPort);
ourServer = new Server(ourPort); ourServer = new Server(ourPort);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider(); DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

View File

@ -1,33 +1,5 @@
package ca.uhn.fhir.rest.server.interceptor; package ca.uhn.fhir.rest.server.interceptor;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.*;
import org.mockito.ArgumentCaptor;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.api.BundleInclusionRule; import ca.uhn.fhir.context.api.BundleInclusionRule;
import ca.uhn.fhir.model.dstu2.resource.Observation; import ca.uhn.fhir.model.dstu2.resource.Observation;
@ -44,6 +16,32 @@ import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
import ca.uhn.fhir.util.PortUtil; import ca.uhn.fhir.util.PortUtil;
import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.TestUtil;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
public class ServerActionInterceptorTest { public class ServerActionInterceptorTest {

View File

@ -358,6 +358,10 @@
<id>InfiniteLoop90</id> <id>InfiniteLoop90</id>
<name>Clayton Bodendein</name> <name>Clayton Bodendein</name>
</developer> </developer>
<developer>
<id>rhausam</id>
<name>Rob Hausam</name>
</developer>
</developers> </developers>
<licenses> <licenses>

View File

@ -328,6 +328,15 @@
specified, regardless of whether the source event was a create or an specified, regardless of whether the source event was a create or an
update update
</action> </action>
<action type="add" issue="712">
Add appropriate import statements for logging to JPA demo code. Thanks to
Rob Hausam for the pull request!
</action>
<action type="add" issue="700">
Add some browser performance logging to ResponseHighlightingInterceptor. Thanks
to Eugene Lubarsky for the pull request, and for convincing James not to
optimize something that did not need optimizing!
</action>
</release> </release>
<release version="2.5" date="2017-06-08"> <release version="2.5" date="2017-06-08">
<action type="fix"> <action type="fix">