当前位置: 首页>>代码示例>>Java>>正文


Java ModificationItem.getModificationOp方法代码示例

本文整理汇总了Java中javax.naming.directory.ModificationItem.getModificationOp方法的典型用法代码示例。如果您正苦于以下问题:Java ModificationItem.getModificationOp方法的具体用法?Java ModificationItem.getModificationOp怎么用?Java ModificationItem.getModificationOp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.naming.directory.ModificationItem的用法示例。


在下文中一共展示了ModificationItem.getModificationOp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toServerModification

import javax.naming.directory.ModificationItem; //导入方法依赖的package包/类
/**
 * Convert a ModificationItem to an instance of a ServerModification object
 *
 * @param modificationImpl the modification instance to convert
 * @param attributeType the associated attributeType
 * @return a instance of a ServerModification object
 */
private static Modification toServerModification( ModificationItem modificationImpl, AttributeType attributeType )
    throws LdapException
{
    ModificationOperation operation;

    switch ( modificationImpl.getModificationOp() )
    {
        case DirContext.REMOVE_ATTRIBUTE:
            operation = ModificationOperation.REMOVE_ATTRIBUTE;
            break;

        case DirContext.REPLACE_ATTRIBUTE:
            operation = ModificationOperation.REPLACE_ATTRIBUTE;
            break;

        case DirContext.ADD_ATTRIBUTE:
        default:
            operation = ModificationOperation.ADD_ATTRIBUTE;
            break;

    }

    Modification modification = new DefaultModification(
        operation,
        ServerEntryUtils.toServerAttribute( modificationImpl.getAttribute(), attributeType ) );

    return modification;

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:37,代码来源:ServerEntryUtils.java

示例2: dumpModificationItems

import javax.naming.directory.ModificationItem; //导入方法依赖的package包/类
/**
 * Dumps the modifications
 */
private String dumpModificationItems()
{
    StringBuffer sb = new StringBuffer();

    for (ModificationItem modif : modificationList) {
        sb.append("            Operation: ");

        switch (modif.getModificationOp()) {
            case DirContext.ADD_ATTRIBUTE :
                sb.append("ADD\n");
                break;

            case DirContext.REMOVE_ATTRIBUTE :
                sb.append("REMOVE\n");
                break;

            case DirContext.REPLACE_ATTRIBUTE :
                sb.append("REPLACE \n");
                break;
        }

        Attribute attribute = modif.getAttribute();

        sb.append("                Attribute: ").append(attribute.getID()).append('\n');

        if (attribute.size() != 0) {
            try {
                for (NamingEnumeration values = attribute.getAll(); values.hasMoreElements();) {
                    Object value = values.nextElement();

                    if (value instanceof String) {
                        sb.append("                ").append((String) value).append('\n');
                    } else {
                        sb.append("                ").append(Utils.dumpBytes((byte[]) value)).append('\n');
                    }
                }
            }
            catch (NamingException ne) {
                return "";
            }
        }
    }

    return sb.toString();
}
 
开发者ID:scriptella,项目名称:scriptella-etl,代码行数:49,代码来源:Entry.java

示例3: modifyAttributes

import javax.naming.directory.ModificationItem; //导入方法依赖的package包/类
public void modifyAttributes(Name name, ModificationItem[] modificationItems)
        throws NamingException {
    checkName(name);

    if (modificationItems == null) {
        // FIXME: spec say ModificationItem may not be null, but ri
        // silence in this case
        throw new NullPointerException(Messages.getString("ldap.27")); //$NON-NLS-1$
    }

    if (hasMultiNamingSpace(name)) {
        /*
         * multi ns, find next ns context, delegate operation to the next
         * context
         */
        DirContext nns = (DirContext) findNnsContext(name);
        Name remainingName = name.getSuffix(1);
        nns.modifyAttributes(remainingName, modificationItems);
        return;
    }

    if (modificationItems.length == 0) {
        return;
    }

    /*
     * there is only one ldap ns
     */
    // get absolute dn name
    String targetDN = getTargetDN(name, contextDn);
    ModifyOp op = new ModifyOp(targetDN);
    for (ModificationItem item : modificationItems) {
        switch (item.getModificationOp()) {
        case DirContext.ADD_ATTRIBUTE:
            op.addModification(0, new LdapAttribute(item.getAttribute(),
                    this));
            break;
        case DirContext.REMOVE_ATTRIBUTE:
            op.addModification(1, new LdapAttribute(item.getAttribute(),
                    this));
            break;
        case DirContext.REPLACE_ATTRIBUTE:
            op.addModification(2, new LdapAttribute(item.getAttribute(),
                    this));
            break;
        default:
            throw new IllegalArgumentException(Messages.getString(
                    "jndi.14", item.getModificationOp())); //$NON-NLS-1$
        }
    }

    try {
        doBasicOperation(op);
    } catch (ReferralException e) {
        if (isFollowReferral(e)) {
            DirContext referralContext = getReferralContext(e);
            referralContext.modifyAttributes(name, modificationItems);
            return;
        }
        throw e;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:63,代码来源:LdapContextImpl.java

示例4: getCompensatingModificationItem

import javax.naming.directory.ModificationItem; //导入方法依赖的package包/类
/**
 * Get a ModificationItem to use for rollback of the supplied modification.
 * 
 * @param originalAttributes
 *            All Attributes of the target DN that are affected of any of
 *            the ModificationItems.
 * @param modificationItem
 *            the ModificationItem to create a rollback item for.
 * @return A ModificationItem to use for rollback of the supplied
 *         ModificationItem.
 */
protected ModificationItem getCompensatingModificationItem(
        Attributes originalAttributes, ModificationItem modificationItem) {
    Attribute modificationAttribute = modificationItem.getAttribute();
    Attribute originalAttribute = originalAttributes
            .get(modificationAttribute.getID());

    if (modificationItem.getModificationOp() == DirContext.REMOVE_ATTRIBUTE) {
        if (modificationAttribute.size() == 0) {
            // If the modification attribute size it means that the
            // Attribute should be removed entirely - we should store a
            // ModificationItem to restore all present values for rollback.
            return new ModificationItem(DirContext.ADD_ATTRIBUTE,
                    (Attribute) originalAttribute.clone());
        } else {
            // The rollback modification will be to re-add the removed
            // attribute values.
            return new ModificationItem(DirContext.ADD_ATTRIBUTE,
                    (Attribute) modificationAttribute.clone());
        }
    } else if (modificationItem.getModificationOp() == DirContext.REPLACE_ATTRIBUTE) {
        if (originalAttribute != null) {
            return new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
                    (Attribute) originalAttribute.clone());
        } else {
            // The attribute doesn't previously exist - the rollback
            // operation will be to remove the attribute.
            return new ModificationItem(DirContext.REMOVE_ATTRIBUTE,
                    new BasicAttribute(modificationAttribute.getID()));
        }
    } else {
        // An ADD_ATTRIBUTE operation
        if (originalAttribute == null) {
            // The attribute doesn't previously exist - the rollback
            // operation will be to remove the attribute.
            return new ModificationItem(DirContext.REMOVE_ATTRIBUTE,
                    new BasicAttribute(modificationAttribute.getID()));
        } else {
            // The attribute does exist before - we should store the
            // previous value and it should be used for replacing in
            // rollback.
            return new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
                    (Attribute) originalAttribute.clone());
        }
    }
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:57,代码来源:ModifyAttributesOperationRecorder.java


注:本文中的javax.naming.directory.ModificationItem.getModificationOp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。