REST API Java Wrapper

For anyone interested in using the REST API, I have written a small java wrapper library to assist in automating action running, content manipulation and Webreports relevance queries.

Comments, suggestions and questions are welcome.

1 Like

Is it possible to run this lib using jdk6?

I have switched the library to use java 1.6. If you have any problems or questions, feel free to open issues on the github page.

Great! Thanks a lot.

Thanks for the contribution, very helpful.

For those that may be interested, there is also a python wrapper, written by @hansen_m :


Thanks a lot for your action, but I failed to build the new package…

error log as follows:

[root@rhel6 github]# git clone https://github.com/eyce9000/iem4j.git
Initialized empty Git repository in /opt/github/iem4j/.git/
remote: Counting objects: 705, done.
remote: Total 705 (delta 0), reused 0 (delta 0), pack-reused 705
Receiving objects: 100% (705/705), 234.52 KiB | 123 KiB/s, done.
Resolving deltas: 100% (375/375), done.
[root@rhel6 github]# ls
floripa-mobi-frontend-master iem4j
floripa-mobi-frontend-master.zip iem-client.tar
[root@rhel6 github]# cd iem4j/
[root@rhel6 iem4j]# ls
LICENSE pom.xml README.md schema src
[root@rhel6 iem4j]# mvn package
[INFO] Scanning for projects…
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building IEM Client 1.2.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] — buildnumber-maven-plugin:1.3:create (default) @ iem4j-client —
[INFO] Executing: /bin/sh -c cd /opt/github/iem4j && git rev-parse --verify HEAD
[INFO] Working directory: /opt/github/iem4j
[INFO] Storing buildNumber: 7c766ac40e414ab77c77c53c1ed1c554fd9751ab at timestamp: 1432969922218
[INFO] Storing buildScmBranch: master
[INFO]
[INFO] — cxf-xjc-plugin:2.3.0:xsdtojava (generate-xsd-sources) @ iem4j-client —
[INFO]
[INFO] — build-helper-maven-plugin:1.9.1:add-source (default) @ iem4j-client —
[INFO] Source directory: /opt/github/iem4j/target/generated-sources/java added.
[INFO]
[INFO] — maven-resources-plugin:2.6:resources (default-resources) @ iem4j-client —
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 9 resources
[INFO]
[INFO] — maven-compiler-plugin:3.2:compile (default-compile) @ iem4j-client —
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 122 source files to /opt/github/iem4j/target/classes
[INFO] /opt/github/iem4j/src/main/java/com/github/eyce9000/iem/api/ClientBuilderWrapper.java: Some input files use or override a deprecated API.
[INFO] /opt/github/iem4j/src/main/java/com/github/eyce9000/iem/api/ClientBuilderWrapper.java: Recompile with -Xlint:deprecation for details.
[INFO] /opt/github/iem4j/src/main/java/com/github/eyce9000/iem/api/impl/AbstractIEMAPI.java: /opt/github/iem4j/src/main/java/com/github/eyce9000/iem/api/impl/AbstractIEMAPI.java uses unchecked or unsafe operations.
[INFO] /opt/github/iem4j/src/main/java/com/github/eyce9000/iem/api/impl/AbstractIEMAPI.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ iem4j-client —
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /opt/github/iem4j/src/test/resources
[INFO]
[INFO] — maven-compiler-plugin:3.2:testCompile (default-testCompile) @ iem4j-client —
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 3 source files to /opt/github/iem4j/target/test-classes
[INFO]
[INFO] — maven-surefire-plugin:2.12.4:test (default-test) @ iem4j-client —
[INFO] Surefire report directory: /opt/github/iem4j/target/surefire-reports


T E S T S

Running com.github.eyce9000.iem.api.webreports.RelevanceQueryTest
javax.xml.bind.UnmarshalException

  • with linked exception:
    [Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.XMLMarshalException
    Exception Description: An error occurred unmarshalling the document
    Internal Exception: java.io.FileNotFoundException: config/test-webreports.xml (No such file or directory)]
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.handleXMLMarshalException(JAXBUnmarshaller.java:980)
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:126)
    at com.github.eyce9000.iem.api.webreports.RelevanceQueryTest.setupClass(RelevanceQueryTest.java:47)
    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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
    Caused by: Exception [EclipseLink-25004] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.XMLMarshalException
    Exception Description: An error occurred unmarshalling the document
    Internal Exception: java.io.FileNotFoundException: config/test-webreports.xml (No such file or directory)
    at org.eclipse.persistence.exceptions.XMLMarshalException.unmarshalException(XMLMarshalException.java:113)
    at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:328)
    at org.eclipse.persistence.oxm.XMLUnmarshaller.unmarshal(XMLUnmarshaller.java:367)
    at org.eclipse.persistence.jaxb.JAXBUnmarshaller.unmarshal(JAXBUnmarshaller.java:123)
    … 22 more
    Caused by: java.io.FileNotFoundException: config/test-webreports.xml (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.(FileInputStream.java:146)
    at org.eclipse.persistence.internal.oxm.record.SAXUnmarshaller.unmarshal(SAXUnmarshaller.java:321)
    … 24 more
    Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 1.95 sec <<< FAILURE!
    testSessionRelevanceQuery(com.github.eyce9000.iem.api.webreports.RelevanceQueryTest) Time elapsed: 0.023 sec <<< ERROR!
    java.lang.NullPointerException
    at com.github.eyce9000.iem.api.webreports.RelevanceQueryTest.setUp(RelevanceQueryTest.java:58)
    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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

testParser(com.github.eyce9000.iem.api.webreports.RelevanceQueryTest) Time elapsed: 0.006 sec <<< ERROR!
java.lang.NullPointerException
at com.github.eyce9000.iem.api.webreports.RelevanceQueryTest.setUp(RelevanceQueryTest.java:58)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Running com.github.eyce9000.iem.api.tools.RelevanceTranslatorTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

Results :

Tests in error:
testSessionRelevanceQuery(com.github.eyce9000.iem.api.webreports.RelevanceQueryTest)
testParser(com.github.eyce9000.iem.api.webreports.RelevanceQueryTest)

Tests run: 3, Failures: 0, Errors: 2, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.851 s
[INFO] Finished at: 2015-05-30T15:12:19+08:00
[INFO] Final Memory: 25M/287M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project iem4j-client: There are test failures.
[ERROR]
[ERROR] Please refer to /opt/github/iem4j/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[root@rhel6 iem4j]#