| | |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.SingletonRelationDefinition; |
| | | import org.opends.server.admin.DefinitionDecodingException.Reason; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.opends.server.admin.client.ClientConstraintHandler; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | | import org.opends.server.admin.client.IllegalManagedObjectNameException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | |
| | | private final class DefaultManagedObjectFactory implements RelationDefinitionVisitor<Void, Void> { |
| | | |
| | | // Possible exceptions. |
| | | private AuthorizationException ae = null; |
| | | |
| | | private ManagedObjectAlreadyExistsException moaee = null; |
| | | |
| | | private MissingMandatoryPropertiesException mmpe = null; |
| | |
| | | |
| | | private OperationRejectedException ore = null; |
| | | |
| | | private CommunicationException ce = null; |
| | | private ErrorResultException ere = null; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | |
| | | |
| | | try { |
| | | child.commit(); |
| | | } catch (AuthorizationException e) { |
| | | ae = e; |
| | | } catch (ManagedObjectAlreadyExistsException e) { |
| | | moaee = e; |
| | | } catch (MissingMandatoryPropertiesException e) { |
| | |
| | | cme = e; |
| | | } catch (OperationRejectedException e) { |
| | | ore = e; |
| | | } catch (CommunicationException e) { |
| | | ce = e; |
| | | } catch (ErrorResultException e) { |
| | | ere = e; |
| | | } |
| | | } |
| | | |
| | |
| | | * @param rd |
| | | * The relation definition. |
| | | */ |
| | | private void createDefaultManagedObjects(RelationDefinition<?, ?> rd) throws AuthorizationException, |
| | | CommunicationException, ConcurrentModificationException, MissingMandatoryPropertiesException, |
| | | private void createDefaultManagedObjects(RelationDefinition<?, ?> rd) throws ErrorResultException, |
| | | ConcurrentModificationException, MissingMandatoryPropertiesException, |
| | | ManagedObjectAlreadyExistsException, OperationRejectedException { |
| | | rd.accept(this, null); |
| | | |
| | | if (ae != null) { |
| | | throw ae; |
| | | } else if (ce != null) { |
| | | throw ce; |
| | | if (ere != null) { |
| | | throw ere; |
| | | } else if (cme != null) { |
| | | throw cme; |
| | | } else if (mmpe != null) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public final void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, AuthorizationException, CommunicationException { |
| | | ConcurrentModificationException, OperationRejectedException, ErrorResultException { |
| | | // First make sure all mandatory properties are defined. |
| | | List<PropertyIsMandatoryException> exceptions = new LinkedList<PropertyIsMandatoryException>(); |
| | | |
| | |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) throws IllegalArgumentException, |
| | | DefinitionDecodingException, ManagedObjectDecodingException, ManagedObjectNotFoundException, |
| | | ConcurrentModificationException, AuthorizationException, CommunicationException { |
| | | ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | ensureThisManagedObjectExists(); |
| | | Driver ctx = getDriver(); |
| | |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | AuthorizationException, CommunicationException { |
| | | ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | ensureThisManagedObjectExists(); |
| | | Driver ctx = getDriver(); |
| | |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SingletonRelationDefinition<C, S> r) throws IllegalArgumentException, DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | AuthorizationException, CommunicationException { |
| | | ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | ensureThisManagedObjectExists(); |
| | | Driver ctx = getDriver(); |
| | |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SetRelationDefinition<C, S> r, String name) throws IllegalArgumentException, DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | AuthorizationException, CommunicationException { |
| | | ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | ensureThisManagedObjectExists(); |
| | | Driver ctx = getDriver(); |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean hasChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, ConcurrentModificationException, |
| | | AuthorizationException, CommunicationException { |
| | | ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | try { |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r) throws IllegalArgumentException, ConcurrentModificationException, |
| | | AuthorizationException, CommunicationException { |
| | | ErrorResultException { |
| | | return listChildren(r, r.getChildDefinition()); |
| | | } |
| | | |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r, AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | | throws IllegalArgumentException, ConcurrentModificationException, AuthorizationException, |
| | | CommunicationException { |
| | | throws IllegalArgumentException, ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | try { |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | SetRelationDefinition<C, S> r) throws IllegalArgumentException, ConcurrentModificationException, |
| | | AuthorizationException, CommunicationException { |
| | | ErrorResultException { |
| | | return listChildren(r, r.getChildDefinition()); |
| | | } |
| | | |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | SetRelationDefinition<C, S> r, AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | | throws IllegalArgumentException, ConcurrentModificationException, AuthorizationException, |
| | | CommunicationException { |
| | | throws IllegalArgumentException, ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | try { |
| | |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) throws IllegalArgumentException, |
| | | ManagedObjectNotFoundException, OperationRejectedException, ConcurrentModificationException, |
| | | AuthorizationException, CommunicationException { |
| | | ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | boolean found; |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, ManagedObjectNotFoundException, |
| | | OperationRejectedException, ConcurrentModificationException, AuthorizationException, CommunicationException { |
| | | OperationRejectedException, ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | boolean found; |
| | |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | SetRelationDefinition<C, S> r, String name) throws IllegalArgumentException, |
| | | ManagedObjectNotFoundException, OperationRejectedException, ConcurrentModificationException, |
| | | AuthorizationException, CommunicationException { |
| | | ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | boolean found; |
| | |
| | | * @throws OperationRejectedException |
| | | * If the managed object cannot be added due to some client-side |
| | | * or server-side constraint which cannot be satisfied. |
| | | * @throws AuthorizationException |
| | | * If the server refuses to add this managed object because the |
| | | * client does not have the correct privileges. |
| | | * @throws CommunicationException |
| | | * If the client cannot contact the server due to an underlying |
| | | * communication problem. |
| | | * @throws ErrorResultException |
| | | * If any other error occurs. |
| | | */ |
| | | protected abstract void addNewManagedObject() throws AuthorizationException, CommunicationException, |
| | | protected abstract void addNewManagedObject() throws ErrorResultException, |
| | | OperationRejectedException, ConcurrentModificationException, ManagedObjectAlreadyExistsException; |
| | | |
| | | /** |
| | |
| | | * communication problem. |
| | | */ |
| | | protected abstract void modifyExistingManagedObject() throws ConcurrentModificationException, |
| | | OperationRejectedException, AuthorizationException, CommunicationException; |
| | | OperationRejectedException, ErrorResultException; |
| | | |
| | | /** |
| | | * Creates a new managed object. |
| | |
| | | } |
| | | |
| | | // Makes sure that this managed object exists. |
| | | private void ensureThisManagedObjectExists() throws ConcurrentModificationException, CommunicationException, |
| | | AuthorizationException { |
| | | private void ensureThisManagedObjectExists() throws ConcurrentModificationException, ErrorResultException { |
| | | if (!path.isEmpty()) { |
| | | Driver ctx = getDriver(); |
| | | |