/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
* Portions Copyright 2013-2015 ForgeRock AS.
*/
/**
* This class provides an implementation of a Directory Server task that can be
* used to add the contents of a new schema file into the server schema.
*/
public class AddSchemaFileTask
extends Task
{
/** The list of files to be added to the server schema. */
/** {@inheritDoc} */
return INFO_TASK_ADD_SCHEMA_FILE_NAME.get();
}
/** {@inheritDoc} */
public void initializeTask()
throws DirectoryException
{
// If the client connection is available, then make sure the associated
// client has the UPDATE_SCHEMA privilege.
{
{
message);
}
}
// Get the attribute that specifies which schema file(s) to add.
AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(ATTR_TASK_ADDSCHEMAFILE_FILENAME);
{
}
// Get the name(s) of the schema files to add and make sure they exist in
// the schema directory.
filesToAdd = new TreeSet<>();
{
for (ByteString v : a)
{
try
{
if (! schemaFile.exists())
{
message);
}
}
catch (Exception e)
{
logger.traceException(e);
getExceptionMessage(e));
message, e);
}
}
}
// Create a new dummy schema and make sure that we can add the contents of
// all the schema files into it. Even though this duplicates work we'll
// have to do later, it will be good to do it now as well so we can reject
// the entry immediately which will fail the attempt by the client to add it
// to the server, rather than having to check its status after the fact.
{
try
{
}
catch (ConfigException | InitializationException e)
{
logger.traceException(e);
LocalizableMessage message = ERR_TASK_ADDSCHEMAFILE_ERROR_LOADING_SCHEMA_FILE.get(schemaFile, e.getMessage());
}
}
}
/** {@inheritDoc} */
{
// Obtain a write lock on the server schema so that we can be sure nothing
// else tries to write to it at the same time.
if (schemaLock == null)
{
return TaskState.STOPPED_BY_ERROR;
}
try
{
{
try
{
for (Modification m : modList)
{
Attribute a = m.getAttribute();
.getAttributeType(), a.getName());
for (ByteString v : a)
{
if (!s.contains(SCHEMA_PROPERTY_FILENAME))
{
if (s.endsWith(" )"))
{
}
else if (s.endsWith(")"))
{
}
}
}
.toAttribute()));
}
}
catch (ConfigException | InitializationException e)
{
logger.traceException(e);
return TaskState.STOPPED_BY_ERROR;
}
}
{
{
try
{
}
catch (Exception e)
{
logger.traceException(e);
}
}
}
return TaskState.COMPLETED_SUCCESSFULLY;
}
finally
{
schemaLock.unlock();
}
}
}