001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.model.subtree; 021 022 023import java.util.Set; 024 025 026 027/** 028 * An operational view of a subentry within the system. A Subentry can have 029 * many types (Collective, Schema, AccessControl or Trigger) but only one 030 * Subtree Specification. 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public class Subentry 035{ 036 /** The Subtree Specification associated with this subentry */ 037 private SubtreeSpecification ss; 038 039 /** The administratives roles */ 040 private Set<AdministrativeRole> administrativeRoles; 041 042 043 /** 044 * Stores the subtree 045 * 046 * @param ss The subtree specification 047 */ 048 public final void setSubtreeSpecification( SubtreeSpecification ss ) 049 { 050 this.ss = ss; 051 } 052 053 054 /** 055 * @return The subtree specification 056 */ 057 public final SubtreeSpecification getSubtreeSpecification() 058 { 059 return ss; 060 } 061 062 063 /** 064 * Store the Set of administrative roles supported by this Subentry 065 * 066 * @param administrativeRoles The Administrative roles to set 067 */ 068 public final void setAdministrativeRoles( Set<AdministrativeRole> administrativeRoles ) 069 { 070 this.administrativeRoles = administrativeRoles; 071 } 072 073 074 /** 075 * @return The Set of administratoveRole supported by this Subentry 076 */ 077 public final Set<AdministrativeRole> getAdministrativeRoles() 078 { 079 return administrativeRoles; 080 } 081 082 083 /** 084 * Tells if the type contains the Collective attribute Administrative Role 085 * 086 * @return <tt>true</tt> if the type contains the Collective Attribute Administrative Role, <tt>false</tt> otherwise 087 */ 088 public final boolean isCollectiveAdminRole() 089 { 090 return administrativeRoles.contains( AdministrativeRole.CollectiveAttributeInnerArea ) 091 || administrativeRoles.contains( AdministrativeRole.CollectiveAttributeSpecificArea ); 092 } 093 094 095 /** 096 * Tells if the type contains the SubSchema Administrative Role 097 * 098 * @return <tt>true</tt> if the type contains the SubSchema Administrative Role, <tt>false</tt> otherwise 099 */ 100 public final boolean isSchemaAdminRole() 101 { 102 return administrativeRoles.contains( AdministrativeRole.SubSchemaSpecificArea ); 103 } 104 105 106 /** 107 * Tells if the type contains the Access Control Administrative Role 108 * 109 * @return <tt>true</tt> if the type contains the Access Control Administrative Role, <tt>false</tt> otherwise 110 */ 111 public final boolean isAccessControlAdminRole() 112 { 113 return administrativeRoles.contains( AdministrativeRole.AccessControlSpecificArea ) 114 || administrativeRoles.contains( AdministrativeRole.AccessControlInnerArea ); 115 } 116 117 118 /** 119 * Tells if the type contains the Triggers Administrative Role 120 * 121 * @return <tt>true</tt> if the type contains the Triggers Administrative Role, <tt>false</tt> otherwise 122 */ 123 public final boolean isTriggersAdminRole() 124 { 125 return administrativeRoles.contains( AdministrativeRole.TriggerExecutionSpecificArea ) 126 || administrativeRoles.contains( AdministrativeRole.TriggerExecutionInnerArea ); 127 } 128 129 130 /** 131 * @see Object#toString() 132 */ 133 @Override 134 public String toString() 135 { 136 return "Subentry[" + administrativeRoles + ", " + ss + "]"; 137 } 138}