CramerRao1
2021-02-03 17:07:13
public static void SubmitNewFlightSubmission(String accessToken, String applicationId,
String flightId, String flightSubmissionRequestJson, String zipFilePath)
throws InterruptedException, URISyntaxException, IOException {
CloseableHttpClient httpclient = HttpClients.createDefault();
ResponseHandler<JsonObject> responseHandler = CreateJsonResponseHandler();
try {
// Get flight
HttpGet getFlightRequest = new HttpGet(MessageFormat.format(
"https://manage.devcenter.microsoft.com/v1.0/my/applications/{0}/flights/{1}", applicationId,
flightId));
getFlightRequest.addHeader("Authorization", "Bearer " + accessToken);
getFlightRequest.addHeader("User-Agent", "Java");
JsonObject getFlightResponse = httpclient.execute(getFlightRequest, responseHandler);
// Delete existing in-progress submission
JsonObject submissionToRemove = getFlightResponse.getJsonObject("pendingFlightSubmission");
if(submissionToRemove != null){
String submissionToRemoveId = submissionToRemove.getString("id");
HttpDelete deleteSubmissionRequest = new HttpDelete(MessageFormat.format(
"https://manage.devcenter.microsoft.com/v1.0/my/applications/{0}/flights/{1}/submissions/{2}",
applicationId, flightId, submissionToRemoveId));
deleteSubmissionRequest.addHeader("Authorization", "Bearer " + accessToken);
deleteSubmissionRequest.addHeader("User-Agent", "Java");
httpclient.execute(deleteSubmissionRequest, responseHandler);
}
// Create submission
HttpPost createSubmissionRequest = new HttpPost(MessageFormat.format(
"https://manage.devcenter.microsoft.com/v1.0/my/applications/{0}/flights/{1}/submissions",
applicationId, flightId));
createSubmissionRequest.addHeader("Authorization", "Bearer " + accessToken);
createSubmissionRequest.addHeader("User-Agent", "Java");
JsonObject createSubmissionResponse = httpclient.execute(createSubmissionRequest, responseHandler);
String submissionId = createSubmissionResponse.getString("id");
String fileUploadUrl = createSubmissionResponse.getString("fileUploadUrl");
// Update submission
HttpPut updateSubmissionRequest = new HttpPut(MessageFormat.format(
"https://manage.devcenter.microsoft.com/v1.0/my/applications/{0}/flights/{1}/submissions/{2}",
applicationId, flightId, submissionId));
updateSubmissionRequest.addHeader("Authorization", "Bearer " + accessToken);
updateSubmissionRequest.addHeader("Content-type", "application/json");
updateSubmissionRequest.addHeader("User-Agent", "Java");
updateSubmissionRequest.setEntity(new StringEntity(flightSubmissionRequestJson));
JsonObject updateSubmissionResponse = httpclient.execute(updateSubmissionRequest, responseHandler);
// Upload images and packages in a zip file
UploadZipFile(fileUploadUrl, zipFilePath);
// Commit submission
HttpPost commitSubmissionRequest = new HttpPost(MessageFormat.format(
"https://manage.devcenter.microsoft.com/v1.0/my/applications/{0}/flights/{1}/submissions/{2}/commit",
applicationId, flightId, submissionId));
commitSubmissionRequest.addHeader("Authorization", "Bearer " + accessToken);
commitSubmissionRequest.addHeader("User-Agent", "Java");
JsonObject commitSubmissionResponse = httpclient.execute(commitSubmissionRequest, responseHandler);
System.out.println(commitSubmissionResponse.getString("status"));
// Pull submission status until commit process is completed
HttpGet getSubmissionStatusRequest = new HttpGet(MessageFormat.format(
"https://manage.devcenter.microsoft.com/v1.0/my/applications/{0}/flights/{1}/submissions/{2}",
applicationId, flightId, submissionId));
getSubmissionStatusRequest.addHeader("Authorization", "Bearer " + accessToken);
getSubmissionStatusRequest.addHeader("User-Agent", "Java");
JsonObject getSubmissionStatusResponse = httpclient.execute(getSubmissionStatusRequest,
responseHandler);
String submissionStatus = getSubmissionStatusResponse.getString("status");
while(submissionStatus.equals("CommitStarted")){
Thread.sleep(60*1000);
getSubmissionStatusResponse = httpclient.execute(getSubmissionStatusRequest, responseHandler);
submissionStatus = getSubmissionStatusResponse.getString("status");
}
System.out.println(submissionStatus);
} catch (HttpResponseException e){
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
httpclient.close();
}
}
si je vous parle en java vous allez mieux comprendre peut-être
Iphila
2021-02-03 17:10:13
Classe interface héritage typage statique et dynamique, classe object, itterateur, listes, awt/swing et deux trois autre librairie, les packages