/*
* 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-2009 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* An abstract managed object implementation.
*
* @param <T>
* The type of client configuration represented by the client
* managed object.
*/
implements ManagedObject<T> {
/**
* Creates any default managed objects associated with a relation
* definition.
*/
private final class DefaultManagedObjectFactory implements
/** Possible exceptions. */
/** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
ManagedObjectDefinition<? extends C, ? extends S> d = dmo
ManagedObject<? extends C> child;
try {
} catch (IllegalManagedObjectNameException e) {
// This should not happen.
throw new RuntimeException(e);
}
}
return null;
}
/** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
ManagedObjectDefinition<? extends C, ? extends S> d = dmo
}
return null;
}
/** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
// Do nothing - not possible to create singletons
// dynamically.
return null;
}
/** {@inheritDoc} */
public <C extends ConfigurationClient, S extends Configuration>
ManagedObjectDefinition<? extends C, ? extends S> d = dmo
}
return null;
}
/** Create the child managed object. */
}
try {
} catch (AuthorizationException e) {
ae = e;
} catch (ManagedObjectAlreadyExistsException e) {
moaee = e;
} catch (MissingMandatoryPropertiesException e) {
mmpe = e;
} catch (ConcurrentModificationException e) {
cme = e;
} catch (OperationRejectedException e) {
ore = e;
} catch (CommunicationException e) {
ce = e;
}
}
/**
* Creates the default managed objects associated with the
* provided relation definition.
*
* @param rd
* The relation definition.
*/
throw ae;
throw ce;
throw cme;
throw mmpe;
throw moaee;
throw ore;
}
}
/** Set property values. */
}
}
/** The managed object definition associated with this managed object. */
/**
* Indicates whether or not this managed object exists on the server
* (false means the managed object is new and has not been committed).
*/
private boolean existsOnServer;
/** Optional naming property definition. */
/** The path associated with this managed object. */
/** The managed object's properties. */
/**
* Creates a new abstract managed object.
*
* @param d
* The managed object's definition.
* @param path
* The managed object's path.
* @param properties
* The managed object's properties.
* @param existsOnServer
* Indicates whether or not the managed object exists on
* the server (false means the managed object is new and
* has not been committed).
* @param namingPropertyDefinition
* Optional naming property definition.
*/
protected AbstractManagedObject(
ManagedObjectDefinition<T, ? extends Configuration> d,
this.definition = d;
this.properties = properties;
this.existsOnServer = existsOnServer;
}
/** {@inheritDoc} */
// First make sure all mandatory properties are defined.
&& p.getEffectiveValues().isEmpty()) {
}
}
if (!exceptions.isEmpty()) {
}
// Now enforce any constraints.
boolean isAcceptable = true;
if (existsOnServer) {
isAcceptable = false;
}
} else {
isAcceptable = false;
}
}
}
if (!isAcceptable) {
break;
}
}
if (!isAcceptable) {
if (existsOnServer) {
.getUserFriendlyName(), messages);
} else {
.getUserFriendlyName(), messages);
}
}
// Commit the managed object.
if (existsOnServer) {
} else {
}
// Make all pending property values active.
properties.commit();
// If the managed object was created make sure that any default
// subordinate managed objects are also created.
if (!existsOnServer) {
for (RelationDefinition<?, ?> rd :
}
existsOnServer = true;
}
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration,
CC extends C>
InstantiableRelationDefinition<C, S> r,
// Empty names are not allowed.
throw new IllegalManagedObjectNameException(name);
}
// If the relation uses a naming property definition then it must
// be a valid value.
try {
} catch (PropertyException e) {
}
}
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient,
S extends Configuration, CC extends C>
OptionalRelationDefinition<C, S> r,
ManagedObjectDefinition<CC, ? extends S> d,
throws IllegalArgumentException {
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration,
CC extends C>
SetRelationDefinition<C, S> r,
ManagedObjectDefinition<CC, ? extends S> d,
throws IllegalArgumentException {
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
OptionalRelationDefinition<C, S> r) throws IllegalArgumentException,
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
SingletonRelationDefinition<C, S> r) throws IllegalArgumentException,
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
AbstractManagedObjectDefinition<C, S> d = r.getChildDefinition();
AbstractManagedObjectDefinition<? extends C, ? extends S> cd;
try
{
}
catch (IllegalArgumentException e)
{
// Unrecognized definition name - report this as a decoding
// exception.
throw new DefinitionDecodingException(d,
}
}
/** {@inheritDoc} */
public final T getConfiguration() {
return definition.createClientConfiguration(this);
}
/** {@inheritDoc} */
public final ManagedObjectDefinition<T, ? extends Configuration>
return definition;
}
/** {@inheritDoc} */
public final ManagedObjectPath<T, ? extends Configuration>
return path;
}
/** {@inheritDoc} */
}
/** {@inheritDoc} */
throws IllegalArgumentException {
}
return null;
}
/** {@inheritDoc} */
throws IllegalArgumentException {
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
boolean hasChild(
OptionalRelationDefinition<C, S> r) throws IllegalArgumentException,
try {
} catch (ManagedObjectNotFoundException e) {
throw new ConcurrentModificationException();
}
}
/** {@inheritDoc} */
throws IllegalArgumentException {
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
InstantiableRelationDefinition<C, S> r) throws IllegalArgumentException,
return listChildren(r, r.getChildDefinition());
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
InstantiableRelationDefinition<C, S> r,
AbstractManagedObjectDefinition<? extends C, ? extends S> d)
try {
} catch (ManagedObjectNotFoundException e) {
throw new ConcurrentModificationException();
}
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
SetRelationDefinition<C, S> r) throws IllegalArgumentException,
return listChildren(r, r.getChildDefinition());
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
SetRelationDefinition<C, S> r,
AbstractManagedObjectDefinition<? extends C, ? extends S> d)
try {
} catch (ManagedObjectNotFoundException e) {
throw new ConcurrentModificationException();
}
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
void removeChild(
boolean found;
try {
} catch (ManagedObjectNotFoundException e) {
throw new ConcurrentModificationException();
}
if (!found) {
throw new ManagedObjectNotFoundException();
}
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
void removeChild(
OptionalRelationDefinition<C, S> r) throws IllegalArgumentException,
boolean found;
try {
} catch (ManagedObjectNotFoundException e) {
throw new ConcurrentModificationException();
}
if (!found) {
throw new ManagedObjectNotFoundException();
}
}
/** {@inheritDoc} */
public final <C extends ConfigurationClient, S extends Configuration>
void removeChild(
boolean found;
try {
} catch (ManagedObjectNotFoundException e) {
throw new ConcurrentModificationException();
}
if (!found) {
throw new ManagedObjectNotFoundException();
}
}
/** {@inheritDoc} */
throws PropertyException, PropertyException,
} else {
}
}
/** {@inheritDoc} */
}
}
// If this is a naming property then update the name.
// The property must be single-valued and mandatory.
}
}
/** {@inheritDoc} */
}
}
/**
* Adds this new managed object.
*
* @throws ManagedObjectAlreadyExistsException
* If the managed object cannot be added to the server
* because it already exists.
* @throws ConcurrentModificationException
* If the managed object's parent has been removed by
* another client.
* @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.
*/
/**
* Gets the management context driver associated with this managed
* object.
*
* @return Returns the management context driver associated with
* this managed object.
*/
/**
* Gets the naming property definition associated with this managed
* object.
*
* @return Returns the naming property definition associated with
* this managed object, or <code>null</code> if this
* managed object does not have a naming property.
*/
return namingPropertyDefinition;
}
/**
* Gets the property associated with the specified property
* definition.
*
* @param
* The underlying type of the property.
* @param pd
* The Property definition.
* @return Returns the property associated with the specified
* property definition.
* @throws IllegalArgumentException
* If this property provider does not recognize the
* requested property definition.
*/
throws IllegalArgumentException {
}
/**
* Applies changes made to this managed object.
*
* @throws ConcurrentModificationException
* If this managed object has been removed from the server
* by another client.
* @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 modify 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.
*/
protected abstract void modifyExistingManagedObject()
/**
* Creates a new managed object.
*
* @param <M>
* The type of client configuration represented by the
* client managed object.
* @param d
* The managed object's definition.
* @param path
* The managed object's path.
* @param properties
* The managed object's properties.
* @param existsOnServer
* Indicates whether or not the managed object exists on
* the server (false means the managed object is new and
* has not been committed).
* @param namingPropertyDefinition
* Optional naming property definition.
* @return Returns the new managed object.
*/
protected abstract <M extends ConfigurationClient>
/**
* Creates a new managed object with no active values, just default
* values.
*/
ManagedObjectDefinition<M, ?> d, ManagedObjectPath<M, ?> p,
try {
} catch (PropertyException e) {
// Add the exception if requested.
if (exceptions != null) {
exceptions.add(e);
}
}
}
// Set the naming property if there is one.
if (namingPropertyDefinition != null) {
}
}
/** Create an empty property. */
throws PropertyException {
try {
} catch (PropertyException e) {
// Make sure that we have still created the property.
throw e;
}
}
/** Makes sure that this managed object exists. */
private void ensureThisManagedObjectExists()
try {
throw new ConcurrentModificationException();
}
} catch (ManagedObjectNotFoundException e) {
throw new ConcurrentModificationException();
}
}
}
/** Validate that a relation definition belongs to this managed object. */
throws IllegalArgumentException {
ManagedObjectDefinition<T, ?> d = getManagedObjectDefinition();
+ " is not associated with a " + d.getName());
}
}
}