Package si.unimb.cot.mgbl.gamemgmt.datamodel

Examples of si.unimb.cot.mgbl.gamemgmt.datamodel.Game


    //reset(null);
  }
 
  public void reset() {
    //call reset() when in use!
    game=new Game();
    allowBrowseForUsers=new ArrayList<User>();
    allowPlayForUsers=new ArrayList<User>();
    allowEditForUsers=new ArrayList<User>();
    allowViewScoresForUsers=new ArrayList<User>();
    allowAllForUsers=new ArrayList<User>();
View Full Code Here


     
      form.reset();
     
      long id=Long.parseLong(req.getParameter("id"));
      GameHiber g=GameDao.findGameHiber(id,session);
      Game g2=GameDao.findGame(id,session);
     
      form.setGame(g2);
     
      ArrayList<GameScoreHiber> gs=null;
      ArrayList<GameScore> gs2=null;
View Full Code Here

    //game logo
    if (entity.equals("game")) {
//      Session hibernateSession=HibernateSessions.startTransactionSilently();
      Session hibernateSession = HibernateSessions.getSessionFactory().openSession();
      try {
        Game gt=GameDao.findGame(id,hibernateSession);
        if (gt.getLogo()==null) {

          try {
            res.setContentType("image/png");
            OutputStream os = res.getOutputStream();
            ImageIO.write(getNullImage(), "png", os);
            os.close();
          } catch (Exception e) {
          }
         
        } else {
          res.setContentType(gt.getLogoType());
          try {
            InputStream in=gt.getLogo().getBinaryStream();
            OutputStream out = res.getOutputStream();
            byte[] buf = new byte[1024];
            int count = 0;
            while((count = in.read(buf)) >= 0) {
              out.write(buf, 0, count);
View Full Code Here

      MessageBean.addSpeedOMeterCheckPoint(req, "point2");
     
 
      long id=Long.parseLong(req.getParameter("id"));
      GameHiber g=GameDao.findGameHiber(id,session);
      Game g2=GameDao.findGame(id,session);
     
      form.setGame(g2);
 

      MessageBean.addSpeedOMeterCheckPoint(req, "point3");
View Full Code Here

     
      long id=Long.parseLong(req.getParameter("id"));
 
      ArrayList<Game> ret=new ArrayList<Game>();
 
      Game g=GameDao.findGame(id,session);
     
      if (SecurityCenter.canIPlayGame(form.getMyUserId(), g, session)) {
        ret.add(g);
      }
 
View Full Code Here

    }
   
   
   
    long id=Long.parseLong(req.getParameter("id"));
    Game g=GameDao.findGame(id,session);
    GameHiber gh=GameDao.findGameHiber(id,session);
    form.setG(g);
   
    AOGGameHiber ag=AOGGameDao.findGameHiberForGame(g.getId(), session);
    //if null is returned: game has not been authored => create instance!
    if (ag==null) {
      ag=new AOGGameHiber();
      ag.setGame(gh);
      ag.setHalfJokerNumber(0);
      ag.setHintJokerNumber(0);
      ag.setPauseJokerNumber(0);
      ag.setRepublishNeeded(true);
      ag.setServiceId("");
      ag.setAuthKey("");
      AOGGameDao.persistAOGGameHiber(ag, session);
    }
   
    form.setAogGame(ag);
   
    //ACTIONS SWITCH
   
    //hide level
    if (req.getParameter("hideLevelContnt")!=null) {
      form.getHidenLevels().add(new Long(req.getParameter("hideLevelContnt")));
      return am.findForward("ok");
    }

    //show level
    if (req.getParameter("showLevelContnt")!=null) {
      form.getHidenLevels().remove(new Long(req.getParameter("showLevelContnt")));
      return am.findForward("ok");
    }
   
    //delete picture
    if (req.getParameter("deletePicture")!=null) {
      return defaultMethodDeletePicture(am, af, req, res, g, gh, ag);
    }

    //change the game
    if (req.getParameter("change")!=null) {
      ActionForward r=defaultMethodChangeGame(am, af, req, res, g, gh, ag);
      if (r!=null) return r;
    }
   
    //insert new level
    if ((req.getParameter("change")!=null)&&(req.getParameter("newLevelSubmit")!=null))
      return defaultMethodInsertLevel(am, af, req, res, g, gh, ag);

    //insert new picture
    if ((req.getParameter("change")!=null)&&(req.getParameter("newPictureSubmit")!=null))
      return defaultMethodInsertPicture(am, af, req, res, g, gh, ag);
     
    //publish game - create JAR
   
    //this functionality is now implemented at downloading game - XML holds user ID...
   
    //if ((req.getParameter("change")!=null)&&(req.getParameter("republishGameSubmit")!=null))
    //  return defaultMethodCreateJar(am, af, req, res, g, gh, ag);
   
    //delete level
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("deleteLevelSubmit")!=null))
      return defaultMethodDeleteLevel(am, af, req, res, g, gh, ag);
     
    //delete card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("deleteCardSubmit")!=null))
      return defaultMethodDeleteCard(am, af, req, res, g, gh, ag);

    //move card up
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("movecardUp")!=null))
      return defaultMethodMoveCardUpCard(am, af, req, res, g, gh, ag);
 
    //move card down
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("movecardDown")!=null))
      return defaultMethodMoveCardDownCard(am, af, req, res, g, gh, ag);

    //move level up
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("movelevelUp")!=null))
      return defaultMethodMoveLevelUp(am, af, req, res, g, gh, ag);
 
    //move level down
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("movelevelDown")!=null))
      return defaultMethodMoveLevelDown(am, af, req, res, g, gh, ag);
   
   
    //new info card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelInfoSubmit")!=null))
      defaultMethodCreateInfoCard(am, af, req, res, g, gh, ag);
     
    //new intro card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelIntroSubmit")!=null))
      defaultMethodCreateIntroCard(am, af, req, res, g, gh, ag);
     
    //new question card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelQuestionSubmit")!=null))
      defaultMethodCreateQuestionCard(am, af, req, res, g, gh, ag);

    //new order-question card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelOQuestionSubmit")!=null))
      defaultMethodCreateOQuestionCard(am, af, req, res, g, gh, ag);

    //new self-assessment card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelSASubmit")!=null))
      defaultMethodCreateSACard(am, af, req, res, g, gh, ag);
   
    //new image card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelImageSubmit")!=null))
      defaultMethodCreateImageCard(am, af, req, res, g, gh, ag);

    //new imagetext card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelImageTextSubmit")!=null))
      defaultMethodCreateImageTextCard(am, af, req, res, g, gh, ag);

    //new textfree card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelTextFreeSubmit")!=null))
      defaultMethodCreateTxtFreeCard(am, af, req, res, g, gh, ag);

    //new reward card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelRewardSubmit")!=null))
      defaultMethodCreateRewardCard(am, af, req, res, g, gh, ag);
   
    //new simulation card
    if ((req.getParameter("changeLevel")!=null)&&(req.getParameter("newLevelSimulationSubmit")!=null))
      defaultMethodCreateSimulationCard(am, af, req, res, g, gh, ag);
   
   
    form.setHalfJokerNumber(ag.getHalfJokerNumber());
    form.setPauseJokerNumber(ag.getPauseJokerNumber());
    form.setHintJokerNumber(ag.getHintJokerNumber());
    form.setMaxScores(g.getMaksimumScore());
   
    form.setServiceId(ag.getServiceId());
    form.setAuthKey(ag.getAuthKey());

    form.setOrderedLevels(AOGGameLevelDao.getOrderedLevelsForGame(ag.getId(),session));
View Full Code Here

   
    form.setMyUserId(webUser.getId());
   
    long id=Long.parseLong(req.getParameter("id"));
    GameHiber g=GameDao.findGameHiber(id,session);
    Game g2=GameDao.findGame(id,session);

    MessageBean.addSpeedOMeterCheckPoint(req, "point2");
   
    form.setGame(g2);
   
    if (!SecurityCenter.canIDefineSecurityForGame(webUser.getId(), form.getGame())) {
      MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
      form.reset();
      return am.findForward("error");
    }
   
    //if needeed invalidate cache
    if (req.getParameter("invalidateCache")!=null) {
      SecurityCenter.invalidateCache();
      searchGroupsCache=null;
      searchUserSetsCache=null;
      searchUsersCache=null;
      MessageBean.setMyMessage(req, ("Security cache invalidated."));
    }
   
    //do the update, if needed - allow
    MessageBean.addSpeedOMeterCheckPoint(req, "point3");
    boolean changed=false;
   
    if (req.getParameter("AllowBrowseUser")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,Long.parseLong(req.getParameter("AllowBrowseUser")),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("AllowPlayUser")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,Long.parseLong(req.getParameter("AllowPlayUser")),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("AllowEditUser")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,Long.parseLong(req.getParameter("AllowEditUser")),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("AllowViewScoresUser")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,Long.parseLong(req.getParameter("AllowViewScoresUser")),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("AllowAllUser")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,Long.parseLong(req.getParameter("AllowAllUser")),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}

    if (req.getParameter("AllowBrowseGroup")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,Long.parseLong(req.getParameter("AllowBrowseGroup")),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("AllowPlayGroup")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,Long.parseLong(req.getParameter("AllowPlayGroup")),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("AllowEditGroup")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,Long.parseLong(req.getParameter("AllowEditGroup")),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("AllowViewScoresGroup")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,Long.parseLong(req.getParameter("AllowViewScoresGroup")),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("AllowAllGroup")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,Long.parseLong(req.getParameter("AllowAllGroup")),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}

    if (req.getParameter("AllowBrowseUserSet")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,Long.parseLong(req.getParameter("AllowBrowseUserSet")),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("AllowPlayUserSet")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,Long.parseLong(req.getParameter("AllowPlayUserSet")),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("AllowEditUserSet")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,Long.parseLong(req.getParameter("AllowEditUserSet")),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("AllowViewScoresUserSet")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,Long.parseLong(req.getParameter("AllowViewScoresUserSet")),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("AllowAllUserSet")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,Long.parseLong(req.getParameter("AllowAllUserSet")),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
   
    //do the update, if needed - revoke
    if (req.getParameter("RevokeSubmitPlayUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowPlayForUsersSelected(),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("RevokeSubmitPlayGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowPlayForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("RevokeSubmitPlaySet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowPlayForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point7");

    if (req.getParameter("RevokeSubmitEditUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowEditForUsersSelected(),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("RevokeSubmitEditGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowEditForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("RevokeSubmitEditSet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowEditForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point8");

    if (req.getParameter("RevokeSubmitBrowseUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowBrowseForUsersSelected(),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("RevokeSubmitBrowseGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowBrowseForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("RevokeSubmitBrowseSet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowBrowseForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point9");

    if (req.getParameter("RevokeSubmitAllUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowAllForUsersSelected(),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
    if (req.getParameter("RevokeSubmitAllGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowAllForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
    if (req.getParameter("RevokeSubmitAllSet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowAllForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point10");

    if (req.getParameter("RevokeSubmitViewScoresUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowViewScoresForUsersSelected(),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("RevokeSubmitViewScoresGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowViewScoresForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("RevokeSubmitViewScoresSet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowViewScoresForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
   
    if (changed) {
      //update the security summary for the game
      //for faster working!
     
      List<GameSecurityHiber> gss=null;
      StringBuffer summary=new StringBuffer();
     
      gss=GameSecurityDao.getGameSecurityForGameAllowAll(g.getId(),session);
      if (gss.size()>0) {
        summary.append("A(");
        boolean first=true;
       
        MessageBean.addSpeedOMeterCheckPoint(req, "point11");

        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;

          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
       
        MessageBean.addSpeedOMeterCheckPoint(req, "point12");

       
        summary.append(") ");
      }
     
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point13");


      gss=GameSecurityDao.getGameSecurityForGameAllowEdit(g.getId(),session);
      if (gss.size()>0) {
        summary.append("E(");
        boolean first=true;
        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;

          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
        if (first) { first=false;} else {summary.append(", "); }
        summary.append(") ");
      }

     
      MessageBean.addSpeedOMeterCheckPoint(req, "point14");


      gss=GameSecurityDao.getGameSecurityForGameAllowPlay(g.getId(),session);
      if (gss.size()>0) {
        summary.append("P(");
        boolean first=true;
        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;
          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
        summary.append(") ");
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point15");

      gss=GameSecurityDao.getGameSecurityForGameAllowBrowse(g.getId(),session);
      if (gss.size()>0) {
        summary.append("B(");
        boolean first=true;
        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;

          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
        summary.append(") ");
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point16");

      gss=GameSecurityDao.getGameSecurityForGameAllowViewScores(g.getId(),session);
      if (gss.size()>0) {
        summary.append("VS(");
        boolean first=true;
        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;

          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
        summary.append(") ");
      }

      g.setSecuritySummary(summary.toString());
      GameDao.updateGame(g,session);
    }
   
    //end updating summary
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point17");

    //reset the view
    form.reset();
    MessageBean.addSpeedOMeterCheckPoint(req, "point18a");
    if (req.getParameter("id")!=null) {
      //display security for game

      Game toSet=Game.asGameObject(g);
      toSet.setGameType(g2.getGameType());
      form.setGame(toSet);

      List<GameSecurityHiber> all;
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point18");
View Full Code Here

   
    form.setMyUserId(webUser.getId());
   
    long id=Long.parseLong(req.getParameter("id"));
    GameHiber g=GameDao.findGameHiber(id,session);
    Game g2=GameDao.findGame(id,session);

    MessageBean.addSpeedOMeterCheckPoint(req, "point2");
   
    form.setGame(g2);
   
    if (!SecurityCenter.canIDefineSecurityForGame(webUser.getId(), form.getGame())) {
      MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
      form.reset(session);
      return am.findForward("error");
    }
   
    //if needeed invalidate cache
    if (req.getParameter("invalidateCache")!=null) {
      SecurityCenter.invalidateCache();
      MessageBean.setMyMessage(req, ("Security cache invalidated."));
    }
   
    //do the update, if needed - allow
    MessageBean.addSpeedOMeterCheckPoint(req, "point3");

    boolean changed=false;
    if (req.getParameter("AllowBrowseSubmitUsers")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getSelectedUser(),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("AllowPlaySubmitUsers")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getSelectedUser(),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("AllowEditSubmitUsers")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getSelectedUser(),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("AllowViewScoresSubmitUsers")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getSelectedUser(),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("AllowAllSubmitUsers")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getSelectedUser(),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point4");

    if (req.getParameter("AllowBrowseSubmitGroups")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getSelectedGroup(),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("AllowPlaySubmitGroups")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getSelectedGroup(),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("AllowEditSubmitGroups")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getSelectedGroup(),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("AllowViewScoresSubmitGroups")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getSelectedGroup(),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("AllowAllSubmitGroups")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getSelectedGroup(),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point5");

    if (req.getParameter("AllowBrowseSubmitSets")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getSelectedUserSet(),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("AllowPlaySubmitSets")!=null) { changed=true;  GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getSelectedUserSet(),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("AllowEditSubmitSets")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getSelectedUserSet(),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("AllowViewScoresSubmitSets")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getSelectedUserSet(),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("AllowAllSubmitSets")!=null)  { changed=true; GameSecurityDao.allow(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getSelectedUserSet(),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point6");

    //do the update, if needed - revoke
    if (req.getParameter("RevokeSubmitPlayUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowPlayForUsersSelected(),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("RevokeSubmitPlayGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowPlayForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
    if (req.getParameter("RevokeSubmitPlaySet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowPlayForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_PLAY,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point7");

    if (req.getParameter("RevokeSubmitEditUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowEditForUsersSelected(),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("RevokeSubmitEditGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowEditForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
    if (req.getParameter("RevokeSubmitEditSet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowEditForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_EDIT,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point8");

    if (req.getParameter("RevokeSubmitBrowseUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowBrowseForUsersSelected(),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("RevokeSubmitBrowseGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowBrowseForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
    if (req.getParameter("RevokeSubmitBrowseSet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowBrowseForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_BROWSE,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point9");

    if (req.getParameter("RevokeSubmitAllUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowAllForUsersSelected(),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
    if (req.getParameter("RevokeSubmitAllGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowAllForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
    if (req.getParameter("RevokeSubmitAllSet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowAllForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_ALL,req,session);}
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point10");

    if (req.getParameter("RevokeSubmitViewScoresUser")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_USER,form.getAllowViewScoresForUsersSelected(),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("RevokeSubmitViewScoresGroup")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_ROLE,form.getAllowViewScoresForUserGroupsSelected(),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
    if (req.getParameter("RevokeSubmitViewScoresSet")!=null)   { changed=true; GameSecurityDao.revoke(form.getGame(),GameSecurity.TARGET_TYPE_SET,form.getAllowViewScoresForUserSetsSelected(),GameSecurityDao.SECURITY_TYPE_VIEW_SCORES,req,session);}
   
    if (changed) {
      //update the security summary for the game
      //for faster working!
     
      List<GameSecurityHiber> gss=null;
      StringBuffer summary=new StringBuffer();
     
      gss=GameSecurityDao.getGameSecurityForGameAllowAll(g.getId(),session);
      if (gss.size()>0) {
        summary.append("A(");
        boolean first=true;
       
        MessageBean.addSpeedOMeterCheckPoint(req, "point11");

        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;

          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
       
        MessageBean.addSpeedOMeterCheckPoint(req, "point12");

       
        summary.append(") ");
      }
     
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point13");


      gss=GameSecurityDao.getGameSecurityForGameAllowEdit(g.getId(),session);
      if (gss.size()>0) {
        summary.append("E(");
        boolean first=true;
        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;

          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
        if (first) { first=false;} else {summary.append(", "); }
        summary.append(") ");
      }

     
      MessageBean.addSpeedOMeterCheckPoint(req, "point14");


      gss=GameSecurityDao.getGameSecurityForGameAllowPlay(g.getId(),session);
      if (gss.size()>0) {
        summary.append("P(");
        boolean first=true;
        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;
          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
        summary.append(") ");
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point15");

      gss=GameSecurityDao.getGameSecurityForGameAllowBrowse(g.getId(),session);
      if (gss.size()>0) {
        summary.append("B(");
        boolean first=true;
        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;

          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
        summary.append(") ");
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point16");

      gss=GameSecurityDao.getGameSecurityForGameAllowViewScores(g.getId(),session);
      if (gss.size()>0) {
        summary.append("VS(");
        boolean first=true;
        for (GameSecurityHiber security : gss) {
          String name="";
          switch (security.getTargetType()) {
            case GameSecurity.TARGET_TYPE_ROLE: name=UserRoleDao.findRole(security.getTargetId(),session).getRolename(); break;
            case GameSecurity.TARGET_TYPE_SET: name=UserSetDao.findUserSet(security.getTargetId(),session).getName(); break;
            case GameSecurity.TARGET_TYPE_USER:
              User u=UserDao.findUser(security.getTargetId(),session);
              name=u.getUsername();
              if ((name==null)||(name.equals(""))) name=u.getMsisdn()+"";
               
            break;

          }
          if (first) { first=false;} else {summary.append(", "); }
          summary.append(name);
        }
        summary.append(") ");
      }

      g.setSecuritySummary(summary.toString());
      GameDao.updateGame(g,session);
    }
   
    MessageBean.addSpeedOMeterCheckPoint(req, "point17");

    //reset the view
    form.reset(session);
    MessageBean.addSpeedOMeterCheckPoint(req, "point18a");
    if (req.getParameter("id")!=null) {
      //display security for game

      Game toSet=Game.asGameObject(g);
      toSet.setGameType(g2.getGameType());
      form.setGame(toSet);

      List<GameSecurityHiber> all;
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point18");
View Full Code Here

TOP

Related Classes of si.unimb.cot.mgbl.gamemgmt.datamodel.Game

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.