Index: /sandbox/2.4.1-3/prototype/config/Tonic.srv
===================================================================
--- /sandbox/2.4.1-3/prototype/config/Tonic.srv	(revision 6395)
+++ /sandbox/2.4.1-3/prototype/config/Tonic.srv	(revision 6429)
@@ -27,5 +27,10 @@
 UserResource = /user/UserResource.php
 
+[/contacts]
+ContactsResource = /catalog/ContactsResource.php
+
 [/contact/:id]
 ContactResource = /catalog/ContactResource.php
 
+[/group/:id]
+GroupResource = /catalog/GroupResource.php
Index: /sandbox/2.4.1-3/prototype/config/contactGroup.ini
===================================================================
--- /sandbox/2.4.1-3/prototype/config/contactGroup.ini	(revision 6429)
+++ /sandbox/2.4.1-3/prototype/config/contactGroup.ini	(revision 6429)
@@ -0,0 +1,10 @@
+service = PostgreSQL
+PostgreSQL.concept = phpgw_cc_groups
+
+[after.find]
+findGroupConnections = modules/catalog/interceptors/DBMapping.php
+
+[PostgreSQL.mapping]
+id  = id_group
+user = owner
+name = title 
Index: /sandbox/2.4.1-3/prototype/rest/hypermedia/collection.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/hypermedia/collection.php	(revision 6351)
+++ /sandbox/2.4.1-3/prototype/rest/hypermedia/collection.php	(revision 6429)
@@ -14,8 +14,8 @@
     public $error;
     public $pagination;
-    public $queries;
+    public $queries = array();
     public $template;
     public $type;
-    public $data;
+    public $data = array();
 
     function __construct($config, $className) {
@@ -32,7 +32,7 @@
 	$this->itens[] = $item;
     }
-
-    function setData($data) {
-	$this->data = $data;
+	
+	function addData($data) {
+	$this->data[] = $data;
     }
 
@@ -57,6 +57,6 @@
     }
 
-    function setQueries($queries) {
-	$this->queries = $queries;
+    function addQueries($queries) {
+	$this->queries[] = $queries;
     }
 
Index: /sandbox/2.4.1-3/prototype/rest/catalog/ContactResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/catalog/ContactResource.php	(revision 6397)
+++ /sandbox/2.4.1-3/prototype/rest/catalog/ContactResource.php	(revision 6429)
@@ -161,5 +161,5 @@
             $d->setRequired(null);
 
-            $c->setData($d);
+            $c->addData($d);
 
             $h->setCollection($c);
Index: /sandbox/2.4.1-3/prototype/rest/catalog/ContactsResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/catalog/ContactsResource.php	(revision 6429)
+++ /sandbox/2.4.1-3/prototype/rest/catalog/ContactsResource.php	(revision 6429)
@@ -0,0 +1,185 @@
+<?php
+
+if( !defined( 'ROOTPATH' ) )
+    define( 'ROOTPATH', dirname(__FILE__).'/..' );
+
+require_once(ROOTPATH.'/rest/hypermedia/hypermedia.php');
+
+use prototype\api\Config as Config;
+
+class ContactsResource extends Resource {
+
+    /**
+     * Retorna uma lista de usuários
+     *
+     * @license    http://www.gnu.org/copyleft/gpl.html GPL
+     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+     * @sponsor    Caixa Econômica Federal
+     * @author     José Vicente Tezza Jr. 
+     * @return     Retorna uma lista de usuários do LDAP
+     * @access     public
+     * */
+    function get($request) {
+
+	$response = new Response($request);
+	$response->addHeader('Content-type', 'aplication/json');
+	$response->code = Response::OK;
+
+	$h = new Hypermedia();
+	$c = new Collection($request->resources, 'ContactsResource');
+
+	try {
+	    $this->secured();
+
+            $contacts = Controller::find( array( 'concept' => 'contact' ), false, array( 'filter' => array( '=', 'user',  Config::me("uidNumber") ) ) );
+
+	    //Se nao foi encontrado contatos na consulta
+	    if($contacts===false){
+		$error = new Error();
+		$error->setCode(Response::NOTFOUND);
+		$error->setTitle('Contacts not found');
+		$error->setDescription('Contacts not found.');
+
+		$c->setError($error);
+		$h->setCollection($c);
+
+		$response->code = Response::NOTFOUND;
+		$response->body = $h->getHypermedia($request->accept[10][0]);
+		return $response;
+	    }
+
+            foreach($contacts as $value){
+		$d = new Data();
+                $i = new Item($request->resources, 'ContactsResource', $value['id']);
+
+		$d->setName('name');
+                $d->setValue($value['name']);
+                $d->setPrompt('Nome do Contato');
+                $d->setDataType('string');
+                $d->setMaxLength('100');
+                $d->setMinLength(null);
+                $d->setRequired(true);
+
+                $i->addData($d);
+
+		$d = new Data();
+                $d->setName('email');
+                $d->setValue($value['email']);
+                $d->setPrompt('Email do Contato');
+                $d->setDataType('string');
+                $d->setMaxLength('100');
+                $d->setMinLength(null);
+                $d->setRequired(true);
+
+                $i->addData($d);
+
+		$d = new Data();
+                $d->setName('telephone');
+                $d->setValue($value['telephone']);
+                $d->setPrompt('Telefone do Contato');
+                $d->setDataType('string');
+                $d->setMaxLength('100');
+                $d->setMinLength(null);
+                $d->setRequired(true);
+
+                $i->addData($d);
+
+                $l = new Link();
+
+                $l->setHref('');
+                $l->setRel('delete');
+                $l->setAlt('Remover');
+                $l->setPrompt('Remover');
+                $l->setRender('link');
+
+                $i->addLink($l);
+
+                $l = new Link();
+                $l->setHref('');
+                $l->setRel('put');
+                $l->setAlt('Atualizar');
+                $l->setPrompt('Atualizar');
+                $l->setRender('link');
+
+                $i->addLink($l);
+
+                $l = new Link();
+                $l->setHref('/contact/'.$value['id']);
+                $l->setRel('get');
+                $l->setAlt('Buscar');
+                $l->setPrompt('Buscar');
+                $l->setRender('link');
+
+                $i->addLink($l);
+                $c->addItem($i);
+	    }
+
+            $t = new Template();
+            $d = new Data();
+
+            $d->setName('name');
+            $d->setValue(null);
+            $d->setPrompt('Nome do Contato');
+            $d->setDataType('string');
+            $d->setMaxLength(100);
+            $d->setMinLength(null);
+            $d->setRequired(true);
+
+            $t->addData($d);
+
+            $d = new Data();
+            $d->setName('email');
+            $d->setValue(null);
+            $d->setPrompt('Email do Contato');
+            $d->setDataType('string');
+            $d->setMaxLength(100);
+            $d->setMinLength(null);
+            $d->setRequired(true);
+
+            $t->addData($d);
+
+            $d = new Data();
+            $d->setName('telefone');
+            $d->setValue(null);
+            $d->setPrompt('Telefone do Contato');
+            $d->setDataType('string');
+            $d->setMaxLength(100);
+            $d->setMinLength(null);
+            $d->setRequired(true);
+
+            $t->addData($d);
+
+            $c->setTemplate($t);
+
+            $d = new Data();
+            $d->setName('Contato');
+            $d->setValue(null);
+            $d->setPrompt('Contato');
+            $d->setDataType(null);
+            $d->setMaxLength(null);
+            $d->setMinLength(null);
+            $d->setRequired(null);
+
+            $c->addData($d);
+
+            $h->setCollection($c);
+
+	}catch (Exception $ex){
+		$error = new Error();
+		$error->setCode(Response::INTERNALSERVERERROR);
+		$error->setTitle('Internal Server Error');
+		$error->setDescription($ex);
+
+		$c->setError($error);
+		$h->setCollection($c);
+
+		$response->code = Response::INTERNALSERVERERROR;
+		$response->body = $h->getHypermedia($request->accept[10][0]);
+		return $response;
+	}
+
+	$response->body = $h->getHypermedia($request->accept[10][0]);
+	return $response;
+  }
+}
+?>
Index: /sandbox/2.4.1-3/prototype/rest/user/UsersResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/user/UsersResource.php	(revision 6395)
+++ /sandbox/2.4.1-3/prototype/rest/user/UsersResource.php	(revision 6429)
@@ -43,168 +43,167 @@
 		    }
 		    else{
-			//lança warning no log do Expresso
-			trigger_error("Invalid field (".$_GET['field'].") in the query.", E_USER_WARNING);
-
-			//formata os atributos LDAP do conceito 'user'
-			$attributes = implode(', ', $map); 
-
-			//Configura o erro na hypermedia
+				//lança warning no log do Expresso
+				trigger_error("Invalid field (".$_GET['field'].") in the query.", E_USER_WARNING);
+
+				//formata os atributos LDAP do conceito 'user'
+				$attributes = implode(', ', $map); 
+
+				//Configura o erro na hypermedia
+				$error = new Error();
+				$error->setCode(Response::NOTFOUND);
+				$error->setTitle('UserLDAP not found');
+				$error->setDescription("Invalid field (".$_GET['field'].") in the query. Use of these: ".$attributes);
+
+				$c->setError($error);
+				$h->setCollection($c);
+
+				//retorna a hypermedia
+				$response->code = Response::NOTFOUND;
+				$response->body = $h->getHypermedia($request->accept[10][0]);
+				return $response;
+		    }
+	    }
+	    else{
+		    //Executa a consulta dos primeiros 20 usuarios do LDAP
+		    $users = Controller::find(array('concept' => 'user','service'=>'OpenLDAP'), false, array('filter' => array('=', 'phpgwAccountType', 'u'),'limit'=>20));
+	    }
+
+	    //Se nao foi encontrado usuarios na consulta
+	    if($users===false){
 			$error = new Error();
 			$error->setCode(Response::NOTFOUND);
 			$error->setTitle('UserLDAP not found');
-			$error->setDescription("Invalid field (".$_GET['field'].") in the query. Use of these: ".$attributes);
+			$error->setDescription('Users not found.');
 
 			$c->setError($error);
 			$h->setCollection($c);
 
-			//retorna a hypermedia
 			$response->code = Response::NOTFOUND;
 			$response->body = $h->getHypermedia($request->accept[10][0]);
 			return $response;
-		    }
-	    }
-	    else{
-		    //Executa a consulta dos primeiros 20 usuarios do LDAP
-		    $users = Controller::find(array('concept' => 'user','service'=>'OpenLDAP'), false, array('filter' => array('=', 'phpgwAccountType', 'u'),'limit'=>20));
-	    }
-
-	    //Se nao foi encontrado usuarios na consulta
-	    if($users===false){
-		$error = new Error();
-		$error->setCode(Response::NOTFOUND);
-		$error->setTitle('UserLDAP not found');
-		$error->setDescription('Users not found.');
-
-		$c->setError($error);
+	    }
+
+		foreach($users as $value){
+			$d = new Data();
+			$i = new Item($request->resources, 'UsersResource', $value['uid']);
+
+			$d->setName('name');
+			$d->setValue($value['name']);
+			$d->setPrompt('Nome do Usuario');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+
+			$i->addData($d);
+
+			$d = new Data();
+			$d->setName('email');
+			$d->setValue($value['mail']);
+			$d->setPrompt('Email do Usuario');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+
+			$i->addData($d);
+
+			$d = new Data();
+			$d->setName('telephoneNumber');
+			$d->setValue($value['telephoneNumber']);
+			$d->setPrompt('Telefone do Usuario');
+			$d->setDataType('string');
+			$d->setMaxLength('100');
+			$d->setMinLength(null);
+			$d->setRequired(true);
+
+			$i->addData($d);
+
+			$l = new Link();
+
+			$l->setHref('');
+			$l->setRel('delete');
+			$l->setAlt('Remover');
+			$l->setPrompt('Remover');
+			$l->setRender('link');
+
+			$i->addLink($l);
+
+			$l = new Link();
+			$l->setHref('');
+			$l->setRel('put');
+			$l->setAlt('Atualizar');
+			$l->setPrompt('Atualizar');
+			$l->setRender('link');
+
+			$i->addLink($l);
+
+			$l = new Link();
+			$l->setHref('/userldap/'.$value['uid']);
+			$l->setRel('get');
+			$l->setAlt('Buscar');
+			$l->setPrompt('Buscar');
+			$l->setRender('link');
+
+			$i->addLink($l);
+			$c->addItem($i);
+	    }
+
+		$t = new Template();
+		$d = new Data();
+
+		$d->setName('name');
+		$d->setValue(null);
+		$d->setPrompt('Nome do Usuario');
+		$d->setDataType('string');
+		$d->setMaxLength(100);
+		$d->setMinLength(null);
+		$d->setRequired(true);
+
+		$t->addData($d);
+
+		$d = new Data();
+		$d->setName('email');
+		$d->setValue(null);
+		$d->setPrompt('Email do Usuario');
+		$d->setDataType('string');
+		$d->setMaxLength(100);
+		$d->setMinLength(null);
+		$d->setRequired(true);
+
+		$t->addData($d);
+
+		$d = new Data();
+		$d->setName('telefone');
+		$d->setValue(null);
+		$d->setPrompt('Telefone do Usuario');
+		$d->setDataType('string');
+		$d->setMaxLength(100);
+		$d->setMinLength(null);
+		$d->setRequired(true);
+
+		$t->addData($d);
+
+		$c->setTemplate($t);
+
+		$d = new Data();
+		$d->setName('Usuario LDAP');
+		$d->setValue(null);
+		$d->setPrompt('Usuario do LDAP');
+		$d->setDataType(null);
+		$d->setMaxLength(null);
+		$d->setMinLength(null);
+		$d->setRequired(null);
+
+		$c->addData($d);
+
+	    $queries = new Querie();    
+		$queries->setHref($c->href);
+	    $queries->setData('field','',true);
+	    $queries->setData('value','',true);
+	    $c->addQueries($queries);
+
+
 		$h->setCollection($c);
-
-		$response->code = Response::NOTFOUND;
-		$response->body = $h->getHypermedia($request->accept[10][0]);
-		return $response;
-	    }
-
-            foreach($users as $value){
-		$d = new Data();
-                $i = new Item($request->resources, 'UsersResource', $value['uid']);
-
-		$d->setName('name');
-                $d->setValue($value['name']);
-                $d->setPrompt('Nome do Usuário');
-                $d->setDataType('string');
-                $d->setMaxLength('100');
-                $d->setMinLength(null);
-                $d->setRequired(true);
-
-                $i->addData($d);
-
-		$d = new Data();
-                $d->setName('email');
-                $d->setValue($value['mail']);
-                $d->setPrompt('Email do Usuário');
-                $d->setDataType('string');
-                $d->setMaxLength('100');
-                $d->setMinLength(null);
-                $d->setRequired(true);
-
-                $i->addData($d);
-
-		$d = new Data();
-                $d->setName('telephoneNumber');
-                $d->setValue($value['telephoneNumber']);
-                $d->setPrompt('Telefone do Usuário');
-                $d->setDataType('string');
-                $d->setMaxLength('100');
-                $d->setMinLength(null);
-                $d->setRequired(true);
-
-                $i->addData($d);
-
-                $l = new Link();
-
-                $l->setHref('');
-                $l->setRel('delete');
-                $l->setAlt('Remover');
-                $l->setPrompt('Remover');
-                $l->setRender('link');
-
-                $i->addLink($l);
-
-                $l = new Link();
-                $l->setHref('');
-                $l->setRel('put');
-                $l->setAlt('Atualizar');
-                $l->setPrompt('Atualizar');
-                $l->setRender('link');
-
-                $i->addLink($l);
-
-                $l = new Link();
-                $l->setHref('/userldap/'.$value['uid']);
-                $l->setRel('get');
-                $l->setAlt('Buscar');
-                $l->setPrompt('Buscar');
-                $l->setRender('link');
-
-                $i->addLink($l);
-                $c->addItem($i);
-	    }
-
-            $t = new Template();
-            $d = new Data();
-
-            $d->setName('name');
-            $d->setValue(null);
-            $d->setPrompt('Nome do Usuário');
-            $d->setDataType('string');
-            $d->setMaxLength(100);
-            $d->setMinLength(null);
-            $d->setRequired(true);
-
-            $t->addData($d);
-
-            $d = new Data();
-            $d->setName('email');
-            $d->setValue(null);
-            $d->setPrompt('Email do Usuário');
-            $d->setDataType('string');
-            $d->setMaxLength(100);
-            $d->setMinLength(null);
-            $d->setRequired(true);
-
-            $t->addData($d);
-
-            $d = new Data();
-            $d->setName('telefone');
-            $d->setValue(null);
-            $d->setPrompt('Telefone do Usuário');
-            $d->setDataType('string');
-            $d->setMaxLength(100);
-            $d->setMinLength(null);
-            $d->setRequired(true);
-
-            $t->addData($d);
-
-            $c->setTemplate($t);
-
-            $d = new Data();
-            $d->setName('Usuário LDAP');
-            $d->setValue(null);
-            $d->setPrompt('Usuário do LDAP');
-            $d->setDataType(null);
-            $d->setMaxLength(null);
-            $d->setMinLength(null);
-            $d->setRequired(null);
-
-            $c->setData($d);
-
-	    $queries = array();
-	    $queries[0] = new Querie();
-            $queries[0]->setHref($c->href);
-	    $queries[0]->setData('field','',true);
-	    $queries[0]->setData('value','',true);
-	    $c->setQueries($queries);
-
-
-            $h->setCollection($c);
 
 	}catch (Exception $ex){
Index: /sandbox/2.4.1-3/prototype/rest/user/UserResource.php
===================================================================
--- /sandbox/2.4.1-3/prototype/rest/user/UserResource.php	(revision 6360)
+++ /sandbox/2.4.1-3/prototype/rest/user/UserResource.php	(revision 6429)
@@ -160,5 +160,5 @@
             $d->setRequired(null);
 
-            $c->setData($d);
+            $c->addData($d);
 
             $h->setCollection($c);
