%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.userinfo.impl.AbstractUserInfoManagerImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.userinfo.impl; |
|
18 | ||
19 | import java.util.ArrayList; |
|
20 | import java.util.Collection; |
|
21 | import java.util.Iterator; |
|
22 | ||
23 | import org.apache.commons.logging.Log; |
|
24 | import org.apache.commons.logging.LogFactory; |
|
25 | import org.apache.jetspeed.om.common.UserAttribute; |
|
26 | import org.apache.jetspeed.om.common.UserAttributeRef; |
|
27 | import org.apache.jetspeed.om.impl.UserAttributeRefImpl; |
|
28 | ||
29 | /** |
|
30 | * <p> Common user info management support |
|
31 | * </p> |
|
32 | * |
|
33 | * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a> |
|
34 | * @version $Id: AbstractUserInfoManagerImpl.java 516448 2007-03-09 16:25:47Z ate $ |
|
35 | */ |
|
36 | 0 | public abstract class AbstractUserInfoManagerImpl |
37 | { |
|
38 | /** Logger */ |
|
39 | 0 | private static final Log log = LogFactory.getLog(UserInfoManagerImpl.class); |
40 | ||
41 | /** |
|
42 | * <p> |
|
43 | * Return the linked attributes mapping portlet user attributes to portal |
|
44 | * user attributes. |
|
45 | * </p> |
|
46 | * |
|
47 | * @param userAttributes |
|
48 | * The declarative portlet user attributes. |
|
49 | * @param userAttributeRefs |
|
50 | * The declarative jetspeed portlet extension user attributes |
|
51 | * reference. |
|
52 | * @return The collection of linked attributes. |
|
53 | */ |
|
54 | protected Collection mapLinkedUserAttributes(Collection userAttributes, Collection userAttributeRefs) |
|
55 | { |
|
56 | 0 | Collection linkedUserAttributes = new ArrayList(); |
57 | 0 | if ((null != userAttributeRefs) && (userAttributeRefs.size() > 0)) |
58 | { |
|
59 | 0 | Iterator attrIter = userAttributes.iterator(); |
60 | 0 | while (attrIter.hasNext()) |
61 | { |
|
62 | 0 | UserAttribute currentAttribute = (UserAttribute) attrIter.next(); |
63 | 0 | boolean linkedAttribute = false; |
64 | 0 | if (null != currentAttribute) |
65 | { |
|
66 | 0 | Iterator attrRefsIter = userAttributeRefs.iterator(); |
67 | 0 | while (attrRefsIter.hasNext()) |
68 | { |
|
69 | 0 | UserAttributeRef currentAttributeRef = (UserAttributeRef) attrRefsIter.next(); |
70 | 0 | if (null != currentAttributeRef) |
71 | { |
|
72 | 0 | if ((currentAttribute.getName()).equals(currentAttributeRef.getNameLink())) |
73 | { |
|
74 | 0 | if (log.isDebugEnabled()) |
75 | 0 | log.debug("Linking user attribute ref: [[name, " + currentAttribute.getName() |
76 | + "], [linked name, " + currentAttributeRef.getName() + "]]"); |
|
77 | 0 | linkedUserAttributes.add(currentAttributeRef); |
78 | 0 | linkedAttribute = true; |
79 | } |
|
80 | } |
|
81 | 0 | } |
82 | } |
|
83 | 0 | if (!linkedAttribute) |
84 | { |
|
85 | 0 | linkedUserAttributes.add(new UserAttributeRefImpl(currentAttribute)); |
86 | } |
|
87 | 0 | } |
88 | 0 | } |
89 | else |
|
90 | { |
|
91 | 0 | Iterator attrIter = userAttributes.iterator(); |
92 | 0 | while (attrIter.hasNext()) |
93 | { |
|
94 | 0 | UserAttribute currentAttribute = (UserAttribute) attrIter.next(); |
95 | 0 | linkedUserAttributes.add(new UserAttributeRefImpl(currentAttribute)); |
96 | 0 | } |
97 | } |
|
98 | 0 | return linkedUserAttributes; |
99 | } |
|
100 | ||
101 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |