Commit 307b06e0 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Modified user creation, update or deletion to check if the provider is read-only.

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2789 b35dd754-fafc-0310-a699-88a17e54d16e
parent f531e993
......@@ -89,6 +89,10 @@ public class DefaultUserProvider implements UserProvider {
public User createUser(String username, String password, String name, String email)
throws UserAlreadyExistsException
{
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
try {
loadUser(username);
// The user already exists since no exception, so:
......@@ -134,6 +138,10 @@ public class DefaultUserProvider implements UserProvider {
}
public void deleteUser(String username) {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null;
PreparedStatement pstmt = null;
boolean abortTransaction = false;
......@@ -248,6 +256,10 @@ public class DefaultUserProvider implements UserProvider {
}
public void setName(String username, String name) throws UserNotFoundException {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null;
PreparedStatement pstmt = null;
try {
......@@ -269,6 +281,10 @@ public class DefaultUserProvider implements UserProvider {
}
public void setEmail(String username, String email) throws UserNotFoundException {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null;
PreparedStatement pstmt = null;
try {
......@@ -290,6 +306,10 @@ public class DefaultUserProvider implements UserProvider {
}
public void setCreationDate(String username, Date creationDate) throws UserNotFoundException {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null;
PreparedStatement pstmt = null;
try {
......@@ -311,6 +331,10 @@ public class DefaultUserProvider implements UserProvider {
}
public void setModificationDate(String username, Date modificationDate) throws UserNotFoundException {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null;
PreparedStatement pstmt = null;
try {
......@@ -332,6 +356,10 @@ public class DefaultUserProvider implements UserProvider {
}
public String getPassword(String username) throws UserNotFoundException {
if (!supportsPasswordRetrieval()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null;
PreparedStatement pstmt = null;
try {
......@@ -355,8 +383,11 @@ public class DefaultUserProvider implements UserProvider {
}
}
public void setPassword(String username, String password) throws UserNotFoundException
{
public void setPassword(String username, String password) throws UserNotFoundException {
if (isReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
Connection con = null;
PreparedStatement pstmt = null;
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment