com.autonomy.nonaci.indexing.impl.DreAddCommand 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 index IDX or XML files located on the same machine as IDOL server directly into an IDOL server.
* Parameters you use with DREADD override any equivalent settings in IDOL server's configuration file.
*
* If you have set DelayedSync to true or you have set a high MaxSyncDelay in the configuration file,
* some time may elapse before a file is indexed.
*
* Note: You must specify dreDbName or databaseFields if the IDOL server
* configuration file does not contain a field process that allows it to read documents' destination databases from
* fields they contain.
*
* @author boba
*/
public class DreAddCommand extends AbstractAddCommand {
private String indexFile;
private final URLCodec urlCodec = new URLCodec();
/** Creates a new instance of DreAddCommand. */
public DreAddCommand() {
super(CMD_DREADD);
}
@Override
public String getQueryString() {
try {
// Get the query string comprising of all the other parameters...
final String queryString = super.getQueryString();
return StringUtils.isNotBlank(queryString)
? urlCodec.encode(indexFile, "UTF-8") + '&' + queryString
: urlCodec.encode(indexFile, "UTF-8");
}
catch(final UnsupportedEncodingException uee) {
throw new IndexingException(uee);
}
}
public String getIndexFile() {
return indexFile;
}
/**
* Enter the full path to the IDX or XML file you want to index. Note: The DREADD command also accepts IDX or XML
* files that are compressed by gzip.
*
* @param indexFile The full path to the IDX or XML file to be indexed.
*/
public void setIndexFile(final String indexFile) {
this.indexFile = indexFile;
}
public boolean isDelete() {
return BooleanUtils.toBoolean(get(PARAM_DELETE));
}
/**
* When set to true, IDOL server deletes the file you are indexing after it is indexed.
*
* @param delete true to delete the IDX or XML file after indexing.
*/
public void setDelete(final boolean delete) {
put(PARAM_DELETE, BooleanUtils.toStringTrueFalse(delete));
}
} // End of class DreAddCommand...