Author: chathura
Date: Sun Jan 13 21:30:00 2008
New Revision: 12182
Log:
Improving the exception handling.
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
Sun Jan 13 21:30:00 2008
@@ -162,7 +162,7 @@
String msg = Messages.getMessage("jdbc.reg.init.fail");
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
@@ -216,7 +216,7 @@
} catch (SQLException e) {
String msg = "Failed to check the exsitence of a resource at path
" + path;
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -261,7 +261,7 @@
String msg = e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -297,7 +297,7 @@
String msg = e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -357,7 +357,7 @@
String msg = e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -395,7 +395,7 @@
String msg = "Could not get the version paths of the resource " +
path + ". Caused by: " + e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -439,8 +439,6 @@
long artifactID = resourceDAO.getResourceID(plainPath, conn);
resourceDAO.restore(artifactID, versionNumber, conn);
- //resourceDAO.restore(artifactID, versionNumber, conn);
- //VersionHandler.revert(artifactID, versionNumber, conn);
conn.commit();
@@ -448,7 +446,7 @@
String msg = "Could not restore the version " +
versionPath + ". Caused by: " + e.getMessage();
- log.error(msg);
+ log.error(msg, e);
try {
conn.rollback();
@@ -456,7 +454,7 @@
log.error(e1);
}
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -529,7 +527,7 @@
String msg = Messages.getMessage("resource.tagging.fail",
resourcePath, tag);
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -580,7 +578,7 @@
String msg = Messages.getMessage("tag.search.fail.1", tag);
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -617,7 +615,7 @@
String msg = Messages.getMessage("tag.search.fail.2",
resourcePath);
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -652,12 +650,17 @@
} catch (SQLException e) {
+ String msg = "Could not remove the tag: " + tag + " from the
resource at path: " + path + ".";
+ log.error(msg, e);
+
try {
conn.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
+ throw new RegistryException(msg, e);
+
} finally {
try {
conn.close();
@@ -718,7 +721,7 @@
String msg = Messages.
getMessage("resource.comment.fail", resourcePath,
comment.getText());
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
@@ -765,7 +768,7 @@
String msg = Messages.getMessage("get.comments.fail",
resourcePath);
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -834,7 +837,7 @@
String msg = Messages.getMessage("resource.rating.fail",
resourcePath);
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
@@ -868,7 +871,7 @@
String msg = Messages.getMessage("get.average.rating.fail",
resourcePath);
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -896,7 +899,7 @@
String msg = "Could not get the rating of the resource " + path +
" given by the user " + userName + ". Caused by: " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -956,7 +959,7 @@
String msg = Messages.getMessage("define.query.fail", name, query);
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
@@ -1023,7 +1026,7 @@
} catch (SQLException e) {
String msg = "Could not get logs. Caused by: " + e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
} finally {
try {
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
Sun Jan 13 21:30:00 2008
@@ -86,7 +86,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authentication. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
this.userID = userID;
@@ -122,7 +122,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authentication. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
this.userID = userID;
@@ -159,7 +159,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -247,7 +247,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
}
@@ -274,7 +274,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -324,7 +324,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -352,7 +352,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -380,7 +380,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -413,7 +413,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -441,7 +441,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -469,7 +469,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -495,7 +495,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -528,7 +528,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -556,7 +556,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -584,7 +584,7 @@
} catch (UserManagerException e) {
String msg = "Could not check authorization. \nCaused by " +
e.getMessage();
log.error(msg, e);
- throw new RegistryException(msg);
+ throw new RegistryException(msg, e);
}
User.setCurrentUser(userID);
@@ -618,7 +618,7 @@
authorizedEnListList.add(allEntries[i]);
}
} catch (UserManagerException e) {
- //TODO Need to log what happen here
+ log.error("Could not check permissions for resource: " +
allEntries[i].getResourcePath(), e);
}
}
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
Sun Jan 13 21:30:00 2008
@@ -94,7 +94,7 @@
dbConfiguration.getDataSourceName() + ".
Caused by: " +
e.getMessage();
log.fatal(msg, e);
- throw new ServletException(msg);
+ throw new ServletException(msg, e);
}
} else {
dataSource = new RegistryDataSource(
@@ -132,7 +132,8 @@
System.getProperties().put(RegistryConstants.SYSTEM_REGISTRY,
systemRegistry);
System.getProperties().put(RegistryConstants.REGISTRY_REALM,
registryRealm);
} catch (RegistryException e) {
- throw new ServletException(e.getMessage());
+ String msg = "Registry initialization failed.";
+ throw new ServletException(msg, e);
}
log.info(Messages.getMessage("server.initalized"));
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev