001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2008-2010 Sun Microsystems, Inc.
015 * Portions Copyright 2015 ForgeRock AS.
016 */
017
018package org.opends.guitools.controlpanel.ui.nodes;
019
020import javax.swing.tree.TreePath;
021
022import org.opends.server.types.LDAPURL;
023
024/**
025 * Interface used in the LDAP entries browser code to deal with entries.
026 *
027 */
028public interface BrowserNodeInfo {
029
030  /**
031   * URL of the displayed entry.
032   * @return the URL of the displayed entry.
033   */
034  LDAPURL getURL();
035
036
037  /**
038   * Returns  <CODE>true</CODE> if the displayed entry is the top entry of a
039   * suffix and <CODE>false</CODE> otherwise.
040   * @return <CODE>true</CODE> if the displayed entry is the top entry of a
041   * suffix and <CODE>false</CODE> otherwise.
042   */
043  boolean isSuffix();
044
045
046  /**
047   * Returns <CODE>true</CODE> if the displayed entry is the root node of the
048   * server (the dn="" entry) and <CODE>false</CODE> otherwise.
049   * @return <CODE>true</CODE> if the displayed entry is the root node of the
050   * server (the dn="" entry) and <CODE>false</CODE> otherwise.
051   */
052  boolean isRootNode();
053
054  /**
055   * Returns <CODE>true</CODE> if the displayed entry is not located on the
056   * current server. An entry is declared 'remote' when the host/port of
057   * getURL() is different from the host/port of the DirContext associated to
058   * the browser controller. Returns <CODE>false</CODE> otherwise.
059   * @return <CODE>true</CODE> if the displayed entry is not located on the
060   * current server. An entry is declared 'remote' when the host/port of
061   * getURL() is different from the host/port of the DirContext associated to
062   * the browser controller. Returns <CODE>false</CODE> otherwise.
063   *
064   */
065  boolean isRemote();
066
067
068  /**
069   * Returns the value of numsubordinates for the entry.
070   * -1 if the numsubordinates attribute is not defined.
071   * @return the value of numsubordinates for the entry.
072   */
073  int getNumSubOrdinates();
074
075
076  /**
077   * Returns the value of hassubordinates for the entry.
078   * @return the value of hassubordinates for the entry.
079   */
080  boolean hasSubOrdinates();
081
082  /**
083   * Returns the referrals attached to the displayed entry.
084   * This is the value of the 'ref' attribute.
085   * Returns <CODE>null</CODE> if the attribute is not present.
086   * @return the referrals attached to the displayed entry.
087   */
088  String[] getReferral();
089
090
091  /**
092   * Returns the error detected while reading this entry.
093   * @return the error detected while reading this entry.
094   */
095  int getErrorType();
096
097
098  /**
099   * Returns the exception associated to the error.
100   * Returns <CODE>null</CODE> if getErrorType() == ERROR_NONE.
101   * @return the exception associated to the error.
102   */
103  Exception getErrorException();
104
105
106  /**
107   * Returns the argument associated to an error/exception.
108   * Always null except when errorType == ERROR_SOLVING_REFERRAL,
109   * errorArg contains the String representing the faulty LDAP URL.
110   * @return the argument associated to an error/exception.
111   */
112  Object getErrorArg();
113
114  /**
115   * Returns the basic node associated with the node info.
116   * @return the basic node associated with the node info.
117   */
118  BasicNode getNode();
119
120
121  /**
122   * Returns the TreePath corresponding to the displayed entry.
123   * @return the TreePath corresponding to the displayed entry.
124   */
125  TreePath getTreePath();
126
127
128  /**
129   * Tells whether the node passed as parameter represents the same node as this
130   * one.
131   * @param node the node.
132   * @return <CODE>true</CODE> if the node passed as parameter represents the
133   * same node as this one and <CODE>false</CODE> otherwise.
134   */
135  boolean representsSameNode(BrowserNodeInfo node);
136
137  /**
138   * Returns the object class value of the entry that the nodes represents.
139   * @return the object class value of the entry that the nodes represents.
140   */
141  String[] getObjectClassValues();
142
143  /**
144   * Error types
145   */
146  /** No error happened. */
147  int ERROR_NONE          = 0;
148  /** And error reading the entry occurred. */
149  int ERROR_READING_ENTRY     = 1;
150  /** An error following referrals occurred. */
151  int ERROR_SOLVING_REFERRAL    = 2;
152  /** An error occurred searching the children of the entry. */
153  int ERROR_SEARCHING_CHILDREN  = 3;
154
155}