Search in sources :

Example 31 with AS400

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;
}
Also used : AS400(com.ibm.as400.access.AS400)

Example 32 with AS400

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;
}
Also used : CommandCall(com.ibm.as400.access.CommandCall) AS400(com.ibm.as400.access.AS400) AS400Message(com.ibm.as400.access.AS400Message) HopException(org.apache.hop.core.exception.HopException)

Example 33 with AS400

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();
    }
}
Also used : DefaultPooledObject(org.apache.commons.pool2.impl.DefaultPooledObject) Watch(sirius.kernel.commons.Watch) AS400(com.ibm.as400.access.AS400) Explain(sirius.kernel.commons.Explain)

Example 34 with AS400

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);
    }
}
Also used : SystemValue(com.ibm.as400.access.SystemValue) RequestNotSupportedException(com.ibm.as400.access.RequestNotSupportedException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) ConnectorSecurityException(org.identityconnectors.framework.common.exceptions.ConnectorSecurityException) IntrospectionException(java.beans.IntrospectionException) ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) RequestNotSupportedException(com.ibm.as400.access.RequestNotSupportedException) IOException(java.io.IOException) AS400SecurityException(com.ibm.as400.access.AS400SecurityException)

Example 35 with AS400

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;
}
Also used : CommandCall(com.ibm.as400.access.CommandCall) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) AS400Message(com.ibm.as400.access.AS400Message) ConnectorSecurityException(org.identityconnectors.framework.common.exceptions.ConnectorSecurityException) IntrospectionException(java.beans.IntrospectionException) ConnectorIOException(org.identityconnectors.framework.common.exceptions.ConnectorIOException) ConnectorException(org.identityconnectors.framework.common.exceptions.ConnectorException) RequestNotSupportedException(com.ibm.as400.access.RequestNotSupportedException) IOException(java.io.IOException) AS400SecurityException(com.ibm.as400.access.AS400SecurityException)

Aggregations

IFSFile (com.ibm.as400.access.IFSFile)16 AS400Text (com.ibm.as400.access.AS400Text)14 IllegalCharsetNameException (java.nio.charset.IllegalCharsetNameException)14 UnsupportedCharsetException (java.nio.charset.UnsupportedCharsetException)14 AS400Message (com.ibm.as400.access.AS400Message)12 AS400 (com.ibm.as400.access.AS400)11 CommandCall (com.ibm.as400.access.CommandCall)9 IOException (java.io.IOException)8 AS400FileRecordDescription (com.ibm.as400.access.AS400FileRecordDescription)5 Record (com.ibm.as400.access.Record)5 RecordFormat (com.ibm.as400.access.RecordFormat)5 SequentialFile (com.ibm.as400.access.SequentialFile)5 BadLocationException (javax.swing.text.BadLocationException)5 ProgramCall (com.ibm.as400.access.ProgramCall)4 Point (java.awt.Point)4 Path (java.nio.file.Path)4 AS400SecurityException (com.ibm.as400.access.AS400SecurityException)3 RequestNotSupportedException (com.ibm.as400.access.RequestNotSupportedException)3 IntrospectionException (java.beans.IntrospectionException)3 ConnectorException (org.identityconnectors.framework.common.exceptions.ConnectorException)3