@ -73,7 +73,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
stmt . setBoolean ( 11 , application . isActive ( ) ) ;
stmt . setInt ( 12 , deviceId ) ;
stmt . setInt ( 13 , enrolmentId ) ;
stmt . set Boolean ( 14 , application . isSystemApp ( ) ) ;
stmt . set Int ( 14 , application . isSystemApp ( ) ) ;
stmt . addBatch ( ) ;
}
stmt . executeBatch ( ) ;
@ -105,7 +105,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
stmt . setString ( 7 , application . getImageUrl ( ) ) ;
stmt . setInt ( 8 , application . getMemoryUsage ( ) ) ;
stmt . setBoolean ( 9 , application . isActive ( ) ) ;
stmt . set Boolean ( 10 , application . isSystemApp ( ) ) ;
stmt . set Int ( 10 , application . isSystemApp ( ) ) ;
stmt . setInt ( 11 , application . getId ( ) ) ;
stmt . addBatch ( ) ;
}
@ -213,7 +213,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
try {
conn = this . getConnection ( ) ;
stmt = conn . prepareStatement ( "SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, IS_SYSTEM_APP, TENANT_ID " +
"FROM DM_APPLICATION WHERE DEVICE_ID = ? AND ENROLMENT_ID = ? AND APP_IDENTIFIER = ? AND " +
"VERSION = ? AND TENANT_ID = ?" ) ;
stmt . setInt ( 1 , deviceId ) ;
@ -224,7 +224,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
rs = stmt . executeQuery ( ) ;
if ( rs . next ( ) ) {
application = this . loadApplication ( rs ) ;
application = this . loadApplication Details ( rs ) ;
}
return application ;
} catch ( SQLException e ) {
@ -239,6 +239,45 @@ public class ApplicationDAOImpl implements ApplicationDAO {
return DeviceManagementDAOFactory . getConnection ( ) ;
}
private Application loadApplicationDetails ( ResultSet rs ) throws DeviceManagementDAOException {
ByteArrayInputStream bais ;
ObjectInputStream ois ;
Properties properties ;
Application application = new Application ( ) ;
try {
application . setId ( rs . getInt ( "ID" ) ) ;
application . setName ( rs . getString ( "NAME" ) ) ;
application . setType ( rs . getString ( "TYPE" ) ) ;
if ( rs . getBytes ( "APP_PROPERTIES" ) ! = null ) {
byte [ ] appProperties = rs . getBytes ( "APP_PROPERTIES" ) ;
bais = new ByteArrayInputStream ( appProperties ) ;
ois = new ObjectInputStream ( bais ) ;
properties = ( Properties ) ois . readObject ( ) ;
application . setAppProperties ( properties ) ;
}
application . setCategory ( rs . getString ( "CATEGORY" ) ) ;
application . setImageUrl ( rs . getString ( "IMAGE_URL" ) ) ;
application . setLocationUrl ( rs . getString ( "LOCATION_URL" ) ) ;
application . setPlatform ( rs . getString ( "PLATFORM" ) ) ;
application . setVersion ( rs . getString ( "VERSION" ) ) ;
application . setMemoryUsage ( rs . getInt ( "MEMORY_USAGE" ) ) ;
application . setActive ( rs . getBoolean ( "IS_ACTIVE" ) ) ;
application . setSystemApp ( rs . getInt ( "IS_SYSTEM_APP" ) ) ;
application . setApplicationIdentifier ( rs . getString ( "APP_IDENTIFIER" ) ) ;
} catch ( IOException e ) {
throw new DeviceManagementDAOException ( "IO error occurred fetch at app properties" , e ) ;
} catch ( ClassNotFoundException e ) {
throw new DeviceManagementDAOException ( "Class not found error occurred fetch at app properties" , e ) ;
} catch ( SQLException e ) {
throw new DeviceManagementDAOException ( "SQL error occurred fetch at application" , e ) ;
}
return application ;
}
@Override
public List < Application > getInstalledApplications ( int deviceId , int enrolmentId , int tenantId )
throws DeviceManagementDAOException {
@ -250,7 +289,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
try {
conn = this . getConnection ( ) ;
stmt = conn . prepareStatement ( "SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID FROM DM_APPLICATION " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, IS_SYSTEM_APP, TENANT_ID FROM DM_APPLICATION " +
"WHERE DEVICE_ID = ? AND ENROLMENT_ID = ? AND TENANT_ID = ?" ) ;
stmt . setInt ( 1 , deviceId ) ;
@ -259,7 +298,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
rs = stmt . executeQuery ( ) ;
while ( rs . next ( ) ) {
application = loadApplication ( rs ) ;
application = loadApplication Details ( rs ) ;
applications . add ( application ) ;
}
} catch ( SQLException e ) {
@ -424,45 +463,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
return application ;
}
private Application loadApplicationDetails ( ResultSet rs ) throws DeviceManagementDAOException {
ByteArrayInputStream bais ;
ObjectInputStream ois ;
Properties properties ;
Application application = new Application ( ) ;
try {
application . setId ( rs . getInt ( "ID" ) ) ;
application . setName ( rs . getString ( "NAME" ) ) ;
application . setType ( rs . getString ( "TYPE" ) ) ;
if ( rs . getBytes ( "APP_PROPERTIES" ) ! = null ) {
byte [ ] appProperties = rs . getBytes ( "APP_PROPERTIES" ) ;
bais = new ByteArrayInputStream ( appProperties ) ;
ois = new ObjectInputStream ( bais ) ;
properties = ( Properties ) ois . readObject ( ) ;
application . setAppProperties ( properties ) ;
}
application . setCategory ( rs . getString ( "CATEGORY" ) ) ;
application . setImageUrl ( rs . getString ( "IMAGE_URL" ) ) ;
application . setLocationUrl ( rs . getString ( "LOCATION_URL" ) ) ;
application . setPlatform ( rs . getString ( "PLATFORM" ) ) ;
application . setVersion ( rs . getString ( "VERSION" ) ) ;
application . setMemoryUsage ( rs . getInt ( "MEMORY_USAGE" ) ) ;
application . setActive ( rs . getBoolean ( "IS_ACTIVE" ) ) ;
application . setSystemApp ( rs . getBoolean ( "IS_SYSTEM_APP" ) ) ;
application . setApplicationIdentifier ( rs . getString ( "APP_IDENTIFIER" ) ) ;
} catch ( IOException e ) {
throw new DeviceManagementDAOException ( "IO error occurred fetch at app properties" , e ) ;
} catch ( ClassNotFoundException e ) {
throw new DeviceManagementDAOException ( "Class not found error occurred fetch at app properties" , e ) ;
} catch ( SQLException e ) {
throw new DeviceManagementDAOException ( "SQL error occurred fetch at application" , e ) ;
}
return application ;
}
@Override
public void saveApplicationIcon ( String iconPath , String packageName , String version , int tenantId )
@ -589,7 +590,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
}
@Override
public List < Application > getInstalledApplicationListOnDevice ( int deviceId , int enrolmentId , int offset , int limit , int tenantId )
public List < Application > getInstalledApplicationListOnDevice ( int deviceId , int enrolmentId , int offset , int limit , int tenantId , int isSystemApp )
throws DeviceManagementDAOException {
Connection conn ;
List < Application > applicationList = new ArrayList < > ( ) ;
@ -613,6 +614,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
"WHERE DEVICE_ID = ? AND " +
"ENROLMENT_ID = ? AND " +
"TENANT_ID = ? " +
( isSystemApp ! = 0 ? "AND IS_SYSTEM_APP = ? " : "" ) +
"LIMIT ? " +
"OFFSET ? " ;
try {
@ -621,8 +623,14 @@ public class ApplicationDAOImpl implements ApplicationDAO {
stmt . setInt ( 1 , deviceId ) ;
stmt . setInt ( 2 , enrolmentId ) ;
stmt . setInt ( 3 , tenantId ) ;
stmt . setInt ( 4 , limit ) ;
stmt . setInt ( 5 , offset ) ;
int paramIndex = 4 ;
if ( isSystemApp ! = 0 ) {
stmt . setInt ( paramIndex , isSystemApp ) ;
paramIndex + + ;
}
stmt . setInt ( paramIndex , limit ) ;
paramIndex + + ;
stmt . setInt ( paramIndex , offset ) ;
try ( ResultSet rs = stmt . executeQuery ( ) ) {
while ( rs . next ( ) ) {
application = loadApplicationDetails ( rs ) ;
@ -633,13 +641,14 @@ public class ApplicationDAOImpl implements ApplicationDAO {
} catch ( SQLException e ) {
String msg = "SQL Error occurred while retrieving the list of Applications " +
"installed in device id '" + deviceId ;
"installed on device id '" + deviceId + "'" ;
log . error ( msg , e ) ;
throw new DeviceManagementDAOException ( msg , e ) ;
}
return applicationList ;
}
public List < Application > getInstalledApplicationListOnDevice ( int deviceId , int enrolmentId , int tenantId )
throws DeviceManagementDAOException {
Connection conn ;