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)
private String fileURL;
@ApiModelProperty(name = "userName", value = "User Name", required = true)
private String userName;
@ApiModelProperty(name = "ftpPassword", value = "FTP password", required = true)
private String ftpPassword;
@ -62,4 +65,12 @@ public class FileTransfer extends AndroidOperation implements Serializable {
public void setFileLocation(String 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
public Response fileTransfer(FileTransferBeanWrapper fileTransferBeanWrapper) {
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.";
log.error(errorMessage);
throw new BadRequestException(
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());
}
FileTransfer file = fileTransferBeanWrapper.getOperation();

@ -24,6 +24,9 @@ function operationSelect(selection) {
$(modalPopupContent).addClass("operation-data");
$(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html());
$(modalPopupContent).data("operation-code", selection);
if (selection === "FILE_TRANSFER") {
fillUserName();
}
showPopup();
}
@ -32,6 +35,24 @@ var resetLoader = function () {
$('#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
* and shows an info label for FILE UPLOAD regarding saving location.
@ -42,13 +63,14 @@ function changeLabel(type) {
if (type == "no") {
$(".modal #operation-warn-msg span").text("File will be saved in default location if not specified.");
$(".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";
} else {
$(".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";
}
fillUserName();
}
function submitForm(formId) {
@ -275,6 +297,7 @@ var generatePayload = function (operationCode, operationData, deviceList) {
payload = {
"operation": {
"fileURL": operationData["fileURL"],
"userName": operationData["userName"],
"ftpPassword": operationData["ftpPassword"],
"fileLocation": operationData["fileLocation"]
},

@ -151,13 +151,19 @@
"type": "text",
"id": "fileURL",
"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",
"id": "ftpPassword",
"optional": false,
"label": "Password (Ignore if you don't need any)"
"label": "Password (Ignore if you don't need authentication.)"
},
{
"type": "text",

Loading…
Cancel
Save