forked from community/device-mgt-plugins
commit
42b50b642a
@ -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,3 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
@ -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;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue