• jersey client usage

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #19460  by ikawalec
 
Hi everyone, firstly I must thank you for great product which for sure openKM is!

I'm just starting working with openKM. My point is to extend search / indexing engine in semantic direction.
I've added front end extension responsible for adding some extra metadata to document. It's available as a tab when you click on particular document.
Extension is called GeoSpatialDocumentPropertiesTab and it extends TabDocumentExtension.
Result:
Screen: http://postimage.org/image/7j5zcpnh3/

Now I've got additional external system already written which is responsible for semantic data processing which offers REST API.
Example: when you access link below (through browser or curl)
http://localhost:9090/geospatialsis/res ... 6d59566894
it will produce xml:
Code: Select all
<document-properties>
<area>
<points>
<latitude>12.0</latitude>
<longitude>31.0</longitude>
</points>
<radius>100</radius>
<type>POINT</type>
</area>
<period>
<from>2012-11-22T03:01:39.202+01:00</from>
</period>
<place>
<apartmentNumber>915</apartmentNumber>
<buildingNumber>4</buildingNumber>
<continent>EUROPE</continent>
<country>Poland</country>
<city>Wroclaw</country>
<street>Swietokrzyska</street>
<zipCode>51-231</zipCode>
</place>
<uuid>284b4b9e-8b1a-4bb7-aee1-7a6d59566894</uuid>
</document-properties>
Inside my extension I want to call rest get method using jersey-client.
I've already added dependency in pom.xml:
Code: Select all
    <!--  jersey client -->
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-client</artifactId>
      <version>1.8</version>
    </dependency>
I wrote DocumentPropertyService with simple methods like: get, add
Example (get method)
Code: Select all
Client c = new Client();
WebResource r = c.resource("http://localhost:9090/geospatialsis/rest-api/document-properties/284b4b9e-8b1a-4bb7-aee1-7a6d59566894");
		
ClientResponse cr = r.accept("application/xml").get(ClientResponse.class);
		
if(cr.getStatus() == 200){
	DocumentProperties d = cr.getEntity(DocumentProperties.class);
} else {
	throw new RuntimeException("Failed to load rest resource. Error code: " + cr.getStatus());
}
DocumentProperties it just simple dto class with xml annotations:
Code: Select all
@XmlRootElement(name="document-properties") 
public class DocumentProperties {
	
	private String uuid;
	private Place place;
	private Area area;
	private Period period;
	
	@XmlElement(name="uuid")
	public String getUuid() {
		return uuid;
	}
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}
..
So my questions are:
1) Where should I put dto classes (in which package?) Should I also made some changes in xml somewhere to inform that I want to use this class in GeoSpatialDocumentPropertiesTab?
2) Where should I put my DocumentPropertyService class?

I tried to put dto classes and service class in com.openkm.extension.dao and later in com.openkm.dao
but whenever I try to create and access mentioned classes I got compilation error in GeoSpatialDocumentPropertiesTab.java in import statement.

Even thought when I just call jersey-client directly from GeoSpatialDocumentPropertiesTab I get error like:
Code: Select all
[INFO] com.google.gwt.dev.jjs.InternalCompilerException: Failed to get JNode
[INFO] 	at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:140)
[INFO] 	at com.google.gwt.dev.jjs.impl.TypeMap.get(TypeMap.java:71)
[INFO] 	at com.google.gwt.dev.jjs.impl.BuildTypeMap.getType(BuildTypeMap.java:730)
[INFO] 	at com.google.gwt.dev.jjs.impl.BuildTypeMap.access$000(BuildTypeMap.java:99)
[INFO] 	at com.google.gwt.dev.jjs.impl.BuildTypeMap$BuildDeclMapVisitor.visit(BuildTypeMap.java:195)
[INFO] 	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.traverse(LocalDeclaration.java:237)
[INFO] 	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:239)
[INFO] 	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1239)
[INFO] 	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:687)
[INFO] 	at com.google.gwt.dev.jjs.impl.BuildTypeMap.createPeersForNonTypeDecls(BuildTypeMap.java:637)
[INFO] 	at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:514)
[INFO] 	at com.google.gwt.dev.jjs.impl.BuildTypeMap.exec(BuildTypeMap.java:523)
[INFO] 	at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:599)
[INFO] 	at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:33)
[INFO] 	at com.google.gwt.dev.Precompile.precompile(Precompile.java:284)
[INFO] 	at com.google.gwt.dev.Precompile.precompile(Precompile.java:233)
[INFO] 	at com.google.gwt.dev.Precompile.precompile(Precompile.java:145)
[INFO] 	at com.google.gwt.dev.Compiler.run(Compiler.java:232)
[INFO] 	at com.google.gwt.dev.Compiler.run(Compiler.java:198)
[INFO] 	at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
[INFO] 	at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
[INFO] 	at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
[INFO] 	at com.google.gwt.dev.Compiler.main(Compiler.java:177)
[INFO]       [ERROR] <no source info>: public class com.sun.jersey.api.client.Client
[INFO] 	extends Unresolved type com.sun.jersey.api.client.filter.Filterable
[INFO] 	implements : Unresolved type com.sun.jersey.api.client.ClientHandler
I went through the wiki and I know that you are using webservices, but jersey client should also work here (am I wrong?)
Probably I don't have enough knowledge about openKM, if you have any other ideas how to solve accessing data from rest api in quicker / nicer way just please let me know.

Sorry, if my question are trivial. Hope that I make myself clear.
Thanks in advice for replay.
 #19486  by jllort
 
I think I understand your problem. Basically if you want to show data to GWT can not instance classes directly ( because can not be compiled under GWT take a look here that can help you to understanding https://developers.google.com/web-toolk ... patibility, basically the GWT idea is with some JAVA emulation convert to javascript, that mean not all java api and obviously thirdparty libraries can not be accessed directly to GWT ).

To get data into GWT you should serialize objects across RPC :
Here are defined remote services http://doxygen.openkm.com/6.2.x/da/df5/ ... rvice.html
Which are implemented into servlets http://doxygen.openkm.com/6.2.x/d6/dc1/ ... ntend.html
And called by gwt classes for example here http://doxygen.openkm.com/6.2.x/dd/ddb/ ... ument.html to with more in deep http://doxygen.openkm.com/6.2.x/d0/d86/ ... ource.html look how is used
Code: Select all
private final OKMPropertyGroupServiceAsync propertyGroupService = (OKMPropertyGroupServiceAsync) GWT.create(OKMPropertyGroupService.class);
Basically the idea is :
Your GWT class call servlet which call some logic ( or implements ) and return values which are serialized by GWT ( object or collections of objects ).

Into this package will be good place to build it http://doxygen.openkm.com/6.2.x/d9/ded/ ... nsion.html here you can define your beans http://doxygen.openkm.com/6.2.x/dd/dd0/ ... 1bean.html your widget extensions http://doxygen.openkm.com/6.2.x/db/d14/ ... idget.html your services http://doxygen.openkm.com/6.2.x/d7/d36/ ... rvice.html and your servlet http://doxygen.openkm.com/6.2.x/df/da2/ ... rvlet.html

Hope this can help you in some way

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.