0% found this document useful (0 votes)
4 views34 pages

Alfresco Java API

The document provides an overview of the Java API for Alfresco, detailing how developers can create new services and customizations using Java. It lists various public Java API services available through the Service Registry, including ActionService, ActivityService, and AuthenticationService, among others. Each service is described with its functionality and status, emphasizing the importance of using recommended API calls for future compatibility.

Uploaded by

kkosikov01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views34 pages

Alfresco Java API

The document provides an overview of the Java API for Alfresco, detailing how developers can create new services and customizations using Java. It lists various public Java API services available through the Service Registry, including ActionService, ActivityService, and AuthenticationService, among others. Each service is described with its functionality and status, emphasizing the importance of using recommended API calls for future compatibility.

Uploaded by

kkosikov01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Published on Alfresco Documentation ([Link]

com)
Home > Alfresco Community Edition 5.1 > Developer guide > API guide > Reference > Java API

Java API
When you need to create new services in Alfresco, or develop applications or customizations that cannot be implemented at the web script level, it is
necessary to write those extensions in Java. Alfresco provides numerous Java­level APIs, which are documented through the JavaDoc system.

Links to the JavaDoc documentation can be found on the Alfresco Developer Site [1]. While in theory it is possible to access the complete range of Java
APIs, there is a list of recommended Public Java API calls below. Where possible it is strongly recommended that your application limits itself to this list,
so that your application works on future versions of Alfresco.

Public Java API services [2] The Public Java API provides access to Alfresco through a number of services that are exposed. These services are
accessed via a single point of access ­ the Service Registry. This information provides an overview of the services exposed by the Public Java
API.

Parent topic: Reference [3]

Public Java API services


The Public Java API provides access to Alfresco through a number of services that are exposed. These services are accessed via a single point of
access ­ the Service Registry. This information provides an overview of the services exposed by the Public Java API.

The following table summarizes the main services available to the developer. These services are available via the service registry [4].

Important: There is a wealth of additional information to be found in the Public Java API access and transaction management documentation [5]. This
documentation also shows you how to obtain the service registry.
Support
Service Description Status
ActionService [6] An action represents a unit of work that can be applied to a node. Using the Action Service, actions of specific Full
types can be created. Support
[7]

ActivityService [8] A service to manage activity feeds. Full


Support
[7]

AttributeService [9] This provides services for reading, writing, and querying global attributes. Full
Support
[7]

AuditService [10] This provides services for querying audit data and enabling and disabling auditing. Full
Support
[7]

AuthenticationService [11] This service provides an API to allow authentication of users using various methods, such as username and Full
password and authentication tickets. Support
[7]

CategoryService [12] Provides a system for creating and managing categories of nodes. Full
Support
[7]

CheckOutCheckInService Service to provide document locking. If a document is locked, other users cannot change its content, until it is Full
[13] unlocked. Support
[7]

ContentService [14] A service for accessing and transforming content. Full


Support
[7]

CopyService [15] This service provides methods to copy nodes within and across workspaces and to update the state of a node, Full
with that of another node, within and across workspaces. Support
[7]

DictionaryService [16] This service represents the repository Data Dictionary. The dictionary provides access to content meta­data Full
such as Type and Aspect descriptions. Content meta­data is organized into models where each model is given Support
a qualified name. This means that it is safe to develop independent models and bring them together into the [7]
same repository without name clashes (as long their namespace is different).
FileFolderService [17] Provides methods specific to manipulating files and folders. This service provides a simple way of accessing Full
simple trees of files and folders in Alfresco. Support
[7]

JobLockService [18] This service ensures that a scheduled job can only run on one node of a cluster at a time. A scheduled job Full
could be, for example, an Activities feed job that generates email to send to everyone every night or a content Support
cleaner job that cleans up orphaned content. [7]

LockService [19] A low­level locking service, used by the CheckOutCheckIn service. Does not create a working copy. Full
Support
[7]

MessageService [20] Provides methods to access the locale of the current thread and to get localised strings. These strings may be Full
loaded from resource bundles deployed in the Repository. Support
[7]

MimetypeService [21] Provides support related to content mimetype. For example, provides methods to retrieve the extension for the Full
specified mimetype. Support
[7]

ModuleService [22] A service to control and provide information about the currently­installed modules. Full
Support
[7]

NamespaceService [23] Provides access to and definition of namespace URIs and prefixes. Full
Support
[7]

NodeService [24] Provides an API for managing nodes. Full


Support
[7]

NodeLocatorService [25] The NodeLocatorService looks up node locators registered via Spring configuration by name. Full
Support
[7]

PermissionService [26] Provides an API for managing the node permissions. Permissions specify users and groups that have access Full
to a node. Each user and group can be assigned a role. Support
[7]

PersonService [27] This service encapsulates the management of people and groups. People and groups may be managed Full
entirely in the repository or entirely in some other implementation such as LDAP or via NTLM. Some properties Support
may be in the repository and some in another store. Individual properties may or may not be mutable. [7]

RenditionService [28] Provides support for rendering content nodes into other forms, known as renditions. The rendition nodes are Full
derived from their source node and as such can be updated automatically when their source node's content (or Support
other properties) are changed. Examples of renditions include reformatted content (essentially a transformation [7]
from one MIME­type to another), rescaled images (including thumbnails), and the output of a Freemarker or
XSLT template. Renditions can be performed synchronously or asynchronously and can be created at a
specified location within the Alfresco repository. By default they are created as primary children of their source
node but it is possible to have them created at other nodes specified explicitly or as templated paths.
RetryingTransactionHelper A helper that runs a unit of work inside a UserTransaction, transparently retrying the unit of work if the cause of Full
[29] failure is an optimistic locking or deadlock condition. Support
[7]

SearchService [30] This encapsulates the execution of search against different indexing mechanisms. Full
Support
[7]

SiteService [31] Provides an extensive API for managing Sites in the Alfresco Share web client. Full
Support
[7]

TaggingService [32] It is possible to tag (a text label) any content, including folders, in Alfresco. This service provides an API for Full
creating, deleting, and adding tags, and other tag management methods. Support
[7]

TemplateService [33] Provides an API for executing template engine against a template file and data model. The service provides a Full
configured list of available template engines. The template file can either be in the repository (passed as Support
NodeRef string) or on the classpath. Also a template can be passed directly as a String using the [7]

processTemplateString() methods. The data model is specified to the template engine. The FreeMarker template
engine is used by default.
TenantService [34] Provides APIs around Alfresco's multi­tenancy capability. The service is applicable in both Single Tenancy and Full
Multi Tenancy arrangements. Support
[7]

VersionService [35] Provides an API for managing the versions of a piece of content. Full
Support
[7]

WorkflowService [36] Provides a client­facing API for interacting with Alfresco workflows and tasks. Full
Support
[7]

ActionService [6] An action represents a unit of work that can be applied to a node. Using the Action Service, actions of specific types can be
created.
ActivityService [8] The ActivityServices is responsible for generating activity feeds for each member of a Share site. The activities generated
include such events as a document was added, a document was previewed, the wiki was updated.
AttributeService [9] This provides services for reading, writing, and querying global attributes.
AuditService [10] The API by which applications can query the audit logs and enable or disable auditing.
AuthenticationService [11] This service provides an API to allow authentication of users using various methods, such as username and password
and authentication tickets.
AuthorityService [37] The service that encapsulates authorities granted to users. This service will refuse to create any user authorities. These
should be managed using the AuthenticationService and PersonService. Methods that try to change alter users will throw an exception. A string
key is used to identify the authority. These follow the contract defined in AuthorityType. If there are entities linked to these authorities this key
should be used to find them, as userName is used to link user and person.
CategoryService [12] Provides an API for creating and managing categories of nodes.
CheckOutCheckInService [13] Service to provide document locking. If a document is locked, other users cannot change its content, until it is
unlocked.
ContentService [14] A service for accessing and transforming content.
CopyService [15] This service provides methods to copy nodes within and across workspaces. It also provides support to update the state of a
node, with that of another node, within and across workspaces.
DictionaryService [16] This service represents the Repository Data Dictionary. The dictionary provides access to content meta­data such as Type
and Aspect descriptions. Content metadata is organized into models where each model is given a qualified name. This means that it is safe to
develop independent models and bring them together into the same Repository without name clashes (as long their namespace is different).
FileFolderService [17] Provides methods specific to manipulating files and folders. This service provides a simple way of accessing simple trees of
files and folders in Alfresco.
JobLockService [18] This service ensures that a scheduled job can only run on one node of a cluster at a time. A scheduled job could be, for
example, an Activities feed job that generates email to send to everyone every night or a content cleaner job that cleans up orphaned content.
LockService [19] A node­level locking service, used by the CheckOutCheckIn service. Does not create a working copy.
MessageService [20] Provides methods to access the Locale of the current thread and to get Localised strings. These strings may be loaded from
resource bundles deployed in the Repository.
MimetypeService [21] Provides support related to content mimetype. For example, provides methods to retrieve the extension for the specified
mimetype.
ModuleService [22] A service to control and provide information about the currently­installed modules.
NamespaceService [23] Provides access to and definition of namespace URIs and Prefixes.
NodeService [24] Provides an API for managing nodes.
NodeLocatorService [25] The NodeLocatorService looks up node locators registered via Spring configuration by name.
PermissionService [26] Provides an API for managing the node permissions. Permissions specify users and groups that have access to a node.
Each user and group can be assigned a role.
PersonService [27] This service encapsulates the management of people and groups. People and groups may be managed entirely in the
repository or entirely in some other implementation such as LDAP or via NTLM. Some properties may be in the repository and some in another
store. Individual properties may or may not be mutable.
RenditionService [28] Provides support for rendering content nodes into other forms, known as renditions. The rendition nodes are derived from
their source node and as such can be updated automatically when their source node's content (or other properties) are changed. Examples of
renditions include reformatted content (essentially a transformation from one MIME­type to another), rescaled images (including thumbnails), and
the output of a Freemarker or XSLT template. Renditions can be performed synchronously or asynchronously and can be created at a specified
location within the Alfresco repository. By default they are created as primary children of their source node but it is possible to have them created
at other nodes specified explicitly or as templated paths.
RetryingTransactionHelper [29] A helper that runs a unit of work inside a UserTransaction, transparently retrying the unit of work if the cause of
failure is an optimistic locking or deadlock condition.
SearchService [30] This encapsulates the execution of search against different indexing mechanisms.
SiteService [31] Provides an extensive API for managing Sites in the Alfresco Share web client.
TaggingService [32] It is possible to tag (a text label) any content, including folders, in Alfresco. This service provides an API for creating, deleting,
and adding tags, and other tag management methods.
TemplateService [33] Provides an API for executing template engine against a template file and data model. The service provides a configured list
of available template engines. The template file can either be in the repository (passed as NodeRef string) or on the classpath. Also a template
can be passed directly as a String using the processTemplateString() methods. The data model is specified to the template engine. The FreeMarker
template engine is used by default.
TenantService [34] Provides APIs around Alfresco's multi­tenancy capability. The service is applicable in both Single Tenancy and Multi Tenancy
arrangements.
VersionService [35] Provides an API for managing the versions of a piece of content.
WorkflowService [36] Provides a client­facing API for interacting with Alfresco Workflows and Tasks.

Parent topic: Java API [5]


Parent topic: Java API [38]

ActionService
An action represents a unit of work that can be applied to a node. Using the Action Service, actions of specific types can be created.
Information ActionService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description An Action is a unit of work that can be carried out on a node. Actions are commonly used in conjunction with Rules, but that is not
mandatory. When you create Rules for a folder in Alfresco, you can specify certain Actions to occur to nodes added to the folder. For
example, when a Word document is added to a folder, you may want a PDF to be automatically generated, or a notification email to
sent. There are a number of built­in Actions available by default:

Execute Script
Copy
Move
Checkin
Checkout
Link to category
Add Aspect
Remove Aspect
Add simple workflow
Send email
Transform and copy content
Transform and copy image
Extract common metadata fields
Import
Specialise type
Increment counter
Set property value

You can also create custom Actions to do whatever you want to content added to the folder.

While Actions are typically triggered by Rules, you can also invoke them directly by selecting them from a menu item. The Action
Service also allows you to call them directly from code. Any piece of code that can access the ActionService can invoke the Action, for
example:

JavaScript
Workflow
Web script
Java

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [40]
Java
example
public void sendEmailWithDoc(String to, String subject, String bodyText, NodeRef docNodeRef) {
boolean executeAsync = true;
Map<String, Serializable> aParams = new HashMap<String, Serializable>();
[Link]("to", to);
[Link]("subject", subject);
[Link]("body_text", bodyText);

Action a = [Link]().createAction("send‐as‐email", aParams);


if (a != null) {
[Link]().executeAction(a, docNodeRef, true, executeAsync);
} else {
throw new RuntimeException("Could not create send‐as‐email action");
}
}

More
Information Actions platform extension point documentation [41].
Java API ­ Access and Transaction Management documentation [42].

Tutorials Jeff Potts Custom Action tutorial [43]


Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

ActivityService
The ActivityServices is responsible for generating activity feeds for each member of a Share site. The activities generated include such events as a
document was added, a document was previewed, the wiki was updated.
Information ActivityService
Support Status Full Support [7]
Architecture Platform Architecture [39]
Information
Description
What is an activity?

Activity represents an action that has taken place within an Alfresco client interface (app/tool)
Activity is typically initiated by the Alfresco app/tool/component/service on behalf of a user (it is not necessarily initiated by
the underlying repository)
Activity is of a given/named type specified by the Alfresco app/tool (for example document added)
Activity is performed at a particular point in time (post date)
Activity may have associated data dependent on type of activity
Activity may be performed within a given site/network context
Activity may be performed within a given app/tool context
Activity may be sensitive, that is, associated with data that is permission controlled, therefore, the activity itself may be
permission controlled (can or can't be read)
Activity may be rendered into one or more UI views (activity summary)

Activities may be raised by one or more Alfresco applications. The posted activity must have a uniquely named activity type.

Examples of activity types include:

Added, updated, and deleted documents


Triggered on versioning
Includes changes to metadata (explicitly denoted in feed)
Does not include updates to tags
Uploaded and expanded ZIP
Added and deleted folders
Added and removed members (person joined/left site)
User role changes (change of user role for a site)
New comments (on any artifact in a site, including documents, blog entries, etc.)
Workflow­generated activities (requires explicit posting via customizing workflow definition)
Added, updated, and deleted events (calendar entries)
Published, updated, and deleted wiki pages
Published, updated, and deleted blog entries
Blog entry published to external blog engine

Deployment ­ App Deploy as AMP or Simple Module (JAR) package.


Server
Deployment ­ SDK Use SDK archetypes to produce AMP or Simple Module.
Project
Java API Java API Documentation [44]
Java example None
More Information None
Tutorials See this blog post [45].
Alfresco Developer None
Blogs
Parent topic: Public Java API services [2]

AttributeService
This provides services for reading, writing, and querying global attributes.
Information AttributeService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description Attributes are a system­wide storage system. Attributes typically have up to three keys (known as a key set) and a value. Attributes are
stored in the database (rather than the repository). An example of use is for persisting system­wide JMX configuration properties in
Alfresco Enterprise.

The AttributeService provides a Java interface for creating and managing Attributes, including such operations as:

Getting a collection of Attributes


Getting a single Attribute
Creating an Attribute
Removing an Attribute
Removing a collection of Attributes

Collections of Attributes can be processed on retrieval by implementing a callback handler object. The callback handler object's
handleAttribute method is invoked for each Attribute retrieved.

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [46]
Java For examples see how email aliases are stored [47] and also here [48]. You can also see an example in the Repo Usage Component [49]
example implementation.
More
Information Tech Talk Live video [50]
AttributeService Primer video [51]
Java API ­ Access and Transaction Management documentation [42].
Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

AuditService
The API by which applications can query the audit logs and enable or disable auditing.
Information AuditService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description The AuditService API provides faciities to query audit data. There are also methods to clear audit data, enable and disable auditing, and check audit
Deployment Deploy as AMP or Simple Module (JAR) package.
­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [52]
Java
example /**
* Returns content changes.
*/
public ObjectList getContentChanges(Holder<String> changeLogToken, BigInteger maxItems)
{
final ObjectListImpl result = new ObjectListImpl();
[Link](new ArrayList<ObjectData>());

EntryIdCallback changeLogCollectingCallback = new EntryIdCallback(true)


{
@Override
public boolean handleAuditEntry(Long entryId, String user, long time, Map<String, Serializable> values)
{
[Link]().addAll(createChangeEvents(time, values));
return [Link](entryId, user, time, values);
}
};

Long from = null;


if ((changeLogToken != null) && ([Link]() != null))
{
try
{
from = [Link]([Link]());
}
catch (NumberFormatException e)
{
throw new CmisInvalidArgumentException("Invalid change log token: " + changeLogToken);
}
}

AuditQueryParameters params = new AuditQueryParameters();


[Link](CMIS_CHANGELOG_AUDIT_APPLICATION);
[Link](true);
[Link](from);

int maxResults = (maxItems == null ? 0 : [Link]());


maxResults = (maxResults < 1 ? 0 : maxResults + 1);

[Link](changeLogCollectingCallback, params, maxResults);

String newChangeLogToken = null;


if (maxResults > 0)
{
if ([Link]().size() >= maxResults)
{
StringBuilder clt = new StringBuilder();
newChangeLogToken = (from == null ? [Link]([Link]() + 1).toString() : [Link]([Link]() + [Link]
[Link]().remove([Link]().size() ‐ 1).getId();
[Link](true);
}
else
{
[Link](false);
}
}

if (changeLogToken != null)
{
[Link](newChangeLogToken);
}

return result;
}

More
Information Audit platform extension point documentation [53].
Auditing Alfresco [54] in the Alfresco Administration documentation provides a detailed overview of Auditing in Alfresco.

Tutorials
Audit API Hints and Tricks [55] DevCon presentation by Mehdi Belmekki.
Audit and Reporting with Alfresco and NoSQL by Zaizi [56]
Audit tutorials [57]

Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

AuthenticationService
This service provides an API to allow authentication of users using various methods, such as username and password and authentication tickets.
Information AuthenticationService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description Authentication is required at various access points into the Repository. For example web scripts, CMIS, CIFS, FTP, WebDAV, and web
clients represent access points where authentication needs to take place. Authentication can be via Alfresco ticket, a username and
password pair, or some other mechanism.

The authentication service provides an API to:

Authenticate using a user name and password


Authenticate using a ticket
Create, update and delete authentication information
Clear the current authentication
Invalidate a ticket
Get the username for who is currently authenticated
Get a ticket for subsequent re­authentication
Determine if the current user is "the system user"

Not all implementations will support creating, updating and deleting authentication information.

The authenticated username is used as the key to obtain other security information such as group membership, the details about the
person, to record a user as the owner of an object. It is one of the identifiers against which permissions may be assigned.

The authentication service does not provide any details about a user other than authentication.

The authentication service stores authentication information on the calling thread. Application developers should ensure that this
information is cleared.

The authentication service brings together three components:

The authentication component


The authentication DAO
The ticket component

The authentication component supports authentication only. The authentication DAO provides an API to create, delete and update
authentication information. The ticket component is resposible for managing and storing tickets that may be obtained after
authentication and used in place of authentication.

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [58]
Java
example
// Get service registry
ServiceRegistry serviceRegistry = (ServiceRegistry) [Link](ServiceRegistry.SERVICE_REGISTRY);

// Get services
AuthenticationService authService = (AuthenticationService)[Link]();
PersonService personService = (PersonService)[Link]();

// Get current user


NodeRef person = [Link]([Link]());

More
Information Authentication Documentation [59]
AuthorityService JavaScript API documentation [60]
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

AuthorityService
The service that encapsulates authorities granted to users. This service will refuse to create any user authorities. These should be managed using the
AuthenticationService and PersonService. Methods that try to change alter users will throw an exception. A string key is used to identify the authority.
These follow the contract defined in AuthorityType. If there are entities linked to these authorities this key should be used to find them, as userName is
used to link user and person.
Information AuthorityService
Support Status Full Support [7]
Architecture Platform Architecture [39]
Information
Description Authority is a general term to describe a group, user, or role. The AuthorityService provides an API to:

Add and delete authorities.


Get authorities.
Retrieve authority details such as short name.

Deployment ­ Deploy as AMP or Simple Module (JAR) package.


App Server
Deployment ­ Use SDK archetypes to produce AMP or Simple Module.
SDK Project
Java API Java API Documentation [61]
Java example
/**
* Search the root groups, those without a parent group.
*
* @param paging Paging object with max number to return, and items to skip
* @param sortBy What to sort on (authorityName, shortName or displayName)
* @return The root groups (empty if there are no root groups)
*/
public ScriptGroup[] searchRootGroupsInZone(String displayNamePattern, String zone, ScriptPagingDetails paging, String sortBy)
{
Set<String> authorities;
try
{
authorities = [Link]([Link],
null, true, displayNamePattern, zone);
}
catch (UnknownAuthorityException e)
{
authorities = [Link]();
}
return makeScriptGroups(authorities, paging, sortBy, serviceRegistry, [Link]());
}

More
Information Authentication Documentation [59]
AuthorityService JavaScript API documentation [60]
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer Blogs
Parent topic: Public Java API services [2]

CategoryService
Provides an API for creating and managing categories of nodes.
Information CategoryService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description Categories provide a system for organizing content. Unlike tags, which have no hierarchical structure, and which can be created and
applied by anyone, categories are created by the Administrator, and are hierarchical in nature. For example, You might have a Europe
category, and then sub­categories such as France, Germany, Spain, and so on. The top Category in the hierarchical structure is known
as the Root Category.

The CategoryService API provides methods to perform actions such as the following:

Create a Category
Create a root Category
Delete a Category
Create a Classification (a grouping of Categories)
Delete a Classification
Get most popular Categories

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [62]
Java
example
// To create a root category:
NodeRef newRootCat = [Link](
spacesStore,
ContentModel.ASPECT_GEN_CLASSIFIABLE,
"newRootCat");

// To create a category
NodeRef newCategory = [Link](newRootCat, "newCategory");

More
Information Tagging and Categorizing Content [63]
Category Manager Documentation [64]
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

CheckOutCheckInService
Service to provide document locking. If a document is locked, other users cannot change its content, until it is unlocked.
Information CheckOutCheckInService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description Check out locks the item and creates a working copy that can be edited. The locked item can be viewed by others, but not changed.
When the item is checked in, the working copy replaces the original item and removes the lock. Methods are provided to:

Check out a node


Check in a node
Check if a node is a working copy
Check if a node is locked (checked out)
Cancel a check out for a given working copy
Get a working copy
Get the original checked out node

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [65]
Java
example CheckOutCheckInService checkOutCheckInService = [Link]();

NodeRef checkedOutCopy = [Link](nodeRef);

More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

ContentService
A service for accessing and transforming content.
Information ContentService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description The ContentService provides an API for accessing and transforming content. You may want to read the content associated with a node,
or transform the content from one format to another, for example from .ppt to .pdf. Methods provided by the API includes functionality to:

Get obtainable transformers (to convert one mimetype to another)


Get a suitable reader for a content type. The returned ContentReader will have a getContent method to actually read the content
to a specified file.
Get a suitable writer for a content type. The returned ContentWriter will have a putContent method to write the content to a
specified file.
Transform content from one mimetype to another.
Get a transformer suitable for transforming images.
Utility methods (for example to check size of content and free space in the content store).

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [66]
Java
example // Read data associated with a content NodeRef (plain text)

ContentReader reader = [Link](nodeRef, ContentModel.PROP_CONTENT);

// Reading the data content of a NodeRef (binary)

ContentReader reader = [Link](nodeRef, ContentModel.PROP_CONTENT);


InputStream originalInputStream = [Link]();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final int BUF_SIZE = 1 << 8; //1KiB buffer
byte[] buffer = new byte[BUF_SIZE];
int bytesRead = ‐1;
while((bytesRead = [Link](buffer)) > ‐1) {
[Link](buffer, 0, bytesRead);
}
[Link]();
byte[] binaryData = [Link]();

// Writing data to a node's content


// Writing data to a node's content

ContentWriter writer = [Link](nodeRef, ContentModel.PROP_CONTENT, true);


[Link](new ByteArrayInputStream(content));

// Writing a file's data to a node's content

ContentWriter writer = [Link](nodeRef, ContentModel.PROP_CONTENT, true);


[Link](CONTENT_LOCALE);
File file = new File("c:/temp/images/[Link]");
[Link]("image/bmp");
[Link](file);

// Transforming a PPT to PDF (also works for other file formats)

ContentReader pptReader = [Link](pptNodeRef, ContentModel.PROP_CONTENT);


ContentWriter pdfWriter = [Link](pdfNodeRef, ContentModel.PROP_CONTENT, true);
ContentTransformer pptToPdfTransformer =
[Link](MimetypeMap.MIMETYPE_PPT, MimetypeMap.MIMETYPE_PDF);
[Link](pptReader, pdfWriter);

/**
* Creates a new content node setting the content provided.
*
* @param parent the parent node reference
* @param name the name of the newly created content object
* @param text the content text to be set on the newly created node
* @return NodeRef node reference to the newly created content node
*/

private NodeRef createContentNode(NodeRef parent, String name, String text)


{

// Create a map to contain the values of the properties of the node

Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);


[Link](ContentModel.PROP_NAME, name);

// use the node service to create a new node


NodeRef node = [Link](
parent,
ContentModel.ASSOC_CONTAINS,
[Link](NamespaceService.CONTENT_MODEL_1_0_URI, name),
ContentModel.TYPE_CONTENT,
props).getChildRef();

// Use the content service to set the content onto the newly created node
ContentWriter writer = [Link](node, ContentModel.PROP_CONTENT, true);
[Link](MimetypeMap.MIMETYPE_TEXT_PLAIN);
[Link]("UTF‐8");
[Link](text);

// Return a node reference to the newly created node


return node;
}

More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

CopyService
This service provides methods to copy nodes within and across workspaces. It also provides support to update the state of a node, with that of another
node, within and across workspaces.
Information CopyService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description It is very useful to able to copy nodes. When copying container nodes (folders) you also have the option to copy child nodes. Operations provided by
include:

Copy a node, along with (optionally) its children.


Copy and rename a node.
Get the copies of a specified node (with paged results).
Check if the name of a top­level node will be changed during copy, due to policies in place.
Given the copied node, obtain the original node.
Copies can be performed across workspaces.

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [67]
Java
example
/*
* Copyright (C) 2005‐2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <[Link]
*/
/**
*
*/
package [Link];

import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

/**
* Copy action executor.
* <p>
* Copies the actioned upon node to a specified location.
*
* @author Roy Wetherall
*/
public class CopyActionExecuter extends ActionExecuterAbstractBase
{
public static final String ERR_OVERWRITE = "Unable to overwrite copy because more than one have been found.";

public static final String NAME = "copy";


public static final String PARAM_DESTINATION_FOLDER = "destination‐folder";
public static final String PARAM_DEEP_COPY = "deep‐copy";
public static final String PARAM_OVERWRITE_COPY = "overwrite‐copy";

private CopyService copyService;

/**
* The node service
*/
private NodeService nodeService;
private CheckOutCheckInService checkOutCheckInService;

/**
* Sets the node service
*/
public void setNodeService(NodeService nodeService)
{
[Link] = nodeService;
}

/**
* Sets the copy service
*/
public void setCopyService(CopyService copyService)
{
[Link] = copyService;
}
/**
* Service to determine check‐in or check‐out status
*/
public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService)
{
[Link] = checkOutCheckInService;
}

@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
[Link](new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF, true, getParamDisplayLabel(PARAM_DESTINAT
[Link](new ParameterDefinitionImpl(PARAM_DEEP_COPY, [Link], false, getParamDisplayLabel(PARAM_DEEP_COPY)));
[Link](new ParameterDefinitionImpl(PARAM_OVERWRITE_COPY, [Link], false, getParamDisplayLabel(PARAM_OVERWRITE_CO
}

@Override
public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
{
if (![Link](actionedUponNodeRef))
{
return;
}
NodeRef destinationParent = (NodeRef) [Link](PARAM_DESTINATION_FOLDER);

// Check the destination not to be in a pending delete list


// MNT‐11695
Set<QName> destinationAspects = [Link](destinationParent);
if ([Link](ContentModel.ASPECT_PENDING_DELETE))
{
return;
}

// Get the deep copy value


boolean deepCopy = false;
Boolean deepCopyValue = (Boolean)[Link](PARAM_DEEP_COPY);
if (deepCopyValue != null)
{
deepCopy = [Link]();
}

// Get the overwirte value


boolean overwrite = true;
Boolean overwriteValue = (Boolean)[Link](PARAM_OVERWRITE_COPY);
if (overwriteValue != null)
{
overwrite = [Link]();
}

// Since we are overwriting we need to figure out whether the destination node exists
NodeRef copyNodeRef = null;
if (overwrite == true)
{
// Try and find copies of the actioned upon node reference.
// Include the parent folder because that's where the copy will be if this action
// had done the first copy.
PagingResults<CopyInfo> copies = [Link](
actionedUponNodeRef,
destinationParent,
new PagingRequest(1000));
for (CopyInfo copyInfo : [Link]())
{
NodeRef copy = [Link]();
// We know that it is in the destination parent, but avoid working copies
if ([Link](copy))
{
continue;
}
if (copyNodeRef == null)
{
copyNodeRef = copy;
}
else
{
throw new RuleServiceException(ERR_OVERWRITE);
}
}
}

if (copyNodeRef != null)
{
// Overwrite the state of the destination node ref with the actioned upon node state
[Link](actionedUponNodeRef, copyNodeRef);
}
else
{
ChildAssociationRef originalAssoc = [Link](actionedUponNodeRef);
// Create a new copy of the node
[Link](
actionedUponNodeRef,
destinationParent,
[Link](),
[Link](),
deepCopy);
}
}
}

More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

DictionaryService
This service represents the Repository Data Dictionary. The dictionary provides access to content meta­data such as Type and Aspect descriptions.
Content metadata is organized into models where each model is given a qualified name. This means that it is safe to develop independent models and
bring them together into the same Repository without name clashes (as long their namespace is different).
Information DictionaryService
Support Status Full Support [7]
Architecture Platform Architecture [39]
Information
Description The DictionaryService provides access to the entire content meta­model. The content meta­model contains information of Types,
DataTypes, Properties, Aspects, Associations and Constraints. Operations supported include:

Get DataTypes, Types, Associations, Properties, Constraints, Classes from a Content Model.
Check if a class is a sub­class.
Get SubTypes and SubAspects.

Deployment ­ Deploy as AMP or Simple Module (JAR) package.


App Server
Deployment ­ Use SDK archetypes to produce AMP or Simple Module.
SDK Project
Java API Java API Documentation [68]
Java example
/**
* Determines whether one class is a sub type of an other. Returns true if it is, false otherwise.
*
* @param clazz the class to test
* @param subTypeOf test whether the class is a sub‐type of this class
* @return boolean true if it is a sub‐class, false otherwise
*/
public boolean isSubTypeOf(final String clazz, final String subTypeOf)
{
Boolean result = [Link](new SessionWork<Boolean>()
{
public Boolean doWork()
{
// Convert to full names if required
String fullClazz = [Link]().getFullName(clazz);
String fullSubTypeOf = [Link]().getFullName(subTypeOf);

// Create the QNames for the passes classes


QName className = [Link](fullClazz);
QName ofClassName = [Link](fullSubTypeOf);

// Return the result


return new Boolean([Link](className, ofClassName));
}
});

return [Link]();
}

More
Information Content Model Extension Point [69]
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

FileFolderService
Provides methods specific to manipulating files and folders. This service provides a simple way of accessing simple trees of files and folders in Alfresco.
Information FileFolderService
Support Status Full Support [7]
Architecture Information Platform Architecture [39]
Description The FileFolderService provides methods for dealing with Files and Folders. Operations include:

Copy a file or folder


Create a file or folder
Delete a file or folder
Get Readers and Writers for a file
List files and folders (with paged results)

The methods typically work with a NodeRef for the node that represents the target file or folder.

Deployment ­ App Server Deploy as AMP or Simple Module (JAR) package.


Deployment ­ SDK Project Use SDK archetypes to produce AMP or Simple Module.
Java API Java API Documentation [70]
Java example
// Creating a PDF (or other document)

QName contentQName = [Link]("{[Link]


FileInfo pdfInfo = [Link](directory, filename, contentQName);
NodeRef pdf = [Link]();

More Information
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco Developer Blogs None
Parent topic: Public Java API services [2]

JobLockService
This service ensures that a scheduled job can only run on one node of a cluster at a time. A scheduled job could be, for example, an Activities feed job
that generates email to send to everyone every night or a content cleaner job that cleans up orphaned content.
Information JobLockService
Support Status Full Support [7]
Architecture Information Platform Architecture [39]
Description The JobLockService is used to provide a locking service at the job level, rather than the node level.
Deployment ­ App Server Deploy as AMP or Simple Module (JAR) package.
Deployment ­ SDK Project Use SDK archetypes to produce AMP or Simple Module.
Java API Java API Documentation [71]
Java example For an example of using the JobLockService see the Content Store Cleaner code [72] on GitHub.
More Information
Scheduled Jobs extension point documentation [73]
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco Developer Blogs None
Parent topic: Public Java API services [2]

LockService
A node­level locking service, used by the CheckOutCheckIn service. Does not create a working copy.
Information LockService
Support Status Full Support [7]
Architecture Information Platform Architecture [39]
Description If you need a node­level locking system, then the LockService can provide this. Functionality provided by the service
includes:

Checking for a lock on a node


Obtaining lock information
Locking and unlocking a node
Suspend and enable locks

Deployment ­ App Server Deploy as AMP or Simple Module (JAR) package.


Deployment ­ SDK Use SDK archetypes to produce AMP or Simple Module.
Project
Java API Java API Documention [74]
Java example
/**
* Return whether a Node is currently locked
* @param node The Node wrapper to test against
* @param lockService The LockService to use
* @return whether a Node is currently locked
*/
public static Boolean isNodeLocked(Node node,LockService lockService){
Boolean locked=[Link];
if ([Link](ContentModel.ASPECT_LOCKABLE)) {
LockStatus lockStatus=[Link]([Link]());
if (lockStatus == [Link] || lockStatus == LockStatus.LOCK_OWNER) {
locked=[Link];
}
}
return locked;
}

More Information
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco Developer Blogs None
Parent topic: Public Java API services [2]

MessageService
Provides methods to access the Locale of the current thread and to get Localised strings. These strings may be loaded from resource bundles deployed
in the Repository.
Information MessageService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description This service provides functionality around Internationalization (i18n). It provides facilities to:

Get and set the locale


Register and unregister resource bundles

All user displayed strings that originate in the repository should be externalised into resource bundles to ensure that the repository is
fully localisable. Examples of strings requiring extraction include:

Descriptive display labels used by a client


Error messages

Extracted strings should be gathered into resource bundles by functional area. This enables functional areas to remain distinct within
the repository.

The base bundle should be named by functional area and have the .properties extension. All base bundles should be in US English.

If a message needs to be parameterised the Java MessageFormatter style should be used.

The IDs used in the resource bundles should be scoped by functional area to avoid clashes (this is important since at runtime the
contents of the various resource bundles in combined, any names clashes will result in message values being overwritten).

A resource bundle can be placed anywhere in the source tree, but in general repository resource bundles should be placed in the
[Link] package found in the config directory.

Example resource bundle contents:


# User displayed string for the rule service functional area
[Link]=There has been an error executing rule {0}.
ruleservice.confimation_all=All rules have been executed.

Before a resource bundle can be used by the repository it must be registered. Suitable methods are provided by the service to support
this.

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [75]
Java You can see an example of use of the MessageService in the invite sender implementation [76]. The messages are located here [77].
example
More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

MimetypeService
Provides support related to content mimetype. For example, provides methods to retrieve the extension for the specified mimetype.
Information MimetypeService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description Alfresco ECM supportes numerous mimetypes OOTB. However, it is also possible to add your own custom mimetypes. The
MimetypeService provides an API for managing mimetypes. For example, you can obtain a list of current mimetypes, mimetype
extensions, and guess mimetypes using a specified file and content reader.
Deployment Deploy as AMP or Simple Module (JAR) package.
­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API [78]
Java
example // Using mimetype service when writing content

ContentWriter contentWriter = [Link](node, ContentModel.PROP_CONTENT, true);

[Link]([Link](filename));

[Link]([Link]());

More
Information Java API ­ Access and Transaction Management documentation [42].
Mimetype platform extension point documentation [79]

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

ModuleService
A service to control and provide information about the currently­installed modules.
Information ModuleService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description A module is an extension to Alfresco that is developed with a particular project structure and packaging. Modules can be registered and
loaded as part of the boot process. In the Repository Admin Tools (Enterprise version) you can view the currently installed Modules [80].
The ModuleService provides functionality to programmatically start up and shut down modules, and get module information.
Deployment Deploy as AMP or Simple Module (JAR) package.
­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [81]
Java
example
// Get all Modules

List<ModuleDetails> modules = [Link]();


[Link]([Link](MSG_FOUND_MODULES, [Link]()));

for (ModuleDetails module : modules)


{
Map<String, ModuleComponent> components = getComponents([Link]());
for (ModuleComponent component : [Link]())
{
[Link]();
}
}

More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

NamespaceService
Provides access to and definition of namespace URIs and Prefixes.
Information NamespaceService
Support Status Full Support [7]
Architecture Platform Architecture [39]
Information
Description Alfresco namespaces start with [Link]

The top­level namespace sub­divisions are:

model ­ identify an Alfresco data model


view ­ identify a view of content held in the Alfresco Repository
ws ­ identify an Alfresco Web Service definition
test ­ identify a test definition

Each namespace typically ends with its version number.

Registry

Note: This list will expand / change between now and the next release.

Common
Namespace Prefix Description
[Link] alf General Alfresco Namespace
[Link] d Data Dictionary model
[Link] sys Repository system model
[Link] cm Content Domain model
[Link] app Application model
[Link] bpm Business Process Model
[Link] st Site Model
[Link] fm Forum Model
[Link] usr User model (in [Link])
[Link] view Alfresco Import / Export View
[Link] act Action service model
[Link] rule Rule service model
[Link] auth Authentication Web Service
[Link] rep Repository Web Service
[Link] content Content Web Service
[Link] author Authoring Web Service
[Link] cls Classification Web Service
[Link] cml Content Manipulation Language
[Link] cm Web Service Content Domain Model
[Link] wf Workflow Model(link is to Alfresco simple workflow model,
not generally extended)

Deployment ­ App Deploy as AMP or Simple Module (JAR) package.


Server
Deployment ­ SDK Use SDK archetypes to produce AMP or Simple Module.
Project
Java API Java API Documentation [82]
Java example See Jeff Potts example code on GitHub [83].
More Information
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco Developer None
Blogs
Parent topic: Public Java API services [2]

NodeService
Provides an API for managing nodes.
Information NodeService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description Nodes are the fundamental data structure in Alfresco ECM. All content that is stored is represented by a node data structure, which contains
content metadata and is persisted in a database (such as PostgreSQL). The content referenced by the node is stored as a *.bin file in a
content store (such as the file system, S3, encrypted or other content store). Every node in the system is referenced by a NodeRef, which is
made up of the content store protocol, the content store name, and the Universal Unique Identifier (UUID) of the content, for example:
workspace://SpacesStore/ccb906ba‐a768‐4ccb‐8b26‐515119e1efdc.

Generally nodes are of two main types, a content node (cm:content), or a folder node (cm:folder). Folders can contain child nodes. Note that
each content store will have a root node, and all other nodes in the store will be children of the root node.

The NodeService provides an extensive API for managing nodes. Functionality includes:

Adding aspects, children, properties, associations


Getting aspects, children, properties, associations
Removing aspects, children, properties, associations
Creating and deleting stores
Creating and deleting nodes
Checking for existence of a node
Get available content stores
Moving nodes

The NodeService makes extensive use of NodeRefs to reference the node of interest.

Since Alfresco 4.1.1 the alf_node.node_deleted column has been replaced by a system type (sys:deleted) and an aspect (sys:pendingDelete).
While the sys:deleted type will never be visible to client code, the sys:pendingDelete aspect will be. Any custom code that attempts to modify
behaviour during node deletion may need to be adjusted.
Node deletion

Changes made in 4.1.1 introduced comprehensive policy callbacks for all associations during node deletion. The following node policies are
available for node deletion:

BeforeDeleteNodePolicy
BeforeArchiveNodePolicy
OnDeleteNodePolicy
BeforeDeleteChildAssociationPolicy
OnDeleteChildAssociationPolicy
BeforeDeleteAssociationPolicy
OnDeleteAssociationPolicy

The association (peer and child) policies are now fired reliably for all associations within the node hierarchy being deleted. For examples of
their usage, see: [Link].

Once [Link] is called:

It is impossible to add or remove associations to or from any node in the hierarchy being deleted. This includes attempted changes from
any source including changes attempted by custom code reacting to before­ or on­delete callbacks.
All nodes in the hierarchy will temporarily have the sys:pendingDelete aspect applied. Custom code can using [Link]
to discover if a node is about to be deleted.
It is impossible to add new nodes or link other nodes into any node in the hierarchy being deleted. Any attempt to do so will be treated as
a concurrency violation since custom code should not be attempting this from callbacks during the node deletion.
All associations, with the notable exception of the primary parent­child links, will be removed even if node archival is taking place. Node
archival now only preserves the core parent­child associations and discards all other associations after making the relevant callbacks.
Custom code must use the association deletion callbacks to remove nodes or aspects that might violate model integrity constraints in the
archived hierarchy.

A good example of the changes is in the handling of the cm:copiedFrom aspect. Copied nodes have an aspect cm:copiedfrom, which has a
mandatory association to the original source node. When either the source or copy is deleted the aspect has to be removed. See
[Link] for how the association deletion is detected in order to ensure that the
aspect is removed from the copied node.

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API [84]
Java
example
// Getting a NodeRef from its path

StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");


ResultSet rs = [Link](storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home/app:user_homes/sys:boris/cm:mypics\"");
NodeRef companyHomeNodeRef = null;
try
{
if ([Link]() == 0)
{
throw new AlfrescoRuntimeException("Didn't find Company Home");
}
companyHomeNodeRef = [Link](0);
}
finally
{
[Link]();
}

// Getting a file name from a NodeRef

String fileName = (String) [Link](nodeRef, ContentModel.PROP_NAME);

// Reading a property of a node


// The property may come from an aspect or not. You will probably want to cast to the appropriate type.

QName PROP_QNAME_MY_PROPERTY = [Link]("[Link]", "myProperty");


value = [Link](nodeRef, PROP_QNAME_MY_PROPERTY);

// Updating a property of a node


// The property may come from an aspect or not.

QName PROP_QNAME_MY_PROPERTY = [Link]("[Link]", "myProperty");


[Link](nodeRef, PROP_QNAME_MY_PROPERTY, value);

// Getting the parent of a NodeRef

ChildAssociationRef childAssociationRef = [Link](nodeRef);


NodeRef parent = [Link]();

// Adding an aspect to a node


// Supposing the "MyAspect" aspect defines a "myProperty" property in the "[Link]" namespace.

QName CUSTOM_ASPECT_QNAME = [Link]("[Link]", "MyAspect");


QName PROP_QNAME_MY_PROPERTY = [Link]("[Link]", "myProperty");
Map<QName,Serializable> aspectValues = new HashMap<QName,Serializable>();
[Link](PROP_QNAME_MY_PROPERTY, value);
[Link](nodeRef, CUSTOM_ASPECT_QNAME, aspectValues);

// Checking whether a node has a given aspect

QName CUSTOM_ASPECT_QNAME = [Link]("[Link]", "MyAspect");


boolean hasAspect = [Link](node, CUSTOM_ASPECT_QNAME);

// Looping through children of a NodeRef

List<ChildAssociationRef> children = [Link](companyHome);


for (ChildAssociationRef childAssoc : children) {
NodeRef childNodeRef = [Link]();
// Use childNodeRef here.
}

// Creating a child association between two existing NodeRef

QName PROP_QNAME_MY_CHILD_ASSOCIATION = [Link]("[Link]", "myChildAssociation");


[Link](parentNodeRef, childNodeRef, PROP_QNAME_MY_CHILD_ASSOCIATION, PROP_QNAME_MY_CHILD_ASSOCIATION);

// Creating an association between two NodeRef

QName PROP_QNAME_MY_ASSOCIATION = [Link]("[Link]", "myAssociation");


[Link](sourceNodeRef, targetNodeRef, PROP_QNAME_MY_ASSOCIATION);

// Setting the type of a node

QName PROP_QNAME_MY_TYPE = [Link]("[Link]", "myType");


[Link](finalOriginal, MY_TYPE);

// Getting the MIME type of a node

ContentData contentData = (ContentData) [Link](nodeRef, ContentModel.PROP_CONTENT);


String originalMimeType = [Link]();

// Adding a category to a node

ArrayList<NodeRef> categories = new ArrayList<NodeRef>(1);


[Link](categoryNode);
if(![Link](targetNode, ContentModel.ASPECT_GEN_CLASSIFIABLE)
{
HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
[Link](ContentModel.PROP_CATEGORIES, categories);
[Link](targetNode, ContentModel.ASPECT_GEN_CLASSIFIABLE, props);
}
else
{
[Link](targetNode, ContentModel.PROP_CATEGORIES, categories);
}

// Getting the categories of a node

List<NodeRef> categories = (List<NodeRef>) [Link](nodeRef, ContentModel.PROP_CATEGORIES);

// Deleting a node for real (not recycle bin)

[Link](nodeRef, ContentModel.ASPECT_TEMPORARY, null);


[Link](nodeRef);

More
Information Java API ­ Access and Transaction Management documentation [42].
Custom Content Store platform extension point documentation [85]

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

NodeLocatorService
The NodeLocatorService looks up node locators registered via Spring configuration by name.
Information NodeLocatorService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description
Introduction

The 4.0 release saw the introduction of the NodeLocatorService.


The service provides a way to lookup one node from another, its main use is from the Forms association control, allowing custom
"startLocation" strategies to be plugged in.

Configuration

The NodeLocatorService looks up node locators by name, the out­of­the­box node locators are defined in a file named node­locator­
[Link].

This Spring configuration file defines a base bean that can be used to define new node locator implementations. Using this bean will
automatically register the node locator with the repository and make it available.

This page will use an example node locator to describe the service, it will allow a named folder to be found. To define the example node
locator the following Spring configuration would be used (in a custom context file):

<bean id="namedFolderNodeLocator" class="[Link]" parent="baseNodeLocator">


<property name="NodeService" ref="NodeService" />
<property name="FileFolderService" ref="FileFolderService" />
</bean>

Java API

The NodeLocatorService looks up node locators registered via Spring configuration by name. A node locator must implement the
NodeLocator interface, whose definition is shown below:

public interface NodeLocator


{
NodeRef getNode(NodeRef source, Map<String, Serializable> params);
public List<ParameterDefinition> getParameterDefinitions();
}

A NodeLocator in its simplest form takes a source node, some optional parameters and returns a node or null if a suitable node could
not be found. If a node is not found the NodeLocatorService returns the NodeRef representing "Company Home".

The source node is not mandatory, node locators can be used to return well known nodes, "Company Home", "User Home" for example
in which case a source node is not required.

If a NodeLocator has parameters they must be defined using the same definition classes (ParameterDefinition) used by the
ActionService.

A base class AbstractNodeLocator is provided and it is recommended that your NodeLocator extends this base class. It provides the
functionality to register the NodeLocator with the NodeLocatorService registry. This class also defines an abstract method your
implementation must override.

public abstract String getName();

This is the unique name for your NodeLocator and will be used by the NodeLocatorService in the lookup process. It is also used in the
startLocation configuration.

Example

Our example locator, NamedFolderNodeLocator, will be named "namedfolder" and will expect a single parameter called "name" which
will indicate what folder to locate. The full source for this example is shown below:

public class NamedFolderNodeLocator extends AbstractNodeLocator


{
public static final String LOCATOR_NAME = "namedfolder";
public static final String NAME_PARAM = "name";

private NodeService nodeService;


private FileFolderService fileFolderService;

public void setNodeService(NodeService nodeService)


{
[Link] = nodeService;
}

public void setFileFolderService(FileFolderService fileFolderService)


{
[Link] = fileFolderService;
}

@Override
public NodeRef getNode(NodeRef source, Map<String, Serializable> params)
{
NodeRef node = null;

String folderName = (String)[Link](NAME_PARAM);


if (source != null && folderName != null)
{
// get the parent of the source node
NodeRef parent = [Link](source).getParentRef();
// look for a child with the provided name
NodeRef folder = [Link](parent, ContentModel.ASSOC_CONTAINS, folderName);
// make sure it's a folder
if (folder != null && [Link](folder).isFolder())
{
node = folder;
}
}
return node;
}

public List<ParameterDefinition> getParameterDefinitions()


{
List<ParameterDefinition> paramDefs = new ArrayList<ParameterDefinition>(2);
[Link](new ParameterDefinitionImpl(NAME_PARAM, [Link], false, "Name"));
return paramDefs;
}

public String getName()


{
return LOCATOR_NAME;
}
}

The "source" parameter in getNode() represents the starting point, in a form association control this will be the node being edited, for a
create form it will be the destination node. Our example finds the primary parent of the source node and looks for a child folder with the
given name. This is a fairly simple example but it is easy to see how this could be extended to allow for a named folder to be located up
or down a folder hierarchy.

REST API

A REST API is provided for the NodeLocatorService, it is used by the form association control to determine the startLocation of the
control but of course can be used by any client if required.

The webscript descriptor is shown below:

<webscript>
<shortname>Node Locator</shortname>
<description>Locates a Node in the repository using the specified Node Location strategy.</description>
<url>/api/{store_type}/{store_id}/{node_id}/nodelocator/{node_locator_name}</url>
<url>/api/nodelocator/{node_locator_name}</url>
<format default="json"/>
<authentication>user</authentication>
<transaction allow="readonly">required</transaction>
</webscript>

Two URLs are supported, one that allows a source node to be provided and one that does not, this is useful for "well known" nodes,
"Company Home", "Sites Home" for example. Parameters are passed as query string parameters, a request for our example node
locator may look like the following:

[Link]

A typical response is shown below:


{
"data":
{
"nodeRef": "workspace://SpacesStore/d2a8bc42‐4874‐4d45‐9a23‐33cdd02be777"
}
}

startLocation

The main use of the NodeLocatorService is to determine where the forms association control should start when it is first displayed. In
some scenarios the picker may need to start in the root of the document library of a Share site or start in the folder where the node
being edit is located. See the next section for a list of NodeLocators provided out­of­the­box.

NodeLocators are configured using form control parameters. The name of the NodeLocator implementation is provided as the
'startLocation' parameter and the parameters are provided by a 'startLocationParameters' parameter. They should be provided in the
form of query string parameters, for example name=value&name=value.

The configuration for our example node locator is shown below, it will look for a folder named "Example" in the same folder as the node
being edited.

<field id="my:association">
<control>
<control‐param name="startLocation">{namedfolder}</control‐param>
<control‐param name="startLocationParams">name=Example</control‐param>
</control>
</field>

Note: The curly braces are required around the node locator name.

Available Node Locators

The following table shows the node locators available out­of­the­box, the parameters they accept and their use.

Name Class Parameters Usage


companyhome CompanyHomeNodeLocator None Returns the Company Home node
userhome UserHomeNodeLocator None Returns the current user's home folder node
sharedhome SharedHomeNodeLocator None Returns the Shared Home root node
siteshome SitesHomeNodeLocator None Returns the Sites root node
doclib DocLibNodeLocator None Returns the documentLibrary node for the site the source node belongs
to
self SelfNodeLocator None Returns the source node
xpath XPathNodeLocator query, Returns the node pointed to by the given XPath query. The XPath should
store_type be relative to the root of a store. If a source node is provided the Store is
and taken from the node, otherwise the store_type and store_id must be
store_id provided.
ancestor AncestorNodeLocator type and Returns an ancestor node of the source node. If no parameters are
aspect provided the immediate parent is returned. If a type parameter is present
the first ancestor node of that type is returned. If an aspect parameter is
present the first ancestor node with that aspect applied is returned. The
type and aspect parameters can be combined thus finding an ancestor
node of a certain type and with a specific aspect applied.

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [86]
Java See Description for example.
example
More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

PermissionService
Provides an API for managing the node permissions. Permissions specify users and groups that have access to a node. Each user and group can be
assigned a role.
Information PermissionService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description The permission service is responsible for:

Providing well known permissions and authorities


Providing an API to read, set, and delete permissions for a node
Providing an API to query, enable, and disable permission inheritance for a node
Determining if the current, authenticated user has a permission for a node

The PermissionService interface defines constants for well­known permissions and authorities.

The default implementation coordinates implementations of two service provider interfaces: a ModelDAO and a PermissionsDAO. A
permission is simply a name scoped by the fully qualified name of the type or aspect to which it applies. The beans are defined and
configured in <installLocation>\tomcat\webapps\alfresco\WEB­INF\classes\alfresco\public­services­security­[Link]. This file also
contains the configuration for security enforcement.

The ModelDAO interface defines an API to access a permissions model. The default permission model is in XML and defines
permission sets, and their related permission groups and permissions. Global permissions are part of the permission model. There may
be more than one permission model defined in XML; they are in practice merged into one permission model. A module can extend the
permission model.

The available permissions are defined in the permission model. This is defined in <installLocation>\tomcat\webapps\alfresco\WEB­
INF\classes\alfresco\model\[Link]. This configuration is loaded in a bean definition in
<installLocation>\tomcat\webapps\alfresco\WEB­INF\classes\alfresco\public­services­security­[Link]. This file also defines global
permissions. The definition file is read once at application start­up. If you make changes to this file, you will have to restart the repository
in order to apply the changes.
Deployment Deploy as AMP or Simple Module (JAR) package.
­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [87]
Java
example
// Set permissions for a user on a node
[Link](nodeRef, "NameOfUser...", [Link], true);

More
Information Java API ­ Access and Transaction Management documentation [42].
Permissions platform extension point documentation [88]

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

PersonService
This service encapsulates the management of people and groups. People and groups may be managed entirely in the repository or entirely in some
other implementation such as LDAP or via NTLM. Some properties may be in the repository and some in another store. Individual properties may or
may not be mutable.
Information PersonService
Support Status Full Support [7]
Architecture Information Platform Architecture [39]
Description The Person service supports various methods relating to users.

The methods relating to the Person service include the ability to:

Look up people from user names


Create user information
Delete user information
Modify user information

Deployment ­ App Server Deploy as AMP or Simple Module (JAR) package.


Deployment ­ SDK Project Use SDK archetypes to produce AMP or Simple Module.
Java API Java API Documentation [89]
Java example
// Create user with authentication
if ([Link](userName) == false)
{
[Link](userName, [Link]());

Map user = new Map();


[Link](ContentModel.PROP_USERNAME, userName);
[Link](ContentModel.PROP_FIRSTNAME, "firstName");
[Link](ContentModel.PROP_LASTNAME, "lastName");
[Link](ContentModel.PROP_EMAIL, userName+"@[Link]");
[Link](ContentModel.PROP_JOBTITLE, "jobTitle");

NodeRef person = [Link](user);

// ...
}

More Information
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco Developer Blogs None

Parent topic: Public Java API services [2]


RenditionService
Provides support for rendering content nodes into other forms, known as renditions. The rendition nodes are derived from their source node and as
such can be updated automatically when their source node's content (or other properties) are changed. Examples of renditions include reformatted
content (essentially a transformation from one MIME­type to another), rescaled images (including thumbnails), and the output of a Freemarker or XSLT
template. Renditions can be performed synchronously or asynchronously and can be created at a specified location within the Alfresco repository. By
default they are created as primary children of their source node but it is possible to have them created at other nodes specified explicitly or as
templated paths.
Information RenditionService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description The DM Rendition Service was introduced in Alfresco 3.3. Its purpose is to provide support for rendering content nodes into other forms,
known as renditions. The rendition nodes are derived from their source node and as such can be updated automatically when their
source node's content (or other properties) are changed. Examples of renditions include:

Reformatted content (essentially a transformation from one MIME­type to another)


Rescaled images (including thumbnails) the output of a Freemarker or XSLT template

Renditions can be performed synchronously or asynchronously and can be created at a specified location within the Alfresco repository.
By default they are created as primary children of their source node but it is possible to have them created at other nodes specified
explicitly or as templated paths.

Terminology
Rendering Engines
Are responsible for performing the transformation on a source node to create a rendition. Different Rendering Engines will perform
different types of transformation. They can be registered with the Rendition Service using a unique name.
Rendering Engine Definitions
Provide a description of a given Rendering Engine. Each Rendering Engine Definition exposes parameter definitions for all the
parameters which can be provided to the associated Rendering Engine. Each parameter definition describes the parameter name,
type and whether or not it is mandatory.
Rendition Definitions
Encapsulate all the necessary information for rendering a given source node into a rendition. This includes the Rendering Engine
which is used to perform the rendition and all the parameter values specified. Rendition Definitions have unique, qualified names
and can be persisted within the repository.
Composite Rendition Definitions
are a special type of Rendition Definition which allow the creation of renditions which require a sequence of two or more
transformation steps. For example, a Composite Rendition Definition could be used to first reformat a PDF document into a PNG
image and then resize the image to a small thumbnail. Composite Rendition Definitions specify an ordered list of other Rendition
Definitions to be sequentially executed, with the output of the previous transformation feeding in as the source node for the next
definition. All Composite Rendition Definitions specify the Composite Rendering Engine for their transformations.

Available rendering engines include:

Base rendering engine


Reformat rendering engine
Image rendering engine
FreeMarker rendering engine
XSLT rendering engine
HTML rendering engine
Composite rendering engine

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [90]
Java
example Registering a new Rendering Engine

Rendering Engines are registered with the Rendition Service through Spring dependency injection. rendition­services­[Link]
declares an abstract bean called baseRenderingAction which is the parent bean for all rendering engines. baseRenderingAction itself is
a child bean of the ActionService's action­executer bean.

Alfresco provides a number of concrete rendering engine beans e.g. reformat within the same spring context file. In order to register a
new rendering engine, simply add new spring bean definitions in the normal way.

Retrieving registered Rendering Engine Definitions

// Rendering Engine Definitions can be retrieved


// 1. as a list of all registered engine definitions

List<RenderingEngineDefinition> engineDefs = [Link]();


// 2. by name
// This name must be the same as the spring bean name used for the rendering engine.

String renderingEngineName = "myEngineName";


RenderingEngineDefinition engineDef = [Link](renderingEngineName);

Creating a Rendition Definition

// Names must be provided for the rendition definition and the rendering engine to use.
QName renditionName = [Link](NamespaceService.CONTENT_MODEL_1_0_URI, "myRendDefn");
String renderingEngineName = [Link];

// Create the Rendition Definition object.


RenditionDefinition renditionDef = [Link](renditionName, renderingEngineName);

// Set parameters on the rendition definition.


[Link](AbstractRenderingEngine.PARAM_MIME_TYPE, MimetypeMap.MIMETYPE_PDF);

Storing a Rendition Definition

// Store the Rendition Definition using the QName


// of the Rendition Definition as a unique identifier.
[Link](renditionDef);

Retrieving a Rendition Definition

// Rendition Definitions can be retrieved:


// 1. As a list of all stored Rendition Definitions
List<RenditionDefinition> definitions = [Link]();

// 2. As a list of stored Rendition Definitions filtered by Rendering Engine name.


String renderingEngineName = "myEngineName";
List<RenditionDefinition> definitions = [Link]();

// 3. As a single Rendition Definition, uniquely identified by its QName.


QName renditionName = [Link](NamespaceService.CONTENT_MODEL_1_0_URI, "myRendDefn");
RenditionDefinition renditionDef = [Link](renditionName);

Editing an existing Rendition Definition

// Retrieve the existing Rendition Definition


QName renditionName = [Link](NamespaceService.CONTENT_MODEL_1_0_URI, "myRendDefn");
RenditionDefinition renditionDef = [Link](renditionName);

// Make changes.
[Link](AbstractRenderingEngine.PARAM_MIME_TYPE, MimetypeMap.MIMETYPE_PDF);
[Link](RenditionService.PARAM_ORPHAN_EXISTING_RENDITION, true);

// Persist the changes.


[Link](renditionDef);

Performing a simple rendition

// A rendition definition is required to perform any rendition.


// The rendition definition can be loaded from the repository or created as shown above.
NodeRef sourceNode = // obtained in the usual way e.g. from nodeService
ChildAssociationRef renditionAssoc = [Link](sourceNode, renditionDef);

Performing a composite rendition

// First obtain a Composite Rendition Definition


// This can be loaded from the repository or created as shown here.
QName renditionName = [Link](NamespaceService.CONTENT_MODEL_1_0_URI, "myRendDefn");
CompositeRenditionDefinition compositeDefinition =
[Link](renditionName);

// Now specify which other renditions are to be performed as part of the composite rendition.
RenditionDefinition reformatDefinition = [Link](reformatRenditionName);
RenditionDefinition rescaleImageDefinition = [Link](rescaleImageRenditionName);

[Link](reformatDefinition);
[Link](rescaleImageDefinition);

// Perform the composite rendition


NodeRef sourceNode = // obtained in the usual way e.g. from nodeService
ChildAssociationRef renditionAssoc = [Link](sourceNode, compositeDefinition);

Retrieving renditions for a node

NodeRef sourceNode = // obtained in the usual way e.g. from nodeService


// 1. Get all renditions with the specified node as their source.
List<ChildAssociationRef> allRenditions = [Link](sourceNode);

// 2. Get the rendition with the specified source node and the specified rendition definition name.
// If there is no matching rendition, null is returned
QName renditionName = [Link](NamespaceService.CONTENT_MODEL_1_0_URI, "myRenditionDef");
ChildAssociationRef rendition = [Link](sourceNode, renditionName);

// 3. Get the renditions with the specified source node whose MIME types match a filter
// This example returns renditions whose mimetype starts with "image".
List<ChildAssociationRef> imageRenditions = [Link](sourceNode, "image");

Specifying a RenditionDefinition as asynchronous or synchronous

This behaviour is inherited from the ActionService ­ remember that RenditionDefinition extends Action. So we can create a Rendition
Definition as shown above and set it to execute asynchronously:

RenditionDefinition renditionDef = // created as shown above

[Link](true);

More
Information Java API ­ Access and Transaction Management documentation [42].
Mimetypes platform extension documentation [79]

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

RetryingTransactionHelper
A helper that runs a unit of work inside a UserTransaction, transparently retrying the unit of work if the cause of failure is an optimistic locking or
deadlock condition.
Information RetryingTransactionHelper
Support Status Full Support [7]
Architecture Information Platform Architecture [39]
Description A description and application of the RetryingTransactionHelper can be found here [42].
Deployment ­ App Server Deploy as AMP or Simple Module (JAR) package.
Deployment ­ SDK Project Use SDK archetypes to produce AMP or Simple Module.
Java API Java API Documentation [91]
Java example See here [42].
More Information See here [42].
Tutorials None
Alfresco Developer Blogs None
Parent topic: Public Java API services [2]

SearchService
This encapsulates the execution of search against different indexing mechanisms.
Information SearchService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description Solr provides indexing of metadata and the plain text of content. This can be queried using various query languages. The query languages supporte

LANGUAGE_CMIS_ALFRESCO
LANGUAGE_CMIS_STRICT
LANGUAGE_FTS_ALFRESCO
LANGUAGE_LUCENE
LANGUAGE_SOLR_ALFRESCO
LANGUAGE_SOLR_CMIS
LANGUAGE_SOLR_FTS_ALFRESCO
LANGUAGE_XPATH

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [92]
Java
example
// Simple example
ResultSet results = [Link](storeRef, SearchService.LANGUAGE_FTS_ALFRESCO, "quick");

// Find all the nodes under the root node by QName namespace:one
// The prefix must be resolved to a URI
ResultSet results = [Link]([Link](), "lucene", "PATH:\"/namespace:one\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:one/namespace:five\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:one/namespace:five/namespace:twelve\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:*/namespace:*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:*/namespace:*/namespace:*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:one/namespace:*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:*/namespace:five/namespace:*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:one/namespace:*/namespace:nine\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/*/*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/*/namespace:five\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/*/*/*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:one/*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/*/namespace:five/*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/namespace:one/*/namespace:nine\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"//.\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"//*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"//*/.\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"//*/./.\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"//./*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"//././*/././.\"", null, null);

// Examples using the default namespace


results = [Link](storeRef, "lucene", "PATH:\"//common\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/one//common\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/one/five//*\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/one/five//.\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/one//five/nine\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/one//thirteen/fourteen\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/one//thirteen/fourteen//.\"", null, null);
results = [Link](storeRef, "lucene", "PATH:\"/one//thirteen/fourteen//.//.\"", null, null);

// Type based queries.


// escapeQName uses QueryParser static method to escape the string.

QName qname = [Link](NamespaceService.ALFRESCO_URI, "int‐ista");


results = [Link](storeRef, "lucene", "\\@" + escapeQName(qname) + ":\"01\"", null, null);

qname = [Link](NamespaceService.ALFRESCO_URI, "long‐ista");


results = [Link](storeRef, "lucene", "\\@" + escapeQName(qname) + ":\"2\"", null, null);

qname = [Link](NamespaceService.ALFRESCO_URI, "float‐ista");


results = [Link](storeRef, "lucene", "\\@" + escapeQName(qname) + ":\"3.4\"", null, null);

results = [Link](storeRef, "lucene", "\\@" + escapeQName([Link](NamespaceService.ALFRESCO_URI, "double‐ista")) + ":\"5.6\"", nu

Date date = new Date();


String sDate = [Link]().format(date);
results = [Link](storeRef, "lucene", "\\@" + escapeQName([Link](NamespaceService.ALFRESCO_URI, "date‐ista")) + ":\"" + sDate +

results = [Link](storeRef, "lucene",


"\\@" + escapeQName([Link](NamespaceService.ALFRESCO_URI, "datetime‐ista")) + ":\"" + sDate + "\"", null, null);

results = [Link](storeRef, "lucene", "\\@" + escapeQName([Link](NamespaceService.ALFRESCO_URI, "boolean‐ista")) + ":\"true\"",


null);

results = [Link](storeRef, "lucene", "\\@" + escapeQName([Link](NamespaceService.ALFRESCO_URI, "qname‐ista")) + ":\"{wibble}wob


null, null);
results = [Link](storeRef, "lucene", "\\@" + escapeQName([Link](NamespaceService.ALFRESCO_URI, "guid‐ista")) + ":\"My‐GUID\"",
null);

results = [Link](storeRef, "lucene", "\\@" + escapeQName([Link](NamespaceService.ALFRESCO_URI, "category‐ista")) + ":\"Category


null, null);

results = [Link](storeRef, "lucene", "\\@" + escapeQName([Link](NamespaceService.ALFRESCO_URI, "noderef‐ista")) + ":\"" + n1 +


null, null);

results = [Link](storeRef, "lucene", "\\@" + escapeQName([Link](NamespaceService.ALFRESCO_URI, "path‐ista")) + ":\""


+ [Link](n3) + "\"", null, null);

// Queries based on type.

results = [Link](storeRef, "lucene", "TYPE:\"" + [Link]() + "\"", null, null);

results = [Link](storeRef, "lucene", "TYPE:\"" + [Link]() + "\"", null, null);


results = [Link](storeRef, "lucene", "ASPECT:\"" + [Link]() + "\"", null, null);

results = [Link](storeRef, "lucene", "ASPECT:\"" + [Link]() + "\"", null, null);

// Full text search examples

results = [Link](storeRef, "lucene", "TEXT:\"fox\"", null, null);

QName queryQName = [Link]("alf:test1", namespacePrefixResolver);


results = [Link](storeRef, queryQName, null);

// Canned queries and query parameters

queryQName = [Link]("alf:test2", namespacePrefixResolver);


results = [Link](storeRef, queryQName, null);

queryQName = [Link]("alf:test2", namespacePrefixResolver);


QueryParameter qp = new QueryParameter([Link]("alf:banana", namespacePrefixResolver), "woof");
results = [Link](storeRef, queryQName, new QueryParameter[] { qp });

queryQName = [Link]("alf:test3", namespacePrefixResolver);


qp = new QueryParameter([Link]("alf:banana", namespacePrefixResolver), "/one/five//*");
results = [Link](storeRef, queryQName, new QueryParameter[] { qp });

// TODO: should not have a null property type definition


QueryParameterDefImpl paramDef = new QueryParameterDefImpl([Link]("alf:lemur", namespacePrefixResolver), (PropertyTypeDefinition) null,
results = [Link](storeRef, "lucene", "TEXT:\"${alf:lemur}\"", null, new QueryParameterDefinition[] { paramDef });

paramDef = new QueryParameterDefImpl([Link]("alf:intvalue", namespacePrefixResolver), (PropertyTypeDefinition) null, true, "1");


qname = [Link](NamespaceService.ALFRESCO_URI, "int‐ista");
results = [Link](storeRef, "lucene", "\\@" + escapeQName(qname) + ":\"${alf:intvalue}\"", null, new QueryParameterDefinition[] { paramDef

// Other

results = [Link]([Link](), "lucene", "PARENT:\"" + [Link]() + "\"", null, null);

results = [Link]([Link](), "lucene", "+PARENT:\"" + [Link]() + "\" +QNAME:\"one\"", null, null);

More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

SiteService
Provides an extensive API for managing Sites in the Alfresco Share web client.
Information SiteService
Support Status Full Support [7]
Architecture Platform Architecture [39]
Information
Description The SiteService provides an extension API for creating, deleting and managing Share Sites. Both JavaScript and Java APIs are
available, and access to Sites is also possible via the Alfresco REST API.
Deployment ­ Deploy as AMP or Simple Module (JAR) package.
App Server
Deployment ­ Use SDK archetypes to produce AMP or Simple Module.
SDK Project
Java API Java API Documentation [93]
Java example
// Using siteService to obtain info about site
SiteInfo siteInfo = [Link](nodeRef);
String siteShortName = [Link]();
String siteGroup = [Link](siteShortName);

More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials
Alfresco xxx
Developer Blogs
Parent topic: Public Java API services [2]

TaggingService
It is possible to tag (a text label) any content, including folders, in Alfresco. This service provides an API for creating, deleting, and adding tags, and
other tag management methods.
Information TaggingService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description Tags are simple text labels that are attached to a piece of content. Each piece of content can have multiple tags. Folders also have a
TagScope object which encapsulates information about the tags used on content in that folder. The JavaScript TagScope [94] object
provides a simple illustration of what a TagScope represents. The TagScope object contains an array that lists Tags in count order.
There are methods to find out how many times a particualr tag is used.
Deployment Deploy as AMP or Simple Module (JAR) package.
­ App
Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [95]
Java
example // Get tags applied to node

List<String> tags = [Link](nodeRef);

More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

TemplateService
Provides an API for executing template engine against a template file and data model. The service provides a configured list of available template
engines. The template file can either be in the repository (passed as NodeRef string) or on the classpath. Also a template can be passed directly as a
String using the processTemplateString() methods. The data model is specified to the template engine. The FreeMarker template engine is used by
default.
Information TemplateService
Support Status Full Support [7]
Architecture Information Platform Architecture [39]
Description
Deployment ­ App Server Deploy as AMP or Simple Module (JAR) package.
Deployment ­ SDK Project Use SDK archetypes to produce AMP or Simple Module.
Java API Java API Documentation [96]
Java example
// build the email template model
final Map<String, Object> model = createEmailTemplateModel(nodeRef);

// process the template against the model


text = [Link]("freemarker", [Link](), model);

More Information
Java API ­ Access and Transaction Management documentation [42].
Template Reference Guide [97]
Tutorials None
Alfresco Developer Blogs None
Parent topic: Public Java API services [2]

TenantService
Provides APIs around Alfresco's multi­tenancy capability. The service is applicable in both Single Tenancy and Multi Tenancy arrangements.
Information TenantService
Support Status Full Support [7]
Architecture Information Platform Architecture [39]
Description
Deployment ­ App Server Deploy as AMP or Simple Module (JAR) package.
Deployment ­ SDK Project Use SDK archetypes to produce AMP or Simple Module.
Java API Java API Documentation [98]
Java example An example of using the TenantService can be found on GitHub [99].
More Information
Java API ­ Access and Transaction Management documentation [42].

Tutorials None
Alfresco Developer Blogs None
Parent topic: Public Java API services [2]

VersionService
Provides an API for managing the versions of a piece of content.
Information VersionService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description If content has the aspect versionable applied to it, then multiple versions of the content can be managed. The VersionService provides
an API to allow you to do this programmatically:

createVersion ­ this creates a new version of the referenced node which is placed at the end of the appropriate version history.
If the node has no version history then one is created and this version is considered to be the initial version.
getVersionHistory ­ this gets the version history that relates to the node referenced.
deleteVersionHistory ­ this deletes the version history for a versioned node.
getCurrentVersion ­ gets the current version for a referenced node.
revert ­ reverts the state of a referenced node to that of a previous node.
restore ­ restores a previously deleted node from a version in its version history.

Deployment ­ Deploy as AMP or Simple Module (JAR) package.


App Server
Deployment ­ Use SDK archetypes to produce AMP or Simple Module.
SDK Project
Java API Java API Documentation [100]
Java example See Tutorials and Developer Blogs for example code.
More
Information Java API ­ Access and Transaction Management documentation [42].

Tutorials Mass Nerder's Version Pruning tutorial [101] ­ includes code and a video.
Alfresco Jared Ottley's Max Version Policy blog post [102] demonstrates using the VersionService from Java.
Developer
Blogs
Parent topic: Public Java API services [2]

WorkflowService
Provides a client­facing API for interacting with Alfresco Workflows and Tasks.
Information WorkflowService
Support Full Support [7]
Status
Architecture Platform Architecture [39]
Information
Description The Activiti workflow engine is built into Alfresco ECM. You can create and manage workflows [103] directly from your Dashboard. Of
course, with the WorkflowService, you can create and manage these workflows programmatically. The default workflows OOTB are:

New Task
Assign a new task to yourself or a colleague
Review and approve (group review)
Assign a review task to a group
Review and Approve (one or more reviewers)
Assign a review task to multiple reviewers
Review and Approve (pooled review)
Assign a review task to multiple reviewers, who can take ownership of the task
Review and Approve (single reviewer)
Assign a review task to a single reviewer

It is also possible to create custom workflows.

Deployment Deploy as AMP or Simple Module (JAR) package.


­ App Server
Deployment Use SDK archetypes to produce AMP or Simple Module.
­ SDK
Project
Java API Java API Documentation [104]
Java An extensive example of using the Workflow API is provided in the code
example ./projects/repository/source/java/org/alfresco/repo/workflow/[Link].
More
Information Java API ­ Access and Transaction Management documentation [42].
Workflow platform extension point documentation [105]
Creating and managing workflows [103]
Activiti Documentation [106]

Tutorials
Advanced Workflows using Activiti by Jeff Potts [107]
Alfresco workflow video by Joram Barrez [108]

Alfresco None
Developer
Blogs
Parent topic: Public Java API services [2]

Source URL: [Link]

Links:
[1] [Link]
[2] [Link]
[3] [Link]
[4] [Link]
[5] [Link]
[6] [Link]
[7] [Link]
[8] [Link]
[9] [Link]
[10] [Link]
[11] [Link]
[12] [Link]
[13] [Link]
[14] [Link]
[15] [Link]
[16] [Link]
[17] [Link]
[18] [Link]
[19] [Link]
[20] [Link]
[21] [Link]
[22] [Link]
[23] [Link]
[24] [Link]
[25] [Link]
[26] [Link]
[27] [Link]
[28] [Link]
[29] [Link]
[30] [Link]
[31] [Link]
[32] [Link]
[33] [Link]
[34] [Link]
[35] [Link]
[36] [Link]
[37] [Link]
[38] [Link]
[39] [Link]
[40] [Link]
[41] [Link]
[42] [Link]
[43] [Link]
[44] [Link]
[45] [Link]
[46] [Link]
[47] [Link]
[48] [Link]
[49] [Link]
[50] [Link]
[51] [Link]
[52] [Link]
[53] [Link]
[54] [Link]
[55] [Link]
[56] [Link]
[57] [Link]
[58] [Link]
[59] [Link]
[60] [Link]
[61] [Link]
[62] [Link]
[63] [Link]
[64] [Link]
[65] [Link]
[66] [Link]
[67] [Link]
[68] [Link]
[69] [Link]
[70] [Link]
[71] [Link]
[72] [Link]
[73] [Link]
[74] [Link]
[75] [Link]
[76] [Link]
[77] [Link]
[78] [Link]
[79] [Link]
[80] [Link]
[81] [Link]
[82] [Link]
[83] [Link]
[84] [Link]
[85] [Link]
[86] [Link]
[87] [Link]
[88] [Link]
[89] [Link]
[90] [Link]
[91] [Link]
[92] [Link]
[93] [Link]
[94] [Link]
[95] [Link]
[96] [Link]
[97] [Link]
[98] [Link]
[99] [Link]
[100] [Link]
[101] [Link]
[102] [Link]
[103] [Link]
[104] [Link]
[105] [Link]
[106] [Link]
[107] [Link]
[108] [Link]

You might also like