directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject directory-fortress-core git commit: FC-137 - Add system properties in tests kicked off by maven
Date Fri, 22 Jan 2016 14:52:49 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master b7c5659b7 -> 1bcd0a1b1


 FC-137 - Add system properties in tests kicked off by maven


Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/1bcd0a1b
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/1bcd0a1b
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/1bcd0a1b

Branch: refs/heads/master
Commit: 1bcd0a1b1e9f18196e815192853ee89156409fb8
Parents: b7c5659
Author: Shawn McKinney <smckinney@apache.org>
Authored: Fri Jan 22 07:56:54 2016 -0600
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Fri Jan 22 07:56:54 2016 -0600

----------------------------------------------------------------------
 ldap/setup/FortressDemoUsers.xml                |  2 +
 .../fortress/core/ant/FortressAntTask.java      | 53 +++++++++++++++-----
 .../core/impl/OrganizationalUnitDAO.java        |  6 ++-
 3 files changed, 47 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1bcd0a1b/ldap/setup/FortressDemoUsers.xml
----------------------------------------------------------------------
diff --git a/ldap/setup/FortressDemoUsers.xml b/ldap/setup/FortressDemoUsers.xml
index 73a6eb0..ba6a272 100755
--- a/ldap/setup/FortressDemoUsers.xml
+++ b/ldap/setup/FortressDemoUsers.xml
@@ -25,9 +25,11 @@
     <target name="all">
         <FortressAdmin>
 
+<!--
             <addcontext>
                 <context name="${tenant}"/>
             </addcontext>
+-->
 
             <addcontainer>
                 <container name="People" description="Fortress People"/>

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1bcd0a1b/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java b/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
index ac7b1cc..da7bfa2 100755
--- a/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
+++ b/src/main/java/org/apache/directory/fortress/core/ant/FortressAntTask.java
@@ -316,6 +316,8 @@ public class FortressAntTask extends Task implements InputHandler
     private static final String CLS_NM = FortressAntTask.class.getName();
     protected static final Logger LOG = LoggerFactory.getLogger( CLS_NM );
     private Context context;
+    // This system property can be used to set the default tenant id:
+    private static final String TENANT = System.getProperty( "tenant" );
 
 
     /**
@@ -329,6 +331,15 @@ public class FortressAntTask extends Task implements InputHandler
     }
 
 
+    /**
+     * This method is used as an alternative way to set tenant id.  By setting this element
in xml file:
+     * <addcontext>
+     *     <context name="${tenant}"/>
+     </addcontext>
+     *
+     *
+     * @param context contains the tenant info.
+     */
     public void setContext( Context context )
     {
         System.out.println( CLS_NM + ".setContext name: " + context.getName() );
@@ -352,17 +363,29 @@ public class FortressAntTask extends Task implements InputHandler
      */
     public FortressAntTask()
     {
+        String tenant = "";
         try
         {
+            // This value is set by system property "tenant":
+            if( StringUtils.isEmpty( TENANT ) || TENANT.equals( "${tenant}" ) )
+            {
+                // Use the default context:
+                tenant = GlobalIds.HOME;
+            }
+            else
+            {
+                LOG.info( "FortressAntTask constructor using tenant={}", tenant );
+            }
             cfgMgr = ConfigMgrFactory.createInstance();
-            adminMgr = AdminMgrFactory.createInstance( GlobalIds.HOME );
-            dAdminMgr = DelAdminMgrFactory.createInstance( GlobalIds.HOME );
-            policyMgr = PwPolicyMgrFactory.createInstance( GlobalIds.HOME );
-            groupMgr = GroupMgrFactory.createInstance( GlobalIds.HOME );
+            adminMgr = AdminMgrFactory.createInstance( tenant );
+            dAdminMgr = DelAdminMgrFactory.createInstance( tenant );
+            policyMgr = PwPolicyMgrFactory.createInstance( tenant );
+            groupMgr = GroupMgrFactory.createInstance( tenant );
+
         }
         catch ( SecurityException se )
         {
-            LOG.warn( " FortressAntTask constructor caught SecurityException={}", se );
+            LOG.warn( " FortressAntTask constructor tenant={}, caught SecurityException={}",
tenant, se );
         }
     }
 
@@ -1579,8 +1602,8 @@ public class FortressAntTask extends Task implements InputHandler
                         if ( se.getErrorId() == GlobalErrIds.PERM_DUPLICATE )
                         {
                             adminMgr.updatePermObj( permObj );
-                            System.out.println( CLS_NM + ".addPermObjs - update entity objName="
+ permObj
-                                .getObjName() );
+                            LOG.info( "addPermObjs update entity objName={} description={}
orgUnit={} type={}", permObj.getObjName(), permObj
+                                .getDescription(), permObj.getOu(), permObj.getType() );
                         }
                         else
                         {
@@ -1889,17 +1912,17 @@ public class FortressAntTask extends Task implements InputHandler
                 try
                 {
                     OrganizationalUnitP op = new OrganizationalUnitP();
-
-                    if ( this.context != null )
+                    // Set the tenant id onto the entity.
+                    // Normally this info would be passed in via a manager constructor. 
Since these methods aren't implemented by a manager, we must do this here:
+                    if( ! StringUtils.isEmpty( TENANT ) && ! TENANT.equals( "${tenant}"
) )
                     {
-                        ou.setContextId( this.context.getName() );
+                        ou.setContextId( TENANT );
                     }
-
                     op.add( ou );
                 }
                 catch ( SecurityException se )
                 {
-                    LOG.warn( "addContainers name [{}] caught SecurityException={}", ou.getName(),
se );
+                    LOG.warn( "addContainers name [{}] caught SecurityException={}", ou.getName(),
se.getMessage() );
                 }
             }
         }
@@ -1926,6 +1949,12 @@ public class FortressAntTask extends Task implements InputHandler
                 try
                 {
                     OrganizationalUnitP op = new OrganizationalUnitP();
+                    // Set the tenant id onto the entity.
+                    // Normally this info would be passed in via a manager constructor. 
Since these methods aren't implemented by a manager, we must do this here:
+                    if( ! StringUtils.isEmpty( TENANT ) && ! TENANT.equals( "${tenant}"
) )
+                    {
+                        ou.setContextId( TENANT );
+                    }
                     op.delete( ou );
                 }
                 catch ( SecurityException se )

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/1bcd0a1b/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java
b/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java
index ea69cef..66e942a 100644
--- a/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/OrganizationalUnitDAO.java
@@ -92,6 +92,8 @@ final class OrganizationalUnitDAO extends ApacheDsDataProvider
             nodeDn += SchemaConstants.OU_AT + "=" + oe.getParent() + ",";
         }
 
+        System.out.println("CONTEXTID = " + oe.getContextId());
+
         nodeDn += getRootDn( oe.getContextId() );
 
         try
@@ -108,8 +110,8 @@ final class OrganizationalUnitDAO extends ApacheDsDataProvider
         }
         catch ( LdapException e )
         {
-            String error = "create container node dn [" + nodeDn + "] caught LDAPException="
-                + e.getMessage();
+            String error = "create container node dn [" + nodeDn + "] caught LdapException="
+                + e;
             throw new CreateException( GlobalErrIds.CNTR_CREATE_FAILED, error, e );
         }
         finally


Mime
View raw message