Merge branch 'master' into release-2.2.1

merge-requests/1/head
Chatura Dilan Perera 8 years ago
commit 42b50b642a

@ -1123,7 +1123,7 @@ public interface DeviceManagementAdminService {
message = "Internal Server Error. \n " +
"Server error occurred while adding a new send notification operation.")
})
@Permission(name = "Send Notifications", permission = "/device-mgt/devices/owning-device/operations/android/notification")
@Permission(name = "Send Notifications", permission = "/device-mgt/devices/owning-device/operations/android/send-notification")
Response sendNotification(
@ApiParam(name = "notificationBeanWrapper",
value = "Notification Configurations and device Ids")
@ -1284,7 +1284,7 @@ public interface DeviceManagementAdminService {
message = "Internal Server Error. \n " +
"Server error occurred while adding a new change lock code operation.")
})
@Permission(name = "Change Password of Device", permission = "/device-mgt/devices/owning-device/operations/android/change-lock")
@Permission(name = "Change Password of Device", permission = "/device-mgt/devices/owning-device/operations/android/change-lock-code")
Response changeLockCode(
@ApiParam(name = "lockCodeBeanWrapper",
value = "Configurations and device Ids need to be done change lock code")

@ -0,0 +1,25 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{#zone "topCss"}}
{{css "css/daterangepicker.css"}}
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/moment.min.js"}}
{{js "js/daterangepicker.js"}}
{{/zone}}

@ -0,0 +1,21 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function onRequest() {
return "";
}

@ -0,0 +1,361 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
.date-picker {
width: 170px;
height: 25px;
padding: 0;
border: 0;
line-height: 25px;
padding-left: 10px;
font-size: 12px;
font-family: Arial;
font-weight: bold;
cursor: pointer;
color: #303030;
position: relative;
z-index: 2;
}
.date-picker-wrapper {
position: absolute;
z-index: 1;
border: 1px solid #bfbfbf;
background-color: #efefef;
width: 448px;
padding: 5px 12px;
font-size: 12px;
line-height: 20px;
color: #aaa;
font-family: Arial;
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
}
.date-picker-wrapper.single-date {
width: auto;
}
.date-picker-wrapper.no-shortcuts {
padding-bottom: 12px;
}
.date-picker-wrapper .footer {
display: none;
font-size: 11px;
padding-top: 3px;
}
.date-picker-wrapper b {
color: #666;
font-weight: 700;
}
.date-picker-wrapper a {
color: rgb(107, 180, 214);
text-decoration: underline;
}
.date-picker-wrapper .month-wrapper {
border: 1px solid #bfbfbf;
border-radius: 3px;
background-color: #fff;
padding: 5px;
cursor: default;
position: relative;
_overflow: hidden;
}
.date-picker-wrapper .month-wrapper table {
width: 190px;
float: left;
}
.date-picker-wrapper .month-wrapper table.month2 {
width: 190px;
float: right;
}
.date-picker-wrapper .month-wrapper table th,
.date-picker-wrapper .month-wrapper table td {
vertical-align: middle;
text-align: center;
line-height: 14px;
margin: 0px;
padding: 0px;
}
.date-picker-wrapper .month-wrapper table .day {
height: 19px;
line-height: 19px;
font-size: 12px;
margin-bottom: 1px;
color: #999;
cursor: default;
}
.date-picker-wrapper .month-wrapper table div.day.lastMonth,
.date-picker-wrapper .month-wrapper table div.day.nextMonth {
color: #999;
cursor: default;
}
.date-picker-wrapper .month-wrapper table .day.checked {
background-color: rgb(156, 219, 247);
}
.date-picker-wrapper .month-wrapper table .week-name {
height: 20px;
line-height: 20px;
font-weight: 100;
}
.date-picker-wrapper .month-wrapper table .day.has-tooltip {
cursor: help !important;
}
.date-picker-wrapper .month-wrapper table .day.toMonth.valid {
color: #333;
cursor: pointer;
}
.date-picker-wrapper .month-wrapper table .day.real-today {
background-color: rgb(255, 230, 132);
}
.date-picker-wrapper .month-wrapper table .day.real-today.checked {
background-color: rgb(112, 204, 213);
}
.date-picker-wrapper table .caption {
height: 40px;
}
.date-picker-wrapper table .caption .next,
.date-picker-wrapper table .caption .prev {
padding: 0 5px;
cursor: pointer;
}
.date-picker-wrapper table .caption .next:hover,
.date-picker-wrapper table .caption .prev:hover {
background-color: #ccc;
color: white;
}
.date-picker-wrapper .gap {
position: absolute;
display: none;
top: 0px;
left: 204px;
z-index: 1;
width: 15px;
height: 100%;
background-color: red;
font-size: 0;
line-height: 0;
}
.date-picker-wrapper .gap .gap-lines {
height: 100%;
overflow: hidden;
}
.date-picker-wrapper .gap .gap-line {
height: 15px;
width: 15px;
position: relative;
}
.date-picker-wrapper .gap .gap-line .gap-1 {
z-index: 1;
height: 0;
border-left: 8px solid white;
border-top: 8px solid #eee;
border-bottom: 8px solid #eee;
}
.date-picker-wrapper .gap .gap-line .gap-2 {
position: absolute;
right: 0;
top: 0px;
z-index: 2;
height: 0;
border-left: 8px solid transparent;
border-top: 8px solid white;
}
.date-picker-wrapper .gap .gap-line .gap-3 {
position: absolute;
right: 0;
top: 8px;
z-index: 2;
height: 0;
border-left: 8px solid transparent;
border-bottom: 8px solid white;
}
.date-picker-wrapper .gap .gap-top-mask {
width: 6px;
height: 1px;
position: absolute;
top: -1px;
left: 1px;
background-color: #eee;
z-index: 3;
}
.date-picker-wrapper .gap .gap-bottom-mask {
width: 6px;
height: 1px;
position: absolute;
bottom: -1px;
left: 7px;
background-color: #eee;
z-index: 3;
}
.date-picker-wrapper .selected-days {
display: none;
}
.date-picker-wrapper .drp_top-bar {
line-height: 40px;
height: 40px;
position: relative;
}
.date-picker-wrapper .drp_top-bar .error-top {
display: none;
}
.date-picker-wrapper .drp_top-bar .normal-top {
display: none;
}
.date-picker-wrapper .drp_top-bar .default-top {
display: block;
}
.date-picker-wrapper .drp_top-bar.error .default-top {
display: none;
}
.date-picker-wrapper .drp_top-bar.error .error-top {
display: block;
color: red;
}
.date-picker-wrapper .drp_top-bar.normal .default-top {
display: none;
}
.date-picker-wrapper .drp_top-bar.normal .normal-top {
display: block;
}
.date-picker-wrapper .drp_top-bar .apply-btn {
position: absolute;
right: 0px;
top: 6px;
padding: 3px 5px;
margin: 0;
font-size: 12px;
border-radius: 4px;
cursor: pointer;
color: #d9eef7;
border: solid 1px #0076a3;
background: #0095cd;
background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5));
background: -moz-linear-gradient(top, #00adee, #0078a5);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
color: white;
}
.date-picker-wrapper .drp_top-bar .apply-btn.disabled {
pointer-events: none;
color: #606060;
border: solid 1px #b7b7b7;
background: #fff;
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed));
background: -moz-linear-gradient(top, #fff, #ededed);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed');
}
/*time styling*/
.time {
position: relative;
}
.time input[type=range] {
vertical-align: middle;
}
.time1, .time2 {
width: 180px;
padding: 0 5px;
text-align: center;
}
.time1 {
float: left;
}
.time2 {
float: right;
}
.hour, .minute {
text-align: left;
}
.hide {
display: none;
}
input.hour-range, input.minute-range {
width: 150px;
}
#dateRangePickerContainer .date-range, #dateRangePickerContainer .input-append {
background: none !important;
}
#date-range {
padding-right: 30px;
width: 300px;
height: 100%;
display: inline-block;
}
#dateRangePickerContainer {
float: right;
}
.date-range {
border: 1px solid #ccc;
}
#dateRangePickerContainer button.active {
background-color: #e6e6e6 !important;
}
#dateRangePickerContainer .btn-default:hover {
background-color: #b2b2b2;
border-color: #000000;
}

@ -16,7 +16,7 @@
* under the License.
*/
function onRequest(context) {
function onRequest() {
// var log = new Log("mdm.unit.device.operation-bar");
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var viewModel = {};
@ -27,10 +27,10 @@ function onRequest(context) {
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/ring")) {
permissions["android"].push("DEVICE_RING");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/lock-devices")) {
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/lock")) {
permissions["android"].push("DEVICE_LOCK");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/unlock-devices")) {
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/unlock")) {
permissions["android"].push("DEVICE_UNLOCK");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/location")) {

@ -1182,7 +1182,7 @@ var operationModule = function () {
"WIPE_DATA": "wipe-devices"
};
//return "/mdm-windows-agent/services/windows/operation/" + featureMap[operationCode];
return "/api/device-mgt/windows/v1.0/admin/devices/" + featureMap[operationCode];
return "/api/device-mgt/windows/v1.0/services/windows/admin/devices/" + featureMap[operationCode];
};
/**
* Get the icon for the featureCode

@ -44,7 +44,7 @@ var InitiateViewOption = null;
// error-callback
function () {
var defaultInnerHTML =
"<br><p class='fw-warning'>Device data may not have been updated. Please refresh to try again.<p>";
"<br><p class='small'><i class='fw-warning'></i>&nbsp;Device data may not have been updated. Please refresh to try again.<p>";
$(".panel-body").append(defaultInnerHTML);
}
);

@ -312,7 +312,7 @@ deviceModule = function () {
var url;
var license;
if (deviceType == "windows") {
url = devicemgtProps["httpURL"] + "/mdm-windows-agent/services/device/license";
url = devicemgtProps["httpURL"] + "/api/device-mgt/windows/v1.0/services/configuration/license";
} else if (deviceType == "ios") {
url = devicemgtProps["httpsURL"] + "/ios-enrollment/license/";
}

@ -63,7 +63,7 @@ if (platform != "Windows Phone") {
var status = restAPIResponse["status"];
if (status == 200) {
session.put("authenticatedUser", username);
session.put("windowsBinaryToken", parse(xmlHttpRequest["responseText"]).UserToken);
session.put("windowsBinaryToken", parse(restAPIResponse["responseText"]).UserToken);
response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/license-agent");
} else if (status == 403) {
response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=auth-failed");

@ -36,10 +36,10 @@ if (platform != "Windows Phone") {
if (!authenticatedUser) {
response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request");
} else {
var enrollmentUtils = require("/modules/enrollments/util/utils.js")["methods"];
var Handlebars = require("/lib/handlebars-v2.0.0.js")["Handlebars"];
var enrollmentUtils = require("/app/modules/enrollments/util/utils.js")["methods"];
var Handlebars = require("/lib/modules/handlebars/handlebars-v2.0.0.js")["Handlebars"];
var template = Handlebars.compile(enrollmentUtils.
getResource("/modules/enrollments/windows/config/workplace-switch-request-template.hbs"));
getResource("/app/modules/enrollments/windows/config/workplace-switch-request-template.hbs"));
var windowsWorkplaceAppID = session.get("windowsWorkplaceAppID");
var windowsBinaryToken = session.get("windowsBinaryToken");

@ -263,6 +263,13 @@ public final class PluginConstants {
}
public static final int MULTI_STATUS_HTTP_CODE = 207;
}
public final class WindowsConstant {
public static final String DEVICE_TYPE_WINDOWS = "windows";
public static final String HEADER_CONTENT_TYPE = "Content-Type";
public static final String APPLICATION_JSON = "application/json";
}
/**
@ -282,6 +289,7 @@ public final class PluginConstants {
public static final String DEFAULT_AUTH_POLICY = "Federated";
}
/**
* Policy Configuration related constants.
*/

@ -0,0 +1,86 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.mobile.windows.api.common.beans;
import java.util.ArrayList;
import java.util.List;
public class ErrorDTO {
private Long code = null;
private String message = null;
private String description = null;
public void setMoreInfo(String moreInfo) {
this.moreInfo = moreInfo;
}
public void setCode(Long code) {
this.code = code;
}
public void setMessage(String message) {
this.message = message;
}
public void setDescription(String description) {
this.description = description;
}
public void setError(List<ErrorDTO> error) {
this.error = error;
}
private String moreInfo = null;
public String getMessage() {
return message;
}
public Long getCode() {
return code;
}
public String getDescription() {
return description;
}
public String getMoreInfo() {
return moreInfo;
}
public List<ErrorDTO> getError() {
return error;
}
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("class ErrorDTO {\n");
stringBuilder.append(" code: ").append(code).append("\n");
stringBuilder.append(" message: ").append(message).append("\n");
stringBuilder.append(" description: ").append(description).append("\n");
stringBuilder.append(" moreInfo: ").append(moreInfo).append("\n");
stringBuilder.append(" error: ").append(error).append("\n");
stringBuilder.append("}\n");
return stringBuilder.toString();
}
private List<ErrorDTO> error = new ArrayList<>();
}

@ -0,0 +1,77 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.mgt.mobile.windows.api.common.beans;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
@ApiModel(description = "")
public class ErrorListItem {
@NotNull
private String code = null;
@NotNull
private String message = null;
@ApiModelProperty(required = true, value = "")
@JsonProperty("code")
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public ErrorListItem() {}
public ErrorListItem(String code, String msg) {
this.code = code;
this.message = msg;
}
/**
* Description about individual errors occurred
**/
@ApiModelProperty(required = true, value = "Description about individual errors occurred")
@JsonProperty("message")
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("errorItem {\n");
sb.append(" code: ").append(code).append("\n");
sb.append(" message: ").append(message).append("\n");
sb.append("}\n");
return sb.toString();
}
}

@ -0,0 +1,167 @@
package org.wso2.carbon.device.mgt.mobile.windows.api.common.beans;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
public class ErrorResponse {
private Long code = null;
private String message = null;
private String description = null;
private String moreInfo = null;
private List<ErrorListItem> errorItems = new ArrayList<>();
@JsonProperty(value = "code")
@ApiModelProperty(required = true, value = "")
public Long getCode() {
return code;
}
public void setCode(Long code) {
this.code = code;
}
@JsonProperty(value = "message")
@ApiModelProperty(required = true, value = "ErrorResponse message.")
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@JsonProperty(value = "description")
@ApiModelProperty(value = "A detail description about the error message.")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@JsonProperty(value = "moreInfo")
@ApiModelProperty(value = "Preferably an url with more details about the error.")
public String getMoreInfo() {
return moreInfo;
}
public void setMoreInfo(String moreInfo) {
this.moreInfo = moreInfo;
}
public void addErrorListItem(ErrorListItem item) {
this.errorItems.add(item);
}
/**
* If there are more than one error list them out. \nFor example, list out validation errors by each field.
*/
@JsonProperty(value = "errorItems")
@ApiModelProperty(value = "If there are more than one error list them out. \n" +
"For example, list out validation errors by each field.")
public List<ErrorListItem> getErrorItems() {
return errorItems;
}
public void setErrorItems(List<ErrorListItem> error) {
this.errorItems = error;
}
@Override
public String toString() {
// StringBuilder sb = new StringBuilder();
// sb.append("{");
// boolean cont = false;
// if (code != null) {
// cont = true;
// sb.append(" \"code\": ").append(code);
// }
// if (message != null) {
// if (cont) {
// sb.append(",");
// }
// cont = true;
// sb.append(" \"message\": \"").append(message).append("\"");
// }
// if (description != null) {
// if (cont) {
// sb.append(",");
// }
// cont = true;
// sb.append(" \"description\": ").append(description).append("\"");
// }
// if (moreInfo != null) {
// if (cont) {
// sb.append(",");
// }
// cont = true;
// sb.append(" \"moreInfo\": \"").append(moreInfo).append("\"");
// }
// if (error != null && error.size() > 0) {
// if (cont) {
// sb.append(",");
// }
// sb.append(" \"errorItems\": ").append(error);
// }
// sb.append("}");
// return sb.toString();
return null;
}
public static class ErrorResponseBuilder {
private Long code = null;
private String message = null;
private String description = null;
private String moreInfo = null;
private List<ErrorListItem> error;
public ErrorResponseBuilder() {
this.error = new ArrayList<>();
}
public ErrorResponseBuilder setCode(long code) {
this.code = code;
return this;
}
public ErrorResponseBuilder setMessage(String message) {
this.message = message;
return this;
}
public ErrorResponseBuilder setDescription(String description) {
this.description = description;
return this;
}
public ErrorResponseBuilder setMoreInfo(String moreInfo) {
this.moreInfo = moreInfo;
return this;
}
public ErrorResponseBuilder addErrorItem(String code, String msg) {
ErrorListItem item = new ErrorListItem();
item.setCode(code);
item.setMessage(msg);
this.error.add(item);
return this;
}
public ErrorResponse build() {
ErrorResponse errorResponse = new ErrorResponse();
errorResponse.setCode(code);
errorResponse.setMessage(message);
errorResponse.setErrorItems(error);
errorResponse.setDescription(description);
errorResponse.setMoreInfo(moreInfo);
return errorResponse;
}
}
}

@ -18,10 +18,9 @@
package org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.ErrorResponse;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
@ -29,8 +28,7 @@ import javax.ws.rs.core.Response;
*/
public class BadRequestException extends WebApplicationException {
public BadRequestException(Message message, MediaType mediaType) {
super(Response.status(Response.Status.BAD_REQUEST).entity(message).
type(mediaType).build());
public BadRequestException(ErrorResponse error) {
super(Response.status(Response.Status.BAD_REQUEST).entity(error).build());
}
}

@ -0,0 +1,49 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.ErrorDTO;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.ErrorResponse;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
public class UnexpectedServerErrorException extends WebApplicationException {
private String message;
private static final long serialVersionUID = 147943579458906890L;
public UnexpectedServerErrorException(ErrorResponse error) {
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build());
}
public UnexpectedServerErrorException(ErrorDTO errorDTO) {
super(Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity(errorDTO)
.header(PluginConstants.WindowsConstant.HEADER_CONTENT_TYPE, PluginConstants.WindowsConstant.APPLICATION_JSON)
.build());
message = errorDTO.getDescription();
}
@Override
public String getMessage() {
return message;
}
}

@ -18,18 +18,24 @@
package org.wso2.carbon.device.mgt.mobile.windows.api.common.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.BadRequestException;
import org.wso2.carbon.identity.core.util.IdentityTenantUtil;
import org.wso2.carbon.identity.oauth2.OAuth2TokenValidationService;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
@ -42,6 +48,7 @@ import org.wso2.carbon.webapp.authenticator.framework.config.AuthenticatorConfig
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
/**
@ -49,6 +56,8 @@ import java.util.List;
*/
public class WindowsAPIUtils {
private static Log log = LogFactory.getLog(WindowsAPIUtils.class);
public static DeviceIdentifier convertToDeviceIdentifierObject(String deviceId) {
DeviceIdentifier identifier = new DeviceIdentifier();
identifier.setId(deviceId);
@ -87,21 +96,25 @@ public class WindowsAPIUtils {
return responseMediaType;
}
public static Response getOperationResponse(List<String> deviceIDs, Operation operation,
Message message, MediaType responseMediaType)
throws DeviceManagementException, OperationManagementException {
WindowsDeviceUtils deviceUtils = new WindowsDeviceUtils();
DeviceIDHolder deviceIDHolder = deviceUtils.validateDeviceIdentifiers(deviceIDs,
message, responseMediaType);
// getDeviceManagementService().addOperation(operation, deviceIDHolder.getValidDeviceIDList());
if (!deviceIDHolder.getInvalidDeviceIdList().isEmpty()) {
return Response.status(PluginConstants.StatusCodes.
MULTI_STATUS_HTTP_CODE).type(
responseMediaType).entity(deviceUtils.
convertErrorMapIntoErrorMessage(deviceIDHolder.getInvalidDeviceIdList())).build();
public static Response getOperationResponse(List<String> deviceIDs, Operation operation)
throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
if (deviceIDs == null || deviceIDs.size() == 0) {
String errorMessage = "Device identifier list is empty";
log.error(errorMessage);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
DeviceIdentifier deviceIdentifier;
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
for (String deviceId : deviceIDs) {
deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId(deviceId);
deviceIdentifier.setType(PluginConstants.WindowsConstant.DEVICE_TYPE_WINDOWS);
deviceIdentifiers.add(deviceIdentifier);
}
return Response.status(Response.Status.CREATED).
type(responseMediaType).build();
Activity activity = getDeviceManagementService().addOperation(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, operation, deviceIdentifiers);
return Response.status(Response.Status.CREATED).entity(activity).build();
}
public static PolicyManagerService getPolicyManagerService() {
@ -126,8 +139,8 @@ public class WindowsAPIUtils {
throws OperationManagementException, DeviceManagementException {
List<? extends Operation> pendingDataOperations;
pendingDataOperations = org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils.
getDeviceManagementService().getOperationsByDeviceAndStatus(
deviceIdentifier, Operation.Status.PENDING);
getDeviceManagementService().getOperationsByDeviceAndStatus(
deviceIdentifier, Operation.Status.PENDING);
return pendingDataOperations;
}

@ -1,86 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* you may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.mobile.windows.api.common.util;
import org.apache.commons.lang.StringUtils;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.BadRequestException;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.List;
/**
* Class for get windows device utilities.
*/
public class WindowsDeviceUtils {
private static final String COMMA_SEPARATION_PATTERN = ", ";
public DeviceIDHolder validateDeviceIdentifiers(List<String> deviceIDs,
Message message, MediaType responseMediaType) {
if (deviceIDs == null) {
message.setResponseMessage("Device identifier list is empty");
throw new BadRequestException(message, responseMediaType);
}
List<String> errorDeviceIdList = new ArrayList<>();
List<DeviceIdentifier> validDeviceIDList = new ArrayList<>();
int deviceIDCounter = 0;
for (String deviceID : deviceIDs) {
deviceIDCounter++;
if (deviceID == null || deviceID.isEmpty()) {
errorDeviceIdList.add(String.format(PluginConstants.DeviceConstants.DEVICE_ID_NOT_FOUND,
deviceIDCounter));
continue;
}
try {
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setId(deviceID);
deviceIdentifier.setType(DeviceManagementConstants.MobileDeviceTypes.
MOBILE_DEVICE_TYPE_WINDOWS);
Device device = WindowsAPIUtils.getDeviceManagementService().
getDevice(deviceIdentifier);
if (device == null || device.getDeviceIdentifier() == null ||
device.getDeviceIdentifier().isEmpty()) {
errorDeviceIdList.add(String.format(PluginConstants.DeviceConstants.DEVICE_ID_NOT_FOUND,
deviceIDCounter));
continue;
}
validDeviceIDList.add(deviceIdentifier);
} catch (DeviceManagementException e) {
errorDeviceIdList.add(String.format(PluginConstants.DeviceConstants.DEVICE_ID_SERVICE_NOT_FOUND,
deviceIDCounter));
}
}
DeviceIDHolder deviceIDHolder = new DeviceIDHolder();
deviceIDHolder.setValidDeviceIDList(validDeviceIDList);
deviceIDHolder.setInvalidDeviceIdList(errorDeviceIdList);
return deviceIDHolder;
}
public String convertErrorMapIntoErrorMessage(List<String> errorDeviceIdList) {
return StringUtils.join(errorDeviceIdList.iterator(), COMMA_SEPARATION_PATTERN);
}
}

@ -18,7 +18,7 @@
package org.wso2.carbon.device.mgt.mobile.windows.api.services;
import io.swagger.annotations.Api;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.api.Permission;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@ -27,6 +27,8 @@ import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message;
import javax.jws.WebService;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
* Windows Platform Configuration REST-API implementation.
@ -42,25 +44,47 @@ import javax.ws.rs.*;
@Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"})
public interface ConfigurationMgtService {
/**
* Save Tenant configurations.
*
* @param configuration Tenant Configurations to be saved.
* @return Message type object for the provide save status.
* @throws WindowsConfigurationException
*/
@POST
@Permission(name = "Manage Configurations", permission = "/device-mgt/platform-configurations/manage")
Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException;
/**
* Retrieve Tenant configurations according to the device type.
*
* @return Tenant configuration object contains specific tenant configurations.
* @throws WindowsConfigurationException
*/
@GET
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Getting Windows Platform Configurations",
notes = "Get the Windows platform configuration details using this REST API",
response = PlatformConfiguration.class,
tags = "Windows Configuration Management"
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched Windows platform configuration.",
response = PlatformConfiguration.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching Windows platform configuration.")
})
@Permission(name = "View Configurations", permission = "/device-mgt/platform-configurations/view")
PlatformConfiguration getConfiguration() throws WindowsConfigurationException;
@ -72,6 +96,98 @@ public interface ConfigurationMgtService {
* @throws WindowsConfigurationException
*/
@PUT
@Permission(name = "Manage Configurations", permission = "/device-mgt/platform-configurations/manage")
Message updateConfiguration(PlatformConfiguration configuration) throws WindowsConfigurationException;
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "Updating Windows Platform Configuration.",
notes = "Update the Windows platform configurations using this REST API.",
tags = "Windows Configuration Management"
)
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Windows platform configuration has been updated successfully",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the updated Windows platform configuration."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while modifying Windows platform configuration.")
})
@Permission(name = "Manage Configurations", permission = "/device-mgt/configurations/manage")
Message updateConfiguration( @ApiParam(name = "configuration",
value = "PlatformConfiguration")PlatformConfiguration configuration) throws WindowsConfigurationException;
@GET
@Path("license")
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(
produces = MediaType.TEXT_PLAIN,
httpMethod = "GET",
value = "Getting the License Agreement for Windows Device Registration",
notes = "Use this REST API to retrieve the license agreement that is used for the Windows device " +
"registration process",
response = String.class,
tags = "Windows Configuration Management")
@ApiResponses(value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched Windows license configuration.",
response = String.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching Windows license configuration.")
})
Response getLicense(
@ApiParam(
name = "If-Modified-Since",
value = "Validates if the requested variant has not been modified since the time specified",
required = false)
@HeaderParam("If-Modified-Since") String ifModifiedSince) throws WindowsConfigurationException;
}

@ -26,6 +26,8 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.UnexpectedServerErrorException;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.WindowsAPIUtils;
@ -46,58 +48,6 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
private static Log log = LogFactory.getLog(
org.wso2.carbon.device.mgt.mobile.windows.api.services.impl.ConfigurationMgtServiceImpl.class);
/**
* Save Tenant configurations.
*
* @param configuration Tenant Configurations to be saved.
* @return Message type object for the provide save status.
* @throws WindowsConfigurationException
*/
@POST
public Message ConfigureSettings(PlatformConfiguration configuration) throws WindowsConfigurationException {
Message responseMsg = new Message();
ConfigurationEntry licenseEntry = null;
String message;
try {
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
if (!configuration.getConfiguration().isEmpty()) {
List<ConfigurationEntry> configs = configuration.getConfiguration();
for (ConfigurationEntry entry : configs) {
if (PluginConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) {
License license = new License();
license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS);
license.setLanguage(PluginConstants.TenantConfigProperties.LANGUAGE_US);
license.setVersion("1.0.0");
license.setText(entry.getValue().toString());
WindowsAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS, license);
licenseEntry = entry;
}
}
if (licenseEntry != null) {
configs.remove(licenseEntry);
}
configuration.setConfiguration(configs);
WindowsAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
Response.status(Response.Status.CREATED);
responseMsg.setResponseMessage("Windows platform configuration saved successfully.");
responseMsg.setResponseCode(Response.Status.CREATED.toString());
return responseMsg;
} else {
Response.status(Response.Status.BAD_REQUEST);
responseMsg.setResponseMessage("Windows platform configuration can not be saved.");
responseMsg.setResponseCode(Response.Status.CREATED.toString());
}
} catch (DeviceManagementException e) {
message = "Error Occurred while configuring Windows Platform.";
log.error(message, e);
throw new WindowsConfigurationException(message, e);
}
return responseMsg;
}
/**
* Retrieve Tenant configurations according to the device type.
*
@ -182,4 +132,24 @@ public class ConfigurationMgtServiceImpl implements ConfigurationMgtService {
}
return responseMsg;
}
@GET
@Path("/license")
public Response getLicense(
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
License license;
try {
license =
WindowsAPIUtils.getDeviceManagementService().getLicense(
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS,
DeviceManagementConstants.LanguageCodes.LANGUAGE_CODE_ENGLISH_US);
} catch (DeviceManagementException e) {
String msg = "Error occurred while retrieving the license configured for Windows device enrolment";
log.error(msg, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
}
return Response.status(Response.Status.OK).entity(license).build();
}
}

@ -22,10 +22,13 @@ import com.ibm.wsdl.OperationImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.BadRequestException;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsDeviceEnrolmentException;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsOperationsException;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.util.Message;
@ -69,7 +72,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
operation.setCode(PluginConstants.OperationCodes.DEVICE_LOCK);
operation.setType(Operation.Type.COMMAND);
operation.setEnabled(true);
return WindowsAPIUtils.getOperationResponse(deviceIDs, operation, message, responseMediaType);
return WindowsAPIUtils.getOperationResponse(deviceIDs, operation);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message.setResponseMessage(errorMessage);
@ -82,6 +85,11 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
message.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString());
log.error(errorMessage, e);
throw new WindowsOperationsException(message, responseMediaType);
} catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
}
@ -105,7 +113,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
operation.setType(Operation.Type.COMMAND);
operation.setEnabled(true);
try {
return WindowsAPIUtils.getOperationResponse(deviceIDs, operation, message, responseMediaType);
return WindowsAPIUtils.getOperationResponse(deviceIDs, operation);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message.setResponseMessage(errorMessage);
@ -118,7 +126,12 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
message.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString());
log.error(errorMessage, e);
throw new WindowsOperationsException(message, responseMediaType);
}
} catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
}
/**
@ -143,7 +156,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
operation.setCode(PluginConstants.OperationCodes.WIPE_DATA);
operation.setType(Operation.Type.COMMAND);
try {
return WindowsAPIUtils.getOperationResponse(deviceids, operation, message, responseMediaType);
return WindowsAPIUtils.getOperationResponse(deviceids, operation);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message.setResponseMessage(errorMessage);
@ -156,6 +169,11 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
message.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString());
log.error(errorMessage, e);
throw new WindowsOperationsException(message, responseMediaType);
} catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
}
@ -181,7 +199,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
CommandOperation operation = new CommandOperation();
operation.setCode(PluginConstants.OperationCodes.DEVICE_RING);
operation.setType(Operation.Type.COMMAND);
return WindowsAPIUtils.getOperationResponse(deviceIDs, operation, message, responseMediaType);
return WindowsAPIUtils.getOperationResponse(deviceIDs, operation);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message.setResponseMessage(errorMessage);
@ -194,6 +212,11 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
message.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString());
log.error(errorMessage, e);
throw new WindowsOperationsException(message, responseMediaType);
} catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
}
@ -224,7 +247,7 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
CommandOperation operation = new CommandOperation();
operation.setCode(PluginConstants.OperationCodes.LOCK_RESET);
operation.setType(Operation.Type.COMMAND);
return WindowsAPIUtils.getOperationResponse(deviceIDs, operation, message, responseMediaType);
return WindowsAPIUtils.getOperationResponse(deviceIDs, operation);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
message.setResponseMessage(errorMessage);
@ -237,6 +260,11 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
message.setResponseCode(Response.Status.INTERNAL_SERVER_ERROR.toString());
log.error(errorMessage, e);
throw new WindowsOperationsException(message, responseMediaType);
} catch (InvalidDeviceException e) {
String errorMessage = "Invalid Device Identifiers found.";
log.error(errorMessage, e);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
}
}

Loading…
Cancel
Save