Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Alfresco module that exposes a Clojure API to access the repository.
Clojure Java Shell
branch: master

This branch is 51 commits ahead, 6 commits behind skuro:master

README.md

Lambdalf -- Clojure support for Alfresco

Lambdalf logo

This library adds Clojure support to the open source Alfresco Content Management System. Specifically, it:

  • adds an idiomatic Clojure wrapper around (an increasing %age of) the Alfresco Java API
  • provides support for implementing Alfresco extension points in Clojure, including behaviours, and web scripts
  • adds an nREPL server to the Alfresco server (disabled by default - requires administrator rights to enable), allowing for productive REPL-style experimentation and development within Alfresco
  • packages all of this, along with the Clojure runtime, into an Alfresco Module Package (AMP file) that 3rd party code can depend on (thereby minimising conflicts between multiple independent Clojure extensions)

Packaging

Due to the way Alfresco's AMP module mechanism works, lambdalf is shipped as an AMP file in addition to the clojars artifacts (which are used for development only). It is this AMP artifact that should be deployed to a running Alfresco server, prior to the deployment of your own AMP.

Your code should also be packaged as an AMP (using the lein amp plugin), and must include a module dependency on lambdalf in order to prevent an Alfresco administrator from inadvertently deploying your AMP without first deploying the lambdalf AMP. If you use the lein AMP template (strongly recommended) to create your project, these dependencies will be configured for you automatically.

Installing lambdalf into Alfresco

Download the latest lambdalf AMP file from the releases page, then install it just like any other AMP (i.e. using Alfresco's MMT tool).

Opening a REPL

For security reasons (i.e. it opens a massive script injection attack hole!) the nREPL server included in lambdalf is not running by default. To enable it (keeping in mind that it opens a massive script injection attack hole!) an administrator-only HTTP POST Web Script is provided at /alfresco/service/clojure/nrepl. For a default installation of Alfresco on localhost, you can run:

    $ curl -u admin:admin -X POST http://localhost:8080/alfresco/service/clojure/nrepl

to enable the nREPL server. The Web Script's JSON response includes the port that the nREPL server is running on (default is 7888). From there you can use leiningen's built-in nREPL client to connect to the nREPL server:

    $ lein repl :connect 7888

See below for some example Clojure expressions that can validate the installation (although being able to connect is itself a good sign that everything's hunky dory).

To disable the nREPL server, you may issue an HTTP DELETE to the same Web Script:

    $ curl -u admin:admin -X DELETE http://localhost:8080/alfresco/service/clojure/nrepl

You may also query the status of the nREPL server via an HTTP GET:

    $ curl -u admin:admin http://localhost:8080/alfresco/service/clojure/nrepl

Developing with lambdalf

The best way to get started developing with lambdalf is to use the lein AMP template to generate a skeleton AMP project for you. We highly recommend starting out this way to get familiar with the structure of an AMP project, and to get familiarity with lambdalf, AMPs and the deployment process.

For those upgrading an existing AMP project, the latest version of lambdalf is:

version

Here's some sample code from an nREPL session connected to a running Alfresco repository. Note that there are better ways to get a handle to the Company Home nodeRef. Note also that unlike Alfresco's native Java API, each ResultSet is automatically closed after a search.

    user> (require '[alfresco.auth :as a])
    nil
    user> (require '[alfresco.search :as s])
    nil
    user> (require '[alfresco.nodes :as n])
    nil
    user> (def company-home
              (a/as-admin
               (first
                (s/query "PATH:\"/*\" AND TYPE:\"cm:folder\""))))
    #'user/company-home
    user> (clojure.pprint/pprint
       (a/as-admin
        (n/properties company-home)))
    {"sys:store-identifier" "SpacesStore",
     "cm:modifier" "System",
     "cm:title" "Company Home",
     "cm:description" "The company root space",
     "sys:store-protocol" "workspace",
     "app:icon" "space-icon-default",
     "sys:node-dbid" 13,
     "cm:created" #<Date Sun Sep 04 15:11:18 CEST 2011>,
     "sys:node-uuid" "43356014-0428-4e86-9490-e78a6c0c48ef",
     "cm:modified" #<Date Sun Sep 04 15:11:18 CEST 2011>,
     "cm:name" "Company Home",
     "cm:creator" "System"}
    nil

Developer Information

GitHub project

Bug Tracker

License

Copyright © 2011-2014 Carlo Sciolla

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Something went wrong with that request. Please try again.