Devan is an Adobe CRX/JCRclient.
The easiest way to get started is by taking a look at some of the examples written in Java that demonstrate how to work with a CRX/JCR repository.
/* * This Java Quick Start uses the jackrabbit-standalone-2.4.0.jar * file. See the previous section for the location of this JAR file * * Source: http://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-using.html */importjavax.jcr.Repository; importjavax.jcr.Session; importjavax.jcr.SimpleCredentials; importjavax.jcr.Node; importorg.apache.jackrabbit.commons.JcrUtils;
importorg.apache.jackrabbit.core.TransientRepository; publicclassGetRepository { publicstaticvoidmain(String[] args) throwsException { try { //Create a connection to the CQ repository running on local host Repositoryrepository = JcrUtils.getRepository("http://localhost:4502/crx/server");
//Create a Sessionjavax.jcr.Sessionsession = repository.login( newSimpleCredentials("admin", "admin".toCharArray())); //Create a node that represents the root nodeNoderoot = session.getRootNode(); // Store content Nodeadobe = root.addNode("adobe"); Nodeday = adobe.addNode("cq"); day.setProperty("message", "Adobe Experience Manager is part of the Adobe Digital Marketing Suite!");
// Retrieve content Nodenode = root.getNode("adobe/cq"); System.out.println(node.getPath()); System.out.println(node.getProperty("message").getString()); // Save the session changes and log outsession.save(); session.logout();
}
catch(Exceptione){
e.printStackTrace();
}
} }The example above is rewritten as follows using Devan.
require'devan'beginrepository=Devan::Repository.new('http://localhost:4502')repository.login(Devan::Credentials.new('admin','admin'))root=repository.getRootNode()adobe=root.addNode("adobe")day=adobe.addNode("cq")day.setProperty("message","Adobe Experience Manager is part of the Adobe Digital Marketing Suite!")node=root.getNode("adobe/cq")putsnode.getPath()putsnode.getProperty("message")repository.saverepository.logoutrescueDevan::Error=>eputse.backtrace.join("\n")endNow let's take a look at a 'file upload' example and its equivalent using
Devan.
/* Source: http://wiki.apache.org/jackrabbit/ExamplesPage*/publicNodeimportFile (NodefolderNode, Filefile, StringmimeType,
Stringencoding) throwsRepositoryException, IOException
{
//create the file node - see section 6.7.22.6 of the specNodefileNode = folderNode.addNode (file.getName (), "nt:file");
//create the mandatory child node - jcr:contentNoderesNode = fileNode.addNode ("jcr:content", "nt:resource");
resNode.setProperty ("jcr:mimeType", mimeType);
resNode.setProperty ("jcr:encoding", encoding);
resNode.setProperty ("jcr:data", newFileInputStream (file));
CalendarlastModified = Calendar.getInstance ();
lastModified.setTimeInMillis (file.lastModified ());
resNode.setProperty ("jcr:lastModified", lastModified);
returnfileNode;
}The example above is rewritten as follows using Devan.
defimportFile(folderNode,file,mimeType,encoding)fileNode=folderNode.addNode(File.basename(file.path),"nt:file")resNode=fileNode.addNode("jcr:content","nt:resource")resNode.setProperty("jcr:mimeType",mimeType);resNode.setProperty("jcr:encoding",encoding);resNode.setProperty("jcr:data",Devan::Binary.new(file));resNode.setProperty("jcr:lastModified",Devan::DateTime.new(file.mtime));fileNodeend- Proper Test Suite
- Documentation via TomDoc
- Fork the project.
- Make your feature addition or bug fix.
- Do not bump the version number.
- Send me a pull request. Bonus points for topic branches.
Copyright (c) 2013 - 2014, Mihail Szabolcs
Devan is provided as-is under the MIT license. For more information see LICENSE.