Welcome to the new Box Support website. Check out all the details here on what’s changed.

NullPointerException on BoxFolder.Info method after folder creation

Answered
New post

Comments

7 comments

  • cbetta

     where is the code that calls getIsExternallyOwned?

    0
    Comment actions Permalink
  • konady

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

    0
    Comment actions Permalink
  • 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
    Comment actions Permalink
  • konady

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

    0
    Comment actions Permalink
  • 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
    Comment actions Permalink
  • 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
    Comment actions Permalink
  • konady

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

    0
    Comment actions Permalink

Please sign in to leave a comment.