]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/internal/UiAdminUtils.java
Improve and simplify OSGi Boot
[lgpl/argeo-commons.git] / org.argeo.security.ui.admin / src / org / argeo / security / ui / admin / internal / UiAdminUtils.java
index d1596190a906b3a7812046a13268dc833fa0a974..871877a0e21d349f2cf36a469fca092fb7c6a0de 100644 (file)
@@ -1,23 +1,32 @@
 package org.argeo.security.ui.admin.internal;
 
-import java.security.AccessController;
-import java.security.Principal;
+import javax.transaction.UserTransaction;
 
-import javax.security.auth.Subject;
-import javax.security.auth.x500.X500Principal;
+import org.argeo.cms.CmsException;
+import org.argeo.security.ui.admin.internal.providers.UserTransactionProvider;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.services.ISourceProviderService;
 
 /** First effort to centralize back end methods used by the user admin UI */
 public class UiAdminUtils {
-       public final static String getUsername() {
-               Subject subject = Subject.getSubject(AccessController.getContext());
-               Principal principal = subject.getPrincipals(X500Principal.class)
-                               .iterator().next();
-               return principal.getName();
-
-       }
-
        /*
         * INTERNAL METHODS: Below methods are meant to stay here and are not part
         * of a potential generic backend to manage the useradmin
         */
+       /** Easily notify the ActiveWindow that the transaction had a state change */
+       public final static void notifyTransactionStateChange(
+                       UserTransaction userTransaction) {
+               try {
+                       IWorkbenchWindow aww = PlatformUI.getWorkbench()
+                                       .getActiveWorkbenchWindow();
+                       ISourceProviderService sourceProviderService = (ISourceProviderService) aww
+                                       .getService(ISourceProviderService.class);
+                       UserTransactionProvider esp = (UserTransactionProvider) sourceProviderService
+                                       .getSourceProvider(UserTransactionProvider.TRANSACTION_STATE);
+                       esp.fireTransactionStateChange();
+               } catch (Exception e) {
+                       throw new CmsException("Unable to begin transaction", e);
+               }
+       }
 }
\ No newline at end of file