From 113c546a12919b433ce2ef13c4dbd0140e444c99 Mon Sep 17 00:00:00 2001 From: Christoph Thelen <christoph.thelen@mni.thm.de> Date: Thu, 19 Feb 2015 16:49:44 +0100 Subject: [PATCH] Remove deprecated methods --- .../java/de/thm/arsnova/dao/CouchDBDao.java | 67 +------------------ .../java/de/thm/arsnova/dao/IDatabaseDao.java | 35 ---------- .../ApplicationPermissionEvaluator.java | 4 +- .../de/thm/arsnova/dao/StubDatabaseDao.java | 32 --------- 4 files changed, 3 insertions(+), 135 deletions(-) diff --git a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java index f78c83a3..57aa2c48 100644 --- a/src/main/java/de/thm/arsnova/dao/CouchDBDao.java +++ b/src/main/java/de/thm/arsnova/dao/CouchDBDao.java @@ -107,21 +107,6 @@ public class CouchDBDao implements IDatabaseDao { sessionService = service; } - /** - * @deprecated Use getSessionFromKeyword instead. The database should not throw HTTP exceptions. - * Additionally, the caching mechanism won't work here because it is calling inside the same class. - */ - @Deprecated - @Override - public Session getSession(final String keyword) { - final Session result = getSessionFromKeyword(keyword); - if (result != null) { - return result; - } - - throw new NotFoundException(); - } - @Override public List<Session> getMySessions(final User user) { final NovaView view = new NovaView("session/by_creator"); @@ -457,7 +442,7 @@ public class CouchDBDao implements IDatabaseDao { return null; } // session caching is done by loading the created session - return getSession(sessionDocument.getString("keyword")); + return getSessionFromKeyword(sessionDocument.getString("keyword")); } @Override @@ -1382,23 +1367,6 @@ public class CouchDBDao implements IDatabaseDao { } } - /** - * @deprecated The decision to load data depending on the user should be made by a service class, not this - * database class. Please use getLectureQuestionsForUsers or getLectureQuestionsForTeachers as this will enable - * caching. - */ - @Deprecated - @Override - public List<Question> getLectureQuestions(final User user, final Session session) { - String viewName; - if (session.isCreator(user)) { - viewName = "skill_question/lecture_question_by_session"; - } else { - viewName = "skill_question/lecture_question_by_session_for_all"; - } - return getQuestions(new NovaView(viewName), session); - } - @Cacheable("lecturequestions") @Override public List<Question> getLectureQuestionsForUsers(final Session session) { @@ -1412,22 +1380,6 @@ public class CouchDBDao implements IDatabaseDao { return getQuestions(new NovaView(viewName), session); } - /** - * @deprecated The decision to load data depending on the user should be made by a service class, not this - * database class. Please use getFlashcardsForUsers or getFlashcardsForTeachers as this will enable caching. - */ - @Deprecated - @Override - public List<Question> getFlashcards(final User user, final Session session) { - String viewName; - if (session.isCreator(user)) { - viewName = "skill_question/flashcard_by_session"; - } else { - viewName = "skill_question/flashcard_by_session_for_all"; - } - return getQuestions(new NovaView(viewName), session); - } - @Cacheable("flashcardquestions") @Override public List<Question> getFlashcardsForUsers(final Session session) { @@ -1441,23 +1393,6 @@ public class CouchDBDao implements IDatabaseDao { return getQuestions(new NovaView(viewName), session); } - /** - * @deprecated The decision to load data depending on the user should be made by a service class, not this - * database class. Please use getPreparationQuestionsForUsers or getPreparationQuestionsForTeachers as this will enable - * caching. - */ - @Deprecated - @Override - public List<Question> getPreparationQuestions(final User user, final Session session) { - String viewName; - if (session.isCreator(user)) { - viewName = "skill_question/preparation_question_by_session"; - } else { - viewName = "skill_question/preparation_question_by_session_for_all"; - } - return getQuestions(new NovaView(viewName), session); - } - @Cacheable("preparationquestions") @Override public List<Question> getPreparationQuestionsForUsers(final Session session) { diff --git a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java index bf328a62..6d0fd41c 100644 --- a/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java +++ b/src/main/java/de/thm/arsnova/dao/IDatabaseDao.java @@ -35,14 +35,6 @@ import de.thm.arsnova.entities.transport.ImportExportSession; public interface IDatabaseDao { Session getSessionFromKeyword(String keyword); - /** - * @deprecated Use getSessionFromKeyword - * @param keyword - * @return - */ - @Deprecated - Session getSession(String keyword); - List<Session> getMySessions(User user); List<Session> getPublicPoolSessions(); @@ -148,41 +140,14 @@ public interface IDatabaseDao { void deleteSession(Session session); - /** - * @deprecated Use getLectureQuestionsForUsers or getLectureQuestionsForTeachers - * @param user - * @param session - * @return - */ - @Deprecated - List<Question> getLectureQuestions(User user, Session session); - List<Question> getLectureQuestionsForUsers(Session session); List<Question> getLectureQuestionsForTeachers(Session session); - /** - * @deprecated Use getFlashcardsForUsers or getFlashcardsForTeachers - * @param user - * @param session - * @return - */ - @Deprecated - List<Question> getFlashcards(User user, Session session); - List<Question> getFlashcardsForUsers(Session session); List<Question> getFlashcardsForTeachers(Session session); - /** - * @deprecated Use getPreparationQuestionsForUsers or getPreparationQuestionsForTeachers - * @param user - * @param session - * @return - */ - @Deprecated - List<Question> getPreparationQuestions(User user, Session session); - List<Question> getPreparationQuestionsForUsers(Session session); List<Question> getPreparationQuestionsForTeachers(Session session); diff --git a/src/main/java/de/thm/arsnova/security/ApplicationPermissionEvaluator.java b/src/main/java/de/thm/arsnova/security/ApplicationPermissionEvaluator.java index 559c9297..167d1dd0 100644 --- a/src/main/java/de/thm/arsnova/security/ApplicationPermissionEvaluator.java +++ b/src/main/java/de/thm/arsnova/security/ApplicationPermissionEvaluator.java @@ -91,9 +91,9 @@ public class ApplicationPermissionEvaluator implements PermissionEvaluator { final Object permission ) { if (permission instanceof String && (permission.equals("owner") || permission.equals("write"))) { - return dao.getSession(targetId.toString()).getCreator().equals(username); + return dao.getSessionFromKeyword(targetId.toString()).getCreator().equals(username); } else if (permission instanceof String && permission.equals("read")) { - return dao.getSession(targetId.toString()).isActive(); + return dao.getSessionFromKeyword(targetId.toString()).isActive(); } return false; } diff --git a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java index bdb69adf..2ec9225d 100644 --- a/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java +++ b/src/test/java/de/thm/arsnova/dao/StubDatabaseDao.java @@ -36,7 +36,6 @@ import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.SessionInfo; import de.thm.arsnova.entities.User; import de.thm.arsnova.entities.transport.ImportExportSession; -import de.thm.arsnova.exceptions.ForbiddenException; import de.thm.arsnova.exceptions.NoContentException; import de.thm.arsnova.exceptions.NotFoundException; @@ -107,19 +106,6 @@ public class StubDatabaseDao implements IDatabaseDao { stubQuestions.put("12345678", questions); } - @Override - public Session getSession(String keyword) { - // Magic keyword for forbidden session - if (keyword.equals("99999999")) - throw new ForbiddenException(); - - Session session = stubSessions.get(keyword); - if (session == null) - throw new NotFoundException(); - - return session; - } - @Override public Session saveSession(User user, Session session) { stubSessions.put(session.getKeyword(), session); @@ -390,24 +376,6 @@ public class StubDatabaseDao implements IDatabaseDao { } - @Override - public List<Question> getLectureQuestions(User user, Session session) { - // TODO Auto-generated method stub - return null; - } - - @Override - public List<Question> getFlashcards(User user, Session session) { - // TODO Auto-generated method stub - return null; - } - - @Override - public List<Question> getPreparationQuestions(User user, Session session) { - // TODO Auto-generated method stub - return null; - } - @Override public int getLectureQuestionCount(Session session) { // TODO Auto-generated method stub -- GitLab