refactoring
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
index 071a74a..b9fd4dd 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
@@ -3,7 +3,7 @@
import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.Userdetails2;
+import de.ids_mannheim.korap.user.UserDetails;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -18,7 +18,7 @@
* @author hanl
* @date 27/01/2016
*/
-public class UserDetailsDao implements UserDataDbIface<Userdetails2> {
+public class UserDetailsDao implements UserDataDbIface<UserDetails> {
private NamedParameterJdbcTemplate jdbcTemplate;
@@ -27,7 +27,7 @@
}
@Override
- public int store(Userdetails2 data) {
+ public int store(UserDetails data) {
String sql = "INSERT INTO user_details2 (user_id, data) VALUES (:userid, :data);";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", data.getUserID());
@@ -46,7 +46,7 @@
}
@Override
- public int update(Userdetails2 data) {
+ public int update(UserDetails data) {
String sql = "UPDATE user_details2 SET data = :data WHERE user_id=:userid;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", data.getUserID());
@@ -60,19 +60,19 @@
}
@Override
- public Userdetails2 get(Integer id) {
+ public UserDetails get(Integer id) {
String sql = "SELECT * FROM user_details2 WHERE id=:id;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("id", id);
try {
return this.jdbcTemplate
- .queryForObject(sql, source, new RowMapper<Userdetails2>() {
+ .queryForObject(sql, source, new RowMapper<UserDetails>() {
@Override
- public Userdetails2 mapRow(ResultSet rs, int rowNum)
+ public UserDetails mapRow(ResultSet rs, int rowNum)
throws SQLException {
- Userdetails2 details = new Userdetails2(
+ UserDetails details = new UserDetails(
rs.getInt("user_id"));
details.setId(rs.getInt("id"));
details.setData(rs.getString("data"));
@@ -86,19 +86,19 @@
}
@Override
- public Userdetails2 get(User user) {
+ public UserDetails get(User user) {
String sql = "SELECT * FROM user_details2 WHERE user_id=:userid;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", user.getId());
try {
return this.jdbcTemplate
- .queryForObject(sql, source, new RowMapper<Userdetails2>() {
+ .queryForObject(sql, source, new RowMapper<UserDetails>() {
@Override
- public Userdetails2 mapRow(ResultSet rs, int rowNum)
+ public UserDetails mapRow(ResultSet rs, int rowNum)
throws SQLException {
- Userdetails2 details = new Userdetails2(
+ UserDetails details = new UserDetails(
rs.getInt("user_id"));
details.setId(rs.getInt("id"));
details.setData(rs.getString("data"));
@@ -113,7 +113,7 @@
}
@Override
- public int delete(Userdetails2 data) {
+ public int delete(UserDetails data) {
String sql = "DELETE FROM user_details2 WHERE id=:id";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("id", data.getId());
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
index dfc8830..948eae3 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
@@ -3,7 +3,7 @@
import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserSettings2;
+import de.ids_mannheim.korap.user.UserSettings;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -18,7 +18,7 @@
* @author hanl
* @date 28/01/2016
*/
-public class UserSettingsDao implements UserDataDbIface<UserSettings2> {
+public class UserSettingsDao implements UserDataDbIface<UserSettings> {
NamedParameterJdbcTemplate jdbcTemplate;
@@ -26,7 +26,7 @@
this.jdbcTemplate = (NamedParameterJdbcTemplate) client.getSource();
}
@Override
- public int store(UserSettings2 data) {
+ public int store(UserSettings data) {
String sql = "INSERT INTO user_settings2 (user_id, data) VALUES (:userid, :data);";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", data.getUserID());
@@ -45,7 +45,7 @@
}
@Override
- public int update(UserSettings2 data) {
+ public int update(UserSettings data) {
String sql = "UPDATE user_settings2 SET data = :data WHERE user_id=:userid;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", data.getUserID());
@@ -59,19 +59,19 @@
}
@Override
- public UserSettings2 get(Integer id) {
+ public UserSettings get(Integer id) {
String sql = "SELECT * FROM user_settings2 WHERE id=:id;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("id", id);
try {
return this.jdbcTemplate
- .queryForObject(sql, source, new RowMapper<UserSettings2>() {
+ .queryForObject(sql, source, new RowMapper<UserSettings>() {
@Override
- public UserSettings2 mapRow(ResultSet rs, int rowNum)
+ public UserSettings mapRow(ResultSet rs, int rowNum)
throws SQLException {
- UserSettings2 details = new UserSettings2(
+ UserSettings details = new UserSettings(
rs.getInt("user_id"));
details.setId(rs.getInt("id"));
details.setData(rs.getString("data"));
@@ -85,19 +85,19 @@
}
@Override
- public UserSettings2 get(User user) {
+ public UserSettings get(User user) {
String sql = "SELECT * FROM user_settings2 WHERE user_id=:userid;";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("userid", user.getId());
try {
return this.jdbcTemplate
- .queryForObject(sql, source, new RowMapper<UserSettings2>() {
+ .queryForObject(sql, source, new RowMapper<UserSettings>() {
@Override
- public UserSettings2 mapRow(ResultSet rs, int rowNum)
+ public UserSettings mapRow(ResultSet rs, int rowNum)
throws SQLException {
- UserSettings2 details = new UserSettings2(
+ UserSettings details = new UserSettings(
rs.getInt("user_id"));
details.setId(rs.getInt("id"));
details.setData(rs.getString("data"));
@@ -112,7 +112,7 @@
}
@Override
- public int delete(UserSettings2 data) {
+ public int delete(UserSettings data) {
String sql = "DELETE FROM user_settings2 WHERE id=:id";
MapSqlParameterSource source = new MapSqlParameterSource();
source.addValue("id", data.getId());
diff --git a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
index e6393e9..a53cf73 100644
--- a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
+++ b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
@@ -156,7 +156,7 @@
Attributes.API_AUTHENTICATION);
if (attr.get(Attributes.SCOPES) != null)
- this.getUserData(user, Userdetails2.class);
+ this.getUserData(user, UserDetails.class);
TokenContext context = provider.createUserSession(user, attr);
if (context == null)
@@ -496,16 +496,16 @@
user.setPassword(hash);
try {
entHandler.createAccount(user);
- Userdetails2 details = new Userdetails2(user.getId());
+ UserDetails details = new UserDetails(user.getId());
details.readDefaults(safeMap);
details.checkRequired();
- UserSettings2 settings = new UserSettings2(user.getId());
+ UserSettings settings = new UserSettings(user.getId());
settings.readDefaults(safeMap);
settings.checkRequired();
- UserdataFactory.getDaoInstance(Userdetails2.class).store(details);
- UserdataFactory.getDaoInstance(UserSettings2.class).store(settings);
+ UserdataFactory.getDaoInstance(UserDetails.class).store(details);
+ UserdataFactory.getDaoInstance(UserSettings.class).store(settings);
}catch (KustvaktException e) {
throw new WrappedException(e, StatusCodes.CREATE_ACCOUNT_FAILED,
user.toString());
@@ -642,7 +642,7 @@
username), StatusCodes.PASSWORD_RESET_FAILED, username);
}
- Userdata data = this.getUserData(ident, Userdetails2.class);
+ Userdata data = this.getUserData(ident, UserDetails.class);
KorAPUser user = (KorAPUser) ident;
if (!mail.equals(data.get(Attributes.EMAIL)))
diff --git a/src/main/java/de/ids_mannheim/korap/user/Userdetails2.java b/src/main/java/de/ids_mannheim/korap/user/Userdetails.java
similarity index 87%
rename from src/main/java/de/ids_mannheim/korap/user/Userdetails2.java
rename to src/main/java/de/ids_mannheim/korap/user/Userdetails.java
index 0f40f57..47ca9f7 100644
--- a/src/main/java/de/ids_mannheim/korap/user/Userdetails2.java
+++ b/src/main/java/de/ids_mannheim/korap/user/Userdetails.java
@@ -5,9 +5,9 @@
* @date 22/01/2016
* persistence issue with query request
*/
-public class Userdetails2 extends Userdata {
+public class UserDetails extends Userdata {
- public Userdetails2(Integer userid) {
+ public UserDetails(Integer userid) {
super(userid);
}
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserSettings2.java b/src/main/java/de/ids_mannheim/korap/user/Usersettings.java
similarity index 76%
rename from src/main/java/de/ids_mannheim/korap/user/UserSettings2.java
rename to src/main/java/de/ids_mannheim/korap/user/Usersettings.java
index d6b86a9..dd4190c 100644
--- a/src/main/java/de/ids_mannheim/korap/user/UserSettings2.java
+++ b/src/main/java/de/ids_mannheim/korap/user/Usersettings.java
@@ -4,10 +4,10 @@
* @author hanl
* @date 28/01/2016
*/
-public class UserSettings2 extends Userdata {
+public class UserSettings extends Userdata {
- public UserSettings2(Integer userid) {
+ public UserSettings(Integer userid) {
super(userid);
}
diff --git a/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java b/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
index 1d886ed..9c9cd9c 100644
--- a/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
+++ b/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
@@ -115,7 +115,7 @@
// since this is cached, not very expensive!
User user = controller.getUser(context.getUsername());
Userdata data = controller
- .getUserData(user, UserSettings2.class);
+ .getUserData(user, UserSettings.class);
if ((Boolean) data.get(Attributes.COLLECT_AUDITING_DATA))
customVars.put("username", context.getUsername());
}catch (KustvaktException | UnsupportedOperationException e) {
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
index 86424c5..5199855 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
@@ -116,7 +116,7 @@
try {
User user = controller.authenticate(0, values[0], values[1], attr);
Userdata data = this.controller
- .getUserData(user, Userdetails2.class);
+ .getUserData(user, UserDetails.class);
// todo: is this necessary?
// attr.putAll(data.fields());
context = controller.createTokenContext(user, attr,
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java
index c516364..5e5e2cf 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java
@@ -126,7 +126,7 @@
try {
User user = this.controller.getUser(ctx.getUsername());
Userdata data = this.controller
- .getUserData(user, Userdetails2.class);
+ .getUserData(user, UserDetails.class);
details = data.fields();
Set<String> base_scope = StringUtils.toSet(scopes, " ");
base_scope.retainAll(StringUtils.toSet(scopes));
@@ -199,7 +199,7 @@
try {
user = controller.getUser(c.getUsername());
Userdata data = controller
- .getUserData(user, Userdetails2.class);
+ .getUserData(user, UserDetails.class);
user.addUserData(data);
}catch (KustvaktException e) {
throw KustvaktResponseHandler.throwit(e);
@@ -543,7 +543,7 @@
.authenticate(0, oauthRequest.getUsername(),
oauthRequest.getPassword(), attr);
Userdata data = controller
- .getUserData(user, Userdetails2.class);
+ .getUserData(user, UserDetails.class);
user.addUserData(data);
attr.put(Attributes.CLIENT_SECRET,
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
index 03b19bc..b7a5e5e 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
@@ -213,7 +213,7 @@
Scopes m;
try {
User user = controller.getUser(ctx.getUsername());
- Userdata data = controller.getUserData(user, Userdetails2.class);
+ Userdata data = controller.getUserData(user, UserDetails.class);
Set<String> base_scope = StringUtils.toSet(scopes, " ");
if (scopes != null)
@@ -236,7 +236,7 @@
String result;
try {
User user = controller.getUser(ctx.getUsername());
- Userdata data = controller.getUserData(user, UserSettings2.class);
+ Userdata data = controller.getUserData(user, UserSettings.class);
data.addField(Attributes.USERNAME, ctx.getUsername());
result = data.data();
}catch (KustvaktException e) {
@@ -262,14 +262,14 @@
if (user.isDemo())
return Response.notModified().build();
- Userdata data = controller.getUserData(user, UserSettings2.class);
+ Userdata data = controller.getUserData(user, UserSettings.class);
// todo: check setting only within the scope of user settings permissions; not foundry range. Latter is part of
// frontend which only displays available foundries and
// SecurityManager.findbyId(us.getDefaultConstfoundry(), user, Foundry.class);
// SecurityManager.findbyId(us.getDefaultLemmafoundry(), user, Foundry.class);
// SecurityManager.findbyId(us.getDefaultPOSfoundry(), user, Foundry.class);
// SecurityManager.findbyId(us.getDefaultRelfoundry(), user, Foundry.class);
- Userdata new_data = new UserSettings2(user.getId());
+ Userdata new_data = new UserSettings(user.getId());
new_data.setData(JsonUtils.toJSON(settings));
data.update(new_data);
@@ -292,7 +292,7 @@
String result;
try {
User user = controller.getUser(ctx.getUsername());
- Userdata data = controller.getUserData(user, Userdetails2.class);
+ Userdata data = controller.getUserData(user, UserDetails.class);
data.addField(Attributes.USERNAME, ctx.getUsername());
result = data.data();
}catch (KustvaktException e) {
@@ -318,10 +318,10 @@
if (user.isDemo())
return Response.notModified().build();
- Userdetails2 new_data = new Userdetails2(user.getId());
+ UserDetails new_data = new UserDetails(user.getId());
new_data.setData(JsonUtils.toJSON(wrapper));
- Userdetails2 det = controller.getUserData(user, Userdetails2.class);
+ UserDetails det = controller.getUserData(user, UserDetails.class);
det.update(new_data);
controller.updateUserData(det);
}catch (KustvaktException e) {
diff --git a/src/test/java/UserdataTest.java b/src/test/java/UserdataTest.java
index 1acd921..f8cd1b9 100644
--- a/src/test/java/UserdataTest.java
+++ b/src/test/java/UserdataTest.java
@@ -37,7 +37,7 @@
user.setId(1);
UserDetailsDao dao = new UserDetailsDao(
BeanConfiguration.getBeans().getPersistenceClient());
- Userdetails2 d = new Userdetails2(1);
+ UserDetails d = new UserDetails(1);
d.addField("key_1", "value is a value");
assert dao.store(d) != -1;
}
@@ -48,7 +48,7 @@
user.setId(1);
UserDetailsDao dao = new UserDetailsDao(
BeanConfiguration.getBeans().getPersistenceClient());
- Userdetails2 d = new Userdetails2(1);
+ UserDetails d = new UserDetails(1);
d.addField("key_1", "value is a value");
assert dao.store(d) != -1;
@@ -63,7 +63,7 @@
@Test
public void testDataValidation() {
- Userdata data = new Userdetails2(1);
+ Userdata data = new UserDetails(1);
data.addField(Attributes.COUNTRY, "Germany");
String[] req = data.requiredFields();
@@ -75,7 +75,7 @@
@Test
public void testSettingsValidation() {
- Userdata data = new UserSettings2(1);
+ Userdata data = new UserSettings(1);
data.addField(Attributes.FILE_FORMAT_FOR_EXPORT, "export");
String[] req = data.requiredFields();
@@ -88,7 +88,7 @@
@Test
public void testUserdatafactory() throws KustvaktException {
UserDataDbIface dao = UserdataFactory
- .getDaoInstance(Userdetails2.class);
+ .getDaoInstance(UserDetails.class);
assert UserDetailsDao.class.equals(dao.getClass());
}