Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4685317E39 for ; Wed, 29 Oct 2014 16:10:26 +0000 (UTC) Received: (qmail 4634 invoked by uid 500); 29 Oct 2014 16:10:26 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 4522 invoked by uid 500); 29 Oct 2014 16:10:26 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 4420 invoked by uid 99); 29 Oct 2014 16:10:26 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Oct 2014 16:10:26 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id CF29AA00E0E; Wed, 29 Oct 2014 16:10:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: elecharny@apache.org To: commits@directory.apache.org Date: Wed, 29 Oct 2014 16:10:28 -0000 Message-Id: <6749b63dc9554005aca31d89e7d45000@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/6] git commit: o Added the toString() method o Added some Javadoc o A bit of refactoring o Added the toString() method o Added some Javadoc o A bit of refactoring 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/a4c5e213 Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/a4c5e213 Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/a4c5e213 Branch: refs/heads/master Commit: a4c5e213d00a690f02d4e2bab78fdc1c08ffb156 Parents: 9bb82e6 Author: Emmanuel Lécharny Authored: Wed Oct 29 14:44:04 2014 +0100 Committer: Emmanuel Lécharny Committed: Wed Oct 29 14:44:04 2014 +0100 ---------------------------------------------------------------------- .../directory/fortress/core/rbac/OrgUnit.java | 98 +++++++++++++++++++- 1 file changed, 94 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/a4c5e213/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java b/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java index a1db133..a975e5b 100755 --- a/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java +++ b/src/main/java/org/apache/directory/fortress/core/rbac/OrgUnit.java @@ -20,6 +20,7 @@ package org.apache.directory.fortress.core.rbac; +import java.io.Serializable; import java.util.HashSet; import java.util.Set; import java.util.UUID; @@ -161,19 +162,30 @@ import javax.xml.bind.annotation.XmlType; "parents", "type" }) -public class OrgUnit extends FortEntity - implements Graphable, java.io.Serializable +public class OrgUnit extends FortEntity implements Graphable, Serializable { + private static final long serialVersionUID = 1L; + /** - * Maps to the location for a particular OrgUnit entity to either the User, {@code ou=OS-U}, or Permission, {@code ou=OS-P}, tree in ldap. - * + * Maps to the location for a particular OrgUnit entity to either the User, + * {@code ou=OS-U}, or Permission, {@code ou=OS-P}, tree in ldap. */ public Type type; + + /** The name required attribute of the OrgUnit object */ private String name; + + /** the internal id that is associated with OrgUnit */ private String id; + + /** The description that is associated with OrgUnit */ private String description; + + /** The names of orgUnits that are parents (direct ascendants) of this orgUnit */ @XmlElement(nillable = true) private Set parents; + + /** The set of child orgUnit names (direct descendants) of this orgUnit */ @XmlElement(nillable = true) private Set children; @@ -359,6 +371,7 @@ public class OrgUnit extends FortEntity { this.parents = new HashSet<>(); } + this.parents.add( parent ); } @@ -403,14 +416,91 @@ public class OrgUnit extends FortEntity public boolean equals( Object thatObj ) { if ( this == thatObj ) + { return true; + } + if ( this.getName() == null ) + { return false; + } + if ( !( thatObj instanceof OrgUnit ) ) + { return false; + } + OrgUnit thatOrg = ( OrgUnit ) thatObj; + if ( thatOrg.getName() == null ) + { return false; + } + return thatOrg.getName().equalsIgnoreCase( this.getName() ); } + + + /** + * @see Object#toString() + */ + public String toString() + { + StringBuilder sb = new StringBuilder(); + + sb.append( "OrgUnit object: \n" ); + + sb.append( " name :" ).append( name ).append( '\n' ); + sb.append( " id :" ).append( id ).append( '\n' ); + sb.append( " description :" ).append( description ).append( '\n' ); + sb.append( " type :" ).append( type ).append( '\n' ); + + if ( parents != null ) + { + sb.append( " parents : " ); + + boolean isFirst = true; + + for ( String parent : parents ) + { + if ( isFirst ) + { + isFirst = false; + } + else + { + sb.append( ", " ); + } + + sb.append( parent ); + } + + sb.append( '\n' ); + } + + if ( children != null ) + { + sb.append( " children : " ); + + boolean isFirst = true; + + for ( String child : children ) + { + if ( isFirst ) + { + isFirst = false; + } + else + { + sb.append( ", " ); + } + + sb.append( child ); + } + + sb.append( '\n' ); + } + + return sb.toString(); + } }