Introduced processor that operates on Postfix hashed files.
This commit is contained in:
parent
1d8141e6b0
commit
632833308a
55
hsarback/src/de/hsadmin/core/qserv/PostmapProcessor.java
Normal file
55
hsarback/src/de/hsadmin/core/qserv/PostmapProcessor.java
Normal file
@ -0,0 +1,55 @@
|
||||
package de.hsadmin.core.qserv;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PostmapProcessor extends AbstractProcessor {
|
||||
|
||||
private static final long serialVersionUID = 506775231401876523L;
|
||||
private HashMap<String, String> operations;
|
||||
private String file;
|
||||
private String error;
|
||||
|
||||
public PostmapProcessor(String file) {
|
||||
super();
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public void set(String key, String value) {
|
||||
operations.put(key, value);
|
||||
}
|
||||
|
||||
public void unset(String key) {
|
||||
operations.put(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String logInfo() {
|
||||
StringBuffer log = new StringBuffer("Postmap\n");
|
||||
log.append("\nError: ");
|
||||
log.append(error);
|
||||
log.append("\n");
|
||||
return log.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object process() throws ProcessorException {
|
||||
ArrayList<String> output = new ArrayList<String>();
|
||||
for (String key : operations.keySet()) {
|
||||
String value = operations.get(key);
|
||||
try {
|
||||
if (value == null) {
|
||||
output.add(CommandShell.execute("/usr/sbin/postmap -d " + key + " " + file));
|
||||
} else {
|
||||
output.add(CommandShell.execute("/usr/sbin/postmap -i " + file, key + "\t" + value));
|
||||
}
|
||||
} catch (ShellException e) {
|
||||
error = e.getMessage();
|
||||
e.printStackTrace(System.err); // Logging
|
||||
throw new ProcessorException(e);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user