001: package com.sun.portal.community.impl;
002:
003: import com.sun.portal.community.mc.CMCRolePrincipal;
004: import com.sun.portal.community.CommunityContainerName;
005: import com.sun.portal.community.CommunityId;
006: import com.sun.portal.community.TemplateTokens;
007: import java.util.HashMap;
008: import java.util.Map;
009:
010: public class TokenMapping implements TemplateTokens {
011: private CommunityId communityId;
012: private String portalId;
013: private String communityDescription;
014: private int communityDpBasePriority;
015: private String communitySearchUrl;
016: private String communityContentsSearchDb;
017: private String communityDiscussionsSearchDb;
018: private String communitySearchDbPrefix;
019:
020: public Map get() {
021: Map tokenMapping = new HashMap();
022: HashMap tokens = new HashMap();
023:
024: tokens.put(TOKEN_COMMUNITY_ID, communityId.toString());
025: tokens.put(TOKEN_COMMUNITY_NAME, communityId.getName());
026: tokens.put(TOKEN_PORTAL_ID, portalId);
027: tokens.put(TOKEN_COMMUNITY_DESCRIPTION, communityDescription);
028: tokens.put(TOKEN_COMMUNITY_CONTAINER,
029: new CommunityContainerName(communityId).toString());
030: tokens.put(TOKEN_COMMUNITY_SEARCH_URL, communitySearchUrl);
031: tokens.put(TOKEN_COMMUNITY_CONTENTS_SEARCH_DB,
032: communityContentsSearchDb);
033: tokens.put(TOKEN_COMMUNITY_DISCUSSIONS_SEARCH_DB,
034: communityDiscussionsSearchDb);
035: tokens.put(TOKEN_COMMUNITY_SEARCH_DB_PREFIX,
036: communitySearchDbPrefix);
037:
038: HashMap visitorTokens = (HashMap) tokens.clone();
039: visitorTokens.put(TOKEN_COMMUNITY_DP_PRIORITY, Integer
040: .toString(communityDpBasePriority));
041: tokenMapping.put(CMCRolePrincipal.VISITOR_ROLE.toString(),
042: visitorTokens);
043:
044: HashMap memberTokens = (HashMap) tokens.clone();
045: memberTokens.put(TOKEN_COMMUNITY_DP_PRIORITY, Integer
046: .toString(communityDpBasePriority + 5));
047: tokenMapping.put(CMCRolePrincipal.MEMBER_ROLE.toString(),
048: memberTokens);
049:
050: HashMap ownerTokens = (HashMap) tokens.clone();
051: ownerTokens.put(TOKEN_COMMUNITY_DP_PRIORITY, Integer
052: .toString(communityDpBasePriority + 10));
053: tokenMapping.put(CMCRolePrincipal.OWNER_ROLE.toString(),
054: ownerTokens);
055:
056: HashMap invitedTokens = (HashMap) tokens.clone();
057: invitedTokens.put(TOKEN_COMMUNITY_DP_PRIORITY, Integer
058: .toString(communityDpBasePriority + 15));
059: tokenMapping.put(CMCRolePrincipal.INVITED_ROLE.toString(),
060: invitedTokens);
061:
062: HashMap pendingTokens = (HashMap) tokens.clone();
063: pendingTokens.put(TOKEN_COMMUNITY_DP_PRIORITY, Integer
064: .toString(communityDpBasePriority + 20));
065: tokenMapping.put(CMCRolePrincipal.PENDING_ROLE.toString(),
066: pendingTokens);
067:
068: HashMap rejectedTokens = (HashMap) tokens.clone();
069: rejectedTokens.put(TOKEN_COMMUNITY_DP_PRIORITY, Integer
070: .toString(communityDpBasePriority + 25));
071: tokenMapping.put(CMCRolePrincipal.REJECTED_ROLE.toString(),
072: rejectedTokens);
073:
074: HashMap bannedTokens = (HashMap) tokens.clone();
075: bannedTokens.put(TOKEN_COMMUNITY_DP_PRIORITY, Integer
076: .toString(communityDpBasePriority + 30));
077: tokenMapping.put(CMCRolePrincipal.BANNED_ROLE.toString(),
078: bannedTokens);
079:
080: HashMap disabledTokens = (HashMap) tokens.clone();
081: disabledTokens.put(TOKEN_COMMUNITY_DP_PRIORITY, Integer
082: .toString(communityDpBasePriority + 35));
083: tokenMapping.put(CMCRolePrincipal.DISABLED_ROLE.toString(),
084: disabledTokens);
085:
086: HashMap deletedTokens = (HashMap) tokens.clone();
087: deletedTokens.put(TOKEN_COMMUNITY_DP_PRIORITY, Integer
088: .toString(communityDpBasePriority + 40));
089: tokenMapping.put(CMCRolePrincipal.DELETED_ROLE.toString(),
090: deletedTokens);
091:
092: return tokenMapping;
093: }
094:
095: public void setCommunityId(CommunityId communityId) {
096: this .communityId = communityId;
097: }
098:
099: public void setPortalId(String portalId) {
100: this .portalId = portalId;
101: }
102:
103: public void setCommunityDescription(String communityDescription) {
104: this .communityDescription = communityDescription;
105: }
106:
107: public void setCommunityDpBasePriority(int communityDpBasePriority) {
108: this .communityDpBasePriority = communityDpBasePriority;
109: }
110:
111: public void setCommunitySearchUrl(String communitySearchUrl) {
112: this .communitySearchUrl = communitySearchUrl;
113: }
114:
115: public void setCommunityContentsSearchDb(
116: String communityContentsSearchDb) {
117: this .communityContentsSearchDb = communityContentsSearchDb;
118: }
119:
120: public void setCommunityDiscussionsSearchDb(
121: String communityDiscussionsSearchDb) {
122: this .communityDiscussionsSearchDb = communityDiscussionsSearchDb;
123: }
124:
125: public void setCommunitySearchDbPrefix(
126: String communitySearchDbPrefix) {
127: this.communitySearchDbPrefix = communitySearchDbPrefix;
128: }
129: }
|