private static final String sslLocation = "CPersonAttributes/CPersonAttributes.ssl";
public void renderXML (ContentHandler out, String uid) throws PortalException {
ChannelState channelState = (ChannelState)channelStateMap.get(uid);
ChannelStaticData staticData = channelState.getStaticData();
ChannelRuntimeData runtimeData = channelState.getRuntimeData();
IPerson person = staticData.getPerson();
Document doc = DocumentFactory.getNewDocument();
Element attributesE = doc.createElement("attributes");
IPersonAttributeDao pa = PersonDirectory.getPersonAttributeDao();
Set possibleAttrs = pa.getPossibleUserAttributeNames();
if (possibleAttrs != null)
possibleAttrs = new HashSet(possibleAttrs);
else
possibleAttrs = new HashSet();
for (Enumeration attribs = person.getAttributeNames(); attribs.hasMoreElements(); ) {
// Get the attribute name
String attName = (String) attribs.nextElement();
// Remove this attr from the list of possible attrs
possibleAttrs.remove(attName);
// Set the attribute
Element attributeE = doc.createElement("attribute");
Element nameE = doc.createElement("name");
nameE.appendChild(doc.createTextNode(attName));
attributeE.appendChild(nameE);
// Get the IPerson attribute value for this eduPerson attribute name
if (person.getAttributeValues(attName) != null) {
Object[] values = person.getAttributeValues(attName);
for (int i = 0; i < values.length; i++) {
if (log.isTraceEnabled())
log.trace("type of value["+i+"] is " + values[i].getClass().getName());
String value = values[i].toString();
Element valueE = doc.createElement("value");
valueE.appendChild(doc.createTextNode(value));
attributeE.appendChild(valueE);
}
}
attributesE.appendChild(attributeE);
}
//Sort the set of possible attributes
possibleAttrs = new TreeSet(possibleAttrs);
//Add the unknown attributes to the element list.
for (Iterator attribs = possibleAttrs.iterator(); attribs.hasNext(); ) {
// Get the attribute name
String attName = (String) attribs.next();
// Set the attribute
Element attributeE = doc.createElement("attribute");
Element nameE = doc.createElement("name");
nameE.appendChild(doc.createTextNode(attName));
attributeE.appendChild(nameE);
attributesE.appendChild(attributeE);
}
doc.appendChild(attributesE);
XSLT xslt = XSLT.getTransformer(this, runtimeData.getLocales());
xslt.setXML(doc);
xslt.setStylesheetParameter("baseActionURL",runtimeData.getBaseActionURL());
xslt.setStylesheetParameter("downloadWorkerURL",
runtimeData.getBaseWorkerURL(UPFileSpec.FILE_DOWNLOAD_WORKER,true));
xslt.setXSL(sslLocation, runtimeData.getBrowserInfo());
xslt.setTarget(out);
xslt.transform();
}