com.autonomy.nonaci.indexing.impl.DreInitialCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of indexing-api Show documentation
Show all versions of indexing-api Show documentation
API for indexing into IDOL using Java
/*
* (c) Copyright 2008-2015 Micro Focus or one of its affiliates.
*
* Licensed under the MIT License (the "License"); you may not use this file
* except in compliance with the License.
*
* The only warranties for products and services of Micro Focus and its affiliates
* and licensors ("Micro Focus") are as may be set forth in the express warranty
* statements accompanying such products and services. Nothing herein should be
* construed as constituting an additional warranty. Micro Focus shall not be
* liable for technical or editorial errors or omissions contained herein. The
* information contained herein is subject to change without notice.
*/
package com.autonomy.nonaci.indexing.impl;
import com.autonomy.nonaci.indexing.IndexingException;
import org.apache.commons.codec.net.URLCodec;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.UnsupportedEncodingException;
/**
* Allows you to delete all data from your IDOL server's data index, and to reset the data index. Your configuration
* file is not reset, so none of your changes are lost.
*
* You can also use the DREINITIAL command to restore backed up files to an IDOL server.
*
* @author boba
*/
public class DreInitialCommand extends IndexCommandImpl {
/** The full path to the data backup. */
private String path;
private final URLCodec urlCodec = new URLCodec();
/**
* Default constructor...
*/
public DreInitialCommand() {
super(CMD_DREINITIAL);
}
@Override
public String getQueryString() {
// Get the query string comprising of all the other parameters...
final String queryString = super.getQueryString();
try {
return (StringUtils.isBlank(path))
? queryString
: StringUtils.isBlank(queryString)
? urlCodec.encode(path, "UTF-8")
: urlCodec.encode(path, "UTF-8") + '&' + queryString;
}
catch(final UnsupportedEncodingException uee) {
throw new IndexingException(uee);
}
}
public String getInitialId() {
return get(PARAM_INITIAL_ID);
}
/**
* Enter the ID of the DREINITIAL command that should be processed when multiple commands are sent.
*
* In a system with an array of DIHs, a DREINITIAL command could be sent to an engine multiple
* times; and if there was a delay in sending a subsequent command, documents could be deleted that in fact arrived
* after the original DREINITIAL. The InitialID parameter ensures that when a
* DREINITIAL command is received by an engine multiple times, only the first command (identified
* by the InitialID) is processed, and the rest are ignored.
*
* @param initialId The ID of the DREINITIAL command that should be processed when multiple
* commands are sent.
*/
public void setInitialId(final String initialId) {
put(PARAM_INITIAL_ID, initialId);
}
public String getHostDetails() {
return get(PARAM_INITIAL_ID);
}
/**
* Specifies that the restoration should use a backup directory based on a specific host/port combination.
*
* When using DREBACKUP you can set HostDetails to true, so that
* the backup will be written to a subdirectory named with the host and ACI port of the engine. You can then restore
* these backups using a DREINITIAL action with HostDetails set to true
* .This allows you to restore a series of engines under a Distributed Index Handler (DIH) from their own
* backup.
*
* @param hostDetails Specifies that the restoration should use a backup directory based on a specific host/port
* combination.
*/
public void setHostDetails(final boolean hostDetails) {
put(PARAM_HOST_DETAILS, BooleanUtils.toStringTrueFalse(hostDetails));
}
public String getPath() {
return path;
}
/**
* Enter the full path to where IDOL server's backups are stored.
*
* @param path The full path to the data backup.
*/
public void setPath(final String path) {
this.path = path;
}
} // End of class DreInitialCommand...