We're updating the issue view to help you get more done. 

Zanata Client API (old endpoints support)

Description

There are bugs regarding old endpoint handling when transition from JAX-RS1 to JAX-RS2 was done using latest develop branch.

This code does not work as intended when connecting to old endpoint, because 404 is now an exception ResponseProcessingException:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 Response response = webResource.request(MediaType.APPLICATION_XML_TYPE) .put(Entity.entity(resource, MediaType.APPLICATION_XML_TYPE)); if (RestUtil.isNotFound(response)) { // fallback to old endpoint response.close(); String idNoSlash = RestUtil.convertToDocumentURIId(docId); webResource = getBaseServiceResource(client) .path("r") .path(idNoSlash) .queryParam("ext", extensions.toArray()) .queryParam("copyTrans", String.valueOf(copyTrans)); response = webResource.request(MediaType.APPLICATION_XML_TYPE) .put(Entity.entity(resource, MediaType.APPLICATION_XML_TYPE)); }

It should be something like:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 try { Response response = webResource.request(MediaType.APPLICATION_XML_TYPE) .get(); return response.readEntity(Resource.class); } catch (ResponseProcessingException e) { if (RestUtil.isNotFound(e.getResponse())) { // fallback to old endpoint String idNoSlash = RestUtil.convertToDocumentURIId(docId); webResource = getBaseServiceResource(client) .path("r") .path(idNoSlash) .queryParam("ext", extensions.toArray()); return webResource.request(MediaType.APPLICATION_XML_TYPE) .get(Resource.class); } throw e; }

SourceDocResourceClient.java: getResource
SourceDocResourceClient.java: putResource
SourceDocResourceClient.java: deleteResource
TransDocResourceClient.java: getTranslations
AsyncProcessClient.java: startSourceDocCreationOrUpdateWithDocId
AsyncProcessClient.java: startTranslatedDocCreationOrUpdateWithDocId

Environment

None

Status

Assignee

Alex Eng

Reporter

MatejM

Tested Version/s

None

Sprint

None

Fix versions

Affects versions

platform-4.2.4

Priority

unspecified