2016-09-01 4 views
0

WebサービスコールでユーザーのprofilePicURLを取得したいとします。
私はそのユーザーのuserIdを持っています。私はSystem.out.println(themeDisplay)をしたとき、私はLiferay:serviceImplクラスのThemeDisplayを使わないでuser profilePicURLを取得するには?

public String getProfilePicURL(long userId) throws SystemException, 
     PortalException { 
    String url = ""; 

    ServiceContext serviceContext = ServiceContextThreadLocal 
      .getServiceContext(); 
    ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); 

    User user = UserLocalServiceUtil.getUser(userId); 

    try { 
     url = user.getPortraitURL(themeDisplay); 
    } catch (PortalException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } finally { 
     return url; 
    } 
} 

をしようとしています何
これは、それは私がこれを達成するための他の方法を知らないnull
として出てきました。

変更する必要はありますか?

答えて

1

UserConstants.getPortraitURL(imagePath, male, portraitId); UserConstants liferayのクラスを使用できます。

+0

ありがとうDevz、 ここでimagePathとは何ですか? 私はそこに何を渡すべきか分かりません。 ありがとう –

+0

「/画像」です。 – Devz

+0

こんにちはDevz、 私はそれを理解しました。 そして、私は 'themeDisplay.getPathImage()'を試みましたが、themeDisplay nullを取得しているのと同じ問題に戻ります。 –

関連する問題