Fix formatting issues

revert-70aa11f8
lasanthaDLPDS 5 years ago
parent e42950dd76
commit 9d9f420c83

@ -108,15 +108,15 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String msg = "Invalid device identifiers are found with the request."; String msg = "Invalid device identifiers are found with the request.";
log.error(msg); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred when updating device owners."; String msg = "Error occurred when updating device owners.";
log.error(msg); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (UserNotFoundException e) { } catch (UserNotFoundException e) {
String msg = "Couldn't found the owner in user store to update the owner of devices."; String msg = "Couldn't found the owner in user store to update the owner of devices.";
log.error(msg); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
} }

@ -498,7 +498,8 @@ public interface DeviceDAO {
* @throws DeviceManagementDAOException throws {@link DeviceManagementDAOException} if connections establishment * @throws DeviceManagementDAOException throws {@link DeviceManagementDAOException} if connections establishment
* fails. * fails.
*/ */
List<Device> getDevicesByIdentifiers(List<String> deviceIdentifiers, int tenantId) throws DeviceManagementDAOException; List<Device> getDevicesByIdentifiers(List<String> deviceIdentifiers, int tenantId)
throws DeviceManagementDAOException;
/** /**
* This method is used to permanently delete the device and its related details * This method is used to permanently delete the device and its related details
@ -508,4 +509,3 @@ public interface DeviceDAO {
*/ */
void deleteDevice(DeviceIdentifier deviceIdentifier, int tenantId) throws DeviceManagementDAOException; void deleteDevice(DeviceIdentifier deviceIdentifier, int tenantId) throws DeviceManagementDAOException;
} }

@ -1507,8 +1507,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
} }
return devices; return devices;
} catch (SQLException e) { } catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while obtaining the DB connection when adding tags", throw new DeviceManagementDAOException("Error occurred while obtaining the DB connection to get devices for"
e); + " given device identifiers.", e);
} }
} }

@ -369,7 +369,11 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
try { try {
Connection conn = this.getConnection(); Connection conn = this.getConnection();
boolean updateStatus = true; boolean updateStatus = true;
String sql = "UPDATE DM_ENROLMENT SET OWNER = ? WHERE ID = ? AND TENANT_ID = ?"; String sql = "UPDATE "
+ "DM_ENROLMENT "
+ "SET OWNER = ? "
+ "WHERE ID = ? AND "
+ "TENANT_ID = ?";
try (PreparedStatement ps = conn.prepareStatement(sql)) { try (PreparedStatement ps = conn.prepareStatement(sql)) {
if (conn.getMetaData().supportsBatchUpdates()) { if (conn.getMetaData().supportsBatchUpdates()) {
for (Device device : devices) { for (Device device : devices) {
@ -381,6 +385,7 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
for (int i : ps.executeBatch()) { for (int i : ps.executeBatch()) {
if (i == 0 || i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) { if (i == 0 || i == Statement.SUCCESS_NO_INFO || i == Statement.EXECUTE_FAILED) {
updateStatus = false; updateStatus = false;
break;
} }
} }
} else { } else {
@ -390,14 +395,15 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
ps.setInt(3, tenantId); ps.setInt(3, tenantId);
if (ps.executeUpdate() == 0) { if (ps.executeUpdate() == 0) {
updateStatus = false; updateStatus = false;
break;
} }
} }
} }
} }
return updateStatus; return updateStatus;
} catch (SQLException e) { } catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while obtaining the DB connection when adding tags", throw new DeviceManagementDAOException("Error occurred while obtaining the DB connection to update the "
e); + "owner of the device enrollment.", e);
} }
} }

@ -3086,12 +3086,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
DeviceManagementDAOFactory.rollbackTransaction(); DeviceManagementDAOFactory.rollbackTransaction();
return false; return false;
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
String msg = "Error occurred while initiating transaction"; String msg = "Error occurred while initiating the transaction.";
log.error(msg, e); log.error(msg, e);
throw new DeviceManagementException(msg, e); throw new DeviceManagementException(msg, e);
} catch (DeviceManagementDAOException e) { } catch (DeviceManagementDAOException e) {
String msg = "Error occurred either verifying existence of device ids or updating owner of the device."; String msg = "Error occurred either verifying existence of device ids or updating owner of the device.";
log.error(msg); log.error(msg, e);
throw new DeviceManagementException(msg, e); throw new DeviceManagementException(msg, e);
} finally { } finally {
DeviceManagementDAOFactory.closeConnection(); DeviceManagementDAOFactory.closeConnection();
@ -3114,7 +3114,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return owner; return owner;
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred when checking whether owner is exist or not. Owner: " + owner; String msg = "Error occurred when checking whether owner is exist or not. Owner: " + owner;
log.error(msg); log.error(msg, e);
throw new DeviceManagementException(msg, e); throw new DeviceManagementException(msg, e);
} }
} }

@ -147,6 +147,7 @@ import java.util.List;
key = "perm:get-activity", key = "perm:get-activity",
permissions = {"/device-mgt/devices/owning-device/view"} permissions = {"/device-mgt/devices/owning-device/view"}
) )
} }
) )
@Path("/users") @Path("/users")

@ -106,15 +106,15 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (InvalidDeviceException e) { } catch (InvalidDeviceException e) {
String msg = "Invalid device identifiers are found with the request."; String msg = "Invalid device identifiers are found with the request.";
log.error(msg); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred when updating the device owner."; String msg = "Error occurred when updating the device owner.";
log.error(msg); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (UserNotFoundException e) { } catch (UserNotFoundException e) {
String msg = "Couldn't found the owner in user store to update the owner of devices."; String msg = "Couldn't found the owner in user store to update the owner of devices.";
log.error(msg); log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
} }

Loading…
Cancel
Save