You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2014/03/20 09:16:10 UTC
svn commit: r1579559 [15/23] - in /james/hupa/trunk: ./ client/
client/src/main/java/com/google/web/bindery/requestfactory/server/
client/src/main/java/org/apache/hupa/
client/src/main/java/org/apache/hupa/client/
client/src/main/java/org/apache/hupa/c...
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendMessageBaseServiceImpl.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendMessageBaseServiceImpl.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendMessageBaseServiceImpl.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendMessageBaseServiceImpl.java Thu Mar 20 08:16:02 2014
@@ -1,437 +1,437 @@
-/****************************************************************
- * 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.hupa.server.service;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.activation.DataSource;
-import javax.mail.AuthenticationFailedException;
-import javax.mail.BodyPart;
-import javax.mail.Flags.Flag;
-import javax.mail.Folder;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Multipart;
-import javax.mail.Session;
-import javax.mail.internet.AddressException;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeBodyPart;
-import javax.mail.internet.MimeMessage;
-import javax.mail.internet.MimeMessage.RecipientType;
-import javax.mail.internet.MimeMultipart;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.fileupload.FileItem;
-import org.apache.hupa.server.FileItemRegistry;
-import org.apache.hupa.server.IMAPStoreCache;
-import org.apache.hupa.server.preferences.UserPreferencesStorage;
-import org.apache.hupa.server.utils.MessageUtils;
-import org.apache.hupa.server.utils.RegexPatterns;
-import org.apache.hupa.server.utils.SessionUtils;
-import org.apache.hupa.shared.SConsts;
-import org.apache.hupa.shared.data.GenericResultImpl;
-import org.apache.hupa.shared.domain.GenericResult;
-import org.apache.hupa.shared.domain.MessageAttachment;
-import org.apache.hupa.shared.domain.SendMessageAction;
-import org.apache.hupa.shared.domain.SmtpMessage;
-import org.apache.hupa.shared.domain.User;
-import org.apache.hupa.shared.exception.HupaException;
-
-import com.google.inject.Inject;
-import com.google.web.bindery.requestfactory.server.RequestFactoryServlet;
-import com.sun.mail.imap.IMAPFolder;
-import com.sun.mail.imap.IMAPStore;
-
-public class SendMessageBaseServiceImpl extends AbstractService implements SendMessageService {
-
- UserPreferencesStorage userPreferences;
-
- @Inject
- public SendMessageBaseServiceImpl(UserPreferencesStorage preferences, IMAPStoreCache cache) {
- this.cache = cache;
- this.userPreferences = preferences;
- }
-
- public GenericResult send(SendMessageAction action)
- throws Exception {
- GenericResult result = new GenericResultImpl();
- try {
- User user = getUser();
- Message message = createMessage(cache.getMailSession(user), action);
- message = fillBody(message,action);
- sendMessage(getUser(), message);
- if (!user.getSettings().getSmtpServer().contains("gmail.com")) {
- saveSentMessage(getUser(), message);
- }
- resetAttachments(action);
-
- // TODO: notify the user more accurately where the error is
- // if the message was sent and the storage in the sent folder failed, etc.
- } catch (AddressException e) {
- result.setError("Error while parsing recipient: " + e.getMessage());
- logger.error("Error while parsing recipient", e);
- } catch (AuthenticationFailedException e) {
- result.setError("Error while sending message: SMTP Authentication error.");
- logger.error("SMTP Authentication error", e);
- } catch (MessagingException e) {
- result.setError("Error while sending message: " + e.getMessage());
- logger.error("Error while sending message", e);
- } catch (Exception e) {
- result.setError("Unexpected exception while sendig message: " + e.getMessage());
- logger.error("Unexpected exception while sendig message: ", e);
- }
- return result;
- }
-
- /**
- * Create basic Message which contains all headers. No body is filled
- *
- * @param session the Session
- * @param action the action
- * @return message
- * @throws AddressException
- * @throws MessagingException
- */
- public Message createMessage(Session session, SendMessageAction action) throws AddressException, MessagingException {
- MimeMessage message = new MimeMessage(session);
- SmtpMessage m = action.getMessage();
- message.setFrom(new InternetAddress(m.getFrom()));
-
- userPreferences.addContact(m.getTo());
- userPreferences.addContact(m.getCc());
- userPreferences.addContact(m.getBcc());
-
- message.setRecipients(RecipientType.TO, MessageUtils.getRecipients(m.getTo()));
- message.setRecipients(RecipientType.CC, MessageUtils.getRecipients(m.getCc()));
- message.setRecipients(RecipientType.BCC, MessageUtils.getRecipients(m.getBcc()));
- message.setSentDate(new Date());
- message.addHeader("User-Agent:", "HUPA, The Apache JAMES webmail client.");
- message.addHeader("X-Originating-IP", getClientIpAddr());
- message.setSubject(m.getSubject(), "utf-8");
- updateHeaders(message, action);
- message.saveChanges();
- return message;
- }
-
- public static String getClientIpAddr() {
- HttpServletRequest request = RequestFactoryServlet.getThreadLocalRequest();
- String ip = "unknown";
- if (request != null) {
- ip = request.getHeader("X-Forwarded-For");
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
- ip = request.getHeader("Proxy-Client-IP");
- }
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
- ip = request.getHeader("WL-Proxy-Client-IP");
- }
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
- ip = request.getHeader("HTTP_CLIENT_IP");
- }
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
- ip = request.getHeader("HTTP_X_FORWARDED_FOR");
- }
- if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
- ip = request.getRemoteAddr();
- }
- }
- return ip;
- }
-
- protected void updateHeaders(MimeMessage message, SendMessageAction action) {
- if (action.getInReplyTo() != null) {
- try {
- message.addHeader(SConsts.HEADER_IN_REPLY_TO, action.getInReplyTo());
- } catch (MessagingException e) {
- logger.error("Error while setting header:" + e.getMessage(), e);
- }
- }
- if (action.getReferences() != null) {
- try {
- message.addHeader(SConsts.HEADER_REFERENCES, action.getReferences());
- } catch (MessagingException e) {
- logger.error("Error while setting header:" + e.getMessage(), e);
- }
- }
- }
-
- /**
- * Fill the body of the given message with data which the given action contain
- *
- * @param message the message
- * @param action the action
- * @return filledMessage
- * @throws MessagingException
- * @throws IOException
- * @throws HupaException
- */
- public Message fillBody(Message message, SendMessageAction action) throws MessagingException, IOException, HupaException {
-
- String html = restoreInlineLinks(action.getMessage().getText());
-
- // TODO: client sends the message as a html document right now,
- // the idea is that it should be sent in both formats because
- // it is easier to handle html in the browser.
- String text = htmlToText(html);
-
- @SuppressWarnings("rawtypes")
- List items = getAttachments(action);
-
- return composeMessage(message, text, html, items);
- }
-
- protected String restoreInlineLinks(String s) {
- return RegexPatterns.replaceAll(s, RegexPatterns.regex_revertInlineImg, RegexPatterns.repl_revertInlineImg);
- }
-
- // TODO: just temporary stuff because it has to be done in the client side
- protected String htmlToText(String s){
- s=s.replaceAll("\n", " ");
- s=s.replaceAll("(?si)<br\\s*?/?>", "\n");
- s=s.replaceAll("(?si)</div\\s*?>", "\n");
- s=s.replaceAll("(\\w)<.*?>(\\w)", "$1 $2");
- s=s.replaceAll("<.*?>", "");
- s=s.replaceAll("[ \t]+", " ");
- return s;
- }
-
- /**
- * Get the attachments stored in the registry.
- *
- * @param action
- * @return A list of stored attachments
- * @throws HupaException
- */
- @SuppressWarnings("rawtypes")
- protected List getAttachments(SendMessageAction action) throws MessagingException, HupaException {
- FileItemRegistry registry = SessionUtils.getSessionRegistry(logger, httpSessionProvider.get());
- List<MessageAttachment> attachments = action.getMessage().getMessageAttachments();
-
- ArrayList<FileItem> items = new ArrayList<FileItem>();
- if (attachments != null && attachments.size() > 0) {
- for (MessageAttachment attachment: attachments) {
- FileItem fItem = registry.get(attachment.getName());
- if (fItem != null)
- items.add(fItem);
- }
- logger.debug("Found " + items.size() + " attachmets in the registry.");
- }
- return items;
- }
-
- /**
- * Remove attachments from the registry
- *
- * @param action
- * @throws MessagingException
- * @throws ActionException
- */
- protected void resetAttachments(SendMessageAction action) throws MessagingException {
- SmtpMessage msg = action.getMessage();
- List<MessageAttachment> attachments = msg.getMessageAttachments();
- if (attachments != null && ! attachments.isEmpty()) {
- for(MessageAttachment attach : attachments)
- SessionUtils.getSessionRegistry(logger, httpSessionProvider.get()).remove(attach.getName());
- }
- }
-
- /**
- * Send the message using SMTP, if the configuration uses authenticated SMTP, it uses
- * the user stored in session to get the given login and password.
- *
- * @param user
- * @param session
- * @param message
- * @throws MessagingException
- */
- protected void sendMessage(User user, Message message) throws MessagingException {
- cache.sendMessage(message);
- logger.info("Send message from " + message.getFrom()[0].toString());
- }
-
- /**
- * Save the message in the sent folder
- *
- * @param user
- * @param message
- * @throws MessagingException
- * @throws IOException
- */
- protected void saveSentMessage(User user, Message message) throws MessagingException, IOException {
- IMAPStore iStore = cache.get(user);
- IMAPFolder folder = (IMAPFolder) iStore.getFolder(user.getSettings().getSentFolderName());
-
- if (folder.exists() || folder.create(IMAPFolder.READ_WRITE)) {
- if (folder.isOpen() == false) {
- folder.open(Folder.READ_WRITE);
- }
-
- // It is necessary to copy the message, before putting it
- // in the sent folder. If not, it is not guaranteed that it is
- // stored in ascii and is not possible to get the attachments
- // size. message.saveChanges() doesn't fix the problem.
- // There are tests which demonstrate this.
- message = new MimeMessage((MimeMessage)message);
-
- message.setFlag(Flag.SEEN, true);
- folder.appendMessages(new Message[] {message});
-
- try {
- folder.close(false);
- } catch (MessagingException e) {
- // we don't care on close
- }
- }
- }
-
- /**
- * Fill the body of a message already created.
- * The result message depends on the information given.
- *
- * @param message
- * @param text
- * @param html
- * @param parts
- * @return The composed message
- * @throws MessagingException
- * @throws IOException
- */
- @SuppressWarnings("rawtypes")
- public static Message composeMessage (Message message, String text, String html, List parts) throws MessagingException, IOException {
-
- MimeBodyPart txtPart = null;
- MimeBodyPart htmlPart = null;
- MimeMultipart mimeMultipart = null;
-
- if (text == null && html == null) {
- text = "";
- }
- if (text != null) {
- txtPart = new MimeBodyPart();
- txtPart.setContent(text, "text/plain; charset=UTF-8");
- }
- if (html != null) {
- htmlPart = new MimeBodyPart();
- htmlPart.setContent(html, "text/html; charset=UTF-8");
- }
- if (html != null && text != null) {
- mimeMultipart = new MimeMultipart();
- mimeMultipart.setSubType("alternative");
- mimeMultipart.addBodyPart(txtPart);
- mimeMultipart.addBodyPart(htmlPart);
- }
-
- if (parts == null || parts.isEmpty()) {
- if (mimeMultipart != null) {
- message.setContent(mimeMultipart);
- } else if (html != null) {
- message.setText(html);
- message.setHeader("Content-type", "text/html");
- } else if (text != null) {
- message.setText(text);
- }
- } else {
- MimeBodyPart bodyPart = new MimeBodyPart();
- if (mimeMultipart != null) {
- bodyPart.setContent(mimeMultipart);
- } else if (html != null) {
- bodyPart.setText(html);
- bodyPart.setHeader("Content-type", "text/html");
- } else if (text != null) {
- bodyPart.setText(text);
- }
- Multipart multipart = new MimeMultipart();
- multipart.addBodyPart(bodyPart);
- for (Object attachment: parts) {
- if (attachment instanceof FileItem) {
- multipart.addBodyPart(MessageUtils.fileitemToBodypart((FileItem)attachment));
- } else {
- multipart.addBodyPart((BodyPart)attachment);
- }
- }
- message.setContent(multipart);
- }
-
- message.saveChanges();
- return message;
-
- }
-
- /**
- * DataStore which wrap a FileItem
- *
- */
- public static class FileItemDataStore implements DataSource {
-
- private FileItem item;
-
- public FileItemDataStore(FileItem item) {
- this.item = item;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.activation.DataSource#getContentType()
- */
- public String getContentType() {
- return item.getContentType();
- }
-
- /*
- * (non-Javadoc)
- * @see javax.activation.DataSource#getInputStream()
- */
- public InputStream getInputStream() throws IOException {
- return item.getInputStream();
- }
-
- /*
- * (non-Javadoc)
- * @see javax.activation.DataSource#getName()
- */
- public String getName() {
- String fullName = item.getName();
-
- // Strip path from file
- int index = fullName.lastIndexOf(File.separator);
- if (index == -1) {
- return fullName;
- } else {
- return fullName.substring(index +1 ,fullName.length());
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.activation.DataSource#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- return null;
- }
-
- }
-
-
-}
+/****************************************************************
+ * 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.hupa.server.service;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.activation.DataSource;
+import javax.mail.AuthenticationFailedException;
+import javax.mail.BodyPart;
+import javax.mail.Flags.Flag;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Session;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMessage.RecipientType;
+import javax.mail.internet.MimeMultipart;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.hupa.server.FileItemRegistry;
+import org.apache.hupa.server.IMAPStoreCache;
+import org.apache.hupa.server.preferences.UserPreferencesStorage;
+import org.apache.hupa.server.utils.MessageUtils;
+import org.apache.hupa.server.utils.RegexPatterns;
+import org.apache.hupa.server.utils.SessionUtils;
+import org.apache.hupa.shared.SConsts;
+import org.apache.hupa.shared.data.GenericResultImpl;
+import org.apache.hupa.shared.domain.GenericResult;
+import org.apache.hupa.shared.domain.MessageAttachment;
+import org.apache.hupa.shared.domain.SendMessageAction;
+import org.apache.hupa.shared.domain.SmtpMessage;
+import org.apache.hupa.shared.domain.User;
+import org.apache.hupa.shared.exception.HupaException;
+
+import com.google.inject.Inject;
+import com.google.web.bindery.requestfactory.server.RequestFactoryServlet;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPStore;
+
+public class SendMessageBaseServiceImpl extends AbstractService implements SendMessageService {
+
+ UserPreferencesStorage userPreferences;
+
+ @Inject
+ public SendMessageBaseServiceImpl(UserPreferencesStorage preferences, IMAPStoreCache cache) {
+ this.cache = cache;
+ this.userPreferences = preferences;
+ }
+
+ public GenericResult send(SendMessageAction action)
+ throws Exception {
+ GenericResult result = new GenericResultImpl();
+ try {
+ User user = getUser();
+ Message message = createMessage(cache.getMailSession(user), action);
+ message = fillBody(message,action);
+ sendMessage(getUser(), message);
+ if (!user.getSettings().getSmtpServer().contains("gmail.com")) {
+ saveSentMessage(getUser(), message);
+ }
+ resetAttachments(action);
+
+ // TODO: notify the user more accurately where the error is
+ // if the message was sent and the storage in the sent folder failed, etc.
+ } catch (AddressException e) {
+ result.setError("Error while parsing recipient: " + e.getMessage());
+ logger.error("Error while parsing recipient", e);
+ } catch (AuthenticationFailedException e) {
+ result.setError("Error while sending message: SMTP Authentication error.");
+ logger.error("SMTP Authentication error", e);
+ } catch (MessagingException e) {
+ result.setError("Error while sending message: " + e.getMessage());
+ logger.error("Error while sending message", e);
+ } catch (Exception e) {
+ result.setError("Unexpected exception while sendig message: " + e.getMessage());
+ logger.error("Unexpected exception while sendig message: ", e);
+ }
+ return result;
+ }
+
+ /**
+ * Create basic Message which contains all headers. No body is filled
+ *
+ * @param session the Session
+ * @param action the action
+ * @return message
+ * @throws AddressException
+ * @throws MessagingException
+ */
+ public Message createMessage(Session session, SendMessageAction action) throws AddressException, MessagingException {
+ MimeMessage message = new MimeMessage(session);
+ SmtpMessage m = action.getMessage();
+ message.setFrom(new InternetAddress(m.getFrom()));
+
+ userPreferences.addContact(m.getTo());
+ userPreferences.addContact(m.getCc());
+ userPreferences.addContact(m.getBcc());
+
+ message.setRecipients(RecipientType.TO, MessageUtils.getRecipients(m.getTo()));
+ message.setRecipients(RecipientType.CC, MessageUtils.getRecipients(m.getCc()));
+ message.setRecipients(RecipientType.BCC, MessageUtils.getRecipients(m.getBcc()));
+ message.setSentDate(new Date());
+ message.addHeader("User-Agent:", "HUPA, The Apache JAMES webmail client.");
+ message.addHeader("X-Originating-IP", getClientIpAddr());
+ message.setSubject(m.getSubject(), "utf-8");
+ updateHeaders(message, action);
+ message.saveChanges();
+ return message;
+ }
+
+ public static String getClientIpAddr() {
+ HttpServletRequest request = RequestFactoryServlet.getThreadLocalRequest();
+ String ip = "unknown";
+ if (request != null) {
+ ip = request.getHeader("X-Forwarded-For");
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("Proxy-Client-IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("WL-Proxy-Client-IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("HTTP_CLIENT_IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getRemoteAddr();
+ }
+ }
+ return ip;
+ }
+
+ protected void updateHeaders(MimeMessage message, SendMessageAction action) {
+ if (action.getInReplyTo() != null) {
+ try {
+ message.addHeader(SConsts.HEADER_IN_REPLY_TO, action.getInReplyTo());
+ } catch (MessagingException e) {
+ logger.error("Error while setting header:" + e.getMessage(), e);
+ }
+ }
+ if (action.getReferences() != null) {
+ try {
+ message.addHeader(SConsts.HEADER_REFERENCES, action.getReferences());
+ } catch (MessagingException e) {
+ logger.error("Error while setting header:" + e.getMessage(), e);
+ }
+ }
+ }
+
+ /**
+ * Fill the body of the given message with data which the given action contain
+ *
+ * @param message the message
+ * @param action the action
+ * @return filledMessage
+ * @throws MessagingException
+ * @throws IOException
+ * @throws HupaException
+ */
+ public Message fillBody(Message message, SendMessageAction action) throws MessagingException, IOException, HupaException {
+
+ String html = restoreInlineLinks(action.getMessage().getText());
+
+ // TODO: client sends the message as a html document right now,
+ // the idea is that it should be sent in both formats because
+ // it is easier to handle html in the browser.
+ String text = htmlToText(html);
+
+ @SuppressWarnings("rawtypes")
+ List items = getAttachments(action);
+
+ return composeMessage(message, text, html, items);
+ }
+
+ protected String restoreInlineLinks(String s) {
+ return RegexPatterns.replaceAll(s, RegexPatterns.regex_revertInlineImg, RegexPatterns.repl_revertInlineImg);
+ }
+
+ // TODO: just temporary stuff because it has to be done in the client side
+ protected String htmlToText(String s){
+ s=s.replaceAll("\n", " ");
+ s=s.replaceAll("(?si)<br\\s*?/?>", "\n");
+ s=s.replaceAll("(?si)</div\\s*?>", "\n");
+ s=s.replaceAll("(\\w)<.*?>(\\w)", "$1 $2");
+ s=s.replaceAll("<.*?>", "");
+ s=s.replaceAll("[ \t]+", " ");
+ return s;
+ }
+
+ /**
+ * Get the attachments stored in the registry.
+ *
+ * @param action
+ * @return A list of stored attachments
+ * @throws HupaException
+ */
+ @SuppressWarnings("rawtypes")
+ protected List getAttachments(SendMessageAction action) throws MessagingException, HupaException {
+ FileItemRegistry registry = SessionUtils.getSessionRegistry(logger, httpSessionProvider.get());
+ List<MessageAttachment> attachments = action.getMessage().getMessageAttachments();
+
+ ArrayList<FileItem> items = new ArrayList<FileItem>();
+ if (attachments != null && attachments.size() > 0) {
+ for (MessageAttachment attachment: attachments) {
+ FileItem fItem = registry.get(attachment.getName());
+ if (fItem != null)
+ items.add(fItem);
+ }
+ logger.debug("Found " + items.size() + " attachmets in the registry.");
+ }
+ return items;
+ }
+
+ /**
+ * Remove attachments from the registry
+ *
+ * @param action
+ * @throws MessagingException
+ * @throws ActionException
+ */
+ protected void resetAttachments(SendMessageAction action) throws MessagingException {
+ SmtpMessage msg = action.getMessage();
+ List<MessageAttachment> attachments = msg.getMessageAttachments();
+ if (attachments != null && ! attachments.isEmpty()) {
+ for(MessageAttachment attach : attachments)
+ SessionUtils.getSessionRegistry(logger, httpSessionProvider.get()).remove(attach.getName());
+ }
+ }
+
+ /**
+ * Send the message using SMTP, if the configuration uses authenticated SMTP, it uses
+ * the user stored in session to get the given login and password.
+ *
+ * @param user
+ * @param session
+ * @param message
+ * @throws MessagingException
+ */
+ protected void sendMessage(User user, Message message) throws MessagingException {
+ cache.sendMessage(message);
+ logger.info("Send message from " + message.getFrom()[0].toString());
+ }
+
+ /**
+ * Save the message in the sent folder
+ *
+ * @param user
+ * @param message
+ * @throws MessagingException
+ * @throws IOException
+ */
+ protected void saveSentMessage(User user, Message message) throws MessagingException, IOException {
+ IMAPStore iStore = cache.get(user);
+ IMAPFolder folder = (IMAPFolder) iStore.getFolder(user.getSettings().getSentFolderName());
+
+ if (folder.exists() || folder.create(IMAPFolder.READ_WRITE)) {
+ if (folder.isOpen() == false) {
+ folder.open(Folder.READ_WRITE);
+ }
+
+ // It is necessary to copy the message, before putting it
+ // in the sent folder. If not, it is not guaranteed that it is
+ // stored in ascii and is not possible to get the attachments
+ // size. message.saveChanges() doesn't fix the problem.
+ // There are tests which demonstrate this.
+ message = new MimeMessage((MimeMessage)message);
+
+ message.setFlag(Flag.SEEN, true);
+ folder.appendMessages(new Message[] {message});
+
+ try {
+ folder.close(false);
+ } catch (MessagingException e) {
+ // we don't care on close
+ }
+ }
+ }
+
+ /**
+ * Fill the body of a message already created.
+ * The result message depends on the information given.
+ *
+ * @param message
+ * @param text
+ * @param html
+ * @param parts
+ * @return The composed message
+ * @throws MessagingException
+ * @throws IOException
+ */
+ @SuppressWarnings("rawtypes")
+ public static Message composeMessage (Message message, String text, String html, List parts) throws MessagingException, IOException {
+
+ MimeBodyPart txtPart = null;
+ MimeBodyPart htmlPart = null;
+ MimeMultipart mimeMultipart = null;
+
+ if (text == null && html == null) {
+ text = "";
+ }
+ if (text != null) {
+ txtPart = new MimeBodyPart();
+ txtPart.setContent(text, "text/plain; charset=UTF-8");
+ }
+ if (html != null) {
+ htmlPart = new MimeBodyPart();
+ htmlPart.setContent(html, "text/html; charset=UTF-8");
+ }
+ if (html != null && text != null) {
+ mimeMultipart = new MimeMultipart();
+ mimeMultipart.setSubType("alternative");
+ mimeMultipart.addBodyPart(txtPart);
+ mimeMultipart.addBodyPart(htmlPart);
+ }
+
+ if (parts == null || parts.isEmpty()) {
+ if (mimeMultipart != null) {
+ message.setContent(mimeMultipart);
+ } else if (html != null) {
+ message.setText(html);
+ message.setHeader("Content-type", "text/html");
+ } else if (text != null) {
+ message.setText(text);
+ }
+ } else {
+ MimeBodyPart bodyPart = new MimeBodyPart();
+ if (mimeMultipart != null) {
+ bodyPart.setContent(mimeMultipart);
+ } else if (html != null) {
+ bodyPart.setText(html);
+ bodyPart.setHeader("Content-type", "text/html");
+ } else if (text != null) {
+ bodyPart.setText(text);
+ }
+ Multipart multipart = new MimeMultipart();
+ multipart.addBodyPart(bodyPart);
+ for (Object attachment: parts) {
+ if (attachment instanceof FileItem) {
+ multipart.addBodyPart(MessageUtils.fileitemToBodypart((FileItem)attachment));
+ } else {
+ multipart.addBodyPart((BodyPart)attachment);
+ }
+ }
+ message.setContent(multipart);
+ }
+
+ message.saveChanges();
+ return message;
+
+ }
+
+ /**
+ * DataStore which wrap a FileItem
+ *
+ */
+ public static class FileItemDataStore implements DataSource {
+
+ private FileItem item;
+
+ public FileItemDataStore(FileItem item) {
+ this.item = item;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.activation.DataSource#getContentType()
+ */
+ public String getContentType() {
+ return item.getContentType();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.activation.DataSource#getInputStream()
+ */
+ public InputStream getInputStream() throws IOException {
+ return item.getInputStream();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.activation.DataSource#getName()
+ */
+ public String getName() {
+ String fullName = item.getName();
+
+ // Strip path from file
+ int index = fullName.lastIndexOf(File.separator);
+ if (index == -1) {
+ return fullName;
+ } else {
+ return fullName.substring(index +1 ,fullName.length());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.activation.DataSource#getOutputStream()
+ */
+ public OutputStream getOutputStream() throws IOException {
+ return null;
+ }
+
+ }
+
+
+}
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendMessageService.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendMessageService.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendMessageService.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendMessageService.java Thu Mar 20 08:16:02 2014
@@ -1,27 +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.hupa.server.service;
-
-import org.apache.hupa.shared.domain.GenericResult;
-import org.apache.hupa.shared.domain.SendMessageAction;
-
-public interface SendMessageService {
- GenericResult send(SendMessageAction action)throws Exception;
-}
+/****************************************************************
+ * 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.hupa.server.service;
+
+import org.apache.hupa.shared.domain.GenericResult;
+import org.apache.hupa.shared.domain.SendMessageAction;
+
+public interface SendMessageService {
+ GenericResult send(SendMessageAction action)throws Exception;
+}
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendReplyMessageService.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendReplyMessageService.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendReplyMessageService.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendReplyMessageService.java Thu Mar 20 08:16:02 2014
@@ -1,27 +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.hupa.server.service;
-
-import org.apache.hupa.shared.domain.GenericResult;
-import org.apache.hupa.shared.domain.SendMessageAction;
-
-public interface SendReplyMessageService {
- GenericResult send(SendMessageAction action)throws Exception;
-}
+/****************************************************************
+ * 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.hupa.server.service;
+
+import org.apache.hupa.shared.domain.GenericResult;
+import org.apache.hupa.shared.domain.SendMessageAction;
+
+public interface SendReplyMessageService {
+ GenericResult send(SendMessageAction action)throws Exception;
+}
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendReplyMessageServiceImpl.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendReplyMessageServiceImpl.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendReplyMessageServiceImpl.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SendReplyMessageServiceImpl.java Thu Mar 20 08:16:02 2014
@@ -1,77 +1,77 @@
-/****************************************************************
- * 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.hupa.server.service;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.mail.Folder;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-
-import org.apache.hupa.server.IMAPStoreCache;
-import org.apache.hupa.server.preferences.UserPreferencesStorage;
-import org.apache.hupa.server.utils.MessageUtils;
-import org.apache.hupa.shared.domain.SendMessageAction;
-import org.apache.hupa.shared.domain.SendReplyMessageAction;
-import org.apache.hupa.shared.exception.HupaException;
-
-import com.google.inject.Inject;
-import com.sun.mail.imap.IMAPFolder;
-import com.sun.mail.imap.IMAPStore;
-
-public class SendReplyMessageServiceImpl extends SendMessageBaseServiceImpl implements SendReplyMessageService{
-
- @Inject
- public SendReplyMessageServiceImpl(UserPreferencesStorage preferences, IMAPStoreCache cache) {
- super(preferences, cache);
- }
-
- @Override
- @SuppressWarnings({ "rawtypes", "unchecked" })
- protected List getAttachments(SendMessageAction action) throws MessagingException, HupaException {
- SendReplyMessageAction replyAction = (SendReplyMessageAction)action;
- List<?> items = new ArrayList();
- IMAPStore store = cache.get(getUser());
-
- IMAPFolder folder = (IMAPFolder) store.getFolder(replyAction.getFolder().getFullName());
- if (folder.isOpen() == false) {
- folder.open(Folder.READ_ONLY);
- }
-
- // Only original inline images have to be added to the list
- Message msg = folder.getMessageByUID(replyAction.getUid());
- try {
- items = MessageUtils.extractInlineImages(logger, msg.getContent());
- if (items.size() > 0)
- logger.debug("Replying a message, extracted: " + items.size() + " inline image from");
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- // Put into the list the attachments uploaded by the user
- items.addAll(super.getAttachments(replyAction));
-
- return items;
- }
-
-
-}
+/****************************************************************
+ * 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.hupa.server.service;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+import org.apache.hupa.server.IMAPStoreCache;
+import org.apache.hupa.server.preferences.UserPreferencesStorage;
+import org.apache.hupa.server.utils.MessageUtils;
+import org.apache.hupa.shared.domain.SendMessageAction;
+import org.apache.hupa.shared.domain.SendReplyMessageAction;
+import org.apache.hupa.shared.exception.HupaException;
+
+import com.google.inject.Inject;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPStore;
+
+public class SendReplyMessageServiceImpl extends SendMessageBaseServiceImpl implements SendReplyMessageService{
+
+ @Inject
+ public SendReplyMessageServiceImpl(UserPreferencesStorage preferences, IMAPStoreCache cache) {
+ super(preferences, cache);
+ }
+
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ protected List getAttachments(SendMessageAction action) throws MessagingException, HupaException {
+ SendReplyMessageAction replyAction = (SendReplyMessageAction)action;
+ List<?> items = new ArrayList();
+ IMAPStore store = cache.get(getUser());
+
+ IMAPFolder folder = (IMAPFolder) store.getFolder(replyAction.getFolder().getFullName());
+ if (folder.isOpen() == false) {
+ folder.open(Folder.READ_ONLY);
+ }
+
+ // Only original inline images have to be added to the list
+ Message msg = folder.getMessageByUID(replyAction.getUid());
+ try {
+ items = MessageUtils.extractInlineImages(logger, msg.getContent());
+ if (items.size() > 0)
+ logger.debug("Replying a message, extracted: " + items.size() + " inline image from");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ // Put into the list the attachments uploaded by the user
+ items.addAll(super.getAttachments(replyAction));
+
+ return items;
+ }
+
+
+}
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SetFlagService.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SetFlagService.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SetFlagService.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SetFlagService.java Thu Mar 20 08:16:02 2014
@@ -1,29 +1,29 @@
-/****************************************************************
- * 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.hupa.server.service;
-
-import org.apache.hupa.shared.domain.GenericResult;
-import org.apache.hupa.shared.domain.SetFlagAction;
-
-public interface SetFlagService {
-
- GenericResult set(SetFlagAction action) throws Exception;
-
-}
+/****************************************************************
+ * 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.hupa.server.service;
+
+import org.apache.hupa.shared.domain.GenericResult;
+import org.apache.hupa.shared.domain.SetFlagAction;
+
+public interface SetFlagService {
+
+ GenericResult set(SetFlagAction action) throws Exception;
+
+}
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SetFlagServiceImpl.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SetFlagServiceImpl.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SetFlagServiceImpl.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/service/SetFlagServiceImpl.java Thu Mar 20 08:16:02 2014
@@ -1,83 +1,83 @@
-/****************************************************************
- * 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.hupa.server.service;
-
-import java.util.List;
-
-import javax.mail.Flags;
-import javax.mail.Flags.Flag;
-import javax.mail.Folder;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-
-import org.apache.hupa.server.handler.JavamailUtil;
-import org.apache.hupa.shared.data.GenericResultImpl;
-import org.apache.hupa.shared.domain.GenericResult;
-import org.apache.hupa.shared.domain.ImapFolder;
-import org.apache.hupa.shared.domain.SetFlagAction;
-import org.apache.hupa.shared.domain.User;
-
-import com.sun.mail.imap.IMAPStore;
-
-public class SetFlagServiceImpl extends AbstractService implements SetFlagService {
-
- @Override
- public GenericResult set(SetFlagAction action) throws Exception {
- User user = getUser();
- ImapFolder folder = action.getFolder();
- List<Long> uids = action.getUids();
- com.sun.mail.imap.IMAPFolder f = null;
- try {
- IMAPStore store = cache.get(user);
-
- f = (com.sun.mail.imap.IMAPFolder) store.getFolder(folder.getFullName());
- if (f.isOpen() == false) {
- f.open(Folder.READ_WRITE);
- }
- Message[] msgs = f.getMessagesByUID(toArray(uids));
- Flag flag = JavamailUtil.convert(action.getFlag());
- Flags flags = new Flags();
- flags.add(flag);
-
- f.setFlags(msgs, flags, action.getValue());
- return new GenericResultImpl();
- } catch (MessagingException e) {
- String errorMsg = "Error while setting flags of messages with uids " + uids + " for user " + user;
- logger.error(errorMsg, e);
- throw new Exception(errorMsg, e);
- } finally {
- if (f != null && f.isOpen()) {
- try {
- f.close(false);
- } catch (MessagingException e) {
- // ignore on close
- }
- }
- }
- }
-
- private long[] toArray(List<Long> uids) {
- long[] array = new long[uids.size()];
- for (int i = 0; i < uids.size(); i++) {
- array[i] = uids.get(i);
- }
- return array;
- }
-}
+/****************************************************************
+ * 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.hupa.server.service;
+
+import java.util.List;
+
+import javax.mail.Flags;
+import javax.mail.Flags.Flag;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+import org.apache.hupa.server.handler.JavamailUtil;
+import org.apache.hupa.shared.data.GenericResultImpl;
+import org.apache.hupa.shared.domain.GenericResult;
+import org.apache.hupa.shared.domain.ImapFolder;
+import org.apache.hupa.shared.domain.SetFlagAction;
+import org.apache.hupa.shared.domain.User;
+
+import com.sun.mail.imap.IMAPStore;
+
+public class SetFlagServiceImpl extends AbstractService implements SetFlagService {
+
+ @Override
+ public GenericResult set(SetFlagAction action) throws Exception {
+ User user = getUser();
+ ImapFolder folder = action.getFolder();
+ List<Long> uids = action.getUids();
+ com.sun.mail.imap.IMAPFolder f = null;
+ try {
+ IMAPStore store = cache.get(user);
+
+ f = (com.sun.mail.imap.IMAPFolder) store.getFolder(folder.getFullName());
+ if (f.isOpen() == false) {
+ f.open(Folder.READ_WRITE);
+ }
+ Message[] msgs = f.getMessagesByUID(toArray(uids));
+ Flag flag = JavamailUtil.convert(action.getFlag());
+ Flags flags = new Flags();
+ flags.add(flag);
+
+ f.setFlags(msgs, flags, action.getValue());
+ return new GenericResultImpl();
+ } catch (MessagingException e) {
+ String errorMsg = "Error while setting flags of messages with uids " + uids + " for user " + user;
+ logger.error(errorMsg, e);
+ throw new Exception(errorMsg, e);
+ } finally {
+ if (f != null && f.isOpen()) {
+ try {
+ f.close(false);
+ } catch (MessagingException e) {
+ // ignore on close
+ }
+ }
+ }
+ }
+
+ private long[] toArray(List<Long> uids) {
+ long[] array = new long[uids.size()];
+ for (int i = 0; i < uids.size(); i++) {
+ array[i] = uids.get(i);
+ }
+ return array;
+ }
+}
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/servlet/DownloadAttachmentServlet.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/servlet/DownloadAttachmentServlet.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/servlet/DownloadAttachmentServlet.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/servlet/DownloadAttachmentServlet.java Thu Mar 20 08:16:02 2014
@@ -49,7 +49,7 @@ import com.sun.mail.imap.IMAPFolder;
public class DownloadAttachmentServlet extends HttpServlet {
private static final long serialVersionUID = 1245563204035792963L;
-
+
private IMAPStoreCache cache;
private Log logger;
@@ -104,7 +104,7 @@ public class DownloadAttachmentServlet e
} else {
response.setContentType("application/download");
}
-
+
handleAttachmentData(request, m, attachmentName, part.getInputStream(), out);
return;
} catch (Exception e) {
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/servlet/UploadAttachmentServlet.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/servlet/UploadAttachmentServlet.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/servlet/UploadAttachmentServlet.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/servlet/UploadAttachmentServlet.java Thu Mar 20 08:16:02 2014
@@ -35,36 +35,36 @@ import com.google.inject.Inject;
/**
* Servlet which handle uploads. The uploaded files will get added to a temporary registry to get looked-up
* later.
- *
+ *
*
*/
public class UploadAttachmentServlet extends UploadAction{
private static final long serialVersionUID = 4936687307133529124L;
-
-
+
+
private Log logger;
-
+
@Inject
public UploadAttachmentServlet(Log logger) {
this.logger = logger;
}
-
+
@Override
public String executeAction(HttpServletRequest request, List<FileItem> sessionFiles) throws UploadActionException {
logger.info("Executing Action, files in session: " + sessionFiles.size() + " previous files in registry: " + SessionUtils.getSessionRegistry(logger, request.getSession()).size());
// save file items in the user session's registry
- for(FileItem item: sessionFiles)
+ for(FileItem item: sessionFiles)
SessionUtils.getSessionRegistry(logger, request.getSession()).add(item);
-
+
// remove items from session but not remove the data from disk or memory
removeSessionFileItems(request, false);
return null;
}
-
+
@Override
public void removeItem(HttpServletRequest request, FileItem item) throws UploadActionException {
SessionUtils.getSessionRegistry(logger, request.getSession()).remove(item);
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/ConfigurationProperties.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/ConfigurationProperties.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/ConfigurationProperties.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/ConfigurationProperties.java Thu Mar 20 08:16:02 2014
@@ -55,20 +55,20 @@ public enum ConfigurationProperties {
// Used only in demo mode
USERNAME("Username", false, null),
PASSWORD("Password", false, null);
-
+
private String property;
private boolean mandatory;
private String propValue;
-
+
private ConfigurationProperties (String property, boolean mandatory, String propValue) {
this.property = property;
this.mandatory = mandatory;
this.propValue = propValue;
}
-
+
/**
* Return a ConfigurationProperties enumeration that matches the passed command.
- *
+ *
* @param property
* The property to use for lookup.
* @return the ConfigurationProperties enumeration that matches the passed property, or null
@@ -82,10 +82,10 @@ public enum ConfigurationProperties {
}
return null;
}
-
+
/**
* Return the name of property.
- *
+ *
* @return the name of property.
*/
public String getProperty() {
@@ -94,7 +94,7 @@ public enum ConfigurationProperties {
/**
* Return if property is mandatory
- *
+ *
* @return true if mandatory else false.
*/
public boolean isMandatory() {
@@ -103,7 +103,7 @@ public enum ConfigurationProperties {
/**
* Return the value of the property.
- *
+ *
* @return the value of the property.
*/
public String getPropValue() {
@@ -115,7 +115,7 @@ public enum ConfigurationProperties {
* missing, and avoid unknown properties.
*/
public static void validateProperties(Properties properties) {
-
+
List<String> errors = new ArrayList<String>();
// Test for mandatory and complete properties with default values when
@@ -145,10 +145,10 @@ public enum ConfigurationProperties {
throw new IllegalArgumentException("Error validating configuration : \n" + properties + "\n" + errors.toString());
}
}
-
+
/**
* Loads and validate a properties file.
- *
+ *
* @param configDir
* @param name
* @return
@@ -159,7 +159,7 @@ public enum ConfigurationProperties {
Properties properties = null;
File file = new File(name);
-
+
if (file.exists()) {
FileInputStream fis = null;
try {
@@ -167,7 +167,7 @@ public enum ConfigurationProperties {
fis = new FileInputStream(file);
properties.load(fis);
} catch (Exception e) {
- properties = null;
+ properties = null;
e.printStackTrace();
} finally {
if (fis != null) {
@@ -179,7 +179,7 @@ public enum ConfigurationProperties {
}
}
}
-
+
return properties;
}
}
\ No newline at end of file
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/MessageUtils.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/MessageUtils.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/MessageUtils.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/MessageUtils.java Thu Mar 20 08:16:02 2014
@@ -57,8 +57,8 @@ import org.apache.hupa.shared.domain.Mes
public class MessageUtils {
/**
- * Get a Address array for a set of address passed as arguments
- *
+ * Get a Address array for a set of address passed as arguments
+ *
* @param addresses
* @return Address array
* @throws AddressException
@@ -68,8 +68,8 @@ public class MessageUtils {
}
/**
- * Get a Address array for the given ArrayList
- *
+ * Get a Address array for the given ArrayList
+ *
* @param recipients
* @return addressArray
* @throws AddressException
@@ -87,7 +87,7 @@ public class MessageUtils {
/**
* Extract the attachments present in a mime message
- *
+ *
* @param logger
* @param content
* @return A list of body parts of the attachments
@@ -124,11 +124,11 @@ public class MessageUtils {
}
return ret;
}
-
+
/**
* Handle the parts of the given message. The method will call itself
* recursively to handle all nested parts
- *
+ *
* @param message the MimeMessage
* @param content the current processing Content
* @param sbPlain the StringBuffer to fill with text
@@ -201,7 +201,7 @@ public class MessageUtils {
}
return isHTML;
}
-
+
private static boolean handleMultiPartAlternative(Multipart mp, StringBuffer sbPlain) throws MessagingException, IOException {
String text = null;
boolean isHTML = false;
@@ -268,14 +268,14 @@ public class MessageUtils {
}
return null;
}
-
+
private static String cleanName(String s) {
return s.replaceAll("[^\\w .+-]", "");
}
/**
* Convert a FileItem to a BodyPart
- *
+ *
* @param item
* @return message body part
* @throws MessagingException
@@ -290,7 +290,7 @@ public class MessageUtils {
/**
* DataStore which wrap a FileItem
- *
+ *
*/
public static class FileItemDataStore implements DataSource {
@@ -322,7 +322,7 @@ public class MessageUtils {
*/
public String getName() {
String fullName = item.getName();
-
+
// Strip path from file
int index = fullName.lastIndexOf(File.separator);
if (index == -1) {
@@ -340,11 +340,11 @@ public class MessageUtils {
return null;
}
- }
+ }
/**
* Decode iso-xxxx strings present in subjects and emails like:
- *
- * =?ISO-8859-1?Q?No=20hay=20ma=F1ana?= <he...@hupa.org>
+ *
+ * =?ISO-8859-1?Q?No=20hay=20ma=F1ana?= <he...@hupa.org>
*/
public static String decodeText(String s) {
String ret = s;
@@ -358,11 +358,11 @@ public class MessageUtils {
.replaceFirst("^[<\"' ]+([^\"<>]*)[>\"' ]+<", "$1 <");
return ret;
}
-
+
/**
* Encode non ascii characters present in emails like:
- *
- * =?ISO-8859-1?Q?No=20hay=20ma=F1ana?= <he...@hupa.org>
+ *
+ * =?ISO-8859-1?Q?No=20hay=20ma=F1ana?= <he...@hupa.org>
*/
public static String encodeEmail(String s) {
if (s == null) {
@@ -372,7 +372,7 @@ public class MessageUtils {
Matcher m = p.matcher(s);
return m.matches() ? encodeTexts(m.group(1)) + " " + m.group(2) : s;
}
-
+
/**
* Encode non ascii characters present in email headers
*/
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/RegexPatterns.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/RegexPatterns.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/RegexPatterns.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/RegexPatterns.java Thu Mar 20 08:16:02 2014
@@ -24,14 +24,14 @@ import java.util.regex.Pattern;
import org.apache.hupa.shared.SConsts;
/**
- * A place where we centralize all compiled regular expressions which will be used in
+ * A place where we centralize all compiled regular expressions which will be used in
* server side for html and text transformations.
*/
public class RegexPatterns {
-
+
public static final Pattern regex_lt = Pattern.compile("<");
public static final String repl_lt = "<";
-
+
public static final Pattern regex_gt = Pattern.compile(">");
public static final String repl_gt = ">";
@@ -41,57 +41,57 @@ public class RegexPatterns {
public static final String HTML_LINK_REGEXP = "\\b?(https?://[\\w\\d:#@%/;$\\(\\)~_\\?\\+\\-=\\\\.&]*)\\b?";
public static final Pattern regex_htmllink = Pattern.compile(HTML_LINK_REGEXP);
public static final String repl_htmllink = "<a href=\"$1\">$1</a>";
-
+
public static final String EMAIL_REGEXP = "\\b(?<![A-z0-9._%\\+\\-=])([A-z][A-z0-9._%\\+\\-]+@[A-z0-9\\.\\-]+\\.[A-z]{2,4})";
public static final Pattern regex_email = Pattern.compile("\\b"+ EMAIL_REGEXP);
public static final String repl_email = "<a href=\"mailto:$1\">$1</a>";
-
+
public static final Pattern regex_inlineImg = Pattern.compile("(?si)(<\\s*img\\s+.*?src=)[\"']?cid:([^\"']+)[\"']?");
- public static final String repl_inlineImg = "$1'" + SConsts.HUPA + SConsts.SERVLET_DOWNLOAD
- + "?" + SConsts.PARAM_MODE + "=inline"
- + "&" + SConsts.PARAM_FOLDER + "=%%FOLDER%%"
- + "&" + SConsts.PARAM_UID + "=%%UID%%"
+ public static final String repl_inlineImg = "$1'" + SConsts.HUPA + SConsts.SERVLET_DOWNLOAD
+ + "?" + SConsts.PARAM_MODE + "=inline"
+ + "&" + SConsts.PARAM_FOLDER + "=%%FOLDER%%"
+ + "&" + SConsts.PARAM_UID + "=%%UID%%"
+ "&" + SConsts.PARAM_NAME + "=$2' name='cid:$2'";
-
+
public static final Pattern regex_revertInlineImg = Pattern.compile("(?si)(<img\\s[^>]*src=)[^>]+name=([\"']cid:[^\"']+[\"'])");
public static final String repl_revertInlineImg = "$1$2";
-
+
public static final Pattern regex_badTags = Pattern.compile("(?si)<(script|style|head).*?</\\1\\s*>");
public static final String repl_badTags = "";
-
+
public static final Pattern regex_unneededTags = Pattern.compile("(?si)(</?(html|body)[^>]*?>)");
public static final String repl_unneededTags = "";
-
+
public static final String EVENT_ATTR_REGEX = "(?:on[dbl]*click)|(?:onmouse[a-z]+)|(?:onkey[a-z]+)";
public static final Pattern regex_badAttrs = Pattern.compile("(?si)(<\\w+[^<>]*)\\s+("+ EVENT_ATTR_REGEX + ")=[\"']?([^\\s<>]+?)[\"']?([\\s>])");
public static final String repl_badAttrs = "$1$4";
-
+
public static final Pattern regex_orphandHttpLinks = Pattern.compile("(?si)(?!.*<a\\s?[^>]*?>.+</a\\s*>.*)(<[^<]*?>[^<>]*)" + HTML_LINK_REGEXP + "([^<>]*<[^>]*?>)");
public static final String repl_orphandHttpLinks = "$1<a href=\"$2\">$2</a>$3";
-
+
public static final Pattern regex_existingHttpLinks = Pattern.compile("(?si)<a\\s[^>]*?href=[\"']?" + HTML_LINK_REGEXP + "[\"']?");
public static final String repl_existingHttpLinks = "<a onClick=\"openLink('$1');return false;\" href=\"$1\"";
-
+
public static final Pattern regex_orphandEmailLinks = Pattern.compile("(?si)(?!.*<a\\s?[^>]*?>.+</a\\s*>.*)(<[^<]*?>[^<>]*)" + EMAIL_REGEXP + "([^<>]*<[^>]*?>)");
public static final String repl_orphandEmailLinks = "$1<a href=\"mailto:$2\">$2</a>$3";
-
+
public static final Pattern regex_existingEmailLinks = Pattern.compile("(?si)<a\\s[^>]*?href=[\"']*mailto:[\"']?([^\"]+)[\"']?");
public static final String repl_existngEmailLinks = "<a onClick=\"mailTo('$1');return false;\" href=\"mailto:$1\"";
-
+
public static String replaceAll(String txt, Pattern pattern, String replacement) {
return pattern.matcher(txt).replaceAll(replacement);
}
-
+
public static String replaceAllRecursive(String txt, Pattern pattern, String replacement) {
while (pattern.matcher(txt).find())
txt = pattern.matcher(txt).replaceAll(replacement);
return txt;
}
-
+
public static final Pattern regex_nl_tags = Pattern.compile("(?si)(<br\\s*?/?>)|(</div\\s*?>)");
public static final Pattern regex_any_tag = Pattern.compile("(\\w)<.*?>(\\w)");
public static final String repl_any_tag = "$1 $2";
-
+
// s=s.replaceAll("\n", " ");
// s=s.replaceAll("(?si)<br\\s*?/?>", "\n");
// s=s.replaceAll("(?si)</div\\s*?>", "\n");
@@ -99,5 +99,5 @@ public class RegexPatterns {
// s=s.replaceAll("<.*?>", "");
// s=s.replaceAll("[ \t]+", " ");
-
+
}
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/SessionUtils.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/SessionUtils.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/SessionUtils.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/SessionUtils.java Thu Mar 20 08:16:02 2014
@@ -42,7 +42,7 @@ public class SessionUtils {
}
return registry;
}
-
+
/**
* Remove session attributes, it has to be done in the login and logout actions
* @param session
@@ -63,5 +63,5 @@ public class SessionUtils {
}
}
}
-
+
}
\ No newline at end of file
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/SettingsDiscoverer.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/SettingsDiscoverer.java?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/SettingsDiscoverer.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/utils/SettingsDiscoverer.java Thu Mar 20 08:16:02 2014
@@ -26,33 +26,33 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
public class SettingsDiscoverer {
-
+
private static HashMap<String, Settings> validConfigs = new HashMap<String, Settings>();
-
+
@Inject private Provider<Settings> settingsProvider;
public Settings discoverSettings(String email) {
-
+
if (!email.matches("^(.*<)?[A-Za-z0-9._%'*/=+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}(>)?\\s*$")) {
return new SettingsImpl();
}
-
+
String domain = email.replaceFirst("^.*@", "");
-
+
Settings s = validConfigs.get(domain);
if (s != null) {
return s;
}
-
+
String [] mxHosts = null;
try {
mxHosts = lookupMailHosts(domain);
} catch (Exception e) {
mxHosts = new String[0];
}
-
+
s = settingsProvider != null ? settingsProvider.get() : new SettingsImpl();
-
+
if (email.matches(".*@gmail.com") || isValidMx(".*google.*.com", mxHosts)) {
s.setImapServer("imap.gmail.com");
s.setImapPort(993);
@@ -92,11 +92,11 @@ public class SettingsDiscoverer {
} else {
String[] hostNames = new String[]{"imap." + domain, "smtp." + domain, "www." + domain, "mail." + domain, domain};
String[] hosts = (String[])ArrayUtils.addAll(hostNames, mxHosts);
-
+
Integer[] imapPorts = new Integer[]{993, 585, 143};
Integer[] smtpPorts = new Integer[]{465, 587, 25};
Integer[] ports = (Integer[])ArrayUtils.addAll(imapPorts, smtpPorts);
-
+
final List<String> validPorts = new ArrayList<String>();
ExecutorService es = Executors.newCachedThreadPool();
for (final String h : hosts) {
@@ -107,19 +107,19 @@ public class SettingsDiscoverer {
if (isValidPort(h, p)) {
validPorts.add(h + ":" + p);
}
- }
+ }
});
}
}
}
-
+
try {
es.awaitTermination(1500, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("ValidPorts: " + domain + " -> "+ validPorts);
-
+
boolean imapdone = false;
loop: for (final String h : hosts) {
for (final Integer p : imapPorts) {
@@ -155,17 +155,17 @@ public class SettingsDiscoverer {
s.setSmtpPort(0);
s.setSmtpSecure(false);
}
-
+
s.setSmtpAuth(true);
s.setInboxFolderName("INBOX");
s.setSentFolderName("Sent");
s.setTrashFolderName("Trash");
- s.setDraftsFolderName("Drafts");
+ s.setDraftsFolderName("Drafts");
System.out.println("Returning config: \n" + s);
}
return s;
}
-
+
static boolean isValidMx(String regexp, String[] mailhosts) {
if (mailhosts != null) for (String h : mailhosts) {
if (h.toLowerCase().matches(regexp)) {
@@ -174,7 +174,7 @@ public class SettingsDiscoverer {
}
return false;
}
-
+
static boolean isValidHostName(String name) {
try {
InetAddress.getByName(name);
@@ -183,7 +183,7 @@ public class SettingsDiscoverer {
return false;
}
}
-
+
static boolean isValidPort(String hostname, int port) {
try {
Socket socket = new Socket();
@@ -195,7 +195,7 @@ public class SettingsDiscoverer {
return false;
}
}
-
+
static String[] lookupMailHosts(String domainName) throws NamingException {
InitialDirContext iDirC = new InitialDirContext();
Attributes attributes = iDirC.getAttributes("dns:/" + domainName,
@@ -231,5 +231,5 @@ public class SettingsDiscoverer {
String domain = user.getName().replaceFirst("^.*@", "");
validConfigs.put(domain, user.getSettings());
}
-
+
}
Modified: james/hupa/trunk/server/src/site/site.xml
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/site/site.xml?rev=1579559&r1=1579558&r2=1579559&view=diff
==============================================================================
--- james/hupa/trunk/server/src/site/site.xml (original)
+++ james/hupa/trunk/server/src/site/site.xml Thu Mar 20 08:16:02 2014
@@ -1,27 +1,27 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- 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.
--->
-<project name="Hupa">
- <body>
- <!-- This is a "dummy" site because of this bug: -->
- <!-- http://jira.codehaus.org/browse/MSITE-345 -->
- <menu ref="parent" />
- <menu ref="reports" />
- </body>
-</project>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<project name="Hupa">
+ <body>
+ <!-- This is a "dummy" site because of this bug: -->
+ <!-- http://jira.codehaus.org/browse/MSITE-345 -->
+ <menu ref="parent" />
+ <menu ref="reports" />
+ </body>
+</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org