ExportTask.java revision a632fbfad0ddbe8b343c6abe8e28dc41e3df9b7e
/*
* 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 2006-2009 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* 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;
private boolean includeOperationalAttributes;
private LDIFExportConfig exportConfig;
/** {@inheritDoc} */
public LocalizableMessage getDisplayName() {
return INFO_TASK_EXPORT_NAME.get();
}
/** {@inheritDoc} */
}
/** {@inheritDoc} */
public void initializeTask() throws DirectoryException
{
// If the client connection is available, then make sure the associated
// client has the LDIF_EXPORT privilege.
{
{
message);
}
}
if (! f.isAbsolute())
{
try
{
ldifFile = f.getCanonicalPath();
}
{
ldifFile = f.getAbsolutePath();
}
}
includeOperationalAttributes = toBoolean(taskEntry, true, ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES);
}
{
}
{
}
{
}
/** {@inheritDoc} */
{
exportConfig != null)
{
}
}
/** {@inheritDoc} */
public boolean isInterruptable() {
return true;
}
/** {@inheritDoc} */
{
// filters. If so, then process them.
if (excludeFilterStrings == null)
{
}
else
{
excludeFilters = new ArrayList<>();
{
try
{
}
catch (DirectoryException de)
{
return TaskState.STOPPED_BY_ERROR;
}
catch (Exception e)
{
return TaskState.STOPPED_BY_ERROR;
}
}
}
if (includeFilterStrings == null)
{
}
else
{
includeFilters = new ArrayList<>();
{
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;
}
{
return TaskState.STOPPED_BY_ERROR;
}
if (excludeBranchStrings != null)
{
for (String s : excludeBranchStrings)
{
try
{
}
catch (DirectoryException de)
{
return TaskState.STOPPED_BY_ERROR;
}
catch (Exception e)
{
return TaskState.STOPPED_BY_ERROR;
}
{
}
}
}
if (!includeBranchStrings.isEmpty())
{
includeBranches = new ArrayList<>();
for (String s : includeBranchStrings)
{
try
{
}
catch (DirectoryException de)
{
return TaskState.STOPPED_BY_ERROR;
}
catch (Exception 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.
}
// If the operation was cancelled delete the export file since
// if will be incomplete.
if (exportConfig.isCancelled())
{
if (f.exists())
{
f.delete();
}
}
// If we got here the task either completed successfully or was interrupted
return getFinalTaskState();
}
{
if (attributeStrings == null)
{
return null;
}
{
}
return attributes;
}
}