Author: btellier
Date: Tue Sep 22 10:38:44 2015
New Revision: 1704563

URL: http://svn.apache.org/viewvc?rev=1704563&view=rev
Log:
PROTOCOLS-108 Adding IMAP Quota messages

Added:
    
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRequest.java
    
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRootRequest.java
    
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/SetQuotaRequest.java
    
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaResponse.java
    
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaRootResponse.java

Added: 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRequest.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRequest.java?rev=1704563&view=auto
==============================================================================
--- 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRequest.java
 (added)
+++ 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRequest.java
 Tue Sep 22 10:38:44 2015
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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.james.imap.message.request;
+
+import org.apache.james.imap.api.ImapCommand;
+
+/**
+ * GETQUOTA Request
+ *
+ * @author Tellier Benoit
+ */
+public class GetQuotaRequest extends AbstractImapRequest {
+    private final String quotaRoot;
+
+    public GetQuotaRequest(String tag, ImapCommand command, String quotaRoot) {
+        super(tag, command);
+        this.quotaRoot = quotaRoot;
+    }
+
+    public String getQuotaRoot() {
+        return quotaRoot;
+    }
+
+}
\ No newline at end of file

Added: 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRootRequest.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRootRequest.java?rev=1704563&view=auto
==============================================================================
--- 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRootRequest.java
 (added)
+++ 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/GetQuotaRootRequest.java
 Tue Sep 22 10:38:44 2015
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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.james.imap.message.request;
+
+import org.apache.james.imap.api.ImapCommand;
+
+/**
+ * GETQUOTAROOT Request
+ *
+ * @author Tellier Benoit
+ */
+public class GetQuotaRootRequest extends AbstractImapRequest {
+    private final String mailboxName;
+
+    public GetQuotaRootRequest(String tag, ImapCommand command, String 
mailboxName) {
+        super(tag, command);
+        this.mailboxName = mailboxName;
+    }
+
+    public String getMailboxName() {
+        return mailboxName;
+    }
+
+}

Added: 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/SetQuotaRequest.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/SetQuotaRequest.java?rev=1704563&view=auto
==============================================================================
--- 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/SetQuotaRequest.java
 (added)
+++ 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/request/SetQuotaRequest.java
 Tue Sep 22 10:38:44 2015
@@ -0,0 +1,70 @@
+/****************************************************************
+ * 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.james.imap.message.request;
+
+import org.apache.james.imap.api.ImapCommand;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * SETQUOTA request
+ */
+public class SetQuotaRequest extends AbstractImapRequest {
+
+    public class ResourceLimit {
+        private String resource;
+        private Long limit;
+
+        public ResourceLimit(String resource, long limit) {
+            this.limit = limit;
+            this.resource = resource;
+        }
+
+        public String getResource() {
+            return resource;
+        }
+
+        public long getLimit() {
+            return limit;
+        }
+    }
+
+    private final String quotaRoot;
+    private final List<ResourceLimit> resourceLimits;
+
+    public SetQuotaRequest(String tag, ImapCommand command, String quotaRoot) {
+        super(tag, command);
+        this.quotaRoot = quotaRoot;
+        this.resourceLimits = new ArrayList<ResourceLimit>();
+    }
+
+    public void addResourceLimit(String resource, long limit) {
+        resourceLimits.add(new ResourceLimit(resource, limit));
+    }
+
+    public List<ResourceLimit> getResourceLimits() {
+        return new ArrayList<ResourceLimit>(resourceLimits);
+    }
+
+    public String getQuotaRoot() {
+        return quotaRoot;
+    }
+}

Added: 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaResponse.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaResponse.java?rev=1704563&view=auto
==============================================================================
--- 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaResponse.java
 (added)
+++ 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaResponse.java
 Tue Sep 22 10:38:44 2015
@@ -0,0 +1,86 @@
+/****************************************************************
+ * 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.james.imap.message.response;
+
+import com.google.common.base.Objects;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.message.response.ImapResponseMessage;
+import org.apache.james.mailbox.model.Quota;
+
+/**
+ * Quota Response
+ */
+public class QuotaResponse implements ImapResponseMessage {
+    private String resourceName;
+    private String quotaRoot;
+    private Quota quota;
+
+    public QuotaResponse(String resource, String quotaRoot, Quota quota) {
+        this.quota = quota;
+        this.resourceName = resource;
+        this.quotaRoot = quotaRoot;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o instanceof QuotaResponse) {
+            QuotaResponse other = (QuotaResponse) o;
+            return Objects.equal(this.quotaRoot, other.quotaRoot)
+                && Objects.equal(this.resourceName, other.resourceName)
+                && Objects.equal(this.quota, other.quota);
+        }
+        return false;
+    }
+
+    public Quota getQuota() {
+        return quota;
+    }
+
+    public String getResourceName() {
+        return resourceName;
+    }
+
+    public String getQuotaRoot() {
+        return quotaRoot;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(resourceName, quotaRoot, quota);
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder result = new StringBuilder()
+                .append(ImapConstants.QUOTA_RESPONSE_NAME)
+                .append(' ')
+                .append(quotaRoot)
+                .append(' ')
+                .append('(')
+                .append(resourceName)
+                .append(' ')
+                .append(quota.getUsed())
+                .append(' ')
+                .append(quota.getMax())
+                .append(')');
+        return result.toString();
+    }
+
+}

Added: 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaRootResponse.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaRootResponse.java?rev=1704563&view=auto
==============================================================================
--- 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaRootResponse.java
 (added)
+++ 
james/protocols/trunk/imap/src/main/java/org/apache/james/imap/message/response/QuotaRootResponse.java
 Tue Sep 22 10:38:44 2015
@@ -0,0 +1,74 @@
+/****************************************************************
+ * 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.james.imap.message.response;
+
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.message.response.ImapResponseMessage;
+/**
+ * Quota Root Response
+ */
+public class QuotaRootResponse implements ImapResponseMessage {
+    private final String quotaRoot;
+
+    private final String mailboxName;
+
+    public QuotaRootResponse(String mailboxName, String quotaRoot) {
+        super();
+        this.mailboxName = mailboxName;
+        this.quotaRoot= quotaRoot;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o instanceof QuotaRootResponse) {
+            QuotaRootResponse other = (QuotaRootResponse) o;
+            return (this.quotaRoot == other.quotaRoot || (this.quotaRoot != 
null && this.quotaRoot.equals(other.quotaRoot)))
+                    && (this.mailboxName == other.mailboxName || 
(this.mailboxName != null && this.mailboxName.equals(other.mailboxName)))
+                    ;
+        }
+        return false;
+    }
+
+    public String getQuotaRoot() {
+        return quotaRoot;
+    }
+
+    public String getMailboxName() {
+        return mailboxName;
+    }
+
+    @Override
+    public int hashCode() {
+        final int PRIME = 31;
+        return PRIME * quotaRoot.hashCode() + mailboxName.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder result = new StringBuilder()
+                .append(ImapConstants.QUOTAROOT_RESPONSE_NAME)
+                .append(' ')
+                .append(mailboxName)
+                .append(' ')
+                .append(quotaRoot);
+        return result.toString();
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to