Vojtech Szocs has uploaded a new change for review. Change subject: Revert "database, core: Add the UserProfile entity" ......................................................................
Revert "database, core: Add the UserProfile entity" This reverts commit db95bc08815feb14ba309badfc19e186bb880cd0. Change-Id: I31fcb89b8a2302380a7228e904126ab923908dbd Signed-off-by: Vojtech Szocs <[email protected]> --- D backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/UserProfile.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java D backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UserProfileDAO.java D backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UserProfileDAODbFacadeImpl.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbFacadeDAOTest.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbUserDAOTest.java D backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/UserProfileDAOTest.java M backend/manager/modules/dal/src/test/resources/fixtures.xml D packaging/dbscripts/upgrade/03_06_1170_add_user_profiles.sql D packaging/dbscripts/user_profiles_sp.sql 10 files changed, 2 insertions(+), 498 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/82/39682/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/UserProfile.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/UserProfile.java deleted file mode 100644 index e44341e..0000000 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/UserProfile.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.ovirt.engine.core.common.businessentities; - -import org.ovirt.engine.core.common.utils.ObjectUtils; -import org.ovirt.engine.core.compat.Guid; - -public class UserProfile extends IVdcQueryable { - private static final long serialVersionUID = 7251907866347833460L; - - private Guid id; - - private Guid userId; - - private String sshPublicKey; - - public UserProfile() { - sshPublicKey = ""; - } - - public Guid getId() { - return id; - } - - public void setId(Guid id) { - this.id = id; - } - - public Guid getUserId() { - return userId; - } - - public void setUserId(Guid user_id) { - this.userId = user_id; - } - - public String getSshPublicKey() { - return sshPublicKey; - } - - public void setSshPublicKey(String sshPublicKey) { - this.sshPublicKey = sshPublicKey; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((sshPublicKey == null) ? 0 : sshPublicKey.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - UserProfile other = (UserProfile) obj; - return ObjectUtils.objectsEqual(sshPublicKey, other.sshPublicKey); - } -} diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java index e6d87c1..7703539 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java @@ -48,7 +48,6 @@ import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.VmStatistics; import org.ovirt.engine.core.common.businessentities.VmTemplate; -import org.ovirt.engine.core.common.businessentities.UserProfile; import org.ovirt.engine.core.common.businessentities.network.Network; import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; import org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics; @@ -109,7 +108,6 @@ import org.ovirt.engine.core.dao.StorageServerConnectionLunMapDAO; import org.ovirt.engine.core.dao.TagDAO; import org.ovirt.engine.core.dao.UnregisteredOVFDataDAO; -import org.ovirt.engine.core.dao.UserProfileDAO; import org.ovirt.engine.core.dao.VdcOptionDAO; import org.ovirt.engine.core.dao.VdsCpuStatisticsDAO; import org.ovirt.engine.core.dao.VdsDAO; @@ -230,7 +228,6 @@ put(FenceAgent.class, FenceAgentDAO.class); put(EngineSession.class, EngineSessionDAO.class); put(HostDevice.class, HostDeviceDao.class); - put(UserProfile.class, UserProfileDAO.class); } }; @@ -421,15 +418,6 @@ */ public DbUserDAO getDbUserDao() { return getDao(DbUserDAO.class); - } - - /** - * Returns the singleton instance of {@link UserProfileDAO}. - * - * @return the dao - */ - public UserProfileDAO getUserProfileDao() { - return getDao(UserProfileDAO.class); } /** diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UserProfileDAO.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UserProfileDAO.java deleted file mode 100644 index a748af6..0000000 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UserProfileDAO.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.ovirt.engine.core.dao; - -import org.ovirt.engine.core.common.businessentities.UserProfile; -import org.ovirt.engine.core.compat.Guid; - -import java.util.List; - -public interface UserProfileDAO extends DAO { - /** - * Retrieves the user profile with the specified id. - * - * @param id - * the id - * @return the user profile, or <code>null</code> if the id was invalid - */ - UserProfile get(Guid id); - - /** - * Retrieves the user profile associated with the specified user id. - * - * @param userId - * the user id - * @return the user profile, or <code>null</code> if the id was invalid - */ - UserProfile getByUserId(Guid userId); - - /** - * Retrieves all user profiles. - * - * @return the collection of all user profiles - */ - List<UserProfile> getAll(); - - /** - * Saves the user profile. - * - * @param profile - * the user profile - */ - void save(UserProfile profile); - - /** - * Updates the specified user profile in the database. - * - * @param profile - * the user profile - */ - void update(UserProfile profile); - - /** - * Removes the user profile with the specified id. - * - * @param id - * the user profile id - */ - void remove(Guid id); -} diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UserProfileDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UserProfileDAODbFacadeImpl.java deleted file mode 100644 index c1aed33..0000000 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UserProfileDAODbFacadeImpl.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.ovirt.engine.core.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.ovirt.engine.core.common.businessentities.UserProfile; -import org.ovirt.engine.core.compat.Guid; -import org.springframework.jdbc.core.RowMapper; -import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; - -@Named -@Singleton -public class UserProfileDAODbFacadeImpl extends BaseDAODbFacade implements UserProfileDAO { - - private static final class UserProfileRowMapper implements RowMapper<UserProfile> { - public static final UserProfileRowMapper instance = new UserProfileRowMapper(); - - @Override - public UserProfile mapRow(ResultSet rs, int rowNum) - throws SQLException { - UserProfile entity = new UserProfile(); - entity.setId(getGuidDefaultEmpty(rs, "profile_id")); - entity.setUserId(getGuidDefaultEmpty(rs, "user_id")); - entity.setSshPublicKey(rs.getString("ssh_public_key")); - return entity; - } - } - - @Override - public UserProfile get(Guid id) { - MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() - .addValue("profile_id", id); - - return getCallsHandler().executeRead("GetUserProfileByProfileId", UserProfileRowMapper.instance, parameterSource); - } - - @Override - public UserProfile getByUserId(Guid id) { - MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() - .addValue("user_id", id); - - return getCallsHandler().executeRead("GetUserProfileByUserId", UserProfileRowMapper.instance, parameterSource); - } - - @Override - public List<UserProfile> getAll() { - MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource(); - return getCallsHandler().executeReadList("GetAllFromUserProfiles", UserProfileRowMapper.instance, parameterSource); - } - - private MapSqlParameterSource createIdParameterMapper(Guid id) { - return getCustomMapSqlParameterSource().addValue("profile_id", id); - } - - @Override - public void save(UserProfile profile) { - getCallsHandler().executeModification("InsertUserProfile", - createIdParameterMapper(profile.getId()) - .addValue("user_id", profile.getUserId()) - .addValue("ssh_public_key", profile.getSshPublicKey())); - } - - @Override - public void update(UserProfile profile) { - getCallsHandler().executeModification("UpdateUserProfile", - createIdParameterMapper(profile.getId()) - .addValue("user_id", profile.getUserId()) - .addValue("ssh_public_key", profile.getSshPublicKey())); - } - - @Override - public void remove(Guid id) { - MapSqlParameterSource parameterSource = createIdParameterMapper(id); - - getCallsHandler().executeModification("DeleteUserProfile", parameterSource); - } -} diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbFacadeDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbFacadeDAOTest.java index 73078d2..1844132 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbFacadeDAOTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbFacadeDAOTest.java @@ -70,7 +70,7 @@ private static final Guid ADMIN_ROLE_TYPE_FROM_FIXTURE_ID = new Guid("F5972BFA-7102-4D33-AD22-9DD421BFBA78"); private static final Guid SYSTEM_OBJECT_ID = new Guid("AAA00000-0000-0000-0000-123456789AAA"); private static final int NUM_OF_VM_IN_FIXTURES_WITH_STATUS_MIGRATING_FROM = 2; - private static final int NUM_OF_USERS_IN_FIXTURES = 4; + private static final int NUM_OF_USERS_IN_FIXTURES = 2; private static final Guid STORAGE_POOL_WITH_MASTER_UP = new Guid("386BFFD1-E7ED-4B08-BCE9-D7DF10F8C9A0"); private static final Guid STORAGE_POOL_WITH_MASTER_DOWN = new Guid("72B9E200-F48B-4687-83F2-62828F249A47"); private static final Guid VM_STATIC_GUID = new Guid("77296e00-0cad-4e5a-9299-008a7b6f4354"); diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbUserDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbUserDAOTest.java index 1e617c4..a106568 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbUserDAOTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/DbUserDAOTest.java @@ -146,7 +146,7 @@ assertNotNull(result); assertFalse(result.isEmpty()); - assertEquals(4, result.size()); + assertEquals(2, result.size()); } @Test diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/UserProfileDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/UserProfileDAOTest.java deleted file mode 100644 index 2c8cc29..0000000 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/UserProfileDAOTest.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.ovirt.engine.core.dao; - -import org.junit.Before; -import org.junit.Test; -import org.ovirt.engine.core.common.businessentities.UserProfile; -import org.ovirt.engine.core.compat.Guid; - -import java.util.List; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -public class UserProfileDAOTest extends BaseDAOTestCase { - private UserProfileDAO dao; - private UserProfile existingProfile; - private UserProfile deletableProfile; - private UserProfile newProfile; - - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - dao = dbFacade.getUserProfileDao(); - - existingProfile = dao.get(new Guid("38cb5663-96bc-485c-834a-cbbc03acc820")); - deletableProfile = dao.get(new Guid("38cb5663-96bc-485c-834a-cbbc03acc821")); - - newProfile = new UserProfile(); - - newProfile.setId(Guid.newGuid()); - newProfile.setUserId(new Guid("81940459-2ec4-4afa-bbaa-22549555293c")); - newProfile.setSshPublicKey("key3"); - } - - /** - * Ensures that trying to get a user profile using an invalid id fails. - */ - @Test - public void testGetWithInvalidId() { - UserProfile result = dao.get(Guid.newGuid()); - - assertNull(result); - } - - /** - * Ensures that retrieving an user profile by id works as expected. - */ - @Test - public void testGet() { - UserProfile result = dao.get(existingProfile.getId()); - - assertNotNull(result); - assertEquals(existingProfile, result); - } - - /** - * Ensures that retrieving an user profile by user id works as expected. - */ - @Test - public void testGetByUserId() { - UserProfile result = dao.getByUserId(existingProfile.getUserId()); - - assertNotNull(result); - assertEquals(existingProfile, result); - } - - @Test - public void testGetAll() { - List<UserProfile> result = dao.getAll(); - - assertNotNull(result); - assertFalse(result.isEmpty()); - assertEquals(2, result.size()); - } - - /** - * Ensures that saving a user profile works as expected. - */ - @Test - public void testSave() { - dao.save(newProfile); - - UserProfile result = dao.get(newProfile.getId()); - - assertEquals(newProfile, result); - } - - /** - * Ensures that updating a user profile works as expected. - */ - @Test - public void testUpdate() { - existingProfile.setSshPublicKey("key4"); - - dao.update(existingProfile); - - UserProfile result = dao.get(existingProfile.getId()); - - assertEquals(existingProfile, result); - } - - /** - * Ensures that removing user profiles works as expected. - */ - @Test - public void testRemove() { - dao.remove(deletableProfile.getId()); - - UserProfile result = dao.get(deletableProfile.getId()); - - assertNull(result); - } -} diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index edb99a5..7fc618e 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -4975,48 +4975,6 @@ <value>0</value> <value>*</value> </row> - <row> - <value>81940459-2ec4-4afa-bbaa-22549555293b</value> - <value>c</value> - <value>userportal4</value> - <null /> - <value>testportal.redhat.com</value> - <value>[email protected]</value> - <null /> - <null /> - <null /> - <value>0</value> - <value>*</value> - </row> - <row> - <value>81940459-2ec4-4afa-bbaa-22549555293c</value> - <value>d</value> - <value>userportal4</value> - <null /> - <value>testportal.redhat.com</value> - <value>[email protected]</value> - <null /> - <null /> - <null /> - <value>0</value> - <value>*</value> - </row> - </table> - - <table name="user_profiles"> - <column>profile_id</column> - <column>user_id</column> - <column>ssh_public_key</column> - <row> - <value>38cb5663-96bc-485c-834a-cbbc03acc820</value> - <value>9bf7c640-b620-456f-a550-0348f366544a</value> - <value>key1</value> - </row> - <row> - <value>38cb5663-96bc-485c-834a-cbbc03acc821</value> - <value>81940459-2ec4-4afa-bbaa-22549555293b</value> - <value>key2</value> - </row> </table> <table name="tags_user_map"> diff --git a/packaging/dbscripts/upgrade/03_06_1170_add_user_profiles.sql b/packaging/dbscripts/upgrade/03_06_1170_add_user_profiles.sql deleted file mode 100644 index c0a3806..0000000 --- a/packaging/dbscripts/upgrade/03_06_1170_add_user_profiles.sql +++ /dev/null @@ -1,17 +0,0 @@ --- ---------------------------------------------------------------------- --- table user_profiles --- ---------------------------------------------------------------------- - -CREATE TABLE user_profiles -( - profile_id UUID NOT NULL, - user_id UUID NOT NULL, - ssh_public_key TEXT, - CONSTRAINT PK_profile_id PRIMARY KEY (profile_id) -) WITH OIDS; - -ALTER TABLE user_profiles ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) - REFERENCES users (user_id) - ON UPDATE NO ACTION ON DELETE CASCADE; - -CREATE INDEX IDX_user_profiles_user_id ON user_profiles(user_id); diff --git a/packaging/dbscripts/user_profiles_sp.sql b/packaging/dbscripts/user_profiles_sp.sql deleted file mode 100644 index 1aee4d0..0000000 --- a/packaging/dbscripts/user_profiles_sp.sql +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - ----------------------------------------------------------------- --- [user_profiles] Table --- - - - - - -Create or replace FUNCTION InsertUserProfile( - v_profile_id UUID, - v_user_id UUID, - v_ssh_public_key TEXT) -RETURNS VOID -AS $procedure$ -BEGIN - INSERT INTO user_profiles ( - profile_id, - user_id, - ssh_public_key) - VALUES( - v_profile_id, - v_user_id, - v_ssh_public_key); -END; $procedure$ -LANGUAGE plpgsql; - - - - - -Create or replace FUNCTION UpdateUserProfile( - v_profile_id UUID, - v_user_id UUID, - v_ssh_public_key TEXT) -RETURNS VOID -AS $procedure$ -BEGIN - UPDATE user_profiles - SET profile_id = v_profile_id, - user_id = v_user_id, - ssh_public_key = v_ssh_public_key - WHERE profile_id = v_profile_id; -END; $procedure$ -LANGUAGE plpgsql; - - - - - -Create or replace FUNCTION DeleteUserProfile(v_profile_id UUID) -RETURNS VOID -AS $procedure$ -BEGIN - DELETE - FROM user_profiles - WHERE profile_id = v_profile_id; -END; $procedure$ -LANGUAGE plpgsql; - - - - - -Create or replace FUNCTION GetAllFromUserProfiles() RETURNS SETOF user_profiles STABLE - AS $procedure$ -BEGIN - RETURN QUERY SELECT user_profiles.* - FROM user_profiles; -END; $procedure$ -LANGUAGE plpgsql; - - - - - -Create or replace FUNCTION GetUserProfileByUserId(v_user_id UUID) -RETURNS SETOF user_profiles STABLE -AS $procedure$ -BEGIN - RETURN QUERY - SELECT * - FROM user_profiles - WHERE user_id = v_user_id; -END; $procedure$ -LANGUAGE plpgsql; - - - - - -Create or replace FUNCTION GetUserProfileByProfileId(v_profile_id UUID) -RETURNS SETOF user_profiles STABLE -AS $procedure$ -BEGIN - RETURN QUERY - SELECT * - FROM user_profiles - WHERE profile_id = v_profile_id; -END; $procedure$ -LANGUAGE plpgsql; -- To view, visit https://gerrit.ovirt.org/39682 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I31fcb89b8a2302380a7228e904126ab923908dbd Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Vojtech Szocs <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
