Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.User


  /**
   * Retrieve tokens.
   */
  public void retrieveTokens() throws APIException {
    Map<String, String> properties = getProperties(ACTION_TOKENS, result.getFormat());
    User user = (getWiki().getConnection() != null) ? getWiki().getConnection().getUser() : null;
    properties.put(PROPERTY_TYPE,
        PROPERTY_TYPE_EDIT +
        ((user != null) && (user.hasRight(User.RIGHT_DELETE)) ? "|" + PROPERTY_TYPE_DELETE : ""));
    result.executeTokens(properties);
  }
View Full Code Here


      XPath xpa = XPath.newInstance("/api/query/users/user");
      List results = xpa.selectNodes(root);
      Iterator iter = results.iterator();
      while (iter.hasNext()) {
        Element currentNode = (Element) iter.next();
        User user = new User(currentNode.getAttributeValue("name"));
        List<String> groups = new ArrayList<String>();
        XPath xpaGroups = XPath.newInstance("./groups/g");
        List resultGroups = xpaGroups.selectNodes(currentNode);
        Iterator itGroups = resultGroups.iterator();
        while (itGroups.hasNext()) {
          groups.add(((Element) itGroups.next()).getValue());
        }
        user.setGroups(groups);
        List<String> rights = new ArrayList<String>();
        XPath xpaRights = XPath.newInstance("./rights/r");
        List resultRights = xpaRights.selectNodes(currentNode);
        Iterator itRights = resultRights.iterator();
        while (itRights.hasNext()) {
          rights.add(((Element) itRights.next()).getValue());
        }
        user.setRights(rights);
        return user;
      }
    } catch (JDOMException e) {
      log.error("Error retrieving user information", e);
      throw new APIException("Error parsing XML", e);
View Full Code Here

        if (login) {
          if ((result == null) || (!result.isLoginSuccessful())) {
            throw new APIException("Login unsuccessful: " + ((result != null) ? result.toString() : ""));
          }
        }
        User user = api.retrieveUser(wiki, username);
        username = (user != null) ? user.getName() : null;
        wiki.getConnection().setUser(user);
        api.retrieveTokens(wiki);
        logged = true;
      }
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.data.User

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