Author: norman
Date: Tue Jul 14 18:05:29 2009
New Revision: 793996
URL: http://svn.apache.org/viewvc?rev=793996&view=rev
Log:
on the way to implement deletion of messages
Added:
labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java
labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessage.java
labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessageResult.java
Modified:
labs/hupa/src/main/java/org/apache/hupa/shared/data/IMAPFolder.java
Added: labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java?rev=793996&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java
(added)
+++ labs/hupa/src/main/java/org/apache/hupa/server/DeleteMessageHandler.java
Tue Jul 14 18:05:29 2009
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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;
+
+import net.customware.gwt.dispatch.server.ExecutionContext;
+import net.customware.gwt.dispatch.shared.ActionException;
+
+import org.apache.hupa.shared.data.IMAPFolder;
+import org.apache.hupa.shared.rpc.DeleteMessage;
+import org.apache.hupa.shared.rpc.DeleteMessageResult;
+import org.columba.ristretto.imap.IMAPFlags;
+import org.columba.ristretto.imap.IMAPProtocol;
+import org.columba.ristretto.imap.SequenceSet;
+
+public class DeleteMessageHandler extends
AbstractIMAPActionHandler<DeleteMessage, DeleteMessageResult>{
+
+ public DeleteMessageResult execute(DeleteMessage action,
ExecutionContext context)
+ throws ActionException {
+ try {
+ IMAPProtocol protocol = getProtocol(action.getUser());
+ IMAPFolder folder = action.getFolder();
+ protocol.select(folder.getFullName());
+
+ if
(folder.getFullName().equalsIgnoreCase(IMAPFolder.DEFAULT_TRASH) == false) {
+ protocol.copy(new
SequenceSet(action.getMessageUids()), IMAPFolder.DEFAULT_TRASH);
+ }
+ protocol.store(new
SequenceSet(action.getMessageUids()), true, new IMAPFlags(IMAPFlags.DELETED));
+ protocol.expunge();
+ } catch (Exception e) {
+ throw new ActionException("Error while deleting
messages",e);
+ }
+ return new DeleteMessageResult();
+ }
+
+ public Class<DeleteMessage> getActionType() {
+ return DeleteMessage.class;
+ }
+
+ public void rollback(DeleteMessage arg0, DeleteMessageResult arg1,
+ ExecutionContext arg2) throws ActionException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified: labs/hupa/src/main/java/org/apache/hupa/shared/data/IMAPFolder.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/shared/data/IMAPFolder.java?rev=793996&r1=793995&r2=793996&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/shared/data/IMAPFolder.java
(original)
+++ labs/hupa/src/main/java/org/apache/hupa/shared/data/IMAPFolder.java Tue Jul
14 18:05:29 2009
@@ -30,6 +30,8 @@
*/
private static final long serialVersionUID = 2084188092060266479L;
public static final String DEFAULT_INBOX = "INBOX";
+ public static final String DEFAULT_TRASH = "Trash";
+
private List<IMAPFolder> childs = new ArrayList<IMAPFolder>();
private String fullName;
private String delimiter;
Added: labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessage.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessage.java?rev=793996&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessage.java
(added)
+++ labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessage.java Tue
Jul 14 18:05:29 2009
@@ -0,0 +1,61 @@
+package org.apache.hupa.shared.rpc;
+
+import java.util.ArrayList;
+
+import net.customware.gwt.dispatch.shared.Action;
+
+import org.apache.hupa.shared.data.IMAPFolder;
+import org.apache.hupa.shared.data.IMAPUser;
+
+/****************************************************************
+ * 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. *
+ ****************************************************************/
+
+public class DeleteMessage implements Action<DeleteMessageResult>{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 801294103124082592L;
+ private IMAPUser user;
+ private IMAPFolder folder;
+ private ArrayList<Integer> messageUids;
+
+ @SuppressWarnings("unused")
+ private DeleteMessage() {
+
+ }
+ public DeleteMessage(IMAPUser user,IMAPFolder folder,
ArrayList<Integer> messageUids) {
+ this.user = user;
+ this.folder = folder;
+ this.messageUids = messageUids;
+ }
+
+ public IMAPUser getUser() {
+ return user;
+ }
+
+ public IMAPFolder getFolder() {
+ return folder;
+ }
+
+ public ArrayList<Integer> getMessageUids() {
+ return messageUids;
+ }
+
+}
Added:
labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessageResult.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessageResult.java?rev=793996&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessageResult.java
(added)
+++ labs/hupa/src/main/java/org/apache/hupa/shared/rpc/DeleteMessageResult.java
Tue Jul 14 18:05:29 2009
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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.shared.rpc;
+
+import net.customware.gwt.dispatch.shared.Result;
+
+public class DeleteMessageResult implements Result{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5149203502019947912L;
+
+
+ public DeleteMessageResult() {
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]