Alfresco Developer Guide source reorg and 3.2 Community update

[UPDATE: Added a link to the source code that works with 3.2 Enterprise]

I originally wrote the Alfresco Developer Guide source code for Alfresco 2.2 Enterprise and Alfresco 3 Labs. The code was pretty much the same regardless of which one you were running. For things that did happen to be different, I handled those with separate projects: one for community-specific stuff and one for enterprise-specific stuff. This was pretty much limited to minor web script differences for the “client extensions” projects and LDAP configuration differences for the “server extension” project.

With the release of 3.2 Community, I realized:

  • The number of different flavors of Alfresco any given reader might be running are going up, not down. Who knows when 2.2 Enterprise will be sunset.
  • It is no longer as easy as “Enterprise” versus “Labs/Community” because multiple releases of the same flavor are prevalent (2.2E, 3.0E, and 3.1E, for example).
  • Tagging my code in Subversion by Chapter alone is no longer enough–I need to tag by Chapter and by Alfresco version.
  • Sending the publisher the code one chapter at-a-time and expecting them to manage updates and deciding how to organize all of the chapter code was a bad idea.

So, I’ve done some work to make this better (reorg the projects, restructure the download files). I’ve also tested the example code from each chapter against the latest service packs for all releases since 2.2 Enterprise. That includes making some small updates to get the examples running on 3.2 Community.

You can now download either all of the source for every version I tested against, or, download the source that works for a specific version. It may take the official download site at Packt a while to get the new files, so here are links to download them from my site:

Alfresco Developer Guide example source code for…

  • Alfresco 2.2 Enterprise (~5.3 MB, Download)
  • Alfresco 3.0 Labs (~5.6 MB, Download)
  • Alfresco 3.0 Enterprise (~5.7 MB, Download)
  • Alfresco 3.1 Enterprise (~5.6 MB, Download)
  • Alfresco 3.2 Community (~5.7 MB, Download)
  • Alfresco 3.2 Enterprise (~5.9 MB, Download)
  • All of the above, combined (~28.1 MB, Download)

Hopefully this makes it easier for you to grab only what you need and makes it clear that each Eclipse project contains only what’s needed to work with that version of Alfresco. Deployment is easier too. Most of the time, it’s just the “someco-client-extensions” project that you deploy.

Now that I’ve got everything structured like I want it, as new versions of Alfresco are released, it should be much easier to keep up.

34 comments

  1. Jeff,

    Thank you for updating your sample code to the latest version, and separating the code into version-specific releases. I appreciate the efforts of an author to keep a book relevant — and thus useful to readers — when the targeted platform keeps evolving.

    -Tom

  2. Dirk says:

    Hi Jeff,

    congratulations also from my part! i pay high tribute to your travails in the alfresco project, which are so helpful to get the volatile elephant under control!

    after one year working intensely with Alfresco i must say, the complexity of the code and configuration, together with the half-hearted modularization (restart for nearly every extension!) makes one pay a high price for the conceptional ingeniousness. for this reason people like you are so important for the community!

    Thanks a lot for sharing your knowledge!!

    Dirk

  3. Michael Muller says:

    I’m trying to learn how to develop and deploy workflows in Alfresco’s WCM module using your book.

    I downloaded your sample code for enterprise 3.1 and followed the instructions in your readme, but the workflow is not visible in alfresco.

    I can make the workflow appear by adding a workflow deployer spring bean in a context file. Did you forget to document a step?

    Thanks,

    — Mike

  4. jpotts says:

    You have three primary choices when deploying workflows, all of which are in the book:
    * You can use the workflow console (p.285),
    * Use a spring bean in the context file (p.294), as you noted,
    * You can deploy using the deploy tab on the JBoss Graphical Process Designer Eclipse plug-in (p.286, p.291), which is my favorite approach during development.

    You can also use Ant or the jBPM API which I mention (p.294) but don’t show examples of because they don’t seem common, at least for Alfresco projects.

    In any case, thanks for reading and I’m glad you got yours working!

    Jeff

  5. Al says:

    Hi Jeff,

    I’ve been going through your book. It’s a very good resource. The step by step approach is great!

    I’m having a problem though and can’t figure out what I’m doing wrong. In chapter 4, there’s a bean created called “policyLogger”

    However, when I start Tomcat, I get an error stating that opsDoc has not been added to the dictionary model. But, I’m see it in the scModel.xml file and all my other dictionary definitions are loading fine. Can you shed some light for me please?

    BTW, I tried adding to the bean definition depends-on”someco.dictionaryBootstrap”. When I did that, Tomcat did not complain and I was able to get into Alfresco, but the behavior is not running when I create a sc:opsDoc (I confirmed log4j.prop is set correctly to debug… but no messages).

    I’m really excited about getting through your book. Thanks so much for a great product.

    Best,
    Al

  6. Al says:

    Nevermind. I did fix it with the depends-on attribute. FYI, the way the code is written right now, Spring tries to load the PolicyLogger bean before the someco.dictionaryBootstrap. if you modify the PolicyLogger bean as follows, it works:

    [code]

    [/code]

    The reason I was not seeing the debug logs was due to my log4j.property file being in two places. I inadvertently updated the wrong log4j.property file. However, without the “depends-on” attribute added to the bean above, I was getting Tomcat errors. Now it all works!

    Thanks again for a great book, Jeff. I am starting to get a feel for the power of Alfresco. I wake every day excited to become a little more proficient with Alfresco via your step by step book.

    Best,
    Al

  7. Al says:

    I guess it does not like the [code][/code] tags as I’m not seeing the bean in my code. Oh well, here it is again if anyone stumbles across it:

    That will get rid of your “opsDoc Class does not exist in the dictionary model” exception.

  8. Al says:

    bean id=”policyLogger” class=”com.someco.behaviour.PolicyLogger” init-method=”init” depends-on=”someco.dictionaryBootstrap”

  9. Pedro Saraiva says:

    Hello,

    I’m trying to run your code from the chapter 4. After deployment I start Alfresco server and it gaves an exception about not finding pdfbox and log4j. The two jars are in WEB-INF/lib.. so what I’m missing?

    Thanks!

  10. Pedro Saraiva says:

    Hello,

    I’m running Alfresco 3.2r2 Community.
    I’m trying to implement a listener to integrate with another system that will be triggered when a file (or folder) is created, deleted, updated and versioned. I’ve follow your steps to create a behaviour and bind to policies. However, if I bind the “onCreateVersion”, the version system stops working giving this error on the web interface when I try to access a version of the document:

    The node’s content is missing:
    node: versionStore://version2Store/832c5cae-d7e8-4945-96db-5cbb3169b0b9
    reader: null
    Please contact your system administrator.

    On the javadoc of the method there’s this warning:

    WARNING: implementing behaviour for this policy effects the versioning behaviour of the type the behaviour is registered against.

    How can I make this work right?

    Thanks for your time,

    Pedro Saraiva

  11. jpotts says:

    Pedro,

    I’ve never bound anything to onCreateVersion so I don’t know for sure how well it does/doesn’t work. I wonder if Alfresco already has something bound to that behavior and is doing something with the node before you get a chance to do anything with it. It looks like the node you’re getting is pointing to the version store. Is there a way you could get the workspace node and work with that instead? I’m just taking a few wild guesses here. You’ll probably have better luck in the forums on this one.

    Jeff

  12. jpotts says:

    You may have figured this out already but between 3.2 Community and 3.2R Community, Alfresco upgraded pdfbox to the Apache incubating version. If you change the SomeCo extracter classes to point to org.apache.pdfbox instead of org.pdfbox, that will address the pdfbox problem. The other change is that log4j is no longer being distributed with the SDK or the web app. You can grab log4j-1.2.15.jar and place it in the SDK’s library for compile purposes and WEB-INF/lib for run-timer purposes.

    Jeff

  13. jpotts says:

    I don’t have any solid plans at the moment. Alfresco has a new book coming out in April or May. Depending on how much overlap there is, I would consider doing an update for 3.3 or 3.4 which are shaping up to be fairly major releases.

    Jeff

  14. Pauli says:

    I’m encouraged to see that you’re considering doing a new edition covering 3.3 or 3.4. Depending on your reply to my question below, maybe I’ll wait for it.

    How much of the current release would be useful for someone working with Alf CE 3.3 — if said someone knows Ruby, a bit of javascript, xsd/xpath/xml, html, css, C/C++/C#, php, sql and basic linux admin — but doesn’t know anything about Java, beans, or application servers.

    I’m concerned that minor differences between the releases will have broken the sample code you have for 3.2 (linked above) in 3.3, and that I won’t be able to troubleshoot easily, because the development environment is foreign.

  15. Ray says:

    Hi Jeff, amazing book.
    I guess there’s something missing in my buildpath cause there is an error in my BootstrapAuthorityCreator.java

    From what I see I can’t acces
    import org.alfresco.service.cmr.security.MutableAuthenticationService;

    my project can’t seem to find the interface.
    any hints, thoughts on this?

    my thanks in advance

  16. jpotts says:

    What release of Alfresco are you using? I think some of the auth stuff changed in 3.2. If you give me a specific version I can check to see if I validated against it.

    Jeff

  17. jpotts says:

    I haven’t tried my source on 3.3 so I don’t know what issues are there. The main thing about the book is that it covers fundamentals that are core to the platform. Much of those fundamentals haven’t changed between 2.x and 3.x.

    Honestly, if you’re going to do any work with Alfresco, you’re going to have to get comfortable searching through the web app config files and source code. You might as well bite the bullet and use the book to help you climb the curve even if you have to address a couple of tweaks here and there. I do assume readers are Java coders, but with your coding experience, you’ll be fine.

    Jeff

  18. Hi Jeff, still making my way through your fantastic book. On page 104, the variable activeFlag on this line of code:
    boolean activeFlag = (Boolean)action.getParameterValue
    (PARAM_ACTIVE);

    Should probably be declared as a Boolean, not boolean.

    Also, steps 9 and 10 – that set up variables and imports used by code in earlier steps – really should be steps 2 and 3. Personally, I was creating the class in Eclipse as I read and was a bit frustrated at not knowing if I was doing something wrong because there was PARAM_RESULT in ActionExecutor, but no PARAM_ACTIVE.

    Thanks again for the great book.

    Rob
    🙂

  19. hello says:

    hello thanks ,
    iam new in alfresco,
    i use your someco tutoriel
    bat in the someco-client-extensions-ch6
    i have probleme with tomcat
    HTTP Status 404 –

    ——————————————————————————–

    type Status report

    message

    description The requested resource () is not available.

    ——————————————————————————–

    Apache Tomcat/6.0.18

  20. vijay pandey says:

    hi jpotts

    I am very happy to look your code . i am new in alfresco. so please give me steps to run any projects …

    Thanks
    Vijay Pandey

  21. fursten says:

    Hello,

    Im using alfresco community v 3.2r2.

    As far as I understand, your code in chapter 9 wasnt to this version of alfresco. For instance, I was not able to find a “ldap-authentication-context.xml.sample”.

    However, the code for the 3.2 version you have in this page seems to correspond to the code of your book in what concerns to ldap configuration… Is this correct? Because I was expecting to see something about subsystems like the code for the enterpise edition.

    Finally, cam you tell be if it is a good practice to configure ldap inside the global properties file. I see a lot examples on the net doing this…

    thank you

  22. jpotts says:

    Correct. The book was written before 3.2, so the text does not talk about the newer subsystems configuration. However, the sample code for Chapter 9 for 3.2 Enterprise does include a subsystems directory. It is in the someco-server-extensions Eclipse project.

    I like seeing the ldap props set in the global properties file because it centralizes your properties in that file. The drawback is the properties are “further away” from your XML config. If you are using the out-of-the-box configuration, then that isn’t a big deal. If you are changing both, it might be a small nuisance temporarily while you fine-tune your configuration.

  23. suman says:

    Hi Jeff,

    I am making some changes for Approve/Reject workflow.My requirement is to send the email to the reviewer with 2 links for approve and reject.So the approve/reject to be done from email it self.
    I saw your chapter 7 example, but i m not able to finish successfully.

    Can you help how I can do it?

    Thanks

  24. jpotts says:

    Suman,

    You might be able to get more timely help from the Alfresco forums. Still, if you have some specific questions, feel free to post them here and I will see what I can do to help.

    Jeff

  25. Prem Kumar says:

    Dear Jeff

    I have brought your Book ALFRESCO DEVELOPER GUIDE

    I wish to use the Alfresco Explorer to customize an existing Alfresco DMS, in which i have stored/uploaded docs with xml info. now i wish to develop a UI to Query the DMS with respect to the XML data.

    Kindly tell me how should go about.

    With regards
    Prem

Comments are closed.