Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Suggestion: ProfileService.checkColleague should catch 404 error and return null #1579

Closed
emmaleisisw opened this issue Jul 11, 2014 · 4 comments
Assignees

Comments

@emmaleisisw
Copy link

In the Java class com.ibm.sbt.services.client.connections.profiles.ProfileService, these two methods can be used to check if two people are colleagues:

  • checkColleague(String,String); and
  • checkColleague(String,String,Map<String,String>).

These use the Connections API for checking whether two people are colleagues.
According to the API document, and confirmed by my testing, this API request produces a 404 error when the specified people are not colleagues and have no pending invitation.

The SBT methods throw an exception when the 404 error occurs. As this particular 404 error is expected behaviour, the SBT methods should catch it and, instead of re-throwing it to the caller, just return null to indicate that the specified people are not colleagues.

@markewallace
Copy link
Contributor

@CarlosManias can you add a task to the backlog to track this request

@CarlosManias
Copy link

Created Task 145373

@emmaleisisw
Copy link
Author

As an interim solution in the application I'm currently working on, I have the following method in a subclass of com.ibm.sbt.services.client.connections.profiles.ProfileService:

public ColleagueConnection checkColleague(String sourceId,String targetId)
    throws ProfileServiceException
{
    try {
        return super.checkColleague(sourceId,targetId);
    } catch (ProfileServiceException e) {
        Throwable cause=e.getCause();
        String cStr=(cause==null?"":cause.toString());
        if (cStr.contains("404 Not Found")) return null;
        throw e;
    }
}

The effect is that if the exception cause contains "404 Not Found", my method just returns null, otherwise it re-throws the exception.

@prb112
Copy link
Contributor

prb112 commented Nov 11, 2015

Fix will be in the next build. changes were required to a lowerlevel code to allow 404 through a checkStatus. I changed that and committed the code. a few other items of code were changed related to
Failed tests: testGetCommunityByInvalidId(com.ibm.sbt.services.client.connections.communities.CommunityServiceNoCommonCommunityTest): Expected exception: com.ibm.sbt.services.client.ClientServicesException
deleteWikiTest(com.ibm.sbt.services.client.connections.wikis.WikiCreateAndDeleteTest): Expected test to throw (an instance of com.ibm.sbt.services.client.ClientServicesException and exception with message a string containing "404:Not Found")
getAndDeleteWikiPageTest(com.ibm.sbt.services.client.connections.wikis.WikiPageTest): Expected test to throw (an instance of com.ibm.sbt.services.client.ClientServicesException and exception with message a string containing "404:Not Found")
getAndDeleteWikiPageTest(com.ibm.sbt.services.client.connections.wikis.WikiPageTest): Expected test to throw (an instance of com.ibm.sbt.services.client.ClientServicesException and exception with message a string containing "404:Not Found")

@prb112 prb112 closed this as completed Nov 11, 2015
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants