Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting canViewPath parameter for collabs always returns false #569

Closed
1 task done
jasonpan12 opened this issue Mar 8, 2018 · 2 comments
Closed
1 task done

Getting canViewPath parameter for collabs always returns false #569

jasonpan12 opened this issue Mar 8, 2018 · 2 comments
Labels
bug Added to issues that describes SDK bug

Comments

@jasonpan12
Copy link

Description of the Issue

Hey guys! Writing in on behalf of a Japanese customer, while I don't have a Java test environment myself so apologies in advance for any Java faux pas.

In response to #560, it looks like getCanViewPath
It always returns "false" even though the actual value should be "true".
It seems that the value of canViewPath can only be retrieved/returned when it is set, but can't be get'd. Instead, the value always seems to return false.

Versions Used

Java SDK: Version is 2.14.0
Java: // Replace with the version of Java your application is running on.

Steps to Reproduce

-----Summary------
//invite the target user to the target folder (canviewpath=true)
String trueCollaboId = folder.collaborate(user,
BoxCollaboration.Role.EDITOR, false, true).getID();
System.out.println(trueCollaboId); //Result:13114521128

//Get information of above collaboration. Even though canViewPath is
true, result is always false.
BoxCollaboration trueCollabo = new BoxCollaboration(api, trueCollaboId);
BoxCollaboration.Info trueCollaboInfo = trueCollabo.getInfo();
System.out.println(trueCollaboInfo.getCanViewPath()); //Result:false
System.out.println(trueCollaboInfo.getRole()); //Result:EDITOR
System.out.println(trueCollaboInfo.getStatus()); //Result:ACCEPTED
-----Summary------

-----Details------
Version is 2.14.0

//Enter box credential (Let me skip details about the credential here)
BoxAPIConnection api;
//Target folder
BoxFolder folder = new BoxFolder(api, "removed");
//Target user
BoxUser user = new BoxUser(api, "removed");

/** canviewpath=true **/
//invite the target user to the target folder (canviewpath=true)
String trueCollaboId = folder.collaborate(user,
BoxCollaboration.Role.EDITOR, false, true).getID();
System.out.println(trueCollaboId); //Result: collab_id value

//Get information of above collaboration. Even though canViewPath is
true, result is always false.
BoxCollaboration trueCollabo = new BoxCollaboration(api, trueCollaboId);
BoxCollaboration.Info trueCollaboInfo = trueCollabo.getInfo();
System.out.println(trueCollaboInfo.getCanViewPath()); //Result:false
System.out.println(trueCollaboInfo.getRole()); //Result:EDITOR
System.out.println(trueCollaboInfo.getStatus()); //Result:ACCEPTED

// Set canviewpath=true via setCanViewPath, then call getCanViewPath, it
returns true.
trueCollaboInfo.setRole(BoxCollaboration.Role.VIEWER);
trueCollaboInfo.setCanViewPath(true);
System.out.println(trueCollaboInfo.getCanViewPath()); //Result:true
System.out.println(trueCollaboInfo.getRole()); //Result:VIEWER
System.out.println(trueCollaboInfo.getStatus()); //Result:ACCEPTED

// Do the updateInfo to make sure
trueCollabo.updateInfo(trueCollaboInfo);
System.out.println(trueCollaboInfo.getCanViewPath()); //Result:true
System.out.println(trueCollaboInfo.getRole()); //Result:VIEWER
System.out.println(trueCollaboInfo.getStatus()); //Result:ACCEPTED

// Get it as a different object, it returns false even though the actual
value is true
BoxCollaboration trueCollabo2 = new BoxCollaboration(api, trueCollaboId);
BoxCollaboration.Info trueCollaboInfo2 = trueCollabo2.getInfo();
System.out.println(trueCollaboInfo2.getCanViewPath()); //Result:false
System.out.println(trueCollaboInfo2.getRole()); //Result:VIEWER
System.out.println(trueCollaboInfo2.getStatus()); //Result:ACCEPTED

/** canviewpath=false**/
// Delete the collaboration first
trueCollabo.delete();
// invite the target user to the target folder (canviewpath=false)
String falseCollaboId = folder.collaborate(user,
BoxCollaboration.Role.EDITOR, false, false).getID();
System.out.println(falseCollaboId); //Result:13114516801

// Get information of above collaboration. Result is false and that is
expected.
BoxCollaboration falseCollabo = new BoxCollaboration(api, falseCollaboId);
BoxCollaboration.Info falseCollaboInfo = falseCollabo.getInfo();
System.out.println(falseCollaboInfo.getCanViewPath()); //Result:false
System.out.println(falseCollaboInfo.getRole()); //Result:EDITOR
System.out.println(falseCollaboInfo.getStatus()); //Result:ACCEPTED

// Call setCanViewPath to set canviewpath=true
falseCollaboInfo.setRole(BoxCollaboration.Role.VIEWER);
falseCollaboInfo.setCanViewPath(true);
System.out.println(falseCollaboInfo.getCanViewPath()); //Result:true
System.out.println(falseCollaboInfo.getRole()); //Result:VIEWER
System.out.println(falseCollaboInfo.getStatus()); //Result:ACCEPTED

// Do the updateInfo to make sure
falseCollabo.updateInfo(falseCollaboInfo);
System.out.println(falseCollaboInfo.getCanViewPath()); //Result:true
System.out.println(falseCollaboInfo.getRole()); //Result:VIEWER
System.out.println(falseCollaboInfo.getStatus()); //Result:ACCEPTED

// Get it as a different object, it returns false even though the actual
value is true
BoxCollaboration falseCollabo2 = new BoxCollaboration(api, falseCollaboId);
BoxCollaboration.Info falseCollaboInfo2 = falseCollabo2.getInfo();
System.out.println(falseCollaboInfo2.getCanViewPath()); //Result:false
System.out.println(falseCollaboInfo2.getRole()); //Result:VIEWER
System.out.println(falseCollaboInfo2.getStatus()); //Result:ACCEPTED
-----Details----

Error Message, Including Stack Trace

Ehh... just the above?

@mattwiller
Copy link

@jasonpan12 I think this is the same issue as #386 — basically, can_view_path is not a field that is returned by default and since the type of the field is the primitive boolean the BoxCollaboration.Info object defaults it to false when it's not set on the object.

Unfortunately, the SDK does not currently provide a way to request the field; we can fix that! I'll get to that ASAP since it's a quick fix. Once we have the fix made, the necessary code will look something like this:

BoxCollaboration.Info falseCollaboInfo = falseCollabo.getInfo("role", "status", "can_view_path");

This whole class of issue is an unfortunate side-effect of using primitives to store these values in the SDK — definitely something we want to address at a higher level throughout the SDK.

@jasonpan12
Copy link
Author

awwww YISSSSSSS

thanks very much for the great explanation and quick reply :)

@mattwiller mattwiller added the bug Added to issues that describes SDK bug label May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Added to issues that describes SDK bug
Projects
None yet
Development

No branches or pull requests

2 participants