コード例 #1
0
  /**
   * @param userId
   * @return User
   * @throws Exception
   */
  public UserDetail getUserDetail(String userId) throws Exception {
    UserDetail ud = null;
    try {
      // Set the OrganizationSchema (if not already done)
      getOrganizationSchema();

      // Get the user information
      UserRow ur = getOrganization().user.getUser(idAsInt(userId));
      if (ur == null) {
        throw new AdminException(
            "DomainDriverManager.getUser",
            SilverpeasException.ERROR,
            "admin.EX_ERR_USER_NOT_FOUND",
            "user Id: '" + userId + "'");
      }

      // Get a DomainDriver instance
      DomainDriver domainDriver = this.getDomainDriver(ur.domainId);

      // Get User detail from specific domain
      try {
        ud = domainDriver.getUser(ur.specificId);
      } catch (AdminException e) {
        SilverTrace.error(
            "admin",
            "DomainDriverManager.getUser",
            "admin.MSG_ERR_GET_USER",
            "user Id: '" + userId + "', domain Id: '" + ur.domainId + "'",
            e);
        ud = new UserDetail();
        ud.setLogin(ur.login);
        ud.setFirstName(ur.firstName);
        ud.setLastName(ur.lastName);
        ud.seteMail(ur.eMail);
      }

      // Fill silverpeas info of user details
      ud.setId(userId);
      ud.setSpecificId(ur.specificId);
      ud.setDomainId(idAsString(ur.domainId));
      ud.setAccessLevel(ur.accessLevel);
    } catch (AdminException e) {
      throw new AdminException(
          "DomainDriverManager.getUser",
          SilverpeasException.ERROR,
          "admin.EX_ERR_GET_USER",
          "user Id: '" + userId + "', domain Id: '" + userId + "'",
          e);
    } finally {
      releaseOrganizationSchema();
    }
    return ud;
  }
コード例 #2
0
 /**
  * @param user
  * @throws Exception
  */
 @Override
 public void updateUserDetail(UserDetail user) throws Exception {
   try {
     // Get a DomainDriver instance
     DomainDriver domainDriver = this.getDomainDriver(idAsInt(user.getDomainId()));
     // Update User detail in specific domain
     domainDriver.updateUserDetail(user);
   } catch (AdminException e) {
     throw new AdminException(
         "DomainDriverManager.updateUser",
         SilverpeasException.ERROR,
         "admin.EX_ERR_UPDATE_USER",
         user.getFirstName() + " " + user.getLastName(),
         e);
   }
 }
コード例 #3
0
 @Override
 public void resetEncryptedPassword(UserDetail user, String encryptedPassword) throws Exception {
   try {
     // Get a DomainDriver instance
     DomainDriver domainDriver = this.getDomainDriver(idAsInt(user.getDomainId()));
     // Update User detail in specific domain
     domainDriver.resetEncryptedPassword(user, encryptedPassword);
   } catch (AdminException e) {
     throw new AdminException(
         "DomainDriverManager.resetEncryptedPassword",
         SilverpeasException.ERROR,
         "admin.EX_ERR_UPDATE_USER",
         "userId : " + user.getId(),
         e);
   }
 }
コード例 #4
0
  /**
   * Create a new User.
   *
   * @param user
   * @return
   * @throws Exception
   */
  @Override
  public String createUser(UserDetail user) throws Exception {
    try {
      // Get a DomainDriver instance
      DomainDriver domainDriver = this.getDomainDriver(idAsInt(user.getDomainId()));

      // Create User in specific domain
      String sUserId = domainDriver.createUser(user);
      return sUserId;
    } catch (AdminException e) {
      throw new AdminException(
          "DomainDriverManager.createUser",
          SilverpeasException.ERROR,
          "admin.EX_ERR_ADD_USER",
          user.getFirstName() + " " + user.getLastName(),
          e);
    }
  }
コード例 #5
0
ファイル: User.java プロジェクト: LAOSChool/Android
  public static User parseFromJson(String jsonString) {
    try {
      User user = new User();
      JSONObject mainObject = new JSONObject(jsonString);
      user.setId(mainObject.getInt("id"));
      user.setSso_id(mainObject.getString("sso_id"));
      user.setFullname(mainObject.getString("fullname"));
      user.setNickname(mainObject.getString("nickname"));
      user.setPhone(mainObject.getString("phone"));
      user.setState(mainObject.getString("state"));
      user.setSchool_id(mainObject.getInt("school_id"));
      user.setRoles(mainObject.getString("roles"));
      user.setSchoolName(mainObject.getString("schoolName"));
      user.setPhoto(mainObject.getString("photo"));
      user.setGender(mainObject.getString("gender"));
      // User detail
      UserDetail userDetail = new UserDetail();
      userDetail.setAddr1(mainObject.getString("addr1"));
      userDetail.setAddr2(mainObject.getString("addr2"));
      userDetail.setPhone(mainObject.getString("phone"));
      userDetail.setExt(mainObject.getString("ext"));
      userDetail.setPhoto(mainObject.getString("photo"));
      userDetail.setBirthday(mainObject.getString("birthday"));
      userDetail.setGender(mainObject.getString("gender"));
      userDetail.setEmail(mainObject.getString("email"));
      // Class
      JSONArray classarray = mainObject.getJSONArray("classes");
      List<Class> classes = new ArrayList<Class>();
      for (int i = 0; i < classarray.length(); i++) {
        JSONObject eclassObj = classarray.getJSONObject(i);
        Class eclass = new Class();
        eclass.setId(eclassObj.getInt("id"));
        eclass.setSchool_id(eclassObj.getInt("school_id"));
        eclass.setTitle(eclassObj.getString("title"));
        eclass.setLocation(eclassObj.getString("location"));
        try {
          eclass.setTerm(eclassObj.getInt("term"));
        } catch (JSONException e) {
          Log.w("UserProfile", "term in class is null");
        }
        eclass.setYears(eclassObj.getString("years"));
        eclass.setYear_id(eclassObj.getInt("year_id"));
        eclass.setStart_dt(eclassObj.getString("start_dt"));
        eclass.setEnd_dt(eclassObj.getString("end_dt"));
        eclass.setHead_teacher_id(eclassObj.getInt("head_teacher_id"));
        eclass.setHeadTeacherName(eclassObj.getString("headTeacherName"));
        classes.add(eclass);
        Log.d("", eclass.toString());
      }

      // user.setEclass(eclass);
      user.setUserDetail(userDetail);
      user.setClasses(classes);
      if (classes.size() > 0) user.setEclass(classes.get(0));
      // Return user
      return user;
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
  }