/*
 * Copyright 2001-2012 Remi Vankeisbelck
 *
 * Licensed 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 woko.facets;

import net.sourceforge.jfacets.IProfile;
import net.sourceforge.jfacets.IProfileRepository;
import woko.users.UserManager;

import java.util.ArrayList;
import java.util.List;

public class WokoProfileRepository implements IProfileRepository {

  private final UserManager userManager;

  public WokoProfileRepository(UserManager userManager) {
    this.userManager = userManager;
  }

  public IProfile getProfileById(String profileId) {
    return new WokoProfile(profileId);
  }

  public IProfile[] getSuperProfiles(IProfile profile) {
    List<String> roles = userManager.getRoles(profile.getId());
    List<IProfile> profiles = new ArrayList<IProfile>();
    for (String role : roles) {
      profiles.add(new WokoProfile(role));
    }
    IProfile[] result = new IProfile[profiles.size()];
    return profiles.toArray(result);
  }

}

@@ -868,16 +868,18 @@
 tory %7B%0A%0A
+  
   privat
@@ -912,16 +912,18 @@
 nager;%0A%0A
+  
   public
@@ -976,16 +976,20 @@
 ) %7B%0A    
+   
+ 
 this.use
@@ -1012,21 +1012,25 @@
 anager;%0A
+  
   %7D%0A%0A
+  
   public
@@ -1074,24 +1074,28 @@
 leId) %7B%0A    
+ 
+   
 return new W
@@ -1117,21 +1117,25 @@
 ileId);%0A
+  
   %7D%0A%0A
+  
   public
@@ -1179,24 +1179,28 @@
  profile) %7B%0A
+    
     List%3CStr
@@ -1251,24 +1251,28 @@
 tId());%0A    
+  
+  
 List%3CIProfil
@@ -1312,16 +1312,20 @@
 ile%3E();%0A
+    
     for 
@@ -1354,16 +1354,22 @@
 %7B%0A      
+ 
+     
 profiles
@@ -1401,18 +1401,26 @@
 ));%0A    
+ 
-%7D%0A
+   %7D%0A    
     IPro
@@ -1466,16 +1466,20 @@
 ize()%5D;%0A
+    
     retu
@@ -1507,15 +1507,17 @@
 esult);%0A
+  
   %7D%0A%0A%7D%0A

reformat code