当前位置: 首页>>代码示例>>Java>>正文


Java RequestDetails类代码示例

本文整理汇总了Java中ca.uhn.fhir.rest.method.RequestDetails的典型用法代码示例。如果您正苦于以下问题:Java RequestDetails类的具体用法?Java RequestDetails怎么用?Java RequestDetails使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RequestDetails类属于ca.uhn.fhir.rest.method包,在下文中一共展示了RequestDetails类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleException

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
@Override
public boolean handleException(RequestDetails theRequestDetails, Throwable theException, HttpServletRequest theServletRequest,
      HttpServletResponse theServletResponse) throws ServletException, IOException {
   
   // If the exception is a built-in type, it defines the correct status
   // code to return. Otherwise default to 500.
   if (theException instanceof BaseServerResponseException) {
      theServletResponse.setStatus(((BaseServerResponseException) theException).getStatusCode());
   } else {
      theServletResponse.setStatus(Constants.STATUS_HTTP_500_INTERNAL_ERROR);
   }
   
   // Provide a response ourself
   theServletResponse.setContentType("text/plain");
   theServletResponse.getWriter().append("Failed to process!");
   theServletResponse.getWriter().close();
   
   // Since we handled this response in the interceptor, we must return false
   // to stop processing immediately
   return false;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:22,代码来源:RequestExceptionInterceptor.java

示例2: parseParams

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
private void parseParams(RequestDetails theRequest, List<QualifiedParamList> paramList, String theQualifiedParamName, String theQualifier) {
	QualifierDetails qualifiers = SearchMethodBinding.extractQualifiersFromParameterName(theQualifier);
	if (!qualifiers.passes(getQualifierWhitelist(), getQualifierBlacklist())) {
		return;
	}

	String[] value = theRequest.getParameters().get(theQualifiedParamName);
	if (value != null) {
		for (String nextParam : value) {
			if (nextParam.contains(",") == false) {
				paramList.add(QualifiedParamList.singleton(theQualifier, nextParam));
			} else {
				paramList.add(QualifiedParamList.splitQueryStringByCommasIgnoreEscape(theQualifier, nextParam));
			}
		}
	}
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:18,代码来源:BaseQueryParameter.java

示例3: determineNarrativeMode

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
public static RestfulServer.NarrativeModeEnum determineNarrativeMode(RequestDetails theRequest) {
	Map<String, String[]> requestParams = theRequest.getParameters();
	String[] narrative = requestParams.remove(Constants.PARAM_NARRATIVE);
	RestfulServer.NarrativeModeEnum narrativeMode = null;
	if (narrative != null && narrative.length > 0) {
		try {
			narrativeMode = RestfulServer.NarrativeModeEnum.valueOfCaseInsensitive(narrative[0]);
		} catch (IllegalArgumentException e) {
			ourLog.debug("Invalid {} parameger: {}", Constants.PARAM_NARRATIVE, narrative[0]);
			narrativeMode = null;
		}
	}
	if (narrativeMode == null) {
		narrativeMode = RestfulServer.NarrativeModeEnum.NORMAL;
	}
	return narrativeMode;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:18,代码来源:RestfulServerUtils.java

示例4: testThrowUnprocessableEntityException

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
@Test
public void testThrowUnprocessableEntityException() throws Exception {

	when(myInterceptor.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor.handleException(any(RequestDetails.class), any(Throwable.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);

	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=throwUnprocessableEntityException");
	HttpResponse status = ourClient.execute(httpGet);
	ourLog.info(IOUtils.toString(status.getEntity().getContent()));
	assertEquals(422, status.getStatusLine().getStatusCode());
	IOUtils.closeQuietly(status.getEntity().getContent());

	ArgumentCaptor<Throwable> captor = ArgumentCaptor.forClass(Throwable.class);
	verify(myInterceptor, times(1)).handleException(any(RequestDetails.class), captor.capture(), any(HttpServletRequest.class), any(HttpServletResponse.class));

	assertEquals(UnprocessableEntityException.class, captor.getValue().getClass());
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:19,代码来源:ExceptionInterceptorMethodTest.java

示例5: testInterceptorFires

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
@Test
public void testInterceptorFires() throws Exception {
	when(myInterceptor1.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor1.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor1.outgoingResponse(any(RequestDetails.class), any(IResource.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor2.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor2.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor2.outgoingResponse(any(RequestDetails.class), any(IResource.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	
	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/1");
	HttpResponse status = ourClient.execute(httpGet);
	IOUtils.closeQuietly(status.getEntity().getContent());

	InOrder order = inOrder(myInterceptor1, myInterceptor2);
	order.verify(myInterceptor1, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
	order.verify(myInterceptor2, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
	order.verify(myInterceptor1, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
	order.verify(myInterceptor2, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
	
	order.verify(myInterceptor2, times(1)).outgoingResponse(any(RequestDetails.class), any(IResource.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
	order.verify(myInterceptor1, times(1)).outgoingResponse(any(RequestDetails.class), any(IResource.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
	verifyNoMoreInteractions(myInterceptor1);
	verifyNoMoreInteractions(myInterceptor2);
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:25,代码来源:InterceptorTest.java

示例6: testAllParams

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
@Test
public void testAllParams() {
	List<IParameter> methodParams = new ArrayList<IParameter>();

	methodParams.add(new SearchParameter("firstName", false));
	methodParams.add(new SearchParameter("lastName", false));
	methodParams.add(new SearchParameter("mrn", true));

	rm.setParameters(methodParams);

	Set<String> inputParams = new HashSet<String>();
	inputParams.add("firstName");
	inputParams.add("lastName");
	inputParams.add("mrn");

	RequestDetails params = withResourceAndParams("Patient", RequestTypeEnum.GET, inputParams);
	boolean actual = rm.incomingServerRequestMatchesMethod(params);
	assertTrue( actual); // True
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:20,代码来源:ResourceMethodTest.java

示例7: read

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
public ValueSet read(IIdType theId, RequestDetails theRequestDetails) {	
	ValueSet retVal = myEntityManager.find(ValueSet.class, theId.getIdPart());
	
	if (retVal == null) {
		throw new ResourceNotFoundException(theId);
	}				
	
	return retVal;
}
 
开发者ID:Discovery-Research-Network-SCCM,项目名称:FHIR-CQL-ODM-service,代码行数:10,代码来源:FhirValueSetDaoDstu3.java

示例8: incomingRequestPostProcessed

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
@Override
public boolean incomingRequestPostProcessed(final RequestDetails theRequestDetails, final HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException {

	// Perform any string substitutions from the message format
	StrLookup<?> lookup = new MyLookup(theRequest, theRequestDetails);
	StrSubstitutor subs = new StrSubstitutor(lookup, "${", "}", '\\');

	// Actuall log the line
	String line = subs.replace(myMessageFormat);
	myLogger.info(line);

	return true;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:14,代码来源:LoggingInterceptor.java

示例9: incomingRequestPostProcessed

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
@Override
public boolean incomingRequestPostProcessed(RequestDetails theRequestDetails, HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException {
	if (theRequestDetails.getOtherOperationType() == OtherOperationTypeEnum.METADATA) {
		return true;
	}
	
	authenticate(theRequest);
	
	return true;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:11,代码来源:OpenIdConnectBearerTokenServerInterceptor.java

示例10: getEventInfo

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
/**
 * Generates the Event segment of the SecurityEvent based on the incoming request details
 * @param theRequestDetails the RequestDetails of the incoming request
 * @return an Event populated with the action, date, and outcome
 */
protected Event getEventInfo(RequestDetails theRequestDetails) {
	Event event = new Event();
	event.setAction(mapResourceTypeToSecurityEventAction(theRequestDetails.getResourceOperationType()));
	event.setDateTimeWithMillisPrecision(new Date());
	event.setOutcome(SecurityEventOutcomeEnum.SUCCESS); //we audit successful return of PHI only, otherwise an exception is thrown and no resources are returned to be audited		
	return event;
	
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:14,代码来源:AuditingInterceptor.java

示例11: getQueryFromRequestDetails

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
/**
 * Return the query URL encoded to bytes to be set as the Object.query on the Security Event
 * @param theRequestDetails the RequestDetails of the incoming request
 * @return the query URL of the request encoded to bytes
 */
protected byte[] getQueryFromRequestDetails(RequestDetails theRequestDetails) {
	byte[] query;
	try {
		query = theRequestDetails.getCompleteUrl().getBytes("UTF-8");
	} catch (UnsupportedEncodingException e1) {
		log.warn("Unable to encode URL to bytes in UTF-8, defaulting to platform default charset.", e1);
		query = theRequestDetails.getCompleteUrl().getBytes();
	}
	return query;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:16,代码来源:AuditingInterceptor.java

示例12: testThrowUnprocessableEntityExceptionAndOverrideResponse

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
@Test
public void testThrowUnprocessableEntityExceptionAndOverrideResponse() throws Exception {

	when(myInterceptor.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	
	when(myInterceptor.handleException(any(RequestDetails.class), any(Throwable.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenAnswer(new Answer<Boolean>() {
		@Override
		public Boolean answer(InvocationOnMock theInvocation) throws Throwable {
			HttpServletResponse resp = (HttpServletResponse) theInvocation.getArguments()[3];
			resp.setStatus(405);
			resp.setContentType("text/plain");
			resp.getWriter().write("HELP IM A BUG");
			resp.getWriter().close();
			return false;
		}
	});

	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=throwUnprocessableEntityException");
	HttpResponse status = ourClient.execute(httpGet);
	String responseContent = IOUtils.toString(status.getEntity().getContent());
	ourLog.info(responseContent);
	assertEquals(405, status.getStatusLine().getStatusCode());
	IOUtils.closeQuietly(status.getEntity().getContent());
	
	assertEquals("HELP IM A BUG", responseContent);
	
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:29,代码来源:ExceptionInterceptorMethodTest.java

示例13: getEventInfo

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
/**
 * Generates the Event segment of the SecurityEvent based on the incoming request details
 * 
 * @param theRequestDetails
 *           the RequestDetails of the incoming request
 * @return an Event populated with the action, date, and outcome
 */
protected Event getEventInfo(RequestDetails theRequestDetails) {
	Event event = new Event();
	event.setAction(mapResourceTypeToSecurityEventAction(theRequestDetails.getRestOperationType()));
	event.setDateTimeWithMillisPrecision(new Date());
	event.setOutcome(SecurityEventOutcomeEnum.SUCCESS); // we audit successful return of PHI only, otherwise an
																			// exception is thrown and no resources are returned to be
																			// audited
	return event;

}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:18,代码来源:AuditingInterceptor.java

示例14: getQueryFromRequestDetails

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
/**
 * Return the query URL encoded to bytes to be set as the Object.query on the Security Event
 * 
 * @param theRequestDetails
 *           the RequestDetails of the incoming request
 * @return the query URL of the request encoded to bytes
 */
protected byte[] getQueryFromRequestDetails(RequestDetails theRequestDetails) {
	byte[] query;
	try {
		query = theRequestDetails.getCompleteUrl().getBytes("UTF-8");
	} catch (UnsupportedEncodingException e1) {
		log.warn("Unable to encode URL to bytes in UTF-8, defaulting to platform default charset.", e1);
		query = theRequestDetails.getCompleteUrl().getBytes();
	}
	return query;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:18,代码来源:AuditingInterceptor.java

示例15: testInterceptorFires

import ca.uhn.fhir.rest.method.RequestDetails; //导入依赖的package包/类
@Test
public void testInterceptorFires() throws Exception {
	when(myInterceptor1.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor1.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor1.outgoingResponse(any(RequestDetails.class), any(IResource.class))).thenReturn(true);
	when(myInterceptor2.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor2.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
	when(myInterceptor2.outgoingResponse(any(RequestDetails.class), any(IResource.class))).thenReturn(true);
	
	HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/1");
	HttpResponse status = ourClient.execute(httpGet);
	IOUtils.closeQuietly(status.getEntity().getContent());

	InOrder order = inOrder(myInterceptor1, myInterceptor2);
	order.verify(myInterceptor1, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
	order.verify(myInterceptor2, times(1)).incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class));
	order.verify(myInterceptor1, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
	order.verify(myInterceptor2, times(1)).incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class));
	order.verify(myInterceptor1, times(1)).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
	order.verify(myInterceptor2, times(1)).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
	
	order.verify(myInterceptor2, times(1)).outgoingResponse(any(RequestDetails.class), any(IResource.class));
	order.verify(myInterceptor1, times(1)).outgoingResponse(any(RequestDetails.class), any(IResource.class));
	
	order.verify(myInterceptor2, times(1)).processingCompletedNormally(any(ServletRequestDetails.class));
	order.verify(myInterceptor1, times(1)).processingCompletedNormally(any(ServletRequestDetails.class));
	
	verifyNoMoreInteractions(myInterceptor1);
	verifyNoMoreInteractions(myInterceptor2);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:31,代码来源:InterceptorTest.java


注:本文中的ca.uhn.fhir.rest.method.RequestDetails类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。