Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1D35A633E for ; Mon, 13 Jun 2011 15:11:02 +0000 (UTC) Received: (qmail 24813 invoked by uid 500); 13 Jun 2011 15:11:02 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 24785 invoked by uid 500); 13 Jun 2011 15:11:02 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 24777 invoked by uid 99); 13 Jun 2011 15:11:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jun 2011 15:11:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Jun 2011 15:10:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E45D323888DD; Mon, 13 Jun 2011 15:10:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1135130 - in /activemq/activemq-apollo/trunk: apollo-dto/src/main/java/org/apache/activemq/apollo/dto/ apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/ apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ Date: Mon, 13 Jun 2011 15:10:36 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110613151036.E45D323888DD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: chirino Date: Mon Jun 13 15:10:36 2011 New Revision: 1135130 URL: http://svn.apache.org/viewvc?rev=1135130&view=rev Log: Wrap the tabular results in a DataPageDTO so that the client can also get information about how many total pages there are available to be paged. Added: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DataPageDTO.java Modified: activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala Added: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DataPageDTO.java URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DataPageDTO.java?rev=1135130&view=auto ============================================================================== --- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DataPageDTO.java (added) +++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DataPageDTO.java Mon Jun 13 15:10:36 2011 @@ -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.activemq.apollo.dto; + +import javax.xml.bind.annotation.*; +import java.util.ArrayList; +import java.util.List; + +/** + *

+ *

+ * + * @author Hiram Chirino + */ +@XmlRootElement(name="data_table") +@XmlAccessorType(XmlAccessType.FIELD) +public class DataPageDTO { + + /** + */ + @XmlAttribute(name="page") + public int page; + + /** + */ + @XmlAttribute(name="row_max") + public int row_max; + + /** + */ + @XmlAttribute(name="total_pages") + public int total_pages; + + /** + */ + @XmlAttribute(name="total_rows") + public long total_rows; + + @XmlElement(name="header") + public List headers = new ArrayList(); + + @XmlElement(name="row") + public List rows = new ArrayList(); + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof DataPageDTO)) return false; + + DataPageDTO that = (DataPageDTO) o; + + if (page != that.page) return false; + if (row_max != that.row_max) return false; + if (total_pages != that.total_pages) return false; + if (total_rows != that.total_rows) return false; + if (headers != null ? !headers.equals(that.headers) : that.headers != null) return false; + if (rows != null ? !rows.equals(that.rows) : that.rows != null) return false; + + return true; + } + + @Override + public int hashCode() { + int result = page; + result = 31 * result + row_max; + result = 31 * result + total_pages; + result = 31 * result + (int) (total_rows ^ (total_rows >>> 32)); + result = 31 * result + (headers != null ? headers.hashCode() : 0); + result = 31 * result + (rows != null ? rows.hashCode() : 0); + return result; + } +} Modified: activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index?rev=1135130&r1=1135129&r2=1135130&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index (original) +++ activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index Mon Jun 13 15:10:36 2011 @@ -44,4 +44,5 @@ TopicDTO LinkDTO QueueConsumerStatusDTO ValueDTO -StringListDTO \ No newline at end of file +StringListDTO +DataPageDTO \ No newline at end of file Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala?rev=1135130&r1=1135129&r2=1135130&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala (original) +++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala Mon Jun 13 15:10:36 2011 @@ -308,7 +308,18 @@ case class BrokerResource() extends Reso val list = query.execute(records).getResults - Success(seqAsJavaList( headers :: list.toList) ) + val rc = new DataPageDTO + rc.page = page + rc.row_max = page_size + + def total_pages(x:Int,y:Int) = if(x==0) 1 else { x/y + (if ( x%y == 0 ) 0 else 1) } + rc.total_pages = total_pages(records.length, rc.row_max) + + rc.total_rows = records.length + rc.headers = headers + rc.rows = list + + Success(rc) } catch { case e:Throwable => Failure(e) } @@ -317,7 +328,7 @@ case class BrokerResource() extends Reso @GET @Path("virtual-hosts/{id}/topics") @Produces(Array("application/json")) def topics(@PathParam("id") id : String, @QueryParam("f") f:java.util.List[String], - @QueryParam("q") q:String, @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):java.util.List[_] = { + @QueryParam("q") q:String, @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):DataPageDTO = { with_virtual_host(id) { host => val router: LocalRouter = host val records = Future.all { @@ -325,7 +336,7 @@ case class BrokerResource() extends Reso status(value) } } - val rc:FutureResult[java.util.List[_]] = records.map(narrow(classOf[TopicStatusDTO], _, f, q, p, ps)) + val rc:FutureResult[DataPageDTO] = records.map(narrow(classOf[TopicStatusDTO], _, f, q, p, ps)) rc } } @@ -342,7 +353,7 @@ case class BrokerResource() extends Reso @GET @Path("virtual-hosts/{id}/queues") @Produces(Array("application/json")) def queues(@PathParam("id") id : String, @QueryParam("f") f:java.util.List[String], - @QueryParam("q") q:String, @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):java.util.List[_] = { + @QueryParam("q") q:String, @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):DataPageDTO = { with_virtual_host(id) { host => val router: LocalRouter = host val values: Iterable[Queue] = router.queue_domain.destination_by_id.values @@ -351,7 +362,7 @@ case class BrokerResource() extends Reso status(value, false) } - val rc:FutureResult[java.util.List[_]] = records.map(narrow(classOf[QueueStatusDTO], _, f, q, p, ps)) + val rc:FutureResult[DataPageDTO] = records.map(narrow(classOf[QueueStatusDTO], _, f, q, p, ps)) rc } } @@ -389,7 +400,7 @@ case class BrokerResource() extends Reso @GET @Path("virtual-hosts/{id}/dsubs") @Produces(Array("application/json")) def durable_subscriptions(@PathParam("id") id : String, @QueryParam("f") f:java.util.List[String], - @QueryParam("q") q:String, @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):java.util.List[_] = { + @QueryParam("q") q:String, @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):DataPageDTO = { with_virtual_host(id) { host => val router: LocalRouter = host val values: Iterable[Queue] = router.topic_domain.durable_subscriptions_by_id.values @@ -398,7 +409,7 @@ case class BrokerResource() extends Reso status(value, false) } - val rc:FutureResult[java.util.List[_]] = records.map(narrow(classOf[QueueStatusDTO], _, f, q, p, ps)) + val rc:FutureResult[DataPageDTO] = records.map(narrow(classOf[QueueStatusDTO], _, f, q, p, ps)) rc } } @@ -537,7 +548,7 @@ case class BrokerResource() extends Reso @GET @Path("connectors") @Produces(Array("application/json")) def connectors(@QueryParam("f") f:java.util.List[String], @QueryParam("q") q:String, - @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):java.util.List[_] = { + @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):DataPageDTO = { with_broker { broker => monitoring(broker) { @@ -605,7 +616,7 @@ case class BrokerResource() extends Reso @GET @Path("connections") @Produces(Array("application/json")) def connections(@QueryParam("f") f:java.util.List[String], @QueryParam("q") q:String, - @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):java.util.List[_] = { + @QueryParam("p") p:java.lang.Integer, @QueryParam("ps") ps:java.lang.Integer ):DataPageDTO = { with_broker { broker => monitoring(broker) { @@ -614,7 +625,7 @@ case class BrokerResource() extends Reso value.get_connection_status } - val rc:FutureResult[java.util.List[_]] = records.map(narrow(classOf[ConnectionStatusDTO], _, f, q, p, ps)) + val rc:FutureResult[DataPageDTO] = records.map(narrow(classOf[ConnectionStatusDTO], _, f, q, p, ps)) rc } }