| 8224 |
manish.sha |
1 |
/*******************************************************************************
|
|
|
2 |
* Copyright 2009 Amazon Services.
|
|
|
3 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
4 |
*
|
|
|
5 |
* You may not use this file except in compliance with the License.
|
|
|
6 |
* You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
|
|
|
7 |
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
8 |
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
|
9 |
* specific language governing permissions and limitations under the License.
|
|
|
10 |
* *****************************************************************************
|
|
|
11 |
*
|
|
|
12 |
* Marketplace Web Service Java Library
|
|
|
13 |
* API Version: 2009-01-01
|
|
|
14 |
* Generated: Wed Feb 18 13:28:48 PST 2009
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
package com.amazonaws.mws.samples;
|
|
|
21 |
|
|
|
22 |
import java.util.List;
|
|
|
23 |
import java.util.ArrayList;
|
|
|
24 |
import com.amazonaws.mws.*;
|
|
|
25 |
import com.amazonaws.mws.model.*;
|
|
|
26 |
import java.util.concurrent.Future;
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
*
|
|
|
30 |
* Get Feed Submission List Samples
|
|
|
31 |
*
|
|
|
32 |
*
|
|
|
33 |
*/
|
|
|
34 |
public class GetFeedSubmissionListAsyncSample {
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Just add a few required parameters, and try the service
|
|
|
38 |
* Get Feed Submission List functionality
|
|
|
39 |
*
|
|
|
40 |
* @param args unused
|
|
|
41 |
*/
|
|
|
42 |
public static void main(String... args) {
|
|
|
43 |
|
|
|
44 |
/************************************************************************
|
|
|
45 |
* Access Key ID and Secret Access Key ID, obtained from:
|
|
|
46 |
* http://aws.amazon.com
|
|
|
47 |
***********************************************************************/
|
|
|
48 |
final String accessKeyId = "<Your Access Key ID>";
|
|
|
49 |
final String secretAccessKey = "<Your Secret Access Key>";
|
|
|
50 |
final String appName = "<Your Application or Company Name>";
|
|
|
51 |
final String appVersion = "<Your Application Version or Build Number or Release Date>";
|
|
|
52 |
|
|
|
53 |
MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();
|
|
|
54 |
|
|
|
55 |
/************************************************************************
|
|
|
56 |
* Uncomment to set the appropriate MWS endpoint.
|
|
|
57 |
************************************************************************/
|
|
|
58 |
// US
|
|
|
59 |
// config.setServiceURL("https://mws.amazonservices.com");
|
|
|
60 |
// UK
|
|
|
61 |
// config.setServiceURL("https://mws.amazonservices.co.uk");
|
|
|
62 |
// Germany
|
|
|
63 |
// config.setServiceURL("https://mws.amazonservices.de");
|
|
|
64 |
// France
|
|
|
65 |
// config.setServiceURL("https://mws.amazonservices.fr");
|
|
|
66 |
// Italy
|
|
|
67 |
// config.setServiceURL("https://mws.amazonservices.it");
|
|
|
68 |
// Japan
|
|
|
69 |
// config.setServiceURL("https://mws.amazonservices.jp");
|
|
|
70 |
// China
|
|
|
71 |
// config.setServiceURL("https://mws.amazonservices.com.cn");
|
|
|
72 |
// Canada
|
|
|
73 |
// config.setServiceURL("https://mws.amazonservices.ca");
|
|
|
74 |
// India
|
|
|
75 |
// config.setServiceURL("https://mws.amazonservices.in");
|
|
|
76 |
|
|
|
77 |
/************************************************************************
|
|
|
78 |
* The argument (35) set below is the number of threads client should
|
|
|
79 |
* spawn for processing.
|
|
|
80 |
***********************************************************************/
|
|
|
81 |
|
|
|
82 |
config.setMaxAsyncThreads(35);
|
|
|
83 |
|
|
|
84 |
/************************************************************************
|
|
|
85 |
* You can also try advanced configuration options. Available options are:
|
|
|
86 |
*
|
|
|
87 |
* - Signature Version
|
|
|
88 |
* - Proxy Host and Proxy Port
|
|
|
89 |
* - User Agent String to be sent to Marketplace Web Service
|
|
|
90 |
*
|
|
|
91 |
***********************************************************************/
|
|
|
92 |
|
|
|
93 |
/************************************************************************
|
|
|
94 |
* Instantiate Http Client Implementation of Marketplace Web Service
|
|
|
95 |
***********************************************************************/
|
|
|
96 |
|
|
|
97 |
MarketplaceWebService service = new MarketplaceWebServiceClient(
|
|
|
98 |
accessKeyId, secretAccessKey, appName, appVersion, config);
|
|
|
99 |
|
|
|
100 |
/************************************************************************
|
|
|
101 |
* Setup requests parameters and invoke parallel processing. Of course
|
|
|
102 |
* in real world application, there will be much more than a couple of
|
|
|
103 |
* requests to process.
|
|
|
104 |
***********************************************************************/
|
|
|
105 |
|
|
|
106 |
/************************************************************************
|
|
|
107 |
* Marketplace and Merchant IDs are required parameters for all
|
|
|
108 |
* Marketplace Web Service calls.
|
|
|
109 |
***********************************************************************/
|
|
|
110 |
final String merchantId = "<Your Merchant ID>";
|
|
|
111 |
|
|
|
112 |
GetFeedSubmissionListRequest requestOne = new GetFeedSubmissionListRequest();
|
|
|
113 |
requestOne.setMerchant( merchantId );
|
|
|
114 |
// @TODO: set request parameters here
|
|
|
115 |
|
|
|
116 |
GetFeedSubmissionListRequest requestTwo = new GetFeedSubmissionListRequest();
|
|
|
117 |
requestTwo.setMerchant( merchantId );
|
|
|
118 |
// @TODO: set second request parameters here
|
|
|
119 |
|
|
|
120 |
List<GetFeedSubmissionListRequest> requests = new ArrayList<GetFeedSubmissionListRequest>();
|
|
|
121 |
requests.add(requestOne);
|
|
|
122 |
requests.add(requestTwo);
|
|
|
123 |
|
|
|
124 |
// invokeGetFeedSubmissionList(service, requests);
|
|
|
125 |
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
/**
|
|
|
131 |
* Get Feed Submission List request sample
|
|
|
132 |
* returns a list of feed submission identifiers and their associated metadata
|
|
|
133 |
*
|
|
|
134 |
* @param service instance of MarketplaceWebService service
|
|
|
135 |
* @param requests list of requests to process
|
|
|
136 |
*/
|
|
|
137 |
public static void invokeGetFeedSubmissionList(MarketplaceWebService service, List<GetFeedSubmissionListRequest> requests) {
|
|
|
138 |
List<Future<GetFeedSubmissionListResponse>> responses = new ArrayList<Future<GetFeedSubmissionListResponse>>();
|
|
|
139 |
for (GetFeedSubmissionListRequest request : requests) {
|
|
|
140 |
responses.add(service.getFeedSubmissionListAsync(request));
|
|
|
141 |
}
|
|
|
142 |
for (Future<GetFeedSubmissionListResponse> future : responses) {
|
|
|
143 |
while (!future.isDone()) {
|
|
|
144 |
Thread.yield();
|
|
|
145 |
}
|
|
|
146 |
try {
|
|
|
147 |
GetFeedSubmissionListResponse response = future.get();
|
|
|
148 |
// Original request corresponding to this response, if needed:
|
|
|
149 |
GetFeedSubmissionListRequest originalRequest = requests.get(responses.indexOf(future));
|
|
|
150 |
System.out.println("Response request id: " + response.getResponseMetadata().getRequestId());
|
|
|
151 |
System.out.println(response.getResponseHeaderMetadata());
|
|
|
152 |
System.out.println();
|
|
|
153 |
} catch (Exception e) {
|
|
|
154 |
if (e.getCause() instanceof MarketplaceWebServiceException) {
|
|
|
155 |
MarketplaceWebServiceException exception = MarketplaceWebServiceException.class.cast(e.getCause());
|
|
|
156 |
System.out.println("Caught Exception: " + exception.getMessage());
|
|
|
157 |
System.out.println("Response Status Code: " + exception.getStatusCode());
|
|
|
158 |
System.out.println("Error Code: " + exception.getErrorCode());
|
|
|
159 |
System.out.println("Error Type: " + exception.getErrorType());
|
|
|
160 |
System.out.println("Request ID: " + exception.getRequestId());
|
|
|
161 |
System.out.print("XML: " + exception.getXML());
|
|
|
162 |
System.out.println("ResponseHeaderMetadata: " + exception.getResponseHeaderMetadata());
|
|
|
163 |
} else {
|
|
|
164 |
e.printStackTrace();
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
}
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
}
|