From c46af50806d85adb61b9998643b01c9c7dd5057c Mon Sep 17 00:00:00 2001 From: j-dimension Date: Fri, 29 Sep 2023 12:41:26 +0200 Subject: [PATCH] sonarqube fixes. close #1228. --- .../client/bea/SendBeaMessageDialog.java | 8 ++++---- .../client/drebis/freetext/FreeTextStep.java | 19 ++++++++----------- .../client/mail/EmailTemplatesPanel.java | 2 +- .../jlawyer/client/mail/SendEmailDialog.java | 6 +++--- .../services/IntegrationServiceRemote.java | 2 +- .../jlawyer/services/IntegrationService.java | 2 +- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageDialog.java index e8de8b676..da603b037 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/bea/SendBeaMessageDialog.java @@ -823,15 +823,15 @@ public SendBeaMessageDialog(java.awt.Frame parent, boolean modal) { try { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); - Collection templates = locator.lookupIntegrationServiceRemote().getAllEmailTemplateNames(); + Collection templates = locator.lookupIntegrationServiceRemote().getAllEmailTemplateNames(); this.cmbTemplates.removeAllItems(); this.cmbTemplates.addItem(""); String lastUsedTemplate = UserSettings.getInstance().getSetting(UserSettings.CONF_BEA_LASTUSEDTEMPLATE, null); - for (Object t : templates) { - EmailTemplate etpl = locator.lookupIntegrationServiceRemote().getEmailTemplate(t.toString()); + for (String t : templates) { + EmailTemplate etpl = locator.lookupIntegrationServiceRemote().getEmailTemplate(t); if (etpl != null) { if (etpl.isText()) { - this.cmbTemplates.addItem(t.toString()); + this.cmbTemplates.addItem(t); } } diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextStep.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextStep.java index 59465340c..61f35b661 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextStep.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/drebis/freetext/FreeTextStep.java @@ -716,16 +716,14 @@ public FreeTextStep() { try { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); - Collection templates = locator.lookupIntegrationServiceRemote().getAllEmailTemplateNames(); + Collection templates = locator.lookupIntegrationServiceRemote().getAllEmailTemplateNames(); this.cmbTemplates.removeAllItems(); this.cmbTemplates.addItem(""); String lastUsedTemplate = UserSettings.getInstance().getSetting(UserSettings.CONF_DREBIS_LASTUSEDTEMPLATE, null); - for (Object t : templates) { - EmailTemplate etpl = locator.lookupIntegrationServiceRemote().getEmailTemplate(t.toString()); - if (etpl != null) { - if (etpl.isText()) { - this.cmbTemplates.addItem(t.toString()); - } + for (String t : templates) { + EmailTemplate etpl = locator.lookupIntegrationServiceRemote().getEmailTemplate(t); + if (etpl != null && etpl.isText()) { + this.cmbTemplates.addItem(t); } } if (lastUsedTemplate != null) { @@ -961,20 +959,19 @@ private void cmbTemplatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN- log.warn("Unable to load assistant with id " + contextArchiveFile.getAssistant()); } - List selectedParties = this.partiesPanel.getSelectedParties(new ArrayList(allPartyTypes)); + List selectedParties = this.partiesPanel.getSelectedParties(new ArrayList<>(allPartyTypes)); List partiesTriplets = new ArrayList<>(); for (PartiesPanelEntry pe : selectedParties) { PartiesTriplet triplet = new PartiesTriplet(pe.getAddress(), pe.getReferenceType(), pe.getInvolvement()); partiesTriplets.add(triplet); } - HashMap htValues = locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, contextArchiveFile, partiesTriplets, null, null, formPlaceHolderValues, caseLawyer, caseAssistant, author, null, null, null); - + placeHolderNames = EmailTemplateAccess.getPlaceHoldersInTemplate(tpl.getBody(), allPartyTypesPlaceholders, formPlaceHolders); ht = new HashMap<>(); for (String ph : placeHolderNames) { ht.put(ph, ""); } - htValues = locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, contextArchiveFile, partiesTriplets, null, null, formPlaceHolderValues, caseLawyer, caseAssistant, author, null, null, null); + HashMap htValues = locator.lookupSystemManagementRemote().getPlaceHolderValues(ht, contextArchiveFile, partiesTriplets, null, null, formPlaceHolderValues, caseLawyer, caseAssistant, author, null, null, null); String t = EmailTemplateAccess.replacePlaceHolders(tpl.getBody(), htValues); int cursorIndex = t.indexOf(EmailTemplate.PLACEHOLDER_CURSOR); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java index ad535197c..38baa671e 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/EmailTemplatesPanel.java @@ -772,7 +772,7 @@ private void refreshList() { try { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); - Collection fileNames=locator.lookupIntegrationServiceRemote().getAllEmailTemplateNames(); + Collection fileNames=locator.lookupIntegrationServiceRemote().getAllEmailTemplateNames(); for(Object o:fileNames) { model.addElement(o); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java index 476be1a58..d6895f4a1 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/mail/SendEmailDialog.java @@ -850,12 +850,12 @@ private void initialize() { try { JLawyerServiceLocator locator = JLawyerServiceLocator.getInstance(settings.getLookupProperties()); - Collection templates = locator.lookupIntegrationServiceRemote().getAllEmailTemplateNames(); + Collection templates = locator.lookupIntegrationServiceRemote().getAllEmailTemplateNames(); this.cmbTemplates.removeAllItems(); this.cmbTemplates.addItem(""); String lastUsedTemplate = UserSettings.getInstance().getSetting(UserSettings.CONF_MAIL_LASTUSEDTEMPLATE, null); - for (Object t : templates) { - this.cmbTemplates.addItem(t.toString()); + for (String t : templates) { + this.cmbTemplates.addItem(t); } if (lastUsedTemplate != null) { this.cmbTemplates.setSelectedItem(lastUsedTemplate); diff --git a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/IntegrationServiceRemote.java b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/IntegrationServiceRemote.java index 37a7425fb..4a9ed7b39 100644 --- a/j-lawyer-server-api/src/com/jdimension/jlawyer/services/IntegrationServiceRemote.java +++ b/j-lawyer-server-api/src/com/jdimension/jlawyer/services/IntegrationServiceRemote.java @@ -689,7 +689,7 @@ public interface IntegrationServiceRemote { String assignObservedFile(String fileName, String archiveFileId, String renameTo) throws Exception; - Collection getAllEmailTemplateNames(); + Collection getAllEmailTemplateNames(); void saveEmailTemplate(EmailTemplate template, boolean replace) throws Exception; diff --git a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/IntegrationService.java b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/IntegrationService.java index 2c6bb0699..ef3ca7316 100644 --- a/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/IntegrationService.java +++ b/j-lawyer-server/j-lawyer-server-ejb/src/java/com/jdimension/jlawyer/services/IntegrationService.java @@ -903,7 +903,7 @@ public String assignObservedFile(String fileName, String archiveFileId, String r @Override @RolesAllowed(value = {"loginRole"}) - public Collection getAllEmailTemplateNames() { + public Collection getAllEmailTemplateNames() { String localBaseDir = System.getProperty("jlawyer.server.basedirectory"); localBaseDir = localBaseDir.trim(); if (!localBaseDir.endsWith(System.getProperty("file.separator"))) {