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; package org.wso2.carbon.device.application.mgt.core.dao;
/**
* This interface specifies the database access operations performed for comments.
*/
public interface CommentDAO { public interface CommentDAO {
} }

@ -18,5 +18,9 @@
*/ */
package org.wso2.carbon.device.application.mgt.core.dao; 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 { public interface SubscriptionDAO {
} }

@ -24,7 +24,9 @@ import org.wso2.carbon.device.application.mgt.core.exception.VisibilityManagemen
import java.util.List; 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 { 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.ApplicationDAO;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO; 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.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.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.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.GenericApplicationReleaseDAOImpl;
import org.wso2.carbon.device.application.mgt.core.dao.impl.application.release.OracleApplicationDAOImpl; import org.wso2.carbon.device.application.mgt.core.dao.impl.application.release.OracleApplicationDAOImpl;
@ -108,6 +108,7 @@ public class DAOFactory {
/** /**
* To get the instance of ApplicationReleaseDAOImplementation of the particular database engine. * To get the instance of ApplicationReleaseDAOImplementation of the particular database engine.
*
* @return specific ApplicationReleaseDAOImplementation * @return specific ApplicationReleaseDAOImplementation
*/ */
public static ApplicationReleaseDAO getApplicationReleaseDAO() { public static ApplicationReleaseDAO getApplicationReleaseDAO() {
@ -127,9 +128,10 @@ public class DAOFactory {
/** /**
* To get the instance of VisibilityDAOImplementation of the particular database engine. * To get the instance of VisibilityDAOImplementation of the particular database engine.
*
* @return specific VisibilityDAOImplementation * @return specific VisibilityDAOImplementation
*/ */
public static VisibilityDAO getVisibilityDAO(){ public static VisibilityDAO getVisibilityDAO() {
if (databaseEngine != null) { if (databaseEngine != null) {
switch (databaseEngine) { switch (databaseEngine) {
case Constants.DataBaseTypes.DB_TYPE_H2: case Constants.DataBaseTypes.DB_TYPE_H2:

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

@ -32,7 +32,6 @@ import java.sql.Date;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -56,7 +55,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
String sql = "insert into APPM_APPLICATION_RELEASE(VERSION_NAME, RELEASE_RESOURCE, RELEASE_CHANNEL ," String sql = "insert into APPM_APPLICATION_RELEASE(VERSION_NAME, RELEASE_RESOURCE, RELEASE_CHANNEL ,"
+ "RELEASE_DETAILS, CREATED_AT, APPM_APPLICATION_ID, IS_DEFAULT) values (?, ?, ?, ?, ?, ?, ?)"; + "RELEASE_DETAILS, CREATED_AT, APPM_APPLICATION_ID, IS_DEFAULT) values (?, ?, ?, ?, ?, ?, ?)";
int index = 0; int index = 0;
String generatedColumns[] = { "ID" }; String generatedColumns[] = {"ID"};
try { try {
connection = this.getDBConnection(); connection = this.getDBConnection();
statement = connection.prepareStatement(sql, generatedColumns); statement = connection.prepareStatement(sql, generatedColumns);
@ -199,9 +198,9 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
throws ApplicationManagementDAOException { throws ApplicationManagementDAOException {
Connection connection; Connection connection;
PreparedStatement statement = null; PreparedStatement statement = null;
String sql = "UPDATE APPM_APPLICATION_RELEASE SET RELEASE_RESOURCE = IFNULL (?, RELEASE_RESOURCE), RELEASE_CHANNEL = IFNULL " String sql = "UPDATE APPM_APPLICATION_RELEASE SET RELEASE_RESOURCE = IFNULL (?, RELEASE_RESOURCE)," +
+ "(?, RELEASE_CHANNEL), RELEASE_DETAILS = IFNULL (?, RELEASE_DETAILS), IS_DEFAULT = IFNULL " " RELEASE_CHANNEL = IFNULL (?, RELEASE_CHANNEL), RELEASE_DETAILS = IFNULL (?, RELEASE_DETAILS), " +
+ "(?, IS_DEFAULT) WHERE APPM_APPLICATION_ID = ? AND VERSION_NAME = ?"; "IS_DEFAULT = IFNULL (?, IS_DEFAULT) WHERE APPM_APPLICATION_ID = ? AND VERSION_NAME = ?";
try { try {
connection = this.getDBConnection(); connection = this.getDBConnection();
statement = connection.prepareStatement(sql); statement = connection.prepareStatement(sql);
@ -311,6 +310,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements
/** /**
* To insert the application release properties. * 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. * @param applicationRelease Application Release the properties of which that need to be inserted.
* @throws SQLException SQL Exception. * @throws SQLException SQL Exception.

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

@ -22,7 +22,15 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.CarbonConstants; import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext; 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.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO; 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.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.CategoryManager; import org.wso2.carbon.device.application.mgt.common.services.CategoryManager;
/**
* This class is the default implementation for the CategoryManager.
*
*/
public class CategoryManagerImpl implements CategoryManager { public class CategoryManagerImpl implements CategoryManager {
@Override @Override

@ -19,5 +19,8 @@ package org.wso2.carbon.device.application.mgt.core.impl;
import org.wso2.carbon.device.application.mgt.common.services.CommentsManager; 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 { public class CommentsManagerImpl implements CommentsManager {
} }

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

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

Loading…
Cancel
Save