On 8/2/10 3:24 AM, Colin Coe wrote:
Well, been poking it with a stick it see if it moves...
---
diff --git 
a/java/code/src/com/redhat/rhn/common/db/datasource/xml/General_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/General_queries.xml
index 1c0e43a..7167ede 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/General_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/General_queries.xml
@@ -347,5 +347,14 @@ SELECT max_members, current_members FROM
rhnServerGroup sg, rhnServerGroupType s
    </query>
  </write-mode>

+<write-mode name="insert_sw_mgr_enterprise">
+<query params="org_id, ent_id">
+    INSERT
+      INTO rhnOrgEntitlements
+           (org_id, ENTITLEMENT_ID)
+    VALUES (:org_id, :ent_id)
+</query>
+</write-mode>
+
  </datasource_modes>

diff --git a/java/code/src/com/redhat/rhn/manager/org/CreateOrgCommand.java
b/java/code/src/com/redhat/rhn/manager/org/CreateOrgCommand.java
index d13d943..85ddbc6 100644
--- a/java/code/src/com/redhat/rhn/manager/org/CreateOrgCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/org/CreateOrgCommand.java
@@ -14,6 +14,8 @@
   */
  package com.redhat.rhn.manager.org;

+import com.redhat.rhn.common.db.datasource.ModeFactory;
+import com.redhat.rhn.common.db.datasource.WriteMode;
  import com.redhat.rhn.common.localization.LocalizationService;
  import com.redhat.rhn.common.validator.ValidatorError;
  import com.redhat.rhn.common.validator.ValidatorException;
@@ -27,7 +29,9 @@ import com.redhat.rhn.manager.user.CreateUserCommand;

  import org.apache.log4j.Logger;

+import java.util.HashMap;
  import java.util.List;
+import java.util.Map;

  /**
   * CreateOrgCommand - Command to create an org and the first admin in the Org.
@@ -171,10 +175,23 @@ public class CreateOrgCommand {

              ChannelFamilyFactory.lookupOrCreatePrivateFamily(createdOrg);

+            setSwMgrEnterpriseEntitlement(this.newOrg.getId(),
+                    OrgFactory.getEntitlementEnterprise().getId());
+
              return null;
          }
      }

+    private void setSwMgrEnterpriseEntitlement(Long orgId, Long entId) {
+        Map params = new HashMap();
+        params.put("ent_id", entId);
+        params.put("org_id", orgId);
+
+        WriteMode m = ModeFactory.getWriteMode("General_queries",
+                                               "insert_sw_mgr_enterprise");
+        m.executeUpdate(params);
+    }
+
      /**
       * Get the newly created org.
       * @return Org that was stored to DB
---

This does let an Org Admin in a non-primary Org manage users but now
when I attempt to delete an organisation I get a traceback.  Not sure
if its something I've done ATM.

Could someone review this and see if it looks OK?  I looked but
couldn't find a method to set the 'sw_mgr_enterprise' for the org
which is why I ended up using the insert query.  I'd rather not commit
this without comment from the group.

The traceback when I attempt to delete an org starts with:
---
2010-08-02 15:20:45,404 [TP-Processor1] WARN
org.apache.struts.action.RequestProcessor - Unhandled Exception
thrown: class com.redhat.rhn.common.db.WrappedSQLException
2010-08-02 15:20:45,408 [TP-Processor1] ERROR
com.redhat.rhn.frontend.servlets.SessionFilter - Error during
transaction. Rolling back
javax.servlet.ServletException: ORA-04063: package body
"SPACEWALK.RHN_ORG" has errors
ORA-06508: PL/SQL: could not find program unit being called: "SPACEWALK.RHN_ORG"
ORA-06512: at line 1
---

CC

On Mon, Aug 2, 2010 at 1:36 PM, Colin Coe<colin....@gmail.com>  wrote:
That should have been 'sw_mgr_enterprise' not 'sw_mgr_entitled'.

On Mon, Aug 2, 2010 at 1:06 PM, Colin Coe<colin....@gmail.com>  wrote:
Hi all

I've been looking at the no Users tab problem for subsequent orgs (not
org ID 1).  Its definitely not an 'org_admin' ACL problem.  It seems
to be a problem with 'sw_mgr_entitled' as when I take that away the
Users tab appears but gives errors whenever click on the links on the
page (user details or 'create user').

I'm not really sure what 'sw_mgr_entitled' is for.  Could someone explain?

Thanks

CC

Doing a 'insert into rhnOrgEntitlements (org_id, ENTITLEMENT_ID)
values (2,1);' makes it WorkForMe(tm).



Hey Colin,

So essentially this was more related to rhn.redhat.com (the hosted service). In order to be able to create other users, it was required to have at least one management entitlement. And thus, each org currently requires at least one management entitlement to be able to see/access the users tab.

Satellite requires a management entitlement for each system, so this restriction is really pretty silly. We've talked about removing it, but haven't really ever gotten around to it. Feel free to remove this restriction.


Looking at your patch, you would need to call the stored procedure if you wanted to transfer an entitlement from one org to the next (just doing an insert doesn't preserve entitlement validation for satellite users). I wouldn't bother with trying to automatically move give management entitlements to a new org, i would just remove the original restriction from those User tabs.

-Justin

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to