[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-12-04 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16709665#comment-16709665
 ] 

ASF GitHub Bot commented on SCB-1054:
-

wujimin closed pull request #1016: [SCB-1054]when download file, we should 
ignore consumer acceptType
URL: https://github.com/apache/servicecomb-java-chassis/pull/1016
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
 
b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
index ee7c40137..99d7a8970 100644
--- 
a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
+++ 
b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
@@ -25,6 +25,7 @@
 import java.util.Locale;
 import java.util.Map;
 
+import javax.servlet.http.Part;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 
@@ -35,9 +36,12 @@
 import org.apache.servicecomb.common.rest.definition.path.URLPathBuilder;
 import org.apache.servicecomb.core.definition.OperationMeta;
 import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.swagger.invocation.response.ResponseMeta;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.fasterxml.jackson.databind.JavaType;
+
 import io.swagger.models.Operation;
 import io.swagger.models.Swagger;
 import io.swagger.models.parameters.Parameter;
@@ -52,6 +56,9 @@
 
   protected boolean formData;
 
+  // make sure if response is file
+  protected boolean downloadFile;
+
   protected List paramList = new ArrayList<>();
 
   // key为参数名
@@ -80,13 +87,14 @@ public void init(OperationMeta operationMeta) {
   this.produces = swagger.getProduces();
 }
 
+this.downloadFile = checkDownloadFileFlag();
 this.createProduceProcessors();
 
 Method method = operationMeta.getMethod();
 Type[] genericParamTypes = method.getGenericParameterTypes();
 if (genericParamTypes.length != operation.getParameters().size()) {
   throw new Error("Param count is not equal between swagger and method, 
path=" + absolutePath
-+ ";operation=" + operationMeta.getMicroserviceQualifiedName());
+  + ";operation=" + operationMeta.getMicroserviceQualifiedName());
 }
 
 // 初始化所有rest param
@@ -105,6 +113,15 @@ public void init(OperationMeta operationMeta) {
 setAbsolutePath(concatPath(swagger.getBasePath(), 
operationMeta.getOperationPath()));
   }
 
+  private boolean checkDownloadFileFlag() {
+ResponseMeta responseMeta = operationMeta.findResponseMeta(200);
+if (responseMeta != null) {
+  JavaType javaType = responseMeta.getJavaType();
+  return javaType.getRawClass().equals(Part.class);
+}
+return false;
+  }
+
   public boolean isFormData() {
 return formData;
   }
@@ -214,12 +231,17 @@ public ProduceProcessor 
ensureFindProduceProcessor(HttpServletRequestEx requestE
   }
 
   public ProduceProcessor ensureFindProduceProcessor(String acceptType) {
+if (downloadFile) {
+  //do not check accept type, when the produces of provider is text/plain 
there will return text/plain processor
+  //when the produces of provider is application/json there will return 
the application/json processor
+  //so do not care what accept type the consumer will set.
+  return this.produceProcessorMap.get(MediaType.WILDCARD);
+}
 if (StringUtils.isEmpty(acceptType)) {
   return defaultProcessor;
 }
-
-List mimeTyps = 
MimeTypesUtils.getSortedAcceptableMimeTypes(acceptType.toLowerCase(Locale.US));
-for (String mime : mimeTyps) {
+List mimeTypes = 
MimeTypesUtils.getSortedAcceptableMimeTypes(acceptType.toLowerCase(Locale.US));
+for (String mime : mimeTypes) {
   ProduceProcessor processor = this.produceProcessorMap.get(mime);
   if (null != processor) {
 return processor;
diff --git 
a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
 
b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
index 34621d6e2..623e1171a 100644
--- 
a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
+++ 
b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
@@ -171,6 +171,20 @@ public void testEnsureFindProduceProcessorAcceptFound() {
 
operationMeta.ensureFindProduceProcessor("text/plain;q=0.7;charset=utf-8

[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-12-04 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16709382#comment-16709382
 ] 

ASF GitHub Bot commented on SCB-1054:
-

coveralls edited a comment on issue #1016: [SCB-1054]when download file, we 
should ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#issuecomment-442685627
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/20444824/badge)](https://coveralls.io/builds/20444824)
   
   Coverage increased (+0.03%) to 86.744% when pulling 
**bae955707154770cf34d71da051feb3234d0b799 on heyile:downloadAccept** into 
**a21611163909bd075f3f7c737474e44c95f4c062 on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-12-02 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16706773#comment-16706773
 ] 

ASF GitHub Bot commented on SCB-1054:
-

wujimin commented on a change in pull request #1016: [SCB-1054]when download 
file, we should ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#discussion_r238161533
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
 ##
 @@ -105,6 +111,24 @@ public void init(OperationMeta operationMeta) {
 setAbsolutePath(concatPath(swagger.getBasePath(), 
operationMeta.getOperationPath()));
   }
 
+  private void checkDownloadFile(Operation operation) {
 
 Review comment:
   1.change name to checkDownloadFileFlag
   2.OperationMeta already collect ResponseMetas, just invoke 
org.apache.servicecomb.swagger.invocation.response.ResponsesMeta#findResponseMeta,
 and determined by 
org.apache.servicecomb.swagger.invocation.response.ResponseMeta#javaType


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16704361#comment-16704361
 ] 

ASF GitHub Bot commented on SCB-1054:
-

coveralls edited a comment on issue #1016: [SCB-1054]when download file, we 
should ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#issuecomment-442685627
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/20377424/badge)](https://coveralls.io/builds/20377424)
   
   Coverage increased (+0.02%) to 86.795% when pulling 
**779c53d901f0736f801eb4f1f936a60cdf9a1156 on heyile:downloadAccept** into 
**47d4773f3db7444e07fa2bb5bf87ac0a0387855f on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16704355#comment-16704355
 ] 

ASF GitHub Bot commented on SCB-1054:
-

coveralls edited a comment on issue #1016: [SCB-1054]when download file, we 
should ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#issuecomment-442685627
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/20377323/badge)](https://coveralls.io/builds/20377323)
   
   Coverage increased (+0.01%) to 86.789% when pulling 
**779c53d901f0736f801eb4f1f936a60cdf9a1156 on heyile:downloadAccept** into 
**47d4773f3db7444e07fa2bb5bf87ac0a0387855f on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16704344#comment-16704344
 ] 

ASF GitHub Bot commented on SCB-1054:
-

heyile commented on a change in pull request #1016: [SCB-1054]when download 
file, we should ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#discussion_r237764327
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
 ##
 @@ -105,6 +110,16 @@ public void init(OperationMeta operationMeta) {
 setAbsolutePath(concatPath(swagger.getBasePath(), 
operationMeta.getOperationPath()));
   }
 
+  private void checkDownloadFile(Operation operation) {
+try {
+  Response response = operation.getResponses().get("200");
+  downloadFile = 
response.getSchema().getType().toLowerCase().equals("file");
+} catch (Exception e) {
 
 Review comment:
   ok


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16704333#comment-16704333
 ] 

ASF GitHub Bot commented on SCB-1054:
-

heyile commented on a change in pull request #1016: [SCB-1054]when download 
file, we should ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#discussion_r237762109
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
 ##
 @@ -217,9 +232,14 @@ public ProduceProcessor ensureFindProduceProcessor(String 
acceptType) {
 if (StringUtils.isEmpty(acceptType)) {
   return defaultProcessor;
 }
-
-List mimeTyps = 
MimeTypesUtils.getSortedAcceptableMimeTypes(acceptType.toLowerCase(Locale.US));
-for (String mime : mimeTyps) {
+if (downloadFile) {
 
 Review comment:
   ok, I will change it. actually, it doesn't matter where it's .
   As   **produceProcessorMap.putIfAbsent(MediaType.WILDCARD, 
defaultProcessor);**
   so **defaultProcessor**  equals  
**produceProcessorMap.get(MediaType.WILDCARD);**


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16704332#comment-16704332
 ] 

ASF GitHub Bot commented on SCB-1054:
-

heyile commented on a change in pull request #1016: [SCB-1054]when download 
file, we should ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#discussion_r237762154
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
 ##
 @@ -217,9 +232,14 @@ public ProduceProcessor ensureFindProduceProcessor(String 
acceptType) {
 if (StringUtils.isEmpty(acceptType)) {
   return defaultProcessor;
 }
-
-List mimeTyps = 
MimeTypesUtils.getSortedAcceptableMimeTypes(acceptType.toLowerCase(Locale.US));
-for (String mime : mimeTyps) {
+if (downloadFile) {
 
 Review comment:
   ok


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16704197#comment-16704197
 ] 

ASF GitHub Bot commented on SCB-1054:
-

liubao68 commented on a change in pull request #1016: [SCB-1054]when download 
file, we should ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#discussion_r237733865
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
 ##
 @@ -217,9 +232,14 @@ public ProduceProcessor ensureFindProduceProcessor(String 
acceptType) {
 if (StringUtils.isEmpty(acceptType)) {
   return defaultProcessor;
 }
-
-List mimeTyps = 
MimeTypesUtils.getSortedAcceptableMimeTypes(acceptType.toLowerCase(Locale.US));
-for (String mime : mimeTyps) {
+if (downloadFile) {
 
 Review comment:
   Is it better to add it before StringUtils.isEmpty(acceptType)?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-29 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16704192#comment-16704192
 ] 

ASF GitHub Bot commented on SCB-1054:
-

liubao68 commented on a change in pull request #1016: [SCB-1054]when download 
file, we should ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#discussion_r237733614
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
 ##
 @@ -105,6 +110,16 @@ public void init(OperationMeta operationMeta) {
 setAbsolutePath(concatPath(swagger.getBasePath(), 
operationMeta.getOperationPath()));
   }
 
+  private void checkDownloadFile(Operation operation) {
+try {
+  Response response = operation.getResponses().get("200");
+  downloadFile = 
response.getSchema().getType().toLowerCase().equals("file");
+} catch (Exception e) {
 
 Review comment:
   Do not use exception to do flow control. Check null is better. 


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-28 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16702654#comment-16702654
 ] 

ASF GitHub Bot commented on SCB-1054:
-

coveralls commented on issue #1016: [SCB-1054]when download file, we should 
ignore consumer acceptType
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1016#issuecomment-442685627
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/20350872/badge)](https://coveralls.io/builds/20350872)
   
   Coverage increased (+0.02%) to 86.792% when pulling 
**bab7da07af7753161ef25d117b72ed9abb8e755a on heyile:downloadAccept** into 
**47d4773f3db7444e07fa2bb5bf87ac0a0387855f on apache:master**.
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-28 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16701949#comment-16701949
 ] 

ASF GitHub Bot commented on SCB-1054:
-

heyile opened a new pull request #1016: [SCB-1054]when download file, we should 
ignore consumer acceptType
URL: https://github.com/apache/servicecomb-java-chassis/pull/1016
 
 
   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
- [ ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [ ] Run `mvn clean install` to make sure basic checks pass. A more 
thorough check will be performed on your pull request automatically.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-28 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16701948#comment-16701948
 ] 

ASF GitHub Bot commented on SCB-1054:
-

heyile closed pull request #1016: [SCB-1054]when download file, we should 
ignore consumer acceptType
URL: https://github.com/apache/servicecomb-java-chassis/pull/1016
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
 
b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
index ee7c40137..d08d43fb6 100644
--- 
a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
+++ 
b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
@@ -39,6 +39,7 @@
 import org.slf4j.LoggerFactory;
 
 import io.swagger.models.Operation;
+import io.swagger.models.Response;
 import io.swagger.models.Swagger;
 import io.swagger.models.parameters.Parameter;
 import io.vertx.ext.web.impl.MimeTypesUtils;
@@ -52,6 +53,9 @@
 
   protected boolean formData;
 
+  // make sure if response is file
+  protected boolean downloadFile;
+
   protected List paramList = new ArrayList<>();
 
   // key为参数名
@@ -80,6 +84,7 @@ public void init(OperationMeta operationMeta) {
   this.produces = swagger.getProduces();
 }
 
+checkDownloadFile(operation);
 this.createProduceProcessors();
 
 Method method = operationMeta.getMethod();
@@ -105,6 +110,16 @@ public void init(OperationMeta operationMeta) {
 setAbsolutePath(concatPath(swagger.getBasePath(), 
operationMeta.getOperationPath()));
   }
 
+  private void checkDownloadFile(Operation operation) {
+try {
+  Response response = operation.getResponses().get("200");
+  downloadFile = 
response.getSchema().getType().toLowerCase().equals("file");
+} catch (Exception e) {
+  // if throw NullPointer Exception, set false
+  downloadFile = false;
+}
+  }
+
   public boolean isFormData() {
 return formData;
   }
@@ -217,9 +232,14 @@ public ProduceProcessor ensureFindProduceProcessor(String 
acceptType) {
 if (StringUtils.isEmpty(acceptType)) {
   return defaultProcessor;
 }
-
-List mimeTyps = 
MimeTypesUtils.getSortedAcceptableMimeTypes(acceptType.toLowerCase(Locale.US));
-for (String mime : mimeTyps) {
+if (downloadFile) {
+  //do not check accept type, when the produces of provider is text/plain 
there will return text/plain processor
+  // when the produces of provider is application/json there will return 
application/json processor
+  //so do not care what accept type the consumer will set.
+  return this.produceProcessorMap.get(MediaType.WILDCARD);
+}
+List mimeTypes = 
MimeTypesUtils.getSortedAcceptableMimeTypes(acceptType.toLowerCase(Locale.US));
+for (String mime : mimeTypes) {
   ProduceProcessor processor = this.produceProcessorMap.get(mime);
   if (null != processor) {
 return processor;
diff --git 
a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
 
b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
index 34621d6e2..623e1171a 100644
--- 
a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
+++ 
b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
@@ -171,6 +171,20 @@ public void testEnsureFindProduceProcessorAcceptFound() {
 
operationMeta.ensureFindProduceProcessor("text/plain;q=0.7;charset=utf-8,application/json;q=0.8"));
   }
 
+  @Test
+  public void testEnsureFindProduceProcessorWithDownload() {
+RestOperationMeta operationMeta = new RestOperationMeta();
+operationMeta.produces = Arrays.asList(MediaType.APPLICATION_JSON);
+operationMeta.downloadFile = true;
+operationMeta.createProduceProcessors();
+
+Assert.assertSame(ProduceProcessorManager.JSON_PROCESSOR,
+operationMeta.ensureFindProduceProcessor("text/plain"));
+
+operationMeta.downloadFile = false;
+Assert.assertNull(operationMeta.ensureFindProduceProcessor("text/plain"));
+  }
+
   @Test
   public void testEnsureFindProduceProcessorAcceptNotFound() {
 RestOperationMeta operationMeta = new RestOperationMeta();
diff --git 
a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestDownload.java
 
b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestDownload.java
index 9a3

[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-28 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16701859#comment-16701859
 ] 

ASF GitHub Bot commented on SCB-1054:
-

heyile closed pull request #1016: [SCB-1054]when download file, we should 
ignore consumer acceptType
URL: https://github.com/apache/servicecomb-java-chassis/pull/1016
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
 
b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
index ee7c40137..d08d43fb6 100644
--- 
a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
+++ 
b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/definition/RestOperationMeta.java
@@ -39,6 +39,7 @@
 import org.slf4j.LoggerFactory;
 
 import io.swagger.models.Operation;
+import io.swagger.models.Response;
 import io.swagger.models.Swagger;
 import io.swagger.models.parameters.Parameter;
 import io.vertx.ext.web.impl.MimeTypesUtils;
@@ -52,6 +53,9 @@
 
   protected boolean formData;
 
+  // make sure if response is file
+  protected boolean downloadFile;
+
   protected List paramList = new ArrayList<>();
 
   // key为参数名
@@ -80,6 +84,7 @@ public void init(OperationMeta operationMeta) {
   this.produces = swagger.getProduces();
 }
 
+checkDownloadFile(operation);
 this.createProduceProcessors();
 
 Method method = operationMeta.getMethod();
@@ -105,6 +110,16 @@ public void init(OperationMeta operationMeta) {
 setAbsolutePath(concatPath(swagger.getBasePath(), 
operationMeta.getOperationPath()));
   }
 
+  private void checkDownloadFile(Operation operation) {
+try {
+  Response response = operation.getResponses().get("200");
+  downloadFile = 
response.getSchema().getType().toLowerCase().equals("file");
+} catch (Exception e) {
+  // if throw NullPointer Exception, set false
+  downloadFile = false;
+}
+  }
+
   public boolean isFormData() {
 return formData;
   }
@@ -217,9 +232,14 @@ public ProduceProcessor ensureFindProduceProcessor(String 
acceptType) {
 if (StringUtils.isEmpty(acceptType)) {
   return defaultProcessor;
 }
-
-List mimeTyps = 
MimeTypesUtils.getSortedAcceptableMimeTypes(acceptType.toLowerCase(Locale.US));
-for (String mime : mimeTyps) {
+if (downloadFile) {
+  //do not check accept type, when the produces of provider is text/plain 
there will return text/plain processor
+  // when the produces of provider is application/json there will return 
application/json processor
+  //so do not care what accept type the consumer will set.
+  return this.produceProcessorMap.get(MediaType.WILDCARD);
+}
+List mimeTypes = 
MimeTypesUtils.getSortedAcceptableMimeTypes(acceptType.toLowerCase(Locale.US));
+for (String mime : mimeTypes) {
   ProduceProcessor processor = this.produceProcessorMap.get(mime);
   if (null != processor) {
 return processor;
diff --git 
a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
 
b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
index 34621d6e2..623e1171a 100644
--- 
a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
+++ 
b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/definition/TestRestOperationMeta.java
@@ -171,6 +171,20 @@ public void testEnsureFindProduceProcessorAcceptFound() {
 
operationMeta.ensureFindProduceProcessor("text/plain;q=0.7;charset=utf-8,application/json;q=0.8"));
   }
 
+  @Test
+  public void testEnsureFindProduceProcessorWithDownload() {
+RestOperationMeta operationMeta = new RestOperationMeta();
+operationMeta.produces = Arrays.asList(MediaType.APPLICATION_JSON);
+operationMeta.downloadFile = true;
+operationMeta.createProduceProcessors();
+
+Assert.assertSame(ProduceProcessorManager.JSON_PROCESSOR,
+operationMeta.ensureFindProduceProcessor("text/plain"));
+
+operationMeta.downloadFile = false;
+Assert.assertNull(operationMeta.ensureFindProduceProcessor("text/plain"));
+  }
+
   @Test
   public void testEnsureFindProduceProcessorAcceptNotFound() {
 RestOperationMeta operationMeta = new RestOperationMeta();
diff --git 
a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestDownload.java
 
b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/testcase/TestDownload.java
index 9a3

[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-28 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16701860#comment-16701860
 ] 

ASF GitHub Bot commented on SCB-1054:
-

heyile opened a new pull request #1016: [SCB-1054]when download file, we should 
ignore consumer acceptType
URL: https://github.com/apache/servicecomb-java-chassis/pull/1016
 
 
   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
- [ ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [ ] Run `mvn clean install` to make sure basic checks pass. A more 
thorough check will be performed on your pull request automatically.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SCB-1054) when download file, we should ignore consumer acceptType

2018-11-28 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/SCB-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16701822#comment-16701822
 ] 

ASF GitHub Bot commented on SCB-1054:
-

heyile opened a new pull request #1016: [SCB-1054]when download file, we should 
ignore consumer acceptType
URL: https://github.com/apache/servicecomb-java-chassis/pull/1016
 
 
   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
- [ ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line 
and body.
- [ ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
- [ ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
- [ ] Run `mvn clean install` to make sure basic checks pass. A more 
thorough check will be performed on your pull request automatically.
- [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> when download file, we should ignore consumer acceptType
> 
>
> Key: SCB-1054
> URL: https://issues.apache.org/jira/browse/SCB-1054
> Project: Apache ServiceComb
>  Issue Type: Bug
>Reporter: 何一乐
>Assignee: 何一乐
>Priority: Critical
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)