Package javax.naming.directory

Examples of javax.naming.directory.Attribute


    // Log Search Attributes
    LogManager.logDetail(LogConstants.CTX_CONNECTOR,"Search attributes: "); //$NON-NLS-1$ 
    Iterator itr = this.attributeList.iterator();
    int i = 0;
    while(itr.hasNext()) {
      Attribute attr = (Attribute)itr.next();
      LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Attribute [" + i + "]: " + attr.getID() + " (" +attr.get().toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
      i++;
    }
   
    // Log Context Filter
    if(contextFilter != null && (!contextFilter.equals(""))) { //$NON-NLS-1$
View Full Code Here


    if(modelAttrName == null) {
            final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.nullAttrError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }

    Attribute resultAttr = attrs.get(modelAttrName);
   
    // If the attribute is not present, we return NULL.
    if(resultAttr == null) {
      // MPW - 2-20-07 - Changed from returning empty string to returning null.
      //row.add("");
      //logger.logTrace("Did not find a match for attribute named: " + modelAttrName);
      // GHH 20080326 - return DN from input parameter
      // if DN attribute is not present in search result
      if (modelAttrName.toUpperCase().equals("DN")) {  //$NON-NLS-1$
        row.add(resultDistinguishedName);
      }
      else {
        row.add(null);
      }
      return;
    }
    Object objResult = null;
    try {
      if(TypeFacility.RUNTIME_TYPES.STRING.equals(modelAttrClass) && "multivalued-concat".equalsIgnoreCase(multivalAttr)) { //$NON-NLS-1$
        // mpw 5/09
        // Order the multi-valued attrs alphabetically before creating a single string,
        // using the delimiter to separate each token
        ArrayList<String> multivalList = new ArrayList<String>();
        NamingEnumeration<?> attrNE = resultAttr.getAll();
        int length = 0;
        while(attrNE.hasMore()) {
          String val = (String)attrNE.next();
          multivalList.add(val);
          length += ((val==null?0:val.length()) + 1);
        }
        Collections.sort(multivalList);
 
        StringBuilder multivalSB = new StringBuilder(length);
        Iterator<String> itr = multivalList.iterator();
        while(itr.hasNext()) {
          multivalSB.append(itr.next());
          if (itr.hasNext()) {
            multivalSB.append(delimiter);
          }
        }
        row.add(multivalSB.toString());
        return;
      }
     
      //just a single value
      objResult = resultAttr.get();
    } catch (NamingException ne) {
            final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.attrValueFetchError",modelAttrName) +" : "+ne.getExplanation(); //$NON-NLS-1$m//$NON-NLS-2$
            LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg);
      throw new TranslatorException(msg);
    }
View Full Code Here

    List<ColumnReference> insertElementList = ((Insert)command).getColumns();
    List<Expression> insertValueList = ((ExpressionValueSource)((Insert)command).getValueSource()).getValues();
    // create a new attribute list with case ignored in attribute
    // names
    Attributes insertAttrs = new BasicAttributes(true);
    Attribute insertAttr; // what we will use to populate the attribute list
    ColumnReference insertElement;
    String nameInsertElement;
    Object insertValue;
    String distinguishedName = null;
    // The IInsert interface uses separate List objects for
    // the element names and values to be inserted, limiting
    // the potential for code reuse in reading them (since all
    // other interfaces use ICriteria-based mechanisms for such
    // input).
    for (int i=0; i < insertElementList.size(); i++) {
      insertElement = insertElementList.get(i);
      // call utility class to get NameInSource/Name of element
      nameInsertElement = getNameFromElement(insertElement);
      // special handling for DN attribute - use it to set
      // distinguishedName value.
      if (nameInsertElement.toUpperCase().equals("DN")) {  //$NON-NLS-1$
        insertValue = ((Literal)insertValueList.get(i)).getValue();
        if (insertValue == null) {
                final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.columnSourceNameDNNullError"); //$NON-NLS-1$
          throw new TranslatorException(msg);
        }
        if (!(insertValue instanceof java.lang.String)) {
                final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.columnSourceNameDNTypeError"); //$NON-NLS-1$
          throw new TranslatorException(msg);
        }
        distinguishedName = (String)insertValue;
      }
      // for other attributes specified in the insert command,
      // create a new
      else {
        insertAttr = new BasicAttribute(nameInsertElement);
        insertValue = ((Literal)insertValueList.get(i)).getValue();
        insertAttr.add(insertValue);
        insertAttrs.put(insertAttr);
      }
    }
    // if the DN is not specified, we don't know enough to attempt
    // the LDAP add operation, so throw an exception
View Full Code Here

   * Return    : None, prints to the system output the list of all attributes
   */
  public void listAllAttributes() throws Exception
  {
    NamingEnumeration   valueEnum = null;
    Attribute      attr = null;
    int         aindex = 0, vindex = 0;

    this.getAllAttributes();

    // Search for objects that have those matching attributes
    NamingEnumeration attrEnum = attributes.getAll();
   
    aindex = 0;
   
    // List the attributes
    while (attrEnum.hasMore())
    {
      attr = (Attribute)attrEnum.next();
     
      System.out.println("Attribute[ " + aindex + "]: " + attr.getID());
     
      valueEnum = attr.getAll();

      vindex = 0;
     
      while (valueEnum.hasMore())
      {
View Full Code Here

     
      Attributes attrs = context.getAttributes( host, new String[]{ "AAAA" });
     
      if ( attrs != null ){
     
        Attribute attr = attrs.get( "aaaa" );
     
        if ( attr != null ){
         
          NamingEnumeration values = attr.getAll();
     
          while( values.hasMore()){
         
            Object value = values.next();
           
View Full Code Here

         
        }
      } else {

        Attributes a = ctx.getAttributes(dn, new String[] { "uniquemember" });
        Attribute memberAttr = a.get("uniquemember");
       
        if (memberAttr != null) {
          for (NamingEnumeration de=memberAttr.getAll(); de.hasMore(); ) {
            String val = (String)de.next();
            String name = val.substring(val.indexOf("=")+1, val.indexOf(",")).trim();
           
            if (isTribe) {
              if (val.startsWith("cn")) {
View Full Code Here

        if (parentFail != null) {
          throw new OperationFailedException("Loops not allowed, '"+dn+"' is parent of of '"+this.dn+"'");
        }
      }
     
      Attribute currMembers = fetchMembers(ctx);
      String failer = containsName(ctx, currMembers, dn);
      if (failer == null) {
        currMembers.add(dn);
        Attributes attrs = new BasicAttributes();
        attrs.put(currMembers);
       
        ctx.modifyAttributes(this.dn, DirContext.REPLACE_ATTRIBUTE, attrs);
        return true;
View Full Code Here

 
    try {
      connImpl = realm.getConnection();
      ctx = (DirContext)connImpl.getConnection();
 
      Attribute currMembers = fetchMembers(ctx);
      String result = containsName(ctx, currMembers, dn);
      if (result != null) {
        currMembers.remove(result);
        Attributes attrs = new BasicAttributes();
        attrs.put(currMembers);
     
        ctx.modifyAttributes(this.dn, DirContext.REPLACE_ATTRIBUTE, attrs);
       
View Full Code Here

 
 
  private Attribute fetchMembers(DirContext ctx, String fetchDN) throws NamingException
  {
    Attributes attrs = ctx.getAttributes(fetchDN, new String[] { "uniquemember" });
    Attribute members = attrs.get("uniquemember");
    return (members == null)? new BasicAttribute("uniquemember") : members;
  }
View Full Code Here

    Element record = null;
    Element attribute = null;

    SearchResult sr = null;
    NamingEnumeration attrs = null;
    Attribute attr = null;
    String key = null;
    NamingEnumeration values = null;
    String value = null;

    try
    {
      while (results.hasMore())
      {
        sr = (SearchResult) results.next();
        attrs = sr.getAttributes().getAll();

        record = doc.createElement("Record");

        while (attrs.hasMore())
        {
          attr = (Attribute) attrs.next();
          key = attr.getID();
          values = attr.getAll();
          while (values.hasMore())
          {
            value = values.next().toString();
            attribute = doc.createElement(key);
            attribute.appendChild(doc.createTextNode(value));
View Full Code Here

TOP

Related Classes of javax.naming.directory.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.