TaskScannerService.java revision 406a7a7473c9d8bc85ec6cd5042f0ade70806aa5
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2012-2014 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]"
*/
@Component(name = "org.forgerock.openidm.taskscanner", policy = ConfigurationPolicy.IGNORE, immediate = true)
@Properties({
})
private int maxCompletedRuns;
/**
* Map from TaskScanID ID to the run itself
* In historical start order, oldest first.
*/
/** The Connection Factory */
protected ConnectionFactory connectionFactory;
private ScriptRegistry scriptRegistry;
}
/**
* Invoked by the Task Scanner whenever the task scanner is triggered by the scheduler
*/
public void execute(ServerContext context, Map<String, Object> contextMap) throws ExecutionException {
}
public void handleRead(ServerContext context, ReadRequest request, ResultHandler<Resource> handler) {
try {
}
} else {
}
}
} catch (Throwable t) {
}
}
// TODO maybe move this into TaskScannerContext?
return result;
}
public void handleAction(ServerContext context, ActionRequest request, ResultHandler<JsonValue> handler) {
try {
try {
try {
} catch (JsonProcessingException e) {
throw new InternalServerErrorException(e);
} catch (IOException e) {
throw new InternalServerErrorException(e);
}
} else {
}
} catch (ExecutionException e) {
throw new BadRequestException(e.getMessage(), e);
}
} else {
// operation on individual resource
}
if (foundRun.isCompleted()) {
} else {
}
} else {
throw new BadRequestException("Action '" + action + "' on Task '" + request.getResourceName() + "' not supported " + params);
}
}
} catch (Throwable t) {
}
}
/**
* Performs the "execute" action, executing a supplied configuration
*
* Expects a field "name" containing the name of some config object that can be found via
* a read on "config/" + name <br><br>
*
* <b><i>e.g.</b></i> "taskscan/sunset" => "config/taskscan/sunset" => "[openidm-directory]/conf/taskscan-sunset.json"<br>
*
* @param id the id to perform the action on
* @param params field contaning the parameters of execution
* @return the set of parameters supplied
* @throws ExecutionException
* @throws JsonProcessingException
* @throws IOException
*/
try {
config = connectionFactory.getConnection().read(context, Requests.newReadRequest("config/" + name)).getContent();
} catch (ResourceException e) {
}
}
private String startTaskScanJob(ServerContext context, String invokerName, String scriptName, JsonValue params) throws ExecutionException {
try {
} catch (ScriptException e) {
throw new ExecutionException(e);
}
return taskScanJob.startTask();
}
// 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(taskScanRuns) {
int completedCount = 0;
// Since oldest runs are first in the list, inspect backwards
while (iter.hasPrevious()) {
if (aRun.isCompleted()) {
if (completedCount > maxCompletedRuns) {
}
}
}
}
}
}
public void handleCreate(ServerContext context, CreateRequest request, ResultHandler<Resource> handler) {
}
public void handleDelete(ServerContext context, DeleteRequest request, ResultHandler<Resource> handler) {
}
public void handlePatch(ServerContext context, PatchRequest request, ResultHandler<Resource> handler) {
}
}
public void handleUpdate(ServerContext context, UpdateRequest request, ResultHandler<Resource> handler) {
}
}