ReconciliationService.java revision adb077e59a0318a46a2079cccd8fd4a05841130c
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2012-2013 ForgeRock AS. All Rights Reserved
*
* 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
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* 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]"
*
*/
/**
* Reconciliation service implementation
*
* @author aegloff
*/
@Component(name = ReconciliationService.PID, immediate = true, policy = ConfigurationPolicy.OPTIONAL)
@Service()
@Properties({
})
public class ReconciliationService
implements RequestHandler, Reconcile {
public enum ReconAction {
/**
* Convenience helper that checks if a given string
* is contained in this enum
* @param action the stringified action to check
* @return true if it is contained in this enum, false if not
*/
try {
return true;
} catch (IllegalArgumentException ex) {
return false;
}
}
};
)
/**
* The thread pool for executing full reconciliation runs.
*/
/**
* Map from reconciliation ID to the run itself
* In historical start order, oldest first.
*/
/**
* The approximate max number of runs in COMPLETED state to keep in the recon runs list
*/
private int maxCompletedRuns;
/**
* Get the the list of all reconciliations, or details of one specific recon instance
*
* {@inheritDoc}
*/
public void handleRead(ServerContext context, ReadRequest request, ResultHandler<Resource> handler) {
try {
}
} else {
// First try and get it from in memory
handler.handleResult(new Resource(localId, null, new JsonValue(reconRuns.get(localId).getSummary())));
} else {
// Next, if not in memory, try and get it from audit log
null,
}
}
}
} catch (Throwable t) {
}
}
/**
* {@inheritDoc}
*/
public void handleCreate(ServerContext context, CreateRequest request, ResultHandler<Resource> handler) {
}
/**
* {@inheritDoc}
*/
public void handleDelete(ServerContext context, DeleteRequest request, ResultHandler<Resource> handler) {
}
/**
* {@inheritDoc}
*/
public void handlePatch(ServerContext context, PatchRequest request, ResultHandler<Resource> handler) {
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
public void handleUpdate(ServerContext context, UpdateRequest request, ResultHandler<Resource> handler) {
}
public void handleAction(ServerContext context, ActionRequest request, ResultHandler<JsonValue> handler) {
try {
throw new BadRequestException("Action parameter is not present or value is null");
}
// operation on collection
try {
} else {
}
} catch (SynchronizationException se) {
throw new ConflictException(se);
}
} else {
throw new BadRequestException("Action " + request.getAction() + " on reconciliation not supported " + request.getAdditionalActionParameters());
}
} else {
// operation on individual resource
}
} else {
throw new BadRequestException("Action " + request.getAction() + " on recon run " + id + " not supported " + request.getAdditionalActionParameters());
}
}
} catch (Throwable t) {
}
finally {
}
}
/**
* {@inheritDoc}
*/
public String reconcile(ReconAction reconAction, final JsonValue mapping, Boolean synchronous, JsonValue reconParams)
throws SynchronizationException {
} else {
public void run() {
try {
} catch (SynchronizationException ex) {
}
finally {
}
}
};
}
return reconContext.getReconId();
}
/**
* Allocates a new reconciliation run's context, including its identifier
* Separate from the actual execution so that the execution can happen asynchronously,
* whilst we hand back the identifier to the caller.
*
* @param reconAction the recon action
* @param mapping the mapping configuration
* @param reconParams
* @return a new reconciliation context
*/
private ReconciliationContext newReconContext(ReconAction reconAction, JsonValue mapping, JsonValue reconParams)
throws SynchronizationException {
throw new SynchronizationException("Unknown mapping type, no mappings configured");
}
// FIXME: Entire mapping configs defined in scheduled jobs?! Not a good idea! –PB
} else {
throw new SynchronizationException("Unknown mapping type");
}
try {
} catch (BadRequestException ex) {
throw new SynchronizationException("Failure in initializing reconciliation: "
}
return reconContext;
}
/**
* Start a full reconciliation run
*
* @param reconContext a new reconciliation context. Do not re-use these contexts for more than one call to reconcile.
* @throws SynchronizationException
*/
try {
} catch (SynchronizationException ex) {
if (reconContext.isCanceled()) {
} else {
}
throw ex;
} catch (RuntimeException ex) {
throw ex;
}
}
/**
* Add a reconciliation run to the cached list of reconcliation runs.
* May clean out old entries of completed reconciliation runs.
* @param reconContext the reconciliation run specific context
*/
// Clean out run history if needed
// Since it only checks for completed runs when a new run is started this
// only provides for approximate adherence to maxCompleteRuns
synchronized(reconRuns) {
int completedCount = 0;
// Since oldest runs are first in the list, inspect backwards
while (iter.hasPrevious()) {
if (completedCount > maxCompletedRuns) {
}
}
}
}
}
}
// TODO: replace with common utility to handle ID, this is temporary
}
if (lastSlashPos > -1) {
} else {
}
}
return localId;
}
// TODO: replace with common utility to handle ID, this is temporary
if (slashPos > -1) {
}
}
return type;
}
try {
// Until we have a recon service config, allow overrides via (unsupported) properties
} catch (RuntimeException ex) {
throw ex;
}
}
/* Currently rely on deactivate/activate to be called by DS if config changes instead
@Modified
void modified(ComponentContext compContext) {
logger.info("Configuration of service changed.");
deactivate(compContext);
activate(compContext);
}
*/
}
/**
* Accessor to router
* @return handle to router accessor
*/
return ObjectSetContext.get();
}
}