String role,
String id,
boolean adminProfile)
throws ProcessingException, SAXException, javax.xml.transform.TransformerException {
// calling method is synced
Resource res = (Resource)config.get(Constants.CONF_STATUS_SAVERESOURCE);
Element statusProfile = (Element)XMLUtil.getFirstNodeFromPath((DocumentFragment)profile.get(Constants.PROFILE_PROFILE),
new String[] {"profile","status-profile"}, false);
if (res != null && statusProfile != null) {
DocumentFragment userFragment = statusProfile.getOwnerDocument().createDocumentFragment();
Element oldParent = (Element)statusProfile.getParentNode();
Element saveStatus = (Element)statusProfile.cloneNode(true);
userFragment.appendChild(saveStatus);
// now filter all not persistent sunlets!
NodeList list = XMLUtil.getNodeListFromPath(saveStatus, new String[] {"customization","sunlet"});
String sunletID;
String sunletNumber;
Element sunlet;
Element sunletConfig;
Map sunletConfigs = (Map)profile.get(Constants.PROFILE_DEFAULT_SUNLETS);
Map mediaSunletConfigs = (Map)profile.get(Constants.PROFILE_MEDIA_SUNLETS);
boolean isPersistent;
for(int i = 0; i < list.getLength(); i++) {
sunlet = (Element)list.item(i);
sunletID = sunlet.getAttributeNS(null, "id");
sunletNumber = sunlet.getAttributeNS(null, "number");
sunletConfig = this.getSunletConfiguration(sunletID, sunletConfigs, mediaSunletConfigs);
isPersistent = XMLUtil.getValueAsBooleanOf(sunletConfig, "configuration/persistent", false);
if (isPersistent == false) {
sunlet.getParentNode().removeChild(sunlet);
}
}
try {
SourceParameters pars;
pars = new SourceParameters();
pars.setSingleParameterValue("ID", id);
pars.setSingleParameterValue("role", role);
pars.setSingleParameterValue("application", (String)this.request.getAttribute(org.apache.cocoon.sunshine.sunrise.Constants.REQUEST_ATTRIBUTE_APPLICATION_NAME));
pars.setSingleParameterValue("handler", (String)this.request.getAttribute(org.apache.cocoon.sunshine.sunrise.Constants.REQUEST_ATTRIBUTE_HANDLER_NAME));
pars.setSingleParameterValue("profile", "user-status");
this.getResourceConnector().saveXML(res.getResourceType(), null,
res.getResourceIdentifier(), pars,
userFragment);
} finally {
userFragment.removeChild(saveStatus);
}
}