Examples of GameHiber


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

   
   
   
    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) {
View Full Code Here

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

      ApplyLabelToGameForm form=(ApplyLabelToGameForm)af;
 
      //Prepare method
      form.reset();
      form.setMyUserId(webUser.getId());
      GameHiber g=GameDao.findGameHiber(Long.parseLong(req.getParameter("game")), session);
      form.setLabels(GameLabelDao.getAllLabelsToBeAppliedToGame(g, webUser.getId(), session));
     
      return am.findForward("showForm");
    } finally {
      this.session.close();
View Full Code Here

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

        form.setTemplateToUse(Long.parseLong(req.getParameter("template")));
      }
     
      if (req.getParameter("id")!=null) {
        long id=Long.parseLong(req.getParameter("id"));
        GameHiber g=GameDao.findGameHiber(id,session);
       
        if (SecurityCenter.canIEditGame(webUser.getId(), g.getId(),session)) {
          form.setName(g.getName());
          form.setDescription(g.getDescription());
          form.setTemplateToUse(g.getBasedOnTemplate().getId());
          form.setModifyMe(true);
          form.setModifyId(id);
          form.setInstructions(g.getInstructions());
          //form.setTemplates(GameTemplateDao.getAllGameTemplates()); - in reset!
         
          form.setDC_contributor(g.getDC_contributor());
          form.setDC_coverage(g.getDC_coverage());
          form.setDC_creator(g.getDC_creator());
          form.setDC_date(g.getDC_date());
          form.setDC_description(g.getDC_description());
          form.setDC_format(g.getDC_format());
          form.setDC_identifier(g.getDC_identifier());
          form.setDC_language(g.getDC_language());
          form.setDC_publisher(g.getDC_publisher());
          form.setDC_relation(g.getDC_relation());
          form.setDC_rights(g.getDC_rights());
          form.setDC_source(g.getDC_source());
          form.setDC_subject(g.getDC_subject());
          form.setDC_title(g.getDC_title());
          form.setDC_type(g.getDC_type());

          form.setDC_contributor_manual(g.getDC_contributor_manual());
          form.setDC_coverage_manual(g.getDC_coverage_manual());
          form.setDC_creator_manual(g.getDC_creator_manual());
          form.setDC_date_manual(g.getDC_date_manual());
          form.setDC_description_manual(g.getDC_description_manual());
          form.setDC_format_manual(g.getDC_format_manual());
          form.setDC_identifier_manual(g.getDC_identifier_manual());
          form.setDC_language_manual(g.getDC_language_manual());
          form.setDC_publisher_manual(g.getDC_publisher_manual());
          form.setDC_relation_manual(g.getDC_relation_manual());
          form.setDC_rights_manual(g.getDC_rights_manual());
          form.setDC_source_manual(g.getDC_source_manual());
          form.setDC_subject_manual(g.getDC_subject_manual());
          form.setDC_title_manual(g.getDC_title_manual());
          form.setDC_type_manual(g.getDC_type_manual());         
         
        } else {
          MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
        }
      }
 
      if (req.getParameter("like")!=null) {
        //"duplicate" the game
        long id=Long.parseLong(req.getParameter("like"));
        GameHiber g=GameDao.findGameHiber(id,session);
       
        if (SecurityCenter.canICopyGame(webUser.getId(), g)) {
          form.setName(g.getName());
          form.setDescription(g.getDescription());
          form.setTemplateToUse(g.getBasedOnTemplate().getId());
          form.setLikeMe(true);
          form.setLikeId(id);
          form.setInstructions(g.getInstructions());
          //form.setTemplates(GameTemplateDao.getAllGameTemplates()); - in reset!
        } else {
          MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
        }
      }
View Full Code Here

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

    MessageBean.addSpeedOMeterCheckPoint(req, "point1");
   
    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");

      //allow browse
      all=GameSecurityDao.getGameSecurityForGameAllowBrowse(g.getId(),session);
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point19a");
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowBrowseForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowBrowseForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowBrowseForUsers().add(UserDao.findUser(security.getTargetId(),session));
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point19");

      //allow play
      all=GameSecurityDao.getGameSecurityForGameAllowPlay(g.getId(),session);
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowPlayForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowPlayForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowPlayForUsers().add(UserDao.findUser(security.getTargetId(),session));
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point20");

      //allow edit
      all=GameSecurityDao.getGameSecurityForGameAllowEdit(g.getId(),session);
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowEditForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowEditForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowEditForUsers().add(UserDao.findUser(security.getTargetId(),session));
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point21");

      //allow view scores
      all=GameSecurityDao.getGameSecurityForGameAllowViewScores(g.getId(),session);
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowViewScoresForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowViewScoresForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowViewScoresForUsers().add(UserDao.findUser(security.getTargetId(),session));
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point22");

      //allow all
      all=GameSecurityDao.getGameSecurityForGameAllowAll(g.getId(),session);
      MessageBean.addSpeedOMeterCheckPoint(req, "point23a");
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowAllForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowAllForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowAllForUsers().add(UserDao.findUser(security.getTargetId(),session));
View Full Code Here

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

    if (req.getParameter("cancelChangesSubmit")!=null) {
      form.reset();
      return am.findForward("cancel");
    }

    GameHiber likeGame=null;
    if (form.isLikeMe()) {
      likeGame=GameDao.findGameHiber(form.getLikeId(),session);
      if (!SecurityCenter.canICopyGame(webUser.getId(), likeGame)) {
        MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
        form.reset();
        return am.findForward("ok");
      }
    }
   
    GameHiber g=null;
    if (form.isModifyMe()) {
      //modify existing
      g=GameDao.findGameHiber(form.getModifyId(),session);
      if (!SecurityCenter.canIEditGame(webUser.getId(), g.getId(),session)) {
        MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
        form.reset();
        return am.findForward("ok");
      }
    } else {
      //add new
      g=new GameHiber();
      g.setCreator(webUser.getId());
      if (!SecurityCenter.canICreateGame(webUser.getId(),session)) {
        MessageBean.setMyMessage(req, ("Error: Insufficient privileges."));
        form.reset();
        return am.findForward("ok");
      }
    }
   
    g.setName(form.getName());
    g.setDescription(form.getDescription());
    g.setInstructions(form.getInstructions());
   
    g.setDC_contributor(form.getDC_contributor());
    g.setDC_coverage(form.getDC_coverage());
    g.setDC_creator(form.getDC_creator());
    g.setDC_date(form.getDC_date());
    g.setDC_description(form.getDC_description());
    g.setDC_format(form.getDC_format());
    g.setDC_identifier(form.getDC_identifier());
    g.setDC_language(form.getDC_language());
    g.setDC_publisher(form.getDC_publisher());
    g.setDC_relation(form.getDC_relation());
    g.setDC_rights(form.getDC_rights());
    g.setDC_source(form.getDC_source());
    g.setDC_subject(form.getDC_subject());
    g.setDC_title(form.getDC_title());
    g.setDC_type(form.getDC_type());

    g.setDC_contributor_manual(req.getParameter("DC_contributor_manual")!=null);
    g.setDC_coverage_manual(req.getParameter("DC_coverage_manual")!=null);
    g.setDC_creator_manual(req.getParameter("DC_creator_manual")!=null);
    g.setDC_date_manual(req.getParameter("DC_date_manual")!=null);
    g.setDC_description_manual(req.getParameter("DC_description_manual")!=null);
    g.setDC_format_manual(req.getParameter("DC_format_manual")!=null);
    g.setDC_identifier_manual(req.getParameter("DC_identifier_manual")!=null);
    g.setDC_language_manual(req.getParameter("DC_language_manual")!=null);
    g.setDC_publisher_manual(req.getParameter("DC_publisher_manual")!=null);
    g.setDC_relation_manual(req.getParameter("DC_relation_manual")!=null);
    g.setDC_rights_manual(req.getParameter("DC_rights_manual")!=null);
    g.setDC_source_manual(req.getParameter("DC_source_manual")!=null);
    g.setDC_subject_manual(req.getParameter("DC_subject_manual")!=null);
    g.setDC_title_manual(req.getParameter("DC_title_manual")!=null);
    g.setDC_type_manual(req.getParameter("DC_type_manual")!=null);

    boolean imageset=false;
   
    if (form.getLogo().getFileName()!=null)
      if (!form.getLogo().getFileName().equals("")) {
        try {
          g.setLogo(Hibernate.createBlob(form.getLogo().getInputStream()));
          g.setLogoType(form.getLogo().getContentType());
          imageset=true;
        } catch (Exception e) {
          // TODO Wo image
        }
       
      }

    g.setBasedOnTemplate(GameTemplateDao.findGameTemplate(form.getTemplateToUse(),session));

    if (form.isModifyMe()) {
      GameDao.updateGame(g,session);
      MessageBean.setMyMessage(req, "Game updated successfuly.");
    } else {
     
      boolean createAppAndBlog=false;
     
      if (form.isLikeMe()) {
        g.setCreator(webUser.getId());
        g.setRemoved(req.getParameter("createEnabled")==null);
        g.setAvailableFrom(likeGame.getAvailableFrom());
        g.setAvailableTo(likeGame.getAvailableTo());
        g.setMaksimumScore(likeGame.getMaksimumScore());
        if (!imageset) {
          //copy image if needed
          if (likeGame.getLogo()!=null){
            try {
              g.setLogoType(likeGame.getLogoType());
              g.setLogo(Hibernate.createBlob(likeGame.getLogo().getBinaryStream()));
            } catch (Exception e) {
              // TODO Wo handle exception
            }
           
          }
        }
        //TODO Wo when duplicating game, duplicate content also...
       
       
        g.setCreationTime(new GregorianCalendar());
        g.setStatus(Game.STATUS_IN_PREPARATION);
       
        g.setMaxScore("Game not played yet.");
        g.setAvgScore("Game not played yet.");
        g.setSecuritySummary("Advanced security not set.");

        g.setMaksimumScore(-1);

       
      } else {
        //adding new one
       
       
        g.setCreator(webUser.getId());
        g.setRemoved(req.getParameter("createEnabled")==null);
       
        g.setCreationTime(new GregorianCalendar());
        g.setStatus(Game.STATUS_IN_PREPARATION);
       
        g.setMaxScore("Game not played yet.");
        g.setAvgScore("Game not played yet.");
        g.setSecuritySummary("Advanced security not set.");

        g.setMaksimumScore(-1);
       
        createAppAndBlog=true;
       
      }
     
      GameDao.persistGame(g,session);
      if (createAppAndBlog) {
        //create new blog & application
        DbManager dbm=new DbManager(locale,session);
        //UserManager um=new UserManager(locale,session);
       
        // for now, all professors and students have permissions on blog...
//        ArrayList<Role> rols=new ArrayList<Role>();
//        rols.add(um.getRole("teacher"));
//        rols.add(um.getRole("student"));
       
        g.setApplication(dbm.createApplication("Game("+g.getId()+"): "+g.getName()));
//        g.setBlog(dbm.createBlog("Game: "+g.getName(), rols, rols, rols));

        String[] labels = new String[] {g.getBasedOnTemplate().getGameType()};
        g.setArticle(dbm.createGameBlogArticle(g, webUser, labels));
       
        GameDao.persistGame(g,session);
      }
     
      //allow all to creator
      GameSecurityDao.allow(Game.asGameObject(g), GameSecurity.TARGET_TYPE_USER, webUser.getId(), GameSecurityDao.SECURITY_TYPE_ALL,req,session);

      MessageBean.setMyMessage(req, "Game created successfuly.");
     
    }
   
   
    form.reset();
   
    if (req.getParameter("applyAndGoToEditing")!=null) {
      try {
        res.sendRedirect("auth"+g.getBasedOnTemplate().getAuthoringHandlerCode()+".do?id="+g.getId()+"&startAuthoring=1");
      } catch (Exception e) {
        // TODO: handle exception
      }
     
    }
View Full Code Here

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

   
//    Session hibernateSession=HibernateSessions.startTransactionSilently();
    Session hibernateSession = HibernateSessions.getSessionFactory().openSession();
    try {
      User u=UserDao.findUser(req.getUserPrincipal().getName(), hibernateSession);
      GameHiber g=GameDao.findGameHiber(id,hibernateSession);
      //security check
      if (SecurityCenter.canIPlayGame(u.getId(),g,hibernateSession)) {
        try {
          InputStream in=null;
         
          boolean jarCreated=false;
         
          if (g.getBasedOnTemplate().getAuthoringHandlerCode().equals(AuthTool.MAGOBAL_CODE)) {
            jarCreated=true;
            //if game 2: create jar, download file
       
            String tempDestinationFileName=req.getRealPath("/gamemgmt/jsp/author_magobal/dest"+g.getId()+"_"+u.getId()+".temp.jar");
            String destinationFileName=req.getRealPath("/gamemgmt/jsp/author_magobal/dest"+g.getId()+"_"+u.getId()+".jar");
            String destinationXMLFileName=req.getRealPath("/gamemgmt/jsp/author_magobal/dest"+g.getId()+"_"+u.getId()+".jar.xml");
//            String destinationCFGFileName=req.getRealPath("/gamemgmt/jsp/dest"+g.getId()+"_"+u.getId()+".cfg");
            //TODO transformer does not work with long filenames... - for now temp goes to c:...
            String destinationCFGFileName="c:/temp_dest"+g.getId()+"_"+u.getId()+".cfg";
            String xslFileName=req.getRealPath("/gamemgmt/jsp/author_magobal/Mogabal.xsl");
           
            //save game jar content to file
            InputStream inputstream=g.getJarContent().getBinaryStream();

            OutputStream out = new FileOutputStream(new File(tempDestinationFileName));
            byte[] buf = new byte[1024];
            int count = 0;
            while((count = inputstream.read(buf)) >= 0) {
              out.write(buf, 0, count);
            }
            out.close();
            inputstream.close();         
           
            //create jar
            MagobalJARCreator.createJAR(g.getId(), hibernateSession,tempDestinationFileName,destinationFileName,destinationXMLFileName,xslFileName,destinationCFGFileName);

            MessageBean.setMyMessage(req, "Game JAR created, served to download.");
           
            in=new FileInputStream(destinationFileName);
           
          }         
         
          if (g.getBasedOnTemplate().getAuthoringHandlerCode().equals(AuthTool.AOG_CODE)) {
            jarCreated=true;
            //if game 1: create jar, download file
       
            String templateFileName=req.getRealPath("/gamemgmt/jsp/author_aog/game_composer/template.jar");
            String destinationFileName=req.getRealPath("/gamemgmt/jsp/author_aog/game_composer/dest"+g.getId()+"_"+u.getId()+".jar");
            String destinationXMLFileName=req.getRealPath("/gamemgmt/jsp/author_aog/game_composer/dest"+g.getId()+"_"+u.getId()+".jar.xml");
           
            //get content provider url
            String providerUrl=null;
           
            //try to read from database
           
            try {
              SQLQuery sq=hibernateSession.createSQLQuery("select CONTENT_PROVIDER_URL from T_SYS_CONFIGURATION").addScalar("CONTENT_PROVIDER_URL",Hibernate.STRING);
              for (Object o:sq.list()) {
               
                URL url=new URL(o.toString());
                String s=url.toString();
                providerUrl= s.substring(0,s.length()-url.getPath().length());
              }
            } catch (Exception e) {
              // TODO: handle exception
            }
            //if not - get actual URL from request
            if (providerUrl==null) {
              URL url=new URL(req.getRequestURL().toString());
              String s=url.toString();
              providerUrl= s.substring(0,s.length()-url.getPath().length());
            }
           
            AOGJARCreator.createJAR(AOGGameDao.findGameHiberForGame(g.getId(), hibernateSession), u.getId(),hibernateSession,templateFileName,destinationFileName,destinationXMLFileName,providerUrl);

            MessageBean.setMyMessage(req, "Game JAR created, served to download.");
           
            in=new FileInputStream(destinationFileName);
           
          }
         
          if (!jarCreated){
            //else: download from database
            in=g.getJarContent().getBinaryStream();
           
          }

          res.setContentType("application/java-archive");
          try {
View Full Code Here

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

   
    long id=Long.parseLong(req.getParameter("id"));
    long lid=Long.parseLong(req.getParameter("levelId"));
    long cid=Long.parseLong(req.getParameter("cardId"));
   
    GameHiber g=GameDao.findGameHiber(id,session);
    form.setGh(g);
    form.setG(GameDao.findGame(id,session));

    AOGGameHiber ag=AOGGameDao.findGameHiberForGame(g.getId(), session);
    form.setAh(ag);
   
    AOGGameLevelHiber level=AOGGameLevelDao.findGameLevelHiber(lid, session);
    form.setLh(level);
View Full Code Here

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

   
    //we use transaction here
    //super.defaultMethod(am, af, req, res);
   
    long gameId=Long.parseLong(req.getParameter("id"));
    GameHiber g=GameDao.findGameHiber(gameId,session);

    if (req.getParameter("action")!=null) {
      if (req.getParameter("action").equals("start")) {
        //start the game
        if (!SecurityCenter.canIStartGame(webUser.getId(),g)) {
          MessageBean.setMyMessage(req, ("Error: Insufficient privileges or game cannot be started."));
          return am.findForward("ok");
        }
        g.setStatus(Game.STATUS_STARTED);
        GameDao.updateGame(g,session);
        MessageBean.setMyMessage(req, ("Game started."));
       
        //invalidate security cache
        SecurityCenter.invalidateCache();
      }
      if (req.getParameter("action").equals("stop")) {
        //stop the game
        if (!SecurityCenter.canIStopGame(webUser.getId(),g)) {
          MessageBean.setMyMessage(req, ("Error: Insufficient privileges or game cannot be stopped."));
          return am.findForward("ok");
        }
        g.setStatus(Game.STATUS_STOPPED);
        GameDao.updateGame(g,session);
        MessageBean.setMyMessage(req, ("Game stopped."));

        //invalidate security cache
        SecurityCenter.invalidateCache();
View Full Code Here

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

    MessageBean.addSpeedOMeterCheckPoint(req, "point1");
   
    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");

      //allow browse
      all=GameSecurityDao.getGameSecurityForGameAllowBrowse(g.getId(),session);
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point19a");
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowBrowseForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowBrowseForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowBrowseForUsers().add(UserDao.findUser(security.getTargetId(),session));
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point19");

      //allow play
      all=GameSecurityDao.getGameSecurityForGameAllowPlay(g.getId(),session);
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowPlayForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowPlayForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowPlayForUsers().add(UserDao.findUser(security.getTargetId(),session));
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point20");

      //allow edit
      all=GameSecurityDao.getGameSecurityForGameAllowEdit(g.getId(),session);
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowEditForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowEditForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowEditForUsers().add(UserDao.findUser(security.getTargetId(),session));
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point21");

      //allow view scores
      all=GameSecurityDao.getGameSecurityForGameAllowViewScores(g.getId(),session);
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowViewScoresForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowViewScoresForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowViewScoresForUsers().add(UserDao.findUser(security.getTargetId(),session));
      }
     
      MessageBean.addSpeedOMeterCheckPoint(req, "point22");

      //allow all
      all=GameSecurityDao.getGameSecurityForGameAllowAll(g.getId(),session);
      MessageBean.addSpeedOMeterCheckPoint(req, "point23a");
      for (GameSecurityHiber security : all) {
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_ROLE)form.getAllowAllForUserGroups().add(UserRoleDao.findRole(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_SETform.getAllowAllForUserSets().add(UserSetDao.findUserSet(security.getTargetId(),session));
        if (security.getTargetType()==GameSecurity.TARGET_TYPE_USER) form.getAllowAllForUsers().add(UserDao.findUser(security.getTargetId(),session));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.