revert-70aa11f8
dilanua 8 years ago
commit 92aa413773

@ -48,11 +48,12 @@ if (!user) {
var deviceType = request.getParameter("deviceType"); // need a better solution here
deviceTypeConfig = utility.getDeviceTypeConfig(deviceType);
if (deviceTypeConfig && deviceTypeConfig.deviceType.downloadAgentUri) {
hearders = [{"name": constants["ACCEPT_IDENTIFIER"], "value": constants["APPLICATION_ZIP"]}];
sketchDownloadEndPoint = devicemgtProps["httpsURL"] + "/" + deviceTypeConfig.deviceType.downloadAgentUri;
serviceInvokers.HttpClient.get(sketchDownloadEndPoint + queryString, function (responsePayload, responseHeaders) {
if (responseHeaders) {
for (var i = 0; i < responseHeaders.length; i++) {
var header = responseHeaders[i]
var header = responseHeaders[i];
var headerName = String(header.getName());
var headerValue = String(header.getValue());
response.addHeader(headerName, headerValue);
@ -63,12 +64,12 @@ if (!user) {
return responsePayload;
}
}, function (responsePayload) {
log.error(responsePayload)
log.error(responsePayload);
var response = {};
response["status"] = "error";
return response;
}
);
, hearders);
} else {
result = 400;
}

@ -275,6 +275,8 @@ var invokers = function () {
throw new IllegalArgumentException("Invalid HTTP request method: " + method);
}
//noinspection JSUnresolvedVariable
var Header = Packages.org.apache.commons.httpclient.Header;
for(var i in headers){
var header = new Header();
header.setName(headers[i].name);
@ -282,8 +284,6 @@ var invokers = function () {
httpMethodObject.addRequestHeader(header);
}
//noinspection JSUnresolvedVariable
var Header = Packages.org.apache.commons.httpclient.Header;
var header = new Header();
header.setName(constants["CONTENT_TYPE_IDENTIFIER"]);
header.setValue(constants["APPLICATION_JSON"]);
@ -320,12 +320,14 @@ var invokers = function () {
client.executeMethod(httpMethodObject);
//noinspection JSUnresolvedFunction
var status = httpMethodObject.getStatusCode();
new Log().error(status);
if (status == 200) {
//noinspection JSUnresolvedFunction
var responseContentDispositionHeader = httpMethodObject.getResponseHeader(constants["CONTENT_DISPOSITION_IDENTIFIER"]);
if (responseContentDispositionHeader) {
return successCallback(httpMethodObject.getResponseBodyAsStream(), httpMethodObject.getResponseHeaders());
} else {
return successCallback(httpMethodObject.getResponseBody());
}
} else {
//noinspection JSUnresolvedFunction
return errorCallback(httpMethodObject.getResponseBody());
}
} catch (e) {

Loading…
Cancel
Save