You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/08/09 14:29:54 UTC
svn commit: r1512282 - in /syncope/trunk: ./
console/src/main/java/org/apache/syncope/console/pages/
console/src/main/resources/org/apache/syncope/console/pages/
core/src/main/java/org/apache/syncope/core/notification/
core/src/main/java/org/apache/syn...
Author: ilgrosso
Date: Fri Aug 9 12:29:53 2013
New Revision: 1512282
URL: http://svn.apache.org/r1512282
Log:
[SYNCOPE-409] Merge from 1_1_X
Modified:
syncope/trunk/ (props changed)
syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties
syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties
syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java
syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java
syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java
Propchange: syncope/trunk/
------------------------------------------------------------------------------
Merged /syncope/branches/1_1_X:r1511191-1512281
Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java?rev=1512282&r1=1512281&r2=1512282&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java (original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/NotificationModalPage.java Fri Aug 9 12:29:53 2013
@@ -90,8 +90,31 @@ class NotificationModalPage extends Base
traceLevel.addRequiredLabel();
form.add(traceLevel);
+ final WebMarkupContainer aboutContainer = new WebMarkupContainer("aboutContainer");
+ aboutContainer.setOutputMarkupId(true);
+
+ form.add(aboutContainer);
+
+ final AjaxCheckBoxPanel checkAbout =
+ new AjaxCheckBoxPanel("checkAbout", "checkAbout",
+ new Model<Boolean>(notificationTO.getAbout() == null));
+ aboutContainer.add(checkAbout);
+
final UserSearchPanel about = new UserSearchPanel.Builder("about").nodeCond(notificationTO.getAbout()).build();
- form.add(about);
+ aboutContainer.add(about);
+ about.setEnabled(!checkAbout.getModelObject());
+
+ checkAbout.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ about.setEnabled(!checkAbout.getModelObject());
+ target.add(about);
+ target.add(aboutContainer);
+ }
+ });
final AjaxDropDownChoicePanel<IntMappingType> recipientAttrType = new AjaxDropDownChoicePanel<IntMappingType>(
"recipientAttrType", new ResourceModel("recipientAttrType", "recipientAttrType").getObject(),
@@ -186,7 +209,7 @@ class NotificationModalPage extends Base
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
- notificationTO.setAbout(about.buildSearchCond());
+ notificationTO.setAbout(checkAbout.getModelObject() ? null : about.buildSearchCond());
notificationTO.setRecipients(checkRecipients.getModelObject() ? recipients.buildSearchCond() : null);
try {
Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html?rev=1512282&r1=1512281&r2=1512282&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.html Fri Aug 9 12:29:53 2013
@@ -88,28 +88,38 @@ under the License.
</div>
<div id="about">
- <span wicket:id="about"/>
- </div>
+ <span wicket:id="aboutContainer">
+ <div class="tablerow" style="width: auto;">
+ <div class="tablecolumn_field" style="width: auto; padding-right: 5px;">
+ <span wicket:id="checkAbout">[checkAbout]</span>
+ </div>
+ <div class="tablecolumn_label" style="width: auto;">
+ <label for="checkAbout"><wicket:message key="checkAbout"/></label>
+ </div>
+ </div>
+ <span wicket:id="about"/>
+ </span>
+ </div>
<div id="events">
<span wicket:id="events"/>
</div>
<div id="recipients">
- <div class="tablerow">
- <div class="tablecolumn_field">
+ <div class="tablerow" style="width: auto; display: block;">
+ <div class="tablecolumn_field" style="width: auto; padding-right: 5px;">
<span wicket:id="selfAsRecipient">[selfAsRecipient]</span>
</div>
- <div class="tablecolumn_label">
+ <div class="tablecolumn_label" style="width: auto;">
<label for="selfAsRecipient"><wicket:message key="selfAsRecipient"/></label>
</div>
</div>
<span wicket:id="recipientsContainer">
- <div class="tablerow">
- <div class="tablecolumn_field">
+ <div class="tablerow" style="width: auto;">
+ <div class="tablecolumn_field" style="width: auto; padding-right: 5px;">
<span wicket:id="checkRecipients">[checkRecipients]</span>
</div>
- <div class="tablecolumn_label">
+ <div class="tablecolumn_label" style="width: auto;">
<label for="checkRecipients"><wicket:message key="checkRecipients"/></label>
</div>
</div>
Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties?rev=1512282&r1=1512281&r2=1512282&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage.properties Fri Aug 9 12:29:53 2013
@@ -28,3 +28,4 @@ selfAsRecipient=Include users matching A
recipientAttrType=Recipients e-mail attribute type
recipientAttrName=Recipients e-mail attribute schema
checkRecipients=Search recipients
+checkAbout=All users
Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties?rev=1512282&r1=1512281&r2=1512282&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_it.properties Fri Aug 9 12:29:53 2013
@@ -27,4 +27,5 @@ recipients=Destinatari
selfAsRecipient=Includi i soggetti
recipientAttrType=Tipo attributo e-mail destinatari
recipientAttrName=Shcema attributo e-mail destinatari
-checkRecipients=Cerca i destinatari
\ No newline at end of file
+checkRecipients=Cerca i destinatari
+checkAbout=Tutti gli utenti
\ No newline at end of file
Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties?rev=1512282&r1=1512281&r2=1512282&view=diff
==============================================================================
--- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties (original)
+++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/NotificationModalPage_pt_BR.properties Fri Aug 9 12:29:53 2013
@@ -28,3 +28,4 @@ selfAsRecipient=Incluir usu\u00E1rios re
recipientAttrType=Tipo de atributo de destinat\u00E1rio de email.
recipientAttrName=Destinat\u00E1rios de e-mail para atributos de esquema
checkRecipients=Buscar Destinat\u00E1rios
+checkAbout=Todos os usu\u00E1rios
\ No newline at end of file
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java?rev=1512282&r1=1512281&r2=1512282&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/notification/NotificationManager.java Fri Aug 9 12:29:53 2013
@@ -199,7 +199,10 @@ public class NotificationManager {
}
for (Notification notification : notificationDAO.findAll()) {
- if (searchDAO.matches(user, notification.getAbout(), AttributableUtil.getInstance(AttributableType.USER))) {
+ if (notification.getAbout() == null
+ || searchDAO.matches(user, notification.getAbout(),
+ AttributableUtil.getInstance(AttributableType.USER))) {
+
Set<String> events = new HashSet<String>(notification.getEvents());
events.retainAll(performedTasks);
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java?rev=1512282&r1=1512281&r2=1512282&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/Notification.java Fri Aug 9 12:29:53 2013
@@ -56,7 +56,6 @@ public class Notification extends Abstra
@Column(name = "events")
private List<String> events;
- @NotNull
@Lob
private String xmlAbout;
@@ -100,19 +99,11 @@ public class Notification extends Abstra
}
public NodeCond getAbout() {
- NodeCond result = XMLSerializer.<NodeCond>deserialize(xmlAbout);
- if (result == null) {
- result = new NodeCond();
- }
- return result;
+ return xmlAbout == null ? null : XMLSerializer.<NodeCond>deserialize(xmlAbout);
}
public void setAbout(NodeCond about) {
- if (about == null) {
- about = new NodeCond();
- }
-
- xmlAbout = XMLSerializer.serialize(about);
+ xmlAbout = about == null ? null : XMLSerializer.serialize(about);
}
public NodeCond getRecipients() {
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java?rev=1512282&r1=1512281&r2=1512282&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/validation/entity/NotificationValidator.java Fri Aug 9 12:29:53 2013
@@ -45,7 +45,7 @@ public class NotificationValidator exten
getTemplate(EntityViolationType.InvalidNotification, "No events")).
addNode("events").addConstraintViolation();
}
- if (!value.getAbout().isValid()) {
+ if (value.getAbout() != null && !value.getAbout().isValid()) {
isValid = false;
context.buildConstraintViolationWithTemplate(
Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java?rev=1512282&r1=1512281&r2=1512282&view=diff
==============================================================================
--- syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java (original)
+++ syncope/trunk/core/src/test/java/org/apache/syncope/core/notification/NotificationTest.java Fri Aug 9 12:29:53 2013
@@ -306,4 +306,58 @@ public class NotificationTest {
assertTrue(task.isExecuted());
assertTrue(StringUtils.isNotBlank(task.getLatestExecStatus()));
}
+
+ @Test
+ public void notifyByMailEmptyAbout() throws Exception {
+ // 1. create suitable notification for subsequent tests
+ Notification notification = new Notification();
+ notification.addEvent("create");
+
+ notification.setAbout(null);
+
+ MembershipCond membCond = new MembershipCond();
+ membCond.setRoleId(8L);
+ notification.setRecipients(NodeCond.getLeafCond(membCond));
+ notification.setSelfAsRecipient(true);
+
+ notification.setRecipientAttrName("email");
+ notification.setRecipientAttrType(IntMappingType.UserSchema);
+
+ Random random = new Random(System.currentTimeMillis());
+ String sender = "syncopetest-" + random.nextLong() + "@syncope.apache.org";
+ notification.setSender(sender);
+ String subject = "Test notification " + random.nextLong();
+ notification.setSubject(subject);
+ notification.setTemplate("optin");
+
+ Notification actual = notificationDAO.save(notification);
+ assertNotNull(actual);
+
+ notificationDAO.flush();
+
+ // 2. create user
+ UserTO userTO = UserTestITCase.getSampleTO(mailAddress);
+ MembershipTO membershipTO = new MembershipTO();
+ membershipTO.setRoleId(7);
+ userTO.addMembership(membershipTO);
+
+ userController.create(new MockHttpServletResponse(), userTO);
+
+ // 3. force Quartz job execution and verify e-mail
+ notificationJob.execute(null);
+ assertTrue(verifyMail(sender, subject));
+
+ // 4. get NotificationTask id
+ Long taskId = null;
+ for (NotificationTask task : taskDAO.findAll(NotificationTask.class)) {
+ if (sender.equals(task.getSender())) {
+ taskId = task.getId();
+ }
+ }
+ assertNotNull(taskId);
+
+ // 5. execute Notification task and verify e-mail
+ taskController.execute(taskId, false);
+ assertTrue(verifyMail(sender, subject));
+ }
}