Search in sources :

Example 1 with InitializeResponse

use of iso.std.iso_iec._24727.tech.schema.InitializeResponse in project open-ecard by ecsec.

the class SelectorSAL method initialize.

@Override
public InitializeResponse initialize(Initialize init) {
    InitializeResponse response = WSHelper.makeResponse(InitializeResponse.class, WSHelper.makeResultOK());
    // only initialize one time
    if (initializedSals.isEmpty()) {
        LinkedList<SAL> sals = new LinkedList<>();
        sals.add(main);
        sals.addAll(special);
        for (SAL next : sals) {
            try {
                InitializeResponse res = next.initialize(init);
                WSHelper.checkResult(res);
                if (!WSHelper.resultsInWarn(res)) {
                    if (next instanceof SpecializedSAL) {
                        initializedSpecializedSals.add((SpecializedSAL) next);
                    } else {
                        initializedSals.add(next);
                    }
                }
            } catch (WSHelper.WSException ex) {
                String msg = "One of the SAL instances failed to initialize:\n" + ex.getMessage();
                terminate(new Terminate());
                response.setResult(WSHelper.makeResultError(ECardConstants.Minor.Disp.COMM_ERROR, msg));
                return response;
            }
        }
    }
    return response;
}
Also used : WSHelper(org.openecard.common.WSHelper) InitializeResponse(iso.std.iso_iec._24727.tech.schema.InitializeResponse) Terminate(iso.std.iso_iec._24727.tech.schema.Terminate) LinkedList(java.util.LinkedList) SAL(org.openecard.ws.SAL) SpecializedSAL(org.openecard.common.sal.SpecializedSAL) SpecializedSAL(org.openecard.common.sal.SpecializedSAL)

Example 2 with InitializeResponse

use of iso.std.iso_iec._24727.tech.schema.InitializeResponse in project open-ecard by ecsec.

the class TinySALTest method testInitialize.

/**
 * Test of initialize method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testInitialize() {
    System.out.println("initialize");
    Initialize parameters = new Initialize();
    InitializeResponse result = instance.initialize(parameters);
    assertEquals(ECardConstants.Major.ERROR, result.getResult().getResultMajor());
}
Also used : InitializeResponse(iso.std.iso_iec._24727.tech.schema.InitializeResponse) Initialize(iso.std.iso_iec._24727.tech.schema.Initialize) Test(org.testng.annotations.Test)

Example 3 with InitializeResponse

use of iso.std.iso_iec._24727.tech.schema.InitializeResponse in project open-ecard by ecsec.

the class MiddlewareSAL method initialize.

@Override
public InitializeResponse initialize(Initialize parameters) {
    InitializeResponse resp = WSHelper.makeResponse(InitializeResponse.class, WSHelper.makeResultOK());
    try {
        mwModule.initialize();
        eventMan.initialize();
        if (gui == null) {
            throw new InternalAppError("GUI is not initialized.");
        }
    } catch (UnsatisfiedLinkError | InitializationException ex) {
        String mwSALName = mwSALConfig.getMiddlewareName();
        String msg = String.format("Failed to initialize Middleware for '%s'-SAL.", mwSALName);
        if (mwSALConfig.isSALRequired()) {
            LOG.error(msg, ex);
            resp.setResult(WSHelper.makeResultError(ECardConstants.Minor.Disp.COMM_ERROR, msg));
        } else {
            LOG.warn(msg, ex);
            resp.setResult(WSHelper.makeResult(ECardConstants.Major.WARN, ECardConstants.Minor.App.NOT_INITIALIZED, msg));
        }
    } catch (InternalAppError ex) {
        LOG.error(ex.getMessage());
        resp.setResult(ex.getResult());
    }
    return resp;
}
Also used : InitializeResponse(iso.std.iso_iec._24727.tech.schema.InitializeResponse) InitializationException(org.openecard.mdlw.sal.exceptions.InitializationException) InternalAppError(org.openecard.common.sal.exception.InternalAppError)

Aggregations

InitializeResponse (iso.std.iso_iec._24727.tech.schema.InitializeResponse)3 Initialize (iso.std.iso_iec._24727.tech.schema.Initialize)1 Terminate (iso.std.iso_iec._24727.tech.schema.Terminate)1 LinkedList (java.util.LinkedList)1 WSHelper (org.openecard.common.WSHelper)1 SpecializedSAL (org.openecard.common.sal.SpecializedSAL)1 InternalAppError (org.openecard.common.sal.exception.InternalAppError)1 InitializationException (org.openecard.mdlw.sal.exceptions.InitializationException)1 SAL (org.openecard.ws.SAL)1 Test (org.testng.annotations.Test)1