Search in sources :

Example 1 with XMLDBException

use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.

the class UserManagerDialog method refreshUsersTableModel.

public void refreshUsersTableModel() {
    final int rowCount = usersTableModel.getRowCount();
    for (int i = 0; i < rowCount; i++) {
        usersTableModel.removeRow(0);
    }
    try {
        final Account[] accounts = userManagementService.getAccounts();
        Arrays.sort(accounts, new AccountComparator());
        for (Account account : accounts) {
            usersTableModel.addRow(new String[] { account.getName(), account.getMetadataValue(AXSchemaType.FULLNAME), account.getMetadataValue(EXistSchemaType.DESCRIPTION) });
        }
    } catch (final XMLDBException xmldbe) {
        JOptionPane.showMessageDialog(this, "Could not get users list: " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : Account(org.exist.security.Account) XMLDBException(org.xmldb.api.base.XMLDBException) AccountComparator(org.exist.security.AccountComparator)

Example 2 with XMLDBException

use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.

the class UserManagerDialog method showEditUserDialog.

private void showEditUserDialog(final Account account) {
    final UserManagerDialog that = this;
    final DialogCompleteWithResponse<String> callback = response -> {
        // get client to reconnect with edited users new password
        try {
            System.out.println("Detected logged-in user password change, reconnecting to server...");
            that.userManagementService = reconnectClientAndUserManager(response);
            System.out.println("Reconnected.");
        } catch (final XMLDBException xmldbe) {
            JOptionPane.showMessageDialog(that, "Could not edit user '" + getSelectedUsername() + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
        }
    };
    final EditUserDialog userDialog = new EditUserDialog(userManagementService, account);
    if (getSelectedUsername().equals(currentUser)) {
        // register for password update event, if we are changing the password
        // of the current user
        userDialog.addDialogCompleteWithResponseCallback(callback);
    }
    userDialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(final WindowEvent e) {
            refreshUsersTableModel();
        }
    });
    userDialog.setVisible(true);
}
Also used : XMLDBException(org.xmldb.api.base.XMLDBException) Arrays(java.util.Arrays) Properties(java.util.Properties) HighlightedTableCellRenderer(org.exist.client.HighlightedTableCellRenderer) DefaultTableModel(javax.swing.table.DefaultTableModel) Group(org.exist.security.Group) AXSchemaType(org.exist.security.AXSchemaType) AccountComparator(org.exist.security.AccountComparator) DialogCompleteWithResponse(org.exist.client.DialogCompleteWithResponse) WindowAdapter(java.awt.event.WindowAdapter) JOptionPane(javax.swing.JOptionPane) WindowEvent(java.awt.event.WindowEvent) EXistSchemaType(org.exist.security.EXistSchemaType) Account(org.exist.security.Account) SecurityManager(org.exist.security.SecurityManager) InteractiveClient(org.exist.client.InteractiveClient) ClientFrame(org.exist.client.ClientFrame) UserManagementService(org.exist.xmldb.UserManagementService) TableModel(javax.swing.table.TableModel) WindowEvent(java.awt.event.WindowEvent) XMLDBException(org.xmldb.api.base.XMLDBException) WindowAdapter(java.awt.event.WindowAdapter)

Example 3 with XMLDBException

use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.

the class UserManagerDialog method miEditGroupActionPerformed.

// GEN-LAST:event_tblUsersMouseClicked
private void miEditGroupActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_miEditGroupActionPerformed
    final String selectedGroup = getSelectedGroup();
    try {
        final Group group = userManagementService.getGroup(selectedGroup);
        showEditGroupDialog(group);
    } catch (final XMLDBException xmldbe) {
        JOptionPane.showMessageDialog(this, "Could not edit group '" + selectedGroup + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : Group(org.exist.security.Group) XMLDBException(org.xmldb.api.base.XMLDBException)

Example 4 with XMLDBException

use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.

the class UserManagerDialog method tblUsersMouseClicked.

// GEN-LAST:event_btnCreateActionPerformed
private void tblUsersMouseClicked(java.awt.event.MouseEvent evt) {
    // GEN-FIRST:event_tblUsersMouseClicked
    final boolean userSelected = tblUsers.getSelectedRow() > -1;
    final String selectedUsername = getSelectedUsername();
    boolean canModify = userSelected && !selectedUsername.equals(SecurityManager.SYSTEM);
    boolean canDelete = userSelected && !(selectedUsername.equals(SecurityManager.SYSTEM) || selectedUsername.equals(SecurityManager.DBA_USER) || selectedUsername.equals(SecurityManager.GUEST_USER));
    miEditUser.setEnabled(canModify);
    miRemoveUser.setEnabled(canDelete);
    if (evt.getClickCount() == 2 && canModify) {
        try {
            final Account account = userManagementService.getAccount(selectedUsername);
            showEditUserDialog(account);
        } catch (final XMLDBException xmldbe) {
            JOptionPane.showMessageDialog(this, "Could not edit user '" + selectedUsername + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : Account(org.exist.security.Account) XMLDBException(org.xmldb.api.base.XMLDBException)

Example 5 with XMLDBException

use of org.xmldb.api.base.XMLDBException in project exist by eXist-db.

the class UserManagerDialog method miEditUserActionPerformed.

// GEN-LAST:event_miRemoveUserActionPerformed
private void miEditUserActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_miEditUserActionPerformed
    final String selectedUsername = getSelectedUsername();
    try {
        final Account account = userManagementService.getAccount(selectedUsername);
        showEditUserDialog(account);
    } catch (final XMLDBException xmldbe) {
        JOptionPane.showMessageDialog(this, "Could not edit user '" + selectedUsername + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : Account(org.exist.security.Account) XMLDBException(org.xmldb.api.base.XMLDBException)

Aggregations

XMLDBException (org.xmldb.api.base.XMLDBException)174 Collection (org.xmldb.api.base.Collection)66 Resource (org.xmldb.api.base.Resource)34 URISyntaxException (java.net.URISyntaxException)30 XMLResource (org.xmldb.api.modules.XMLResource)30 ResourceSet (org.xmldb.api.base.ResourceSet)23 BuildException (org.apache.tools.ant.BuildException)21 IOException (java.io.IOException)19 XPathException (org.exist.xquery.XPathException)18 PermissionDeniedException (org.exist.security.PermissionDeniedException)16 SAXException (org.xml.sax.SAXException)16 EXistException (org.exist.EXistException)15 UserManagementService (org.exist.xmldb.UserManagementService)15 XPathQueryService (org.xmldb.api.modules.XPathQueryService)13 BinaryResource (org.xmldb.api.modules.BinaryResource)12 ArrayList (java.util.ArrayList)11 Account (org.exist.security.Account)11 EXistResource (org.exist.xmldb.EXistResource)10 EXistXPathQueryService (org.exist.xmldb.EXistXPathQueryService)10 Properties (java.util.Properties)9