forked from community/device-mgt-plugins
commit
aa1e64738f
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.mdm.services.android.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents information of configuring App Restriction ex: White list and Black list
|
||||
*/
|
||||
@ApiModel(value = "AppRestriction",
|
||||
description = "This class carries all information related to application restriction.")
|
||||
public class AppRestriction extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "restrictionType", value = "Restriction type of the application.", required = true)
|
||||
private String restrictionType;
|
||||
@ApiModelProperty(name = "restrictedList", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> restrictedList;
|
||||
|
||||
public String getRestrictionType() {
|
||||
return restrictionType;
|
||||
}
|
||||
|
||||
public void setRestrictionType(String restrictionType) {
|
||||
this.restrictionType = restrictionType;
|
||||
}
|
||||
|
||||
public List<String> getRestrictedList() {
|
||||
return restrictedList;
|
||||
}
|
||||
|
||||
public void setRestrictedList(List<String> restrictedList) {
|
||||
this.restrictedList = restrictedList;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.mdm.services.android.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of Update application operation.
|
||||
*/
|
||||
@ApiModel(value = "ApplicationUpdate",
|
||||
description = "This class carries all information related to application update.")
|
||||
public class ApplicationUpdate extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "appIdentifier", value = "The package name of the application " +
|
||||
"to be update.", required = true)
|
||||
private String appIdentifier;
|
||||
@ApiModelProperty(name = "type", value = "The type of the application. The following types of applications " +
|
||||
"are supported: enterprise, public and webapp.", required = true)
|
||||
private String type;
|
||||
@ApiModelProperty(name = "url", value = "The URL of the application.", required = true)
|
||||
private String url;
|
||||
@ApiModelProperty(name = "schedule", value = "Application update schedule.", required = true)
|
||||
private String schedule;
|
||||
|
||||
public String getAppIdentifier() {
|
||||
return appIdentifier;
|
||||
}
|
||||
|
||||
public void setAppIdentifier(String appIdentifier) {
|
||||
this.appIdentifier = appIdentifier;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public void setSchedule(String schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
}
|
@ -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.mdm.services.android.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ApiModel(value = "DeviceLock",
|
||||
description = "This class carries all information related to device lock operation.")
|
||||
public class DeviceLock extends AndroidOperation implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "message", value = "Pop up message of the lock operation.", required = true)
|
||||
private String message;
|
||||
@ApiModelProperty(name = "isHardLockEnabled", value = "Hard lock enable status of the Device", required = true)
|
||||
private boolean isHardLockEnabled;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public boolean isHardLockEnabled() {
|
||||
return isHardLockEnabled;
|
||||
}
|
||||
|
||||
public void setHardLockEnabled(boolean hardLockEnabled) {
|
||||
isHardLockEnabled = hardLockEnabled;
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.mdm.services.android.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@XmlRootElement
|
||||
/**
|
||||
* Store Device state event/data for androidDevice.
|
||||
*/
|
||||
@ApiModel(value = "DeviceState",
|
||||
description = "This class carries all information related to device state.")
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DeviceState {
|
||||
|
||||
@XmlElementWrapper(required = true, name = "values")
|
||||
@ApiModelProperty(name = "values", value = "Device and its statuses.", required = true)
|
||||
private Map<String, Object> values;
|
||||
|
||||
/** The id. */
|
||||
@XmlElement(required = false, name = "id")
|
||||
@ApiModelProperty(name = "id", value = "Identification code.", required = true)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Gets the values.
|
||||
* @return the values
|
||||
*/
|
||||
public Map<String, Object> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the values.
|
||||
* @param values the values
|
||||
*/
|
||||
public void setValues(Map<String, Object> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
valueList.add(entry.getKey() + ":" + entry.getValue());
|
||||
}
|
||||
return valueList.toString();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.mdm.services.android.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of sending Upgrade Firmware operation.
|
||||
*/
|
||||
@ApiModel(value = "UpgradeFirmware",
|
||||
description = "This class carries all information related to UpgradeFirmware.")
|
||||
public class UpgradeFirmware extends AndroidOperation implements Serializable {
|
||||
@ApiModelProperty(name = "schedule", value = "Schedule of the UpgradeFirmware.", required = true)
|
||||
private String schedule;
|
||||
|
||||
public String getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public void setSchedule(String schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.mdm.services.android.bean;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class represents the information of configuring VPN operation.
|
||||
*/
|
||||
@ApiModel(value = "Vpn",
|
||||
description = "This class carries all information related to VPN.")
|
||||
public class Vpn extends AndroidOperation implements Serializable {
|
||||
@ApiModelProperty(name = "serverAddress", value = "Server Address.", required = true)
|
||||
private String serverAddress;
|
||||
@ApiModelProperty(name = "serverPort", value = "Server Port.", required = true)
|
||||
private String serverPort;
|
||||
@ApiModelProperty(name = "sharedSecret", value = "Shared secret.", required = true)
|
||||
private String sharedSecret;
|
||||
@ApiModelProperty(name = "dnsServer", value = "DNS server.", required = true)
|
||||
private String dnsServer;
|
||||
|
||||
public String getServerAddress() {
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
public void setServerAddress(String serverAddress) {
|
||||
this.serverAddress = serverAddress;
|
||||
}
|
||||
|
||||
public String getServerPort() {
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
public void setServerPort(String serverPort) {
|
||||
this.serverPort = serverPort;
|
||||
}
|
||||
|
||||
public String getSharedSecret() {
|
||||
return sharedSecret;
|
||||
}
|
||||
|
||||
public void setSharedSecret(String sharedSecret) {
|
||||
this.sharedSecret = sharedSecret;
|
||||
}
|
||||
|
||||
public String getDnsServer() {
|
||||
return dnsServer;
|
||||
}
|
||||
|
||||
public void setDnsServer(String dnsServer) {
|
||||
this.dnsServer = dnsServer;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.mdm.services.android.bean.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.AppRestriction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap AppRestriction bean with devices
|
||||
*/
|
||||
@ApiModel(value = "AppRestrictionBeanWrapper",
|
||||
description = "Application Restriction related information.")
|
||||
public class AppRestrictionBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "operation", value = "AppRestriction related information.", required = true)
|
||||
private AppRestriction operation;
|
||||
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public AppRestriction getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(AppRestriction operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.mdm.services.android.bean.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.ApplicationUpdate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the UpdateApplication bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "ApplicationUpdateBeanWrapper",
|
||||
description = "Application Update related Info.")
|
||||
public class ApplicationUpdateBeanWrapper {
|
||||
|
||||
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
@ApiModelProperty(name = "operation", value = "Application Update related information.", required = true)
|
||||
private ApplicationUpdate operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public ApplicationUpdate getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(ApplicationUpdate operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.mdm.services.android.bean.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceLock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Notification bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "DeviceLockBeanWrapper",
|
||||
description = "DeviceLock related Information.")
|
||||
public class DeviceLockBeanWrapper {
|
||||
@ApiModelProperty(name = "deviceIDs", value = "Device id list of the operation to be executed.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
@ApiModelProperty(name = "operation", value = "Information of the Device lock operation.", required = true)
|
||||
private DeviceLock operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public DeviceLock getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(DeviceLock operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.mdm.services.android.bean.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the events which receive from the agent application.
|
||||
*/
|
||||
@ApiModel(value = "EventBeanWrapper",
|
||||
description = "Android agent's event related Information.")
|
||||
public class EventBeanWrapper {
|
||||
@ApiModelProperty(name = "deviceIdentifier", value = "DeviceIdentifier to be need to retrieve/publish Event.", required = true)
|
||||
private String deviceIdentifier;
|
||||
@ApiModelProperty(name = "payload", value = "Event payload.", required = true)
|
||||
private String payload;
|
||||
@ApiModelProperty(name = "type", value = "Type of the event.", required = true)
|
||||
private String type;
|
||||
|
||||
public String getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(String payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public String getDeviceIdentifier() {
|
||||
return deviceIdentifier;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifier(String deviceIdentifier) {
|
||||
this.deviceIdentifier = deviceIdentifier;
|
||||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.mdm.services.android.bean.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.UpgradeFirmware;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the UpgradeFirmware bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "UpgradeFirmwareBeanWrapper",
|
||||
description = "Information related to UpgradeFirmware.")
|
||||
public class UpgradeFirmwareBeanWrapper {
|
||||
@ApiModelProperty(name = "deviceIDs",
|
||||
value = "List of device Ids to be need to execute UpgradeFirmware operation.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
@ApiModelProperty(name = "operation", value = "Information related to UpgradeFirmware operation.", required = true)
|
||||
private UpgradeFirmware operation;
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
|
||||
public UpgradeFirmware getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(UpgradeFirmware operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.mdm.services.android.bean.wrapper;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.wso2.carbon.mdm.services.android.bean.Vpn;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is used to wrap the Vpn bean with devices.
|
||||
*/
|
||||
@ApiModel(value = "VpnBeanWrapper",
|
||||
description = "Information related to VPN Configuration.")
|
||||
public class VpnBeanWrapper {
|
||||
@ApiModelProperty(name = "operation",
|
||||
value = "List of device Ids to be need to execute UpgradeFirmware operation.", required = true)
|
||||
private Vpn operation;
|
||||
@ApiModelProperty(name = "deviceIDs",
|
||||
value = "List of device Ids to be need to execute VPN operation.", required = true)
|
||||
private List<String> deviceIDs;
|
||||
|
||||
public Vpn getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(Vpn operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public List<String> getDeviceIDs() {
|
||||
return deviceIDs;
|
||||
}
|
||||
|
||||
public void setDeviceIDs(List<String> deviceIDs) {
|
||||
this.deviceIDs = deviceIDs;
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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.mdm.services.android.services.event;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
/**
|
||||
* APIs related to events published from Android agent are implemented here.
|
||||
*/
|
||||
@Api(value = "EventService", description = "Android Device Management REST-API implementation.")
|
||||
public interface EventService {
|
||||
String ACCEPT = "Accept";
|
||||
|
||||
@POST
|
||||
@ApiOperation(
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "POST",
|
||||
value = "Event Publishing via REST API.",
|
||||
notes = "Publish events received by the WSO2 EMM Android client to WSO2 DAS using this API."
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 201, message = "Event is published successfully."),
|
||||
@ApiResponse(code = 500, message = "Error occurred while publishing the events from Android agent.")
|
||||
})
|
||||
Response publishEvents(@ApiParam(name = "acceptHeader", value = "Accept Header.")
|
||||
@HeaderParam(ACCEPT) String acceptHeader,
|
||||
@ApiParam(name = "eventBeanWrapper",
|
||||
value = "Information of the agent event to be published on DAS.")
|
||||
EventBeanWrapper eventBeanWrapper) throws AndroidAgentException;
|
||||
@GET
|
||||
@Path("{deviceId}")
|
||||
@Produces("application/json")
|
||||
@ApiOperation(
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting Event Details of a Device.",
|
||||
notes = "Get the event details received by an Android device using this API.",
|
||||
response = DeviceState.class,
|
||||
responseContainer = "List"
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "List of Device statuses."),
|
||||
@ApiResponse(code = 500,
|
||||
message = "Error occurred while getting published events for specific given device.")
|
||||
})
|
||||
Response retrieveAlert(@ApiParam(name = "acceptHeader", value = "Accept Header.")
|
||||
@HeaderParam(ACCEPT) String acceptHeader,
|
||||
@ApiParam(name = "deviceId", value = "DeviceId which need to retrieve published events.")
|
||||
@PathParam("deviceId") String deviceId) throws AndroidAgentException;
|
||||
|
||||
@GET
|
||||
@Path("{deviceId}/date")
|
||||
@Produces("application/json")
|
||||
@ApiOperation(
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting Event Details for a Given Time Period.",
|
||||
notes = "Get the event details of a device for a given time duration using this API.",
|
||||
response = DeviceState.class,
|
||||
responseContainer = "List"
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "event details of a device for a given time duration"),
|
||||
@ApiResponse(code = 500, message = "Error occurred while getting published events for" +
|
||||
" specific device on given Date.")
|
||||
})
|
||||
Response retrieveAlertFromDate(@ApiParam(name = "acceptHeader", value = "Accept Header.")
|
||||
@HeaderParam(ACCEPT) String acceptHeader,
|
||||
@ApiParam(name = "deviceId",
|
||||
value = "Device Identifier to be need to retrieve events.")
|
||||
@PathParam("deviceId") String deviceId,
|
||||
@ApiParam(name = "from", value = "From Date.")
|
||||
@QueryParam("from") long from,
|
||||
@ApiParam(name = "to", value = "To Date.")
|
||||
@QueryParam("to") long to) throws AndroidAgentException;
|
||||
|
||||
@GET
|
||||
@Path("{deviceId}/type/{type}")
|
||||
@ApiOperation(
|
||||
consumes = MediaType.APPLICATION_JSON,
|
||||
produces = MediaType.APPLICATION_JSON,
|
||||
httpMethod = "GET",
|
||||
value = "Getting Event Details for a Given Time Period.",
|
||||
notes = "Get the event details of a device for a given time duration using this API.",
|
||||
response = DeviceState.class,
|
||||
responseContainer = "List"
|
||||
)
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "event details of a device for a given time duration"),
|
||||
@ApiResponse(code = 500, message = "Error occurred while getting published events for" +
|
||||
" specific device on given Date.")
|
||||
})
|
||||
Response retrieveAlertType(@ApiParam(name = "acceptHeader", value = "Accept Header.")
|
||||
@HeaderParam(ACCEPT) String acceptHeader,
|
||||
@ApiParam(name = "deviceId", value = "Device Identifier to be need to retrieve events.")
|
||||
@PathParam("deviceId") String deviceId,
|
||||
@ApiParam(name = "type", value = "Type of the Alert to be need to retrieve events.")
|
||||
@PathParam("type") String type) throws AndroidAgentException;
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
/*
|
||||
* 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.mdm.services.android.services.event.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
|
||||
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
|
||||
import org.wso2.carbon.mdm.services.android.bean.DeviceState;
|
||||
import org.wso2.carbon.mdm.services.android.bean.wrapper.EventBeanWrapper;
|
||||
import org.wso2.carbon.mdm.services.android.exception.AndroidAgentException;
|
||||
import org.wso2.carbon.mdm.services.android.services.event.EventService;
|
||||
import org.wso2.carbon.mdm.services.android.util.AndroidAPIUtils;
|
||||
import org.wso2.carbon.mdm.services.android.util.Message;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
public class EventServiceImpl implements EventService {
|
||||
|
||||
private static final String ACCEPT = "Accept";
|
||||
private static Log log = LogFactory.getLog(EventService.class);
|
||||
private static final String EVENT_STREAM_DEFINITION = "android_agent";
|
||||
|
||||
@POST
|
||||
public Response publishEvents(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
EventBeanWrapper eventBeanWrapper) throws AndroidAgentException {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android device even logging.");
|
||||
}
|
||||
Message message = new Message();
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
|
||||
Object payload[] = {eventBeanWrapper.getDeviceIdentifier(), eventBeanWrapper.getPayload(), eventBeanWrapper.getType()};
|
||||
try {
|
||||
if (AndroidAPIUtils.getEventPublisherService().publishEvent(
|
||||
EVENT_STREAM_DEFINITION, "1.0.0", new Object[0], new Object[0], payload)) {
|
||||
message.setResponseCode("Event is published successfully.");
|
||||
return Response.status(Response.Status.CREATED).entity(message).type(responseMediaType).build();
|
||||
} else {
|
||||
message.setResponseCode("Error occurred while publishing the event.");
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).
|
||||
entity(message).type(responseMediaType).build();
|
||||
}
|
||||
} catch (DataPublisherConfigurationException e) {
|
||||
String msg = "Error occurred while publishing the events from Android agent.";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Path("{deviceId}")
|
||||
@Produces("application/json")
|
||||
@GET
|
||||
public Response retrieveAlert(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
@PathParam("deviceId") String deviceId) throws AndroidAgentException {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Retrieving events for given device Identifier.");
|
||||
}
|
||||
Message message = new Message();
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
String query = "deviceIdentifier:" + deviceId;
|
||||
List<DeviceState> deviceStates;
|
||||
try {
|
||||
deviceStates = AndroidAPIUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
||||
if (deviceStates == null) {
|
||||
message.setResponseCode("No any alerts are published for Device: " + deviceId + ".");
|
||||
return Response.status(Response.Status.OK).entity(message).type(responseMediaType).build();
|
||||
|
||||
} else {
|
||||
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
||||
}
|
||||
} catch (AnalyticsException e) {
|
||||
String msg = "Error occurred while getting published events for specific " +
|
||||
"Device: " + deviceId + ".";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Path("{deviceId}/date")
|
||||
@Produces("application/json")
|
||||
@GET
|
||||
public Response retrieveAlertFromDate(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
|
||||
@QueryParam("to") long to) throws AndroidAgentException {
|
||||
String fromDate = String.valueOf(from);
|
||||
String toDate = String.valueOf(to);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Retrieving events for given device Identifier and time period.");
|
||||
}
|
||||
Message message = new Message();
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
|
||||
String query = "deviceIdentifier:" + deviceId + " AND _timestamp: [" + fromDate + " TO " + toDate + "]";
|
||||
List<DeviceState> deviceStates;
|
||||
try {
|
||||
deviceStates = AndroidAPIUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
||||
if (deviceStates == null) {
|
||||
message.
|
||||
setResponseCode("No any alerts are published on given date for given Device: " + deviceId + ".");
|
||||
return Response.status(Response.Status.OK).entity(message).build();
|
||||
|
||||
} else {
|
||||
return Response.status(Response.Status.OK).entity(deviceStates).type(responseMediaType).build();
|
||||
}
|
||||
} catch (AnalyticsException e) {
|
||||
String msg = "Error occurred while getting published events for specific " +
|
||||
"Device: " + deviceId + " on given Date.";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Path("{deviceId}/type/{type}")
|
||||
@GET
|
||||
public Response retrieveAlertType(@HeaderParam(ACCEPT) String acceptHeader,
|
||||
@PathParam("deviceId") String deviceId, @PathParam("type") String type)
|
||||
throws AndroidAgentException {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Retrieving events for given device identifier and type.");
|
||||
}
|
||||
Message message = new Message();
|
||||
MediaType responseMediaType = AndroidAPIUtils.getResponseMediaType(acceptHeader);
|
||||
String query = "deviceIdentifier:" + deviceId + " AND type:" + type;
|
||||
List<DeviceState> deviceStates;
|
||||
try {
|
||||
deviceStates = AndroidAPIUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
||||
if (deviceStates == null) {
|
||||
message.
|
||||
setResponseCode("No any alerts are published on given date for given Device: " + deviceId + ".");
|
||||
return Response.status(Response.Status.OK).entity(message).build();
|
||||
|
||||
} else {
|
||||
return Response.status(Response.Status.OK).entity(deviceStates).type(responseMediaType).build();
|
||||
}
|
||||
} catch (AnalyticsException e) {
|
||||
String msg = "Error occurred while getting published events for specific " +
|
||||
"Device: " + deviceId + "og given device Type.";
|
||||
log.error(msg, e);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in new issue