Bug 1124630 - RFE: zanata-client should use jersey instead of resteasy
Summary: RFE: zanata-client should use jersey instead of resteasy
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Zanata
Classification: Retired
Component: Component-Maven
Version: client-3.3
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: client-3.7
Assignee: Patrick Huang
QA Contact: Ding-Yi Chen
URL:
Whiteboard:
Depends On:
Blocks: 1124615 1171529
TreeView+ depends on / blocked
 
Reported: 2014-07-30 00:59 UTC by Patrick Huang
Modified: 2017-05-31 01:52 UTC (History)
4 users (show)

Fixed In Version: commit eec55675829ea6d53a719645837c50d2cad112d4
Doc Type: Bug Fix
Doc Text:
Story Points: 5
Clone Of:
Environment:
Last Closed: 2015-07-30 01:57:51 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1124615 None None None Never

Internal Links: 1124615

Description Patrick Huang 2014-07-30 00:59:54 UTC
Description of problem:
When installing zanata-client in fedora, it downloads over 200m from the network. Actual download size may vary depending on what packages you have already installed. The biggest contributor to this is resteasy. I tested on a fresh rawhide build. The required download for each packages respectively:
jersey 102m
resteasy 278m
zanata-client 285m

In other words, if zanata-client depends on jersey instead of resteasy, we will save users 170m from download.  

Version-Release number of selected component (if applicable):
3.3.2-3

How reproducible:
Always

Steps to Reproduce:
1. Build a new VM using fedora 20,21 or rawhide image
2. Run yum install zanata-client

Actual results:
Need to download over 200m

Expected results:
For a command line tool, this is way to big.

Additional info:
At the moment resteasy is pulling down massive dependencies whereas jersey is not. There is no guarantee this will always be the case in future fedora. Jersey may not be the only option either.

Comment 1 Carlos Munoz 2014-07-30 05:18:46 UTC
We have estimated story points for switching the client from using Resteasy to a leaner library in Fedora. 
It was also noted that using Resteasy interfaces to invoke clients is discouraged.
Discussed replacement options where:
- Apache HttpClient
- Jersey
- Direct curl invocation (not probable since it would break platform independence)

All of these would reduce the transitive dependency size.

Comment 2 Patrick Huang 2014-10-30 04:55:36 UTC
After a bit of digging, it's a lot more involved then I thought.

First we need to migrate from RESTEasy specific things to JAX-RS api (Use JAX-RS interface only). This includes but not limited to:
- in zanata API change all ClientResponse<T> to JAX-RS Response
- in zanata API org.zanata.rest.DocumentFileUploadForm to remove the dependency to RESTEasy multipart and to use generic JAX-RS. Seems possible http://stackoverflow.com/a/20477172/345718
- in zanata API remove @Wrapped annotation from SourceDocsResource and ProjectsResource. Looks like we don't have to use it? http://stackoverflow.com/a/11775245/345718
- remove all the IXXXResource proxy interfaces as they won't be used anymore.
- change server to implement this new zanata API (actual implementation may not change too much. Just the annotation and returned type has changed. Maybe some more configuration for multipart to work.)
- in Zanata client change ZanataProxyFactory to use JAX-RS client API(I've tried it and it works for the normal end points but haven't tried the multipart one)
- figure out how to make disableSSLCert work in this new client API http://stackoverflow.com/questions/6047996/ignore-self-signed-ssl-cert-using-jersey-client

Comment 3 Patrick Huang 2014-10-30 05:00:41 UTC
jersey version in f21 and rawhide: 1.17.1

Comment 4 Patrick Huang 2014-10-30 23:02:27 UTC
Another thought:
We may only need to change the return type to Response and remove/replace RESTEasy annotation from API. The server could stay the same. After all what the client sees should be just XML/JSON payload.
This means: 
- we could move the @Wrapped annotation to server
- either move org.zanata.rest.DocumentFileUploadForm to server or figure out a way to use JAX-RS annotation only.

Comment 5 Sean Flanigan 2014-11-03 01:44:05 UTC
Patrick, you could use (eg) org.zanata.rest.service.SourceDocResource in the client (as in the server), instead of org.zanata.rest.client.ISourceDocResource.  It's already using plain JAX-RS Response return types rather than ClientResponse.  Or you might want to use org.zanata.rest.enunciate.SourceDocResource

By "move the @Wrapped annotation to server", I assume you mean move it to (zanata-server)/SourceDocResourceService instead of (zanata-api)/SourceDocResource.  That sounds okay, but perhaps GenericEntity is more portable?

Comment 6 Patrick Huang 2014-12-02 00:54:01 UTC
https://github.com/zanata/zanata-client/pull/37

Comment 7 Ding-Yi Chen 2014-12-04 23:39:03 UTC
Tested with commit ffcc07caa662d87b7d801703b808d2d03ee2469d

Push with tar-1.26
==   ][ERROR] Operation failed: Invalid syntax for the expression '%5Ba-zA-Z0-9%5D+(%5Ba-zA-Z0-9_%5C-,{.}%5D*%5Ba-zA-Z0-9%5D+)%3F' associated with the name 'id'

    To retry from the last document, please set the following option(s):

        --from-doc "tar"

.
[ERROR] Execution failed: 
java.lang.RuntimeException: Invalid syntax for the expression '%5Ba-zA-Z0-9%5D+(%5Ba-zA-Z0-9_%5C-,{.}%5D*%5Ba-zA-Z0-9%5D+)%3F' associated with the name 'id'
        at org.zanata.client.commands.push.PushCommand.pushCurrentModule(PushCommand.java:428)
        at org.zanata.client.commands.push.PushCommand.run(PushCommand.java:199)
        at org.zanata.client.commands.ConfigurableCommand.runWithActions(ConfigurableCommand.java:106)
        at org.zanata.client.commands.ArgsUtil.runCommand(ArgsUtil.java:48)
        at org.zanata.client.ZanataClient.processArgs(ZanataClient.java:170)
        at org.zanata.client.ZanataClient.main(ZanataClient.java:95)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Invalid syntax for the expression '%5Ba-zA-Z0-9%5D+(%5Ba-zA-Z0-9_%5C-,{.}%5D*%5Ba-zA-Z0-9%5D+)%3F' associated with the name 'id'
        at com.sun.jersey.api.uri.UriTemplateParser.parseName(UriTemplateParser.java:390)
        at com.sun.jersey.api.uri.UriTemplateParser.parse(UriTemplateParser.java:282)
        at com.sun.jersey.api.uri.UriTemplateParser.<init>(UriTemplateParser.java:154)
        at com.sun.jersey.api.uri.UriTemplate.createURIComponent(UriTemplate.java:799)
        at com.sun.jersey.api.uri.UriTemplate.createURIWithStringValues(UriTemplate.java:769)
        at com.sun.jersey.api.uri.UriTemplate.createURIWithStringValues(UriTemplate.java:720)
        at com.sun.jersey.api.uri.UriTemplate.createURI(UriTemplate.java:663)
        at com.sun.jersey.api.uri.UriBuilderImpl._build(UriBuilderImpl.java:661)
        at com.sun.jersey.api.uri.UriBuilderImpl.build(UriBuilderImpl.java:641)
        at org.zanata.rest.client.ClientUtil.resolvePath(ClientUtil.java:69)
        at org.zanata.rest.client.AsyncProcessClient.startSourceDocCreationOrUpdate(AsyncProcessClient.java:68)
        at org.zanata.client.commands.push.PushCommand.pushSrcDocToServer(PushCommand.java:499)
        at org.zanata.client.commands.push.PushCommand.pushCurrentModule(PushCommand.java:384)
        ... 11 more
Caused by: java.util.regex.PatternSyntaxException: Illegal repetition near index 34
%5Ba-zA-Z0-9%5D+(%5Ba-zA-Z0-9_%5C-,{.}%5D*%5Ba-zA-Z0-9%5D+)%3F
                                  ^
        at java.util.regex.Pattern.error(Pattern.java:1924)
        at java.util.regex.Pattern.closure(Pattern.java:3104)
        at java.util.regex.Pattern.sequence(Pattern.java:2101)
        at java.util.regex.Pattern.expr(Pattern.java:1964)
        at java.util.regex.Pattern.group0(Pattern.java:2854)
        at java.util.regex.Pattern.sequence(Pattern.java:2018)
        at java.util.regex.Pattern.expr(Pattern.java:1964)
        at java.util.regex.Pattern.compile(Pattern.java:1665)
        at java.util.regex.Pattern.<init>(Pattern.java:1337)
        at java.util.regex.Pattern.compile(Pattern.java:1022)
        at com.sun.jersey.api.uri.UriTemplateParser.parseName(UriTemplateParser.java:366)
        ... 23 more

Comment 8 Patrick Huang 2014-12-05 03:03:15 UTC
fixed in last commit

Comment 9 Ding-Yi Chen 2014-12-08 01:00:58 UTC
As the fix verified in maven client but not yet packed to fedora, I change the title and other fields to reflect this.

VERIFIED with eec55675829ea6d53a719645837c50d2cad112d4

Comment 10 Sean Flanigan 2017-05-31 01:52:52 UTC
See also https://github.com/zanata/zanata-api/pull/22 for related API changes.


Note You need to log in before you can comment on or make changes to this bug.