use of com.ibm.as400.access.AS400 in project hop by apache.
the class ActionAs400Command method test.
public boolean test(IVariables variables, final String server, final String user, final String password, final String proxyHost, final String proxyPort) throws Exception {
// Create proxy server
String proxyServer = this.getProxyServer(variables.resolve(proxyHost), variables.resolve(proxyPort));
// Create an AS400 object
AS400 system = new AS400(variables.resolve(server), variables.resolve(user), Utils.resolvePassword(this, password), proxyServer);
system.connectService(AS400.COMMAND);
return true;
}
use of com.ibm.as400.access.AS400 in project hop by apache.
the class ActionAs400Command method execute.
@Override
public Result execute(final Result result, int nr) throws HopException {
AS400 system = null;
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "ActionAs400Command.Log.Started"));
}
// Resolve variables
String serverString = resolve(server);
String userString = resolve(user);
String passwordString = Utils.resolvePassword(this, password);
String commandString = resolve(command);
try {
// Create proxy server
String proxyServer = this.getProxyServer(resolve(proxyHost), resolve(proxyPort));
// Create an AS400 object
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "ActionAs400Command.Log.Connecting", serverString, userString));
}
system = new AS400(serverString, userString, passwordString, proxyServer);
// Connect to service
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "ActionAs400Command.Log.Connected", serverString));
}
// Run the command
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "ActionAs400Command.Log.CommandRun", commandString));
}
final CommandCall command = new CommandCall(system);
if (command.run(commandString)) {
if (isBasic()) {
logBasic(BaseMessages.getString(PKG, "ActionAs400Command.Log.CommandSuccess", serverString, commandString));
}
result.setNrErrors(0);
result.setResult(true);
} else {
logError(BaseMessages.getString(PKG, "ActionAs400Command.Log.CommandFailed", serverString, commandString));
// Get the command results
for (AS400Message message : command.getMessageList()) {
logError(message.getID() + ':' + message.getText());
logError(message.getHelp());
}
result.setNrErrors(1);
result.setResult(false);
}
} catch (Exception e) {
logError(BaseMessages.getString(PKG, "ActionAs400Command.Log.CommandFailed", serverString, commandString), e);
result.setNrErrors(1);
result.setResult(false);
} finally {
try {
// Make sure to disconnect
system.disconnectService(AS400.COMMAND);
} catch (Exception e) {
// Ignore
}
}
return result;
}
use of com.ibm.as400.access.AS400 in project sirius-biz by scireum.
the class I5ConnectionPool method makeObject.
@Override
@SuppressWarnings("squid:S2095")
@Explain("We cannot close the i5 connection here as it is returned as PooledObject")
public PooledObject<I5Connection> makeObject() throws Exception {
try {
Watch w = Watch.start();
I5Connection result = new I5Connection();
result.pool = this;
result.i5 = new AS400(host, username, password);
result.initialize();
w.submitMicroTiming("UPOS", "I5ConnectionPool.makeObject");
openConnections.add(new WeakReference<>(result));
return new DefaultPooledObject<>(result);
} catch (Exception e) {
throw Exceptions.handle().to(I5Connector.LOG).error(e).withSystemErrorMessage("Cannot create connection to %s as %s: %s (%s)", host, username).handle();
}
}
use of com.ibm.as400.access.AS400 in project openicf by Evolveum.
the class OS400Connector method fetchPasswordLevel.
protected void fetchPasswordLevel() throws ConnectorException {
try {
SystemValue systemValue = new SystemValue(as400, "QPWDLVL");
Object qpwdlvl = systemValue.getValue();
if (qpwdlvl instanceof Integer) {
this.passwordLevel = ((Integer) qpwdlvl).intValue();
}
} catch (RequestNotSupportedException e) {
this.passwordLevel = QPWDLVL_UNSET;
LOG.error("QPWDLVL System Value not supported on this resource");
} catch (Exception e) {
throw new ConnectorException(e);
}
}
use of com.ibm.as400.access.AS400 in project openicf by Evolveum.
the class OS400Connector method runCommand.
protected boolean runCommand(String command) throws ConnectorException {
boolean success = false;
try {
CommandCall cc = new CommandCall(as400);
cc.setCommand(command);
success = cc.run();
AS400Message[] msgs = cc.getMessageList();
if (success) {
// TODO implement
} else {
// TODO implement
}
} catch (Exception e) {
throw new ConnectorException(e);
}
return success;
}
Aggregations