kamidu 8 years ago
commit 082e708e8a

@ -43,9 +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 = "url", value = "The URL of the application.", required = true)
private String url;
@ApiModelProperty(name = "name", value = "The name of the application.", required = true) @ApiModelProperty(name = "name", value = "The name of the application.", required = true)
@Size(min = 2, max = 45) @Size(min = 2, max = 45)
private String name; private String name;
@ -66,14 +63,6 @@ public class ApplicationUninstallation extends AndroidOperation implements Seria
this.type = type; this.type = type;
} }
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getName() { public String getName() {
return name; return name;
} }

@ -558,22 +558,7 @@ 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());
} }
if (payload.has("type")) { validateType(payload);
String type = payload.getString("type");
if (!"enterprise".equalsIgnoreCase(type)
&& !"public".equalsIgnoreCase(type)
&& !"webapp".equalsIgnoreCase(type)) {
String errorMessage = "Invalid application type.";
log.error(errorMessage);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
} else {
String errorMessage = "Application type is missing.";
log.error(errorMessage);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
String errorMessage = "Malformed application url."; String errorMessage = "Malformed application url.";
log.error(errorMessage); log.error(errorMessage);
@ -673,6 +658,9 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build()); new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
} }
ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation(); ApplicationUninstallation applicationUninstallation = applicationUninstallationBeanWrapper.getOperation();
JSONObject payload = new JSONObject(applicationUninstallation.toJSON());
validateType(payload);
ProfileOperation operation = new ProfileOperation(); ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION); operation.setCode(AndroidConstants.OperationCodes.UNINSTALL_APPLICATION);
operation.setType(Operation.Type.PROFILE); operation.setType(Operation.Type.PROFILE);
@ -698,6 +686,25 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
} }
} }
private void validateType(JSONObject payload) {
if (payload.has("type")) {
String type = payload.getString("type");
if (!"enterprise".equalsIgnoreCase(type)
&& !"public".equalsIgnoreCase(type)
&& !"webapp".equalsIgnoreCase(type)) {
String errorMessage = "Invalid application type.";
log.error(errorMessage);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
} else {
String errorMessage = "Application type is missing.";
log.error(errorMessage);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
}
@POST @POST
@Path("/blacklist-applications") @Path("/blacklist-applications")
@Override @Override

@ -215,7 +215,7 @@ $(document).ready(function () {
// on-click function for policy un-publishing "yes" button // on-click function for policy un-publishing "yes" button
$("a#unpublish-policy-yes-link").click(function () { $("a#unpublish-policy-yes-link").click(function () {
invokerUtil.put( invokerUtil.post(
serviceURL, serviceURL,
policyList, policyList,
// on success // on success
@ -268,7 +268,7 @@ $(document).ready(function () {
// on-click function for policy removing "yes" button // on-click function for policy removing "yes" button
$("a#publish-policy-yes-link").click(function () { $("a#publish-policy-yes-link").click(function () {
invokerUtil.put( invokerUtil.post(
serviceURL, serviceURL,
policyList, policyList,
// on success // on success

@ -2038,7 +2038,7 @@ var updatePolicy = function (policy, state) {
policyList.push(getParameterByName("id")); policyList.push(getParameterByName("id"));
if (state == "save") { if (state == "save") {
serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy"; serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy";
invokerUtil.put( invokerUtil.post(
serviceURL, serviceURL,
policyList, policyList,
// on success // on success
@ -2055,7 +2055,7 @@ var updatePolicy = function (policy, state) {
); );
} else if (state == "publish") { } else if (state == "publish") {
serviceURL = "/api/device-mgt/v1.0/policies/activate-policy"; serviceURL = "/api/device-mgt/v1.0/policies/activate-policy";
invokerUtil.put( invokerUtil.post(
serviceURL, serviceURL,
policyList, policyList,
// on success // on success

@ -1824,7 +1824,7 @@ var updatePolicy = function (policy, state) {
var policyList = []; var policyList = [];
policyList.push(getParameterByName("id")); policyList.push(getParameterByName("id"));
serviceURL = base_api_url + "/policies/deactivate-policy"; serviceURL = base_api_url + "/policies/deactivate-policy";
invokerUtil.put( invokerUtil.post(
serviceURL, serviceURL,
policyList, policyList,
// on success // on success
@ -1841,7 +1841,7 @@ var updatePolicy = function (policy, state) {
var policyList = []; var policyList = [];
policyList.push(getParameterByName("id")); policyList.push(getParameterByName("id"));
serviceURL = base_api_url + "/policies/activate-policy"; serviceURL = base_api_url + "/policies/activate-policy";
invokerUtil.put( invokerUtil.post(
serviceURL, serviceURL,
policyList, policyList,
// on success // on success

Loading…
Cancel
Save