You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2008/11/19 23:35:10 UTC
svn commit: r719100 - in /lenya/sandbox/access_control_redesign/src/modules:
blog/java/src/org/apache/lenya/cms/site/usecases/
contactform/java/src/org/apache/lenya/cms/contactform/
editors/java/src/org/apache/lenya/cms/editors/ lucene/java/src/org/apa...
Author: andreas
Date: Wed Nov 19 14:35:09 2008
New Revision: 719100
URL: http://svn.apache.org/viewvc?rev=719100&view=rev
Log:
Committing changes to modules.
Added:
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Address.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/GroupAddress.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/UserAddress.java
Modified:
lenya/sandbox/access_control_redesign/src/modules/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java
lenya/sandbox/access_control_redesign/src/modules/contactform/java/src/org/apache/lenya/cms/contactform/ContactForm.java
lenya/sandbox/access_control_redesign/src/modules/editors/java/src/org/apache/lenya/cms/editors/InsertAsset.java
lenya/sandbox/access_control_redesign/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/SendMessage.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/AbstractNotifier.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Message.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java
lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java
lenya/sandbox/access_control_redesign/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/transformation/AccessControlSitetreeTransformer.java
lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java
Modified: lenya/sandbox/access_control_redesign/src/modules/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/blog/java/src/org/apache/lenya/cms/site/usecases/CreateBlogEntry.java Wed Nov 19 14:35:09 2008
@@ -257,7 +257,7 @@
throw new RuntimeException("Element entry/author/name not found.");
}
- DocumentHelper.setSimpleElementText(element, identity.getUser().getId());
+ DocumentHelper.setSimpleElementText(element, identity.getUserReference().getId());
// Replace date created, issued and modified
DateFormat datefmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Modified: lenya/sandbox/access_control_redesign/src/modules/contactform/java/src/org/apache/lenya/cms/contactform/ContactForm.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/contactform/java/src/org/apache/lenya/cms/contactform/ContactForm.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/contactform/java/src/org/apache/lenya/cms/contactform/ContactForm.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/contactform/java/src/org/apache/lenya/cms/contactform/ContactForm.java Wed Nov 19 14:35:09 2008
@@ -23,8 +23,11 @@
import org.apache.lenya.ac.User;
import org.apache.lenya.ac.UserManager;
import org.apache.lenya.cms.usecase.AbstractUsecase;
+import org.apache.lenya.notification.Address;
import org.apache.lenya.notification.Message;
import org.apache.lenya.notification.NotificationUtil;
+import org.apache.lenya.notification.Text;
+import org.apache.lenya.notification.UserAddress;
/**
* Contact form. The recipient user ID is set using the "recipient" parameter. The sender user ID is
@@ -68,18 +71,17 @@
String senderUserId = getParameterAsString(SENDER);
String recipientUserId = getParameterAsString(RECIPIENT);
- User sender = getUser(senderUserId);
+ Address sender = new UserAddress(getUser(senderUserId));
User recipient = getUser(recipientUserId);
- User[] recipients = { recipient };
+ UserAddress[] recipients = { new UserAddress(recipient) };
String name = getParameterAsString(NAME);
String body = getParameterAsString(MESSAGE);
String from = getParameterAsString(FROM);
- Message message = new Message("Contact form submitted by " + name + " (" + from + ")",
- new String[0],
- body,
- new String[0],
+ Message message = new Message(new Text("Contact form submitted by " + name + " (" + from + ")",
+ false),
+ new Text(body, false),
sender,
recipients);
Modified: lenya/sandbox/access_control_redesign/src/modules/editors/java/src/org/apache/lenya/cms/editors/InsertAsset.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/editors/java/src/org/apache/lenya/cms/editors/InsertAsset.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/editors/java/src/org/apache/lenya/cms/editors/InsertAsset.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/editors/java/src/org/apache/lenya/cms/editors/InsertAsset.java Wed Nov 19 14:35:09 2008
@@ -24,7 +24,7 @@
import java.util.Map;
import org.apache.cocoon.environment.Request;
-import org.apache.lenya.ac.User;
+import org.apache.lenya.ac.UserReference;
import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
import org.apache.lenya.cms.linking.LinkRewriter;
import org.apache.lenya.cms.linking.OutgoingLinkRewriter;
@@ -56,9 +56,9 @@
setParameter(DOCUMENT, getSourceDocument());
try {
- User user = getSession().getIdentity().getUser();
- if (user != null) {
- setParameter("creator", user.getId());
+ UserReference userRef = getSession().getIdentity().getUserReference();
+ if (userRef != null) {
+ setParameter("creator", userRef.getId());
}
} catch (final Exception e) {
throw new RuntimeException(e);
Modified: lenya/sandbox/access_control_redesign/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/lucene/java/src/org/apache/cocoon/transformation/LuceneIndexTransformer2.java Wed Nov 19 14:35:09 2008
@@ -17,7 +17,6 @@
package org.apache.cocoon.transformation;
import java.io.IOException;
-import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Map;
@@ -30,6 +29,7 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.search.Index;
@@ -40,14 +40,20 @@
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
-import org.apache.lenya.ac.Identifiable;
+import org.apache.lenya.ac.AccessController;
+import org.apache.lenya.ac.AccessControllerResolver;
+import org.apache.lenya.ac.Identity;
import org.apache.lenya.ac.User;
import org.apache.lenya.ac.UserManager;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.modules.lucene.MetaDataFieldRegistry;
+import org.apache.lenya.notification.Address;
import org.apache.lenya.notification.Message;
import org.apache.lenya.notification.NotificationUtil;
+import org.apache.lenya.notification.Text;
+import org.apache.lenya.notification.UserAddress;
+import org.apache.lenya.util.ServletHelper;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -651,18 +657,17 @@
try {
Session session = RepositoryUtil.getSession(this.manager, this.request);
- User sender = session.getIdentity().getUser();
- UserManager userManager = (UserManager) sender.getItemManager();
+ User user = getErrorMessageRecipient();
+ Address sender = new UserAddress(user);
+ UserManager userManager = (UserManager) user.getItemManager();
User recipient = userManager.getUser(this.notificationRecipient);
- Identifiable[] recipients = { recipient };
+ Address[] recipients = { new UserAddress(recipient) };
- String subject = "indexing-failed-subject";
- String[] subjectParams = new String[0];
- String body = "indexing-failed-body";
+ Text subject = new Text("indexing-failed-subject", true);
String[] bodyParams = { this.pubId, this.area, this.uuid, this.language, msg };
+ Text body = new Text("indexing-failed-body", bodyParams);
- Message message = new Message(subject, subjectParams, body, bodyParams, sender,
- recipients);
+ Message message = new Message(subject, body, sender, recipients);
NotificationUtil.notify(this.manager, message);
getLogger().error(
@@ -680,6 +685,43 @@
* new SAXException(msg, ex); }
*/
}
+
+ protected User getErrorMessageRecipient() {
+
+ ServiceSelector selector = null;
+ AccessControllerResolver acResolver = null;
+ AccessController accessController = null;
+ try {
+ selector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
+ + "Selector");
+ acResolver = (AccessControllerResolver) selector
+ .select(AccessControllerResolver.DEFAULT_RESOLVER);
+ String webappUrl = ServletHelper.getWebappURI(this.request);
+ accessController = acResolver.resolveAccessController(webappUrl);
+
+ UserManager userManager = accessController.getAccreditableManager().getUserManager();
+ Identity identity = (Identity) this.request.getSession().getAttribute(Identity.class.getName());
+ String userId = identity.getUserReference().getId();
+ User user = userManager.getUser(userId);
+ if (user == null) {
+ throw new RuntimeException("The user '" + userId + "' doesn't exist.");
+ }
+ return user;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (selector != null) {
+ if (acResolver != null) {
+ if (accessController != null) {
+ acResolver.release(accessController);
+ }
+ selector.release(acResolver);
+ }
+ this.manager.release(selector);
+ }
+ }
+ }
+
/**
* Close the indexer
Modified: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java Wed Nov 19 14:35:09 2008
@@ -23,13 +23,17 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.components.modules.input.AbstractInputModule;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
+import org.apache.lenya.ac.AccessController;
+import org.apache.lenya.ac.AccessControllerResolver;
import org.apache.lenya.ac.User;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.util.ServletHelper;
/**
* <p>
@@ -53,12 +57,23 @@
Object value = null;
if (name.equals(NEW_MESSAGE_COUNT)) {
+ ServiceSelector selector = null;
+ AccessControllerResolver acResolver = null;
+ AccessController accessController = null;
InboxManager inboxManager = null;
try {
- inboxManager = (InboxManager) this.manager.lookup(InboxManager.ROLE);
+ selector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
+ + "Selector");
+ acResolver = (AccessControllerResolver) selector
+ .select(AccessControllerResolver.DEFAULT_RESOLVER);
+
Request request = ObjectModelHelper.getRequest(objectModel);
+ String webappUrl = ServletHelper.getWebappURI(request);
+ accessController = acResolver.resolveAccessController(webappUrl);
+ inboxManager = (InboxManager) this.manager.lookup(InboxManager.ROLE);
Session session = RepositoryUtil.getSession(manager, request);
- User user = session.getIdentity().getUser();
+ String userId = session.getIdentity().getUserReference().getId();
+ User user = accessController.getAccreditableManager().getUserManager().getUser(userId);
if (user == null) {
return "0";
} else {
@@ -76,6 +91,15 @@
} catch (Exception e) {
throw new ConfigurationException("Attribute [" + name + "]: ", e);
} finally {
+ if (selector != null) {
+ if (acResolver != null) {
+ if (accessController != null) {
+ acResolver.release(accessController);
+ }
+ selector.release(acResolver);
+ }
+ this.manager.release(selector);
+ }
if (inboxManager != null) {
this.manager.release(inboxManager);
}
Modified: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java Wed Nov 19 14:35:09 2008
@@ -17,7 +17,11 @@
*/
package org.apache.lenya.inbox.usecases;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.lenya.ac.AccessController;
+import org.apache.lenya.ac.AccessControllerResolver;
import org.apache.lenya.ac.User;
+import org.apache.lenya.ac.UserManager;
import org.apache.lenya.cms.usecase.AbstractUsecase;
import org.apache.lenya.inbox.InboxManager;
import org.apache.lenya.inbox.InboxMessage;
@@ -30,18 +34,41 @@
protected void initParameters() {
super.initParameters();
- User user = getSession().getIdentity().getUser();
- setParameter("user", user);
-
+ ServiceSelector selector = null;
+ AccessControllerResolver acResolver = null;
+ AccessController accessController = null;
InboxManager inboxManager = null;
+
try {
+ selector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
+ + "Selector");
+ acResolver = (AccessControllerResolver) selector
+ .select(AccessControllerResolver.DEFAULT_RESOLVER);
+ accessController = acResolver.resolveAccessController(getSourceURL());
inboxManager = (InboxManager) this.manager.lookup(InboxManager.ROLE);
+
+ UserManager userManager = accessController.getAccreditableManager().getUserManager();
+ String userId = getSession().getIdentity().getUserReference().getId();
+
+ User user = userManager.getUser(userId);
+ setParameter("user", user);
+
org.apache.lenya.inbox.Inbox inbox = inboxManager.getInbox(user);
setParameter("inbox", inbox);
+
} catch (Exception e) {
throw new RuntimeException(e);
- }
- finally {
+
+ } finally {
+ if (selector != null) {
+ if (acResolver != null) {
+ if (accessController != null) {
+ acResolver.release(accessController);
+ }
+ selector.release(acResolver);
+ }
+ this.manager.release(selector);
+ }
if (inboxManager != null) {
this.manager.release(inboxManager);
}
Modified: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/SendMessage.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/SendMessage.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/SendMessage.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/SendMessage.java Wed Nov 19 14:35:09 2008
@@ -17,12 +17,17 @@
*/
package org.apache.lenya.inbox.usecases;
-import org.apache.lenya.ac.Identifiable;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.lenya.ac.AccessController;
+import org.apache.lenya.ac.AccessControllerResolver;
import org.apache.lenya.ac.User;
import org.apache.lenya.ac.UserManager;
import org.apache.lenya.cms.usecase.AbstractUsecase;
+import org.apache.lenya.notification.Address;
import org.apache.lenya.notification.Message;
import org.apache.lenya.notification.NotificationUtil;
+import org.apache.lenya.notification.Text;
+import org.apache.lenya.notification.UserAddress;
import org.apache.lenya.util.Assert;
/**
@@ -33,18 +38,37 @@
protected void initParameters() {
super.initParameters();
- User user = getSession().getIdentity().getUser();
- setParameter("user", user);
-
+ ServiceSelector selector = null;
+ AccessControllerResolver acResolver = null;
+ AccessController accessController = null;
try {
- UserManager userManager = user.getAccreditableManager().getUserManager();
+ selector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
+ + "Selector");
+ acResolver = (AccessControllerResolver) selector
+ .select(AccessControllerResolver.DEFAULT_RESOLVER);
+ accessController = acResolver.resolveAccessController(getSourceURL());
+
+ UserManager userManager = accessController.getAccreditableManager().getUserManager();
+ String userId = getSession().getIdentity().getUserReference().getId();
+ User user = userManager.getUser(userId);
+ setParameter("user", user);
+
User[] users = userManager.getUsers();
setParameter("users", users);
-
} catch (Exception e) {
throw new RuntimeException(e);
- }
+ } finally {
+ if (selector != null) {
+ if (acResolver != null) {
+ if (accessController != null) {
+ acResolver.release(accessController);
+ }
+ selector.release(acResolver);
+ }
+ this.manager.release(selector);
+ }
+ }
}
protected void doCheckExecutionConditions() throws Exception {
@@ -74,25 +98,44 @@
protected void doExecute() throws Exception {
super.doExecute();
- String recipientId = getRecipient();
- User sender = getSession().getIdentity().getUser();
- User recipient;
-
+ ServiceSelector selector = null;
+ AccessControllerResolver acResolver = null;
+ AccessController accessController = null;
try {
- UserManager userManager = sender.getAccreditableManager().getUserManager();
- recipient = userManager.getUser(recipientId);
+ selector = (ServiceSelector) this.manager.lookup(AccessControllerResolver.ROLE
+ + "Selector");
+ acResolver = (AccessControllerResolver) selector
+ .select(AccessControllerResolver.DEFAULT_RESOLVER);
+ accessController = acResolver.resolveAccessController(getSourceURL());
+
+ UserManager userManager = accessController.getAccreditableManager().getUserManager();
+ String userId = getSession().getIdentity().getUserReference().getId();
+ User sender = userManager.getUser(userId);
+ Address senderAddress = new UserAddress(sender);
+
+ String recipientId = getRecipient();
+ User recipient = userManager.getUser(recipientId);
Assert.notNull("user " + recipientId, recipient);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- Identifiable[] recipients = { recipient };
- String subject = getSubject();
- String body = getBody();
-
- Message message = new Message(subject, new String[0], body, new String[0], sender,
- recipients);
- NotificationUtil.notify(this.manager, message);
+ Address[] recipients = { new UserAddress(recipient) };
+ String subject = getSubject();
+ String body = getBody();
+
+ Message message = new Message(new Text(subject, new String[0]), new Text(body,
+ new String[0]), senderAddress, recipients);
+ NotificationUtil.notify(this.manager, message);
+
+ } finally {
+ if (selector != null) {
+ if (acResolver != null) {
+ if (accessController != null) {
+ acResolver.release(accessController);
+ }
+ selector.release(acResolver);
+ }
+ this.manager.release(selector);
+ }
+ }
}
Modified: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java Wed Nov 19 14:35:09 2008
@@ -27,13 +27,16 @@
import org.apache.axis.components.uuid.UUIDGenFactory;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Group;
-import org.apache.lenya.ac.Identifiable;
import org.apache.lenya.ac.User;
import org.apache.lenya.cms.cocoon.source.SourceUtil;
import org.apache.lenya.inbox.Inbox;
import org.apache.lenya.inbox.InboxMessage;
+import org.apache.lenya.notification.Address;
+import org.apache.lenya.notification.GroupAddress;
import org.apache.lenya.notification.Message;
import org.apache.lenya.notification.Notifier;
+import org.apache.lenya.notification.Text;
+import org.apache.lenya.notification.UserAddress;
import org.apache.lenya.util.Assert;
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
@@ -117,7 +120,7 @@
}
String senderId = messageElements[i].getAttribute("sender");
- User sender = getUser(senderId);
+ Address sender = new UserAddress(getUser(senderId));
Element recipientElement = helper.getFirstChild(messageElements[i],
"recipients");
@@ -125,17 +128,17 @@
Element[] userElements = helper.getChildren(recipientElement, "user");
Element[] groupElements = helper.getChildren(recipientElement, "group");
- Identifiable[] recipients = new Identifiable[userElements.length
+ Address[] recipients = new Address[userElements.length
+ groupElements.length];
for (int u = 0; u < userElements.length; u++) {
String userId = userElements[u].getAttribute("id");
- recipients[u] = getUser(userId);
+ recipients[u] = new UserAddress(getUser(userId));
}
for (int g = 0; g < groupElements.length; g++) {
String groupId = groupElements[g].getAttribute("id");
- recipients[userElements.length + g] = getGroup(groupId);
+ recipients[userElements.length + g] = new GroupAddress(getGroup(groupId));
}
Element bodyElement = helper.getFirstChild(messageElements[i], "body");
@@ -163,7 +166,7 @@
}
boolean read = Boolean.valueOf(readString).booleanValue();
- Message message = new Message(subject, subjectParams, body, bodyParams, sender,
+ Message message = new Message(new Text(subject, subjectParams), new Text(body, bodyParams), sender,
recipients);
InboxMessage msg = new XmlSourceInboxMessage(this, id, message, read);
this.messages.add(msg);
@@ -223,13 +226,13 @@
Element messageElement = helper.createElement("message");
helper.getDocument().getDocumentElement().appendChild(messageElement);
- User sender = (User) message.getSender();
+ Address sender = message.getSenderAddress();
messageElement.setAttribute("sender", sender.getId());
Element recipientsElement = helper.createElement("recipients");
messageElement.appendChild(recipientsElement);
- Identifiable[] recipients = message.getRecipients();
+ Address[] recipients = message.getRecipientAddresses();
for (int r = 0; r < recipients.length; r++) {
if (recipients[r] instanceof User) {
Element userElement = helper.createElement("user");
@@ -244,21 +247,21 @@
Element subjectElement = helper.createElement("subject");
messageElement.appendChild(subjectElement);
- Element subjectTextElement = helper.createElement("text", message.getSubject());
+ Element subjectTextElement = helper.createElement("text", message.getSubjectText().getText());
subjectElement.appendChild(subjectTextElement);
- String[] subjectParams = message.getSubjectParameters();
+ Text[] subjectParams = message.getSubjectText().getParameters();
for (int p = 0; p < subjectParams.length; p++) {
- Element paramElement = helper.createElement("param", subjectParams[p]);
+ Element paramElement = helper.createElement("param", subjectParams[p].getText());
subjectElement.appendChild(paramElement);
}
Element bodyElement = helper.createElement("body");
messageElement.appendChild(bodyElement);
- Element bodyTextElement = helper.createElement("text", message.getBody());
+ Element bodyTextElement = helper.createElement("text", message.getBodyText().getText());
bodyElement.appendChild(bodyTextElement);
- String[] bodyParams = message.getBodyParameters();
+ Text[] bodyParams = message.getBodyText().getParameters();
for (int p = 0; p < bodyParams.length; p++) {
- Element paramElement = helper.createElement("param", bodyParams[p]);
+ Element paramElement = helper.createElement("param", bodyParams[p].getText());
bodyElement.appendChild(paramElement);
}
Modified: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/AbstractNotifier.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/AbstractNotifier.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/AbstractNotifier.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/AbstractNotifier.java Wed Nov 19 14:35:09 2008
@@ -53,7 +53,7 @@
Set noDuplicates = new HashSet();
- Identifiable[] recipients = message.getRecipients();
+ Address[] recipients = message.getRecipientAddresses();
for (int i = 0; i < recipients.length; i++) {
if (recipients[i] instanceof Group) {
@@ -144,7 +144,7 @@
String body = DocumentHelper.getSimpleElementText(bodyElement);
return new Message(new Text(subject, false), new Text(body, false), message
- .getSender(), message.getRecipients());
+ .getSenderAddress(), message.getRecipientAddresses());
} else {
// this happens in the test
getLogger().info("cocoon protocol not available, not translating message");
Added: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Address.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Address.java?rev=719100&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Address.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Address.java Wed Nov 19 14:35:09 2008
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.notification;
+
+/**
+ * A message recipient address.
+ */
+public interface Address {
+
+ String getId();
+
+}
Modified: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java Wed Nov 19 14:35:09 2008
@@ -25,7 +25,6 @@
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.cocoon.mail.MailSender;
-import org.apache.lenya.ac.Identifiable;
import org.apache.lenya.ac.User;
import org.apache.lenya.inbox.InboxNotifier;
@@ -43,7 +42,7 @@
return;
}
- Identifiable sender = translatedMessage.getSender();
+ Address sender = translatedMessage.getSenderAddress();
MailSender mailer = null;
try {
mailer = (MailSender) this.manager.lookup(MailSender.ROLE);
@@ -54,12 +53,12 @@
}
mailer.setTo(recipient.getEmail());
- if (sender instanceof User) {
- mailer.setFrom(((User) sender).getEmail());
+ if (sender instanceof UserAddress) {
+ mailer.setFrom(((UserAddress) sender).getUser().getEmail());
}
- mailer.setSubject(translatedMessage.getSubject());
- mailer.setBody(translatedMessage.getBody(), "text/plain; charset=UTF-8");
+ mailer.setSubject(translatedMessage.getSubjectText().getText());
+ mailer.setBody(translatedMessage.getBodyText().getText(), "text/plain; charset=UTF-8");
mailer.send();
} catch (AddressException e) {
Added: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/GroupAddress.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/GroupAddress.java?rev=719100&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/GroupAddress.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/GroupAddress.java Wed Nov 19 14:35:09 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.notification;
+
+import org.apache.lenya.ac.Group;
+import org.apache.lenya.util.Assert;
+
+public class GroupAddress implements Address {
+
+ private Group group;
+
+ public GroupAddress(Group group) {
+ Assert.notNull("group", group);
+ this.group = group;
+ }
+
+ public String getId() {
+ return getGroup().getId();
+ }
+
+ private Group getGroup() {
+ return this.group;
+ }
+
+}
Modified: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Message.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Message.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Message.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/Message.java Wed Nov 19 14:35:09 2008
@@ -17,10 +17,8 @@
*/
package org.apache.lenya.notification;
-import java.util.Arrays;
import java.util.Date;
-import org.apache.lenya.ac.Identifiable;
import org.apache.lenya.util.Assert;
/**
@@ -31,17 +29,17 @@
private Text subject;
private Text body;
- private Identifiable sender;
- private Identifiable[] recipients;
private Date time;
-
+ private Address sender;
+ private Address[] recipients;
+
/**
* @param subject The subject.
* @param body The body.
* @param sender The sender.
* @param recipients The recipients.
*/
- public Message(Text subject, Text body, Identifiable sender, Identifiable[] recipients) {
+ public Message(Text subject, Text body, Address sender, Address[] recipients) {
Assert.notNull("subject", subject);
Assert.notNull("body", body);
Assert.notNull("sender", sender);
@@ -53,22 +51,7 @@
this.time = new Date();
}
- /**
- * Constructor.
- * @param subject The subject.
- * @param subjectParams The subject parameters.
- * @param body The body.
- * @param bodyParams The body parameters.
- * @param sender The sender.
- * @param recipients The recipients.
- * @deprecated Use {@link #Message(Text, Text, Identifiable, Identifiable[])}ĂŠinstead.
- */
- public Message(String subject, String[] subjectParams, String body, String[] bodyParams,
- Identifiable sender, Identifiable[] recipients) {
- this(new Text(subject, subjectParams), new Text(body, bodyParams), sender, recipients);
- }
-
- /**
+ /**
* Determine if this message has parameters
* @return true if the message has parameters
*/
@@ -132,22 +115,6 @@
}
/**
- * @return The sender.
- */
- public Identifiable getSender() {
- return this.sender;
- }
-
- /**
- * @return The recipients.
- */
- public Identifiable[] getRecipients() {
- // don't expose the internal array
- return (Identifiable[]) Arrays.asList(this.recipients).toArray(
- new Identifiable[this.recipients.length]);
- }
-
- /**
* @return The time when the message was sent.
*/
public Date getTime() {
@@ -167,5 +134,19 @@
public Text getBodyText() {
return this.body;
}
+
+ /**
+ * @return The sender address.
+ */
+ public Address getSenderAddress() {
+ return this.sender;
+ }
+
+ /**
+ * @return The recipient addresses.
+ */
+ public Address[] getRecipientAddresses() {
+ return this.recipients;
+ }
}
Added: lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/UserAddress.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/UserAddress.java?rev=719100&view=auto
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/UserAddress.java (added)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/src/org/apache/lenya/notification/UserAddress.java Wed Nov 19 14:35:09 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.notification;
+
+import org.apache.lenya.ac.User;
+import org.apache.lenya.util.Assert;
+
+public class UserAddress implements Address {
+
+ private User user;
+
+ public UserAddress(User user) {
+ Assert.notNull("user", user);
+ this.user = user;
+ }
+
+ public User getUser() {
+ return this.user;
+ }
+
+ public String getId() {
+ return getUser().getId();
+ }
+
+}
Modified: lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java Wed Nov 19 14:35:09 2008
@@ -17,51 +17,58 @@
*/
package org.apache.lenya.inbox;
-import org.apache.lenya.ac.Identifiable;
import org.apache.lenya.ac.User;
import org.apache.lenya.inbox.xml.XmlSourceInbox;
import org.apache.lenya.notification.AbstractNotificationTest;
+import org.apache.lenya.notification.Address;
import org.apache.lenya.notification.Message;
+import org.apache.lenya.notification.Text;
+import org.apache.lenya.notification.UserAddress;
/**
* Inbox test.
*/
public class InboxTest extends AbstractNotificationTest {
-
+
protected static final String SUBJECT = "hello";
/**
* The test.
- * @throws Exception if an error occurs.
+ *
+ * @throws Exception
+ * if an error occurs.
*/
public void testInbox() throws Exception {
-
+
User lenya = getAccreditableManager().getUserManager().getUser("lenya");
Inbox inbox = getInbox(lenya);
-
+
cleanUp(inbox, SUBJECT);
assertFalse(containsMessage(inbox, SUBJECT));
-
- Identifiable[] recipients = { lenya };
- Message message = new Message(SUBJECT, new String[0], "body", new String[0], lenya,
- recipients);
+ Address sender = new UserAddress(lenya);
+ Address[] recipients = { sender };
+
+ Text subject = new Text(SUBJECT, new String[0]);
+ Text body = new Text("body", new String[0]);
+
+ Message message = new Message(subject, body, sender, recipients);
InboxMessage inboxMessage = inbox.add(message);
-
- assertEquals(inboxMessage.getMessage().getSubject(), SUBJECT);
-
+
+ assertEquals(inboxMessage.getMessage().getSubjectText().getText(), SUBJECT);
+
assertFalse(inboxMessage.isMarkedAsRead());
inboxMessage.markAsRead(true);
assertTrue(inboxMessage.isMarkedAsRead());
-
+
XmlSourceInbox xmlInbox = new XmlSourceInbox(getManager(), lenya);
assertTrue(containsMessage(xmlInbox, SUBJECT));
-
+
InboxMessage xmlMessage = getMessage(xmlInbox, SUBJECT);
assertTrue(xmlMessage.isMarkedAsRead());
-
+
cleanUp(inbox, SUBJECT);
-
+
}
}
Modified: lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java Wed Nov 19 14:35:09 2008
@@ -17,7 +17,6 @@
*/
package org.apache.lenya.notification;
-import org.apache.lenya.ac.Identifiable;
import org.apache.lenya.ac.User;
import org.apache.lenya.cms.observation.RepositoryEvent;
import org.apache.lenya.cms.observation.RepositoryEventFactory;
@@ -44,10 +43,11 @@
User lenya = getAccreditableManager().getUserManager().getUser("lenya");
User alice = getAccreditableManager().getUserManager().getUser("alice");
- Identifiable[] recipients = { alice };
+ Address[] recipients = { new UserAddress(alice) };
+ Text subject = new Text(SUBJECT, true);
+ Text body = new Text("body", true);
- Message message = new Message(SUBJECT, new String[0], "body", new String[0], lenya,
- recipients);
+ Message message = new Message(subject, body, new UserAddress(lenya), recipients);
NotificationEventDescriptor descr = new NotificationEventDescriptor(message);
RepositoryEvent event = RepositoryEventFactory.createEvent(getManager(), session,
getLogger(), descr);
Modified: lenya/sandbox/access_control_redesign/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/transformation/AccessControlSitetreeTransformer.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/transformation/AccessControlSitetreeTransformer.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/transformation/AccessControlSitetreeTransformer.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/sitetree/java/src/org/apache/lenya/cms/cocoon/transformation/AccessControlSitetreeTransformer.java Wed Nov 19 14:35:09 2008
@@ -83,7 +83,7 @@
this.acResolver = null;
this.policyManager = null;
- this.identity = Identity.getIdentity(this.request.getSession(false));
+ this.identity = (Identity) this.request.getSession(false).getAttribute(Identity.class.getName());
try {
String publicationId = par.getParameter(PARAMETER_PUBLICATION_ID);
Modified: lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNode.java Wed Nov 19 14:35:09 2008
@@ -28,7 +28,7 @@
import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.source.TraversableSource;
import org.apache.lenya.ac.Identity;
-import org.apache.lenya.ac.User;
+import org.apache.lenya.ac.UserReference;
import org.apache.lenya.cms.metadata.MetaData;
import org.apache.lenya.cms.metadata.MetaDataException;
import org.apache.lenya.cms.observation.DocumentEvent;
@@ -91,7 +91,7 @@
String userId = null;
Identity identity = getSession().getIdentity();
if (identity != null) {
- User user = identity.getUser();
+ UserReference user = identity.getUserReference();
if (user != null) {
userId = user.getId();
}
Modified: lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java
URL: http://svn.apache.org/viewvc/lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java?rev=719100&r1=719099&r2=719100&view=diff
==============================================================================
--- lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java (original)
+++ lenya/sandbox/access_control_redesign/src/modules/sourcerepository/java/src/org/apache/lenya/cms/repository/SourceNodeRCML.java Wed Nov 19 14:35:09 2008
@@ -144,7 +144,7 @@
public synchronized void checkOutIn(Node node, short type, long time, boolean backup,
boolean newVersion, boolean restrictedToSession) throws RevisionControlException {
- String identity = node.getSession().getIdentity().getUser().getId();
+ String identity = node.getSession().getIdentity().getUserReference().getId();
Vector entries = getEntries();
if (entries.size() == 0) {
@@ -625,7 +625,7 @@
// not restricted to session
if (otherSessionId.equals(ALL_SESSIONS)) {
String otherUserId = entry.getIdentity();
- String userId = session.getIdentity().getUser().getId();
+ String userId = session.getIdentity().getUserReference().getId();
return userId.equals(otherUserId);
}
// restricted to session
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org