SimplePagedRequest breaking Plugin when using paged Response


#1

Hi,

writing a Jira plugin beiing able to use JiraServiceDesk OrganizationService breaks in case of accessing PagedResponse due to static declaration of “ONE” in SimplePagedRequest (com.atlassian.servicedesk.api.util.paging).

Example:
e.g.:
try {
OrganizationService organizationService = ComponentAccessor.getOSGiComponentInstanceOfType(OrganizationService.class);
ApplicationUser appUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
// The type com.atlassian.pocketknife.api.commons.error.AnError cannot be resolved
// check if avialable in vesion 3.6.2
Either<AnError, PagedResponse> orgResultListEither = organizationService.getOrganizations(appUser, orgQueryTmp);

		Either<AnError, PagedResponse<CustomerOrganization>>.RightProjection rightSide = orgResultListEither.right();
		PagedResponse<CustomerOrganization> pagedResponse = rightSide.get();

		List<CustomerOrganization> orgResultList = pagedResponse.getResults();
		for (CustomerOrganization org : orgResultList) {
			// this is harsh ...
			String orgStringId = new Integer(org.getId()).toString();
			organizationMap.put(orgStringId, org.getName());
			logger.info(MessageFormat.format("Adding org with Id: {0} and name {1}", orgStringId, org.getName()));
		}

} catch (Exception e) {
// JSD Service NOT available
}

Above code works well, even in case JSD is NOT present. Adding paged support to the above code:

PagedRequest pagedRequest = new SimplePagedRequest(0, myPageLimit);

results in adding the dependency (through import) of:
import com.atlassian.servicedesk.api.util.paging.SimplePagedRequest;

Due to static declaration of “ONE” in SimplePage Request, including the import breaks dynamic usage of the Service within a component declaration caused by the class loader.

Means: Declaring static elements in Classes markes as @PublicAPI (as done in SimplePage) seems to have unwanted impacts on plugins having support for Jira installations with optional JSD support.

From our perspective this is - at least not know - solvable for the existing declared interfaces (of JSD).

Using JSD services should be possible in a dynamic way. This implies that parameter types as well as return types of services should be usable using @PublicAPI marked Jira API interfaces.

Obviously it is useless to change this now, because this won’t have any effect on the existing and released Versions of the JSD API.

Is there anybody else having the same problem? Has anybody else found a dynamic solution to get around?