예제 #1
0
 private static AttributeType getAttribute(
     Schema schema,
     boolean allowUnknownElements,
     String valueStr,
     StringBuilder woidBuffer,
     Arg2<Object, Object> msg)
     throws DirectoryException {
   String woidString = woidBuffer.toString();
   AttributeType attr = schema.getAttributeType(woidString);
   if (attr == null) {
     // This isn't good because it means that the DIT content rule
     // refers to an attribute type that we don't know anything about.
     if (!allowUnknownElements) {
       throw new DirectoryException(
           ResultCode.CONSTRAINT_VIOLATION, msg.get(valueStr, woidString));
     }
     attr = DirectoryServer.getDefaultAttributeType(woidString);
   }
   return attr;
 }
예제 #2
0
 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;
 }