Package org.nasutekds.server.types

Examples of org.nasutekds.server.types.ObjectClass


    boolean extensibleObject = false;

    // Update ocs tables.
    NdbTransaction ndbDATxn = null;
    for (Map.Entry<ObjectClass, String> ocEntry : ocMap.entrySet()) {
      ObjectClass oc = ocEntry.getKey();
      String ocName = oc.getNameOrOID();

      Map<Integer, NdbOperation> mvOpMap =
        new HashMap<Integer, NdbOperation>();

      if (nClasses > 0) {
        ocBuffer.append(" ");
      }
      ocBuffer.append(ocName);
      nClasses++;

      if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
        continue;
      }

      if (ocName.equalsIgnoreCase(OC_EXTENSIBLEOBJECT)) {
        extensibleObject = true;
      }

      if (ndbDATxn == null) {
        ndbDATxn = txn.getNdbDATransaction(ocName, id);
      }
      if (overwrite) {
        op = ndbDATxn.getWriteOperation(ocName);
      } else {
        op = ndbDATxn.getInsertOperation(ocName);
      }
      op.equalLong(BackendImpl.EID, id);
      op.equalInt(BackendImpl.MID, MIN_MID);
      mvOpMap.put(MIN_MID, op);

      for (AttributeType reqAttr : oc.getRequiredAttributes()) {
        if (userAttributes.contains(reqAttr)) {
          continue;
        }
        if (reqAttr.isOperational()) {
          userAttrMap.put(reqAttr, entry.getOperationalAttribute(reqAttr));
        }
        String attrName = reqAttr.getNameOrOID();
        if (entry.hasAttribute(reqAttr)) {
          boolean indexed = BackendImpl.indexes.contains(attrName);
          List<Attribute> attrList = userAttrMap.get(reqAttr);
          int mid = MIN_MID;
          for (Attribute attr : attrList) {
            if (attr.isVirtual() || attr.isEmpty()) {
              continue;
            }
            // Attribute options.
            Set<String> attrOptionsSet = attr.getOptions();
            if (!attrOptionsSet.isEmpty()) {
              if (overwrite) {
                tagOp =
                  ndbDATxn.getWriteOperation(BackendImpl.TAGS_TABLE);
              } else {
                tagOp =
                  ndbDATxn.getInsertOperation(BackendImpl.TAGS_TABLE);
              }
              tagOp.equalLong(BackendImpl.EID, id);
              tagOp.equalString(BackendImpl.TAG_ATTR, attrName);
              tagOp.equalInt(BackendImpl.MID, mid);
              StringBuilder buffer = new StringBuilder();
              for (String option : attrOptionsSet) {
                buffer.append(';');
                buffer.append(option);
              }
              tagOp.setString(BackendImpl.TAG_TAGS, buffer.toString());
            }
            for (AttributeValue attrVal : attr) {
              String attrStringVal = attrVal.toString();
              NdbOperation attrOp = mvOpMap.get(mid);
              if (attrOp == null) {
                if (overwrite) {
                  attrOp = ndbDATxn.getWriteOperation(ocName);
                } else {
                  attrOp = ndbDATxn.getInsertOperation(ocName);
                }
                attrOp.equalLong(BackendImpl.EID, id);
                attrOp.equalInt(BackendImpl.MID, mid);
                mvOpMap.put(mid, attrOp);
              }
              if (BackendImpl.blobAttributes.contains(attrName)) {
                NdbBlob blob = attrOp.getBlobHandle(attrName);
                blob.setValue(new byte[0]);
                byte[] blobBytes = attrVal.getValue().toByteArray();
                blobMap.put(blob, blobBytes);
              } else {
                attrOp.setString(attrName, attrStringVal);
              }
              // Update Indexes.
              if (indexed) {
                NdbOperation idxOp = null;
                if (overwrite) {
                  idxOp = ndbDATxn.getWriteOperation(
                    BackendImpl.IDX_TABLE_PREFIX + attrName);
                } else {
                  idxOp = ndbDATxn.getInsertOperation(
                    BackendImpl.IDX_TABLE_PREFIX + attrName);
                }
                idxOp.equalLong(BackendImpl.EID, id);
                idxOp.equalInt(BackendImpl.MID, mid);
                idxOp.setString(BackendImpl.IDX_VAL, attrStringVal);
              }
              mid++;
            }
          }
          userAttributes.add(reqAttr);
        }
      }

      for (AttributeType optAttr : oc.getOptionalAttributes()) {
        if (userAttributes.contains(optAttr)) {
          continue;
        }
        if (optAttr.isOperational()) {
          userAttrMap.put(optAttr, entry.getOperationalAttribute(optAttr));
View Full Code Here


      new ArrayList<AttributeType>();
    Map<AttributeType, List<Attribute>> originalUserAttrMap =
      originalEntry.getUserAttributes();

    for (Map.Entry<ObjectClass, String> ocEntry : originalOcMap.entrySet()) {
      ObjectClass oc = ocEntry.getKey();
      String ocName = oc.getNameOrOID();
      Map<Integer, NdbOperation> mvOpMap =
        new HashMap<Integer, NdbOperation>();

      if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
        continue;
      }

      if (ocName.equalsIgnoreCase(OC_EXTENSIBLEOBJECT)) {
        extensibleObject = true;
      }

      if (ndbDATxn == null) {
        ndbDATxn = txn.getNdbDATransaction(ocName, id);
      }
      op = ndbDATxn.getDeleteOperation(ocName);
      op.equalLong(BackendImpl.EID, id);
      op.equalInt(BackendImpl.MID, MIN_MID);
      mvOpMap.put(MIN_MID, op);

      for (AttributeType reqAttr : oc.getRequiredAttributes()) {
        String attrName = reqAttr.getNameOrOID();
        if (originalUserAttributes.contains(reqAttr)) {
          continue;
        }
        if (originalEntry.hasUserAttribute(reqAttr)) {
          boolean indexed = BackendImpl.indexes.contains(attrName);
          List<Attribute> attrList = originalUserAttrMap.get(reqAttr);
          int mid = MIN_MID;
          for (Attribute attr : attrList) {
            if (attr.isVirtual() || attr.isEmpty()) {
              continue;
            }
            // Attribute options.
            Set<String> attrOptionsSet = attr.getOptions();
            if (!attrOptionsSet.isEmpty()) {
              tagOp =
                ndbDATxn.getDeleteOperation(BackendImpl.TAGS_TABLE);
              tagOp.equalLong(BackendImpl.EID, id);
              tagOp.equalString(BackendImpl.TAG_ATTR, attrName);
              tagOp.equalInt(BackendImpl.MID, mid);
            }
            for (AttributeValue attrVal : attr) {
              NdbOperation attrOp = mvOpMap.get(mid);
              if (attrOp == null) {
                attrOp = ndbDATxn.getDeleteOperation(ocName);
                attrOp.equalLong(BackendImpl.EID, id);
                attrOp.equalInt(BackendImpl.MID, mid);
                mvOpMap.put(mid, attrOp);
              }
              // Update Indexes.
              if (indexed) {
                NdbOperation idxOp = ndbDATxn.getDeleteOperation(
                  BackendImpl.IDX_TABLE_PREFIX + attrName);
                idxOp.equalLong(BackendImpl.EID, id);
                idxOp.equalInt(BackendImpl.MID, mid);
              }
              mid++;
            }
          }
          originalUserAttributes.add(reqAttr);
        }
      }

      for (AttributeType optAttr : oc.getOptionalAttributes()) {
        String attrName = optAttr.getNameOrOID();
        if (originalUserAttributes.contains(optAttr)) {
          continue;
        }
        if (originalEntry.hasUserAttribute(optAttr)) {
View Full Code Here

      if (xocsString.length() > 0) {
        extensibleObject = true;
      }

      for (String ocName : ocsStringArray) {
        ObjectClass oc =
          DirectoryServer.getObjectClass(ocName, true);
        if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
          continue;
        }
        if (ndbDATxn == null) {
          ndbDATxn = txn.getNdbDATransaction(ocName, eid);
        }
        indexScanOp =
          ndbDATxn.getSelectIndexScanOperation(PRIMARY_INDEX_NAME, ocName);
        indexScanOp.setBoundLong(BackendImpl.EID,
            NdbIndexScanOperation.BoundType.BoundEQ, eid);
        indexScanOp.getValue(BackendImpl.MID);
        ocRsList.add(indexScanOp.resultData());
      }

      // Extensible object.
      if (extensibleObject) {
        for (String xocName : xocsStringArray) {
          ObjectClass xoc =
            DirectoryServer.getObjectClass(xocName, true);
          if (xoc.getObjectClassType() == ObjectClassType.ABSTRACT) {
            continue;
          }
          if (ndbDATxn == null) {
            ndbDATxn = txn.getNdbDATransaction(xocName, eid);
          }
          indexScanOp =
            ndbDATxn.getSelectIndexScanOperation(PRIMARY_INDEX_NAME, xocName);
          indexScanOp.setBoundLong(BackendImpl.EID,
            NdbIndexScanOperation.BoundType.BoundEQ, eid);
          indexScanOp.getValue(BackendImpl.MID);
          ocRsList.add(indexScanOp.resultData());
        }
      }
    }

    // Attribute options.
    if (ndbDATxn == null) {
      ndbDATxn = txn.getNdbDATransaction(BackendImpl.TAGS_TABLE, eid);
    }
    indexScanOp = ndbDATxn.getSelectIndexScanOperation(PRIMARY_INDEX_NAME,
      BackendImpl.TAGS_TABLE);
    indexScanOp.setBoundLong(BackendImpl.EID,
      NdbIndexScanOperation.BoundType.BoundEQ, eid);
    indexScanOp.getValue(BackendImpl.TAG_ATTR);
    indexScanOp.getValue(BackendImpl.MID);
    NdbResultSet tagRs = indexScanOp.resultData();

    ndbDATxn.execute(ExecType.NoCommit, AbortOption.AO_IgnoreError, true);

    Iterator<NdbResultSet> rsIterator = ocRsList.iterator();
    for (String ocName : ocsStringArray) {
      ObjectClass oc =
        DirectoryServer.getObjectClass(ocName, true);
      if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
        continue;
      }
      NdbResultSet ocRs = rsIterator.next();
      while (ocRs.next()) {
        int mid = ocRs.getInt(BackendImpl.MID);
        op = ndbDATxn.getDeleteOperation(ocName);
        op.equalLong(BackendImpl.EID, eid);
        op.equalInt(BackendImpl.MID, mid);
      }
    }

    // Extensible object.
    if (extensibleObject) {
      for (String xocName : xocsStringArray) {
        ObjectClass xoc =
          DirectoryServer.getObjectClass(xocName, true);
        if (xoc.getObjectClassType() == ObjectClassType.ABSTRACT) {
          continue;
        }
        NdbResultSet ocRs = rsIterator.next();
        while (ocRs.next()) {
          int mid = ocRs.getInt(BackendImpl.MID);
View Full Code Here

    NdbTransaction ndbDATxn = null;
    NdbIndexScanOperation tagScanOp = null;

    for (String ocName : ocsStringArray) {
      ObjectClass oc =
        DirectoryServer.getObjectClass(ocName, true);
      objectClasses.put(oc, ocName);
      if (oc.getObjectClassType() == ObjectClassType.ABSTRACT) {
        continue;
      }

      if (ndbDATxn == null) {
        ndbDATxn = txn.getNdbDATransaction(ocName, eid);
      }

      indexScanOp =
        ndbDATxn.getSelectIndexScanOperation(
        PRIMARY_INDEX_NAME, ocName,
        NdbOperation.LockMode.LM_CommittedRead);
      indexScanOp.setBoundLong(BackendImpl.EID,
        NdbIndexScanOperation.BoundType.BoundEQ, eid);
      indexScanOp.getValue(BackendImpl.MID);

      for (AttributeType reqAttr : oc.getRequiredAttributes()) {
        String attrName = reqAttr.getNameOrOID();
        if (BackendImpl.blobAttributes.contains(attrName)) {
          NdbBlob blob = indexScanOp.getBlobHandle(attrName);
          Map<String, NdbBlob> attr2Blob = blobMap.get(ocName);
          if (attr2Blob == null) {
            attr2Blob = new HashMap<String, NdbBlob>();
          }
          attr2Blob.put(attrName, blob);
          blobMap.put(ocName, attr2Blob);
        } else {
          indexScanOp.getValue(attrName);
        }
      }
      for (AttributeType optAttr : oc.getOptionalAttributes()) {
        String attrName = optAttr.getNameOrOID();
        if (BackendImpl.blobAttributes.contains(attrName)) {
          NdbBlob blob = indexScanOp.getBlobHandle(attrName);
          Map<String, NdbBlob> attr2Blob = blobMap.get(ocName);
          if (attr2Blob == null) {
            attr2Blob = new HashMap<String, NdbBlob>();
          }
          attr2Blob.put(attrName, blob);
          blobMap.put(ocName, attr2Blob);
        } else {
          indexScanOp.getValue(attrName);
        }
      }
      ocRsList.add(indexScanOp.resultData());
    }

    // Extensible object.
    if (extensibleObject) {
      for (String xocName : xocsStringArray) {
        ObjectClass xoc =
          DirectoryServer.getObjectClass(xocName, true);
        objectClasses.put(xoc, xocName);
        xObjectClasses.put(xoc, xocName);
        if (xoc.getObjectClassType() == ObjectClassType.ABSTRACT) {
          continue;
        }

        if (ndbDATxn == null) {
          ndbDATxn = txn.getNdbDATransaction(xocName, eid);
        }

        indexScanOp =
          ndbDATxn.getSelectIndexScanOperation(
          PRIMARY_INDEX_NAME, xocName,
          NdbOperation.LockMode.LM_CommittedRead);
        indexScanOp.setBoundLong(BackendImpl.EID,
          NdbIndexScanOperation.BoundType.BoundEQ, eid);
        indexScanOp.getValue(BackendImpl.MID);

        for (AttributeType reqAttr : xoc.getRequiredAttributes()) {
          String attrName = reqAttr.getNameOrOID();
          if (BackendImpl.blobAttributes.contains(attrName)) {
            NdbBlob blob = indexScanOp.getBlobHandle(attrName);
            Map<String, NdbBlob> attr2Blob = blobMap.get(xocName);
            if (attr2Blob == null) {
              attr2Blob = new HashMap<String, NdbBlob>();
            }
            attr2Blob.put(attrName, blob);
            blobMap.put(xocName, attr2Blob);
          } else {
            indexScanOp.getValue(attrName);
          }
        }
        for (AttributeType optAttr : xoc.getOptionalAttributes()) {
          String attrName = optAttr.getNameOrOID();
          if (BackendImpl.blobAttributes.contains(attrName)) {
            NdbBlob blob = indexScanOp.getBlobHandle(attrName);
            Map<String, NdbBlob> attr2Blob = blobMap.get(xocName);
            if (attr2Blob == null) {
View Full Code Here

    RDN rdn = dn.getRDN();
    int numAVAs = rdn.getNumValues();

    // If there is only one RDN attribute, then see which objectclass we should
    // use.
    ObjectClass structuralClass;
    if (numAVAs == 1)
    {
      AttributeType attrType = rdn.getAttributeType(0);

      if (attrType.hasName(ATTR_C))
      {
        structuralClass = DirectoryServer.getObjectClass(OC_COUNTRY, true);
      }
      else if (attrType.hasName(ATTR_DC))
      {
        structuralClass = DirectoryServer.getObjectClass(OC_DOMAIN, true);
      }
      else if (attrType.hasName(ATTR_O))
      {
        structuralClass = DirectoryServer.getObjectClass(OC_ORGANIZATION, true);
      }
      else if (attrType.hasName(ATTR_OU))
      {
        structuralClass =
             DirectoryServer.getObjectClass(OC_ORGANIZATIONAL_UNIT_LC, true);
      }
      else
      {
        structuralClass =
             DirectoryServer.getObjectClass(OC_UNTYPED_OBJECT_LC, true);
      }
    }
    else
    {
      structuralClass =
           DirectoryServer.getObjectClass(OC_UNTYPED_OBJECT_LC, true);
    }


    // Get the top and untypedObject classes to include in the entry.
    LinkedHashMap<ObjectClass,String> objectClasses =
         new LinkedHashMap<ObjectClass,String>(3);

    objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
    objectClasses.put(structuralClass, structuralClass.getNameOrOID());


    // Iterate through the RDN attributes and add them to the set of user or
    // operational attributes.
    LinkedHashMap<AttributeType,List<Attribute>> userAttributes =
         new LinkedHashMap<AttributeType,List<Attribute>>();
    LinkedHashMap<AttributeType,List<Attribute>> operationalAttributes =
         new LinkedHashMap<AttributeType,List<Attribute>>();

    boolean extensibleObjectAdded = false;
    for (int i=0; i < numAVAs; i++)
    {
      AttributeType attrType = rdn.getAttributeType(i);
      AttributeValue attrValue = rdn.getAttributeValue(i);
      String attrName = rdn.getAttributeName(i);

      // First, see if this type is allowed by the untypedObject class.  If not,
      // then we'll need to include the extensibleObject class.
      if ((! structuralClass.isRequiredOrOptional(attrType)) &&
          (! extensibleObjectAdded))
      {
        ObjectClass extensibleObjectOC =
             DirectoryServer.getObjectClass(OC_EXTENSIBLE_OBJECT_LC);
        if (extensibleObjectOC == null)
        {
          extensibleObjectOC =
               DirectoryServer.getDefaultObjectClass(OC_EXTENSIBLE_OBJECT);
View Full Code Here


    // Determine whether it is a groupOfNames or groupOfUniqueNames entry.  If
    // neither, then that's a problem.
    AttributeType memberAttributeType;
    ObjectClass groupOfEntriesClass =
         DirectoryConfig.getObjectClass(OC_GROUP_OF_ENTRIES_LC, true);
    ObjectClass groupOfNamesClass =
         DirectoryConfig.getObjectClass(OC_GROUP_OF_NAMES_LC, true);
    ObjectClass groupOfUniqueNamesClass =
         DirectoryConfig.getObjectClass(OC_GROUP_OF_UNIQUE_NAMES_LC, true);
    if (groupEntry.hasObjectClass(groupOfEntriesClass))
    {
      if (groupEntry.hasObjectClass(groupOfNamesClass))
      {
View Full Code Here

  {
    ensureNotNull(entry);

    // FIXME -- This needs to exclude enhanced groups once we have support for
    //them.
    ObjectClass virtualStaticGroupClass =
         DirectoryConfig.getObjectClass(OC_VIRTUAL_STATIC_GROUP, true);
    if (entry.hasObjectClass(virtualStaticGroupClass))
    {
      return false;
    }

    ObjectClass groupOfEntriesClass =
         DirectoryConfig.getObjectClass(OC_GROUP_OF_ENTRIES_LC, true);
    ObjectClass groupOfNamesClass =
         DirectoryConfig.getObjectClass(OC_GROUP_OF_NAMES_LC, true);
    ObjectClass groupOfUniqueNamesClass =
         DirectoryConfig.getObjectClass(OC_GROUP_OF_UNIQUE_NAMES_LC, true);
    if (entry.hasObjectClass(groupOfEntriesClass))
    {
      if (entry.hasObjectClass(groupOfNamesClass) ||
          entry.hasObjectClass(groupOfUniqueNamesClass))
View Full Code Here

      {
        return attrType1.equals(attrType2);
      }
    }

    ObjectClass oc1 = DirectoryServer.getObjectClass(oid);
    if (oc1 != null)
    {
      ObjectClass oc2 = DirectoryServer.getObjectClass(value2String);
      if (oc2 == null)
      {
        return false;
      }
      else
View Full Code Here

    // Initialize null entry object classes.
    objectClasses = new HashMap<ObjectClass,String>();

    String topOCName = "top";
    ObjectClass topOC = DirectoryServer.getObjectClass(topOCName);
    if (topOC == null) {
      throw new InitializationException(Message.raw(
        Category.BACKEND, Severity.FATAL_ERROR,
        "Unable to locate " + topOCName +
        " objectclass in the current server schema"));
    }
    objectClasses.put(topOC, topOCName);

    String nulOCName = "nullbackendobject";
    ObjectClass nulOC = DirectoryServer.getDefaultObjectClass(nulOCName);
    try {
      DirectoryServer.registerObjectClass(nulOC, false);
    } catch (DirectoryException de) {
      if (debugEnabled())
      {
        TRACER.debugCaught(DebugLogLevel.ERROR, de);
      }
      throw new InitializationException(de.getMessageObject());
    }
    objectClasses.put(nulOC, nulOCName);

    String extOCName = "extensibleobject";
    ObjectClass extOC = DirectoryServer.getObjectClass(extOCName);
    if (extOC == null) {
      throw new InitializationException(Message.raw(
        Category.BACKEND, Severity.FATAL_ERROR,
        "Unable to locate " + extOCName +
        " objectclass in the current server schema"));
View Full Code Here

   * @return  <CODE>true</CODE> if this configuration entry contains the
   *          specified objectclass, or <CODE>false</CODE> if not.
   */
  public boolean hasObjectClass(String name)
  {
    ObjectClass oc = DirectoryServer.getObjectClass(name.toLowerCase());
    if (oc == null)
    {
      oc = DirectoryServer.getDefaultObjectClass(name);
    }

View Full Code Here

TOP

Related Classes of org.nasutekds.server.types.ObjectClass

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.