private LocalizableMessage getDisconnectMessage(Entry taskEntry) { AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_MESSAGE); for (Attribute a : taskEntry.getAttribute(attrType)) { for (ByteString v : a) { return LocalizableMessage.raw(v.toString()); } } return INFO_TASK_DISCONNECT_GENERIC_MESSAGE.get(); }
private Set<AttributeType> toAttributeTypes(StringArgument attributeArg) { if (attributeArg == null) { return null; } Set<AttributeType> results = new HashSet<>(); for (String attrName : attributeArg.getValues()) { results.add(DirectoryServer.getAttributeTypeOrDefault(attrName.toLowerCase(), attrName)); } return results; }
private long getConnectionID(Entry taskEntry) throws DirectoryException { final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_CONN_ID); for (Attribute a : taskEntry.getAttribute(attrType)) { for (ByteString v : a) { 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 -1; }
private boolean mustNotifyClient(Entry taskEntry) throws DirectoryException { final AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_DISCONNECT_NOTIFY_CLIENT); for (Attribute a : taskEntry.getAttribute(attrType)) { for (ByteString v : a) { 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 false; }
private Integer getIntegerUserAttribute( Entry userEntry, String attributeTypeName, Arg1<Object> nonUniqueAttributeMessage, Arg2<Object, Object> cannotProcessAttributeMessage) { AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(attributeTypeName); List<Attribute> attrList = userEntry.getAttribute(attrType); if (attrList != null && attrList.size() == 1) { Attribute a = attrList.get(0); if (a.size() == 1) { ByteString v = a.iterator().next(); try { return Integer.valueOf(v.toString()); } catch (Exception e) { logger.traceException(e); logger.error(cannotProcessAttributeMessage.get(v, userEntry.getName())); } } else if (a.size() > 1) { logger.error(nonUniqueAttributeMessage.get(userEntry.getName())); } } return null; }