| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.guitools.controlpanel.browser.BrowserController; |
| | | import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; |
| | | import org.opends.guitools.controlpanel.task.NewEntryTask; |
| | |
| | | import org.opends.guitools.controlpanel.ui.nodes.BasicNode; |
| | | import org.opends.guitools.controlpanel.util.BackgroundTask; |
| | | import org.opends.guitools.controlpanel.util.Utilities; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.util.LDIFException; |
| | |
| | | /** |
| | | * Abstract class used to re-factor some code among the different panels that |
| | | * are used to create a new entry. |
| | | * |
| | | */ |
| | | public abstract class AbstractNewEntryPanel extends StatusGenericPanel |
| | | { |
| | | private static final long serialVersionUID = 6894546787832469213L; |
| | | |
| | | /** |
| | | * The parent node that was selected when the user clicked on the new entry |
| | | * action. |
| | | */ |
| | | /** The parent node that was selected when the user clicked on the new entry action. */ |
| | | protected BasicNode parentNode; |
| | | |
| | | /** |
| | | * The browser controller. |
| | | */ |
| | | /** The browser controller. */ |
| | | protected BrowserController controller; |
| | | |
| | | /** |
| | |
| | | */ |
| | | protected Entry getEntry() throws LDIFException, IOException |
| | | { |
| | | Entry entry; |
| | | LDIFImportConfig ldifImportConfig = null; |
| | | try |
| | | { |
| | | String ldif = getLDIF(); |
| | | |
| | | if (ldif.trim().length() == 0) |
| | | { |
| | | throw new LDIFException(ERR_LDIF_REPRESENTATION_REQUIRED.get()); |
| | |
| | | |
| | | ldifImportConfig = new LDIFImportConfig(new StringReader(ldif)); |
| | | LDIFReader reader = new LDIFReader(ldifImportConfig); |
| | | entry = reader.readEntry(checkSchema()); |
| | | Entry entry = reader.readEntry(checkSchema()); |
| | | if (entry == null) |
| | | { |
| | | throw new LDIFException(ERR_LDIF_REPRESENTATION_REQUIRED.get()); |
| | | } |
| | | else |
| | | if (entry.getObjectClasses().isEmpty()) |
| | | { |
| | | if (entry.getObjectClasses().size() == 0) |
| | | { |
| | | throw new LDIFException(ERR_OBJECTCLASS_FOR_ENTRY_REQUIRED.get()); |
| | | } |
| | | throw new LDIFException(ERR_OBJECTCLASS_FOR_ENTRY_REQUIRED.get()); |
| | | } |
| | | return entry; |
| | | } |
| | | finally |
| | | { |
| | |
| | | ldifImportConfig.close(); |
| | | } |
| | | } |
| | | return entry; |
| | | } |
| | | |
| | | /** |