Wednesday, November 19, 2014

Installing a JDK on windows without admin rights

Here at the office I do not have admin rights.
This is a pain because I cannot update the JDK to a version I'd like/have to use.
Well there is an option.

Download the desired JDK from the regular location.
Open the executable file using 7-zip or something similar. The executable contains only a single file named tools.zip. Unzip that file to a location where you want the JDK installed and you have write access to, for instance c:\development\jdk-8.20.
This will create the installation structure, although many of the jar file components are still compressed. These must be de compressed using a tool provided with the JDK itself, unpack200, that is found in jre\bin.
Locate all .pack files using dir *.pack /s/b and de-compress each of them using upack200:

c:\development\jdk-8.20\jre\bin\unpack200.exe -v -r path\file.pack path\file.jar.
The '-v' option provides for verbose output and the '-r' option removes the original pack file afterwards.

Tuesday, August 05, 2014

Mocking the InitialContext

Unit testing with JNDI

One of the issue's with unit tests is that it is not always easy to control the java.naming.InitialContext provided to the object under test.
Mock frameworks cannot create mocks for JRE classes like InitialContext, so how can we solve this challenge?

One solution could be to create a simple implementation for the javax.naming.spi.InitialContextFactory that returns a mock implementation provided by mockito. Through configuration, our implementation is then used.

public class InitialContextFactoryMock implements InitialContextFactory {

  private static Context mockContext;

  /**
    * The mockContext is created here to be able to use the {@link Context}
    * mock object while defining the expectations.
    * Remember to call this method each time a new test case is run.
    * 
    * @return a fresh {@link Context} mock.
    */
  public static Context getMockContext() {
    mockContext = mock(Context.class);

    return mockContext;
  }

  /**
    * This factory returns the {@link Context} mock created earlier.
    */
  public Context getInitialContext(Hashtable environment) throws NamingException {
    return mockContext;
  }
}

To use the InitialContextFactoryMock you need to specify it in the jndi.properties:


java.naming.factory.initial=the.mocks.InitialContextFactoryMock

Tuesday, April 12, 2011

Fine grained authorization with Spring Security 3

For a project I'm currently working on the authorization requuirements are such that we need method level authorization.
The projects will create a REST service whoes functionality I will not describe here, but it is based on Spring MVC, requires authentication based on Kerberos and user ID/password and fine grained authorization based on roles. The roles are taken from the Active Directory.

Since Spring is already used and because we need two distinct manners for authentication, spring security seems to be the best choice for this.
Using spring security, the authorization checks can be configured using annotations on the MVC controller using @PreAuthorize("hasRole('ROLE_USER')") and the like.

Starting with spring security works like a breeze, until you try to step outside of the boundaries.
Setting up simple authentication based on hard coded user ID's with hard coded password and hard coded roles goes like this:
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:sec="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
          http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    ">

    <sec:http auto-config="true">
        <sec:intercept-url pattern="/*" access="ROLE_USER" />
    </sec:http>

    <sec:authentication-manager alias="authenticationManager">
        <sec:authentication-provider>
                <sec:user-service>
                    <sec:user authorities="ROLE_USER"
                        name="jim" password="morisson"/>
                    <sec:user authorities="ROLE_USER,ROLE_OPERATOR"
                        name="stevie" password="vaughan"/>
                    <sec:user authorities="ROLE_USER,ROLE_OPERATOR,ROLE_DEPLOYMENT_ENGINEER"
                        name="brian" password="jones"/>
                </sec:user-service>
        </sec:authentication-provider>
    </sec:authentication-manager>
</beans>

According to the documentation, all you need to do to enable the @PreAuthorize annotation is adding <sec:global-method-security pre-post-annotations="enabled"/>
So I did, but the authorization checks did not kick in at all.
I have been struggling with this for a while until I stumbled over this post on stackoverflow. The solution is as simple as it is strange, I only needed to move the line <sec:global-method-security pre-post-annotations="enabled"/> from the security-context.xml to the dispatcher-servlet.xml. Nowhere else can I find this suggestion, even in Peter Mularien's book its written as:
Instructing Spring Security to use method annotations
We'll also need to make a one-time change to dogstore-security.xml, where we've got the rest of our Spring Security configuration. Simply add the following element right before the <http> declaration:

<global-method-security pre-post-annotations="enabled"/>

It seems that the above declaration registers a bean post-processor that is applied to the context in which it is declared, that means that declaring it in the security context, the post-processor is not applied to beans declared in the web context.

Wednesday, February 02, 2011

Create mock objects in spring configuration

In case you ever need to supply a mock object in spring configuration, here's a snippet that does just that:

<!-- Define the Mockito class as factory for creating the mock -->
<bean id="restTemplate" class="org.mockito.Mockito" factory-method="mock">
  <!-- The constructor contains the full name of the class being mocked -->
  <constructor-arg value="org.springframework.web.client.RestTemplate"/>
</bean>


The defined restTemplate bean can be be referenced in other bean definitions, for instance the object under test.

Wednesday, August 11, 2010

How to test a class that directly uses java.rmi.Naming

While in the process of doing a handover of a project, some pieces of the projects source do not comply with the code standard. In this holiday season the original developer wasn't available, so I made my sleeves wet and hands dirty again, and started fixing it.

The major thing the code lacked was a proper unit test with coverage higher than 80%, well it didn't have a unit test at all.
Adding a unit test normally is not a big deal, but in this case, the class, a simple servlet that connects to a remote RMI object and calls a status method on it, directly uses java.rmi.Naming.
java.rmi.Naming is notorious for its static methods, which are hard to mock when unit testing.
There are great products out there, like powermock that can actually mock static methods, but not in system classes.
I could change the servlet code and provide a wrapper around accessing the java.rmi.Naming class, but I didn't want to change the code.

Instead I chose to not mock java.rmi.Naming, but instead just create my own instance:
@BeforeClass
public static void initNamingRegistry() throws RemoteException {
// Create a local registry with an arbitrary port number
rmiRegistry = LocateRegistry.createRegistry(9901);
This registry is alive and kickin' during the execution of my test suite, so I can now register the mock object that implements the remote business interface:
@Before
public void registerRemoteMock() throws Exception {
// Register the mock of the remote business object
rmiRegistry.bind("testName", remoteMock);
}
Then the actual servlet method can bet tested:
@Test
public void testSomeBehaviour()
// Prepare the mocks
when(requestMock.getParameter("name").thenReturn("val");
...
// Call the test method
testObject.doGet(requestMock, responseMock);

// Verify the calls if needed
verify(remoteMock).doIt();
Nice, clean and simple!

Thursday, June 26, 2008

Passed !!

Grade: P
Score: 75
Comment: This report shows the total points that could have been awarded in each section and the actual amount of points you were awarded. This information is provided in order to give you feedback on your relative strengths on a section basis. The maximum number of points you could have received is 100, minimum to pass is 70.

Class Diagram (44 maximum) .......................... 31
Component Diagram (44 maximum) ...................... 32
Sequence/Collaboration Diagrams (12 maximum) ........ 12

Tuesday, June 17, 2008

SCEA part III

As we say in holland, "the bullit has gone through the church", altough we usually say it in Dutch like: "De kogel is door de kerk", which means something like I have finally done it...
Last week Sunday I've uploaded my assignment, and today I took me essay exams.

So now its waiting, and waiting...
Until the results are published.

Keep you posted.

Monday, March 10, 2008

java.io.NotSerializableException

I can't fully dedicate my time to the SCEA assignment, I am also fulltime working on projects.
Today I ran into a java.io.NotSerializableException.
The stack trace is not at all helpfull, it just says "Caused by: java.io.NotSerializableException: foo.bar.FooBar."
While I am sure that foo.bar.FooBar implements java.io.Serializable.
I checked all the class members and marked some of the members transient (log4j Logger), but still the thing is popping up.

Googling for that exception showed this blog post. As it appeared, their first attempt wasn't very useful, although the idea looked promising.
Their DebugObjectOutputStream doesn't handle private fields, and can't cope with inheritance.
These issues seem to have been resolved in the wicked code itself, but that is a bit too harsh to just get

Browsing the comments posted underneath the post showed a link to Bob Lee's blog where he tackles the same problem.
Although the output generated by his solution isn't as verbose as the other one, it does give the expected results.
This showed me that I missed out on some of the fields.
Great help. Thanks Bob.


Tuesday, February 12, 2008

Creating sequence diagrams

The sequence diagrams are getting complicated.
I am now looking at the benefits that UML 2.0 can bring us in reducing the complexity.
I mean I started off modelling the sequence diagram for the prepare itinerary use case and ended up with a diagram that didn't fit on the screen any more, and I didn't even modelled the business functionality yet, I stopped at the business delegate.
So looking at the new elements in UML 2.0 I found the Interaction Overview diagrams useful for splitting the complex sequence diagram into smaller more usable chunks.
I'd like to soon finish the sequence diagram for this first, but major, use case and then start modelling the class diagram.
When that has been done, most likely I will need to correct my sequence diagrams again to reflect corrected flaws discovered when doing the class diagram.


In the mean time I am having a great discussion on javaranch about a discrepancy in the requirements. The prepare itinerary scenario mentions alternative flights within one hour and less than the selected, while in the given interview with CEO and CIO the flights have a flat price per destination, per seat class. Another thread on javaranch discusses the difference (or lack off) between flight and segment.


Speeking with UB40: both these discussions give me quite some food for thought!

Monday, January 28, 2008

Going thru the requirements

I have some problems getting myself up to speed on this assignment. I can blame lots of things like work load, my wife and children needing atention, but in the end I can only just blame myself. It seems to be hard just starting on it.
But allright finally I started really reading the requirements specs a couple of times.
Going thru them I wrote down the things that seemed unclear.

Then going over the scenario's given, I started out in writing down the entities I discovered in there, these are possible classes and/or attributes.

Now I am working on the creation of the sequence diagrams based on the scenraio's this will also result in class diagrams.

Well I just must make sure that I keep this up and continue...

Monday, January 21, 2008

Using stereotypes to describe J2EE components

For the SCEA assignment the architecture needs to be documented using UML.
Most architectures will have J2EE components like EJB's or servlets.
When these are documented you can opt to fully document each EJB, meaning adding all interfaces as separate elements on a class diagram, and incorporating the complete message flow in sequence diagrams containing all standard EJB message calls, like ejbCreate, etc.
I think that documenting the design and architecture in such a way will clutter the diagrams too much, thereby making the design/architecture harder to read.

Simplifying the diagrams by adding stereotypes to these elements, like &lt;ejb&gt; makes reading the the design/architecture easier and keeps the focus on the essential parts.

Sun has documented some annotations they use in their pattern catalog.

In addition to these stereotypes I will add Stateless/Stateful to designate the different session beans when needed, and maybe come up with some additional stereotypes when necessary.

Thursday, January 17, 2008

Netbeans 6.0 Keyboard shortcuts

I am trying to switch from eclipse to Netbeans when doing some Java coding.
The biggest problem that came up is the keyboard shortcuts, obviously they all differ, so I miss the ones I learned to love and use a lot in eclipse, like pressing Ctrl-1, in eclipse this opens an assistant that helps you resolve compilation problems.

I found a link that at least shows some of the shortcuts, and one that describes where to find a keyboard shortcut list in the netbeans installation. The shortcuts.pdf file also contains a link to a wiki page that describes the keyboard shortcuts specification.

From the wiki page I learned that the shortcut I so desperately need is Alt + Enter, as explained in the 'Coding in Java' section under 'Show suggestion/Tip/Hint'.


Wednesday, January 02, 2008

SCEA Part I

On December 14th I passed for the first part of the Sun Certified Enterprise Architect exam (SCEA), with a score of 93%.
Immediately after this multiple choice exam I registered for its follow-up: the assignment.
The assignment consists of some requirements, a business domain model and use cases for a flight booking system for the airliner Fly By Night. Due to the non diclosure agreement I have signed when registering for the assignment, I cannot write about the assignment and my solution in much detail, but I will try to keep a record of my doings here on the blog from now on.

Friday, October 05, 2007

Using spring's webflow package

As an architect I get a lot of challenging questions.
Like this week, a team of the company I am currently working for needs to migrate a number of simple applications written in PHP to a J2EE environment.
In addition to this, the first release will run as standalone web applications while in the (near) future they need to be incorporated into the soon to be released company web portal.
So I needed to come up with a way that simplifies the transition of a web application into a portlet application.
Since almost any web application can be in different states, as is the case with these applications, I thought of Spring's webflow package.
Spring's webflow uses either Spring Web MVC or Spring Portlet MVC underneath, so is it possible to easily swap either of them without changing the code?

Let's find out...

Wednesday, September 26, 2007

Java coding tips

This page, 7 Top Tips for Quality Java Software, contains some really useful tips. Although most of it seems common sense to me, it did reactivate the associated neurons in my brain.
Good piece Jason!

Monday, July 16, 2007

Using Alfresco's WCM

Alfresco is supplying a nicely looking evaluation guide for using their Web Content Management package.
After briefly giving an overview of the Web Content Management Package, a scenario can be followed along while reading.
The scenario describes using Alfresco WCM with a couple of different users, each having a different role in the system.



I followed this scenario from creating new users and assigning roles to them, creating a new web project, creating new web forms for the project, etc. until I came to the point of creating new web content. When trying expand the list of web forms next to my sandbox, I stumbled into a NullPointerException:


So a good citizen of the open source world, I immediately went to Alfresco's issue tracker and found a report about this issue (WCM-486).


Sadly this prevents me from finishing the scenario, So today I will see if the issue report can help me fix this on my system.

Thursday, July 12, 2007

How to setup a WCMS

OK I am going to try to setup alfresco 2.0 WCM on JBoss AS using Hypersonic SQL as database.
I am using HSQL because the can easily be zipped and distributed to fellow developers.

As usual I'll first create a dedicated server configuration and name it alfresco20, this instance can be started using <jboss-root>/bin/run.sh -c alfresco20.

Upfront I know that the alfresco.war must be deployed exploded in JBoss. So the war file is unzipped into <jboss-root>/server/alfresco20/deploy/alfresco.war.

Two issue's arise immediately:
  1. Alfresco has a version of log4j packaged in the war, this generates ClassCastExceptions, so the log4j is removed from alfresco.war/WEB-INF/lib.
  2. The log4j configuration in JBoss lacks a root logger, and alfresco generates a lot log messages, so I opened <jboss-root>/server/alfresco20/conf/log4j.xml, and added <level value="warn"/> to the <root> element.
Configuring HSQL as database for alfresco is properly documented at the alfresco wiki, I know because I did it myself ;-)

When starting JBoss, after quite a while and a lot of warn and info log messages on the console, the server is started. Checking the base functionality at http://localhost:8080/alfresco shows the login page.
But this merrily is alfresco's CMS not the WCM version, so stop the server again, either via the jmx-console or using Ctrl-C.
According to the readme that comes with alfresco's WCM, the wcm-bootstrap-context.xml file needs to be placed in the <jboss-root>/server/alfresco20/conf/alfresco/extension directory.

That should be it, unless the website preview feature is needed. For now lets first try if this works as suggested. After starting JBoss again using the above command, the server starts without a problem, and when browsing to the alfresco page, I get presented with the login screen. So the JBoss server appears to be working fine.
Now lets start the virtualization server.

Out of the box, the virtualization server did not need any configuration and it started without any problem. Great.

Now I want to evaluate the functionality supplied, but that'll have to wait till next time.

Wednesday, July 11, 2007

Alfresco Content Package

One of my colleague suggested to look at ACP, Alfresco's content package. This could be useful in the publication of content from one repository into the other, but we have a JCR compliant repository on the published end, not necessarily an Alfresco repository.

An ACP package is a zipped directory structure, that has the extension '.acp'.
When doing an export, an acp file is created inside alfresco itself, in a space that can be arbitrarily chosen.
Besides the target space, the package name must be provided.
The acp file, assuming package as package name, has the following structure:
/package.xml
/package
/content0.html
/content1.pdf
/content2.jpg

The package.xml has a proprietary XML structure and looks like:
<?xml version="1.0" encoding="UTF-8"?>
<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0">
<view:metadata>
<view:exportBy>admin</view:exportBy>
<view:exportDate>2007-07-10T13:45:02.277+02:00</view:exportDate>
<view:exporterVersion>2.0.0 (build-185)</view:exporterVersion>
<view:exportOf>/app:company_home/cm:Books</view:exportOf>
</view:metadata>
<cm:content xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:wf="http://www.alfresco.org/model/workflow/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:wcm="http://www.alfresco.org/model/wcmmodel/1.0" xmlns:wca="http://www.alfresco.org/model/wcmappmodel/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:wcmwf="http://www.alfresco.org/model/wcmworkflow/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:bpm="http://www.alfresco.org/model/bpm/1.0" xmlns:custom="custom.model" xmlns="" view:childName="cm:index.html">
<view:aspects>
<cm:titled></cm:titled>
<cm:auditable></cm:auditable>
<sys:referenceable></sys:referenceable>
<cm:author></cm:author>
<app:inlineeditable></app:inlineeditable>
</view:aspects>
<view:properties>
<app:editInline>true</app:editInline>
<cm:description>Index page for books</cm:description>
<sys:node-uuid>59d1c1dc-2e12-11dc-8613-e518334e1caa</sys:node-uuid>
<sys:node-dbid>397</sys:node-dbid>
<cm:content>contentUrl=backup\content0.html|mimetype=text/html|size=51|encoding=UTF-8|locale=nl_NL_</cm:content>
<cm:title>Books</cm:title>
<cm:author>Stephen King</cm:author>
<cm:created>2007-07-09T13:48:46.673+02:00</cm:created>
<cm:modifier>admin</cm:modifier>
<cm:modified>2007-07-10T12:15:31.346+02:00</cm:modified>
<cm:creator>admin</cm:creator>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:name>index.html</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
</view:properties>
<view:associations></view:associations>
</cm:content>
<cm:content xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:wf="http://www.alfresco.org/model/workflow/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:wcm="http://www.alfresco.org/model/wcmmodel/1.0" xmlns:wca="http://www.alfresco.org/model/wcmappmodel/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:wcmwf="http://www.alfresco.org/model/wcmworkflow/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:bpm="http://www.alfresco.org/model/bpm/1.0" xmlns:custom="custom.model" xmlns="" view:childName="cm:DarkTower.pdf">
<view:aspects>
<cm:auditable></cm:auditable>
<cm:titled></cm:titled>
<sys:referenceable></sys:referenceable>
<cm:author></cm:author>
</view:aspects>
<view:properties>
<cm:description></cm:description>
<sys:node-uuid>c0db7bd5-2eda-11dc-96f5-878a8c8564f1</sys:node-uuid>
<sys:node-dbid>404</sys:node-dbid>
<cm:content>contentUrl=backup\content1.pdf|mimetype=application/pdf|size=1366321|encoding=UTF-8|locale=nl_NL_</cm:content>
<cm:title>DarkTower.pdf</cm:title>
<cm:author>Stephen King</cm:author>
<cm:created>2007-07-10T13:43:18.809+02:00</cm:created>
<cm:modifier>admin</cm:modifier>
<cm:modified>2007-07-10T13:43:26.637+02:00</cm:modified>
<cm:creator>admin</cm:creator>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:name>DarkTower.pdf</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
</view:properties>
<view:associations></view:associations>
</cm:content>
<cm:content xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns:alf="http://www.alfresco.org" xmlns:d="http://www.alfresco.org/model/dictionary/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:act="http://www.alfresco.org/model/action/1.0" xmlns:wf="http://www.alfresco.org/model/workflow/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:ver="http://www.alfresco.org/model/versionstore/1.0" xmlns:usr="http://www.alfresco.org/model/user/1.0" xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:mix="http://www.jcp.org/jcr/mix/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:wcm="http://www.alfresco.org/model/wcmmodel/1.0" xmlns:wca="http://www.alfresco.org/model/wcmappmodel/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:wcmwf="http://www.alfresco.org/model/wcmworkflow/1.0" xmlns:rule="http://www.alfresco.org/model/rule/1.0" xmlns:fm="http://www.alfresco.org/model/forum/1.0" xmlns:bpm="http://www.alfresco.org/model/bpm/1.0" xmlns:custom="custom.model" xmlns="" view:childName="cm:Cover.jpg">
<view:aspects>
<cm:auditable></cm:auditable>
<cm:titled></cm:titled>
<sys:referenceable></sys:referenceable>
<cm:author></cm:author>
</view:aspects>
<view:properties>
<cm:description></cm:description>
<sys:node-uuid>cf782d38-2eda-11dc-96f5-878a8c8564f1</sys:node-uuid>
<sys:node-dbid>405</sys:node-dbid>
<cm:content>contentUrl=backup\content2.jpg|mimetype=image/jpeg|size=64599|encoding=UTF-8|locale=nl_NL_</cm:content>
<cm:title>Cover.jpg</cm:title>
<cm:author>Stephen King</cm:author>
<cm:created>2007-07-10T13:43:43.309+02:00</cm:created>
<cm:modifier>admin</cm:modifier>
<cm:modified>2007-07-10T13:43:49.106+02:00</cm:modified>
<cm:creator>admin</cm:creator>
<sys:store-protocol>workspace</sys:store-protocol>
<cm:name>Cover.jpg</cm:name>
<sys:store-identifier>SpacesStore</sys:store-identifier>
</view:properties>
<view:associations></view:associations>
</cm:content>
</view:view>

This view does contain most of the information I need. The jcr system view as exported by alfresco, lacks the mime type, which is included in alfresco's acp descriptor:
<cm:content>contentUrl=backup\content2.jpg|mimetype=image/jpeg|size=64599|encoding=UTF-8|locale=nl_NL_</cm:content>
.

Maybe I am overseeing something, but shouldn't the mime type info be part of JCR's system view as well?

Thursday, July 05, 2007

Custom JCR node types in Alfresco

With the document "Working with Custom Content Types" on my desk, I started to develop my own content model to be used in alfresco.
Naive as I can be, I tried to convert the jackrabbit based cnd into alfresco's content definition. Obviously that failed, alfresco does not support multiple inheritance. Alright, that one can be circumvented.
After deploying, correcting and re-deploying the model until satisfied, I tried to add the model to the web client user interface, but it was not accepted. It appears that if you want to expose your custom content model to the web client user interface, the defined types must extend cm:content or one of its descendants. Sadly this is not mentioned in the named document.

Tuesday, June 19, 2007

Problems exporting content

The export process seemed to work fine, until I took a close look at the actual exported XML.

It appears that the actual content is stored in a binary format, which prevents adjustments within the actual HTML itself, like references to content stored in the same repository.

To try to circumvent this, I changed the cm:content property of the cm:content type, as defined in alfresco's contentModel.xml, to d:text instead of d:content, but this gave the following error:

11:11:58,926 ERROR [Utils] A system error happened during the operation: The node property must be of type content:
  node: workspace://SpacesStore/221a7c69-1e45-11dc-a1bf-4985acca4591
  property name: {http://www.alfresco.org/model/content/1.0}content
  property type: {http://www.alfresco.org/model/dictionary/1.0}text

So its time to create our own model for alfresco.