001: /**
002: * $Id: ProducerEntityImpl.java,v 1.7 2005/08/05 06:27:03 rt130506 Exp $
003: * Copyright 2003 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.wsrp.consumer.producermanager.impl;
014:
015: import java.util.Map;
016: import java.util.Date;
017:
018: import java.io.Serializable;
019:
020: import java.net.URL;
021:
022: import com.sun.portal.wsrp.common.stubs.RegistrationData;
023: import com.sun.portal.wsrp.common.stubs.RegistrationContext;
024: import com.sun.portal.wsrp.common.stubs.ServiceDescription;
025: import com.sun.portal.wsrp.common.stubs.PortletDescription;
026:
027: import com.sun.portal.wsrp.WSRPException;
028: import com.sun.portal.wsrp.common.IdentityPropagationConstants;
029: import com.sun.portal.wsrp.common.WSRPFactory;
030:
031: import com.sun.portal.wsrp.consumer.common.WSRPConsumerException;
032:
033: import com.sun.portal.wsrp.consumer.producermanager.ConsumerObjectFactory;
034: import com.sun.portal.wsrp.consumer.producermanager.ProducerEntity;
035: import com.sun.portal.wsrp.consumer.producermanager.ProducerEntityStatus;
036:
037: public class ProducerEntityImpl implements ProducerEntity, Serializable {
038:
039: private String id = null;
040: private String name = null;
041: private URL url = null;
042: private String markupEndpoint = null;
043: private ProducerEntityStatus status = null;
044: private RegistrationData regData = null;
045: private RegistrationContext regContext = null;
046: private ServiceDescription serviceDescription = null;
047: private Map userCategoryMapping = null;
048: private Map allowedUserProfileMapping = null;
049: private Map customUserProfileMapping = null;
050: private long serviceDescriptionLastModified = -1;
051: private String lastModified = null;
052: private String identityPropagationType = IdentityPropagationConstants.NO_IDENTITY_PROPAGATION;
053:
054: public ProducerEntityImpl(String id, String name, URL url,
055: String markupEndpoint, ProducerEntityStatus status,
056: RegistrationData regData, RegistrationContext regContext,
057: ServiceDescription serviceDescription,
058: Map userCategoryMapping, Map allowedUserProfileMapping,
059: Map customUserProfileMapping,
060: long serviceDescriptionLastModified, String lastModified,
061: String identityPropagationType) {
062: this .id = id;
063: this .name = name;
064: this .url = url;
065: this .markupEndpoint = markupEndpoint;
066: this .status = status;
067: this .regData = regData;
068: this .regContext = regContext;
069: this .serviceDescription = serviceDescription;
070: this .userCategoryMapping = userCategoryMapping;
071: this .allowedUserProfileMapping = allowedUserProfileMapping;
072: this .customUserProfileMapping = customUserProfileMapping;
073: this .serviceDescriptionLastModified = serviceDescriptionLastModified;
074: this .lastModified = lastModified;
075: if (identityPropagationType != null
076: && identityPropagationType.trim().length() != 0) {
077: this .identityPropagationType = identityPropagationType;
078: }
079: }
080:
081: public String getId() {
082: return id;
083: }
084:
085: public String getName() {
086: return name;
087: }
088:
089: public URL getURL() {
090: return url;
091: }
092:
093: public String getMarkupEndpoint() {
094: return markupEndpoint;
095: }
096:
097: public RegistrationData getRegistrationData() {
098: return regData;
099: }
100:
101: public RegistrationContext getRegistrationContext() {
102: return regContext;
103: }
104:
105: public Map getUserCategoryMapping() {
106: return userCategoryMapping;
107: }
108:
109: public Map getAllowedUserProfileMapping() {
110: return allowedUserProfileMapping;
111: }
112:
113: public Map getCustomUserProfileMapping() {
114: return customUserProfileMapping;
115: }
116:
117: public ProducerEntityStatus getStatus() {
118: return status;
119: }
120:
121: public ServiceDescription getServiceDescription() {
122: return serviceDescription;
123: }
124:
125: public PortletDescription getPortletDescription(String portletHandle) {
126: //
127: // TBD: room for perf. improvement
128: //
129: PortletDescription pd = null;
130: PortletDescription[] pds = serviceDescription
131: .getOfferedPortlets();
132: for (int i = 0; i < pds.length; i++) {
133: if (pds[i].getPortletHandle().equals(portletHandle)) {
134: pd = pds[i];
135: break;
136: }
137: }
138: return pd;
139: }
140:
141: public long getServiceDescriptionLastModified() {
142: return serviceDescriptionLastModified;
143: }
144:
145: public String getLastModified() {
146: return lastModified;
147: }
148:
149: public String getIdentityPropagationType() {
150: return identityPropagationType;
151: }
152:
153: public String toString() {
154: StringBuffer buf = new StringBuffer();
155: buf.append("ID: ").append(id).append("\nName: ").append(name)
156: .append("\nWSDL URL: ").append(url).append(
157: "\nMarkup Endpoint: ").append(markupEndpoint)
158: .append("\nStatus: ").append(status).append(
159: "\nIdentityPropagationType: ").append(
160: identityPropagationType);
161:
162: WSRPFactory factory = null;
163: ConsumerObjectFactory cofactory = null;
164:
165: try {
166: factory = WSRPFactory.getInstance();
167: buf.append("\nRegistration Data: ").append(
168: factory.getRegistrationDataXML(regData, true))
169: .append("\nRegistration Context: ").append(
170: factory.getRegistrationContextXML(
171: regContext, true)).append(
172: "\nService Description: ").append(
173: factory.getServiceDescriptionXML(
174: serviceDescription, true));
175:
176: } catch (WSRPException we) {
177: buf.append("[ERROR]");
178: }
179:
180: try {
181: cofactory = ConsumerObjectFactory.getInstance();
182: buf.append("\nUser Category Mapping: ").append(
183: cofactory.getMultiValueMapXML(userCategoryMapping,
184: true));
185: } catch (WSRPConsumerException wce) {
186: buf.append("[ERROR]");
187: }
188:
189: buf
190: .append("\nAllowed User Profile Mapping: ")
191: .append(
192: allowedUserProfileMapping != null ? allowedUserProfileMapping
193: .toString()
194: : "null")
195: .append("\nCustom User Profile Mapping: ")
196: .append(
197: customUserProfileMapping != null ? customUserProfileMapping
198: .toString()
199: : "null").append(
200: "\nService Description Last Modified on: ")
201: .append(new Date(serviceDescriptionLastModified))
202: .append("\nLast Modified on: ").append(lastModified);
203:
204: return buf.toString();
205: }
206: }
|