Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java	(revision 5555)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java	(revision 5556)
@@ -41,5 +41,5 @@
      * @throws ComponentRegistryException
      */
-    List<ComponentDescription> getComponentDescriptions() throws ComponentRegistryException, UserUnauthorizedException;
+    List<ComponentDescription> getComponentDescriptions() throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException;
 
    
@@ -52,5 +52,5 @@
      * @throws ComponentRegistryException
      */
-    List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException, UserUnauthorizedException;
+    List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException;
 
 
@@ -60,5 +60,5 @@
      * @throws ComponentRegistryException
      */
-    List<ProfileDescription> getProfileDescriptionsForMetadaEditor() throws ComponentRegistryException;
+    List<ProfileDescription> getProfileDescriptionsForMetadaEditor() throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException;
 
     /**
@@ -67,5 +67,5 @@
     * @throws ComponentRegistryException
     */
-   List<ProfileDescription> getProfileDescriptionsForMetadaEditor(Number groupId) throws ComponentRegistryException, UserUnauthorizedException;
+   List<ProfileDescription> getProfileDescriptionsForMetadaEditor(Number groupId) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException;
 
    ProfileDescription getProfileDescriptionAccessControlled(String id) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException;
Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/frontend/AdminHomePage.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/frontend/AdminHomePage.java	(revision 5555)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/frontend/AdminHomePage.java	(revision 5556)
@@ -29,4 +29,5 @@
 import clarin.cmdi.componentregistry.ComponentRegistryException;
 import clarin.cmdi.componentregistry.ComponentRegistryFactory;
+import clarin.cmdi.componentregistry.ItemNotFoundException;
 import clarin.cmdi.componentregistry.MDMarshaller;
 import clarin.cmdi.componentregistry.RegistrySpace;
@@ -53,5 +54,5 @@
     private MDMarshaller marshaller;
 
-    public AdminHomePage(final PageParameters parameters) throws ComponentRegistryException {
+    public AdminHomePage(final PageParameters parameters) throws ComponentRegistryException, ItemNotFoundException {
         super(parameters);
         adminRegistry.setComponentRegistryFactory(componentRegistryFactory);
@@ -181,5 +182,5 @@
     }
 
-    private void reloadTreeModel(CMDItemInfo info) throws UserUnauthorizedException {
+    private void reloadTreeModel(CMDItemInfo info) throws UserUnauthorizedException, ItemNotFoundException {
         try {
             tree.setModelObject(createDBTreeModel());
@@ -254,5 +255,5 @@
     }
 
-    private TreeModel createDBTreeModel() throws ComponentRegistryException, UserUnauthorizedException {
+    private TreeModel createDBTreeModel() throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
         DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(new DisplayDataNode("ComponentRegistry", false));
         DefaultMutableTreeNode publicNode = new DefaultMutableTreeNode(new DisplayDataNode("Public", false));
@@ -270,5 +271,5 @@
     }
 
-    private void add(DefaultMutableTreeNode parent, ComponentRegistry registry) throws ComponentRegistryException, UserUnauthorizedException {
+    private void add(DefaultMutableTreeNode parent, ComponentRegistry registry) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
         DefaultMutableTreeNode componentsNode = new DefaultMutableTreeNode(new DisplayDataNode("Components", false));
         parent.add(componentsNode);
Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/frontend/StatisticsPage.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/frontend/StatisticsPage.java	(revision 5555)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/frontend/StatisticsPage.java	(revision 5556)
@@ -14,4 +14,5 @@
 import clarin.cmdi.componentregistry.ComponentRegistryException;
 import clarin.cmdi.componentregistry.ComponentRegistryFactory;
+import clarin.cmdi.componentregistry.ItemNotFoundException;
 import clarin.cmdi.componentregistry.RegistrySpace;
 import clarin.cmdi.componentregistry.UserUnauthorizedException;
@@ -42,5 +43,5 @@
     }
 
-    public StatisticsPage(final PageParameters pageParameters) throws IOException, ComponentRegistryException, UserUnauthorizedException {
+    public StatisticsPage(final PageParameters pageParameters) throws IOException, ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
         super(pageParameters);
         ComponentRegistry registry = componentRegistryFactory.getComponentRegistry(RegistrySpace.PUBLISHED, null, null, null);
@@ -49,5 +50,5 @@
     }
 
-    private void displayStatistics(ComponentRegistry registry) throws ComponentRegistryException, UserUnauthorizedException {
+    private void displayStatistics(ComponentRegistry registry) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
         List<ProfileDescription> profileList = registry.getProfileDescriptions();
         RepeatingView repeating = new RepeatingView("repeating");
Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java	(revision 5555)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java	(revision 5556)
@@ -155,16 +155,16 @@
         }
     }
-    
-    @Override
-    public Number makeGroupMember(String principalName, String groupName) throws  UserUnauthorizedException, ItemNotFoundException{
+
+    @Override
+    public Number makeGroupMember(String principalName, String groupName) throws UserUnauthorizedException, ItemNotFoundException {
         RegistryUser regOwner = userDao.getPrincipalNameById(registryOwner.getId());
-        if  (groupService.isUserOwnerOfGroup(groupName, regOwner.getPrincipalName()) || 
-                configuration.isAdminUser(regOwner.getPrincipalName())) {
-        return groupService.makeMember(principalName, groupName);
+        if (groupService.isUserOwnerOfGroup(groupName, regOwner.getPrincipalName())
+                || configuration.isAdminUser(regOwner.getPrincipalName())) {
+            return groupService.makeMember(principalName, groupName);
         } else {
             throw new UserUnauthorizedException("The registry owner is not the admin or not the owner of the group and cannot add users to the group");
         }
     }
-    
+
 //    @Override
 //    public long removeGroupMember(String principalName, String groupName) throws  UserUnauthorizedException, ItemNotFoundException{
@@ -177,8 +177,6 @@
 //        }
 //    }
-    
-   
-    @Override
-    public List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException, UserUnauthorizedException {
+    @Override
+    public List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
         try {
             switch (registrySpace) {
@@ -234,5 +232,5 @@
 
     @Override
-    public List<ComponentDescription> getComponentDescriptions() throws ComponentRegistryException, UserUnauthorizedException {
+    public List<ComponentDescription> getComponentDescriptions() throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
         try {
             switch (registrySpace) {
@@ -861,9 +859,10 @@
 
     private List<ComponentDescription> getComponentDescriptionsInGroup(Number groupId)
-            throws ComponentRegistryException, UserUnauthorizedException {
+            throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
 
         String principalName = userDao.getPrincipalNameById(registryOwner.getId()).getPrincipalName();
-
-        if (!groupService.userGroupMember(principalName, groupId.toString())) {
+        String groupName = groupService.getGroupNameById(groupId.longValue());
+        if (!groupService.userGroupMember(principalName, groupId.toString())
+                && !groupService.isUserOwnerOfGroup(groupName, principalName)) {
             throw new UserUnauthorizedException("The user \'" + principalName + "\' does not have access to components of the group " + groupId);
         }
@@ -880,9 +879,10 @@
     }
 
-    private List<ProfileDescription> getProfileDescriptionsInGroup(Number groupId) throws ComponentRegistryException, UserUnauthorizedException {
+    private List<ProfileDescription> getProfileDescriptionsInGroup(Number groupId) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
 
         String principalName = userDao.getPrincipalNameById(registryOwner.getId()).getPrincipalName();
-
-        if (!groupService.userGroupMember(principalName, groupId.toString())) {
+        String groupName = groupService.getGroupNameById(groupId.longValue());
+        if (!groupService.userGroupMember(principalName, groupId.toString())
+                && !groupService.isUserOwnerOfGroup(groupName, principalName)) {
             throw new UserUnauthorizedException("The user \'" + principalName + "\' does not have access to profiles of the group " + groupId);
         }
@@ -900,6 +900,5 @@
 
     @Override
-    public List<ProfileDescription> getProfileDescriptionsForMetadaEditor(Number groupId) throws UserUnauthorizedException,
-            ComponentRegistryException {
+    public List<ProfileDescription> getProfileDescriptionsForMetadaEditor(Number groupId) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException {
         return this.getProfileDescriptionsInGroup(groupId.longValue());
     }
@@ -984,5 +983,3 @@
         }
     }
-    
-    
 }
Index: /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 5555)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java	(revision 5556)
@@ -200,4 +200,9 @@
             return new ArrayList<ComponentDescription>();
 
+        
+        
+        } catch (ItemNotFoundException e) {
+            response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString());
+            return new ArrayList<ComponentDescription>();
         }
 
@@ -235,4 +240,9 @@
         } catch (UserUnauthorizedException e) {
             response.sendError(Status.FORBIDDEN.getStatusCode(), e.toString());
+            return new ArrayList<ProfileDescription>();
+        
+        
+        } catch (ItemNotFoundException e) {
+            response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString());
             return new ArrayList<ProfileDescription>();
         }
@@ -1558,4 +1568,8 @@
             return new Rss();
         }
+        catch (ItemNotFoundException e) {
+            response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString());
+            return new Rss();
+        }
         // obsolete, add group Id
         final RssCreatorDescriptions instance = new RssCreatorDescriptions(!registrySpace.equalsIgnoreCase("published"), getApplicationBaseURI(), "components",
@@ -1596,4 +1610,8 @@
         } catch (UserUnauthorizedException e) {
             response.sendError(Status.FORBIDDEN.getStatusCode(), e.toString());
+            return new Rss();
+        
+        } catch (ItemNotFoundException e) {
+            response.sendError(Status.NOT_FOUND.getStatusCode(), e.toString());
             return new Rss();
         }
Index: /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java	(revision 5555)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java	(revision 5556)
@@ -49,5 +49,6 @@
 	return addComponent(testRegistry, id, getComponentTestContent(), isPublic);
     }
-
+    
+    
     public static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, String content, boolean isPublic) throws ParseException,
 	    JAXBException, UnsupportedEncodingException {
@@ -60,4 +61,24 @@
 	desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
         desc.setUserId(DummyPrincipal.DUMMY_PRINCIPAL.getName());
+	desc.setName(id);
+	desc.setDescription("Test Description");
+	desc.setId(ComponentDescription.COMPONENT_PREFIX + id);
+	desc.setHref("link:" + desc.getId());
+        desc.setPublic(isPublic);
+	CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
+	testRegistry.register(desc, spec);
+	return desc;
+    }
+    
+    public static ComponentDescription addComponentAnotherPrincipal(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException {
+	return addComponentAnotherPrincipal(testRegistry, id, getComponentTestContent(), isPublic);
+    }
+
+     private static ComponentDescription addComponentAnotherPrincipal(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
+	    JAXBException {
+	ComponentDescription desc = ComponentDescription.createNewDescription();
+	desc.setCreatorName("AnotherPrincipal");
+        desc.setUserId("AnotherPrincipal");
+        desc.setDbUserId(2);
 	desc.setName(id);
 	desc.setDescription("Test Description");
@@ -121,4 +142,24 @@
 	desc.setCreatorName(DummyPrincipal.DUMMY_CREDENTIALS.getDisplayName());
 	desc.setUserId(DummyPrincipal.DUMMY_CREDENTIALS.getPrincipalName());
+	desc.setName(id);
+	desc.setDescription("Test Description");
+	desc.setId(ProfileDescription.PROFILE_PREFIX + id);
+	desc.setHref("link:" + ProfileDescription.PROFILE_PREFIX + id);
+        desc.setPublic(isPublic);
+	CMDComponentSpec spec = marshaller.unmarshal(CMDComponentSpec.class, content, marshaller.getCMDComponentSchema());
+	testRegistry.register(desc, spec);
+	return desc;
+    }
+    
+    public static ProfileDescription addProfileAnotherPrincipal(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException, ItemNotFoundException {
+	return addProfileAnotherPrincipal(testRegistry, id, RegistryTestHelper.getTestProfileContent(), isPublic);
+    }
+    
+    private static ProfileDescription addProfileAnotherPrincipal(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
+	    JAXBException, ItemNotFoundException {
+	ProfileDescription desc = ProfileDescription.createNewDescription();
+	desc.setCreatorName("AnotherPrincipal");
+	desc.setUserId("AnotherPrincipal");
+        desc.setDbUserId(2);
 	desc.setName(id);
 	desc.setDescription("Test Description");
Index: /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java
===================================================================
--- /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java	(revision 5555)
+++ /ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RestGroupServiceTest.java	(revision 5556)
@@ -8,4 +8,5 @@
 import clarin.cmdi.componentregistry.ComponentRegistryFactory;
 import clarin.cmdi.componentregistry.ItemNotFoundException;
+import clarin.cmdi.componentregistry.components.CMDComponentSpec;
 import clarin.cmdi.componentregistry.impl.database.ComponentRegistryTestDatabase;
 import clarin.cmdi.componentregistry.impl.database.GroupService;
@@ -184,7 +185,7 @@
         MakeGroupC();
         
-        RegistryTestHelper.addProfile(baseRegistry, "Cprofile-1", false);
-        RegistryTestHelper.addComponent(baseRegistry, "Ccomponent-1", false);
-        RegistryTestHelper.addComponent(baseRegistry, "Ccomponent-2", false);
+        RegistryTestHelper.addProfileAnotherPrincipal(baseRegistry, "Cprofile-1", false);
+        RegistryTestHelper.addComponentAnotherPrincipal(baseRegistry, "Ccomponent-1", false);
+        RegistryTestHelper.addComponentAnotherPrincipal(baseRegistry, "Ccomponent-2", false);
         
         Ownership ownership = new Ownership();
@@ -497,4 +498,76 @@
     }
     
+    @Test
+    public void testGetGroupProfilesAndComponents() throws Exception {
+
+        System.out.println("test getGroupProfiles");
+
+        fillUpGroupA();
+        fillUpGroupB();        
+        fillUpGroupC();
+
+        
+        List<ProfileDescription> response = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles").queryParam("registrySpace", "group").queryParam("groupid", "1")).accept(MediaType.APPLICATION_XML)
+                .get(PROFILE_LIST_GENERICTYPE);
+        assertEquals(1, response.size());
+        
+        List<ComponentDescription> responseC = this.getAuthenticatedResource(getResource()
+                .path("/registry/components").queryParam("registrySpace", "group").queryParam("groupid", "1")).accept(MediaType.APPLICATION_XML)
+                .get(COMPONENT_LIST_GENERICTYPE);
+        assertEquals(2, responseC.size());
+        
+        response = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles").queryParam("registrySpace", "group").queryParam("groupid", "2")).accept(MediaType.APPLICATION_XML)
+                .get(PROFILE_LIST_GENERICTYPE);
+        assertEquals(1, response.size());
+        
+        responseC = this.getAuthenticatedResource(getResource()
+                .path("/registry/components").queryParam("registrySpace", "group").queryParam("groupid", "2")).accept(MediaType.APPLICATION_XML)
+                .get(COMPONENT_LIST_GENERICTYPE);
+        assertEquals(2, responseC.size());
+        
+        ClientResponse clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/components").queryParam("registrySpace", "group").queryParam("groupid", "3")).accept(MediaType.APPLICATION_XML)
+                .get(ClientResponse.class);
+        
+        assertEquals(403, clientResponse.getStatus());
+        
+        
+        CMDComponentSpec component = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"profile-1"))
+                .accept(MediaType.APPLICATION_JSON).get(CMDComponentSpec.class);
+        assertNotNull(component);
+        assertEquals("Actor", component.getCMDComponent().getName());
+    
+        component = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"component-1"))
+                .accept(MediaType.APPLICATION_JSON).get(CMDComponentSpec.class);
+        assertNotNull(component);
+        assertEquals("Access", component.getCMDComponent().getName());
+    
+        component = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Bprofile-1"))
+                .accept(MediaType.APPLICATION_JSON).get(CMDComponentSpec.class);
+        assertNotNull(component);
+        assertEquals("Actor", component.getCMDComponent().getName());
+    
+        component = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Bcomponent-1"))
+                .accept(MediaType.APPLICATION_JSON).get(CMDComponentSpec.class);
+        assertNotNull(component);
+        assertEquals("Access", component.getCMDComponent().getName());
+    
+        clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/profiles/" + ProfileDescription.PROFILE_PREFIX+"Cprofile-1"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.getStatus());
+        
+         clientResponse = this.getAuthenticatedResource(getResource()
+                .path("/registry/components/" + ComponentDescription.COMPONENT_PREFIX+"Ccomponent-1"))
+                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
+        assertEquals(403, clientResponse.getStatus());
+        
+    }
 
 }
