About Me

Please scroll down (bottom of the page) to see links to previous posts.

Thursday, December 27, 2007

Alfresco : Build Environment

How to setup Eclipse IDE for ECM projects.
Alfresco Development Setup
  1. Download form the customer portal alfresco-enterprise-tomcat-2.1.1.zip
  2. Make a folder {projectname} under your main drive.
  3. Create 2 folders under the {projectname} folder, workalfresco and deployalfresco.
  4. Extract the downloaded zip file in both these folders.
  5. Run Alfresco once before proceeding further.
  6. Download & Extract the SDK alfresco-enterprise-sdk-2.1.1.zip, in a temporary folder.
  7. Import the SDK in eclipse (Europa).
    • Create a new eclipse workspace. You can call it {projectname}EWS. (EWS stands for Eclipse WorkSpace).
    • Select File - Import..
    • General - Existing...
    • Select Root and Browse...
    • Browse to the the folder where the SDK was extracted.
    • Eclipse finds the projects that can be imported, the one that is required is SDKAlfrescoEmbedded. Although I typically select all, so that I can refer to source code examples.
    • Make sure that 'Copy projects into WorkSpace' is selected.
    • It will take some time for this activity to finish (have some coffee).

  8. Download the {projectname} project from Source Control, and configure it as a project in eclipse. Some teams like to share a zip file on ftp, extract it in temp folder and then import it as a project in eclipse. Just like above. If you are building from scratch then the {projectname} project will consist of the following directory structure...

The Build Process
  1. The build.xml file for this project does the work of building a jar file (for java classes) and a zip file containing both the jar above and the web resources like jsp, ftl, js, xml etc.
  2. In the middle of development if we need to reflect any change to the web resources only (those that do not need a restart of tomcat) then the ant target dev-refresh should be used.
  3. In case of a java or configuration xml change, the ant target dev-restart should be used, this will stop the running tomcat, compile and build all resources, inject the change in alfresco.war and starts tomcat
  4. NOTE: care should be taken for resource files that are deleted, as the build for dev does not start with a fresh war and will carry old, deleted files unless a fresh war is taken. This will not happen on production.
  5. So far everything is on the 'work' copy of alfresco and nothing on the deploy. Well the deploy is only for simulating production so the prod-restart ant target will do that. Make sure you have an old (the one that you started with for the first time) alfresco.war file with you.
  6. Here's how all the targets look like...

Thursday, December 13, 2007

Alfresco : ViewOne Pro Integration

  1. Download the V1Pro.zip from www.daeja.com. Give a legitimate email address as the trial license key will be mailed to this address and there's no way to install without this key.
  2. Extract the zip file, this will yield a directory structure, out of which v1files is the folder that has all the necessary files for configuring ViewOne.
  3. Double Click on the index.htm file in the parent directory, click on the 'Click here to see demonstration' link.
  4. Click the first/second or third demo (doesn't matter to activate the product).
  5. Click yes to trust the applet (no IE browsers) and Yes for installing ActiveX control (IE browser).
  6. Enter the License Key and notice ViewOne Pro installed. I am not sure what settings does the application does next, but it does appear to now start recognizing the lic.v1 file as a valid 14 day license.
  7. Copy the v1files directory to tomcat/webapps/alfresco
  8. Custom View under Details View
    1. In Alfresco upload a Presentation Template, that holds the code to display documents via the ViewOne Pro Applet. This template needs to be uploaded in the Data Dictionary/Presentation Templates folder. Our file is docPreview.ftl
    2. For any Custom View configuration of elements (documents or spaces), go to the 'Details View' of that element, click on the custom view and select apply template. In the drop down for templates, select the docPreview.ftl template added above. Notice ViewOne Pro displaying the images/pdfs.
  9. Open the document in a new tab/window
    1. This functionality is possible by modifying the tomcat\webapps\alfresco\jsp\browse\browse.jsp file. In this file, we will find the line %-- Primary column for icons view mode --%. Under this section, replace this a:actionLink id="col11-act2" value="#{r.name}" href="#{r.url}" target="new" styleClass="header" (which is the second link, the first being the icon of the document) with...
      a:actionLink id="col11-act2" value="#{r.name}" href="http://localhost:8080/alfresco/jsp/extension/dashboards/view1pro.jsp?name=#{r.url}" target="new" styleClass="header"
    2. Notice that for the above to work, we will have to add a file view1pro.jsp containing the Applet code to the Alfresco directory. Also notice that the extension directory is not present by default, its what we created.
    3. [TODO] The URL should be taking a relative path rather than a hard reference to localhost:8080.
  10. Finally Viewone in the MySpaces WebScript.
    1. Please refer to the avspaces blog for configuration on your own MySpaces window.
    2. Copy the myspaces_preview_panel.ftl (This is the one that renders the preview window) in tomcat\webapps\alfresco\WEB-INF\classes\alfresco\templates\client to avspaces_preview_panel.ftl. I am not sure why this is kept here, will find it someday [TODO].
    3. A few modifications (which results in avspaces_preview_panel.ftl)
      • include tiff as a mimetype in the isImage variable.
      • include pdf as a mimetype and introduce it via isPdf variable.
      • modify the isImage condition to include isPdf and render both via ViewOne.
      • to render delete the current tag under the center tag and introduce the applet tag.
    4. In the avspaces.js, find the line ~309 "noderef=" + resource.id + "&template=myspaces_preview_panel.ftl" and replace it with a reference to avspaces_preview_panel.ftl above.
    5. Make sure that tomcat is restarted and all the files are correctly picked up, I had to spend 3 hours chasing behind this ghost, until it finally picked up everything correctly. The way you can say whether your file is picked up correctly or not, is by modifying the Update, Edit Details labels in the ftl file, if they change, its being picked up correctly.

Monday, December 10, 2007

Eclipse : Ant Projects

Running Ant From Eclipse

We can run Ant targets from build.xml files from within Eclipse, but there's a little setup you have to do.

Create a new Simple Project (not a Java Project), I call mine "ANT_ProjectName".

  1. Right click on the Ant project and select New > File
  2. Click the Advanced button
  3. Select the option Link to file in the filesystem
  4. Browse for the build.xml file, if you expanaded to c:\alfresco you need to browse to c:\alfresco\common, select build.xml and press the Open button
  5. Enter build.xml in the File name field.
  6. Click Finish

You should now see a link to build.xml in your Ant project. Double-click the file to see the contents. Eclipse also has several options to allow you to run targets in the file.

One way is to use the 'Outline' window as it shows you all the targets in the project. Find the target you want to run and right click. Choose Run As > Ant build.

If you really want to you can also debug the Ant script by placing a breakpoint in build.xml and choosing Debug As > Ant Build.