{
ClientConnection conn = operation.getClientConnection();
if (! conn.hasPrivilege(Privilege.DISCONNECT_CLIENT, operation))
{
Message message = ERR_TASK_DISCONNECT_NO_PRIVILEGE.get();
throw new DirectoryException(ResultCode.INSUFFICIENT_ACCESS_RIGHTS,
message);
}
}
// Get the connection ID for the client connection.
Entry taskEntry = getTaskEntry();
connectionID = -1L;
AttributeType attrType =
DirectoryServer.getAttributeType(ATTR_TASK_DISCONNECT_CONN_ID, true);
List<Attribute> attrList = taskEntry.getAttribute(attrType);
if (attrList != null)
{
connIDLoop:
for (Attribute a : attrList)
{
for (AttributeValue v : a)
{
try
{
connectionID = Long.parseLong(v.getValue().toString());
break connIDLoop;
}
catch (Exception e)
{
Message message =
ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v.getValue().toString());
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message, e);
}
}
}
}
if (connectionID < 0)
{
Message message =
ERR_TASK_DISCONNECT_NO_CONN_ID.get(ATTR_TASK_DISCONNECT_CONN_ID);
throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
message);
}
// Determine whether to notify the client.
notifyClient = false;
attrType =
DirectoryServer.getAttributeType(ATTR_TASK_DISCONNECT_NOTIFY_CLIENT,
true);
attrList = taskEntry.getAttribute(attrType);
if (attrList != null)
{
notifyClientLoop:
for (Attribute a : attrList)
{
for (AttributeValue v : a)
{
String stringValue = toLowerCase(v.getValue().toString());
if (stringValue.equals("true"))
{
notifyClient = true;
break notifyClientLoop;
}
else if (stringValue.equals("false"))
{
break notifyClientLoop;
}
else
{
Message message =
ERR_TASK_DISCONNECT_INVALID_NOTIFY_CLIENT.get(stringValue);
throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
message);
}
}
}
}