Archive by Author

Zia reorganizes code on GitHub

Zia has setup a GitHub organization to better manage team members and our open source code repositories. We have migrated the current project to the new organization and will be migrating our other work.

If you were watching freshdocs/cmsandroid we hope you will switch over to watching ziaconsulting/cmsandroid.

We also plan on migrating the google code project and will soon release our Zoho integration.

Thanks for your patience during this migration.

Connecting to an untrusted certificate in java

Reposted from here

I was getting errors(unable to find valid certification path to requested target) in Alfresco trying to connect to LDAP over ssl using an untrusted certificate and found a great hint on the interwebs that I thought I’d share.

Most of the hits on google mention this post: http://blogs.sun.com/gc/entry/unable_to_find_valid_certification

My only criticism of that article is that it only minimally addresses how to actually use the fixed keystore.  I downloaded their source and hacked it  up a little change the name of the certificate store from “jssecacerts” into “cacert” which is the default certificate store for all java programs.  My goal was to fix the certificate store for the entire machine.

To install an untrusted certificate into your keystore the process is like this:

$ javac InstallCert.java
# Backup the current castore
$ sudo cp $JAVA_HOME/jre/lib/security/cacerts $JAVA_HOME/jre/lib/security/cacerts.bak
$ sudo mv $JAVA_HOME/jre/lib/security/cacerts .
$ sudo java InstallCert <HOST>:<PORT>
# Program is really straight forward
# You can check that it worked by running the same program again, it will tell you if it’s already installed
# You can check the count of the number of certificates before and after running this:
# $ keytool -list -keystore cacerts
$ sudo mv cacerts $JAVA_HOME/jre/lib/security/
# Now just restart your JVM (Alfresco) and it should be able to reach the previously unreachable URL.

 

 

Creating custom JMX MBeans for reporting in Alfresco

JMX rocks.  When configuring a server it is a boon to developers.  Especially when combined with the Alfresco subsystem architecture.  You can interate on changes to the LDAP sync without having to restart the server.  JMX also gives savvy system administrators a way to manage and monitor what’s going on within the repository.

In this tutorial I’ll point you to documents outlining the basics of JMX in Alfresco and show some sample code for creating a new MBean that will appear in a JMX console.

The rest of the post can be read over here.

Introducing Fresh Agenda

Zia Consulting is proud to announce Fresh Agenda.  Agenda Management built directly into Alfresco Share.  Zia has been approached by public entities, such as cities and counties, to build an Agenda Management system that can integrate directly into an existing ECM implementation.

Features include

  • Manage multiple agendas
  • Agendas can have multiple items with sortable attachments
  • Agendas Items can be run through advanced workflow.  Items will also indicate workflow status.
  • Permissions for agendas are managed through standard Share site permissions.
  • Agenda can be distributed as PDFs
  • Agendas can be marked as opened or closed.
Screen shot 2010-11-02 at 3.55.13 PM.png

Multiple Agenda Items

Screen shot 2010-11-02 at 3.57.30 PM.png

Agenda Items show workflow status

Screen shot 2010-11-02 at 3.58.20 PM.png

Workflow transition screens allow users to click on items

Screen shot 2010-11-02 at 4.01.57 PM.png

The final printed document includes chapters for all items and attachments.

Using the patch service to run arbitrary code on AMP install

Reposted from here

###

There seems to be many times that the Alfresco repository needs to be modified when an AMP is first installed e.g. migration of current nodes.  While Alfresco provides a data bootstrap mechanism it appears it is inadequate for anything except the most basic tasks.  This post was predicated on finding a use of the patch service in the WCM installation script.

I haven’t seen many docs on the proper or improper use of the patch service.  At first blush it is used as a Repository internal tool to update the repository during major releases and hotfixes. As I’ve mentioned, the inspiration for this came from the WCM “installation” during which you insert the wcm-bootstrap-context.xml into the repositories classpath and then start it up.  In that file is a new bean that uses the patch service to create a couple of folders.

Creating my own patch

To create a new patch we need a couple of things

  • A context file to create the spring beans
  • A properties file with description information
  • A java class to instantiate that will run the patch

The context file can exist any where in the alfresco/extension package.  It should contain a bean that inherits from the basePatch abstract bean.

<bean id="patch.pmoUsers" class="com.ziaconsulting.bootstrap.FreshProjectData"
  parent="basePatch">
  <property name="id">
    <value>patch.pmoUsers</value>
  </property>
  <property name="description">
    <value>patch.pmoUsers.description</value>
  </property>
  <property name="fixesFromSchema">
    <value>0</value>
  </property>
  <property name="fixesToSchema">
    <value>${version.schema}</value>
  </property>
  <property name="targetSchema">
    <value>10000</value>
  </property>
  <property name="services" ref="ServiceRegistry"/>
  <property name="groupAuthorityName" value="freshprojectadmins"/>
  <property name="groupDisplayName" value="Fresh Project Admins"/>
</bean>

This is a simple bean that inherits from basePatch.  The settings that are the most important are the three versions that are passed in (fixesFromSchema, fixesToSchema and targetSchema).  This is in contrast to the way that Alfresco typically uses this service, where the patch is meant to be applied to one specific schema.

The “id” is written to the patch table in the database and the description is a reference to a key in a properties file that has been loaded by the i18n Resource Bundle Bootstrap Component.

The properties file looks like any normal properties and is loaded by the I18N service.  The bean that we will use is:

<bean id="patch.pmoUsers.resourceBundles"
class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
    <property name="resourceBundles">
    <list>
      <value>alfresco.extension.pmoPatches</value>
    </list>
  </property>
</bean>

Nothing fancy here.  Just make sure that the ID is unique so you don’t stomp the original message bundle bean.

The last thing to create is the java class that runs when the patch is installed.  It’s pretty easy to find loads of examples in the repository of other patches and copy the ideas.  Here is one for completeness.

public class FreshProjectData extends AbstractPatch {
...... La la la, details ......
@Override
protected String applyInternal() throws Exception {
    // Create the new user group
    String freshProjectAdmingroup = services.getAuthorityService()
      .createAuthority(AuthorityType.GROUP, groupAuthorityName);
    services.getAuthorityService().setAuthorityDisplayName(
      freshProjectAdmingroup, groupDisplayName);
    return "Created " + freshProjectAdmingroup;
  }
}

One thing to note is that the return string is placed into the “report” field in the database (see next section).

Changes to the database

The database stores a record of the applied patch in the alf_applied_patch table.  Which you shouldn’t need to check unless you’re curious.

Screen shot 2010-09-03 at 9.07.48 PM.png