Fixing AppManager connector initialization issue at server start up and adding support for retrieving the complete operation list for a given device

merge-requests/7/head
prabathabey 10 years ago
parent 5f7e4306de
commit add470c483

@ -44,8 +44,6 @@ public class RemoteAppManagerConnector implements AppManagerConnector {
private ConfigurationContext configCtx; private ConfigurationContext configCtx;
private ServiceAuthenticator authenticator; private ServiceAuthenticator authenticator;
private AppManagementConfig appManagementConfig;
private IdentityConfigurations identityConfig;
private String oAuthAdminServiceUrl; private String oAuthAdminServiceUrl;
private static final String GET_APP_LIST_URL = "store/apis/assets/mobileapp?domain=carbon.super&page=1"; private static final String GET_APP_LIST_URL = "store/apis/assets/mobileapp?domain=carbon.super&page=1";
@ -53,12 +51,10 @@ public class RemoteAppManagerConnector implements AppManagerConnector {
private static final Log log = LogFactory.getLog(RemoteAppManagerConnector.class); private static final Log log = LogFactory.getLog(RemoteAppManagerConnector.class);
public RemoteAppManagerConnector(AppManagementConfig appManagementConfig) { public RemoteAppManagerConnector(AppManagementConfig appManagementConfig) {
this.appManagementConfig = appManagementConfig; IdentityConfigurations identityConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
getDeviceManagementConfigRepository().getIdentityConfigurations();
this.authenticator = this.authenticator =
new ServiceAuthenticator(identityConfig.getAdminUsername(), identityConfig.getAdminPassword()); new ServiceAuthenticator(identityConfig.getAdminUsername(), identityConfig.getAdminPassword());
this.identityConfig =
DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
getDeviceManagementConfigRepository().getIdentityConfigurations();
this.oAuthAdminServiceUrl = this.oAuthAdminServiceUrl =
identityConfig.getServerUrl() + DeviceManagementConstants.AppManagement.OAUTH_ADMIN_SERVICE; identityConfig.getServerUrl() + DeviceManagementConstants.AppManagement.OAUTH_ADMIN_SERVICE;
try { try {

@ -33,7 +33,9 @@ public interface OperationDAO {
Operation getOperation(int operationId) throws OperationManagementDAOException; Operation getOperation(int operationId) throws OperationManagementDAOException;
List<Operation> getOperations() throws OperationManagementDAOException; Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException;
List<Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException;
List<Operation> getOperations(String status) throws OperationManagementDAOException; List<Operation> getOperations(String status) throws OperationManagementDAOException;

@ -70,7 +70,12 @@ public class CommandOperationDAOImpl extends OperationDAOImpl {
} }
@Override @Override
public List<Operation> getOperations() throws OperationManagementDAOException { public Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException {
return null;
}
@Override
public List<Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException {
return null; return null;
} }

@ -47,7 +47,12 @@ public class ConfigOperationDAOImpl extends OperationDAOImpl {
} }
@Override @Override
public List<Operation> getOperations() throws OperationManagementDAOException { public Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException {
return null;
}
@Override
public List<Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException {
return null; return null;
} }

@ -28,6 +28,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.List;
@ -75,7 +76,33 @@ public class OperationDAOImpl implements OperationDAO {
} }
@Override @Override
public List<Operation> getOperations() throws OperationManagementDAOException { public Operation getOperation(DeviceIdentifier deviceId, int operationId) throws OperationManagementDAOException {
return null;
}
@Override
public List<Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException {
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, o.STATUS FROM DM_OPERATION o " +
"INNER JOIN (SELECT dom.OPERATION_ID AS OP_ID FROM (SELECT d.ID FROM DM_DEVICE d INNER JOIN " +
"DM_DEVICE_TYPE dm ON d.DEVICE_TYPE_ID = dm.ID AND dm.NAME = ? AND d.DEVICE_IDENTIFICATION = ?) d1 " +
"INNER JOIN DM_DEVICE_OPERATION_MAPPING dom ON d1.ID = dom.DEVICE_ID) ois ON o.ID = ois.OP_ID";
try {
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setString(1, deviceId.getType());
stmt.setString(2, deviceId.getId());
List<Operation> operations = new ArrayList<Operation>();
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
Operation operation = new Operation();
//operation.setType();
}
} catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while retrieving the operation list " +
"available for the '" + deviceId.getType() + "' with id '" + deviceId.getId() + "'" , e);
}
return null; return null;
} }

@ -137,7 +137,7 @@ public class ProfileOperationDAOImpl extends OperationDAOImpl {
} }
@Override @Override
public List<Operation> getOperations() throws OperationManagementDAOException { public List<Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementDAOException {
return null; return null;
} }

Loading…
Cancel
Save