TaskClient.java revision a395dd575518d9e5280fc5d5d5ef47c61b174647
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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 Sun Microsystems, Inc.
*/
/**
* Helper class for interacting with the task backend on behalf of utilities
* that are capable of being scheduled.
*/
public class TaskClient {
/**
* Connection through which task scheduling will take place.
*/
protected LDAPConnection connection;
/**
* Keeps track of message IDs.
*/
/**
* Creates a new TaskClient for interacting with the task backend remotely.
* @param conn for accessing the task backend
*/
this.connection = conn;
}
/**
* Schedule a task for execution by writing an entry to the task backend.
*
* @param information to be scheduled
* @return String task ID assigned the new task
* @throws IOException if there is a stream communication problem
* @throws LDAPException if there is a problem getting information
* out to the directory
* @throws ASN1Exception if there is a problem with the encoding
* @throws TaskClientException if there is a problem with the task entry
*/
{
// add the start time if necessary
}
// add dependency IDs
}
// add the dependency action
}
fdaValues));
}
// add completion notification email addresses
}
}
// add error notification email addresses
}
}
// Send the request to the server and read the response.
if (responseMessage == null)
{
throw new LDAPException(
}
if (responseMessage.getProtocolOpType() !=
{
throw new LDAPException(
}
if (errorMessage != null) {
throw new LDAPException(
}
return getTaskEntry(taskID);
}
/**
* Gets all the ds-task entries from the task root.
*
* @return list of entries from the task root
* @throws IOException if there is a stream communication problem
* @throws LDAPException if there is a problem getting information
* out to the directory
* @throws ASN1Exception if there is a problem with the encoding
*/
false,
new LinkedHashSet<String>()));
byte opType;
do {
if (responseMessage == null) {
throw new LDAPException(
} else {
}
}
}
}
}
/**
* Gets the entry of the task whose ID is <code>id</code> from the directory.
*
* @param id of the entry to retrieve
* @return Entry for the task
* @throws IOException if there is a stream communication problem
* @throws LDAPException if there is a problem getting information
* out to the directory
* @throws ASN1Exception if there is a problem with the encoding
* @throws TaskClientException if there is no task with the requested id
*/
{
false,
new LinkedHashSet<String>()));
byte opType;
do {
if (responseMessage == null) {
} else {
}
}
}
}
}
/**
* Changes that the state of the task in the backend to a canceled state.
*
* @param id if the task to cancel
* @return Entry of the task before the modification
* @throws IOException if there is a stream communication problem
* @throws LDAPException if there is a problem getting information
* out to the directory
* @throws ASN1Exception if there is a problem with the encoding
* @throws TaskClientException if there is no task with the requested id
*/
{
} else {
}
// We have to reset the start time or the scheduler will
// reschedule to task.
// attr = new LDAPAttribute(ATTR_TASK_SCHEDULED_START_TIME);
// mods.add(new LDAPModification(ModificationType.DELETE, attr));
if (responseMessage == null) {
}
if (responseMessage.getProtocolOpType() !=
{
throw new LDAPException(
}
if (errorMessage != null) {
throw new LDAPException(
}
} else {
throw new TaskClientException(
}
} else {
throw new TaskClientException(
}
return getTaskEntry(id);
}
/**
* Writes a search to the directory writer.
* @param searchRequest to write
* @throws IOException if there is a stream communication problem
*/
throws IOException {
new ArrayList<LDAPControl>());
// Send the request to the server and read the response.
}
}