Repository: syncope Updated Branches: refs/heads/master 29928e1e7 -> 601a171a5
[SYNCOPE-766] Small improvements Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/601a171a Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/601a171a Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/601a171a Branch: refs/heads/master Commit: 601a171a5036f146d586a9537d1eac3dab5f59f2 Parents: 29928e1 Author: Francesco Chicchiriccò <[email protected]> Authored: Thu Mar 10 11:02:43 2016 +0100 Committer: Francesco Chicchiriccò <[email protected]> Committed: Thu Mar 10 11:02:43 2016 +0100 ---------------------------------------------------------------------- .../console/SyncopeConsoleApplication.java | 36 +++++++++++----- .../console/widgets/ReconciliationWidget.java | 43 ++++++++++++-------- .../ReconciliationReportParser.java | 9 ---- .../src/main/resources/console.properties | 2 + .../provisioning/java/MailTemplateTest.java | 3 +- .../src/main/resources/console.properties | 2 + .../syncope/fit/console/ParametersITCase.java | 7 +--- .../apache/syncope/fit/console/RolesITCase.java | 1 - .../src/test/resources/console.properties | 2 + 9 files changed, 59 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/601a171a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java index f24bdcf..f0671f9 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleApplication.java @@ -58,9 +58,9 @@ import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.request.resource.IResource; import org.apache.wicket.request.resource.ResourceReference; import org.apache.wicket.resource.DynamicJQueryResourceReference; +import org.apache.wicket.util.lang.Args; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.util.Assert; public class SyncopeConsoleApplication extends AuthenticatedWebApplication { @@ -91,6 +91,8 @@ public class SyncopeConsoleApplication extends AuthenticatedWebApplication { private String activitiModelerDirectory; + private Long reconciliationReportKey; + private SyncopeClientFactoryBean clientFactory; private Map<String, Class<? extends BasePage>> pageClasses; @@ -136,24 +138,24 @@ public class SyncopeConsoleApplication extends AuthenticatedWebApplication { throw new WicketRuntimeException("Could not read " + CONSOLE_PROPERTIES, e); } version = props.getProperty("version"); - Assert.notNull(version, "<version> not set"); + Args.notNull(version, "<version> not set"); site = props.getProperty("site"); - Assert.notNull(site, "<site> not set"); + Args.notNull(site, "<site> not set"); license = props.getProperty("license"); - Assert.notNull(license, "<license> not set"); + Args.notNull(license, "<license> not set"); anonymousUser = props.getProperty("anonymousUser"); - Assert.notNull(anonymousUser, "<anonymousUser> not set"); + Args.notNull(anonymousUser, "<anonymousUser> not set"); anonymousKey = props.getProperty("anonymousKey"); - Assert.notNull(anonymousKey, "<anonymousKey> not set"); + Args.notNull(anonymousKey, "<anonymousKey> not set"); String scheme = props.getProperty("scheme"); - Assert.notNull(scheme, "<scheme> not set"); + Args.notNull(scheme, "<scheme> not set"); String host = props.getProperty("host"); - Assert.notNull(host, "<host> not set"); + Args.notNull(host, "<host> not set"); String port = props.getProperty("port"); - Assert.notNull(port, "<port> not set"); + Args.notNull(port, "<port> not set"); String rootPath = props.getProperty("rootPath"); - Assert.notNull(rootPath, "<rootPath> not set"); + Args.notNull(rootPath, "<rootPath> not set"); clientFactory = new SyncopeClientFactoryBean().setAddress(scheme + "://" + host + ":" + port + "/" + rootPath); @@ -193,7 +195,15 @@ public class SyncopeConsoleApplication extends AuthenticatedWebApplication { mountPage("/login", getSignInPageClass()); activitiModelerDirectory = props.getProperty("activitiModelerDirectory"); - Assert.notNull(activitiModelerDirectory, "<activitiModelerDirectory> not set"); + Args.notNull(activitiModelerDirectory, "<activitiModelerDirectory> not set"); + + try { + reconciliationReportKey = Long.valueOf(props.getProperty("reconciliationReportKey")); + } catch (NumberFormatException e) { + LOG.error("While parsing reconciliationReportKey", e); + } + Args.notNull(reconciliationReportKey, "<reconciliationReportKey> not set"); + mountResource("/" + ACTIVITI_MODELER_CONTEXT, new ResourceReference(ACTIVITI_MODELER_CONTEXT) { private static final long serialVersionUID = -128426276529456602L; @@ -275,6 +285,10 @@ public class SyncopeConsoleApplication extends AuthenticatedWebApplication { return activitiModelerDirectory; } + public Long getReconciliationReportKey() { + return reconciliationReportKey; + } + public SyncopeClientFactoryBean getClientFactory() { return clientFactory; } http://git-wip-us.apache.org/repos/asf/syncope/blob/601a171a/client/console/src/main/java/org/apache/syncope/client/console/widgets/ReconciliationWidget.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/ReconciliationWidget.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/ReconciliationWidget.java index 7d52d81..71ddcdf 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/ReconciliationWidget.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/ReconciliationWidget.java @@ -36,6 +36,7 @@ import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.Transformer; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; +import org.apache.syncope.client.console.SyncopeConsoleApplication; import org.apache.syncope.client.console.SyncopeConsoleSession; import org.apache.syncope.client.console.commons.Constants; import org.apache.syncope.client.console.commons.SearchableDataProvider; @@ -97,8 +98,6 @@ public class ReconciliationWidget extends BaseWidget { private static final Logger LOG = LoggerFactory.getLogger(ReconciliationWidget.class); - private static final long RECONCILIATION_REPORT_KEY = 2L; - private static final int ROWS = 10; private final BaseModal<Any> detailsModal = new BaseModal<>("detailsModal"); @@ -122,26 +121,34 @@ public class ReconciliationWidget extends BaseWidget { overlay.setVisible(false); add(overlay); - ReportTO reconciliationReport = restClient.read(RECONCILIATION_REPORT_KEY); + ReportTO reconciliationReport = null; + try { + reconciliationReport = restClient.read(SyncopeConsoleApplication.get().getReconciliationReportKey()); + } catch (Exception e) { + LOG.error("Could not fetch the expected reconciliation report with key {}, aborting", + SyncopeConsoleApplication.get().getReconciliationReportKey(), e); + } - Fragment reportResult = reconciliationReport.getExecutions().isEmpty() + Fragment reportResult = reconciliationReport == null || reconciliationReport.getExecutions().isEmpty() ? new Fragment("reportResult", "noExecFragment", this) : buildExecFragment(); reportResult.setOutputMarkupId(true); add(reportResult); - add(new WebSocketBehavior() { + if (reconciliationReport != null) { + add(new WebSocketBehavior() { - private static final long serialVersionUID = 3507933905864454312L; + private static final long serialVersionUID = 3507933905864454312L; - @Override - protected void onConnect(final ConnectedMessage message) { - super.onConnect(message); + @Override + protected void onConnect(final ConnectedMessage message) { + super.onConnect(message); - SyncopeConsoleSession.get().scheduleAtFixedRate( - new ReconciliationJobInfoUpdater(message), 0, 10, TimeUnit.SECONDS); - } - }); + SyncopeConsoleSession.get().scheduleAtFixedRate( + new ReconciliationJobInfoUpdater(message), 0, 10, TimeUnit.SECONDS); + } + }); + } add(new IndicatorAjaxLink<Void>("refresh") { @@ -150,7 +157,7 @@ public class ReconciliationWidget extends BaseWidget { @Override public void onClick(final AjaxRequestTarget target) { try { - restClient.startExecution(RECONCILIATION_REPORT_KEY, null); + restClient.startExecution(SyncopeConsoleApplication.get().getReconciliationReportKey(), null); overlay.setVisible(true); target.add(ReconciliationWidget.this); @@ -236,7 +243,7 @@ public class ReconciliationWidget extends BaseWidget { @Override public boolean evaluate(final ExecTO exec) { - return exec.getRefKey() == RECONCILIATION_REPORT_KEY; + return exec.getRefKey() == SyncopeConsoleApplication.get().getReconciliationReportKey(); } }); if (exec == null) { @@ -501,11 +508,13 @@ public class ReconciliationWidget extends BaseWidget { @Override public boolean evaluate(final JobTO jobTO) { - return RECONCILIATION_REPORT_KEY == jobTO.getRefKey(); + return SyncopeConsoleApplication.get(). + getReconciliationReportKey().equals(jobTO.getRefKey()); } }); if (reportJobTO != null && !reportJobTO.isRunning()) { - LOG.debug("Report {} is not running", RECONCILIATION_REPORT_KEY); + LOG.debug("Report {} is not running", + SyncopeConsoleApplication.get().getReconciliationReportKey()); WebSocketSettings webSocketSettings = WebSocketSettings.Holder.get(application); WebSocketPushBroadcaster broadcaster = http://git-wip-us.apache.org/repos/asf/syncope/blob/601a171a/client/console/src/main/java/org/apache/syncope/client/console/widgets/reconciliation/ReconciliationReportParser.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/widgets/reconciliation/ReconciliationReportParser.java b/client/console/src/main/java/org/apache/syncope/client/console/widgets/reconciliation/ReconciliationReportParser.java index c99b7e3..9a795d1 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/widgets/reconciliation/ReconciliationReportParser.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/widgets/reconciliation/ReconciliationReportParser.java @@ -18,8 +18,6 @@ */ package org.apache.syncope.client.console.widgets.reconciliation; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; @@ -176,13 +174,6 @@ public final class ReconciliationReportParser { streamReader.next(); } - try { - System.out.println("QQQQQQQQQ\n" + new ObjectMapper().writeValueAsString(report)); - } catch (JsonProcessingException ex) { - System.err.println("nuuuuuuuuuuuuuuuuuuuuuuuu"); - ex.printStackTrace(); - } - return report; } http://git-wip-us.apache.org/repos/asf/syncope/blob/601a171a/client/console/src/main/resources/console.properties ---------------------------------------------------------------------- diff --git a/client/console/src/main/resources/console.properties b/client/console/src/main/resources/console.properties index c1d70e9..24169f5 100644 --- a/client/console/src/main/resources/console.properties +++ b/client/console/src/main/resources/console.properties @@ -30,6 +30,8 @@ rootPath=/syncope/rest/ activitiModelerDirectory=${activiti-modeler.directory} +reconciliationReportKey=1 + page.dashboard=org.apache.syncope.client.console.pages.Dashboard page.realms=org.apache.syncope.client.console.pages.Realms page.topology=org.apache.syncope.client.console.topology.Topology http://git-wip-us.apache.org/repos/asf/syncope/blob/601a171a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java ---------------------------------------------------------------------- diff --git a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java index b87a6a9..bf972c4 100644 --- a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java +++ b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/MailTemplateTest.java @@ -117,8 +117,7 @@ public class MailTemplateTest extends AbstractTest { ctx); assertNotNull(htmlBody); - System.out.println("AAAAAAAAAAAAA\n" + htmlBody); - + assertTrue(htmlBody.contains("Hi John Doe,")); assertTrue(htmlBody.contains("Your email address is [email protected].")); assertTrue(htmlBody.contains("<li>[email protected]</li>")); http://git-wip-us.apache.org/repos/asf/syncope/blob/601a171a/fit/console-reference/src/main/resources/console.properties ---------------------------------------------------------------------- diff --git a/fit/console-reference/src/main/resources/console.properties b/fit/console-reference/src/main/resources/console.properties index fa4c289..0de5557 100644 --- a/fit/console-reference/src/main/resources/console.properties +++ b/fit/console-reference/src/main/resources/console.properties @@ -30,6 +30,8 @@ rootPath=/syncope/rest/ activitiModelerDirectory=${activiti-modeler.directory} +reconciliationReportKey=2 + page.dashboard=org.apache.syncope.client.console.pages.Dashboard page.realms=org.apache.syncope.client.console.pages.Realms page.topology=org.apache.syncope.client.console.topology.Topology http://git-wip-us.apache.org/repos/asf/syncope/blob/601a171a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/ParametersITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/ParametersITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/ParametersITCase.java index 5173a68..389a7be 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/ParametersITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/ParametersITCase.java @@ -61,13 +61,8 @@ public class ParametersITCase extends AbstractConsoleITCase { formTester.submit("content:parametersCreateWizardPanel:form:buttons:finish"); - try { wicketTester.assertInfoMessages("Operation executed successfully"); - } catch(Throwable t) { - System.err.println("EEEEEEEEEEEEEE " + wicketTester.getLastResponseAsString()); - t.printStackTrace(); - } - + wicketTester.cleanupFeedbackMessages(); wicketTester.assertRenderedPage(Parameters.class); } http://git-wip-us.apache.org/repos/asf/syncope/blob/601a171a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RolesITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RolesITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RolesITCase.java index dae373b..5a1c851 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RolesITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/RolesITCase.java @@ -18,7 +18,6 @@ */ package org.apache.syncope.fit.console; -import static org.apache.syncope.fit.console.AbstractConsoleITCase.KEY; import static org.junit.Assert.assertNull; import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal; http://git-wip-us.apache.org/repos/asf/syncope/blob/601a171a/fit/core-reference/src/test/resources/console.properties ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/resources/console.properties b/fit/core-reference/src/test/resources/console.properties index fa4c289..0de5557 100644 --- a/fit/core-reference/src/test/resources/console.properties +++ b/fit/core-reference/src/test/resources/console.properties @@ -30,6 +30,8 @@ rootPath=/syncope/rest/ activitiModelerDirectory=${activiti-modeler.directory} +reconciliationReportKey=2 + page.dashboard=org.apache.syncope.client.console.pages.Dashboard page.realms=org.apache.syncope.client.console.pages.Realms page.topology=org.apache.syncope.client.console.topology.Topology
