Dennis’s Weblog

Alfresco Introduce

Posted on: November 3, 2008

Alfresco is an open source Document Management System, below i will descript how it works base on my research in weekend.

1.Docasu UI:

There is a file named DocasuSearch.js locate in the docasu/wcs folder, It used to present the Search user interface(UI), In this file it uses EXTJS javascript library which is a UI.

And then in this library, it also have some build-in functions to submit the Form(in ExtJs)  to Server-Side program for processing.

var searchProxy = new Ext.data.HttpProxy({
url: ‘ui/search’,
method: ‘GET’
});

var searchResultsStore = new Ext.data.Store({
remoteSort: true,

proxy: searchProxy,

Here the proxy is for this purpose. In this Javascript file it will generate the URL path for search, just like  us/search?q = {text ?}…. because it actully do the work that submit a form to server.

And the ui/search is a URL, It use Restful technology. It can be associated to a webscript because of the system framework, This is so called Spring framework, this framework can generate some objects according to the XML file(docasu-context.xml). And in the xml, it will make the URL evently refer to the Search.class (in Docasu/wcs package ?). And this class do the actually work to search the Alfresco repository and return the data.

//docasu-context.xml

<bean name=”webscript.com.optaros.alfresco.docasu.search.search.get”
class=”com.optaros.alfresco.docasu.wcs.Search” parent=”webscript”>
<property name=”customFileFolderService”
ref=”CustomFileFolderService” />
<property name=”serviceRegistry”>
<ref bean=”ServiceRegistry” />
</property>
<property name=”repositoryImageResolver”>
<ref bean=”webscripts.repo.imageresolver” />
</property>
</bean>
//this so spring framework, use bean to generate POJO.

in JSP, all the class are located in Web-INF folder!

and this webscript xml:

<webscript>
<shortname>Custom UI – Search</shortname>
<description>Search the repository</description>
<url>/docasu/ui/search?q={searchText}&amp;t={searchType?}&amp;nodeId={lookIn?}&amp;createdFrom={createdFrom?}&amp;createdTo={createdTo?}&amp;modifiedFrom={modifiedFrom?}&amp;modifiedTo={modifiedTo?}&amp;start={rowsFrom?}&amp;limit={rowsTo?}&amp;sort={orderBy?}&amp;dir={orderDirection?}</url>
<format default=”json”>extension</format>
<authentication>user</authentication>
<transaction>none</transaction>
</webscript>

It designate the information which will be read by the classes in Search.class, and retrieve information to search from repository and return result.

At the same time, you can register javascript API by yourself. What this process do is to bridge for Javascript API(object) and Java class, this is script service. After the registeration, In Javascript can directly use object in alfresco class, and use their methods to operate at the data on alfresco. For example, create folder, delete folder and so on.

The common:

Ext UI use Ext.ajax.request or HttpProxy to connect a URL such as ui/search. And the system will search for the right webscript to match, and find the right Search.get.desc.xml file. Accompany this file it also have two another files, one is search.get.js and search.get.json.ftl. search.get.js is to connect the java class as describe before and execute the class methods to accomplish the actual work. and search.get.json.ftl is the format for returning data. Look at the files you will know.

2.Alfresco UI

Three main techonlogies used:

In the JSP file it use JSF technology the generate the UI. And there are a file called web-client-config-actions.xml which can work with JSF to customize the UI and do the actual work.

Here is an example:

Custom dialog disappears

Postby pau.carre on 19 Sep 2008, 10:44

Hi, I am developing an add-in for Alfresco. This add-in is a custom dialog linked to each document. I have had no problem since the dialog icon disappeared from all documents. After a lot of “trial and error” I finally had to reinstall Alfresco and then the new icon appeared. But, lately it disappeared again. I did not change any relevant file from the add in (just som JSPs). So I do not know why the icon disappears. I restart the server each time I deploy a new version and I do not see any error in the apache tomcat log.

Any idea of how to identify the problem?

thanks,
Pau Carré Cardona

source/alfresco.extension/web-client-config-custom.xml

Code: Select all
<alfresco-config>

<config>
<actions>
<!-- Launch Add Aspect Dialog -->
<action id="afegir_signatura">
<label>Afegir signatura</label>
<image>/images/icons/sign.png</image>
<action>dialog:afegirSignatura</action>
<action-listener>#{BrowseBean.setupContentAction}</action-listener>
<params>
<param name="id">#{actionContext.id}</param>
</params>
</action>

<!-- Add action to more actions menu for each space -->
<action-group id="document_browse">
<action idref="afegir_signatura" />
</action-group>
</actions>
Here is the really important position, it is the place that system designate the script to execute when a button click, just like event handler. And usually Dialog and in another XML file with name refer to "dialog".
<dialogs>
<dialog name="afegirSignatura" page="/jsp/extension/add-signature.jsp" managed-bean="AddSignatureDialog"
icon="/images/icons/sign.png" title="Afegir signatura"
description="Afegeix una signatura al document actual" />
</dialogs>

</config>

</alfresco-config>

AddSignatureDialog.java

Code: Select all
package org.alfresco.sample;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import javax.faces.context.FacesContext;
import org.alfresco.repo.content.RoutingContentService;
import org.alfresco.repo.model.filefolder.FileFolderServiceImpl;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;

import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.Node;

public class AddSignatureDialog extends BaseDialogBean {
protected String url = null;

@Override
protected String finishImpl(FacesContext context, String outcome)
throws Exception {
return outcome;
}

@Override
public boolean getFinishButtonDisabled() {
return false;
}

public String getURL() {
if (url == null) {
Node documentNode = browseBean.getDocument();
NodeRef documentNodeRef = documentNode.getNodeRef();
url = DownloadContentServlet.generateDownloadURL(documentNodeRef,
"document");
}
return url;
}

public void setURL(String url) {
this.url = url;
}

FacesConfig.xml

Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>

<managed-bean>
<managed-bean-name>AddSignatureDialog</managed-bean-name>
<managed-bean-class>org.alfresco.sample.AddSignatureDialog</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>nodeService</property-name>
<value>#{NodeService}</value>
</managed-property>
<managed-property>
<property-name>browseBean</property-name>
<value>#{BrowseBean}</value>
</managed-property>
</managed-bean>

</faces-config>

add-signature.jsp

Code: Select all

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<%@ include file="base.jspf" %>

<%
String target=base + "/jsp/extension/receive.jsp";
String codebase = "../extension/signatureapplet.jar,../extension/signaturaapi-2.2.jar";
String width = "700";
String height = "300";

%>
<applet width="<%=width%>" height="<%=height%>" align="baseline"
code="es.caib.signatura.client.applet.SignApplet"
archive="<%=codebase%>"
source="<%=base%><c:out value="${DialogManager.bean.URL}"/>;jsesssionid=<%=session.getId()%>"
target="<%=target%>"
/>

From this example you can know how it works.


Advertisements

1 Response to "Alfresco Introduce"

Note what you have learned as soon as possible!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: