X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.security.ui.admin%2Fsrc%2Forg%2Fargeo%2Fsecurity%2Fui%2Fadmin%2Feditors%2FUserEditor.java;h=2f7aa41c7c2672a3562bb909c746eded2507ebbb;hb=d5ffed5d8b881677873e32abd39440d0a0ac73e0;hp=af6f5748e84a6c59c9d779bde6a23f852e28decd;hpb=70bf531fd1410ffbaaa4083a4f763b04a7c3f95b;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/editors/UserEditor.java b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/editors/UserEditor.java index af6f5748e..2f7aa41c7 100644 --- a/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/editors/UserEditor.java +++ b/org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/editors/UserEditor.java @@ -21,8 +21,8 @@ import java.util.List; import javax.transaction.UserTransaction; import org.argeo.ArgeoException; -import org.argeo.security.ui.admin.SecurityAdminImages; import org.argeo.security.ui.admin.SecurityAdminPlugin; +import org.argeo.security.ui.admin.internal.UiAdminUtils; import org.argeo.security.ui.admin.internal.UserAdminConstants; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.ui.IEditorInput; @@ -56,20 +56,28 @@ public class UserEditor extends FormEditor implements UserAdminConstants { user = (User) userAdmin.getRole(username); String commonName = getProperty(KEY_CN); - // this.setPartProperty("name", commonName != null ? commonName - // : "username"); - // if (user.getType() == Role.GROUP) { - // this.setPartProperty("icon", "icons/users.gif"); - // firePartPropertyChanged("icon", "icons/user.gif", "icons/users.gif"); - // } setPartName(commonName != null ? commonName : "username"); - setTitleImage(user.getType() == Role.GROUP ? SecurityAdminImages.ICON_GROUP - : SecurityAdminImages.ICON_USER); + + // TODO: following has been disabled because it causes NPE after a + // login/logout on RAP + // Image titleIcon = user.getType() == Role.GROUP ? + // SecurityAdminImages.ICON_GROUP + // : SecurityAdminImages.ICON_USER; + // setTitleImage(titleIcon); } - protected List getFlatGroups() { - Authorization currAuth = userAdmin.getAuthorization(user); + /** + * returns the list of all authorisation for the given user or of the + * current displayed user if parameter is null + */ + protected List getFlatGroups(User aUser) { + Authorization currAuth; + if (aUser == null) + currAuth = userAdmin.getAuthorization(this.user); + else + currAuth = userAdmin.getAuthorization(aUser); + String[] roles = currAuth.getRoles(); List groups = new ArrayList(); @@ -109,7 +117,14 @@ public class UserEditor extends FormEditor implements UserAdminConstants { return ""; } - /** The property is directly updated!!! */ + protected void beginTransactionIfNeeded() { + UiAdminUtils.beginTransactionIfNeeded(userTransaction); + } + + /** + * Updates the property in the working copy. The transaction must be + * explicitly committed to persist the update. + */ @SuppressWarnings("unchecked") protected void setProperty(String key, String value) { user.getProperties().put(key, value); @@ -117,14 +132,15 @@ public class UserEditor extends FormEditor implements UserAdminConstants { @Override public void doSave(IProgressMonitor monitor) { + UiAdminUtils.beginTransactionIfNeeded(userTransaction); commitPages(true); firePropertyChange(PROP_DIRTY); // FIXME transaction should be managed at a higher level - try { - userTransaction.commit(); - } catch (Exception e) { - throw new ArgeoException("Could not save user editor", e); - } + // try { + // userTransaction.commit(); + // } catch (Exception e) { + // throw new ArgeoException("Could not save user editor", e); + // } } @Override