ExportTask.java revision 36bb690a409d9e6e3defd678f47acbbf02bd9167
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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
*
*
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
/**
* This class provides an implementation of a Directory Server task that can
* be used to export the contents of a Directory Server backend to an LDIF file.
*/
public class ExportTask extends Task
{
/**
* Stores mapping between configuration attribute name and its label.
*/
static {
}
private int wrapColumn;
private boolean appendToLDIF;
private boolean compressLDIF;
private boolean encryptLDIF;
private boolean signHash;
/**
* {@inheritDoc}
*/
public Message getDisplayName() {
return INFO_TASK_EXPORT_NAME.get();
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
{
// If the client connection is available, then make sure the associated
// client has the LDIF_EXPORT privilege.
{
{
message);
}
}
}
/**
* {@inheritDoc}
*/
{
// filters. If so, then process them.
if (excludeAttributeStrings == null)
{
}
else
{
{
{
}
}
}
if (includeAttributeStrings == null)
{
}
else
{
{
{
}
}
}
if (excludeFilterStrings == null)
{
}
else
{
{
try
{
}
catch (DirectoryException de)
{
return TaskState.STOPPED_BY_ERROR;
}
catch (Exception e)
{
return TaskState.STOPPED_BY_ERROR;
}
}
}
if (includeFilterStrings == null)
{
}
else
{
{
try
{
}
catch (DirectoryException de)
{
return TaskState.STOPPED_BY_ERROR;
}
catch (Exception e)
{
return TaskState.STOPPED_BY_ERROR;
}
}
}
// Get the backend into which the LDIF should be imported.
{
return TaskState.STOPPED_BY_ERROR;
}
else if (! backend.supportsLDIFExport())
{
return TaskState.STOPPED_BY_ERROR;
}
{
}
if (excludeBranchStrings != null)
{
for (String s : excludeBranchStrings)
{
try
{
}
catch (DirectoryException de)
{
s, de.getMessageObject());
return TaskState.STOPPED_BY_ERROR;
}
catch (Exception e)
{
s, getExceptionMessage(e));
return TaskState.STOPPED_BY_ERROR;
}
{
}
}
}
if (!includeBranchStrings.isEmpty())
{
for (String s : includeBranchStrings)
{
try
{
}
catch (DirectoryException de)
{
s, de.getMessageObject());
return TaskState.STOPPED_BY_ERROR;
}
catch (Exception e)
{
s, getExceptionMessage(e));
return TaskState.STOPPED_BY_ERROR;
}
{
return TaskState.STOPPED_BY_ERROR;
}
}
}
else
{
}
// Create the LDIF export configuration to use when reading the LDIF.
if (appendToLDIF)
{
}
else
{
}
// FIXME -- Should this be conditional?
// Get the set of base DNs for the backend as an array.
// From here we must make sure we close the export config.
try
{
// Acquire a shared lock for the backend.
try
{
{
return TaskState.STOPPED_BY_ERROR;
}
}
catch (Exception e)
{
return TaskState.STOPPED_BY_ERROR;
}
// From here we must make sure we release the shared backend lock.
try
{
// Launch the export.
try
{
}
catch (DirectoryException de)
{
return TaskState.STOPPED_BY_ERROR;
}
catch (Exception e)
{
return TaskState.STOPPED_BY_ERROR;
}
}
finally
{
// Release the shared lock on the backend.
try
{
{
return TaskState.COMPLETED_WITH_ERRORS;
}
}
catch (Exception e)
{
return TaskState.COMPLETED_WITH_ERRORS;
}
}
}
finally
{
// Clean up after the export by closing the export config.
}
return TaskState.COMPLETED_SUCCESSFULLY;
}
}