Java API Cookbook

cancel
Showing results for 
Search instead for 
Did you mean: 

Java API Cookbook

Intermediate
0 0 1,849

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



Java_APICookbookDeveloper GuideExamples
right
This page is the central page for examples for the Java API.   Feel free to add your examples to this.


Working with NodeRef (Files, Directories)


The NodeRef object is a unique reference to a Node, the object that represents locations and resources within an Alfresco repository.

The page will explain how :


  • Create a file or directory
  • Get the name of a noderef
  • Read properties
  • Transforming a PPT to PDF
  • Set Rule on a node
  • ...

NodeRef CookBook


Write logs


The class Logger (log4j) allows to write some logs (information) in the console and/or the alfresco log file.


Samples


  • Write a debug message (only if the logger is in debug level)

import org.apache.log4j.Logger;

public class myClass{
private static Logger logger = Logger.getLogger(myClass.class);
public void myMethod(){
  ...
  logger.debug('Message...');
  ...
}
}

  • Print stacktrace if error. You can add comment replacing the ''.

import org.apache.log4j.Logger;

public class myClass{
private static Logger logger = Logger.getLogger(myClass.class);
public void myMethod(){
  try{
   ...
  }catch (Exception e){
   logger.error('',e);
  }
  ...
}
}

Links about Logger


Links


Write transactions


How to


Development Environments


Use Eclipse, NetBeans, ...


Alfresco Sources