mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'application-mgt-new' into 'application-mgt-new'
Creating basics for app install See merge request entgra/carbon-device-mgt!7
This commit is contained in:
commit
dac15e5206
@ -51,7 +51,7 @@
|
|||||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||||
<Bundle-Description>Application Management Common Bundle</Bundle-Description>
|
<Bundle-Description>Application Management Common Bundle</Bundle-Description>
|
||||||
<Import-Package>
|
<Import-Package>
|
||||||
org.wso2.carbon.device.mgt.common.operation.mgt.*;version="${carbon.device.mgt.version}",
|
org.wso2.carbon.device.mgt.common.*;version="${carbon.device.mgt.version}",
|
||||||
com.google.gson,
|
com.google.gson,
|
||||||
io.swagger.annotations.*;resolution:=optional
|
io.swagger.annotations.*;resolution:=optional
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
|
|||||||
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.application.mgt.common;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.DeviceConnectorException;
|
||||||
|
|
||||||
|
public class AndroidApplication {
|
||||||
|
private String type;
|
||||||
|
private String appIdentifier;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 760343716452548282L;
|
||||||
|
|
||||||
|
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 toJSON() throws DeviceConnectorException {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
return gson.toJson(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.application.mgt.common;
|
||||||
|
|
||||||
|
public class AppOperation {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7603215716452548282L;
|
||||||
|
|
||||||
|
private Application application;
|
||||||
|
private int tenantId;
|
||||||
|
private String activityId;
|
||||||
|
private String scheduledDateTime;
|
||||||
|
private OperationType type;
|
||||||
|
private String subscribedBy;
|
||||||
|
private int appReleaseId;
|
||||||
|
private InstallState installState;
|
||||||
|
|
||||||
|
public InstallState getInstallState() {
|
||||||
|
return installState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstallState(InstallState installState) {
|
||||||
|
this.installState = installState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum InstallState {
|
||||||
|
PENDING, INPROGRESS, INSTALLED, UNINSTALLED, ERROR
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAppReleaseId() {
|
||||||
|
return appReleaseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppReleaseId(int appReleaseId) {
|
||||||
|
this.appReleaseId = appReleaseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubscribedBy() {
|
||||||
|
return subscribedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubscribedBy(String subscribedBy) {
|
||||||
|
this.subscribedBy = subscribedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum OperationType {
|
||||||
|
INSTALL, UNINSTALL, UPDATE
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(OperationType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Application getApplication() {
|
||||||
|
return application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplication(Application application) {
|
||||||
|
this.application = application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTenantId() {
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTenantId(int tenantId) {
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(String activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getScheduledDateTime() {
|
||||||
|
return scheduledDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScheduledDateTime(String scheduledDateTime) {
|
||||||
|
this.scheduledDateTime = scheduledDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.application.mgt.common;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the Enterprise Application information.
|
||||||
|
*/
|
||||||
|
public class EnterpriseApplication extends AndroidApplication implements Serializable {
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
private String schedule;
|
||||||
|
private String packageName;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 660343716452348222L;
|
||||||
|
|
||||||
|
public String getSchedule() {
|
||||||
|
return schedule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSchedule(String schedule) {
|
||||||
|
this.schedule = schedule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPackageName() {
|
||||||
|
return packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
this.packageName = packageName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2017, 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.application.mgt.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the exception thrown during device connections.
|
||||||
|
*/
|
||||||
|
public class DeviceConnectorException extends Exception {
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public DeviceConnectorException(String message, Throwable throwable) {
|
||||||
|
super(message, throwable);
|
||||||
|
setMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceConnectorException(String message) {
|
||||||
|
super(message);
|
||||||
|
setMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceConnectorException() {
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.application.mgt.common.services;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.AppOperation;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.DeviceConnectorException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface contains operations necessary to perform actions on a device such as install and application on a
|
||||||
|
* device, uninstall or upgrade. This must be implemented to connect to an external device management server.
|
||||||
|
*/
|
||||||
|
public interface DeviceConnector {
|
||||||
|
|
||||||
|
Boolean sendOperationToDevice(AppOperation appOperation, DeviceIdentifier deviceIdentifier) throws
|
||||||
|
DeviceConnectorException;
|
||||||
|
|
||||||
|
Boolean sendOperationToGroup(AppOperation appOperation, String groupID) throws DeviceConnectorException;
|
||||||
|
|
||||||
|
Boolean sendOperationToUser(AppOperation appOperation, List<String> userList) throws DeviceConnectorException;
|
||||||
|
|
||||||
|
Boolean sendOperationToRole(AppOperation appOperation, String role) throws DeviceConnectorException;
|
||||||
|
|
||||||
|
}
|
||||||
@ -42,7 +42,7 @@ public interface SubscriptionDAO {
|
|||||||
* @throws ApplicationManagementDAOException If unable to add a mapping between device and application
|
* @throws ApplicationManagementDAOException If unable to add a mapping between device and application
|
||||||
*/
|
*/
|
||||||
void subscribeDeviceToApplication(int tenantId, String subscribedBy, List<Device> deviceList, int appId,
|
void subscribeDeviceToApplication(int tenantId, String subscribedBy, List<Device> deviceList, int appId,
|
||||||
int releaseId) throws ApplicationManagementDAOException;
|
int releaseId, String installStatus) throws ApplicationManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a mapping between user and the application which the application is installed on. This mapping will be
|
* Adds a mapping between user and the application which the application is installed on. This mapping will be
|
||||||
|
|||||||
@ -37,14 +37,14 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribeDeviceToApplication(int tenantId, String subscribedBy, List<Device> deviceList, int appId,
|
public void subscribeDeviceToApplication(int tenantId, String subscribedBy, List<Device> deviceList, int appId,
|
||||||
int releaseId) throws ApplicationManagementDAOException {
|
int releaseId, String installStatus) throws ApplicationManagementDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
conn = this.getDBConnection();
|
conn = this.getDBConnection();
|
||||||
long time = System.currentTimeMillis() / 1000;
|
long time = System.currentTimeMillis() / 1000;
|
||||||
String sql = "INSERT INTO AP_DEVICE_SUBSCRIPTION(TENANT_ID, SUBSCRIBED_BY, SUBSCRIBED_TIMESTAMP, "
|
String sql = "INSERT INTO AP_DEVICE_SUBSCRIPTION(TENANT_ID, SUBSCRIBED_BY, SUBSCRIBED_TIMESTAMP, "
|
||||||
+ "DM_DEVICE_ID, AP_APP_RELEASE_ID, AP_APP_ID) VALUES (?, ?, ?, ?, ?, ?)";
|
+ "DM_DEVICE_ID, AP_APP_RELEASE_ID, AP_APP_ID, INSTALL_STATUS) VALUES (?, ?, ?, ?, ?, ?)";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
for (Device device : deviceList) {
|
for (Device device : deviceList) {
|
||||||
stmt.setInt(1, tenantId);
|
stmt.setInt(1, tenantId);
|
||||||
@ -53,6 +53,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|||||||
stmt.setInt(4, device.getId());
|
stmt.setInt(4, device.getId());
|
||||||
stmt.setInt(5, releaseId);
|
stmt.setInt(5, releaseId);
|
||||||
stmt.setInt(6, appId);
|
stmt.setInt(6, appId);
|
||||||
|
stmt.setString(7, installStatus);
|
||||||
stmt.addBatch();
|
stmt.addBatch();
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Adding a mapping to device ID[" + device.getId() + "] to the application [" + appId
|
log.debug("Adding a mapping to device ID[" + device.getId() + "] to the application [" + appId
|
||||||
|
|||||||
@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.application.mgt.core.impl;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.AppOperation;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.exception.DeviceConnectorException;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.services.DeviceConnector;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.dao.SubscriptionDAO;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory;
|
||||||
|
import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MAMDeviceConnectorImpl implements DeviceConnector{
|
||||||
|
private static final Log log = LogFactory.getLog(MAMDeviceConnectorImpl.class);
|
||||||
|
private ApplicationDAO applicationDAO;
|
||||||
|
private SubscriptionDAO subscriptionDAO;
|
||||||
|
|
||||||
|
public MAMDeviceConnectorImpl() {
|
||||||
|
this.applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO();
|
||||||
|
this.subscriptionDAO = ApplicationManagementDAOFactory.getSubscriptionDAO();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean sendOperationToDevice(AppOperation appOperation, DeviceIdentifier deviceIdentifier) throws DeviceConnectorException {
|
||||||
|
if (String.valueOf(appOperation.getType()).equals("INSTALL")) {
|
||||||
|
|
||||||
|
} else if (String.valueOf(appOperation.getType()).equals("UNINSTALL")) {
|
||||||
|
|
||||||
|
} else if (String.valueOf(appOperation.getType()).equals("UPDATE")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean sendOperationToGroup(AppOperation appOperation, String groupID) throws DeviceConnectorException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean sendOperationToUser(AppOperation appOperation, List<String> userList) throws DeviceConnectorException {
|
||||||
|
if (String.valueOf(appOperation.getType()).equals("INSTALL")) {
|
||||||
|
//First subscribe the user to the app.
|
||||||
|
try {
|
||||||
|
|
||||||
|
subscriptionDAO.subscribeUserToApplication(appOperation.getTenantId(), appOperation.getSubscribedBy(),
|
||||||
|
userList, appOperation.getApplication().getId(), appOperation.getAppReleaseId());
|
||||||
|
for (String username: userList) {
|
||||||
|
List<Device> devices = getDeviceManagementService().getDevicesOfUser(username);
|
||||||
|
List<DeviceIdentifier> deviceIdentifiers = convertDeviceToDeviceIdentifier(devices);
|
||||||
|
// getDeviceManagementService().addOperation(appOperation.getApplication().getDeviceType(),
|
||||||
|
// operationEKA, devices);
|
||||||
|
subscriptionDAO.subscribeDeviceToApplication(appOperation.getTenantId(), appOperation.getSubscribedBy(),
|
||||||
|
devices, appOperation.getApplication().getId(), appOperation.getAppReleaseId(),
|
||||||
|
String.valueOf(AppOperation.InstallState.PENDING));
|
||||||
|
}
|
||||||
|
} catch (ApplicationManagementDAOException e) {
|
||||||
|
String msg = "Error subscribing the user to the application Id" + appOperation.getApplication().getId();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceConnectorException(msg, e);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error getting the list of user devices.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceConnectorException(msg, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (String.valueOf(appOperation.getType()).equals("UNINSTALL")) {
|
||||||
|
|
||||||
|
} else if (String.valueOf(appOperation.getType()).equals("UPDATE")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean sendOperationToRole(AppOperation appOperation, String role) throws DeviceConnectorException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DeviceIdentifier> convertDeviceToDeviceIdentifier(List<Device> devices) {
|
||||||
|
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<>();
|
||||||
|
for (Device device:devices) {
|
||||||
|
deviceIdentifiers.add(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
|
||||||
|
}
|
||||||
|
return deviceIdentifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceManagementProviderService getDeviceManagementService() {
|
||||||
|
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService =
|
||||||
|
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||||
|
if (deviceManagementProviderService == null) {
|
||||||
|
String msg = "DeviceImpl Management provider service has not initialized.";
|
||||||
|
log.error(msg);
|
||||||
|
throw new IllegalStateException(msg);
|
||||||
|
}
|
||||||
|
return deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.application.mgt.core.impl;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.AppOperation;
|
||||||
import org.wso2.carbon.device.application.mgt.common.Application;
|
import org.wso2.carbon.device.application.mgt.common.Application;
|
||||||
import org.wso2.carbon.device.application.mgt.common.ApplicationInstallResponse;
|
import org.wso2.carbon.device.application.mgt.common.ApplicationInstallResponse;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
@ -250,7 +251,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
subscriptionDAO.subscribeDeviceToApplication(tenantId, subscriber, deviceList, application.getId(),
|
subscriptionDAO.subscribeDeviceToApplication(tenantId, subscriber, deviceList, application.getId(),
|
||||||
applicationReleaseId);
|
applicationReleaseId, String.valueOf(AppOperation.InstallState.UNINSTALLED));
|
||||||
} finally {
|
} finally {
|
||||||
ConnectionManagerUtil.closeDBConnection();
|
ConnectionManagerUtil.closeDBConnection();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.application.mgt.core.util;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.AppOperation;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.EnterpriseApplication;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||||
|
|
||||||
|
public class AndroidApplicationOperationUtil {
|
||||||
|
// public static Operation installApp(AppOperation appOperation) {
|
||||||
|
// ProfileOperation operation = new ProfileOperation();
|
||||||
|
// operation.setCode(MDMAppConstants.AndroidConstants.OPCODE_INSTALL_APPLICATION);
|
||||||
|
// operation.setType(Operation.Type.PROFILE);
|
||||||
|
// switch (appOperation.getApplication().getType()) {
|
||||||
|
// case "ENTERPRISE"://TODO: fix with ENUM
|
||||||
|
// EnterpriseApplication enterpriseApplication = new EnterpriseApplication();
|
||||||
|
// enterpriseApplication.setType(appOperation.getApplication().toString());
|
||||||
|
// enterpriseApplication.setUrl(application.getLocation());
|
||||||
|
// enterpriseApplication.setSchedule(appOperation.getScheduledDateTime());
|
||||||
|
// enterpriseApplication.setPackageName(appOperation.getApplication().get);
|
||||||
|
// operation.setPayLoad(enterpriseApplication.toJSON());
|
||||||
|
// break;
|
||||||
|
// case "PUBLIC":
|
||||||
|
// setOperationForPublicApp(operation, application);
|
||||||
|
// break;
|
||||||
|
// case "WEBAPP":
|
||||||
|
// setOperationForWebApp(operation, application);
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// String errorMessage = "Invalid application type.";
|
||||||
|
// throw new DeviceApplicationException(errorMessage);
|
||||||
|
// }
|
||||||
|
// return operation;
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, 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.application.mgt.core.util;
|
||||||
|
|
||||||
|
public class MDMAppConstants {
|
||||||
|
public static final String USER = "user";
|
||||||
|
public static final String ROLE = "role";
|
||||||
|
public static final String IOS = "ios";
|
||||||
|
public static final String ANDROID = "android";
|
||||||
|
public static final String WEBAPP = "webapp";
|
||||||
|
public static final String INSTALL = "install";
|
||||||
|
public static final String UPDATE = "update";
|
||||||
|
public static final String ACTIVE = "active";
|
||||||
|
public static final String ENTERPRISE = "enterprise";
|
||||||
|
public static final String DEVICE = "device";
|
||||||
|
public static final String MOBILE_DEVICE = "mobileDevice";
|
||||||
|
public static final String NEXUS = "nexus";
|
||||||
|
public static final String IPHONE = "iphone";
|
||||||
|
public static final String NONE = "none";
|
||||||
|
public static final String IMAGE_URL = "ImageURL";
|
||||||
|
public static final String TYPE = "type";
|
||||||
|
public static final String ID = "id";
|
||||||
|
|
||||||
|
public class IOSConstants {
|
||||||
|
|
||||||
|
private IOSConstants() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String IS_REMOVE_APP = "isRemoveApp";
|
||||||
|
public static final String IS_PREVENT_BACKUP = "isPreventBackup";
|
||||||
|
public static final String I_TUNES_ID = "iTunesId";
|
||||||
|
public static final String LABEL = "label";
|
||||||
|
public static final String PUBLIC = "public";
|
||||||
|
public static final String OPCODE_INSTALL_ENTERPRISE_APPLICATION =
|
||||||
|
"INSTALL_ENTERPRISE_APPLICATION";
|
||||||
|
public static final String OPCODE_INSTALL_STORE_APPLICATION = "INSTALL_STORE_APPLICATION";
|
||||||
|
public static final String OPCODE_INSTALL_WEB_APPLICATION = "WEB_CLIP";
|
||||||
|
public static final String OPCODE_REMOVE_APPLICATION = "REMOVE_APPLICATION";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AndroidConstants {
|
||||||
|
private AndroidConstants() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String OPCODE_INSTALL_APPLICATION = "INSTALL_APPLICATION";
|
||||||
|
public static final String OPCODE_UPDATE_APPLICATION = "UPDATE_APPLICATION";
|
||||||
|
public static final String OPCODE_UNINSTALL_APPLICATION = "UNINSTALL_APPLICATION";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RegistryConstants {
|
||||||
|
private RegistryConstants() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String GENERAL_CONFIG_RESOURCE_PATH = "general";
|
||||||
|
}
|
||||||
|
|
||||||
|
public class APPManagerConstants {
|
||||||
|
private static final String APP_MANAGER_MDM_SERVICE_NAME =
|
||||||
|
"org.wso2.carbon.appmgt.mobile.interfaces.MDMOperations";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user