Examples of UserStoreException


Examples of org.wso2.carbon.user.core.UserStoreException

            prepStmt = dbConnection.prepareStatement(sqlStmt);
            if (params != null && params.length > 0) {
                for (int i = 0; i < params.length; i++) {
                    Object param = params[i];
                    if (param == null) {
                        throw new UserStoreException("Invalid data provided");
                    } else if (param instanceof String) {
                        prepStmt.setString(i + 1, (String) param);
                    } else if (param instanceof Integer) {
                        prepStmt.setInt(i + 1, (Integer) param);
                    } else if (param instanceof Date) {
                        //Timestamp timestamp = new Timestamp(((Date) param).getTime());
                        //prepStmt.setTimestamp(i + 1, timestamp);
                        prepStmt.setTimestamp(i + 1,new Timestamp(System.currentTimeMillis()));
                    } else if (param instanceof Boolean) {
                        prepStmt.setBoolean(i + 1, (Boolean) param);
                    }
                }
            }
            int count = prepStmt.executeUpdate();
            if(count == 0) {
                log.info("No rows were updated");
            }
            if (log.isDebugEnabled()) {
                log.debug("Executed querry is " + sqlStmt + " and number of updated rows :: "
                        + count);
            }

            if (localConnection) {
                dbConnection.commit();
            }
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            log.error("Using sql : " + sqlStmt);
            throw new UserStoreException(e.getMessage(), e);
        } finally {
            if (localConnection) {
                DatabaseUtil.closeAllConnections(dbConnection);
            }
            DatabaseUtil.closeAllConnections(null, prepStmt);
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

            if (sqlStmt == null) {
                sqlStmt = realmConfig
                        .getUserStoreProperty(JDBCRealmConstants.ADD_USER_PROPERTY);
            }
            if (sqlStmt == null) {
                throw new UserStoreException("The sql statement for add user property sql is null");
            }
            updateStringValuesToDatabase(dbConnection, sqlStmt, userName, tenantId, propertyName,
                    value, profileName, tenantId);
        } catch (UserStoreException e) {
            throw e;
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new UserStoreException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

    protected void updateProperty(Connection dbConnection, String userName, String propertyName,
            String value, String profileName) throws UserStoreException {
        String sqlStmt = realmConfig
                .getUserStoreProperty(JDBCRealmConstants.UPDATE_USER_PROPERTY);
        if (sqlStmt == null) {
            throw new UserStoreException("The sql statement for add user property sql is null");
        }
        updateStringValuesToDatabase(dbConnection, sqlStmt, value, userName, tenantId,
                propertyName, profileName, tenantId);
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

    protected void deleteProperty(Connection dbConnection, String userName, String propertyName,
            String profileName) throws UserStoreException {
        String sqlStmt = realmConfig
                .getUserStoreProperty(JDBCRealmConstants.DELETE_USER_PROPERTY);
        if (sqlStmt == null) {
            throw new UserStoreException("The sql statement for add user property sql is null");
        }
        updateStringValuesToDatabase(dbConnection, sqlStmt, userName, tenantId, propertyName,
                profileName, tenantId);
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

    protected String getProperty(Connection dbConnection, String userName, String propertyName,
            String profileName) throws UserStoreException {
        String sqlStmt = realmConfig
                .getUserStoreProperty(JDBCRealmConstants.GET_PROP_FOR_PROFILE);
        if (sqlStmt == null) {
            throw new UserStoreException("The sql statement for add user property sql is null");
        }
        PreparedStatement prepStmt = null;
        ResultSet rs = null;
        String value = null;
        try {
            prepStmt = dbConnection.prepareStatement(sqlStmt);
            prepStmt.setString(1, userName);
            prepStmt.setString(2, propertyName);
            prepStmt.setString(3, profileName);
            if (sqlStmt.contains(UserCoreConstants.UM_TENANT_COLUMN)) {
                prepStmt.setInt(4, tenantId);
                prepStmt.setInt(5, tenantId);
            }

            rs = prepStmt.executeQuery();
            while (rs.next()) {
                value = rs.getString(1);
            }
            return value;
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            log.error("Using sql : " + sqlStmt);
            throw new UserStoreException(e.getMessage(), e);
        } finally {
            DatabaseUtil.closeAllConnections(null, rs, prepStmt);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

                password = Base64.encode(byteValue);
            }
            return password;
        } catch (NoSuchAlgorithmException e) {
            log.error(e.getMessage(), e);
            throw new UserStoreException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

        } else {
            if (!isExistingUser(realmConfig.getAdminUserName())) {
                if ("true".equals(realmConfig
                        .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_READ_ONLY))) {
                    log.error("Admin user name is not valid");
                    throw new UserStoreException("Admin user name is not valid");
                }
                // it is not required to notify to the listeners, just persist data.
                this.persistUser(realmConfig.getAdminUserName(), realmConfig.getAdminPassword(),
                        null, null, null, false);
            }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

                        tenantId);
            }
            dbConnection.commit();
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            throw new UserStoreException(e.getMessage(), e);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new UserStoreException(e.getMessage(), e);
        } finally {
            DatabaseUtil.closeAllConnections(dbConnection);
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

                createdTime = rs.getTimestamp(2);
            }
        } catch (SQLException e) {
            log.error(e.getMessage(), e);
            log.error("Using sql : " + HybridJDBCConstants.GET_REMEMBERME_VALUE_SQL);
            throw new UserStoreException(e.getMessage(), e);
        } finally {
            DatabaseUtil.closeAllConnections(null, rs, prepStmt);
        }

        if (value != null && createdTime != null) {
View Full Code Here

Examples of org.wso2.carbon.user.core.UserStoreException

                    if (context != null && context.getRealmService() != null) {
                        try {
                            tenantId = context.getRealmService().getTenantManager().getTenantId(
                                    tenantIdString);
                        } catch (org.wso2.carbon.user.api.UserStoreException e) {
                            throw new UserStoreException(e);
                        }
                    }
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.