You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2011/07/23 18:09:43 UTC
svn commit: r1150139 [3/3] - in /incubator/empire-db/branches/EMPIREDB-99:
empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/
empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/sam...
Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java?rev=1150139&r1=1150138&r2=1150139&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java Sat Jul 23 16:09:27 2011
@@ -24,8 +24,6 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.Iterator;
-import org.apache.empire.commons.EmpireException;
-import org.apache.empire.commons.Errors;
import org.apache.empire.data.DataType;
import org.apache.empire.db.DBCmdType;
import org.apache.empire.db.DBColumn;
@@ -34,7 +32,6 @@ import org.apache.empire.db.DBCommandExp
import org.apache.empire.db.DBDatabase;
import org.apache.empire.db.DBDatabaseDriver;
import org.apache.empire.db.DBDriverFeature;
-import org.apache.empire.db.DBErrors;
import org.apache.empire.db.DBExpr;
import org.apache.empire.db.DBIndex;
import org.apache.empire.db.DBObject;
@@ -44,6 +41,10 @@ import org.apache.empire.db.DBSQLScript;
import org.apache.empire.db.DBTable;
import org.apache.empire.db.DBTableColumn;
import org.apache.empire.db.DBView;
+import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.NotImplementedException;
+import org.apache.empire.exceptions.NotSupportedException;
/**
@@ -321,7 +322,7 @@ public class DBDatabaseDriverOracle exte
{
// The Object's database must be attached to this driver
if (dbo==null || dbo.getDatabase().getDriver()!=this)
- throw new EmpireException(Errors.InvalidArg, dbo, "dbo");
+ throw new InvalidArgumentException("dbo", dbo);
// Check Type of object
if (dbo instanceof DBDatabase)
{ // Database
@@ -334,7 +335,7 @@ public class DBDatabaseDriverOracle exte
dropObject(((DBDatabase) dbo).getSchema(), "USER", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBTable)
@@ -348,7 +349,7 @@ public class DBDatabaseDriverOracle exte
dropObject(((DBTable) dbo).getName(), "TABLE", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBView)
@@ -362,7 +363,7 @@ public class DBDatabaseDriverOracle exte
dropObject(((DBView) dbo).getName(), "VIEW", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBRelation)
@@ -376,7 +377,7 @@ public class DBDatabaseDriverOracle exte
dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBTableColumn)
@@ -385,8 +386,8 @@ public class DBDatabaseDriverOracle exte
return;
}
else
- { // an invalid argument has been supplied
- throw new EmpireException(Errors.InvalidArg, dbo, "dbo");
+ { // dll generation not supported for this type
+ throw new NotSupportedException(this, "getDDLScript() for "+dbo.getClass().getName());
}
}
@@ -406,8 +407,7 @@ public class DBDatabaseDriverOracle exte
return (rs.next() ? rs.getTimestamp(1) : null);
} catch (SQLException e) {
// throw exception
- String msg = extractErrorMessage(e);
- throw new EmpireException(DBErrors.SQLException, new Object[] { msg }, e);
+ throw new InternalSQLException(this, e);
} finally
{ // Cleanup
try
@@ -419,8 +419,7 @@ public class DBDatabaseDriverOracle exte
stmt.close();
} catch (SQLException e) {
// throw exception
- String msg = extractErrorMessage(e);
- throw new EmpireException(DBErrors.SQLException, new Object[] { msg }, e);
+ throw new InternalSQLException(this, e);
}
}
}
@@ -465,14 +464,10 @@ public class DBDatabaseDriverOracle exte
{
try {
createView(views.next(), script);
- } catch(EmpireException e) {
- // Error
- if (e.getErrorType()!=Errors.NotImplemented)
- { // View command not implemented
- log.warn("Error creating the view {0}. This view will be ignored.");
- continue;
- }
- else throw e;
+ } catch(NotImplementedException e) {
+ // View command not implemented
+ log.warn("Error creating the view {0}. This view will be ignored.");
+ continue;
}
}
}
@@ -766,7 +761,7 @@ public class DBDatabaseDriverOracle exte
if (cmd==null)
{ // Check whether Error information is available
log.error("No command has been supplied for view " + v.getName());
- throw new EmpireException(Errors.NotImplemented, v.getName() + ".createCommand");
+ throw new NotImplementedException(this, v.getName() + ".createCommand");
}
// Make sure there is no OrderBy
cmd.clearOrderBy();
@@ -827,7 +822,7 @@ public class DBDatabaseDriverOracle exte
protected void dropObject(String name, String objType, DBSQLScript script)
{
if (name == null || name.length() == 0)
- throw new EmpireException(Errors.InvalidArg, name, "name");
+ throw new InvalidArgumentException("name", name);
// Create Drop Statement
StringBuilder sql = new StringBuilder();
sql.append("DROP ");
@@ -848,7 +843,7 @@ public class DBDatabaseDriverOracle exte
{
// Check Params
if (owner==null || owner.length()==0)
- throw new EmpireException(Errors.InvalidArg, owner, "owner");
+ throw new InvalidArgumentException("owner", owner);
// Database definition
OracleSYSDatabase sysDB = new OracleSYSDatabase(this);
// Check Columns
Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java?rev=1150139&r1=1150138&r2=1150139&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java Sat Jul 23 16:09:27 2011
@@ -23,8 +23,6 @@ import java.sql.SQLException;
import java.util.GregorianCalendar;
import java.util.Iterator;
-import org.apache.empire.commons.EmpireException;
-import org.apache.empire.commons.Errors;
import org.apache.empire.commons.StringUtils;
import org.apache.empire.data.DataType;
import org.apache.empire.db.DBCmdType;
@@ -34,7 +32,6 @@ import org.apache.empire.db.DBCommandExp
import org.apache.empire.db.DBDatabase;
import org.apache.empire.db.DBDatabaseDriver;
import org.apache.empire.db.DBDriverFeature;
-import org.apache.empire.db.DBErrors;
import org.apache.empire.db.DBExpr;
import org.apache.empire.db.DBIndex;
import org.apache.empire.db.DBObject;
@@ -43,6 +40,10 @@ import org.apache.empire.db.DBSQLScript;
import org.apache.empire.db.DBTable;
import org.apache.empire.db.DBTableColumn;
import org.apache.empire.db.DBView;
+import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.NotImplementedException;
+import org.apache.empire.exceptions.NotSupportedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -282,8 +283,7 @@ public class DBDatabaseDriverPostgreSQL
executeSQL(CREATE_REVERSE_FUNCTION, null, conn, null);
} catch(SQLException e) {
log.error("Unable to create reverse function!", e);
- String msg = extractErrorMessage(e);
- throw new EmpireException(DBErrors.SQLException, new Object[] { msg }, e);
+ throw new InternalSQLException(this, e);
}
}
@@ -444,7 +444,7 @@ public class DBDatabaseDriverPostgreSQL
{
// The Object's database must be attached to this driver
if (dbo==null || dbo.getDatabase().getDriver()!=this)
- throw new EmpireException(Errors.InvalidArg, dbo, "dbo");
+ throw new InvalidArgumentException("dbo", dbo);
// Check Type of object
if (dbo instanceof DBDatabase)
{ // Database
@@ -457,7 +457,7 @@ public class DBDatabaseDriverPostgreSQL
dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript."+dbo.getClass().getName()+"."+String.valueOf(type));
+ throw new NotImplementedException(this, "getDDLScript."+dbo.getClass().getName()+"."+String.valueOf(type));
}
}
else if (dbo instanceof DBTable)
@@ -471,7 +471,7 @@ public class DBDatabaseDriverPostgreSQL
dropObject(((DBTable) dbo).getName(), "TABLE", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBView)
@@ -485,7 +485,7 @@ public class DBDatabaseDriverPostgreSQL
dropObject(((DBView) dbo).getName(), "VIEW", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBRelation)
@@ -499,7 +499,7 @@ public class DBDatabaseDriverPostgreSQL
dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBTableColumn)
@@ -508,8 +508,8 @@ public class DBDatabaseDriverPostgreSQL
return;
}
else
- { // an invalid argument has been supplied
- throw new EmpireException(Errors.InvalidArg, dbo, "dbo");
+ { // dll generation not supported for this type
+ throw new NotSupportedException(this, "getDDLScript() for "+dbo.getClass().getName());
}
}
@@ -893,7 +893,7 @@ public class DBDatabaseDriverPostgreSQL
if (cmd==null)
{ // Check whether Error information is available
log.error("No command has been supplied for view " + v.getName());
- throw new EmpireException(Errors.NotImplemented, v.getName() + ".createCommand");
+ throw new NotImplementedException(this, v.getName() + ".createCommand");
}
// Make sure there is no OrderBy
cmd.clearOrderBy();
@@ -927,7 +927,7 @@ public class DBDatabaseDriverPostgreSQL
protected void dropObject(String name, String objType, DBSQLScript script)
{
if (name == null || name.length() == 0)
- throw new EmpireException(Errors.InvalidArg, name, "name");
+ throw new InvalidArgumentException("name", name);
// Create Drop Statement
StringBuilder sql = new StringBuilder();
sql.append("DROP ");
Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java?rev=1150139&r1=1150138&r2=1150139&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java Sat Jul 23 16:09:27 2011
@@ -23,8 +23,6 @@ import java.sql.SQLException;
import java.util.GregorianCalendar;
import java.util.Iterator;
-import org.apache.empire.commons.EmpireException;
-import org.apache.empire.commons.Errors;
import org.apache.empire.commons.ObjectUtils;
import org.apache.empire.commons.StringUtils;
import org.apache.empire.data.DataType;
@@ -35,7 +33,6 @@ import org.apache.empire.db.DBCommandExp
import org.apache.empire.db.DBDatabase;
import org.apache.empire.db.DBDatabaseDriver;
import org.apache.empire.db.DBDriverFeature;
-import org.apache.empire.db.DBErrors;
import org.apache.empire.db.DBExpr;
import org.apache.empire.db.DBIndex;
import org.apache.empire.db.DBObject;
@@ -44,6 +41,11 @@ import org.apache.empire.db.DBSQLScript;
import org.apache.empire.db.DBTable;
import org.apache.empire.db.DBTableColumn;
import org.apache.empire.db.DBView;
+import org.apache.empire.db.exceptions.InternalSQLException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.NotImplementedException;
+import org.apache.empire.exceptions.NotSupportedException;
+import org.apache.empire.exceptions.InvalidPropertyException;
/**
@@ -199,8 +201,7 @@ public class DBDatabaseDriverMSSQL exten
} catch (SQLException e) {
// throw exception
- String msg = extractErrorMessage(e);
- throw new EmpireException(DBErrors.SQLException, new Object[] { msg }, e);
+ throw new InternalSQLException(this, e);
}
}
@@ -383,7 +384,7 @@ public class DBDatabaseDriverMSSQL exten
{
// The Object's database must be attached to this driver
if (dbo==null || dbo.getDatabase().getDriver()!=this)
- throw new EmpireException(Errors.InvalidArg, dbo, "dbo");
+ throw new InvalidArgumentException("dbo", dbo);
// Check Type of object
if (dbo instanceof DBDatabase)
{ // Database
@@ -396,7 +397,7 @@ public class DBDatabaseDriverMSSQL exten
dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBTable)
@@ -410,7 +411,7 @@ public class DBDatabaseDriverMSSQL exten
dropObject(((DBTable) dbo).getName(), "TABLE", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBView)
@@ -424,7 +425,7 @@ public class DBDatabaseDriverMSSQL exten
dropObject(((DBView) dbo).getName(), "VIEW", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBRelation)
@@ -438,7 +439,7 @@ public class DBDatabaseDriverMSSQL exten
dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
return;
default:
- throw new EmpireException(Errors.NotImplemented, "getDDLScript." + dbo.getClass().getName() + "." + type);
+ throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName() + "." + type);
}
}
else if (dbo instanceof DBTableColumn)
@@ -447,8 +448,8 @@ public class DBDatabaseDriverMSSQL exten
return;
}
else
- { // an invalid argument has been supplied
- throw new EmpireException(Errors.InvalidArg, dbo, "dbo");
+ { // dll generation not supported for this type
+ throw new NotSupportedException(this, "getDDLScript() for "+dbo.getClass().getName());
}
}
@@ -474,7 +475,7 @@ public class DBDatabaseDriverMSSQL exten
if (createSchema)
{ // check database Name
if (StringUtils.isEmpty(databaseName))
- throw new EmpireException(Errors.InvalidProperty, "databaseName");
+ throw new InvalidPropertyException("databaseName", databaseName);
// Create Database
script.addStmt("USE master");
script.addStmt("IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = '" + databaseName + "') CREATE DATABASE " + databaseName);
@@ -771,7 +772,7 @@ public class DBDatabaseDriverMSSQL exten
if (cmd==null)
{ // Check whether Error information is available
log.error("No command has been supplied for view " + v.getName());
- throw new EmpireException(Errors.NotImplemented, v.getName() + ".createCommand");
+ throw new NotImplementedException(this, v.getName() + ".createCommand");
}
// Make sure there is no OrderBy
cmd.clearOrderBy();
@@ -805,7 +806,7 @@ public class DBDatabaseDriverMSSQL exten
protected void dropObject(String name, String objType, DBSQLScript script)
{
if (name == null || name.length() == 0)
- throw new EmpireException(Errors.InvalidArg, name, "name");
+ throw new InvalidArgumentException("name", name);
// Create Drop Statement
StringBuilder sql = new StringBuilder();
sql.append("DROP ");
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/
------------------------------------------------------------------------------
eol-style = native
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanInstantiationException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanInstantiationException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanInstantiationException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanInstantiationException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeanInstantiationException extends EmpireException
+{
+ // Logger
+ private static final Logger log = LoggerFactory.getLogger(BeanInstantiationException.class);
+
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.BeanInstantiation", "Unable create an instance of type {0}.");
+
+ public BeanInstantiationException(Class<?> className, Throwable cause)
+ {
+ super(errorType, new Object[] { className }, cause);
+ }
+
+ /**
+ * log the error
+ */
+ @Override
+ protected void log()
+ {
+ if ( log.isErrorEnabled() )
+ log.error(getMessage());
+ else
+ super.log();
+ }
+
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanInstantiationException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanInstantiationException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertyGetException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertyGetException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertyGetException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertyGetException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeanPropertyGetException extends EmpireException
+{
+ // Logger
+ private static final Logger log = LoggerFactory.getLogger(BeanPropertyGetException.class);
+
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.PropertyGet", "Unable to get the property {0} from type {1}.");
+
+ public BeanPropertyGetException(Object bean, String property, Throwable cause)
+ {
+ super(errorType, new Object[] { property, (bean!=null ? bean.getClass().getName() : "{unknown}") }, cause);
+ }
+
+ /**
+ * log the error
+ */
+ @Override
+ protected void log()
+ {
+ if ( log.isErrorEnabled() )
+ log.error(getMessage());
+ else
+ super.log();
+ }
+
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertyGetException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertyGetException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertySetException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertySetException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertySetException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertySetException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BeanPropertySetException extends EmpireException
+{
+ // Logger
+ private static final Logger log = LoggerFactory.getLogger(BeanPropertySetException.class);
+
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.PropertySet", "The property {0} cannot be set on type {1}.");
+
+ public BeanPropertySetException(Object bean, String property, Throwable cause)
+ {
+ super(errorType, new Object[] { property, (bean!=null ? bean.getClass().getName() : "{unknown}") }, cause);
+ }
+
+ /**
+ * log the error
+ */
+ @Override
+ protected void log()
+ {
+ if ( log.isErrorEnabled() )
+ log.error(getMessage());
+ else
+ super.log();
+ }
+
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertySetException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/BeanPropertySetException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java (from r1149172, incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/commons/EmpireException.java)
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java?p2=incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java&p1=incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/commons/EmpireException.java&r1=1149172&r2=1150139&rev=1150139&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/commons/EmpireException.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java Sat Jul 23 16:09:27 2011
@@ -16,10 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.empire.commons;
+package org.apache.empire.exceptions;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
import java.text.MessageFormat;
+import org.apache.empire.commons.ErrorType;
+import org.apache.empire.commons.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,12 +45,6 @@ public class EmpireException extends Run
private static String formatErrorMessage(final ErrorType errType, final Object[] params)
{
- // check error code
- if (errType == Errors.None)
- { // Must supply a valid error code
- log.error("error function called with invalid error Code.");
- return formatErrorMessage(Errors.Internal, new Object[] { "Invalid Error Code" });
- }
// Check parameter count
int paramCount = (params!=null) ? params.length : 0;
if (paramCount!= errType.getNumParams())
@@ -59,49 +57,13 @@ public class EmpireException extends Run
return msg;
}
- private static Object[] paramsFromThrowable(final Throwable exptn)
- {
- // Exception
- String type = exptn.getClass().getName();
- if (type.startsWith("java.lang."))
- type = type.substring("java.lang.".length());
- // The message
- String msg = exptn.getMessage();
- // Prepare stack trace
- StackTraceElement[] stack = exptn.getStackTrace();
- String pos = (stack!=null) ? stack[0].toString() : "{unknown}";
- // Create Error
- return new Object[] { type, msg, pos };
- }
-
- private static Object[] normalizeParams(final Object[] params)
- {
- if (params!=null && params.length>0)
- { // convert complex params form object[] to string[]
- for (int i=0; i<params.length; i++)
- { // convert to String
- Object o = params[i];
- if (o==null || (o instanceof String))
- continue;
- if (o.getClass().isPrimitive())
- continue;
- // Convert to String
- if (o instanceof RuntimeException)
- params[i] = ((RuntimeException)o).getMessage();
- else
- params[i] = String.valueOf(o.toString());
- }
- }
- return params;
- }
-
/**
* Constructor for derived classes
* @param errType
* @param params
* @param cause
*/
- public EmpireException(final ErrorType errType, final Object[] params, final Throwable cause)
+ protected EmpireException(final ErrorType errType, final Object[] params, final Throwable cause)
{
super(formatErrorMessage(errType, params), cause);
// save type and params for custom message formatting
@@ -110,54 +72,21 @@ public class EmpireException extends Run
// done
log();
}
-
/**
- * Constructor
+ * Constructor for derived classes
* @param errType
* @param params
- */
- public EmpireException(final ErrorType errType, final Object... params)
- {
- super(formatErrorMessage(errType, params));
- // save type and params for custom message formatting
- this.errorType = errType;
- this.errorParams = normalizeParams(params);
- // done
- log();
- }
-
- /**
- * Constructor
* @param cause
*/
- public EmpireException(final Throwable cause)
- {
- super(formatErrorMessage(Errors.Exception, paramsFromThrowable(cause)), cause);
- // save type and params for custom message formatting
- this.errorType = Errors.Exception;
- this.errorParams = paramsFromThrowable(cause);
- // done
- log();
- }
-
- /**
- * Constructor
- * @param other
- */
- public EmpireException(final EmpireException other)
+ protected EmpireException(final ErrorType errType, final Object[] params)
{
- super(other.getMessage(), other);
- // save type and params for custom message formatting
- this.errorType = other.getErrorType();
- this.errorParams = other.getErrorParams();
- // done
- log();
+ this(errType, params, null);
}
/**
* log the error (info must be enabled)
*/
- private void log()
+ protected void log()
{
if (log.isInfoEnabled())
log.info("An Error occured. Message is: {}", this.getMessage());
@@ -182,4 +111,29 @@ public class EmpireException extends Run
{
return errorParams;
}
+
+ /**
+ * when serializing, convert all params to strings
+ * @param out
+ * @throws IOException
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException
+ {
+ // normalize Params
+ if (errorParams!=null)
+ { // convert complex params from object[] to string[]
+ for (int i=0; i<errorParams.length; i++)
+ { // convert to String
+ Object o = errorParams[i];
+ if (o==null || (o instanceof String))
+ continue;
+ if (o.getClass().isPrimitive())
+ continue;
+ // Convert to String
+ errorParams[i] = StringUtils.toString(o);
+ }
+ }
+ // Serialize
+ out.defaultWriteObject();
+ }
}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireFileException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireFileException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireFileException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireFileException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+/**
+ * This exception type is used for all empire errors.<br>
+ * Exceptions will only be thrown if exceptions are enabled in the ErrorObject.
+ * @see ErrorObject#setExceptionsEnabled(boolean)
+ */
+public abstract class EmpireFileException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ protected EmpireFileException(final ErrorType errType, final Object[] params, final Throwable cause)
+ {
+ super(errType, params, cause);
+ }
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireFileException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/EmpireFileException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileParseException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileParseException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileParseException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileParseException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+public class FileParseException extends EmpireFileException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.FileParseException", "The file {0} has an invalid format.");
+
+ public FileParseException(String fileName, Exception cause)
+ {
+ super(errorType, new Object[] { fileName }, cause);
+ }
+
+ public FileParseException(String fileName)
+ {
+ this(fileName, null);
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileParseException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileParseException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileReadException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileReadException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileReadException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileReadException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import java.io.IOException;
+
+import org.apache.empire.commons.ErrorType;
+
+public class FileReadException extends EmpireFileException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.FileReadException", "Error reading the file {0}. Message is: {1}.");
+
+ public FileReadException(String fileName, IOException cause)
+ {
+ super(errorType, new Object[] { fileName, cause.toString() }, cause);
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileReadException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileReadException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileWriteException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileWriteException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileWriteException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileWriteException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import java.io.IOException;
+
+import org.apache.empire.commons.ErrorType;
+
+public class FileWriteException extends EmpireFileException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.FileWriteException", "Error writing the file {0}. Message is: {1}.");
+
+ public FileWriteException(String fileName, IOException cause)
+ {
+ super(errorType, new Object[] { fileName, cause.toString() }, cause);
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileWriteException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/FileWriteException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InternalException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InternalException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InternalException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InternalException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class InternalException extends EmpireException
+{
+ // Logger
+ private static final Logger log = LoggerFactory.getLogger(InternalException.class);
+
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.exception", "An Exception of type {0} occurred.\n-->Message is: {1}\n-->at Position: {2}");
+
+ private static Object[] paramsFromThrowable(final Throwable exptn)
+ {
+ // Exception
+ String type = exptn.getClass().getName();
+ if (type.startsWith("java.lang."))
+ type = type.substring("java.lang.".length());
+ // The message
+ String msg = exptn.getMessage();
+ // Prepare stack trace
+ StackTraceElement[] stack = exptn.getStackTrace();
+ String pos = (stack!=null) ? stack[0].toString() : "{unknown}";
+ // Create Error
+ return new Object[] { type, msg, pos };
+ }
+
+ public InternalException(Throwable cause)
+ {
+ super(errorType, paramsFromThrowable(cause));
+ }
+
+ public InternalException(EmpireException other)
+ {
+ super(other.getErrorType(), other.getErrorParams());
+ // should not happen
+ log.warn("InternalException used to wrap an EmpireException! Type and params will be copied.");
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InternalException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InternalException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidArgumentException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidArgumentException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidArgumentException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidArgumentException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+import org.apache.empire.commons.StringUtils;
+
+public class InvalidArgumentException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.invalidarg", "Invalid Argument {0} for parameter {1}.");
+
+ public InvalidArgumentException(String param, Object value)
+ {
+ super(errorType, new Object[] { value, param } );
+ }
+
+ public InvalidArgumentException(String param, Object[] value)
+ {
+ super(errorType, new Object[] { StringUtils.valueOf(param), param } );
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidArgumentException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidArgumentException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidPropertyException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidPropertyException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidPropertyException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidPropertyException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+import org.apache.empire.commons.StringUtils;
+
+public class InvalidPropertyException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.PropertyInvalid", "The property {0} is not valid. Current value is {1}.");
+
+ public InvalidPropertyException(String property, Object value)
+ {
+ super(errorType, new Object[] { property, StringUtils.valueOf(value) });
+ }
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidPropertyException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/InvalidPropertyException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemExistsException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemExistsException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemExistsException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemExistsException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+public class ItemExistsException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.itemexists", "The element {0} already exists.");
+
+ public ItemExistsException(Object item)
+ {
+ super(errorType, new Object[] { (item!=null) ? item : "{unknown}" } );
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemExistsException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemExistsException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemNotFoundException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemNotFoundException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemNotFoundException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+public class ItemNotFoundException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.itemnotfound", "The element {0} was not found.");
+
+ public ItemNotFoundException(Object item)
+ {
+ super(errorType, new Object[] { (item!=null) ? item : "{unknown}" } );
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemNotFoundException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ItemNotFoundException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/MiscellaneousErrorException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/MiscellaneousErrorException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/MiscellaneousErrorException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/MiscellaneousErrorException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+public class MiscellaneousErrorException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.internal", "Internal Error: {0}");
+
+ public MiscellaneousErrorException(String errorMessage)
+ {
+ super(errorType, new Object[] { errorMessage });
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/MiscellaneousErrorException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/MiscellaneousErrorException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotImplementedException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotImplementedException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotImplementedException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotImplementedException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+public class NotImplementedException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.notimplemented", "The function {0} is not implemented for type {1}.");
+
+ public NotImplementedException(Object object, String functionName)
+ {
+ super(errorType, new Object[] { functionName, (object!=null ? object.getClass().getName() : "{unknown}") });
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotImplementedException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotImplementedException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotSupportedException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotSupportedException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotSupportedException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotSupportedException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+public class NotSupportedException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.notsupported", "The function {0} is not supported for type {1}.");
+
+ public NotSupportedException(Object object, String functionName)
+ {
+ super(errorType, new Object[] { functionName, (object!=null ? object.getClass().getName() : "{unknown}") });
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotSupportedException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/NotSupportedException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+public class ObjectNotValidException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.objectnotvalid", "The object of type {0} has not been initialized.");
+
+ public ObjectNotValidException(Object obj)
+ {
+ super(errorType, new Object[] { (obj!=null) ? obj.getClass().getName() : "{unknown}" } );
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/ObjectNotValidException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/PropertyReadOnlyException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/PropertyReadOnlyException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/PropertyReadOnlyException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/PropertyReadOnlyException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+public class PropertyReadOnlyException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.PropertyReadOnly", "The property {0} is read only.");
+
+ public PropertyReadOnlyException(String property)
+ {
+ super(errorType, new Object[] { property });
+ }
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/PropertyReadOnlyException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/PropertyReadOnlyException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/UnexpectedReturnValueException.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/UnexpectedReturnValueException.java?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/UnexpectedReturnValueException.java (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/UnexpectedReturnValueException.java Sat Jul 23 16:09:27 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.exceptions;
+
+import org.apache.empire.commons.ErrorType;
+
+public class UnexpectedReturnValueException extends EmpireException
+{
+ /**
+ * Comment for <code>serialVersionUID</code>
+ */
+ private static final long serialVersionUID = 1L;
+
+ public static final ErrorType errorType = new ErrorType("error.UnexpectedReturnValueException", "Unexpected return value {0} for function {1}.");
+
+ public UnexpectedReturnValueException(Object value, String function)
+ {
+ super(errorType, new Object[] { value, function } );
+ }
+
+}
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/UnexpectedReturnValueException.java
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/UnexpectedReturnValueException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/package.html
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/package.html?rev=1150139&view=auto
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/package.html (added)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/package.html Sat Jul 23 16:09:27 2011
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<html>
+<head>
+</head>
+<body>
+
+This package contains classes for exception handling of general errors.
+
+</body></html>
\ No newline at end of file
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/package.html
------------------------------------------------------------------------------
eol-style = native
Propchange: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/exceptions/package.html
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java?rev=1150139&r1=1150138&r2=1150139&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/xml/XMLConfiguration.java Sat Jul 23 16:09:27 2011
@@ -30,10 +30,14 @@ import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.beanutils.BeanUtils;
-import org.apache.empire.commons.EmpireException;
-import org.apache.empire.commons.Errors;
import org.apache.empire.commons.ObjectUtils;
import org.apache.empire.commons.StringUtils;
+import org.apache.empire.exceptions.FileParseException;
+import org.apache.empire.exceptions.FileReadException;
+import org.apache.empire.exceptions.InternalException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.ItemNotFoundException;
+import org.apache.empire.exceptions.ObjectNotValidException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
@@ -110,19 +114,19 @@ public class XMLConfiguration
} catch (FileNotFoundException e)
{
log.error("Configuration file {} not found!", fileName, e);
- throw new EmpireException(Errors.FileNotFound, fileName);
+ throw new FileReadException(fileName, e);
} catch (IOException e)
{
log.error("Error reading configuration file {}", fileName, e);
- throw new EmpireException(Errors.FileReadError, fileName);
+ throw new FileReadException(fileName, e);
} catch (SAXException e)
{
log.error("Invalid XML in configuration file {}", fileName, e);
- throw new EmpireException(e);
+ throw new FileParseException(fileName, e);
} catch (ParserConfigurationException e)
{
log.error("ParserConfigurationException: {}", e.getMessage(), e);
- throw new EmpireException(e);
+ throw new InternalException(e);
} finally
{
close(reader);
@@ -140,22 +144,22 @@ public class XMLConfiguration
{
// Check state
if (configRootNode == null)
- throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
+ throw new ObjectNotValidException(this);
// Check arguments
if (bean == null)
- throw new EmpireException(Errors.InvalidArg, null, "bean");
+ throw new InvalidArgumentException("bean", bean);
Element propertiesNode = configRootNode;
for(String nodeName : propertiesNodeNames)
{
if (StringUtils.isEmpty(nodeName))
- throw new EmpireException(Errors.InvalidArg, null, "propertiesNodeNames");
+ throw new InvalidArgumentException("propertiesNodeNames", null);
// Get configuration node
propertiesNode = XMLUtil.findFirstChild(propertiesNode, nodeName);
if (propertiesNode == null)
{ // Configuration
log.error("Property-Node {} has not been found.", nodeName);
- throw new EmpireException(Errors.ItemNotFound, nodeName);
+ throw new ItemNotFoundException(nodeName);
}
}
// read the properties
@@ -172,9 +176,9 @@ public class XMLConfiguration
{
// Check arguments
if (propertiesNode == null)
- throw new EmpireException(Errors.InvalidArg, null, "propertiesNode");
+ throw new InvalidArgumentException("propertiesNode", propertiesNode);
if (bean == null)
- throw new EmpireException(Errors.InvalidArg, null, "bean");
+ throw new InvalidArgumentException("bean", bean);
// apply configuration
log.info("reading bean properties from node: {}", propertiesNode.getNodeName());
NodeList nodeList = propertiesNode.getChildNodes();
Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/commons/ErrorsTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/commons/ErrorsTest.java?rev=1150139&r1=1150138&r2=1150139&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/commons/ErrorsTest.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/test/java/org/apache/empire/commons/ErrorsTest.java Sat Jul 23 16:09:27 2011
@@ -20,13 +20,53 @@ package org.apache.empire.commons;
import static org.junit.Assert.assertEquals;
-import org.apache.empire.db.DBErrors;
+import org.apache.empire.exceptions.EmpireException;
+import org.apache.empire.exceptions.InternalException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.junit.Before;
import org.junit.Test;
public class ErrorsTest
{
private static final String ROOT_EXCEPTION_MSG = "This is the root exception message!";
+ private Throwable cause;
+
+ @Before
+ public void setupException()
+ {
+ cause = new RuntimeException(ROOT_EXCEPTION_MSG);
+ }
+
+ @Test
+ public void testInvalidArgumentException()
+ {
+ try {
+ // Test InvalidArg
+ throw new InvalidArgumentException("testparam", "testvalue");
+
+ } catch (EmpireException e) {
+
+ assertEquals(e.getMessage(), "Invalid Argument testvalue for parameter testparam.");
+ }
+ }
+
+ @Test
+ public void testInternalException()
+ {
+ try {
+ // Test InvalidArg
+ throw new InternalException(cause);
+
+ } catch (EmpireException e) {
+
+ assertEquals(e.getErrorParams()[0], "RuntimeException");
+ assertEquals(e.getErrorParams()[1], ROOT_EXCEPTION_MSG);
+ }
+ }
+
+ /*
+
private static final String NATIVE_ERROR_MSG = "This is the native error message!";
@Test
@@ -63,7 +103,7 @@ public class ErrorsTest
assertEquals(e.getErrorParams()[0], NATIVE_ERROR_MSG);
}
-
}
+ */
}