ManagedObjectSet.java revision 10a9be648c010204b8ba63b283aa177749227e11
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions Copyrighted [year] [name of copyright owner]".
*
* Copyright © 2011 ForgeRock AS. All rights reserved.
*/
// Java Standard Edition
// SLF4J
// OSGi Framework
// JSON Fluent library
// OpenIDM
/**
* Provides access to a set of managed objects of a given type.
*
* @author Paul C. Bryan
*/
class ManagedObjectSet implements ObjectSet {
/** TODO: Description. */
/** Name of the managed object type. */
/** The schema to use to validate the structure and content of the managed object. */
/** Script to execute when the creation of an object is being requested. */
/** Script to execute when the read of an object is being requested. */
/** Script to execute when the update of an object is being requested. */
/** Script to execute when the deletion of an object is being requested. */
/** Script to execute when a managed object requires validation. */
private Script onValidate;
/** Script to execute once an object is retrieved from the repository. */
private Script onRetrieve;
/** Script to execute when an object is about to be stored in the repository. */
/** Properties for which triggers are executed during object set operations. */
/** The managed objects service that instantiated this managed object set. */
private ManagedObjectService service;
/**
* Constructs a new managed object set.
*
* @param config configuration object to use to initialize managed object set.
* @throws JsonNodeException if the configuration is malformed.
*/
}
}
/**
* Generates a fully-qualified object identifier for the managed object.
*
* @param id the local managed object identifier to qualify.
* @return the fully-qualified managed object identifier.
*/
// TODO: consider moving this logic somewhere else
}
}
/**
* Generates a fully-qualified object identifier for the repository.
*
* @param id the local managed object identifier to qualify.
* @return the fully-qualified repository object identifier.
*/
}
/**
* Executes a script if it exists, populating an {@code "object"} property in the root
* scope.
*
* @param script the script to execute, or {@code null} to execute nothing.
* @param node the JSON node whose value is to be populated in the script scope.
* @throws ForbiddenException if the script throws an exception.
* @throws InternalServerErrorException if any other exception is encountered.
*/
private void execScript(Script script, JsonNode node) throws ForbiddenException, InternalServerErrorException {
try {
} catch (ScriptThrownException ste) {
} catch (ScriptException se) {
}
}
}
/**
* Executes all of the necessary trigger scripts when an object is retrieved from the
* repository.
*
* @param node the JSON node that was retrieved from the repository.
* @throws ForbiddenException if a validation trigger throws an exception.
* @throws InternalServerErrorException if any other exception occurs.
*/
}
// TODO: schema validation here (w. optimization), using on-the-fly decryption transformations
}
}
/**
* Executes all of the necessary trigger scripts when an object is to be stored in the
* repository.
*
* @param node the JSON node to be stored in the repository.
* @throws ForbiddenException if a validation trigger throws an exception.
* @throws InternalServerErrorException if any other exception occurs.
*/
}
// TODO: schema validation here (w. optimizations)
}
}
/**
* TODO: Description.
*
* @param object TODO.
* @return TODO.
* @throws InternalServerErrorException TODO.
*/
try {
return service.getCryptoService().decrypt(new JsonNode(object)); // makes a copy, which we can modify
} catch (JsonException je) {
throw new InternalServerErrorException(je);
}
}
}
}
ActivityLog.log(service.getRouter(), Action.CREATE, "", managedId(id), null, node.asMap(), Status.SUCCESS);
try {
}
} catch (SynchronizationException se) {
throw new InternalServerErrorException(se);
}
// workaround until JsonNode works its way into the ObjectSet API
}
throw new ForbiddenException("cannot read entire set");
}
ActivityLog.log(service.getRouter(), Action.READ, "", managedId(id), node.asMap(), null, Status.SUCCESS);
}
throw new ForbiddenException("cannot update entire set");
}
return; // object hasn't changed; do not update
}
try {
} catch (ScriptThrownException ste) {
} catch (ScriptException se) {
}
}
ActivityLog.log(service.getRouter(), Action.UPDATE, "", managedId(id), oldEncrypted, node.asMap(), Status.SUCCESS);
try {
}
} catch (SynchronizationException se) {
throw new InternalServerErrorException(se);
}
// workaround until JsonNode works its way into the ObjectSet API
}
throw new ForbiddenException("cannot delete entire set");
}
}
ActivityLog.log(service.getRouter(), Action.DELETE, "", managedId(id), encrypted, null, Status.SUCCESS);
try {
}
} catch (SynchronizationException se) {
throw new InternalServerErrorException(se);
}
}
throw new InternalServerErrorException("patch not yet implemented");
}
return result;
}
public Map<String, Object> action(String id, Map<String, Object> params) throws ObjectSetException {
throw new ForbiddenException("action not yet implemented");
}
/**
* Returns the name of the managed object set.
*/
return name;
}
}