6. Some new words (for newbies)
Aikau! Activiti!
AMP!
WebScript! Spring Surf!
FreeMarker!
CMIS! Content Model!
7. Is there another life?
!
"With even a few lines of code, you can
easily add useful functionality to Alfresco."
!
(April 4, 2014 by Jeff Potts)!
8. Disclaimer
!
Source code based on Alfresco CE 4.2.f !
and available at GitHub !
!
WARNING!!
Code for teaching purposes. !
Don’t try to compile it on your head.!
10. 10. Add a download button
Motivation. "When I get a shared
document link by email and click on it, the
result may not be accessible: sometimes
the preview is not working, sometimes I
can only see a simple picture, sometimes
my computer has no Flash Player... How
can I get the content of a document
shared with me?"!
13. 10. Add a download button
2 lines!
Not all browsers supported *!
!
Danger zone!
Alfresco default FTL!
should not be !
overwritten!!
!
web-extension
FTL
WebScript
CE
5.0.a
14. 9. Site creation ability
Motivation. "I don't want all the users
creating sites without control, our
organization is being directed by our own
Process Map and no one should create
content out of its limits."!
18. 9. Site creation ability (share)
<!-- Required from 5.0.a -->
<customization>
<targetPackageRoot>org.alfresco.share.pages
</targetPackageRoot>
<sourcePackageRoot>es.keensoft.share.header
</sourcePackageRoot>
<alwaysApply>
<webscript>share-header</webscript>
</alwaysApply>
</customization>
web-extension/site-data/extensions/hide-create-site-extensions.xml
C
E
>=
5.0.a
(aikau)!
19. 9. Site creation ability (repo)
function main(){
var user = people.getPerson(person.properties.userName);
if (!people.isAdmin(user)) {
status.setCode(status.STATUS_FORBIDDEN, "error.noPermissions");
return;
}
config/alfresco/extension/templates/webscripts/org/alfresco/repository/site/
sites.post.json.js
5.
6.
7.
8.
20. 9. Site creation ability
web-extension
8 lines!
No Alfresco repository!
permissions modified *!
but!
repo webscript overridden!
WebScript
aikau
Alfresco JS API
* http://wiki.alfresco.com/wiki/Site_Service#Controlling_who_can_create_sites
Other dashlets could be extended: dynamic-welcome, my-meeting-workspaces, my-workspaces
21. 8. Changing document extension
Motivation. "We are elaborating
documents on Microsoft Word, once the
document is closed we are uploading a
final version in PDF. Surprisingly, final
document has the same extension as
original (.DOC) although mimetype is right.
Users can't open PDF document by
downloading or by editing online because
local programs are associated by file
extension."!
26. 7. Setting create missing person
Motivation. "I have configured our LDAP
for identification because I don't want to
take care of passwords, but I don't want
everyone on this LDAP to have access to
Alfresco.!
27. 7. Setting create missing person
# Some authentication mechanisms may need to create people
# in the repository on demand. This enables that feature.
# If disabled an error will be generated for missing
# people. If enabled then a person will be created and
# persisted.
create.missing.people=${server.transaction.allow-writes}!
!
From 4.2.d!
!
From 4.2!
CE
EE
28. 7. Setting create missing person
1.
2.
3.
4.
public class CustomSpringBeanPostProcessor implements
BeanFactoryPostProcessor, ApplicationContextAware {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
BeanDefinition bd = beanFactory.getBeanDefinition(beanName);
bd.getPropertyValues().add(propertyName, propertyValue);
}
}
es.keensoft.alfresco.behaviour.ContentBehaviour.java
C
E
<
4.2.d
E
E
<
4.2
30. 7. Setting create missing person
Spring bean
post-processor
4 lines!
!
Updating Alfresco properties
after Spring initialization
phase!
31. 6. Custom LDAP identification
Motivation. "We have several LDAP
branches, one for each mail subdomain,
but mail attribute is not bindable. The only
attribute bindable is an UID which can be
repeated on every branch. How can I
identify my users?"!
38. 5. PDF/A transformation
Properties
override
0 lines!
!
Some additional development
would be necessary to have
both (PDF and PDFA)
transformers available!
39. 4. Importing original dates
Motivation. "We have large history before
Alfresco, how can I preserve the records of
date for every imported document?”!
42. 4. Importing original dates
Content Model
5 lines!
!
Other formats could be
included (PDF, ODF…)!
Some other XML config is
required for Alfresco Share!
Extracter
configuration
43. 3. Custom EML node names
Motivation. "I don't understand Alfresco
imported mails from IMAP, the names have
no sense for me."!
47. 3. Custom EML node names
behavior
6 lines!
!
Custom RFC822 transformer
for HTML could be included !
Alfresco Java
API
48. 2. Site custom properties
Motivation. "Every site on our company
belongs to one entity and it’s identified by
an internal ID, it’s required to set this entity
on every Alfresco site creation."!
51. 2. Site custom properties (repo)
5.
6.
7.
8.
site = siteService.createSite(sitePreset, shortName, title, description, visibility,
sitetype);
if (json.has("idEntity")) {
site.node.properties["stcp:idEntity"] = json.get("idEntity");
site.node.save();
site.save();
}
model.site = site;
config/alfresco/extension/templates/webscripts/org/alfresco/repository/site/
sites.post.json.js
2 in a row!
52. 2. Site custom properties
web-extension
8 lines!
!
Alfresco webscript repo
extension not available!
Easy to extend this !
sample for site edition!
FTL
Alfresco JS API
53. 1. Site templates with folders
Motivation. "Someone recently asked how
to create Alfresco Share sites with a
default folder structure. Currently, out-of-the-
box, when you create an Alfresco
Share site, the document library is empty.
This person instead wanted to define a set
of folders that would be created in the
document library when a new Alfresco
Share site is created."!
http://ecmarchitect.com/archives/2014/04/04/3687
58. Badges earned
Content Model
FTL
Alfresco JS API
behavior
Alfresco Java
API
Alfresco source
aikau
web-extension
WebScriptoverride
59. What should I learn?
XML!
JS!
FTL!
Java!
Source code lines (percentage)
60. Keep it SSO
Extend!
Override!
Overwrite!
!
Alfresco source code to the rescue! .!
The less you write, the better you code .
Alfresco is full of hooks! .!
!
[Open]