Exemple #1
0
 @RequestMapping("/addUser4")
 @ResponseBody
 public String addUser4(User user) {
   log.info("userName is:" + user.getUserName());
   log.info("password is:" + user.getPassword());
   return user.getUserName();
 }
Exemple #2
0
 public void setPower(boolean power) {
   if (!car.getPhone().getOnCall()) {
     if (power) {
       if (currentStation == null) setNextStation();
       startDate = new Date();
       radioStartTime = System.currentTimeMillis();
     } else {
       makeStationLog();
       car.addRadioLog(new RadioLog(user.getUserName(), startDate, radioStartTime));
       currentStation = null;
       startDate = null;
       radioStartTime = 0;
     }
     radioOn = power;
   } else {
     if (radioOn) {
       makeStationLog();
       car.addRadioLog(new RadioLog(user.getUserName(), startDate, radioStartTime));
       currentStation = null;
       startDate = null;
       radioStartTime = 0;
     }
     radioOn = false;
   }
 }
 @RequestMapping(value = "/login", method = RequestMethod.POST)
 public void login(
     @ModelAttribute("user") User user,
     HttpSession session,
     HttpServletRequest request,
     HttpServletResponse response,
     @RequestParam(value = "userId", required = true) String userId,
     @RequestParam(value = "passwd", required = true) String passwd)
     throws Exception {
   user = this.userService.getUser(userId, passwd);
   PrintWriter pw = response.getWriter();
   if (user != null) {
     Cookie cookie = new Cookie(Constants.BRUSERID, user.getId());
     cookie.setPath("/");
     cookie.setMaxAge(10 * 365 * 24 * 3600);
     response.addCookie(cookie);
     WebContextThreadLocal.setCurrentUser(user);
     LoggerUtil.info(this.getClass(), "当前登录用户为:" + user.getUserName());
     AuthenticateRole.authenticate(request, user, (String) request.getAttribute("userIdRuleReg"));
     request.setAttribute("user", user);
     session.setAttribute("user", user);
     this.userService.flush();
     pw.write(
         "{\"login\" : true ,\"user\":\""
             + user.getUserName()
             + "\",\"isTeacher\":\""
             + request.getAttribute("isTeacher")
             + "\"}");
   } else {
     LoggerUtil.debug(this.getClass(), "用户名或密码错误!");
     pw.write("{\"login\":false}");
   }
   pw.close();
 }
Exemple #4
0
 public void Verify() {
   String ID = $V("ID");
   String Type = $V("Type");
   String IDs = $V("IDs");
   if ((XString.isNotEmpty(ID)) && (XString.isEmpty(IDs))) {
     ZCCommentSchema comment = new ZCCommentSchema();
     comment.setID(ID);
     comment.fill();
     if (Type.equals("Pass")) comment.setVerifyFlag("Y");
     else if (Type.equals("NoPass")) {
       comment.setVerifyFlag("N");
     }
     comment.setVerifyUser(User.getUserName());
     comment.setVerifyTime(new Date());
     if (comment.update()) this.response.setLogInfo(1, "审核成功");
     else this.response.setLogInfo(0, "审核失败");
   } else if ((XString.isNotEmpty(IDs)) && (XString.isEmpty(ID))) {
     ZCCommentSchema comment = new ZCCommentSchema();
     ZCCommentSet set = comment.query(new QueryBuilder("where ID in (" + IDs + ")"));
     Transaction trans = new Transaction();
     for (int i = 0; i < set.size(); i++) {
       comment = set.get(i);
       if (Type.equals("Pass")) comment.setVerifyFlag("Y");
       else if (Type.equals("NoPass")) {
         comment.setVerifyFlag("N");
       }
       comment.setVerifyUser(User.getUserName());
       comment.setVerifyTime(new Date());
       trans.add(comment, OperateType.UPDATE);
     }
     if (trans.commit()) this.response.setLogInfo(1, "审核成功");
     else this.response.setLogInfo(0, "审核失败");
   }
 }
  @Test
  public void username_is_set_no_empty_string_is_thrown_probably() {
    createFullUser("ietiuuitp");
    createUpdateUserWithEmptyUserName();

    updateUser();

    assertThat(returnUser.getUserName(), is(equalTo(testUser.getUserName())));
  }
 public UserDetailsAdapter(User userEntity) {
   super(
       userEntity.getUserName(),
       userEntity.getPassword(),
       userEntity.getActive(),
       true,
       true,
       true,
       new ArrayList<GrantedAuthority>());
   userName = userEntity.getUserName();
 }
 private void printRemainingDataSourcesList(PrintWriter out, User user, ConnectToDB ctdb)
     throws SQLException {
   DataSource dataSource = null;
   String dataSourceName = null;
   Vector remainingDataSourcesList =
       ctdb.getDataSourceListsDifference(
           this.dataSourceVectorForDataSourceNames(
               ctdb.getValuesVectorForOneColumnUnderOneCondition(
                   new Column("DATASOURCENAME"), new Column("ISCANDIDATE", "no"), "ACDATASOURCE")),
           user.getDataSourceList());
   if (remainingDataSourcesList.size() == 0) {
     out.println("<table class=transparenttable>");
     out.println("<tr><td><FONT COLOR=#000000>No virtaul sensor is available.</td></tr>");
     out.println("</table>");
   } else {
     out.println("<table>");
     out.println("<tr><th> virtual sensor name </th>");
     out.println("<th> access right</th></tr>");
     for (int i = 0; i < remainingDataSourcesList.size(); i++) {
       dataSource = (DataSource) (remainingDataSourcesList.get(i));
       dataSourceName = dataSource.getDataSourceName();
       if (ctdb.valueExistsForThisColumnUnderTwoConditions(
           new Column("ISUSERWAITING", "yes"),
           new Column("USERNAME", user.getUserName()),
           new Column("DATASOURCENAME", dataSource.getDataSourceName()),
           "ACUSER_ACDATASOURCE")) {
         out.println("<tr><td>" + dataSourceName + " </td>");
       } else {
         out.println("<FORM ACTION=/gsn/MyUpdateUserWaitingForDataSourceServlet METHOD=POST>");
         out.println("<tr><td>" + dataSourceName + " </td>");
         out.println("<td><INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 1> read ");
         out.println("<INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE= 2> write ");
         out.println("<INPUT TYPE=RADIO NAME=" + dataSourceName + " VALUE=3> read/write ");
       }
       if (ctdb.valueExistsForThisColumnUnderTwoConditions(
           new Column("ISUSERWAITING", "yes"),
           new Column("USERNAME", user.getUserName()),
           new Column("DATASOURCENAME", dataSource.getDataSourceName()),
           "ACUSER_ACDATASOURCE")) {
         out.println("<td>" + "<FONT COLOR=#0000FF>in updates waiting list!</td></tr>");
       } else {
         out.println(
             "&nbsp&nbsp&nbsp<INPUT TYPE=SUBMIT TYPE=SUBMIT class= buttonstyle VALUE=\"add\"></td></tr>");
         out.println("</FORM>");
       }
     }
     out.println("</table>");
   }
 }
  /**
   * p>사용자그룹(tm_usergroup)에서 수정한다.
   *
   * @param groupID
   * @return
   * @throws DataAccessException
   */
  public int updateUser(User user) throws DataAccessException {

    String sql =
        QueryUtil.getStringQuery(
            "admin_sql", "admin.usergroup.updateuser"); // 쿼리 프로퍼티파일의 키값에 해당되는 sql문을 읽어온다.
    // 넘겨받은 파라미터를 세팅한다.

    Map<String, Object> param = new HashMap<String, Object>();
    param.put("userPWD", user.getUserPWD());
    param.put("userName", user.getUserName());
    param.put("groupID", user.getGroupID());
    param.put("userLevel", user.getUserLevel());
    param.put("description", user.getDescription());
    param.put("useYN", user.getUseYN());
    param.put("userID", user.getUserID());
    param.put("isHelper", user.getIsHelper());
    param.put("senderName", user.getSenderName());
    param.put("email", user.getEmail());
    param.put("cellPhone", user.getCellPhone());
    param.put("senderEmail", user.getSenderEmail());
    param.put("senderCellPhone", user.getSenderCellPhone());

    // SQL문이 실행된다.
    return getSimpleJdbcTemplate().update(sql, param);
  }
  @SuppressWarnings("unchecked")
  @Override
  public void readExternal(ObjectInput arg0) throws IOException, ClassNotFoundException {
    createdDate = (LocalDate) arg0.readObject();
    createdTime = (LocalTime) arg0.readObject();
    user = (User) arg0.readObject();
    serveAtDate = (LocalDate) arg0.readObject();
    serveAtTime = (LocalTime) arg0.readObject();
    active = (boolean) arg0.readObject();
    number = (String) arg0.readObject();
    orderedMeals = (ArrayList<MealAndQuantity>) arg0.readObject();

    sspCreatedDate = new SimpleStringProperty(createdDate.toString());
    sspCreatedTime = new SimpleStringProperty(createdTime.toString());
    sspOrderedMeals = new SimpleStringProperty();
    sspUserName = new SimpleStringProperty(user.getUserName().get());
    sspNumber = new SimpleStringProperty(number.toString());
    sspServeAtDate = new SimpleStringProperty(serveAtDate.toString());
    sspServeAtTime = new SimpleStringProperty(serveAtTime.toString());
    sspPrice = new SimpleStringProperty();

    sspCreatedAtCompact =
        new SimpleStringProperty(createdDate.toString() + " " + createdTime.toString());
    sspServeAtCompact =
        new SimpleStringProperty(serveAtDate.toString() + " " + serveAtTime.toString());
  }
Exemple #10
0
  /*
   * Private methods
   */
  public WebApiElaborated getWebApiForUser(User user) {
    WebApiElaborated actualWebApiElaborated = null;

    for (WebApiElaborated webApiElaborated : getWebApiElaboratedList()) {
      if (webApiElaborated.getUser().getUserName().equals(user.getUserName())) {
        actualWebApiElaborated = webApiElaborated;
        break;
      }
    }

    if (actualWebApiElaborated == null) {
      // Create new WebApiElaborated
      try {
        actualWebApiElaborated = new WebApiElaborated();
        actualWebApiElaborated.setUser(user);
      } catch (QuestionListException e) {
        e.printStackTrace();
      }

      // Add to the list of APIs
      getWebApiElaboratedList().add(actualWebApiElaborated);
    }

    return actualWebApiElaborated;
  }
Exemple #11
0
  @RequestMapping("/addUser6")
  public void addUser6(User user, PrintWriter out) {
    log.info("userName is:" + user.getUserName());
    log.info("password is:" + user.getPassword());
    String json = null;
    /** 使用Jackson */
    ObjectMapper map = new ObjectMapper();
    try {
      json = map.writeValueAsString(user);

    } catch (JsonGenerationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (JsonMappingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    log.info("使用Jackson:" + json);

    /** 使用fastjson */
    json = JSON.toJSONString(user);
    log.info("使用fastjson:" + json);
    out.write(json);
  }
Exemple #12
0
 @RequestMapping("/addUser3")
 public String addUser3(User user, Model model) {
   log.info("userName is:" + user.getUserName());
   log.info("password is:" + user.getPassword());
   model.addAttribute(user);
   return "/user/success2";
 }
 public User updateUser(User user) {
   int count =
       entityManager
           .createQuery("UPDATE User SET userName=:userName , password=:passwd WHERE userId=:uid")
           .setParameter("userName", user.getUserName())
           .setParameter("passwd", user.getPassword())
           .executeUpdate();
   System.out.println("Records Updated:" + count);
   return entityManager.find(User.class, user.getUserId());
 }
  /**
   * Put User Payoff history into a readable double 2D array for JFreeChart
   *
   * @return A 2D double array of coordinates
   */
  private XYSeries getUserPayoffData() {
    XYSeries xySeries = new XYSeries("User: "******"'s Payoff History (Over "
            + userInfo.getPayoffHistory().size()
            + " Steps)");

    // Set the points of the data set
    for (int i = 0; i < userInfo.getPayoffHistory().size(); i++) {
      xySeries.add(i, userInfo.getPayoffHistory().get(i));
    }

    return xySeries;
  }
 private void printUserInformation(PrintWriter out, User user) {
   out.println("<table>");
   out.println("<tr><th>username</th>");
   out.println("<th>user first name</th>");
   out.println("<th>user last name</th>");
   out.println("<th>user E-mail</th></tr>");
   out.println("<tr><td>" + user.getUserName() + "</td>");
   out.println("<td>" + user.getFirstName() + " </td>");
   out.println("<td>" + user.getLastName() + "</td>");
   out.println("<td>" + user.getEmail() + "</td></tr>");
   out.println("</table>");
 }
Exemple #16
0
 public void add() {
   Transaction tran = new Transaction();
   ZCFullTextSchema ft = new ZCFullTextSchema();
   if (XString.isEmpty($V("ID"))) {
     ft.setValue(this.request);
     ft.setID(NoUtil.getMaxID("FullTextID"));
     ft.setSiteID(ApplicationPage.getCurrentSiteID());
     ft.setAddTime(new Date());
     ft.setAddUser(User.getUserName());
     tran.add(ft, OperateType.INSERT);
   } else {
     ft.setID(Long.parseLong($V("ID")));
     ft.fill();
     ft.setValue(this.request);
     ft.setModifyTime(new Date());
     ft.setModifyUser(User.getUserName());
     tran.add(ft, OperateType.UPDATE);
   }
   if (tran.commit()) this.response.setMessage("保存成功");
   else this.response.setError("发生错误,保存失败");
 }
  // new version without group ds combunation
  private void printUserGroupList(PrintWriter out, User user) {
    Group group = null;
    String label = null;
    String groupName = null;
    String groupType = null;
    String userName = user.getUserName();
    if (user.getGroupList().size() == 0) {

      out.println("<p>No group is selected.</p>");
    } else {
      out.println("<table >");
      out.println("<tr><th> group name </th>");
      out.println("<th> group structure</th>");
      out.println("<th> user choice</th>");
      out.println("<th> admin decision</th>");
      out.println("<th> admin decision</th></tr>");
      for (int i = 0; i < user.getGroupList().size(); i++) {

        group = (Group) (user.getGroupList().get(i));
        groupName = group.getGroupName();
        groupType = group.getGroupType();

        if (groupType.equals("5")) {
          label = " user wants to add this group ";
        } else if (groupType.equals("0")) {
          label = " user wants to delete this group ";
        }
        out.println("<tr><td>" + groupName + "</td>");
        this.printGroupStructureLink(out, group.getGroupName());
        out.println("<td>" + label + " </td>");

        out.println("<FORM ACTION=/gsn/MyUpdateUserGroupServlet METHOD=POST>");
        out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
        out.println("<INPUT  TYPE=HIDDEN NAME=grouptype VALUE=" + groupType + ">");
        out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
        out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= yes>");
        out.println(
            "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"agree to update\"></td>");
        out.println("</FORM>");

        out.println("<FORM ACTION=/gsn/MyUpdateUserGroupServlet METHOD=POST>");
        out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
        out.println("<INPUT  TYPE=HIDDEN NAME=grouptype VALUE=" + groupType + ">");
        out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
        out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= no>");
        out.println(
            "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"refuse to update\"></td></tr>");
        out.println("</FORM>");
      }
      out.println("</table>");
    }
  }
  public void buyItemFromUser(User buyer, User seller, Item currentItem)
        // PRE:  buyer, seller, currentItem must be initialized
        // POST: Purchases item from the store and has stores it into inventory.
      {

    int buyer_balance; // The new balance of the buyer
    int seller_balance; // The new balance of the seller
    String str; // First query
    String str2; // Second query
    String str3; // Third query

    buyer_balance = buyer.getBalance() - currentItem.getPrice();
    seller_balance = seller.getBalance() + currentItem.getPrice();

    if (buyer_balance > 0) // If the buyer wont go negative
    {
      str =
          String.format(
              "Update users set balance = (%d) where user_name = '%s'",
              buyer_balance, buyer.getUserName());

      str2 =
          String.format(
              "Update users set balance = (%d) where user_name = '%s'",
              seller_balance, seller.getUserName());

      str3 =
          String.format(
              "Update items set owner_id = (%d) where item_name = '%s'",
              buyer.getUserId(), currentItem.getItemName());

      updateTables(str, str2, str3);

    } else {
      // Prompt the user with an error
      JOptionPane.showMessageDialog(
          null, "You will go bankrupt if you try buying that, try selling some items.");
    }
  }
  @Timeout
  public void replicateUsers() throws IOException {

    logger.info("replicating users from MySQL to CouchDB");
    List<SecuredUser> users = userService.list();

    List<User> usersView = userDb.getUsersView().<User>createDocQuery().asDocs();
    Map<String, User> couchUsers = User.toMap(usersView);

    List<User> newOrModifiedUsers = new ArrayList<>();

    // Add new users to couchdb
    for (SecuredUser user : users) {
      String id = user.getId().toString();
      if (!couchUsers.containsKey(id)) {
        String mmsi = getMmsi(user);
        String name = getName(user);
        newOrModifiedUsers.add(new User(id, user.getUserName(), name, mmsi));
        logger.info("Adding user with id={} and name={}", user.getId(), name);
      } else {
        User couchUser = couchUsers.get(id);
        String mmsi = getMmsi(user);
        String name = getName(user);
        if (!Objects.equals(couchUser.getName(), name)
            || !Objects.equals(couchUser.getMmsi(), mmsi)
            || !Objects.equals(couchUser.getUserName(), user.getUserName())) {
          couchUser.setMmsi(mmsi);
          couchUser.setName(name);
          couchUser.setUserName(user.getUserName());
          logger.info("Updating user with id={} and name={}", id, name);
          newOrModifiedUsers.add(couchUser);
        }
      }
    }
    userDb.bulk(newOrModifiedUsers);

    // remove deleted users from couchdb
    Map<Long, SecuredUser> securedUsers =
        users.stream().collect(Collectors.toMap(SecuredUser::getId, u -> u));
    List<User> toRemove = new ArrayList<>();
    for (User user : couchUsers.values()) {
      if (!securedUsers.containsKey(Long.parseLong(user.getDocId()))) {
        toRemove.add(user);
        user.setDeleted();
        logger.info("Removing user with id={} and name={}", user.getDocId(), user.getName());
      }
    }

    userDb.bulk(toRemove);
  }
  @Test
  public void testFindUser() throws Exception {

    // Stub the value that will returned on call to userService.findUserByName
    User stubbedUser = new User("userAfterSave");
    Mockito.when(userService.findUserByName("user1")).thenReturn(stubbedUser);

    // make the call
    User user = userManager.findUser("user1");

    // Verify if findUserByName method was invoked on userService call
    Mockito.verify(userService).findUserByName("user1");

    Assert.assertEquals("userAfterSave", user.getUserName());
  }
 private static void fillInSubject(PolicyRule rule) throws Throwable {
   if (rule instanceof UserPolicyRule) {
     User user = ((UserPolicyRule<User>) rule).getSubject();
     User filledInUser = tbclient.getUserByUsername(USER_SERVICE_ROOT, user.getUserName());
     if (filledInUser == null) {
       throw new RuntimeException("Could not find real user for: " + user.getUserName());
     }
     rule.setSubject(filledInUser);
   } else if (rule instanceof GroupPolicyRule) {
     Group group = ((GroupPolicyRule<? extends Group>) rule).getSubject();
     Project filledInProject = getProjectByGroupName(group.getGroupName());
     if (filledInProject != null) {
       rule.setSubject(filledInProject);
     } else {
       Organisation filledInOrg = getOrganisationByGroupName(group.getGroupName());
       if (filledInOrg != null) {
         rule.setSubject(filledInOrg);
       } else {
         throw new RuntimeException(
             "Could not find project or organisation for group name: " + group.getGroupName());
       }
     }
   }
 }
  /**
   * Create a GUI that shows a graph for the specified user's payoff history
   *
   * @param user The user to show the Payoff history for
   */
  public GraphGUI(User user) {
    super(
        user.getUserName()
            + "'s Payoff History (Over "
            + user.getPayoffHistory().size()
            + " Steps)");

    this.userInfo = user;
    this.pack();

    // Set size
    this.setMinimumSize(new Dimension(500, 500));

    // Center the graph
    this.setLocationRelativeTo(null);

    // Create a series collection
    xySeriesCollection = new XYSeriesCollection();

    // Create (refresh) chart data
    refreshChartData();

    // Create an XY Line Chart
    chart =
        ChartFactory.createXYLineChart(
            "User Payoff Over Time",
            "Steps (Simulation Iterations)",
            "User Payoff",
            xySeriesCollection);
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.getPlot().setOutlinePaint(Color.BLACK);

    // Draw the Initial Chart
    chart.draw(
        (Graphics2D) this.getGraphics(),
        (Rectangle2D) new Rectangle2D.Double(0, 0, this.getWidth(), this.getHeight()));

    // Set the content pane to a graphics panel for drawing the graph
    this.setContentPane(new GraphPanel(this));

    // Show the frame
    this.setVisible(true);

    // Subscribe to the user's UserPayoff events
    user.addPayoffListener(this);
  }
 // 初始化
 public DrawingOrder(
     User user, BigDecimal money, BankInfo bankInfo, String mobile, Long funddetailId) {
   this.userId = user.getId();
   this.userName = user.getUserName();
   this.realName = user.getInfo().getRealName();
   this.money = money;
   this.bankAccounts = bankInfo.getBankCard();
   this.bankName = bankInfo.getBankName();
   this.partBankCity = bankInfo.getPartBankCity();
   this.partBankProvince = bankInfo.getPartBankProvince();
   this.partBankName = bankInfo.getPartBankName();
   this.mobile = mobile;
   this.funddetailId = funddetailId;
   this.enable = Boolean.TRUE;
   this.sendtime = new Date();
   state = DrawingOrderState.CHECKING;
 }
Exemple #24
0
  public boolean addOneJob(long configID, boolean immediate) {
    ZCDeployJobSchema job = new ZCDeployJobSchema();
    ZCDeployConfigSchema config = new ZCDeployConfigSchema();
    config.setID(configID);
    if (!config.fill()) {
      return false;
    }

    String staticDir =
        Config.getContextRealPath() + Config.getValue("Statical.TargetDir").replace('\\', '/');
    String sourcePath =
        staticDir + "/" + ApplicationPage.getCurrentSiteAlias() + config.getSourceDir();
    job.setID(NoUtil.getMaxID("DeployJobID"));
    job.setConfigID(config.getID());
    job.setSource(sourcePath);
    job.setMethod(config.getMethod());

    String targetDir = config.getTargetDir();
    if (XString.isEmpty(targetDir)) {
      targetDir = "/";
    } else if (!targetDir.endsWith("/")) {
      targetDir = targetDir + "/";
    }

    job.setTarget(targetDir);
    job.setSiteID(config.getSiteID());
    job.setHost(config.getHost());
    job.setPort(config.getPort());
    job.setUserName(config.getUserName());
    job.setPassword(config.getPassword());
    job.setStatus(0L);
    job.setAddTime(new Date());
    job.setAddUser(User.getUserName());

    Transaction trans = new Transaction();
    trans.add(job, OperateType.INSERT);
    if (trans.commit()) {
      if (immediate) {
        executeJob(config, job);
      }
      return true;
    }
    LogUtil.getLogger().info("添加部署任务时,数据库操作失败");
    return false;
  }
  private void printRemainingGroupsList(PrintWriter out, User user, ConnectToDB ctdb)
      throws SQLException {
    Vector remainingGroupList =
        ctdb.getGroupListsDifference(ctdb.getGroupList(), user.getGroupList());
    Group group = null;
    String groupName = null;
    String userName = user.getUserName();
    if (remainingGroupList.size() == 0) {
      out.println("<table class =transparenttable>");
      out.println("<tr><td><FONT COLOR=#000000>No group is available.</td></tr>");
      out.println("</table>");
    } else {
      out.println("<table>");
      out.println("<tr>");
      out.println("<th>group name</th>");
      out.println("<th>group structure</th>");
      out.println("<th>updates</th>");
      out.println("</tr>");

      for (int i = 0; i < remainingGroupList.size(); i++) {
        group = (Group) (remainingGroupList.get(i));
        groupName = group.getGroupName();
        out.println("<tr>");
        out.println("<td>" + groupName + "</td>");
        this.printGroupStructureLink(out, groupName);
        if (ctdb.valueExistsForThisColumnUnderTwoConditions(
                new Column("ISUSERWAITING", "yes"),
                new Column("GROUPNAME", groupName),
                new Column("USERNAME", userName),
                "ACUSER_ACGROUP")
            == false) {
          out.println("<FORM ACTION=/gsn/MyUpdateUserWaitingForGroupServlet METHOD=POST>");
          out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
          out.println("<INPUT  TYPE=HIDDEN NAME=addgroup VALUE=Yes>");
          out.println(
              "<td style=text-align:center><INPUT TYPE=SUBMIT class= buttonstyle VALUE=\"add\"></td>");
          out.println("</FORM>");
        } else {
          out.println("<td>" + "<FONT COLOR=#0000FF>in updates waiting list!</td>");
        }
        out.println("</tr>");
      }
      out.println("</table>");
    }
  }
  private void printGroupListModulo(PrintWriter out, User user, int index) {
    Group group = null;
    String label = null;
    String groupName = null;
    String groupType = null;
    String userName = user.getUserName();
    group = (Group) (user.getGroupList().get(index));
    groupName = group.getGroupName();
    groupType = group.getGroupType();
    if (groupType.equals("5")) {
      label = " user wants to add this group ";
    } else if (groupType.equals("0")) {
      label = " user wants to delete this group ";
    }

    out.println("<table class=\"transparenttable\">");
    out.println("<tr><td><B>groupname: </B>" + groupName + "</td></tr>");
    out.println("<tr><td><B>user choice: </B>" + label + " </td></tr>");
    out.println("</table>");
    out.println("<BR>");
    this.printGroupDataSourceList(out, group);
    out.println("<BR>");

    out.println("<FORM ACTION=/gsn/MyUpdateUserGroupServlet METHOD=POST>");
    out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
    out.println("<INPUT  TYPE=HIDDEN NAME=grouptype VALUE=" + groupType + ">");
    out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
    out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= yes>");
    out.println("<table class=\"transparenttable\">");
    out.println(
        "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"agree to update\"></td>");
    out.println("</FORM>");

    out.println("<FORM ACTION=/gsn/MyUpdateUserGroupServlet METHOD=POST>");
    out.println("<INPUT  TYPE=HIDDEN NAME=groupname VALUE=" + groupName + ">");
    out.println("<INPUT  TYPE=HIDDEN NAME=grouptype VALUE=" + groupType + ">");
    out.println("<INPUT TYPE=HIDDEN NAME=username VALUE= " + userName + ">");
    out.println("<INPUT TYPE=HIDDEN NAME=update VALUE= no>");
    out.println(
        "<td><INPUT TYPE=SUBMIT class=creategroupbuttonstyle VALUE=\"refuse to update\"></td></tr>");
    out.println("</FORM>");

    out.println("</table>");
  }
Exemple #27
0
  public static Mapx init(Mapx params) {
    String ForumID = params.getString("ForumID");
    String ThemeID = params.getString("ThemeID");
    String SiteID = params.getString("SiteID");
    ZCThemeSchema theme = new ZCThemeSchema();
    theme.setID(ThemeID);
    theme.setForumID(ForumID);
    Mapx map = theme.toMapx();
    ZCForumSchema forum = new ZCForumSchema();
    forum.setID(ForumID);
    forum.fill();
    map.put("Name", forum.getName());
    map.put("AddUser", User.getUserName());
    map.put("SiteID", SiteID);
    map.put("Priv", ForumUtil.initPriv(ForumID, SiteID));
    map.put("BBSName", ForumUtil.getBBSName(SiteID));

    return map;
  }
Exemple #28
0
  private User getFriendlyName(
      PublisherPublicKeyDigest digest, CCNHandle tempReadHandle, CCNHandle tempWriteHandle)
      throws MalformedContentNameStringException, IOException {
    User userFriendlyName = null;
    if (_userToDigestHash.containsKey(digest)) {
      userFriendlyName = _userToDigestHash.get(digest);
      Log.info("GET digest: " + digest.digest() + " --> " + userFriendlyName.getUserName());
    } else {
      Log.info("We DON'T have an entry in our hash for this " + digest);
    }

    if (userFriendlyName == null) {

      // Its not in the hashMap.. So, try and read the user's
      // friendly name from the ContentName and then add it to
      // the hashMap....
      String userNameStr = _namespaceStr + MEMBER_COMPONENT;
      _userNamespace =
          KeyProfile.keyName(ContentName.fromURI(userNameStr), _readString.getContentPublisher());

      try {
        _readNameString =
            new CCNStringObject(_userNamespace, (String) null, SaveType.RAW, tempReadHandle);
      } catch (Exception e) {
        e.printStackTrace();
      }

      _readNameString.update(WAIT_TIME_FOR_FRIENDLY_NAME);

      if (_readNameString.available()) {

        if (_readString.getContentPublisher().equals(_readNameString.getContentPublisher())) {
          userFriendlyName =
              addNameToHash(_readNameString.getContentPublisher(), _readNameString.string());
        }
      } else {
        userFriendlyName =
            new Speaker(
                "", "", _readString.getContentPublisher().shortFingerprint().substring(0, 8));
      }
    }
    return userFriendlyName;
  }
  @Test
  public void update_all_single_values() {
    createFullUser("uasv");
    createUpdateUserWithUpdateFields();

    updateUser();

    assertEquals("UserName", returnUser.getUserName());
    assertEquals("NickName", returnUser.getNickName());
    assertNotEquals(testUser.isActive(), returnUser.isActive());
    assertEquals("DisplayName", returnUser.getDisplayName());
    assertEquals("ExternalId", returnUser.getExternalId());
    assertEquals("Locale", returnUser.getLocale());
    assertEquals("PreferredLanguage", returnUser.getPreferredLanguage());
    assertEquals("ProfileUrl", returnUser.getProfileUrl());
    assertEquals("Timezone", returnUser.getTimezone());
    assertEquals("Title", returnUser.getTitle());
    assertEquals("UserType", returnUser.getUserType());
    assertEquals("FamilyName", returnUser.getName().getFamilyName());
    assertEquals("ExternalId", returnUser.getExternalId());
  }
Exemple #30
0
  public static void addMovieReview(User user, Movie movie) {
    Scanner sc = new Scanner(System.in);
    int i = 0;
    double newRating = 0;

    MovieSerializer movieSerializer = new MovieSerializer();
    UserSerializer userSerializer = new UserSerializer();
    MovieReview reviewForThisMovie = new MovieReview();

    if (user.getMovieReviewedByUser() != null) {
      while (i < user.getMovieReviewedByUser().size()) {
        if (user.getMovieReviewedByUser().get(i).getMovieName().equals(movie.getMovieTitle())) {
          System.out.println("You have rated this movie.");
          user.getMovieReviewedByUser().get(i).print();
          System.out.println("Do you want to modify the review? (Y/N)");
          if (UserApp.YN()) {
            modifyReview(user, i);
            return;
          } else return;
        } else i++;
      }
    }
    reviewForThisMovie.setMovieName(movie.getMovieTitle());
    reviewForThisMovie.setReviewer(user.getUserName());
    while ((newRating > 5) || (newRating < 1)) {
      System.out.print("Rating(1 - 5 [best]): ");
      newRating = sc.nextInt();
      if ((newRating > 5) || (newRating < 1))
        System.out.println("You can only give a rating between 1 to 5!");
    }
    reviewForThisMovie.setRating(newRating);
    System.out.print("Review: ");
    sc.nextLine();
    reviewForThisMovie.setReview(sc.nextLine());
    movie.addReviewForThisMovie(reviewForThisMovie);
    user.getMovieReviewedByUser().add(reviewForThisMovie);
    movieSerializer.serializeMovie(movie);
    userSerializer.serializeUser(user);
    return;
  }