diff --git a/reqbaz/src/main/java/de/rwth/dbis/acis/bazaar/service/BazaarService.java b/reqbaz/src/main/java/de/rwth/dbis/acis/bazaar/service/BazaarService.java index fd88dfa..179141c 100755 --- a/reqbaz/src/main/java/de/rwth/dbis/acis/bazaar/service/BazaarService.java +++ b/reqbaz/src/main/java/de/rwth/dbis/acis/bazaar/service/BazaarService.java @@ -116,6 +116,7 @@ public class BazaarService extends RESTService { protected String gfUsername; protected String gfPassword; protected String gfGameId; + protected String gfNamespace; public BazaarService() throws Exception { setFieldValues(); @@ -174,7 +175,7 @@ public BazaarService() throws Exception { tweetDispatcher = new TweetDispatcher(this, twitterApiKey, twitterApiKeySecret, twitterClientId, twitterClientSecret); new WeeklyNewProjectsTweetTask(this).schedule(timer); - gamificationManager = new GamificationManager(gfBaseUrl, gfUsername, gfPassword, gfGameId); + gamificationManager = new GamificationManager(gfBaseUrl, gfUsername, gfPassword, gfGameId, gfNamespace); notificationDispatcher.setBazaarService(this); } diff --git a/reqbaz/src/main/java/de/rwth/dbis/acis/bazaar/service/gamification/GamificationManager.java b/reqbaz/src/main/java/de/rwth/dbis/acis/bazaar/service/gamification/GamificationManager.java index dc5e426..88137ea 100644 --- a/reqbaz/src/main/java/de/rwth/dbis/acis/bazaar/service/gamification/GamificationManager.java +++ b/reqbaz/src/main/java/de/rwth/dbis/acis/bazaar/service/gamification/GamificationManager.java @@ -12,6 +12,8 @@ public class GamificationManager { private final GamificationFrameworkClient gfClient; private final String gfGameId; + private final String gfNamespace; + /** * Notifications returned by the framework during request processing. @@ -20,10 +22,11 @@ public class GamificationManager { */ private Map>> notificationCache = new HashMap<>(); - public GamificationManager(String gfBaseUrl, String gfUsername, String gfPassword, String gfGameId) { + public GamificationManager(String gfBaseUrl, String gfUsername, String gfPassword, String gfGameId, String gfNamespace) { this.gfGameId = gfGameId; + this.gfNamespace = gfNamespace; - if (StringUtils.isAnyBlank(gfBaseUrl, gfUsername, gfPassword, gfGameId)) { + if (StringUtils.isAnyBlank(gfBaseUrl, gfUsername, gfPassword, gfGameId, gfNamespace)) { logger.warning("Gamification functionality cannot be used without GamificationFramework credentials!"); gfClient = null; } else { @@ -38,8 +41,8 @@ public void initializeUser(Integer userId, boolean firstLogin) { } try { - gfClient.registerUser(gfGameId, "reqbaz_" + userId); - gfClient.addMemberToGame(gfGameId, "reqbaz_" + userId); + gfClient.registerUser(gfGameId, gfNamespace + userId); + gfClient.addMemberToGame(gfGameId, gfNamespace + userId); if (firstLogin) { triggerFirstLoginAction((userId)); } @@ -50,35 +53,35 @@ public void initializeUser(Integer userId, boolean firstLogin) { } public void triggerCreateRequirementAction(Integer userId) { - triggerActionIfGamificationAvailable(Actions.CREATE_REQUIREMENT, userId, "reqbaz_" + userId); + triggerActionIfGamificationAvailable(Actions.CREATE_REQUIREMENT, userId, gfNamespace + userId); } public void triggerCompleteRequirementAction(Integer userId) { - triggerActionIfGamificationAvailable(Actions.COMPLETE_REQUIREMENT, userId, "reqbaz_" + userId); + triggerActionIfGamificationAvailable(Actions.COMPLETE_REQUIREMENT, userId, gfNamespace + userId); } public void triggerCreateProjectAction(Integer userId) { - triggerActionIfGamificationAvailable(Actions.CREATE_PROJECT, userId, "reqbaz_" + userId); + triggerActionIfGamificationAvailable(Actions.CREATE_PROJECT, userId, gfNamespace + userId); } public void triggerCreateCommentAction(Integer userId) { - triggerActionIfGamificationAvailable(Actions.CREATE_COMMENT, userId, "reqbaz_" + userId); + triggerActionIfGamificationAvailable(Actions.CREATE_COMMENT, userId, gfNamespace + userId); } public void triggerVoteAction(Integer userId) { - triggerActionIfGamificationAvailable(Actions.VOTE_REQUIREMENT, userId, "reqbaz_" + userId); + triggerActionIfGamificationAvailable(Actions.VOTE_REQUIREMENT, userId, gfNamespace + userId); } public void triggerDevelopAction(Integer userId) { - triggerActionIfGamificationAvailable(Actions.DEVELOP_REQUIREMENT, userId, "reqbaz_" + userId); + triggerActionIfGamificationAvailable(Actions.DEVELOP_REQUIREMENT, userId, gfNamespace + userId); } public void triggerFollowAction(Integer userId) { - triggerActionIfGamificationAvailable(Actions.FOLLOW_REQUIREMENT, userId, "reqbaz_" + userId); + triggerActionIfGamificationAvailable(Actions.FOLLOW_REQUIREMENT, userId, gfNamespace + userId); } public void triggerFirstLoginAction(Integer userId) { - triggerActionIfGamificationAvailable(Actions.FIRST_LOGIN, userId, "reqbaz_" + userId); + triggerActionIfGamificationAvailable(Actions.FIRST_LOGIN, userId, gfNamespace + userId); } private void triggerActionIfGamificationAvailable(String actionId, Integer userId, String gamificationUser) { @@ -112,9 +115,9 @@ private void storeUserNotifications(Integer userId, List> no public List> getUserBadges(Integer userId) { try { - return gfClient.getEarnedBadges(gfGameId, "reqbaz_" + userId); + return gfClient.getEarnedBadges(gfGameId, gfNamespace + userId); } catch (IOException e) { - logger.warning("Failed to get badges for user " + "reqbaz_" + userId); + logger.warning("Failed to get badges for user " + gfNamespace + userId); e.printStackTrace(); return Collections.emptyList(); } @@ -122,10 +125,10 @@ public List> getUserBadges(Integer userId) { public Map getUserStatus(Integer userId) { try { - Map status = gfClient.getMemberStatus(gfGameId, "reqbaz_" + userId); + Map status = gfClient.getMemberStatus(gfGameId, gfNamespace + userId); return status; } catch (IOException e) { - logger.warning("Failed to get status for user " + "reqbaz_" + userId); + logger.warning("Failed to get status for user " + gfNamespace + userId); e.printStackTrace(); return Collections.emptyMap(); }