Fixing the error reported by check styles plugin.

feature/appm-store/pbac
sinthuja 7 years ago
parent 783ead216e
commit 9656b9b747

@ -18,5 +18,8 @@
*/
package org.wso2.carbon.device.application.mgt.core.dao;
/**
* This interface specifies the database access operations performed for comments.
*/
public interface CommentDAO {
}

@ -18,5 +18,9 @@
*/
package org.wso2.carbon.device.application.mgt.core.dao;
/**
* This interface provides the list of operations that are supported with subscription database.
*
*/
public interface SubscriptionDAO {
}

@ -24,7 +24,9 @@ import org.wso2.carbon.device.application.mgt.core.exception.VisibilityManagemen
import java.util.List;
/**
* This interface provides the list of operations that are performed in the database layer with respect to the visibility.
* This interface provides the list of operations that are performed in the database
* layer with respect to the visibility.
*
*/
public interface VisibilityDAO {

@ -25,8 +25,8 @@ import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO;
import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO;
import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO;
import org.wso2.carbon.device.application.mgt.core.dao.PlatformDAO;
import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO;
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.GenericApplicationDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.release.GenericApplicationReleaseDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.release.OracleApplicationDAOImpl;
@ -61,14 +61,14 @@ public class DAOFactory {
public static ApplicationDAO getApplicationDAO() {
if (databaseEngine != null) {
switch (databaseEngine) {
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
return new GenericApplicationDAOImpl();
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new OracleApplicationDAOImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
return new GenericApplicationDAOImpl();
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new OracleApplicationDAOImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
}
}
throw new IllegalStateException("Database engine has not initialized properly.");
@ -77,15 +77,15 @@ public class DAOFactory {
public static PlatformDAO getPlatformDAO() {
if (databaseEngine != null) {
switch (databaseEngine) {
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
return new GenericPlatformDAOImpl();
case Constants.DataBaseTypes.DB_TYPE_MSSQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new OracleMsSQLPlatformDAOImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
return new GenericPlatformDAOImpl();
case Constants.DataBaseTypes.DB_TYPE_MSSQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new OracleMsSQLPlatformDAOImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
}
}
throw new IllegalStateException("Database engine has not initialized properly.");
@ -94,13 +94,13 @@ public class DAOFactory {
public static LifecycleStateDAO getLifecycleStateDAO() {
if (databaseEngine != null) {
switch (databaseEngine) {
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new GenericLifecycleStateImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new GenericLifecycleStateImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
}
}
throw new IllegalStateException("Database engine has not initialized properly.");
@ -108,18 +108,19 @@ public class DAOFactory {
/**
* To get the instance of ApplicationReleaseDAOImplementation of the particular database engine.
*
* @return specific ApplicationReleaseDAOImplementation
*/
public static ApplicationReleaseDAO getApplicationReleaseDAO() {
if (databaseEngine != null) {
switch (databaseEngine) {
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new GenericApplicationReleaseDAOImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
case Constants.DataBaseTypes.DB_TYPE_H2:
case Constants.DataBaseTypes.DB_TYPE_MYSQL:
case Constants.DataBaseTypes.DB_TYPE_POSTGRESQL:
case Constants.DataBaseTypes.DB_TYPE_ORACLE:
return new GenericApplicationReleaseDAOImpl();
default:
throw new UnsupportedDatabaseEngineException("Unsupported database engine : " + databaseEngine);
}
}
throw new IllegalStateException("Database engine has not initialized properly.");
@ -127,9 +128,10 @@ public class DAOFactory {
/**
* To get the instance of VisibilityDAOImplementation of the particular database engine.
*
* @return specific VisibilityDAOImplementation
*/
public static VisibilityDAO getVisibilityDAO(){
public static VisibilityDAO getVisibilityDAO() {
if (databaseEngine != null) {
switch (databaseEngine) {
case Constants.DataBaseTypes.DB_TYPE_H2:

@ -39,7 +39,6 @@ import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

@ -32,7 +32,6 @@ import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -41,7 +40,7 @@ import java.util.Map;
/**
* GenericApplicationReleaseDAOImpl holds the implementation of ApplicationRelease related DAO operations.
*/
public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements ApplicationReleaseDAO {
public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements ApplicationReleaseDAO {
@Override
public ApplicationRelease createRelease(ApplicationRelease applicationRelease) throws
@ -56,7 +55,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
String sql = "insert into APPM_APPLICATION_RELEASE(VERSION_NAME, RELEASE_RESOURCE, RELEASE_CHANNEL ,"
+ "RELEASE_DETAILS, CREATED_AT, APPM_APPLICATION_ID, IS_DEFAULT) values (?, ?, ?, ?, ?, ?, ?)";
int index = 0;
String generatedColumns[] = { "ID" };
String generatedColumns[] = {"ID"};
try {
connection = this.getDBConnection();
statement = connection.prepareStatement(sql, generatedColumns);
@ -134,7 +133,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
versionName, e);
} catch (SQLException e) {
throw new ApplicationManagementDAOException("Error while getting release details of the application " +
applicationUuid + " and version " + versionName + " , while executing the query " + sql, e);
applicationUuid + " and version " + versionName + " , while executing the query " + sql, e);
} finally {
Util.cleanupResources(statement, resultSet);
Util.cleanupResources(null, rsProperties);
@ -199,9 +198,9 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement statement = null;
String sql = "UPDATE APPM_APPLICATION_RELEASE SET RELEASE_RESOURCE = IFNULL (?, RELEASE_RESOURCE), RELEASE_CHANNEL = IFNULL "
+ "(?, RELEASE_CHANNEL), RELEASE_DETAILS = IFNULL (?, RELEASE_DETAILS), IS_DEFAULT = IFNULL "
+ "(?, IS_DEFAULT) WHERE APPM_APPLICATION_ID = ? AND VERSION_NAME = ?";
String sql = "UPDATE APPM_APPLICATION_RELEASE SET RELEASE_RESOURCE = IFNULL (?, RELEASE_RESOURCE)," +
" RELEASE_CHANNEL = IFNULL (?, RELEASE_CHANNEL), RELEASE_DETAILS = IFNULL (?, RELEASE_DETAILS), " +
"IS_DEFAULT = IFNULL (?, IS_DEFAULT) WHERE APPM_APPLICATION_ID = ? AND VERSION_NAME = ?";
try {
connection = this.getDBConnection();
statement = connection.prepareStatement(sql);
@ -277,7 +276,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
@Override
public void changeReleaseDefault(String uuid, String version, boolean isDefault, String releaseChannel,
int tenantId) throws ApplicationManagementDAOException {
int tenantId) throws ApplicationManagementDAOException {
Connection connection;
PreparedStatement statement = null;
String sql = "UPDATE APPM_APPLICATION_RELEASE SET IS_DEFAULT = ? AND RELEASE_CHANNEL = ? WHERE "
@ -311,7 +310,8 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
/**
* To insert the application release properties.
* @param connection Database Connection
*
* @param connection Database Connection
* @param applicationRelease Application Release the properties of which that need to be inserted.
* @throws SQLException SQL Exception.
*/
@ -343,11 +343,11 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
/**
* To make all the releases of particular release channel as non-default ones.
*
* @param uuid UUID of the Application.
* @param uuid UUID of the Application.
* @param releaseChannel ReleaseChannel for which we need to make all the releases as non-default ones.
* @param tenantId ID of the tenant.
* @param tenantId ID of the tenant.
* @throws DBConnectionException Database Connection Exception.
* @throws SQLException SQL Exception.
* @throws SQLException SQL Exception.
*/
private void removeDefaultReleases(String uuid, String releaseChannel, int tenantId)
throws DBConnectionException, SQLException {

@ -117,12 +117,12 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil
public Visibility get(int applicationId) throws VisibilityManagementDAOException {
PreparedStatement stmt = null;
ResultSet resultSet = null;
final String VISIBILITY_TYPE = "VISIBILITY_TYPE";
final String ALLOWED_VAL = "ALLOWED_VAL";
final String visibilityTypeColumn = "VISIBILITY_TYPE";
final String allowedValColumn = "ALLOWED_VAL";
try {
Connection connection = getDBConnection();
String sql = "SELECT APPM_VISIBILITY.VALUE as " + ALLOWED_VAL + ", APPM_RESOURCE_TYPE.NAME AS " +
VISIBILITY_TYPE + " FROM APPM_VISIBILITY JOIN APPM_RESOURCE_TYPE " +
String sql = "SELECT APPM_VISIBILITY.VALUE as " + allowedValColumn + ", APPM_RESOURCE_TYPE.NAME AS " +
visibilityTypeColumn + " FROM APPM_VISIBILITY JOIN APPM_RESOURCE_TYPE " +
"ON APPM_VISIBILITY.RESOURCE_TYPE_ID = APPM_RESOURCE_TYPE.ID " +
"WHERE APPM_VISIBILITY.APPLICATION_ID = ?";
stmt = connection.prepareStatement(sql);
@ -132,14 +132,14 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil
List<String> allowedVal = new ArrayList<>();
while (resultSet.next()) {
if (visibility.getType() == null) {
visibility.setType(Visibility.Type.valueOf(resultSet.getString(VISIBILITY_TYPE)));
visibility.setType(Visibility.Type.valueOf(resultSet.getString(visibilityTypeColumn)));
}
String val = resultSet.getString(ALLOWED_VAL);
String val = resultSet.getString(allowedValColumn);
if (val != null) {
allowedVal.add(val);
}
}
if (!allowedVal.isEmpty()){
if (!allowedVal.isEmpty()) {
visibility.setAllowedList(allowedVal);
}
return visibility;

@ -22,7 +22,15 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.application.mgt.common.*;
import org.wso2.carbon.device.application.mgt.common.Application;
import org.wso2.carbon.device.application.mgt.common.ApplicationList;
import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.Lifecycle;
import org.wso2.carbon.device.application.mgt.common.LifecycleState;
import org.wso2.carbon.device.application.mgt.common.LifecycleStateTransition;
import org.wso2.carbon.device.application.mgt.common.Platform;
import org.wso2.carbon.device.application.mgt.common.User;
import org.wso2.carbon.device.application.mgt.common.Visibility;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO;

@ -22,6 +22,10 @@ import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
/**
* This class is the default implementation for the CategoryManager.
*
*/
public class CategoryManagerImpl implements CategoryManager {
@Override

@ -19,5 +19,8 @@ package org.wso2.carbon.device.application.mgt.core.impl;
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager;
/**
* This class is the default implementation for the Managing the comments.
*/
public class CommentsManagerImpl implements CommentsManager {
}

@ -25,12 +25,17 @@ import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManage
import java.util.List;
/**
* This is the default implementation for the Subscription Manager.
*/
public class SubscriptionManagerImpl implements SubscriptionManager {
private static final Log log = LogFactory.getLog(SubscriptionManagerImpl.class);
@Override
public List<DeviceIdentifier> installApplicationForDevices(String applicationUUID, List<DeviceIdentifier> deviceList) throws ApplicationManagementException {
public List<DeviceIdentifier> installApplicationForDevices(String applicationUUID,
List<DeviceIdentifier> deviceList)
throws ApplicationManagementException {
log.info("Install application: " + applicationUUID + " to: " + deviceList.size() + " devices.");
for (DeviceIdentifier device : deviceList) {
String deviceId = device.getId();
@ -42,7 +47,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
@Override
public List<String> installApplicationForUsers(String applicationUUID, List<String> userList) throws ApplicationManagementException {
public List<String> installApplicationForUsers(String applicationUUID, List<String> userList)
throws ApplicationManagementException {
log.info("Install application: " + applicationUUID + " to: " + userList.size() + " users.");
for (String user : userList) {
//Todo: implementation
@ -51,7 +57,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
@Override
public List<String> installApplicationForRoles(String applicationUUID, List<String> roleList) throws ApplicationManagementException {
public List<String> installApplicationForRoles(String applicationUUID, List<String> roleList)
throws ApplicationManagementException {
log.info("Install application: " + applicationUUID + " to: " + roleList.size() + " users.");
for (String role : roleList) {
//Todo: implementation
@ -60,7 +67,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
@Override
public List<DeviceIdentifier> uninstallApplication(String applicationUUID, List<DeviceIdentifier> deviceList) throws ApplicationManagementException {
public List<DeviceIdentifier> uninstallApplication(String applicationUUID,
List<DeviceIdentifier> deviceList)
throws ApplicationManagementException {
return null;
}
}

@ -32,7 +32,7 @@ public class VisibilityManagerImpl implements VisibilityManager {
@Override
public Visibility put(int applicationID, Visibility visibility) throws VisibilityManagementException {
if (visibility == null){
if (visibility == null) {
visibility = new Visibility();
visibility.setType(Visibility.Type.PUBLIC);
}
@ -71,8 +71,9 @@ public class VisibilityManagerImpl implements VisibilityManager {
public Visibility get(int applicationID) throws VisibilityManagementException {
try {
VisibilityDAO visibilityDAO = DAOFactory.getVisibilityDAO();
Visibility visibility = visibilityDAO.get(applicationID);
if (visibility.getType() == null && (visibility.getAllowedList() == null || visibility.getAllowedList().isEmpty())){
Visibility visibility = visibilityDAO.get(applicationID);
if (visibility.getType() == null && (visibility.getAllowedList() == null ||
visibility.getAllowedList().isEmpty())) {
visibility.setType(Visibility.Type.PUBLIC);
}
return visibility;

Loading…
Cancel
Save