Package javax.naming.directory

Examples of javax.naming.directory.Attributes


   * @param result the search result
   */
  // GHH 20080326 - added fetching of DN of result, for directories that
  // do not include it as an attribute
  private List<?> getRow(SearchResult result) throws TranslatorException {
    Attributes attrs = result.getAttributes();
    String resultDN = result.getNameInNamespace(); // added GHH 20080326
    ArrayList<Column> attributeList = searchDetails.getElementList();
    List<Object> row = new ArrayList<Object>(attributeList.size());
   
    for (Column col : attributeList) {
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
    if (distinguishedName == null) {
View Full Code Here

    List<Inet6Address>  result = new ArrayList<Inet6Address>();

    try{     
      DirContext context = getInitialDirContext();
     
      Attributes attrs = context.getAttributes( host, new String[]{ "AAAA" });
     
      if ( attrs != null ){
     
        Attribute attr = attrs.get( "aaaa" );
     
        if ( attr != null ){
         
          NamingEnumeration values = attr.getAll();
     
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();
View Full Code Here

     
      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

 
      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);
       
        return true;
      }
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

    Node requestNode = null;
    String requestString = null;
    RequestContainer request = null;
    NodeList children = null;
    Node child = null;
    Attributes attrs;

    for (int i = 0; i < nodes.getLength(); i++)
    {
      requestNode = nodes.item(i);
      if (requestNode.getNodeType() == Element.ELEMENT_NODE)
      {
        if (requestNode.getNodeName().equals(SEARCH_STRING))
        {
          requestString = XMLHelper.getNodeText(requestNode);
          if (requestString == null)
          {
            throw new XException(Constants.LOCATION_EXTERN,
                Constants.LAYER_TECHNICAL,
                Constants.PACKAGE_TECHNICAL_LDAP, "1");
          }
          else
          {
            request = new RequestContainer(SEARCH_STRING,
                getContext(requestNode), requestString);
            retVector.add(request);
          }
        }
        else if (requestNode.getNodeName().equals(SEARCH_ATTRIBUTES))
        {
          children = requestNode.getChildNodes();
          attrs = new BasicAttributes();
          for (int j = 0; j < children.getLength(); j++)
          {
            child = children.item(j);
            if (child.getNodeType() == Element.ELEMENT_NODE)
            {
              String attributeName = child.getNodeName();
              String attributeValue = XMLHelper
                  .getNodeText(child);
              attrs.put(attributeName, attributeValue);
            }
          }
          request = new RequestContainer(SEARCH_ATTRIBUTES,
              getContext(requestNode), attrs);
          retVector.add(request);
View Full Code Here

      ldapResult = executeLdap(binding, context);

      while (ldapResult.hasMore())
      {
        SearchResult sr = ldapResult.next();
        Attributes sra = sr.getAttributes();
       
        Map<String, Node> aBinding = new HashMap<String, Node>();

        // Mapping results to rdf
        if (subject.isVariable())
          aBinding.put(subject.getName(), createLdapNode(sr
              .getNameInNamespace()));

        boolean valid = true;

        for (Triple triple : query)
        {
          if (!triple.getObject().isVariable())
            continue;

          String attribute = predToAttribute(triple.getPredicate());

          if (sra.get(attribute) == null) // no value -- not a hit
          {
            log.debug("Attribute not found");
            valid = false;
            break;
          }
         
          // FIXME I get the first value, but there may be more. tricky.
          // TODO If pred is type unmap value to node (often multiple vals, btw)
          Object val = sra.get(attribute).get();
          String var = triple.getObject().getName();

          // I don't think this does anything useful, since we prebind
          if (aBinding.containsKey(var)) // if we have a binding for
          // this
View Full Code Here

   
    NamingEnumeration<SearchResult> results = null;
   
    if ("".equals(queryString)) // We aren't searching, just get attributes
    {
      Attributes attrs = context.getAttributes(baseURI, (String[]) toGet
          .toArray(new String[] {}));
      // Wrap this to fit this method's contract
      SearchResult sr = new SearchResult(null, null, attrs);
      sr.setNameInNamespace(uriToName(baseURI));
      results = new SingletonNamingEnumeration<SearchResult>(sr);
View Full Code Here

TOP

Related Classes of javax.naming.directory.Attributes

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.