test_class.declarator: messageMetadata
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private MessageMetadata messageMetadata;
test_class.type: MessageMetadata
test_class.var_name: messageMetadata
test_class.declarator: resourceConfigurationParameter
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private ResourceConfigurationParameter resourceConfigurationParameter;
test_class.type: ResourceConfigurationParameter
test_class.var_name: resourceConfigurationParameter
test_class.declarator: requestContextHolder = null
test_class.modifier: @Mocked
  	private final
test_class.original_string: @Mocked
  	private final RequestContextHolder requestContextHolder = null;
test_class.type: RequestContextHolder
test_class.var_name: requestContextHolder
test_class.declarator: principal
test_class.modifier: @Mocked
  	private
test_class.original_string: @Mocked
  	private Principal principal;
test_class.type: Principal
test_class.var_name: principal
test_class.declarator: requestAttributes
test_class.modifier: @Mocked
  	private
test_class.original_string: @Mocked
  	private RequestAttributes requestAttributes;
test_class.type: RequestAttributes
test_class.var_name: requestAttributes
test_class.declarator: requestMessageContext
test_class.modifier: @Mocked
  	private
test_class.original_string: @Mocked
  	private RequestMessageContext requestMessageContext;
test_class.type: RequestMessageContext
test_class.var_name: requestMessageContext
test_class.declarator: responseMessageContext
test_class.modifier: @Mocked
  	private
test_class.original_string: @Mocked
  	private ResponseMessageContext responseMessageContext;
test_class.type: ResponseMessageContext
test_class.var_name: responseMessageContext
test_class.declarator: resourceProcessor
test_class.modifier: @Mocked
  	private
test_class.original_string: @Mocked
  	private ResourceProcessor resourceProcessor;
test_class.type: ResourceProcessor
test_class.var_name: resourceProcessor
test_class.file: hifiveResourceFramework/src/test/java/com/htmlhifive/resourcefw/ctrl/ResourceControllerTest.java
test_class.identifier: ResourceControllerTest
test_case.body: @Test
  	public void testPutContentDisposition(final @Mocked WebRequest webRequest) throws Exception {
  
  		final ResourceController target = new ResourceController();
  		target.setMessageMetadata(messageMetadata);
  		target.setResourceConfigurationParameter(resourceConfigurationParameter);
  
  		final RequestMessage reqMsg = new RequestMessage(messageMetadata) {
  			{
  				put(messageMetadata.ACTION, "findById");
  				put(messageMetadata.HTTP_METHOD, "GET");
  				put(messageMetadata.REQUEST_FILE_DOWNLOAD, "true");
  			}
  		};
  
  		final RequestMessageContainer reqContainer = new RequestMessageContainer(false) {
  			{
  				addMessage(reqMsg);
  			}
  		};
  
  		final ResponseMessage resMsg1 = new ResponseMessage(reqMsg) {
  			{
  				put(messageMetadata.RESPONSE_DOWNLOAD_FILE_NAME, "日本語 ファイル名");
  			}
  		};
  
  		final ResponseMessageContainer expected = new ResponseMessageContainer(false) {
  			{
  				addMessage(resMsg1);
  			}
  		};
  
  		new Expectations() {
  			{
  				setField(target, resourceProcessor);
  
  				webRequest.getUserPrincipal();
  				result = principal;
  
  				requestMessageContext.put(messageMetadata.USER_PRINCIPAL, principal, MessageSource.CONTROLLER);
  
  				resourceProcessor.process(reqContainer);
  				result = expected;
  
  				responseMessageContext.get(messageMetadata.RESPONSE_HEADER);
  				result = null;
  
  				responseMessageContext.get(messageMetadata.HTTP_HEADER_USER_AGENT);
  				result = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7";
  			}
  		};
  
  		ResponseMessageContainer actual = target.handle(webRequest, reqContainer);
  		ResponseMessage responseMessage = actual.getMessages().get(0);
  		assertThat(responseMessage.get(messageMetadata.RESPONSE_HEADER), is(not(nullValue())));
  
  		@SuppressWarnings("unchecked")
  		Map<String, Object> headers = (Map<String, Object>) responseMessage.get(messageMetadata.RESPONSE_HEADER);
  		assertThat(headers.get(messageMetadata.HTTP_HEADER_CONTENT_DISPOSITION), is(not(nullValue())));
  
  		String urlEncodedFileName = URLEncoder.encode("日本語 ファイル名", "UTF8").replace("+", "%20");
  
  		String contentDisposition = (String) headers.get(messageMetadata.HTTP_HEADER_CONTENT_DISPOSITION);
  		assertThat(contentDisposition, is(equalTo("attachment;filename*=utf-8'ja'" + urlEncodedFileName)));
  	}
test_case.class_method_signature: ResourceControllerTest.testPutContentDisposition(final @Mocked WebRequest webRequest)
test_case.full_signature: @Test public void testPutContentDisposition(final @Mocked WebRequest webRequest)
test_case.identifier: testPutContentDisposition
test_case.invocations: setMessageMetadata setResourceConfigurationParameter put put put addMessage put addMessage setField getUserPrincipal put process get get handle get getMessages assertThat get is not nullValue get assertThat get is not nullValue 0"); encode get assertThat is equalTo
test_case.modifiers: @Test public
test_case.parameters: (final @Mocked WebRequest webRequest)
test_case.return: void
test_case.signature: void testPutContentDisposition(final @Mocked WebRequest webRequest)
focal_class.declarator: IE_UA_CONTAINS = "MSIE"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String IE_UA_CONTAINS = "MSIE";
focal_class.type: String
focal_class.var_name: IE_UA_CONTAINS
focal_class.declarator: CHROME_UA_CONTAINS = "Chrome"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String CHROME_UA_CONTAINS = "Chrome";
focal_class.type: String
focal_class.var_name: CHROME_UA_CONTAINS
focal_class.declarator: FIREFOX_UA_CONTAINS = "Firefox"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String FIREFOX_UA_CONTAINS = "Firefox";
focal_class.type: String
focal_class.var_name: FIREFOX_UA_CONTAINS
focal_class.declarator: OPERA_UA_CONTAINS = "Opera"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String OPERA_UA_CONTAINS = "Opera";
focal_class.type: String
focal_class.var_name: OPERA_UA_CONTAINS
focal_class.declarator: SAFARI_UA_CONTAINS = "Safari"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String SAFARI_UA_CONTAINS = "Safari";
focal_class.type: String
focal_class.var_name: SAFARI_UA_CONTAINS
focal_class.declarator: resourceProcessor
focal_class.modifier: private
focal_class.original_string: private ResourceProcessor resourceProcessor;
focal_class.type: ResourceProcessor
focal_class.var_name: resourceProcessor
focal_class.declarator: messageMetadata
focal_class.modifier: private
focal_class.original_string: private MessageMetadata messageMetadata;
focal_class.type: MessageMetadata
focal_class.var_name: messageMetadata
focal_class.declarator: resourceConfigurationParameter
focal_class.modifier: private
focal_class.original_string: private ResourceConfigurationParameter resourceConfigurationParameter;
focal_class.type: ResourceConfigurationParameter
focal_class.var_name: resourceConfigurationParameter
focal_class.file: hifiveResourceFramework/src/main/java/com/htmlhifive/resourcefw/ctrl/ResourceController.java
focal_class.identifier: ResourceController
focal_class.class_method_signature: ResourceController.handle(WebRequest webRequest, RequestMessageContainer requestMessages)
focal_class.full_signature: @ResourceHandler public ResponseMessageContainer handle(WebRequest webRequest, RequestMessageContainer requestMessages)
focal_class.identifier: handle
focal_class.modifiers: @ResourceHandler public
focal_class.parameters: (WebRequest webRequest, RequestMessageContainer requestMessages)
focal_class.return: ResponseMessageContainer
focal_class.signature: ResponseMessageContainer handle(WebRequest webRequest, RequestMessageContainer requestMessages)
focal_class.class_method_signature: ResourceController.putContentDisposition(RequestMessage requestMessage, ResponseMessage responseMessage)
focal_class.full_signature: @SuppressWarnings("unchecked") private void putContentDisposition(RequestMessage requestMessage, ResponseMessage responseMessage)
focal_class.identifier: putContentDisposition
focal_class.modifiers: @SuppressWarnings("unchecked") private
focal_class.parameters: (RequestMessage requestMessage, ResponseMessage responseMessage)
focal_class.return: void
focal_class.signature: void putContentDisposition(RequestMessage requestMessage, ResponseMessage responseMessage)
focal_class.class_method_signature: ResourceController.editRequest(WebRequest webRequest, RequestMessageContainer requestMessages)
focal_class.full_signature: protected void editRequest(WebRequest webRequest, RequestMessageContainer requestMessages)
focal_class.identifier: editRequest
focal_class.modifiers: protected
focal_class.parameters: (WebRequest webRequest, RequestMessageContainer requestMessages)
focal_class.return: void
focal_class.signature: void editRequest(WebRequest webRequest, RequestMessageContainer requestMessages)
focal_class.class_method_signature: ResourceController.editResponse(WebRequest webRequest, ResponseMessageContainer responseMessages,
  			RequestMessageContainer requestMessages)
focal_class.full_signature: protected void editResponse(WebRequest webRequest, ResponseMessageContainer responseMessages,
  			RequestMessageContainer requestMessages)
focal_class.identifier: editResponse
focal_class.modifiers: protected
focal_class.parameters: (WebRequest webRequest, ResponseMessageContainer responseMessages,
  			RequestMessageContainer requestMessages)
focal_class.return: void
focal_class.signature: void editResponse(WebRequest webRequest, ResponseMessageContainer responseMessages,
  			RequestMessageContainer requestMessages)
focal_class.class_method_signature: ResourceController.applyDefaultAction(RequestMessage message)
focal_class.full_signature: protected void applyDefaultAction(RequestMessage message)
focal_class.identifier: applyDefaultAction
focal_class.modifiers: protected
focal_class.parameters: (RequestMessage message)
focal_class.return: void
focal_class.signature: void applyDefaultAction(RequestMessage message)
focal_class.class_method_signature: ResourceController.getResourceProcessor()
focal_class.full_signature: protected ResourceProcessor getResourceProcessor()
focal_class.identifier: getResourceProcessor
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: ResourceProcessor
focal_class.signature: ResourceProcessor getResourceProcessor()
focal_class.class_method_signature: ResourceController.setResourceProcessor(ResourceProcessor resourceProcessor)
focal_class.full_signature: public void setResourceProcessor(ResourceProcessor resourceProcessor)
focal_class.identifier: setResourceProcessor
focal_class.modifiers: public
focal_class.parameters: (ResourceProcessor resourceProcessor)
focal_class.return: void
focal_class.signature: void setResourceProcessor(ResourceProcessor resourceProcessor)
focal_class.class_method_signature: ResourceController.getMessageMetadata()
focal_class.full_signature: protected MessageMetadata getMessageMetadata()
focal_class.identifier: getMessageMetadata
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: MessageMetadata
focal_class.signature: MessageMetadata getMessageMetadata()
focal_class.class_method_signature: ResourceController.setMessageMetadata(MessageMetadata messageMetadata)
focal_class.full_signature: public void setMessageMetadata(MessageMetadata messageMetadata)
focal_class.identifier: setMessageMetadata
focal_class.modifiers: public
focal_class.parameters: (MessageMetadata messageMetadata)
focal_class.return: void
focal_class.signature: void setMessageMetadata(MessageMetadata messageMetadata)
focal_class.class_method_signature: ResourceController.getResourceConfigurationParameter()
focal_class.full_signature: protected ResourceConfigurationParameter getResourceConfigurationParameter()
focal_class.identifier: getResourceConfigurationParameter
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: ResourceConfigurationParameter
focal_class.signature: ResourceConfigurationParameter getResourceConfigurationParameter()
focal_class.class_method_signature: ResourceController.setResourceConfigurationParameter(ResourceConfigurationParameter resourceConfigurationParameter)
focal_class.full_signature: public void setResourceConfigurationParameter(ResourceConfigurationParameter resourceConfigurationParameter)
focal_class.identifier: setResourceConfigurationParameter
focal_class.modifiers: public
focal_class.parameters: (ResourceConfigurationParameter resourceConfigurationParameter)
focal_class.return: void
focal_class.signature: void setResourceConfigurationParameter(ResourceConfigurationParameter resourceConfigurationParameter)
focal_method.body: @SuppressWarnings("unchecked")
  	private void putContentDisposition(RequestMessage requestMessage, ResponseMessage responseMessage) {
  
  		// リクエストメッセージからファイルのダウンロード要求を表すパラメータを取得
  		Object downloadRequestObj = requestMessage.get(messageMetadata.REQUEST_FILE_DOWNLOAD);
  		if (downloadRequestObj == null) {
  			return;
  		}
  
  		// レスポンスメッセージにすでにRESPONSE_HEADERがあれば取得し、無ければMapをput
  		Map<String, Object> headers;
  		Object headersObj = responseMessage.get(messageMetadata.RESPONSE_HEADER);
  		if (headersObj == null) {
  			headers = new HashMap<>();
  			responseMessage.put(messageMetadata.RESPONSE_HEADER, headers);
  		} else {
  			headers = (Map<String, Object>) headersObj;
  		}
  
  		try {
  
  			// パラメータ値が"true"であれば、リクエストのUser-Agentを見てレスポンスにContent-Dispotionヘッダを設定する
  			if (Boolean.valueOf((String) downloadRequestObj)) {
  
  				// リソースクラスで指定されたファイル名
  				String fileName = (String) responseMessage.get(messageMetadata.RESPONSE_DOWNLOAD_FILE_NAME);
  				if (fileName == null || fileName.isEmpty()) {
  					throw new GenericResourceException(
  							"When resource class returns file data, response message need to include RESPONSE_DOWNLOAD_FILE_NAME metadata.");
  				}
  
  				// リクエストヘッダからユーザーエージェント（ブラウザの名前）取得
  				String userAgent = (String) requestMessage.get(messageMetadata.HTTP_HEADER_USER_AGENT);
  
  				// Content-DispositionのfileNameに用いる文字列の生成
  				String fileNameStr = null;
  				if (userAgent.contains(IE_UA_CONTAINS)) {
  					fileNameStr = "filename=\"" + URLEncoder.encode(fileName, "UTF8").replace("+", "%20") + "\"";
  					// Safariは、HttpHeaderをバイナリ化する必要があり、現状対応できていない
  					//				} else if (!userAgent.contains(CHROME_UA_CONTAINS) && userAgent.contains(SAFARI_UA_CONTAINS)) {
  					//					fileNameStr = "\"" + fileName + "\"";
  				} else {
  					// Chrome,Firefox,Opera
  					fileNameStr = "filename*=utf-8'ja'" + URLEncoder.encode(fileName, "UTF8").replace("+", "%20");
  				}
  
  				String contentDispositionValue = "attachment;" + fileNameStr;
  
  				headers.put(messageMetadata.HTTP_HEADER_CONTENT_DISPOSITION, contentDispositionValue);
  			}
  
  		} catch (UnsupportedEncodingException e) {
  			throw new GenericResourceException("bad charactor encoding on response file name.");
  		}
  	}
focal_method.class_method_signature: ResourceController.putContentDisposition(RequestMessage requestMessage, ResponseMessage responseMessage)
focal_method.full_signature: @SuppressWarnings("unchecked") private void putContentDisposition(RequestMessage requestMessage, ResponseMessage responseMessage)
focal_method.identifier: putContentDisposition
focal_method.invocations: get get put valueOf get isEmpty get contains replace encode replace encode put
focal_method.modifiers: @SuppressWarnings("unchecked") private
focal_method.parameters: (RequestMessage requestMessage, ResponseMessage responseMessage)
focal_method.return: void
focal_method.signature: void putContentDisposition(RequestMessage requestMessage, ResponseMessage responseMessage)