Package ch.tatool.app.data

Examples of ch.tatool.app.data.UserAccountImpl


     *
     * Note: This method does NOT save the account data!
     */
    public void closeAccount(UserAccount account) {
        // force the database to shutdown
        final UserAccountImpl userAccount = (UserAccountImpl) account;
        // shutdown the database - necessary for hsql. we do it currently by adding a shutdown=true parameter to the connection string
        userAccount.getTransactionTemplate().execute(
            new TransactionCallbackWithoutResult() {
                public void doInTransactionWithoutResult(TransactionStatus status) {
                    UserAccountDAO userAccountDAO = userAccount.getUserAccountDAO();
                    userAccountDAO.shutdown();
                }
            }
        );
       
        // destroy all singletons - this will trigger the close method of the DataSource
        DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) userAccount.getBeanFactory();
        beanFactory.destroySingletons();
    }
View Full Code Here


   
    /**
     * Change the password for an account.
     */
    public void changePassword(UserAccount account, final String newPassword) {
        final UserAccountImpl userAccount = (UserAccountImpl) account;
        userAccount.getTransactionTemplate().execute(
            new TransactionCallbackWithoutResult() {
                public void doInTransactionWithoutResult(TransactionStatus status) {
                    UserAccountDAO userAccountDAO = userAccount.getUserAccountDAO();
                    userAccountDAO.setAccountPassword(userAccount, newPassword);
                }
            }
        );
        updateUserAccountInfo(userAccount);
View Full Code Here

    /** Delete a module.
     *
     * This method should completely remove all module related data from the system.
     */
    public void deleteAccount(UserAccount account) {
        final UserAccountImpl userAccount = (UserAccountImpl) account;
       
        // delete the data object
        userAccount.getTransactionTemplate().execute(
            new TransactionCallbackWithoutResult() {
                public void doInTransactionWithoutResult(TransactionStatus status) {
                    UserAccountDAO userAccountDAO = userAccount.getUserAccountDAO();
                    userAccountDAO.deleteAccount(userAccount);
                }
            }
        );
       
       
        // first close the account
        closeAccount(account);
       
        // then delete the account folder
        File folder = userAccount.getFolder();
        if (folder.exists()) {
            // delete the folder and all files in it
            try {
                logger.info("Deleting directory {}", folder.getAbsolutePath());
                FileUtils.deleteDirectory(folder);
View Full Code Here

        info.setName(accountName);
        info.setPasswordProtected(password != null && password.length() > 0);
        info.setVersion(System.getProperty("app.version"));
       
        // open the database layer with an empty password by default
        UserAccountImpl account = (UserAccountImpl) loadAccount(info, null);
       
        // write the description file
        info.setId(account.getId());
        writeAccountDescFile(info);
       
        // set the password of the account if provided
        if (password != null && password.length() > 0) {
            changePassword(account, password);
        }
       
        // set additional properties of the account
        for(String s : userProperties.keySet()) {
          account.getProperties().put(s, userProperties.get(s));
    }
       
        saveAccount(account);
       
        changeLocale(account);
View Full Code Here

        }

        BeanFactory beanFactory = ContextUtils.createBeanFactory(configurationFilePath, properties);
       
        // create an account object, and bind it to the database
        final UserAccountImpl userAccount = new UserAccountImpl();
        userAccount.setFolder(infoImpl.getFolder());
        userAccount.setBeanFactory(beanFactory);
        userAccount.setPassword(password);
        userAccount.setName(infoImpl.getName());
        userAccount.setId(infoImpl.getId());
        userAccount.setVersion(infoImpl.getVersion());

        // initialize transaction management
        PlatformTransactionManager transactionManager = (PlatformTransactionManager) beanFactory.getBean("userAccountTxManager")
        TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
        userAccount.setTransactionTemplate(transactionTemplate);
       
        // load the account in a transaction
        try {
            transactionTemplate.execute(
                new TransactionCallbackWithoutResult() {
                    public void doInTransactionWithoutResult(TransactionStatus status) {
                        UserAccountDAO userAccountDAO = userAccount.getUserAccountDAO();
                        userAccountDAO.loadAccount(userAccount);
                    }
                }
            );
View Full Code Here

    /**
     * Saves an account.
     */
    public void saveAccount(UserAccount account) {
        // write the database
        final UserAccountImpl userAccount = (UserAccountImpl) account;
        userAccount.getTransactionTemplate().execute(
            new TransactionCallbackWithoutResult() {
                public void doInTransactionWithoutResult(TransactionStatus status) {
                    UserAccountDAO userAccountDAO = userAccount.getUserAccountDAO();
                    userAccountDAO.saveAccount(userAccount);
                }
            }
        );
        updateUserAccountInfo(userAccount);
View Full Code Here

     *
     * Note: This method does NOT save the account data!
     */
    public void closeAccount(UserAccount account) {
        // force the database to shutdown
        final UserAccountImpl userAccount = (UserAccountImpl) account;
        // shutdown the database - necessary for hsql. we do it currently by adding a shutdown=true parameter to the connection string
        userAccount.getTransactionTemplate().execute(
            new TransactionCallbackWithoutResult() {
                public void doInTransactionWithoutResult(TransactionStatus status) {
                    UserAccountDAO userAccountDAO = userAccount.getUserAccountDAO();
                    userAccountDAO.shutdown();
                }
            }
        );
       
        // destroy all singletons - this will trigger the close method of the DataSource
        DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) userAccount.getBeanFactory();
        beanFactory.destroySingletons();
    }
View Full Code Here

   
    /**
     * Change the password for an account.
     */
    public void changePassword(UserAccount account, final String newPassword) {
        final UserAccountImpl userAccount = (UserAccountImpl) account;
        userAccount.getTransactionTemplate().execute(
            new TransactionCallbackWithoutResult() {
                public void doInTransactionWithoutResult(TransactionStatus status) {
                    UserAccountDAO userAccountDAO = userAccount.getUserAccountDAO();
                    userAccountDAO.setAccountPassword(userAccount, newPassword);
                }
            }
        );
        updateUserAccountInfo(userAccount);
View Full Code Here

    /** Delete a module.
     *
     * This method should completely remove all module related data from the system.
     */
    public void deleteAccount(UserAccount account) {
        final UserAccountImpl userAccount = (UserAccountImpl) account;
       
        // delete the data object
        userAccount.getTransactionTemplate().execute(
            new TransactionCallbackWithoutResult() {
                public void doInTransactionWithoutResult(TransactionStatus status) {
                    UserAccountDAO userAccountDAO = userAccount.getUserAccountDAO();
                    userAccountDAO.deleteAccount(userAccount);
                }
            }
        );
       
       
        // first close the account
        closeAccount(account);
       
        // then delete the account folder
        File folder = userAccount.getFolder();
        if (folder.exists()) {
            // delete the folder and all files in it
            try {
                logger.info("Deleting directory {}", folder.getAbsolutePath());
                FileUtils.deleteDirectory(folder);
View Full Code Here

TOP

Related Classes of ch.tatool.app.data.UserAccountImpl

Copyright © 2018 www.massapicom. 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.