001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.portal.profile.impl;
018:
019: import java.util.HashMap;
020: import java.util.Iterator;
021: import java.util.Map;
022:
023: import org.apache.cocoon.portal.layout.CompositeLayout;
024: import org.apache.cocoon.portal.layout.Item;
025: import org.apache.cocoon.portal.layout.Layout;
026:
027: /**
028: * This data object holds all information about the current user:
029: * - references to the configuration
030: * - all selected coplets (coplet instance datas)
031: * - layout objects
032: *
033: * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
034: * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
035: */
036: public class UserProfile {
037:
038: protected Map copletBaseDatas;
039:
040: protected Map copletDatas;
041:
042: protected Map copletInstanceDatas;
043:
044: protected Map layouts;
045:
046: protected Layout rootLayout;
047:
048: /**
049: * @return Returns the copletBaseDatas.
050: */
051: public Map getCopletBaseDatas() {
052: return copletBaseDatas;
053: }
054:
055: /**
056: * @param copletBaseDatas The copletBaseDatas to set.
057: */
058: public void setCopletBaseDatas(Map copletBaseDatas) {
059: this .copletBaseDatas = copletBaseDatas;
060: }
061:
062: /**
063: * @return Returns the copletDatas.
064: */
065: public Map getCopletDatas() {
066: return copletDatas;
067: }
068:
069: /**
070: * @param copletDatas The copletDatas to set.
071: */
072: public void setCopletDatas(Map copletDatas) {
073: this .copletDatas = copletDatas;
074: }
075:
076: /**
077: * @return Returns the copletInstanceDatas.
078: */
079: public Map getCopletInstanceDatas() {
080: return copletInstanceDatas;
081: }
082:
083: /**
084: * @param copletInstanceDatas The copletInstanceDatas to set.
085: */
086: public void setCopletInstanceDatas(Map copletInstanceDatas) {
087: this .copletInstanceDatas = copletInstanceDatas;
088: }
089:
090: /**
091: * @return Returns the layouts.
092: */
093: public Map getLayouts() {
094: return layouts;
095: }
096:
097: /**
098: * @return Returns the rootLayout.
099: */
100: public Layout getRootLayout() {
101: return rootLayout;
102: }
103:
104: /**
105: * @param rootLayout The rootLayout to set.
106: */
107: public void setRootLayout(Layout rootLayout) {
108: this .rootLayout = rootLayout;
109: this .layouts = new HashMap();
110: this .cacheLayouts(this .layouts, rootLayout);
111: }
112:
113: protected void cacheLayouts(Map layoutMap, Layout layout) {
114: if (layout != null) {
115: if (layout.getId() != null) {
116: layoutMap.put(layout.getId(), layout);
117: }
118: if (layout instanceof CompositeLayout) {
119: final CompositeLayout cl = (CompositeLayout) layout;
120: final Iterator i = cl.getItems().iterator();
121: while (i.hasNext()) {
122: final Item current = (Item) i.next();
123: this.cacheLayouts(layoutMap, current.getLayout());
124: }
125: }
126: }
127: }
128:
129: }
|