Пример #1
0
  /**
   * Wrapper method to get a list of pending invites for a user
   *
   * @param parameters list of query string parameters to pass to API
   * @return Collection<ConnectionEntry>
   * @throws ProfileServiceException
   */
  private Collection<ConnectionEntry> getMyInvites(Map<String, String> parameters)
      throws ProfileServiceException {
    if (logger.isLoggable(Level.FINEST)) {
      logger.entering(sourceClass, "getMyInvites", parameters);
    }

    Document data = null;
    Collection<ConnectionEntry> invites = null;
    String url =
        resolveProfileUrl(
            ProfileEntity.NONADMIN.getProfileEntityType(),
            ProfileType.CONNECTIONS.getProfileType());
    data = executeGet(url, parameters, ClientService.FORMAT_XML);
    if (parameters.containsKey("outputType")) {
      if (parameters.get("outputType").equalsIgnoreCase("profile")) {
        invites = Converter.returnConnectionEntries(data, "profile");
      } else invites = Converter.returnConnectionEntries(data, "connection");
    } else {
      invites = Converter.returnConnectionEntries(data, "connection");
    }
    if (logger.isLoggable(Level.FINEST)) {
      logger.exiting(sourceClass, "getMyInvites");
    }
    return invites;
  }
Пример #2
0
 /**
  * Wrapper method to search profiles based on different parameters
  *
  * @param parameters list of query string parameters to pass to API
  * @return Collection<Profile>
  */
 public Collection<Profile> searchProfiles(Map<String, String> parameters) {
   if (logger.isLoggable(Level.FINEST)) {
     logger.entering(sourceClass, "searchProfiles", parameters);
   }
   Document data = null;
   Collection<Profile> profiles = null;
   if (null == parameters) {
     parameters = new HashMap<String, String>();
   }
   try {
     String url =
         resolveProfileUrl(
             ProfileEntity.NONADMIN.getProfileEntityType(), ProfileType.SEARCH.getProfileType());
     data = (Document) getClientService().get(url, parameters);
     profiles = Converter.returnProfileEntries(this, data);
   } catch (ClientServicesException e) {
     if (logger.isLoggable(Level.SEVERE)) {
       logger.log(Level.SEVERE, Messages.ProfileServiceException_1 + "searchProfiles()", e);
     }
   }
   if (logger.isLoggable(Level.FINEST)) {
     logger.exiting(sourceClass, "getColleagues");
   }
   return profiles;
 }
Пример #3
0
  /**
   * Wrapper method to get common colleagues of two users
   *
   * @param sourceId userid or email of first user
   * @param targetId userid or email of second user
   * @return Collection<ConnectionEntry>
   * @throws ProfileServiceException
   */
  private Collection<ConnectionEntry> getColleaguesInCommon(
      String sourceId, String targetId, Map<String, String> parameters)
      throws ProfileServiceException {

    if (logger.isLoggable(Level.FINEST)) {
      logger.entering(sourceClass, "checkColleague");
    }
    if (StringUtil.isEmpty(sourceId)) {
      throw new IllegalArgumentException(Messages.InvalidArgument_4);
    }
    if (StringUtil.isEmpty(targetId)) {
      throw new IllegalArgumentException(Messages.InvalidArgument_5);
    }
    Document data = null;
    if (parameters == null) {
      parameters = new HashMap<String, String>();
    }
    String url =
        resolveProfileUrl(
            ProfileEntity.NONADMIN.getProfileEntityType(),
            ProfileType.CONNECTIONS_IN_COMMON.getProfileType());
    if (isEmail(sourceId)) {
      StringBuilder value = new StringBuilder(sourceId);
      value = value.append(",").append(targetId);
      parameters.put(ProfileRequestParams.EMAIL, value.toString());
    } else {

      StringBuilder value = new StringBuilder(sourceId);
      value = value.append(",").append(targetId);
      parameters.put(ProfileRequestParams.USERID, value.toString());
    }
    parameters.put("connectionType", "colleague");

    data = executeGet(url, parameters, ClientService.FORMAT_XML);
    Collection<ConnectionEntry> colleaguesInCommon =
        Converter.returnConnectionEntries(data, "connectionEntry");

    if (logger.isLoggable(Level.FINEST)) {
      logger.exiting(sourceClass, "getColleagues");
    }
    return colleaguesInCommon;
  }
Пример #4
0
  /**
   * Wrapper method to get a user's report to chain
   *
   * @param id unique identifier of the user whose direct reports are needed, it can be email or
   *     userID
   * @param parameters list of query string parameters to pass to API
   * @return List of Profiles
   * @throws ProfileServiceException
   */
  public Collection<Profile> getReportToChain(String id, Map<String, String> parameters)
      throws ProfileServiceException {

    if (logger.isLoggable(Level.FINEST)) {
      logger.entering(sourceClass, "getReportToChain", parameters);
    }
    if (parameters == null) parameters = new HashMap<String, String>();
    String url =
        resolveProfileUrl(
            ProfileEntity.NONADMIN.getProfileEntityType(),
            ProfileType.REPORTINGCHAIN.getProfileType());

    Document data = executeGet(url, parameters, ClientService.FORMAT_XML);
    Collection<Profile> reportingChain = Converter.returnProfileEntries(this, data);

    if (logger.isLoggable(Level.FINEST)) {
      logger.exiting(sourceClass, "getReportToChain");
    }
    return reportingChain;
  }
Пример #5
0
  /**
   * Wrapper method to get check if two users are colleagues
   *
   * @param sourceId userid or email of first user
   * @param targetId userid or email of second user
   * @param parameters list of query string parameters to pass to API
   * @return ConnectionEntry
   * @throws ProfileServiceException
   */
  private ConnectionEntry checkColleague(
      String sourceId, String targetId, Map<String, String> parameters)
      throws ProfileServiceException {

    if (logger.isLoggable(Level.FINEST)) {
      logger.entering(sourceClass, "checkColleague");
    }
    if (StringUtil.isEmpty(sourceId)) {
      throw new IllegalArgumentException(Messages.InvalidArgument_4);
    }
    if (StringUtil.isEmpty(targetId)) {
      throw new IllegalArgumentException(Messages.InvalidArgument_5);
    }
    Document data = null;
    if (parameters == null) {
      parameters = new HashMap<String, String>();
    }
    String url =
        resolveProfileUrl(
            ProfileEntity.NONADMIN.getProfileEntityType(), ProfileType.CONNECTION.getProfileType());
    if (isEmail(sourceId)) {
      parameters.put(ProfileRequestParams.SOURCEEMAIL, sourceId);
    } else {
      parameters.put(ProfileRequestParams.SOURCEUSERID, sourceId);
    }
    if (isEmail(targetId)) {
      parameters.put(ProfileRequestParams.TARGETEMAIL, targetId);
    } else {
      parameters.put(ProfileRequestParams.TARGETUSERID, targetId);
    }
    parameters.put("connectionType", "colleague");

    data = executeGet(url, parameters, ClientService.FORMAT_XML);
    ConnectionEntry connection =
        Converter.returnConnectionEntries(data, "connectionEntry").iterator().next();

    if (logger.isLoggable(Level.FINEST)) {
      logger.exiting(sourceClass, "getColleagues");
    }
    return connection;
  }
Пример #6
0
  /**
   * Wrapper method to get user's colleagues
   *
   * @param profile profile of the user whose contacts are to be returned
   * @param parameters list of query string parameters to pass to API
   * @return Profiles of User's colleagues
   * @throws ProfileServiceException
   */
  public Profile[] getColleagues(Profile profile, Map<String, String> parameters)
      throws ProfileServiceException {
    if (logger.isLoggable(Level.FINEST)) {
      logger.entering(sourceClass, "getColleagues", parameters);
    }
    if (profile == null) {
      throw new IllegalArgumentException(StringUtil.format("A null profile was passed"));
    }
    Document data = null;
    Profile[] colleagues = null;
    if (parameters == null) parameters = new HashMap<String, String>();
    String url =
        resolveProfileUrl(
            ProfileEntity.NONADMIN.getProfileEntityType(),
            ProfileType.CONNECTIONS.getProfileType());
    if (isEmail(profile.getReqId())) {
      parameters.put(ProfileRequestParams.EMAIL, profile.getReqId());
    } else {
      parameters.put(ProfileRequestParams.USERID, profile.getReqId());
    }

    if (parameters.get("connectionType")
        != null) // this is to remove any other values put in by sample user in following
    parameters.remove("connectionType"); // mandatory parameters
    if (parameters.get("outputType") != null) parameters.remove("outputType");
    parameters.put("connectionType", "colleague");
    parameters.put("outputType", "profile");

    data = executeGet(url, parameters, ClientService.FORMAT_XML);
    colleagues = Converter.convertToProfiles(this, data);

    if (logger.isLoggable(Level.FINEST)) {
      logger.exiting(sourceClass, "getColleagues");
    }
    return colleagues;
  }