/*
* 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 copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
/**
* A generic token store that can read an write a java bean, {@code T}, that has annotations to support conversion
* to and from a Token.
* @param <T> The object type being stored.
*/
public class TokenDataStore<T> {
/**
* Create a new TokenDataStore. This could be called from an extension class, or constructed as a raw store.
* @param adapter The Java bean token adapter for the type of bean being stored as tokens.
* @param taskExecutor The data layer task executor, for executing operations on the data store. Should be a
* {@link org.forgerock.openam.sm.datalayer.impl.SimpleTaskExecutor}.
* @param taskFactory The task factory for creating data store operations.
*/
public TokenDataStore(JavaBeanAdapter<T> adapter, TaskExecutor taskExecutor, TaskFactory taskFactory) {
InjectorHolder.getInstance(Key.get(Debug.class, Names.named(DataLayerConstants.DATA_LAYER_DEBUG))));
}
TokenDataStore(JavaBeanAdapter<T> adapter, TaskExecutor taskExecutor, TaskFactory taskFactory, Debug debug) {
this.taskExecutor = taskExecutor;
this.taskFactory = taskFactory;
}
/**
* Create an object. The id field will be populated with the resulting identifier.
*
* @param obj The object being created.
* @throws ServerException When an error occurs during creation.
*/
try {
} catch (ServerException e) {
throw e;
} catch (DataLayerException e) {
if (debug.warningEnabled()) {
}
}
}
/**
* Reads a {@code T} out of the store using its OpenAM Unique ID.
*
* @param id The OpenAM Unique ID assigned to the object.
* @return The object, T.
* @throws NotFoundException If the object is not found.
* @throws ServerException When the object cannot be loaded.
*/
try {
throw new NotFoundException("Object not found");
}
}
} catch (NotFoundException e) {
throw e;
} catch (ServerException e) {
throw e;
} catch (DataLayerException e) {
if (debug.warningEnabled()) {
}
}
}
/**
* Update a given instance.
*
* @param obj The object being updated.
* @throws ServerException When the object cannot be found, or an error occurs during update.
*/
try {
// Check it exists
// Update it
} catch (ServerException e) {
throw e;
} catch (NotFoundException e) {
throw e;
} catch (DataLayerException e) {
if (debug.warningEnabled()) {
}
}
}
/**
* Remove an object with the given ID from the store.
*
* @param id The identifier of the object being removed.
* @throws ServerException When an error occurs during removal.
*/
try {
} catch (ServerException e) {
throw e;
} catch (DataLayerException e) {
if (debug.warningEnabled()) {
}
}
}
/**
* Query the store for instances.
*
* @param query The criteria of the query, using {@code T} bean property names as fields.
* @return A set of all matching objects.
* @throws ServerException When an error occurs when querying the store.
*/
try {
} catch (ServerException e) {
throw e;
} catch (DataLayerException e) {
if (debug.warningEnabled()) {
}
}
}
/**
* Internal conversion function to handle the query result.
*
* @param tokens A non null, but possibly empty collection of tokens.
* @return A set of {@code T} objects expected by the caller.
*/
}
return results;
}
/**
* Different ways to combine criteria in a filter.
*
* @since 13.0.0
*/
public static enum FilterType {
}
/**
* Because we're using the SimpleTaskExecutor, we can expect all tasks to have been completed before returning
* for the task executor.
* @param <R>
*/
private boolean processed = false;
private R result;
if (!processed) {
throw new IllegalStateException("Synchronous result handler hasn't been processed");
}
throw error;
}
return result;
}
processed = true;
}
processed = true;
}
}
}