| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | private long getConnectionID(Entry taskEntry) throws DirectoryException |
| | | { |
| | | final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_CONN_ID); |
| | | final List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | for (Attribute a : taskEntry.getAttribute(attrType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | try |
| | | { |
| | | try |
| | | { |
| | | return Long.parseLong(v.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e); |
| | | } |
| | | return Long.parseLong(v.toString()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_CONN_ID.get(v); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, e); |
| | | } |
| | | } |
| | | } |
| | |
| | | private boolean mustNotifyClient(Entry taskEntry) throws DirectoryException |
| | | { |
| | | final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_NOTIFY_CLIENT); |
| | | final List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | for (Attribute a : taskEntry.getAttribute(attrType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | final String stringValue = toLowerCase(v.toString()); |
| | | if ("true".equals(stringValue)) |
| | | { |
| | | final String stringValue = toLowerCase(v.toString()); |
| | | if ("true".equals(stringValue)) |
| | | { |
| | | return true; |
| | | } |
| | | else if ("false".equals(stringValue)) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_NOTIFY_CLIENT.get(stringValue); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | return true; |
| | | } |
| | | else if ("false".equals(stringValue)) |
| | | { |
| | | return false; |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_TASK_DISCONNECT_INVALID_NOTIFY_CLIENT.get(stringValue); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | private LocalizableMessage getDisconnectMessage(Entry taskEntry) |
| | | { |
| | | AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_MESSAGE); |
| | | List<Attribute> attrList = taskEntry.getAttribute(attrType); |
| | | if (attrList != null) |
| | | for (Attribute a : taskEntry.getAttribute(attrType)) |
| | | { |
| | | for (Attribute a : attrList) |
| | | for (ByteString v : a) |
| | | { |
| | | for (ByteString v : a) |
| | | { |
| | | return LocalizableMessage.raw(v.toString()); |
| | | } |
| | | return LocalizableMessage.raw(v.toString()); |
| | | } |
| | | } |
| | | return INFO_TASK_DISCONNECT_GENERIC_MESSAGE.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected TaskState runTask() |
| | | { |