新しいBoxサポートサイトへようこそ。 変更点の詳細はこちらをご確認ください .

NullPointerException on BoxFolder.Info method after folder creation

回答済み
新規投稿

コメント

7件のコメント

  • cbetta

     where is the code that calls getIsExternallyOwned?

    0
    コメントアクション パーマリンク
  • konady

    The objectmapper uses the getters to convert the object into a JSON string.

    0
    コメントアクション パーマリンク
  • cbetta

    Could you try running the code without the object mapper first? Create the folder, and then try and print out the getIsExternallyOwned value? If that doesn't thrown an error then we know something weird is happening when using the object mapper.

    0
    コメントアクション パーマリンク
  • konady

    I did try running getIsExternallyOwned() by itself and I got the same NullPointerException. 

    0
    コメントアクション パーマリンク
  • sgarlanka

    I believe the issue is that to get that field you need to pass in is_externally_owned to get the fields parameter. It is not part of the standard object returned. So you have to use this method public BoxFolder.Info getInfo(String... fields) . An example of how to use this method can be found here. If you want to get all the field for a folder so you don't have any issues iterating, I would pass in the ALL_FIELDS variable found here.

    0
    コメントアクション パーマリンク
  • konady

    It appears the problem seems to be in the SDK.

     

    The variable, isExternallyOwned, is of type Boolean (Object), whereas the getter returns a boolean (primitive). If the variable is null, it will return a NullPointerException. 

     

    From Java SDK 2.41.0

     

    public class Info extends BoxItem.Info {
    private BoxUploadEmail uploadEmail;
    private boolean hasCollaborations;
    private SyncState syncState;
    private EnumSet permissions;
    private boolean canNonOwnersInvite;
    private boolean isWatermarked;
    private boolean isCollaborationRestrictedToEnterprise;
    private Boolean isExternallyOwned; // This is the only one that is an object
    private Map, Map, Metadata>> metadataMap;
    private List allowedSharedLinkAccessLevels;
    private List allowedInviteeRoles;

    /*This returns a primitive boolean*/
    public boolean getIsExternallyOwned(){
    return this.isExternallyOwned;
    }

     

    0
    コメントアクション パーマリンク
  • konady

    Either way, that getInfo method is a perfect workaround. Thank you so much!

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。