Nuxeo quick reference - easysoa/EasySOA GitHub Wiki
NB. see also Developing on the service registry for debugging, testing & more development reference, and Using Nuxeo IDE for using Nuxeo IDE (not mandatory).
- source root and how to get it
- javadoc
- [Nuxeo Explorer] (http://explorer.nuxeo.org/nuxeo/site/distribution/current) for bundles, components (and services), extension points & contributions (configuration), automation operations
- to override configuration (extension definitions) : create a new component ("component" XML file) and register it in OSGI-INF/MANIFEST.MF (in "Nuxeo-Component:"), copy in it all extension definitions you wish to override and patch them, and "require" each of their original components at the beginning of this one (so that this one will come after).
- TODO for assembly and (marketplace) packaging
- document types : see in [OSGI-INF/CoreExtensions.xml] (http://explorer.nuxeo.org/nuxeo/site/distribution/current/viewComponent/org.nuxeo.ecm.core.CoreExtensions) in nuxeo-core-xxx.jar in $NUXEO_HOME/nxserver/bundles
- document metadata schemas : see main default ones in schema/ and others in schema directories in source
- [query reference & examples (NXQL)] (https://doc.nuxeo.com/display/NXDOC/NXQL)
- how to get the Nuxeo source, to be able to target it when your IDE wants to open the source of Java code being executed
- Nuxeo online documentation about layouts and widgets
- Layout widget complete list, avaible on your local Nuxeo.
- Online Nuxeo showcase for layout widgets
- An article explaining how to use generic widgets in layout.
In the end, the best reference is Nuxeo's own source code. So get it (see above) and search in it to find useful examples, using for instance "find" command lines such as:
- *find . -name "xml" -exec grep "id="newDocument" {} ; -print for configuration (XML contributions).
- *find . -name "java" -exec grep "selectionActions"" {} ; -print for java class.
- *find . -name "xhtml" -exec grep "f:param" {} ; -print for xhtml templates.
- overriding default templates : copy to another file name, modify them and refer to their file name in a "template" widget
- overriding default Seam beans : create an inheriting class and @Install it using a higher precedence, see http://answers.nuxeo.com/questions/411/how-configuring-the-default-page-after-the-user-connexion
- overriding other stuff (actions, layouts, widgets) : override them like you would any extension (see above)
- for document : see nxd tld, or source of DocumentModelFunctions javadoc and some tag handlers javadoc.
- for util (base tags) : see nxu tld, or source of Functions javadoc and some tag handlers javadoc.
- for layout : see nxl tld
- for directory : see nxdir tld
- for html, ajax, theme : see full tld of "nxweb" prefixed URIs
(as seen in AbstractWebContext and at http://doc.nuxeo.com/pages/viewpage.action?pageId=11044493 )
- Context : the View extending AbstractWebContext, which provides : i18n (module's messages) & locale, logging, cookies, principal (user), properties (context variables shared among scripts), user session, running scripts, loginPath, headers, request, form and everything below (path /url...)
- Root : the controller. So you can put there (or in the ModuleRoot class it extends) code available here that requires the request.
- Module : NOT your own module Class. Provides class loading, adapters & resources, validators.
- Runtime : Framework.getRuntime()
- Engine : WebEngine
- basePath : /nuxeo/site
- skinPath : /nuxeo/site/skin/easysoa
- contextPath : /nuxeo
- This : the Web Object if any
- Document : its (adapted) DocumentModel if any
- Adapter : the adapter of the first WebEngine resource having one, starting from the controller
- Session : CoreSession
- & what's put by controller
- Freemarker doesn't support null. So use instead something different from your normal variable type, like "" (empty string) if it is an object, and test which one it is using builtins like ?string and ?is_hash (for objects). Don't use ?is_string on Java objects, because the may return ?is_string == true ! Also, calls to Java methods returning null actually return an empty string.
- macro don't support optional parameters, so pass instead something you can test not to be your normal variable type, like an empty string if it should be an object (see above).
See also Developing on the service registry.
Simply remove the nxserver/data
folder from Nuxeo (in the EasySOA package, Nuxeo is filed under the serviceregistry
folder).
Open bin/nuxeo.conf
and uncomment the "DEBUGGING" options line:
# Sample JPDA settings for remote socket debugging
JAVA_OPTS=$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
You can switch suspend=n
to suspend=y
if you want to monitor Nuxeo right from the start (Java will wait for you to connect with Eclipse before to start Nuxeo).
You can use a special software like (CMIS Workbench)[http://chemistry.apache.org/java/developing/tools/dev-tools-workbench.html]. The address where the Nuxeo CMIS is published is : [http://localhost:8080/nuxeo/atom/cmis]
Error :
com.google.inject.ProvisionException: Guice provision errors:
1) null returned by binding at org.nuxeo.runtime.test.runner.RuntimeFeature.bind0(RuntimeFeature.java:196)
but org.nuxeo.snapshot.AbstractTestSnapshot.session is not @Nullable
at org.nuxeo.runtime.test.runner.RuntimeFeature.bind0(RuntimeFeature.java:196)
while locating org.nuxeo.ecm.core.api.CoreSession
Solution :
In your test annotations, change cleanup to Granularity.CLASS in
@RepositoryConfig(type = BackendType.H2, init = PublishRepositoryInit.class, user = "Administrator", cleanup = Granularity.METHOD)
In iteration, "c:" tags (ex. "c:if") and those derived from them (ex. "nxu:set") can't be used. Rather, replace "c:if" by "h:panelGroup rendered=test" and set cache="false" on "nxu:set".
It is not done by "+" but by either by putting them along each other in an EL expression, [using <c:set var="s" value="${s1} ${s2}"/>
beforehand] (http://stackoverflow.com/questions/296398/concatenate-strings-in-jsp-el), or defining a [custom concat() function] (http://stackoverflow.com/questions/2192759/concatenate-strings-in-jsf-jsp-el-and-javascript).
-
How to return collections in jaxrs / jaxb / cxf (without going to Spring conf) : create a strong-typed collection class ex. ExchangeRecordCollection See http://dhruba.name/2008/12/08/rest-service-example-using-cxf-22-jax-rs-10-jaxb-and-spring/#comment-781 NB. resteasy provides additional non-standard annotations for that : @Wrapped http://stackoverflow.com/questions/6192389/root-element-name-in-collections-returned-by-resteasy
-
How to handle a reference to another object not as an object but as its id : XmlJavaTypeAdapter See http://docs.oracle.com/javase/6/docs/api/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.html
-
How to automatically convert java objects to JSON with a JAX RS service : Some annotation need to ba added on the method :
@GET
@Path("/getExchangeRecordStorelist")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public StoreCollection getExchangeRecordStorelist() { ...
@Produces to tell that the returned type can be a json string. The returned java object, here StoreCollection must have some annotations :
@XmlRootElement
public class StoreCollection {
private Collection<ExchangeRecordStore> stores;
...
@XmlElement(name="ExchangeRecordStore")
@XmlElementWrapper(name="stores")
public Collection<ExchangeRecordStore> getStores() {
return stores;
}
}
Simply create a class that extends ModuleRoot class. Then add JAX-RS annotations to publish the service and at least one method to generate the response. You have to create a contrib file in OSGI-INF folder to start the mock in Nuxeo.
For a complete example see the MockServer class and the contrib file.
Source code for the mock class. in this sample, we create a mock server exposed on path "/mock" with one operation "wsdl". This operation needs a String parameter "wsdlResource" and produces a text/xml result.
@Path("/mock")
@Produces("text/xml;charset=UTF-8")
@WebObject(type = "MockServer")
public class MockServer extends ModuleRoot {
@GET
@Path("wsdl/{wsdlResource}")
public Object doGet(@PathParam("wsdlResource") String wsdlResource) throws Exception {
...
// Get the wsdl file list
....
for(File file : fileList){
// If the requested file is in the list return it
if(file.getName().toLowerCase().contains(wsdlResource.toLowerCase())){
return FileUtils.readFileToString(file);
}
}
throw new Exception("Resource '" + wsdlResource + "' not found");
}
}
Source code for the contrib file
<?xml version="1.0" encoding="UTF-8"?>
<component name="org.easysoa.registry.doctypes.core.mock.wsdlMockServer" version="1.0">
<implementation class="org.easysoa.registry.mock.MockServer" />
</component>