Charitha Goonetilleke 5 years ago
commit 311ddc307e

@ -1894,16 +1894,23 @@ public class ApplicationManagerImpl implements ApplicationManager {
DeviceManagementProviderService deviceManagementProviderService = DataHolder.getInstance() DeviceManagementProviderService deviceManagementProviderService = DataHolder.getInstance()
.getDeviceManagementService(); .getDeviceManagementService();
try { try {
DeviceType deviceType = deviceManagementProviderService.getDeviceType(deviceTypeName); int deviceTypeId;
if (deviceType == null) { if (!deviceTypeName.equals(Constants.ALL)) {
String msg = "Device type doesn't exist. Hence check the application name existence with valid " DeviceType deviceType = deviceManagementProviderService.getDeviceType(deviceTypeName);
+ "device type name."; deviceTypeId = deviceType.getId();
log.error(msg); if (deviceType == null) {
throw new BadRequestException(msg); String msg = "Device type doesn't exist. Hence check the application name existence with valid "
+ "device type name.";
log.error(msg);
throw new BadRequestException(msg);
}
} else {
//For web-clips device type = 'ALL'
deviceTypeId = 0;
} }
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
if (applicationDAO.isExistingAppName(appName, deviceType.getId(), tenantId)) { if (applicationDAO.isExistingAppName(appName, deviceTypeId, tenantId)) {
return true; return true;
} }
} catch (DBConnectionException e) { } catch (DBConnectionException e) {

@ -48,6 +48,7 @@ public class Constants {
public static final String FORWARD_SLASH = "/"; public static final String FORWARD_SLASH = "/";
public static final String ANY = "ANY"; public static final String ANY = "ANY";
public static final String DEFAULT_PCK_NAME = "default.app.com"; public static final String DEFAULT_PCK_NAME = "default.app.com";
public static final String ALL = "ALL";
public static final String GOOGLE_PLAY_STORE_URL = "https://play.google.com/store/apps/details?id="; public static final String GOOGLE_PLAY_STORE_URL = "https://play.google.com/store/apps/details?id=";
public static final String APPLE_STORE_URL = "https://itunes.apple.com/country/app/app-name/id"; public static final String APPLE_STORE_URL = "https://itunes.apple.com/country/app/app-name/id";

@ -0,0 +1,69 @@
/*
* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.common;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* This class represents the information of QR enrollment payload.
*/
@ApiModel(value = "QREnrollmentPayload",
description = "Details related to QR enrollment to generate QR code.")
public class QREnrollmentPayload implements Serializable {
@ApiModelProperty(name = "payload", value = "Platform configuration payload to generate QR code.", required = true)
private Map<String, Object> payload;
@ApiModelProperty(name = "invalidPlatformConfigs", value = "Invalid platform configs to show when an " +
"invalidation occurs.", required = true)
private List<String> invalidPlatformConfigs;
@ApiModelProperty(name = "optionalPlatformConfigs", value = "Optional platform configs to show when an " +
"values are not set.")
private List<String> optionalPlatformConfigs;
public Map<String, Object> getPayload() {
return payload;
}
public void setPayload(Map<String, Object> payload) {
this.payload = payload;
}
public List<String> getInvalidPlatformConfigs() {
return invalidPlatformConfigs;
}
public void setInvalidPlatformConfigs(List<String> invalidPlatformConfigs) {
this.invalidPlatformConfigs = invalidPlatformConfigs;
}
public List<String> getOptionalPlatformConfigs() {
return optionalPlatformConfigs;
}
public void setOptionalPlatformConfigs(List<String> optionalPlatformConfigs) {
this.optionalPlatformConfigs = optionalPlatformConfigs;
}
}

@ -17,10 +17,9 @@
package org.wso2.carbon.device.mgt.common.spi; package org.wso2.carbon.device.mgt.common.spi;
import org.wso2.carbon.device.mgt.common.QREnrollmentPayload;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import java.util.Map;
/** /**
* This implementation populates device type plugin management service. * This implementation populates device type plugin management service.
*/ */
@ -29,8 +28,9 @@ public interface DeviceTypeCommonService {
/** /**
* To get Enrollment QR code against Ownership type * To get Enrollment QR code against Ownership type
* *
* @return QR code Map which contains key value pairs to have for the QR String. * @return {@link QREnrollmentPayload} object with payload to generate QR, invalidPlatformConfigs
* and optionalPlatformConfigs.
* @throws DeviceManagementException if error occurred while generating the QR String for Ownership * @throws DeviceManagementException if error occurred while generating the QR String for Ownership
*/ */
Map<String, Object> getEnrollmentQRCode(String ownershipType) throws DeviceManagementException; QREnrollmentPayload getEnrollmentQRCode(String ownershipType) throws DeviceManagementException;
} }

@ -1912,12 +1912,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
removeEnrollmentDeviceDetail(conn, enrollmentIds); removeEnrollmentDeviceDetail(conn, enrollmentIds);
removeEnrollmentDeviceLocation(conn, enrollmentIds); removeEnrollmentDeviceLocation(conn, enrollmentIds);
removeEnrollmentDeviceInfo(conn, enrollmentIds); removeEnrollmentDeviceInfo(conn, enrollmentIds);
removeDeviceLargeOperationResponse(conn, enrollmentIds);
removeDeviceOperationResponse(conn, enrollmentIds); removeDeviceOperationResponse(conn, enrollmentIds);
removeEnrollmentOperationMapping(conn, enrollmentIds); removeEnrollmentOperationMapping(conn, enrollmentIds);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Successfully removed enrollment device details, enrollment device location," + log.debug("Successfully removed enrollment device details, enrollment device location," +
"enrollment device info, enrollment device application mapping, " + "enrollment device info, enrollment device application mapping, " +
"enrollment device operation response, enrollment operation mapping data of " + "enrollment device operation large response, enrollment device " +
"operation response, enrollment operation mapping data of " +
"devices with identifiers: " + deviceIdentifiers); "devices with identifiers: " + deviceIdentifiers);
} }
removeDeviceEnrollment(conn, deviceIds); removeDeviceEnrollment(conn, deviceIds);
@ -2397,8 +2399,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
*/ */
private void removeDeviceOperationResponse(Connection conn, List<Integer> enrollmentIds) private void removeDeviceOperationResponse(Connection conn, List<Integer> enrollmentIds)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
try { try {
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
if (!executeBatchOperation(conn, sql, enrollmentIds)) { if (!executeBatchOperation(conn, sql, enrollmentIds)) {
String msg = "Failed to remove device operation response of devices with enrollmentIds : " String msg = "Failed to remove device operation response of devices with enrollmentIds : "
+ enrollmentIds + " while executing batch operation"; + enrollmentIds + " while executing batch operation";
@ -2413,6 +2415,29 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} }
} }
private void removeDeviceLargeOperationResponse(Connection conn, List<Integer> enrollmentIds)
throws DeviceManagementDAOException {
String sql = "DELETE DM_DEVICE_OPERATION_RESPONSE_LARGE " +
"FROM DM_DEVICE_OPERATION_RESPONSE_LARGE " +
"INNER JOIN DM_DEVICE_OPERATION_RESPONSE ON DM_DEVICE_OPERATION_RESPONSE_LARGE.ID = " +
"DM_DEVICE_OPERATION_RESPONSE.ID " +
"WHERE ENROLMENT_ID = ?";
try {
if (!executeBatchOperation(conn, sql, enrollmentIds)) {
String msg = "Failed to remove device large operation response of devices with " +
"enrollmentIds : "
+ enrollmentIds + " while executing batch operation";
log.error(msg);
throw new DeviceManagementDAOException(msg);
}
} catch (SQLException e) {
String msg = "SQL error occurred while removing large device operation response of " +
"devices with enrollmentIds : " + enrollmentIds;
log.error(msg, e);
throw new DeviceManagementDAOException(msg, e);
}
}
/*** /***
* This method removes records of a given list of enrollments from the DM_ENROLMENT_OP_MAPPING table * This method removes records of a given list of enrollments from the DM_ENROLMENT_OP_MAPPING table
* @param conn Connection object * @param conn Connection object

Loading…
Cancel
Save