/** * Renders a list of attributeTypes for things like the must or may list of * objectClasses using the ( oid $ oid ) format. * * @param ats * the attributeTypes to list * @return a buffer which contains the rendered list */ public static StringBuilder render( AttributeType[] ats ) { StringBuilder buf = new StringBuilder(); return render( buf, ats ); }
/** * Normalize the ReturningAttributes. It reads all the String from the returningAttributesString, * and grab the associated AttributeType from the schema to store it into the returningAttributes * Set. * * @param schemaManager The schema manager */ public void normalize( SchemaManager schemaManager ) { for ( String returnAttribute : returningAttributesStr ) { try { String id = SchemaUtils.stripOptions( returnAttribute ); Set<String> options = SchemaUtils.getOptions( returnAttribute ); AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); AttributeTypeOptions attrOptions = new AttributeTypeOptions( attributeType, options ); returningAttributes.add( attrOptions ); } catch ( LdapException ne ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_13500_ATTRIBUTE_NOT_IN_SCHEMA, returnAttribute ) ); } // Unknown attributes should be silently ignored, as RFC 2251 states } } }
/** * Returns a String description of a schema. The resulting String format is : * <br> * (OID [DESC '<description>'] FQCN <fcqn> [BYTECODE <bytecode>] X-SCHEMA '<schema>') * <br> * @param description The description to transform to a String * @return The rendered schema object */ public static String render( LoadableSchemaObject description ) { StringBuilder buf = new StringBuilder(); buf.append( "( " ).append( description.getOid() ); if ( description.getDescription() != null ) { buf.append( " DESC " ); renderQDString( buf, description.getDescription() ); } buf.append( " FQCN " ).append( description.getFqcn() ); if ( !Strings.isEmpty( description.getBytecode() ) ) { buf.append( " BYTECODE " ).append( description.getBytecode() ); } buf.append( " X-SCHEMA '" ); buf.append( getSchemaName( description ) ); buf.append( "' )" ); return buf.toString(); }
/** * {@inheritDoc} */ @Override public AttributeType getAttributeType( String oid ) { try { // Get rid of the options String attributeTypeNoOptions = SchemaUtils.stripOptions( oid ); return registries.getAttributeTypeRegistry().lookup( Strings.toLowerCaseAscii( attributeTypeNoOptions ).trim() ); } catch ( LdapException lnsae ) { return null; } }
/** * Check that we can modify an entry */ private void checkModify( ModifyOperationContext modifyContext ) throws LdapException { List<Modification> mods = modifyContext.getModItems(); Entry originalEntry = modifyContext.getEntry(); Entry targetEntry = SchemaUtils.getTargetEntry( mods, originalEntry ); // If the modified entry contains the CollectiveAttributeSubentry, then the modification // is accepted, no matter what if ( targetEntry.contains( directoryService.getAtProvider().getObjectClass(), SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRY_OC ) ) { return; } // Check that we don't add any collectve attribute, this is not allowed on normal entries if ( hasCollectiveAttributes( mods ) ) { /* * TODO: Replace the Exception and the ResultCodeEnum with the correct ones. */ LOG.info( "Cannot modify the entry {} : it contains some CollectiveAttributes and is not a collective subentry", targetEntry ); throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, I18n.err( I18n.ERR_242 ) ); } }
/** * Normalize the ReturningAttributes. It reads all the String from the returningAttributesString, * and grab the associated AttributeType from the schema to store it into the returningAttributes * Set. * * @param schemaManager The schema manager */ public void normalize( SchemaManager schemaManager ) { for ( String returnAttribute : returningAttributesStr ) { try { String id = SchemaUtils.stripOptions( returnAttribute ); Set<String> options = SchemaUtils.getOptions( returnAttribute ); AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); AttributeTypeOptions attrOptions = new AttributeTypeOptions( attributeType, options ); returningAttributes.add( attrOptions ); } catch ( LdapException ne ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_13500_ATTRIBUTE_NOT_IN_SCHEMA, returnAttribute ) ); } // Unknown attributes should be silently ignored, as RFC 2251 states } } }
/** * Returns a String description of a schema. The resulting String format is : * <br> * (OID [DESC '<description>'] FQCN <fcqn> [BYTECODE <bytecode>] X-SCHEMA '<schema>') * <br> * @param description The description to transform to a String * @return The rendered schema object */ public static String render( LoadableSchemaObject description ) { StringBuilder buf = new StringBuilder(); buf.append( "( " ).append( description.getOid() ); if ( description.getDescription() != null ) { buf.append( " DESC " ); renderQDString( buf, description.getDescription() ); } buf.append( " FQCN " ).append( description.getFqcn() ); if ( !Strings.isEmpty( description.getBytecode() ) ) { buf.append( " BYTECODE " ).append( description.getBytecode() ); } buf.append( " X-SCHEMA '" ); buf.append( getSchemaName( description ) ); buf.append( "' )" ); return buf.toString(); }
/** * {@inheritDoc} */ @Override public AttributeType getAttributeType( String oid ) { try { // Get rid of the options String attributeTypeNoOptions = SchemaUtils.stripOptions( oid ); return registries.getAttributeTypeRegistry().lookup( Strings.toLowerCaseAscii( attributeTypeNoOptions ).trim() ); } catch ( LdapException lnsae ) { return null; } }
/** * {@inheritDoc} */ public void modify( ModifyOperationContext modifyContext ) throws LdapException { Entry entry = modifyContext.getEntry(); if ( entry == null ) { LookupOperationContext lookupCtx = new LookupOperationContext( modifyContext.getSession(), modifyContext.getDn() ); lookupCtx.setPartition( this ); lookupCtx.setTransaction( modifyContext.getTransaction() ); entry = wrapped.lookup( lookupCtx ); modifyContext.setEntry( entry ); } Entry targetEntry = SchemaUtils.getTargetEntry( modifyContext.getModItems(), entry ); boolean cascade = modifyContext.hasRequestControl( Cascade.OID ); boolean hasModification = synchronizer.modify( modifyContext, targetEntry, cascade ); if ( hasModification ) { wrapped.modify( modifyContext ); } if ( !modifyContext.getDn().equals( schemaModificationDN ) ) { updateSchemaModificationAttributes( modifyContext ); } }
/** * Normalize the ReturningAttributes. It reads all the String from the returningAttributesString, * and grab the associated AttributeType from the schema to store it into the returningAttributes * Set. * * @param schemaManager The schema manager */ public void normalize( SchemaManager schemaManager ) { for ( String returnAttribute : returningAttributesStr ) { try { String id = SchemaUtils.stripOptions( returnAttribute ); Set<String> options = SchemaUtils.getOptions( returnAttribute ); AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); AttributeTypeOptions attrOptions = new AttributeTypeOptions( attributeType, options ); returningAttributes.add( attrOptions ); } catch ( LdapException ne ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_13500_ATTRIBUTE_NOT_IN_SCHEMA, returnAttribute ) ); } // Unknown attributes should be silently ignored, as RFC 2251 states } } }
/** * Renders a list of attributeTypes for things like the must or may list of * objectClasses using the ( oid $ oid ) format. * * @param ats * the attributeTypes to list * @return a buffer which contains the rendered list */ public static StringBuilder render( AttributeType[] ats ) { StringBuilder buf = new StringBuilder(); return render( buf, ats ); }
/** * Returns a String description of a schema. The resulting String format is : * <br> * (OID [DESC '<description>'] FQCN <fcqn> [BYTECODE <bytecode>] X-SCHEMA '<schema>') * <br> * @param description The description to transform to a String * @return The rendered schema object */ public static String render( LoadableSchemaObject description ) { StringBuilder buf = new StringBuilder(); buf.append( "( " ).append( description.getOid() ); if ( description.getDescription() != null ) { buf.append( " DESC " ); renderQDString( buf, description.getDescription() ); } buf.append( " FQCN " ).append( description.getFqcn() ); if ( !Strings.isEmpty( description.getBytecode() ) ) { buf.append( " BYTECODE " ).append( description.getBytecode() ); } buf.append( " X-SCHEMA '" ); buf.append( getSchemaName( description ) ); buf.append( "' )" ); return buf.toString(); }
/** * {@inheritDoc} */ @Override public AttributeType getAttributeType( String oid ) { try { // Get rid of the options String attributeTypeNoOptions = SchemaUtils.stripOptions( oid ); return registries.getAttributeTypeRegistry().lookup( Strings.toLowerCaseAscii( attributeTypeNoOptions ).trim() ); } catch ( LdapException lnsae ) { return null; } }
String id = SchemaUtils.stripOptions( returnAttribute ); Set<String> options = SchemaUtils.getOptions( returnAttribute );
/** * Renders a list of object classes for things like a list of superior * objectClasses using the ( oid $ oid ) format. * * @param ocs * the objectClasses to list * @return a buffer which contains the rendered list */ public static StringBuilder render( ObjectClass[] ocs ) { StringBuilder buf = new StringBuilder(); return render( buf, ocs ); }
String id = SchemaUtils.stripOptions( attributeId ); Set<String> options = SchemaUtils.getOptions( attributeId );
/** * Renders a list of object classes for things like a list of superior * objectClasses using the ( oid $ oid ) format. * * @param ocs * the objectClasses to list * @return a buffer which contains the rendered list */ public static StringBuilder render( ObjectClass[] ocs ) { StringBuilder buf = new StringBuilder(); return render( buf, ocs ); }
/** * Renders a list of object classes for things like a list of superior * objectClasses using the ( oid $ oid ) format. * * @param ocs * the objectClasses to list * @return a buffer which contains the rendered list */ public static StringBuilder render( ObjectClass[] ocs ) { StringBuilder buf = new StringBuilder(); return render( buf, ocs ); }
/** * Renders a list of attributeTypes for things like the must or may list of * objectClasses using the ( oid $ oid ) format. * * @param ats * the attributeTypes to list * @return a buffer which contains the rendered list */ public static StringBuilder render( AttributeType[] ats ) { StringBuilder buf = new StringBuilder(); return render( buf, ats ); }
/** * Generate the comparators attribute from the registry */ private static Attribute generateComparators( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( SchemaConstants.COMPARATORS_AT ) ); for ( LdapComparator<?> comparator : schemaManager.getComparatorRegistry() ) { attr.add( SchemaUtils.render( comparator ) ); } return attr; }