From fed2f58dda88649d78a63e2aa3e63705677cbed9 Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Thu, 30 Jun 2016 15:37:01 +0200 Subject: Replace signature note if it's the previous default --- .../workflow/states/PrepareConfigurationState.java | 41 ++++++++++++++++------ .../at/asit/pdfover/gui/messages.properties | 3 +- .../at/asit/pdfover/gui/messages_de.properties | 3 +- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java index 327bb0c3..b1af315e 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareConfigurationState.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URI; +import java.util.Locale; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.GetMethod; @@ -118,7 +119,7 @@ public class PrepareConfigurationState extends State { // we only check for resource config file if it is the // default value! try { - InputStream is = this.getClass().getResourceAsStream( + InputStream is = getClass().getResourceAsStream( Constants.RES_PKG_PATH + filename); getStateMachine().getConfigProvider() .loadConfiguration(is); @@ -138,6 +139,23 @@ public class PrepareConfigurationState extends State { } } + /** + * Update configuration values as necessary + */ + private void updateConfiguration() { + ConfigProvider config = getStateMachine().getConfigProvider(); + + //Update signature note if old default is used + String note = config.getSignatureNote(); + Locale loc = config.getSignatureLocale(); + + String note_old = Messages.getString("simple_config.Note_Default_Old", loc); //$NON-NLS-1$ + if (note.equals(note_old)) { + note = Messages.getString("simple_config.Note_Default", loc); //$NON-NLS-1$ + getStateMachine().getConfigManipulator().setSignatureNote(note); + } + } + private void initializeFromArguments(String[] args, ArgumentHandler handler) throws InitializationException { handler.handleArguments(args); @@ -155,7 +173,7 @@ public class PrepareConfigurationState extends State { InputStream inputStream = null; FileOutputStream pdfOverConfig = null; try { - inputStream = this.getClass().getResourceAsStream( + inputStream = getClass().getResourceAsStream( Constants.RES_PKG_PATH + Constants.DEFAULT_CONFIG_FILENAME); pdfOverConfig = new FileOutputStream( getStateMachine().getConfigProvider().getConfigurationDirectory() + @@ -199,7 +217,7 @@ public class PrepareConfigurationState extends State { InputStream inputStream = null; FileOutputStream pdfOverConfig = null; try { - inputStream = this.getClass().getResourceAsStream( + inputStream = getClass().getResourceAsStream( Constants.RES_PKG_PATH + Constants.DEFAULT_LOG4J_FILENAME); String filename = getStateMachine().getConfigProvider().getConfigurationDirectory() + FILE_SEPARATOR + Constants.DEFAULT_LOG4J_FILENAME; @@ -238,7 +256,7 @@ public class PrepareConfigurationState extends State { } private void unzipPdfAsConfig(File configDir) throws InitializationException { - InputStream is = this.getClass().getResourceAsStream(Constants.RES_CFG_ZIP); + InputStream is = getClass().getResourceAsStream(Constants.RES_CFG_ZIP); try { Zipper.unzip(is, configDir.getAbsolutePath()); @@ -268,7 +286,7 @@ public class PrepareConfigurationState extends State { } private void initializeConfig() throws InitializationException { - this.initializeFromConfigurationFile(getStateMachine() + initializeFromConfigurationFile(getStateMachine() .getConfigProvider().getConfigurationFile()); getStateMachine().getConfigManipulator().setSignatureNote(Messages.getString("simple_config.Note_Default")); //$NON-NLS-1$ @@ -394,7 +412,7 @@ public class PrepareConfigurationState extends State { // Read cli arguments for config file first try { - this.initializeFromArguments(stateMachine.getCmdArgs(), + initializeFromArguments(stateMachine.getCmdArgs(), this.configFileHandler); } catch (InitializationException e) { log.error("Error in cmd line arguments: ", e); //$NON-NLS-1$ @@ -407,11 +425,12 @@ public class PrepareConfigurationState extends State { } // initialize from config file - this.initializeFromConfigurationFile(config.getConfigurationFile()); + initializeFromConfigurationFile(config.getConfigurationFile()); + updateConfiguration(); // Read cli arguments try { - this.initializeFromArguments(stateMachine.getCmdArgs(), + initializeFromArguments(stateMachine.getCmdArgs(), this.handler); } catch (InitializationException e) { log.error("Error in cmd line arguments: ", e); //$NON-NLS-1$ @@ -487,7 +506,7 @@ public class PrepareConfigurationState extends State { status.setSignaturePosition(getStateMachine().getConfigProvider() .getDefaultSignaturePosition()); - this.setNextState(new OpenState(stateMachine)); + setNextState(new OpenState(stateMachine)); } catch (InitializationException e) { log.error("Failed to initialize: ", e); //$NON-NLS-1$ @@ -496,7 +515,7 @@ public class PrepareConfigurationState extends State { Messages.getString("error.Initialization"), //$NON-NLS-1$ BUTTONS.OK); // error.setException(e); - // this.setNextState(error); + // setNextState(error); error.open(); getStateMachine().exit(); } @@ -524,6 +543,6 @@ public class PrepareConfigurationState extends State { @Override public String toString() { - return this.getClass().getName(); + return getClass().getName(); } } diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties index a3668580..baf5ee6c 100644 --- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties +++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages.properties @@ -199,7 +199,8 @@ simple_config.ExampleNumber=+43676123456789 simple_config.ExampleNumber_ToolTip=To use a default mobile phone number enter it here simple_config.MobileBKU_Title=&Mobile signature simple_config.Note=Text\: -simple_config.Note_Default=This document is signed with a qualified electronic signature. According to \u00A7\u00A04 art.\u00A01 of the Signature Act it in principle is legally equivalent to a handwritten signature. +simple_config.Note_Default=This document is signed with a qualified electronic signature. According to Art. 25 para. 2 of the Regulation (EU) No 910/2014 of 23. July 2014 ("eIDAS-Regulation") it shall have the equivalent legal effect of a handwritten signature. +simple_config.Note_Default_Old=This document is signed with a qualified electronic signature. According to \u00A7\u00A04 art.\u00A01 of the Signature Act it in principle is legally equivalent to a handwritten signature. simple_config.Note_SetDefault=Restore default simple_config.Note_Title=Signature &Note simple_config.Note_Tooltip=Add an optional note to display on your Signature diff --git a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties index 70b1662b..506abebd 100644 --- a/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties +++ b/pdf-over-gui/src/main/resources/at/asit/pdfover/gui/messages_de.properties @@ -199,7 +199,8 @@ simple_config.ExampleNumber=+43676123456789 simple_config.ExampleNumber_ToolTip=Um die Handynummer voreinzustellen hier eingeben simple_config.MobileBKU_Title=&Handy-Signatur simple_config.Note=Text\: -simple_config.Note_Default=Dieses mit einer qualifizierten elektronischen Signatur versehene Dokument ist gem\u00E4\u00DF \u00A7\u00A04 Abs.\u00A01 Signaturgesetz einem handschriftlich unterschriebenen Dokument grunds\u00E4tzlich rechtlich gleichgestellt. +simple_config.Note_Default=Dieses mit einer qualifizierten elektronischen Signatur versehene Dokument hat gem\u00E4\u00DF Art. 25 Abs. 2 der Verordnung (EU) Nr. 910/2014 vom 23.\u00A0Juli\u00A02014 ("eIDAS-VO") die gleiche Rechtswirkung wie ein handschriftlich unterschriebenes Dokument. +simple_config.Note_Default_Old=Dieses mit einer qualifizierten elektronischen Signatur versehene Dokument ist gem\u00E4\u00DF \u00A7\u00A04 Abs.\u00A01 Signaturgesetz einem handschriftlich unterschriebenen Dokument grunds\u00E4tzlich rechtlich gleichgestellt. simple_config.Note_SetDefault=Standard wiederherstellen simple_config.Note_Title=Signaturhi&nweis simple_config.Note_Tooltip=Ein optionaler Hinweis, der in Ihrer Signatur angezeigt wird -- cgit v1.2.3