⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appsforyourdomainclient.java

📁 google的gdata api包
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
  public UserFeed retrieveAllUsers()      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Retrieving all users.");    URL retrieveUrl = new URL(domainUrlBase + "user/"	+ SERVICE_VERSION + "/");    UserFeed allUsers = new UserFeed();    UserFeed currentPage;    Link nextLink;    do {      currentPage = userService.getFeed(retrieveUrl, UserFeed.class);      allUsers.getEntries().addAll(currentPage.getEntries());      nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);      if (nextLink != null) {	retrieveUrl = new URL(nextLink.getHref());      }    } while (nextLink != null);    return allUsers;  }  /**   * Retrieves one page (100) of users in domain.  Any changes to users,   * including creations and deletions, which are made after this method is   * called may or may not be included in the Feed which is returned.  If the   * optional startUsername parameter is specified, one page of users is   * returned which have usernames at or after the startUsername as per ASCII   * value ordering with case-insensitivity.  A value of null or empty string   * indicates you want results from the beginning of the list.   *   * @param startUsername The starting point of the page (optional).   * @return A UserFeed object of the retrieved users.   * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public UserFeed retrievePageOfUsers(String startUsername)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Retrieving one page of users"	+ (startUsername != null ? " starting at " + startUsername : "")	+ ".");        URL retrieveUrl = new URL(domainUrlBase + "user/" + SERVICE_VERSION + "/");    AppsForYourDomainQuery query = new AppsForYourDomainQuery(retrieveUrl);    query.setStartUsername(startUsername);    return userService.query(query, UserFeed.class);  }  /**   * Updates a user.   *   * @param username The user to update.   * @param userEntry The updated UserEntry for the user.   * @return A UserEntry object of the newly updated user.    * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public UserEntry updateUser(String username, UserEntry userEntry)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Updating user '" + username + "'.");    URL updateUrl = new URL(domainUrlBase + "user/" 	+ SERVICE_VERSION + "/" + username);    return userService.update(updateUrl, userEntry);  }  /**   * Deletes a user.   *   * @param username The user you wish to delete.   * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public void deleteUser(String username)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Deleting user '" + username + "'.");    URL deleteUrl = new URL(	domainUrlBase + "user/" + SERVICE_VERSION + "/" +  username);    userService.delete(deleteUrl);  }  /**   * Suspends a user.  Note that executing this method for a user who is   * already suspended has no effect.   *   * @param username The user you wish to suspend.   * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public UserEntry suspendUser(String username)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,	"Suspending user '" + username + "'.");    URL retrieveUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    UserEntry userEntry = userService.getEntry(retrieveUrl, UserEntry.class);    userEntry.getLogin().setSuspended(true);    URL updateUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    return userService.update(updateUrl, userEntry);  }  /**   * Restores a user.  Note that executing this method for a user who is not   * suspended has no effect.   *   * @param username The user you wish to restore.   * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public UserEntry restoreUser(String username)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Restoring user '" + username + "'.");    URL retrieveUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    UserEntry userEntry = userService.getEntry(retrieveUrl, UserEntry.class);    userEntry.getLogin().setSuspended(false);    URL updateUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    return userService.update(updateUrl, userEntry);  }    /**   * Set admin privilege for user.  Note that executing this method for a user    * who is already an admin has no effect.   *   * @param username The user you wish to make an admin.   * @throws AppsForYourDomainException If a Provisioning API specific error    * occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public UserEntry addAdminPrivilege(String username)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO, "Setting admin privileges for user '" + username         + "'.");    URL retrieveUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    UserEntry userEntry = userService.getEntry(retrieveUrl, UserEntry.class);    userEntry.getLogin().setAdmin(true);    URL updateUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    return userService.update(updateUrl, userEntry);  }  /**   * Remove admin privilege for user.  Note that executing this method for a    * user who is not an admin has no effect.   *   * @param username The user you wish to remove admin privileges.   * @throws AppsForYourDomainException If a Provisioning API specific error    * occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public UserEntry removeAdminPrivilege(String username)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO, "Removing admin privileges for user '" + username         + "'.");    URL retrieveUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    UserEntry userEntry = userService.getEntry(retrieveUrl, UserEntry.class);    userEntry.getLogin().setAdmin(false);    URL updateUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    return userService.update(updateUrl, userEntry);  }  /**   * Require a user to change password at next login.  Note that executing this    * method for a user who is already required to change password at next login   * as no effect.   *   * @param username The user who must change his or her password.   * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public UserEntry forceUserToChangePassword(String username)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO, "Requiring " + username + " to change password at " +            "next login.");    URL retrieveUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    UserEntry userEntry = userService.getEntry(retrieveUrl, UserEntry.class);    userEntry.getLogin().setChangePasswordAtNextLogin(true);    URL updateUrl = new URL(domainUrlBase + "user/"        + SERVICE_VERSION + "/" + username);    return userService.update(updateUrl, userEntry);  }  /**   * Creates a nickname for the username.   *   * @param username The user for which we want to create a nickname.   * @param nickname The nickname you wish to create.   * @return A NicknameEntry object of the newly created nickname.    * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public NicknameEntry createNickname(String username, String nickname)       throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Creating nickname '" + nickname +        "' for user '" + username + "'.");    NicknameEntry entry = new NicknameEntry();    Nickname nicknameExtension = new Nickname();    nicknameExtension.setName(nickname);    entry.addExtension(nicknameExtension);    Login login = new Login();    login.setUserName(username);    entry.addExtension(login);    URL insertUrl = new URL(domainUrlBase + "nickname/" + SERVICE_VERSION);    return nicknameService.insert(insertUrl, entry);  }  /**   * Retrieves a nickname.   *   * @param nickname The nickname you wish to retrieve.   * @return A NicknameEntry object of the newly created nickname.    * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public NicknameEntry retrieveNickname(String nickname)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Retrieving nickname '" + nickname + "'.");    URL retrieveUrl = new URL(domainUrlBase + "nickname/" 	+ SERVICE_VERSION + "/" +  nickname);    return nicknameService.getEntry(retrieveUrl, NicknameEntry.class);  }  /**   * Retrieves all nicknames for the given username.   *   * @param username The user for which you want all nicknames.   * @return A NicknameFeed object with all the nicknames for the user.   * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public NicknameFeed retrieveNicknames(String username)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Retrieving nicknames for user '" + username + "'.");    URL feedUrl = new URL(domainUrlBase + "nickname/" + SERVICE_VERSION);    AppsForYourDomainQuery query = new AppsForYourDomainQuery(feedUrl);    query.setUsername(username);    return nicknameService.query(query, NicknameFeed.class);  }  /**   * Retrieves one page (100) of nicknames in domain.  Any changes to   * nicknames, including creations and deletions, which are made after   * this method is called may or may not be included in the Feed which is   * returned.  If the optional startNickname parameter is specified, one page   * of nicknames is returned which have names at or after startNickname as per   * ASCII value ordering with case-insensitivity.  A value of null or empty   * string indicates you want results from the beginning of the list.   *   * @param startNickname The starting point of the page (optional).   * @return A NicknameFeed object of the retrieved nicknames.   * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public NicknameFeed retrievePageOfNicknames(String startNickname)      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Retrieving one page of nicknames"        + (startNickname != null ? " starting at " + startNickname : "")        + ".");    URL retrieveUrl = new URL(	domainUrlBase + "nickname/" + SERVICE_VERSION + "/");    AppsForYourDomainQuery query = new AppsForYourDomainQuery(retrieveUrl);    query.setStartNickname(startNickname);    return nicknameService.query(query, NicknameFeed.class);  }  /**   * Retrieves all nicknames in domain.  This method may be very slow for   * domains with a large number of nicknames.  Any changes to nicknames,   * including creations and deletions, which are made after this method is   * called may or may not be included in the Feed which is returned.   *   * @return A NicknameFeed object of the retrieved nicknames.   * @throws AppsForYourDomainException If a Provisioning API specific occurs.   * @throws ServiceException If a generic GData framework error occurs.   * @throws IOException If an error occurs communicating with the GData   * service.   */  public NicknameFeed retrieveAllNicknames()      throws AppsForYourDomainException, ServiceException, IOException {    LOGGER.log(Level.INFO,        "Retrieving all nicknames.");    URL retrieveUrl = new URL(domainUrlBase + "nickname/"        + SERVICE_VERSION + "/");    NicknameFeed allNicknames = new NicknameFeed();    NicknameFeed currentPage;    Link nextLink;    do {      currentPage = nicknameService.getFeed(retrieveUrl, NicknameFeed.class);      allNicknames.getEntries().addAll(currentPage.getEntries());      nextLink = currentPage.getLink(Link.Rel.NEXT, Link.Type.ATOM);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -