| | |
| | | import org.opends.server.api.plugin.PluginResult; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeBuilder; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.ByteStringFactory; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import org.opends.server.types.DirectoryConfig; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ModificationType; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.operation.PreOperationAddOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyOperation; |
| | | import org.opends.server.types.operation.PreOperationModifyDNOperation; |
| | |
| | | import static org.opends.server.util.TimeThread.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class implements a Directory Server plugin that will add the |
| | | * creatorsName and createTimestamp attributes to an entry whenever it is added |
| | |
| | | { |
| | | // This must mean that the operation was performed anonymously. |
| | | // Even so, we still need to update the creatorsName attribute. |
| | | builder.add(new AttributeValue(creatorsNameType, ByteStringFactory |
| | | .create())); |
| | | builder.add(AttributeValues.create(creatorsNameType, |
| | | ByteString.empty())); |
| | | } |
| | | else |
| | | { |
| | | builder.add(new AttributeValue(creatorsNameType, ByteStringFactory |
| | | .create(creatorDN.toString()))); |
| | | builder.add(AttributeValues.create(creatorsNameType, |
| | | ByteString.valueOf(creatorDN.toString()))); |
| | | } |
| | | Attribute nameAttr = builder.toAttribute(); |
| | | ArrayList<Attribute> nameList = new ArrayList<Attribute>(1); |
| | |
| | | |
| | | // Create the attribute list for the createTimestamp attribute. |
| | | Attribute timeAttr = Attributes.create(createTimestampType, |
| | | OP_ATTR_CREATE_TIMESTAMP, new AttributeValue(createTimestampType, |
| | | ByteStringFactory.create(getGMTTime()))); |
| | | OP_ATTR_CREATE_TIMESTAMP, |
| | | AttributeValues.create(createTimestampType, |
| | | ByteString.valueOf(getGMTTime()))); |
| | | ArrayList<Attribute> timeList = new ArrayList<Attribute>(1); |
| | | timeList.add(timeAttr); |
| | | addOperation.setAttribute(createTimestampType, timeList); |
| | |
| | | { |
| | | // This must mean that the operation was performed anonymously. |
| | | // Even so, we still need to update the modifiersName attribute. |
| | | builder.add(new AttributeValue(modifiersNameType, ByteStringFactory |
| | | .create())); |
| | | builder.add(AttributeValues.create(modifiersNameType, |
| | | ByteString.empty())); |
| | | } |
| | | else |
| | | { |
| | | builder.add(new AttributeValue(modifiersNameType, ByteStringFactory |
| | | .create(modifierDN.toString()))); |
| | | builder.add(AttributeValues.create(modifiersNameType, |
| | | ByteString.valueOf(modifierDN.toString()))); |
| | | } |
| | | Attribute nameAttr = builder.toAttribute(); |
| | | try |
| | |
| | | |
| | | // Create the modifyTimestamp attribute. |
| | | Attribute timeAttr = Attributes.create(modifyTimestampType, |
| | | OP_ATTR_MODIFY_TIMESTAMP, new AttributeValue(modifyTimestampType, |
| | | ByteStringFactory.create(getGMTTime()))); |
| | | OP_ATTR_MODIFY_TIMESTAMP, |
| | | AttributeValues.create(modifyTimestampType, |
| | | ByteString.valueOf(getGMTTime()))); |
| | | try |
| | | { |
| | | modifyOperation.addModification(new Modification(ModificationType.REPLACE, |
| | |
| | | { |
| | | // This must mean that the operation was performed anonymously. |
| | | // Even so, we still need to update the modifiersName attribute. |
| | | builder.add(new AttributeValue(modifiersNameType, ByteStringFactory |
| | | .create())); |
| | | builder.add(AttributeValues.create(modifiersNameType, |
| | | ByteString.empty())); |
| | | } |
| | | else |
| | | { |
| | | builder.add(new AttributeValue(modifiersNameType, ByteStringFactory |
| | | .create(modifierDN.toString()))); |
| | | builder.add(AttributeValues.create(modifiersNameType, |
| | | ByteString.valueOf(modifierDN.toString()))); |
| | | } |
| | | Attribute nameAttr = builder.toAttribute(); |
| | | modifyDNOperation.addModification(new Modification( |
| | |
| | | |
| | | // Create the modifyTimestamp attribute. |
| | | Attribute timeAttr = Attributes.create(modifyTimestampType, |
| | | OP_ATTR_MODIFY_TIMESTAMP, new AttributeValue(modifyTimestampType, |
| | | ByteStringFactory.create(getGMTTime()))); |
| | | OP_ATTR_MODIFY_TIMESTAMP, |
| | | AttributeValues.create(modifyTimestampType, |
| | | ByteString.valueOf(getGMTTime()))); |
| | | modifyDNOperation.addModification(new Modification( |
| | | ModificationType.REPLACE, timeAttr, true)); |
| | | |