Problem wit Rest API Extension executing Tahiti Vacation Management example

1
0
-1

When executing Tahiti Vacation Management example from https://github.com/Bonitasoft-Community/vacation-management-example I am able to run the application, however when logging as a manager I don't see the vacation requests sent by other employees. Since this information is retrieved using the rest-api-extension I believe this might be a problem with that extension, but apparently everything is correctly deployed.

Can anybody help me assessing this error?

Alternatively is there any way I can debug the extension? I tried including in the extension code (Index.groovy) the following code to check if it was executed, but no file was created.

def file1 = new File('c:/groovy1.txt')
file1.write 'Executing Rest Api Extension for Tahiti.\n'

Thanks in advance.
Jorge

Comments

Submitted by Sean McP on Tue, 04/04/2017 - 11:18

What does the log say? Anything?

Submitted by diazbesjorge on Thu, 04/06/2017 - 13:10

Hi Sean, thanks for pointing that out, I hadn't realized logs are accessible directly through the studio. This is what I get in the Engine log:

2017-04-04 11:26:58.094 +0200 SEVERE: org.bonitasoft.console.common.server.page.RestApiRenderer Error when executing rest api extension call to apiExtension|GET|vacationRequest
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(Unknown Source)
    ...
Submitted by Sean McP on Tue, 04/04/2017 - 22:06

well the problem is:

2017-04-04 11:26:58.094 +0200 SEVERE: org.bonitasoft.console.common.server.page.RestApiRenderer Error when executing rest api extension call to apiExtension|GET|vacationRequest
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

So it looks like the REST call is getting nothing then trying to do something with it.

I would log before the for() loop to find out what's happening,

regards
Seán

1 answer

1
0
-1

OK, I found out the problem. It happens in this piece of code:

// If vacation request is pending
                if(currentUserVacationRequest.status == "pending") {
                    // Search for "Review request" task id using "New Vacation Request" process instance id store in business variable "VacationRequest"
                    reviewRequestTaskId = processAPI.getHumanTaskInstances(currentUserVacationRequest.newRequestProcessInstanceId, REVIEW_REQUEST_TASK_NAME, 0, 1).get(0).id
                }

The problem in my case is that there are pending vacation requests but the associated human tasks can't be found anymore. I guess this is due to several tests and deployments done during development. Basically the vacation requests persisted in memory but the process instances (HumanTaskInstances) didn't. Could it be related to my current database settings in Bonita preferences?

The way I'm currently solving it is by adding a try-catch block (maybe something to be included in the original code):

        // If vacation request is pending
        if(currentUserVacationRequest.status == "pending") {
            // Search for "Review request" task id using "New Vacation Request" process instance id store in business variable "VacationRequest"
                try {
                    reviewRequestTaskId = processAPI.getHumanTaskInstances(currentUserVacationRequest.newRequestProcessInstanceId, REVIEW_REQUEST_TASK_NAME, 0, 1).get(0).id
                }
                catch (Exception e) {
                    LOGGER.severe("No human task instance was found for the following request: "+currentUserVacationRequest);
                }
        }
Notifications