Returns the root folder for the PhotoFolder hierarchy, i.e. the folder with id 1.
*/
public static PhotoFolder getRoot() {
PhotoFolder rootFolder = PhotoFolder.rootFolder;
if ( rootFolder == null ) {
ODMGXAWrapper txw = new ODMGXAWrapper();
Implementation odmg = ODMG.getODMGImplementation();
List folders = null;
boolean mustCommit = false;
try {
OQLQuery query = odmg.newOQLQuery();
query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = 1" );
folders = (List) query.execute();
} catch ( Exception e ) {
Throwable rootCause = e;
while ( rootCause.getCause() != null ) {
rootCause = rootCause.getCause();
}
log.error( rootCause.getMessage() );
txw.abort();
return null;
}
rootFolder = (PhotoFolder) folders.get( 0 );
PhotoFolder.rootFolder = rootFolder;
// If a new transaction was created, commit it
txw.commit();
}
return rootFolder;
}