Exemplo n.º 1
0
 private Authenticator createAuthenticator() {
   UserList userList = new UserList();
   User user = new User("111-1111", "password");
   userList.add(user);
   Login login = new Login(console, userList);
   return new Authenticator(null, login);
 }
    public void main(IWContext iwc) throws Exception {

      Form myForm = new Form();
      myForm.maintainParameter(_PARAMETER_GROUP_ID);

      int groupId = -1;
      try {
        groupId = Integer.parseInt(iwc.getParameter(_PARAMETER_GROUP_ID));
      } catch (Exception ex) {
        // do Nothing
      }

      if (iwc.getParameter("commit") != null) {

        // Save

        // System.out.println("----------------------------");
        // System.out.println("users: "+iwc.getParameterValues(_USERS_RELATED));

        UserGroupBusiness.updateUsersInGroup(groupId, iwc.getParameterValues(_USERS_RELATED));

        this.setParentToReload();
        this.close();

      } else {
        UserList uList = new UserList(_USERS_RELATED);

        List lDirect =
            com.idega.core.user.business.UserGroupBusiness.getUsersContainedDirectlyRelated(
                groupId);
        Set direct = new HashSet();
        if (lDirect != null) {
          Iterator iter = lDirect.iterator();
          while (iter.hasNext()) {
            User item = (User) iter.next();
            direct.add(Integer.toString(item.getGroupID()));
          }
        }
        uList.setDirectlyRelatedUserIds(direct);

        List lNotDirect =
            com.idega.core.user.business.UserGroupBusiness.getUsersContainedNotDirectlyRelated(
                groupId);
        Set notDirect = new HashSet();
        if (lNotDirect != null) {
          Iterator iter2 = lNotDirect.iterator();
          while (iter2.hasNext()) {
            User item = (User) iter2.next();
            notDirect.add(Integer.toString(item.getGroupID()));
          }
        }
        uList.setRelatedUserIdsNotDirectly(notDirect);

        myForm.add(uList);

        myForm.add(new SubmitButton("commit", "    OK   "));
        myForm.add(new CloseButton("  Cancel  "));
        this.add(myForm);
      }
    }
Exemplo n.º 3
0
  private Object interpretFunctionListItem(Object left, Sprite sprite) {
    UserList userList = null;
    if (rightChild.getElementType() == ElementType.USER_LIST) {
      DataContainer dataContainer =
          ProjectManager.getInstance().getSceneToPlay().getDataContainer();
      userList = dataContainer.getUserList(rightChild.getValue(), sprite);
    }

    if (userList == null) {
      return "";
    }

    int index = 0;
    if (left instanceof String) {
      try {
        Double doubleValueOfLeftChild = Double.valueOf((String) left);
        index = doubleValueOfLeftChild.intValue();
      } catch (NumberFormatException numberFormatexception) {
        Log.d(getClass().getSimpleName(), "Couldn't parse String", numberFormatexception);
      }
    } else {
      index = ((Double) left).intValue();
    }

    index--;

    if (index < 0) {
      return "";
    } else if (index >= userList.getList().size()) {
      return "";
    }

    return userList.getList().get(index);
  }
Exemplo n.º 4
0
 @Override
 public Void visit(TermCons c, Void _) {
     Production prod = c.getProduction();
     builder.append("`");
     if (prod.isListDecl() && c.getContents().size() == 2) {
         UserList list = prod.getListDecl();
         builder.append('_'+list.getSeparator()+prod.getSort()+'_');
     } else {
         builder.append(prod.getKLabel());
     }
     builder.append("`");
     builder.append('(');
     boolean listOp = false;
     for (ProductionItem i : c.getProduction().getItems()) {
         if (i instanceof NonTerminal && ((NonTerminal)i).getName().equals("KList")) {
             listOp = true;
             break;
         }
     }
     boolean first = true;
     for (Term t : c.getContents()) {
         if (!first) {
             builder.append(", ");
         }
         first = false;
         if (listOp) {
             visitNodeOrKList(t);
         } else {
             this.visitNode(t);
         }
     }
     builder.append(')');
     return null;
 }
 private User getUserByLogin(String userLogin) {
   for (int i = 0; i < mUserList.size(); i++) {
     final User user = mUserList.get(i);
     if (user.getUserLogin().equalsIgnoreCase(StringUtils.parseBareAddress(userLogin))) {
       return user;
     }
   }
   return null;
 }
 public User getUserByFullUserLogin(String fullUserLogin) {
   for (int i = 0; i < mUserList.size(); i++) {
     final User user = mUserList.get(i);
     if (user.getFullUserLogin().equalsIgnoreCase(fullUserLogin)) {
       return user;
     }
   }
   return null;
 }
Exemplo n.º 7
0
  private int handleNumberOfItemsOfUserListParameter(Sprite sprite) {
    DataContainer dataContainer = ProjectManager.getInstance().getSceneToPlay().getDataContainer();
    UserList userList = dataContainer.getUserList(leftChild.value, sprite);

    if (userList == null) {
      return 0;
    }

    return userList.getList().size();
  }
Exemplo n.º 8
0
  /**
   * Remove all user lists irrelevant of creation date since that information is not exposed via
   * twitter/ twitter4j. Note: Not time aware.
   */
  private void removeLists() {
    try {
      ResponseList<UserList> lists = twitter.getUserLists(twitter.getScreenName());
      for (UserList list : lists) {
        twitter.destroyUserList(list.getId());
      }

    } catch (TwitterException e) {
      logger.error("Twitter exception occurred", e);
    }
  }
Exemplo n.º 9
0
 // Methods for the treatment of the different message types
 private void loginMessageTreatment() throws IncorrectMessageException {
   String content = message.getText().trim();
   if (content != null && !content.contains("&")) {
     if (this.userList.getUserByNick(content) != null) {
       // The nick already exist (send 301)
       String response = new Integer(Message.ERROR_MESSAGE_EXISTING_NICK).toString();
       sendDatagram(
           new User(
               null,
               messageToProcces.getAddress().getHostAddress(),
               this.messageToProcces.getPort()),
           response);
       // Comprobamos el nick pero, ¿Y si ya hay un usuario en esa IP???
     } else {
       // Everything correct, send ACK
       User newUser =
           new User(
               content,
               this.messageToProcces.getAddress().getHostAddress(),
               this.messageToProcces.getPort());
       userList.add(newUser);
       String response =
           new Integer(Message.SERVER_MESSAGE_CONNECTED).toString() + this.userList.toString();
       sendDatagram(newUser, response);
     }
   } else {
     throw new IncorrectMessageException(
         "The Login message is not correct: '" + content.toString() + "'");
   }
 }
Exemplo n.º 10
0
  void transportCheck() {
    final UserList transportList = new UserList();
    for (final User user : mUserList) {
      if (user.getTransportState() == User.TSTATE_IS_TRANSPORT) {
        transportList.add(user);
      }
    }

    for (final User user : mUserList) {
      if (!transportList.contains(user)) {
        for (final User transport : transportList) {
          user.transportCheck(transport);
        }
      }
    }
  }
Exemplo n.º 11
0
  public void updateList(UserList list) {
    Log.d(TAG, "updateList");

    cancelAllTasks();
    mList.update(list);
    notifyDataSetChanged();
  }
Exemplo n.º 12
0
 @Override
 public void entriesDeleted(Collection<String> addresses) {
   for (final String uid : addresses) {
     final User user = getUser(uid, false);
     mUserList.remove(user);
     mContactList.removeUser(uid);
     service.sendRosterDeleted(uid);
   }
 }
Exemplo n.º 13
0
 public void destroy() {
   mUserList.clear();
   mUserList = null;
   mContactList.clear();
   mContactList = null;
   mRoster.removeRosterListener(this);
   mRoster = null;
   mUserMe = null;
 }
Exemplo n.º 14
0
  /**
   * Update the list of managed parks of a Park Manager.
   *
   * @author Taylor Gorman
   */
  public void updateParkList(String theEmail, List<String> theManagedParks) {
    List<User> myManagerList = myUserList.getParkManagerListCopy();

    for (User manager : myManagerList) {
      if (manager.getEmail().equals(theEmail)) {
        ((ParkManager) manager).setManagedParks(theManagedParks);
      }
    }
  }
Exemplo n.º 15
0
  private Object interpretFunctionContains(Object right, Sprite sprite) {
    if (leftChild.getElementType() == ElementType.USER_LIST) {
      DataContainer dataContainer =
          ProjectManager.getInstance().getSceneToPlay().getDataContainer();
      UserList userList = dataContainer.getUserList(leftChild.getValue(), sprite);

      if (userList == null) {
        return 0d;
      }

      for (Object userListElement : userList.getList()) {
        if (interpretOperatorEqual(userListElement, right) == 1d) {
          return 1d;
        }
      }
    }

    return 0d;
  }
Exemplo n.º 16
0
 @Override
 public int compareTo(UserList that) {
   long delta = this.id - that.getId();
   if (delta < Integer.MIN_VALUE) {
     return Integer.MIN_VALUE;
   } else if (delta > Integer.MAX_VALUE) {
     return Integer.MAX_VALUE;
   }
   return (int) delta;
 }
Exemplo n.º 17
0
  private Object interpretFunctionLength(Object left, Sprite sprite) {
    if (leftChild == null) {
      return 0d;
    }
    if (leftChild.type == ElementType.NUMBER) {
      return (double) leftChild.value.length();
    }
    if (leftChild.type == ElementType.STRING) {
      return (double) leftChild.value.length();
    }
    if (leftChild.type == ElementType.USER_VARIABLE) {
      return (double) handleLengthUserVariableParameter(sprite);
    }
    if (leftChild.type == ElementType.USER_LIST) {
      DataContainer dataContainer =
          ProjectManager.getInstance().getSceneToPlay().getDataContainer();
      UserList userList = dataContainer.getUserList(leftChild.getValue(), sprite);
      if (userList == null) {
        return 0d;
      }
      if (userList.getList().size() == 0) {
        return 0d;
      }

      Object interpretedList = leftChild.interpretRecursive(sprite);
      if (interpretedList instanceof Double) {
        Double interpretedListDoubleValue = (Double) interpretedList;
        if (interpretedListDoubleValue.isNaN() || interpretedListDoubleValue.isInfinite()) {
          return 0d;
        }
        return (double) (String.valueOf(interpretedListDoubleValue.intValue())).length();
      }
      if (interpretedList instanceof String) {
        String interpretedListStringValue = (String) interpretedList;
        return (double) interpretedListStringValue.length();
      }
    }
    if (left instanceof Double && ((Double) left).isNaN()) {
      return 0d;
    }
    return (double) (String.valueOf(left)).length();
  }
Exemplo n.º 18
0
  /**
   * Cancels all file transfers, sets all users as logged off, and removes them from the user list.
   */
  private void removeAllUsers() {
    final UserList userList = getUserList();

    for (int i = 0; i < userList.size(); i++) {
      final User user = userList.get(i);

      if (!user.isMe()) {
        user.setOnline(false);
        cancelFileTransfers(user);
        userList.remove(user);

        if (user.getPrivchat() != null) {
          msgController.showPrivateSystemMessage(user, "You logged off");
          user.getPrivchat().setLoggedOff();
        }

        i--;
      }
    }
  }
Exemplo n.º 19
0
 public User setupUser(User user) {
   final User user2 = getUserByFullUserLogin(user.getFullUserLogin());
   if (user2 == null) {
     mUserList.add(user);
     mContactList.add(user);
     service.sendRosterAdded(user);
     return user;
   } else {
     user2.setUserState(user.getUserState());
     service.sendRosterUpdated(user2);
     return user2;
   }
 }
Exemplo n.º 20
0
  private Object interpretUserList(Sprite sprite) {
    DataContainer dataContainer = ProjectManager.getInstance().getSceneToPlay().getDataContainer();
    UserList userList = dataContainer.getUserList(value, sprite);
    if (userList == null) {
      return NOT_EXISTING_USER_LIST_INTERPRETATION_VALUE;
    }

    List<Object> userListValues = userList.getList();

    if (userListValues.size() == 0) {
      return 0d;
    } else if (userListValues.size() == 1) {
      Object userListValue = userListValues.get(0);
      if (userListValue instanceof String) {
        return userListValue;
      } else {
        return userListValue;
      }
    } else {
      return interpretMultipleItemsUserList(userListValues);
    }
  }
Exemplo n.º 21
0
  /**
   * generates a message from the data of the datagram
   *
   * @throws IncorrectMessageException If the message cannot be correctly created.
   */
  private void generateMessage() throws IncorrectMessageException {

    // obtain all the params from the datagram data
    String ip = messageToProcces.getAddress().getHostAddress();
    int port = messageToProcces.getPort();
    User userFrom = userList.getUserByIpAndPort(ip, port);
    User userTo = null;
    String content = new String(messageToProcces.getData());
    content = content.trim();
    int id = Integer.parseInt(content.substring(0, 3));
    if (content.length() > 4) {
      // also eliminate the first &
      content = content.substring(4);
    } else {
      content = null;
    }

    // obtain the destination user if the message should have it
    if (Message.hasDestination(id)) {
      try {
        String[] splited = content.split("&");
        String nickTo = splited[0];
        userTo = userList.getUserByNick(nickTo);
        if (splited.length > 1) {
          content = content.substring(nickTo.length() + 1);
        }
      } catch (RuntimeException e) {
        throw new IncorrectMessageException("Incorrect message. No destination user found");
      }
    }

    // pass all the params to the message object
    message.setFrom(userFrom);
    message.setTo(userTo);
    message.setText(content);
    message.setMessageType(id);
  }
Exemplo n.º 22
0
  public void addUser(
      String theEmail, String theFirstName, String theLastName, String theUserType) {

    User user = null;

    switch (theUserType) {
      case "Volunteer":
        user = new Volunteer(theEmail, theFirstName, theLastName);
        break;
      case "Administrator":
        user = new Administrator(theEmail, theFirstName, theLastName);
        break;
      case "ParkManager":
        user = new ParkManager(theEmail, theFirstName, theLastName, new ArrayList<String>());
        break;
      default:
        throw new IllegalArgumentException(
            "Error: Invalid user type. Please logout and try again.");
    }

    myUserList.addNewUser(user);
  }
Exemplo n.º 23
0
 public UserList getRegList() throws SQLException {
   UserList userList;
   UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
   if (userMapper != null) {
     List<UserInfo> reqList = userMapper.getRequest();
     if (reqList == null) {
       userList = new UserList();
       userList.setErrorCode(Configuration.ErrorCodes.ER1001.getCodeName());
       userList.setSubscribe_kor(Configuration.ErrorCodes.ER1001.getSubtitleKor());
       return userList;
     } else {
       userList = new UserList();
       userList.setReqList(reqList);
       userList.setErrorCode(Configuration.ErrorCodes.Success.getCodeName());
       userList.setSubscribe_kor(Configuration.ErrorCodes.Success.getSubtitleKor());
       return userList;
     }
   } else {
     userList = new UserList();
     userList.setErrorCode(Configuration.ErrorCodes.ER0000.getCodeName());
     userList.setSubscribe_kor(Configuration.ErrorCodes.ER0000.getSubtitleKor());
     return userList;
   }
 }
Exemplo n.º 24
0
 @Override
 public Object getItem(int position) {
   return mList.get(position);
 }
Exemplo n.º 25
0
 @Override
 public int getCount() {
   return mList.size();
 }
Exemplo n.º 26
0
 private User getUser(int position) {
   return mList.get(position);
 }
Exemplo n.º 27
0
  public void testSchema() throws Exception {
    String[] schema;
    String url;

    //        JSONObject json = new
    // JSONObject("{\"a\":\"avalue\",\"b\":\"bvalue\",\"c\":{\"c-1\":12,\"c-2\":\"c-2value\"}}");
    //        schema = new String[]{"a", "b", "c/c-1", "c/c-2"};
    //        validateJSONObjectSchema(json, schema);
    //        try {
    //            schema = new String[]{"a", "b", "c/c-1"};
    //            validateJSONObjectSchema(json, schema);
    //            fail("c/c-2 is missing. expecting an AssertionFailedError.");
    //        } catch (AssertionFailedError ignore) {
    ////            ignore.printStackTrace();
    //        }
    //        try {
    //            schema = new String[]{"a", "b"};
    //            validateJSONObjectSchema(json, schema);
    //            fail("c is missing. expecting an AssertionFailedError.");
    //        } catch (AssertionFailedError ignore) {
    ////            ignore.printStackTrace();
    //        }
    //        try {
    //            schema = new String[]{"a", "b","c"};
    //            validateJSONObjectSchema(json, schema);
    //            fail("c/* is missing. expecting an AssertionFailedError.");
    //        } catch (AssertionFailedError ignore) {
    ////            ignore.printStackTrace();
    //        }
    //        schema = new String[]{"a", "b", "c/*"};
    //        validateJSONObjectSchema(json, schema);
    //
    //        JSONArray array = new JSONArray("[{\"slug\":\"art-design\",\"name\":\"Art &
    // Design\"},{\"slug\":\"books\",\"name\":\"Books\"}]");
    //        schema = new String[]{"slug", "name"};
    //        validateJSONArraySchema(array, schema);

    // Location

    //        schema = new
    // String[]{"url","country","woeid","placeType/name","placeType/code","name","countryCode"};
    //        url = "http://api.twitter.com/1.1/trends/available.json";
    //        validateJSONArraySchema(url, schema);
    // Place
    if (!Boolean.valueOf(System.getProperties().getProperty("twitter4j.test.schema"))) {
      // skipping schema validation
      return;
    }

    schema =
        new String[] {
          "slug", "name", "size",
        };
    url = "http://api.twitter.com/1.1/users/suggestions.json";
    List categories =
        CategoryJSONImpl.createCategoriesList(validateJSONArraySchema(url, schema), null, conf);
    Assert.assertEquals(20, categories.size());

    schema = new String[] {"slug", "name", "size", "categories/*", "users/*"};
    url = "http://api.twitter.com/1.1/users/suggestions/art-design.json";
    validateJSONObjectSchema(url, schema);

    schema =
        new String[] {
          "result/places/name",
          "result/places/street_address",
          "result/places/attributes/*",
          "result/places/country_code",
          "result/places/id",
          "result/places/country",
          "result/places/place_type",
          "result/places/url",
          "result/places/full_name",
          "result/places/bounding_box/*",
          "result/places/contained_within/place_type",
          "result/places/contained_within/attributes/*",
          "result/places/contained_within/street_address",
          "result/places/contained_within/url",
          "result/places/contained_within/bounding_box/type",
          "result/places/contained_within/bounding_box/coordinates/*",
          "result/places/contained_within/full_name",
          "result/places/contained_within/country_code",
          "result/places/contained_within/name",
          "result/places/contained_within/id",
          "result/places/contained_within/country",
          "query",
          "query/type",
          "query/url",
          "query/params",
          "query/params/granularity",
          "query/params/coordinates",
          "query/params/coordinates/type",
          "query/params/coordinates/coordinates",
          "query/params/coordinates/coordinates/*",
          "query/params/accuracy",
        };
    url = "http://api.twitter.com/1.1/geo/reverse_geocode.json?lat=37.78215&long=-122.40060";
    validateJSONObjectSchema(url, schema);

    schema =
        new String[] {
          "next_cursor",
          "next_cursor_str",
          "previous_cursor",
          "previous_cursor_str",
          "lists/id",
          "lists/id_str",
          "lists/member_count",
          "lists/description",
          "lists/name",
          "lists/subscriber_count",
          "lists/slug",
          "lists/user/*",
          "lists/uri",
          "lists/full_name",
          "lists/mode",
          "lists/following",
        };
    url = "http://api.twitter.com/1.1/twit4j2/lists.json";
    validateJSONObjectSchema(url, schema);

    schema =
        new String[] {
          "id",
          "id_str",
          "member_count",
          "description",
          "name",
          "subscriber_count",
          "slug",
          "user/*",
          "uri",
          "full_name",
          "mode",
          "following",
        };
    url = "http://api.twitter.com/1.1/twit4j2/lists/9499823.json";
    UserList userList = new UserListJSONImpl(validateJSONObjectSchema(url, schema));
    Assert.assertEquals("", userList.getDescription());
    Assert.assertEquals("@twit4j2/test", userList.getFullName());
    Assert.assertEquals(9499823, userList.getId());
    Assert.assertTrue(1 < userList.getMemberCount());
    Assert.assertEquals("test", userList.getName());
    Assert.assertEquals("test", userList.getSlug());
    Assert.assertEquals(0, userList.getSubscriberCount());
    Assert.assertEquals("/twit4j2/test", userList.getURI().toString());
    Assert.assertNotNull(userList.getUser());
    Assert.assertTrue(userList.isPublic());
    Assert.assertFalse(userList.isFollowing());

    schema =
        new String[] {
          "favorited",
          "in_reply_to_status_id",
          "in_reply_to_status_id_str",
          "created_at",
          "geo",
          "place",
          "source",
          "in_reply_to_screen_name",
          "in_reply_to_user_id",
          "in_reply_to_user_id_str",
          "coordinates",
          "truncated",
          "contributors",
          "id",
          "id_str",
          "text",
          "user/*",
          "retweeted",
          "retweet_count"
        };
    url = "http://api.twitter.com/1.1/statuses/show/2245071380.json";
    Status status = new StatusJSONImpl(validateJSONObjectSchema(url, schema));

    schema =
        new String[] {
          "profile_background_image_url",
          "created_at",
          "friends_count",
          "profile_link_color",
          "description",
          "contributors_enabled",
          "status/*",
          "following",
          "profile_background_tile",
          "favourites_count",
          "profile_sidebar_fill_color",
          "url",
          "profile_image_url",
          "geo_enabled",
          "notifications",
          "profile_sidebar_border_color",
          "location",
          "screen_name",
          "verified",
          "time_zone",
          "profile_background_color",
          "profile_use_background_image",
          "protected",
          "name",
          "profile_text_color",
          "followers_count",
          "id",
          "id_str",
          "lang",
          "statuses_count",
          "follow_request_sent",
          "utc_offset",
          "listed_count",
          "is_translator",
          "show_all_inline_media"
        };

    url = "http://api.twitter.com/1.1/users/show/yusukey.json";
    User user = new UserJSONImpl(validateJSONObjectSchema(url, schema));
  }
Exemplo n.º 28
0
 private void allUsersMenuItemActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_allUsersMenuItemActionPerformed
   UserList ul = new UserList(this, true);
   ul.setVisible(true);
 } // GEN-LAST:event_allUsersMenuItemActionPerformed