| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS |
| | | * Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.tools.upgrade; |
| | |
| | | import javax.security.auth.callback.TextOutputCallback; |
| | | |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException; |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.tools.RebuildIndex; |
| | |
| | | * <pre> |
| | | * register("2.5.0.7192", |
| | | * newAttributeTypes(Message.raw("New attribute etag"), |
| | | * false, "00-core.ldif", "etag")); |
| | | * false, "00-core.ldif", |
| | | * "1.3.6.1.4.1.36733.2.1.1.59")); |
| | | * </pre> |
| | | * |
| | | * @param summary |
| | | * The summary of the task. |
| | | * @param fileName |
| | | * The file where to add the new attribute types. This file must be |
| | | * contained in the config/schema folder. |
| | | * @param names |
| | | * The names of the new attributes to add to. |
| | | * contained in the configuration/schema folder. |
| | | * @param attributeOids |
| | | * The OIDs of the new attributes to add to. |
| | | * @return An upgrade task which adds new attribute types, defined previously |
| | | * in the config template files, reads the definition and adds it onto |
| | | * the specified file in parameter. |
| | | * in the configuration template files, reads the definition |
| | | * and adds it onto the specified file in parameter. |
| | | */ |
| | | public static UpgradeTask newAttributeTypes(final Message summary, |
| | | final String fileName, final String... names) |
| | | final String fileName, final String... attributeOids) |
| | | { |
| | | return new AbstractUpgradeTask() |
| | | { |
| | |
| | | { |
| | | final int changeCount = |
| | | updateSchemaFile(schemaFileTemplate, pathDestination, |
| | | names, null); |
| | | attributeOids, null); |
| | | |
| | | displayChangeCount(pathDestination.getPath(), changeCount); |
| | | |
| | |
| | | manageTaskException(context, ERR_UPGRADE_ADDATTRIBUTE_FAILS.get( |
| | | schemaFileTemplate.getName(), e.getMessage()), pnc); |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | catch (final IllegalStateException e) |
| | | { |
| | | manageTaskException(context, ERR_UPGRADE_ADDATTRIBUTE_FAILS.get( |
| | | schemaFileTemplate.getName(), e.getMessage()), pnc); |
| | |
| | | * The summary of the task. |
| | | * @param fileName |
| | | * The file where to add the new object classes. This file must be |
| | | * contained in the config/schema folder. |
| | | * @param names |
| | | * The names of the new object classes to add to. |
| | | * contained in the configuration/schema folder. |
| | | * @param objectClassesOids |
| | | * The OIDs of the new object classes to add to. |
| | | * @return An upgrade task which adds new object classes, defined previously |
| | | * in the config template files, reads the definition and adds it onto |
| | | * the specified file in parameter. |
| | | * in the configuration template files, |
| | | * reads the definition and adds it onto the specified file in |
| | | * parameter. |
| | | */ |
| | | public static UpgradeTask newObjectClasses(final Message summary, |
| | | final String fileName, final String... names) |
| | | final String fileName, final String... objectClassesOids) |
| | | { |
| | | return new AbstractUpgradeTask() |
| | | { |
| | |
| | | { |
| | | final int changeCount = |
| | | updateSchemaFile(schemaFileTemplate, pathDestination, |
| | | null, names); |
| | | null, objectClassesOids); |
| | | |
| | | displayChangeCount(pathDestination.getPath(), changeCount); |
| | | |
| | |
| | | manageTaskException(context, ERR_UPGRADE_ADDOBJECTCLASS_FAILS.get( |
| | | schemaFileTemplate.getName(), e.getMessage()), pnc); |
| | | } |
| | | catch (final UnknownSchemaElementException e) |
| | | catch (final IllegalStateException e) |
| | | { |
| | | manageTaskException(context, ERR_UPGRADE_ADDOBJECTCLASS_FAILS.get( |
| | | manageTaskException(context, ERR_UPGRADE_ADDATTRIBUTE_FAILS.get( |
| | | schemaFileTemplate.getName(), e.getMessage()), pnc); |
| | | } |
| | | } |