From e4a47aa9393d74647f4f0c66b54dc4519fed492f Mon Sep 17 00:00:00 2001 From: clemenso Date: Tue, 11 Nov 2008 12:16:00 +0000 Subject: Interrupt in waitForAction (applet closed) git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@162 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../egiz/bku/smccstal/AbstractRequestHandler.java | 9 +++---- .../at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java | 28 ++++++++++++++++------ .../bku/smccstal/InfoBoxReadRequestHandler.java | 4 ++-- .../egiz/bku/smccstal/SMCCSTALRequestHandler.java | 2 +- .../gv/egiz/bku/smccstal/SignRequestHandler.java | 4 ++-- 5 files changed, 31 insertions(+), 16 deletions(-) (limited to 'smccSTAL/src/main/java/at') diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractRequestHandler.java index 995e2b77..98b21f79 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractRequestHandler.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractRequestHandler.java @@ -39,8 +39,8 @@ public abstract class AbstractRequestHandler implements SMCCSTALRequestHandler, protected boolean actionPerformed = false; @Override - public abstract STALResponse handleRequest(STALRequest request); - + public abstract STALResponse handleRequest(STALRequest request) throws InterruptedException; + @Override public void init(SignatureCard sc, BKUGUIFacade gui) { if ((sc == null) || (gui == null)) { @@ -60,13 +60,14 @@ public abstract class AbstractRequestHandler implements SMCCSTALRequestHandler, } } - protected synchronized void waitForAction() { + protected synchronized void waitForAction() throws InterruptedException { try { while (!actionPerformed) { wait(); } } catch (InterruptedException e) { - log.info(e); + log.error("interrupt in waitForAction"); + throw e; } actionPerformed = false; } diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java index f310dd42..04d8d0dd 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java @@ -24,6 +24,8 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,6 +36,7 @@ import at.gv.egiz.stal.InfoboxReadRequest; import at.gv.egiz.stal.STAL; import at.gv.egiz.stal.STALRequest; import at.gv.egiz.stal.STALResponse; +import java.util.Collections; public abstract class AbstractSMCCSTAL implements STAL { private static Log log = LogFactory.getLog(AbstractSMCCSTAL.class); @@ -61,7 +64,7 @@ public abstract class AbstractSMCCSTAL implements STAL { protected abstract BKUGUIFacade getGUI(); - private STALResponse getRespone(STALRequest request) { + private STALResponse getRespone(STALRequest request) throws InterruptedException { log.info("Processing: " + request.getClass()); int retryCounter = 0; while (retryCounter < maxRetries) { @@ -99,6 +102,9 @@ public abstract class AbstractSMCCSTAL implements STAL { log.info("Got null response from handler, assuming quit"); return null; } + } catch (InterruptedException e) { + log.info("Interrupt in handleRequest, do not retry"); + throw e; } catch (Exception e) { log.info("Error while handling STAL request:" + e); if (++retryCounter < maxRetries) { @@ -125,14 +131,22 @@ public abstract class AbstractSMCCSTAL implements STAL { .size()); for (STALRequest request : requestList) { log.info("Processing: " + request.getClass()); - STALResponse response = getRespone(request); - if (response != null) { - responseList.add(response); - if (response instanceof ErrorResponse) { - log.info("Got an error response, don't process remaining requests"); - break; + STALResponse response; + try { + response = getRespone(request); + if (response != null) { + responseList.add(response); + if (response instanceof ErrorResponse) { + log.info("Got an error response, don't process remaining requests"); + break; + } } + } catch (InterruptedException ex) { + log.error("got interrupted, return ErrorResponse 6001"); + responseList = Collections.singletonList((STALResponse) new ErrorResponse(6001)); + break; } + } return responseList; } diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java index cfc5c4bd..04f179e7 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java @@ -41,7 +41,7 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements private int retryCounter = 0; @Override - public STALResponse handleRequest(STALRequest request) { + public STALResponse handleRequest(STALRequest request) throws InterruptedException { if (request instanceof InfoboxReadRequest) { InfoboxReadRequest infoBox = (InfoboxReadRequest) request; try { @@ -134,7 +134,7 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements } @Override - public String providePIN(PINSpec spec, int retries) { + public String providePIN(PINSpec spec, int retries) throws InterruptedException { if (retryCounter++ > 0) { log.info("PIN wrong retrying ..."); gui.showCardPINRetryDialog(spec, retries, this, "ok", this, "cancel"); diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java index 94ab7a5b..f19b3ef3 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java @@ -26,7 +26,7 @@ public interface SMCCSTALRequestHandler { public void init(SignatureCard sc, BKUGUIFacade gui); - public STALResponse handleRequest(STALRequest request); + public STALResponse handleRequest(STALRequest request) throws InterruptedException; public boolean requireCard(); diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java index dbc70bff..6c30a68a 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java @@ -67,7 +67,7 @@ public abstract class SignRequestHandler extends AbstractRequestHandler implemen @SuppressWarnings("unchecked") @Override - public STALResponse handleRequest(STALRequest request) { + public STALResponse handleRequest(STALRequest request) throws InterruptedException { if (request instanceof SignRequest) { SignRequest signReq = (SignRequest) request; newSTALMessage("Message.RequestCaption", "Message.SignRequest"); @@ -213,7 +213,7 @@ public abstract class SignRequestHandler extends AbstractRequestHandler implemen } @Override - public String providePIN(PINSpec spec, int retries) { + public String providePIN(PINSpec spec, int retries) throws InterruptedException { showSignaturePINDialog(spec, retries); -- cgit v1.2.3