X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmir%2Fmodule%2FAbstractModule.java;h=d65dd2b331c920ad328463e71549c709a002dda0;hb=42680c1f9fe3250bcbd0f9ed5d9dee6188333b15;hp=eb4f9dab725d065ee96556c1c691019e795eb2b1;hpb=95c2e3a74f492f6f61d4dbe8bb47996f43af0627;p=mir.git diff --git a/source/mir/module/AbstractModule.java b/source/mir/module/AbstractModule.java index eb4f9dab..d65dd2b3 100755 --- a/source/mir/module/AbstractModule.java +++ b/source/mir/module/AbstractModule.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001, 2002 The Mir-coders group + * Copyright (C) 2001-2006 The Mir-coders group * * This file is part of Mir. * @@ -19,19 +19,19 @@ * * In addition, as a special exception, The Mir-coders gives permission to link * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), * and distribute linked combinations including the two. You must obey the * GNU General Public License in all respects for all of the code used other than * the above mentioned libraries. If you modify this file, you may extend this * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ + package mir.module; import mir.entity.Entity; import mir.entity.EntityList; import mir.storage.Database; +import mir.storage.DatabaseExc; import java.util.Map; @@ -61,19 +61,23 @@ public class AbstractModule { return database; } - public Entity getById (String id) throws ModuleExc, ModuleFailure { - try { - if (database == null) - throw new ModuleExc("AbstractModule.getById: No Database set!"); - Entity entity = database.selectById(id); + public Entity getById (String anId) throws ModuleFailure, EntityNotFoundExc { + if (database == null) { + throw new ModuleFailure("AbstractModule.getById: No Database set!"); + } - if (entity == null) - throw new ModuleExc("AbstractModule.getById: No object for id = " + id); - return entity; - } - catch (Throwable e) { - throw new ModuleFailure(e); - } + try { + Entity result = database.selectById(anId); + + if (result == null) { + throw new EntityNotFoundExc("AbstractModule.getById: No object for id = " + anId); + } + + return result; + } + catch (DatabaseExc e) { + throw new ModuleFailure("Database exception while retrieving entity with id " + anId); + } } public EntityList getByWhereClause (String whereClause, int offset) throws ModuleExc, ModuleFailure {