adding userName parameter to API

revert-dabc3590
Nirothipan 7 years ago
parent cff69459be
commit d217a72851

@ -33,6 +33,9 @@ public class FileTransfer extends AndroidOperation implements Serializable {
@ApiModelProperty(name = "fileURL", value = "File URL", required = true) @ApiModelProperty(name = "fileURL", value = "File URL", required = true)
private String fileURL; private String fileURL;
@ApiModelProperty(name = "userName", value = "User Name", required = true)
private String userName;
@ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true) @ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true)
private String ftpPassword; private String ftpPassword;
@ -62,4 +65,12 @@ public class FileTransfer extends AndroidOperation implements Serializable {
public void setFileLocation(String fileLocation) { public void setFileLocation(String fileLocation) {
this.fileLocation = fileLocation; this.fileLocation = fileLocation;
} }
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
} }

@ -95,13 +95,14 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
@Override @Override
public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) { public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) {
try { try {
if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null) { if (fileTransferBeanWrapper == null || fileTransferBeanWrapper.getOperation() == null
|| fileTransferBeanWrapper.getDeviceIDs() == null) {
String errorMessage = "The payload of the file transfer operation is incorrect."; String errorMessage = "The payload of the file transfer operation is incorrect.";
log.error(errorMessage); log.error(errorMessage);
throw new BadRequestException( throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
if (fileTransferBeanWrapper.getDeviceIDs() != null && log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs()); log.debug("Invoking Android file transfer operation for " + fileTransferBeanWrapper.getDeviceIDs());
} }
FileTransfer file = fileTransferBeanWrapper.getOperation(); FileTransfer file = fileTransferBeanWrapper.getOperation();
@ -1105,7 +1106,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
} }
private static void validateScheduleDate(String dateString){ private static void validateScheduleDate(String dateString) {
try { try {
if (dateString != null && !dateString.isEmpty()) { if (dateString != null && !dateString.isEmpty()) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);

@ -24,6 +24,9 @@ function operationSelect(selection) {
$(modalPopupContent).addClass("operation-data"); $(modalPopupContent).addClass("operation-data");
$(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html()); $(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html());
$(modalPopupContent).data("operation-code", selection); $(modalPopupContent).data("operation-code", selection);
if (selection === "FILE_TRANSFER") {
fillUserName();
}
showPopup(); showPopup();
} }
@ -32,6 +35,24 @@ var resetLoader = function () {
$('#lbl-execution').addClass("hidden"); $('#lbl-execution').addClass("hidden");
}; };
function fillUserName() {
var inputBox = document.getElementById('fileURL');
var regexp = ':\/\/[^\/]*@';
var pattern = new RegExp(regexp);
jQuery(inputBox).on('input', function () {
var fileUrl = inputBox.value;
var res = pattern.test(fileUrl);
if (res) {
var name = fileUrl.match(regexp).toString();
document.getElementById('userName').value = name.substring(3, name.length - 1);
} else {
document.getElementById('userName').value = "";
document.getElementById('userName').placeholder = "User Name"
}
}
);
}
/** /**
* This changes the text box label when the operation is toggled between FILE UPLOAD and FILE DOWNLOAD * This changes the text box label when the operation is toggled between FILE UPLOAD and FILE DOWNLOAD
* and shows an info label for FILE UPLOAD regarding saving location. * and shows an info label for FILE UPLOAD regarding saving location.
@ -42,13 +63,14 @@ function changeLabel(type) {
if (type == "no") { if (type == "no") {
$(".modal #operation-warn-msg span").text("File will be saved in default location if not specified."); $(".modal #operation-warn-msg span").text("File will be saved in default location if not specified.");
$(".modal #operation-warn-msg").removeClass("hidden"); $(".modal #operation-warn-msg").removeClass("hidden");
document.getElementById('fileURL').placeholder = "HTTP/FTP URL of the file"; document.getElementById('fileURL').placeholder = "File URL";
document.getElementById('fileLocation').placeholder = "Location to save file in device"; document.getElementById('fileLocation').placeholder = "Location to save file in device";
} else { } else {
$(".modal #operation-warn-msg").addClass("hidden"); $(".modal #operation-warn-msg").addClass("hidden");
document.getElementById('fileURL').placeholder = "FTP URL of the folder to upload file"; document.getElementById('fileURL').placeholder = "URL for file upload";
document.getElementById('fileLocation').placeholder = "File location in the device"; document.getElementById('fileLocation').placeholder = "File location in the device";
} }
fillUserName();
} }
function submitForm(formId) { function submitForm(formId) {
@ -97,7 +119,7 @@ function submitForm(formId) {
var defaultStatusClasses = "fw fw-stack-1x"; var defaultStatusClasses = "fw fw-stack-1x";
var content = $("#operation-response-template").find(".content"); var content = $("#operation-response-template").find(".content");
var title = content.find("#title"); var title = content.find("#title");
title.attr("class","center-block text-center"); title.attr("class", "center-block text-center");
var statusIcon = content.find("#status-icon"); var statusIcon = content.find("#status-icon");
var description = content.find("#description"); var description = content.find("#description");
description.html(""); description.html("");
@ -275,6 +297,7 @@ var generatePayload = function (operationCode, operationData, deviceList) {
payload = { payload = {
"operation": { "operation": {
"fileURL": operationData["fileURL"], "fileURL": operationData["fileURL"],
"userName": operationData["userName"],
"ftpPassword": operationData["ftpPassword"], "ftpPassword": operationData["ftpPassword"],
"fileLocation": operationData["fileLocation"] "fileLocation": operationData["fileLocation"]
}, },

@ -151,13 +151,19 @@
"type": "text", "type": "text",
"id": "fileURL", "id": "fileURL",
"optional": false, "optional": false,
"label": "FTP URL of the folder to upload file" "label": "URL for file upload"
},
{
"type": "text",
"id": "userName",
"optional": false,
"label": "User Name (Ignore if you don't need authentication.)"
}, },
{ {
"type": "password", "type": "password",
"id": "ftpPassword", "id": "ftpPassword",
"optional": false, "optional": false,
"label": "Password (Ignore if you don't need any)" "label": "Password (Ignore if you don't need authentication.)"
}, },
{ {
"type": "text", "type": "text",

Loading…
Cancel
Save