ViewEntryPanel.java revision 998747bfaaa3c6b28bbfaf0e282e6c0ccbf46bc0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* Abstract class containing code shared by the different LDAP entry view
* panels (Simplified View, Attribute View and LDIF View).
*
*/
public abstract class ViewEntryPanel extends StatusGenericPanel
{
private static final long serialVersionUID = -1908757626234678L;
/**
* The read-only attributes as they appear on the schema.
*/
/**
* The read-only attributes in lower case.
*/
/**
* The editable operational attributes.
*/
/**
* Whether the entry change events should be ignored or not.
*/
protected boolean ignoreEntryChangeEvents;
/**
* Static boolean used to know whether only attributes with values should be
* displayed or not.
*/
protected static boolean displayOnlyWithAttrs = true;
/**
* {@inheritDoc}
*/
public void okClicked()
{
// No ok button
}
/**
* Returns an Entry object representing what the panel is displaying.
* @return an Entry object representing what the panel is displaying.
* @throws OpenDsException if the entry cannot be generated (in particular if
* the user provided invalid data).
*/
/**
* Updates the contents of the panel.
* @param sr the search result to be used to update the panel.
* @param isReadOnly whether the entry is read-only or not.
* @param path the tree path associated with the entry in the tree.
*/
/**
* Adds a title panel to the container.
* @param c the container where the title panel must be added.
* @param gbc the grid bag constraints to be used.
*/
{
}
/**
* Whether the schema must be checked or not.
* @return <CODE>true</CODE> if the server is configured to check schema and
* <CODE>false</CODE> otherwise.
*/
protected boolean checkSchema()
{
}
/**
* Adds an LDAP entry change listener.
* @param listener the listener.
*/
{
}
/**
* Removes an LDAP entry change listener.
* @param listener the listener.
*/
{
}
/**
* {@inheritDoc}
*/
public boolean requiresBorder()
{
return true;
}
/**
* Returns the DN of the entry that the user is editing (it might differ
* from the DN of the entry in the tree if the user modified the DN).
* @return the DN of the entry that the user is editing.
*/
protected abstract String getDisplayedDN();
/**
* Notifies the entry changed listeners that the entry changed.
*
*/
protected void notifyListeners()
{
{
return;
}
// TODO: With big entries this is pretty slow. Until there is a fix, try
// simply to update the dn
{
}
/*
Entry entry;
try
{
entry = getEntry();
String dn = entry.getDN().toString();
if (!dn.equals(title.getText()))
{
title.setText(dn);
}
}
catch (OpenDsException de)
{
entry = null;
}
catch (Throwable t)
{
entry = null;
logger.warn(LocalizableMessage.raw("Unexpected error: "+t, t));
}
*/
{
}
}
/**
* Updates the title panel with the provided entry.
* @param sr the search result.
* @param path the path to the node of the entry selected in the tree. Used
* to display the same icon as in the tree.
*/
{
{
}
{
}
{
}
else
{
}
{
{
}
{
{
}
}
}
else
{
}
}
/**
* Returns an object class value representing all the object class values of
* the entry.
* @param ocValues the list of object class values.
* @param schema the schema.
* @return an object class value representing all the object class values of
* the entry.
*/
{
{
if (objectClass != null)
{
{
if (structuralObjectClass == null)
{
}
else
{
{
}
}
}
else
{
{
}
}
}
}
}
/**
* Adds the values in the RDN to the entry definition.
* @param entry the entry to be updated.
*/
{
// Add the values in the RDN if they are not there
{
boolean done = false;
{
{
{
{
}
done = true;
break;
}
}
}
if (!done)
{
}
}
}
/**
* {@inheritDoc}
*/
public LocalizableMessage getTitle()
{
return INFO_CTRL_PANEL_EDIT_LDAP_ENTRY_TITLE.get();
}
/**
* {@inheritDoc}
*/
{
{
{
if (attr.isNoUserModification())
{
}
else if (attr.isOperational())
{
}
}
}
}
/**
* Appends the LDIF lines corresponding to the different values of an
* attribute to the provided StringBuilder.
* @param sb the StringBuilder that must be updated.
* @param attrName the attribute name.
* @param values the attribute values.
*/
{
{
}
}
/**
* Appends the LDIF line corresponding to the value of an
* attribute to the provided StringBuilder.
* @param sb the StringBuilder that must be updated.
* @param attrName the attribute name.
* @param value the attribute value.
*/
{
if (value instanceof ObjectClassValue)
{
{
{
{
{
}
}
}
}
{
}
}
else if (value instanceof byte[])
{
{
}
}
else if (value instanceof BinaryValue)
{
}
{
}
}
/**
* Returns <CODE>true</CODE> if the provided attribute name has binary syntax
* and <CODE>false</CODE> otherwise.
* @param attrName the attribute name.
* @return <CODE>true</CODE> if the provided attribute name has binary syntax
* and <CODE>false</CODE> otherwise.
*/
{
}
/**
* Returns <CODE>true</CODE> if the provided attribute name has password
* syntax and <CODE>false</CODE> otherwise.
* @param attrName the attribute name.
* @return <CODE>true</CODE> if the provided attribute name has password
* syntax and <CODE>false</CODE> otherwise.
*/
{
}
/**
* Returns <CODE>true</CODE> if the provided attribute name has certificate
* syntax and <CODE>false</CODE> otherwise.
* @param attrName the attribute name.
* @param schema the schema.
* @return <CODE>true</CODE> if the provided attribute name has certificate
* syntax and <CODE>false</CODE> otherwise.
*/
{
boolean isCertificate = false;
// Check all the attributes that we consider binaries.
{
{
{
}
}
}
return isCertificate;
}
/**
* Gets the values associated with a given attribute. The values are the
* ones displayed in the panel.
* @param attrName the attribute name.
* @return the values associated with a given attribute.
*/
/**
* Sets the values displayed in the panel for a given attribute in the
* provided search result.
* @param sr the search result to be updated.
* @param attrName the attribute name.
*/
{
{
if (value instanceof ObjectClassValue)
{
{
}
}
else if (value instanceof byte[])
{
}
else if (value instanceof BinaryValue)
{
try
{
}
catch (ParseException pe)
{
}
}
else
{
{
}
}
}
{
}
}
/**
* Returns <CODE>true</CODE> if the provided attribute name is an editable
* attribute and <CODE>false</CODE> otherwise.
* @param attrName the attribute name.
* @param schema the schema.
* @return <CODE>true</CODE> if the provided attribute name is an editable
* attribute and <CODE>false</CODE> otherwise.
*/
{
boolean isEditable = false;
{
{
}
}
return isEditable;
}
/**
* Returns the list of superior object classes (to top) for a given object
* class.
* @param oc the object class.
* @return the set of superior object classes for a given object classes.
*/
{
{
{
}
}
return names;
}
}