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     *
065     * TODO setAdministrativeRoles.
066     *
067     * @param administrativeRoles
068     */
069    public final void setAdministrativeRoles( Set<AdministrativeRole> administrativeRoles )
070    {
071        this.administrativeRoles = administrativeRoles;
072    }
073
074
075    public final Set<AdministrativeRole> getAdministrativeRoles()
076    {
077        return administrativeRoles;
078    }
079
080
081    /**
082     * Tells if the type contains the Collective attribute Administrative Role
083     */
084    public final boolean isCollectiveAdminRole()
085    {
086        return administrativeRoles.contains( AdministrativeRole.CollectiveAttributeInnerArea ) ||
087            administrativeRoles.contains( AdministrativeRole.CollectiveAttributeSpecificArea );
088    }
089
090
091    /**
092     * Tells if the type contains the SubSchema Administrative Role
093     */
094    public final boolean isSchemaAdminRole()
095    {
096        return administrativeRoles.contains( AdministrativeRole.SubSchemaSpecificArea );
097    }
098
099
100    /**
101     * Tells if the type contains the Access Control Administrative Role
102     */
103    public final boolean isAccessControlAdminRole()
104    {
105        return administrativeRoles.contains( AdministrativeRole.AccessControlSpecificArea ) ||
106            administrativeRoles.contains( AdministrativeRole.AccessControlInnerArea );
107    }
108
109
110    /**
111     * Tells if the type contains the Triggers Administrative Role
112     */
113    public final boolean isTriggersAdminRole()
114    {
115        return administrativeRoles.contains( AdministrativeRole.TriggerExecutionSpecificArea ) ||
116            administrativeRoles.contains( AdministrativeRole.TriggerExecutionInnerArea );
117    }
118
119
120    /**
121     * @see Object#toString()
122     */
123    public String toString()
124    {
125        return "Subentry[" + administrativeRoles + ", " + ss + "]";
126    }
127}