Subversion Repositories SmartDukaan

Rev

Rev 24694 | Rev 24763 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24694 Rev 24698
Line 1... Line 1...
1
package com.spice.profitmandi.common.services;
1
package com.spice.profitmandi.common.services;
2
 
2
 
3
import java.io.ByteArrayInputStream;
-
 
4
import java.util.Collections;
3
import java.util.Collections;
5
import java.util.HashMap;
4
import java.util.HashMap;
6
import java.util.Map;
5
import java.util.Map;
-
 
6
import java.util.Set;
7
 
7
 
8
import org.apache.http.HttpResponse;
8
import org.apache.http.HttpResponse;
-
 
9
import org.apache.http.client.methods.HttpGet;
9
import org.apache.http.conn.HttpHostConnectException;
10
import org.apache.http.conn.HttpHostConnectException;
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.core.io.ByteArrayResource;
12
import org.springframework.core.io.ByteArrayResource;
12
import org.springframework.core.io.InputStreamSource;
13
import org.springframework.core.io.InputStreamSource;
13
import org.springframework.http.HttpEntity;
14
import org.springframework.http.HttpEntity;
14
import org.springframework.http.HttpHeaders;
15
import org.springframework.http.HttpHeaders;
15
import org.springframework.http.HttpMethod;
16
import org.springframework.http.HttpMethod;
16
import org.springframework.http.ResponseEntity;
17
import org.springframework.http.ResponseEntity;
17
import org.springframework.stereotype.Component;
18
import org.springframework.stereotype.Component;
18
import org.springframework.web.client.RestTemplate;
19
import org.springframework.web.client.RestTemplate;
-
 
20
import org.springframework.web.util.UriComponentsBuilder;
19
 
21
 
20
import com.spice.profitmandi.common.enumuration.ReporticoProject;
22
import com.spice.profitmandi.common.enumuration.ReporticoProject;
21
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
23
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
22
import com.spice.profitmandi.common.web.client.RestClient;
24
import com.spice.profitmandi.common.web.client.RestClient;
23
 
25
 
Line 75... Line 77...
75
		
77
		
76
		Map<String, String> params = new HashMap<>(authMap);
78
		Map<String, String> params = new HashMap<>(authMap);
77
		params.put("xmlin", reportName);
79
		params.put("xmlin", reportName);
78
		params.put("target_format", "CSV");
80
		params.put("target_format", "CSV");
79
		params.put("execute_mode", "EXECUTE");
81
		params.put("execute_mode", "EXECUTE");
-
 
82
		UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(reporticoUrl);
-
 
83
		Set<String> keys = params.keySet();
80
		
84
		
-
 
85
		for(String key : keys){
-
 
86
			builder.queryParam(key, params.get(key));
-
 
87
		}
81
		HttpEntity<String> requestEntity = new HttpEntity<String>("", new HttpHeaders());
88
		HttpEntity<String> requestEntity = new HttpEntity<String>("", new HttpHeaders());
82
		ResponseEntity<byte[]> responseEntity = restTemplate.exchange(reporticoUrl, HttpMethod.GET, requestEntity, byte[].class);
89
		ResponseEntity<byte[]> responseEntity = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET, requestEntity, byte[].class);
83
		return new ByteArrayResource(responseEntity.getBody());
90
		return new ByteArrayResource(responseEntity.getBody());
84
		
91
		
85
	}
92
	}
86
	
93
	
87
	public HttpResponse getReportFile(int fofoId, ReporticoProject projectName, String reportName) throws HttpHostConnectException, ProfitMandiBusinessException {
94
	public HttpResponse getReportFile(int fofoId, ReporticoProject projectName, String reportName) throws HttpHostConnectException, ProfitMandiBusinessException {