Added scheduled time to App-install operation

merge-requests/1/head
harshanl 8 years ago
parent 13aedbc6c6
commit 212dcae8e7

@ -44,6 +44,8 @@ public class ApplicationInstallation extends AndroidOperation implements Seriali
@ApiModelProperty(name = "url", value = "Application URL", required = true) @ApiModelProperty(name = "url", value = "Application URL", required = true)
private String url; private String url;
@ApiModelProperty(name = "schedule", value = "Application install schedule.", required = false)
private String schedule;
public String getAppIdentifier() { public String getAppIdentifier() {
return appIdentifier; return appIdentifier;
@ -68,4 +70,12 @@ public class ApplicationInstallation extends AndroidOperation implements Seriali
public void setUrl(String url) { public void setUrl(String url) {
this.url = url; this.url = url;
} }
public String getSchedule() {
return schedule;
}
public void setSchedule(String schedule) {
this.schedule = schedule;
}
} }

@ -43,10 +43,6 @@ public class ApplicationUninstallation extends AndroidOperation implements Seria
@Pattern(regexp = "^[A-Za-z]*$") @Pattern(regexp = "^[A-Za-z]*$")
private String type; private String type;
@ApiModelProperty(name = "name", value = "The name of the application.", required = true)
@Size(min = 2, max = 45)
private String name;
public String getAppIdentifier() { public String getAppIdentifier() {
return appIdentifier; return appIdentifier;
} }
@ -63,11 +59,4 @@ public class ApplicationUninstallation extends AndroidOperation implements Seria
this.type = type; this.type = type;
} }
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
} }

@ -44,7 +44,7 @@ public class ApplicationUpdate extends AndroidOperation implements Serializable
private String type; private String type;
@ApiModelProperty(name = "url", value = "The URL of the application.", required = true) @ApiModelProperty(name = "url", value = "The URL of the application.", required = true)
private String url; private String url;
@ApiModelProperty(name = "schedule", value = "Application update schedule.", required = true) @ApiModelProperty(name = "schedule", value = "Application update schedule.", required = false)
private String schedule; private String schedule;
public String getAppIdentifier() { public String getAppIdentifier() {

@ -534,6 +534,18 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
throw new BadRequestException( throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
String scheduledTime = applicationInstallationBeanWrapper.getOperation().getSchedule();
if (scheduledTime != null && !scheduledTime.isEmpty()) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
try {
String formattedScheduledDate = format.format(format.parse(scheduledTime));
applicationInstallationBeanWrapper.getOperation().setSchedule(formattedScheduledDate);
} catch (ParseException e) {
String errorMessage = "Invalid date string is provided in for schedule parameter";
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
}
ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation(); ApplicationInstallation applicationInstallation = applicationInstallationBeanWrapper.getOperation();
JSONObject payload = new JSONObject(applicationInstallation.toJSON()); JSONObject payload = new JSONObject(applicationInstallation.toJSON());
@ -615,6 +627,18 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
throw new BadRequestException( throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
String scheduledTime = applicationUpdateBeanWrapper.getOperation().getSchedule();
if (scheduledTime != null && !scheduledTime.isEmpty()) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
try {
String formattedScheduledDate = format.format(format.parse(scheduledTime));
applicationUpdateBeanWrapper.getOperation().setSchedule(formattedScheduledDate);
} catch (ParseException e) {
String errorMessage = "Invalid date string is provided in for schedule parameter";
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
}
ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation(); ApplicationUpdate applicationUpdate = applicationUpdateBeanWrapper.getOperation();
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.UPDATE_APPLICATION); operation.setCode(AndroidConstants.OperationCodes.UPDATE_APPLICATION);

Loading…
Cancel
Save